Re: [PATCH] usb: xhci: fix event trb handling missed

2020-11-05 Thread Bin Meng
On Tue, Sep 22, 2020 at 7:41 PM Marek Vasut  wrote:
>
> On 9/22/20 6:54 AM, Ran Wang wrote:
> > In functiion xhci_bulk_tx(), when buffer cross 64KB boundary, it will
> > send request in more than 1 Transfer TRB by chaining them, but then handle
> > only 1 event TRB to mark request completed.
> >
> > However, on Layerscape platforms (LS1028A, LS1088A, etc), we observe xhci
> > controller will generated more than 1 event TRB sometimes, this cause that
> > function mishandle event TRB in next round call, then system hang due to
> > BUG() checking.
> >
> > This patch adds a loop to make sure the event TRB for last Transfer TRB has
> > to be handled in time.
>
> Bin, can you please take a look at this one ? Thanks

Sorry I missed this one. Will take a look at this soon.

Regards,
Bin


Re: [PATCH] env: env_sf: don't set .init op if not needed

2020-11-05 Thread Rasmus Villemoes
On 05/11/2020 17.40, Wolfgang Denk wrote:
> Dear Rasmus,
> 
> In message <8ff3b8ad-8c4e-fe99-69c8-7c174e997...@prevas.dk> you wrote:
>>
 Not in a none standard way! Instead you can define more than one
 environment storage devices and load them in a board specific order
 (defined thorugh board specfif function env_get_location())
>>>
>>> Yes, agreed.  But this logically impossible if there is no storage
>>> at all, which is what CONFIG_ENV_IS_NOWHERE says.
>>
>> Then should all the current config options CONFIG_ENV_IS_ be renamed to
>> CONFIG_ENV_MAY_BE_? Because that's really what they mean.
> 
> This is not correct.
> 
> The CONFIG_ENV_IS_FOO means: if you use "env save", then U-Boot will
> write the config to external storage using the FOO storage device.

Wolfgang, you're wrong. What you're saying was once true, when the
location was a "choice" in Kconfig, but it hasn't been that since
fb69464eae. Nowadays one can select multiple possible backends, and only
one of them will be used when doing "env save".

Later (208bd2b8), _NOWHERE was made non-mutually-exclusive with the real
storage targets.

> If you define CONFIG_ENV_IS_NOWHERE, I would for example expect that
> all "env save" related code is omitted as we will never need it.

I haven't checked, but that functionality does seem to exist - not
depending on whether CONFIG_ENV_IS_NOWHERE is not selected, but whether
any of the CONFIG_ENV_IS_ is. See the ENV_IS_IN_DEVICE logic
in cmd/nvedit.c. So if you select CONFIG_ENV_IS_NOWHERE and not any of
the others, I think the build works as you'd expect.

Rasmus


Re: [PATCH] arm: mvebu: a38x: Configurable USB2 high-speed impedance threshold

2020-11-05 Thread Stefan Roese

On 06.11.20 05:08, Joshua Scott wrote:

Hardware testing of a board using the Armada 385 has shown that an
impedance threshold setting of 0x7 performs better in an eye-diagram
test than with Marvell's recommended value 0x6.

As other boards may still perform better with Marvell's reccomended value,
a configuration option is added with a default value of 0x6.

Signed-off-by: Joshua Scott 
Cc: Stefan Roese 
---
  arch/arm/mach-mvebu/Kconfig   | 5 +
  arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c | 6 +++---
  2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 0d8e0922a2..bec011e584 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -30,6 +30,11 @@ config ARMADA_38X
select ARMADA_32BIT
select HAVE_MVEBU_EFUSE
  
+config ARMADA_38X_HS_IMPEDANCE_THRESH

+   hex  "Armada 38x USB 2.0 High-Speed Impedance Threshold (0x0 - 0x7)"
+   depends on ARMADA_38X
+   default 0x6
+


Please add "range" here (range 0 7), so that no unsupported values can
be chosen here.

Other than that:

Reviewed-by: Stefan Roese 

Thanks,
Stefan


  config ARMADA_XP
