Re: [U-Boot] [PATCH 1/2] rpi: Fix fdt_high & initrd_high for 64-bit builds

2018-05-24 Thread Alexander Graf


On 20.04.18 12:03, Tuomas Tynkkynen wrote:
> The magic value that disables relocation is dependent on the CPU word
> size, so the current '' is doing the wrong thing on aarch64.
> 
> Signed-off-by: Tuomas Tynkkynen 

The BCM283x series of SOCs is limited to 32bit address space, so I don't
quite see why the current (int)-1 is wrong?


Alex

> ---
>  include/configs/rpi.h | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
> index 325e52a019..f1189a27f3 100644
> --- a/include/configs/rpi.h
> +++ b/include/configs/rpi.h
> @@ -91,6 +91,14 @@
>   "stdout=serial,vidconsole\0" \
>   "stderr=serial,vidconsole\0"
>  
> +#ifdef CONFIG_ARM64
> +#define FDT_HIGH ""
> +#define INITRD_HIGH ""
> +#else
> +#define FDT_HIGH ""
> +#define INITRD_HIGH ""
> +#endif
> +
>  /*
>   * Memory layout for where various images get loaded by boot scripts:
>   *
> @@ -122,8 +130,8 @@
>   *   for any boot script to be up to 1M, which is hopefully plenty.
>   */
>  #define ENV_MEM_LAYOUT_SETTINGS \
> - "fdt_high=\0" \
> - "initrd_high=\0" \
> + "fdt_high=" FDT_HIGH "\0" \
> + "initrd_high=" INITRD_HIGH "\0" \
>   "fdt_addr_r=0x0100\0" \
>   "pxefile_addr_r=0x0010\0" \
>   "kernel_addr_r=0x0100\0" \
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] sunxi: add support for Banana Pi M2 Zero board

2018-05-24 Thread Maxime Ripard
Hi,

On Thu, May 24, 2018 at 12:38:19PM +0800, Jun Nie wrote:
> Banana Pi M2 Zero is a board by Sinovoip with Allwinner H2+ SoC, 16-bit
> 512MiB DDR3 memory, a MicroSD slot, two MicroUSB ports (one OTG and one
> powering-only) and a miniHDMI port.
> 
> DTS file is from Linux kernel with removing some nodes that are not needed
> in u-boot or not merged into u-boot yet.
> 
> Signed-off-by: Icenowy Zheng 
> Signed-off-by: Jun Nie 


Don't forget to CC me on the sunxi-related patches.

> ---
>  arch/arm/dts/Makefile   |  1 +
>  arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 68 
> +
>  board/sunxi/MAINTAINERS |  5 ++
>  configs/bananapi_m2_zero_defconfig  | 15 ++
>  4 files changed, 89 insertions(+)
>  create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>  create mode 100644 configs/bananapi_m2_zero_defconfig
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 20a4c37..8d6fab2 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -338,6 +338,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \
>   sun8i-a83t-cubietruck-plus.dtb \
>   sun8i-a83t-tbs-a711.dts
>  dtb-$(CONFIG_MACH_SUN8I_H3) += \
> + sun8i-h2-plus-bananapi-m2-zero.dtb \
>   sun8i-h2-plus-orangepi-zero.dtb \
>   sun8i-h3-bananapi-m2-plus.dtb \
>   sun8i-h3-libretech-all-h3-cc.dtb \
> diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts 
> b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> new file mode 100644
> index 000..92e8cf4
> --- /dev/null
> +++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
> @@ -0,0 +1,68 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (C) 2017 Icenowy Zheng 
> + *
> + * Based on sun8i-h3-bananapi-m2-plus.dts, which is:
> + *   Copyright (C) 2016 Chen-Yu Tsai 
> + */
> +
> +/dts-v1/;
> +#include "sun8i-h3.dtsi"
> +#include "sunxi-common-regulators.dtsi"
> +
> +#include 
> +#include 
> +
> +/ {
> + model = "Banana Pi BPI-M2-Zero";
> + compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
> +
> + aliases {
> + serial0 = &uart0;
> + serial1 = &uart1;
> + };
> +
> + chosen {
> + stdout-path = "serial0:115200n8";
> + };
> +
> + leds {
> + compatible = "gpio-leds";
> +
> + pwr_led {
> + label = "bananapi-m2-zero:red:pwr";
> + gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
> + default-state = "on";
> + };
> + };
> +
> + gpio_keys {
> + compatible = "gpio-keys";
> +
> + sw4 {
> + label = "power";
> + linux,code = ;
> + gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
> + };
> + };
> +};
> +
> +&mmc0 {
> + vmmc-supply = <®_vcc3v3>;
> + bus-width = <4>;
> + /*
> +  * On the production batch of this board the card detect GPIO is
> +  * high active (card inserted), although on the early samples it's
> +  * low active.
> +  */
> + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
> + status = "okay";
> +};
> +
> +&uart0 {
> + status = "okay";
> +};
> +
> +&uart1 {
> + status = "okay";
> +};

Why not using straight the DT from linux here? There's a couple of
things missing from this one (the pinctrl nodes, for example).

> diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
> index 5eb8bbe..0d904d9 100644
> --- a/board/sunxi/MAINTAINERS
> +++ b/board/sunxi/MAINTAINERS
> @@ -363,6 +363,11 @@ M:   Icenowy Zheng 
>  S:   Maintained
>  F:   configs/Sinovoip_BPI_M2_Plus_defconfig
>  
> +SINOVOIP BPI M2 ZERO BOARD
> +M:   Icenowy Zheng 
> +S:   Maintained
> +F:   configs/Sinovoip_BPI_M2_Zero_defconfig
> +
>  SINOVOIP BPI M3 A83T BOARD
>  M:   VishnuPatekar 
>  S:   Maintained
> diff --git a/configs/bananapi_m2_zero_defconfig 
> b/configs/bananapi_m2_zero_defconfig
> new file mode 100644
> index 000..b919d8b
> --- /dev/null
> +++ b/configs/bananapi_m2_zero_defconfig
> @@ -0,0 +1,15 @@
> +CONFIG_ARM=y
> +CONFIG_ARCH_SUNXI=y
> +CONFIG_SYS_TEXT_BASE=0x4a00

Did you run savedefconfig recently? That should be the default nowadays.

> +CONFIG_MACH_SUN8I_H3=y
> +CONFIG_DRAM_CLK=408
> +CONFIG_DRAM_ZQ=3881979
> +CONFIG_DRAM_ODT_EN=y
> +CONFIG_MMC0_CD_PIN=""

That doesn't match the DT.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] menu: fix timeout duration

2018-05-24 Thread Masahiro Yamada
For distro-boot, the TIMEOUT directive in the boot script specifies
how long to pause in units of 1/10 sec. [1]

Commit 8594753ba0a7 ("menu: only timeout when menu is displayed")
corrected this by simply dividing the timeout value by 10 in
menu_interactive_choice().

I see two problems:

 - For example, "TIMEOUT 5" should wait for 0.5 sec, but the current
   implementation cannot handle the granularity of 1/10 sec.
   In fact, it never breaks because "m->timeout / 10" is zero,
   which means no timeout.

 - The menu API is used not only by cmd/pxe.c but also by
   common/autoboot.c .  For the latter case, the unit of the
   timeout value is _second_ because its default is associated
   with CONFIG_BOOTDELAY.

To fix the first issue, use DIV_ROUND_UP() so that the timeout value
is rounded up to the closest integer.

For the second issue, move the division to the boundary between
cmd/pxe.c and common/menu.c .  This is a more desirable place because
the comment of struct pxe_menu says:

 * timeout - time in tenths of a second to wait for a user key-press before
 *   booting the default label.

Then, the comment of menu_create() says:

 * timeout - A delay in seconds to wait for user input. If 0, timeout is
 * disabled, and the default choice will be returned unless prompt is 1.

[1] https://www.syslinux.org/wiki/index.php?title=SYSLINUX#TIMEOUT_timeout

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
  - In v1, I was misunderstanding.  I thought the unit of TIMEOUT was
second, but it is actually 1/10 second.  Use round up to fix the
"never timeout" problem.
Also, move the division to the correct place to fix CONFIG_MENU_SHOW.

 cmd/pxe.c | 4 ++--
 common/menu.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/cmd/pxe.c b/cmd/pxe.c
index 7649d92..5609545 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -1453,8 +1453,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
/*
 * Create a menu and add items for all the labels.
 */
-   m = menu_create(cfg->title, cfg->timeout, cfg->prompt, label_print,
-   NULL, NULL);
+   m = menu_create(cfg->title, DIV_ROUND_UP(cfg->timeout, 10),
+   cfg->prompt, label_print, NULL, NULL);
 
if (!m)
return NULL;
diff --git a/common/menu.c b/common/menu.c
index bf2b471..0f0a29a 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -194,8 +194,7 @@ static inline int menu_interactive_choice(struct menu *m, 
void **choice)
 
if (!m->item_choice) {
readret = cli_readline_into_buffer("Enter choice: ",
-  cbuf,
-  m->timeout / 10);
+  cbuf, m->timeout);
 
if (readret >= 0) {
choice_item = menu_item_by_key(m, cbuf);
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] rpi: Adjust fdt_addr_r to a sane address

2018-05-24 Thread Alexander Graf


On 14.04.18 20:04, Tuomas Tynkkynen wrote:
> Hi Alexander,
> 
> On Fri, 13 Apr 2018 17:49:00 +0200
> Alexander Graf  wrote:
> 
> [...]
>>
>> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
>> index 325e52a019..fcf7e0976b 100644
>> --- a/include/configs/rpi.h
>> +++ b/include/configs/rpi.h
>> @@ -124,7 +124,7 @@
>>  #define ENV_MEM_LAYOUT_SETTINGS \
>>  "fdt_high=\0" \
>>  "initrd_high=\0" \
>> -"fdt_addr_r=0x0100\0" \
>> +"fdt_addr_r=0x01f0\0" \
>>  "pxefile_addr_r=0x0010\0" \
>>  "kernel_addr_r=0x0100\0" \
>>  "scriptaddr=0x0200\0" \
> 
> Note that above the #define is a larger comment block that needs to be
> updated as well. Also the other addresses also need updatingfor bigger
> kernels on AArch64: https://patchwork.ozlabs.org/patch/25/
> 
> Though now I double-checked that the smallest possible GPU-CPU memory
> split is actually 64MB for the CPU, not 128M. So maybe something like:
> 
>  "kernel_addr_r=0x0008\0" \
>  "fdt_addr_r=0x0240\0" \
>  "scriptaddr=0x0250\0" \
>  "pxefile_addr_r=0x0260\0" \
>  "ramdisk_addr_r=0x0270\0"
> 
> which would allow a kernel up to 36M, 1M for dtb, script and pxe files
> each, and at least 25M for the initrd. Also I think giving up with the
> constraint of locating the zImage high enough so that the kernel
> decompressor doesn't need to relocate itself can be dropped. If the
> boot speed of their Raspi matters that much, probably they wouldn't use
> U-Boot in the first place.
> 
> What is the address that the RPi firmware loads its device tree to? I
> hope that we don't have to worry about the positioning of that too...

U-Boot> bdinfo
arch_number = 0x
boot_params = 0x0100
DRAM bank   = 0x
-> start= 0x
-> size = 0x3B40
baudrate= 115200 bps
TLB addr= 0x3B3F
relocaddr   = 0x3B348000
reloc off   = 0x3B2C8000
irq_sp  = 0x3AF3E120
sp start= 0x3AF3E120
Early malloc usage: 138 / 2000
fdt_blob = 3af3e130
U-Boot> print fdt_addr
fdt_addr=2effb300

So on boot the DT passed into U-Boot is either at ~750MB or close to the
top. I can't quite find any code that explains the difference in the two
variables. Either way, I guess firmware tries to put it reasonably high?

So as long as we keep the load addresses low enough, we should be safe.

Also fyi, I would like to switch to CONFIG_OF_BOARD by default, once I
added code that marks u-boot.bin as an "upstream kernel" for the RPi
firmware, because then newer RPi firmwares will pass us a fully upstream
compatible device tree [1] which we can then pass on to Linux as default.


Alex

[1] https://github.com/raspberrypi/firmware/issues/943
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] sunxi: add support for Banana Pi M2 Zero board

2018-05-24 Thread Jun Nie
2018-05-24 15:54 GMT+08:00 Maxime Ripard :
> Hi,
>
> On Thu, May 24, 2018 at 12:38:19PM +0800, Jun Nie wrote:
>> Banana Pi M2 Zero is a board by Sinovoip with Allwinner H2+ SoC, 16-bit
>> 512MiB DDR3 memory, a MicroSD slot, two MicroUSB ports (one OTG and one
>> powering-only) and a miniHDMI port.
>>
>> DTS file is from Linux kernel with removing some nodes that are not needed
>> in u-boot or not merged into u-boot yet.
>>
>> Signed-off-by: Icenowy Zheng 
>> Signed-off-by: Jun Nie 
>
>
> Don't forget to CC me on the sunxi-related patches.

Sure, will add your email in the script.
>
>> ---
>>  arch/arm/dts/Makefile   |  1 +
>>  arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 68 
>> +
>>  board/sunxi/MAINTAINERS |  5 ++
>>  configs/bananapi_m2_zero_defconfig  | 15 ++
>>  4 files changed, 89 insertions(+)
>>  create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>>  create mode 100644 configs/bananapi_m2_zero_defconfig
>>
>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>> index 20a4c37..8d6fab2 100644
>> --- a/arch/arm/dts/Makefile
>> +++ b/arch/arm/dts/Makefile
>> @@ -338,6 +338,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \
>>   sun8i-a83t-cubietruck-plus.dtb \
>>   sun8i-a83t-tbs-a711.dts
>>  dtb-$(CONFIG_MACH_SUN8I_H3) += \
>> + sun8i-h2-plus-bananapi-m2-zero.dtb \
>>   sun8i-h2-plus-orangepi-zero.dtb \
>>   sun8i-h3-bananapi-m2-plus.dtb \
>>   sun8i-h3-libretech-all-h3-cc.dtb \
>> diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts 
>> b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>> new file mode 100644
>> index 000..92e8cf4
>> --- /dev/null
>> +++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>> @@ -0,0 +1,68 @@
>> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>> +/*
>> + * Copyright (C) 2017 Icenowy Zheng 
>> + *
>> + * Based on sun8i-h3-bananapi-m2-plus.dts, which is:
>> + *   Copyright (C) 2016 Chen-Yu Tsai 
>> + */
>> +
>> +/dts-v1/;
>> +#include "sun8i-h3.dtsi"
>> +#include "sunxi-common-regulators.dtsi"
>> +
>> +#include 
>> +#include 
>> +
>> +/ {
>> + model = "Banana Pi BPI-M2-Zero";
>> + compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
>> +
>> + aliases {
>> + serial0 = &uart0;
>> + serial1 = &uart1;
>> + };
>> +
>> + chosen {
>> + stdout-path = "serial0:115200n8";
>> + };
>> +
>> + leds {
>> + compatible = "gpio-leds";
>> +
>> + pwr_led {
>> + label = "bananapi-m2-zero:red:pwr";
>> + gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
>> + default-state = "on";
>> + };
>> + };
>> +
>> + gpio_keys {
>> + compatible = "gpio-keys";
>> +
>> + sw4 {
>> + label = "power";
>> + linux,code = ;
>> + gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
>> + };
>> + };
>> +};
>> +
>> +&mmc0 {
>> + vmmc-supply = <®_vcc3v3>;
>> + bus-width = <4>;
>> + /*
>> +  * On the production batch of this board the card detect GPIO is
>> +  * high active (card inserted), although on the early samples it's
>> +  * low active.
>> +  */
>> + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
>> + status = "okay";
>> +};
>> +
>> +&uart0 {
>> + status = "okay";
>> +};
>> +
>> +&uart1 {
>> + status = "okay";
>> +};
>
> Why not using straight the DT from linux here? There's a couple of
> things missing from this one (the pinctrl nodes, for example).

I had thought that pinctrl is not merged yet in u-boot per the
comments for patch V1. Will
keep it in next version.

WIFI is removed because it shall not work in u-boot.

ehci0/ohci0 are removed because they are still missing in h3.dtsi.

>
>> diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
>> index 5eb8bbe..0d904d9 100644
>> --- a/board/sunxi/MAINTAINERS
>> +++ b/board/sunxi/MAINTAINERS
>> @@ -363,6 +363,11 @@ M:   Icenowy Zheng 
>>  S:   Maintained
>>  F:   configs/Sinovoip_BPI_M2_Plus_defconfig
>>
>> +SINOVOIP BPI M2 ZERO BOARD
>> +M:   Icenowy Zheng 
>> +S:   Maintained
>> +F:   configs/Sinovoip_BPI_M2_Zero_defconfig
>> +
>>  SINOVOIP BPI M3 A83T BOARD
>>  M:   VishnuPatekar 
>>  S:   Maintained
>> diff --git a/configs/bananapi_m2_zero_defconfig 
>> b/configs/bananapi_m2_zero_defconfig
>> new file mode 100644
>> index 000..b919d8b
>> --- /dev/null
>> +++ b/configs/bananapi_m2_zero_defconfig
>> @@ -0,0 +1,15 @@
>> +CONFIG_ARM=y
>> +CONFIG_ARCH_SUNXI=y
>> +CONFIG_SYS_TEXT_BASE=0x4a00
>
> Did you run savedefconfig recently? That should be the default nowadays.

Yes, this config is copied from saved defconfig. I rebased to
denx/next to generate patch.
Or I should prepare the patch based on denx/master?
>
>> +CONFIG_MACH_SUN8I_H3=y
>> +CONFIG_DRAM_CLK=408
>> +CONFIG_DRAM_ZQ=3881979
>> +CONFIG_DR

Re: [U-Boot] mmc: Unirqify bcm2835_sdhost and fix writes

2018-05-24 Thread Alexander Graf
> The bcm2835 sdhost driver has a problem with "write multiple" commands.
> It seems to boil down to the fact that the controller dislikes its FIFO
> to get drained at the end of a block when a write multiple blocks command
> is in flight.
> 
> The easy fix is to simply get rid of all the IRQ driven logic and make
> the driver push as much data into the FIFO as it can. That way we never
> drain and we never run into the problem.
> 
> Reported-by: Jan Leonhardt 
> Signed-off-by: Alexander Graf 

Thanks, applied to rpi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PULL] rpi patch queue 2018-05-24

2018-05-24 Thread Alexander Graf
Hi Tom,

This is my current patch queue for rpi.  Please pull.

Alex


The following changes since commit dca268a8f987730978e1a23adfd0ac82db341a10:

  .travis.yml: Further optimizations (2018-05-22 22:08:57 -0400)

are available in the git repository at:

  git://github.com/agraf/u-boot.git tags/signed-rpi-next

for you to fetch changes up to 385cbe298a6ddcab2d6cc21fb6a549152572957b:

  rpi: Change load addresses to make more room for the kernel & DTB (2018-05-24 
10:20:53 +0200)


Patch queue for rpi - 2018-05-24

Some minor fixes for the Raspberry Pi:

  - Fix SD writes on new sdhost controller
  - Sanitize default load addresses, allowing for better payload placement


Alexander Graf (2):
  rpi: Adjust fdt_addr_r to a sane address
  mmc: Unirqify bcm2835_sdhost and fix writes

Tuomas Tynkkynen (1):
  rpi: Change load addresses to make more room for the kernel & DTB

 drivers/mmc/bcm2835_sdhost.c | 265 ---
 include/configs/rpi.h|  61 ++
 2 files changed, 83 insertions(+), 243 deletions(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 08/11] common: board_f: Sort includes

2018-05-24 Thread Mario Six
Includes should be sorted.

Reviewed-by: Simon Glass 
Signed-off-by: Mario Six 

---

v2 -> v3:
No changes

v1 -> v2:
New in v2

---
 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/board_f.c b/common/board_f.c
index d24513d6d18..a716eeb8990 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -11,8 +11,8 @@

 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
--
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 05/11] mpc83xx: Add sysreset driver

2018-05-24 Thread Mario Six
Add a sysreset driver for the MPC83xx platform.

Reviewed-by: Simon Glass 
Signed-off-by: Mario Six 

---

v2 -> v3:
* Added driver file to MAINTAINERS

v1 -> v2:
New in v2

---
 MAINTAINERS |   1 +
 arch/powerpc/cpu/mpc83xx/cpu.c  |   3 +-
 drivers/sysreset/Kconfig|   5 ++
 drivers/sysreset/Makefile   |   9 +-
 drivers/sysreset/sysreset_mpc83xx.c | 159 
 5 files changed, 172 insertions(+), 5 deletions(-)
 create mode 100644 drivers/sysreset/sysreset_mpc83xx.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 139f7af26ac..b43e4bc179d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -470,6 +470,7 @@ S:  Maintained
 T: git git://git.denx.de/u-boot-mpc83xx.git
 F: drivers/ram/mpc83xx_sdram.c
 F: include/dt-bindings/memory/mpc83xx-sdram.h
+F: drivers/sysreset/sysreset_mpc83xx.c
 F: arch/powerpc/cpu/mpc83xx/
 F: arch/powerpc/include/asm/arch-mpc83xx/

diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c
index 82370b54301..e1d2f2f07cb 100644
--- a/arch/powerpc/cpu/mpc83xx/cpu.c
+++ b/arch/powerpc/cpu/mpc83xx/cpu.c
@@ -115,6 +115,7 @@ int checkcpu(void)
return 0;
 }

+#ifndef CONFIG_SYSRESET
 int
 do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
@@ -169,7 +170,7 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * 
const argv[])

return 1;
 }
-
+#endif

 /*
  * Get timebase clock frequency (like cpu_clk in Hz)
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index a6d48e8a662..fd89e5f474c 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -37,4 +37,9 @@ config SYSRESET_WATCHDOG
help
  Reboot support for generic watchdog reset.

+config SYSRESET_MCP83XX
+   bool "Enable support MPC83xx SoC family reboot driver"
+   help
+ Reboot support for NXP MPC83xx SoCs.
+
 endmenu
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index 0da58a1cf6a..50a7aef9fd7 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -3,11 +3,12 @@
 # (C) Copyright 2016 Cadence Design Systems Inc.

 obj-$(CONFIG_SYSRESET) += sysreset-uclass.o
+obj-$(CONFIG_ARCH_ASPEED) += sysreset_ast.o
+obj-$(CONFIG_ARCH_ROCKCHIP) += sysreset_rockchip.o
+obj-$(CONFIG_ARCH_STI) += sysreset_sti.o
+obj-$(CONFIG_SANDBOX) += sysreset_sandbox.o
+obj-$(CONFIG_SYSRESET_MCP83XX) += sysreset_mpc83xx.o
 obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
 obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
 obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
-obj-$(CONFIG_ARCH_ROCKCHIP) += sysreset_rockchip.o
-obj-$(CONFIG_SANDBOX) += sysreset_sandbox.o
-obj-$(CONFIG_ARCH_STI) += sysreset_sti.o
 obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o
-obj-$(CONFIG_ARCH_ASPEED) += sysreset_ast.o
diff --git a/drivers/sysreset/sysreset_mpc83xx.c 
b/drivers/sysreset/sysreset_mpc83xx.c
new file mode 100644
index 000..e61777e95f5
--- /dev/null
+++ b/drivers/sysreset/sysreset_mpc83xx.c
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ */
+
+#include 
+#include 
+#include 
+
+static void __do_reset(void)
+{
+   ulong msr;
+
+   immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
+
+   puts("Resetting the board.\n");
+
+   /* Interrupts and MMU off */
+   msr = mfmsr();
+   msr &= ~(MSR_EE | MSR_IR | MSR_DR);
+   mtmsr(msr);
+
+   /* enable Reset Control Reg */
+   out_be32(&immap->reset.rpr, 0x52535445);
+   sync();
+   isync();
+
+   /* confirm Reset Control Reg is enabled */
+
+   while (!(in_be32(&immap->reset.rcer) & RCER_CRE))
+   ;
+
+   udelay(200);
+
+   /* perform reset, only one bit */
+   out_be32(&immap->reset.rcr, RCR_SWHR);
+}
+
+int mpc83xx_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+   switch (type) {
+   case SYSRESET_WARM:
+   case SYSRESET_COLD:
+   __do_reset();
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
+
+#if defined(CONFIG_DISPLAY_AER_FULL)
+static int print_83xx_arb_event(int force)
+{
+   int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT)
+   >> AEATR_EVENT_SHIFT;
+   int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID)
+ >> AEATR_MSTR_ID_SHIFT;
+   int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST)
+  >> AEATR_TBST_SHIFT;
+   int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE)
+   >> AEATR_TSIZE_SHIFT;
+   int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE)
+   >> AEATR_TTYPE_SHIFT;
+
+   if (!force && !gd->arch.arbiter_event_address)
+   return 0;
+
+   puts("Arbiter Event Status:\n");
+   printf("   Event Address: 0x%

[U-Boot] [PATCH v3 09/11] board_f: Use static print_cpuinfo if CONFIG_CPU is active

2018-05-24 Thread Mario Six
When the DM CPU drivers are active, printing information about a CPU
should be delegated to a matching driver.

Hence, add a static print_cpuinfo that implements this delegation when
DM CPU drivers are active.

Signed-off-by: Mario Six 

---

v2 -> v3:
No changes

v1 -> v2:
New in v2

---
 common/board_f.c | 16 
 include/init.h   |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/common/board_f.c b/common/board_f.c
index a716eeb8990..327c7d83e2c 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -11,6 +11,7 @@

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -165,6 +166,21 @@ static int print_resetinfo(void)
 }
 #endif

