Skip to contentSkip to conversation

Support to run U-Boot on sc7180 Trogdor Chromebooks

PATCH In review Stephen Boyd 3 participants 38 messages May 23, 2025 – Jul 1, 2025 1 message not in the archive

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

v4 cover Support to run U-Boot on sc7180 Trogdor Chromebooks

This series supports running U-Boot as a payload on sc7180 Trogdor Chromebooks like Lazor or Wormdingler. This is a jumble of different patches to get to the final goal of booting a Linux distro from the eMMC on Lazor. I'm able to boot Fedora Workstation 41 from a USB stick on my Lazor.

I moved the reviewed patch to the start. After that one line fix there's a few patches to add support for the particular SoC used on Trogdor devices, sc7180. The next set of patches move the coreboot logic out of arch/x86/ into lib/ to find the coreboot tables on ARM and stash them in global data. Then I have a handful of patches to let the coreboot commands and utilities parse and populate various things like pstore and firmware details into the DTB with the proper data from the coreboot tables. Finally, I add the calls to coreboot dram parsing code in the snapdragon board so that if coreboot tables exist we get the memory info from coreboot instead of from an earlier stage DTB.

I tested the SPI driver with the crosec command. The cros bootflow method almost works, but it seems like chromeos userspace blows up spectacularly likely because crossystem can't figure out what board it is running on. I don't really care too much about booting chromeos userspace here so I'm ignoring that problem.

I'm able to install fedora on Lazor with this as long as I start the USB with CONFIG_PREBOOT=y. I tried to get this working on SC7280 Hoglin but it crashed in Fedora. I'm not sure why but it could be because the memory stuff was all wrong. Either way I hope it may work in the near future.

The display is almost there but I suspect I'll need to do the whole initialization all over again so I punted for now.

TODO:
* Get display working
* Implement FIT FDT picking similar to depthcharge based on coreboot tables indicating the SKU and board id

Changes from v3 https://lore.kernel.org/r/[email protected]
* GPIO chipselect in the SPI driver support
* sc7280 clk driver support for UART
* Enable the UART clk at probe
* Read VPD and inject the wifi MAC address
* Patch to inject wifi MAC from the environment
* Add a debug_board_init routine for trogdor to support early debug
* Add a defconfig

Changes from v2 https://lore.kernel.org/r/[email protected]
* Check SPI proto in probe
* Handle pins differently in pinctrl driver
* Pick up tags
* Rebase to ToT
* Update pinctrl driver for new changes in last few months
* Add some more gates to clk driver to handle missing clk warnings
* New patch to locate coreboot tables early

Changes from v1 https://lore.kernel.org/r/[email protected]
* Add Kconfig file in lib/coreboot/ to hold the coreboot config stuff similar to EFI
* Couple new patches for ximg to support extracting the FDT from chromeos kernel partitions
* Move the timestamp file out of arch/x86 as well in a different patch

Stephen Boyd (28):
bootstd: cros: Return negative error code
clk: qcom: Add driver for sc7180
clk/stub: Add sc7180-rpmh clock
clk: qcom: Support uart clk on sc7280 CRD
pinctrl: qcom: Add driver for sc7180
spi: Add Qualcomm GENI SPI driver
serial: msm-geni: Enable SE clk in probe
coreboot: Move coreboot logic out of x86 to a generic place
coreboot: Set gd->ram_base when parsing tables
coreboot: Locate table earlier than arch_cpu_init()
arm: Support running U-Boot as a coreboot payload on ARM64 cmd/cbsysinfo: Skip the CMOS 'option_table' when not present cmd/cbsysinfo: Allow on ARM as well
coreboot: Parse sku_id/fw_config from coreboot tables
pstore: Add pstore address from coreboot tables
coreboot: Add /firmware/coreboot node to DT
coreboot: Move timestamp parsing to generic place
coreboot: Dump VPD information in cbsysinfo command
coreboot: Set serial# from VPD
coreboot: Set wifi mac addr from VPD
fdt: Populate wifi MAC from environment
mach-snapdragon: Support booting as a coreboot payload
mach-snapdragon: Allow usb3 to work when a coreboot payload
board: google: Add board_debug_uart_init() for Trogdor
cmd: ximg: Support LZO compressed images
cmd: ximg: Support LZ4 compressed images
configs: Add chromebook_trogdor defconfig
doc: chromebook_trogdor: Add document detailing installation steps

 arch/arm/cpu/armv8/Makefile                   |   1 +
 arch/arm/cpu/armv8/coreboot/Makefile          |   4 +
 arch/arm/cpu/armv8/coreboot/cpu.c             |  22 +
 arch/arm/include/asm/global_data.h            |   3 +
 arch/arm/mach-snapdragon/board.c              |  23 +
 arch/arm/mach-snapdragon/of_fixup.c           |  22 +-
 arch/x86/Kconfig                              |  22 -
 arch/x86/cpu/coreboot/Kconfig                 |  33 -
 arch/x86/cpu/coreboot/Makefile                |   1 -
 arch/x86/cpu/coreboot/coreboot.c              |  16 +-
 arch/x86/cpu/coreboot/sdram.c                 |  78 +--
 arch/x86/cpu/cpu.c                            |  15 +-
 arch/x86/cpu/i386/cpu.c                       |   2 +-
 arch/x86/lib/bootm.c                          |   5 +-
 arch/x86/lib/coreboot/Makefile                |   1 -
 arch/x86/lib/coreboot/cb_support.c            |   2 +-
 arch/x86/lib/coreboot_table.c                 |   2 +-
 arch/x86/lib/tables.c                         |   2 +-
 arch/x86/lib/zimage.c                         |   3 -
 board/coreboot/coreboot/coreboot.c            |   2 +-
 board/coreboot/coreboot/sysinfo.c             |   2 +-
 board/google/chromebook_coral/coral.c         |   2 +-
 board/google/trogdor/Makefile                 |   3 +
 board/google/trogdor/debug.config             |   6 +
 board/google/trogdor/debug_uart.c             |  41 ++
 boot/Kconfig                                  |   1 +
 boot/bootmeth_cros.c                          |   2 +-
 boot/expo_build_cb.c                          |   2 +-
 boot/fdt_support.c                            |  54 +-
 boot/image-fdt.c                              |   4 +
 cmd/Kconfig                                   |   4 +-
 cmd/Makefile                                  |   1 +
 cmd/{x86 => }/cbsysinfo.c                     |  40 +-
 cmd/pstore.c                                  |  51 +-
 cmd/version.c                                 |   2 +-
 cmd/x86/Makefile                              |   1 -
 cmd/x86/cbcmos.c                              |   2 +-
 cmd/ximg.c                                    |  28 +
 common/board_f.c                              |   4 +
 configs/chromebook_trogdor_defconfig          | 138 +++++
 doc/board/google/chromebook_trogdor.rst       |  69 +++
 doc/board/google/index.rst                    |   1 +
 drivers/clk/clk-stub.c                        |   1 +
 drivers/clk/qcom/Kconfig                      |   8 +
 drivers/clk/qcom/Makefile                     |   1 +
 drivers/clk/qcom/clock-sc7180.c               | 153 +++++
 drivers/clk/qcom/clock-sc7280.c               |  22 +
 drivers/misc/cbmem_console.c                  |   2 +-
 drivers/pinctrl/qcom/Kconfig                  |   8 +
 drivers/pinctrl/qcom/Makefile                 |   1 +
 drivers/pinctrl/qcom/pinctrl-sc7180.c         | 133 ++++
 drivers/serial/serial_coreboot.c              |   2 +-
 drivers/serial/serial_msm_geni.c              |  26 +-
 drivers/spi/Kconfig                           |  10 +
 drivers/spi/Makefile                          |   1 +
 drivers/spi/spi-geni-qcom.c                   | 569 ++++++++++++++++++
 drivers/video/coreboot.c                      |   2 +-
 .../x86/include/asm => include}/cb_sysinfo.h  |  51 +-
 .../include/asm => include}/coreboot_tables.h |  24 +
 .../coreboot_timestamp.h                      |   9 +-
 lib/Makefile                                  |   2 +
 lib/coreboot/Kconfig                          |  55 ++
 {arch/x86/cpu => lib}/coreboot/Makefile       |  11 +-
 {arch/x86/lib => lib}/coreboot/cb_sysinfo.c   | 288 ++++++++-
 {arch/x86/cpu => lib}/coreboot/sdram.c        |  25 +-
 {arch/x86/cpu => lib}/coreboot/timestamp.c    |  15 +-
 66 files changed, 1863 insertions(+), 273 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/coreboot/Makefile
 create mode 100644 arch/arm/cpu/armv8/coreboot/cpu.c
 delete mode 100644 arch/x86/cpu/coreboot/Kconfig
 create mode 100644 board/google/trogdor/Makefile
 create mode 100644 board/google/trogdor/debug.config
 create mode 100644 board/google/trogdor/debug_uart.c
 rename cmd/{x86 => }/cbsysinfo.c (93%)
 create mode 100644 configs/chromebook_trogdor_defconfig
 create mode 100644 doc/board/google/chromebook_trogdor.rst
 create mode 100644 drivers/clk/qcom/clock-sc7180.c
 create mode 100644 drivers/pinctrl/qcom/pinctrl-sc7180.c
 create mode 100644 drivers/spi/spi-geni-qcom.c
 rename {arch/x86/include/asm => include}/cb_sysinfo.h (86%)
 rename {arch/x86/include/asm => include}/coreboot_tables.h (96%)
 rename arch/x86/include/asm/arch-coreboot/timestamp.h => include/coreboot_timestamp.h (63%)
 create mode 100644 lib/coreboot/Kconfig
 copy {arch/x86/cpu => lib}/coreboot/Makefile (71%)
 rename {arch/x86/lib => lib}/coreboot/cb_sysinfo.c (62%)
 copy {arch/x86/cpu => lib}/coreboot/sdram.c (84%)
 rename {arch/x86/cpu => lib}/coreboot/timestamp.c (83%)

base-commit: 9d3f1ebaf8751f0287b5d02158cc706435f8fb19

Signature · 1 line
Sent by a computer, using git, on the internet
#1 lore raw

PATCH v4 1/28 bootstd: cros: Return negative error code

This should be negative EFAULT to indicate an error code.

---
 boot/bootmeth_cros.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boot/bootmeth_cros.c +1 -1
index c7b862e512a0..d4c4ed328bd0 100644
@@ -340,7 +340,7 @@ static int cros_read_kernel(struct bootflow *bflow)
 
 	/* Check that the header is not smaller than permitted */
 	if (priv->body_offset < PROBE_SIZE)
-		return log_msg_ret("san", EFAULT);
+		return log_msg_ret("san", -EFAULT);
 
 	/* Read kernel body */
 	num_blks = priv->body_size >> desc->log2blksz;
Signature · 1 line
Sent by a computer, using git, on the internet
#2 lore raw

PATCH v4 2/28 clk: qcom: Add driver for sc7180

In reply to Stephen Boyd

The clks are already configured properly by coreboot on sc7180, but this is good enough to make the MMC and USB drivers work.

---
 drivers/clk/qcom/Kconfig        |   8 ++
 drivers/clk/qcom/Makefile       |   1 +
 drivers/clk/qcom/clock-sc7180.c | 153 ++++++++++++++++++++++++++++++++
 3 files changed, 162 insertions(+)
 create mode 100644 drivers/clk/qcom/clock-sc7180.c
drivers/clk/qcom/Kconfig +8 -0
index 3ea01f3c969a..f310fd0d78f6 100644
@@ -111,6 +111,14 @@ config CLK_QCOM_SM8650
 	  on the Snapdragon SM8650 SoC. This driver supports the clocks
 	  and resets exposed by the GCC hardware block.
 
+config CLK_QCOM_SC7180
+	bool "Qualcomm SC7180 GCC"
+	select CLK_QCOM
+	help
+	  Say Y here to enable support for the Global Clock Controller
+	  on the Snapdragon SC7180 SoC. This driver supports the clocks
+	  and resets exposed by the GCC hardware block.
+
 config CLK_QCOM_SC7280
 	bool "Qualcomm SC7280 GCC"
 	select CLK_QCOM
drivers/clk/qcom/Makefile +1 -0
index e13fc8c10717..ddca98950d47 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_CLK_QCOM_IPQ9574) += clock-ipq9574.o
 obj-$(CONFIG_CLK_QCOM_QCM2290) += clock-qcm2290.o
 obj-$(CONFIG_CLK_QCOM_QCS404) += clock-qcs404.o
 obj-$(CONFIG_CLK_QCOM_SA8775P) += clock-sa8775p.o
+obj-$(CONFIG_CLK_QCOM_SC7180) += clock-sc7180.o
 obj-$(CONFIG_CLK_QCOM_SC7280) += clock-sc7280.o
 obj-$(CONFIG_CLK_QCOM_SM6115) += clock-sm6115.o
 obj-$(CONFIG_CLK_QCOM_SM8150) += clock-sm8150.o
drivers/clk/qcom/clock-sc7180.c new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
Sent by a computer, using git, on the internet
#3 lore raw

PATCH v4 3/28 clk/stub: Add sc7180-rpmh clock

In reply to Stephen Boyd

Stub the RPMh clock controller on SC7180

---
 drivers/clk/clk-stub.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/clk-stub.c +1 -0