bool
select ARMADA_32BIT
diff --git a/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c 
b/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
index 2454730e6d..ae2a361104 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
+++ b/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
@@ -677,9 +677,9 @@ struct op_params usb2_power_up_params[] = {
{0xc200c, 0x0 /*NA*/, 0xf000, {0x1000}, 0, 0},
{0xc400c, 0x0 /*NA*/, 0xf000, {0x1000}, 0, 0},
/* Change the High speed impedance threshold */
-   {0xc0008, 0x0 /*NA*/, 0x700, {0x600}, 0, 0},
-   {0xc2008, 0x0 /*NA*/, 0x700, {0x600}, 0, 0},
-   {0xc4008, 0x0 /*NA*/, 0x700, {0x600}, 0, 0},
+   {0xc0008, 0x0 /*NA*/, 0x700, {CONFIG_ARMADA_38X_HS_IMPEDANCE_THRESH << 
8}, 0, 0},
+   {0xc2008, 0x0 /*NA*/, 0x700, {CONFIG_ARMADA_38X_HS_IMPEDANCE_THRESH << 
8}, 0, 0},
+   {0xc4008, 0x0 /*NA*/, 0x700, {CONFIG_ARMADA_38X_HS_IMPEDANCE_THRESH << 
8}, 0, 0},
/* Change the squelch level of the receiver to meet the receiver 
electrical measurements (squelch and receiver sensitivity tests) */
{0xc0014, 0x0 /*NA*/, 0xf, {0x8}, 0, 0},
{0xc2014, 0x0 /*NA*/, 0xf, {0x8}, 0, 0},




Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


[PATCH v1 2/4] ARM: dts: stm32: DT sync with kernel v5.10-rc1 for MCU's boards

2020-11-05 Thread Patrice Chotard
Device tree alignment with kernel v5.10-rc1.

Signed-off-by: Patrice Chotard 
---

 arch/arm/dts/stm32429i-eval-u-boot.dtsi  |   2 +-
 arch/arm/dts/stm32429i-eval.dts  |  21 +++--
 arch/arm/dts/stm32746g-eval-u-boot.dtsi  |   4 +-
 arch/arm/dts/stm32746g-eval.dts  |  13 ++-
 arch/arm/dts/stm32f4-pinctrl.dtsi| 107 ---
 arch/arm/dts/stm32f429-disco-u-boot.dtsi |   2 +-
 arch/arm/dts/stm32f429-disco.dts |  99 -
 arch/arm/dts/stm32f429.dtsi  |  30 +--
 arch/arm/dts/stm32f469-disco-u-boot.dtsi |   6 +-
 arch/arm/dts/stm32f469-disco.dts |  19 ++--
 arch/arm/dts/stm32f469.dtsi  |   1 -
 arch/arm/dts/stm32f7-pinctrl.dtsi|  22 ++---
 arch/arm/dts/stm32f7-u-boot.dtsi |   3 +-
 arch/arm/dts/stm32f746-disco-u-boot.dtsi |   4 +-
 arch/arm/dts/stm32f746-disco.dts |   2 +-
 arch/arm/dts/stm32f746.dtsi  |  12 ++-
 arch/arm/dts/stm32f769-disco-u-boot.dtsi |   4 +-
 arch/arm/dts/stm32f769-disco.dts |   6 +-
 arch/arm/dts/stm32h743-pinctrl.dtsi  |  10 +--
 arch/arm/dts/stm32h743.dtsi  |  37 +---
 arch/arm/dts/stm32h743i-disco.dts|   2 +-
 arch/arm/dts/stm32h743i-eval.dts |   2 +-
 22 files changed, 308 insertions(+), 100 deletions(-)

diff --git a/arch/arm/dts/stm32429i-eval-u-boot.dtsi 
b/arch/arm/dts/stm32429i-eval-u-boot.dtsi
index fe437bbfe2..1e7429b2c6 100644
--- a/arch/arm/dts/stm32429i-eval-u-boot.dtsi
+++ b/arch/arm/dts/stm32429i-eval-u-boot.dtsi
@@ -136,7 +136,7 @@
 };
 
  {
-   usart1_pins_a: usart1@0 {
+   usart1_pins_a: usart1-0 {
u-boot,dm-pre-reloc;
pins1 {
u-boot,dm-pre-reloc;
diff --git a/arch/arm/dts/stm32429i-eval.dts b/arch/arm/dts/stm32429i-eval.dts
index c5afa0c162..592b182c1a 100644
--- a/arch/arm/dts/stm32429i-eval.dts
+++ b/arch/arm/dts/stm32429i-eval.dts
@@ -19,7 +19,7 @@
stdout-path = "serial0:115200n8";
};
 
-   memory {
+   memory@ {
device_type = "memory";
reg = <0x 0x200>;
};
@@ -54,19 +54,26 @@
regulator-max-microvolt = <330>;
};
 
+   vdd_panel: vdd-panel {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_panel";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
leds {
compatible = "gpio-leds";
-   green {
+   led-green {
gpios = < 6 1>;
linux,default-trigger = "heartbeat";
};
-   orange {
+   led-orange {
gpios = < 7 1>;
};
-   red {
+   led-red {
gpios = < 10 1>;
};
-   blue {
+   led-blue {
gpios = < 12 1>;
};
};
@@ -97,6 +104,7 @@
 
panel_rgb: panel-rgb {
compatible = "ampire,am-480272h3tmqw-t01h";
+   power-supply = <_panel>;
status = "okay";
port {
panel_in_rgb: endpoint {
@@ -191,9 +199,8 @@
 
  {
status = "okay";
-   pinctrl-0 = <_pins>;
+   pinctrl-0 = <_pins_a>;
pinctrl-names = "default";
-   dma-ranges;
 
port {
ltdc_out_rgb: endpoint {
diff --git a/arch/arm/dts/stm32746g-eval-u-boot.dtsi 
b/arch/arm/dts/stm32746g-eval-u-boot.dtsi
index d5fb92795d..f2195a6c51 100644
--- a/arch/arm/dts/stm32746g-eval-u-boot.dtsi
+++ b/arch/arm/dts/stm32746g-eval-u-boot.dtsi
@@ -165,7 +165,7 @@
};
};
 
-   usart1_pins_a: usart1@0 {
+   usart1_pins_a: usart1-0 {
u-boot,dm-pre-reloc;
pins1 {
u-boot,dm-pre-reloc;
@@ -178,7 +178,7 @@
 
  {
reg = <0xA0001000 0x1000>, <0x9000 0x400>;
-   qflash0: n25q512a {
+   qflash0: n25q512a@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "jedec,spi-nor";
diff --git a/arch/arm/dts/stm32746g-eval.dts b/arch/arm/dts/stm32746g-eval.dts
index d77eb53c6a..9940cf1873 100644
--- a/arch/arm/dts/stm32746g-eval.dts
+++ b/arch/arm/dts/stm32746g-eval.dts
@@ -19,7 +19,7 @@
stdout-path = "serial0:115200n8";
};
 
-   memory {
+   memory@c000 {
device_type = "memory";
reg = <0xc000 0x200>;
};
@@ -30,17 +30,17 @@
 
leds {
compatible = "gpio-leds";
-   green {
+   led-green {
gpios = < 10 1>;
linux,default-trigger = "heartbeat";
};
-   orange {
+   led-orange {

[PATCH v1 4/4] ARM: dts: stm32: Fix typo in stm32h7-u-boot.dtsi

2020-11-05 Thread Patrice Chotard
Fix typo "firsct"

Signed-off-by: Patrice Chotard 

---

 arch/arm/dts/stm32h7-u-boot.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/stm32h7-u-boot.dtsi b/arch/arm/dts/stm32h7-u-boot.dtsi
index 7182533cc9..54dd406b6b 100644
--- a/arch/arm/dts/stm32h7-u-boot.dtsi
+++ b/arch/arm/dts/stm32h7-u-boot.dtsi
@@ -39,7 +39,7 @@
 
/*
 * Memory configuration from sdram datasheet 
IS42S32800G-6BLI
-* firsct bank is bank@0
+* first bank is bank@0
 * second bank is bank@1
 */
bank1: bank@1 {
-- 
2.17.1



[PATCH v1 1/4] ARM: dts: sync armv7-m.dtsi with kernel v5.10-rc1

2020-11-05 Thread Patrice Chotard
Since kernel v4.8-rc1, commit 05b23ebc2bd9 ("ARM: dts: armv7-m: remove 
skeleton.dtsi include"),
skeleton.dtsi file is no more included.

This synchronization is needed to avoid to get 2 memory node
in DTB file if, in DTS file, memory node is declared with the correct
syntax as following:

memory@9000 {
device_type = "memory";
reg = <0x9000 0x80>;
};

Then in DTB, we will have the 2 memory nodes, which is incorrect and
cause misbehavior during DT parsing by U-boot:

memory {
device_type = "memory";
reg = <0x00 0x00>;
};

memory@9000 {
device_type = "memory";
reg = <0x9000 0x80>;
};

Issue found when synchronizing MCU's STM32 DT from kernel v5.10-rc1.
When using fdtdec_setup_mem_size_base() or fdtdec_setup_memory_banksize()
API, first above memory node is found (with reg = <0x00 0x00>), so
gd->ram_size, gd->ram_base, gd->bd->bi_dram[bank].start and
gd->bd->bi_dram[bank].size are all set to 0 which avoid boards to boot.

Signed-off-by: Patrice Chotard 
---

 arch/arm/dts/armv7-m.dtsi | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/dts/armv7-m.dtsi b/arch/arm/dts/armv7-m.dtsi
index 31349da75a..26f5443d85 100644
--- a/arch/arm/dts/armv7-m.dtsi
+++ b/arch/arm/dts/armv7-m.dtsi
@@ -1,5 +1,4 @@
-#include "skeleton.dtsi"
-
+// SPDX-License-Identifier: GPL-2.0
 / {
nvic: interrupt-controller@e000e100  {
compatible = "arm,armv7m-nvic";
@@ -22,4 +21,3 @@
ranges;
};
 };
-
-- 
2.17.1



[PATCH v1 3/4] ARM: dts: stm32: Fix timer initialization for stm32 MCU's board

2020-11-05 Thread Patrice Chotard
Commit 4b2be78ab66c ("time: Fix get_ticks being non-monotonic")
puts in evidence that get_ticks is called before timer initialization.
Fix it by initializing timer before relocation.

Signed-off-by: Patrice Chotard 
---

 arch/arm/dts/stm32429i-eval-u-boot.dtsi  |  4 
 arch/arm/dts/stm32f429-disco-u-boot.dtsi |  4 
 arch/arm/dts/stm32f469-disco-u-boot.dtsi | 20 
 arch/arm/dts/stm32f746-disco-u-boot.dtsi |  4 
 arch/arm/dts/stm32h7-u-boot.dtsi |  4 
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/arch/arm/dts/stm32429i-eval-u-boot.dtsi 
b/arch/arm/dts/stm32429i-eval-u-boot.dtsi
index 1e7429b2c6..e75cf99f8f 100644
--- a/arch/arm/dts/stm32429i-eval-u-boot.dtsi
+++ b/arch/arm/dts/stm32429i-eval-u-boot.dtsi
@@ -217,3 +217,7 @@
};
};
 };
+
+ {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/stm32f429-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f429-disco-u-boot.dtsi
index 77d5ea07bb..df99e01393 100644
--- a/arch/arm/dts/stm32f429-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f429-disco-u-boot.dtsi
@@ -192,3 +192,7 @@
  {
u-boot,dm-pre-reloc;
 };
+
+ {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/stm32f469-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
index 3cf3a6aa6f..7223ba4a60 100644
--- a/arch/arm/dts/stm32f469-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
@@ -235,14 +235,6 @@
u-boot,dm-pre-reloc;
 };
 
- {
-   u-boot,dm-pre-reloc;
-};
-
- {
-   u-boot,dm-pre-reloc;
-};
-
  {
reg = <0xA0001000 0x1000>, <0x9000 0x100>;
flash0: n25q128a@0 {
@@ -255,3 +247,15 @@
reg = <0>;
};
 };
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/stm32f746-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f746-disco-u-boot.dtsi
index 860dd77668..4f34fc9a8c 100644
--- a/arch/arm/dts/stm32f746-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f746-disco-u-boot.dtsi
@@ -239,7 +239,3 @@
reg = <0>;
};
 };
-
- {
-   u-boot,dm-pre-reloc;
-};
diff --git a/arch/arm/dts/stm32h7-u-boot.dtsi b/arch/arm/dts/stm32h7-u-boot.dtsi
index 361c8e5d80..7182533cc9 100644
--- a/arch/arm/dts/stm32h7-u-boot.dtsi
+++ b/arch/arm/dts/stm32h7-u-boot.dtsi
@@ -218,3 +218,7 @@
  {
compatible = "st,stm32-sdmmc2", "arm,pl18x", "arm,primecell";
 };
+
+ {
+   u-boot,dm-pre-reloc;
+};
-- 
2.17.1



[PATCH v1 0/4] ARM: dts: STM32: MCU's DT update

2020-11-05 Thread Patrice Chotard
   - Sync STM32 MCU's DT with kernel v5.10-rc1
   - Fix typo
   - Fix timer init
   - Sync armv7-m.dtsi with kernel v5.10-rc1


Patrice Chotard (4):
  ARM: dts: sync armv7-m.dtsi with kernel v5.10-rc1
  ARM: dts: stm32: DT sync with kernel v5.10-rc1 for MCU's boards
  ARM: dts: stm32: Fix timer initialization for stm32 MCU's board
  ARM: dts: stm32: Fix typo in stm32h7-u-boot.dtsi

 arch/arm/dts/armv7-m.dtsi|   4 +-
 arch/arm/dts/stm32429i-eval-u-boot.dtsi  |   6 +-
 arch/arm/dts/stm32429i-eval.dts  |  21 +++--
 arch/arm/dts/stm32746g-eval-u-boot.dtsi  |   4 +-
 arch/arm/dts/stm32746g-eval.dts  |  13 ++-
 arch/arm/dts/stm32f4-pinctrl.dtsi| 107 ---
 arch/arm/dts/stm32f429-disco-u-boot.dtsi |   6 +-
 arch/arm/dts/stm32f429-disco.dts |  99 -
 arch/arm/dts/stm32f429.dtsi  |  30 +--
 arch/arm/dts/stm32f469-disco-u-boot.dtsi |  26 +++---
 arch/arm/dts/stm32f469-disco.dts |  19 ++--
 arch/arm/dts/stm32f469.dtsi  |   1 -
 arch/arm/dts/stm32f7-pinctrl.dtsi|  22 ++---
 arch/arm/dts/stm32f7-u-boot.dtsi |   3 +-
 arch/arm/dts/stm32f746-disco-u-boot.dtsi |   8 +-
 arch/arm/dts/stm32f746-disco.dts |   2 +-
 arch/arm/dts/stm32f746.dtsi  |  12 ++-
 arch/arm/dts/stm32f769-disco-u-boot.dtsi |   4 +-
 arch/arm/dts/stm32f769-disco.dts |   6 +-
 arch/arm/dts/stm32h7-u-boot.dtsi |   6 +-
 arch/arm/dts/stm32h743-pinctrl.dtsi  |  10 +--
 arch/arm/dts/stm32h743.dtsi  |  37 +---
 arch/arm/dts/stm32h743i-disco.dts|   2 +-
 arch/arm/dts/stm32h743i-eval.dts |   2 +-
 24 files changed, 334 insertions(+), 116 deletions(-)

-- 
2.17.1



[PATCH 0/2] Fix the potential warning without DM_REGULATOR

2020-11-05 Thread Jaehoon Chung
When CONFIG_DM_REGULATOR is disabled, there are some warnings.
This patch-set is fixed them.

drivers/phy/meson-g12a-usb2.c: In function 'phy_meson_g12a_usb2_power_on':
drivers/phy/meson-g12a-usb2.c:70:35: warning: unused variable 'priv' 
[-Wunused-variable]
   70 |  struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
  |   ^~~~
drivers/phy/meson-g12a-usb2.c: In function 'phy_meson_g12a_usb2_power_off':
drivers/phy/meson-g12a-usb2.c:86:35: warning: unused variable 'priv' 
[-Wunused-variable]
   86 |  struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
  |   ^~~~
  LD  drivers/phy/built-in.o
  CC  drivers/video/simple_panel.o
  CC  drivers/video/meson/meson_dw_hdmi.o
drivers/video/meson/meson_dw_hdmi.c: In function 'meson_dw_hdmi_probe':
drivers/video/meson/meson_dw_hdmi.c:382:18: warning: unused variable 'supply' 
[-Wunused-variable]
  382 |  struct udevice *supply;
  |  ^~

Jaehoon Chung (2):
  phy: meson-g12a-usb2: fix the potential build warning
  video: meson: meson_dw_hdmi: fix the potential build warning

 drivers/phy/meson-g12a-usb2.c   | 4 ++--
 drivers/video/meson/meson_dw_hdmi.c | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.29.0



[PATCH 2/2] video: meson: meson_dw_hdmi: fix the potential build warning

2020-11-05 Thread Jaehoon Chung
Fix the potential build warning.

Signed-off-by: Jaehoon Chung 
---
 drivers/video/meson/meson_dw_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/meson/meson_dw_hdmi.c 
b/drivers/video/meson/meson_dw_hdmi.c
index 7b2ff94eba58..5d74f7f1a740 100644
--- a/drivers/video/meson/meson_dw_hdmi.c
+++ b/drivers/video/meson/meson_dw_hdmi.c
@@ -379,7 +379,9 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
struct meson_dw_hdmi *priv = dev_get_priv(dev);
struct reset_ctl_bulk resets;
struct clk_bulk clocks;
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
struct udevice *supply;
+#endif
int ret;
 
priv->dev = dev;
-- 
2.29.0



[PATCH 1/2] phy: meson-g12a-usb2: fix the potential build warning

2020-11-05 Thread Jaehoon Chung
Fix the potential build warning.

Signed-off-by: Jaehoon Chung 
---
 drivers/phy/meson-g12a-usb2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
index a1e621975867..447ce7283db2 100644
--- a/drivers/phy/meson-g12a-usb2.c
+++ b/drivers/phy/meson-g12a-usb2.c
@@ -66,10 +66,10 @@ struct phy_meson_g12a_usb2_priv {
 
 static int phy_meson_g12a_usb2_power_on(struct phy *phy)
 {
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
struct udevice *dev = phy->dev;
struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
 
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->phy_supply) {
int ret = regulator_set_enable(priv->phy_supply, true);
if (ret)
@@ -82,10 +82,10 @@ static int phy_meson_g12a_usb2_power_on(struct phy *phy)
 
 static int phy_meson_g12a_usb2_power_off(struct phy *phy)
 {
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
struct udevice *dev = phy->dev;
struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
 
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->phy_supply) {
int ret = regulator_set_enable(priv->phy_supply, false);
if (ret) {
-- 
2.29.0



Please pull u-boot-x86

2020-11-05 Thread Bin Meng
Hi Tom,

This PR includes the following changes for v2021.01 release:

- Add a new SMBIOS parser and enable it when booting from coreboot
- Fix up various driver names to avoid dtoc warnings
- Fully enable ACPI support on Google Chromebook Coral
- Add a way to set SMBIOS properties using the devicetree
- Update existing boards to use devicetree for SMBIOS using a new
default sysinfo driver

Azure results: PASS
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=299=results

The following changes since commit 35b7ca768f7d826b77d5d3d6ccd6b1b8ed21f186:

  arch: Move NEEDS_MANUAL_RELOC symbol to Kconfig (2020-11-04 10:13:44 -0500)

are available in the git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-x86

for you to fetch changes up to e4f8e543f1a905857a753a1d411997a81f4f52aa:

  smbios: Drop the unused Kconfig options (2020-11-06 10:26:32 +0800)


Christian Gmeiner (2):
  smbios: add parsing API
  coreboot: make use of smbios parser

Simon Glass (48):
  cros_ec: Fix up driver names to avoid dtoc warnings
  x86: Fix up driver names to avoid dtoc warnings
  Add an assembly guard around linux/bitops.h
  x86: apl: Add core init for the SoC
  x86: Add a layout for Chrome OS verified boot
  x86: Add support for private files
  x86: Allow writing tables to fail
  x86: acpi: Store the ACPI context in global_data
  x86: Don't bother clearing global NVS
  x86: coral: Drop the duplicate PCIe settings
  x86: Add SMBIOS info for Coral
  x86: Use if instead of #ifdef in write_tables()
  x86: Allow putting some tables in the bloblist
  x86: nhlt: Correct output of bytes and 16-bit data
  x86: nhlt: Fix a few bugs in the table generation
  x86: Show the interrupt pointer with 'irqinfo'
  x86: sound: Correct error handling
  acpi: Correct reset handling in acpi_device_add_power_res()
  x86: acpi: Allow the SSDT to be empty
  x86: acpi: Put the generated code first in DSDT
  acpi: Don't reset the tables with every new generation
  x86: Define the Chrome OS GNVS region
  x86: Use CONFIG_CHROMEOS_VBOOT for verified boot
  x86: Set up Chrome OS to boot into developer mode
  x86: Boot coral into Chrome OS by default
  x86: fsp: Convert fsp_dram to use log_debug()
  x86: Silence some logging statements
  x86: acpi: Include the TPMv1 table only if needed
  x86: acpi: Don't show the UART address by default
  x86: pinctrl: Silence the warning when a pin is not found
  x86: fsp: Adjust calculations for MTRR range and DRAM top
  x86: zimage: Add a little more logging
  x86: zimage: Sanity-check the kernel version before printing it
  x86: zimage: Quieten down the zimage boot process
  board: Rename uclass to sysinfo
  doc: Add a binding for sysinfo
  x86: Pass an ofnode into each SMBIOS function
  smbios: Allow properties to come from the device tree
  smbios: Add more properties
  smbios: Add documentation and devicetree binding
  sysinfo: Provide a default driver to set SMBIOS values
  rockchip: Use devicetree for SMBIOS settings
  imx: Use devicetree for SMBIOS settings on MYiR MYS-6ULX
  odroid-c2: Use devicetree for SMBIOS settings
  arm64: mvebu: Use devicetree for SMBIOS settings on uDPU
  x86: galileo: Use devicetree for SMBIOS settings
  x86: Provide default SMBIOS manufacturer/product
  smbios: Drop the unused Kconfig options

 arch/Kconfig
|   2 ++
 arch/arm/dts/armada-3720-uDPU-u-boot.dtsi
|  20 +++
 arch/arm/dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts
|  25 ++
 arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi
|  23 +
 arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
|  21 
 arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
|  23 +
 arch/arm/dts/rk3328-rock64-u-boot.dtsi
|  21 
 arch/arm/dts/rk3368-lion-u-boot.dtsi
|  20 +++
 arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
|   2 +-
 arch/sandbox/dts/test.dts
|   8 ++---
 arch/x86/cpu/apollolake/acpi.c
|  25 +++---
 arch/x86/cpu/apollolake/cpu.c
|  88
+--
 arch/x86/cpu/apollolake/cpu_common.c
|  25 ++
 arch/x86/cpu/apollolake/cpu_spl.c
|  20 ---
 arch/x86/cpu/apollolake/fsp_s.c
|   8 ++---
 arch/x86/cpu/apollolake/hostbridge.c
|   2 +-
 arch/x86/cpu/apollolake/lpc.c
|   2 +-
 arch/x86/cpu/apollolake/pch.c

[PATCH] arm: mvebu: a38x: Configurable USB2 high-speed impedance threshold

2020-11-05 Thread Joshua Scott
Hardware testing of a board using the Armada 385 has shown that an
impedance threshold setting of 0x7 performs better in an eye-diagram
test than with Marvell's recommended value 0x6.

As other boards may still perform better with Marvell's reccomended value,
a configuration option is added with a default value of 0x6.

Signed-off-by: Joshua Scott 
Cc: Stefan Roese 
---
 arch/arm/mach-mvebu/Kconfig   | 5 +
 arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 0d8e0922a2..bec011e584 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -30,6 +30,11 @@ config ARMADA_38X
select ARMADA_32BIT
select HAVE_MVEBU_EFUSE
 
+config ARMADA_38X_HS_IMPEDANCE_THRESH
+   hex  "Armada 38x USB 2.0 High-Speed Impedance Threshold (0x0 - 0x7)"
+   depends on ARMADA_38X
+   default 0x6
+
 config ARMADA_XP
bool
select ARMADA_32BIT
diff --git a/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c 
b/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
index 2454730e6d..ae2a361104 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
+++ b/arch/arm/mach-mvebu/serdes/a38x/high_speed_env_spec.c
@@ -677,9 +677,9 @@ struct op_params usb2_power_up_params[] = {
{0xc200c, 0x0 /*NA*/, 0xf000, {0x1000}, 0, 0},
{0xc400c, 0x0 /*NA*/, 0xf000, {0x1000}, 0, 0},
/* Change the High speed impedance threshold */
-   {0xc0008, 0x0 /*NA*/, 0x700, {0x600}, 0, 0},
-   {0xc2008, 0x0 /*NA*/, 0x700, {0x600}, 0, 0},
-   {0xc4008, 0x0 /*NA*/, 0x700, {0x600}, 0, 0},
+   {0xc0008, 0x0 /*NA*/, 0x700, {CONFIG_ARMADA_38X_HS_IMPEDANCE_THRESH << 
8}, 0, 0},
+   {0xc2008, 0x0 /*NA*/, 0x700, {CONFIG_ARMADA_38X_HS_IMPEDANCE_THRESH << 
8}, 0, 0},
+   {0xc4008, 0x0 /*NA*/, 0x700, {CONFIG_ARMADA_38X_HS_IMPEDANCE_THRESH << 
8}, 0, 0},
/* Change the squelch level of the receiver to meet the receiver 
electrical measurements (squelch and receiver sensitivity tests) */
{0xc0014, 0x0 /*NA*/, 0xf, {0x8}, 0, 0},
{0xc2014, 0x0 /*NA*/, 0xf, {0x8}, 0, 0},
-- 
2.29.2



Re: [PATCH v6 00/14] x86: Updates to SMBIOS

2020-11-05 Thread Bin Meng
On Thu, Nov 5, 2020 at 9:32 PM Simon Glass  wrote:
>
> At present there are a few Kconfig options which allow SMBIOS fields to
> be specified at build time.
>
> Not all fields are supported. Also, defining these at build-time is
> limiting since a factory system cannot insert values for particular boards
> or models without rebuilding U-Boot.
>
> This series adds a way to set SMBIOS properties using the devicetree.
> With this approach, more fields are supported and it is easy to update
> values in the devicetree in the factory.
>
> It also updates existing boards to use devicetree and drops the CONFIG
> options, using a new default sysinfo driver.
>
> Changes in v6:
> - Fix 'manuafacture' typo in Kconfig
> - Add new patch to provide default SMBIOS manufacturer/product
>

series On Thu, Nov 5, 2020 at 9:32 PM Simon Glass  wrote:
>
> At present there are a few Kconfig options which allow SMBIOS fields to
> be specified at build time.
>
> Not all fields are supported. Also, defining these at build-time is
> limiting since a factory system cannot insert values for particular boards
> or models without rebuilding U-Boot.
>
> This series adds a way to set SMBIOS properties using the devicetree.
> With this approach, more fields are supported and it is easy to update
> values in the devicetree in the factory.
>
> It also updates existing boards to use devicetree and drops the CONFIG
> options, using a new default sysinfo driver.
>
> Changes in v6:
> - Fix 'manuafacture' typo in Kconfig
> - Add new patch to provide default SMBIOS manufacturer/product
>

series applied to u-boot-x86, thanks!


Re: [PATCH v6 14/14] smbios: Drop the unused Kconfig options

2020-11-05 Thread Bin Meng
On Thu, Nov 5, 2020 at 9:36 PM Simon Glass  wrote:
>
> Now that we can use devicetree to specify this information, drop the old
> CONFIG options.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v5)
>
> Changes in v5:
> - Rename smbios_add_prop_default() to smbios_add_prop()
>
> Changes in v3:
> - Add onto the sysinfo binding
>
>  configs/clearfog_gt_8k_defconfig|  2 --
>  configs/mt7622_rfb_defconfig|  1 -
>  configs/mvebu_db_armada8k_defconfig |  2 --
>  configs/r8a774a1_beacon_defconfig   |  2 --
>  configs/r8a77970_eagle_defconfig|  2 --
>  configs/r8a77980_condor_defconfig   |  2 --
>  configs/r8a77990_ebisu_defconfig|  2 --
>  configs/r8a77995_draak_defconfig|  2 --
>  configs/rcar3_salvator-x_defconfig  |  2 --
>  configs/rcar3_ulcb_defconfig|  2 --
>  lib/Kconfig | 16 --
>  lib/smbios.c| 46 -
>  12 files changed, 13 insertions(+), 68 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH v6 13/14] x86: Provide default SMBIOS manufacturer/product

2020-11-05 Thread Bin Meng
On Thu, Nov 5, 2020 at 9:32 PM Simon Glass  wrote:
>
> Add a file containing defaults for these, using the existing CONFIG
> options. This file must be included with #include since it needs to
> are not passed through the C preprocessor.

it needs to be ?

>
> Enable the driver for all x86 boards that generate SMBIOS tables. Disable
> it for coral since it has its own driver.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v6:
> - Add new patch to provide default SMBIOS manufacturer/product
>
>  arch/Kconfig  |  2 ++
>  arch/x86/dts/bayleybay.dts|  2 ++
>  arch/x86/dts/baytrail_som-db5800-som-6867.dts |  2 ++
>  arch/x86/dts/cherryhill.dts   |  2 ++
>  arch/x86/dts/chromebook_link.dts  |  2 ++
>  arch/x86/dts/chromebook_samus.dts |  2 ++
>  arch/x86/dts/chromebox_panther.dts|  2 ++
>  arch/x86/dts/conga-qeval20-qa3-e3845.dts  |  2 ++
>  arch/x86/dts/cougarcanyon2.dts|  2 ++
>  arch/x86/dts/crownbay.dts |  2 ++
>  arch/x86/dts/dfi-bt700.dtsi   |  2 ++
>  arch/x86/dts/edison.dts   |  2 ++
>  arch/x86/dts/minnowmax.dts|  2 ++
>  arch/x86/dts/qemu-x86_i440fx.dts  |  2 ++
>  arch/x86/dts/qemu-x86_q35.dts |  2 ++
>  arch/x86/dts/smbios.dtsi  | 32 +++
>  configs/chromebook_coral_defconfig|  2 +-
>  17 files changed, 63 insertions(+), 1 deletion(-)
>  create mode 100644 arch/x86/dts/smbios.dtsi
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 3b9fcce980a..041e179256a 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -198,6 +198,8 @@ config X86
> imply RTC_MC146818
> imply IRQ
> imply ACPIGEN if !QEMU
> +   imply SYSINFO if GENERATE_SMBIOS_TABLE
> +   imply SYSINFO_SMBIOS if GENERATE_SMBIOS_TABLE
>
> # Thing to enable for when SPL/TPL are enabled: SPL
> imply SPL_DM
> diff --git a/arch/x86/dts/bayleybay.dts b/arch/x86/dts/bayleybay.dts
> index d0168e88dbd..70e57984031 100644
> --- a/arch/x86/dts/bayleybay.dts
> +++ b/arch/x86/dts/bayleybay.dts
> @@ -16,6 +16,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  / {
> model = "Intel Bayley Bay";
> compatible = "intel,bayleybay", "intel,baytrail";
> diff --git a/arch/x86/dts/baytrail_som-db5800-som-6867.dts 
> b/arch/x86/dts/baytrail_som-db5800-som-6867.dts
> index 5abbc66ce98..a7dc03b6458 100644
> --- a/arch/x86/dts/baytrail_som-db5800-som-6867.dts
> +++ b/arch/x86/dts/baytrail_som-db5800-som-6867.dts
> @@ -16,6 +16,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  / {
> model = "Advantech SOM-DB5800-SOM-6867";
> compatible = "advantech,som-db5800-som-6867", "intel,baytrail";
> diff --git a/arch/x86/dts/cherryhill.dts b/arch/x86/dts/cherryhill.dts
> index 37146fde2ba..2ce7f1aa91a 100644
> --- a/arch/x86/dts/cherryhill.dts
> +++ b/arch/x86/dts/cherryhill.dts
> @@ -14,6 +14,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  / {
> model = "Intel Cherry Hill";
> compatible = "intel,cherryhill", "intel,braswell";
> diff --git a/arch/x86/dts/chromebook_link.dts 
> b/arch/x86/dts/chromebook_link.dts
> index 09488f13b58..e529c4b63e0 100644
> --- a/arch/x86/dts/chromebook_link.dts
> +++ b/arch/x86/dts/chromebook_link.dts
> @@ -11,6 +11,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  / {
> model = "Google Link";
> compatible = "google,link", "intel,celeron-ivybridge";
> diff --git a/arch/x86/dts/chromebook_samus.dts 
> b/arch/x86/dts/chromebook_samus.dts
> index d8e04a66985..adaeb1ea355 100644
> --- a/arch/x86/dts/chromebook_samus.dts
> +++ b/arch/x86/dts/chromebook_samus.dts
> @@ -9,6 +9,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  #ifdef CONFIG_CHROMEOS_VBOOT
>  #include "chromeos-x86.dtsi"
>  #include "flashmap-x86-ro.dtsi"
> diff --git a/arch/x86/dts/chromebox_panther.dts 
> b/arch/x86/dts/chromebox_panther.dts
> index bcd4c4d9c1b..77b6ac9ab96 100644
> --- a/arch/x86/dts/chromebox_panther.dts
> +++ b/arch/x86/dts/chromebox_panther.dts
> @@ -6,6 +6,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  / {
> model = "Google Panther";
> compatible = "google,panther", "intel,haswell";
> diff --git a/arch/x86/dts/conga-qeval20-qa3-e3845.dts 
> b/arch/x86/dts/conga-qeval20-qa3-e3845.dts
> index 70b8c045193..bbea99da2c9 100644
> --- a/arch/x86/dts/conga-qeval20-qa3-e3845.dts
> +++ b/arch/x86/dts/conga-qeval20-qa3-e3845.dts
> @@ -16,6 +16,8 @@
>  /include/ "rtc.dtsi"
>  /include/ "tsc_timer.dtsi"
>
> +#include "smbios.dtsi"
> +
>  / {
> model = "congatec-QEVAL20-QA3-E3845";
> compatible = 

Fail to reset on Odroid-C4

2020-11-05 Thread Jaehoon Chung
Hi,

I have checked U-boot on Odroid-C4 with v2020.10.
I found a problem about reset behavior.

In my environment,
- Boot to SD-card,
- built u-boot v2020.10 with ordoid-c4_defconfig
- Referred to doc/board/amlogic/odroid-c4.rst


If do "reset" command after run command "mmcinfo", it didn't work anymore.
- After something to do operation relevant to MMC. (read/write or ls mmc, etc..)


U-Boot 2020.10-00383-g2f27fb20151b-dirty (Nov 06 2020 - 10:37:09 +0900) 
odroid-c4

Model: Hardkernel ODROID-C4
SoC:   Amlogic Meson SM1 (Unknown) Revision 2b:c (10:2)
DRAM:  3.8 GiB
MMC:   sd@ffe05000: 0, mmc@ffe07000: 1
In:serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@ff3f
Hit any key to stop autoboot:  0
Odroid N2>
Odroid N2>
Odroid N2>
Odroid N2>
Odroid N2>
Odroid N2> mmcinfo
Device: sd@ffe05000
Manufacturer ID: 3
OEM: 5344
Name: SB16G
Bus Speed: 5000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
Odroid N2> reset
resetting ...
bl31 reboot reason: 0xd
bl31 reboot reason: 0x0
system cmd  1.
SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:F;RCY:0;EMMC:800;NAND:81;SD?:0;SD:0;READ:0;0.0;CHK:0;
bl2_stage_init 0x01
bl2_stage_init 0x81
hw 
id:?M1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:F;RCY:0;EMMC:800;NAND:81;SD?:0;SD:800;USB:8;


I didn't analyze it in more detail. I will do. But it seems that relevant to 
BL2 binary.
If nothing to do before reset, it's working fine.

If someone already fixed this or I missed something to do, let me know, plz.

Best Regards,
Jaehoon Chung


Re: [PATCH] fixup: x86: Add missing global_data declaration in tables

2020-11-05 Thread Bin Meng
On Thu, Nov 5, 2020 at 9:24 PM Simon Glass  wrote:
>
> This file needs to use the global data pointer. Add the required
> declaration.
>
> This is a fixup patch for the following:
>
>09218442ca7 x86: Allow putting some tables in the bloblist
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/lib/tables.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
> index 8dc07868c1f..c4007fa4866 100644
> --- a/arch/x86/lib/tables.c
> +++ b/arch/x86/lib/tables.c
> @@ -14,6 +14,8 @@
>  #include 
>  #include 
>
> +DECLARE_GLOBAL_DATA_PTR;
> +
>  /**
>   * Function prototype to write a specific configuration table
>   *
> --

squashed in the following commit:
09218442ca7 x86: Allow putting some tables in the bloblist

applied to u-boot-x86, thanks!


[dwi2c PATCH v1] dwi2c add offsets to reads

2020-11-05 Thread cduffinx
modify the designware_i2c_xfer function to use 1 byte per
address, it was set to 0 before which makes it think its
reading a register type. Added offset of where it is
supposed to read from. Before it was always reading from
offset 0 despite specifying the offset in the higher level
function.

Signed-off-by: Cooper Duffin 
Signed-off-by: cduffinx 
---

 drivers/i2c/designware_i2c.c | 5 +++--
 drivers/i2c/i2c-uclass.c | 1 +
 include/i2c.h| 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index 0b5e70af59..46f5d1e56c 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -658,8 +658,9 @@ static int designware_i2c_xfer(struct udevice *bus, struct 
i2c_msg *msg,
for (; nmsgs > 0; nmsgs--, msg++) {
debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
if (msg->flags & I2C_M_RD) {
-   ret = __dw_i2c_read(i2c->regs, msg->addr, 0, 0,
-   msg->buf, msg->len);
+   ret = __dw_i2c_read(i2c->regs, msg->addr,
+   msg->offset, 1, msg->buf,
+   msg->len);
} else {
ret = __dw_i2c_write(i2c->regs, msg->addr, 0, 0,
 msg->buf, msg->len);
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 2aa3efe8aa..455d56c3b8 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -147,6 +147,7 @@ int dm_i2c_read(struct udevice *dev, uint offset, uint8_t 
*buffer, int len)
ptr->flags |= I2C_M_RD;
ptr->len = len;
ptr->buf = buffer;
+   ptr->offset = offset;
ptr++;
}
msg_count = ptr - msg;
diff --git a/include/i2c.h b/include/i2c.h
index 0faf8542e2..f997c2537e 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -141,6 +141,7 @@ struct i2c_msg {
uint addr;
uint flags;
uint len;
+   uint offset;
u8 *buf;
 };
 
-- 
2.25.1



[PATCH 2/3 v2] tpm: Add some headers from the spec

2020-11-05 Thread Ilias Apalodimas
A following patch introduces EFI_TCG2_PROTOCOL.
Add the required TPMv2 headers to support that and remove the (now)
redundant definitions from tpm2_tis_sandbox

Signed-off-by: Ilias Apalodimas 
---
 include/tpm-v2.h | 69 
 1 file changed, 69 insertions(+)

diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index f6c045d35480..b62f2c5b0fb8 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -11,6 +11,73 @@
 
 #define TPM2_DIGEST_LEN32
 
+#define TPM2_MAX_PCRS 32
+#define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8)
+#define TPM2_MAX_CAP_BUFFER 1024
+#define TPM2_MAX_TPM_PROPERTIES   ((TPM2_MAX_CAP_BUFFER - sizeof(u32) /* 
TPM2_CAP */ - \
+  sizeof(u32)) / sizeof(struct 
tpms_tagged_property))
+
+/*
+ *  We deviate from this draft of the specification by increasing the value of 
TPM2_NUM_PCR_BANKS
+ *  from 3 to 16 to ensure compatibility with TPM2 implementations that have 
enabled a larger than
+ *  typical number of PCR banks. This larger value for TPM2_NUM_PCR_BANKS is 
expected to be included
+ *  in a future revision of the specification.
+ */
+#define TPM2_NUM_PCR_BANKS 16
+
+/* Definition of (UINT32) TPM2_CAP Constants */
+#define TPM2_CAP_PCRS 0x0005U
+#define TPM2_CAP_TPM_PROPERTIES 0x0006U
+
+/* Definition of (UINT32) TPM2_PT Constants */
+#define PT_GROUP   (u32)(0x0100)
+#define PT_FIXED   (u32)(PT_GROUP * 1)
+#define TPM2_PT_MANUFACTURER(u32)(PT_FIXED + 5)
+#define TPM2_PT_PCR_COUNT   (u32)(PT_FIXED + 18)
+#define TPM2_PT_MAX_COMMAND_SIZE(u32)(PT_FIXED + 30)
+#define TPM2_PT_MAX_RESPONSE_SIZE   (u32)(PT_FIXED + 31)
+
+/* TPMS_TAGGED_PROPERTY Structure */
+struct tpms_tagged_property {
+   u32 property;
+   u32 value;
+} __packed;
+
+/* TPMS_PCR_SELECTION Structure */
+struct tpms_pcr_selection {
+   u16 hash;
+   u8 size_of_select;
+   u8 pcr_select[TPM2_PCR_SELECT_MAX];
+} __packed;
+
+/* TPML_PCR_SELECTION Structure */
+struct tpml_pcr_selection {
+   u32 count;
+   struct tpms_pcr_selection selection[TPM2_NUM_PCR_BANKS];
+} __packed;
+
+/* TPML_TAGGED_TPM_PROPERTY Structure */
+struct tpml_tagged_tpm_property {
+   u32 count;
+   struct tpms_tagged_property tpm_property[TPM2_MAX_TPM_PROPERTIES];
+} __packed;
+
+/* TPMU_CAPABILITIES Union */
+union tpmu_capabilities {
+   /*
+* Non exhaustive. Only added the structs needed for our
+* current code
+*/
+   struct tpml_pcr_selection assigned_pcr;
+   struct tpml_tagged_tpm_property tpm_properties;
+} __packed;
+
+/* TPMS_CAPABILITY_DATA Structure */
+struct tpms_capability_data {
+   u32 capability;
+   union tpmu_capabilities data;
+} __packed;
+
 /**
  * TPM2 Structure Tags for command/response buffers.
  *
@@ -123,11 +190,13 @@ enum tpm2_return_codes {
  * TPM2 algorithms.
  */
 enum tpm2_algorithms {
+   TPM2_ALG_SHA1   = 0x04,
TPM2_ALG_XOR= 0x0A,
TPM2_ALG_SHA256 = 0x0B,
TPM2_ALG_SHA384 = 0x0C,
TPM2_ALG_SHA512 = 0x0D,
TPM2_ALG_NULL   = 0x10,
+   TPM2_ALG_SM3_256= 0x12,
 };
 
 /* NV index attributes */
-- 
2.29.2



[PATCH 3/3 v2] efi: Add basic EFI_TCG2_PROTOCOL support

2020-11-05 Thread Ilias Apalodimas
Since U-boot EFI implementation is getting richer it makes sense to
add support for EFI_TCG2_PROTOCOL taking advantage of any hardware TPM
available on the device.

This is the initial implementation of the protocol which only adds
support for GetCapability(). It's limited in the newer and safer
TPMv2 devices.

Signed-off-by: Ilias Apalodimas 
---
changes since v1: 
- change return variable of platform_get_tpm2_device() when used
- since more headers were included in patch #2 use them in offset 
  calculations for all tpm commands
- change the size of the response buffer regardless of what 
  tpm2_get_capability() is doing
 include/efi_loader.h   |   2 +
 include/efi_tcg2.h |  91 +++
 lib/efi_loader/Kconfig |   8 +
 lib/efi_loader/Makefile|   1 +
 lib/efi_loader/efi_setup.c |   7 +
 lib/efi_loader/efi_tcg2.c  | 493 +
 6 files changed, 602 insertions(+)
 create mode 100644 include/efi_tcg2.h
 create mode 100644 lib/efi_loader/efi_tcg2.c

diff --git a/include/efi_loader.h b/include/efi_loader.h
index f550ced56876..e5015d865ec9 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -405,6 +405,8 @@ efi_status_t efi_console_register(void);
 efi_status_t efi_disk_register(void);
 /* Called by efi_init_obj_list() to install EFI_RNG_PROTOCOL */
 efi_status_t efi_rng_register(void);
+/* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
+efi_status_t efi_tcg2_register(void);
 /* Create handles and protocols for the partitions of a block device */
 int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
   const char *if_typename, int diskid,
diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
new file mode 100644
index ..9e7b85db058d
--- /dev/null
+++ b/include/efi_tcg2.h
@@ -0,0 +1,91 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2020, Linaro Limited
+ */
+
+#if !defined _EFI_TCG2_PROTOCOL_H_
+#define _EFI_TCG2_PROTOCOL_H_
+
+#include 
+
+#define EFI_TCG2_PROTOCOL_GUID \
+   EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
+0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
+
+/* TPMV2 only */
+#define TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+/* SHA1, SHA256, SHA384, SHA512, TPM_ALG_SM3_256 */
+#define MAX_HASH_COUNT 5
+/* Algorithm Registry */
+#define EFI_TCG2_BOOT_HASH_ALG_SHA10x0001
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256  0x0002
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384  0x0004
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512  0x0008
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+typedef u32 efi_tcg_event_log_bitmap;
+typedef u32 efi_tcg_event_log_format;
+typedef u32 efi_tcg_event_algorithm_bitmap;
+
+struct efi_tcg2_version {
+   u8 major;
+   u8 minor;
+};
+
+struct efi_tcg2_event_header {
+   u32 header_size;
+   u16 header_version;
+   u32 pcr_index;
+   u32 event_type;
+} __packed;
+
+struct efi_tcg2_event {
+   u32 size;
+   struct efi_tcg2_event_header header;
+   u8 event[];
+} __packed;
+
+struct efi_tcg2_boot_service_capability {
+   u8 size;
+   struct efi_tcg2_version structure_version;
+   struct efi_tcg2_version protocol_version;
+   efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
+   efi_tcg_event_log_bitmap supported_event_logs;
+   bool tpm_present_flag;
+   u16 max_command_size;
+   u16 max_response_size;
+   u32 manufacturer_id;
+   u32 number_of_pcr_banks;
+   efi_tcg_event_algorithm_bitmap active_pcr_banks;
+};
+
+#define boot_service_capability_min \
+   sizeof(struct efi_tcg2_boot_service_capability) - \
+   offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
+
+struct efi_tcg2_protocol {
+   efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
+  struct 
efi_tcg2_boot_service_capability *capability);
+   efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
+efi_tcg_event_log_format 
log_format,
+u64 *event_log_location, u64 
*event_log_last_entry,
+bool *event_log_truncated);
+   efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol 
*this,
+ u64 flags, u64 
data_to_hash,
+ u64 data_to_hash_len,
+ struct efi_tcg2_event 
*efi_tcg_event);
+   efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
+  u32 input_parameter_block_size,
+  u8 *input_parameter_block,
+  u32 output_parameter_block_size,
+  u8 

[PATCH 1/3 v2] tpm: Change response length of tpm2_get_capability()

2020-11-05 Thread Ilias Apalodimas
For implementing the EFI_TCG2_PROTOCOL we need the count field returned by
the TPM when reading capabilities via tpm2_get_capability().

Adjust the implementation of the 'tpm2 get_capability' command accordingly.

Suggested-by: Heinrich Schuchardt 
Signed-off-by: Ilias Apalodimas 
---
Changes since v1:
- Unconditionally get the extra 4 bytes on the response and account for them
  in do_tpm_get_capability()
 cmd/tpm-v2.c | 4 ++--
 lib/tpm-v2.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c
index e6742656f578..5fa4788a72de 100644
--- a/cmd/tpm-v2.c
+++ b/cmd/tpm-v2.c
@@ -191,10 +191,10 @@ static int do_tpm_get_capability(struct cmd_tbl *cmdtp, 
int flag, int argc,
for (i = 0; i < count; i++) {
printf("Property 0x");
for (j = 0; j < 4; j++)
-   printf("%02x", data[(i * 8) + j]);
+   printf("%02x", data[(i * 8) + j + sizeof(u32)]);
printf(": 0x");
for (j = 4; j < 8; j++)
-   printf("%02x", data[(i * 8) + j]);
+   printf("%02x", data[(i * 8) + j + sizeof(u32)]);
printf("\n");
}
 
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index a4c352e3ef75..91759068cf03 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -184,10 +184,10 @@ u32 tpm2_get_capability(struct udevice *dev, u32 
capability, u32 property,
/*
 * In the response buffer, the properties are located after the:
 * tag (u16), response size (u32), response code (u32),
-* YES/NO flag (u8), TPM_CAP (u32) and TPMU_CAPABILITIES (u32).
+* YES/NO flag (u8), TPM_CAP (u32).
 */
properties_off = sizeof(u16) + sizeof(u32) + sizeof(u32) +
-sizeof(u8) + sizeof(u32) + sizeof(u32);
+sizeof(u8) + sizeof(u32);
memcpy(buf, [properties_off], response_len - properties_off);
 
return 0;
-- 
2.29.2



Re: [rockchip] broken SPI on RockPro64 and other RK3399 targets

2020-11-05 Thread Marcin Juszkiewicz

W dniu 05.11.2020 o 17:49, Alper Nebi Yasak pisze:


I suspect this change in that commit (rk3399-u-boot.dtsi):


  / {
 aliases {
 mmc0 = 
 mmc1 = 
 pci0 = 
+   spi1 = 
 };


Can you test adding spi0 =  above that in the list?


Helps ;D

=> sf probe
SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 
16 MiB




[PATCH] Kconfig: simple panel requires backlight

2020-11-05 Thread Marcin Juszkiewicz
During build of simple panel driver backlight is needed so let's enable
it:

aarch64-linux-gnu-ld.bfd: drivers/built-in.o: in function 
`simple_panel_set_backlight':
u-boot/drivers/video/simple_panel.c:43: undefined reference to 
`backlight_set_brightness'
aarch64-linux-gnu-ld.bfd: drivers/built-in.o: in function 
`simple_panel_enable_backlight':
u-boot/drivers/video/simple_panel.c:28: undefined reference to 
`backlight_enable'

Signed-off-by: Marcin Juszkiewicz 
---
 drivers/video/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git drivers/video/Kconfig drivers/video/Kconfig
index 998271b9b6..0dd78472d5 100644
--- drivers/video/Kconfig
+++ drivers/video/Kconfig
@@ -199,7 +199,7 @@ config PANEL
 
 config SIMPLE_PANEL
bool "Enable simple panel support"
-   depends on PANEL
+   depends on PANEL && BACKLIGHT
default y
help
  This turns on a simple panel driver that enables a compatible
-- 
2.28.0



Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Simon Glass
Hi Wolfgang,

On Thu, 5 Nov 2020 at 12:10, Wolfgang Denk  wrote:
>
> Dear Simon.
>
> In message 
>  you 
> wrote:
> >
> > > > setexpr c *10 + *100
> > >
> > > I don't get it.  The equivalent to "${a}${b}" would be
> > >
> > > setexpr c "*10*100"
> > >
> > > which is even simpler?
> >
> > I don't see how that works. The *10 thing in my example reads a string
> > out of address 10.
>
> Ah, got it.  This requires your "[PATCH 10/10] setexpr: Add support
> for strings" first...
>
> But then... should there not be some '.s' size specification
> somewhere?

Ooops yes:

setexpr.s c *10 + *100

Regards,
Simon


[rockchip] broken SPI on RockPro64 and other RK3399 targets

2020-11-05 Thread Marcin Juszkiewicz
I wanted to update U-Boot on my RockPro64 board from some random build 
of 2020.07-rc with out of tree patches to official one. Built, flashed 
and then got this:


Loading Environment from SPI Flash... Invalid bus 0 (err=-19)
*** Warning - spi_flash_probe_bus_cs() failed, using default environment

According to Peter Robinson it happens also on other RK3399 boards.

As I had a bit of time I started bisecting and found reason:

16:43 (7s) hrw@puchatek:u-boot$ git bisect good
c4cea2bbf995764f325a907061c22ecd6768cf7b is the first bad commit
commit c4cea2bbf995764f325a907061c22ecd6768cf7b
Author: Simon Glass 
Date:   Sun Jul 19 13:55:58 2020 -0600

rockchip: Enable building a SPI ROM image on bob

Add a simple binman config and enable CONFIG_HAS_ROM so that U-Boot
produces a ROM for bob.

Signed-off-by: Simon Glass 

 arch/arm/dts/rk3399-gru-u-boot.dtsi   |  4 
 arch/arm/dts/rk3399-gru.dtsi  |  2 +-
 arch/arm/dts/rk3399-u-boot.dtsi   | 27 +++
 arch/arm/mach-rockchip/rk3399/Kconfig |  2 ++
 4 files changed, 34 insertions(+), 1 deletion(-)

Then I checked out HEAD of master branch, reverted that patch and SPI 
flash got detected properly.


Not looked yet on how it should be fixed.


Re: [rockchip] broken SPI on RockPro64 and other RK3399 targets

2020-11-05 Thread Alper Nebi Yasak
On 05/11/2020 20:04, Marcin Juszkiewicz wrote:
> W dniu 05.11.2020 o 17:49, Alper Nebi Yasak pisze:
> 
>> I suspect this change in that commit (rk3399-u-boot.dtsi):
>>
>>>   / {
>>>  aliases {
>>>  mmc0 = 
>>>  mmc1 = 
>>>  pci0 = 
>>> +   spi1 = 
>>>  };
>>
>> Can you test adding spi0 =  above that in the list?
> 
> Helps ;D
> 
> => sf probe
> SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 
> 16 MiB
> 

I looked around a bit more and saw rk3399--u-boot.dtsi files
(including rockpro64) defining a "spi0 = " alias, so I guess what
I suggested would be overridden by that and is actually a no-op?

Maybe two aliases pointing to the same bus is what's really causing the
problem?

Something else you can test:
- Remove the aliases block from rk3399-rockpro64-u-boot.dtsi
- Add "spi[0-5] = [0-5];" aliases to rk3399-u-boot.dtsi
- Add CONFIG_SF_DEFAULT_BUS=1 to configs/rockpro64-rk3399_defconfig

I guess that's the proper solution if it works.


Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Wolfgang Denk
Dear Simon.

In message  
you wrote:
>
> > > setexpr c *10 + *100
> >
> > I don't get it.  The equivalent to "${a}${b}" would be
> >
> > setexpr c "*10*100"
> >
> > which is even simpler?
>
> I don't see how that works. The *10 thing in my example reads a string
> out of address 10.

Ah, got it.  This requires your "[PATCH 10/10] setexpr: Add support
for strings" first...

But then... should there not be some '.s' size specification
somewhere?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"Unix is simple, but it takes a genius to understand the simplicity."
 - Dennis Ritchie


Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Marek Behun
On Thu, 5 Nov 2020 10:27:28 -0700
Simon Glass  wrote:

> I don't see how that works. The *10 thing in my example reads a string
> out of address 10.

/o\ ah, OK, that makes sense. So setexpr can dereference strings.
I didn't know about that, I thouth the resulting string would be
"*10*100".

In this case
Acked-by: Marek Behún 


[PATCH v2 12/12] bootm: Support string substitution in bootargs

2020-11-05 Thread Simon Glass
In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

  setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
  part uuid mmc 2:2 uuid
  bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Use ${} for subtitution instead of %
- Tweak cover letter

 arch/Kconfig|   1 +
 common/Kconfig.boot |  17 +++
 common/bootm.c  |  38 +--
 include/bootm.h |  14 --
 test/bootm.c| 114 ++--
 5 files changed, 172 insertions(+), 12 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 6caf2338bcf..421ea9a9b51 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -141,6 +141,7 @@ config SANDBOX
imply CMD_PMC
imply CMD_CLONE
imply SILENT_CONSOLE
+   imply BOOTARGS_SUBST
 
 config SH
bool "SuperH architecture"
diff --git a/common/Kconfig.boot b/common/Kconfig.boot
index 522f5f3d6a4..27e5d45fd70 100644
--- a/common/Kconfig.boot
+++ b/common/Kconfig.boot
@@ -848,6 +848,23 @@ config BOOTARGS
  CONFIG_BOOTARGS goes into the environment value "bootargs". Note that
  this value will also override the "chosen" node in FDT blob.
 
+config BOOTARGS_SUBST
+   bool "Support substituting strings in boot arguments"
+   help
+ This allows substituting string values in the boot arguments. These
+ are applied after the commandline has been built. 
+
+ One use for this is to insert the root-disk UUID into the command
+ line where bootargs contains "root=${uuid}"
+
+   setenv bootargs "console= root=${uuid}"
+   # Set the 'uuid' environment variable
+   part uuid mmc 2:2 uuid
+
+   # Command-line substitution will put the real uuid into the
+   # kernel command line
+   bootm
+
 config USE_BOOTCOMMAND
bool "Enable a default value for bootcmd"
help
diff --git a/common/bootm.c b/common/bootm.c
index 020449db3fb..6c286942a41 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -7,6 +7,7 @@
 #ifndef USE_HOSTCC
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -542,6 +543,33 @@ static int fixup_silent_linux(char *buf, int maxlen)
return 0;
 }
 
+/**
+ * process_subst() - Handle substitution of ${...} fields in the environment
+ *
+ * Handle variable substitution in the provided buffer
+ *
+ * @buf: Buffer containing the string to process
+ * @maxlen: Maximum length of buffer
+ * @return 0 if OK, -ENOSPC if @maxlen is too small
+ */
+static int process_subst(char *buf, int maxlen)
+{
+   char *cmdline;
+   int size;
+   int ret;
+
+   /* Move to end of buffer */
+   size = strlen(buf) + 1;
+   cmdline = buf + maxlen - size;
+   if (buf + size > cmdline)
+   return -ENOSPC;
+   memmove(cmdline, buf, size);
+
+ret = cli_simple_process_macros(cmdline, buf, cmdline - buf);
+
+   return ret;
+}
+
 int bootm_process_cmdline(char *buf, int maxlen, int flags)
 {
int ret;
@@ -554,6 +582,11 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags)
if (ret)
return log_msg_ret("silent", ret);
}
+   if (IS_ENABLED(CONFIG_BOOTARGS_SUBST) && (flags & BOOTM_CL_SUBST)) {
+   ret = process_subst(buf, maxlen);
+   if (ret)
+   return log_msg_ret("silent", ret);
+   }
 
return 0;
 }
@@ -569,7 +602,7 @@ int bootm_process_cmdline_env(int flags)
/* First check if any action is needed */
do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
!IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && (flags & BOOTM_CL_SILENT);
-   if (!do_silent)
+   if (!do_silent && !IS_ENABLED(CONFIG_BOOTARGS_SUBST))
return 0;
 
env = 

[PATCH v2 10/12] x86: zimage: Add silent-console processing

2020-11-05 Thread Simon Glass
At present zimage does its own command-line processing and does not
support the 'silent console' feature. There doesn't seem to be any good
reason for this.

Add support for silent console to zimage.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/lib/zimage.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index a00964cc8d9..8e1e8017bd8 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -13,6 +13,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -317,6 +318,11 @@ int setup_zimage(struct boot_params *setup_base, char 
*cmd_line, int auto_boot,
}
 
if (cmd_line) {
+   int max_size = 0xff;
+   int ret;
+
+   if (bootproto >= 0x0206)
+   max_size = hdr->cmdline_size;
if (bootproto >= 0x0202) {
hdr->cmd_line_ptr = (uintptr_t)cmd_line;
} else if (bootproto >= 0x0200) {
@@ -332,6 +338,14 @@ int setup_zimage(struct boot_params *setup_base, char 
*cmd_line, int auto_boot,
strcpy(cmd_line, (char *)cmdline_force);
else
build_command_line(cmd_line, auto_boot);
+   ret = bootm_process_cmdline(cmd_line, max_size, BOOTM_CL_ALL);
+   if (ret) {
+   printf("Cmdline setup failed (err=%d)\n", ret);
+   return ret;
+   }
+   printf("Kernel command line: \"");
+   puts(cmd_line);
+   printf("\"\n");
}
 
if (IS_ENABLED(CONFIG_INTEL_MID) && bootproto >= 0x0207)
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 11/12] cli: Support macro processing with a fixed-size buffer

2020-11-05 Thread Simon Glass
At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add a new patch to support macro processing with a fixed-size buffer

 cmd/pxe_utils.c |  6 --
 common/cli_simple.c | 17 -
 include/cli.h   |  4 +++-
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 8716e782f6a..69cac149c0c 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -322,7 +322,8 @@ static int label_localboot(struct pxe_label *label)
if (label->append) {
char bootargs[CONFIG_SYS_CBSIZE];
 
-   cli_simple_process_macros(label->append, bootargs);
+   cli_simple_process_macros(label->append, bootargs,
+ sizeof(bootargs));
env_set("bootargs", bootargs);
}
 
@@ -430,7 +431,8 @@ static int label_boot(struct cmd_tbl *cmdtp, struct 
pxe_label *label)
strcat(bootargs, ip_str);
strcat(bootargs, mac_str);
 
-   cli_simple_process_macros(bootargs, finalbootargs);
+   cli_simple_process_macros(bootargs, finalbootargs,
+ sizeof(finalbootargs));
env_set("bootargs", finalbootargs);
printf("append: %s\n", finalbootargs);
}
diff --git a/common/cli_simple.c b/common/cli_simple.c
index 7d91316a0fb..e80ba488a5e 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -60,13 +60,14 @@ int cli_simple_parse_line(char *line, char *argv[])
return nargs;
 }
 
-void cli_simple_process_macros(const char *input, char *output)
+int cli_simple_process_macros(const char *input, char *output, int max_size)
 {
char c, prev;
const char *varname_start = NULL;
int inputcnt = strlen(input);
-   int outputcnt = CONFIG_SYS_CBSIZE;
+   int outputcnt = max_size;
int state = 0;  /* 0 = waiting for '$'  */
+   int ret;
 
/* 1 = waiting for '(' or '{' */
/* 2 = waiting for ')' or '}' */
@@ -157,13 +158,18 @@ void cli_simple_process_macros(const char *input, char 
*output)
prev = c;
}
 
-   if (outputcnt)
+   ret = inputcnt ? -ENOSPC : 0;
+   if (outputcnt) {
*output = 0;
-   else
+   } else {
*(output - 1) = 0;
+   ret = -ENOSPC;
+   }
 
debug_parser("[PROCESS_MACROS] OUTPUT len %zd: \"%s\"\n",
 strlen(output_start), output_start);
+
+   return ret;
 }
 
  /*
@@ -239,7 +245,8 @@ int cli_simple_run_command(const char *cmd, int flag)
debug_parser("token: \"%s\"\n", token);
 
/* find macros in this token and replace them */
-   cli_simple_process_macros(token, finaltoken);
+   cli_simple_process_macros(token, finaltoken,
+ sizeof(finaltoken));
 
/* Extract arguments */
argc = cli_simple_parse_line(finaltoken, argv);
diff --git a/include/cli.h b/include/cli.h
index 39b913743b5..3449fa6ae72 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -34,8 +34,10 @@ int cli_simple_run_command(const char *cmd, int flag);
  *
  * @param inputInput string possible containing $() / ${} vars
  * @param output   Output string with $() / ${} vars expanded
+ * @param max_size Maximum size of @output (including terminator)
+ * @return 0 if OK, -ENOSPC if we ran out of space in @output
  */
-void cli_simple_process_macros(const char *input, char *output);
+int cli_simple_process_macros(const char *input, char *output, int max_size);
 
 /**
  * cli_simple_run_command_list() - Execute a list of command
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 09/12] bootm: Allow updating the bootargs in a buffer

2020-11-05 Thread Simon Glass
At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c  |  18 +++-
 include/bootm.h |  16 +++
 test/bootm.c| 114 +---
 3 files changed, 132 insertions(+), 16 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 912ed906ef3..020449db3fb 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -542,6 +542,22 @@ static int fixup_silent_linux(char *buf, int maxlen)
return 0;
 }
 
+int bootm_process_cmdline(char *buf, int maxlen, int flags)
+{
+   int ret;
+
+   /* Check config first to enable compiler to eliminate code */
+   if (IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
+   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) &&
+   (flags & BOOTM_CL_SILENT)) {
+   ret = fixup_silent_linux(buf, maxlen);
+   if (ret)
+   return log_msg_ret("silent", ret);
+   }
+
+   return 0;
+}
+
 int bootm_process_cmdline_env(int flags)
 {
const int maxlen = MAX_CMDLINE_SIZE;
@@ -566,7 +582,7 @@ int bootm_process_cmdline_env(int flags)
strcpy(buf, env);
else
*buf = '\0';
-   ret = fixup_silent_linux(buf, maxlen);
+   ret = bootm_process_cmdline(buf, maxlen, flags);
if (!ret) {
ret = env_set("bootargs", buf);
 
diff --git a/include/bootm.h b/include/bootm.h
index 4876d7b2882..8d95fb2a90a 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -93,6 +93,22 @@ void arch_preboot_os(void);
 void board_preboot_os(void);
 
 /*
+ * bootm_process_cmdline() - Process fix-ups for the command line
+ *
+ * This handles: making Linux boot silently if requested ('silent_linux' 
envvar)
+ *
+ * @maxlen must provide enough space for the string being processed plus the
+ * resulting string
+ *
+ * @buf: buffer holding commandline string to adjust
+ * @maxlen: Maximum length of buffer at @buf (including \0)
+ * @flags: Flags to control what happens (see bootm_cmdline_t)
+ * @return 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too
+ * long
+ */
+int bootm_process_cmdline(char *buf, int maxlen, int flags);
+
+/**
  * bootm_process_cmdline_env() - Process fix-ups for the command line
  *
  * Updates the 'bootargs' envvar as required. This handles making Linux boot
diff --git a/test/bootm.c b/test/bootm.c
index ba08920bb17..d0b29441d65 100644
--- a/test/bootm.c
+++ b/test/bootm.c
@@ -15,33 +15,117 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define BOOTM_TEST(_name, _flags)  UNIT_TEST(_name, _flags, bootm_test)
 
+enum {
+   BUF_SIZE= 1024,
+};
+
 #define CONSOLE_STR"console=/dev/ttyS0"
 
-/* Test silent processing in the bootargs variable */
-static int bootm_test_silent_var(struct unit_test_state *uts)
+/* Test cmdline processing where nothing happens */
+static int bootm_test_nop(struct unit_test_state *uts)
+{
+   char buf[BUF_SIZE];
+
+   *buf = '\0';
+   ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true));
+   ut_asserteq_str("", buf);
+
+   strcpy(buf, "test");
+   ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true));
+   ut_asserteq_str("test", buf);
+
+   return 0;
+}
+BOOTM_TEST(bootm_test_nop, 0);
+
+/* Test cmdline processing when out of space */
+static int bootm_test_nospace(struct unit_test_state *uts)
+{
+   char buf[BUF_SIZE];
+
+   /* Zero buffer size */
+   *buf = '\0';
+   ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, true));
+
+   /* Buffer string not terminated */
+   memset(buf, 'a', BUF_SIZE);
+   ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true));
+
+   /* Not enough space to copy string */
+   memset(buf, '\0', BUF_SIZE);
+   memset(buf, 'a', BUF_SIZE / 2);
+   ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true));
+
+   /* Just enough space */
+   memset(buf, '\0', BUF_SIZE);
+   memset(buf, 'a', BUF_SIZE / 2 - 1);
+   ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true));
+
+   return 0;
+}
+BOOTM_TEST(bootm_test_nospace, 0);
+
+/* Test silent processing */
+static int bootm_test_silent(struct unit_test_state *uts)
 {
+   char buf[BUF_SIZE];
+
/* 'silent_linux' not set should do nothing */
env_set("silent_linux", NULL);
-   env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
-   ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
-
-   env_set("bootargs", NULL);
-   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
-   ut_assertnull(env_get("bootargs"));
+   strcpy(buf, CONSOLE_STR);
+   ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT));
+   ut_asserteq_str(CONSOLE_STR, buf);
 

[PATCH v2 08/12] bootm: Update bootm_process_cmdline_env() to use flags

2020-11-05 Thread Simon Glass
At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c  |  8 +---
 include/bootm.h | 11 +--
 test/bootm.c| 10 +-
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 4fa909f23bc..912ed906ef3 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -542,16 +542,17 @@ static int fixup_silent_linux(char *buf, int maxlen)
return 0;
 }
 
-int bootm_process_cmdline_env(bool do_silent)
+int bootm_process_cmdline_env(int flags)
 {
const int maxlen = MAX_CMDLINE_SIZE;
+   bool do_silent;
const char *env;
char *buf;
int ret;
 
/* First check if any action is needed */
do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
-   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && do_silent;
+   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && (flags & BOOTM_CL_SILENT);
if (!do_silent)
return 0;
 
@@ -685,7 +686,8 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
if (!ret && (states & BOOTM_STATE_OS_BD_T))
ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
if (!ret && (states & BOOTM_STATE_OS_PREP)) {
-   ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX);
+   ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX ?
+   BOOTM_CL_SILENT : 0);
if (ret) {
printf("Cmdline setup failed (err=%d)\n", ret);
ret = CMD_RET_FAILURE;
diff --git a/include/bootm.h b/include/bootm.h
index f12ee2b3cb3..4876d7b2882 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -75,6 +75,13 @@ void board_quiesce_devices(void);
  */
 void switch_to_non_secure_mode(void);
 
+/* Flags to control bootm_process_cmdline() */
+enum bootm_cmdline_t {
+   BOOTM_CL_SILENT = 1 << 0,   /* Do silent console processing */
+
+   BOOTM_CL_ALL= 1,/* All substitutions */
+};
+
 /**
  * arch_preboot_os() - arch specific configuration before booting
  */
@@ -91,9 +98,9 @@ void board_preboot_os(void);
  * Updates the 'bootargs' envvar as required. This handles making Linux boot
  * silently if requested ('silent_linux' envvar)
  *
- * @do_silent: Process bootargs for silent console
+ * @flags: Flags to control what happens (see bootm_cmdline_t)
  * @return 0 if OK, -ENOMEM if out of memory
  */
-int bootm_process_cmdline_env(bool do_silent);
+int bootm_process_cmdline_env(int flags);
 
 #endif
diff --git a/test/bootm.c b/test/bootm.c
index c203f0acd60..ba08920bb17 100644
--- a/test/bootm.c
+++ b/test/bootm.c
@@ -23,26 +23,26 @@ static int bootm_test_silent_var(struct unit_test_state 
*uts)
/* 'silent_linux' not set should do nothing */
env_set("silent_linux", NULL);
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env(true));
+   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
env_set("bootargs", NULL);
-   ut_assertok(bootm_process_cmdline_env(true));
+   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
ut_assertnull(env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "no"));
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env(true));
+   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "yes"));
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env(true));
+   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
ut_asserteq_str("console=", env_get("bootargs"));
 
/* Empty buffer should still add the string */
env_set("bootargs", NULL);
-   ut_assertok(bootm_process_cmdline_env(true));
+   ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
ut_asserteq_str("console=", env_get("bootargs"));
 
return 0;
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 06/12] bootm: Use size rather than length for CONSOLE_ARG

2020-11-05 Thread Simon Glass
Use the size (including terminator) for in this function, rather than
the length. This is arguably easier to follow, with the coming
refactor.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 9b0c81d6534..9295cf5cd3e 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -465,8 +465,8 @@ ulong bootm_disable_interrupts(void)
return iflag;
 }
 
-#define CONSOLE_ARG "console="
-#define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
+#define CONSOLE_ARG"console="
+#define CONSOLE_ARG_SIZE   sizeof(CONSOLE_ARG)
 
 int bootm_process_cmdline_env(bool do_silent)
 {
@@ -500,7 +500,7 @@ int bootm_process_cmdline_env(bool do_silent)
char *start = strstr(cmdline, CONSOLE_ARG);
 
/* Allocate space for maximum possible new command line */
-   buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1);
+   buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_SIZE);
if (!buf) {
debug("%s: out of memory\n", __func__);
return -ENOSPC;
@@ -508,13 +508,14 @@ int bootm_process_cmdline_env(bool do_silent)
 
if (start) {
char *end = strchr(start, ' ');
-   int num_start_bytes = start - cmdline + CONSOLE_ARG_LEN;
+   int start_bytes;
 
-   strncpy(buf, cmdline, num_start_bytes);
+   start_bytes = start - cmdline + CONSOLE_ARG_SIZE - 1;
+   strncpy(buf, cmdline, start_bytes);
if (end)
-   strcpy(buf + num_start_bytes, end);
+   strcpy(buf + start_bytes, end);
else
-   buf[num_start_bytes] = '\0';
+   buf[start_bytes] = '\0';
} else {
sprintf(buf, "%s %s", cmdline, CONSOLE_ARG);
}
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 07/12] bootm: Split out bootargs environment reading / writing

2020-11-05 Thread Simon Glass
At present bootm_process_cmdline_env() reads the 'bootargs' variable and
then writes it back afterwards. This is painful for tests, which would
rather use a simple buffer.

It is also useful for zimage to use a buffer, since it does not actually
put the Linux command line in the bootargs variable.

Refactor the existing code into two pieces. One handles reading and
writing the environment variable, as well as allocating a buffer for use
by the rest of the code, which now operates on a buffer.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c | 95 ++
 1 file changed, 73 insertions(+), 22 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 9295cf5cd3e..4fa909f23bc 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #if defined(CONFIG_CMD_USB)
 #include 
 #endif
@@ -35,6 +36,8 @@
 #define CONFIG_SYS_BOOTM_LEN   0x80
 #endif
 
+#define MAX_CMDLINE_SIZE   SZ_4K
+
 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
 
 #ifndef USE_HOSTCC
@@ -468,20 +471,31 @@ ulong bootm_disable_interrupts(void)
 #define CONSOLE_ARG"console="
 #define CONSOLE_ARG_SIZE   sizeof(CONSOLE_ARG)
 
-int bootm_process_cmdline_env(bool do_silent)
+/**
+ * fixup_silent_linux() - Handle silencing the linux boot if required
+ *
+ * This uses the silent_linux envvar to control whether to add/set a "console="
+ * parameter to the command line
+ *
+ * @buf: Buffer containing the string to process
+ * @maxlen: Maximum length of buffer
+ * @return 0 if OK, -ENOSPC if @maxlen is too small
+ */
+static int fixup_silent_linux(char *buf, int maxlen)
 {
-   char *buf;
-   const char *env_val;
-   char *cmdline;
int want_silent;
+   char *cmdline;
+   int size;
 
-   /* First check if any action is needed */
-   do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
-   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && do_silent;
-   if (!do_silent)
-   return 0;
-   cmdline = env_get("bootargs");
-
+   /*
+* Move the input string to the end of buffer. The output string will be
+* built up at the start.
+*/
+   size = strlen(buf) + 1;
+   if (size * 2 > maxlen)
+   return -ENOSPC;
+   cmdline = buf + maxlen - size;
+   memmove(cmdline, buf, size);
/*
 * Only fix cmdline when requested. The environment variable can be:
 *
@@ -496,15 +510,12 @@ int bootm_process_cmdline_env(bool do_silent)
return 0;
 
debug("before silent fix-up: %s\n", cmdline);
-   if (cmdline && (cmdline[0] != '\0')) {
+   if (*cmdline) {
char *start = strstr(cmdline, CONSOLE_ARG);
 
-   /* Allocate space for maximum possible new command line */
-   buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_SIZE);
-   if (!buf) {
-   debug("%s: out of memory\n", __func__);
+   /* Check space for maximum possible new command line */
+   if (size + CONSOLE_ARG_SIZE > maxlen)
return -ENOSPC;
-   }
 
if (start) {
char *end = strchr(start, ' ');
@@ -519,15 +530,55 @@ int bootm_process_cmdline_env(bool do_silent)
} else {
sprintf(buf, "%s %s", cmdline, CONSOLE_ARG);
}
-   env_val = buf;
+   if (buf + strlen(buf) >= cmdline)
+   return -ENOSPC;
} else {
-   buf = NULL;
-   env_val = CONSOLE_ARG;
+   if (maxlen < sizeof(CONSOLE_ARG))
+   return -ENOSPC;
+   strcpy(buf, CONSOLE_ARG);
}
+   debug("after silent fix-up: %s\n", buf);
 