+#if defined(CONFIG_DISPLAY_CPUINFO) && defined(CONFIG_CPU)
+static int print_cpuinfo(void)
+{
+   struct udevice *dev;
+   char desc[512];
+
+   uclass_first_device_err(UCLASS_CPU, &dev);
+
+   cpu_get_desc(dev, desc, sizeof(desc));
+   printf("%s", desc);
+
+   return 0;
+}
+#endif
+
 static int announce_dram_init(void)
 {
puts("DRAM:  ");
diff --git a/include/init.h b/include/init.h
index f114a889631..38c9680c7a7 100644
--- a/include/init.h
+++ b/include/init.h
@@ -107,7 +107,9 @@ int arch_reserve_stacks(void);
  */
 int init_cache_f_r(void);

+#ifndef CONFIG_CPU
 int print_cpuinfo(void);
+#endif
 int timer_init(void);
 int reserve_mmu(void);
 int misc_init_f(void);
--
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 10/11] cpu: Add MPC83xx CPU driver

2018-05-24 Thread Mario Six
Add a CPU driver for the MPC83xx architecture.

Signed-off-by: Mario Six 

---

v2 -> v3:
* Added driver files to MAINTAINERS

v1 -> v2:
* Removed cpu_print_info
* Fixed CPU info printing
* Removed usage of uclass_{first,next}_device_compat
* Removed printing of reset status

---
 MAINTAINERS  |   2 +
 arch/powerpc/cpu/mpc83xx/cpu.c   |   2 +
 arch/powerpc/cpu/mpc83xx/cpu_init.c  |   2 +
 arch/powerpc/include/asm/processor.h |   2 +
 drivers/cpu/Kconfig  |   7 +
 drivers/cpu/Makefile |   1 +
 drivers/cpu/mpc83xx_cpu.c| 265 +++
 drivers/cpu/mpc83xx_cpu.h| 172 +++
 include/cpu.h|   1 +
 9 files changed, 454 insertions(+)
 create mode 100644 drivers/cpu/mpc83xx_cpu.c
 create mode 100644 drivers/cpu/mpc83xx_cpu.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f03cfcc73b0..11965be1402 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -475,6 +475,8 @@ F:  drivers/clk/mpc83xx_clk.c
 F: drivers/clk/mpc83xx_clk.h
 F: include/dt-bindings/clk/mpc83xx-clk.h
 F: drivers/timer/mpc83xx_timer.c
+F: drivers/cpu/mpc83xx_cpu.c
+F: drivers/cpu/mpc83xx_cpu.h
 F: arch/powerpc/cpu/mpc83xx/
 F: arch/powerpc/include/asm/arch-mpc83xx/

diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c
index ffb42415feb..b29f271e9bc 100644
--- a/arch/powerpc/cpu/mpc83xx/cpu.c
+++ b/arch/powerpc/cpu/mpc83xx/cpu.c
@@ -25,6 +25,7 @@

 DECLARE_GLOBAL_DATA_PTR;

+#ifndef CONFIG_CPU_MPC83XX
 int checkcpu(void)
 {
volatile immap_t *immr;
@@ -114,6 +115,7 @@ int checkcpu(void)

return 0;
 }
+#endif

 #ifndef CONFIG_SYSRESET
 int
diff --git a/arch/powerpc/cpu/mpc83xx/cpu_init.c 
b/arch/powerpc/cpu/mpc83xx/cpu_init.c
index fcac9f63a81..1555205e069 100644
--- a/arch/powerpc/cpu/mpc83xx/cpu_init.c
+++ b/arch/powerpc/cpu/mpc83xx/cpu_init.c
@@ -464,6 +464,7 @@ static int print_83xx_arb_event(int force)
 }
 #endif /* CONFIG_DISPLAY_AER_ */

+#ifndef CONFIG_CPU_MPC83XX
 /*
  * Figure out the cause of the reset
  */
@@ -505,3 +506,4 @@ int prt_83xx_rsr(void)

return 0;
 }
+#endif
diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index 6fbe8c46b31..f97ce48cc27 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -1325,7 +1325,9 @@ void ll_puts(const char *);
 /* In misc.c */
 void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);

+#ifndef CONFIG_CPU_MPC83XX
 int prt_83xx_rsr(void);
+#endif

 #endif /* ndef ASSEMBLY*/

diff --git a/drivers/cpu/Kconfig b/drivers/cpu/Kconfig
index 0d1424d38e9..d4052005e24 100644
--- a/drivers/cpu/Kconfig
+++ b/drivers/cpu/Kconfig
@@ -6,3 +6,10 @@ config CPU
  multiple CPUs, then normally have to be set up in U-Boot so that
  they can work correctly in the OS. This provides a framework for
  finding out information about available CPUs and making changes.
+
+config CPU_MPC83XX
+   bool "Enable MPC83xx CPU driver"
+   depends on CPU
+   select CLK_MPC83XX
+   help
+ Support CPU cores for SoCs of the MPC83xx series.
diff --git a/drivers/cpu/Makefile b/drivers/cpu/Makefile
index db515f6f177..29d7da42fad 100644
--- a/drivers/cpu/Makefile
+++ b/drivers/cpu/Makefile
@@ -7,3 +7,4 @@
 obj-$(CONFIG_CPU) += cpu-uclass.o

 obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o
+obj-$(CONFIG_CPU_MPC83XX) += mpc83xx_cpu.o
diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c
new file mode 100644
index 000..550a7ad89f1
--- /dev/null
+++ b/drivers/cpu/mpc83xx_cpu.c
@@ -0,0 +1,265 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpc83xx_cpu.h"
+
+struct mpc83xx_cpu_priv {
+   struct mpc83xx_cpu_info info;
+};
+
+int checkcpu(void)
+{
+   struct udevice *cpu;
+
+   for (uclass_first_device(UCLASS_CPU, &cpu);
+cpu;
+uclass_next_device(&cpu)) {
+   }
+
+   return 0;
+}
+
+static inline u32 get_spridr(void)
+{
+   immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
+
+   return in_be32(&immr->sysconf.spridr);
+}
+
+static inline void determine_family(struct udevice *dev)
+{
+   struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
+
+   switch ((get_spridr() & 0xFFFE) >> 16) {
+   case 0x80B:
+   priv->info.family = FAMILY_831X;
+   break;
+   case 0x806:
+   priv->info.family = FAMILY_832X;
+   break;
+   case 0x803:
+   priv->info.family = FAMILY_834X;
+   break;
+   case 0x804:
+   priv->info.family = FAMILY_836X;
+   break;
+   case 0x80C:
+   priv->info.family = FAMILY_837X;
+   break;
+   default:
+   priv->info.fa

[U-Boot] [PATCH v3 02/11] sysreset: Add get_status method

2018-05-24 Thread Mario Six
It's useful to have the reset status of the SoC printed out during reset
(e.g. to learn whether the reset was caused by software or a watchdog).

As a first step to implement this, add a get_status method to the
sysreset class, which enables the caller to get printable information
about the reset status (akin to get_desc in the CPU uclass).

Reviewed-by: Simon Glass 
Signed-off-by: Mario Six 

---

v2 -> v3:
No changes

v1 -> v2:
New in v2

---
 drivers/sysreset/sysreset-uclass.c | 10 ++
 include/sysreset.h | 17 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/sysreset/sysreset-uclass.c 
b/drivers/sysreset/sysreset-uclass.c
index 7e06c3c90a7..de0c0aadbd9 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -24,6 +24,16 @@ int sysreset_request(struct udevice *dev, enum sysreset_t 
type)
return ops->request(dev, type);
 }

+int sysreset_get_status(struct udevice *dev, char *buf, int size)
+{
+   struct sysreset_ops *ops = sysreset_get_ops(dev);
+
+   if (!ops->get_status)
+   return -ENOSYS;
+
+   return ops->get_status(dev, buf, size);
+}
+
 int sysreset_walk(enum sysreset_t type)
 {
struct udevice *dev;
diff --git a/include/sysreset.h b/include/sysreset.h
index 81318bdbf5d..a5c0b74a473 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -28,6 +28,14 @@ struct sysreset_ops {
 *  (in which case this method will not actually return)
 */
int (*request)(struct udevice *dev, enum sysreset_t type);
+   /**
+* get_status() - get printable reset status information
+*
+* @buf:Buffer to receive the textual reset information
+* @size:   Size of the passed buffer
+* @return 0 if OK, -ve on error
+*/
+   int (*get_status)(struct udevice *dev, char *buf, int size);
 };

 #define sysreset_get_ops(dev)((struct sysreset_ops 
*)(dev)->driver->ops)
@@ -41,6 +49,15 @@ struct sysreset_ops {
 int sysreset_request(struct udevice *dev, enum sysreset_t type);

 /**
+ * get_status() - get printable reset status information
+ *
+ * @buf:   Buffer to receive the textual reset information
+ * @size:  Size of the passed buffer
+ * @return 0 if OK, -ve on error
+ */
+int sysreset_get_status(struct udevice *dev, char *buf, int size);
+
+/**
  * sysreset_walk() - cause a system reset
  *
  * This works through the available sysreset devices until it finds one that 
can
--
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 07/11] timer: Add MPC83xx timer driver

2018-05-24 Thread Mario Six
Add a timer driver for the MPC83xx architecture.

Signed-off-by: Mario Six 

---

v2 -> v3:
* Got rid of the static variables
* Added driver files to MAINTAINERS

v1 -> v2:
* Removed now-superfluous comments
* Removed usage of uclass_{first,next}_device_compat
* Switched to usage of new board uclass (instead of devinfo)

---
 MAINTAINERS|   1 +
 arch/powerpc/cpu/mpc83xx/cpu.c |   4 +-
 arch/powerpc/lib/Makefile  |   4 +
 arch/powerpc/lib/interrupts.c  |   5 +-
 drivers/timer/Kconfig  |   7 ++
 drivers/timer/Makefile |   1 +
 drivers/timer/mpc83xx_timer.c  | 182 +
 7 files changed, 201 insertions(+), 3 deletions(-)
 create mode 100644 drivers/timer/mpc83xx_timer.c

diff --git a/MAINTAINERS b/MAINTAINERS
index ab0f6a0a5d0..f03cfcc73b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -474,6 +474,7 @@ F:  drivers/sysreset/sysreset_mpc83xx.c
 F: drivers/clk/mpc83xx_clk.c
 F: drivers/clk/mpc83xx_clk.h
 F: include/dt-bindings/clk/mpc83xx-clk.h
+F: drivers/timer/mpc83xx_timer.c
 F: arch/powerpc/cpu/mpc83xx/
 F: arch/powerpc/include/asm/arch-mpc83xx/

diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c
index e1d2f2f07cb..ffb42415feb 100644
--- a/arch/powerpc/cpu/mpc83xx/cpu.c
+++ b/arch/powerpc/cpu/mpc83xx/cpu.c
@@ -175,12 +175,12 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * 
const argv[])
 /*
  * Get timebase clock frequency (like cpu_clk in Hz)
  */
-
+#ifndef CONFIG_TIMER
 unsigned long get_tbclk(void)
 {
return (gd->bus_clk + 3L) / 4L;
 }
-
+#endif

 #if defined(CONFIG_WATCHDOG)
 void watchdog_reset (void)
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index c3acefaea7e..8ac49bdd060 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -17,13 +17,17 @@ endif

 ifdef MINIMAL
 obj-y += cache.o time.o
+ifndef CONFIG_TIMER
 obj-y += ticks.o
+endif
 else

 obj-y  += ppcstring.o

 obj-y  += ppccache.o
+ifndef CONFIG_TIMER
 obj-y  += ticks.o
+endif
 obj-y  += reloc.o

 obj-$(CONFIG_BAT_RW) += bat_rw.o
diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
index f63e5cf799b..19682cfcfad 100644
--- a/arch/powerpc/lib/interrupts.c
+++ b/arch/powerpc/lib/interrupts.c
@@ -14,6 +14,7 @@
 #include 
 #endif

+#ifndef CONFIG_MPC83XX_TIMER
 #ifdef CONFIG_SHOW_ACTIVITY
 void board_show_activity (ulong) __attribute__((weak, 
alias("__board_show_activity")));

@@ -44,7 +45,7 @@ static __inline__ void set_dec (unsigned long val)
if (val)
asm volatile ("mtdec %0"::"r" (val));
 }
-
+#endif /* !CONFIG_MPC83XX_TIMER */

 void enable_interrupts (void)
 {
@@ -60,6 +61,7 @@ int disable_interrupts (void)
return ((msr & MSR_EE) != 0);
 }

+#ifndef CONFIG_MPC83XX_TIMER
 int interrupt_init (void)
 {
/* call cpu specific function from $(CPU)/interrupts.c */
@@ -102,3 +104,4 @@ ulong get_timer (ulong base)
 {
return (timestamp - base);
 }
+#endif /* !CONFIG_MPC83XX_TIMER */
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index 8a31397553d..c7909bd6e52 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -133,4 +133,11 @@ config STM32_TIMER
  Select this to enable support for the timer found on
  STM32 devices.

+config MPC83XX_TIMER
+bool "MPC83xx timer support"
+   depends on TIMER
+   help
+ Select this to enable support for the timer found on
+ devices based on the MPC83xx family of SoCs.
+
 endmenu
diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
index ee2fcb1fa71..75360d81de3 100644
--- a/drivers/timer/Makefile
+++ b/drivers/timer/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_ATCPIT100_TIMER) += atcpit100_timer.o
 obj-$(CONFIG_ROCKCHIP_TIMER) += rockchip_timer.o
 obj-$(CONFIG_ATMEL_PIT_TIMER) += atmel_pit_timer.o
 obj-$(CONFIG_STM32_TIMER)  += stm32_timer.o
+obj-$(CONFIG_MPC83XX_TIMER) += mpc83xx_timer.o
diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
new file mode 100644
index 000..148fb2550ca
--- /dev/null
+++ b/drivers/timer/mpc83xx_timer.c
@@ -0,0 +1,182 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct mpc83xx_timer_priv {
+   uint decrementer_count; /* count value for 1e6/HZ microseconds */
+   ulong timestamp;
+};
+
+static inline unsigned long get_dec(void)
+{
+   unsigned long val;
+
+   asm volatile ("mfdec %0" : "=r" (val) : );
+
+   return val;
+}
+
+static inline void set_dec(unsigned long val)
+{
+   if (val)
+   asm volatile ("mtdec %0"::"r" (val));
+}
+
+/* TODO(mario@gdsys.cc): This should really be done by timer_init, and the
+ * interrupt init should go into a interrupt driver.
+ */
+int interrupt_init(void)
+{
+   immap_t *im

[U-Boot] [PATCH v3 06/11] clk: Add MPC83xx clock driver

2018-05-24 Thread Mario Six
Add a clock driver for the MPC83xx architecture.

Signed-off-by: Mario Six 

---

v2 -> v3:
* Added driver files to MAINTAINERS

v1 -> v2:
* Added binding of sysreset driver

---
 MAINTAINERS   |   3 +
 arch/powerpc/cpu/mpc83xx/speed.c  |   4 +
 arch/powerpc/include/asm/config.h |   2 +-
 drivers/clk/Kconfig   |   6 +
 drivers/clk/Makefile  |   1 +
 drivers/clk/mpc83xx_clk.c | 426 ++
 drivers/clk/mpc83xx_clk.h | 121 ++
 include/dt-bindings/clk/mpc83xx-clk.h |  33 +++
 8 files changed, 595 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mpc83xx_clk.c
 create mode 100644 drivers/clk/mpc83xx_clk.h
 create mode 100644 include/dt-bindings/clk/mpc83xx-clk.h

diff --git a/MAINTAINERS b/MAINTAINERS
index b43e4bc179d..ab0f6a0a5d0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -471,6 +471,9 @@ T:  git git://git.denx.de/u-boot-mpc83xx.git
 F: drivers/ram/mpc83xx_sdram.c
 F: include/dt-bindings/memory/mpc83xx-sdram.h
 F: drivers/sysreset/sysreset_mpc83xx.c
+F: drivers/clk/mpc83xx_clk.c
+F: drivers/clk/mpc83xx_clk.h
+F: include/dt-bindings/clk/mpc83xx-clk.h
 F: arch/powerpc/cpu/mpc83xx/
 F: arch/powerpc/include/asm/arch-mpc83xx/

diff --git a/arch/powerpc/cpu/mpc83xx/speed.c b/arch/powerpc/cpu/mpc83xx/speed.c
index f0945281cd2..39bc1c53406 100644
--- a/arch/powerpc/cpu/mpc83xx/speed.c
+++ b/arch/powerpc/cpu/mpc83xx/speed.c
@@ -6,6 +6,8 @@
  * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  */

+#ifndef CONFIG_CLK_MPC83XX
+
 #include 
 #include 
 #include 
@@ -590,3 +592,5 @@ U_BOOT_CMD(clocks, 1, 0, do_clocks,
"print clock configuration",
"clocks"
 );
+
+#endif
diff --git a/arch/powerpc/include/asm/config.h 
b/arch/powerpc/include/asm/config.h
index 284cfe21ab0..7bc8f5006ec 100644
--- a/arch/powerpc/include/asm/config.h
+++ b/arch/powerpc/include/asm/config.h
@@ -78,7 +78,7 @@
 /* All PPC boards must swap IDE bytes */
 #define CONFIG_IDE_SWAP_IO

-#if defined(CONFIG_DM_SERIAL)
+#if defined(CONFIG_DM_SERIAL) && !defined(CONFIG_CLK_MPC83XX)
 /*
  * TODO: Convert this to a clock driver exists that can give us the UART
  * clock here.
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index edb4ca58ea5..e6ebff0a9d4 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -98,4 +98,10 @@ config ICS8N3QV01
  Crystal Oscillator). The output frequency can be programmed via an
  I2C interface.

+config CLK_MPC83XX
+   bool "Enable MPC83xx clock driver"
+   depends on CLK
+   help
+ Support for the clock driver of the MPC83xx series of SoCs.
+
 endmenu
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 58139b13a89..58f497d3a15 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o
 obj-$(CONFIG_CLK_BOSTON) += clk_boston.o
 obj-$(CONFIG_CLK_EXYNOS) += exynos/
 obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o
+obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o
 obj-$(CONFIG_CLK_RENESAS) += renesas/
 obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o
 obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o
diff --git a/drivers/clk/mpc83xx_clk.c b/drivers/clk/mpc83xx_clk.c
new file mode 100644
index 000..80be597332d
--- /dev/null
+++ b/drivers/clk/mpc83xx_clk.c
@@ -0,0 +1,426 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpc83xx_clk.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static u32 *speed;
+
+struct mpc83xx_clk_priv {
+   u32 *speed;
+};
+
+static const char * const names[] = {
+   [MPC83XX_CLK_CORE] = "Core",
+   [MPC83XX_CLK_CSB] = "Coherent System Bus",
+   [MPC83XX_CLK_QE] = "QE",
+   [MPC83XX_CLK_BRG] = "BRG",
+   [MPC83XX_CLK_LBIU] = "Local Bus Controller",
+   [MPC83XX_CLK_LCLK] = "Local Bus",
+   [MPC83XX_CLK_MEM] = "DDR",
+   [MPC83XX_CLK_MEM_SEC] = "DDR Secondary",
+   [MPC83XX_CLK_ENC] = "SEC",
+   [MPC83XX_CLK_I2C1] = "I2C1",
+   [MPC83XX_CLK_I2C2] = "I2C2",
+   [MPC83XX_CLK_TDM] = "TDM",
+   [MPC83XX_CLK_SDHC] = "SDHC",
+   [MPC83XX_CLK_TSEC1] = "TSEC1",
+   [MPC83XX_CLK_TSEC2] = "TSEC2",
+   [MPC83XX_CLK_USBDR] = "USB DR",
+   [MPC83XX_CLK_USBMPH] = "USB MPH",
+   [MPC83XX_CLK_PCIEXP1] = "PCIEXP1",
+   [MPC83XX_CLK_PCIEXP2] = "PCIEXP2",
+   [MPC83XX_CLK_SATA] = "SATA",
+   [MPC83XX_CLK_DMAC] = "DMAC",
+   [MPC83XX_CLK_PCI] = "PCI",
+};
+
+struct clk_mode {
+   u8 low;
+   u8 high;
+   int type;
+};
+
+const struct clk_mode modes[] = {
+   [MPC83XX_CLK_CORE] = {0, 0, TYPE_SPECIAL},
+   [MPC83XX_CLK_CSB] = {0, 0, TYPE_SPECIAL},
+   [MPC83XX_CLK_QE] = {0, 0, TYPE_SPECIAL},
+   [MPC83XX_CLK_BRG] = {0, 0, TYPE_SPECIAL},
+   [MPC83XX_CLK_MEM] = {1, 1, TYPE_SPMR_DIR

[U-Boot] [PATCH v3 03/11] test: Add tests for sysreset_get_status

2018-05-24 Thread Mario Six
Add some tests for sysreset_get_status.

Signed-off-by: Mario Six 

---

v2 -> v3:
New in v3.

---
 drivers/sysreset/sysreset_sandbox.c | 16 
 test/dm/sysreset.c  | 19 +++
 2 files changed, 35 insertions(+)

diff --git a/drivers/sysreset/sysreset_sandbox.c 
b/drivers/sysreset/sysreset_sandbox.c
index f12c4e84198..e03b5c122fe 100644
--- a/drivers/sysreset/sysreset_sandbox.c
+++ b/drivers/sysreset/sysreset_sandbox.c
@@ -29,6 +29,13 @@ static int sandbox_warm_sysreset_request(struct udevice *dev,
return -EINPROGRESS;
 }

+int sandbox_warm_sysreset_get_status(struct udevice *dev, char *buf, int size)
+{
+   strncpy(buf, "Reset Status: WARM", size);
+
+   return 0;
+}
+
 static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
struct sandbox_state *state = state_get_current();
@@ -60,8 +67,16 @@ static int sandbox_sysreset_request(struct udevice *dev, 
enum sysreset_t type)
return -EINPROGRESS;
 }

+int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size)
+{
+   strncpy(buf, "Reset Status: COLD", size);
+
+   return 0;
+}
+
 static struct sysreset_ops sandbox_sysreset_ops = {
.request= sandbox_sysreset_request,
+   .get_status = sandbox_sysreset_get_status,
 };

 static const struct udevice_id sandbox_sysreset_ids[] = {
@@ -78,6 +93,7 @@ U_BOOT_DRIVER(sysreset_sandbox) = {

 static struct sysreset_ops sandbox_warm_sysreset_ops = {
.request= sandbox_warm_sysreset_request,
+   .get_status = sandbox_warm_sysreset_get_status,
 };

 static const struct udevice_id sandbox_warm_sysreset_ids[] = {
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c
index 33a8bfb33c4..218cc239cc6 100644
--- a/test/dm/sysreset.c
+++ b/test/dm/sysreset.c
@@ -45,6 +45,25 @@ static int dm_test_sysreset_base(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_sysreset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);

+static int dm_test_sysreset_get_status(struct unit_test_state *uts)
+{
+   struct udevice *dev;
+   char msg[64];
+
+   /* Device 1 is the warm sysreset device */
+   ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
+   ut_assertok(sysreset_get_status(dev, msg, sizeof(msg)));
+   ut_asserteq_str("Reset Status: WARM", msg);
+
+   /* Device 2 is the cold sysreset device */
+   ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
+   ut_assertok(sysreset_get_status(dev, msg, sizeof(msg)));
+   ut_asserteq_str("Reset Status: COLD", msg);
+
+   return 0;
+}
+DM_TEST(dm_test_sysreset_get_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
 /* Test that we can walk through the sysreset devices */
 static int dm_test_sysreset_walk(struct unit_test_state *uts)
 {
--
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 11/11] misc: Add MPC83xx serdes driver

2018-05-24 Thread Mario Six
Add a driver to configure the SerDes (Serializer/Deserializer) lanes on
the MPC83xx architecture.

Signed-off-by: Mario Six 

---

v2 -> v3:
* Added driver file to MAINTAINERS

v1 -> v2:
No changes

---
 MAINTAINERS   |   1 +
 arch/powerpc/cpu/mpc83xx/serdes.c |   4 +
 arch/powerpc/include/asm/fsl_mpc83xx_serdes.h |   4 +
 drivers/misc/Kconfig  |   7 +
 drivers/misc/Makefile |   1 +
 drivers/misc/mpc83xx_serdes.c | 228 ++
 6 files changed, 245 insertions(+)
 create mode 100644 drivers/misc/mpc83xx_serdes.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 11965be1402..d55632617ab 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -477,6 +477,7 @@ F:  include/dt-bindings/clk/mpc83xx-clk.h
 F: drivers/timer/mpc83xx_timer.c
 F: drivers/cpu/mpc83xx_cpu.c
 F: drivers/cpu/mpc83xx_cpu.h
+F: drivers/misc/mpc83xx_serdes.c
 F: arch/powerpc/cpu/mpc83xx/
 F: arch/powerpc/include/asm/arch-mpc83xx/

diff --git a/arch/powerpc/cpu/mpc83xx/serdes.c 
b/arch/powerpc/cpu/mpc83xx/serdes.c
index 982a4475f00..8242f952653 100644
--- a/arch/powerpc/cpu/mpc83xx/serdes.c
+++ b/arch/powerpc/cpu/mpc83xx/serdes.c
@@ -8,6 +8,8 @@
  * Author: Li Yang 
  */

+#ifndef CONFIG_MPC83XX_SERDES
+
 #include 
 #include 
 #include 
@@ -148,3 +150,5 @@ void fsl_setup_serdes(u32 offset, char proto, u32 rfcks, 
char vdd)
tmp |= FSL_SRDSRSTCTL_RST;
out_be32(regs + FSL_SRDSRSTCTL_OFFS, tmp);
 }
+
+#endif /* !CONFIG_MPC83XX_SERDES */
diff --git a/arch/powerpc/include/asm/fsl_mpc83xx_serdes.h 
b/arch/powerpc/include/asm/fsl_mpc83xx_serdes.h
index e51d060d6a7..a02b5992654 100644
--- a/arch/powerpc/include/asm/fsl_mpc83xx_serdes.h
+++ b/arch/powerpc/include/asm/fsl_mpc83xx_serdes.h
@@ -6,6 +6,8 @@
 #ifndef __FSL_MPC83XX_SERDES_H
 #define __FSL_MPC83XX_SERDES_H

+#ifndef CONFIG_MPC83XX_SERDES
+
 #include 

 #define FSL_SERDES_CLK_100 (0 << 28)