index 5f5aca41d5b3..23670c2f4425 100644
@@ -51,6 +51,7 @@ static struct clk_ops stub_clk_ops = {
 static const struct udevice_id stub_clk_ids[] = {
 	{ .compatible = "qcom,rpmcc" },
 	{ .compatible = "qcom,sdm845-rpmh-clk" },
+	{ .compatible = "qcom,sc7180-rpmh-clk" },
 	{ .compatible = "qcom,sc7280-rpmh-clk" },
 	{ .compatible = "qcom,sm8150-rpmh-clk" },
 	{ .compatible = "qcom,sm8250-rpmh-clk" },
Signature · 1 line
Sent by a computer, using git, on the internet
#4 lore raw

PATCH v4 4/28 clk: qcom: Support uart clk on sc7280 CRD

In reply to Stephen Boyd

Support setting the frequency of the UART clk on sc7280 so that the serial console works on devices like hoglin.

---
 drivers/clk/qcom/clock-sc7280.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clk/qcom/clock-sc7280.c +22 -0
index 9aff8a847ad1..b9152c129df1 100644
@@ -38,6 +38,22 @@ static const struct freq_tbl ftbl_gcc_usb30_sec_master_clk_src[] = {
 	{ }
 };
 
+static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s2_clk_src[] = {
+        F(7372800, CFG_CLK_SRC_GPLL0_EVEN, 1, 384, 15625),
+        F(14745600, CFG_CLK_SRC_GPLL0_EVEN, 1, 768, 15625),
+        F(19200000, CFG_CLK_SRC_CXO, 1, 0, 0),
+        F(29491200, CFG_CLK_SRC_GPLL0_EVEN, 1, 1536, 15625),
+        F(32000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 75),
+        F(48000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 25),
+        F(52174000, CFG_CLK_SRC_GPLL0, 1, 2, 23),
+        F(64000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 16, 75),
+        F(75000000, CFG_CLK_SRC_GPLL0_EVEN, 4, 0, 0),
+        F(80000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 15),
+        F(96000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 25),
+        F(100000000, CFG_CLK_SRC_GPLL0, 6, 0, 0),
+        { }
+};
+
 static ulong sc7280_set_rate(struct clk *clk, ulong rate)
 {
 	struct msm_clk_priv *priv = dev_get_priv(clk->dev);
@@ -47,6 +63,11 @@ static ulong sc7280_set_rate(struct clk *clk, ulong rate)
 		debug("%s: %s, requested rate=%ld\n", __func__, priv->data->clks[clk->id].name, rate);
 
 	switch (clk->id) {
+	case GCC_QUPV3_WRAP0_S5_CLK: /* UART5 */
+		freq = qcom_find_freq(ftbl_gcc_qupv3_wrap0_s2_clk_src, rate);
+		clk_rcg_set_rate_mnd(priv->base, 0x17600,
+				     freq->pre_div, freq->m, freq->n, freq->src, 16);
+		return freq->freq;
 	case GCC_USB30_PRIM_MASTER_CLK:
 		freq = qcom_find_freq(ftbl_gcc_usb30_prim_master_clk_src, rate);
 		clk_rcg_set_rate_mnd(priv->base, USB30_PRIM_MASTER_CLK_CMD_RCGR,
@@ -107,6 +128,7 @@ static const struct gate_clk sc7280_clks[] = {
 	GATE_CLK(GCC_QUPV3_WRAP0_S0_CLK, 0x52008, BIT(10)),
 	GATE_CLK(GCC_QUPV3_WRAP0_S1_CLK, 0x52008, BIT(11)),
 	GATE_CLK(GCC_QUPV3_WRAP0_S3_CLK, 0x52008, BIT(13)),
+	GATE_CLK(GCC_QUPV3_WRAP0_S5_CLK, 0x52008, BIT(15)),
 	GATE_CLK(GCC_UFS_PHY_AXI_CLK, 0x77010, BIT(0)),
 	GATE_CLK(GCC_AGGRE_UFS_PHY_AXI_CLK, 0x770cc, BIT(0)),
 	GATE_CLK(GCC_UFS_PHY_AHB_CLK, 0x77018, BIT(0)),
Signature · 1 line
Sent by a computer, using git, on the internet
#5 lore raw

Re: [PATCH v4 04/28] clk: qcom: Support uart clk on sc7280 CRD

Quoted 20 lines · Stephen Boyd

Support setting the frequency of the UART clk on sc7280 so that the serial console works on devices like hoglin.

---
  drivers/clk/qcom/clock-sc7280.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
drivers/clk/qcom/clock-sc7280.c +4 -0
index 9aff8a847ad1..b9152c129df1 100644
@@ -38,6 +38,22 @@ static const struct freq_tbl ftbl_gcc_usb30_sec_master_clk_src[] = {
  	{ }
  };
 
+static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s2_clk_src[] = {
+        F(7372800, CFG_CLK_SRC_GPLL0_EVEN, 1, 384, 15625),
+        F(14745600, CFG_CLK_SRC_GPLL0_EVEN, 1, 768, 15625),
+        F(19200000, CFG_CLK_SRC_CXO, 1, 0, 0),

drivers/clk/qcom/clock-sc7280.c static const struct freq_tbl ftbl_gcc_usb30_sec_master_clk_src[] = { · line 54

Quoted 10 lines
drivers/clk/qcom/clock-sc7280.c +10 -0
+        F(29491200, CFG_CLK_SRC_GPLL0_EVEN, 1, 1536, 15625),
+        F(32000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 75),
+        F(48000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 25),
+        F(52174000, CFG_CLK_SRC_GPLL0, 1, 2, 23),
+        F(64000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 16, 75),
+        F(75000000, CFG_CLK_SRC_GPLL0_EVEN, 4, 0, 0),
+        F(80000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 15),
+        F(96000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 25),
+        F(100000000, CFG_CLK_SRC_GPLL0, 6, 0, 0),
+        { }

FYI your formatting got messed up here and it's indented with spaces. I'll fix it up while applying.

Quoted 25 lines
drivers/clk/qcom/clock-sc7280.c +8 -0
+};
+
  static ulong sc7280_set_rate(struct clk *clk, ulong rate)
  {
  	struct msm_clk_priv *priv = dev_get_priv(clk->dev);
@@ -47,6 +63,11 @@ static ulong sc7280_set_rate(struct clk *clk, ulong rate)
  		debug("%s: %s, requested rate=%ld\n", __func__, priv->data->clks[clk->id].name, rate);
 
  	switch (clk->id) {
+	case GCC_QUPV3_WRAP0_S5_CLK: /* UART5 */
+		freq = qcom_find_freq(ftbl_gcc_qupv3_wrap0_s2_clk_src, rate);
+		clk_rcg_set_rate_mnd(priv->base, 0x17600,
+				     freq->pre_div, freq->m, freq->n, freq->src, 16);
+		return freq->freq;
  	case GCC_USB30_PRIM_MASTER_CLK:
  		freq = qcom_find_freq(ftbl_gcc_usb30_prim_master_clk_src, rate);
  		clk_rcg_set_rate_mnd(priv->base, USB30_PRIM_MASTER_CLK_CMD_RCGR,
@@ -107,6 +128,7 @@ static const struct gate_clk sc7280_clks[] = {
  	GATE_CLK(GCC_QUPV3_WRAP0_S0_CLK, 0x52008, BIT(10)),
  	GATE_CLK(GCC_QUPV3_WRAP0_S1_CLK, 0x52008, BIT(11)),
  	GATE_CLK(GCC_QUPV3_WRAP0_S3_CLK, 0x52008, BIT(13)),
+	GATE_CLK(GCC_QUPV3_WRAP0_S5_CLK, 0x52008, BIT(15)),
  	GATE_CLK(GCC_UFS_PHY_AXI_CLK, 0x77010, BIT(0)),
  	GATE_CLK(GCC_AGGRE_UFS_PHY_AXI_CLK, 0x770cc, BIT(0)),
  	GATE_CLK(GCC_UFS_PHY_AHB_CLK, 0x77018, BIT(0)),
Signature · 1 line
Casey (she/they)
#6 lore raw

PATCH v4 5/28 pinctrl: qcom: Add driver for sc7180

In reply to Stephen Boyd

Add a driver for Qualcomm's sc7180 pinctrl device (TLMM). This is largely a copy of a similar driver in U-Boot along with reference to the Linux driver to fix up the data properly.

---
 drivers/pinctrl/qcom/Kconfig          |   8 ++
 drivers/pinctrl/qcom/Makefile         |   1 +
 drivers/pinctrl/qcom/pinctrl-sc7180.c | 133 ++++++++++++++++++++++++++
 3 files changed, 142 insertions(+)
 create mode 100644 drivers/pinctrl/qcom/pinctrl-sc7180.c
drivers/pinctrl/qcom/Kconfig +8 -0
index e567cb113a31..0617443d4db0 100644
@@ -55,11 +55,19 @@ config PINCTRL_QCOM_SA8775P
 	  Say Y here to enable support for pinctrl on the Snapdragon SA8775P SoC,
 	  as well as the associated GPIO driver.
 
+config PINCTRL_QCOM_SC7180
+	bool "Qualcomm SC7180 Pinctrl"
+	select PINCTRL_QCOM
+	help
+	  Say Y here to enable support for pinctrl on the Snapdragon SC7180 SoC,
+	  as well as the associated GPIO driver.
+
 config PINCTRL_QCOM_SC7280
 	bool "Qualcomm SC7280/QCM6490 Pinctrl"
 	select PINCTRL_QCOM
 	help
 	  Say Y here to enable support for pinctrl on the Snapdragon SC7280 SoC,
+	  as well as the associated GPIO driver.
 
 config PINCTRL_QCOM_SDM660
 	bool "Qualcomm SDM630/660 Pinctrl"
drivers/pinctrl/qcom/Makefile +1 -0
index 6ffc6d48c155..8e3e377fa184 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_PINCTRL_QCOM_APQ8096) += pinctrl-apq8096.o
 obj-$(CONFIG_PINCTRL_QCOM_QCM2290) += pinctrl-qcm2290.o
 obj-$(CONFIG_PINCTRL_QCOM_QCS404) += pinctrl-qcs404.o
 obj-$(CONFIG_PINCTRL_QCOM_SA8775P) += pinctrl-sa8775p.o
+obj-$(CONFIG_PINCTRL_QCOM_SC7180) += pinctrl-sc7180.o
 obj-$(CONFIG_PINCTRL_QCOM_SC7280) += pinctrl-sc7280.o
 obj-$(CONFIG_PINCTRL_QCOM_SDM660) += pinctrl-sdm660.o
 obj-$(CONFIG_PINCTRL_QCOM_SDM845) += pinctrl-sdm845.o
drivers/pinctrl/qcom/pinctrl-sc7180.c new file +133 -0

133 lines not on this page · raw message

Signature · 1 line
Sent by a computer, using git, on the internet
#7 lore raw

PATCH v4 6/28 spi: Add Qualcomm GENI SPI driver

In reply to Stephen Boyd

Add a SPI driver for Qualcomm's GENI hardware.

---
 drivers/spi/Kconfig         |  10 +
 drivers/spi/Makefile        |   1 +
 drivers/spi/spi-geni-qcom.c | 569 ++++++++++++++++++++++++++++++++++++
 3 files changed, 580 insertions(+)
 create mode 100644 drivers/spi/spi-geni-qcom.c
drivers/spi/Kconfig +10 -0
index a3513f0a3ef8..9bdfc4c89204 100644
@@ -430,6 +430,16 @@ config SPI_QUP
 	  mode supports up to 50MHz, up to four chip selects, programmable
 	  data path from 4 bits to 32 bits and numerous protocol variants.
 
+config SPI_GENI_QCOM
+	bool "Qualcomm Generic Interface (GENI) SPI controller"
+	depends on ARCH_SNAPDRAGON
+	help
+	  Support for the Qualcomm Generic Interface (GENI) SPI controller.
+	  The Generic Interface (GENI) is a firmware based Qualcomm Universal
+	  Peripherals (QUP) Serial Engine (SE) Wrapper which can support multiple
+	  bus protocols depending on the firmware type loaded at early boot time
+	  based on system configuration.
+
 config RENESAS_RPC_SPI
 	bool "Renesas RPC SPI driver"
 	depends on RCAR_64 || RZA1
drivers/spi/Makefile +1 -0
index da91b18b6ed3..29c20b888278 100644
@@ -66,6 +66,7 @@ obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_PIC32_SPI) += pic32_spi.o
 obj-$(CONFIG_PL022_SPI) += pl022_spi.o
 obj-$(CONFIG_SPI_QUP) += spi-qup.o
+obj-$(CONFIG_SPI_GENI_QCOM) += spi-geni-qcom.o
 obj-$(CONFIG_SPI_MXIC) += spi-mxic.o
 obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o
 obj-$(CONFIG_ROCKCHIP_SFC) += rockchip_sfc.o
drivers/spi/spi-geni-qcom.c new file +569 -0

569 lines not on this page · raw message

Signature · 1 line
Sent by a computer, using git, on the internet
#8 lore raw

PATCH v4 7/28 serial: msm-geni: Enable SE clk in probe

In reply to Stephen Boyd

Enable the serial engine clk in probe so that this driver can work on platforms that don't already initialize the clk for this device before this driver runs. This fixes a problem I see on Coreboot platforms like Trogdor where the UART hardware isn't enabled by coreboot unless the serial console build is used.

---
 drivers/serial/serial_msm_geni.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/serial/serial_msm_geni.c +12 -14
index cb6c09fdd09e..620cb9a59343 100644
@@ -131,6 +131,7 @@ struct msm_serial_data {
 	phys_addr_t base;
 	u32 baud;
 	u32 oversampling;
+	struct clk *se;
 };
 
 unsigned long root_freq[] = {7372800,  14745600, 19200000, 29491200,
@@ -181,19 +182,6 @@ static int get_clk_div_rate(u32 baud, u64 sampling_rate, u32 *clk_div)
 	return ser_clk;
 }
 
-static int geni_serial_set_clock_rate(struct udevice *dev, u64 rate)
-{
-	struct clk *clk;
-	int ret;
-
-	clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-
-	ret = clk_set_rate(clk, rate);
-	return ret;
-}
-
 /**
  * geni_se_get_tx_fifo_depth() - Get the TX fifo depth of the serial engine
  * @base:	Pointer to the concerned serial engine.
@@ -252,7 +240,7 @@ static int msm_serial_setbrg(struct udevice *dev, int baud)
 	priv->baud = baud;
 
 	clk_rate = get_clk_div_rate(baud, priv->oversampling, &clk_div);
-	ret = geni_serial_set_clock_rate(dev, clk_rate);
+	ret = clk_set_rate(priv->se, clk_rate);
 	if (ret < 0) {
 		pr_err("%s: Couldn't set clock rate: %d\n", __func__, ret);
 		return ret;
@@ -561,6 +549,16 @@ static int msm_serial_probe(struct udevice *dev)
 {
 	struct msm_serial_data *priv = dev_get_priv(dev);
 	int ret;
+	struct clk *clk;
+
+	clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	priv->se = clk;
+
+	ret = clk_enable(clk);
+	if (ret)
+		return ret;
 
 	ret = geni_set_oversampling(dev);
 	if (ret < 0)
Signature · 1 line
Sent by a computer, using git, on the internet
#9 lore raw

Re: [PATCH v4 07/28] serial: msm-geni: Enable SE clk in probe

Hi Stephen,

Quoted 56 lines · Stephen Boyd

Enable the serial engine clk in probe so that this driver can work on platforms that don't already initialize the clk for this device before this driver runs. This fixes a problem I see on Coreboot platforms like Trogdor where the UART hardware isn't enabled by coreboot unless the serial console build is used.

---
  drivers/serial/serial_msm_geni.c | 26 ++++++++++++--------------
  1 file changed, 12 insertions(+), 14 deletions(-)
drivers/serial/serial_msm_geni.c +2 -14
index cb6c09fdd09e..620cb9a59343 100644
@@ -131,6 +131,7 @@ struct msm_serial_data {
  	phys_addr_t base;
  	u32 baud;
  	u32 oversampling;
+	struct clk *se;
  };
 
  unsigned long root_freq[] = {7372800,  14745600, 19200000, 29491200,
@@ -181,19 +182,6 @@ static int get_clk_div_rate(u32 baud, u64 sampling_rate, u32 *clk_div)
  	return ser_clk;
  }
 
-static int geni_serial_set_clock_rate(struct udevice *dev, u64 rate)
-{
-	struct clk *clk;
-	int ret;
-
-	clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-
-	ret = clk_set_rate(clk, rate);
-	return ret;
-}
-
  /**
   * geni_se_get_tx_fifo_depth() - Get the TX fifo depth of the serial engine
   * @base:	Pointer to the concerned serial engine.
@@ -252,7 +240,7 @@ static int msm_serial_setbrg(struct udevice *dev, int baud)
  	priv->baud = baud;
 
  	clk_rate = get_clk_div_rate(baud, priv->oversampling, &clk_div);
-	ret = geni_serial_set_clock_rate(dev, clk_rate);
+	ret = clk_set_rate(priv->se, clk_rate);
  	if (ret < 0) {
  		pr_err("%s: Couldn't set clock rate: %d\n", __func__, ret);
  		return ret;
@@ -561,6 +549,16 @@ static int msm_serial_probe(struct udevice *dev)
  {
  	struct msm_serial_data *priv = dev_get_priv(dev);
  	int ret;

drivers/serial/serial_msm_geni.c static int msm_serial_probe(struct udevice *dev) · line 561

Quoted 10 lines
drivers/serial/serial_msm_geni.c +10 -0
+	struct clk *clk;
+
+	clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	priv->se = clk;
+
+	ret = clk_enable(clk);
+	if (ret)
+		return ret;

There's a subtle change in behaviour here, since we'll now fail probe if the clock isn't found. I think it would be best to treat this clock being missing as non-fatal since it can make bringup a little easier (no need to stub the clock).

Kind regards,>

Quoted 2 lines
drivers/serial/serial_msm_geni.c +0 -0
  	ret = geni_set_oversampling(dev);
  	if (ret < 0)
Signature · 1 line
Casey (she/they)
#10 lore raw

Re: [PATCH v4 07/28] serial: msm-geni: Enable SE clk in probe

Quoting Casey Connolly (2025-05-28 04:23:01)

Quoted 12 lines · Stephen Boyd
Quoted 11 lines
drivers/serial/serial_msm_geni.c +7 -0
@@ -561,6 +549,16 @@ static int msm_serial_probe(struct udevice *dev)
  {
      struct msm_serial_data *priv = dev_get_priv(dev);
      int ret;
+     struct clk *clk;
+
+     clk = devm_clk_get(dev, NULL);
+     if (IS_ERR(clk))
+             return PTR_ERR(clk);
+     priv->se = clk;
+
Quoted 8 lines

drivers/serial/serial_msm_geni.c static int msm_serial_probe(struct udevice *dev) · line 561

Quoted 3 lines
drivers/serial/serial_msm_geni.c +3 -0
+     ret = clk_enable(clk);
+     if (ret)
+             return ret;

There's a subtle change in behaviour here, since we'll now fail probe if the clock isn't found. I think it would be best to treat this clock being missing as non-fatal since it can make bringup a little easier (no need to stub the clock).

I tried to return NULL from the sc7180 clk driver as a test and the serial driver still probed. I think clk_enable() doesn't do anything in this case, which is how it should be for other platforms? TL;DR is I don't think this breaks anything.

#11 lore raw

PATCH v4 8/28 coreboot: Move coreboot logic out of x86 to a generic place

In reply to Stephen Boyd

Lay the groundwork to run U-Boot as a payload on ARM coreboot based devices. Move the coreboot table parsing code out of arch/x86 into lib/coreboot. The headers like cb_sysinfo.h and coreboot_tables.h need to be globally accessible, so move them into the top level include directory. Introduce helper functions like board_get_usable_ram_top_from_coreboot(), dram_init_from_coreboot(), and dram_init_banksize_from_coreboot() so that boards can still override these common functions while also supporting booting as a coreboot payload.

---
 arch/x86/Kconfig                              | 22 ------
 arch/x86/cpu/coreboot/Kconfig                 | 33 --------
 arch/x86/cpu/coreboot/coreboot.c              |  4 +-
 arch/x86/cpu/coreboot/sdram.c                 | 78 +------------------
 arch/x86/cpu/coreboot/timestamp.c             |  2 +-
 arch/x86/cpu/cpu.c                            |  2 +-
 arch/x86/cpu/i386/cpu.c                       |  2 +-
 .../x86/include/asm/arch-coreboot/timestamp.h |  2 +-
 arch/x86/lib/coreboot/Makefile                |  1 -
 arch/x86/lib/coreboot/cb_support.c            |  2 +-
 arch/x86/lib/coreboot_table.c                 |  2 +-
 arch/x86/lib/tables.c                         |  2 +-
 board/coreboot/coreboot/coreboot.c            |  2 +-
 board/coreboot/coreboot/sysinfo.c             |  2 +-
 board/google/chromebook_coral/coral.c         |  2 +-
 boot/Kconfig                                  |  1 +
 boot/expo_build_cb.c                          |  2 +-
 cmd/version.c                                 |  2 +-
 cmd/x86/cbcmos.c                              |  2 +-
 cmd/x86/cbsysinfo.c                           |  2 +-
 drivers/misc/cbmem_console.c                  |  2 +-
 drivers/serial/serial_coreboot.c              |  2 +-
 drivers/video/coreboot.c                      |  2 +-
 .../x86/include/asm => include}/cb_sysinfo.h  | 22 +++++-
 .../include/asm => include}/coreboot_tables.h |  0
 lib/Makefile                                  |  2 +
 lib/coreboot/Kconfig                          | 55 +++++++++++++
 lib/coreboot/Makefile                         | 17 ++++
 {arch/x86/lib => lib}/coreboot/cb_sysinfo.c   | 14 +---
 {arch/x86/cpu => lib}/coreboot/sdram.c        | 15 +---
 30 files changed, 125 insertions(+), 173 deletions(-)
 delete mode 100644 arch/x86/cpu/coreboot/Kconfig
 rename {arch/x86/include/asm => include}/cb_sysinfo.h (94%)
 rename {arch/x86/include/asm => include}/coreboot_tables.h (100%)
 create mode 100644 lib/coreboot/Kconfig
 create mode 100644 lib/coreboot/Makefile
 rename {arch/x86/lib => lib}/coreboot/cb_sysinfo.c (95%)
 copy {arch/x86/cpu => lib}/coreboot/sdram.c (87%)
arch/x86/Kconfig +0 -22
index dc9483ad7232..670fc04eb312 100644
@@ -119,7 +119,6 @@ source "arch/x86/cpu/apollolake/Kconfig"
 source "arch/x86/cpu/baytrail/Kconfig"
 source "arch/x86/cpu/braswell/Kconfig"
 source "arch/x86/cpu/broadwell/Kconfig"
-source "arch/x86/cpu/coreboot/Kconfig"
 source "arch/x86/cpu/ivybridge/Kconfig"
 source "arch/x86/cpu/efi/Kconfig"
 source "arch/x86/cpu/qemu/Kconfig"
@@ -1049,27 +1048,6 @@ config INTEL_GMA_SWSMISCI
 
 endif # INTEL_SOC
 
-config COREBOOT_SYSINFO
-	bool "Support reading coreboot sysinfo"
-	default y if SYS_COREBOOT
-	help
-	  Select this option to read the coreboot sysinfo table on start-up,
-	  if present. This is written by coreboot before it exits and provides
-	  various pieces of information about the running system, including
-	  display, memory and build information. It is stored in
-	  struct sysinfo_t after parsing by get_coreboot_info().
-
-config SPL_COREBOOT_SYSINFO
-	bool "Support reading coreboot sysinfo"
-	depends on SPL
-	default y if COREBOOT_SYSINFO
-	help
-	  Select this option to read the coreboot sysinfo table in SPL,
-	  if present. This is written by coreboot before it exits and provides
-	  various pieces of information about the running system, including
-	  display, memory and build information. It is stored in
-	  struct sysinfo_t after parsing by get_coreboot_info().
-
 config ZBOOT
 	bool "Support the zImage format"
 	default y
arch/x86/cpu/coreboot/Kconfig deleted +0 -33
deleted file mode 100644
index 66f25533b97f..000000000000
@@ -1,33 +0,0 @@
-if VENDOR_COREBOOT
-
-config SYS_COREBOOT
-	bool
-	default y
-	imply SYS_NS16550
-	imply SCSI
-	imply SCSI_AHCI
-	imply AHCI_PCI
-	imply MMC
-	imply MMC_PCI
-	imply MMC_SDHCI
-	imply MMC_SDHCI_SDMA
-	imply USB
-	imply USB_EHCI_HCD
-	imply USB_XHCI_HCD
-	imply USB_STORAGE
-	imply USB_KEYBOARD
-	imply VIDEO_COREBOOT
-	imply E1000
-	imply ETH_DESIGNWARE
-	imply PCH_GBE
-	imply RTL8169
-	imply CMD_CBFS
-	imply FS_CBFS
-	imply CBMEM_CONSOLE
-	imply X86_TSC_READ_BASE
-	imply USE_PREBOOT
-	select BINMAN if X86_RUN_64BIT
-	select SYSINFO
-	imply SYSINFO_EXTRA
-
-endif
arch/x86/cpu/coreboot/coreboot.c +3 -1
index d0719d1a4056..cd9ad22b3db3 100644
@@ -5,6 +5,7 @@
  * Graeme Russ, [email protected].
  */
 
+#include <cb_sysinfo.h>
 #include <cpu_func.h>
 #include <event.h>
 #include <fdtdec.h>
@@ -14,7 +15,6 @@
 #include <asm/io.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
-#include <asm/cb_sysinfo.h>
 #include <asm/arch/timestamp.h>
 #include <dm/ofnode.h>
 
@@ -32,6 +32,8 @@ int arch_cpu_init(void)
 		printf("Failed to parse coreboot tables.\n");
 		return ret;
 	}
+	gd_set_acpi_start(map_to_sysmem(lib_sysinfo.rsdp));
+	gd_set_smbios_start(lib_sysinfo.smbios_start);
 
 	timestamp_init();
 
arch/x86/cpu/coreboot/sdram.c +4 -74

102 lines not on this page · raw message

arch/x86/cpu/coreboot/timestamp.c +1 -1
index 681191d85bb6..18be969ccea6 100644
@@ -6,9 +6,9 @@
  */
 
 #include <bootstage.h>
+#include <cb_sysinfo.h>
 #include <errno.h>
 #include <asm/arch/timestamp.h>
-#include <asm/cb_sysinfo.h>
 #include <asm/u-boot-x86.h>
 #include <linux/compiler.h>
 
arch/x86/cpu/cpu.c +1 -1
index c373b14df30c..a40563e5a400 100644
@@ -22,6 +22,7 @@
 
 #include <bootstage.h>
 #include <command.h>
+#include <coreboot_tables.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
@@ -35,7 +36,6 @@
 #include <acpi/acpi_table.h>
 #include <asm/acpi.h>
 #include <asm/control_regs.h>
-#include <asm/coreboot_tables.h>
 #include <asm/cpu.h>
 #include <asm/global_data.h>
 #include <asm/lapic.h>
arch/x86/cpu/i386/cpu.c +1 -1
index ee6dbeb5c48e..14a79963b112 100644
@@ -18,13 +18,13 @@
  * src/arch/x86/lib/cpu.c
  */
 
+#include <coreboot_tables.h>
 #include <cpu_func.h>
 #include <init.h>
 #include <log.h>
 #include <malloc.h>
 #include <spl.h>
 #include <asm/control_regs.h>
-#include <asm/coreboot_tables.h>
 #include <asm/cpu.h>
 #include <asm/global_data.h>
 #include <asm/mp.h>
arch/x86/include/asm/arch-coreboot/timestamp.h +1 -1
index bbf89447dde4..227316975047 100644
@@ -8,7 +8,7 @@
 #ifndef __COREBOOT_TIMESTAMP_H__
 #define __COREBOOT_TIMESTAMP_H__
 
-#include <asm/cb_sysinfo.h>
+#include <cb_sysinfo.h>
 
 void timestamp_init(void);
 void timestamp_add(enum timestamp_id id, uint64_t ts_time);
arch/x86/lib/coreboot/Makefile +0 -1
index cb0ae1d017b2..95dcaf8920db 100644
@@ -3,5 +3,4 @@
 # Copyright 2021 Google LLC
 #
 
-obj-y += cb_sysinfo.o
 obj-y += cb_support.o
arch/x86/lib/coreboot/cb_support.c +1 -1
index b4d5fa4af327..32880d18ed1e 100644
@@ -5,7 +5,7 @@
  * Copyright 2021 Google LLC
  */
 
-#include <asm/cb_sysinfo.h>
+#include <cb_sysinfo.h>
 #include <asm/e820.h>
 #include <linux/kernel.h>
 
arch/x86/lib/coreboot_table.c +1 -1
index 33fce5d0a5e5..ffe98ea491a0 100644
@@ -3,11 +3,11 @@
  * Copyright (C) 2016, Bin Meng <[email protected]>
  */
 
+#include <coreboot_tables.h>
 #include <malloc.h>
 #include <net.h>
 #include <vesa.h>
 #include <acpi/acpi_s3.h>
-#include <asm/coreboot_tables.h>
 #include <asm/e820.h>
 #include <asm/global_data.h>
 
arch/x86/lib/tables.c +1 -1
index ec52992209f0..dadc5694cfbc 100644
@@ -6,6 +6,7 @@
 #define LOG_CATEGORY LOGC_ACPI
 
 #include <bloblist.h>
+#include <coreboot_tables.h>
 #include <log.h>
 #include <malloc.h>
 #include <smbios.h>
@@ -14,7 +15,6 @@
 #include <asm/sfi.h>
 #include <asm/mpspec.h>
 #include <asm/tables.h>
-#include <asm/coreboot_tables.h>
 #include <linux/log2.h>
 #include <linux/sizes.h>
 
board/coreboot/coreboot/coreboot.c +1 -1
index f2ca10767681..c12af5c79322 100644
@@ -3,10 +3,10 @@
  * Copyright (C) 2018, Bin Meng <[email protected]>
  */
 
+#include <cb_sysinfo.h>
 #include <splash.h>
 #include <init.h>
 #include <smbios.h>
-#include <asm/cb_sysinfo.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
board/coreboot/coreboot/sysinfo.c +1 -1
index d6b19530023e..c510cd1e1b7f 100644
@@ -6,10 +6,10 @@
  * Written by Simon Glass <[email protected]>
  */
 
+#include <cb_sysinfo.h>
 #include <dm.h>
 #include <smbios.h>
 #include <sysinfo.h>
-#include <asm/cb_sysinfo.h>
 
 struct cb_sysinfo_priv {
 	const struct smbios_header *bios;
board/google/chromebook_coral/coral.c +1 -1
index db96534857c8..c0d50bf4c717 100644
@@ -6,6 +6,7 @@
 #define LOG_CATEGORY	UCLASS_SYSINFO
 
 #include <bloblist.h>
+#include <cb_sysinfo.h>
 #include <command.h>
 #include <cros_ec.h>
 #include <dm.h>
@@ -16,7 +17,6 @@
 #include <acpi/acpigen.h>
 #include <asm-generic/gpio.h>
 #include <asm/acpi_nhlt.h>
-#include <asm/cb_sysinfo.h>
 #include <asm/intel_gnvs.h>
 #include <asm/intel_pinctrl.h>
 #include <dm/acpi.h>
boot/Kconfig +1 -0
index fb37d912bc95..9d24e22f5603 100644
@@ -1,5 +1,6 @@
 menu "Boot options"
 
+source "lib/coreboot/Kconfig"
 source "lib/efi_loader/Kconfig"
 
 menu "Boot images"
boot/expo_build_cb.c +1 -1
index 442ad760e796..47c62ca7e920 100644
@@ -8,6 +8,7 @@
 
 #define LOG_CATEGORY	LOGC_EXPO
 
+#include <cb_sysinfo.h>
 #include <cedit.h>
 #include <ctype.h>
 #include <errno.h>
@@ -15,7 +16,6 @@
 #include <log.h>
 #include <malloc.h>
 #include <vsprintf.h>
-#include <asm/cb_sysinfo.h>
 
 /**
  * struct build_info - Information to use when building
cmd/version.c +1 -1
index 62406608eb0b..31c8dc5e85bc 100644
@@ -10,7 +10,7 @@
 #include <version_string.h>
 #include <linux/compiler.h>
 #ifdef CONFIG_SYS_COREBOOT
-#include <asm/cb_sysinfo.h>
+#include <cb_sysinfo.h>
 #endif
 
 static int do_version(struct cmd_tbl *cmdtp, int flag, int argc,
cmd/x86/cbcmos.c +1 -1
index fe5582fbf511..84a81be53cdd 100644
@@ -7,10 +7,10 @@
 
 #define LOG_CATEGORY	UCLASS_RTC
 
+#include <cb_sysinfo.h>
 #include <command.h>
 #include <dm.h>
 #include <rtc.h>
-#include <asm/cb_sysinfo.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
cmd/x86/cbsysinfo.c +1 -1
index ea4d89616f62..3936d30da0e1 100644
@@ -4,7 +4,7 @@
  * Written by Simon Glass <[email protected]>
  */
 
-#include <asm/cb_sysinfo.h>
+#include <cb_sysinfo.h>
 #include <command.h>
 #include <console.h>
 #include <asm/global_data.h>
drivers/misc/cbmem_console.c +1 -1
index 8220addd579b..5113e50c53b8 100644
@@ -3,9 +3,9 @@
  * Copyright (C) 2011 The ChromiumOS Authors.  All rights reserved.
  */
 
+#include <cb_sysinfo.h>
 #include <console.h>
 #include <linux/string.h>
-#include <asm/cb_sysinfo.h>
 
 void cbmemc_putc(struct stdio_dev *dev, char data)
 {
drivers/serial/serial_coreboot.c +1 -1
index b1f69f6998cf..1835e333aec0 100644
@@ -7,12 +7,12 @@
 
 #define LOG_CATGEGORY	UCLASS_SERIAL
 
+#include <cb_sysinfo.h>
 #include <dm.h>
 #include <log.h>
 #include <ns16550.h>
 #include <serial.h>
 #include <acpi/acpi_table.h>
-#include <asm/cb_sysinfo.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
drivers/video/coreboot.c +1 -1
index 9aede2626423..ed589cc42bfd 100644
@@ -3,11 +3,11 @@
  * Copyright (C) 2016, Bin Meng <[email protected]>
  */
 
+#include <cb_sysinfo.h>
 #include <dm.h>
 #include <init.h>
 #include <vesa.h>
 #include <video.h>
-#include <asm/cb_sysinfo.h>
 
 static int save_vesa_mode(struct cb_framebuffer *fb,
 			  struct vesa_mode_info *vesa)
include/cb_sysinfo.h renamed from arch/x86/include/asm/cb_sysinfo.h +21 -1
similarity index 94%
rename from arch/x86/include/asm/cb_sysinfo.h
rename to include/cb_sysinfo.h
index 5864b2700cec..62a483e10cef 100644
@@ -8,7 +8,7 @@
 #ifndef _COREBOOT_SYSINFO_H
 #define _COREBOOT_SYSINFO_H
 
-#include <asm/coreboot_tables.h>
+#include <coreboot_tables.h>
 #include <linux/types.h>
 
 /* Maximum number of memory range definitions */
@@ -246,4 +246,24 @@ int get_coreboot_info(struct sysinfo_t *info);
  */
 const struct sysinfo_t *cb_get_sysinfo(void);
 
+/**
+ * coreboot_dram_init_banksize() - Initilize RAM banksize from coreboot sysinfo
+ * table
+ */
+int coreboot_dram_init_banksize(void);
+
+/**
+ * coreboot_dram_init() - Configure available RAM banks from coreboot sysinfo
+ * table
+ */
+int coreboot_dram_init(void);
+
+/**
+ * coreboot_board_get_usable_ram_top() - Get the top of RAM usable by U-Boot
+ * while running as a coreboot payload
+ *
+ * Return: Physical address as the top of RAM
+ */
+phys_addr_t coreboot_board_get_usable_ram_top(phys_size_t total_size);
+
 #endif
include/coreboot_tables.h renamed from arch/x86/include/asm/coreboot_tables.h +0 -0
similarity index 100%
rename from arch/x86/include/asm/coreboot_tables.h
rename to include/coreboot_tables.h
lib/Makefile +2 -0
index 18ae0cd87bfc..4aa066130918 100644
@@ -136,6 +136,8 @@ obj-$(CONFIG_LIB_UUID) += uuid.o
 obj-$(CONFIG_LIB_RAND) += rand.o
 obj-y += panic.o
 
+obj-$(CONFIG_VENDOR_COREBOOT)	+= coreboot/
+
 ifeq ($(CONFIG_XPL_BUILD),y)
 # SPL U-Boot may use full-printf, tiny-printf or none at all
 ifdef CONFIG_$(PHASE_)USE_TINY_PRINTF
lib/coreboot/Kconfig new file +55 -0

55 lines not on this page · raw message

lib/coreboot/Makefile new file +17 -0
new file mode 100644
index 000000000000..a0027bdfa505
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+#
+# (C) Copyright 2008
+# Graeme Russ, [email protected].
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, [email protected].
+#
+# (C) Copyright 2002
+# Daniel Engström, Omicron Ceti AB, [email protected].
+
+obj-$(CONFIG_$(XPL_)COREBOOT_SYSINFO) += cb_sysinfo.o
+ifndef CONFIG_XPL_BUILD
+obj-y += sdram.o
+endif
lib/coreboot/cb_sysinfo.c renamed from arch/x86/lib/coreboot/cb_sysinfo.c +1 -13
similarity index 95%
rename from arch/x86/lib/coreboot/cb_sysinfo.c
rename to lib/coreboot/cb_sysinfo.c
index ec997fa49cf2..f8f2002d46f0 100644
@@ -6,7 +6,7 @@
  * Copyright (C) 2009 coresystems GmbH
  */
 
-#include <asm/cb_sysinfo.h>
+#include <cb_sysinfo.h>
 #include <init.h>
 #include <mapmem.h>
 #include <net.h>
@@ -23,13 +23,6 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 struct sysinfo_t lib_sysinfo __section(".data");
 
-/*
- * Some of this is x86 specific, and the rest of it is generic. Right now,
- * since we only support x86, we'll avoid trying to make lots of infrastructure
- * we don't need. If in the future, we want to use coreboot on some other
- * architecture, then take out the generic parsing code and move it elsewhere.
- */
-
 /* === Parsing code === */
 /* This is the generic parsing code */
 
@@ -453,9 +446,6 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 	return 1;
 }
 
-/* == Architecture specific == */
-/* This is the x86 specific stuff */
-
 int get_coreboot_info(struct sysinfo_t *info)
 {
 	long addr;
@@ -470,8 +460,6 @@ int get_coreboot_info(struct sysinfo_t *info)
 	if (!ret)
 		return -ENOENT;
 	gd->arch.coreboot_table = addr;
-	gd_set_acpi_start(map_to_sysmem(info->rsdp));
-	gd_set_smbios_start(info->smbios_start);
 	gd->flags |= GD_FLG_SKIP_LL_INIT;
 
 	return 0;
lib/coreboot/sdram.c renamed from arch/x86/cpu/coreboot/sdram.c +4 -11
similarity index 87%
copy from arch/x86/cpu/coreboot/sdram.c
copy to lib/coreboot/sdram.c
index 013225f129a9..ac9a95b1d378 100644
@@ -6,18 +6,11 @@
  */
 
 #include <init.h>
-#include <asm/e820.h>
-#include <asm/cb_sysinfo.h>
+#include <cb_sysinfo.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-unsigned int install_e820_map(unsigned int max_entries,
-			      struct e820_entry *entries)
-{
-	return cb_install_e820_map(max_entries, entries);
-}
-
 /*
  * This function looks for the highest region of memory lower than 4GB which
  * has enough space for U-Boot where U-Boot is aligned on a page boundary. It
@@ -26,7 +19,7 @@ unsigned int install_e820_map(unsigned int max_entries,
  * address, and how far U-Boot is moved by relocation are set in the global
  * data structure.
  */
-phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
+phys_addr_t coreboot_board_get_usable_ram_top(phys_size_t total_size)
 {
 	uintptr_t dest_addr = 0;
 	int i;
@@ -60,7 +53,7 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 	return (ulong)dest_addr;
 }
 
-int dram_init(void)
+int coreboot_dram_init(void)
 {
 	int i;
 	phys_size_t ram_size = 0;
@@ -80,7 +73,7 @@ int dram_init(void)
 	return 0;
 }
 
-int dram_init_banksize(void)
+int coreboot_dram_init_banksize(void)
 {
 	int i, j;
 
Signature · 1 line
Sent by a computer, using git, on the internet
Reviewed-by on v4 8/28
#12 lore raw

Re: [PATCH v4 08/28] coreboot: Move coreboot logic out of x86 to a generic place

Quoted 11 lines · Stephen Boyd

Lay the groundwork to run U-Boot as a payload on ARM coreboot based devices. Move the coreboot table parsing code out of arch/x86 into lib/coreboot. The headers like cb_sysinfo.h and coreboot_tables.h need to be globally accessible, so move them into the top level include directory. Introduce helper functions like board_get_usable_ram_top_from_coreboot(), dram_init_from_coreboot(), and dram_init_banksize_from_coreboot() so that boards can still override these common functions while also supporting booting as a coreboot payload.

Signature · 1 line
Tom
#13 lore raw

PATCH v4 9/28 coreboot: Set gd->ram_base when parsing tables

In reply to Stephen Boyd

Set the base of RAM to be the lowest address memory bank from the coreboot tables.

---
 lib/coreboot/sdram.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
lib/coreboot/sdram.c +8 -2
index ac9a95b1d378..25918af003f9 100644
@@ -56,16 +56,22 @@ phys_addr_t coreboot_board_get_usable_ram_top(phys_size_t total_size)
 int coreboot_dram_init(void)
 {
 	int i;
+	phys_size_t ram_base = ~0UL;
 	phys_size_t ram_size = 0;
 
 	for (i = 0; i < lib_sysinfo.n_memranges; i++) {
 		struct memrange *memrange = &lib_sysinfo.memrange[i];
 		unsigned long long end = memrange->base + memrange->size;
 
-		if (memrange->type == CB_MEM_RAM && end > ram_size)
-			ram_size += memrange->size;
+		if (memrange->type == CB_MEM_RAM) {
+			if (ram_base > memrange->base)
+				ram_base = memrange->base;
+			if (end > ram_size)
+				ram_size += memrange->size;
+		}
 	}
 
+	gd->ram_base = ram_base;
 	gd->ram_size = ram_size;
 	if (ram_size == 0)
 		return -1;
Signature · 1 line
Sent by a computer, using git, on the internet
#14 lore raw

PATCH v4 10/28 coreboot: Locate table earlier than arch_cpu_init()

In reply to Stephen Boyd

Currently we locate the coreboot table in arch_cpu_init(). One of the first things that happens in initcall_run_f() initialization is fdtdec_setup() is called which could inspect the DTB for memory information (see mach-snapdragon's board_fdt_blob_setup() code). Introduce an initcall specifically to locate the coreboot table early on in the boot process so that board_fdt_blob_setup() can know that the memory is described in the coreboot tables instead of the DTB that's either embedded in the ELF file or provided by the earlier stage bootloader. This will also help in the future when we want to pick the DTB from a FIT image based on the board and revision ID bits in the coreboot tables.

---
 arch/x86/cpu/coreboot/coreboot.c |  8 ++++----
 common/board_f.c                 |  4 ++++
 include/cb_sysinfo.h             |  7 +++++++
 lib/coreboot/cb_sysinfo.c        | 11 +++++++++++
 4 files changed, 26 insertions(+), 4 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +4 -4
index cd9ad22b3db3..e1dbce4f0b29 100644
@@ -27,11 +27,11 @@ int arch_cpu_init(void)
 	if (ret)
 		return ret;
 
-	ret = get_coreboot_info(&lib_sysinfo);
-	if (ret != 0) {
-		printf("Failed to parse coreboot tables.\n");
-		return ret;
+	if (!gd->arch.coreboot_table)
+		printf("Failed to locate coreboot tables.\n");
+		return -ENOENT;
 	}
+
 	gd_set_acpi_start(map_to_sysmem(lib_sysinfo.rsdp));
 	gd_set_smbios_start(lib_sysinfo.smbios_start);
 
common/board_f.c +4 -0
index bff465d9cb2f..7e314b20c60e 100644
@@ -12,6 +12,7 @@
 #include <config.h>
 #include <bloblist.h>
 #include <bootstage.h>
+#include <cb_sysinfo.h>
 #include <clock_legacy.h>
 #include <console.h>
 #include <cpu.h>
@@ -896,6 +897,9 @@ static void initcall_run_f(void)
 	 * For simplicity it should remain an ordered list of function calls.
 	 */
 	INITCALL(setup_mon_len);
+#if CONFIG_IS_ENABLED(SYS_COREBOOT)
+	INITCALL(coreboot_early_init);
+#endif
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 	INITCALL(fdtdec_setup);
 #endif
include/cb_sysinfo.h +7 -0
index 62a483e10cef..40d8030dbb8b 100644
@@ -239,6 +239,13 @@ extern struct sysinfo_t lib_sysinfo;
  */
 int get_coreboot_info(struct sysinfo_t *info);
 
+/**
+ * coreboot_early_init() - locate the coreboot tables during early init
+ *
+ * Return: 0
+ */
+int coreboot_early_init(void);
+
 /**
  * cb_get_sysinfo() - get a pointer to the parsed coreboot sysinfo
  *
lib/coreboot/cb_sysinfo.c +11 -0
index f8f2002d46f0..1ea4ec4a0487 100644
@@ -465,6 +465,17 @@ int get_coreboot_info(struct sysinfo_t *info)
 	return 0;
 }
 
+int coreboot_early_init(void)
+{
+	int ret;
+
+	ret = get_coreboot_info(&lib_sysinfo);
+	if (ret != 0)
+		debug("Failed to parse coreboot tables.\n");
+
+	return 0;
+}
+
 const struct sysinfo_t *cb_get_sysinfo(void)
 {
 	if (!ll_boot_init())
Signature · 1 line
Sent by a computer, using git, on the internet
#15 lore raw

PATCH v4 11/28 arm: Support running U-Boot as a coreboot payload on ARM64

In reply to Stephen Boyd

Add a 'coreboot' cpu to armv8 that looks for the coreboot table near the top of the 4G address space.

---
 arch/arm/cpu/armv8/Makefile          |  1 +
 arch/arm/cpu/armv8/coreboot/Makefile |  4 ++++
 arch/arm/cpu/armv8/coreboot/cpu.c    | 22 ++++++++++++++++++++++
 arch/arm/include/asm/global_data.h   |  3 +++
 arch/x86/cpu/cpu.c                   | 13 -------------
 include/cb_sysinfo.h                 |  7 +++++++
 lib/Makefile                         |  2 +-
 lib/coreboot/Kconfig                 | 14 +++++++-------
 lib/coreboot/cb_sysinfo.c            | 13 +++++++++++++
 9 files changed, 58 insertions(+), 21 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/coreboot/Makefile
 create mode 100644 arch/arm/cpu/armv8/coreboot/cpu.c
arch/arm/cpu/armv8/Makefile +1 -0
index dd0191a12fac..8699433a96ae 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_ARMV8_CE_SHA1) += sha1_ce_glue.o sha1_ce_core.o
 obj-$(CONFIG_ARMV8_CE_SHA256) += sha256_ce_glue.o sha256_ce_core.o
 
 obj-$(CONFIG_SYSINFO_SMBIOS) += sysinfo.o
+obj-$(CONFIG_SYS_COREBOOT) += coreboot/
arch/arm/cpu/armv8/coreboot/Makefile new file +4 -0
new file mode 100644
index 000000000000..0eca9ff05900
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += cpu.o
+
arch/arm/cpu/armv8/coreboot/cpu.c new file +22 -0
new file mode 100644
index 000000000000..d0133049a294
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <cb_sysinfo.h>
+#include <linux/errno.h>
+#include <linux/sizes.h>
+#include <log.h>
+
+long locate_coreboot_table(void)
+{
+	long addr;
+
+	/*
+	 * We look for LBIO somewhere inside the CBMEM arena, which is
+	 * typically at the top of the first 4G of RAM.
+	 */
+	addr = detect_coreboot_table_at(SZ_4G - SZ_8M, SZ_8M);
+	if (addr < 0)
+		return -ENOENT;
+
+	debug("Located coreboot table at %#lx\n", addr);
+	return addr;
+}
arch/arm/include/asm/global_data.h +3 -0
index 45401d5e3c8a..70299aec2df4 100644
@@ -108,6 +108,9 @@ struct arch_global_data {
 #ifdef CONFIG_SMBIOS
 	ulong smbios_start;		/* Start address of SMBIOS table */
 #endif
+#ifdef CONFIG_SYS_COREBOOT
+	ulong coreboot_table;		/* Address of coreboot table */
+#endif
 };
 
 #include <asm-generic/global_data.h>
arch/x86/cpu/cpu.c +0 -13
index a40563e5a400..f91cfb984c1a 100644
@@ -340,19 +340,6 @@ int reserve_arch(void)
 }
 #endif
 
-static long detect_coreboot_table_at(ulong start, ulong size)
-{
-	u32 *ptr, *end;
-
-	size /= 4;
-	for (ptr = (void *)start, end = ptr + size; ptr < end; ptr += 4) {
-		if (*ptr == 0x4f49424c) /* "LBIO" */
-			return (long)ptr;
-	}
-
-	return -ENOENT;
-}
-
 long locate_coreboot_table(void)
 {
 	long addr;
include/cb_sysinfo.h +7 -0
index 40d8030dbb8b..f24099fc0ef9 100644
@@ -228,6 +228,13 @@ struct sysinfo_t {
 
 extern struct sysinfo_t lib_sysinfo;
 
+/**
+ * detect_coreboot_table_at() - Helper to find coreboot table
+ *
+ * Return: Address of coreboot table or -ENOENT on failure
+ */
+long detect_coreboot_table_at(ulong start, ulong size);
+
 /**
  * get_coreboot_info() - parse the coreboot sysinfo table
  *
lib/Makefile +1 -1
index 4aa066130918..eda969cea109 100644
@@ -136,7 +136,7 @@ obj-$(CONFIG_LIB_UUID) += uuid.o
 obj-$(CONFIG_LIB_RAND) += rand.o
 obj-y += panic.o
 
-obj-$(CONFIG_VENDOR_COREBOOT)	+= coreboot/
+obj-$(CONFIG_SYS_COREBOOT)	+= coreboot/
 
 ifeq ($(CONFIG_XPL_BUILD),y)
 # SPL U-Boot may use full-printf, tiny-printf or none at all
lib/coreboot/Kconfig +7 -7
index cec0bcc0885f..10b67138a400 100644
@@ -1,9 +1,9 @@
 menu "U-Boot as Coreboot payload"
-	depends on VENDOR_COREBOOT
+	depends on ARM64 || VENDOR_COREBOOT
 
 config SYS_COREBOOT
-	bool
-	default y
+	bool "Support for booting u-boot as a coreboot payload" if ARM64
+	default VENDOR_COREBOOT
 	imply SYS_NS16550
 	imply SCSI
 	imply SCSI_AHCI
@@ -17,15 +17,15 @@ config SYS_COREBOOT
 	imply USB_XHCI_HCD
 	imply USB_STORAGE
 	imply USB_KEYBOARD
-	imply VIDEO_COREBOOT
-	imply E1000
+	imply VIDEO_COREBOOT if x86
+	imply E1000 if x86
 	imply ETH_DESIGNWARE
-	imply PCH_GBE
+	imply PCH_GBE if X86
 	imply RTL8169
 	imply CMD_CBFS
 	imply FS_CBFS
 	imply CBMEM_CONSOLE
-	imply X86_TSC_READ_BASE
+	imply X86_TSC_READ_BASE if X86
 	imply USE_PREBOOT
 	select BINMAN if X86_RUN_64BIT
 	select SYSINFO
lib/coreboot/cb_sysinfo.c +13 -0
index 1ea4ec4a0487..101e5ff4037b 100644
@@ -446,6 +446,19 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 	return 1;
 }
 
+long detect_coreboot_table_at(ulong start, ulong size)
+{
+	u32 *ptr, *end;
+
+	size /= 4;
+	for (ptr = (void *)start, end = ptr + size; ptr < end; ptr += 4) {
+		if (*ptr == 0x4f49424c) /* "LBIO" */
+			return (long)ptr;
+	}
+
+	return -ENOENT;
+}
+
 int get_coreboot_info(struct sysinfo_t *info)
 {
 	long addr;
Signature · 1 line
Sent by a computer, using git, on the internet
#16 lore raw

PATCH v4 12/28 cmd/cbsysinfo: Skip the CMOS 'option_table' when not present

In reply to Stephen Boyd

The CMOS 'option_table' isn't populated on ARM devices running coreboot. Check to see if the pointer is NULL and bail out if it is.

---
 cmd/x86/cbsysinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/x86/cbsysinfo.c +1 -1
index 3936d30da0e1..ed7b50f6d0fc 100644
@@ -224,7 +224,7 @@ static void show_option_table(const struct cb_cmos_option_table *tab)
 	const void *ptr, *end;
 
 	print_ptr("option_table", tab);
-	if (!tab->size)
+	if (!tab || !tab->size)
 		return;
 
 	printf(" Bit  Len  Cfg  ID  Name\n");
Signature · 1 line
Sent by a computer, using git, on the internet
#17 lore raw

PATCH v4 13/28 cmd/cbsysinfo: Allow on ARM as well

In reply to Stephen Boyd

This command isn't x86 specific. Move it up one level so that it can be used on a platform that can find the coreboot table, i.e. x86 or ARM.

---
 cmd/Kconfig               | 4 ++--
 cmd/Makefile              | 1 +
 cmd/{x86 => }/cbsysinfo.c | 0
 cmd/x86/Makefile          | 1 -
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename cmd/{x86 => }/cbsysinfo.c (100%)
cmd/Kconfig +2 -2
index 2d31abcef730..5a35dba8681a 100644
@@ -2929,8 +2929,8 @@ menu "Debug commands"
 
 config CMD_CBSYSINFO
 	bool "cbsysinfo"
-	depends on X86
-	default y if SYS_COREBOOT
+	depends on SYS_COREBOOT
+	default y
 	help
 	  This provides information about the coreboot sysinfo table stored in
 	  memory by coreboot before jumping to U-Boot. It can be useful for
cmd/Makefile +1 -0
index 80cf70b7fe8c..7587b258409c 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_CMD_BUTTON) += button.o
 obj-$(CONFIG_CMD_CAT) += cat.o
 obj-$(CONFIG_CMD_CACHE) += cache.o
 obj-$(CONFIG_CMD_CBFS) += cbfs.o
+obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o
 obj-$(CONFIG_CMD_CEDIT) += cedit.o
 obj-$(CONFIG_CMD_CLK) += clk.o
 obj-$(CONFIG_CMD_CLS) += cls.o
cmd/cbsysinfo.c renamed from cmd/x86/cbsysinfo.c +0 -0
similarity index 100%
rename from cmd/x86/cbsysinfo.c
rename to cmd/cbsysinfo.c
cmd/x86/Makefile +0 -1
index 5f3f5be2882f..870e941dcf00 100644
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 
-obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o
 obj-y += cpuid.o msr.o mtrr.o
 obj-$(CONFIG_CMD_CBCMOS) += cbcmos.o
 obj-$(CONFIG_CMD_EXCEPTION) += exception.o
Signature · 1 line
Sent by a computer, using git, on the internet
#18 lore raw

PATCH v4 14/28 coreboot: Parse sku_id/fw_config from coreboot tables

In reply to Stephen Boyd

The SKU ID is part of the coreboot tables. Historically, it was under the coreboot tag for sku_id specifically, but modern coreboot versions have put all the ID values together in one entry CB_TAG_BOARD_CONFIG along with fw_config. Parse that tag to populate the sku_id and fw_config fields.

---
 cmd/cbsysinfo.c           |  2 ++
 include/cb_sysinfo.h      |  4 ++++
 include/coreboot_tables.h | 11 +++++++++++
 lib/coreboot/cb_sysinfo.c | 15 +++++++++++++++
 4 files changed, 32 insertions(+)
cmd/cbsysinfo.c +2 -0
index ed7b50f6d0fc..d6ab71a3db8d 100644
@@ -418,6 +418,8 @@ static void show_table(struct sysinfo_t *info, bool verbose)
 	print_ptr("MRC cache", info->mrc_cache);
 	print_ptr("ACPI GNVS", info->acpi_gnvs);
 	print_hex("Board ID", info->board_id);
+	print_hex("SKU ID", info->sku_id);
+	print_addr64("FWCONFIG", info->fw_config);
 	print_hex("RAM code", info->ram_code);
 	print_ptr("WiFi calib", info->wifi_calibration);
 	print_addr64("Ramoops buff", info->ramoops_buffer);
include/cb_sysinfo.h +4 -0
index f24099fc0ef9..b11d42be549c 100644
@@ -114,6 +114,8 @@
  * acpi_gnvs: @Pointer to Intel Global NVS struct, see struct acpi_global_nvs
  * @board_id: Board ID indicating the board variant, typically 0xffffffff
  * @ram_code: RAM code indicating the SDRAM type, typically 0xffffffff
+ * @sku_id: SKU ID indicating the board SKU, typically 0xffffffff
+ * @fw_config: FW config indicating the firmware configuration, typically 0xffffffff
  * @wifi_calibration: WiFi calibration info, NULL if none
  * @ramoops_buffer: Address of kernel Ramoops buffer
  * @ramoops_buffer_size: Sizeof of Ramoops buffer, typically 1MB
@@ -204,6 +206,8 @@ struct sysinfo_t {
 	void		*acpi_gnvs;
 	u32		board_id;
 	u32		ram_code;
+	u32		sku_id;
+	u64		fw_config;
 	void		*wifi_calibration;
 	u64	ramoops_buffer;
 	u32	ramoops_buffer_size;
include/coreboot_tables.h +11 -0
index 54aeffb9889d..6e7686e360c5 100644
@@ -438,6 +438,17 @@ struct cb_tsc_info {
 #define CB_TAG_SERIALNO			0x002a
 #define CB_MAX_SERIALNO_LENGTH		32
 
+#define CB_TAG_BOARD_CONFIG		0x0040
+struct cb_board_config {
+	u32 tag;
+	u32 size;
+
+	u64 fw_config;
+	u32 board_id;
+	u32 ram_code;
+	u32 sku_id;
+};
+
 #define CB_TAG_ACPI_RSDP		0x0043
 
 #define CB_TAG_CMOS_OPTION_TABLE	0x00c8
lib/coreboot/cb_sysinfo.c +15 -0
index 101e5ff4037b..2e9b98d3ced5 100644
@@ -141,6 +141,16 @@ static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info)
 	info->acpi_gnvs = map_sysmem(cbmem->cbmem_tab, 0);
 }
 
+static void cb_parse_board_config(unsigned char *ptr, struct sysinfo_t *info)
+{
+	struct cb_board_config *const cbbcfg = (struct cb_board_config *)ptr;
+
+	info->board_id = cbbcfg->board_id;
+	info->ram_code = cbbcfg->ram_code;
+	info->sku_id = cbbcfg->sku_id;
+	info->fw_config = cbbcfg->fw_config;
+}
+
 static void cb_parse_board_id(unsigned char *ptr, struct sysinfo_t *info)
 {
 	struct cb_board_id *const cbbid = (struct cb_board_id *)ptr;
@@ -295,6 +305,8 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 	 */
 	info->board_id = ~0;
 	info->ram_code = ~0;
+	info->sku_id = ~0;
+	info->fw_config = ~0ULL;
 
 	/* Now, walk the tables */
 	ptr += header->header_bytes;
@@ -395,6 +407,9 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 		case CB_TAG_CBMEM_ENTRY:
 			cb_parse_cbmem_entry(ptr, info);
 			break;
+		case CB_TAG_BOARD_CONFIG:
+			cb_parse_board_config(ptr, info);
+			break;
 		case CB_TAG_BOARD_ID:
 			cb_parse_board_id(ptr, info);
 			break;
Signature · 1 line
Sent by a computer, using git, on the internet
#19 lore raw

PATCH v4 15/28 pstore: Add pstore address from coreboot tables

In reply to Stephen Boyd

Set the pstore address and size based on the coreboot tables if the coreboot tables are populated.

---
 cmd/pstore.c | 51 ++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 9 deletions(-)
cmd/pstore.c +42 -9
index 9795eea2dbc3..f8858b382215 100644
@@ -3,8 +3,10 @@
  * Copyright © 2019 Collabora Ltd
  */
 
+#include <cb_sysinfo.h>
 #include <config.h>
 #include <command.h>
+#include <event.h>
 #include <fdtdec.h>
 #include <fs.h>
 #include <log.h>
@@ -141,6 +143,19 @@ static void pstore_init_buffer_size(void)
 		buffer_size = pstore_pmsg_size;
 }
 
+static void pstore_set_end(void)
+{
+	if (pstore_length < (pstore_record_size + pstore_console_size
+			     + pstore_ftrace_size + pstore_pmsg_size)) {
+		printf("pstore <len> should be larger than the sum of all records sizes\n");
+		pstore_length = 0;
+	}
+
+	log_debug("pstore set done: start 0x%08llx - length 0x%llx\n",
+		  (unsigned long long)pstore_addr,
+		  (unsigned long long)pstore_length);
+}
+
 /**
  * pstore_set() - Initialize PStore settings from command line arguments
  * @cmdtp: Command data struct pointer
@@ -194,19 +209,37 @@ static int pstore_set(struct cmd_tbl *cmdtp, int flag,  int argc,
 	if (argc > 7)
 		pstore_ecc_size = hextoul(argv[7], NULL);
 
-	if (pstore_length < (pstore_record_size + pstore_console_size
-			     + pstore_ftrace_size + pstore_pmsg_size)) {
-		printf("pstore <len> should be larger than the sum of all records sizes\n");
-		pstore_length = 0;
-	}
-
-	log_debug("pstore set done: start 0x%08llx - length 0x%llx\n",
-	          (unsigned long long)pstore_addr,
-	          (unsigned long long)pstore_length);
+	pstore_set_end();
 
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(SYS_COREBOOT)
+static int pstore_coreboot_init(void)
+{
+	const struct sysinfo_t *sysinfo;
+
+	sysinfo = cb_get_sysinfo();
+	if (!sysinfo)
+		return 0;
+
+	/*
+	 * The sysinfo pointer always exists, while the pstore buffer will be
+	 * zero size if this isn't a coreboot payload.
+	 */
+	if (!sysinfo->ramoops_buffer_size)
+		return 0;
+
+	pstore_addr = sysinfo->ramoops_buffer;
+	pstore_length = sysinfo->ramoops_buffer_size;
+
+	pstore_set_end();
+
+	return 0;
+}
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, pstore_coreboot_init);
+#endif
+
 /**
  * pstore_print_buffer() - Print buffer
  * @type: buffer type
Signature · 1 line
Sent by a computer, using git, on the internet
#20 lore raw

PATCH v4 16/28 coreboot: Add /firmware/coreboot node to DT

In reply to Stephen Boyd

Populate the firmware node with a coreboot node detailing where the coreboot tables and CBMEM area are located.

---
 boot/image-fdt.c          |   4 ++
 include/cb_sysinfo.h      |   7 +++
 lib/coreboot/cb_sysinfo.c | 120 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 131 insertions(+)
boot/image-fdt.c +4 -0
index 8f718ad29f6b..2d37be0ff7da 100644
@@ -8,6 +8,7 @@
  * Wolfgang Denk, DENX Software Engineering, [email protected].
  */
 
+#include <cb_sysinfo.h>
 #include <command.h>
 #include <fdt_support.h>
 #include <fdtdec.h>
@@ -619,6 +620,9 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
 #if IS_ENABLED(CONFIG_CMD_PSTORE)
 	/* Append PStore configuration */
 	fdt_fixup_pstore(blob);
+#endif
+#if CONFIG_IS_ENABLED(SYS_COREBOOT)
+	fdt_fixup_coreboot(blob);
 #endif
 	if (IS_ENABLED(CONFIG_OF_BOARD_SETUP)) {
 		const char *skip_board_fixup;
include/cb_sysinfo.h +7 -0
index b11d42be549c..b2128bb20a19 100644
@@ -264,6 +264,13 @@ int coreboot_early_init(void);
  */
 const struct sysinfo_t *cb_get_sysinfo(void);
 
+/**
+ * fdt_fixup_coreboot() - Add the /firmware/coreboot node to the FDT
+ *
+ * Add the /firmware/coreboot node to the FDT if U-Boot is a coreboot payload.
+ */
+void fdt_fixup_coreboot(void *blob);
+
 /**
  * coreboot_dram_init_banksize() - Initilize RAM banksize from coreboot sysinfo
  * table
lib/coreboot/cb_sysinfo.c +120 -0

129 lines not on this page · raw message

Signature · 1 line
Sent by a computer, using git, on the internet
#21 lore raw

PATCH v4 17/28 coreboot: Move timestamp parsing to generic place

In reply to Stephen Boyd

Move the timestamp code out of x86/cpu/coreboot to lib/coreboot and make it generic. This lets us migrate the timestamp table from coreboot into U-Boot's version of boot stage timing and use it on ARM based devices.

---
 arch/x86/cpu/coreboot/Makefile                      |  1 -
 arch/x86/cpu/coreboot/coreboot.c                    |  6 +-----
 arch/x86/lib/bootm.c                                |  5 ++---
 arch/x86/lib/zimage.c                               |  3 ---
 .../timestamp.h => include/coreboot_timestamp.h     |  7 -------
 lib/coreboot/Makefile                               |  1 +
 lib/coreboot/cb_sysinfo.c                           |  3 +++
 {arch/x86/cpu => lib}/coreboot/timestamp.c          | 13 ++++++++-----
 8 files changed, 15 insertions(+), 24 deletions(-)
 rename arch/x86/include/asm/arch-coreboot/timestamp.h => include/coreboot_timestamp.h (68%)
 rename {arch/x86/cpu => lib}/coreboot/timestamp.c (84%)
arch/x86/cpu/coreboot/Makefile +0 -1
index a6c7d0e56d50..f7ba346b83cd 100644
@@ -20,4 +20,3 @@ else
 obj-y += sdram.o
 endif
 obj-y += coreboot.o
-obj-y += timestamp.o
arch/x86/cpu/coreboot/coreboot.c +1 -5
index e1dbce4f0b29..33e37376e9f4 100644
@@ -6,6 +6,7 @@
  */
 
 #include <cb_sysinfo.h>
+#include <coreboot_timestamp.h>
 #include <cpu_func.h>
 #include <event.h>
 #include <fdtdec.h>
@@ -15,7 +16,6 @@
 #include <asm/io.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
-#include <asm/arch/timestamp.h>
 #include <dm/ofnode.h>
 
 int arch_cpu_init(void)
@@ -35,8 +35,6 @@ int arch_cpu_init(void)
 	gd_set_acpi_start(map_to_sysmem(lib_sysinfo.rsdp));
 	gd_set_smbios_start(lib_sysinfo.smbios_start);
 
-	timestamp_init();
-
 	return 0;
 }
 
@@ -74,8 +72,6 @@ static void board_final_init(void)
 
 static int last_stage_init(void)
 {
-	timestamp_add_to_bootstage();
-
 	if (IS_ENABLED(CONFIG_XPL_BUILD))
 		return 0;
 
arch/x86/lib/bootm.c +2 -3
index 0827a884b1d2..f46d78946929 100644
@@ -10,6 +10,8 @@
 #include <bootm.h>
 #include <bootstage.h>
 #include <command.h>
+#include <coreboot_tables.h>
+#include <coreboot_timestamp.h>
 #include <efi.h>
 #include <hang.h>
 #include <log.h>
@@ -24,9 +26,6 @@
 #include <asm/cpu.h>
 #include <asm/byteorder.h>
 #include <asm/zimage.h>
-#ifdef CONFIG_SYS_COREBOOT
-#include <asm/arch/timestamp.h>
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
arch/x86/lib/zimage.c +0 -3
index 2ea9bcf59c27..8d40714dad0b 100644
@@ -31,9 +31,6 @@
 #include <asm/bootparam.h>
 #include <asm/efi.h>
 #include <asm/global_data.h>
-#ifdef CONFIG_SYS_COREBOOT
-#include <asm/arch/timestamp.h>
-#endif
 #include <linux/compiler.h>
 #include <linux/ctype.h>
 #include <linux/libfdt.h>
include/coreboot_timestamp.h renamed from arch/x86/include/asm/arch-coreboot/timestamp.h +0 -7
similarity index 68%
rename from arch/x86/include/asm/arch-coreboot/timestamp.h
rename to include/coreboot_timestamp.h
index 227316975047..8f34d801037d 100644
@@ -14,11 +14,4 @@ void timestamp_init(void);
 void timestamp_add(enum timestamp_id id, uint64_t ts_time);
 void timestamp_add_now(enum timestamp_id id);
 
-/**
- * timestamp_add_to_bootstage - Add important coreboot timestamps to bootstage
- *
- * Return: 0 if ok, -1 if no timestamps were found
- */
-int timestamp_add_to_bootstage(void);
-
 #endif
lib/coreboot/Makefile +1 -0
index a0027bdfa505..c81f2eae58b9 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_$(XPL_)COREBOOT_SYSINFO) += cb_sysinfo.o
 ifndef CONFIG_XPL_BUILD
 obj-y += sdram.o
 endif
+obj-$(CONFIG_$(XPL_)COREBOOT_SYSINFO) += timestamp.o
lib/coreboot/cb_sysinfo.c +3 -0
index 0155b72ff37e..ec9a47242e34 100644
@@ -7,6 +7,7 @@
  */
 
 #include <cb_sysinfo.h>
+#include <coreboot_timestamp.h>
 #include <fdt_support.h>
 #include <init.h>
 #include <mapmem.h>
@@ -491,6 +492,8 @@ int get_coreboot_info(struct sysinfo_t *info)
 	gd->arch.coreboot_table = addr;
 	gd->flags |= GD_FLG_SKIP_LL_INIT;
 
+	timestamp_init();
+
 	return 0;
 }
 
lib/coreboot/timestamp.c renamed from arch/x86/cpu/coreboot/timestamp.c +8 -5
similarity index 84%
rename from arch/x86/cpu/coreboot/timestamp.c
rename to lib/coreboot/timestamp.c
index 18be969ccea6..192a28d7188a 100644
@@ -7,10 +7,12 @@
 
 #include <bootstage.h>
 #include <cb_sysinfo.h>
+#include <coreboot_tables.h>
+#include <coreboot_timestamp.h>
+#include <event.h>
 #include <errno.h>
-#include <asm/arch/timestamp.h>
-#include <asm/u-boot-x86.h>
 #include <linux/compiler.h>
+#include <time.h>
 
 void timestamp_init(void)
 {
@@ -33,10 +35,10 @@ void timestamp_add(enum timestamp_id id, uint64_t ts_time)
 
 void timestamp_add_now(enum timestamp_id id)
 {
-	timestamp_add(id, rdtsc());
+	timestamp_add(id, get_ticks());
 }
 
-int timestamp_add_to_bootstage(void)
+static int timestamp_add_to_bootstage(void)
 {
 	const struct sysinfo_t *info = cb_get_sysinfo();
 	const struct timestamp_table *ts_table = info->tstamp_table;
@@ -69,9 +71,10 @@ int timestamp_add_to_bootstage(void)
 		if (name) {
 			bootstage_add_record(0, name, BOOTSTAGEF_ALLOC,
 					     tse->entry_stamp /
-							get_tbclk_mhz());
+							(get_tbclk() / 1000000));
 		}
 	}
 
 	return 0;
 }
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, timestamp_add_to_bootstage);
Signature · 1 line
Sent by a computer, using git, on the internet
#22 lore raw

PATCH v4 18/28 coreboot: Dump VPD information in cbsysinfo command

In reply to Stephen Boyd

Coreboot populates a memory copy of the vital product data (VPD) during boot. Read this data structure and print out the contents in the cbsysinfo command.

Example: (redacted some things)

Chrome OS VPD: 00000000ffffd000
RO size : 24e
RW size : 122
"region" = "us"
"bluetooth_mac0" = "8C:FD:F0:40:15:28"
"wifi_mac0" = "8C:FD:F0:40:15:22"
"in_accel_x_lid_calibbias" = "38"
"in_accel_y_lid_calibbias" = "11"
...

---
 cmd/cbsysinfo.c           | 34 +++++++++++++++++++++++++++++++++
 include/cb_sysinfo.h      |  4 ++++
 include/coreboot_tables.h | 13 +++++++++++++
 lib/coreboot/cb_sysinfo.c | 40 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+)
cmd/cbsysinfo.c +34 -0
index d6ab71a3db8d..74a66f8c1b9c 100644
@@ -436,6 +436,40 @@ static void show_table(struct sysinfo_t *info, bool verbose)
 	print_hex("MTC size", info->mtc_size);
 
 	print_ptr("Chrome OS VPD", info->chromeos_vpd);
+	if (info->chromeos_vpd) {
+		struct vpd_cbmem *vpd = info->chromeos_vpd;
+
+		print_hex("RO size", vpd->ro_size);
+		print_hex("RW size", vpd->rw_size);
+
+		unsigned int i = 0;
+		unsigned int len = vpd->ro_size;
+		const u8 *blob = vpd->blob;
+
+		while (i < len) {
+			unsigned int vpd_type = blob[i];
+
+			switch (vpd_type) {
+			case VPD_TYPE_INFO:
+			case VPD_TYPE_STRING:
+				i++;
+				unsigned int key_offset;
+				unsigned int key_len;
+				unsigned int val_offset;
+				unsigned int val_len;
+
+				i = vpd_cbmem_parse_key_value(blob, i, &key_offset, &key_len, &val_offset, &val_len);
+				if (vpd_type == VPD_TYPE_STRING)
+					printf("  \"%.*s\" = \"%.*s\"\n", key_len, blob + key_offset, val_len, blob + val_offset);
+
+				break;
+			default:
+				i++;
+				break;
+			}
+		}
+	}
+
 	print_ptr("RSDP", info->rsdp);
 	printf("%-12s: ", "Unimpl.");
 	if (info->unimpl_count) {
include/cb_sysinfo.h +4 -0
index b2128bb20a19..f6c4f3a5edea 100644
@@ -264,6 +264,10 @@ int coreboot_early_init(void);
  */
 const struct sysinfo_t *cb_get_sysinfo(void);
 
+unsigned int vpd_cbmem_parse_key_value(const u8 *blob, unsigned int offset,
+		unsigned int *key_offset, unsigned int *key_len,
+		unsigned int *val_offset, unsigned int *val_len);
+
 /**
  * fdt_fixup_coreboot() - Add the /firmware/coreboot node to the FDT
  *
include/coreboot_tables.h +13 -0
index 6e7686e360c5..7d54ff94cf93 100644
@@ -551,6 +551,19 @@ struct cbmem_entry {
 #define CBMEM_ID_CONSOLE		0x434f4e53
 #define CBMEM_ID_NONE			0x00000000
 
+struct vpd_cbmem {
+	u32 magic;
+	u32 version;
+	u32 ro_size;
+	u32 rw_size;
+	u8 blob[];
+};
+
+#define VPD_TYPE_TERMINATOR		0x00
+#define VPD_TYPE_STRING			0x01
+#define VPD_TYPE_INFO			0xfe
+#define VPD_TYPE_IMPLICIT_TERMINATOR	0xff
+
 /**
  * high_table_reserve() - reserve configuration table in high memory
  *
lib/coreboot/cb_sysinfo.c +40 -0
index ec9a47242e34..d2e5e6d9bb6e 100644
@@ -634,3 +634,43 @@ clean_coreboot:
 	fdt_del_node_and_alias(blob, node);
 }
 #endif
+
+/*
+ * Parse the length header that is 7 bits of length and a top bit indicating
+ * "more" to the length.
+ *
+ * |  7   | 6   5   4  3  2  1   0 |
+ * |------+------------------------|
+ * | more |        length          |
+ *
+ * The "more" bit indicates the next byte after this one has more lower
+ * significant 7 bits. This can be repeated multiple times to make long keys or
+ * values.
+ */
+static unsigned int vpd_cbmem_parse_len(const u8 *blob, unsigned int i,
+					unsigned int *start, unsigned int *_len)
+{
+	u8 more;
+	unsigned int len = 0;
+
+	do {
+		more = blob[i] & 0x80;
+		len <<= 7;
+		len |= blob[i] & 0x7f;
+		i++;
+	} while (more);
+
+	*_len = len;
+	*start = i;
+
+	return i + len;
+}
+
+unsigned int vpd_cbmem_parse_key_value(const u8 *blob, unsigned int offset,
+		unsigned int *key_offset, unsigned int *key_len,
+		unsigned int *val_offset, unsigned int *val_len)
+{
+	offset = vpd_cbmem_parse_len(blob, offset, key_offset, key_len);
+
+	return vpd_cbmem_parse_len(blob, offset, val_offset, val_len);
+}
Signature · 1 line
Sent by a computer, using git, on the internet
#23 lore raw

PATCH v4 19/28 coreboot: Set serial# from VPD

In reply to Stephen Boyd

Set the serial number environment variable based on the value in VPD.

---
 lib/coreboot/cb_sysinfo.c | 62 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
lib/coreboot/cb_sysinfo.c +62 -0
index d2e5e6d9bb6e..92e4f9ca0c0c 100644
@@ -674,3 +674,65 @@ unsigned int vpd_cbmem_parse_key_value(const u8 *blob, unsigned int offset,
 
 	return vpd_cbmem_parse_len(blob, offset, val_offset, val_len);
 }
+
+static unsigned int coreboot_set_one(const u8 *blob, unsigned int i)
+{
+	unsigned int vpd_type = blob[i++];
+	unsigned int key_offset;
+	unsigned int key_len;
+	unsigned int val_offset;
+	unsigned int val_len;
+	const u8 *key;
+	const u8 *val;
+
+	if (vpd_type != VPD_TYPE_INFO && vpd_type != VPD_TYPE_STRING)
+		return i;
+
+	i = vpd_cbmem_parse_key_value(blob, i, &key_offset, &key_len, &val_offset, &val_len);
+	if (vpd_type != VPD_TYPE_STRING)
+		return i;
+
+	key = blob + key_offset;
+	val = blob + val_offset;
+
+	if (!strncmp(key, "serial_number", key_len)) {
+		unsigned char serialno[64];
+
+		if (val_len > ARRAY_SIZE(serialno))
+			val_len = ARRAY_SIZE(serialno);
+
+		strncpy(serialno, val, val_len);
+		env_set("serial#", serialno);
+	}
+
+	return i;
+}
+
+/*
+ * Set environment variables based on the contents of VPD.
+ */
+static int coreboot_settings_r(void)
+{
+	const struct sysinfo_t *sysinfo;
+	const struct vpd_cbmem *vpd;
+	unsigned int i = 0;
+	unsigned int len;
+	const u8 *blob;
+
+	sysinfo = cb_get_sysinfo();
+	if (!sysinfo)
+		return 0;
+
+	vpd = sysinfo->chromeos_vpd;
+	if (!vpd)
+		return 0;
+
+	len = vpd->ro_size;
+	blob = vpd->blob;
+
+	while (i < len)
+		i = coreboot_set_one(blob, i);
+
+	return 0;
+}
+EVENT_SPY_SIMPLE(EVT_SETTINGS_R, coreboot_settings_r);
Signature · 1 line
Sent by a computer, using git, on the internet
#24 lore raw

PATCH v4 20/28 coreboot: Set wifi mac addr from VPD

In reply to Stephen Boyd

Set the environment variable for the wlan mac address based on the value stored in VPD.

---
 lib/coreboot/cb_sysinfo.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/coreboot/cb_sysinfo.c +10 -0
index 92e4f9ca0c0c..555abc93f1cb 100644
@@ -12,6 +12,7 @@
 #include <init.h>
 #include <mapmem.h>
 #include <net.h>
+#include <net-common.h>
 #include <asm/global_data.h>
 #include <linux/errno.h>
 
@@ -703,6 +704,15 @@ static unsigned int coreboot_set_one(const u8 *blob, unsigned int i)
 
 		strncpy(serialno, val, val_len);
 		env_set("serial#", serialno);
+	} else if (!strncmp(key, "wifi_mac0", key_len)) {
+		u8 buf[ARP_HLEN_ASCII + 1];
+		unsigned char ethaddr[6];
+
+		if (!eth_env_get_enetaddr("wifiaddr", ethaddr)) {
+			strncpy(buf, val, val_len);
+			string_to_enetaddr(buf, ethaddr);
+			eth_env_set_enetaddr("wifiaddr", ethaddr);
+		}
 	}
 
 	return i;
Signature · 1 line
Sent by a computer, using git, on the internet
#25 lore raw

PATCH v4 21/28 fdt: Populate wifi MAC from environment

In reply to Stephen Boyd

Set the MAC address of the wifi device node with an alias like 'wifi0' or 'wifi' based on the environment variables. This allows us to populate the wifi device's MAC address on devices like Trogdor that store the wifi MAC in the VPD.

---
 boot/fdt_support.c        | 54 +++++++++++++++++++++++++++------------
 lib/coreboot/cb_sysinfo.c |  2 ++
 2 files changed, 40 insertions(+), 16 deletions(-)
boot/fdt_support.c +38 -16
index 92f2f534ee02..a02de4dfd9c5 100644
@@ -611,13 +611,34 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
 	return fdt_fixup_memory_banks(blob, &start, &size, 1);
 }
 
+static void fdt_fixup_net_node(void *fdt, const char *path, const char *mac)
+{
+	int j;
+	char *tmp, *end;
+	unsigned char mac_addr[ARP_HLEN];
+
+	tmp = env_get(mac);
+	if (!tmp)
+		return;
+
+	for (j = 0; j < 6; j++) {
+		mac_addr[j] = tmp ?
+			      hextoul(tmp, &end) : 0;
+		if (tmp)
+			tmp = (*end) ? end + 1 : end;
+	}
+
+	do_fixup_by_path(fdt, path, "mac-address",
+			 &mac_addr, 6, 0);
+	do_fixup_by_path(fdt, path, "local-mac-address",
+			 &mac_addr, 6, 1);
+}
+
 void fdt_fixup_ethernet(void *fdt)
 {
-	int i = 0, j, prop;
-	char *tmp, *end;
+	int i = 0, w = 0, j, prop;
 	char mac[16];
 	const char *path;
-	unsigned char mac_addr[ARP_HLEN];
 	int offset;
 #ifdef FDT_SEQ_MACADDR_FROM_ENV
 	int nodeoff;
@@ -670,21 +691,22 @@ void fdt_fixup_ethernet(void *fdt)
 				continue;
 			i++;
 #endif
-			tmp = env_get(mac);
-			if (!tmp)
+			fdt_fixup_net_node(fdt, path, mac);
+		} else if (!strncmp(name, "wifi", 4)) {
+			/* Treat plain "wifi" same as "wifi0". */
+			if (!strcmp(name, "wifi"))
+				w = 0;
+			else
+				w = trailing_strtol(name);
+			if (w != -1) {
+				if (w == 0)
+					strcpy(mac, "wifiaddr");
+				else
+					sprintf(mac, "wifi%daddr", w);
+			} else {
 				continue;
-
-			for (j = 0; j < 6; j++) {
-				mac_addr[j] = tmp ?
-					      hextoul(tmp, &end) : 0;
-				if (tmp)
-					tmp = (*end) ? end + 1 : end;
 			}
-
-			do_fixup_by_path(fdt, path, "mac-address",
-					 &mac_addr, 6, 0);
-			do_fixup_by_path(fdt, path, "local-mac-address",
-					 &mac_addr, 6, 1);
+			fdt_fixup_net_node(fdt, path, mac);
 		}
 	}
 }
lib/coreboot/cb_sysinfo.c +2 -0
index 555abc93f1cb..959eaaab8e88 100644
@@ -686,9 +686,11 @@ static unsigned int coreboot_set_one(const u8 *blob, unsigned int i)
 	const u8 *key;
 	const u8 *val;
 
+	/* We only care about strings that may contain keys we can use */
 	if (vpd_type != VPD_TYPE_INFO && vpd_type != VPD_TYPE_STRING)
 		return i;
 
+	/* Conntinue to move 'i' forward through the VPD blob */
 	i = vpd_cbmem_parse_key_value(blob, i, &key_offset, &key_len, &val_offset, &val_len);
 	if (vpd_type != VPD_TYPE_STRING)
 		return i;
Signature · 1 line
Sent by a computer, using git, on the internet
#26 lore raw

PATCH v4 22/28 mach-snapdragon: Support booting as a coreboot payload

In reply to Stephen Boyd

Coreboot sets up the DRAM, CPU, and devices before booting a payload, meaning we can parse the coreboot tables at boot for memory info when running as a payload. Use the memory descriptors from coreboot if the tables are present so that Snapdragon SoCs can run U-boot as a coreboot payload.

---
 arch/arm/mach-snapdragon/board.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm/mach-snapdragon/board.c +23 -0
index deae4d323789..6850f226f8eb 100644
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <asm/psci.h>
 #include <asm/system.h>
+#include <cb_sysinfo.h>
 #include <dm/device.h>
 #include <dm/pinctrl.h>
 #include <dm/uclass-internal.h>
@@ -48,6 +49,10 @@ static struct {
 
 int dram_init(void)
 {
+#ifdef CONFIG_SYS_COREBOOT
+	if (gd->arch.coreboot_table)
+		return coreboot_dram_init();
+#endif
 	/*
 	 * gd->ram_base / ram_size have been setup already
 	 * in qcom_parse_memory().
@@ -81,8 +86,21 @@ static void qcom_configure_bi_dram(void)
 	}
 }
 
+phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
+{
+#ifdef CONFIG_SYS_COREBOOT
+	if (gd->arch.coreboot_table)
+		return coreboot_board_get_usable_ram_top(total_size);
+#endif
+	return gd->ram_top;
+}
+
 int dram_init_banksize(void)
 {
+#ifdef CONFIG_SYS_COREBOOT
+	if (gd->arch.coreboot_table)
+		return coreboot_dram_init_banksize();
+#endif
 	qcom_configure_bi_dram();
 
 	return 0;
@@ -235,6 +253,11 @@ int board_fdt_blob_setup(void **fdtp)
 		ret = qcom_parse_memory(external_fdt);
 	}
 
+#ifdef CONFIG_SYS_COREBOOT
+	if (gd->arch.coreboot_table)
+		debug("Using coreboot tables for memory ranges\n");
+	else
+#endif
 	if (ret < 0)
 		panic("No valid memory ranges found!\n");
 
Signature · 1 line
Sent by a computer, using git, on the internet
#27 lore raw

PATCH v4 23/28 mach-snapdragon: Allow usb3 to work when a coreboot payload

In reply to Stephen Boyd

Coreboot already initializes the USB3 controller and PHY on Qualcomm devices. Skip fixing up the USB node on platforms that are a coreboot payload. This provides a working USB-A port on device like Lazor.

---
 arch/arm/mach-snapdragon/of_fixup.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
arch/arm/mach-snapdragon/of_fixup.c +15 -7
index 1ea0c18c2f27..fd4aa3ba7055 100644
@@ -41,13 +41,6 @@ static int fixup_qcom_dwc3(struct device_node *glue_np)
 
 	debug("Fixing up %s\n", glue_np->name);
 
-	/* Tell the glue driver to configure the wrapper for high-speed only operation */
-	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
-	if (ret) {
-		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
-		return ret;
-	}
-
 	/* Find the DWC3 node itself */
 	dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
 	if (!dwc3) {
@@ -92,6 +85,21 @@ static int fixup_qcom_dwc3(struct device_node *glue_np)
 		return ret;
 	}
 
+	/*
+	 * Coreboot already initialized USB to the point that USB SuperSpeed
+	 * works, don't tell the glue driver to only use high-speed.
+	 */
+	if (gd->arch.coreboot_table)
+		return 0;
+
+	/* Tell the glue driver to configure the wrapper for high-speed only operation */
+	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
+	if (ret) {
+		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
+		return ret;
+	}
+
+	/* Tell the core driver to configure for high-speed only operation */
 	ret = of_write_prop(dwc3, "maximum-speed", strlen("high-speed") + 1, "high-speed");
 	if (ret) {
 		log_err("Failed to set 'maximum-speed' property: %d\n", ret);
Signature · 1 line
Sent by a computer, using git, on the internet
#28 lore raw

Re: [PATCH v4 23/28] mach-snapdragon: Allow usb3 to work when a coreboot payload

Quoted 28 lines · Stephen Boyd

Coreboot already initializes the USB3 controller and PHY on Qualcomm devices. Skip fixing up the USB node on platforms that are a coreboot payload. This provides a working USB-A port on device like Lazor.

---
  arch/arm/mach-snapdragon/of_fixup.c | 22 +++++++++++++++-------
  1 file changed, 15 insertions(+), 7 deletions(-)
arch/arm/mach-snapdragon/of_fixup.c +0 -7
index 1ea0c18c2f27..fd4aa3ba7055 100644
@@ -41,13 +41,6 @@ static int fixup_qcom_dwc3(struct device_node *glue_np)
 
  	debug("Fixing up %s\n", glue_np->name);
 
-	/* Tell the glue driver to configure the wrapper for high-speed only operation */
-	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
-	if (ret) {
-		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
-		return ret;
-	}
-
  	/* Find the DWC3 node itself */
  	dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
  	if (!dwc3) {

arch/arm/mach-snapdragon/of_fixup.c static int fixup_qcom_dwc3(struct device_node *glue_np) · line 93

Quoted 9 lines
arch/arm/mach-snapdragon/of_fixup.c +6 -0
@@ -92,6 +85,21 @@ static int fixup_qcom_dwc3(struct device_node *glue_np)
  		return ret;
  	}
 
+	/*
+	 * Coreboot already initialized USB to the point that USB SuperSpeed
+	 * works, don't tell the glue driver to only use high-speed.
+	 */
+	if (gd->arch.coreboot_table)
+		return 0;

This is missing an #ifdef, fixed it while applying.> +

Quoted 11 lines
arch/arm/mach-snapdragon/of_fixup.c +8 -0
+	/* Tell the glue driver to configure the wrapper for high-speed only operation */
+	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
+	if (ret) {
+		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
+		return ret;
+	}
+
+	/* Tell the core driver to configure for high-speed only operation */
  	ret = of_write_prop(dwc3, "maximum-speed", strlen("high-speed") + 1, "high-speed");
  	if (ret) {
  		log_err("Failed to set 'maximum-speed' property: %d\n", ret);
Signature · 1 line
Casey (she/they)
#29 lore raw

PATCH v4 24/28 board: google: Add board_debug_uart_init() for Trogdor

In reply to Stephen Boyd

Implement board_debug_uart_init() for Trogdor boards so that the debug UART can be used. Initialize the clk to XO speed (19.2MHz) and change the pin configuration to mux out the uart hardware on the pins that are connected to the closed case debug (CCD) port for the AP. This is enough to get the early debug console working on boards like Lazor, but it should work for all Google Trogdor boards.

---
 board/google/trogdor/Makefile     |  3 +++
 board/google/trogdor/debug.config |  6 +++++
 board/google/trogdor/debug_uart.c | 41 +++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 board/google/trogdor/Makefile
 create mode 100644 board/google/trogdor/debug.config
 create mode 100644 board/google/trogdor/debug_uart.c
board/google/trogdor/Makefile new file +3 -0
new file mode 100644
index 000000000000..fd2933cf1e6f
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_DEBUG_UART_BOARD_INIT) += debug_uart.o
board/google/trogdor/debug.config new file +6 -0
new file mode 100644
index 000000000000..7d8a6706a92e
@@ -0,0 +1,6 @@
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_BASE=0xa88000
+CONFIG_DEBUG_UART_MSM_GENI=y
+CONFIG_DEBUG_UART_CLOCK=36864000
+CONFIG_DEBUG_UART_BOARD_INIT=y
board/google/trogdor/debug_uart.c new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
Sent by a computer, using git, on the internet
Reviewed-by on v4 24/28
#30 lore raw

Re: [PATCH v4 24/28] board: google: Add board_debug_uart_init() for Trogdor

Quoted 8 lines · Stephen Boyd

Implement board_debug_uart_init() for Trogdor boards so that the debug UART can be used. Initialize the clk to XO speed (19.2MHz) and change the pin configuration to mux out the uart hardware on the pins that are connected to the closed case debug (CCD) port for the AP. This is enough to get the early debug console working on boards like Lazor, but it should work for all Google Trogdor boards.

Would you be willing to add a MAINTAINERS file here for the trogdor specific bits?

Kind regards,> ---

Quoted 76 lines
  board/google/trogdor/Makefile     |  3 +++
  board/google/trogdor/debug.config |  6 +++++
  board/google/trogdor/debug_uart.c | 41 +++++++++++++++++++++++++++++++
  3 files changed, 50 insertions(+)

create mode 100644 board/google/trogdor/Makefile create mode 100644 board/google/trogdor/debug.config create mode 100644 board/google/trogdor/debug_uart.c

board/google/trogdor/Makefile new file +3 -0
new file mode 100644
index 000000000000..fd2933cf1e6f
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_DEBUG_UART_BOARD_INIT) += debug_uart.o
board/google/trogdor/debug.config new file +6 -0
new file mode 100644
index 000000000000..7d8a6706a92e
@@ -0,0 +1,6 @@
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_BASE=0xa88000
+CONFIG_DEBUG_UART_MSM_GENI=y
+CONFIG_DEBUG_UART_CLOCK=36864000
+CONFIG_DEBUG_UART_BOARD_INIT=y
board/google/trogdor/debug_uart.c new file +41 -0
new file mode 100644
index 000000000000..3d15d0d77728
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <asm/io.h>
+#include <debug_uart.h>
+#include <linux/delay.h>
+
+/*
+ * Enable the UART8 clks and pinctrl settings for SC7180.
+ *
+ * The debug UART goes out over CCD. The debug uart clk setting is 36864000 to
+ * make the buad rate calculation come out properly for the qcom geni serial
+ * driver.
+ */
+void board_debug_uart_init(void)
+{
+	u32 val, mask;
+	unsigned int timeout = 100;
+
+	/* Enable wrap1_s2 clk */
+	val = readl(0x100000 + 0x52008);
+	val |= BIT(24);
+	writel(val, 0x100000 + 0x52008);
+	/* Wait for enable */
+	do {
+		val = readl(0x100000 + 0x18274);
+		mask = GENMASK(30, 28) | BIT(31);
+		val &= mask;
+		if ((val & BIT(31)) == 0 || ((val >> 28) & 7) == 1)
+			break;
+		udelay(10);
+	} while (timeout--);
+
+	/*
+	 * Configure GPIOs
+	 * Bits: 0-1 = pull
+	 * Bits: 2-4 = func
+	 * Bits: 6-8 = drive strength
+	 */
+	writel(0x3 | (1 << 2), 0x3900000 + (0x1000 * 44)); // Pin 44 - PULL_UP, func1 (qup12), 2ma
+	writel(0x3 | (1 << 2), 0x3900000 + (0x1000 * 45)); // Pin 45 - PULL_UP, func1 (qup12), 2ma
+}
Signature · 1 line
Casey (she/they)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#32 lore raw

Re: [PATCH v4 24/28] board: google: Add board_debug_uart_init() for Trogdor

Quoted 10 lines · Caleb Connolly via groups.io
Quoted 7 lines · Stephen Boyd

Implement board_debug_uart_init() for Trogdor boards so that the debug UART can be used. Initialize the clk to XO speed (19.2MHz) and change the pin configuration to mux out the uart hardware on the pins that are connected to the closed case debug (CCD) port for the AP. This is enough to get the early debug console working on boards like Lazor, but it should work for all Google Trogdor boards.

Quoted 5 lines
Quoted 1 line

Would you be willing to add a MAINTAINERS file here for the trogdor specific bits?

Oh right, CI fails since the trogdor defconfig doesn't have a maintainer, I'm happy to put it under ARM SNAPDRAGON but it would be great if you're willing to take it up. Please let me know ASAP (feel free to send a patch adding board/google/trogdor/MAINTAINERS on top of this series) so I can pick this up :)

Kind regards,>

Quoted 82 lines

Kind regards,> ---

Quoted 80 lines

  board/google/trogdor/Makefile     |  3 +++ board/google/trogdor/debug.config |  6 +++++ board/google/trogdor/debug_uart.c | 41 +++++++++++++++++++++++++++++++

  3 files changed, 50 insertions(+)

  create mode 100644 board/google/trogdor/Makefile create mode 100644 board/google/trogdor/debug.config create mode 100644 board/google/trogdor/debug_uart.c

board/google/trogdor/Makefile new file +3 -0
new file mode 100644
index 000000000000..fd2933cf1e6f
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_DEBUG_UART_BOARD_INIT) += debug_uart.o
board/google/trogdor/debug.config new file +6 -0
new file mode 100644
index 000000000000..7d8a6706a92e
@@ -0,0 +1,6 @@
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_BASE=0xa88000
+CONFIG_DEBUG_UART_MSM_GENI=y
+CONFIG_DEBUG_UART_CLOCK=36864000
+CONFIG_DEBUG_UART_BOARD_INIT=y
board/google/trogdor/debug_uart.c new file +10 -0
new file mode 100644
index 000000000000..3d15d0d77728
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <asm/io.h>
+#include <debug_uart.h>
+#include <linux/delay.h>
+
+/*
+ * Enable the UART8 clks and pinctrl settings for SC7180.
+ *
+ * The debug UART goes out over CCD. The debug uart clk setting is 

36864000 to
+ * make the buad rate calculation come out properly for the qcom geni serial
+ * driver.
+ */

board/google/trogdor/debug_uart.c new file +26 -0
+void board_debug_uart_init(void)
+{
+    u32 val, mask;
+    unsigned int timeout = 100;
+
+    /* Enable wrap1_s2 clk */
+    val = readl(0x100000 + 0x52008);
+    val |= BIT(24);
+    writel(val, 0x100000 + 0x52008);
+    /* Wait for enable */
+    do {
+        val = readl(0x100000 + 0x18274);
+        mask = GENMASK(30, 28) | BIT(31);
+        val &= mask;
+        if ((val & BIT(31)) == 0 || ((val >> 28) & 7) == 1)
+            break;
+        udelay(10);
+    } while (timeout--);
+
+    /*
+     * Configure GPIOs
+     * Bits: 0-1 = pull
+     * Bits: 2-4 = func
+     * Bits: 6-8 = drive strength
+     */
+    writel(0x3 | (1 << 2), 0x3900000 + (0x1000 * 44)); // Pin 44 - 

PULL_UP, func1 (qup12), 2ma
+    writel(0x3 | (1 << 2), 0x3900000 + (0x1000 * 45)); // Pin 45 - PULL_UP, func1 (qup12), 2ma
+}

Signature · 1 line
Casey (she/they)
#33 lore raw

PATCH v4 25/28 cmd: ximg: Support LZO compressed images

In reply to Stephen Boyd

Add support to decompress LZO images.

---
 cmd/ximg.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
cmd/ximg.c +15 -0
index 29d7c3279b39..a6341a078019 100644
@@ -14,6 +14,9 @@
 #include <cpu_func.h>
 #include <env.h>
 #include <gzip.h>
+#if IS_ENABLED(CONFIG_LZO)
+#include <linux/lzo.h>
+#endif
 #if IS_ENABLED(CONFIG_ZSTD)
 #include <linux/zstd.h>
 #endif
@@ -238,6 +241,18 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 			}
 			break;
 #endif /* CONFIG_BZIP2 */
+#if IS_ENABLED(CONFIG_LZO)
+		case IH_COMP_LZO:
+			{
+				int ret;
+				size_t size = unc_len;
+				printf("   Uncompressing part %d ... ", part);
+
+				ret = lzop_decompress((void *)data, len, (void *)dest, &size);
+				len = size;
+			}
+			break;
+#endif /* CONFIG_LZO */
 #if IS_ENABLED(CONFIG_ZSTD)
 		case IH_COMP_ZSTD:
 			{
Signature · 1 line
Sent by a computer, using git, on the internet
#34 lore raw

PATCH v4 26/28 cmd: ximg: Support LZ4 compressed images

In reply to Stephen Boyd

Add support to decompress LZ4 images. LZ4 is used on more recent Chromebooks to store the FIT image.

---
 cmd/ximg.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
cmd/ximg.c +13 -0
index a6341a078019..eed66c776d12 100644
@@ -30,6 +30,7 @@
 #include <asm/byteorder.h>
 #include <asm/cache.h>
 #include <asm/io.h>
+#include <u-boot/lz4.h>
 
 static int
 do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
@@ -253,6 +254,18 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 			}
 			break;
 #endif /* CONFIG_LZO */
+#if IS_ENABLED(CONFIG_LZ4)
+		case IH_COMP_LZ4:
+			{
+				int ret;
+				size_t size = unc_len;
+				printf("   Uncompressing part %d ... ", part);
+
+				ret = ulz4fn((void *)data, len, (void *)dest, &size);
+				len = size;
+			}
+			break;
+#endif /* CONFIG_LZ4 */
 #if IS_ENABLED(CONFIG_ZSTD)
 		case IH_COMP_ZSTD:
 			{
Signature · 1 line
Sent by a computer, using git, on the internet
#35 lore raw

PATCH v4 27/28 configs: Add chromebook_trogdor defconfig

In reply to Stephen Boyd

Add a config that boots on Trogdor Lazor devices.

---
 configs/chromebook_trogdor_defconfig | 138 +++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 configs/chromebook_trogdor_defconfig
configs/chromebook_trogdor_defconfig new file +138 -0
new file mode 100644
index 000000000000..c90dc946494c
@@ -0,0 +1,138 @@
+CONFIG_ARM=y
+CONFIG_SYS_VENDOR="google"
+CONFIG_SYS_BOARD="trogdor"
+CONFIG_SYS_CONFIG_NAME="qcom"
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_TEXT_BASE=0x80c00000
+CONFIG_SYS_MALLOC_LEN=0x4000000
+CONFIG_NR_DRAM_BANKS=32
+CONFIG_DEFAULT_DEVICE_TREE="qcom/sc7180-trogdor-lazor-r3-lte"
+CONFIG_SYS_LOAD_ADDR=0x80000000
+CONFIG_REMAKE_ELF=y
+CONFIG_SYS_COREBOOT=y
+CONFIG_EFI_RT_VOLATILE_STORE=y
+CONFIG_EFI_SCROLL_ON_CLEAR_SCREEN=y
+# CONFIG_BOOTEFI_HELLO_COMPILE is not set
+# CONFIG_BOOTEFI_TESTAPP_COMPILE is not set
+CONFIG_FIT=y
+CONFIG_FIT_BEST_MATCH=y
+CONFIG_BOOTSTD_FULL=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
+# CONFIG_EXPO is not set
+# CONFIG_BOOTMETH_SCRIPT is not set
+CONFIG_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_FDT=y
+CONFIG_SD_BOOT=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="!"
+CONFIG_AUTOBOOT_KEYED_CTRLC=y
+CONFIG_AUTOBOOT_MENU_SHOW=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+# CONFIG_USE_PREBOOT is not set
+CONFIG_LOGLEVEL=9
+CONFIG_CONSOLE_FLUSH_ON_NEWLINE=y
+# CONFIG_CONSOLE_MUX is not set
+# CONFIG_SYS_DEVICE_NULLDEV is not set
+CONFIG_LOG_MAX_LEVEL=9
+CONFIG_LOG_DEFAULT_LEVEL=3
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+# CONFIG_CYCLIC is not set
+CONFIG_HUSH_PARSER=y
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_CMD_VBE is not set
+CONFIG_CMD_BOOTMENU=y
+CONFIG_CMD_SHA1SUM=y
+CONFIG_SHA1SUM_VERIFY=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_LOADM=y
+CONFIG_CMD_MBR=y
+CONFIG_CMD_MISC=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_BKOPS_ENABLE=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_READ=y
+CONFIG_CMD_SPI=y
+CONFIG_DEFAULT_SPI_BUS=6
+CONFIG_CMD_USB=y
+# CONFIG_CMD_CLS is not set
+CONFIG_CMD_PSTORE=y
+CONFIG_CMD_PSTORE_MEM_ADDR=0x0
+CONFIG_CMD_PSTORE_RECORD_SIZE=0x40000
+CONFIG_CMD_PSTORE_CONSOLE_SIZE=0x40000
+CONFIG_CMD_PSTORE_FTRACE_SIZE=0x20000
+CONFIG_CMD_PSTORE_PMSG_SIZE=0x20000
+CONFIG_CMD_BOOTSTAGE=y
+CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_LOG=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_OF_LIVE=y
+# CONFIG_OF_TAG_MIGRATE is not set
+CONFIG_DM_WARN=y
+# CONFIG_OFNODE_MULTI_TREE is not set
+# CONFIG_SCSI_AHCI is not set
+CONFIG_CLK=y
+CONFIG_CLK_STUB=y
+CONFIG_CLK_QCOM_SC7180=y
+CONFIG_MSM_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_SYS_I2C_GENI=y
+CONFIG_CROS_EC_KEYB=y
+CONFIG_MISC=y
+CONFIG_CROS_EC=y
+CONFIG_CROS_EC_SPI=y
+# CONFIG_MMC_PCI is not set
+CONFIG_MMC_SDHCI_MSM=y
+# CONFIG_ETH_DESIGNWARE is not set
+CONFIG_PHY=y
+CONFIG_PHY_QCOM_QUSB2=y
+CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_PINCTRL_QCOM_SC7180=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_CROS_EC=y
+# CONFIG_SCSI is not set
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_CONS_INDEX=0
+# CONFIG_COREBOOT_SERIAL is not set
+# CONFIG_SYS_NS16550 is not set
+CONFIG_MSM_GENI_SERIAL=y
+CONFIG_SOC_QCOM=y
+CONFIG_QCOM_COMMAND_DB=y
+CONFIG_QCOM_RPMH=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SPI_GENI_QCOM=y
+# CONFIG_DM_USB_GADGET is not set
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_RTL8152=y
+CONFIG_VIDEO=y
+CONFIG_VIDEO_PCI_DEFAULT_FB_SIZE=0x1000
+CONFIG_VIDEO_MIPI_DSI=y
+# CONFIG_SIMPLE_PANEL is not set
+CONFIG_BMP=y
+CONFIG_VIDEO_BMP_GZIP=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+# CONFIG_RANDOM_UUID is not set
+# CONFIG_SHA256 is not set
+CONFIG_ZLIB_UNCOMPRESS=y
+CONFIG_BZIP2=y
+CONFIG_ZSTD=y
Signature · 1 line
Sent by a computer, using git, on the internet
#36 lore raw

PATCH v4 28/28 doc: chromebook_trogdor: Add document detailing installation steps

In reply to Stephen Boyd

Make it a little more ergonomic than navigating to the chromium.org docs by just documenting the steps needed to install U-Boot on a Trogdor chromebook. I've been using the Depthcharge 'altfw' flow to do this which is nice because you get to keep ChromeOS installed for any future firmware updates.

---
 doc/board/google/chromebook_trogdor.rst | 69 +++++++++++++++++++++++++
 doc/board/google/index.rst              |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 doc/board/google/chromebook_trogdor.rst
doc/board/google/chromebook_trogdor.rst new file +69 -0
new file mode 100644
index 000000000000..dc40b9072bd5
@@ -0,0 +1,69 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. sectionauthor:: Stephen Boyd <[email protected]>
+
+Chromebook Trogdor/Strongbad
+============================
+
+Trogdor and Strongbad are Chromebooks that are either clamshells or
+detachables. U-Boot can be installed into the alternate firmware (altfw) slot
+in the SPI-NOR flash chip and selected in the developer mode boot screen. This
+chain loads U-Boot from Depthcharge and avoids disabling the write protect
+screw.
+
+Enable Alternate Firmware
+=========================
+
+First, you need to enable developer mode on the Chromebook. On a clamshell
+that's done by pressing power + ESC + refresh. On a detachable you press the
+power button + volume up + volume down. Once you get to the recovery screen,
+press Ctrl+d to enter developer mode.
+
+In developer mode, switch to VT2 (use Ctrl+Alt+refresh) and log in as 'root'
+(the default has no password). Configure Depthcharge to load U-Boot::
+
+  cd /tmp
+  flashrom -r bios.bin
+  cat > ubootfw.txt <<EOF
+  0;uboot;uboot;u-boot for coreboot on ARM
+  1;uboot;uboot;u-boot for coreboot on ARM
+  EOF
+  cbfstool /tmp/bios.bin remove -r RW_LEGACY -n altfw/list
+  cbfstool bios.bin add -r RW_LEGACY -n altfw/list -f ubootfw.txt -t raw
+
+You can also prevent future ChromeOS firmware updates from replacing the
+alternate firmware::
+
+  cbfstool bios.bin remove -r RW_LEGACY -n cros_allow_auto_update
+
+And finally enable the alternate firmware feature::
+
+  crossystem dev_boot_altfw=1
+
+It's a good idea to flash the RW_LEGACY section now with this alternate
+firwmare list even though we haven't installed U-Boot yet::
+
+  flashrom -w bios.bin -i RW_LEGACY
+
+Installation
+------------
+
+Build U-Boot and obtain u-boot.elf::
+
+   $ make chromebook_trogdor_defconfig
+   $ make
+
+Copy the 'u-boot.elf' file to the Chromebook. On the Chromebook, add the u-boot
+payload::
+
+  cd /tmp
+  flashrom -r bios.bin
+  cbfstool bios.bin add-payload -r RW_LEGACY -c lzma -n uboot -f u-boot.elf
+  flashrom -w bios.bin -i RW_LEGACY
+
+Now you can reboot and select the "Select alternate bootloader" option. Select
+'uboot' to boot U-Boot. If you would like this to be the default boot option,
+you can boot into ChromeOS and switch to VT2 (use Ctrl+Alt+refresh) to use
+crossystem::
+
+  crossystem dev_default_boot=altfw
+
doc/board/google/index.rst +1 -0
index 061c79771875..1144b164162c 100644
@@ -9,3 +9,4 @@ Google
    chromebook_coral
    chromebook_link
    chromebook_samus
+   chromebook_trogdor
Signature · 1 line
Sent by a computer, using git, on the internet
#37 lore raw
In reply to Stephen Boyd

Hi Stephen,

There are multiple build errors with this branch, I started trying to fix a few but I think there's enough to warrant a respin...

Please build test for x86 and coreboot targets (try buildman)!

CI failures are here https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/jobs/1174915

Kind regards,

Quoted 182 lines · Stephen Boyd

This series supports running U-Boot as a payload on sc7180 Trogdor Chromebooks like Lazor or Wormdingler. This is a jumble of different patches to get to the final goal of booting a Linux distro from the eMMC on Lazor. I'm able to boot Fedora Workstation 41 from a USB stick on my Lazor.

I moved the reviewed patch to the start. After that one line fix there's a few patches to add support for the particular SoC used on Trogdor devices, sc7180. The next set of patches move the coreboot logic out of arch/x86/ into lib/ to find the coreboot tables on ARM and stash them in global data. Then I have a handful of patches to let the coreboot commands and utilities parse and populate various things like pstore and firmware details into the DTB with the proper data from the coreboot tables. Finally, I add the calls to coreboot dram parsing code in the snapdragon board so that if coreboot tables exist we get the memory info from coreboot instead of from an earlier stage DTB.

I tested the SPI driver with the crosec command. The cros bootflow method almost works, but it seems like chromeos userspace blows up spectacularly likely because crossystem can't figure out what board it is running on. I don't really care too much about booting chromeos userspace here so I'm ignoring that problem.

I'm able to install fedora on Lazor with this as long as I start the USB with CONFIG_PREBOOT=y. I tried to get this working on SC7280 Hoglin but it crashed in Fedora. I'm not sure why but it could be because the memory stuff was all wrong. Either way I hope it may work in the near future.

The display is almost there but I suspect I'll need to do the whole initialization all over again so I punted for now.

TODO:
* Get display working
* Implement FIT FDT picking similar to depthcharge based on coreboot tables indicating the SKU and board id

Changes from v3 https://lore.kernel.org/r/[email protected]
* GPIO chipselect in the SPI driver support
* sc7280 clk driver support for UART
* Enable the UART clk at probe
* Read VPD and inject the wifi MAC address
* Patch to inject wifi MAC from the environment
* Add a debug_board_init routine for trogdor to support early debug
* Add a defconfig

Changes from v2 https://lore.kernel.org/r/[email protected]
* Check SPI proto in probe
* Handle pins differently in pinctrl driver
* Pick up tags
* Rebase to ToT
* Update pinctrl driver for new changes in last few months
* Add some more gates to clk driver to handle missing clk warnings
* New patch to locate coreboot tables early

Changes from v1 https://lore.kernel.org/r/[email protected]
* Add Kconfig file in lib/coreboot/ to hold the coreboot config stuff similar to EFI
* Couple new patches for ximg to support extracting the FDT from chromeos kernel partitions
* Move the timestamp file out of arch/x86 as well in a different patch

Stephen Boyd (28):
bootstd: cros: Return negative error code
clk: qcom: Add driver for sc7180
clk/stub: Add sc7180-rpmh clock
clk: qcom: Support uart clk on sc7280 CRD
pinctrl: qcom: Add driver for sc7180
spi: Add Qualcomm GENI SPI driver
serial: msm-geni: Enable SE clk in probe
coreboot: Move coreboot logic out of x86 to a generic place
coreboot: Set gd->ram_base when parsing tables
coreboot: Locate table earlier than arch_cpu_init()
arm: Support running U-Boot as a coreboot payload on ARM64 cmd/cbsysinfo: Skip the CMOS 'option_table' when not present cmd/cbsysinfo: Allow on ARM as well
coreboot: Parse sku_id/fw_config from coreboot tables
pstore: Add pstore address from coreboot tables
coreboot: Add /firmware/coreboot node to DT
coreboot: Move timestamp parsing to generic place
coreboot: Dump VPD information in cbsysinfo command
coreboot: Set serial# from VPD
coreboot: Set wifi mac addr from VPD
fdt: Populate wifi MAC from environment
mach-snapdragon: Support booting as a coreboot payload
mach-snapdragon: Allow usb3 to work when a coreboot payload
board: google: Add board_debug_uart_init() for Trogdor
cmd: ximg: Support LZO compressed images
cmd: ximg: Support LZ4 compressed images
configs: Add chromebook_trogdor defconfig
doc: chromebook_trogdor: Add document detailing installation steps

  arch/arm/cpu/armv8/Makefile                   |   1 +
  arch/arm/cpu/armv8/coreboot/Makefile          |   4 +
  arch/arm/cpu/armv8/coreboot/cpu.c             |  22 +
  arch/arm/include/asm/global_data.h            |   3 +
  arch/arm/mach-snapdragon/board.c              |  23 +
  arch/arm/mach-snapdragon/of_fixup.c           |  22 +-
  arch/x86/Kconfig                              |  22 -
  arch/x86/cpu/coreboot/Kconfig                 |  33 -
  arch/x86/cpu/coreboot/Makefile                |   1 -
  arch/x86/cpu/coreboot/coreboot.c              |  16 +-
  arch/x86/cpu/coreboot/sdram.c                 |  78 +--
  arch/x86/cpu/cpu.c                            |  15 +-
  arch/x86/cpu/i386/cpu.c                       |   2 +-
  arch/x86/lib/bootm.c                          |   5 +-
  arch/x86/lib/coreboot/Makefile                |   1 -
  arch/x86/lib/coreboot/cb_support.c            |   2 +-
  arch/x86/lib/coreboot_table.c                 |   2 +-
  arch/x86/lib/tables.c                         |   2 +-
  arch/x86/lib/zimage.c                         |   3 -
  board/coreboot/coreboot/coreboot.c            |   2 +-
  board/coreboot/coreboot/sysinfo.c             |   2 +-
  board/google/chromebook_coral/coral.c         |   2 +-
  board/google/trogdor/Makefile                 |   3 +
  board/google/trogdor/debug.config             |   6 +
  board/google/trogdor/debug_uart.c             |  41 ++
  boot/Kconfig                                  |   1 +
  boot/bootmeth_cros.c                          |   2 +-
  boot/expo_build_cb.c                          |   2 +-
  boot/fdt_support.c                            |  54 +-
  boot/image-fdt.c                              |   4 +
  cmd/Kconfig                                   |   4 +-
  cmd/Makefile                                  |   1 +
  cmd/{x86 => }/cbsysinfo.c                     |  40 +-
  cmd/pstore.c                                  |  51 +-
  cmd/version.c                                 |   2 +-
  cmd/x86/Makefile                              |   1 -
  cmd/x86/cbcmos.c                              |   2 +-
  cmd/ximg.c                                    |  28 +
  common/board_f.c                              |   4 +
  configs/chromebook_trogdor_defconfig          | 138 +++++
  doc/board/google/chromebook_trogdor.rst       |  69 +++
  doc/board/google/index.rst                    |   1 +
  drivers/clk/clk-stub.c                        |   1 +
  drivers/clk/qcom/Kconfig                      |   8 +
  drivers/clk/qcom/Makefile                     |   1 +
  drivers/clk/qcom/clock-sc7180.c               | 153 +++++
  drivers/clk/qcom/clock-sc7280.c               |  22 +
  drivers/misc/cbmem_console.c                  |   2 +-
  drivers/pinctrl/qcom/Kconfig                  |   8 +
  drivers/pinctrl/qcom/Makefile                 |   1 +
  drivers/pinctrl/qcom/pinctrl-sc7180.c         | 133 ++++
  drivers/serial/serial_coreboot.c              |   2 +-
  drivers/serial/serial_msm_geni.c              |  26 +-
  drivers/spi/Kconfig                           |  10 +
  drivers/spi/Makefile                          |   1 +
  drivers/spi/spi-geni-qcom.c                   | 569 ++++++++++++++++++
  drivers/video/coreboot.c                      |   2 +-
  .../x86/include/asm => include}/cb_sysinfo.h  |  51 +-
  .../include/asm => include}/coreboot_tables.h |  24 +
  .../coreboot_timestamp.h                      |   9 +-
  lib/Makefile                                  |   2 +
  lib/coreboot/Kconfig                          |  55 ++
  {arch/x86/cpu => lib}/coreboot/Makefile       |  11 +-
  {arch/x86/lib => lib}/coreboot/cb_sysinfo.c   | 288 ++++++++-
  {arch/x86/cpu => lib}/coreboot/sdram.c        |  25 +-
  {arch/x86/cpu => lib}/coreboot/timestamp.c    |  15 +-
  66 files changed, 1863 insertions(+), 273 deletions(-)

create mode 100644 arch/arm/cpu/armv8/coreboot/Makefile
create mode 100644 arch/arm/cpu/armv8/coreboot/cpu.c
delete mode 100644 arch/x86/cpu/coreboot/Kconfig
create mode 100644 board/google/trogdor/Makefile
create mode 100644 board/google/trogdor/debug.config
create mode 100644 board/google/trogdor/debug_uart.c
rename cmd/{x86 => }/cbsysinfo.c (93%)
create mode 100644 configs/chromebook_trogdor_defconfig
create mode 100644 doc/board/google/chromebook_trogdor.rst
create mode 100644 drivers/clk/qcom/clock-sc7180.c
create mode 100644 drivers/pinctrl/qcom/pinctrl-sc7180.c
create mode 100644 drivers/spi/spi-geni-qcom.c
rename {arch/x86/include/asm => include}/cb_sysinfo.h (86%)
rename {arch/x86/include/asm => include}/coreboot_tables.h (96%)
rename arch/x86/include/asm/arch-coreboot/timestamp.h => include/coreboot_timestamp.h (63%) create mode 100644 lib/coreboot/Kconfig
copy {arch/x86/cpu => lib}/coreboot/Makefile (71%)
rename {arch/x86/lib => lib}/coreboot/cb_sysinfo.c (62%)
copy {arch/x86/cpu => lib}/coreboot/sdram.c (84%)
rename {arch/x86/cpu => lib}/coreboot/timestamp.c (83%)

base-commit: 9d3f1ebaf8751f0287b5d02158cc706435f8fb19

Signature · 1 line
Casey (she/they)
#38 lore raw

Quoting Casey Connolly (2025-06-18 10:59:24)

Quoted 9 lines

Hi Stephen,

There are multiple build errors with this branch, I started trying to fix a few but I think there's enough to warrant a respin...

Please build test for x86 and coreboot targets (try buildman)!

CI failures are here
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/jobs/1174915

Thanks! I lost time to work on this with work/life, but I will look into this soon.