-   env_set("bootargs", env_val);
-   debug("after silent fix-up: %s\n", env_val);
+   return 0;
+}
+
+int bootm_process_cmdline_env(bool do_silent)
+{
+   const int maxlen = MAX_CMDLINE_SIZE;
+   const char *env;
+   char *buf;
+   int ret;
+
+   /* First check if any action is needed */
+   do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
+   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && do_silent;
+   if (!do_silent)
+   return 0;
+
+   env = env_get("bootargs");
+   if (env && strlen(env) >= maxlen)
+   return -E2BIG;
+   buf = malloc(maxlen);
+   if (!buf)
+   return -ENOMEM;
+   if (env)
+   strcpy(buf, env);
+   else
+   *buf = '\0';
+   ret = fixup_silent_linux(buf, maxlen);
+   if (!ret) {
+   ret = env_set("bootargs", buf);
+
+   /*
+* If buf is "" and bootargs does not exist, this will produce
+* an error trying to delete bootargs. Ignore it
+*/
+   if (ret == -ENOENT)
+

[PATCH v2 01/12] env: Allow returning errors from hdelete_r()

2020-11-05 Thread Simon Glass
At present this function returns 1 on success and 0 on failure. But in
the latter case it provides no indication of what went wrong.

If an attempt is made to delete a non-existent variable, the caller may
want to ignore this error. This happens when setting a non-existent
variable to "", for example.

Update the function to return 0 on success and a useful error code on
failure. Add a function comment too.

Make sure that env_set() does not return an error if it is deleting a
variable that doesn't exist. We could update env_set() to return useful
error numbers also, but that is beyond the scope of this change.

Signed-off-by: Simon Glass 

wip

---

(no changes since v1)

 cmd/nvedit.c |  6 --
 include/search.h | 11 ++-
 lib/hashtable.c  | 12 ++--
 test/env/hashtable.c |  2 +-
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7fce723800d..d0d2eca9047 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -266,7 +266,9 @@ static int _do_env_set(int flag, int argc, char *const 
argv[], int env_flag)
/* Delete only ? */
if (argc < 3 || argv[2] == NULL) {
int rc = hdelete_r(name, _htab, env_flag);
-   return !rc;
+
+   /* If the variable didn't exist, don't report an error */
+   return rc && rc != -ENOENT ? 1 : 0;
}
 
/*
@@ -895,7 +897,7 @@ static int do_env_delete(struct cmd_tbl *cmdtp, int flag,
while (--argc > 0) {
char *name = *++argv;
 
-   if (!hdelete_r(name, _htab, env_flag))
+   if (hdelete_r(name, _htab, env_flag))
ret = 1;
}
 
diff --git a/include/search.h b/include/search.h
index e56843c26fd..d0bb44388e1 100644
--- a/include/search.h
+++ b/include/search.h
@@ -80,7 +80,16 @@ int hsearch_r(struct env_entry item, enum env_action action,
 int hmatch_r(const char *match, int last_idx, struct env_entry **retval,
 struct hsearch_data *htab);
 
-/* Search and delete entry matching "key" in internal hash table. */
+/**
+ * hdelete_r() - Search and delete entry in internal hash table
+ *
+ * @key: Name of entry to delete
+ * @htab: Hash table
+ * @flag: Flags to use (H_...)
+ * @return 0 on success, -ENOENT if not found, -EPERM if the hash table 
callback
+ * rejected changing the variable, -EINVAL if the hash table refused to
+ * delete the variable
+ */
 int hdelete_r(const char *key, struct hsearch_data *htab, int flag);
 
 ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 7c08f5c8055..ff5ff726394 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -472,7 +472,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
idx = hsearch_r(e, ENV_FIND, , htab, 0);
if (idx == 0) {
__set_errno(ESRCH);
-   return 0;   /* not found */
+   return -ENOENT; /* not found */
}
 
/* Check for permission */
@@ -481,7 +481,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
debug("change_ok() rejected deleting variable "
"%s, skipping it!\n", key);
__set_errno(EPERM);
-   return 0;
+   return -EPERM;
}
 
/* If there is a callback, call it */
@@ -490,12 +490,12 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
debug("callback() rejected deleting variable "
"%s, skipping it!\n", key);
__set_errno(EINVAL);
-   return 0;
+   return -EINVAL;
}
 
_hdelete(key, htab, ep, idx);
 
-   return 1;
+   return 0;
 }
 
 #if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
@@ -917,7 +917,7 @@ int himport_r(struct hsearch_data *htab,
if (!drop_var_from_set(name, nvars, localvars))
continue;
 
-   if (hdelete_r(name, htab, flag) == 0)
+   if (hdelete_r(name, htab, flag))
debug("DELETE ERROR 
##\n");
 
continue;
@@ -979,7 +979,7 @@ int himport_r(struct hsearch_data *htab,
 * b) if the variable was not present in current env, we notify
 *it might be a typo
 */
-   if (hdelete_r(localvars[i], htab, flag) == 0)
+   if (hdelete_r(localvars[i], htab, flag))
printf("WARNING: '%s' neither in running nor in 
imported env!\n", localvars[i]);
else
printf("WARNING: '%s' not in imported env, deleting 
it!\n", localvars[i]);
diff --git a/test/env/hashtable.c b/test/env/hashtable.c
index 339cc19ba14..70102f9121c 100644
--- a/test/env/hashtable.c
+++ 

[PATCH v2 05/12] bootm: Add a bool parameter to bootm_process_cmdline_env()

2020-11-05 Thread Simon Glass
This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c  | 20 ++--
 include/bootm.h |  3 ++-
 test/bootm.c| 10 +-
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 54f64128f86..9b0c81d6534 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -468,15 +468,17 @@ ulong bootm_disable_interrupts(void)
 #define CONSOLE_ARG "console="
 #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
 
-int bootm_process_cmdline_env(void)
+int bootm_process_cmdline_env(bool do_silent)
 {
char *buf;
const char *env_val;
char *cmdline;
int want_silent;
 
-   if (!IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
-   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY))
+   /* First check if any action is needed */
+   do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
+   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && do_silent;
+   if (!do_silent)
return 0;
cmdline = env_get("bootargs");
 
@@ -631,13 +633,11 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
if (!ret && (states & BOOTM_STATE_OS_BD_T))
ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
if (!ret && (states & BOOTM_STATE_OS_PREP)) {
-   if (images->os.os == IH_OS_LINUX) {
-   ret = bootm_process_cmdline_env();
-   if (ret) {
-   printf("Cmdline setup failed (err=%d)\n", ret);
-   ret = CMD_RET_FAILURE;
-   goto err;
-   }
+   ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX);
+   if (ret) {
+   printf("Cmdline setup failed (err=%d)\n", ret);
+   ret = CMD_RET_FAILURE;
+   goto err;
}
ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
}
diff --git a/include/bootm.h b/include/bootm.h
index 35c27ab9609..f12ee2b3cb3 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -91,8 +91,9 @@ void board_preboot_os(void);
  * Updates the 'bootargs' envvar as required. This handles making Linux boot
  * silently if requested ('silent_linux' envvar)
  *
+ * @do_silent: Process bootargs for silent console
  * @return 0 if OK, -ENOMEM if out of memory
  */
-int bootm_process_cmdline_env(void);
+int bootm_process_cmdline_env(bool do_silent);
 
 #endif
diff --git a/test/bootm.c b/test/bootm.c
index b69bfad4f67..c203f0acd60 100644
--- a/test/bootm.c
+++ b/test/bootm.c
@@ -23,26 +23,26 @@ static int bootm_test_silent_var(struct unit_test_state 
*uts)
/* 'silent_linux' not set should do nothing */
env_set("silent_linux", NULL);
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env());
+   ut_assertok(bootm_process_cmdline_env(true));
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
env_set("bootargs", NULL);
-   ut_assertok(bootm_process_cmdline_env());
+   ut_assertok(bootm_process_cmdline_env(true));
ut_assertnull(env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "no"));
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env());
+   ut_assertok(bootm_process_cmdline_env(true));
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "yes"));
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(bootm_process_cmdline_env());
+   ut_assertok(bootm_process_cmdline_env(true));
ut_asserteq_str("console=", env_get("bootargs"));
 
/* Empty buffer should still add the string */
env_set("bootargs", NULL);
-   ut_assertok(bootm_process_cmdline_env());
+   ut_assertok(bootm_process_cmdline_env(true));
ut_asserteq_str("console=", env_get("bootargs"));
 
return 0;
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 04/12] bootm: Rename fixup_silent_linux()

2020-11-05 Thread Simon Glass
We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c  |  4 ++--
 include/bootm.h |  4 ++--
 test/bootm.c| 10 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 950ff7cff62..54f64128f86 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -468,7 +468,7 @@ ulong bootm_disable_interrupts(void)
 #define CONSOLE_ARG "console="
 #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
 
-int fixup_silent_linux(void)
+int bootm_process_cmdline_env(void)
 {
char *buf;
const char *env_val;
@@ -632,7 +632,7 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
if (!ret && (states & BOOTM_STATE_OS_PREP)) {
if (images->os.os == IH_OS_LINUX) {
-   ret = fixup_silent_linux();
+   ret = bootm_process_cmdline_env();
if (ret) {
printf("Cmdline setup failed (err=%d)\n", ret);
ret = CMD_RET_FAILURE;
diff --git a/include/bootm.h b/include/bootm.h
index 438829af0fe..35c27ab9609 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -86,13 +86,13 @@ void arch_preboot_os(void);
 void board_preboot_os(void);
 
 /*
- * fixup_silent_linux() - Process fix-ups for the command line
+ * bootm_process_cmdline_env() - Process fix-ups for the command line
  *
  * Updates the 'bootargs' envvar as required. This handles making Linux boot
  * silently if requested ('silent_linux' envvar)
  *
  * @return 0 if OK, -ENOMEM if out of memory
  */
-int fixup_silent_linux(void);
+int bootm_process_cmdline_env(void);
 
 #endif
diff --git a/test/bootm.c b/test/bootm.c
index ab1711609ba..b69bfad4f67 100644
--- a/test/bootm.c
+++ b/test/bootm.c
@@ -23,26 +23,26 @@ static int bootm_test_silent_var(struct unit_test_state 
*uts)
/* 'silent_linux' not set should do nothing */
env_set("silent_linux", NULL);
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(fixup_silent_linux());
+   ut_assertok(bootm_process_cmdline_env());
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
env_set("bootargs", NULL);
-   ut_assertok(fixup_silent_linux());
+   ut_assertok(bootm_process_cmdline_env());
ut_assertnull(env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "no"));
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(fixup_silent_linux());
+   ut_assertok(bootm_process_cmdline_env());
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "yes"));
env_set("bootargs", CONSOLE_STR);
-   ut_assertok(fixup_silent_linux());
+   ut_assertok(bootm_process_cmdline_env());
ut_asserteq_str("console=", env_get("bootargs"));
 
/* Empty buffer should still add the string */
env_set("bootargs", NULL);
-   ut_assertok(fixup_silent_linux());
+   ut_assertok(bootm_process_cmdline_env());
ut_asserteq_str("console=", env_get("bootargs"));
 
return 0;
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 03/12] bootm: Update fixup_silent_linux() to return an error

2020-11-05 Thread Simon Glass
At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/bootm.c  | 22 +++---
 include/bootm.h | 11 +--
 test/bootm.c| 10 +-
 3 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 0d36c572101..950ff7cff62 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -468,7 +468,7 @@ ulong bootm_disable_interrupts(void)
 #define CONSOLE_ARG "console="
 #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
 
-void fixup_silent_linux(void)
+int fixup_silent_linux(void)
 {
char *buf;
const char *env_val;
@@ -477,7 +477,7 @@ void fixup_silent_linux(void)
 
if (!IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
!IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY))
-   return;
+   return 0;
cmdline = env_get("bootargs");
 
/*
@@ -489,9 +489,9 @@ void fixup_silent_linux(void)
 */
want_silent = env_get_yesno("silent_linux");
if (want_silent == 0)
-   return;
+   return 0;
else if (want_silent == -1 && !(gd->flags & GD_FLG_SILENT))
-   return;
+   return 0;
 
debug("before silent fix-up: %s\n", cmdline);
if (cmdline && (cmdline[0] != '\0')) {
@@ -501,7 +501,7 @@ void fixup_silent_linux(void)
buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1);
if (!buf) {
debug("%s: out of memory\n", __func__);
-   return;
+   return -ENOSPC;
}
 
if (start) {
@@ -525,6 +525,8 @@ void fixup_silent_linux(void)
env_set("bootargs", env_val);
debug("after silent fix-up: %s\n", env_val);
free(buf);
+
+   return 0;
 }
 
 /**
@@ -629,8 +631,14 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
if (!ret && (states & BOOTM_STATE_OS_BD_T))
ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
if (!ret && (states & BOOTM_STATE_OS_PREP)) {
-   if (images->os.os == IH_OS_LINUX)
-   fixup_silent_linux();
+   if (images->os.os == IH_OS_LINUX) {
+   ret = fixup_silent_linux();
+   if (ret) {
+   printf("Cmdline setup failed (err=%d)\n", ret);
+   ret = CMD_RET_FAILURE;
+   goto err;
+   }
+   }
ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
}
 
diff --git a/include/bootm.h b/include/bootm.h
index 6d675e64559..438829af0fe 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -85,7 +85,14 @@ void arch_preboot_os(void);
  */
 void board_preboot_os(void);
 
-/* Adjust the 'bootargs' to ensure that Linux boots silently, if required */
-void fixup_silent_linux(void);
+/*
+ * fixup_silent_linux() - Process fix-ups for the command line
+ *
+ * Updates the 'bootargs' envvar as required. This handles making Linux boot
+ * silently if requested ('silent_linux' envvar)
+ *
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+int fixup_silent_linux(void);
 
 #endif
diff --git a/test/bootm.c b/test/bootm.c
index 59d16cb3df6..ab1711609ba 100644
--- a/test/bootm.c
+++ b/test/bootm.c
@@ -23,26 +23,26 @@ static int bootm_test_silent_var(struct unit_test_state 
*uts)
/* 'silent_linux' not set should do nothing */
env_set("silent_linux", NULL);
env_set("bootargs", CONSOLE_STR);
-   fixup_silent_linux();
+   ut_assertok(fixup_silent_linux());
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
env_set("bootargs", NULL);
-   fixup_silent_linux();
+   ut_assertok(fixup_silent_linux());
ut_assertnull(env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "no"));
env_set("bootargs", CONSOLE_STR);
-   fixup_silent_linux();
+   ut_assertok(fixup_silent_linux());
ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
 
ut_assertok(env_set("silent_linux", "yes"));
env_set("bootargs", CONSOLE_STR);
-   fixup_silent_linux();
+   ut_assertok(fixup_silent_linux());
ut_asserteq_str("console=", env_get("bootargs"));
 
/* Empty buffer should still add the string */
env_set("bootargs", NULL);
-   fixup_silent_linux();
+   ut_assertok(fixup_silent_linux());
ut_asserteq_str("console=", env_get("bootargs"));
 
return 0;
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v2 02/12] bootm: Add tests for fixup_silent_linux()

2020-11-05 Thread Simon Glass
This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/Kconfig  |  1 +
 common/bootm.c| 14 +-
 include/bootm.h   |  3 +++
 include/test/suites.h |  1 +
 test/Makefile |  1 +
 test/bootm.c  | 59 +++
 test/cmd_ut.c |  1 +
 7 files changed, 73 insertions(+), 7 deletions(-)
 create mode 100644 test/bootm.c

diff --git a/arch/Kconfig b/arch/Kconfig
index 683e3843190..6caf2338bcf 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -140,6 +140,7 @@ config SANDBOX
imply ACPI_PMC_SANDBOX
imply CMD_PMC
imply CMD_CLONE
+   imply SILENT_CONSOLE
 
 config SH
bool "SuperH architecture"
diff --git a/common/bootm.c b/common/bootm.c
index 167eea4a1e9..0d36c572101 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -465,18 +465,21 @@ ulong bootm_disable_interrupts(void)
return iflag;
 }
 
-#if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
-
 #define CONSOLE_ARG "console="
 #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
 
-static void fixup_silent_linux(void)
+void fixup_silent_linux(void)
 {
char *buf;
const char *env_val;
-   char *cmdline = env_get("bootargs");
+   char *cmdline;
int want_silent;
 
+   if (!IS_ENABLED(CONFIG_SILENT_CONSOLE) &&
+   !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY))
+   return;
+   cmdline = env_get("bootargs");
+
/*
 * Only fix cmdline when requested. The environment variable can be:
 *
@@ -523,7 +526,6 @@ static void fixup_silent_linux(void)
debug("after silent fix-up: %s\n", env_val);
free(buf);
 }
-#endif /* CONFIG_SILENT_CONSOLE */
 
 /**
  * Execute selected states of the bootm command.
@@ -627,10 +629,8 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
if (!ret && (states & BOOTM_STATE_OS_BD_T))
ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
if (!ret && (states & BOOTM_STATE_OS_PREP)) {
-#if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
if (images->os.os == IH_OS_LINUX)
fixup_silent_linux();
-#endif
ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
}
 
diff --git a/include/bootm.h b/include/bootm.h
index a812a6bf24f..6d675e64559 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -85,4 +85,7 @@ void arch_preboot_os(void);
  */
 void board_preboot_os(void);
 
+/* Adjust the 'bootargs' to ensure that Linux boots silently, if required */
+void fixup_silent_linux(void);
+
 #endif
diff --git a/include/test/suites.h b/include/test/suites.h
index ab7b3bd9cad..c1d8fa9a650 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -26,6 +26,7 @@ int cmd_ut_category(const char *name, const char *prefix,
struct unit_test *tests, int n_ents,
int argc, char *const argv[]);
 
+int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
 int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc,
diff --git a/test/Makefile b/test/Makefile
index 1c930b31485..244ac8be139 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -3,6 +3,7 @@
 # (C) Copyright 2012 The Chromium Authors
 
 obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o
+obj-$(CONFIG_$(SPL_)CMDLINE) += bootm.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += cmd/
 obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o