@@ -19,4 +21,6 @@

 extern void fsl_setup_serdes(u32 offset, char proto, u32 rfcks, char vdd);

+#endif /* !CONFIG_MPC83XX_SERDES */
+
 #endif /* __FSL_MPC83XX_SERDES_H */
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index be900cf4d6e..4794f615093 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -268,4 +268,11 @@ config GDSYS_RXAUI_CTRL
depends on MISC
help
  Support gdsys FPGA's RXAUI control.
+
+config MPC83XX_SERDES
+   bool "Enable MPC83xx serdes driver"
+   depends on MISC
+   help
+ Support for serdes found on MPC83xx SoCs.
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index e362609d62a..f53f87a3639 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -53,3 +53,4 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o
 obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
 obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
+obj-$(CONFIG_MPC83XX_SERDES) += mpc83xx_serdes.o
diff --git a/drivers/misc/mpc83xx_serdes.c b/drivers/misc/mpc83xx_serdes.c
new file mode 100644
index 000..981128e300d
--- /dev/null
+++ b/drivers/misc/mpc83xx_serdes.c
@@ -0,0 +1,228 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ *
+ * base on the MPC83xx serdes initialization, which is
+ *
+ * Copyright 2007,2011 Freescale Semiconductor, Inc.
+ * Copyright (C) 2008 MontaVista Software, Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   SRDSCR0_DPP_1V2= 0x8800,
+
+   SRDSCR0_TXEQA_MASK = 0x7000,
+   SRDSCR0_TXEQA_SATA = 0x1000,
+   SRDSCR0_TXEQE_MASK = 0x0700,
+   SRDSCR0_TXEQE_SATA = 0x0100,
+};
+
+enum {
+   SRDSCR1_PLLBW = 0x0040
+};
+
+enum {
+   SRDSCR2_VDD_1V2= 0x0080,
+
+   SRDSCR2_SEIC_MASK  = 0x1c1c,
+   SRDSCR2_SEIC_SATA  = 0x1414,
+   SRDSCR2_SEIC_PEX   = 0x1010,
+   SRDSCR2_SEIC_SGMII = 0x0101,
+};
+
+enum {
+   SRDSCR3_KFR_SATA  = 0x1010,
+   SRDSCR3_KPH_SATA  = 0x0404,
+   SRDSCR3_SDFM_SATA_PEX = 0x0101,
+   SRDSCR3_SDTXL_SATA= 0x0505,
+};
+
+enum {
+   SRDSCR4_PROT_SATA  = 0x0808,
+   SRDSCR4_PROT_PEX   = 0x0101,
+   SRDSCR4_PROT_SGMII = 0x0505,
+
+   SRDSCR4_PLANE_X2   = 0x0100,
+};
+
+enum {
+   SRDSRSTCTL_RST= 0x8000,
+   SRDSRSTCTL_SATA_RESET = 0xf,
+};
+
+enum {
+   SERDES_CLK_100 = (0 << 28),
+   SERDES_CLK_125 = (1 << 28),
+   SERDES_CLK_150 = (3 << 28),
+};
+
+struct mpc83xx_serdes_regs {
+   u32 srdscr0;
+   u32 srdscr1;
+   u32 srdscr2;
+   u32 srdscr3;
+   u32 srdscr4;
+   u8 fill0[12];
+   u32 srdsrstctl;
+};
+
+enum pex_type {
+   PEX_X1,
+   PEX_X2,
+};
+
+struct mpc83xx_serdes_priv {
+   struct mpc83xx_serdes_regs *regs;
+   u32 rfcks;
+};
+
+static const 

[U-Boot] [PATCH v3 04/11] board_f: Add reset status printing

2018-05-24 Thread Mario Six
To print the reset status during boot, add a method print_resetinfo to
board_f, which is called in init_sequence_f[], that gets the reset
information from the sysreset driver (assuming there is only one seems
reasonable), and prints it.

Reviewed-by: Simon Glass 
Signed-off-by: Mario Six 

---

v2 -> v3:
* Improved behavior and error handling

v1 -> v2:
New in v2

---
 common/board_f.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/common/board_f.c b/common/board_f.c
index fa667c764bc..d24513d6d18 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -140,6 +141,30 @@ static int display_text_info(void)
return 0;
 }

+#ifdef CONFIG_SYSRESET
+static int print_resetinfo(void)
+{
+   struct udevice *dev;
+   char status[256];
+   int ret;
+
+   ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
+   if (ret) {
+   debug("%s: No sysreset device found (error: %d)\n",
+ __func__, ret);
+   /* Not all boards have sysreset drivers available during early
+* boot, so don't fail if one can't be found.
+*/
+   return 0;
+   }
+
+   if (!sysreset_get_status(dev, status, sizeof(status)))
+   printf("%s", status);
+
+   return 0;
+}
+#endif
+
 static int announce_dram_init(void)
 {
puts("DRAM:  ");
@@ -788,6 +813,9 @@ static const init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_PPC) || defined(CONFIG_SH) || defined(CONFIG_X86)
checkcpu,
 #endif
+#if defined(CONFIG_SYSRESET)
+   print_resetinfo,
+#endif
 #if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo,  /* display cpu info (and speed) */
 #endif
--
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 01/11] ram: Add driver for MPC83xx

2018-05-24 Thread Mario Six
Add a RAM driver for the MPC83xx architecture.

Reviewed-by: Simon Glass 
Signed-off-by: Mario Six 

---

v2 -> v3:
* Converted some #ifdefs to if (IS_ENABLED(...))
* Added driver files to MAINTAINERS

v1 -> v2:
No changes

---
 MAINTAINERS|   2 +
 arch/powerpc/cpu/mpc83xx/spd_sdram.c   |   4 +
 drivers/ram/Kconfig|   8 +
 drivers/ram/Makefile   |   1 +
 drivers/ram/mpc83xx_sdram.c| 969 +
 include/dt-bindings/memory/mpc83xx-sdram.h | 151 +
 include/mpc83xx.h  |   6 +
 7 files changed, 1141 insertions(+)
 create mode 100644 drivers/ram/mpc83xx_sdram.c
 create mode 100644 include/dt-bindings/memory/mpc83xx-sdram.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5670917b41b..139f7af26ac 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -468,6 +468,8 @@ POWERPC MPC83XX
 M: Mario Six 
 S: Maintained
 T: git git://git.denx.de/u-boot-mpc83xx.git
+F: drivers/ram/mpc83xx_sdram.c
+F: include/dt-bindings/memory/mpc83xx-sdram.h
 F: arch/powerpc/cpu/mpc83xx/
 F: arch/powerpc/include/asm/arch-mpc83xx/

diff --git a/arch/powerpc/cpu/mpc83xx/spd_sdram.c 
b/arch/powerpc/cpu/mpc83xx/spd_sdram.c
index bbc8ef03c7b..328a018eb6f 100644
--- a/arch/powerpc/cpu/mpc83xx/spd_sdram.c
+++ b/arch/powerpc/cpu/mpc83xx/spd_sdram.c
@@ -10,6 +10,8 @@
  * Xianghua Xiao (x.x...@motorola.com)
  */

+#ifndef CONFIG_MPC83XX_SDRAM
+
 #include 
 #include 
 #include 
@@ -924,3 +926,5 @@ void ddr_enable_ecc(unsigned int dram_size)
__asm__ __volatile__ ("isync");
 }
 #endif /* CONFIG_DDR_ECC */
+
+#endif /* !CONFIG_MPC83XX_SDRAM */
diff --git a/drivers/ram/Kconfig b/drivers/ram/Kconfig
index 496e2b793bd..18532e71be9 100644
--- a/drivers/ram/Kconfig
+++ b/drivers/ram/Kconfig
@@ -34,4 +34,12 @@ config STM32_SDRAM
  support external memories like sdram, psram & nand.
  This driver is for the sdram memory interface with the FMC.

+config MPC83XX_SDRAM
+   bool "Enable MPC83XX SDRAM support"
+   depends on RAM
+   help
+ Enable support for the internal DDR Memory Controller of the MPC83xx
+ family of SoCs. Both static configurations, as well as configuring
+ the RAM through the use of SPD is supported via device tree settings.
+
 source "drivers/ram/stm32mp1/Kconfig"
diff --git a/drivers/ram/Makefile b/drivers/ram/Makefile
index 3820d03aa41..4ad3604d163 100644
--- a/drivers/ram/Makefile
+++ b/drivers/ram/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier:  GPL-2.0+
 #
 obj-$(CONFIG_RAM) += ram-uclass.o
+obj-$(CONFIG_MPC83XX_SDRAM) += mpc83xx_sdram.o
 obj-$(CONFIG_SANDBOX) += sandbox_ram.o
 obj-$(CONFIG_STM32MP1_DDR) += stm32mp1/
 obj-$(CONFIG_STM32_SDRAM) += stm32_sdram.o
diff --git a/drivers/ram/mpc83xx_sdram.c b/drivers/ram/mpc83xx_sdram.c
new file mode 100644
index 000..9d31d28ce0e
--- /dev/null
+++ b/drivers/ram/mpc83xx_sdram.c
@@ -0,0 +1,969 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define CSCONFIG_ENABLE0x8000
+
+#define BANK_BITS_20x
+#define BANK_BITS_30x4000
+
+#define ROW_BITS_120x
+#define ROW_BITS_130x0100
+#define ROW_BITS_140x0200
+
+#define COL_BITS_8 0x
+#define COL_BITS_9 0x0001
+#define COL_BITS_100x0002
+#define COL_BITS_110x0003
+
+#define TIMING_CFG3_EXT_REFREC_SHIFT   16
+
+#define TIMING_CFG0_RWT_SHIFT  30
+#define TIMING_CFG0_WRT_SHIFT  28
+#define TIMING_CFG0_RRT_SHIFT  26
+#define TIMING_CFG0_WWT_SHIFT  24
+#define TIMING_CFG0_ACT_PD_EXIT_SHIFT  20
+#define TIMING_CFG0_PRE_PD_EXIT_SHIFT  16
+#define TIMING_CFG0_ODT_PD_EXIT_SHIFT  8
+#define TIMING_CFG0_MRS_CYC_SHIFT  0
+
+#define TIMING_CFG1_PRETOACT_SHIFT 28
+#define TIMING_CFG1_ACTTOPRE_SHIFT 24
+#define TIMING_CFG1_ACTTORW_SHIFT  20
+#define TIMING_CFG1_CASLAT_SHIFT   16
+#define TIMING_CFG1_REFREC_SHIFT   12
+#define TIMING_CFG1_WRREC_SHIFT8
+#define TIMING_CFG1_ACTTOACT_SHIFT 4
+#define TIMING_CFG1_WRTORD_SHIFT   0
+
+#define TIMING_CFG2_CPO_SHIFT  23
+#define TIMING_CFG2_WR_DATA_DELAY_SHIFT10
+#define TIMING_CFG2_ADD_LAT_SHIFT  28
+#define TIMING_CFG2_WR_LAT_DELAY_SHIFT 19
+#define TIMING_CFG2_RD_TO_PRE_SHIFT13
+#define TIMING_CFG2_CKE_PLS_SHIFT  6
+#define TIMING_CFG2_FOUR_ACT_SHIFT 0
+
+#define SDRAM_CFG_SREN_SHIFT   (31 - 1)
+#define SDRAM_CFG_ECC_EN_SHIFT (31 - 2)
+#define SDRAM_CFG_RD_EN_SHIFT  (31 - 3)
+#define SDRAM_CFG_SDRAM_TYPE_SHIFT (31 - 7)
+#define SDRAM_CFG_DYN_PWR_SHIFT(31 - 10)
+#define SDRAM_CFG_DBW_SHIFT

Re: [U-Boot] [PATCH v3 1/2] arm: print instructions pointed to by pc

2018-05-24 Thread Alexander Graf


On 15.05.18 19:42, Heinrich Schuchardt wrote:
> If an exception occurs in a loaded image and the relocation offset is
> unknown, it is helful to know the instructions pointed to by the
> program counter. This patch adds the missing output.
> 
> A possible output is:
> Code: e1c560d0 e12fff1e e120077b e12fff1e (e7f7defb)
> 
> The parentheses indicate the instruction causing the exception.
> 
> The output can be disassembled using the decodecode script provided
> by the Linux kernel project.
> 
> Signed-off-by: Heinrich Schuchardt 

This is even better than my suggestion. Aweseome ;).

Reviewed-by: Alexander Graf 


Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc

2018-05-24 Thread Alexander Graf


On 13.05.18 16:45, Marek Vasut wrote:
> On 05/13/2018 02:22 PM, Tuomas Tynkkynen wrote:
>> Hi,
>>
>> On Thu, 10 May 2018 16:38:30 +0200
>> Heinrich Schuchardt  wrote:
>>
>>> If an exception occurs in a loaded image and the relocation offset is
>>> unknown, it is helful to know the instructions pointed to by the
>>> program counter. This patch adds the missing output.
>>>
>>> A possible output is:
>>> *pc: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1
>>>
>>> The output can be disassembled with
>>> xxd -pc -r - > a.out
>>> $(CROSS_COMPILE)objdump -D -marm -b binary a.out
>>>
>>> Signed-off-by: Heinrich Schuchardt 
>>> ---
>>> v2
>>> print bytes not halfwords
>>
>> Note that Linux already comes with a scripts/decodecode tool where you paste 
>> the
>> output of an Oops and it disassembles the "Code: " line from the dump. So I'd
>> vote for importing scripts/decodecode from Linux and making U-Boot's output
>> compatible with Linux.
> 
> Sounds good.
> 
> btw if you get exception because the memory at PC is inaccessible, this
> will trigger a double-fault I think.

Yes, but it will only trigger it at the end of the handler at which
point we're panicking anyways, no?

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] sunxi: add support for Banana Pi M2 Zero board

2018-05-24 Thread Maxime Ripard
On Thu, May 24, 2018 at 04:22:53PM +0800, Jun Nie wrote:
> > Why not using straight the DT from linux here? There's a couple of
> > things missing from this one (the pinctrl nodes, for example).
> 
> I had thought that pinctrl is not merged yet in u-boot per the
> comments for patch V1. Will
> keep it in next version.
> 
> WIFI is removed because it shall not work in u-boot.

It doesn't really matter, the hardware is the same and the DT should
be the same as well, even though U-Boot will not use it to its full
extent. There's even some people using directly the U-Boot DT to boot
Linux. In this case, you wouldn't get all the features supported in
Linux either.

> ehci0/ohci0 are removed because they are still missing in h3.dtsi.

You can sync the H3 DTSI with Linux as well then, we probably didn't
do it for quite some time.

> >
> >> diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
> >> index 5eb8bbe..0d904d9 100644
> >> --- a/board/sunxi/MAINTAINERS
> >> +++ b/board/sunxi/MAINTAINERS
> >> @@ -363,6 +363,11 @@ M:   Icenowy Zheng 
> >>  S:   Maintained
> >>  F:   configs/Sinovoip_BPI_M2_Plus_defconfig
> >>
> >> +SINOVOIP BPI M2 ZERO BOARD
> >> +M:   Icenowy Zheng 
> >> +S:   Maintained
> >> +F:   configs/Sinovoip_BPI_M2_Zero_defconfig
> >> +
> >>  SINOVOIP BPI M3 A83T BOARD
> >>  M:   VishnuPatekar 
> >>  S:   Maintained
> >> diff --git a/configs/bananapi_m2_zero_defconfig 
> >> b/configs/bananapi_m2_zero_defconfig
> >> new file mode 100644
> >> index 000..b919d8b
> >> --- /dev/null
> >> +++ b/configs/bananapi_m2_zero_defconfig
> >> @@ -0,0 +1,15 @@
> >> +CONFIG_ARM=y
> >> +CONFIG_ARCH_SUNXI=y
> >> +CONFIG_SYS_TEXT_BASE=0x4a00
> >
> > Did you run savedefconfig recently? That should be the default nowadays.
> 
> Yes, this config is copied from saved defconfig. I rebased to
> denx/next to generate patch.
> Or I should prepare the patch based on denx/master?

This should have been solved by 341c05865478, which is part of
v2018.05

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RFC] arm: dts: am33xx: Sync DTS with Linux 4.16.11

2018-05-24 Thread Felix Brack
Hello,

I am working on a patch to synchronize the DTS files of the am33xx SoC
with those from Linux 4.16.11 (current stable).

After some tiny modifications to the boards am335x-pdu001, am335x-evm,
am335x-rut, am437x-gp-evm and am43x-epos-evm buildman passes without any
warnings on the 46 am33xx based boards. This is required but not
sufficient at all.

As I'm the maintainer of the am335x-pdu001 board I will use it to
illustrate a sample problem.
The am335x-pdu001 board uses the ns16550 driver which reads the property
 from the DT. This property is required and must be set to a
value of 2, otherwise it would default to 0.
The am33xx.dtsi file currently used by U-Boot sets this property
correctly for all 6 uarts. The am33xx.dtsi file from Linux 4.16.11
however does not define this property anymore.
For the am335x-pdu001 board the fix is trivial: just add the property
 to the board and U-Boot specific am335xx-pdu001-u-boot.dtsi
file.
But this has a major drawback: only the am335x-pdu001 board gets fixed.
What about other boards requiring the  property?
The first idea that would probably come into mind is to put the property
 into the SoC specific am33xx-u-boot.dtsi file. But this file
is ignored if a board specific file already exists. Hence this can not
be done.

For the patch I'm working on there is the general question about how to
proceed. Should I just fix the board I'm maintaining and then post the
patch? This would most certainly break some of the remaining 45 boards
which I think is a no-go.

A more specific question dealing with the "missing SoC property"
 above is about <>-u-boot.dtsi files: would it be possible,
useful and hazard-free to change the build process to use, for example,
SoC specific _and_ board specific files? Of course some sort of
hierarchy would be necessary to make sure that properties defined in the
board specific dtsi file would overwrite the same properties defined in
the SoC specific file ect.

I believe that keeping DT files (especially include files) in sync
between U-Boot and Linux is of big importance. Maybe there is already a
standard solution to problems similar to the one depicted above. Anyway,
I would appreciate any feedback.

regards, Felix
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] usb: xhci: Set accurate add context flags when updating hub attributes

2018-05-24 Thread Marek Vasut
On 05/24/2018 08:40 AM, Bin Meng wrote:
> If a USB 3.0 hub is plugged into the root port of the xHC, the xHCI
> driver will issue a 'Configure Endpoint' command to the xHC for it
> to update its internal data structure for this hub device. The hub
> attributes are in the slot context so we need tell xHC to update the
> slot context by setting the add context flags of the input control
> context to only cover the slot context.
> 
> At present the add context flags is or'ed with the slot context bit,
> but it should really be accurately set to the slot context, as the
> variable that holds the value of the add context flags comes from
> whatever was set in the last command execution, which may contain
> additional contexts that 'Configure Endpoint' command should not
> touch. Some xHC implementations like x86 don't complain such, but
> it was observed on Renesas RCar Gen3 platform that the RCar xHC
> complains with a 'TRB error' completion codes as the response.
> 
> Reported-by: Marek Vasut 
> Signed-off-by: Bin Meng 
> Tested-by: Marek Vasut 
> Tested-by: Matthias Blankertz 

Applied all, thanks!

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] arm: print instructions pointed to by pc

2018-05-24 Thread Marek Vasut
On 05/24/2018 10:57 AM, Alexander Graf wrote:
> 
> 
> On 13.05.18 16:45, Marek Vasut wrote:
>> On 05/13/2018 02:22 PM, Tuomas Tynkkynen wrote:
>>> Hi,
>>>
>>> On Thu, 10 May 2018 16:38:30 +0200
>>> Heinrich Schuchardt  wrote:
>>>
 If an exception occurs in a loaded image and the relocation offset is
 unknown, it is helful to know the instructions pointed to by the
 program counter. This patch adds the missing output.

 A possible output is:
 *pc: fb de f7 e7 1e ff 2f e1 01 00 50 e3 f0 4d 2d e9 01 80 a0 e1

 The output can be disassembled with
 xxd -pc -r - > a.out
 $(CROSS_COMPILE)objdump -D -marm -b binary a.out

 Signed-off-by: Heinrich Schuchardt 
 ---
 v2
print bytes not halfwords
>>>
>>> Note that Linux already comes with a scripts/decodecode tool where you 
>>> paste the
>>> output of an Oops and it disassembles the "Code: " line from the dump. So 
>>> I'd
>>> vote for importing scripts/decodecode from Linux and making U-Boot's output
>>> compatible with Linux.
>>
>> Sounds good.
>>
>> btw if you get exception because the memory at PC is inaccessible, this
>> will trigger a double-fault I think.
> 
> Yes, but it will only trigger it at the end of the handler at which
> point we're panicking anyways, no?

Linux prints the faulting function at the top.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] x86: baytrail: Correct the comment of IACORE_VIDS bit ranges

2018-05-24 Thread Bin Meng
The guaranteed vid bit ranges in IACORE_VIDS MSR is actually
[22:16]. This corrects the comment for it.

Signed-off-by: Bin Meng 
---

 arch/x86/cpu/baytrail/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/baytrail/cpu.c b/arch/x86/cpu/baytrail/cpu.c
index 29baf08..56e9813 100644
--- a/arch/x86/cpu/baytrail/cpu.c
+++ b/arch/x86/cpu/baytrail/cpu.c
@@ -80,7 +80,7 @@ static void set_max_freq(void)
perf_ctl.lo = (msr.lo & 0x3f) >> 8;
 
/*
-* Set guaranteed vid [21:16] from IACORE_VIDS to bits [7:0] of
+* Set guaranteed vid [22:16] from IACORE_VIDS to bits [7:0] of
 * the PERF_CTL
 */
msr = msr_read(MSR_IACORE_VIDS);
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] net: add Socionext AVE ethernet driver support

2018-05-24 Thread Kunihiko Hayashi
Add driver for Socionext AVE ethernet controller that includes MAC and
MDIO bus supporting RGMII/RMII modes.
The driver behaves the ethernet driver model (DM_ETH) with devicetree.

This patch requires the internal phy definition [1].
[1] http://patchwork.ozlabs.org/patch/915965/

Signed-off-by: Kunihiko Hayashi 
Signed-off-by: Masahiro Yamada 
---
 drivers/net/Kconfig   |  10 +
 drivers/net/Makefile  |   1 +
 drivers/net/sni_ave.c | 995 ++
 3 files changed, 1006 insertions(+)
 create mode 100644 drivers/net/sni_ave.c

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f2cc75f..e88f056 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -362,6 +362,16 @@ config MPC8XX_FEC
  This driver implements support for the Fast Ethernet Controller
  on MPC8XX
 
+config SNI_AVE
+   bool "Socionext AVE Ethernet support"
+   depends on DM_ETH && ARCH_UNIPHIER
+   select PHYLIB
+   select SYSCON
+   select REGMAP
+   help
+ This driver implements support for the Socionext AVE Ethernet
+ controller, as found on the Socionext UniPhier family.
+
 config ETHER_ON_FEC1
bool "FEC1"
depends on MPC8XX_FEC
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 851f82f..5b40ccc 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -71,3 +71,4 @@ obj-$(CONFIG_VSC9953) += vsc9953.o
 obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
 obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
 obj-$(CONFIG_FSL_PFE) += pfe_eth/
+obj-$(CONFIG_SNI_AVE) += sni_ave.o
diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c
new file mode 100644
index 000..ba51ea5
--- /dev/null
+++ b/drivers/net/sni_ave.c
@@ -0,0 +1,995 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ * sni_ave.c - Socionext UniPhier AVE ethernet driver
+ * Copyright 2016-2018 Socionext inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AVE_GRST_DELAY_MSEC40
+#define AVE_MIN_XMITSIZE   60
+#define AVE_SEND_TIMEOUT_COUNT 1000
+#define AVE_MDIO_TIMEOUT_USEC  1
+#define AVE_HALT_TIMEOUT_USEC  1
+
+/* General Register Group */
+#define AVE_IDR0x000   /* ID */
+#define AVE_VR 0x004   /* Version */
+#define AVE_GRR0x008   /* Global Reset */
+#define AVE_CFGR   0x00c   /* Configuration */
+
+/* Interrupt Register Group */
+#define AVE_GIMR   0x100   /* Global Interrupt Mask */
+#define AVE_GISR   0x104   /* Global Interrupt Status */
+
+/* MAC Register Group */
+#define AVE_TXCR   0x200   /* TX Setup */
+#define AVE_RXCR   0x204   /* RX Setup */
+#define AVE_RXMAC1R0x208   /* MAC address (lower) */
+#define AVE_RXMAC2R0x20c   /* MAC address (upper) */
+#define AVE_MDIOCTR0x214   /* MDIO Control */
+#define AVE_MDIOAR 0x218   /* MDIO Address */
+#define AVE_MDIOWDR0x21c   /* MDIO Data */
+#define AVE_MDIOSR 0x220   /* MDIO Status */
+#define AVE_MDIORDR0x224   /* MDIO Rd Data */
+
+/* Descriptor Control Register Group */
+#define AVE_DESCC  0x300   /* Descriptor Control */
+#define AVE_TXDC   0x304   /* TX Descriptor Configuration */
+#define AVE_RXDC   0x308   /* RX Descriptor Ring0 Configuration */
+#define AVE_IIRQC  0x34c   /* Interval IRQ Control */
+
+/* 64bit descriptor memory */
+#define AVE_DESC_SIZE_64   12  /* Descriptor Size */
+#define AVE_TXDM_640x1000  /* Tx Descriptor Memory */
+#define AVE_RXDM_640x1c00  /* Rx Descriptor Memory */
+
+/* 32bit descriptor memory */
+#define AVE_DESC_SIZE_32   8   /* Descriptor Size */
+#define AVE_TXDM_320x1000  /* Tx Descriptor Memory */
+#define AVE_RXDM_320x1800  /* Rx Descriptor Memory */
+
+/* RMII Bridge Register Group */
+#define AVE_RSTCTRL0x8028  /* Reset control */
+#define AVE_RSTCTRL_RMIIRSTBIT(16)
+#define AVE_LINKSEL0x8034  /* Link speed setting */
+#define AVE_LINKSEL_100M   BIT(0)
+
+/* AVE_GRR */
+#define AVE_GRR_PHYRST BIT(4)  /* Reset external PHY */
+#define AVE_GRR_GRST   BIT(0)  /* Reset all MAC */
+
+/* AVE_CFGR */
+#define AVE_CFGR_MII   BIT(27) /* Func mode (1:MII/RMII, 0:RGMII) */
+
+/* AVE_GISR (common with GIMR) */
+#define AVE_GIMR_CLR   0
+#define AVE_GISR_CLR   GENMASK(31, 0)
+
+/* AVE_TXCR */
+#define AVE_TXCR_FLOCTRBIT(18) /* Flow control */
+#define AVE_TXCR_TXSPD_1G  BIT(17)
+#define AVE_TXCR_TXSPD_100 BIT(16)
+
+/* AVE_RXCR */
+#define AVE_RXCR_RXEN  BIT(30) /* Rx enable */
+#define AVE_RXCR_FDUPENBIT(22) /* Interface mode */
+#define AVE_RXCR_FLOCTRBIT(21) /* Flow control */
+
+/* AVE_MDIOCTR */
+#define AVE_M

[U-Boot] initialization to TI AM335x MII connected to Marvell's 88e6341 switch

2018-05-24 Thread Avner Flesch
Hi,


I have costume board based on Beagle Bone Black board except the networking -

instead of Ethernet PHY, we put a Marvell switch 88e6341 (The CPU port 
connected with MII).

So, I need the u-boot source modification for it (c/h files and dts files)

If someone can point me to a reference or send me the files, I will really 
appreciate it


Thanks


Avner
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/3] dts: mvebu: a80x0: Enable SD/eMMC interfaces

2018-05-24 Thread xswang
From: Konstantin Porotchkin 

Enable SDHCI interface on AP and CP0 in A80x0 DTS files

Signed-off-by: Konstantin Porotchkin 
Signed-off-by: Evan Wang 
---

 arch/arm/dts/armada-8040-db.dts| 14 ++
 arch/arm/dts/armada-8040-mcbin.dts |  8 
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/dts/armada-8040-db.dts b/arch/arm/dts/armada-8040-db.dts
index fa58995..65b30bb 100644
--- a/arch/arm/dts/armada-8040-db.dts
+++ b/arch/arm/dts/armada-8040-db.dts
@@ -81,6 +81,13 @@
 1 3 0 0 0 0 0 0 0 3 >;
 };
 
+&ap_sdhci0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&ap_emmc_pins>;
+   bus-width = <8>;
+   status = "okay";
+};
+
 &cpm_pinctl {
/* MPP Bus:
 *  [0-31]  = 0xff: Keep default CP0_shared_pins
@@ -182,6 +189,13 @@
status = "okay";
 };
 
+&cpm_sdhci0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&cpm_sdhci_pins>;
+   bus-width = <4>;
+   status = "okay";
+};
+
 &cps_pinctl {
/* MPP Bus:
 *  [0-11]  RGMII0
diff --git a/arch/arm/dts/armada-8040-mcbin.dts 
b/arch/arm/dts/armada-8040-mcbin.dts
index 991ddc0..46b32f2 100644
--- a/arch/arm/dts/armada-8040-mcbin.dts
+++ b/arch/arm/dts/armada-8040-mcbin.dts
@@ -156,6 +156,14 @@
status = "okay";
 };
 
+/* uSD slot */
+&cpm_sdhci0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&cpm_sdhci_pins>;
+   bus-width = <4>;
+   status = "okay";
+};
+
 &cpm_comphy {
/*
 * CP0 Serdes Configuration:
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/3] mvebu: pinctrl: sync compatible string with Linux 4.17-rc4

2018-05-24 Thread xswang
From: Evan Wang 

Signed-off-by: Evan Wang 
---

 arch/arm/dts/armada-ap806.dtsi   |  2 +-
 arch/arm/dts/armada-cp110-master.dtsi|  4 ++--
 arch/arm/dts/armada-cp110-slave.dtsi |  2 +-
 .../pinctrl/marvell,mvebu-pinctrl.txt| 16 
 drivers/pinctrl/mvebu/pinctrl-mvebu.c|  8 
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/dts/armada-ap806.dtsi b/arch/arm/dts/armada-ap806.dtsi
index e0d3016..ebdee51 100644
--- a/arch/arm/dts/armada-ap806.dtsi
+++ b/arch/arm/dts/armada-ap806.dtsi
@@ -141,7 +141,7 @@
};
 
ap_pinctl: ap-pinctl@6F4000 {
-   compatible = "marvell,armada-ap806-pinctrl";
+   compatible = "marvell,ap806-pinctrl";
bank-name ="apn-806";
reg = <0x6F4000 0x10>;
pin-count = <20>;
diff --git a/arch/arm/dts/armada-cp110-master.dtsi 
b/arch/arm/dts/armada-cp110-master.dtsi
index 8c336f2..551d00d 100644
--- a/arch/arm/dts/armada-cp110-master.dtsi
+++ b/arch/arm/dts/armada-cp110-master.dtsi
@@ -120,8 +120,8 @@
 
cpm_pinctl: cpm-pinctl@44 {
compatible = "marvell,mvebu-pinctrl",
-"marvell,a70x0-pinctrl",
-"marvell,a80x0-cp0-pinctrl";
+"marvell,armada-7k-pinctrl",
+"marvell,armada-8k-cpm-pinctrl";
bank-name ="cp0-110";
reg = <0x44 0x20>;
pin-count = <63>;
diff --git a/arch/arm/dts/armada-cp110-slave.dtsi 
b/arch/arm/dts/armada-cp110-slave.dtsi
index 0cdb3d3..2ea9004 100644
--- a/arch/arm/dts/armada-cp110-slave.dtsi
+++ b/arch/arm/dts/armada-cp110-slave.dtsi
@@ -120,7 +120,7 @@
 
cps_pinctl: cps-pinctl@44 {
compatible = "marvell,mvebu-pinctrl",
-"marvell,a80x0-cp1-pinctrl";
+"marvell,armada-8k-cps-pinctrl";
bank-name ="cp1-110";
reg = <0x44 0x20>;
pin-count = <63>;
diff --git a/doc/device-tree-bindings/pinctrl/marvell,mvebu-pinctrl.txt 
b/doc/device-tree-bindings/pinctrl/marvell,mvebu-pinctrl.txt
index 5f86c0a..1fc1bc6 100644
--- a/doc/device-tree-bindings/pinctrl/marvell,mvebu-pinctrl.txt
+++ b/doc/device-tree-bindings/pinctrl/marvell,mvebu-pinctrl.txt
@@ -6,10 +6,10 @@ mpp pins or group of pins and a mpp function common to all 
pins.
 
 Required properties for the pinctrl driver:
 - compatible:  "marvell,mvebu-pinctrl",
-   "marvell,armada-ap806-pinctrl",
-   "marvell,a70x0-pinctrl",
-   "marvell,a80x0-cp0-pinctrl",
-   "marvell,a80x0-cp1-pinctrl"
+   "marvell,ap806-pinctrl",
+   "marvell,armada-7k-pinctrl",
+   "marvell,armada-8k-cpm-pinctrl",
+   "marvell,armada-8k-cps-pinctrl"
 - bank-name:   A string defining the pinc controller bank name
 - reg: A pair of values defining the pin controller base 
address
and the address space
@@ -31,7 +31,7 @@ Example:
config-space {
pinctl: pinctl@6F4000 {
compatible = "marvell,mvebu-pinctrl",
-"marvell,armada-ap806-pinctrl";
+"marvell,ap806-pinctrl";
bank-name ="apn-806";
reg = <0x6F4000 0x10>;
pin-count = <20>;
@@ -52,8 +52,8 @@ Example:
config-space {
cpm_pinctl: pinctl@44000 {
compatible = "marvell,mvebu-pinctrl",
-"marvell,a70x0-pinctrl",
-"marvell,a80x0-cp0-pinctrl";
+"marvell,armada-7k-pinctrl",
+"marvell,armada-8k-cpm-pinctrl";
bank-name ="cp0-110";
reg = <0x44 0x20>;
pin-count = <63>;
@@ -89,7 +89,7 @@ Example:
config-space {
cps_pinctl: pinctl@44000 {
compatible = "marvell,mvebu-pinctrl",
-"marvell,a80x0-cp1-pinctrl";
+"marvell,armada-8k-cps-pinctrl";
  

[U-Boot] [PATCH 2/3] mvebu: pinctrl: Add SD/eMMC PHY selector to the driver

2018-05-24 Thread xswang
From: Konstantin Porotchkin 

When the pin control driver selects SD/eMMC function for
a pin group, there is additional configuration to be done
for this case - switch the PHY to work with SDHCI interface.
This patch adds the missing functionality into the pin
control driver.

Signed-off-by: Konstantin Porotchkin 
Signed-off-by: Evan Wang 
---

 drivers/pinctrl/mvebu/pinctrl-mvebu.c | 59 +--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c 
b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index 556bf78..7d8a0b0 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -17,8 +17,48 @@
 #include 
 #include "pinctrl-mvebu.h"
 
+#define AP_EMMC_PHY_CTRL_REG   0x100
+#define CP_EMMC_PHY_CTRL_REG   0x424
+#define EMMC_PHY_CTRL_SDPHY_EN BIT(0)
+
+#define AP806_EMMC_CLK_PIN_ID  0
+#define AP806_EMMC_CLK_FUNC0x1
+#define CP110_EMMC_CLK_PIN_ID  56
+#define CP110_EMMC_CLK_FUNC0xe
+
 DECLARE_GLOBAL_DATA_PTR;
 
+/* mvebu_pinctl_emmc_set_mux: configure sd/mmc PHY mux
+ * To enable SDIO/eMMC in Armada-APN806/CP110, need to configure PHY mux.
+ * eMMC/SD PHY register responsible for muxing between MPPs and SD/eMMC
+ * controller:
+ * - Bit0 enabled SDIO/eMMC PHY is used as a MPP muxltiplexer,
+ * - Bit0 disabled SDIO/eMMC PHY is connected to SDIO/eMMC controller
+ * If pin function is set to eMMC/SD, then configure the eMMC/SD PHY
+ * muxltiplexer register to be on SDIO/eMMC controller
+ */
+void mvebu_pinctl_emmc_set_mux(struct udevice *dev, u32 pin, u32 func)
+{
+   const void *blob = gd->fdt_blob;
+   int node = dev_of_offset(dev);
+   struct mvebu_pinctrl_priv *priv = dev_get_priv(dev);
+
+   if (!fdt_node_check_compatible(blob, node, "marvell,ap806-pinctrl")) {
+   if ((pin == AP806_EMMC_CLK_PIN_ID) &&
+   (func == AP806_EMMC_CLK_FUNC)) {
+   clrbits_le32(priv->base_reg + AP_EMMC_PHY_CTRL_REG,
+EMMC_PHY_CTRL_SDPHY_EN);
+   }
+   } else if (!fdt_node_check_compatible(blob, node,
+   "marvell,armada-8k-cpm-pinctrl")) {
+   if ((pin == CP110_EMMC_CLK_PIN_ID) &&
+   (func == CP110_EMMC_CLK_FUNC)) {
+   clrbits_le32(priv->base_reg + CP_EMMC_PHY_CTRL_REG,
+EMMC_PHY_CTRL_SDPHY_EN);
+   }
+   }
+}
+
 /*
  * mvebu_pinctrl_set_state: configure pin functions.
  * @dev: the pinctrl device to be configured.
@@ -48,9 +88,16 @@ int mvebu_pinctrl_set_state(struct udevice *dev, struct 
udevice *config)
 
function = fdtdec_get_int(blob, node, "marvell,function", 0xff);
 
+   /*
+* Check if setup of PHY mux is needed for this pins group.
+* Only the first pin id in array is tested, all the rest use the same
+* pin function.
+*/
+   mvebu_pinctl_emmc_set_mux(dev, pin_arr[0], function);
+
for (i = 0; i < pin_count; i++) {
-   int reg_offset;
-   int field_offset;
+   int reg_offset;
+   int field_offset;
int pin = pin_arr[i];
 
if (function > priv->max_func) {
@@ -97,6 +144,14 @@ static int mvebu_pinctrl_set_state_all(struct udevice *dev,
return -EINVAL;
}
 
+   /* Check if setup of PHY mux is needed for this pins group. */
+   if (priv->pin_cnt < CP110_EMMC_CLK_PIN_ID)
+   mvebu_pinctl_emmc_set_mux(dev, AP806_EMMC_CLK_PIN_ID,
+ func_arr[AP806_EMMC_CLK_PIN_ID]);
+   else
+   mvebu_pinctl_emmc_set_mux(dev, CP110_EMMC_CLK_PIN_ID,
+ func_arr[CP110_EMMC_CLK_PIN_ID]);
+
for (pin = 0; pin < priv->pin_cnt; pin++) {
int reg_offset;
int field_offset;
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] rpi: Adjust fdt_addr_r to a sane address

2018-05-24 Thread Tuomas Tynkkynen
Hi Alexander,

On Thu, 24 May 2018 10:12:54 +0200
Alexander Graf  wrote:

> On 14.04.18 20:04, Tuomas Tynkkynen wrote:
> > Hi Alexander,
> > 
> > On Fri, 13 Apr 2018 17:49:00 +0200
> > Alexander Graf  wrote:
> > 
> > [...]  
> >>
> >> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
> >> index 325e52a019..fcf7e0976b 100644
> >> --- a/include/configs/rpi.h
> >> +++ b/include/configs/rpi.h
> >> @@ -124,7 +124,7 @@
> >>  #define ENV_MEM_LAYOUT_SETTINGS \
> >>"fdt_high=\0" \
> >>"initrd_high=\0" \
> >> -  "fdt_addr_r=0x0100\0" \
> >> +  "fdt_addr_r=0x01f0\0" \
> >>"pxefile_addr_r=0x0010\0" \
> >>"kernel_addr_r=0x0100\0" \
> >>"scriptaddr=0x0200\0" \  
> > 
> > Note that above the #define is a larger comment block that needs to be
> > updated as well. Also the other addresses also need updatingfor bigger
> > kernels on AArch64: https://patchwork.ozlabs.org/patch/25/
> > 
> > Though now I double-checked that the smallest possible GPU-CPU memory
> > split is actually 64MB for the CPU, not 128M. So maybe something like:
> > 
> >  "kernel_addr_r=0x0008\0" \
> >  "fdt_addr_r=0x0240\0" \
> >  "scriptaddr=0x0250\0" \
> >  "pxefile_addr_r=0x0260\0" \
> >  "ramdisk_addr_r=0x0270\0"
> > 
> > which would allow a kernel up to 36M, 1M for dtb, script and pxe files
> > each, and at least 25M for the initrd. Also I think giving up with the
> > constraint of locating the zImage high enough so that the kernel
> > decompressor doesn't need to relocate itself can be dropped. If the
> > boot speed of their Raspi matters that much, probably they wouldn't use
> > U-Boot in the first place.
> > 
> > What is the address that the RPi firmware loads its device tree to? I
> > hope that we don't have to worry about the positioning of that too...  
> 
> U-Boot> bdinfo
> arch_number = 0x
> boot_params = 0x0100
> DRAM bank   = 0x
> -> start= 0x
> -> size = 0x3B40  
> baudrate= 115200 bps
> TLB addr= 0x3B3F
> relocaddr   = 0x3B348000
> reloc off   = 0x3B2C8000
> irq_sp  = 0x3AF3E120
> sp start= 0x3AF3E120
> Early malloc usage: 138 / 2000
> fdt_blob = 3af3e130
> U-Boot> print fdt_addr
> fdt_addr=2effb300
> 
> So on boot the DT passed into U-Boot is either at ~750MB or close to the
> top. I can't quite find any code that explains the difference in the two
> variables. Either way, I guess firmware tries to put it reasonably high?

I believe fdt_addr is what is passed to the kernel and fdt_blob is what
U-Boot's device model is using.

> So as long as we keep the load addresses low enough, we should be safe.

Good.

> Also fyi, I would like to switch to CONFIG_OF_BOARD by default, once I
> added code that marks u-boot.bin as an "upstream kernel" for the RPi
> firmware, because then newer RPi firmwares will pass us a fully upstream
> compatible device tree [1] which we can then pass on to Linux as default.

Makes sense, but I guess needs some documentation. Also for existing things
like whether enable_uart=1 is needed or not.

> 
> Alex
> 
> [1] https://github.com/raspberrypi/firmware/issues/943

Thanks,
Tuomas
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Exception Level switching seems broken on RK3399

2018-05-24 Thread Dr. Philipp Tomsich
Vincente,

> On 19 May 2018, at 16:58, Vicente Bergas  wrote:
> 
> Hello,
> I am writing this from a standalone Sapphire board [1],
> that is, without the Excavator base board.
> The CPU is the Rockchip RK3399, which implements ARMv8.0-A.
> 
> Currently the boot process is:
> 1.- Boot ROM
> 2.- SPL, provided as closed source binary blob [2]

SPL-support is available in mainline U-Boot.  We developed this for
the RK3399-Q7 and it has been successfully used on other RK3399
boards (e.g. I know that some Firefly-users are using this).

> 3.- ATF, closed source binary blob [3]
> (not using the one from [2] because of stability issues)

Why use the closed-source blob, if the RK3399 is supported in the ATF
mainline and an ATF can be compiled from source?

> 4.- Mainline u-boot, master branch
> 5.- Mainline linux, master branch
> 
> I would like to use an opensource boot process.
> As a first approach I try to completely remove the ATF and
> replace the SPL with the one from u-boot.
> The modified boot process looks like:
> 1.- Boot ROM
> 2.- SPL, from mainline u-boot, master branch
> 3.- Mainline u-boot, master branch
> 4.- Mainline linux, master branch
> But it is not working.
> 
> The replaced SPL works fine and loads u-boot.
> U-boot also works fine, loads linux and jumps into it.

Yes, we’ve done some work to enable us to run U-Boot in EL3 on
the RK3399 (as we use it for programming the secure e-fuses on
the RK3399-Q7 in our factory programming setup).

> But then, linux never gets executed.
> 
> I have traced the issue to: arch/arm/include/asm/macro.h
> 202: msr  spsr_el3, \tmp
> 203: msr  elr_el3, \ep
> 204: eret // This is the last instruction executed
> 
> For testing, I have also set CONFIG_ARMV8_SWITCH_TO_EL1 and
> checked that switch_to_el1 from arch/arm/lib/bootm.c is not reached.
> 
> At this point I have a few questions:
> 1.- Is my first approach feasible? That is, is it possible to boot
> this CPU without ATF?

It is feasible (i.e.: requires implementation work) but not recommended:
Linux will use PSCI to bring up the secondary CPUs.  We have run Linux
(limited to a single CPU) in EL3 on this CPU during our own board bringup,
but I would strongly discourage this as it will entail unnecessary effort.

> 2.- If so, what should I do to make it work? Probably it is just
> a configuration issue, but I do not know what to check. [4]
> 3.- Else, why do I need ATF?

ATF is the secure monitor on ARMv8 and provides services such as PSCI
to start up secondary CPUs.  It will usually also be part of power-management
on most SoCs (after all: power configuration needs to be done in the secure
envelope).

Regards,
Philipp.

> 
> Regards,
>  Vicenç.
> 
> [1] http://opensource.rock-chips.com/wiki_Excavator_sapphire_board
> [2] https://github.com/rockchip-linux/rkbin/tree/29mirror
> [3] 
> https://raw.githubusercontent.com/nightseas/armbian-build/master/packages/blobs/rockchip64/trust.img
> [4]
> CONFIG_ARM=y
> CONFIG_ARCH_ROCKCHIP=y
> CONFIG_SYS_TEXT_BASE=0x0020
> CONFIG_SPL_LIBCOMMON_SUPPORT=y
> CONFIG_SPL_LIBGENERIC_SUPPORT=y
> CONFIG_SYS_MALLOC_F_LEN=0x4000
> CONFIG_ROCKCHIP_RK3399=y
> CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x4000
> CONFIG_SPL_STACK_R_ADDR=0x8
> # CONFIG_PSCI_RESET is not set
> CONFIG_CMD_HDMIDETECT=y
> CONFIG_DEFAULT_DEVICE_TREE="rk3399-evb"
> CONFIG_DEBUG_UART=y
> CONFIG_BOOTDELAY=1
> # CONFIG_DISPLAY_CPUINFO is not set
> # CONFIG_DISPLAY_BOARDINFO is not set
> CONFIG_SPL_STACK_R=y
> CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x4000
> # CONFIG_CMD_IMI is not set
> # CONFIG_CMD_XIMG is not set
> # CONFIG_CMD_SAVEENV is not set
> # CONFIG_CMD_FLASH is not set
> # CONFIG_CMD_LOADB is not set
> # CONFIG_CMD_LOADS is not set
> CONFIG_CMD_MMC=y
> CONFIG_CMD_USB=y
> # CONFIG_CMD_SETEXPR is not set
> # CONFIG_CMD_NET is not set
> # CONFIG_DOS_PARTITION is not set
> # CONFIG_ISO_PARTITION is not set
> CONFIG_SPL_OF_CONTROL=y
> CONFIG_REGMAP=y
> CONFIG_SPL_REGMAP=y
> CONFIG_SYSCON=y
> CONFIG_SPL_SYSCON=y
> CONFIG_CLK=y
> CONFIG_SPL_CLK=y
> CONFIG_ROCKCHIP_GPIO=y
> CONFIG_SYS_I2C_ROCKCHIP=y
> # CONFIG_MMC_WRITE is not set
> # CONFIG_MMC_HW_PARTITIONING is not set
> CONFIG_MMC_DW=y
> CONFIG_MMC_SDHCI=y
> CONFIG_MMC_SDHCI_ROCKCHIP=y
> CONFIG_DM_ETH=y
> # CONFIG_NETDEVICES is not set
> CONFIG_PINCTRL=y
> CONFIG_SPL_PINCTRL=y
> CONFIG_PINCTRL_ROCKCHIP_RK3399=y
> CONFIG_DM_PMIC=y
> CONFIG_PMIC_RK8XX=y
> CONFIG_REGULATOR_PWM=y
> CONFIG_DM_REGULATOR_FIXED=y
> CONFIG_REGULATOR_RK8XX=y
> CONFIG_PWM_ROCKCHIP=y
> CONFIG_RAM=y
> CONFIG_SPL_RAM=y
> CONFIG_BAUDRATE=150
> CONFIG_DEBUG_UART_BASE=0xFF1A
> CONFIG_DEBUG_UART_CLOCK=2400
> CONFIG_DEBUG_UART_SHIFT=2
> CONFIG_SYSRESET=y
> CONFIG_USB=y
> CONFIG_USB_XHCI_HCD=y
> CONFIG_USB_XHCI_DWC3=y
> CONFIG_USB_EHCI_HCD=y
> CONFIG_USB_EHCI_GENERIC=y
> CONFIG_USB_STORAGE=y
> CONFIG_USB_KEYBOARD=y
> CONFIG_USB_HOST_ETHER=y
> CONFIG_USB_ETHER_ASIX=y
> CONFIG_USB_ETHER_ASIX88179=y
> CONFIG_USB_ETHER_MCS7830=y
> CONFIG_USB_ETHER_RTL8152=y
> CONFIG_USB_ETHER_SMS

Re: [U-Boot] [PATCH V3 1/2] mmc: add HS400 support

2018-05-24 Thread Peng Fan
Hi Fabio,

> -Original Message-
> From: Fabio Estevam [mailto:feste...@gmail.com]
> Sent: 2018年5月19日 22:39
> To: Peng Fan 
> Cc: Jaehoon Chung ; Kishon Vijay Abraham I
> ; U-Boot-Denx 
> Subject: Re: [U-Boot] [PATCH V3 1/2] mmc: add HS400 support
> 
> On Sat, May 19, 2018 at 9:54 AM, Peng Fan  wrote:
> > Add HS400 support.
> > Selecting HS400 needs first select HS199 according to spec, so use
> 
> I think you meant HS200 instead?
Yes HS200, thanks.

Jaehoon, would you mind help fix the typo if no more comments?

Thanks,
Peng.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 04/16] sandbox: smbios: Update to support sandbox

2018-05-24 Thread Alexander Graf


On 16.05.18 17:42, Simon Glass wrote:
> At present this code casts addresses to pointers so cannot be used with
> sandbox. Update it to use mapmem instead.
> 
> Signed-off-by: Simon Glass 

I really dislike the whole fact that you have to call map_sysmem() at
all. I don't quite understand the whole point of it either - it just
seems to clutter the code and make it harder to follow.

Can't we just simply make sandbox behave like any other target instead?


Alex
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 07/16] efi: sandbox: Add distroboot support

2018-05-24 Thread Alexander Graf


On 16.05.18 17:42, Simon Glass wrote:
> With sandbox these values depend on the host system. Let's assume that it
> is x86_64 for now.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  include/config_distro_bootcmd.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> index 8d5feb3ac77..97d6baab4be 100644
> --- a/include/config_distro_bootcmd.h
> +++ b/include/config_distro_bootcmd.h
> @@ -246,7 +246,7 @@
>  #elif defined(CONFIG_ARM)
>  #define BOOTENV_EFI_PXE_ARCH "0xa"
>  #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000"
> -#elif defined(CONFIG_X86)
> +#elif defined(CONFIG_X86) || defined(CONFIG_SANDBOX)

Why not

#elif defined(CONFIG_X86) || (defined(CONFIG_SANDBOX) &&
defined(__x86_64__))

and similar for other architectures? That way we should be quite safe in
determining our target architecture, no?


Alex

>  /* Always assume we're running 64bit */
>  #define BOOTENV_EFI_PXE_ARCH "0x7"
>  #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:7:UNDI:003000"
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 10/16] efi: sandbox: Add relocation constants

2018-05-24 Thread Alexander Graf