diff --git a/test/bootm.c b/test/bootm.c
new file mode 100644
index 000..59d16cb3df6
--- /dev/null
+++ b/test/bootm.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for bootm routines
+ *
+ * Copyright 2020 Google LLC
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define BOOTM_TEST(_name, _flags)  UNIT_TEST(_name, _flags, bootm_test)
+
+#define CONSOLE_STR"console=/dev/ttyS0"
+
+/* Test silent processing in the bootargs variable */
+static int bootm_test_silent_var(struct unit_test_state *uts)
+{
+   /* 'silent_linux' not set should do nothing */
+   env_set("silent_linux", NULL);
+   env_set("bootargs", CONSOLE_STR);
+   fixup_silent_linux();
+   ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
+
+   env_set("bootargs", NULL);
+   fixup_silent_linux();
+   ut_assertnull(env_get("bootargs"));
+
+   ut_assertok(env_set("silent_linux", "no"));
+   env_set("bootargs", CONSOLE_STR);
+   fixup_silent_linux();
+   ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
+
+   ut_assertok(env_set("silent_linux", "yes"));
+   env_set("bootargs", CONSOLE_STR);

[PATCH v2 00/12] bootm: Support substitions in bootargs and add tests

2020-11-05 Thread Simon Glass
This series adds tests to the fixup_silent_linux() function and extends
the 'zimage' command to use it.

It also adds a new string-substition feature to allow bootargs to be a
template, rather than having to build it up piece by piece with
information obtained in a build script.

It also updates zimage to use the same command-line processing.

With these additions it is possible to boot Chrome OS from a U-Boot script
on most Chromebooks.

Changes in v2:
- Add a new patch to support macro processing with a fixed-size buffer
- Use ${} for subtitution instead of %
- Tweak cover letter

Simon Glass (12):
  env: Allow returning errors from hdelete_r()
  bootm: Add tests for fixup_silent_linux()
  bootm: Update fixup_silent_linux() to return an error
  bootm: Rename fixup_silent_linux()
  bootm: Add a bool parameter to bootm_process_cmdline_env()
  bootm: Use size rather than length for CONSOLE_ARG
  bootm: Split out bootargs environment reading / writing
  bootm: Update bootm_process_cmdline_env() to use flags
  bootm: Allow updating the bootargs in a buffer
  x86: zimage: Add silent-console processing
  cli: Support macro processing with a fixed-size buffer
  bootm: Support string substitution in bootargs

 arch/Kconfig  |   2 +
 arch/x86/lib/zimage.c |  14 +++
 cmd/nvedit.c  |   6 +-
 cmd/pxe_utils.c   |   6 +-
 common/Kconfig.boot   |  17 +++
 common/bootm.c| 172 +++--
 common/cli_simple.c   |  17 ++-
 include/bootm.h   |  40 +++
 include/cli.h |   4 +-
 include/search.h  |  11 +-
 include/test/suites.h |   1 +
 lib/hashtable.c   |  12 +-
 test/Makefile |   1 +
 test/bootm.c  | 247 ++
 test/cmd_ut.c |   1 +
 test/env/hashtable.c  |   2 +-
 16 files changed, 504 insertions(+), 49 deletions(-)
 create mode 100644 test/bootm.c

-- 
2.29.1.341.ge80a0c044ae-goog



Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Simon Glass
Hi Marek,

On Tue, 3 Nov 2020 at 09:30, Marek Behun  wrote:
>
> On Tue, 3 Nov 2020 08:12:17 -0700
> Simon Glass  wrote:
>
> > Hi Marek,
> >
> > On Sun, 1 Nov 2020 at 16:08, Marek Behun  wrote:
> > >
> > > What is the purpose of + operator on strings?
> > > Can't we use setenv "${a}${b}" ?
> >
> > Yes, that does the same thing, although it is a bit clumsy.
> >
> > setenv a *10
> > setenv b *100
> > setenv c "${a}${b}"
> >
> > instead of
> >
> > setexpr c *10 + *100
>
> Hi Simon,
>
> I don't know. It provides the same functionality that exists, but only
> adds code.
> Is someone really going to use this?

I don't know. Perhaps we can wait and see if anyone cares?

>
> Marek
>
> PS: What I think would be more useful is to add substringing
> functionality into hush, so e.g. ${a:3:5}, and pattern substitions:
> ${parameter/pattern/string} ...

Yes we need to upgrade hush.

Regards,
Simon


Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Simon Glass
Hi Wolfgang,

On Thu, 5 Nov 2020 at 09:47, Wolfgang Denk  wrote:
>
> Dear Simon,
>
> In message 
>  you 
> wrote:
> >
> > > What is the purpose of + operator on strings?
> > > Can't we use setenv "${a}${b}" ?
> >
> > Yes, that does the same thing, although it is a bit clumsy.
> >
> > setenv a *10
> > setenv b *100
> > setenv c "${a}${b}"
> >
> > instead of
> >
> > setexpr c *10 + *100
>
> I don't get it.  The equivalent to "${a}${b}" would be
>
> setexpr c "*10*100"
>
> which is even simpler?

I don't see how that works. The *10 thing in my example reads a string
out of address 10.

Regards,
Simon


Please pull u-boot-dm

2020-11-05 Thread Simon Glass
Hi Tom,

The following changes since commit 35b7ca768f7d826b77d5d3d6ccd6b1b8ed21f186:

  arch: Move NEEDS_MANUAL_RELOC symbol to Kconfig (2020-11-04 10:13:44
-0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull5nov20

for you to fetch changes up to dc4b2a9770b5b932cd6d98c33ebff6dc46de6849:

  patman: Support listing comments from patchwork (2020-11-05 09:11:31
-0700)


patman status subcommand to collect tags from Patchwork
patman showing email replies from Patchwork
sandbox poweroff command
minor fixes in binman, tests


Alper Nebi Yasak (1):
  cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT

Heinrich Schuchardt (10):
  sandbox: eth-raw: do not close the console input
  sandbox: enable poweroff command
  test/py: test poweroff
  sandbox: use O_CLOEXEC in os_open()
  sandbox: implement reset
  test: adjust sysreset tests
  sandbox: update function descriptions in os.h
  doc: add sandbox API
  test: test/bloblist.c depends on asm/state.h
  test: linking test/compression.c fails

Michal Simek (2):
  binman: Call helper function binman_set_rom_offset() to fill offset
  binman: Fix typo in kernel-doc format for binman_symname()

Simon Glass (31):
  binman: Update intel_ifwi to store padded section
  binman: Correct calculation for image-pos
  patman: Correct operation of -n
  azure/gitLab/travis: Add pygit2 as a dependency for tests
  patman: Update how tests are run
  patman: Fix whitespace errors in func_test
  patman: Use capture_sys_output() consistently
  patman: Fix remaining pylint3 warnings in func_test
  patman: Allow linking a series with patchwork
  patman: Fix indenting in patchstream
  patman: Fix constant style in patchstream
  patman: Rename functions in patchstream
  patman: Rename variables in patchstream
  patman: Drop unused args in patchstream
  patman: Fix up argument/return docs in patchstream
  patman: Move warning collection to a function
  patman: Attach warnings to individual patches
  patman: Convert 'Series-xxx' tag errors into warnings
  patman: Drop unused signoff member
  patman: Add a test for PatchStream tags
  patman: Add some tests for warnings
  patman: Convert testBasic() to use an interator
  patman: Fix spelling of plural for warning
  patman: Don't ignore lines starting with hash
  patman: Allow showing a Commit as a string
  patman: Improve handling of files
  patman: Detect missing upstream in CountCommitsToBranch
  patman: Support checking for review tags in patchwork
  patman: Support updating a branch with review tags
  patman: Support parsing of review snippets
  patman: Support listing comments from patchwork

 .azure-pipelines.yml  |   2 +-
 .gitlab-ci.yml|   2 +-
 .travis.yml   |   1 +
 arch/Kconfig  |   3 +-
 arch/sandbox/cpu/eth-raw-os.c |   8 +-
 arch/sandbox/cpu/os.c |  16 +-
 arch/sandbox/cpu/start.c  |  26 ++
 arch/sandbox/cpu/state.c  |   1 +
 arch/sandbox/include/asm/u-boot-sandbox.h |  10 +
 doc/api/index.rst |   1 +
 doc/api/sandbox.rst   |   9 +
 drivers/input/cros_ec_keyb.c  |  32 +-
 drivers/misc/cros_ec.c|  15 +
 drivers/sysreset/sysreset_sandbox.c   |   3 +
 include/binman_sym.h  |   2 +-
 include/cros_ec.h |  11 +
 include/os.h  | 236 ++-
 lib/binman.c  |   4 +-
 test/Kconfig  |   9 +
 test/Makefile |   4 +-
 test/dm/sysreset.c|  11 +-
 test/py/tests/test_sandbox_exit.py|   8 +-
 tools/binman/entry.py |  18 +-
 tools/binman/etype/intel_ifwi.py  |   2 +-
 tools/buildman/control.py |   6 +-
 tools/patman/README   | 110 +-
 tools/patman/checkpatch.py|  18 +-
 tools/patman/commit.py|   5 +
 tools/patman/control.py   |  71 +++-
 tools/patman/func_test.py | 983
++
 tools/patman/gitutil.py   |  10 +-
 tools/patman/main.py  |  42 +-
 tools/patman/patchstream.py   | 485 ---
 tools/patman/series.py|   8 +-
 tools/patman/status.py| 482 +++
 tools/patman/terminal.py  |  21 +-
 tools/patman/test_checkpatch.py   |   6 +-
 37 files changed, 2293 

Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Wolfgang Denk
Dear Marek,

In message <20201103173011.08e22...@nic.cz> you wrote:
>
> PS: What I think would be more useful is to add substringing
> functionality into hush, so e.g. ${a:3:5}, and pattern substitions:
> ${parameter/pattern/string} ...

No, NAK, don't.

At least not to the current imple,entation of hush.  First, upgrade
to the recent version from BusyBox, and then we might discuss
extensions.  Actually we should eventually discuss these in BusyBox
to have such stuff in "hush mainline" ...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"There's only one way to have a happy marriage and as soon as I learn
what it is I'll get married again."  - Clint Eastwood


Re: [rockchip] broken SPI on RockPro64 and other RK3399 targets

2020-11-05 Thread Alper Nebi Yasak
On 05/11/2020 18:55, Marcin Juszkiewicz wrote:
> I wanted to update U-Boot on my RockPro64 board from some random build 
> of 2020.07-rc with out of tree patches to official one. Built, flashed 
> and then got this:
> 
> Loading Environment from SPI Flash... Invalid bus 0 (err=-19)
> *** Warning - spi_flash_probe_bus_cs() failed, using default environment
> 
> According to Peter Robinson it happens also on other RK3399 boards.

FYI: SPI flash commands work for me on rk3399-gru-kevin after just
adding the JEDEC ID things for its chip (with CONFIG_SF_DEFAULT_BUS=1)
but I haven't tried loading environment from it yet (doing weird
out-of-tree things to run U-Boot anyway).

> As I had a bit of time I started bisecting and found reason:
> 
> 16:43 (7s) hrw@puchatek:u-boot$ git bisect good
> c4cea2bbf995764f325a907061c22ecd6768cf7b is the first bad commit
> commit c4cea2bbf995764f325a907061c22ecd6768cf7b
> Author: Simon Glass 
> Date:   Sun Jul 19 13:55:58 2020 -0600
> 
>  rockchip: Enable building a SPI ROM image on bob
> 
>  Add a simple binman config and enable CONFIG_HAS_ROM so that U-Boot
>  produces a ROM for bob.
> 
>  Signed-off-by: Simon Glass 
> 
>   arch/arm/dts/rk3399-gru-u-boot.dtsi   |  4 
>   arch/arm/dts/rk3399-gru.dtsi  |  2 +-
>   arch/arm/dts/rk3399-u-boot.dtsi   | 27 +++
>   arch/arm/mach-rockchip/rk3399/Kconfig |  2 ++
>   4 files changed, 34 insertions(+), 1 deletion(-)
> 
> Then I checked out HEAD of master branch, reverted that patch and SPI 
> flash got detected properly.
> 
> Not looked yet on how it should be fixed.

I suspect this change in that commit (rk3399-u-boot.dtsi):

>  / {
> aliases {
> mmc0 = 
> mmc1 = 
> pci0 = 
> +   spi1 = 
> };

Can you test adding spi0 =  above that in the list?


[GIT PULL] Pull request: u-boot-imx u-boot-imx-20201105

2020-11-05 Thread Stefano Babic
Hi Tom,

please pull from u-boot-imx, thanks !

The following changes since commit 2c31d7e746766f47a007f39c030706e493a9cc77:

  Merge tag 'u-boot-rockchip-20201031' of
https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip (2020-10-30
23:13:13 -0400)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git
tags/u-boot-imx-20201105

for you to fetch changes up to b431970e7f0ce5b83fae1502eddc3568115207ad:

  board: ge: b1x5v2: Add MAINTAINERS (2020-11-04 19:47:30 +0100)


u-boot-imx for 2021.1
-

- new boards : GE (new B1x5v2), phytec phyCORE-i.MX8MM
- converted doc to reST
- fixes for verdin-imx8mm (Toradex)
- fixes for i.MX thermal driver
- mx7ulp: Align the PLL_USB frequency
- mx53: primary/secondary bmode

Travis: https://travis-ci.org/github/sbabic/u-boot-imx/builds/741465284


Fabio Estevam (2):
  mx7ulp: clock: Remove unuseful information
  mx7ulp: clock: Align the PLL_USB frequency

Igor Opaniuk (1):
  verdin-imx8mm: enable fdt overlays and env importing

Jorge Ramirez-Ortiz (1):
  mx6: peripheral clock from oscillator

Lukasz Majewski (3):
  arm: Implement show_boot_progress() for imx53's HSC and DDC devices
  dts: Provide LED DTS description for HSC and DDC imx53 devices
  defconfig: Enable CONFIG_SHOW_BOOT_PROGRESS for imx53's HSC and
DDC devices

Marek Vasut (1):
  ARM: imx: Add support for the primary/secondary bmode to MX53

Michael Walle (1):
  watchdog: Hide WATCHDOG_RESET_DISABLE

Peng Fan (12):
  board: imx: address dd usage in README
  doc: board: Convert i.MX8MP EVK README to reST
  doc: board: Convert i.MX8MN EVK README to reST
  doc: board: Convert i.MX8MM EVK README to reST
  doc: board: Convert i.MX8MQ EVK README to reST
  doc: board: Convert i.MX8QXP MEK README to reST
  doc: board: Convert i.MXRT1020 EVK README to reST
  doc: board: Convert i.MXRT1050 EVK README to reST
  doc: board: Convert i.MX6 Sabreauto README to reST
  doc: board: Convert i.MX6 Sabresd README to reST
  doc: board: Convert i.MX6UL 14x14 EVK README to reST
  doc: board: Convert i.MX6ULL EVK README to reST

Sebastian Reichel (12):
  bootcount: add a DM SPI flash backing store for bootcount
  rtc: m41t62: reset SQW in m41t62_rtc_reset
  rtc: m41t62: add oscillator fail bit reset support
  imx6: allow usage of disable_ldb_di_clock_sources for CONFIG_MX6QDL
  sysreset: Add poweroff-gpio driver
  board: ge: common: rename ge_common.c to ge_rtc.c
  board: ge: common: add config option for RTC and VPD feature
  board: ge: common: vpd: separate I2C specific code
  board: ge: b1x5v2: Add GE B1x5v2 and B1x5Pv2
  board: ge: bx50v3: Update MAINTAINERS
  board: ge: ppd: Update MAINTAINERS
  board: ge: b1x5v2: Add MAINTAINERS

Teresa Remmet (1):
  board: phytec: imx8mm: Add PHYTEC phyCORE-i.MX8MM support

Tim Harvey (2):
  imx: cpu: terminate line with CR if invalid temp sensor
  thermal: imx_tmu: fix missing include

 arch/arm/dts/Makefile
   |2 +
 arch/arm/dts/imx53-kp.dts
   |4 +
 arch/arm/dts/imx6dl-b1x5v2.dts
   |  654 +++
 arch/arm/dts/phycore-imx8mm-u-boot.dtsi
   |  100 
 arch/arm/dts/phycore-imx8mm.dts
   |  259 +++
 arch/arm/mach-imx/cpu.c
   |3 +-
 arch/arm/mach-imx/imx8m/Kconfig
   |6 +
 arch/arm/mach-imx/mx5/soc.c
   |   21 +-
 arch/arm/mach-imx/mx6/Kconfig
   |9 +
 arch/arm/mach-imx/mx6/clock.c
   |2 +-
 arch/arm/mach-imx/mx6/soc.c
   |5 +-
 arch/arm/mach-imx/mx7ulp/clock.c
   |6 +-
 board/freescale/imx8mm_evk/README
   |   37 ---
 board/freescale/imx8mn_evk/README
   |   37 ---
 board/freescale/imx8mp_evk/README
   |   41 ---
 board/freescale/imx8mq_evk/README
   |   37 ---
 board/freescale/imx8qxp_mek/README
   |   50 
 board/freescale/imxrt1020-evk/README
   |   31 ---
 board/freescale/imxrt1050-evk/README
   |   31 ---
 board/freescale/mx6sabreauto/README
   |   82 --
 board/freescale/mx6sabresd/README
   |  114 -
 board/ge/b1x5v2/Kconfig
   |   14 +
 board/ge/b1x5v2/MAINTAINERS
   |9 +
 board/ge/b1x5v2/Makefile
   |6 +
 board/ge/b1x5v2/b1x5v2.c
   |  698 ++
 board/ge/b1x5v2/spl.c
   |  587 ++
 board/ge/bx50v3/Kconfig
   |2 +
 board/ge/bx50v3/MAINTAINERS
   |   11 +-
 board/ge/bx50v3/bx50v3.c
   |4 +-
 board/ge/common/Kconfig
   |7 +
 board/ge/common/Makefile
   |3 +-
 board/ge/common/{ge_common.c => ge_rt

Re: [PATCH 10/10] setexpr: Add support for strings

2020-11-05 Thread Wolfgang Denk
Dear Simon,

In message  
you wrote:
>
> > What is the purpose of + operator on strings?
> > Can't we use setenv "${a}${b}" ?
>
> Yes, that does the same thing, although it is a bit clumsy.
>
> setenv a *10
> setenv b *100
> setenv c "${a}${b}"
>
> instead of
>
> setexpr c *10 + *100

I don't get it.  The equivalent to "${a}${b}" would be

setexpr c "*10*100"

which is even simpler?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"You know, after a woman's raised a family and so on,  she  wants  to
start living her own life."   "Whose life she's _been_ living, then?"
  - Terry Pratchett, _Witches Abroad_


Re: [PATCH] env: env_sf: don't set .init op if not needed

2020-11-05 Thread Wolfgang Denk
Dear Rasmus,

In message <8ff3b8ad-8c4e-fe99-69c8-7c174e997...@prevas.dk> you wrote:
>
> >> Not in a none standard way! Instead you can define more than one
> >> environment storage devices and load them in a board specific order
> >> (defined thorugh board specfif function env_get_location())
> > 
> > Yes, agreed.  But this logically impossible if there is no storage
> > at all, which is what CONFIG_ENV_IS_NOWHERE says.
>
> Then should all the current config options CONFIG_ENV_IS_ be renamed to
> CONFIG_ENV_MAY_BE_? Because that's really what they mean.

This is not correct.

The CONFIG_ENV_IS_FOO means: if you use "env save", then U-Boot will
write the config to external storage using the FOO storage device.

> I certainly agree the current naming isn't very accurate, but the
> ability to choose CONFIG_ENV_IS_NOWHERE along with some "real" storage
> option is quite useful. We use it so that we can use the exact same
> U-Boot binary for both development and production, just different .dtbs;
> there's a board-specific env_get_location() which reads a DT property to
> decide whether to return ENVL_SPI_FLASH or ENVL_NOWHERE. Whether there
> actually needs to be a stub nowhere.c driver for that or one could just
> return ENVL_UNKNOWN I don't know.

If it makes sense do have a nulldev, then it should be added as a
CONFIG_ENV_IS_ option.  This is something fundamental different from
NOWHERE.

If you define CONFIG_ENV_IS_NOWHERE, I would for example expect that
all "env save" related code is omitted as we will never need it.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
A metaphor is like a simile.


[PATCH 1/2] doc: board: amlogic: Update support matrix

2020-11-05 Thread Neil Armstrong
Update the matrix table with new supported features and
new SoC features to support.

Signed-off-by: Neil Armstrong 
---
 doc/board/amlogic/index.rst | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 0e2f8c9aad..9e780ba47c 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -26,7 +26,7 @@ This matrix concerns the actual source code version.
 
+---+---+--+--+++-+--+
 | Clock Control| **Yes**   | **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
-| PWM  | No| No   | No   | No  
   | No | No  | No   |
+| PWM  | **Yes**   | **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
 | Reset Control| **Yes**   | **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
@@ -44,9 +44,9 @@ This matrix concerns the actual source code version.
 
+---+---+--+--+++-+--+
 | I2C  | **Yes**   | **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
-| USB  | **Yes**   | **Yes**  | **Yes**  | No  
   | **Yes**| **Yes** | **Yes**  |
+| USB  | **Yes**   | **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
-| USB OTG  | No| **Yes**  | **Yes**  | No  
   | **Yes**| **Yes** | **Yes**  |
+| USB OTG  | No| **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
 | eMMC | **Yes**   | **Yes**  | **Yes**  | 
**Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
@@ -66,6 +66,8 @@ This matrix concerns the actual source code version.
 
+---+---+--+--+++-+--+
 | LCD/LVDS Output  | No| *N/A*| No   | No  
   | No | No  | No   |
 
+---+---+--+--+++-+--+
+| MIPI DSI Output  | *N/A* | *N/A*| *N/A*| No  
   | No | No  | No   |
++---+---+--+--+++-+--+
 | SoC (version) information| **Yes**   | **Yes**  | **Yes**
  | **Yes**| **Yes**| **Yes** | **Yes**  |
 
+---+---+--+--+++-+--+
 
-- 
2.25.1



[PATCH 2/2] doc: board: vim3: Fix build instructions

2020-11-05 Thread Neil Armstrong
The build instructions were buggy and changed a little since they
were written.

Signed-off-by: Neil Armstrong 
---
 doc/board/amlogic/khadas-vim3.rst  |  9 +
 doc/board/amlogic/khadas-vim3l.rst | 11 +++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/doc/board/amlogic/khadas-vim3.rst 
b/doc/board/amlogic/khadas-vim3.rst
index d6a9642ad6..8b7196d988 100644
--- a/doc/board/amlogic/khadas-vim3.rst
+++ b/doc/board/amlogic/khadas-vim3.rst
@@ -76,15 +76,16 @@ the git tree published by the board vendor:
 
 $ cd vim3-u-boot
 $ make kvim3_defconfig
-$ make
+$ make CROSS_COMPILE=aarch64-none-elf-
 $ export UBOOTDIR=$PWD
 
- Go back to mainline U-Boot source tree then :
+Go back to mainline U-Boot source tree then :
 
 .. code-block:: bash
 
 $ mkdir fip
 
+$ wget 
https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh
 -O fip/blx_fix.sh
 $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
 $ cp $UBOOTDIR/build/board/khadas/kvim3/firmware/acs.bin fip/
 $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/
@@ -101,7 +102,7 @@ the git tree published by the board vendor:
 $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
 $ cp u-boot.bin fip/bl33.bin
 
-$ sh fip/blx_fix.sh \
+$ bash fip/blx_fix.sh \
fip/bl30.bin \
fip/zero_tmp \
fip/bl30_zero.bin \
@@ -110,7 +111,7 @@ the git tree published by the board vendor:
fip/bl30_new.bin \
bl30
 
-$ sh fip/blx_fix.sh \
+$ bash fip/blx_fix.sh \
fip/bl2.bin \
fip/zero_tmp \
fip/bl2_zero.bin \
diff --git a/doc/board/amlogic/khadas-vim3l.rst 
b/doc/board/amlogic/khadas-vim3l.rst
index 3c0a415a87..aed8955391 100644
--- a/doc/board/amlogic/khadas-vim3l.rst
+++ b/doc/board/amlogic/khadas-vim3l.rst
@@ -48,6 +48,8 @@ Then power-cycle the board.
 U-Boot compilation
 --
 
+.. code-block:: bash
+
 $ export CROSS_COMPILE=aarch64-none-elf-
 $ make khadas-vim3l_defconfig
 $ make
@@ -74,15 +76,16 @@ the git tree published by the board vendor:
 
 $ cd vim3l-u-boot
 $ make kvim3l_defconfig
-$ make
+$ make CROSS_COMPILE=aarch64-none-elf-
 $ export UBOOTDIR=$PWD
 
- Go back to mainline U-Boot source tree then :
+Go back to mainline U-Boot source tree then :
 
 .. code-block:: bash
 
 $ mkdir fip
 
+$ wget 
https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh
 -O fip/blx_fix.sh
 $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
 $ cp $UBOOTDIR/build/board/khadas/kvim3l/firmware/acs.bin fip/
 $ cp $UBOOTDIR/fip/g12a/bl2.bin fip/
@@ -99,7 +102,7 @@ the git tree published by the board vendor:
 $ cp $UBOOTDIR/fip/g12a/aml_ddr.fw fip/
 $ cp u-boot.bin fip/bl33.bin
 
-$ sh fip/blx_fix.sh \
+$ bash fip/blx_fix.sh \
fip/bl30.bin \
fip/zero_tmp \
fip/bl30_zero.bin \
@@ -108,7 +111,7 @@ the git tree published by the board vendor:
fip/bl30_new.bin \
bl30
 
-$ sh fip/blx_fix.sh \
+$ bash fip/blx_fix.sh \
fip/bl2.bin \
fip/zero_tmp \
fip/bl2_zero.bin \
-- 
2.25.1



Re: [PATCH] rockchip: Rock960: fix up USB support

2020-11-05 Thread Peter Robinson
On Fri, Oct 30, 2020 at 10:08 AM Kever Yang  wrote:
>
> Hi Peter,
>
>
>  Could you add you signature for this patch?

Apologies, not sure how I missed that, included below, let me know if
you want me to resend the patch instead.

Signed-off-by: Peter Robinson 

>
> Thanks,
>
> - Kever
>
> On 2020/9/29 下午9:06, Peter Robinson wrote:
> > Fix up USB config options so keyboards and other USB devices work.
> > ---
> >   configs/rock960-rk3399_defconfig | 9 ++---
> >   include/configs/rock960_rk3399.h | 2 ++
> >   2 files changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/configs/rock960-rk3399_defconfig 
> > b/configs/rock960-rk3399_defconfig
> > index 1d997847c2..a5a50785c5 100644
> > --- a/configs/rock960-rk3399_defconfig
> > +++ b/configs/rock960-rk3399_defconfig
> > @@ -3,12 +3,12 @@ CONFIG_ARCH_ROCKCHIP=y
> >   CONFIG_SYS_TEXT_BASE=0x0020
> >   CONFIG_ENV_OFFSET=0x3F8000
> >   CONFIG_ROCKCHIP_RK3399=y
> > -CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x4000
> >   CONFIG_TARGET_ROCK960_RK3399=y
> >   CONFIG_DEBUG_UART_BASE=0xFF1A
> >   CONFIG_DEBUG_UART_CLOCK=2400
> >   CONFIG_DEFAULT_DEVICE_TREE="rk3399-rock960"
> >   CONFIG_DEBUG_UART=y
> > +CONFIG_USE_PREBOOT=y
> >   CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock960.dtb"
> >   CONFIG_MISC_INIT_R=y
> >   CONFIG_DISPLAY_BOARDINFO_LATE=y
> > @@ -41,6 +41,8 @@ CONFIG_MMC_SDHCI_ROCKCHIP=y
> >   CONFIG_DM_ETH=y
> >   CONFIG_NVME=y
> >   CONFIG_PCI=y
> > +CONFIG_PHY_ROCKCHIP_INNO_USB2=y
> > +CONFIG_PHY_ROCKCHIP_TYPEC=y
> >   CONFIG_PMIC_RK8XX=y
> >   CONFIG_REGULATOR_PWM=y
> >   CONFIG_REGULATOR_RK8XX=y
> > @@ -54,10 +56,11 @@ CONFIG_USB_XHCI_HCD=y
> >   CONFIG_USB_XHCI_DWC3=y
> >   CONFIG_USB_EHCI_HCD=y
> >   CONFIG_USB_EHCI_GENERIC=y
> > +CONFIG_USB_OHCI_HCD=y
> > +CONFIG_USB_OHCI_GENERIC=y
> >   CONFIG_USB_DWC3=y
> > -CONFIG_ROCKCHIP_USB2_PHY=y
> > +CONFIG_DM_KEYBOARD=y
> >   CONFIG_USB_KEYBOARD=y
> > -CONFIG_USB_GADGET=y
> >   CONFIG_USB_HOST_ETHER=y
> >   CONFIG_USB_ETHER_ASIX=y
> >   CONFIG_USB_ETHER_ASIX88179=y
> > diff --git a/include/configs/rock960_rk3399.h 
> > b/include/configs/rock960_rk3399.h
> > index c6f9122154..2edad71028 100644
> > --- a/include/configs/rock960_rk3399.h
> > +++ b/include/configs/rock960_rk3399.h
> > @@ -15,4 +15,6 @@
> >
> >   #define SDRAM_BANK_SIZE (2UL << 30)
> >
> > +#define CONFIG_USB_OHCI_NEW
> > +#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 2
> >   #endif
>
>


Re: [PATCH 2/2] arm64: meson: add support for libretech-cc v2

2020-11-05 Thread Neil Armstrong
On 05/11/2020 15:35, Jerome Brunet wrote:
> 
> On Thu 05 Nov 2020 at 15:22, Neil Armstrong  wrote:
> 
>> Hi,
>>
>> On 05/11/2020 15:15, Jerome Brunet wrote:
>>> Add support for the Amlogic based libretech cc version 2.
>>> As version 1, it is based on the s905x SoC.
>>>
>>> Signed-off-by: Jerome Brunet 
>>> ---
>>>  arch/arm/dts/Makefile |  1 +
>>>  ...eson-gxl-s905x-libretech-cc-v2-u-boot.dtsi |  7 ++
>>>  configs/libretech-cc_v2_defconfig | 82 +++
>>>  3 files changed, 90 insertions(+)
>>>  create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>>>  create mode 100644 configs/libretech-cc_v2_defconfig
>>>
>>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>>> index b195723f1645..e957820e8e62 100644
>>> --- a/arch/arm/dts/Makefile
>>> +++ b/arch/arm/dts/Makefile
>>> @@ -159,6 +159,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
>>> meson-gxl-s905x-p212.dtb \
>>> meson-gxl-s805x-libretech-ac.dtb \
>>> meson-gxl-s905x-libretech-cc.dtb \
>>> +   meson-gxl-s905x-libretech-cc-v2.dtb \
>>> meson-gxl-s905x-khadas-vim.dtb \
>>> meson-gxl-s905d-libretech-pc.dtb \
>>> meson-gxm-khadas-vim2.dtb \
>>
>> This should be part of the previous patch
>>
> 
> I'm happy to do it but the previous patch is supposed to just be copy of
> the linux file, isn't it ?

If DT files are added, it's better to add them to the Makefile at the same time

> 
> If it is not the case, can we just fold the whole thing in a single
> patch ?

I'd rather prefer separate logical patches for DT, Doc & configs

Neil

> 
>>> diff --git a/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi 
>>> b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>>> new file mode 100644
>>> index ..8ff5a0ef2ba5
>>> --- /dev/null
>>> +++ b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>>> @@ -0,0 +1,7 @@
>>> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>>> +/*
>>> + * Copyright (c) 2020 BayLibre, SAS.
>>> + * Author: Jerome Brunet 
>>> + */
>>> +
>>> +#include "meson-gxl-u-boot.dtsi"
>>> diff --git a/configs/libretech-cc_v2_defconfig 
>>> b/configs/libretech-cc_v2_defconfig
>>> new file mode 100644
>>> index ..e71f88edaec6
>>> --- /dev/null
>>> +++ b/configs/libretech-cc_v2_defconfig
>>> @@ -0,0 +1,82 @@
>>> +CONFIG_ARM=y
>>> +CONFIG_ARCH_MESON=y
>>> +CONFIG_SYS_TEXT_BASE=0x0100
>>> +CONFIG_ENV_SIZE=0x2000
>>> +CONFIG_ENV_OFFSET=0x
>>> +CONFIG_ENV_SECT_SIZE=0x1
>>> +CONFIG_DM_GPIO=y
>>> +CONFIG_MESON_GXL=y
>>> +CONFIG_NR_DRAM_BANKS=1
>>> +CONFIG_DEBUG_UART_BASE=0xc81004c0
>>> +CONFIG_DEBUG_UART_CLOCK=2400
>>> +CONFIG_IDENT_STRING=" libretech-cc-v2"
>>> +CONFIG_DEBUG_UART=y
>>> +CONFIG_OF_BOARD_SETUP=y
>>> +CONFIG_USE_PREBOOT=y
>>> +CONFIG_PREBOOT="usb start"
>>> +CONFIG_MISC_INIT_R=y
>>> +# CONFIG_DISPLAY_CPUINFO is not set
>>> +# CONFIG_DISPLAY_BOARDINFO is not set
>>> +# CONFIG_CMD_BDI is not set
>>> +# CONFIG_CMD_IMI is not set
>>> +CONFIG_CMD_ADC=y
>>> +CONFIG_CMD_GPIO=y
>>> +# CONFIG_CMD_LOADS is not set
>>> +CONFIG_CMD_MMC=y
>>> +CONFIG_CMD_SPI=y
>>> +CONFIG_CMD_USB=y
>>> +CONFIG_CMD_USB_MASS_STORAGE=y
>>> +# CONFIG_CMD_SETEXPR is not set
>>> +CONFIG_CMD_REGULATOR=y
>>> +CONFIG_OF_CONTROL=y
>>> +CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc-v2"
>>> +CONFIG_ENV_IS_IN_SPI_FLASH=y
>>> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>> +CONFIG_NET_RANDOM_ETHADDR=y
>>> +CONFIG_SARADC_MESON=y
>>> +CONFIG_DM_KEYBOARD=y
>>> +CONFIG_DM_MMC=y
>>> +CONFIG_MMC_MESON_GX=y
>>> +CONFIG_MTD=y
>>> +CONFIG_DM_MTD=y
>>> +CONFIG_DM_SPI_FLASH=y
>>> +CONFIG_SPI_FLASH_GIGADEVICE=y
>>> +CONFIG_PHY_ADDR_ENABLE=y
>>> +CONFIG_PHY_ADDR=8
>>> +CONFIG_PHY_MESON_GXL=y
>>> +CONFIG_DM_ETH=y
>>> +CONFIG_ETH_DESIGNWARE=y
>>> +CONFIG_PHY=y
>>> +CONFIG_MESON_GXL_USB_PHY=y
>>> +CONFIG_PINCTRL=y
>>> +CONFIG_PINCTRL_MESON_GXL=y
>>> +CONFIG_POWER_DOMAIN=y
>>> +CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
>>> +CONFIG_DM_REGULATOR_FIXED=y
>>> +CONFIG_DM_RESET=y
>>> +CONFIG_DEBUG_UART_ANNOUNCE=y
>>> +CONFIG_DEBUG_UART_SKIP_INIT=y
>>> +CONFIG_MESON_SERIAL=y
>>> +CONFIG_SPI=y
>>> +CONFIG_DM_SPI=y
>>> +CONFIG_MESON_SPIFC=y
>>> +CONFIG_USB=y
>>> +CONFIG_DM_USB=y
>>> +CONFIG_USB_XHCI_HCD=y
>>> +CONFIG_USB_XHCI_DWC3=y
>>> +CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y
>>> +CONFIG_USB_DWC3=y
>>> +# CONFIG_USB_DWC3_GADGET is not set
>>> +CONFIG_USB_KEYBOARD=y
>>> +CONFIG_USB_GADGET=y
>>> +CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
>>> +CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
>>> +CONFIG_USB_GADGET_DWC2_OTG=y
>>> +CONFIG_USB_GADGET_DOWNLOAD=y
>>> +CONFIG_DM_VIDEO=y
>>> +# CONFIG_VIDEO_BPP8 is not set
>>> +# CONFIG_VIDEO_BPP16 is not set
>>> +CONFIG_SYS_WHITE_ON_BLACK=y
>>> +CONFIG_VIDEO_MESON=y
>>> +CONFIG_VIDEO_DT_SIMPLEFB=y
>>> +CONFIG_OF_LIBFDT_OVERLAY=y
>>>
>>
>> And can you also update :
>> doc/board/amlogic/libretech-cc.rst
>> doc/board/amlogic/index.rst
>> and
>> board/amlogic/p212/MAINTAINERS
>>
>> Thanks,
>> Neil
> 



Re: [PATCH 2/2] arm64: meson: add support for libretech-cc v2

2020-11-05 Thread Jerome Brunet


On Thu 05 Nov 2020 at 15:22, Neil Armstrong  wrote:

> Hi,
>
> On 05/11/2020 15:15, Jerome Brunet wrote:
>> Add support for the Amlogic based libretech cc version 2.
>> As version 1, it is based on the s905x SoC.
>> 
>> Signed-off-by: Jerome Brunet 
>> ---
>>  arch/arm/dts/Makefile |  1 +
>>  ...eson-gxl-s905x-libretech-cc-v2-u-boot.dtsi |  7 ++
>>  configs/libretech-cc_v2_defconfig | 82 +++
>>  3 files changed, 90 insertions(+)
>>  create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>>  create mode 100644 configs/libretech-cc_v2_defconfig
>> 
>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>> index b195723f1645..e957820e8e62 100644
>> --- a/arch/arm/dts/Makefile
>> +++ b/arch/arm/dts/Makefile
>> @@ -159,6 +159,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
>>  meson-gxl-s905x-p212.dtb \
>>  meson-gxl-s805x-libretech-ac.dtb \
>>  meson-gxl-s905x-libretech-cc.dtb \
>> +meson-gxl-s905x-libretech-cc-v2.dtb \
>>  meson-gxl-s905x-khadas-vim.dtb \
>>  meson-gxl-s905d-libretech-pc.dtb \
>>  meson-gxm-khadas-vim2.dtb \
>
> This should be part of the previous patch
>

I'm happy to do it but the previous patch is supposed to just be copy of
the linux file, isn't it ?

If it is not the case, can we just fold the whole thing in a single
patch ?

>> diff --git a/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi 
>> b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>> new file mode 100644
>> index ..8ff5a0ef2ba5
>> --- /dev/null
>> +++ b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>> @@ -0,0 +1,7 @@
>> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>> +/*
>> + * Copyright (c) 2020 BayLibre, SAS.
>> + * Author: Jerome Brunet 
>> + */
>> +
>> +#include "meson-gxl-u-boot.dtsi"
>> diff --git a/configs/libretech-cc_v2_defconfig 
>> b/configs/libretech-cc_v2_defconfig
>> new file mode 100644
>> index ..e71f88edaec6
>> --- /dev/null
>> +++ b/configs/libretech-cc_v2_defconfig
>> @@ -0,0 +1,82 @@
>> +CONFIG_ARM=y
>> +CONFIG_ARCH_MESON=y
>> +CONFIG_SYS_TEXT_BASE=0x0100
>> +CONFIG_ENV_SIZE=0x2000
>> +CONFIG_ENV_OFFSET=0x
>> +CONFIG_ENV_SECT_SIZE=0x1
>> +CONFIG_DM_GPIO=y
>> +CONFIG_MESON_GXL=y
>> +CONFIG_NR_DRAM_BANKS=1
>> +CONFIG_DEBUG_UART_BASE=0xc81004c0
>> +CONFIG_DEBUG_UART_CLOCK=2400
>> +CONFIG_IDENT_STRING=" libretech-cc-v2"
>> +CONFIG_DEBUG_UART=y
>> +CONFIG_OF_BOARD_SETUP=y
>> +CONFIG_USE_PREBOOT=y
>> +CONFIG_PREBOOT="usb start"
>> +CONFIG_MISC_INIT_R=y
>> +# CONFIG_DISPLAY_CPUINFO is not set
>> +# CONFIG_DISPLAY_BOARDINFO is not set
>> +# CONFIG_CMD_BDI is not set
>> +# CONFIG_CMD_IMI is not set
>> +CONFIG_CMD_ADC=y
>> +CONFIG_CMD_GPIO=y
>> +# CONFIG_CMD_LOADS is not set
>> +CONFIG_CMD_MMC=y
>> +CONFIG_CMD_SPI=y
>> +CONFIG_CMD_USB=y
>> +CONFIG_CMD_USB_MASS_STORAGE=y
>> +# CONFIG_CMD_SETEXPR is not set
>> +CONFIG_CMD_REGULATOR=y
>> +CONFIG_OF_CONTROL=y
>> +CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc-v2"
>> +CONFIG_ENV_IS_IN_SPI_FLASH=y
>> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>> +CONFIG_NET_RANDOM_ETHADDR=y
>> +CONFIG_SARADC_MESON=y
>> +CONFIG_DM_KEYBOARD=y
>> +CONFIG_DM_MMC=y
>> +CONFIG_MMC_MESON_GX=y
>> +CONFIG_MTD=y
>> +CONFIG_DM_MTD=y
>> +CONFIG_DM_SPI_FLASH=y
>> +CONFIG_SPI_FLASH_GIGADEVICE=y
>> +CONFIG_PHY_ADDR_ENABLE=y
>> +CONFIG_PHY_ADDR=8
>> +CONFIG_PHY_MESON_GXL=y
>> +CONFIG_DM_ETH=y
>> +CONFIG_ETH_DESIGNWARE=y
>> +CONFIG_PHY=y
>> +CONFIG_MESON_GXL_USB_PHY=y
>> +CONFIG_PINCTRL=y
>> +CONFIG_PINCTRL_MESON_GXL=y
>> +CONFIG_POWER_DOMAIN=y
>> +CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
>> +CONFIG_DM_REGULATOR_FIXED=y
>> +CONFIG_DM_RESET=y
>> +CONFIG_DEBUG_UART_ANNOUNCE=y
>> +CONFIG_DEBUG_UART_SKIP_INIT=y
>> +CONFIG_MESON_SERIAL=y
>> +CONFIG_SPI=y
>> +CONFIG_DM_SPI=y
>> +CONFIG_MESON_SPIFC=y
>> +CONFIG_USB=y
>> +CONFIG_DM_USB=y
>> +CONFIG_USB_XHCI_HCD=y
>> +CONFIG_USB_XHCI_DWC3=y
>> +CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y
>> +CONFIG_USB_DWC3=y
>> +# CONFIG_USB_DWC3_GADGET is not set
>> +CONFIG_USB_KEYBOARD=y
>> +CONFIG_USB_GADGET=y
>> +CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
>> +CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
>> +CONFIG_USB_GADGET_DWC2_OTG=y
>> +CONFIG_USB_GADGET_DOWNLOAD=y
>> +CONFIG_DM_VIDEO=y
>> +# CONFIG_VIDEO_BPP8 is not set
>> +# CONFIG_VIDEO_BPP16 is not set
>> +CONFIG_SYS_WHITE_ON_BLACK=y
>> +CONFIG_VIDEO_MESON=y
>> +CONFIG_VIDEO_DT_SIMPLEFB=y
>> +CONFIG_OF_LIBFDT_OVERLAY=y
>> 
>
> And can you also update :
> doc/board/amlogic/libretech-cc.rst
> doc/board/amlogic/index.rst
> and
> board/amlogic/p212/MAINTAINERS
>
> Thanks,
> Neil



Re: [PATCH 2/2] arm64: meson: add support for libretech-cc v2

2020-11-05 Thread Neil Armstrong
Hi,

On 05/11/2020 15:15, Jerome Brunet wrote:
> Add support for the Amlogic based libretech cc version 2.
> As version 1, it is based on the s905x SoC.
> 
> Signed-off-by: Jerome Brunet 
> ---
>  arch/arm/dts/Makefile |  1 +
>  ...eson-gxl-s905x-libretech-cc-v2-u-boot.dtsi |  7 ++
>  configs/libretech-cc_v2_defconfig | 82 +++
>  3 files changed, 90 insertions(+)
>  create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
>  create mode 100644 configs/libretech-cc_v2_defconfig
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index b195723f1645..e957820e8e62 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -159,6 +159,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
>   meson-gxl-s905x-p212.dtb \
>   meson-gxl-s805x-libretech-ac.dtb \
>   meson-gxl-s905x-libretech-cc.dtb \
> + meson-gxl-s905x-libretech-cc-v2.dtb \
>   meson-gxl-s905x-khadas-vim.dtb \
>   meson-gxl-s905d-libretech-pc.dtb \
>   meson-gxm-khadas-vim2.dtb \

This should be part of the previous patch

> diff --git a/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi 
> b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
> new file mode 100644
> index ..8ff5a0ef2ba5
> --- /dev/null
> +++ b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
> @@ -0,0 +1,7 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (c) 2020 BayLibre, SAS.
> + * Author: Jerome Brunet 
> + */
> +
> +#include "meson-gxl-u-boot.dtsi"
> diff --git a/configs/libretech-cc_v2_defconfig 
> b/configs/libretech-cc_v2_defconfig
> new file mode 100644
> index ..e71f88edaec6
> --- /dev/null
> +++ b/configs/libretech-cc_v2_defconfig
> @@ -0,0 +1,82 @@
> +CONFIG_ARM=y
> +CONFIG_ARCH_MESON=y
> +CONFIG_SYS_TEXT_BASE=0x0100
> +CONFIG_ENV_SIZE=0x2000
> +CONFIG_ENV_OFFSET=0x
> +CONFIG_ENV_SECT_SIZE=0x1
> +CONFIG_DM_GPIO=y
> +CONFIG_MESON_GXL=y
> +CONFIG_NR_DRAM_BANKS=1
> +CONFIG_DEBUG_UART_BASE=0xc81004c0
> +CONFIG_DEBUG_UART_CLOCK=2400
> +CONFIG_IDENT_STRING=" libretech-cc-v2"
> +CONFIG_DEBUG_UART=y
> +CONFIG_OF_BOARD_SETUP=y
> +CONFIG_USE_PREBOOT=y
> +CONFIG_PREBOOT="usb start"
> +CONFIG_MISC_INIT_R=y
> +# CONFIG_DISPLAY_CPUINFO is not set
> +# CONFIG_DISPLAY_BOARDINFO is not set
> +# CONFIG_CMD_BDI is not set
> +# CONFIG_CMD_IMI is not set
> +CONFIG_CMD_ADC=y
> +CONFIG_CMD_GPIO=y
> +# CONFIG_CMD_LOADS is not set
> +CONFIG_CMD_MMC=y
> +CONFIG_CMD_SPI=y
> +CONFIG_CMD_USB=y
> +CONFIG_CMD_USB_MASS_STORAGE=y
> +# CONFIG_CMD_SETEXPR is not set
> +CONFIG_CMD_REGULATOR=y
> +CONFIG_OF_CONTROL=y
> +CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc-v2"
> +CONFIG_ENV_IS_IN_SPI_FLASH=y
> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_SARADC_MESON=y
> +CONFIG_DM_KEYBOARD=y
> +CONFIG_DM_MMC=y
> +CONFIG_MMC_MESON_GX=y
> +CONFIG_MTD=y
> +CONFIG_DM_MTD=y
> +CONFIG_DM_SPI_FLASH=y
> +CONFIG_SPI_FLASH_GIGADEVICE=y
> +CONFIG_PHY_ADDR_ENABLE=y
> +CONFIG_PHY_ADDR=8
> +CONFIG_PHY_MESON_GXL=y
> +CONFIG_DM_ETH=y
> +CONFIG_ETH_DESIGNWARE=y
> +CONFIG_PHY=y
> +CONFIG_MESON_GXL_USB_PHY=y
> +CONFIG_PINCTRL=y
> +CONFIG_PINCTRL_MESON_GXL=y
> +CONFIG_POWER_DOMAIN=y
> +CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
> +CONFIG_DM_REGULATOR_FIXED=y
> +CONFIG_DM_RESET=y
> +CONFIG_DEBUG_UART_ANNOUNCE=y
> +CONFIG_DEBUG_UART_SKIP_INIT=y
> +CONFIG_MESON_SERIAL=y
> +CONFIG_SPI=y
> +CONFIG_DM_SPI=y
> +CONFIG_MESON_SPIFC=y
> +CONFIG_USB=y
> +CONFIG_DM_USB=y
> +CONFIG_USB_XHCI_HCD=y
> +CONFIG_USB_XHCI_DWC3=y
> +CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y
> +CONFIG_USB_DWC3=y
> +# CONFIG_USB_DWC3_GADGET is not set
> +CONFIG_USB_KEYBOARD=y
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
> +CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
> +CONFIG_USB_GADGET_DWC2_OTG=y
> +CONFIG_USB_GADGET_DOWNLOAD=y
> +CONFIG_DM_VIDEO=y
> +# CONFIG_VIDEO_BPP8 is not set
> +# CONFIG_VIDEO_BPP16 is not set
> +CONFIG_SYS_WHITE_ON_BLACK=y
> +CONFIG_VIDEO_MESON=y
> +CONFIG_VIDEO_DT_SIMPLEFB=y
> +CONFIG_OF_LIBFDT_OVERLAY=y
> 

And can you also update :
doc/board/amlogic/libretech-cc.rst
doc/board/amlogic/index.rst
and
board/amlogic/p212/MAINTAINERS

Thanks,
Neil


[PATCH 2/2] arm64: meson: add support for libretech-cc v2

2020-11-05 Thread Jerome Brunet
Add support for the Amlogic based libretech cc version 2.
As version 1, it is based on the s905x SoC.

Signed-off-by: Jerome Brunet 
---
 arch/arm/dts/Makefile |  1 +
 ...eson-gxl-s905x-libretech-cc-v2-u-boot.dtsi |  7 ++
 configs/libretech-cc_v2_defconfig | 82 +++
 3 files changed, 90 insertions(+)
 create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
 create mode 100644 configs/libretech-cc_v2_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b195723f1645..e957820e8e62 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -159,6 +159,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-gxl-s905x-p212.dtb \
meson-gxl-s805x-libretech-ac.dtb \
meson-gxl-s905x-libretech-cc.dtb \
+   meson-gxl-s905x-libretech-cc-v2.dtb \
meson-gxl-s905x-khadas-vim.dtb \
meson-gxl-s905d-libretech-pc.dtb \
meson-gxm-khadas-vim2.dtb \
diff --git a/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi 
b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
new file mode 100644
index ..8ff5a0ef2ba5
--- /dev/null
+++ b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2020 BayLibre, SAS.
+ * Author: Jerome Brunet 
+ */
+
+#include "meson-gxl-u-boot.dtsi"
diff --git a/configs/libretech-cc_v2_defconfig 
b/configs/libretech-cc_v2_defconfig
new file mode 100644
index ..e71f88edaec6
--- /dev/null
+++ b/configs/libretech-cc_v2_defconfig
@@ -0,0 +1,82 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_SYS_TEXT_BASE=0x0100
+CONFIG_ENV_SIZE=0x2000
+CONFIG_ENV_OFFSET=0x
+CONFIG_ENV_SECT_SIZE=0x1
+CONFIG_DM_GPIO=y
+CONFIG_MESON_GXL=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEBUG_UART_BASE=0xc81004c0
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" libretech-cc-v2"
+CONFIG_DEBUG_UART=y
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="usb start"
+CONFIG_MISC_INIT_R=y
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_ADC=y
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc-v2"
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SARADC_MESON=y
+CONFIG_DM_KEYBOARD=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_PHY_ADDR_ENABLE=y
+CONFIG_PHY_ADDR=8
+CONFIG_PHY_MESON_GXL=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_PHY=y
+CONFIG_MESON_GXL_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_GXL=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_MESON_SPIFC=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y
+CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
+CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_DM_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_OF_LIBFDT_OVERLAY=y
-- 
2.28.0



[PATCH 1/2] arm64: dts: import libretech-cc-v2 from linux v5.10-rc1

2020-11-05 Thread Jerome Brunet
Sync the libretech cc v2 device tree from Linux v5.10-rc1
commit 3650b228f83a ("Linux 5.10-rc1")

Signed-off-by: Jerome Brunet 
---
 .../dts/meson-gxl-s905x-libretech-cc-v2.dts   | 318 ++
 1 file changed, 318 insertions(+)
 create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts

diff --git a/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts 
b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts
new file mode 100644
index ..675eaa87963e
--- /dev/null
+++ b/arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts
@@ -0,0 +1,318 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2020 BayLibre, SAS.
+ * Author: Jerome Brunet 
+ */
+
+/dts-v1/;
+
+#include 
+#include 
+#include 
+
+#include "meson-gxl-s905x.dtsi"
+
+/ {
+   compatible = "libretech,aml-s905x-cc-v2", "amlogic,s905x",
+"amlogic,meson-gxl";
+   model = "Libre Computer AML-S905X-CC V2";
+
+   aliases {
+   serial0 = _AO;
+   ethernet0 = 
+   spi0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   emmc_pwrseq: emmc-pwrseq {
+   compatible = "mmc-pwrseq-emmc";
+   reset-gpios = < BOOT_9 GPIO_ACTIVE_LOW>;
+   };
+
+   hdmi-connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint {
+   remote-endpoint = <_tx_tmds_out>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led-blue {
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = < GPIODV_24 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   panic-indicator;
+   };
+
+   led-green {
+   color = ;
+   function = LED_FUNCTION_DISK_ACTIVITY;
+   gpios = <_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "disk-activity";
+   };
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   ao_5v: regulator-ao_5v {
+   compatible = "regulator-fixed";
+   regulator-name = "AO_5V";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_in>;
+   regulator-always-on;
+   };
+
+   dc_in: regulator-dc_in {
+   compatible = "regulator-fixed";
+   regulator-name = "DC_IN";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   };
+
+
+   vcck: regulator-vcck {
+   compatible = "regulator-fixed";
+   regulator-name = "VCCK";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_5v>;
+   regulator-always-on;
+   };
+
+   vcc_card: regulator-vcc_card {
+   compatible = "regulator-fixed";
+   regulator-name = "VCC_CARD";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_ao3v3>;
+
+   gpio = < GPIOCLK_1 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   };
+
+   vcc5v: regulator-vcc5v {
+   compatible = "regulator-fixed";
+   regulator-name = "VCC5V";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_5v>;
+
+   gpio = < GPIOH_3 GPIO_OPEN_DRAIN>;
+   };
+
+   vddio_ao3v3: regulator-vddio_ao3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "VDDIO_AO3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_5v>;
+   regulator-always-on;
+   };
+
+
+   vddio_card: regulator-vddio-card {
+   compatible = "regulator-gpio";
+   regulator-name = "VDDIO_CARD";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+
+   gpios = <_ao GPIOAO_3 GPIO_ACTIVE_HIGH>;
+   gpios-states = <0>;
+
+   states = <330 0>,
+<180 1>;
+
+   regulator-settling-time-up-us = <200>;
+   regulator-settling-time-down-us = <5>;
+   };
+
+   vddio_ao18: regulator-vddio_ao18 {
+   compatible = "regulator-fixed";
+   regulator-name = "VDDIO_AO18";
+  

[PATCH 0/2] arm64: meson: add libretech cc v2 support

2020-11-05 Thread Jerome Brunet
This patchset adds support for the Amlogic based libretech cc v2.
Like the v1, this revised platform used the s905x SoC.

Jerome Brunet (2):
  arm64: dts: import libretech-cc-v2 from linux v5.10-rc1
  arm64: meson: add support for libretech-cc v2

 arch/arm/dts/Makefile |   1 +
 ...eson-gxl-s905x-libretech-cc-v2-u-boot.dtsi |   7 +
 .../dts/meson-gxl-s905x-libretech-cc-v2.dts   | 318 ++
 configs/libretech-cc_v2_defconfig |  82 +
 4 files changed, 408 insertions(+)
 create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2-u-boot.dtsi
 create mode 100644 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts
 create mode 100644 configs/libretech-cc_v2_defconfig

-- 
2.28.0



[PATCH v6 10/14] odroid-c2: Use devicetree for SMBIOS settings

2020-11-05 Thread Simon Glass
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi | 23 
 configs/odroid-c2_defconfig  |  4 ++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi 
b/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi
index 484b40504dc..90087b00dba 100644
--- a/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi
+++ b/arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi
@@ -6,6 +6,29 @@
 
 #include "meson-gx-u-boot.dtsi"
 
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "Hardkernel Co., Ltd.";
+   product = "ODROID-C2";
+   };
+
+   baseboard {
+   manufacturer = "Hardkernel Co., Ltd.";
+   product = "ODROID-C2";
+   };
+
+   chassis {
+   manufacturer = "Hardkernel Co., Ltd.";
+   product = "ODROID-C2";
+   };
+   };
+   };
+};
+
  {
status = "disabled";
 };
diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig
index 5fdce3b4638..f2c9fa72778 100644
--- a/configs/odroid-c2_defconfig
+++ b/configs/odroid-c2_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEBUG_UART_BASE=0xc81004c0
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_IDENT_STRING=" odroid-c2"
 CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-odroidc2"
-CONFIG_SMBIOS_PRODUCT_NAME="ODROID-C2"
 CONFIG_DEBUG_UART=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -64,4 +63,5 @@ CONFIG_BMP_16BPP=y
 CONFIG_BMP_24BPP=y
 CONFIG_BMP_32BPP=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SMBIOS_MANUFACTURER="Hardkernel Co., Ltd."
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
-- 
2.29.1.341.ge80a0c044ae-goog



Re: [PATCH v3 00/30] x86: Allow Coral to boot into Chrome OS

2020-11-05 Thread Simon Glass
Hi Bin,

On Thu, 5 Nov 2020 at 01:43, Bin Meng  wrote:
>
> Hi Simon,
>
> On Thu, Nov 5, 2020 at 2:56 PM Bin Meng  wrote:
> >
> > On Thu, Nov 5, 2020 at 12:57 AM Simon Glass  wrote:
> > >
> > > This series adds various minor features and tweaks to allow Coral to boot
> > > into Chrome OS from U-Boot.
> > >
> > > It relies on three other series which have been recently sent:
> > >
> > >- smbios (u-boot-dm/smbios-working)
> > >- bootm (u-boot-dm/bootm-working)
> > >- misca (u-boot-dm/misca-working)
> > >
> > > This should provide a solid base for using ACPI on other Intel Apollo Lake
> > > (APL) devices.
> > >
> > > Changes in v3:
> > > - Add a macro to read gd->acpi_ctx to allow use of IS_ENABLED()
>
> Unfortunately this series breaks qemu-x86_64 build, see:
> https://dev.azure.com/bmeng/GitHub/_build/results?buildId=298=results
>
> Could you please send a fix and indicate which commit in u-boot-x86
> should be fixed/squashed, etc?

Oh dear. Yes I sent a fix. I think I was looking at an earlier build
so did not notice the problem on gitlab.

>
> > > - Move the bloblist types into this patch
> > > - Avoid build error when gd->acpi_ctx is not available
> > > - Correct printf specifier for debug lines
> > >
> >
> > series applied to u-boot-x86, thanks!

Regards,
Simon


[PATCH v6 14/14] smbios: Drop the unused Kconfig options

2020-11-05 Thread Simon Glass
Now that we can use devicetree to specify this information, drop the old
CONFIG options.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Rename smbios_add_prop_default() to smbios_add_prop()

Changes in v3:
- Add onto the sysinfo binding

 configs/clearfog_gt_8k_defconfig|  2 --
 configs/mt7622_rfb_defconfig|  1 -
 configs/mvebu_db_armada8k_defconfig |  2 --
 configs/r8a774a1_beacon_defconfig   |  2 --
 configs/r8a77970_eagle_defconfig|  2 --
 configs/r8a77980_condor_defconfig   |  2 --
 configs/r8a77990_ebisu_defconfig|  2 --
 configs/r8a77995_draak_defconfig|  2 --
 configs/rcar3_salvator-x_defconfig  |  2 --
 configs/rcar3_ulcb_defconfig|  2 --
 lib/Kconfig | 16 --
 lib/smbios.c| 46 -
 12 files changed, 13 insertions(+), 68 deletions(-)

diff --git a/configs/clearfog_gt_8k_defconfig b/configs/clearfog_gt_8k_defconfig
index 552df3a8b80..9bb1f212a70 100644
--- a/configs/clearfog_gt_8k_defconfig
+++ b/configs/clearfog_gt_8k_defconfig
@@ -12,7 +12,6 @@ CONFIG_DM_GPIO=y
 CONFIG_DEBUG_UART_BASE=0xf0512000
 CONFIG_DEBUG_UART_CLOCK=2
 CONFIG_DEFAULT_DEVICE_TREE="armada-8040-clearfog-gt-8k"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
@@ -78,4 +77,3 @@ CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_MCS7830=y
 CONFIG_USB_ETHER_RTL8152=y
 CONFIG_USB_ETHER_SMSC95XX=y
-CONFIG_SMBIOS_MANUFACTURER=""
diff --git a/configs/mt7622_rfb_defconfig b/configs/mt7622_rfb_defconfig
index a6089d6cf6a..ccf926e1040 100644
--- a/configs/mt7622_rfb_defconfig
+++ b/configs/mt7622_rfb_defconfig
@@ -5,7 +5,6 @@ CONFIG_SYS_TEXT_BASE=0x41e0
 CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_DEFAULT_DEVICE_TREE="mt7622-rfb"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_FIT=y
 CONFIG_DEFAULT_FDT_FILE="mt7622-rfb"
 CONFIG_LOGLEVEL=7
diff --git a/configs/mvebu_db_armada8k_defconfig 
b/configs/mvebu_db_armada8k_defconfig
index a88d5cc98bd..5d8a1b655cd 100644
--- a/configs/mvebu_db_armada8k_defconfig
+++ b/configs/mvebu_db_armada8k_defconfig
@@ -11,7 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x1
 CONFIG_DEBUG_UART_BASE=0xf0512000
 CONFIG_DEBUG_UART_CLOCK=2
 CONFIG_DEFAULT_DEVICE_TREE="armada-8040-db"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
@@ -72,4 +71,3 @@ CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_ETHER_MCS7830=y
 CONFIG_USB_ETHER_RTL8152=y
 CONFIG_USB_ETHER_SMSC95XX=y
-CONFIG_SMBIOS_MANUFACTURER=""
diff --git a/configs/r8a774a1_beacon_defconfig 
b/configs/r8a774a1_beacon_defconfig
index 5d564d82c2f..2f45edd92ec 100644
--- a/configs/r8a774a1_beacon_defconfig
+++ b/configs/r8a774a1_beacon_defconfig
@@ -8,7 +8,6 @@ CONFIG_RCAR_GEN3=y
 CONFIG_TARGET_BEACON_RZG2M=y
 # CONFIG_SPL is not set
 CONFIG_DEFAULT_DEVICE_TREE="r8a774a1-beacon-rzg2m-kit"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_FIT=y
 CONFIG_SUPPORT_RAW_INITRD=y
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
@@ -64,4 +63,3 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SMBIOS_MANUFACTURER=""
diff --git a/configs/r8a77970_eagle_defconfig b/configs/r8a77970_eagle_defconfig
index a7774842353..9dbe0e1d5b4 100644
--- a/configs/r8a77970_eagle_defconfig
+++ b/configs/r8a77970_eagle_defconfig
@@ -11,7 +11,6 @@ CONFIG_SPL_TEXT_BASE=0xe6318000
 CONFIG_RCAR_GEN3=y
 CONFIG_TARGET_EAGLE=y
 CONFIG_DEFAULT_DEVICE_TREE="r8a77970-eagle-u-boot"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_FIT=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_USE_BOOTARGS=y
@@ -74,4 +73,3 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SMBIOS_MANUFACTURER=""
diff --git a/configs/r8a77980_condor_defconfig 
b/configs/r8a77980_condor_defconfig
index 4e457234ed0..dbe2912779c 100644
--- a/configs/r8a77980_condor_defconfig
+++ b/configs/r8a77980_condor_defconfig
@@ -11,7 +11,6 @@ CONFIG_SPL_TEXT_BASE=0xe6318000
 CONFIG_RCAR_GEN3=y
 CONFIG_TARGET_CONDOR=y
 CONFIG_DEFAULT_DEVICE_TREE="r8a77980-condor-u-boot"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_FIT=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_USE_BOOTARGS=y
@@ -75,4 +74,3 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SMBIOS_MANUFACTURER=""
diff --git a/configs/r8a77990_ebisu_defconfig b/configs/r8a77990_ebisu_defconfig
index 4667284bb37..cb75b5c3a60 100644
--- a/configs/r8a77990_ebisu_defconfig
+++ b/configs/r8a77990_ebisu_defconfig
@@ -10,7 +10,6 @@ CONFIG_SPL_TEXT_BASE=0xe6318000
 CONFIG_RCAR_GEN3=y
 CONFIG_TARGET_EBISU=y
 CONFIG_DEFAULT_DEVICE_TREE="r8a77990-ebisu-u-boot"
-CONFIG_SMBIOS_PRODUCT_NAME=""
 CONFIG_FIT=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_USE_BOOTARGS=y
@@ -84,4 +83,3 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SMBIOS_MANUFACTURER=""
diff --git a/configs/r8a77995_draak_defconfig 

[PATCH v6 13/14] x86: Provide default SMBIOS manufacturer/product

2020-11-05 Thread Simon Glass
Add a file containing defaults for these, using the existing CONFIG
options. This file must be included with #include since it needs to
are not passed through the C preprocessor.

Enable the driver for all x86 boards that generate SMBIOS tables. Disable
it for coral since it has its own driver.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Add new patch to provide default SMBIOS manufacturer/product

 arch/Kconfig  |  2 ++
 arch/x86/dts/bayleybay.dts|  2 ++
 arch/x86/dts/baytrail_som-db5800-som-6867.dts |  2 ++
 arch/x86/dts/cherryhill.dts   |  2 ++
 arch/x86/dts/chromebook_link.dts  |  2 ++
 arch/x86/dts/chromebook_samus.dts |  2 ++
 arch/x86/dts/chromebox_panther.dts|  2 ++
 arch/x86/dts/conga-qeval20-qa3-e3845.dts  |  2 ++
 arch/x86/dts/cougarcanyon2.dts|  2 ++
 arch/x86/dts/crownbay.dts |  2 ++
 arch/x86/dts/dfi-bt700.dtsi   |  2 ++
 arch/x86/dts/edison.dts   |  2 ++
 arch/x86/dts/minnowmax.dts|  2 ++
 arch/x86/dts/qemu-x86_i440fx.dts  |  2 ++
 arch/x86/dts/qemu-x86_q35.dts |  2 ++
 arch/x86/dts/smbios.dtsi  | 32 +++
 configs/chromebook_coral_defconfig|  2 +-
 17 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/dts/smbios.dtsi

diff --git a/arch/Kconfig b/arch/Kconfig
index 3b9fcce980a..041e179256a 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -198,6 +198,8 @@ config X86
imply RTC_MC146818
imply IRQ
imply ACPIGEN if !QEMU
+   imply SYSINFO if GENERATE_SMBIOS_TABLE
+   imply SYSINFO_SMBIOS if GENERATE_SMBIOS_TABLE
 
# Thing to enable for when SPL/TPL are enabled: SPL
imply SPL_DM
diff --git a/arch/x86/dts/bayleybay.dts b/arch/x86/dts/bayleybay.dts
index d0168e88dbd..70e57984031 100644
--- a/arch/x86/dts/bayleybay.dts
+++ b/arch/x86/dts/bayleybay.dts
@@ -16,6 +16,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
model = "Intel Bayley Bay";
compatible = "intel,bayleybay", "intel,baytrail";
diff --git a/arch/x86/dts/baytrail_som-db5800-som-6867.dts 
b/arch/x86/dts/baytrail_som-db5800-som-6867.dts
index 5abbc66ce98..a7dc03b6458 100644
--- a/arch/x86/dts/baytrail_som-db5800-som-6867.dts
+++ b/arch/x86/dts/baytrail_som-db5800-som-6867.dts
@@ -16,6 +16,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
model = "Advantech SOM-DB5800-SOM-6867";
compatible = "advantech,som-db5800-som-6867", "intel,baytrail";
diff --git a/arch/x86/dts/cherryhill.dts b/arch/x86/dts/cherryhill.dts
index 37146fde2ba..2ce7f1aa91a 100644
--- a/arch/x86/dts/cherryhill.dts
+++ b/arch/x86/dts/cherryhill.dts
@@ -14,6 +14,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
model = "Intel Cherry Hill";
compatible = "intel,cherryhill", "intel,braswell";
diff --git a/arch/x86/dts/chromebook_link.dts b/arch/x86/dts/chromebook_link.dts
index 09488f13b58..e529c4b63e0 100644
--- a/arch/x86/dts/chromebook_link.dts
+++ b/arch/x86/dts/chromebook_link.dts
@@ -11,6 +11,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
model = "Google Link";
compatible = "google,link", "intel,celeron-ivybridge";
diff --git a/arch/x86/dts/chromebook_samus.dts 
b/arch/x86/dts/chromebook_samus.dts
index d8e04a66985..adaeb1ea355 100644
--- a/arch/x86/dts/chromebook_samus.dts
+++ b/arch/x86/dts/chromebook_samus.dts
@@ -9,6 +9,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 #ifdef CONFIG_CHROMEOS_VBOOT
 #include "chromeos-x86.dtsi"
 #include "flashmap-x86-ro.dtsi"
diff --git a/arch/x86/dts/chromebox_panther.dts 
b/arch/x86/dts/chromebox_panther.dts
index bcd4c4d9c1b..77b6ac9ab96 100644
--- a/arch/x86/dts/chromebox_panther.dts
+++ b/arch/x86/dts/chromebox_panther.dts
@@ -6,6 +6,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
model = "Google Panther";
compatible = "google,panther", "intel,haswell";
diff --git a/arch/x86/dts/conga-qeval20-qa3-e3845.dts 
b/arch/x86/dts/conga-qeval20-qa3-e3845.dts
index 70b8c045193..bbea99da2c9 100644
--- a/arch/x86/dts/conga-qeval20-qa3-e3845.dts
+++ b/arch/x86/dts/conga-qeval20-qa3-e3845.dts
@@ -16,6 +16,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
model = "congatec-QEVAL20-QA3-E3845";
compatible = "congatec,qeval20-qa3-e3845", "intel,baytrail";
diff --git a/arch/x86/dts/cougarcanyon2.dts b/arch/x86/dts/cougarcanyon2.dts
index c6ba811e059..60252e3 100644
--- a/arch/x86/dts/cougarcanyon2.dts
+++ b/arch/x86/dts/cougarcanyon2.dts
@@ -14,6 +14,8 @@
 /include/ "rtc.dtsi"
 /include/ "tsc_timer.dtsi"
 
+#include "smbios.dtsi"
+
 / {
   

[PATCH v6 01/14] board: Rename uclass to sysinfo

2020-11-05 Thread Simon Glass
This uclass is intended to provide a way to obtain information about a
U-Boot board. But the concept of a U-Boot 'board' is the whole system,
not just one circuit board, meaning that 'board' is something of a
misnomer for this uclass.

In addition, the name 'board' is a bit overused in U-Boot and we want to
use the same uclass to provide SMBIOS information.

The obvious name is 'system' but that is so vague as to be meaningless.
Use 'sysinfo' instead, since this uclass is aimed at providing information
on the system.

Rename everything accordingly.

Note: Due to the patch delta caused by the symbol renames, this patch
shows some renamed files as being deleted in one place and created in
another.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v5)

Changes in v5:
- Fix "sysinfo_gazerbeam" compatible string to use a hyphen
- Add a note as to why the patch does not just rename some files

 arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi   |  2 +-
 arch/sandbox/dts/test.dts |  8 +-
 board/gdsys/common/cmd_ioloop.c   | 12 +--
 board/gdsys/mpc8308/gazerbeam.c   | 47 ++-
 board/google/chromebook_coral/coral.c |  2 +-
 common/spl/spl_fit.c  | 15 ++--
 configs/chromebook_coral_defconfig|  2 +-
 configs/gazerbeam_defconfig   |  4 +-
 configs/sandbox64_defconfig   |  4 +-
 configs/sandbox_defconfig |  4 +-
 configs/sandbox_flattree_defconfig|  4 +-
 configs/sandbox_spl_defconfig |  4 +-
 .../gdsys,sysinfo_gazerbeam.txt}  |  8 +-
 drivers/Kconfig   |  4 +-
 drivers/Makefile  |  2 +-
 drivers/board/board-uclass.c  | 71 
 drivers/{board => sysinfo}/Kconfig| 16 ++--
 drivers/{board => sysinfo}/Makefile   |  6 +-
 drivers/{board => sysinfo}/gazerbeam.c| 74 -
 drivers/{board => sysinfo}/gazerbeam.h|  0
 drivers/{board => sysinfo}/sandbox.c  | 50 ++--
 drivers/{board => sysinfo}/sandbox.h  |  0
 drivers/sysinfo/sysinfo-uclass.c  | 71 
 drivers/timer/mpc83xx_timer.c | 10 +--
 include/dm/uclass-id.h|  2 +-
 include/{board.h => sysinfo.h}| 80 +--
 test/dm/Makefile  |  2 +-
 test/dm/board.c   | 59 --
 test/dm/sysinfo.c | 59 ++
 29 files changed, 314 insertions(+), 308 deletions(-)
 rename doc/device-tree-bindings/{board/gdsys,board_gazerbeam.txt => 
sysinfo/gdsys,sysinfo_gazerbeam.txt} (90%)
 delete mode 100644 drivers/board/board-uclass.c
 rename drivers/{board => sysinfo}/Kconfig (65%)
 rename drivers/{board => sysinfo}/Makefile (50%)
 rename drivers/{board => sysinfo}/gazerbeam.c (69%)
 rename drivers/{board => sysinfo}/gazerbeam.h (100%)
 rename drivers/{board => sysinfo}/sandbox.c (50%)
 rename drivers/{board => sysinfo}/sandbox.h (100%)
 create mode 100644 drivers/sysinfo/sysinfo-uclass.c
 rename include/{board.h => sysinfo.h} (65%)
 delete mode 100644 test/dm/board.c
 create mode 100644 test/dm/sysinfo.c

diff --git a/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi 
b/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
index 1c4977f20f3..3439737fa3f 100644
--- a/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
+++ b/arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi
@@ -32,7 +32,7 @@
};
 
board {
-   compatible = "gdsys,board_gazerbeam";
+   compatible = "gdsys,sysinfo-gazerbeam";
csb = <_soc>;
serdes = <>;
rxaui0 = <_0>;
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 70ccb4951ad..f3b766271d3 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -1103,10 +1103,6 @@
compatible = "sandbox,sandbox_osd";
};
 
-   board {
-   compatible = "sandbox,board_sandbox";
-   };
-
sandbox_tee {
compatible = "sandbox,tee";
};
@@ -1242,6 +1238,10 @@
reset-names = "valid", "no_mask", "out_of_range";
};
 
+   sysinfo {
+   compatible = "sandbox,sysinfo-sandbox";
+   };
+
some_regmapped-bus {
#address-cells = <0x1>;
#size-cells = <0x1>;
diff --git a/board/gdsys/common/cmd_ioloop.c b/board/gdsys/common/cmd_ioloop.c
index 3ea2bec8ebd..658756d9842 100644
--- a/board/gdsys/common/cmd_ioloop.c
+++ b/board/gdsys/common/cmd_ioloop.c
@@ -16,7 +16,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "../../../drivers/misc/gdsys_soc.h"
 #include "../../../drivers/misc/gdsys_ioep.h"
@@ -506,11 +506,11 @@ int do_ioloop(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 int 

[PATCH v6 11/14] arm64: mvebu: Use devicetree for SMBIOS settings on uDPU

2020-11-05 Thread Simon Glass
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 arch/arm/dts/armada-3720-uDPU-u-boot.dtsi | 20 
 configs/uDPU_defconfig|  3 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/armada-3720-uDPU-u-boot.dtsi 
b/arch/arm/dts/armada-3720-uDPU-u-boot.dtsi
index ef178bdc86e..fdad90ad123 100644
--- a/arch/arm/dts/armada-3720-uDPU-u-boot.dtsi
+++ b/arch/arm/dts/armada-3720-uDPU-u-boot.dtsi
@@ -1,5 +1,25 @@
 // SPDX-License-Identifier: GPL-2.0+
 
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   product = "uDPU";
+   };
+
+   baseboard {
+   product = "uDPU";
+   };
+
+   chassis {
+   product = "uDPU";
+   };
+   };
+   };
+};
+
  {
u-boot,dm-pre-reloc;
 
diff --git a/configs/uDPU_defconfig b/configs/uDPU_defconfig
index dfab2b306bb..ec97489523d 100644
--- a/configs/uDPU_defconfig
+++ b/configs/uDPU_defconfig
@@ -11,7 +11,6 @@ CONFIG_DM_GPIO=y
 CONFIG_DEBUG_UART_BASE=0xd0012000
 CONFIG_DEBUG_UART_CLOCK=25804800
 CONFIG_DEFAULT_DEVICE_TREE="armada-3720-uDPU"
-CONFIG_SMBIOS_PRODUCT_NAME="uDPU"
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
@@ -97,3 +96,5 @@ CONFIG_USB_ETHER_RTL8152=y
 CONFIG_USB_ETHER_SMSC95XX=y
 CONFIG_LZO=y
 CONFIG_SPL_LZO=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 09/14] imx: Use devicetree for SMBIOS settings on MYiR MYS-6ULX

2020-11-05 Thread Simon Glass
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 .../dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts | 25 +++
 configs/myir_mys_6ulx_defconfig   |  3 ++-
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts

diff --git a/arch/arm/dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts 
b/arch/arm/dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts
new file mode 100644
index 000..378e4fa58dc
--- /dev/null
+++ b/arch/arm/dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Linumiz
+ * Author: Parthiban Nallathambi 
+ */
+
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "MYiR";
+   };
+
+   baseboard {
+   manufacturer = "MYiR";
+   };
+
+   chassis {
+   manufacturer = "MYiR";
+   };
+   };
+   };
+};
diff --git a/configs/myir_mys_6ulx_defconfig b/configs/myir_mys_6ulx_defconfig
index 02b2060874a..4ba817ab1e9 100644
--- a/configs/myir_mys_6ulx_defconfig
+++ b/configs/myir_mys_6ulx_defconfig
@@ -67,4 +67,5 @@ CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_GADGET=y
-CONFIG_SMBIOS_MANUFACTURER="MYiR"
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 08/14] rockchip: Use devicetree for SMBIOS settings

2020-11-05 Thread Simon Glass
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 arch/arm/dts/rk3328-roc-cc-u-boot.dtsi| 21 +
 arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi | 23 +++
 arch/arm/dts/rk3328-rock64-u-boot.dtsi| 21 +
 arch/arm/dts/rk3368-lion-u-boot.dtsi  | 20 
 configs/lion-rk3368_defconfig |  4 ++--
 configs/roc-cc-rk3328_defconfig   |  4 ++--
 configs/rock-pi-e-rk3328_defconfig|  4 ++--
 configs/rock64-rk3328_defconfig   |  4 ++--
 8 files changed, 93 insertions(+), 8 deletions(-)

diff --git a/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi 
b/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
index e929d86e306..08806dfc0f9 100644
--- a/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
@@ -9,6 +9,27 @@
chosen {
u-boot,spl-boot-order = "same-as-spl", , 
};
+
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "firefly";
+   product = "roc-rk3328-cc";
+   };
+
+   baseboard {
+   manufacturer = "firefly";
+   product = "roc-rk3328-cc";
+   };
+
+   chassis {
+   manufacturer = "firefly";
+   product = "roc-rk3328-cc";
+   };
+   };
+   };
 };
 
  {
diff --git a/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi 
b/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
index bf5b1f3adcb..4fc055eacb7 100644
--- a/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
@@ -6,6 +6,29 @@
 #include "rk3328-u-boot.dtsi"
 #include "rk3328-sdram-ddr3-666.dtsi"
 
+/ {
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "radxa";
+   product = "rock-pi-e_rk3328";
+   };
+
+   baseboard {
+   manufacturer = "radxa";
+   product = "rock-pi-e_rk3328";
+   };
+
+   chassis {
+   manufacturer = "radxa";
+   product = "rock-pi-e_rk3328";
+   };
+   };
+   };
+};
+
  {
u-boot,dm-spl;
 };
diff --git a/arch/arm/dts/rk3328-rock64-u-boot.dtsi 
b/arch/arm/dts/rk3328-rock64-u-boot.dtsi
index 7340ef95f1d..2af32aea05a 100644
--- a/arch/arm/dts/rk3328-rock64-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-rock64-u-boot.dtsi
@@ -9,6 +9,27 @@
chosen {
u-boot,spl-boot-order = "same-as-spl", , 
};
+
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "pine64";
+   product = "rock64_rk3328";
+   };
+
+   baseboard {
+   manufacturer = "pine64";
+   product = "rock64_rk3328";
+   };
+
+   chassis {
+   manufacturer = "pine64";
+   product = "rock64_rk3328";
+   };
+   };
+   };
 };
 
  {
diff --git a/arch/arm/dts/rk3368-lion-u-boot.dtsi 
b/arch/arm/dts/rk3368-lion-u-boot.dtsi
index edc93e438f9..6d54214de9c 100644
--- a/arch/arm/dts/rk3368-lion-u-boot.dtsi
+++ b/arch/arm/dts/rk3368-lion-u-boot.dtsi
@@ -14,6 +14,26 @@
u-boot,spl-boot-order = , 
};
 
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   smbios {
+   system {
+   manufacturer = "rockchip";
+   product = "sheep_rk3368";
+   };
+
+   baseboard {
+   manufacturer = "rockchip";
+   product = "sheep_rk3368";
+   };
+
+   chassis {
+   manufacturer = "rockchip";
+   product = "sheep_rk3368";
+   };
+   };
+   };
 };
 
  {
diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig
index b5b7a0b2daa..3287bd1c05e 100644
--- a/configs/lion-rk3368_defconfig
+++ b/configs/lion-rk3368_defconfig
@@ -16,7 +16,6 @@ CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 

[PATCH v6 12/14] x86: galileo: Use devicetree for SMBIOS settings

2020-11-05 Thread Simon Glass
Add settings and enable the default sysinfo driver so that these can come
from the device tree.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v5)

Changes in v5:
- Move the Kconfig comment into the devicetree

 arch/x86/dts/galileo.dts| 28 
 board/intel/galileo/Kconfig | 11 ---
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/arch/x86/dts/galileo.dts b/arch/x86/dts/galileo.dts
index 5de4568679a..501047124ee 100644
--- a/arch/x86/dts/galileo.dts
+++ b/arch/x86/dts/galileo.dts
@@ -164,4 +164,32 @@
};
};
 
+   smbios {
+   compatible = "u-boot,sysinfo-smbios";
+
+   /*
+* Override the default product name U-Boot reports in the
+* SMBIOS table, to be compatible with the Intel provided UEFI
+* BIOS, as Linux kernel drivers
+* (drivers/mfd/intel_quark_i2c_gpio.c and
+* drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c) make use of
+* it to do different board level configuration.
+*
+* This can be "Galileo" for GEN1 Galileo board.
+*/
+   smbios {
+   system {
+   product = "GalileoGen2";
+   };
+
+   baseboard {
+   product = "GalileoGen2";
+   };
+
+   chassis {
+   product = "GalileoGen2";
+   };
+   };
+   };
+
 };
diff --git a/board/intel/galileo/Kconfig b/board/intel/galileo/Kconfig
index 1416c891e86..fb8d94fb5b1 100644
--- a/board/intel/galileo/Kconfig
+++ b/board/intel/galileo/Kconfig
@@ -22,15 +22,4 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select BOARD_ROMSIZE_KB_1024
select SPI_FLASH_WINBOND
 
-config SMBIOS_PRODUCT_NAME
-   default "GalileoGen2"
-   help
- Override the default product name U-Boot reports in the SMBIOS
- table, to be compatible with the Intel provided UEFI BIOS, as
- Linux kernel drivers (drivers/mfd/intel_quark_i2c_gpio.c and
- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c) make use of
- it to do different board level configuration.
-
- This can be "Galileo" for GEN1 Galileo board.
-
 endif
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 02/14] doc: Add a binding for sysinfo

2020-11-05 Thread Simon Glass
Add a simple binding file for this, so that it is clear what this binding
directory is for.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v5)

Changes in v5:
- Fix up the example for the binding

 doc/device-tree-bindings/sysinfo/sysinfo.txt | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 doc/device-tree-bindings/sysinfo/sysinfo.txt

diff --git a/doc/device-tree-bindings/sysinfo/sysinfo.txt 
b/doc/device-tree-bindings/sysinfo/sysinfo.txt
new file mode 100644
index 000..9445031b182
--- /dev/null
+++ b/doc/device-tree-bindings/sysinfo/sysinfo.txt
@@ -0,0 +1,19 @@
+Sysinfo
+===
+
+This provides capabilities to access information about a board/system, for
+use by drivers.
+
+Required properties:
+
+  - compatible: any suitable string where the driver is in the UCLASS_SYSINFO
+  class
+
+See also smbios.txt
+
+
+Example
+
+sysinfo {
+   compatible = "sandbox,sysinfo-sandbox";
+};
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 06/14] smbios: Add documentation and devicetree binding

2020-11-05 Thread Simon Glass
Add information about how to set SMBIOS properties using the devicetree.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 doc/arch/x86.rst|  8 +++
 doc/device-tree-bindings/sysinfo/smbios.txt | 77 +
 2 files changed, 85 insertions(+)
 create mode 100644 doc/device-tree-bindings/sysinfo/smbios.txt

diff --git a/doc/arch/x86.rst b/doc/arch/x86.rst
index c6b70ce61a3..cc307aa8d5e 100644
--- a/doc/arch/x86.rst
+++ b/doc/arch/x86.rst
@@ -740,6 +740,14 @@ Note that this is a development feature only. It is not 
intended for use in
 production environments. Also it is not currently part of the automated tests
 so may break in the future.
 
+SMBIOS tables
+-
+
+To generate SMBIOS tables in U-Boot, for use by the OS, enable the
+CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to
+use is via the device tree. For details see
+device-tree-bindings/sysinfo/smbios.txt
+
 TODO List
 -
 - Audio
diff --git a/doc/device-tree-bindings/sysinfo/smbios.txt 
b/doc/device-tree-bindings/sysinfo/smbios.txt
new file mode 100644
index 000..b5223228025
--- /dev/null
+++ b/doc/device-tree-bindings/sysinfo/smbios.txt
@@ -0,0 +1,77 @@
+SMBIOS sysinfo information
+==
+
+This binding allows the values for the SMBIOS tables to be specified in the
+devicetree, as below.
+
+Required properties:
+
+  - compatible: "u-boot,smbios" or any other string depending on your board
+
+This driver allows providing board-specific features such as power control
+GPIOs. In addition, the SMBIOS values can be specified in the device tree,
+as below:
+
+An optional 'smbios' subnode can be used to provide these properties. Within
+that, the properties are broken down by table type, as in the System Management
+BIOS (Basic Input/Output System) Specification.
+
+Available subnodes for each table type are:
+
+  - 1 : system
+  - 2 : baseboard
+  - 3 : chassis
+
+Within each subnode the following tables are recognised:
+
+"system" subnode optional properties:
+
+  - manufacturer: Product manufacturer for system
+  - product:  Product name
+  - version:  Product version string
+  - serial:   Serial number for system (note that this can be overridden by
+  the serial# environment variable)
+  - sku:  Product SKU (Stock-Keeping Unit)
+  - family:   Product family
+
+"baseboard" subnode optional properties:
+
+  - manufacturer: Product manufacturer for baseboard
+  - product:  Product name
+  - asset-tag:Asset tag for the motherboard, sometimes used in 
organisations
+  to track devices
+
+"chassis" subnode optional properties:
+
+  - manufacturer: Product manufacturer for chassis
+
+
+Example:
+
+sysinfo {
+   compatible = "sandbox,sysinfo-sandbox";
+
+   smbios {
+   /* Type 1 table */
+   system {
+   manufacturer = "Google";
+   product = "Coral";
+   version = "rev2";
+   serial = "123456789";
+   sku = "sku3";
+   family = "Google_Coral";
+   };
+
+   /* Type 2 table */
+   baseboard {
+   manufacturer = "Google";
+   product = "Coral";
+   asset-tag = "ABC123";
+   };
+
+   /* Type 3 table */
+   chassis {
+   manufacturer = "Google";
+   };
+   };
+};
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 07/14] sysinfo: Provide a default driver to set SMBIOS values

2020-11-05 Thread Simon Glass
Some boards want to specify the manufacturer or product name but do not
need to have their own sysinfo driver.

Add a default driver which provides a way to specify this SMBIOS
information in the devicetree, without needing any board-specific
functionality.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

Changes in v6:
- Fix 'manuafacture' typo in Kconfig

Changes in v5:
- Fix 'manuafacture' typo in commit message

 drivers/sysinfo/Kconfig  |  8 
 drivers/sysinfo/Makefile |  1 +
 drivers/sysinfo/smbios.c | 24 
 lib/Kconfig  |  3 +++
 4 files changed, 36 insertions(+)
 create mode 100644 drivers/sysinfo/smbios.c

diff --git a/drivers/sysinfo/Kconfig b/drivers/sysinfo/Kconfig
index 39141500a05..85c1e81e411 100644
--- a/drivers/sysinfo/Kconfig
+++ b/drivers/sysinfo/Kconfig
@@ -22,4 +22,12 @@ config SYSINFO_SANDBOX
help
  Support querying device information for the Sandbox boards.
 
+config SYSINFO_SMBIOS
+   bool "Provide a default sysinfo driver for SMBIOS information"
+   help
+ Some boards want to specify the manufacturer or product name but do
+ not need to have their own sysinfo driver. This includes a default
+ one which provides a way to specify this SMBIOS information in the
+ devicetree, without needing any board-specific functionality.
+
 endif
diff --git a/drivers/sysinfo/Makefile b/drivers/sysinfo/Makefile
index aecf0b0d47c..6d04fcba1d1 100644
--- a/drivers/sysinfo/Makefile
+++ b/drivers/sysinfo/Makefile
@@ -5,3 +5,4 @@
 obj-y += sysinfo-uclass.o
 obj-$(CONFIG_SYSINFO_GAZERBEAM) += gazerbeam.o
 obj-$(CONFIG_SYSINFO_SANDBOX) += sandbox.o
+obj-$(CONFIG_SYSINFO_SMBIOS) += smbios.o
diff --git a/drivers/sysinfo/smbios.c b/drivers/sysinfo/smbios.c
new file mode 100644
index 000..80ebd1921d8
--- /dev/null
+++ b/drivers/sysinfo/smbios.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+
+static const struct udevice_id sysinfo_smbios_ids[] = {
+   { .compatible = "u-boot,sysinfo-smbios" },
+   { /* sentinel */ }
+};
+
+static const struct sysinfo_ops sysinfo_smbios_ops = {
+};
+
+U_BOOT_DRIVER(sysinfo_smbios) = {
+   .name   = "sysinfo_smbios",
+   .id = UCLASS_SYSINFO,
+   .of_match   = sysinfo_smbios_ids,
+   .ops= _smbios_ops,
+};
diff --git a/lib/Kconfig b/lib/Kconfig
index 8f487533e8c..fdc35a92322 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -658,6 +658,9 @@ config GENERATE_SMBIOS_TABLE
 
  Check http://www.dmtf.org/standards/smbios for details.
 
+ See also SMBIOS_SYSINFO which allows SMBIOS values to be provided in
+ the devicetree.
+
 config SMBIOS_MANUFACTURER
string "SMBIOS Manufacturer"
depends on GENERATE_SMBIOS_TABLE
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 00/14] x86: Updates to SMBIOS

2020-11-05 Thread Simon Glass
At present there are a few Kconfig options which allow SMBIOS fields to
be specified at build time.

Not all fields are supported. Also, defining these at build-time is
limiting since a factory system cannot insert values for particular boards
or models without rebuilding U-Boot.

This series adds a way to set SMBIOS properties using the devicetree.
With this approach, more fields are supported and it is easy to update
values in the devicetree in the factory.

It also updates existing boards to use devicetree and drops the CONFIG
options, using a new default sysinfo driver.

Changes in v6:
- Fix 'manuafacture' typo in Kconfig
- Add new patch to provide default SMBIOS manufacturer/product

Changes in v5:
- Fix "sysinfo_gazerbeam" compatible string to use a hyphen
- Add a note as to why the patch does not just rename some files
- Fix up the example for the binding
- Fix "manufactuer" typo
- Fix "Informaiton" typo
- Update commit message to explain why family does not have a default
- Fix 'manuafacture' typo in commit message
- Move the Kconfig comment into the devicetree
- Rename smbios_add_prop_default() to smbios_add_prop()

Changes in v4:
- Fix build error with vexpress_ca9x4

Changes in v3:
- Use a different binding with subnodes for each table type
- Add onto the sysinfo binding

Changes in v2:
- Move dm.h header file to avoid build error on qemu-arm
- Deal with boards that don't use of-control

Simon Glass (14):
  board: Rename uclass to sysinfo
  doc: Add a binding for sysinfo
  x86: Pass an ofnode into each SMBIOS function
  smbios: Allow properties to come from the device tree
  smbios: Add more properties
  smbios: Add documentation and devicetree binding
  sysinfo: Provide a default driver to set SMBIOS values
  rockchip: Use devicetree for SMBIOS settings
  imx: Use devicetree for SMBIOS settings on MYiR MYS-6ULX
  odroid-c2: Use devicetree for SMBIOS settings
  arm64: mvebu: Use devicetree for SMBIOS settings on uDPU
  x86: galileo: Use devicetree for SMBIOS settings
  x86: Provide default SMBIOS manufacturer/product
  smbios: Drop the unused Kconfig options

 arch/Kconfig  |   2 +
 arch/arm/dts/armada-3720-uDPU-u-boot.dtsi |  20 +++
 .../dts/imx6ull-myir-mys-6ulx-eval-u-boot.dts |  25 
 arch/arm/dts/meson-gxbb-odroidc2-u-boot.dtsi  |  23 
 arch/arm/dts/rk3328-roc-cc-u-boot.dtsi|  21 +++
 arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi |  23 
 arch/arm/dts/rk3328-rock64-u-boot.dtsi|  21 +++
 arch/arm/dts/rk3368-lion-u-boot.dtsi  |  20 +++
 arch/powerpc/dts/gdsys/gazerbeam-uboot.dtsi   |   2 +-
 arch/sandbox/dts/test.dts |   8 +-
 arch/x86/dts/bayleybay.dts|   2 +
 arch/x86/dts/baytrail_som-db5800-som-6867.dts |   2 +
 arch/x86/dts/cherryhill.dts   |   2 +
 arch/x86/dts/chromebook_link.dts  |   2 +
 arch/x86/dts/chromebook_samus.dts |   2 +
 arch/x86/dts/chromebox_panther.dts|   2 +
 arch/x86/dts/conga-qeval20-qa3-e3845.dts  |   2 +
 arch/x86/dts/cougarcanyon2.dts|   2 +
 arch/x86/dts/crownbay.dts |   2 +
 arch/x86/dts/dfi-bt700.dtsi   |   2 +
 arch/x86/dts/edison.dts   |   2 +
 arch/x86/dts/galileo.dts  |  28 
 arch/x86/dts/minnowmax.dts|   2 +
 arch/x86/dts/qemu-x86_i440fx.dts  |   2 +
 arch/x86/dts/qemu-x86_q35.dts |   2 +
 arch/x86/dts/smbios.dtsi  |  32 +
 board/gdsys/common/cmd_ioloop.c   |  12 +-
 board/gdsys/mpc8308/gazerbeam.c   |  47 +++
 board/google/chromebook_coral/coral.c |   2 +-
 board/intel/galileo/Kconfig   |  11 --
 common/spl/spl_fit.c  |  15 ++-
 configs/chromebook_coral_defconfig|   2 +-
 configs/clearfog_gt_8k_defconfig  |   2 -
 configs/gazerbeam_defconfig   |   4 +-
 configs/lion-rk3368_defconfig |   4 +-
 configs/mt7622_rfb_defconfig  |   1 -
 configs/mvebu_db_armada8k_defconfig   |   2 -
 configs/myir_mys_6ulx_defconfig   |   3 +-
 configs/odroid-c2_defconfig   |   4 +-
 configs/r8a774a1_beacon_defconfig |   2 -
 configs/r8a77970_eagle_defconfig  |   2 -
 configs/r8a77980_condor_defconfig |   2 -
 configs/r8a77990_ebisu_defconfig  |   2 -
 configs/r8a77995_draak_defconfig  |   2 -
 configs/rcar3_salvator-x_defconfig|   2 -
 configs/rcar3_ulcb_defconfig  |   2 -
 configs/roc-cc-rk3328_defconfig   |   4 +-
 configs/rock-pi-e-rk3328_defconfig|   4 +-
 configs/rock64-rk3328_defconfig   |   4 +-
 configs/sandbox64_defconfig   |   4 +-
 configs/sandbox_defconfig |   4 +-
 configs/sandbox_flattree_defconfig 

[PATCH v6 05/14] smbios: Add more properties

2020-11-05 Thread Simon Glass
The current tables only support a subset of the available fields defined
by the SMBIOS spec. Add a few more.

We could use CONFIG_SYS_CPU or CONFIG_SYS_SOC as a default for family, but
the meaning of that value relates more to the whole system rather than
just the SoC.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v5)

Changes in v5:
- Update commit message to explain why family does not have a default

 lib/smbios.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/smbios.c b/lib/smbios.c
index 3f9d2ec0855..a52a9d5b307 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -173,12 +173,15 @@ static int smbios_write_type1(ulong *current, int handle, 
ofnode node)
  CONFIG_SMBIOS_MANUFACTURER);
t->product_name = smbios_add_prop_default(t->eos, node, "product",
  CONFIG_SMBIOS_PRODUCT_NAME);
+   t->version = smbios_add_prop(t->eos, node, "version");
if (serial_str) {
t->serial_number = smbios_add_string(t->eos, serial_str);
strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
} else {
t->serial_number = smbios_add_prop(t->eos, node, "serial");
}
+   t->sku_number = smbios_add_prop(t->eos, node, "sku");
+   t->family = smbios_add_prop(t->eos, node, "family");
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
@@ -199,6 +202,7 @@ static int smbios_write_type2(ulong *current, int handle, 
ofnode node)
  CONFIG_SMBIOS_MANUFACTURER);
t->product_name = smbios_add_prop_default(t->eos, node, "product",
  CONFIG_SMBIOS_PRODUCT_NAME);
+   t->asset_tag_number = smbios_add_prop(t->eos, node, "asset-tag");
t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING;
t->board_type = SMBIOS_BOARD_MOTHERBOARD;
 
-- 
2.29.1.341.ge80a0c044ae-goog



[PATCH v6 04/14] smbios: Allow properties to come from the device tree

2020-11-05 Thread Simon Glass
Support a way to put SMBIOS properties in the device tree. These can be
placed in a 'board' device in an 'smbios' subnode.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v5)

Changes in v5:
- Fix "manufactuer" typo
- Fix "Informaiton" typo

Changes in v4:
- Fix build error with vexpress_ca9x4

Changes in v3:
- Use a different binding with subnodes for each table type

 lib/smbios.c | 98 +++-
 1 file changed, 81 insertions(+), 17 deletions(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index b0f5e936044..3f9d2ec0855 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -17,6 +17,18 @@
 #include 
 #endif
 
+/**
+ * struct smbios_write_method - Information about a table-writing function
+ *
+ * @write: Function to call
+ * @subnode_name: Name of subnode which has the information for this function,
+ * NULL if none
+ */
+struct smbios_write_method {
+   smbios_write_type write;
+   const char *subnode_name;
+};
+
 /**
  * smbios_add_string() - add a string to the string area
  *
@@ -52,6 +64,43 @@ static int smbios_add_string(char *start, const char *str)
}
 }
 
+/**
+ * smbios_add_prop_default() - Add a property from the device tree or default
+ *
+ * @start: string area start address
+ * @node:  node containing the information to write (ofnode_null() if none)
+ * @prop:  property to write
+ * @def:   default string if the node has no such property
+ * @return 0 if not found, else SMBIOS string number (1 or more)
+ */
+static int smbios_add_prop_default(char *start, ofnode node, const char *prop,
+  const char *def)
+{
+   const char *str = NULL;
+
+   if (IS_ENABLED(CONFIG_OF_CONTROL))
+   str = ofnode_read_string(node, prop);
+   if (str)
+   return smbios_add_string(start, str);
+   else if (def)
+   return smbios_add_string(start, def);
+
+   return 0;
+}
+
+/**
+ * smbios_add_prop() - Add a property from the device tree
+ *
+ * @start: string area start address
+ * @node:  node containing the information to write (ofnode_null() if none)
+ * @prop:  property to write
+ * @return 0 if not found, else SMBIOS string number (1 or more)
+ */
+static int smbios_add_prop(char *start, ofnode node, const char *prop)
+{
+   return smbios_add_prop_default(start, node, prop, NULL);
+}
+
 /**
  * smbios_string_table_len() - compute the string area size
  *
@@ -120,11 +169,15 @@ static int smbios_write_type1(ulong *current, int handle, 
ofnode node)
t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type1));
fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
-   t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
-   t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
+   t->manufacturer = smbios_add_prop_default(t->eos, node, "manufacturer",
+ CONFIG_SMBIOS_MANUFACTURER);
+   t->product_name = smbios_add_prop_default(t->eos, node, "product",
+ CONFIG_SMBIOS_PRODUCT_NAME);
if (serial_str) {
-   strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
t->serial_number = smbios_add_string(t->eos, serial_str);
+   strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
+   } else {
+   t->serial_number = smbios_add_prop(t->eos, node, "serial");
}
 
len = t->length + smbios_string_table_len(t->eos);
@@ -142,8 +195,10 @@ static int smbios_write_type2(ulong *current, int handle, 
ofnode node)
t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type2));
fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
-   t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
-   t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
+   t->manufacturer = smbios_add_prop_default(t->eos, node, "manufacturer",
+ CONFIG_SMBIOS_MANUFACTURER);
+   t->product_name = smbios_add_prop_default(t->eos, node, "product",
+ CONFIG_SMBIOS_PRODUCT_NAME);
t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING;
t->board_type = SMBIOS_BOARD_MOTHERBOARD;
 
@@ -162,7 +217,8 @@ static int smbios_write_type3(ulong *current, int handle, 
ofnode node)
t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type3));
fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);
-   t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
+   t->manufacturer = smbios_add_prop_default(t->eos, node, "manufacturer",
+ CONFIG_SMBIOS_MANUFACTURER);
t->chassis_type = 

[PATCH v6 03/14] x86: Pass an ofnode into each SMBIOS function

2020-11-05 Thread Simon Glass
As a first step to obtaining SMBIOS information from the devicetree, add
an ofnode parameter to the writing functions.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v2)

Changes in v2:
- Move dm.h header file to avoid build error on qemu-arm
- Deal with boards that don't use of-control

 include/smbios.h |  5 -
 lib/smbios.c | 44 ++--
 2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/include/smbios.h b/include/smbios.h
index 44f49e9556b..1846607c3cf 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -8,6 +8,8 @@
 #ifndef _SMBIOS_H_
 #define _SMBIOS_H_
 
+#include 
+
 /* SMBIOS spec version implemented */
 #define SMBIOS_MAJOR_VER   3
 #define SMBIOS_MINOR_VER   0
@@ -222,9 +224,10 @@ static inline void fill_smbios_header(void *table, int 
type,
  *
  * @addr:  start address to write the structure
  * @handle:the structure's handle, a unique 16-bit number
+ * @node:  node containing the information to write (ofnode_null() if none)
  * @return:size of the structure
  */
-typedef int (*smbios_write_type)(ulong *addr, int handle);
+typedef int (*smbios_write_type)(ulong *addr, int handle, ofnode node);
 
 /**
  * write_smbios_table() - Write SMBIOS table
diff --git a/lib/smbios.c b/lib/smbios.c
index 11790443e1a..b0f5e936044 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -13,7 +14,6 @@
 #include 
 #ifdef CONFIG_CPU
 #include 
-#include 
 #include 
 #endif
 
@@ -25,7 +25,7 @@
  *
  * @start: string area start address
  * @str:   string to add
- * @return:string number in the string area
+ * @return:string number in the string area (1 or more)
  */
 static int smbios_add_string(char *start, const char *str)
 {
@@ -74,7 +74,7 @@ static int smbios_string_table_len(char *start)
return len + 1;
 }
 
-static int smbios_write_type0(ulong *current, int handle)
+static int smbios_write_type0(ulong *current, int handle, ofnode node)
 {
struct smbios_type0 *t;
int len = sizeof(struct smbios_type0);
@@ -111,7 +111,7 @@ static int smbios_write_type0(ulong *current, int handle)
return len;
 }
 
-static int smbios_write_type1(ulong *current, int handle)
+static int smbios_write_type1(ulong *current, int handle, ofnode node)
 {
struct smbios_type1 *t;
int len = sizeof(struct smbios_type1);
@@ -134,7 +134,7 @@ static int smbios_write_type1(ulong *current, int handle)
return len;
 }
 
-static int smbios_write_type2(ulong *current, int handle)
+static int smbios_write_type2(ulong *current, int handle, ofnode node)
 {
struct smbios_type2 *t;
int len = sizeof(struct smbios_type2);
@@ -154,7 +154,7 @@ static int smbios_write_type2(ulong *current, int handle)
return len;
 }
 
-static int smbios_write_type3(ulong *current, int handle)
+static int smbios_write_type3(ulong *current, int handle, ofnode node)
 {
struct smbios_type3 *t;
int len = sizeof(struct smbios_type3);
@@ -176,7 +176,7 @@ static int smbios_write_type3(ulong *current, int handle)
return len;
 }
 
-static void smbios_write_type4_dm(struct smbios_type4 *t)
+static void smbios_write_type4_dm(struct smbios_type4 *t, ofnode node)
 {
u16 processor_family = SMBIOS_PROCESSOR_FAMILY_UNKNOWN;
const char *vendor = "Unknown";
@@ -185,20 +185,20 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)
 #ifdef CONFIG_CPU
char processor_name[49];
char vendor_name[49];
-   struct udevice *dev = NULL;
+   struct udevice *cpu = NULL;
 
-   uclass_find_first_device(UCLASS_CPU, );
-   if (dev) {
-   struct cpu_platdata *plat = dev_get_parent_platdata(dev);
+   uclass_find_first_device(UCLASS_CPU, );
+   if (cpu) {
+   struct cpu_platdata *plat = dev_get_parent_platdata(cpu);
 
if (plat->family)
processor_family = plat->family;
t->processor_id[0] = plat->id[0];
t->processor_id[1] = plat->id[1];
 
-   if (!cpu_get_vendor(dev, vendor_name, sizeof(vendor_name)))
+   if (!cpu_get_vendor(cpu, vendor_name, sizeof(vendor_name)))
vendor = vendor_name;
-   if (!cpu_get_desc(dev, processor_name, sizeof(processor_name)))
+   if (!cpu_get_desc(cpu, processor_name, sizeof(processor_name)))
name = processor_name;
}
 #endif
@@ -208,7 +208,7 @@ static void smbios_write_type4_dm(struct smbios_type4 *t)
t->processor_version = smbios_add_string(t->eos, name);
 }
 
-static int smbios_write_type4(ulong *current, int handle)
+static int smbios_write_type4(ulong *current, int handle, ofnode node)
 {
struct smbios_type4 *t;
int len = sizeof(struct smbios_type4);
@@ -217,7 +217,7 @@ static int smbios_write_type4(ulong 

[PATCH] fixup: x86: Add missing global_data declaration in tables

2020-11-05 Thread Simon Glass
This file needs to use the global data pointer. Add the required
declaration.

This is a fixup patch for the following:

   09218442ca7 x86: Allow putting some tables in the bloblist

Signed-off-by: Simon Glass 
---

 arch/x86/lib/tables.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index 8dc07868c1f..c4007fa4866 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -14,6 +14,8 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /**
  * Function prototype to write a specific configuration table
  *
-- 
2.29.1.341.ge80a0c044ae-goog



Re: [PATCH v5 13/13] smbios: Drop the unused Kconfig options

2020-11-05 Thread Simon Glass
Hi Bin,

On Wed, 4 Nov 2020 at 23:49, Bin Meng  wrote:
>
> Hi Simon,
>
> On Wed, Nov 4, 2020 at 11:23 PM Simon Glass  wrote:
> >
> > Now that we can use devicetree to specify this information, drop the old
> > CONFIG options.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v5:
> > - Rename smbios_add_prop_default() to smbios_add_prop()
> >
> > Changes in v3:
> > - Add onto the sysinfo binding
> >
> >  configs/clearfog_gt_8k_defconfig|  2 --
> >  configs/mt7622_rfb_defconfig|  1 -
> >  configs/mvebu_db_armada8k_defconfig |  2 --
> >  configs/r8a774a1_beacon_defconfig   |  2 --
> >  configs/r8a77970_eagle_defconfig|  2 --
> >  configs/r8a77980_condor_defconfig   |  2 --
> >  configs/r8a77990_ebisu_defconfig|  2 --
> >  configs/r8a77995_draak_defconfig|  2 --
> >  configs/rcar3_salvator-x_defconfig  |  2 --
> >  configs/rcar3_ulcb_defconfig|  2 --
> >  lib/Kconfig | 16 --
> >  lib/smbios.c| 46 -
> >  12 files changed, 13 insertions(+), 68 deletions(-)
> >
> > diff --git a/configs/clearfog_gt_8k_defconfig 
> > b/configs/clearfog_gt_8k_defconfig
> > index 552df3a8b80..9bb1f212a70 100644
> > --- a/configs/clearfog_gt_8k_defconfig
> > +++ b/configs/clearfog_gt_8k_defconfig
> > @@ -12,7 +12,6 @@ CONFIG_DM_GPIO=y
> >  CONFIG_DEBUG_UART_BASE=0xf0512000
> >  CONFIG_DEBUG_UART_CLOCK=2
> >  CONFIG_DEFAULT_DEVICE_TREE="armada-8040-clearfog-gt-8k"
> > -CONFIG_SMBIOS_PRODUCT_NAME=""
> >  CONFIG_DEBUG_UART=y
> >  CONFIG_AHCI=y
> >  CONFIG_DISTRO_DEFAULTS=y
> > @@ -78,4 +77,3 @@ CONFIG_USB_ETHER_ASIX=y
> >  CONFIG_USB_ETHER_MCS7830=y
> >  CONFIG_USB_ETHER_RTL8152=y
> >  CONFIG_USB_ETHER_SMSC95XX=y
> > -CONFIG_SMBIOS_MANUFACTURER=""
> > diff --git a/configs/mt7622_rfb_defconfig b/configs/mt7622_rfb_defconfig
> > index a6089d6cf6a..ccf926e1040 100644
> > --- a/configs/mt7622_rfb_defconfig
> > +++ b/configs/mt7622_rfb_defconfig
> > @@ -5,7 +5,6 @@ CONFIG_SYS_TEXT_BASE=0x41e0
> >  CONFIG_SYS_MALLOC_F_LEN=0x4000
> >  CONFIG_NR_DRAM_BANKS=1
> >  CONFIG_DEFAULT_DEVICE_TREE="mt7622-rfb"
> > -CONFIG_SMBIOS_PRODUCT_NAME=""
> >  CONFIG_FIT=y
> >  CONFIG_DEFAULT_FDT_FILE="mt7622-rfb"
> >  CONFIG_LOGLEVEL=7
> > diff --git a/configs/mvebu_db_armada8k_defconfig 
> > b/configs/mvebu_db_armada8k_defconfig
> > index a88d5cc98bd..5d8a1b655cd 100644
> > --- a/configs/mvebu_db_armada8k_defconfig
> > +++ b/configs/mvebu_db_armada8k_defconfig
> > @@ -11,7 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x1
> >  CONFIG_DEBUG_UART_BASE=0xf0512000
> >  CONFIG_DEBUG_UART_CLOCK=2
> >  CONFIG_DEFAULT_DEVICE_TREE="armada-8040-db"
> > -CONFIG_SMBIOS_PRODUCT_NAME=""
> >  CONFIG_DEBUG_UART=y
> >  CONFIG_AHCI=y
> >  CONFIG_DISTRO_DEFAULTS=y
> > @@ -72,4 +71,3 @@ CONFIG_USB_ETHER_ASIX=y
> >  CONFIG_USB_ETHER_MCS7830=y
> >  CONFIG_USB_ETHER_RTL8152=y
> >  CONFIG_USB_ETHER_SMSC95XX=y
> > -CONFIG_SMBIOS_MANUFACTURER=""
> > diff --git a/configs/r8a774a1_beacon_defconfig 
> > b/configs/r8a774a1_beacon_defconfig
> > index 5d564d82c2f..2f45edd92ec 100644
> > --- a/configs/r8a774a1_beacon_defconfig
> > +++ b/configs/r8a774a1_beacon_defconfig
> > @@ -8,7 +8,6 @@ CONFIG_RCAR_GEN3=y
> >  CONFIG_TARGET_BEACON_RZG2M=y
> >  # CONFIG_SPL is not set
> >  CONFIG_DEFAULT_DEVICE_TREE="r8a774a1-beacon-rzg2m-kit"
> > -CONFIG_SMBIOS_PRODUCT_NAME=""
> >  CONFIG_FIT=y
> >  CONFIG_SUPPORT_RAW_INITRD=y
> >  # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
> > @@ -64,4 +63,3 @@ CONFIG_USB_EHCI_HCD=y
> >  CONFIG_USB_EHCI_GENERIC=y
> >  CONFIG_USB_STORAGE=y
> >  CONFIG_OF_LIBFDT_OVERLAY=y
> > -CONFIG_SMBIOS_MANUFACTURER=""
> > diff --git a/configs/r8a77970_eagle_defconfig 
> > b/configs/r8a77970_eagle_defconfig
> > index a7774842353..9dbe0e1d5b4 100644
> > --- a/configs/r8a77970_eagle_defconfig
> > +++ b/configs/r8a77970_eagle_defconfig
> > @@ -11,7 +11,6 @@ CONFIG_SPL_TEXT_BASE=0xe6318000
> >  CONFIG_RCAR_GEN3=y
> >  CONFIG_TARGET_EAGLE=y
> >  CONFIG_DEFAULT_DEVICE_TREE="r8a77970-eagle-u-boot"
> > -CONFIG_SMBIOS_PRODUCT_NAME=""
> >  CONFIG_FIT=y
> >  CONFIG_SUPPORT_RAW_INITRD=y
> >  CONFIG_USE_BOOTARGS=y
> > @@ -74,4 +73,3 @@ CONFIG_USB_EHCI_HCD=y
> >  CONFIG_USB_EHCI_GENERIC=y
> >  CONFIG_USB_STORAGE=y
> >  CONFIG_OF_LIBFDT_OVERLAY=y
> > -CONFIG_SMBIOS_MANUFACTURER=""
> > diff --git a/configs/r8a77980_condor_defconfig 
> > b/configs/r8a77980_condor_defconfig
> > index 4e457234ed0..dbe2912779c 100644
> > --- a/configs/r8a77980_condor_defconfig
> > +++ b/configs/r8a77980_condor_defconfig
> > @@ -11,7 +11,6 @@ CONFIG_SPL_TEXT_BASE=0xe6318000
> >  CONFIG_RCAR_GEN3=y
> >  CONFIG_TARGET_CONDOR=y
> >  CONFIG_DEFAULT_DEVICE_TREE="r8a77980-condor-u-boot"
> > -CONFIG_SMBIOS_PRODUCT_NAME=""
> >  CONFIG_FIT=y
> >  CONFIG_SUPPORT_RAW_INITRD=y
> >  CONFIG_USE_BOOTARGS=y
> > @@ -75,4 +74,3 @@ CONFIG_USB_EHCI_HCD=y
> >  CONFIG_USB_EHCI_GENERIC=y
> >  CONFIG_USB_STORAGE=y
> >  CONFIG_OF_LIBFDT_OVERLAY=y
> > -CONFIG_SMBIOS_MANUFACTURER=""
> > diff --git 

Re: [PATCH] km/common: remove CONFIG_MTD_CONCAT

2020-11-05 Thread Stefan Roese

On 05.11.20 10:28, Holger Brunck wrote:

This was used for a board which is not supproted anymore and can
therefore be dropped.

CC: Stefan Roese 
Signed-off-by: Holger Brunck 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


[v3] net: pfe_eth: read PFE ESBC header flash with spi_flash_read API

2020-11-05 Thread Biwen Li
From: Biwen Li 

Read PFE ESBC header flash with spi_flash_read API
- logs as follows,
  Net:   SF: Detected s25fs512s with page size 256 Bytes, erase size 256
  KiB, total 64 MiB
  "Synchronous Abort" handler, esr 0x96000210
  elr: 8206db44 lr : 82004ea0 (reloc)
  elr: b7ba6b44 lr : b7b3dea0
  x0 : b79407e8 x1 : 4064
  x2 : 0050 x3 : 
  x4 : 000a x5 : 0050
  x6 : 0366 x7 : b7942308
  x8 : b76407c0 x9 : 0008
  x10: 0044 x11: b7634d1c
  x12: 004f x13: 0044
  x14: b7634d98 x15: b76407c0
  x16:  x17: 
  x18: b7636dd8 x19: 
  x20: b79407d0 x21: b79407e8
  x22: 4064 x23: b7634e58
  x24:  x25: 0380
  x26: b7bdd000 x27: 
  x28:  x29: b7634d10

  Code: d283 eb03005f 54000101 d65f03c0 (f8636826)
  Resetting CPU ...

Signed-off-by: Biwen Li 
---
Change in v3:
- cleanup code

Change in v2:
- update subject and description

 board/freescale/ls1012afrdm/Kconfig | 11 +++
 board/freescale/ls1012aqds/Kconfig  | 14 +++--
 board/freescale/ls1012ardb/Kconfig  | 18 +--
 drivers/net/pfe_eth/pfe_firmware.c  | 48 ++---
 4 files changed, 81 insertions(+), 10 deletions(-)

diff --git a/board/freescale/ls1012afrdm/Kconfig 
b/board/freescale/ls1012afrdm/Kconfig
index 55b414e168..4ac69d7117 100644
--- a/board/freescale/ls1012afrdm/Kconfig
+++ b/board/freescale/ls1012afrdm/Kconfig
@@ -16,6 +16,10 @@ config SYS_LS_PFE_FW_ADDR
hex "Flash address of PFE firmware"
default 0x40a0
 
+config SYS_LS_PFE_FW_LENGTH
+   hex "length of PFE firmware"
+   default 0x4
+
 config SYS_LS_PPA_FW_ADDR
hex "PPA Firmware Addr"
default 0x4040
@@ -65,6 +69,10 @@ config SYS_LS_PFE_FW_ADDR
hex "Flash address of PFE firmware"
default 0x4002
 
+config SYS_LS_PFE_FW_LENGTH
+   hex "length of PFE firmware"
+   default 0x4
+
 config SYS_LS_PPA_FW_ADDR
hex "PPA Firmware Addr"
default 0x4006
@@ -77,6 +85,9 @@ config SYS_LS_PFE_ESBC_ADDR
hex "PFE Firmware HDR Addr"
default 0x401f8000
 
+config SYS_LS_PFE_ESBC_LENGTH
+   hex "length of PFE Firmware HDR"
+   default 0xc00
 endif
 
 if TARGET_LS1012AFRDM || TARGET_LS1012AFRWY
diff --git a/board/freescale/ls1012aqds/Kconfig 
b/board/freescale/ls1012aqds/Kconfig
index 8844557aae..59b1a87665 100644
--- a/board/freescale/ls1012aqds/Kconfig
+++ b/board/freescale/ls1012aqds/Kconfig
@@ -20,6 +20,14 @@ if CHAIN_OF_TRUST
 config SYS_LS_PPA_ESBC_ADDR
hex "PPA Firmware HDR Addr"
default 0x4068
+
+config SYS_LS_PFE_ESBC_ADDR
+   hex "PFE Firmware HDR Addr"
+   default 0x4070
+
+config SYS_LS_PFE_ESBC_LENGTH
+   hex "length of PFE Firmware HDR"
+   default 0xc00
 endif
 
 if FSL_PFE
@@ -39,9 +47,9 @@ config SYS_LS_PFE_FW_ADDR
hex "Flash address of PFE firmware"
default 0x40a0
 
-config SYS_LS_PFE_ESBC_ADDR
-   hex "PFE Firmware HDR Addr"
-   default 0x4070
+config SYS_LS_PFE_FW_LENGTH
+   hex "length of PFE firmware"
+   default 0x30
 
 config DDR_PFE_PHYS_BASEADDR
hex "PFE DDR physical base address"
diff --git a/board/freescale/ls1012ardb/Kconfig 
b/board/freescale/ls1012ardb/Kconfig
index 5a2fa91f6b..c4acea3ae2 100644
--- a/board/freescale/ls1012ardb/Kconfig
+++ b/board/freescale/ls1012ardb/Kconfig
@@ -20,6 +20,14 @@ if CHAIN_OF_TRUST
 config SYS_LS_PPA_ESBC_ADDR
hex "PPA Firmware HDR Addr"
default 0x4068
+
+config SYS_LS_PFE_ESBC_ADDR
+   hex "PFE Firmware HDR Addr"
+   default 0x4064
+
+config SYS_LS_PFE_ESBC_LENGTH
+   hex "length of PFE Firmware HDR"
+   default 0xc00
 endif
 
 if FSL_PFE
@@ -33,9 +41,9 @@ config SYS_LS_PFE_FW_ADDR
hex "Flash address of PFE firmware"
default 0x40a0
 
-config SYS_LS_PFE_ESBC_ADDR
-   hex "PFE Firmware HDR Addr"
-   default 0x4064
+config SYS_LS_PFE_FW_LENGTH
+   hex "length of PFE firmware"
+   default 0x30
 
 config DDR_PFE_PHYS_BASEADDR
hex "PFE DDR physical base address"
@@ -89,6 +97,10 @@ config SYS_LS_PFE_FW_ADDR
hex "Flash address of PFE firmware"
default 0x40a0
 
+config SYS_LS_PFE_FW_LENGTH
+   hex "length of PFE firmware"
+   default 0x30
+
 config DDR_PFE_PHYS_BASEADDR
hex "PFE DDR physical base address"
default 0x0380
diff --git a/drivers/net/pfe_eth/pfe_firmware.c 
b/drivers/net/pfe_eth/pfe_firmware.c
index d414c750d4..41999e176d 100644
--- a/drivers/net/pfe_eth/pfe_firmware.c
+++ b/drivers/net/pfe_eth/pfe_firmware.c
@@ -10,6 +10,8 @@
  * files.
  */
 
+#include 
+#include 
 #include 
 #include 
 

[RESEND,PATCH v2 0/1] RISC-V tracing support

2020-11-05 Thread Pragnesh Patel
This series add a support of tracing for RISC-V arch.

This series is also available here [1] for testing.
[1] https://github.com/pragnesh26992/u-boot/tree/trace

How to test this patch:
1) Enable tracing in "configs/sifive_fu540_defconfig"
CONFIG_TRACE=y
CONFIG_TRACE_BUFFER_SIZE=0x0100
CONFIG_TRACE_CALL_DEPTH_LIMIT=15
CONFIG_CMD_TRACE=y

2) make FTRACE=1 sifive_fu540_defconfig
3) make FTRACE=1

Following are the boot messages on FU540 five cores SMP platform:

U-Boot SPL 2021.01-rc1-00244-gc0ac5b69ea-dirty (Nov 05 2020 - 15:21:06 +0530)
Trying to boot from MMC1


U-Boot 2021.01-rc1-00244-gc0ac5b69ea-dirty (Nov 05 2020 - 15:21:06 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
trace: enabled
MMC:   spi@1005:mmc@0: 0
*** Warning - bad CRC, using default environment

In:serial@1001
Out:   serial@1001
Err:   serial@1001
Board serial number should not be 0 !!
Net:
Error: ethernet@1009 address not set.
No ethernet found.

Hit any key to stop autoboot:  0
=> trace stats
178,556 function sites
  9,378,800 function calls
  1 untracked function calls
  1,279,056 traced function calls (8070507 dropped due to overflow)
 19 maximum observed call depth
 15 call depth limit
  9,568,845 calls not traced due to depth
=> trace calls 0x8300 0xf0
Call list dumped to 8300, size 0xea33d0
=>


Pragnesh Patel (1):
  riscv: Add timer_get_us() for tracing

 drivers/timer/andes_plmt_timer.c   | 16 +++-
 drivers/timer/riscv_timer.c| 14 +-
 drivers/timer/sifive_clint_timer.c | 16 +++-
 3 files changed, 43 insertions(+), 3 deletions(-)

-- 
2.17.1



[RESEND,PATCH v2 1/1] riscv: Add timer_get_us() for tracing

2020-11-05 Thread Pragnesh Patel
Add timer_get_us() which is useful for tracing.
For S-mode U-Boot, CSR_TIMEH and CSR_TIME will provide
a timer ticks and For M-mode U-Boot, mtime register will
provide the same.

Signed-off-by: Pragnesh Patel 
---
 drivers/timer/andes_plmt_timer.c   | 16 +++-
 drivers/timer/riscv_timer.c| 14 +-
 drivers/timer/sifive_clint_timer.c | 16 +++-
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/drivers/timer/andes_plmt_timer.c b/drivers/timer/andes_plmt_timer.c
index cec86718c7..9d663e036e 100644
--- a/drivers/timer/andes_plmt_timer.c
+++ b/drivers/timer/andes_plmt_timer.c
@@ -13,11 +13,12 @@
 #include 
 #include 
 #include 
+#include 
 
 /* mtime register */
 #define MTIME_REG(base)((ulong)(base))
 
-static u64 andes_plmt_get_count(struct udevice *dev)
+static u64 notrace andes_plmt_get_count(struct udevice *dev)
 {
return readq((void __iomem *)MTIME_REG(dev->priv));
 }
@@ -26,12 +27,25 @@ static const struct timer_ops andes_plmt_ops = {
.get_count = andes_plmt_get_count,
 };
 
+#if CONFIG_IS_ENABLED(RISCV_MMODE)
+unsigned long notrace timer_get_us(void)
+{
+   u64 ticks;
+
+   /* FIXME: gd->arch.plic should contain valid base address */
+   ticks = andes_plmt_get_count(gd->arch.plic);
+   do_div(ticks, CONFIG_SYS_HZ);
+   return ticks;
+}
+#endif
+
 static int andes_plmt_probe(struct udevice *dev)
 {
dev->priv = dev_read_addr_ptr(dev);
if (!dev->priv)
return -EINVAL;
 
+   gd->arch.plic = dev->priv;
return timer_timebase_fallback(dev);
 }
 
diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c
index 21ae184057..7fa8773da3 100644
--- a/drivers/timer/riscv_timer.c
+++ b/drivers/timer/riscv_timer.c
@@ -15,8 +15,9 @@
 #include 
 #include 
 #include 
+#include 
 
-static u64 riscv_timer_get_count(struct udevice *dev)
+static u64 notrace riscv_timer_get_count(struct udevice *dev)
 {
__maybe_unused u32 hi, lo;
 
@@ -31,6 +32,17 @@ static u64 riscv_timer_get_count(struct udevice *dev)
return ((u64)hi << 32) | lo;
 }
 
+#if CONFIG_IS_ENABLED(RISCV_SMODE)
+unsigned long notrace timer_get_us(void)
+{
+   u64 ticks;
+
+   ticks = riscv_timer_get_count(NULL);
+   do_div(ticks, CONFIG_SYS_HZ);
+   return ticks;
+}
+#endif
+
 static int riscv_timer_probe(struct udevice *dev)
 {
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
diff --git a/drivers/timer/sifive_clint_timer.c 
b/drivers/timer/sifive_clint_timer.c
index 00ce0f08d6..166655e99d 100644
--- a/drivers/timer/sifive_clint_timer.c
+++ b/drivers/timer/sifive_clint_timer.c
@@ -10,11 +10,12 @@
 #include 
 #include 
 #include 
+#include 
 
 /* mtime register */
 #define MTIME_REG(base)((ulong)(base) + 0xbff8)
 
-static u64 sifive_clint_get_count(struct udevice *dev)
+static u64 notrace sifive_clint_get_count(struct udevice *dev)
 {
return readq((void __iomem *)MTIME_REG(dev->priv));
 }
@@ -23,12 +24,25 @@ static const struct timer_ops sifive_clint_ops = {
.get_count = sifive_clint_get_count,
 };
 
+#if CONFIG_IS_ENABLED(RISCV_MMODE)
+unsigned long notrace timer_get_us(void)
+{
+   u64 ticks;
+
+   /* FIXME: gd->arch.clint should contain valid base address */
+   ticks = sifive_clint_get_count(gd->arch.clint);
+   do_div(ticks, CONFIG_SYS_HZ);
+   return ticks;
+}
+#endif
+
 static int sifive_clint_probe(struct udevice *dev)
 {
dev->priv = dev_read_addr_ptr(dev);
if (!dev->priv)
return -EINVAL;
 
+   gd->arch.clint = dev->priv;
return timer_timebase_fallback(dev);
 }
 
-- 
2.17.1



[PATCH v2 0/1] RISC-V tracing support

2020-11-05 Thread Pragnesh Patel
This series add a support of tracing for RISC-V arch.

This series is also available here [1] for testing.
[1] https://github.com/pragnesh26992/u-boot/tree/trace

How to test this patch:
1) Enable tracing in "configs/sifive_fu540_defconfig"
CONFIG_TRACE=y
CONFIG_TRACE_BUFFER_SIZE=0x0100
CONFIG_TRACE_CALL_DEPTH_LIMIT=15
CONFIG_CMD_TRACE=y

2) make FTRACE=1 sifive_fu540_defconfig
3) make FTRACE=1

Following are the boot messages on FU540 five cores SMP platform:

U-Boot SPL 2021.01-rc1-00244-gc0ac5b69ea-dirty (Nov 05 2020 - 15:21:06 +0530)
Trying to boot from MMC1


U-Boot 2021.01-rc1-00244-gc0ac5b69ea-dirty (Nov 05 2020 - 15:21:06 +0530)

CPU:   rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM:  8 GiB
trace: enabled
MMC:   spi@1005:mmc@0: 0
*** Warning - bad CRC, using default environment

In:serial@1001
Out:   serial@1001
Err:   serial@1001
Board serial number should not be 0 !!
Net:
Error: ethernet@1009 address not set.
No ethernet found.

Hit any key to stop autoboot:  0
=> trace stats
178,556 function sites
  9,378,800 function calls
  1 untracked function calls
  1,279,056 traced function calls (8070507 dropped due to overflow)
 19 maximum observed call depth
 15 call depth limit
  9,568,845 calls not traced due to depth
=> trace calls 0x8300 0xf0
Call list dumped to 8300, size 0xea33d0
=>


Pragnesh Patel (1):
  riscv: Add timer_get_us() for tracing

 drivers/timer/andes_plmt_timer.c   | 14 ++
 drivers/timer/riscv_timer.c| 14 +-
 drivers/timer/sifive_clint_timer.c | 16 +++-
 3 files changed, 42 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH v2] riscv: Add timer_get_us() for tracing

2020-11-05 Thread Pragnesh Patel
Add timer_get_us() which is useful for tracing.
For S-mode U-Boot, CSR_TIMEH and CSR_TIME will provide
a timer ticks and For M-mode U-Boot, mtime register will
provide the same.

Signed-off-by: Pragnesh Patel 
---
 drivers/timer/andes_plmt_timer.c   | 16 +++-
 drivers/timer/riscv_timer.c| 14 +-
 drivers/timer/sifive_clint_timer.c | 16 +++-
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/drivers/timer/andes_plmt_timer.c b/drivers/timer/andes_plmt_timer.c
index cec86718c7..9d663e036e 100644
--- a/drivers/timer/andes_plmt_timer.c
+++ b/drivers/timer/andes_plmt_timer.c
@@ -13,11 +13,12 @@
 #include 
 #include 
 #include 
+#include 
 
 /* mtime register */
 #define MTIME_REG(base)((ulong)(base))
 
-static u64 andes_plmt_get_count(struct udevice *dev)
+static u64 notrace andes_plmt_get_count(struct udevice *dev)
 {
return readq((void __iomem *)MTIME_REG(dev->priv));
 }
@@ -26,12 +27,25 @@ static const struct timer_ops andes_plmt_ops = {
.get_count = andes_plmt_get_count,
 };
 
+#if CONFIG_IS_ENABLED(RISCV_MMODE)
+unsigned long notrace timer_get_us(void)
+{
+   u64 ticks;
+
+   /* FIXME: gd->arch.plic should contain valid base address */
+   ticks = andes_plmt_get_count(gd->arch.plic);
+   do_div(ticks, CONFIG_SYS_HZ);
+   return ticks;
+}
+#endif
+
 static int andes_plmt_probe(struct udevice *dev)
 {
dev->priv = dev_read_addr_ptr(dev);
if (!dev->priv)
return -EINVAL;
 
+   gd->arch.plic = dev->priv;
return timer_timebase_fallback(dev);
 }
 
diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c
index 21ae184057..7fa8773da3 100644
--- a/drivers/timer/riscv_timer.c
+++ b/drivers/timer/riscv_timer.c
@@ -15,8 +15,9 @@
 #include 
 #include 
 #include 
+#include 
 
-static u64 riscv_timer_get_count(struct udevice *dev)
+static u64 notrace riscv_timer_get_count(struct udevice *dev)
 {
__maybe_unused u32 hi, lo;
 
@@ -31,6 +32,17 @@ static u64 riscv_timer_get_count(struct udevice *dev)
return ((u64)hi << 32) | lo;
 }
 
+#if CONFIG_IS_ENABLED(RISCV_SMODE)
+unsigned long notrace timer_get_us(void)
+{
+   u64 ticks;
+
+   ticks = riscv_timer_get_count(NULL);
+   do_div(ticks, CONFIG_SYS_HZ);
+   return ticks;
+}
+#endif
+
 static int riscv_timer_probe(struct udevice *dev)
 {
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
diff --git a/drivers/timer/sifive_clint_timer.c 
b/drivers/timer/sifive_clint_timer.c
index 00ce0f08d6..166655e99d 100644
--- a/drivers/timer/sifive_clint_timer.c
+++ b/drivers/timer/sifive_clint_timer.c
@@ -10,11 +10,12 @@
 #include 
 #include 
 #include 
+#include 
 
 /* mtime register */
 #define MTIME_REG(base)((ulong)(base) + 0xbff8)
 
-static u64 sifive_clint_get_count(struct udevice *dev)
+static u64 notrace sifive_clint_get_count(struct udevice *dev)
 {
return readq((void __iomem *)MTIME_REG(dev->priv));
 }
@@ -23,12 +24,25 @@ static const struct timer_ops sifive_clint_ops = {
.get_count = sifive_clint_get_count,
 };
 
+#if CONFIG_IS_ENABLED(RISCV_MMODE)
+unsigned long notrace timer_get_us(void)
+{
+   u64 ticks;
+
+   /* FIXME: gd->arch.clint should contain valid base address */
+   ticks = sifive_clint_get_count(gd->arch.clint);
+   do_div(ticks, CONFIG_SYS_HZ);
+   return ticks;
+}
+#endif
+
 static int sifive_clint_probe(struct udevice *dev)
 {
dev->priv = dev_read_addr_ptr(dev);
if (!dev->priv)
return -EINVAL;
 
+   gd->arch.clint = dev->priv;
return timer_timebase_fallback(dev);
 }
 
-- 
2.17.1



Re: [RESEND PATCH 2/3] pinctrl: renesas: Make sure the pin type is updated after setting the MUX

2020-11-05 Thread Lad, Prabhakar
Hi Marek,

Thank you for the review.

On Wed, Nov 4, 2020 at 7:29 PM Marek Vasut  wrote:
>
> On 11/4/20 6:27 PM, Lad Prabhakar wrote:
> > Update pin type after every successful call to sh_pfc_config_mux().
> >
> > This fixes pin functionality from being overwritten.
>
> Can you please provide more details about the problem you are fixing
> here ? What is the problem ? What triggers it ?
>
By default on startup all the pin types are configured to
PINMUX_TYPE_NONE (in sh_pfc_map_pins()), when pin is set as GPIO the
pin type is updated to PINMUX_TYPE_GPIO. But the type is not updated
when the pin is set as a function in
sh_pfc_pinctrl_pin_set()/sh_pfc_pinctrl_group_set() calls (although
these calls have a check if pin type is not PINMUX_TYPE_NONE). So with
the current implementation suppose initially the pin is configured as
USB function and later as SPI function this driver does not complain
and makes USB unusable.

With this patch on every successful call to
sh_pfc_pinctrl_pin_set()/sh_pfc_pinctrl_group_set()  the pin type is
updated so that the functionality of the pin is not overwritten as
these functions already have the below check,

if (cfg->type != PINMUX_TYPE_NONE) {
  ret = -EBUSY;

Cheers,
Prabhakar


Re: [RFC] serial: pl01x: add sbsa-uart favor

2020-11-05 Thread Oleksandr Andrushchenko
Hi,

On 11/5/20 11:46 AM, AKASHI Takahiro wrote:
> Hi Oleksandr,
>
> On Thu, Nov 05, 2020 at 09:18:39AM +, Oleksandr Andrushchenko wrote:
>> Hello,
>>
>> On 11/4/20 7:24 AM, AKASHI Takahiro wrote:
>>> sbsa-uart is a virtual UART device with a sub-set of PL011 functionality
>>> which is described in SBSA (Server Base System Architecture)[1].
>>>
>>> It mainly targets for server use, but sbsa-uart itself is useful in any
>>> para-virtualized use cases, including Xen.
>>>
>>> At present, this patch is submitted as RFC because:
>>> * for some reason, data cache must be turned off (in initr_dcache())
>> Can it be because of data cache maintenance is required? Please see [1] for
>>
>> more details, just a key note from there (Julien Grall):
>>
>> "Per the hypercall ABI (see include/public/arch-arm.h) all the buffers must 
>> reside in memory which is mapped as Normal Inner Write-Back Inner-Shareable.
>> You are passing non-cacheable memory, so the behavior you see is expected."
> Please note that, as far as this patch is concerned, no hypervisor call
> is used. What is done here is that all the accesses to memory mapped
> sbsa-uart registers are trapped and emulated by the hypervisor (in my case,
> Xen's mmio handler).

The only reason I mentioned [1] is that I think it could be related to what you 
see,

e.g. you need to switch off D-cache completely which makes me think we violate 
the

ABI somehow

>
>> Thank you,
> BTW, what do you think of this patch?

It is good when it works with D-cache ON ;)

Thank you,

Oleksandr

>
> -Takahiro Akashi
>
>> Oleksandr
>>
>>> * there is a prerequisite patch for Xen[2]
>>>
>>> The patch with xenguest_arm64_defconfig was tested on upstream Xen and
>>> qemu-arm64.
>>> (To work with xenguest_arm64_defconfig, minor and non-essential tweaks
>>> are needed.)
>>>
>>> The output looks like:
>>> U-Boot 2021.01-rc1-5-g3b8e3cde5345 (Nov 04 2020 - 13:54:44 +0900) 
>>> xenguest
>>>
>>> Xen virtual CPU
>>> Model: XENVM-4.15
>>> DRAM:  128 MiB
>>> PVBLOCK: Failed to read device/vbd directory: ENOENT
>>>
>>> In:sbsa-pl011
>>> Out:   sbsa-pl011
>>> Err:   sbsa-pl011
>>> xenguest# dm tree
>>>Class Index  Probed  DriverName
>>> ---
>>>root  0  [ + ]   root_driver   root_driver
>>>firmware  0  [   ]   psci  |-- psci
>>>serial0  [ + ]   serial_pl01x  |-- sbsa-pl011
>>>pvblock   0  [   ]   pvblock   `-- pvblock
>>>
>>> [1] 
>>> https://urldefense.com/v3/__https://developer.arm.com/architectures/platform-design/server-systems__;!!GF_29dbcQIUBPA!k49FI4LUby7RffCuUHhIeq1ucvB2hhtch27HKXm3RBDLSY04ge4taCv7zqzDTat-6ZlDP1E68A$
>>>  [developer[.]arm[.]com]
>>> [2] 
>>> https://urldefense.com/v3/__https://lists.xenproject.org/archives/html/xen-devel/2020-10/msg02122.html__;!!GF_29dbcQIUBPA!k49FI4LUby7RffCuUHhIeq1ucvB2hhtch27HKXm3RBDLSY04ge4taCv7zqzDTat-6ZlHuV_0Rg$
>>>  [lists[.]xenproject[.]org]
>>>
>>> Signed-off-by: AKASHI Takahiro 
>>> ---
>>>drivers/serial/Kconfig  | 13 +++--
>>>drivers/serial/serial_pl01x.c   | 16 +---
>>>include/dm/platform_data/serial_pl01x.h |  1 +
>>>3 files changed, 25 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
>>> index b4805a2e4ea4..fb570174c577 100644
>>> --- a/drivers/serial/Kconfig
>>> +++ b/drivers/serial/Kconfig
>>> @@ -332,6 +332,15 @@ config DEBUG_UART_PL011
>>>   work. The driver will be available until the real driver model
>>>   serial is running.
>>>
>>> +config DEBUG_UART_SBSA
>>> +   bool "sbsa-uart"
>>> +   depends on PL01X_SERIAL
>>> +   help
>>> + Select this to enable a debug UART using the pl01x driver with the
>>> + SBSA_UART type. You will need to provide parameters to make this
>>> + work. The driver will be available until the real driver model
>>> + serial is running.
>>> +
>>>config DEBUG_UART_PIC32
>>> bool "Microchip PIC32"
>>> depends on PIC32_SERIAL
>>> @@ -415,7 +424,7 @@ config DEBUG_UART_BASE
>>>
>>>config DEBUG_UART_CLOCK
>>> int "UART input clock"
>>> -   depends on DEBUG_UART
>>> +   depends on DEBUG_UART && !DEBUG_UART_SBSA
>>> default 0 if DEBUG_UART_SANDBOX
>>> help
>>>   The UART input clock determines the speed of the internal UART
>>> @@ -427,7 +436,7 @@ config DEBUG_UART_CLOCK
>>>
>>>config DEBUG_UART_SHIFT
>>> int "UART register shift"
>>> -   depends on DEBUG_UART
>>> +   depends on DEBUG_UART && !DEBUG_UART_SBSA
>>> default 0 if DEBUG_UART
>>> help
>>>   Some UARTs (notably ns16550) support different register layouts
>>> diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
>>> index 2772c25f1d2d..5ef4ae0c6a65 100644
>>> --- a/drivers/serial/serial_pl01x.c
>>> +++ b/drivers/serial/serial_pl01x.c
>>> @@ -84,6 +84,8 @@ static int 

Re: [PATCH] riscv: Fix ax25-ae350 and qemu-riscv Kconfig dependency

2020-11-05 Thread Bin Meng
Hi Heinrich,

On Thu, Nov 5, 2020 at 4:55 PM Heinrich Schuchardt  wrote:
>
> On 05.11.20 09:16, Bin Meng wrote:
> > From: Bin Meng 
> >
> > SPL_RAM_SUPPORT and SPL_RAM_DEVICE are only visible in an SPL config.
>
> 'if SPL' would only be required if you would use 'select'. With 'imply'
> the Kconfig build system takes care of this dependency.

Yes, but I feel that adding a "if" seems to be express the dependency
explicitly to avoid confusions.

>
> My question was about CONFIG_RAM which is not selected on QEMU. But of
> cause you do not need a RAM driver on QEMU.
>

Correct.

> So I think you can drop this patch.
>

I am fine to drop this if there is no concern.

Regards,
Bin


Re: [RFC] serial: pl01x: add sbsa-uart favor

2020-11-05 Thread AKASHI Takahiro
Hi Oleksandr,

On Thu, Nov 05, 2020 at 09:18:39AM +, Oleksandr Andrushchenko wrote:
> Hello,
> 
> On 11/4/20 7:24 AM, AKASHI Takahiro wrote:
> > sbsa-uart is a virtual UART device with a sub-set of PL011 functionality
> > which is described in SBSA (Server Base System Architecture)[1].
> >
> > It mainly targets for server use, but sbsa-uart itself is useful in any
> > para-virtualized use cases, including Xen.
> >
> > At present, this patch is submitted as RFC because:
> > * for some reason, data cache must be turned off (in initr_dcache())
> 
> Can it be because of data cache maintenance is required? Please see [1] for
> 
> more details, just a key note from there (Julien Grall):
> 
> "Per the hypercall ABI (see include/public/arch-arm.h) all the buffers must 
> reside in memory which is mapped as Normal Inner Write-Back Inner-Shareable.
> You are passing non-cacheable memory, so the behavior you see is expected."

Please note that, as far as this patch is concerned, no hypervisor call
is used. What is done here is that all the accesses to memory mapped
sbsa-uart registers are trapped and emulated by the hypervisor (in my case,
Xen's mmio handler).

> Thank you,

BTW, what do you think of this patch?

-Takahiro Akashi

> Oleksandr
> 
> > * there is a prerequisite patch for Xen[2]
> >
> > The patch with xenguest_arm64_defconfig was tested on upstream Xen and
> > qemu-arm64.
> > (To work with xenguest_arm64_defconfig, minor and non-essential tweaks
> > are needed.)
> >
> > The output looks like:
> > U-Boot 2021.01-rc1-5-g3b8e3cde5345 (Nov 04 2020 - 13:54:44 +0900) 
> > xenguest
> >
> > Xen virtual CPU
> > Model: XENVM-4.15
> > DRAM:  128 MiB
> > PVBLOCK: Failed to read device/vbd directory: ENOENT
> >
> > In:sbsa-pl011
> > Out:   sbsa-pl011
> > Err:   sbsa-pl011
> > xenguest# dm tree
> >   Class Index  Probed  DriverName
> > ---
> >   root  0  [ + ]   root_driver   root_driver
> >   firmware  0  [   ]   psci  |-- psci
> >   serial0  [ + ]   serial_pl01x  |-- sbsa-pl011
> >   pvblock   0  [   ]   pvblock   `-- pvblock
> >
> > [1] 
> > https://urldefense.com/v3/__https://developer.arm.com/architectures/platform-design/server-systems__;!!GF_29dbcQIUBPA!k49FI4LUby7RffCuUHhIeq1ucvB2hhtch27HKXm3RBDLSY04ge4taCv7zqzDTat-6ZlDP1E68A$
> >  [developer[.]arm[.]com]
> > [2] 
> > https://urldefense.com/v3/__https://lists.xenproject.org/archives/html/xen-devel/2020-10/msg02122.html__;!!GF_29dbcQIUBPA!k49FI4LUby7RffCuUHhIeq1ucvB2hhtch27HKXm3RBDLSY04ge4taCv7zqzDTat-6ZlHuV_0Rg$
> >  [lists[.]xenproject[.]org]
> >
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >   drivers/serial/Kconfig  | 13 +++--
> >   drivers/serial/serial_pl01x.c   | 16 +---
> >   include/dm/platform_data/serial_pl01x.h |  1 +
> >   3 files changed, 25 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> > index b4805a2e4ea4..fb570174c577 100644
> > --- a/drivers/serial/Kconfig
> > +++ b/drivers/serial/Kconfig
> > @@ -332,6 +332,15 @@ config DEBUG_UART_PL011
> >   work. The driver will be available until the real driver model
> >   serial is running.
> >   
> > +config DEBUG_UART_SBSA
> > +   bool "sbsa-uart"
> > +   depends on PL01X_SERIAL
> > +   help
> > + Select this to enable a debug UART using the pl01x driver with the
> > + SBSA_UART type. You will need to provide parameters to make this
> > + work. The driver will be available until the real driver model
> > + serial is running.
> > +
> >   config DEBUG_UART_PIC32
> > bool "Microchip PIC32"
> > depends on PIC32_SERIAL
> > @@ -415,7 +424,7 @@ config DEBUG_UART_BASE
> >   
> >   config DEBUG_UART_CLOCK
> > int "UART input clock"
> > -   depends on DEBUG_UART
> > +   depends on DEBUG_UART && !DEBUG_UART_SBSA
> > default 0 if DEBUG_UART_SANDBOX
> > help
> >   The UART input clock determines the speed of the internal UART
> > @@ -427,7 +436,7 @@ config DEBUG_UART_CLOCK
> >   
> >   config DEBUG_UART_SHIFT
> > int "UART register shift"
> > -   depends on DEBUG_UART
> > +   depends on DEBUG_UART && !DEBUG_UART_SBSA
> > default 0 if DEBUG_UART
> > help
> >   Some UARTs (notably ns16550) support different register layouts
> > diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
> > index 2772c25f1d2d..5ef4ae0c6a65 100644
> > --- a/drivers/serial/serial_pl01x.c
> > +++ b/drivers/serial/serial_pl01x.c
> > @@ -84,6 +84,8 @@ static int pl01x_generic_serial_init(struct pl01x_regs 
> > *regs,
> > /* disable everything */
> > writel(0, >pl011_cr);
> > break;
> > +   case TYPE_SBSA_UART:
> > +   break;
> > default:
> > return -EINVAL;
> > }
> > @@ -146,7 +148,8 @@ static int pl01x_generic_setbrg(struct pl01x_regs 
> > *regs, 

[PATCH] km/common: remove CONFIG_MTD_CONCAT

2020-11-05 Thread Holger Brunck
This was used for a board which is not supproted anymore and can
therefore be dropped.

CC: Stefan Roese 
Signed-off-by: Holger Brunck 
---
 include/configs/km/keymile-common.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/configs/km/keymile-common.h 
b/include/configs/km/keymile-common.h
index c1968048a7..1bbc599adb 100644
--- a/include/configs/km/keymile-common.h
+++ b/include/configs/km/keymile-common.h
@@ -32,9 +32,6 @@
  */
 #define CONFIG_BOOTP_BOOTFILESIZE
 
-/* UBI Support for all Keymile boards */
-#define CONFIG_MTD_CONCAT
-
 #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
 #define CONFIG_KM_DEF_ENV_BOOTPARAMS \
"actual_bank=0\0"
-- 
2.26.0



Re: [RFC] serial: pl01x: add sbsa-uart favor

2020-11-05 Thread Oleksandr Andrushchenko
Hello,

On 11/4/20 7:24 AM, AKASHI Takahiro wrote:
> sbsa-uart is a virtual UART device with a sub-set of PL011 functionality
> which is described in SBSA (Server Base System Architecture)[1].
>
> It mainly targets for server use, but sbsa-uart itself is useful in any
> para-virtualized use cases, including Xen.
>
> At present, this patch is submitted as RFC because:
> * for some reason, data cache must be turned off (in initr_dcache())

Can it be because of data cache maintenance is required? Please see [1] for

more details, just a key note from there (Julien Grall):

"Per the hypercall ABI (see include/public/arch-arm.h) all the buffers must 
reside in memory which is mapped as Normal Inner Write-Back Inner-Shareable.
You are passing non-cacheable memory, so the behavior you see is expected."

Thank you,

Oleksandr

> * there is a prerequisite patch for Xen[2]
>
> The patch with xenguest_arm64_defconfig was tested on upstream Xen and
> qemu-arm64.
> (To work with xenguest_arm64_defconfig, minor and non-essential tweaks
> are needed.)
>
> The output looks like:
> U-Boot 2021.01-rc1-5-g3b8e3cde5345 (Nov 04 2020 - 13:54:44 +0900) xenguest
>
> Xen virtual CPU
> Model: XENVM-4.15
> DRAM:  128 MiB
> PVBLOCK: Failed to read device/vbd directory: ENOENT
>
> In:sbsa-pl011
> Out:   sbsa-pl011
> Err:   sbsa-pl011
> xenguest# dm tree
>   Class Index  Probed  DriverName
> ---
>   root  0  [ + ]   root_driver   root_driver
>   firmware  0  [   ]   psci  |-- psci
>   serial0  [ + ]   serial_pl01x  |-- sbsa-pl011
>   pvblock   0  [   ]   pvblock   `-- pvblock
>
> [1] 
> https://urldefense.com/v3/__https://developer.arm.com/architectures/platform-design/server-systems__;!!GF_29dbcQIUBPA!k49FI4LUby7RffCuUHhIeq1ucvB2hhtch27HKXm3RBDLSY04ge4taCv7zqzDTat-6ZlDP1E68A$
>  [developer[.]arm[.]com]
> [2] 
> https://urldefense.com/v3/__https://lists.xenproject.org/archives/html/xen-devel/2020-10/msg02122.html__;!!GF_29dbcQIUBPA!k49FI4LUby7RffCuUHhIeq1ucvB2hhtch27HKXm3RBDLSY04ge4taCv7zqzDTat-6ZlHuV_0Rg$
>  [lists[.]xenproject[.]org]
>
> Signed-off-by: AKASHI Takahiro 
> ---
>   drivers/serial/Kconfig  | 13 +++--
>   drivers/serial/serial_pl01x.c   | 16 +---
>   include/dm/platform_data/serial_pl01x.h |  1 +
>   3 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index b4805a2e4ea4..fb570174c577 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -332,6 +332,15 @@ config DEBUG_UART_PL011
> work. The driver will be available until the real driver model
> serial is running.
>   
> +config DEBUG_UART_SBSA
> + bool "sbsa-uart"
> + depends on PL01X_SERIAL
> + help
> +   Select this to enable a debug UART using the pl01x driver with the
> +   SBSA_UART type. You will need to provide parameters to make this
> +   work. The driver will be available until the real driver model
> +   serial is running.
> +
>   config DEBUG_UART_PIC32
>   bool "Microchip PIC32"
>   depends on PIC32_SERIAL
> @@ -415,7 +424,7 @@ config DEBUG_UART_BASE
>   
>   config DEBUG_UART_CLOCK
>   int "UART input clock"
> - depends on DEBUG_UART
> + depends on DEBUG_UART && !DEBUG_UART_SBSA
>   default 0 if DEBUG_UART_SANDBOX
>   help
> The UART input clock determines the speed of the internal UART
> @@ -427,7 +436,7 @@ config DEBUG_UART_CLOCK
>   
>   config DEBUG_UART_SHIFT
>   int "UART register shift"
> - depends on DEBUG_UART
> + depends on DEBUG_UART && !DEBUG_UART_SBSA
>   default 0 if DEBUG_UART
>   help
> Some UARTs (notably ns16550) support different register layouts
> diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
> index 2772c25f1d2d..5ef4ae0c6a65 100644
> --- a/drivers/serial/serial_pl01x.c
> +++ b/drivers/serial/serial_pl01x.c
> @@ -84,6 +84,8 @@ static int pl01x_generic_serial_init(struct pl01x_regs 
> *regs,
>   /* disable everything */
>   writel(0, >pl011_cr);
>   break;
> + case TYPE_SBSA_UART:
> + break;
>   default:
>   return -EINVAL;
>   }
> @@ -146,7 +148,8 @@ static int pl01x_generic_setbrg(struct pl01x_regs *regs, 
> enum pl01x_type type,
>   writel(UART_PL010_CR_UARTEN, >pl010_cr);
>   break;
>   }
> - case TYPE_PL011: {
> + case TYPE_PL011:
> + case TYPE_SBSA_UART: {
>   unsigned int temp;
>   unsigned int divider;
>   unsigned int remainder;
> @@ -171,6 +174,9 @@ static int pl01x_generic_setbrg(struct pl01x_regs *regs, 
> enum pl01x_type type,
>   writel(fraction, >pl011_fbrd);
>   }
>   
> + if (type == TYPE_SBSA_UART)
> + 

Re: [PATCH] remove obsolete option CONFIG_JFFS2_CMDLINE

2020-11-05 Thread Stefan Roese

On 05.11.20 10:15, Holger Brunck wrote:

This option is obsolete since 2009 and can be removed globally.

CC: Stefan Roese 
Signed-off-by: Holger Brunck 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  include/configs/ethernut5.h | 1 -
  include/configs/km/km-powerpc.h | 2 --
  include/configs/kmp204x.h   | 3 ---
  include/configs/pm9263.h| 1 -
  include/configs/stmark2.h   | 1 -
  scripts/config_whitelist.txt| 1 -
  6 files changed, 9 deletions(-)

diff --git a/include/configs/ethernut5.h b/include/configs/ethernut5.h
index b513b4bc68..ca249d9d2b 100644
--- a/include/configs/ethernut5.h
+++ b/include/configs/ethernut5.h
@@ -62,7 +62,6 @@
  
  /* JFFS2 */

  #ifdef CONFIG_CMD_JFFS2
-#define CONFIG_JFFS2_CMDLINE
  #define CONFIG_JFFS2_NAND
  #endif
  
diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h

index 7bfe12fecb..3be926c103 100644
--- a/include/configs/km/km-powerpc.h
+++ b/include/configs/km/km-powerpc.h
@@ -9,8 +9,6 @@
  
  /* Do boardspecific init for all boards */
  
-#define CONFIG_JFFS2_CMDLINE

-
  /* EEprom support 24C08, 24C16, 24C64 */
  #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
  #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3  /* 8 Byte write page */
diff --git a/include/configs/kmp204x.h b/include/configs/kmp204x.h
index ec1254e747..d1eb7b574b 100644
--- a/include/configs/kmp204x.h
+++ b/include/configs/kmp204x.h
@@ -337,9 +337,6 @@ int get_scl(void);
   * additionnal command line configuration.
   */
  
-/* we don't need flash support */

-#undef CONFIG_JFFS2_CMDLINE
-
  /*
   * For booting Linux, the board info and command line data
   * have to be in the first 64 MB of memory, since this is
diff --git a/include/configs/pm9263.h b/include/configs/pm9263.h
index 0ed4b1aaa2..6c882b6ff9 100644
--- a/include/configs/pm9263.h
+++ b/include/configs/pm9263.h
@@ -190,7 +190,6 @@
  
  #endif
  
-#define CONFIG_JFFS2_CMDLINE		1

  #define CONFIG_JFFS2_NAND 1
  #define CONFIG_JFFS2_DEV  "nand0" /* NAND device jffs2 lives on */
  #define CONFIG_JFFS2_PART_OFFSET  0   /* start of jffs2 partition */
diff --git a/include/configs/stmark2.h b/include/configs/stmark2.h
index d9a2f75e73..da162cbb11 100644
--- a/include/configs/stmark2.h
+++ b/include/configs/stmark2.h
@@ -49,7 +49,6 @@
  #define CONFIG_SYS_MCFRRTC_BASE   0xFC0A8000
  
  /* spi not partitions */

-#define CONFIG_JFFS2_CMDLINE
  #define CONFIG_JFFS2_DEV  "nor0"
  
  /* Timer */

diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index a9508448d4..be3a4b3e9a 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -848,7 +848,6 @@ CONFIG_IRAM_STACK
  CONFIG_IRAM_TOP
  CONFIG_IRDA_BASE
  CONFIG_IS_ENABLED
-CONFIG_JFFS2_CMDLINE
  CONFIG_JFFS2_DEV
  CONFIG_JFFS2_LZO
  CONFIG_JFFS2_NAND




Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


[PATCH] remove obsolete option CONFIG_JFFS2_CMDLINE

2020-11-05 Thread Holger Brunck
This option is obsolete since 2009 and can be removed globally.

CC: Stefan Roese 
Signed-off-by: Holger Brunck 
---
 include/configs/ethernut5.h | 1 -
 include/configs/km/km-powerpc.h | 2 --
 include/configs/kmp204x.h   | 3 ---
 include/configs/pm9263.h| 1 -
 include/configs/stmark2.h   | 1 -
 scripts/config_whitelist.txt| 1 -
 6 files changed, 9 deletions(-)

diff --git a/include/configs/ethernut5.h b/include/configs/ethernut5.h
index b513b4bc68..ca249d9d2b 100644
--- a/include/configs/ethernut5.h
+++ b/include/configs/ethernut5.h
@@ -62,7 +62,6 @@
 
 /* JFFS2 */
 #ifdef CONFIG_CMD_JFFS2
-#define CONFIG_JFFS2_CMDLINE
 #define CONFIG_JFFS2_NAND
 #endif
 
diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h
index 7bfe12fecb..3be926c103 100644
--- a/include/configs/km/km-powerpc.h
+++ b/include/configs/km/km-powerpc.h
@@ -9,8 +9,6 @@
 
 /* Do boardspecific init for all boards */
 
-#define CONFIG_JFFS2_CMDLINE
-
 /* EEprom support 24C08, 24C16, 24C64 */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS  3  /* 8 Byte write page */
diff --git a/include/configs/kmp204x.h b/include/configs/kmp204x.h
index ec1254e747..d1eb7b574b 100644
--- a/include/configs/kmp204x.h
+++ b/include/configs/kmp204x.h
@@ -337,9 +337,6 @@ int get_scl(void);
  * additionnal command line configuration.
  */
 
-/* we don't need flash support */
-#undef CONFIG_JFFS2_CMDLINE
-
 /*
  * For booting Linux, the board info and command line data
  * have to be in the first 64 MB of memory, since this is
diff --git a/include/configs/pm9263.h b/include/configs/pm9263.h
index 0ed4b1aaa2..6c882b6ff9 100644
--- a/include/configs/pm9263.h
+++ b/include/configs/pm9263.h
@@ -190,7 +190,6 @@
 
 #endif
 
-#define CONFIG_JFFS2_CMDLINE   1
 #define CONFIG_JFFS2_NAND  1
 #define CONFIG_JFFS2_DEV   "nand0" /* NAND device jffs2 lives on */
 #define CONFIG_JFFS2_PART_OFFSET   0   /* start of jffs2 partition */
diff --git a/include/configs/stmark2.h b/include/configs/stmark2.h
index d9a2f75e73..da162cbb11 100644
--- a/include/configs/stmark2.h
+++ b/include/configs/stmark2.h
@@ -49,7 +49,6 @@
 #define CONFIG_SYS_MCFRRTC_BASE0xFC0A8000
 
 /* spi not partitions */
-#define CONFIG_JFFS2_CMDLINE
 #define CONFIG_JFFS2_DEV   "nor0"
 
 /* Timer */
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index a9508448d4..be3a4b3e9a 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -848,7 +848,6 @@ CONFIG_IRAM_STACK
 CONFIG_IRAM_TOP
 CONFIG_IRDA_BASE
 CONFIG_IS_ENABLED
-CONFIG_JFFS2_CMDLINE
 CONFIG_JFFS2_DEV
 CONFIG_JFFS2_LZO
 CONFIG_JFFS2_NAND
-- 
2.26.0



[PATCH 18/18] global_data: Enable spl_handoff only if CONFIG_HANDOFF is set

2020-11-05 Thread Ovidiu Panait
spl_handoff should only be enabled when CONFIG_HANDOFF is set. Drop the
nested ifdefs and check for CONFIG_HANDOFF instead.

Signed-off-by: Ovidiu Panait 
---
 include/asm-generic/global_data.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index f392043796..fc6105ca8d 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -399,12 +399,12 @@ struct global_data {
 * @new_bloblist: relocated blob list information
 */
struct bloblist_hdr *new_bloblist;
-# ifdef CONFIG_SPL
+#endif
+#if CONFIG_IS_ENABLED(HANDOFF)
/**
 * @spl_handoff: SPL hand-off information
 */
struct spl_handoff *spl_handoff;
-# endif
 #endif
 #if defined(CONFIG_TRANSLATION_OFFSET)
/**
-- 
2.17.1



Re: [PATCH 2/9] board: ge: ppd: Update MAINTAINERS

2020-11-05 Thread Martyn Welch
On Wed, 2020-11-04 at 17:18 +0100, Sebastian Reichel wrote:
> This updates the PPD MAINTAINERS file doing a couple of changes:
> 
>  * Replace Martyn with myself, since he no longer has the hardware
>available and add Ian Ray as maintainer
>  * Fix the board directory path, which was still listing freescale/
>instead of ge/
>  * Order the list of files alphabetically
>  * Add board specific device tree files to the file list
> 
> Cc: Martyn Welch 
> Cc: Ian Ray 
> Signed-off-by: Sebastian Reichel 

Acked-by: Martyn Welch 

> ---
>  board/ge/mx53ppd/MAINTAINERS | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/board/ge/mx53ppd/MAINTAINERS
> b/board/ge/mx53ppd/MAINTAINERS
> index 9b64b5d3893a..2c06c8ee86c9 100644
> --- a/board/ge/mx53ppd/MAINTAINERS
> +++ b/board/ge/mx53ppd/MAINTAINERS
> @@ -1,7 +1,9 @@
> -MX53PPD BOARD
> +GE PPD BOARD
>  M:   Antti Mäentausta 
> -M:   Martyn Welch 
> +M:   Ian Ray 
> +M:   Sebastian Reichel 
>  S:   Maintained
> -F:   board/freescale/mx53ppd/
> -F:   include/configs/mx53ppd.h
> +F:   arch/arm/dts/imx53-ppd*
> +F:   board/ge/mx53ppd/
>  F:   configs/mx53ppd_defconfig
> +F:   include/configs/mx53ppd.h



[PATCH 15/18] common: board_r: Drop initr_bbmii wrapper

2020-11-05 Thread Ovidiu Panait
Add a return value to bb_miiphy_init and use it directly in the
post-relocation init sequence, rather than using a wrapper stub.

Signed-off-by: Ovidiu Panait 
---
 common/board_r.c   | 10 +-
 drivers/net/phy/miiphybb.c |  4 +++-
 include/miiphy.h   |  2 +-
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index b2d8331d6b..3ad4443c22 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -525,14 +525,6 @@ static int initr_scsi(void)
 }
 #endif
 
-#ifdef CONFIG_BITBANGMII
-static int initr_bbmii(void)
-{
-   bb_miiphy_init();
-   return 0;
-}
-#endif
-
 #ifdef CONFIG_CMD_NET
 static int initr_net(void)
 {
@@ -774,7 +766,7 @@ static init_fnc_t init_sequence_r[] = {
initr_scsi,
 #endif
 #ifdef CONFIG_BITBANGMII
-   initr_bbmii,
+   bb_miiphy_init,
 #endif
 #ifdef CONFIG_PCI_ENDPOINT
pci_ep_init,
diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c
index ba97a54c06..59a32c4913 100644
--- a/drivers/net/phy/miiphybb.c
+++ b/drivers/net/phy/miiphybb.c
@@ -105,7 +105,7 @@ int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
  sizeof(bb_miiphy_buses[0]);
 #endif
 
-void bb_miiphy_init(void)
+int bb_miiphy_init(void)
 {
int i;
 
@@ -124,6 +124,8 @@ void bb_miiphy_init(void)
bb_miiphy_buses[i].init(_miiphy_buses[i]);
}
}
+
+   return 0;
 }
 
 static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname)
diff --git a/include/miiphy.h b/include/miiphy.h
index 61c136b114..c166f54e36 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -81,7 +81,7 @@ struct bb_miiphy_bus {
 extern struct bb_miiphy_bus bb_miiphy_buses[];
 extern int bb_miiphy_buses_num;
 
-void bb_miiphy_init(void);
+int bb_miiphy_init(void);
 int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg);
 int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,
u16 value);
-- 
2.17.1



[PATCH 12/18] common: board_r: Drop initr_xen wrapper

2020-11-05 Thread Ovidiu Panait
Add a return value to xen_init and use it directly in the
post-relocation init sequence, rather than using a wrapper stub.

Signed-off-by: Ovidiu Panait 
---
 common/board_r.c | 10 +-
 drivers/xen/hypervisor.c |  4 +++-
 include/xen.h|  2 +-
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 7f69e59250..1cb9f13dc2 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -419,14 +419,6 @@ static int initr_mmc(void)
 }
 #endif
 
-#ifdef CONFIG_XEN
-static int initr_xen(void)
-{
-   xen_init();
-   return 0;
-}
-#endif
-
 #ifdef CONFIG_PVBLOCK
 static int initr_pvblock(void)
 {
@@ -734,7 +726,7 @@ static init_fnc_t init_sequence_r[] = {
initr_mmc,
 #endif
 #ifdef CONFIG_XEN
-   initr_xen,
+   xen_init,
 #endif
 #ifdef CONFIG_PVBLOCK
initr_pvblock,
diff --git a/drivers/xen/hypervisor.c b/drivers/xen/hypervisor.c
index 178c206f5b..2560894832 100644
--- a/drivers/xen/hypervisor.c
+++ b/drivers/xen/hypervisor.c
@@ -232,7 +232,7 @@ void clear_evtchn(uint32_t port)
synch_clear_bit(port, >evtchn_pending[0]);
 }
 
-void xen_init(void)
+int xen_init(void)
 {
debug("%s\n", __func__);
 
@@ -240,6 +240,8 @@ void xen_init(void)
init_events();
init_xenbus();
init_gnttab();
+
+   return 0;
 }
 
 void xen_fini(void)
diff --git a/include/xen.h b/include/xen.h
index a952a2c84b..868132156e 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -11,7 +11,7 @@
  * Map Xen memory pages, initialize event handler and xenbus,
  * setup the grant table.
  */
-void xen_init(void);
+int xen_init(void);
 
 /**
  * xen_fini() - Board cleanup before Linux kernel start
-- 
2.17.1



[PATCH 16/18] common: board_r: Drop arch-specific ifdefs around initr_trap

2020-11-05 Thread Ovidiu Panait
In order to remove the arch-specific ifdefs around initr_trap, introduce
arch_initr_trap weak initcall. Implementations for ppc/m68k/mips have
been moved to arch//lib/traps.c

Default implementation is a nop stub.

Signed-off-by: Ovidiu Panait 
---
 arch/m68k/lib/traps.c |  7 +++
 arch/mips/lib/traps.c |  7 +++
 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/traps.c  | 17 +
 common/board_r.c  | 16 ++--
 include/init.h|  9 +
 6 files changed, 43 insertions(+), 14 deletions(-)
 create mode 100644 arch/powerpc/lib/traps.c

diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
index c49141f376..a9b055cedf 100644
--- a/arch/m68k/lib/traps.c
+++ b/arch/m68k/lib/traps.c
@@ -59,3 +59,10 @@ void trap_init(ulong value) {
 
setvbr(value);  /* set vector base register to new table */
 }
+
+int arch_initr_trap(void)
+{
+   trap_init(CONFIG_SYS_SDRAM_BASE);
+
+   return 0;
+}
diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
index df8b63f383..4f2efd6115 100644
--- a/arch/mips/lib/traps.c
+++ b/arch/mips/lib/traps.c
@@ -131,3 +131,10 @@ void trap_restore(void)
clear_c0_status(ST0_BEV);
execution_hazard_barrier();
 }
+
+int arch_initr_trap(void)
+{
+   trap_init(CONFIG_SYS_SDRAM_BASE);
+
+   return 0;
+}
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index f61809ab05..2782740bf5 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -40,6 +40,7 @@ obj-y += interrupts.o
 obj-$(CONFIG_CMD_KGDB) += kgdb.o
 obj-y  += stack.o
 obj-y  += time.o
+obj-y  += traps.o
 endif # not minimal
 
 ifdef CONFIG_SPL_BUILD
diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c
new file mode 100644
index 00..80822a006a
--- /dev/null
+++ b/arch/powerpc/lib/traps.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ */
+
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int arch_initr_trap(void)
+{
+   trap_init(gd->relocaddr);
+
+   return 0;
+}
diff --git a/common/board_r.c b/common/board_r.c
index 3ad4443c22..927caf1eca 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -182,20 +182,10 @@ static int initr_reloc_global_data(void)
return 0;
 }
 
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
-static int initr_trap(void)
+__weak int arch_initr_trap(void)
 {
-   /*
-* Setup trap handlers
-*/
-#if defined(CONFIG_PPC)
-   trap_init(gd->relocaddr);
-#else
-   trap_init(CONFIG_SYS_SDRAM_BASE);
-#endif
return 0;
 }
-#endif
 
 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
 static int initr_unlock_ram_in_cache(void)
@@ -660,9 +650,7 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,
 #endif
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
-   initr_trap,
-#endif
+   arch_initr_trap,
 #ifdef CONFIG_ADDR_MAP
init_addr_map,
 #endif
diff --git a/include/init.h b/include/init.h
index 5519562163..232a021845 100644
--- a/include/init.h
+++ b/include/init.h
@@ -267,6 +267,15 @@ int board_early_init_r(void);
 /* TODO(s...@chromium.org): Drop this when DM_PCI migration is completed */
 void pci_init_board(void);
 
+/**
+ * arch_initr_trap() - Init traps
+ *
+ * Arch specific routine for initializing traps. It is called during the
+ * generic board init sequence, after relocation.
+ *
+ * Return: 0 if OK
+ */
+int arch_initr_trap(void);
 void trap_init(unsigned long reloc_addr);
 
 /**
-- 
2.17.1



[PATCH 17/18] spl: Kconfig: Add SPL dependency to CONFIG_HANDOFF

2020-11-05 Thread Ovidiu Panait
CONFIG_HANDOFF is used in u-boot proper to locate handoff info from SPL
during pre-relocation init (in setup_spl_handoff). Add explicit dependency
on CONFIG_SPL, to fix the following build error when CONFIG_HANDOFF &&
!CONFIG_SPL:

common/board_f.c: In function ‘setup_spl_handoff’:
common/board_f.c:283:4: error: ‘gd_t {aka struct global_data}’
has no member named ‘spl_handoff’
  gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
^~

Signed-off-by: Ovidiu Panait 
---
 common/spl/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index d8086bd9e8..cd980e96b8 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -117,7 +117,7 @@ endmenu
 
 config HANDOFF
bool "Pass hand-off information from SPL to U-Boot proper"
-   depends on BLOBLIST
+   depends on SPL && BLOBLIST
help
  It is useful to be able to pass information from SPL to U-Boot
  proper to preserve state that is known in SPL and is needed in U-Boot.
-- 
2.17.1



[PATCH 14/18] common: board_r: Drop initr_api wrapper

2020-11-05 Thread Ovidiu Panait
Add a return value to api_init and use it directly in the
post-relocation init sequence, rather than using a wrapper stub.

Signed-off-by: Ovidiu Panait 
---
 api/api.c |  6 --
 api/api_private.h |  2 +-
 common/board_r.c  | 11 +--
 include/api.h |  2 +-
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/api/api.c b/api/api.c
index 493b77f809..89003c161c 100644
--- a/api/api.c
+++ b/api/api.c
@@ -642,7 +642,7 @@ int syscall(int call, int *retval, ...)
return 1;
 }
 
-void api_init(void)
+int api_init(void)
 {
struct api_signature *sig;
 
@@ -679,7 +679,7 @@ void api_init(void)
sig = malloc(sizeof(struct api_signature));
if (sig == NULL) {
printf("API: could not allocate memory for the signature!\n");
-   return;
+   return -ENOMEM;
}
 
env_set_hex("api_address", (unsigned long)sig);
@@ -691,6 +691,8 @@ void api_init(void)
sig->checksum = crc32(0, (unsigned char *)sig,
  sizeof(struct api_signature));
debugf("syscall entry: 0x%lX\n", (unsigned long)sig->syscall);
+
+   return 0;
 }
 
 void platform_set_mr(struct sys_info *si, unsigned long start, unsigned long 
size,
diff --git a/api/api_private.h b/api/api_private.h
index 07fd50ad3a..bb23821c2c 100644
--- a/api/api_private.h
+++ b/api/api_private.h
@@ -8,7 +8,7 @@
 #ifndef _API_PRIVATE_H_
 #define _API_PRIVATE_H_
 
-void   api_init(void);
+intapi_init(void);
 void   platform_set_mr(struct sys_info *, unsigned long, unsigned long, int);
 intplatform_sys_info(struct sys_info *);
 
diff --git a/common/board_r.c b/common/board_r.c
index cb9b2424d1..b2d8331d6b 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -481,15 +481,6 @@ static int initr_malloc_bootparams(void)
 }
 #endif
 
-#if defined(CONFIG_API)
-static int initr_api(void)
-{
-   /* Initialize API */
-   api_init();
-   return 0;
-}
-#endif
-
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
 {
@@ -744,7 +735,7 @@ static init_fnc_t init_sequence_r[] = {
stdio_add_devices,
jumptable_init,
 #ifdef CONFIG_API
-   initr_api,
+   api_init,
 #endif
console_init_r, /* fully init console as a device */
 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
diff --git a/include/api.h b/include/api.h
index 84d81dc817..5370fd5d40 100644
--- a/include/api.h
+++ b/include/api.h
@@ -7,6 +7,6 @@
 #ifndef __API_H
 #define __API_H
 
-void api_init(void);
+int api_init(void);
 
 #endif
-- 
2.17.1



[PATCH 11/18] common: board_r: Drop initr_noncached wrapper

2020-11-05 Thread Ovidiu Panait
Add a return value to noncached_init and use it directly in the
post-relocation init sequence, rather than using a wrapper stub.

Signed-off-by: Ovidiu Panait 
---
 arch/arm/include/asm/system.h |  2 +-
 arch/arm/lib/cache.c  |  4 +++-
 common/board_r.c  | 10 +-
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index ce552944b7..fb059c4588 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -628,7 +628,7 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, 
size_t size,
 enum dcache_option option);
 
 #ifdef CONFIG_SYS_NONCACHED_MEMORY
-void noncached_init(void);
+int noncached_init(void);
 phys_addr_t noncached_alloc(size_t size, size_t align);
 #endif /* CONFIG_SYS_NONCACHED_MEMORY */
 
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index ee7d14b2d3..bdde9cdad5 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -86,7 +86,7 @@ void noncached_set_region(void)
 #endif
 }
 
-void noncached_init(void)
+int noncached_init(void)
 {
phys_addr_t start, end;
size_t size;
@@ -103,6 +103,8 @@ void noncached_init(void)
noncached_next = start;
 
noncached_set_region();
+
+   return 0;
 }
 
 phys_addr_t noncached_alloc(size_t size, size_t align)
diff --git a/common/board_r.c b/common/board_r.c
index 964f3df918..7f69e59250 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -233,14 +233,6 @@ static int initr_malloc(void)
return 0;
 }
 
-#ifdef CONFIG_SYS_NONCACHED_MEMORY
-static int initr_noncached(void)
-{
-   noncached_init();
-   return 0;
-}
-#endif
-
 static int initr_of_live(void)
 {
if (CONFIG_IS_ENABLED(OF_LIVE)) {
@@ -659,7 +651,7 @@ static init_fnc_t init_sequence_r[] = {
console_record_init,
 #endif
 #ifdef CONFIG_SYS_NONCACHED_MEMORY
-   initr_noncached,
+   noncached_init,
 #endif
initr_of_live,
 #ifdef CONFIG_DM
-- 
2.17.1



[PATCH 13/18] common: board_r: Drop initr_jumptable wrapper

2020-11-05 Thread Ovidiu Panait
Add a return value to jumptable_init and use it directly in the
post-relocation init sequence, rather than using a wrapper stub.

Signed-off-by: Ovidiu Panait 
---
 common/board_r.c  | 8 +---
 common/exports.c  | 4 +++-
 include/exports.h | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 1cb9f13dc2..cb9b2424d1 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -481,12 +481,6 @@ static int initr_malloc_bootparams(void)
 }
 #endif
 
-static int initr_jumptable(void)
-{
-   jumptable_init();
-   return 0;
-}
-
 #if defined(CONFIG_API)
 static int initr_api(void)
 {
@@ -748,7 +742,7 @@ static init_fnc_t init_sequence_r[] = {
pci_init,
 #endif
stdio_add_devices,
-   initr_jumptable,
+   jumptable_init,
 #ifdef CONFIG_API
initr_api,
 #endif
diff --git a/common/exports.c b/common/exports.c
index 6253b55694..4578f07021 100644
--- a/common/exports.c
+++ b/common/exports.c
@@ -25,8 +25,10 @@ unsigned long get_version(void)
 # define miiphy_set_current_devdummy
 #endif
 
-void jumptable_init(void)
+int jumptable_init(void)
 {
gd->jt = malloc(sizeof(struct jt_funcs));
 #include <_exports.h>
+
+   return 0;
 }
diff --git a/include/exports.h b/include/exports.h
index b300554091..be13c771a4 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -16,7 +16,7 @@ struct cmd_tbl;
 struct spi_slave;
 
 /* Set up the jump table for use by the API */
-void jumptable_init(void);
+int jumptable_init(void);
 
 /* These are declarations of exported functions available in C code */
 unsigned long get_version(void);
-- 
2.17.1



  1   2   >