On 16.05.18 17:42, Simon Glass wrote:
> Add these so that we can build the EFI loader for sandbox. The values are
> for x86_64 so potentially bogus. But we don't support relocation within
> sandbox anyway.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  lib/efi_loader/efi_runtime.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 52f1301d75b..ac02f64d967 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -47,6 +47,9 @@ static efi_status_t __efi_runtime EFIAPI 
> efi_invalid_parameter(void);
>  #include 
>  #define R_RELATIVE   R_386_RELATIVE
>  #define R_MASK   0xffULL
> +#elif defined(CONFIG_SANDBOX)

Same comment applies here, just change the ifdef above to match on
defined(__x86_64__) && defined(CONFIG_SANDBOX)


Alex

> +#define R_RELATIVE   8
> +#define R_MASK   0xULL
>  #else
>  #error Need to add relocation awareness
>  #endif
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] regmap: Separate memory-based operations

2018-05-24 Thread Alexey Brodkin
One of important features of regmap [at least in Linux kernel]
is an ability to seamlessly communicate to devices connected
via different buses like: MMIO, SPI, I2C and many others.

Current implementation in U-Boot only supports memory-mapped registers
which is a vere valid case but we'll need more in the future.

This change paves the way for support of other buses. Still all existing
users of regmap in U-Boot shouldn't be affected because for now we don't
change API which might be required once we start adding support of more
complicated cases like 8/16/32/64-bit accessors, big- and little-endian
flavours etc.

It was inspired by discussion [1] of addition of even more accessors to
a standard 16550 UART.

[1] https://lists.denx.de/pipermail/u-boot/2018-March/322322.html

Signed-off-by: Alexey Brodkin 
Cc: Simon Glass 
---
 drivers/core/Makefile   |  2 +-
 drivers/core/{regmap.c => regmap-mem.c} | 79 ++-
 drivers/core/regmap.c   | 85 +
 include/regmap.h|  9 +++
 4 files changed, 31 insertions(+), 144 deletions(-)
 copy drivers/core/{regmap.c => regmap-mem.c} (60%)

diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index a5039c5bd311..ce9b32600e97 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -9,7 +9,7 @@ obj-$(CONFIG_DEVRES) += devres.o
 obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE)  += device-remove.o
 obj-$(CONFIG_$(SPL_)SIMPLE_BUS)+= simple-bus.o
 obj-$(CONFIG_DM)   += dump.o
-obj-$(CONFIG_$(SPL_TPL_)REGMAP)+= regmap.o
+obj-$(CONFIG_$(SPL_TPL_)REGMAP)+= regmap.o regmap-mem.o
 obj-$(CONFIG_$(SPL_TPL_)SYSCON)+= syscon-uclass.o
 obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o
 ifndef CONFIG_DM_DEV_READ_INLINE
diff --git a/drivers/core/regmap.c b/drivers/core/regmap-mem.c
similarity index 60%
copy from drivers/core/regmap.c
copy to drivers/core/regmap-mem.c
index 8a0e00ff9aa6..e252794d553d 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap-mem.c
@@ -1,42 +1,34 @@
 /*
- * Copyright (c) 2015 Google, Inc
- * Written by Simon Glass 
+ * Copyright (c) 2018 Synopsys, Inc
+ * Written by Simon Glass  and
+ *Alexey Brodkin 
  *
  * SPDX-License-Identifier:GPL-2.0+
  */
 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
-DECLARE_GLOBAL_DATA_PTR;
+int regmap_mem_read(struct regmap *map, uint offset, uint *valp)
+{
+   u32 *ptr = map_physmem(map->base + offset, sizeof(u32), MAP_NOCACHE);
+
+   *valp = le32_to_cpu(readl(ptr));
+
+   return 0;
+}
 
-static struct regmap *regmap_alloc_count(int count)
+int regmap_mem_write(struct regmap *map, uint offset, uint val)
 {
-   struct regmap *map;
+   u32 *ptr = map_physmem(map->base + offset, sizeof(u32), MAP_NOCACHE);
 
-   map = malloc(sizeof(struct regmap));
-   if (!map)
-   return NULL;
-   if (count <= 1) {
-   map->range = &map->base_range;
-   } else {
-   map->range = malloc(count * sizeof(struct regmap_range));
-   if (!map->range) {
-   free(map);
-   return NULL;
-   }
-   }
-   map->range_count = count;
+   writel(cpu_to_le32(val), ptr);
 
-   return map;
+   return 0;
 }
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
@@ -91,6 +83,7 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
for (range = map->range, index = 0; count > 0;
 count--, range++, index++) {
fdt_size_t sz;
+
if (of_live_active()) {
of_address_to_resource(ofnode_to_np(node), index, &r);
range->start = r.start;
@@ -103,47 +96,11 @@ int regmap_init_mem(struct udevice *dev, struct regmap 
**mapp)
}
}
map->base = map->range[0].start;
+   map->reg_read = regmap_mem_read;
+   map->reg_write = regmap_mem_write;
 
*mapp = map;
 
return 0;
 }
 #endif
-
-void *regmap_get_range(struct regmap *map, unsigned int range_num)
-{
-   struct regmap_range *range;
-
-   if (range_num >= map->range_count)
-   return NULL;
-   range = &map->range[range_num];
-
-   return map_sysmem(range->start, range->size);
-}
-
-int regmap_uninit(struct regmap *map)
-{
-   if (map->range_count > 1)
-   free(map->range);
-   free(map);
-
-   return 0;
-}
-
-int regmap_read(struct regmap *map, uint offset, uint *valp)
-{
-   uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE);
-
-   *valp = le32_to_cpu(readl(ptr));
-
-   return 0;
-}
-
-int regmap_write(struct regmap *map, uint offset, uint val)
-{
-   uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE);
-
-   writel(cpu_to_le32(val), ptr);
-
-   return 0;
-}
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 8a0e00ff9a

Re: [U-Boot] [U-Boot, v3, 1/3] mmc: dwmmc: socfpga: Add reset ctrl to driver

2018-05-24 Thread Tom Rini
On Tue, May 08, 2018 at 11:19:24AM +0800, Ley Foon Tan wrote:

> Add code to reset all reset signals as in mmc DT node. A reset property is an 
> optional feature,
> so only print out a warning and do not fail if a reset property is not 
> present.
> 
> If a reset property is discovered, then use it to deassert, thus bringing the
> IP out of reset.
> 
> Signed-off-by: Ley Foon Tan 
> Reviewed-by: Simon Glass 
> ---
>  drivers/mmc/socfpga_dw_mmc.c |   17 +
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
> index fa0e449..eb7e64e 100644
> --- a/drivers/mmc/socfpga_dw_mmc.c
> +++ b/drivers/mmc/socfpga_dw_mmc.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -33,6 +34,20 @@ struct dwmci_socfpga_priv_data {
>   unsigned intsmplsel;
>  };
>  
> +static void socfpga_dwmci_reset(struct udevice *dev)
> +{
> + struct reset_ctl_bulk reset_bulk;
> + int ret;
> +
> + ret = reset_get_bulk(dev, &reset_bulk);
> + if (ret) {
> + dev_warn(dev, "Can't get reset: %d\n", ret);
> + return;
> + }
> +
> + reset_deassert_bulk(&reset_bulk);
> +}

The driver doesn't depend on DM_RESET and this code hunk doesn't either
so it fails to build on a number of platforms.  This type of comment
applies to the whole series, and may be fixed differently in different
cases (it might be OK to enforce DM_RESET for this driver, but not for
the ns16550 driver).

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 00/16] efi: Enable basic sandbox support for EFI loader

2018-05-24 Thread Alexander Graf


On 16.05.18 17:42, Simon Glass wrote:
> A limitation of the EFI loader at present is that it does not build with
> sandbox. This makes it hard to write tests, since sandbox is used for most
> testing in U-Boot.
> 
> This series enables the EFI loader feature. It allows sandbox to build and
> run a trivial function which calls the EFI API to output a message.
> 
> This series is at u-boot-dm/efi-working

I've picked a few patches that were obviously correct and made sense.
Overall, I think we should allow for real UEFI binaries to run in
sandbox and the only way to get there is to have sandboxed U-Boot live
in the same address space as what it thinks it lives in.

For the selftest bits I'd like to see acks from Heinrich, so I didn't
pick those up yet. They seem to make good sense to me though.


Alex
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] arm: armv7m: Clean up some thumb / compiler flag options

2018-05-24 Thread Tom Rini
On Mon, May 07, 2018 at 08:46:52PM -0400, Tom Rini wrote:

> - The correct way to build with thumb mode is to select SYS_THUMB_BUILD
> - We should be setting -march=armv7-m in arch/arm/Makefile not the
>   sub-config.mk file.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Convert CONFIG_SUPPORT_EMMC_RPMB to Kconfig

2018-05-24 Thread Tom Rini
On Tue, May 08, 2018 at 04:43:31AM +, Alex Kiernan wrote:

> Convert CONFIG_SUPPORT_EMMC_RPMB to Kconfig. Split the command handling
> from the underlying support and expose this through CMD_MMC_RPMB.
> 
> Signed-off-by: Alex Kiernan 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,3/3] i2c: Drop CONFIG_SH_SH7734_I2C

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 03:24:35PM +0300, Tuomas Tynkkynen wrote:

> Last user of this driver went away in May 2017 in commit
> eb5ba3aefdf0f6c ("i2c: Drop use of CONFIG_I2C_HARD").
> 
> Signed-off-by: Tuomas Tynkkynen 
> Acked-by: Heiko Schocher 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/3] configs: at91: Adjust CONFIG_ENV_OFFSET to match sama5 address

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 10:30:25AM +0300, Eugen Hristev wrote:

> From: Nicolas Ferre 
> 
> In order to have a single ENV_OFFSET to manage, use the same as the sama5 one.
> This address matches our NAND flash map available at:
> http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d3XplainedMainPage#NAND_Flash_demo_Memory_map
> 
> Signed-off-by: Nicolas Ferre 
> [eugen.hris...@microchip.com: rework on latest version of u-boot]
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] clk: at91: clk-h32mx: replace dm_warn with dev_dbg

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 10:58:30AM +0300, Eugen Hristev wrote:

> dm_warn is too noisy, replace with dev_dbg for less noise.
> 
> Based on original work by Wenyou Yang
> 
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] configs: sama5d2_xplained: enable ext4 command support

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 01:08:01PM +0300, Eugen Hristev wrote:

> To support loading the zImage + DTB from the rootfs ext4 partitions,
> enable the ext4 command support.
> 
> Based on original work by Wenyou Yang
> 
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] spl: Add full fitImage support

2018-05-24 Thread Tom Rini
On Sun, May 13, 2018 at 12:23:17AM +0200, Marek Vasut wrote:

> Add support for loading U-Boot and optionally FDT from a fitImage
> in SPL by using the full fitImage support from U-Boot. While we do
> have limited SPL loading support in SPL with a small footprint, it
> is missing a lot of important features, like checking signatures.
> This support has all the fitImage features, while the footprint is
> obviously larger.
> 
> Signed-off-by: Marek Vasut 
> Cc: Pantelis Antoniou 
> Cc: Simon Glass 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] twister: Let SPL load U-Boot from MMC

2018-05-24 Thread Tom Rini
On Mon, May 14, 2018 at 09:17:45AM +0200, Ladislav Michl wrote:

> MMC is not initialized in SPL, so it cannot load u-boot.img
> preventing boot from MMC.
> 
> Also driver specific functions are guarded with generic
> configuration options which leads to build failures when device
> driver is not enabled in config. Fix that by using driver
> specific defines.
> 
> Signed-off-by: Ladislav Michl 
> Acked-by: Stefano Babic 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] FIT: Make fit_conf_print() be a static function

2018-05-24 Thread Tom Rini
On Tue, May 08, 2018 at 02:34:05PM -0400, Tom Rini wrote:

> We only call fit_conf_print from one place in the code, so mark it as
> static and move it up to where we call it.  This in turn has us move a
> few other already static functions up further as well.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [uboot-snps-arc] [PATCH 0/3] Improvements for ARC UART

2018-05-24 Thread Alexey Brodkin
Hi Tom,

On Mon, 2018-05-21 at 17:03 +0300, Alexey Brodkin wrote:
>  * Move ARC_SERIAL to Kconfig
>  * Implement DEBUG_SERIAL in ARC_UART and
>  * Enable DEBUG_UART in nSIM boards
> 
> Alexey Brodkin (3):
>   serial: Convert ARC_SERIAL to Kconfig
>   serial/serial_arc: Implement debug serial
>   ARC: Enable debug UART on nSIM boards
> 
>  configs/nsim_700_defconfig|  5 +
>  configs/nsim_700be_defconfig  |  5 +
>  configs/nsim_hs38_defconfig   |  5 +
>  configs/nsim_hs38be_defconfig |  5 +
>  drivers/serial/Kconfig| 16 
>  drivers/serial/serial_arc.c   | 26 ++
>  include/configs/nsim.h| 10 --
>  scripts/config_whitelist.txt  |  1 -
>  8 files changed, 62 insertions(+), 11 deletions(-)

Do you want to pull this series yourself or I may push it
via my tree (in which case I'll add another similar series
from Eugeniy, see
https://patchwork.ozlabs.org/project/uboot/list/?series=42321
which BTW is a pre-requisite because of generic ARC fixup in
https://patchwork.ozlabs.org/patch/907993/).

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v4, 05/16] sandbox: Add a setjmp() implementation

2018-05-24 Thread Alexander Graf
> Add an implementation of setjmp() and longjmp() which rely on the
> underlying host C library. Since we cannot know how large the jump buffer
> needs to be, pick something that should be suitable and check it at
> runtime. At present we need access to the underlying struct as well.
> 
> Signed-off-by: Simon Glass 

Thanks, applied to efi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,v2,1/2] fs: ext4: fix crash on ext4ls

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 04:28:37PM +0300, Eugen Hristev wrote:

> Found a crash while issuing ext4ls with a non-existent directory.
> Crash test:
> 
> => ext4ls mmc 0 1
> ** Can not find directory. **
> data abort
> pc : [<3fd7c2ec>]  lr : [<3fd93ed8>]
> reloc pc : [<26f142ec>]lr : [<26f2bed8>]
> sp : 3f963338  ip : 3fdc3dc4 fp : 3fd6b370
> r10: 0004  r9 : 3f967ec0 r8 : 3f96db68
> r7 : 3fdc99b4  r6 :  r5 : 3f96dc88  r4 : 3fdcbc8c
> r3 : fffa  r2 :  r1 : 3f96e0bc  r0 : 0002
> Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
> Resetting CPU ...
> 
> resetting ...
> 
> Tested on SAMA5D2_Xplained board (sama5d2_xplained_mmc_defconfig)
> 
> Looks like crash is introduced by commit:
> "fa9ca8a" fs/ext4/ext4fs.c: Free dirnode in error path of ext4fs_ls
> 
> Issue is that dirnode is not initialized, and then freed if the call
> to ext4_ls fails. ext4_ls will not change the value of dirnode in this case
> thus we have a crash with data abort.
> 
> I added initialization and a check for dirname being NULL.
> 
> Fixes: "fa9ca8a" fs/ext4/ext4fs.c: Free dirnode in error path of ext4fs_ls
> Cc: Stefan Brüns 
> Cc: Tom Rini 
> Signed-off-by: Eugen Hristev 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v4, 08/16] Define board_quiesce_devices() in a shared location

2018-05-24 Thread Alexander Graf
> This undocumented function relies on arch-specific code to declare a nop
> weak version. Add the weak function in common code instead to avoid having
> to duplicate the same function in each arch.
> 
> Signed-off-by: Simon Glass 

Thanks, applied to efi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,v3,2/2] scripts: add decodecode from Linux

2018-05-24 Thread Tom Rini
On Tue, May 15, 2018 at 07:42:24PM +0200, Heinrich Schuchardt wrote:

> The script decodecode can be used to disassemble the 'Code:' line  written
> when an exception occurs.
> 
> The script is copied from Linux v4.16.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,2/3] i2c: Drop CONFIG_TSI108_I2C

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 03:24:34PM +0300, Tuomas Tynkkynen wrote:

> Last user of this driver went away in June 2015 in commit
> d928664f4101e24 ("powerpc: 74xx_7xx: remove 74xx_7xx cpu support")
> 
> Signed-off-by: Tuomas Tynkkynen 
> Acked-by: Heiko Schocher 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, V2] pylibfdt: Add missing CC and LD to Makefile

2018-05-24 Thread Tom Rini
On Fri, May 18, 2018 at 09:56:53AM +0200, Marek Vasut wrote:

> Add missing CC and LDSHARED variables to the Makefile to pass the
> correct C compiler and linker path to the build of _libfdt.so .
> 
> Signed-off-by: Marek Vasut 
> Cc: Tom Rini 
> Cc: Masahiro Yamada 
> Cc: Simon Glass 
> Reviewed-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Licenses/README: Update some style and add explicit license to the document

2018-05-24 Thread Tom Rini
On Tue, May 08, 2018 at 11:34:36AM -0400, Tom Rini wrote:

> - Add an SPDX license tag to the file, saying it's GPL-2.0.
> - From the Linux Kernel v4.17-rc4, import the "License identifier
>   syntax" section as-is from Documentation/process/license-rules.rst
>   and then change it to be clearer about examples from the Linux Kernel
>   vs examples found in U-Boot, and when we're talking about U-Boot.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v2, 2/2] test: fs: fs-test: Modified test 1 to do a ls to a nonexistent dir

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 04:28:38PM +0300, Eugen Hristev wrote:

> Added a simple ls to a nonexistent directory for test 1.
> In case the driver is broken for a nonexistent directory, U-boot
> might crash.
> 
> Here is an example failed output:
> 
> => # Test Case 1 - ls
> => ext4ls host 0:0
>4096 .
>4096 ..
>   16384 lost+found
>4096 SUBDIR
>   262144 2.5GB.file
>  1048576 1MB.file
> => # In addition, test with a nonexistent directory to see if we crash.
> => ext4ls host 0:0 invalid_d
> ** Can not find directory. **
> ./test/fs/fs-test.sh: line 161: 25786 Segmentation fault  (core dumped) 
> $UBOOT  < 
> Subsequent tests will fail if U-boot crashes.
> 
> Signed-off-by: Eugen Hristev 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/3] configs: at91: sama5_common: Adjust CONFIG_ENV_OFFSET to match block alignment

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 10:30:24AM +0300, Eugen Hristev wrote:

> From: Nicolas Ferre 
> 
> Fix the unaligned environment address.
> This address matches our NAND flash map available at:
> http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d3XplainedMainPage#NAND_Flash_demo_Memory_map
> 
> Signed-off-by: Nicolas Ferre 
> [eugen.hris...@microchip.com: rework on latest version of u-boot]
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/3] fit: Fix CONFIG_FIT_SPL_PRINT

2018-05-24 Thread Tom Rini
On Sun, May 13, 2018 at 12:22:52AM +0200, Marek Vasut wrote:

> Rename CONFIG_FIT_SPL_PRINT to CONFIG_SPL_FIT_PRINT and add Kconfig
> entry for it.
> 
> Signed-off-by: Marek Vasut 
> Cc: Pantelis Antoniou 
> Cc: Simon Glass 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 3/3] configs: at91sam9x5ek: updated mtdparts variable in bootargs

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 10:30:26AM +0300, Eugen Hristev wrote:

> We have a new demo layout of our sama5 boards for the NAND Flash
> memory.
> According to this new layout, adjust the mtdparts variable in bootargs
> to align with this, which is available at :
> http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d3XplainedMainPage#NAND_Flash_demo_Memory_map,
> 
> Based on original work by Wenyou Yang
> 
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] arm64: timer: Create timer_get_bootus for bootstage support

2018-05-24 Thread Tom Rini
On Tue, May 15, 2018 at 04:47:02PM +0200, Michal Simek wrote:

> Implement timer_get_boot_us() based on available functions to support
> bootstage command.
> 
> Signed-off-by: Michal Simek 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] bootcount: Add bootcount command

2018-05-24 Thread Tom Rini
On Sat, May 12, 2018 at 05:49:47AM +, Alex Kiernan wrote:

> Add a command to manipulate the bootcounter. This is useful if you can
> run device recovery from inside U-Boot and need to reset the bootcounter
> after executing that process as part of altbootcmd.
> 
> Signed-off-by: Alex Kiernan 
> Reviewed-by: Lukasz Majewski 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,v2,1/1] doc: expand README.commands

2018-05-24 Thread Tom Rini
On Thu, May 10, 2018 at 03:57:27PM +0200, Heinrich Schuchardt wrote:

> Describe U_BOOT_CMD_COMPLETE.
> Describe the arguments of U_BOOT_CMD and U_BOOT_CMD_COMPLETE.
> Describe the arguments of the command function.
> Describe the arguments of the completion function.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/3] net: Drop CONFIG_TSI108_ETH

2018-05-24 Thread Tom Rini
On Wed, May 09, 2018 at 03:24:33PM +0300, Tuomas Tynkkynen wrote:

> Last user of this driver went away in June 2015 in commit
> d928664f4101e24 ("powerpc: 74xx_7xx: remove 74xx_7xx cpu support")
> 
> Signed-off-by: Tuomas Tynkkynen 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v2] Makefile: adopt --std=gnu11 for HOSTCFLAGS on Linux

2018-05-24 Thread Tom Rini
On Mon, May 14, 2018 at 03:22:06PM +0200, Philipp Tomsich wrote:

> Following the conversion of the SPDX license tags, a number of files
> compiled with -pedantic now generate warnings similar to the following
> for using C99-style '//' comments in ISO C90 code:
> 
>   tools/gen_eth_addr.c:1:1: warning: C++ style comments are not allowed in 
> ISO C90
>// SPDX-License-Identifier: GPL-2.0+
>^
> 
> The SPDX comment-style change means that these files have adopted C99,
> so need to change the language-standard to --std=gnu99 or --std=gnu11
> to let the compiler know this.
> 
> As we now require GCC 6 or newer for the cross-compiler, the project has
> implicitly moved the project to GNU11: let older GCC versions on various
> Linux distros know to treat our host tools as GNU11 as well.
> 
> References: commit 83d290c56fab ("SPDX: Convert all of our single license 
> tags to Linux Kernel style")
> Signed-off-by: Philipp Tomsich 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v4, 09/16] Add a comment for board_quiesce_devices()

2018-05-24 Thread Alexander Graf
> This exported function should have a comment describing what it does. Also
> it should really be removed in favour of device_remove(), which handles
> this sort of thing now. Add a comment with a TODO.
> 
> Signed-off-by: Simon Glass 

Thanks, applied to efi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] spl: fit: Add support for loading FPGA bitstream

2018-05-24 Thread Tom Rini
On Sat, May 12, 2018 at 10:25:28PM +0200, Marek Vasut wrote:

> Add support for loading FPGA into the SPL fitImage support. The
> mechanism is flexible and allows user to override the actual
> function for loading the FPGA itself. This is because on some
> systems, the FPGA must be programmed to allow DRAM access, so
> loading the full fitImage may not be possible if it contains
> the bitstream. Instead, the spl_load_fpga_image() provides all
> the tools to load the bitstream in parts while programming it
> into the FPGA.
> 
> Signed-off-by: Marek Vasut 
> Cc: Tom Rini 

Note that I had to drop one small hunk that had moved a conditional
informational print from an "old if we have ... set" to "always have" as
this caused SPL growth that caused other platforms to fail to link.

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v4, 06/16] efi: sandbox: Add required linker sections

2018-05-24 Thread Alexander Graf
> The EFI loader code requires certain linker sections to exist. Add these
> for sandbox so that the EFI loader code will link.
> 
> Signed-off-by: Simon Glass 

Thanks, applied to efi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/2] configs: sama5d2_xplained: set default FAT env location to SD-Card

2018-05-24 Thread Tom Rini
On Fri, May 11, 2018 at 11:14:31AM +0300, Eugen Hristev wrote:

> For sama5d2_xplained_mmc_defconfig, we have the following layout for SD-Card:
> partition 1: FAT: contains bootstrap binary (second level bootloader),
> U-boot, U-boot env, kernel, dtb
> partition 2: EXT4: Rootfs.
> 
> Add to defconfig CONFIG_ENV_FAT_DEVICE_AND_PART to have environment
> by default on SD-Card, to align with our demo layout.
> 
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v4, 02/16] efi: Update some comments related to smbios tables

2018-05-24 Thread Alexander Graf
> Clarify the operation of this code with some additional comments.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Heinrich Schuchardt 

Thanks, applied to efi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/2] configs: sama5d2_xplained: fix bootcmd/args for spi+emmc demo

2018-05-24 Thread Tom Rini
On Fri, May 11, 2018 at 11:14:32AM +0300, Eugen Hristev wrote:

> For sama5d2_xplained_spiflash_defconfig, we have the demo layout
> as presented on this link:
> http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d2XplainedMainPage#SPI_eMMC_Flash_demo_Memory_map
> 
> on SPI Flash (4 Mbyte) we have Bootstrap (second level bootloader), U-boot + 
> env
> 
> and kernel+dtb we keep on eMMC on single partition in /boot directory, 
> formatted
> with ext4.
> 
> Thus, changing the boot command to reflect this demo for the spiflash config,
> and fixing up bootargs. Sama5d2_xplained does not have NAND flash, so the
> bootargs were completely wrong.
> 
> Fixes: "5abc1a45": common: Move CONFIG_BOOTARGS to Kconfig
> Signed-off-by: Eugen Hristev 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/3] fit: Add empty fit_print_contents() and fit_image_print()

2018-05-24 Thread Tom Rini
On Sun, May 13, 2018 at 12:22:53AM +0200, Marek Vasut wrote:

> These functions may be needed in SPL, so add empty variants of them
> if CONFIG_SPL_FIT_PRINT is disabled.
> 
> Signed-off-by: Marek Vasut 
> Cc: Pantelis Antoniou 
> Cc: Simon Glass 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3, 1/2] arm: print instructions pointed to by pc

2018-05-24 Thread Tom Rini
On Tue, May 15, 2018 at 07:42:23PM +0200, Heinrich Schuchardt wrote:

> If an exception occurs in a loaded image and the relocation offset is
> unknown, it is helful to know the instructions pointed to by the
> program counter. This patch adds the missing output.
> 
> A possible output is:
> Code: e1c560d0 e12fff1e e120077b e12fff1e (e7f7defb)
> 
> The parentheses indicate the instruction causing the exception.
> 
> The output can be disassembled using the decodecode script provided
> by the Linux kernel project.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, v4] efi_loader: fix off-by-one bug in efi_get_variable

2018-05-24 Thread Alexander Graf
> efi_get_variable() always stores an extra zero byte after the output data.
> When the returned data size matches the output buffer size, the extra zero
> byte is stored past the end of the output buffer.
> 
> Signed-off-by: Ivan Gorinov 
> Reviewed-by: Heinrich Schuchardt 

Thanks, applied to efi-next

Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [uboot-snps-arc] [PATCH 0/3] Improvements for ARC UART

2018-05-24 Thread Tom Rini
On Thu, May 24, 2018 at 12:40:30PM +, Alexey Brodkin wrote:
> Hi Tom,
> 
> On Mon, 2018-05-21 at 17:03 +0300, Alexey Brodkin wrote:
> >  * Move ARC_SERIAL to Kconfig
> >  * Implement DEBUG_SERIAL in ARC_UART and
> >  * Enable DEBUG_UART in nSIM boards
> > 
> > Alexey Brodkin (3):
> >   serial: Convert ARC_SERIAL to Kconfig
> >   serial/serial_arc: Implement debug serial
> >   ARC: Enable debug UART on nSIM boards
> > 
> >  configs/nsim_700_defconfig|  5 +
> >  configs/nsim_700be_defconfig  |  5 +
> >  configs/nsim_hs38_defconfig   |  5 +
> >  configs/nsim_hs38be_defconfig |  5 +
> >  drivers/serial/Kconfig| 16 
> >  drivers/serial/serial_arc.c   | 26 ++
> >  include/configs/nsim.h| 10 --
> >  scripts/config_whitelist.txt  |  1 -
> >  8 files changed, 62 insertions(+), 11 deletions(-)
> 
> Do you want to pull this series yourself or I may push it
> via my tree (in which case I'll add another similar series
> from Eugeniy, see
> https://patchwork.ozlabs.org/project/uboot/list/?series=42321
> which BTW is a pre-requisite because of generic ARC fixup in
> https://patchwork.ozlabs.org/patch/907993/).

You can do this via the your tree, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,3/3] fit: Add standalone image type handling

2018-05-24 Thread Tom Rini
On Sun, May 13, 2018 at 12:22:54AM +0200, Marek Vasut wrote:

> Just add IH_TYPE_STANDALONE to fit_get_image_type_property().
> 
> Signed-off-by: Marek Vasut 
> Cc: Pantelis Antoniou 
> Cc: Simon Glass 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC changes

2018-05-24 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 8a9dc16e4d07d29fff08b7caca36f0865065f7f7:

  spl: Add full fitImage support (2018-05-23 22:06:42 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-uart-updates-for-2018.07-rc1

for you to fetch changes up to 0556b569e52caf3ab519c340435236e4940cc1cd:

  ARC: Enable debug UART on nSIM boards (2018-05-24 15:59:17 +0300)


Add support for DEBUG_UART on ARC devboards

This required us to do 2 things:
 1) Insert a call to debug_uart_init() in early boot code
 2) Convert serial_arc to Kconfig

Once both items above are done we just patched defconfigs.


Alexey Brodkin (3):
  serial: Convert ARC_SERIAL to Kconfig
  serial/serial_arc: Implement debug serial
  ARC: Enable debug UART on nSIM boards

Eugeniy Paltsev (2):
  ARC: init debug uart in early common arc code
  ARC: enable debug uart for HSDK and AXS10x boards

 arch/arc/lib/start.S  |  5 +
 configs/axs101_defconfig  |  5 +
 configs/axs103_defconfig  |  5 +
 configs/hsdk_defconfig|  5 +
 configs/nsim_700_defconfig|  5 +
 configs/nsim_700be_defconfig  |  5 +
 configs/nsim_hs38_defconfig   |  5 +
 configs/nsim_hs38be_defconfig |  5 +
 drivers/serial/Kconfig| 16 
 drivers/serial/serial_arc.c   | 26 ++
 include/configs/nsim.h| 10 --
 scripts/config_whitelist.txt  |  1 -
 12 files changed, 82 insertions(+), 11 deletions(-)

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 02/18] fastboot: Refactor fastboot_okay/fail to take response

2018-05-24 Thread Alex Kiernan
Add the response string as a parameter to fastboot_okay/fail, instead
of modifying a global, to match the contract expected by the AOSP
U-Boot code.

Signed-off-by: Alex Kiernan 
Reviewed-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- refactor for changes in master

Changes in v2: None

 cmd/mmc.c   |  2 +-
 common/image-sparse.c   | 32 +++--
 drivers/fastboot/fb_mmc.c   | 83 ++---
 drivers/fastboot/fb_nand.c  | 34 +++---
 drivers/usb/gadget/f_fastboot.c | 35 ++
 include/fastboot.h  |  4 +-
 include/fb_mmc.h|  4 +-
 include/fb_nand.h   |  4 +-
 include/image-sparse.h  |  4 +-
 9 files changed, 105 insertions(+), 97 deletions(-)

diff --git a/cmd/mmc.c b/cmd/mmc.c
index 68bbf1f513..cc445258c0 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -367,7 +367,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag,
sparse.mssg = NULL;
sprintf(dest, "0x" LBAF, sparse.start * sparse.blksz);
 
-   if (write_sparse_image(&sparse, dest, addr))
+   if (write_sparse_image(&sparse, dest, addr, NULL))
return CMD_RET_FAILURE;
else
return CMD_RET_SUCCESS;
diff --git a/common/image-sparse.c b/common/image-sparse.c
index 9223b9a1b8..1ae7a4d0e8 100644
--- a/common/image-sparse.c
+++ b/common/image-sparse.c
@@ -48,10 +48,10 @@
 #define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512)
 #endif
 
-static void default_log(const char *ignored) {}
+static void default_log(const char *ignored, char *response) {}
 
 int write_sparse_image(struct sparse_storage *info,
-  const char *part_name, void *data)
+  const char *part_name, void *data, char *response)
 {
lbaint_t blk;
lbaint_t blkcnt;
@@ -104,7 +104,7 @@ int write_sparse_image(struct sparse_storage *info,
if (offset) {
printf("%s: Sparse image block size issue [%u]\n",
   __func__, sparse_header->blk_sz);
-   info->mssg("sparse image block size issue");
+   info->mssg("sparse image block size issue", response);
return -1;
}
 
@@ -139,7 +139,8 @@ int write_sparse_image(struct sparse_storage *info,
case CHUNK_TYPE_RAW:
if (chunk_header->total_sz !=
(sparse_header->chunk_hdr_sz + chunk_data_sz)) {
-   info->mssg("Bogus chunk size for chunk type 
Raw");
+   info->mssg("Bogus chunk size for chunk type 
Raw",
+  response);
return -1;
}
 
@@ -147,7 +148,8 @@ int write_sparse_image(struct sparse_storage *info,
printf(
"%s: Request would exceed partition 
size!\n",
__func__);
-   info->mssg("Request would exceed partition 
size!");
+   info->mssg("Request would exceed partition 
size!",
+  response);
return -1;
}
 
@@ -157,7 +159,7 @@ int write_sparse_image(struct sparse_storage *info,
printf("%s: %s" LBAFU " [" LBAFU "]\n",
   __func__, "Write failed, block #",
   blk, blks);
-   info->mssg("flash write failure");
+   info->mssg("flash write failure", response);
return -1;
}
blk += blks;
@@ -169,7 +171,7 @@ int write_sparse_image(struct sparse_storage *info,
case CHUNK_TYPE_FILL:
if (chunk_header->total_sz !=
(sparse_header->chunk_hdr_sz + sizeof(uint32_t))) {
-   info->mssg("Bogus chunk size for chunk type 
FILL");
+   info->mssg("Bogus chunk size for chunk type 
FILL", response);
return -1;
}
 
@@ -179,7 +181,8 @@ int write_sparse_image(struct sparse_storage *info,
info->blksz * fill_buf_num_blks,
ARCH_DMA_MINALIGN));
if (!fill_buf) {
-   info->mssg("Malloc failed for: 
CHUNK_TYPE_FILL");
+   info->mssg("Malloc failed for: CHUNK_TYPE_FILL",
+  response);
return -1;
}
 
@@ -196,7 +199,8 @@ int write_sparse_image(struct spar

[U-Boot] [PATCH v7 03/18] fastboot: Extract fastboot_okay/fail to fb_common.c

2018-05-24 Thread Alex Kiernan
Add drivers/fastboot/fb_common.c, where fastboot_okay/fail are implemented
so we can call them from a non-USB implementation.

Introduce fastboot_response which takes varargs parameters so we can
use it to generate formatted response strings. Refactor fastboot_okay/fail
to use it.

Signed-off-by: Alex Kiernan 
Reviewed-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- fix docbook formatting

Changes in v4:
- add docbook comments

Changes in v3:
- Merge subsequent patch for formatting response strings into this one
- allow NULL to fastboot_okay() when there's no message to send

Changes in v2: None

 drivers/Makefile|  4 +--
 drivers/fastboot/Makefile   |  2 ++
 drivers/fastboot/fb_common.c| 61 +
 drivers/usb/gadget/f_fastboot.c | 13 ---
 include/fastboot.h  | 24 +
 5 files changed, 88 insertions(+), 16 deletions(-)
 create mode 100644 drivers/fastboot/fb_common.c

diff --git a/drivers/Makefile b/drivers/Makefile
index a79ff2e6b0..d29a6e467b 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -71,9 +71,7 @@ obj-y += block/
 obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_CPU) += cpu/
 obj-y += crypto/
-ifneq ($(CONFIG_FASTBOOT_FLASH_MMC_DEV)$(CONFIG_FASTBOOT_FLASH_NAND_DEV),)
-obj-y += fastboot/
-endif
+obj-$(CONFIG_FASTBOOT) += fastboot/
 obj-y += firmware/
 obj-$(CONFIG_FPGA) += fpga/
 obj-y += misc/
diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
index 651fbf0935..b38dcff202 100644
--- a/drivers/fastboot/Makefile
+++ b/drivers/fastboot/Makefile
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier:  GPL-2.0+
 
+obj-y += fb_common.o
+
 ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
 obj-y += fb_mmc.o
 endif
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
new file mode 100644
index 00..c4a7702bb3
--- /dev/null
+++ b/drivers/fastboot/fb_common.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2008 - 2009
+ * Windriver, 
+ * Tom Rix 
+ *
+ * Copyright 2011 Sebastian Andrzej Siewior 
+ *
+ * Copyright 2014 Linaro, Ltd.
+ * Rob Herring 
+ */
+
+#include 
+#include 
+
+/**
+ * fastboot_response() - Writes a response of the form "$tag$reason".
+ *
+ * @tag: The first part of the response
+ * @response: Pointer to fastboot response buffer
+ * @format: printf style format string
+ */
+void fastboot_response(const char *tag, char *response,
+  const char *format, ...)
+{
+   va_list args;
+
+   strlcpy(response, tag, FASTBOOT_RESPONSE_LEN);
+   if (format) {
+   va_start(args, format);
+   vsnprintf(response + strlen(response),
+ FASTBOOT_RESPONSE_LEN - strlen(response) - 1,
+ format, args);
+   va_end(args);
+   }
+}
+
+/**
+ * fastboot_fail() - Write a FAIL response of the form "FAIL$reason".
+ *
+ * @reason: Pointer to returned reason string
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_fail(const char *reason, char *response)
+{
+   fastboot_response("FAIL", response, "%s", reason);
+}
+
+/**
+ * fastboot_okay() - Write an OKAY response of the form "OKAY$reason".
+ *
+ * @reason: Pointer to returned reason string, or NULL to send a bare "OKAY"
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_okay(const char *reason, char *response)
+{
+   if (reason)
+   fastboot_response("OKAY", response, "%s", reason);
+   else
+   fastboot_response("OKAY", response, NULL);
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index bb60612647..2e6e1615bf 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -149,19 +149,6 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
 static int strcmp_l1(const char *s1, const char *s2);
 
-
-void fastboot_fail(const char *reason, char *response)
-{
-   strncpy(response, "FAIL\0", 5);
-   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
-}
-
-void fastboot_okay(const char *reason, char *response)
-{
-   strncpy(response, "OKAY\0", 5);
-   strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
-}
-
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
int status = req->status;
diff --git a/include/fastboot.h b/include/fastboot.h
index ed52daeb1b..6cd44d2ab9 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -15,7 +15,31 @@
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN  (64 + 1)
 
+/**
+ * fastboot_response() - Writes a response of the form "$tag$reason".
+ *
+ * @tag: The first part of the response
+ * @response: Pointer to fastboot response buffer
+ * @format: printf style format string
+ */
+void fastboot_response(const char *tag, char *response,
+ 

[U-Boot] [PATCH v7 04/18] fastboot: Correct dependencies in FASTBOOT_FLASH

2018-05-24 Thread Alex Kiernan
Ensure that when selecting FASTBOOT_FLASH you end up with a buildable
configuration. Prior to this you could select NAND without MTDPARTS
and end up with an image which (surprisingly) excluded NAND.

Also fix dependencies on FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME which require
you have EFI_PARTITION/DOS_PARTITION enabled.

Delete redundant FASTBOOT_FLASH_NAND_DEV from Kconfig - it was only ever
used as a guard and the value was ignored in all cases, we're using
FASTBOOT_FLASH_NAND as the guard now.

Signed-off-by: Alex Kiernan 
Reviewed-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6:
- delete redundant FASTBOOT_FLASH_NAND_DEV symbol

Changes in v5: None
Changes in v4: None
Changes in v3:
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION

Changes in v2: None

 arch/arm/mach-omap2/utils.c |  4 ++--
 drivers/fastboot/Kconfig| 17 -
 drivers/fastboot/Makefile   |  8 ++--
 drivers/usb/gadget/f_fastboot.c | 14 +++---
 4 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index dc7b37f164..edf5edcb68 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -85,7 +85,7 @@ static void omap_set_fastboot_board_rev(void)
env_set("fastboot.board_rev", board_rev);
 }
 
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 static u32 omap_mmc_get_part_size(const char *part)
 {
int res;
@@ -128,7 +128,7 @@ static void omap_set_fastboot_userdata_size(void)
 static inline void omap_set_fastboot_userdata_size(void)
 {
 }
-#endif /* CONFIG_FASTBOOT_FLASH_MMC_DEV */
+#endif /* CONFIG_FASTBOOT_FLASH_MMC */
 void omap_set_fastboot_vars(void)
 {
omap_set_fastboot_cpu();
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 93a8ac64e7..9bbc5c661d 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -56,6 +56,7 @@ config FASTBOOT_USB_DEV
 config FASTBOOT_FLASH
bool "Enable FASTBOOT FLASH command"
default y if ARCH_SUNXI
+   depends on MMC || (NAND && CMD_MTDPARTS)
help
  The fastboot protocol includes a "flash" command for writing
  the downloaded image to a non-volatile storage device. Define
@@ -71,7 +72,7 @@ config FASTBOOT_FLASH_MMC
 
 config FASTBOOT_FLASH_NAND
bool "FASTBOOT on NAND"
-   depends on NAND
+   depends on NAND && CMD_MTDPARTS
 
 endchoice
 
@@ -85,19 +86,9 @@ config FASTBOOT_FLASH_MMC_DEV
  regarding the non-volatile storage device. Define this to
  the eMMC device that fastboot should use to store the image.
 
-config FASTBOOT_FLASH_NAND_DEV
-   int "Define FASTBOOT NAND FLASH default device"
-   depends on FASTBOOT_FLASH_NAND
-   depends on CMD_MTDPARTS
-   default 0 if ARCH_SUNXI && NAND_SUNXI
-   help
- The fastboot "flash" command requires additional information
- regarding the non-volatile storage device. Define this to
- the NAND device that fastboot should use to store the image.
-
 config FASTBOOT_GPT_NAME
string "Target name for updating GPT"
-   depends on FASTBOOT_FLASH
+   depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
default "gpt"
help
  The fastboot "flash" command supports writing the downloaded
@@ -110,7 +101,7 @@ config FASTBOOT_GPT_NAME
 
 config FASTBOOT_MBR_NAME
string "Target name for updating MBR"
-   depends on FASTBOOT_FLASH
+   depends on FASTBOOT_FLASH_MMC && DOS_PARTITION
default "mbr"
help
  The fastboot "flash" command allows to write the downloaded image
diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
index b38dcff202..e4bd389adf 100644
--- a/drivers/fastboot/Makefile
+++ b/drivers/fastboot/Makefile
@@ -2,9 +2,5 @@
 
 obj-y += fb_common.o
 
-ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
-obj-y += fb_mmc.o
-endif
-ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-obj-y += fb_nand.o
-endif
+obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
+obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 2e6e1615bf..323ac89417 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -20,10 +20,10 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 #include 
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
 #include 
 #endif
 
@@ -583,11 +583,11 @@ static void cb_flash(struct usb_ep *ep, struct 
usb_request *req)
}
 
fastboot_fail("no flash device defined", response);
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
   download_bytes, response);
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
fb_nand_flash_write

[U-Boot] [PATCH v7 05/18] fastboot: Add missing newlines

2018-05-24 Thread Alex Kiernan
Add newlines so we format our output correctly.

Signed-off-by: Alex Kiernan 
Acked-by: Joe Hershberger 
Reviewed-by: Jocelyn Bohr 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/fb_mmc.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 1bcb2e52d4..b1db29684d 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -125,7 +125,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
sector_size = info->blksz;
hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size);
if (hdr_sectors == 0) {
-   pr_err("invalid number of boot sectors: 0");
+   pr_err("invalid number of boot sectors: 0\n");
fastboot_fail("invalid number of boot sectors: 0", response);
return 0;
}
@@ -133,7 +133,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
/* Read the boot image header */
res = blk_dread(dev_desc, info->start, hdr_sectors, (void *)hdr);
if (res != hdr_sectors) {
-   pr_err("cannot read header from boot partition");
+   pr_err("cannot read header from boot partition\n");
fastboot_fail("cannot read header from boot partition",
  response);
return 0;
@@ -142,7 +142,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc 
*dev_desc,
/* Check boot header magic string */
res = android_image_check_header(hdr);
if (res != 0) {
-   pr_err("bad boot image magic");
+   pr_err("bad boot image magic\n");
fastboot_fail("boot partition not initialized", response);
return 0;
}
@@ -181,7 +181,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
/* Get boot partition info */
res = part_get_info_by_name(dev_desc, BOOT_PARTITION_NAME, &info);
if (res < 0) {
-   pr_err("cannot find boot partition");
+   pr_err("cannot find boot partition\n");
fastboot_fail("cannot find boot partition", response);
return -1;
}
@@ -193,14 +193,14 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
/* Read boot image header */
hdr_sectors = fb_mmc_get_boot_header(dev_desc, &info, hdr, response);
if (hdr_sectors == 0) {
-   pr_err("unable to read boot image header");
+   pr_err("unable to read boot image header\n");
fastboot_fail("unable to read boot image header", response);
return -1;
}
 
/* Check if boot image has second stage in it (we don't support it) */
if (hdr->second_size > 0) {
-   pr_err("moving second stage is not supported yet");
+   pr_err("moving second stage is not supported yet\n");
fastboot_fail("moving second stage is not supported yet",
  response);
return -1;
@@ -219,7 +219,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = blk_dread(dev_desc, ramdisk_sector_start, ramdisk_sectors,
ramdisk_buffer);
if (res != ramdisk_sectors) {
-   pr_err("cannot read ramdisk from boot partition");
+   pr_err("cannot read ramdisk from boot partition\n");
fastboot_fail("cannot read ramdisk from boot partition",
  response);
return -1;
@@ -229,7 +229,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
hdr->kernel_size = download_bytes;
res = blk_dwrite(dev_desc, info.start, hdr_sectors, (void *)hdr);
if (res == 0) {
-   pr_err("cannot writeback boot image header");
+   pr_err("cannot writeback boot image header\n");
fastboot_fail("cannot write back boot image header", response);
return -1;
}
@@ -241,7 +241,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = blk_dwrite(dev_desc, kernel_sector_start, kernel_sectors,
 download_buffer);
if (res == 0) {
-   pr_err("cannot write new kernel");
+   pr_err("cannot write new kernel\n");
fastboot_fail("cannot write new kernel", response);
return -1;
}
@@ -253,7 +253,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
res = blk_dwrite(dev_desc, ramdisk_sector_start, ramdisk_sectors,
 ramdisk_buffer);
if (res == 0) {
-   pr_err("cannot write back original ramdisk");
+   pr_err("cannot write back original ramdisk\n");
fastboot_fail("ca

[U-Boot] [PATCH v7 10/18] fastboot: Rename public fb_ functions to fastboot_

2018-05-24 Thread Alex Kiernan
Rename fb_mmc_flash_write/fb_mmc_erase/fb_nand_flash_write/fb_nand_erase to
fastboot_... as they form a public interface

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
---

Changes in v7: None
Changes in v6:
- add docbook comments

Changes in v5:
- new

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/fb_mmc.c   | 20 +---
 drivers/fastboot/fb_nand.c  | 20 +---
 drivers/usb/gadget/f_fastboot.c | 12 ++--
 include/fb_mmc.h| 21 ++---
 include/fb_nand.h   | 20 +---
 5 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 038905face..47fcf74b69 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -251,8 +251,16 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 }
 #endif
 
-void fb_mmc_flash_write(const char *cmd, void *download_buffer,
-   unsigned int download_bytes, char *response)
+/**
+ * fastboot_mmc_flash_write() - Write image to eMMC for fastboot
+ *
+ * @cmd: Named partition to write image to
+ * @download_buffer: Pointer to image data
+ * @download_bytes: Size of image data
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
+ unsigned int download_bytes, char *response)
 {
struct blk_desc *dev_desc;
disk_partition_t info;
@@ -349,7 +357,13 @@ void fb_mmc_flash_write(const char *cmd, void 
*download_buffer,
}
 }
 
-void fb_mmc_erase(const char *cmd, char *response)
+/**
+ * fastboot_mmc_flash_erase() - Erase eMMC for fastboot
+ *
+ * @cmd: Named partition to erase
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_mmc_erase(const char *cmd, char *response)
 {
int ret;
struct blk_desc *dev_desc;
diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c
index 849a6f16a5..535f541eb8 100644
--- a/drivers/fastboot/fb_nand.c
+++ b/drivers/fastboot/fb_nand.c
@@ -145,8 +145,16 @@ static lbaint_t fb_nand_sparse_reserve(struct 
sparse_storage *info,
return blkcnt + bad_blocks;
 }
 
-void fb_nand_flash_write(const char *cmd, void *download_buffer,
-unsigned int download_bytes, char *response)
+/**
+ * fastboot_nand_flash_write() - Write image to NAND for fastboot
+ *
+ * @cmd: Named device to write image to
+ * @download_buffer: Pointer to image data
+ * @download_bytes: Size of image data
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_nand_flash_write(const char *cmd, void *download_buffer,
+  unsigned int download_bytes, char *response)
 {
struct part_info *part;
struct mtd_info *mtd = NULL;
@@ -204,7 +212,13 @@ void fb_nand_flash_write(const char *cmd, void 
*download_buffer,
fastboot_okay(NULL, response);
 }
 
-void fb_nand_erase(const char *cmd, char *response)
+/**
+ * fastboot_nand_flash_erase() - Erase NAND for fastboot
+ *
+ * @cmd: Named device to erase
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_nand_erase(const char *cmd, char *response)
 {
struct part_info *part;
struct mtd_info *mtd = NULL;
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 25784a193e..07d6a62155 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -577,12 +577,12 @@ static void cb_flash(struct usb_ep *ep, struct 
usb_request *req)
 
fastboot_fail("no flash device defined", response);
 #ifdef CONFIG_FASTBOOT_FLASH_MMC
-   fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
-  download_bytes, response);
+   fastboot_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+download_bytes, response);
 #endif
 #ifdef CONFIG_FASTBOOT_FLASH_NAND
-   fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
-   download_bytes, response);
+   fastboot_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+ download_bytes, response);
 #endif
fastboot_tx_write_str(response);
 }
@@ -625,10 +625,10 @@ static void cb_erase(struct usb_ep *ep, struct 
usb_request *req)
 
fastboot_fail("no flash device defined", response);
 #ifdef CONFIG_FASTBOOT_FLASH_MMC
-   fb_mmc_erase(cmd, response);
+   fastboot_mmc_erase(cmd, response);
 #endif
 #ifdef CONFIG_FASTBOOT_FLASH_NAND
-   fb_nand_erase(cmd, response);
+   fastboot_nand_erase(cmd, response);
 #endif
fastboot_tx_write_str(response);
 }
diff --git a/include/fb_mmc.h b/include/fb_mmc.h
index 39a960cc9d..daca81a201 100644
--- a/include/fb_mmc.h
+++ b/include/fb_mmc.h
@@ -3,6 +3,21 @@
  * Copyright 2014 Broadcom Corporation.
  */
 
-void fb_mmc_flash_write(const char *cmd, v

[U-Boot] [PATCH v7 08/18] fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag

2018-05-24 Thread Alex Kiernan
Rename fb_set_reboot_flag to fastboot_set_reboot_flag so it matches
all other fastboot code in the global name space. Fix the guards around
them so that they're dependent on FASTBOOT, not just USB_FUNCTION_FASTBOOT.

Move the weak implementation of fastboot_set_reboot_flag to fb_common.c
so we can call it from non-USB fastboot code.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
Acked-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 arch/arm/mach-omap2/boot-common.c |  4 ++--
 arch/arm/mach-rockchip/rk3128-board.c |  4 ++--
 arch/arm/mach-rockchip/rk322x-board.c |  4 ++--
 board/amazon/kc1/kc1.c|  2 +-
 board/lg/sniper/sniper.c  |  2 +-
 drivers/fastboot/fb_common.c  | 15 +++
 drivers/usb/gadget/f_fastboot.c   |  7 +--
 include/fastboot.h|  2 +-
 8 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index 0e9fd03fef..b22b6713e5 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -237,8 +237,8 @@ void arch_preboot_os(void)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT) && !defined(CONFIG_ENV_IS_NOWHERE)
-int fb_set_reboot_flag(void)
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
+int fastboot_set_reboot_flag(void)
 {
printf("Setting reboot to fastboot flag ...\n");
env_set("dofastboot", "1");
diff --git a/arch/arm/mach-rockchip/rk3128-board.c 
b/arch/arm/mach-rockchip/rk3128-board.c
index 48cd8ba81e..7fd667a0b8 100644
--- a/arch/arm/mach-rockchip/rk3128-board.c
+++ b/arch/arm/mach-rockchip/rk3128-board.c
@@ -111,8 +111,8 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT)
-int fb_set_reboot_flag(void)
+#if CONFIG_IS_ENABLED(FASTBOOT)
+int fastboot_set_reboot_flag(void)
 {
struct rk3128_grf *grf;
 
diff --git a/arch/arm/mach-rockchip/rk322x-board.c 
b/arch/arm/mach-rockchip/rk322x-board.c
index 99a60c4e2e..7366d45ab6 100644
--- a/arch/arm/mach-rockchip/rk322x-board.c
+++ b/arch/arm/mach-rockchip/rk322x-board.c
@@ -139,8 +139,8 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT)
-int fb_set_reboot_flag(void)
+#if CONFIG_IS_ENABLED(FASTBOOT)
+int fastboot_set_reboot_flag(void)
 {
struct rk322x_grf *grf;
 
diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c
index d9ca18363c..031fd11092 100644
--- a/board/amazon/kc1/kc1.c
+++ b/board/amazon/kc1/kc1.c
@@ -161,7 +161,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
omap_die_id_get_board_serial(serialnr);
 }
 
-int fb_set_reboot_flag(void)
+int fastboot_set_reboot_flag(void)
 {
return omap_reboot_mode_store("b");
 }
diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c
index 34a7a11f05..a7de4c2167 100644
--- a/board/lg/sniper/sniper.c
+++ b/board/lg/sniper/sniper.c
@@ -173,7 +173,7 @@ void reset_misc(void)
omap_reboot_mode_store(reboot_mode);
 }
 
-int fb_set_reboot_flag(void)
+int fastboot_set_reboot_flag(void)
 {
return omap_reboot_mode_store("b");
 }
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index c4a7702bb3..79e080ac87 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -59,3 +59,18 @@ void fastboot_okay(const char *reason, char *response)
else
fastboot_response("OKAY", response, NULL);
 }
+
+/**
+ * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader
+ *
+ * Set flag which indicates that we should reboot into the bootloader
+ * following the reboot that fastboot executes after this function.
+ *
+ * This function should be overridden in your board file with one
+ * which sets whatever flag your board specific Android bootloader flow
+ * requires in order to re-enter the bootloader.
+ */
+int __weak fastboot_set_reboot_flag(void)
+{
+   return -ENOSYS;
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 323ac89417..697eee57d0 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -357,16 +357,11 @@ static void compl_do_reset(struct usb_ep *ep, struct 
usb_request *req)
do_reset(NULL, 0, 0, NULL);
 }
 
-int __weak fb_set_reboot_flag(void)
-{
-   return -ENOSYS;
-}
-
 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 {
char *cmd = req->buf;
if (!strcmp_l1("reboot-bootloader", cmd)) {
-   if (fb_set_reboot_flag()) {
+   if (fastboot_set_reboot_flag()) {
fastboot_tx_write_str("FAILCannot set reboot flag");
return;
}
diff --git a/include/fastboot.h b/include/fastboot.h
index 6cd44d2ab9..816e71b4d0 100644
--- a/inc

[U-Boot] [PATCH v7 11/18] ti: fastboot: Move weak overrides to board files

2018-05-24 Thread Alex Kiernan
Overriding fastboot_set_reboot_flag() in arch/arm/mach-omap2/boot-common.c
leaves it applying all boards that derive from this, not just the ones which
have support for Android bootloader flow. Move the weak function override to
the relevant board files.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 arch/arm/mach-omap2/boot-common.c | 10 --
 board/ti/am57xx/board.c   | 10 ++
 board/ti/dra7xx/evm.c | 10 ++
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index b22b6713e5..d4a1e2e42c 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -236,13 +236,3 @@ void arch_preboot_os(void)
ahci_reset((void __iomem *)DWC_AHSATA_BASE);
 }
 #endif
-
-#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
-int fastboot_set_reboot_flag(void)
-{
-   printf("Setting reboot to fastboot flag ...\n");
-   env_set("dofastboot", "1");
-   env_save();
-   return 0;
-}
-#endif
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index fd9d20779b..177a3246c3 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -1178,5 +1178,15 @@ void board_tee_image_process(ulong tee_image, size_t 
tee_size)
secure_tee_install((u32)tee_image);
 }
 
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
+int fastboot_set_reboot_flag(void)
+{
+   printf("Setting reboot to fastboot flag ...\n");
+   env_set("dofastboot", "1");
+   env_save();
+   return 0;
+}
+#endif
+
 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
 #endif
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 6918f4de01..bbe54450ae 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -1188,5 +1188,15 @@ void board_tee_image_process(ulong tee_image, size_t 
tee_size)
secure_tee_install((u32)tee_image);
 }
 
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
+int fastboot_set_reboot_flag(void)
+{
+   printf("Setting reboot to fastboot flag ...\n");
+   env_set("dofastboot", "1");
+   env_save();
+   return 0;
+}
+#endif
+
 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
 #endif
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 06/18] fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME

2018-05-24 Thread Alex Kiernan
CONFIG_FASTBOOT_GPT_NAME and CONFIG_FASTBOOT_MBR_NAME are always defined
by Kconfig if you're compiling this code, so remove these redundant
defaults.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
Acked-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 drivers/fastboot/fb_mmc.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index b1db29684d..038905face 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -15,19 +15,6 @@
 #include 
 #include 
 
-/*
- * FIXME: Ensure we always set these names via Kconfig once xxx_PARTITION is
- * migrated
- */
-#ifndef CONFIG_FASTBOOT_GPT_NAME
-#define CONFIG_FASTBOOT_GPT_NAME "gpt"
-#endif
-
-
-#ifndef CONFIG_FASTBOOT_MBR_NAME
-#define CONFIG_FASTBOOT_MBR_NAME "mbr"
-#endif
-
 #define BOOT_PARTITION_NAME "boot"
 
 struct fb_mmc_sparse {
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 07/18] fastboot: Fix parameter types in _fb_nand_write

2018-05-24 Thread Alex Kiernan
Compiling on a 64 bit target the arguments to _fb_nand_write are
incompatible:

  drivers/fastboot/fb_nand.c: In function ‘_fb_nand_write’:
  drivers/fastboot/fb_nand.c:101:42: warning: passing argument 3 of 
‘nand_write_skip_bad’ from incompatible pointer type 
[-Wincompatible-pointer-types]
return nand_write_skip_bad(mtd, offset, &length, written,
  ^
  In file included from drivers/fastboot/fb_nand.c:16:0:
  include/nand.h:107:5: note: expected ‘size_t * {aka long unsigned int *}’ but 
argument is of type ‘unsigned int *’
   int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,
   ^~~

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
Acked-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 drivers/fastboot/fb_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c
index 2ee0d644e0..849a6f16a5 100644
--- a/drivers/fastboot/fb_nand.c
+++ b/drivers/fastboot/fb_nand.c
@@ -89,7 +89,7 @@ static int _fb_nand_erase(struct mtd_info *mtd, struct 
part_info *part)
 
 static int _fb_nand_write(struct mtd_info *mtd, struct part_info *part,
  void *buffer, unsigned int offset,
- unsigned int length, size_t *written)
+ size_t length, size_t *written)
 {
int flags = WITH_WR_VERIFY;
 
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 13/18] fastboot: Migrate FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig

2018-05-24 Thread Alex Kiernan
Add FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig; note there are no in-tree
users of it.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- new

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/Kconfig | 7 +++
 scripts/config_whitelist.txt | 1 -
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 9bbc5c661d..1d7caaff99 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -86,6 +86,13 @@ config FASTBOOT_FLASH_MMC_DEV
  regarding the non-volatile storage device. Define this to
  the eMMC device that fastboot should use to store the image.
 
+config FASTBOOT_FLASH_NAND_TRIMFFS
+   bool "Skip empty pages when flashing NAND"
+   depends on FASTBOOT_FLASH_NAND
+   help
+ When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
+ pages.
+
 config FASTBOOT_GPT_NAME
string "Target name for updating GPT"
depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 8327798179..9f95e8fa0e 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -591,7 +591,6 @@ CONFIG_EXYNOS_SPL
 CONFIG_EXYNOS_TMU
 CONFIG_FACTORYSET
 CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE
-CONFIG_FASTBOOT_FLASH_NAND_TRIMFFS
 CONFIG_FAST_FLASH_BIT
 CONFIG_FB_ADDR
 CONFIG_FB_BACKLIGHT
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 18/18] fastboot: Update fastboot documentation

2018-05-24 Thread Alex Kiernan
Update fastboot documentation to reflect merged USB/UDP implementation.

Signed-off-by: Alex Kiernan 
---

Changes in v7: None
Changes in v6:
- new

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 doc/README.android-fastboot | 240 +++-
 1 file changed, 156 insertions(+), 84 deletions(-)

diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
index 2c3ee7810a..431191c473 100644
--- a/doc/README.android-fastboot
+++ b/doc/README.android-fastboot
@@ -1,142 +1,214 @@
+
 Android Fastboot
-
+
 
 Overview
 
-The protocol that is used over USB is described in
-README.android-fastboot-protocol in same directory.
 
-The current implementation is a minimal support of the erase command,the
-"oem format" command and flash command;it only supports eMMC devices.
+The protocol that is used over USB and UDP is described in the
+``README.android-fastboot-protocol`` file in the same directory.
+
+The current implementation supports the following standard commands:
+
+- ``boot``
+- ``continue``
+- ``download``
+- ``erase`` (if enabled)
+- ``flash`` (if enabled)
+- ``getvar``
+- ``reboot``
+- ``reboot-bootloader``
+- ``set_active`` (only a stub implementation which always succeeds)
+
+The following OEM commands are supported (if enabled):
+
+- oem format - this executes ``gpt write mmc %x $partitions``
+
+Support for both eMMC and NAND devices is included.
 
 Client installation
 ===
-The counterpart to this gadget is the fastboot client which can
-be found in Android's platform/system/core repository in the fastboot
-folder. It runs on Windows, Linux and even OSX. Linux user are lucky since
-they only need libusb.
-Windows users need to bring some time until they have Android SDK (currently
-http://dl.google.com/android/installer_r12-windows.exe) installed. You
-need to install ADB package which contains the required glue libraries for
-accessing USB. Also you need "Google USB driver package" and "SDK platform
-tools". Once installed the usb driver is placed in your SDK folder under
-extras\google\usb_driver. The android_winusb.inf needs a line like
-
-   %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022
-
-either in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64]
-for 64bit Windows. VID and PID should match whatever the fastboot is
-advertising.
+
+The counterpart to this is the fastboot client which can be found in
+Android's ``platform/system/core`` repository in the fastboot
+folder. It runs on Windows, Linux and OSX. The fastboot client is
+part of the Android SDK Platform-Tools and can be downloaded from:
+
+https://developer.android.com/studio/releases/platform-tools
 
 Board specific
 ==
+
+USB configuration
+-
+
 The fastboot gadget relies on the USB download gadget, so the following
 options must be configured:
 
-CONFIG_USB_GADGET_DOWNLOAD
-CONFIG_USB_GADGET_VENDOR_NUM
-CONFIG_USB_GADGET_PRODUCT_NUM
-CONFIG_USB_GADGET_MANUFACTURER
+::
+
+   CONFIG_USB_GADGET_DOWNLOAD
+   CONFIG_USB_GADGET_VENDOR_NUM
+   CONFIG_USB_GADGET_PRODUCT_NUM
+   CONFIG_USB_GADGET_MANUFACTURER
 
-NOTE: The CONFIG_USB_GADGET_VENDOR_NUM must be one of the numbers supported by
-the fastboot client. The list of vendor IDs supported can be found in the
-fastboot client source code (fastboot.c) mentioned above.
+NOTE: The ``CONFIG_USB_GADGET_VENDOR_NUM`` must be one of the numbers
+supported by the fastboot client. The list of vendor IDs supported can
+be found in the fastboot client source code.
 
-The fastboot function is enabled by defining CONFIG_USB_FUNCTION_FASTBOOT,
-CONFIG_CMD_FASTBOOT and CONFIG_ANDROID_BOOT_IMAGE.
+General configuration
+-
 
-The fastboot protocol requires a large memory buffer for downloads. This
-buffer should be as large as possible for a platform. The location of the
-buffer and size are set with CONFIG_FASTBOOT_BUF_ADDR and
-CONFIG_FASTBOOT_BUF_SIZE.
+The fastboot protocol requires a large memory buffer for
+downloads. This buffer should be as large as possible for a
+platform. The location of the buffer and size are set with
+``CONFIG_FASTBOOT_BUF_ADDR`` and ``CONFIG_FASTBOOT_BUF_SIZE``. These
+may be overridden on the fastboot command line using ``-l`` and
+``-s``.
+
+Fastboot environment variables
+==
+
+Partition aliases
+-
 
 Fastboot partition aliases can also be defined for devices where GPT
 limitations prevent user-friendly partition names such as "boot", "system"
 and "cache".  Or, where the actual partition name doesn't match a standard
-partition name used commonly with fastboot.  Current implentation checks
-aliases when accessing partitions by name (flash_write and erase functions).
-To define a partition alias add an environment variable similar to:
-fastboot_partition_alias_=
-Example: fastboot_partition_alias_boot=LNX
+partiti

[U-Boot] [PATCH v7 12/18] fs: Add fs_get_type_name to return current filesystem name

2018-05-24 Thread Alex Kiernan
Add fs_get_type_name so we can get the current filesystem type.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
Reviewed-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- add docbook comments

Changes in v3:
- new

Changes in v2: None

 fs/fs.c  | 13 +
 include/fs.h | 10 ++
 2 files changed, 23 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 94cdc37deb..33808d549e 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -265,6 +265,19 @@ static struct fstype_info *fs_get_info(int fstype)
return info;
 }
 
+/**
+ * fs_get_type_name() - Get type of current filesystem
+ *
+ * Return: Pointer to filesystem name
+ *
+ * Returns a string describing the current filesystem, or the sentinel
+ * "unsupported" for any unrecognised filesystem.
+ */
+const char *fs_get_type_name(void)
+{
+   return fs_get_info(fs_type)->name;
+}
+
 int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
 {
struct fstype_info *info;
diff --git a/include/fs.h b/include/fs.h
index d703ed5027..163da103b4 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -37,6 +37,16 @@ int fs_set_blk_dev(const char *ifname, const char 
*dev_part_str, int fstype);
  */
 int fs_set_blk_dev_with_part(struct blk_desc *desc, int part);
 
+/**
+ * fs_get_type_name() - Get type of current filesystem
+ *
+ * Return: Pointer to filesystem name
+ *
+ * Returns a string describing the current filesystem, or the sentinel
+ * "unsupported" for any unrecognised filesystem.
+ */
+const char *fs_get_type_name(void);
+
 /*
  * Print the list of files on the partition previously set by fs_set_blk_dev(),
  * in directory "dirname".
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 14/18] mmc: Separate "mmc swrite" from fastboot

2018-05-24 Thread Alex Kiernan
Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc
swrite" command is separated from the fastboot code.

Move image-sparse from common to lib so it's clear it's library code.

Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
and migrate it to Kconfig.

Signed-off-by: Alex Kiernan 
Acked-by: Jassi Brar 
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
  and migrate it to Kconfig.

Changes in v4:
- new

Changes in v3: None
Changes in v2: None

 cmd/Kconfig|  8 
 cmd/mmc.c  | 12 ++--
 common/Makefile|  1 -
 drivers/fastboot/Kconfig   |  1 +
 lib/Kconfig| 11 +++
 lib/Makefile   |  1 +
 {common => lib}/image-sparse.c |  6 +-
 scripts/config_whitelist.txt   |  1 -
 8 files changed, 28 insertions(+), 13 deletions(-)
 rename {common => lib}/image-sparse.c (97%)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 91f6dfef92..98763c9108 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -826,6 +826,14 @@ config CMD_MMC
help
  MMC memory mapped support.
 
+config CMD_MMC_SWRITE
+   bool "mmc swrite"
+   depends on CMD_MMC && MMC_WRITE
+   select IMAGE_SPARSE
+   help
+ Enable support for the "mmc swrite" command to write Android sparse
+ images to eMMC.
+
 config CMD_NAND
bool "nand"
default y if NAND_SUNXI
diff --git a/cmd/mmc.c b/cmd/mmc.c
index cc445258c0..66c3ee008d 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
 }
 
-#if CONFIG_IS_ENABLED(MMC_WRITE)
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
 static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk,
 lbaint_t blkcnt, const void *buffer)
 {
@@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag,
 }
 #endif
 
+#if CONFIG_IS_ENABLED(MMC_WRITE)
 static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
 {
@@ -868,10 +868,10 @@ static cmd_tbl_t cmd_mmc[] = {
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
 #if CONFIG_IS_ENABLED(MMC_WRITE)
U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
-#if defined(CONFIG_FASTBOOT_FLASH)
-   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
-#endif
U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
+#endif
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
+   U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
 #endif
U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
@@ -927,7 +927,7 @@ U_BOOT_CMD(
"info - display info of the current MMC device\n"
"mmc read addr blk# cnt\n"
"mmc write addr blk# cnt\n"
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
"mmc swrite addr blk#\n"
 #endif
"mmc erase blk# cnt\n"
diff --git a/common/Makefile b/common/Makefile
index 9ec40b9d27..b3da72ebb2 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -29,7 +29,6 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
-obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 1d7caaff99..0c9ced53de 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -57,6 +57,7 @@ config FASTBOOT_FLASH
bool "Enable FASTBOOT FLASH command"
default y if ARCH_SUNXI
depends on MMC || (NAND && CMD_MTDPARTS)
+   select IMAGE_SPARSE
help
  The fastboot protocol includes a "flash" command for writing
  the downloaded image to a non-volatile storage device. Define
diff --git a/lib/Kconfig b/lib/Kconfig
index 1590f7afa4..15c6a52d4a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -61,6 +61,17 @@ config SPL_STRTO
 config TPL_STRTO
bool
 
+config IMAGE_SPARSE
+   bool
+
+config IMAGE_SPARSE_FILLBUF_SIZE
+   hex "Android sparse image CHUNK_TYPE_FILL buffer size"
+   default 0x8
+   depends on IMAGE_SPARSE
+   help
+ Set the size of the fill buffer used when processing CHUNK_TYPE_FILL
+ chunks.
+
 config USE_PRIVATE_LIBGCC
bool "Use private libgcc"
depends on HAVE_PRIVATE_LIBGCC
diff --git a/lib/Makefile b/lib/Makefile
index d531ea54b3..a4bbe2fb48 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 ob

[U-Boot] [PATCH v7 16/18] fastboot: Add support for 'oem format' command

2018-05-24 Thread Alex Kiernan
Introduce 'oem format' which matches the USB implementation, guard this
with CONFIG_FASTBOOT_CMD_OEM_FORMAT so that you can configure it out.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
---

Changes in v7: None
Changes in v6: None
Changes in v5:
- new

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/Kconfig  |  8 
 drivers/fastboot/fb_command.c | 33 +
 include/fastboot.h|  3 +++
 3 files changed, 44 insertions(+)

diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 625f016600..bc25ea1d9c 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -124,6 +124,14 @@ config FASTBOOT_MBR_NAME
  specified on the "fastboot flash" command line matches the value
  defined here. The default target name for updating MBR is "mbr".
 
+config FASTBOOT_CMD_OEM_FORMAT
+   bool "Enable the 'oem format' command"
+   depends on FASTBOOT_FLASH_MMC && CMD_GPT
+   help
+ Add support for the "oem format" command from a client. This
+ relies on the env variable partitions to contain the list of
+ partitions as required by the gpt command.
+
 endif # FASTBOOT
 
 endmenu
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index af4f500694..200f9910c5 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -34,6 +34,9 @@ static void flash(char *, char *);
 static void erase(char *, char *);
 #endif
 static void reboot_bootloader(char *, char *);
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+static void oem_format(char *, char *);
+#endif
 
 static const struct {
const char *command;
@@ -77,6 +80,12 @@ static const struct {
.command = "set_active",
.dispatch = okay
},
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+   [FASTBOOT_COMMAND_OEM_FORMAT] = {
+   .command = "oem format",
+   .dispatch = oem_format,
+   },
+#endif
 };
 
 /**
@@ -300,3 +309,27 @@ static void reboot_bootloader(char *cmd_parameter, char 
*response)
else
fastboot_okay(NULL, response);
 }
+
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+/**
+ * oem_format() - Execute the OEM format command
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void oem_format(char *cmd_parameter, char *response)
+{
+   char cmdbuf[32];
+
+   if (!env_get("partitions")) {
+   fastboot_fail("partitions not set", response);
+   } else {
+   sprintf(cmdbuf, "gpt write mmc %x $partitions",
+   CONFIG_FASTBOOT_FLASH_MMC_DEV);
+   if (run_command(cmdbuf, 0))
+   fastboot_fail("", response);
+   else
+   fastboot_okay(NULL, response);
+   }
+}
+#endif
diff --git a/include/fastboot.h b/include/fastboot.h
index 9a3d5ba693..1933b1d98e 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -33,6 +33,9 @@ enum {
FASTBOOT_COMMAND_REBOOT,
FASTBOOT_COMMAND_REBOOT_BOOTLOADER,
FASTBOOT_COMMAND_SET_ACTIVE,
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+   FASTBOOT_COMMAND_OEM_FORMAT,
+#endif
 
FASTBOOT_COMMAND_COUNT
 };
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 15/18] net: fastboot: Merge AOSP UDP fastboot

2018-05-24 Thread Alex Kiernan
Merge UDP fastboot support from AOSP:

  
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8

Signed-off-by: Alex Kiernan 
Signed-off-by: Alex Deymo 
Signed-off-by: Jocelyn Bohr 
Reviewed-by: Simon Glass 
---

Changes in v7: None
Changes in v6:
- add docbook comments
- rename fastboot_download_data() to fastboot_data_download(), rename
  fastboot_get_bytes_remaining() to fastboot_data_remaining()
- split fastboot_data_complete() out from fastboot_data_download() so we
  can call it at the end of the transfer phase for USB

Changes in v5:
- make fastboot_bytes_received/expected static and add function
  fastboot_get_bytes_remaining()
- move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback
  into fastboot-internal.h
- delete redundant fb_ prefixes from statics

Changes in v4:
- guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
- add docbook comments
- remove parameter from fastboot_boot() since we always want
  fastboot_buf_addr (and if we're using fastboot_bootcmd then it's
  ignored)
- split oem format into new patch

Changes in v3:
- use FASTBOOT as our guard in Kconfig not a list of USB || UDP
- correct mis-translation from AOSP introduced when cleaning up for
  checkpatch - we should write when buffer is not NULL, rather than
  erasing, and erase when buffer is NULL
- use CMD_RET_USAGE from do_fastboot
- remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
- rename timed_send_info to fastboot_send_info, rename fastboot_send_info to
  fastboot_udp_send_info
- replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
- move start time into timed_send_info() rather than passing it in
- make calls to fastboot_udp_send_info a runtime dependency, not a compile
  time one
- set ${filesize} to size of downloaded image
- add progress meter from USB path during download
- add support for 'oem format' command from the USB path
- rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the
  fastboot boot command
- make getvar implementation table driven
- add fastboot_buf_addr, fastboot_buf_size to override buffer address and
  size
- return correct filesystem type in getvar partition-type on MMC
- process "fastboot." prefixed env variables in getvar first so you
  can override the normal values (this also lets you set a fs type for
  NAND devices)
- squash subsequent patches which change this code into this one:
  - If the fastboot flash/erase commands are disabled, remove that support
so we still build correctly.
  - Add NAND support to fastboot UDP flash/erase commands
  - If we don't have a partition name passed, report it as not found.
  - Change the behaviour of the fastboot net code such that
"reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for
use as a marker on reboot (the AOSP code in common/android-bootloader.c
uses this marker - this code could be reinstated there if that gets
merged).
  - Merge USB and UDP boot code. The USB implementation stays the same, but
UDP no longer passes an fdt. We introduce a new environment variable
'fastboot_bootcmd' which if set overrides the hardcoded boot command,
setting this then allows the UDP implementation to remain the same. If
after running 'fastboot_bootcmd' the board has not booted, control is
returned to U-Boot and the fastboot process ends.
  - Separate the fastboot protocol handling from the fastboot UDP code in
preparation for reusing it in the USB code.

Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means
  'fastboot usb 0'

 cmd/Kconfig   |   4 +-
 cmd/fastboot.c|  91 +-
 drivers/fastboot/Kconfig  |   7 +
 drivers/fastboot/Makefile |   3 +-
 drivers/fastboot/fb_command.c | 302 
 drivers/fastboot/fb_common.c  |  93 ++
 drivers/fastboot/fb_getvar.c  | 230 
 drivers/fastboot/fb_mmc.c |  84 -
 drivers/fastboot/fb_nand.c|  19 +-
 include/fastboot-internal.h   |  36 
 include/fastboot.h| 104 +++
 include/fb_mmc.h  |  18 +-
 include/fb_nand.h |  19 +-
 include/net.h |   2 +-
 include/net/fastboot.h|  21 +++
 net/Makefile  |   1 +
 net/fastboot.c| 317 ++
 net/net.c |   7 +
 18 files changed, 1338 insertions(+), 20 deletions(-)
 create mode 100644 drivers/fastboot/fb_command.c
 create mode 100644 drivers/fastboot/fb_getvar.c
 create mode 100644 include/fastboot-internal.h
 create mode 100644 include/net/fastboot.h
 create mode 100644 net/fastboot.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 98763c9108..51fa0dd08a 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -655,8 +655,8 @@ config CMD_FASTBOOT
  This enables the command "fastboot" which enables the Android
  fastboot mode 

[U-Boot] [PATCH v7 09/18] fastboot: Extract common definitions from USB fastboot

2018-05-24 Thread Alex Kiernan
Move FASTBOOT_VERSION to include/fastboot.h so when we merge the UDP code
we only have one definition.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
Acked-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- leave strcmp_l1() in USB fastboot as we don't need it in UDP path

Changes in v3:
- new

Changes in v2: None

 drivers/usb/gadget/f_fastboot.c | 2 --
 include/fastboot.h  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 697eee57d0..25784a193e 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -27,8 +27,6 @@
 #include 
 #endif
 
-#define FASTBOOT_VERSION   "0.4"
-
 #define FASTBOOT_INTERFACE_CLASS   0xff
 #define FASTBOOT_INTERFACE_SUB_CLASS   0x42
 #define FASTBOOT_INTERFACE_PROTOCOL0x03
diff --git a/include/fastboot.h b/include/fastboot.h
index 816e71b4d0..bf3d9e2f67 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -12,6 +12,8 @@
 #ifndef _FASTBOOT_H_
 #define _FASTBOOT_H_
 
+#define FASTBOOT_VERSION   "0.4"
+
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN  (64 + 1)
 
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 00/18] Add fastboot UDP support

2018-05-24 Thread Alex Kiernan

This series merges the fastboot UDP support from AOSP into mainline
U-Boot.

Changes in UDP behaviour from the AOSP code, so it follows the existing USB
behaviour:

- 'boot' now follows the USB code and does 'bootm CONFIG_FASTBOOT_BUF_ADDR'.
  I've added 'fastboot_bootcmd' which if set overrides the boot command and
  allows the existing UDP behaviour to be preserved.
- 'continue' in UDP now exits the fastboot server rather than executing
  'run bootcmd'
- 'reboot-bootloader' no longer writes 'reboot-bootloader' to
  CONFIG_FASTBOOT_BUF_ADDR as its marker for the subsequent boot. The code
  which is in AOSP common/android_bootloader.c expects this marker, but
  we have prior art in the USB code using the weak function
  fastboot_set_reboot_flag
- 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed
  variables (inherited from the USB path), these override the defaults

I've pushed both USB and UDP into a single consolidated protocol layer
now I've tested it on a BeagleBone Green.

Green Travis build: https://travis-ci.org/akiernan/u-boot/builds/383077278

Changes in v7:
- set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV
  that also have CMD_GPT

Changes in v6:
- accomodate master change and switch dependency on imx6dl_mamoj from
  FASTBOOT to USB_FUNCTION_FASTBOOT
- delete redundant FASTBOOT_FLASH_NAND_DEV symbol
- add docbook comments
- add docbook comments
- rename fastboot_download_data() to fastboot_data_download(), rename
  fastboot_get_bytes_remaining() to fastboot_data_remaining()
- split fastboot_data_complete() out from fastboot_data_download() so we
  can call it at the end of the transfer phase for USB
- merged from RFC USB fastboot series
- when entering the DATA phase ensure we actually install the correct handler
- on completion of DATA call new fastboot_data_complete()
- previous changes:
  - remove redundant version.h
  - use new fastboot_get_bytes_remaining() function
- new

Changes in v5:
- don't depend on UDP_FUNCTION_FASTBOOT until it exists
- squash in subsequent patch which updates defconfigs so we don't leave users
  of CONFIG_FASTBOOT without it enabled
- fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash
  or erase and we've not yet added fb_common.c to the build
- fix docbook formatting
- new
- new
- rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE
  and migrate it to Kconfig.
- make fastboot_bytes_received/expected static and add function
  fastboot_get_bytes_remaining()
- move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback
  into fastboot-internal.h
- delete redundant fb_ prefixes from statics
- new

Changes in v4:
- add docbook comments
- leave strcmp_l1() in USB fastboot as we don't need it in UDP path
- add docbook comments
- new
- guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
- add docbook comments
- remove parameter from fastboot_boot() since we always want
  fastboot_buf_addr (and if we're using fastboot_bootcmd then it's
  ignored)
- split oem format into new patch

Changes in v3:
- move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from
  USB_FUNCTION_FASTBOOT
- add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV
- leave images-sparse.c in common to acommodate 2f83f21
- refactor for changes in master
- Merge subsequent patch for formatting response strings into this one
- allow NULL to fastboot_okay() when there's no message to send
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION
- new
- new
- new
- new
- new
- new
- use FASTBOOT as our guard in Kconfig not a list of USB || UDP
- correct mis-translation from AOSP introduced when cleaning up for
  checkpatch - we should write when buffer is not NULL, rather than
  erasing, and erase when buffer is NULL
- use CMD_RET_USAGE from do_fastboot
- remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
- rename timed_send_info to fastboot_send_info, rename fastboot_send_info to
  fastboot_udp_send_info
- replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
- move start time into timed_send_info() rather than passing it in
- make calls to fastboot_udp_send_info a runtime dependency, not a compile
  time one
- set ${filesize} to size of downloaded image
- add progress meter from USB path during download
- add support for 'oem format' command from the USB path
- rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the
  fastboot boot command
- make getvar implementation table driven
- add fastboot_buf_addr, fastboot_buf_size to override buffer address and
  size
- return correct filesystem type in getvar partition-type on MMC
- process "fastboot." prefixed env variables in getvar first so you
  can override the normal values (this also lets you set a fs type for
  NAND devices)
- squash subsequent patches which change this code into this one:
  - If the fastboot flash/erase commands are disabled, remove that support
so we still buil

[U-Boot] [PATCH v7 17/18] usb: fastboot: Convert USB f_fastboot to shared fastboot

2018-05-24 Thread Alex Kiernan
Convert USB fastboot code to use shared fastboot protocol.

Signed-off-by: Alex Kiernan 
---

Changes in v7:
- set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV
  that also have CMD_GPT

Changes in v6:
- merged from RFC USB fastboot series
- when entering the DATA phase ensure we actually install the correct handler
- on completion of DATA call new fastboot_data_complete()
- previous changes:
  - remove redundant version.h
  - use new fastboot_get_bytes_remaining() function

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 configs/A13-OLinuXino_defconfig   |   1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig|   1 +
 configs/A20-OLinuXino-Lime2_defconfig |   1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig  |   1 +
 configs/A20-Olimex-SOM204-EVB_defconfig   |   1 +
 configs/Bananapi_m2m_defconfig|   1 +
 configs/Cubietruck_defconfig  |   1 +
 configs/Sinlinx_SinA33_defconfig  |   1 +
 configs/am335x_boneblack_defconfig|   7 +-
 configs/am57xx_evm_defconfig  |  13 +-
 configs/am57xx_hs_evm_defconfig   |  13 +-
 configs/chromebit_mickey_defconfig|   5 +-
 configs/chromebook_jerry_defconfig|   5 +-
 configs/chromebook_minnie_defconfig   |   5 +-
 configs/dra7xx_evm_defconfig  |  11 +-
 configs/dra7xx_hs_evm_defconfig   |  11 +-
 configs/evb-rk3036_defconfig  |   5 +-
 configs/evb-rk3128_defconfig  |   9 +-
 configs/evb-rk3229_defconfig  |   5 +-
 configs/evb-rk3288_defconfig  |   5 +-
 configs/evb-rk3328_defconfig  |   7 +-
 configs/fennec-rk3288_defconfig   |   5 +-
 configs/firefly-rk3288_defconfig  |   5 +-
 configs/kylin-rk3036_defconfig|   5 +-
 configs/miqi-rk3288_defconfig |   5 +-
 configs/parrot_r16_defconfig  |   1 +
 configs/phycore-rk3288_defconfig  |   5 +-
 configs/popmetal-rk3288_defconfig |   5 +-
 configs/rock2_defconfig   |   5 +-
 configs/stih410-b2260_defconfig   |  11 +-
 configs/tbs_a711_defconfig|   1 +
 configs/tinker-rk3288_defconfig   |   5 +-
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |   7 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   7 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |   7 +-
 drivers/fastboot/Makefile |   4 +-
 drivers/usb/gadget/f_fastboot.c   | 318 ++
 39 files changed, 156 insertions(+), 363 deletions(-)

diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
index 8e160d7cc4..b8ec1e54db 100644
--- a/configs/A13-OLinuXino_defconfig
+++ b/configs/A13-OLinuXino_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_AXP_ALDO3_VOLT=3300
 CONFIG_CONS_INDEX=2
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig 
b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 9d043e856a..5657fc2594 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -20,6 +20,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
diff --git a/configs/A20-OLinuXino-Lime2_defconfig 
b/configs/A20-OLinuXino-Lime2_defconfig
index f2997c6fe5..134d1d3fef 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -19,6 +19,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
diff --git a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig 
b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
index 847945b649..3bb8c4c7e6 100644
--- a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
+++ b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
@@ -18,6 +18,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_PHY_ADDR=3
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
diff --git a/configs/A20-Olimex-SOM204-EVB_defconfig 
b/configs/A20-Olimex-SOM204-EVB_defconfig
index e56f2c7110..cfb7ffa556 100644
--- a/configs/A20-Olimex-SOM204-EVB_defconfig
+++ b/configs/A20-Olimex-SOM204-EVB_defconfig
@@ -17,6 +17,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUID

[U-Boot] [PATCH v7 01/18] fastboot: Move fastboot to drivers/fastboot

2018-05-24 Thread Alex Kiernan
Separate CMD_FASTBOOT from FASTBOOT and move code and configuration to
drivers/fastboot.

Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT as anyone who wants
FASTBOOT before this series wants USB_FUNCTION_FASTBOOT. Split
USB_FUNCTION_FASTBOOT from FASTBOOT so they retain their existing
behaviour.

Signed-off-by: Alex Kiernan 
Reviewed-by: Simon Glass 
Acked-by: Joe Hershberger 
---

Changes in v7: None
Changes in v6:
- accomodate master change and switch dependency on imx6dl_mamoj from
  FASTBOOT to USB_FUNCTION_FASTBOOT

Changes in v5:
- don't depend on UDP_FUNCTION_FASTBOOT until it exists
- squash in subsequent patch which updates defconfigs so we don't leave users
  of CONFIG_FASTBOOT without it enabled
- fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash
  or erase and we've not yet added fb_common.c to the build

Changes in v4: None
Changes in v3:
- move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from
  USB_FUNCTION_FASTBOOT
- add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV
- leave images-sparse.c in common to acommodate 2f83f21

Changes in v2: None

 arch/arm/Kconfig  |  2 --
 board/ti/common/Kconfig   |  1 -
 cmd/Kconfig   | 14 ++--
 common/Makefile   | 15 +---
 configs/am335x_boneblack_defconfig|  2 +-
 configs/am335x_boneblack_vboot_defconfig  |  2 +-
 configs/am335x_evm_defconfig  |  2 +-
 configs/am335x_evm_nor_defconfig  |  2 +-
 configs/am335x_evm_norboot_defconfig  |  2 +-
 configs/am335x_evm_spiboot_defconfig  |  2 +-
 configs/am335x_evm_usbspl_defconfig   |  2 +-
 configs/am57xx_evm_defconfig  |  2 +-
 configs/am57xx_hs_evm_defconfig   |  2 +-
 configs/bcm23550_w1d_defconfig|  2 +-
 configs/bcm28155_ap_defconfig |  2 +-
 configs/birdland_bav335a_defconfig|  2 +-
 configs/birdland_bav335b_defconfig|  2 +-
 configs/cgtqmx6eval_defconfig |  2 +-
 configs/dra7xx_evm_defconfig  |  2 +-
 configs/dra7xx_hs_evm_defconfig   |  2 +-
 configs/imx6dl_mamoj_defconfig|  2 +-
 configs/kc1_defconfig |  2 +-
 configs/mx6qsabrelite_defconfig   |  2 +-
 configs/mx6sabresd_defconfig  |  2 +-
 configs/nitrogen6dl2g_defconfig   |  2 +-
 configs/nitrogen6dl_defconfig |  2 +-
 configs/nitrogen6q2g_defconfig|  2 +-
 configs/nitrogen6q_defconfig  |  2 +-
 configs/nitrogen6s1g_defconfig|  2 +-
 configs/nitrogen6s_defconfig  |  2 +-
 configs/omap3_beagle_defconfig|  2 +-
 configs/omap3_evm_defconfig   |  2 +-
 configs/omap3_logic_defconfig |  2 +-
 configs/sniper_defconfig  |  2 +-
 configs/stih410-b2260_defconfig   |  2 +-
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |  2 +-
 .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig  |  2 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |  2 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |  2 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |  2 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |  2 +-
 drivers/Kconfig   |  2 ++
 drivers/Makefile  |  3 ++
 {cmd => drivers}/fastboot/Kconfig | 35 +++
 drivers/fastboot/Makefile |  8 +
 {common => drivers/fastboot}/fb_mmc.c |  0
 {common => drivers/fastboot}/fb_nand.c|  0
 47 files changed, 75 insertions(+), 79 deletions(-)
 rename {cmd => drivers}/fastboot/Kconfig (88%)
 create mode 100644 drivers/fastboot/Makefile
 rename {common => drivers/fastboot}/fb_mmc.c (100%)
 rename {common => drivers/fastboot}/fb_nand.c (100%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d273294afd..e4c4badfbf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1256,9 +1256,7 @@ config ARCH_ROCKCHIP
select DM_REGULATOR
select ENABLE_ARM_SOC_BOOT0_HOOK
select SPI
-   imply CMD_FASTBOOT
imply DISTRO_DEFAULTS
-   imply FASTBOOT
imply FAT_WRITE
imply USB_FUNCTION_FASTBOOT
imply SPL_SYSRESET
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index c21eb8c2d2..b1956b8100 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -25,7 +25,6 @@ config TI_COMMON_CMD_OPTIONS
imply CMD_EXT2
imply CMD_EXT4
imply CMD_EXT4_WRITE
-   imply CMD_FASTBOOT if FASTBOOT
imply CMD_FAT
imply FAT_WRITE if CMD_FAT
imply CMD_FS_GENERIC
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 38406fcfda..91f6dfef92 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -137,8 +137,6 @@ config AUTOBOOT_STOP_STR_SHA256
 
 endmenu
 
-so

Re: [U-Boot] [PATCH v6 17/18] usb: fastboot: Convert USB f_fastboot to shared fastboot

2018-05-24 Thread Alex Kiernan
Hi Sam

On Tue, May 22, 2018 at 8:16 PM Alex Kiernan  wrote:


> On Tue, May 22, 2018 at 7:41 PM Sam Protsenko 
> wrote:

> > On 22 May 2018 at 18:53, Alex Kiernan  wrote:
> > > On Tue, May 22, 2018 at 4:29 PM Sam Protsenko <
> semen.protse...@linaro.org>
> > > wrote:
> > >
> > >> On 22 May 2018 at 18:21, Sam Protsenko 
> wrote:
> > >> > On 22 May 2018 at 12:23, Alex Kiernan 
wrote:
> > >> >> Convert USB fastboot code to use shared fastboot protocol.
> > >> >>
> > >> >> Signed-off-by: Alex Kiernan 
> > >> >> ---
> > >> >>
> > >> >> Changes in v6:
> > >> >> - merged from RFC USB fastboot series
> > >> >> - when entering the DATA phase ensure we actually install the
> correct
> > > handler
> > >> >> - on completion of DATA call new fastboot_data_complete()
> > >> >> - previous changes:
> > >> >>   - remove redundant version.h
> > >> >>   - use new fastboot_get_bytes_remaining() function
> > >> >
> > >> > Hi Alex,
> > >> >
> > >> > I tested this new patch series (v6) on X15 board, and this patch
> still
> > >> > breaks "fastboot oem format". I see next messages.
> > >> >
> > >> > On host:
> > >> >
> > >> > FAILED (remote: unrecognized command)
> > >> >
> > >> > On device:
> > >> >
> > >> > command oem format not recognized.
> > >> >
> > >> > All other fastboot commands seem to work fine, though. Can you
please
> > >> > look into it? I can help you with testing on my boards, if you are
> > >> > unable to reproduce it. You can prepare GitHub branch for debugging
> > >> > and ask me to check that, I will send you the output.
> > >> >
> > >> > Thanks.
> > >
> > >> Btw, I looked in my .config, and I see that:
> > >
> > >>  # CONFIG_FASTBOOT_CMD_OEM_FORMAT is not set
> > >
> > >> What I think should be done, is in your patch:
> > >
> > >>  fastboot: Add support for 'oem format' command
> > >
> > >> make default=y for FASTBOOT_CMD_OEM_FORMAT. Or add that to all boards
> > >> that use "fastboot oem format". Not sure what is proper way here, but
> > >> defaulting it to "n" (like it's done now) might break a lot of
boards.
> > >
> > > Oh bother... and thank you for testing (again).
> > >
> > > I guess if we enable it on all boards that currently select USB
> fastboot as
> > > part of the patch that merges USB and UDP, then we'll get all existing
> > > boards and don't end up with a default y?
> > >

> > As I see it, the only correct approach in this case is to keep it as
> > it was before. So basically all configs that defined
> > FASTBOOT_FLASH_MMC_DEV option (explicitly or implicitly), should also
> > have FASTBOOT_CMD_OEM_FORMAT enabled.


> Yeah, that's more or less what I've done... I've added it to boards that
> match FASTBOOT_FLASH_MMC_DEV && CMD_GPT (since that's what the
> implementation uses) - there's 37 of them. There's another 7 that have
> FASTBOOT_FLASH_MMC_DEV but don't have CMD_GPT.


Just posted a version which includes these changes (in fact it's the only
change from v6).

It's also here - https://github.com/akiernan/u-boot/tree/us-fastboot-udp-v7

-- 
Alex Kiernan
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] fit: allow fit to call hardware accelerated hash

2018-05-24 Thread Ben Whitten
Move to calling the abstraction which allows for hardware acceleration.

Signed-off-by: Ben Whitten 
---
 common/image-fit.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 8c15ed1..01ea864 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1082,19 +1082,25 @@ int fit_set_timestamp(void *fit, int noffset, time_t 
timestamp)
 int calculate_hash(const void *data, int data_len, const char *algo,
uint8_t *value, int *value_len)
 {
+   struct hash_algo *hash_algo;
+   int ret;
+
+   ret = hash_lookup_algo(algo, &hash_algo);
+   if (ret)
+   return ret;
+
if (IMAGE_ENABLE_CRC32 && strcmp(algo, "crc32") == 0) {
-   *((uint32_t *)value) = crc32_wd(0, data, data_len,
-   CHUNKSZ_CRC32);
-   *((uint32_t *)value) = cpu_to_uimage(*((uint32_t *)value));
-   *value_len = 4;
+   hash_algo->hash_func_ws((unsigned char *)data, data_len,
+   (unsigned char *)value, hash_algo->chunk_size);
+   *value_len = hash_algo->digest_size;
} else if (IMAGE_ENABLE_SHA1 && strcmp(algo, "sha1") == 0) {
-   sha1_csum_wd((unsigned char *)data, data_len,
-(unsigned char *)value, CHUNKSZ_SHA1);
-   *value_len = 20;
+   hash_algo->hash_func_ws((unsigned char *)data, data_len,
+   (unsigned char *)value, hash_algo->chunk_size);
+   *value_len = hash_algo->digest_size;
} else if (IMAGE_ENABLE_SHA256 && strcmp(algo, "sha256") == 0) {
-   sha256_csum_wd((unsigned char *)data, data_len,
-  (unsigned char *)value, CHUNKSZ_SHA256);
-   *value_len = SHA256_SUM_LEN;
+   hash_algo->hash_func_ws((unsigned char *)data, data_len,
+   (unsigned char *)value, hash_algo->chunk_size);
+   *value_len = hash_algo->digest_size;
} else if (IMAGE_ENABLE_MD5 && strcmp(algo, "md5") == 0) {
md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
*value_len = 16;
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] crypto: add Atmel hardware acceleration for SHA1 & 256

2018-05-24 Thread Ben Whitten
We can use the hardware hash block to reduce space, particularly useful
for verifying FIT signatures from SPL.

Signed-off-by: Ben Whitten 
---
 drivers/crypto/Kconfig |   5 +
 drivers/crypto/Makefile|   1 +
 drivers/crypto/atmel_sha.c | 289 +
 drivers/crypto/atmel_sha.h |  52 
 lib/Makefile   |   2 +
 5 files changed, 349 insertions(+)
 create mode 100644 drivers/crypto/atmel_sha.c
 create mode 100644 drivers/crypto/atmel_sha.h

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 1ea116b..7a20edb 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -2,4 +2,9 @@ menu "Hardware crypto devices"
 
 source drivers/crypto/fsl/Kconfig
 
+config ATMEL_SHA
+   bool "Atmel SHA Driver support"
+   help
+ Enables the Atmel SHA accelerator.
+
 endmenu
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index efbd1d3..07af449 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -4,5 +4,6 @@
 #  http://www.samsung.com
 
 obj-$(CONFIG_EXYNOS_ACE_SHA)   += ace_sha.o
+obj-$(CONFIG_ATMEL_SHA)+= atmel_sha.o
 obj-y += rsa_mod_exp/
 obj-y += fsl/
diff --git a/drivers/crypto/atmel_sha.c b/drivers/crypto/atmel_sha.c
new file mode 100644
index 000..ef969eb
--- /dev/null
+++ b/drivers/crypto/atmel_sha.c
@@ -0,0 +1,289 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Atmel SHA engine
+ * Copyright (c) 2018  Laird
+ */
+
+#include 
+#include 
+#include "atmel_sha.h"
+
+#ifdef CONFIG_SHA_HW_ACCEL
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+enum atmel_hash_algos {
+   ATMEL_HASH_SHA1,
+   ATMEL_HASH_SHA256
+};
+
+struct sha_ctx {
+   enum atmel_hash_algos algo;
+   u32 length;
+   u8  buffer[64];
+};
+
+const u8 sha256_der_prefix[SHA256_DER_LEN] = {
+   0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
+   0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
+   0x00, 0x04, 0x20
+};
+
+const u8 sha1_der_prefix[SHA1_DER_LEN] = {
+   0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
+   0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
+};
+
+static enum atmel_hash_algos get_hash_type(struct hash_algo *algo)
+{
+   if (!strcmp(algo->name, "sha1"))
+   return ATMEL_HASH_SHA1;
+   else
+   return ATMEL_HASH_SHA256;
+};
+
+static int atmel_sha_process(const u8 *in_addr, u8 buflen)
+{
+   struct atmel_sha *sha = (struct atmel_sha *)ATMEL_BASE_SHA;
+   int i;
+   u32 *addr_buf;
+
+   /* Copy data in */
+   addr_buf = (u32 *)in_addr;
+   for (i = 0; i < (buflen / 4); i++)
+   sha->idatarx[i] = addr_buf[i];
+   debug("Atmel sha, engine is loaded\n");
+
+   /* Wait for hash to complete */
+   while ((readl(&sha->isr) & ATMEL_HASH_ISR_MASK)
+   != ATMEL_HASH_ISR_DATRDY)
+   ;
+   debug("Atmel sha, engine signaled completion\n");
+
+   return 0;
+}
+
+static int atmel_sha_chunk(struct sha_ctx *ctx, const u8 *buf, unsigned int 
size)
+{
+   u8 remaining, fill;
+
+   /* Chunk to 64 byte blocks */
+   remaining = ctx->length & 0x3F;
+   fill = 64 - remaining;
+
+   /* If we have things in the buffer transfer the remaining into it */
+   if (remaining && size >= fill) {
+   memcpy(ctx->buffer + remaining, buf, fill);
+
+   /* Process 64 byte chunk */
+   atmel_sha_process(ctx->buffer, 64);
+
+   size -= fill;
+   buf += fill;
+   ctx->length += fill;
+   remaining = 0;
+   }
+
+   /* We are aligned take from source for any additional */
+   while (size >= 64) {
+   /* Process 64 byte chunk */
+   atmel_sha_process(buf, 64);
+
+   size -= 64;
+   buf += 64;
+   ctx->length += 64;
+   }
+
+   if (size) {
+   memcpy(ctx->buffer + remaining, buf, size);
+   ctx->length += size;
+   }
+
+   return 0;
+}
+
+static int atmel_sha_fill_padding(struct sha_ctx *ctx)
+{
+   unsigned int index, padlen;
+   u64 size, bits;
+   u8 sha256_padding[64] = {
+   0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+   };
+
+   size = ctx->length;
+
+   bits = cpu_to_be64(size << 3);
+
+   /* 64 byte, 512 bit block size */
+   index = ctx->length & 0x3F;
+   padlen = (index < 56) ? (56 - index) : ((64 + 56) - index);
+
+   /* set last entry to be 0x80 then 0's*/
+   atmel_sha_chunk(ctx, sha256_padding, padlen);
+   /* Bolt number of bits to the end */
+   atmel_sha_chunk(ctx, (u8 *)&bits, 8);
+
+   if (ctx->length & 0x3F)
+   debug("ERROR, Remainder after PADDING");

[U-Boot] [PATCH] board: STiH410-B2260: Add pxefile_addr_r variable

2018-05-24 Thread riku . voipio
From: Riku Voipio 

Reading doc/README.distro , we see platform needs to set
pxefile_addr_r to support distro boot.

Signed-off-by: Riku Voipio 
---
 include/configs/stih410-b2260.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/stih410-b2260.h b/include/configs/stih410-b2260.h
index b4e4619266..d8bf3b6580 100644
--- a/include/configs/stih410-b2260.h
+++ b/include/configs/stih410-b2260.h
@@ -31,6 +31,7 @@
"fdtfile=stih410-b2260.dtb\0"   \
"fdt_addr_r=0x4700\0"   \
"scriptaddr=0x5000\0"   \
+   "pxefile_addr_r=0x5010\0"   \
"fdt_high=0x\0" \
"initrd_high=0x\0"  \
"ramdisk_addr_r=0x4800\0"   \
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >