improve OF_PLATDATA support
Subsystems (20)
v4 cover improve OF_PLATDATA support
When using OF_PLATDATA dtbs are converted to C structs in order to save space as we can remove both dtbs and libraries from TPL/SPL binaries.
This patchset tries to improve its support by overcoming some limitations in the current implementation
First, the support for scan and check for valid driver/aliases is added in order to generate U_BOOT_DEVICE entries with valid driver names.
Secondly, the way information about linked noded (phandle) is generated in C structs is improved in order to make it easier to get a device associated to its data.
Lastly the support for the property cd-gpios is added, which is used to configure the card detection gpio on MMC is added.
This implementation is based in discussion in [1], [2] and [3]
[1] https://patchwork.ozlabs.org/patch/1249198/
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=167495&state=*
[3] https://patchwork.ozlabs.org/project/uboot/list/?series=176759&state=*
Changes for v4
- Fix syntax error on dtoc
Changes for v3
- Split patches to separate core from tools changes
- Squash patches to avoid errors on tests
- Fix lines longer than 80 chars
Changes for v2
- Rename drivers to match compatible strings
- Fix out-of-trees usage of dtoc
- Fix test coverage
- Improve documentation
- Improve format
Walter Lozano (14):
drivers: rename drivers to match compatible string
dtoc: add missing code comments
core: add support for U_BOOT_DRIVER_ALIAS
dtoc: add support to scan drivers
dtoc: add option to disable warnings
dm: doc: update of-plat with the support for driver aliases
core: drop const for struct driver_info
core: extend struct driver_info to point to device
sandbox: Move section u_boot_list to make it RW
dtoc: extend dtoc to use struct driver_info when linking nodes
dm: doc: update of-plat with new phandle support
arm: dts: include gpio nodes for card detect
dtoc: update dtb_platdata to support cd-gpios
dtoc: add test for cd-gpios
arch/arm/dts/da850-evm-u-boot.dtsi | 4 + arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 + arch/arm/dts/rk3288-u-boot.dtsi | 4 + arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 + .../mach-at91/arm926ejs/at91sam9260_devices.c | 6 +- .../arm926ejs/at91sam9m10g45_devices.c | 10 +- arch/arm/mach-rockchip/rk3328/syscon_rk3328.c | 4 +- arch/sandbox/cpu/u-boot-spl.lds | 2 +- board/davinci/da8xxevm/omapl138_lcdk.c | 2 +- board/sandbox/sandbox.c | 2 +- doc/driver-model/of-plat.rst | 38 ++- drivers/clk/at91/clk-master.c | 4 +- drivers/clk/at91/clk-peripheral.c | 4 +- drivers/clk/at91/pmc.c | 6 +- drivers/clk/clk-uclass.c | 11 +- drivers/core/device.c | 28 +- drivers/core/root.c | 6 +- drivers/core/simple-bus.c | 4 +- drivers/gpio/at91_gpio.c | 4 +- drivers/gpio/da8xx_gpio.c | 4 +- drivers/gpio/mxs_gpio.c | 8 +- drivers/gpio/rk_gpio.c | 4 +- drivers/gpio/sandbox.c | 6 +- drivers/i2c/rk_i2c.c | 6 +- drivers/input/cros_ec_keyb.c | 4 +- drivers/misc/cros_ec_sandbox.c | 4 +- drivers/misc/irq-uclass.c | 10 +- drivers/mmc/davinci_mmc.c | 4 +- drivers/mmc/ftsdc010_mci.c | 2 +- drivers/mmc/mxsmmc.c | 7 +- drivers/mmc/rockchip_dw_mmc.c | 7 +- drivers/mmc/rockchip_sdhci.c | 2 +- drivers/mtd/spi/sf-uclass.c | 2 +- drivers/mtd/spi/sf_probe.c | 6 +- drivers/pinctrl/nxp/pinctrl-mxs.c | 6 +- drivers/pinctrl/pinctrl-at91.c | 6 +- drivers/pinctrl/rockchip/pinctrl-rk3188.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3288.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3328.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3368.c | 2 +- drivers/power/pmic/rk8xx.c | 6 +- drivers/power/regulator/fixed.c | 4 +- drivers/ram/rockchip/dmc-rk3368.c | 2 +- drivers/ram/rockchip/sdram_rk3188.c | 2 +- drivers/ram/rockchip/sdram_rk3288.c | 2 +- drivers/ram/rockchip/sdram_rk3328.c | 2 +- drivers/ram/rockchip/sdram_rk3399.c | 2 +- drivers/serial/ns16550.c | 4 + drivers/serial/sandbox.c | 6 +- drivers/spi/mxs_spi.c | 8 +- drivers/spi/rk_spi.c | 10 +- drivers/spi/sandbox_spi.c | 4 +- drivers/tpm/tpm_tis_sandbox.c | 4 +- drivers/video/rockchip/rk3288_vop.c | 4 +- drivers/video/sandbox_sdl.c | 4 +- drivers/watchdog/at91sam9_wdt.c | 4 +- include/clk.h | 4 +- include/dm/device-internal.h | 2 +- include/dm/device.h | 22 ++ include/dm/platdata.h | 14 + test/dm/gpio.c | 2 +- test/dm/spi.c | 6 +- test/py/tests/test_bind.py | 54 ++-- tools/dtoc/dtb_platdata.py | 143 ++++++++- tools/dtoc/dtoc_test_invalid_driver.dts | 15 + tools/dtoc/dtoc_test_phandle_cd_gpios.dts | 42 +++ tools/dtoc/test_dtoc.py | 287 +++++++++++++----- 68 files changed, 672 insertions(+), 239 deletions(-) create mode 100644 arch/arm/dts/rk3288-veyron-u-boot.dtsi create mode 100644 tools/dtoc/dtoc_test_invalid_driver.dts create mode 100644 tools/dtoc/dtoc_test_phandle_cd_gpios.dts
Signature · 1 line
2.20.1
PATCH v4 1/14 drivers: rename drivers to match compatible string
When using OF_PLATDATA, the bind process between devices and drivers is performed trying to match compatible string with driver names. However driver names are not strictly defined, and also there are different names used when declaring a driver with U_BOOT_DRIVER, the name of the symbol used in the linker list and the used in the struct driver_info.
In order to make things a bit more clear, rename the drivers names. This will also help for further OF_PLATDATA improvements, such as checking for valid driver names.
---
.../mach-at91/arm926ejs/at91sam9260_devices.c | 6 +-- .../arm926ejs/at91sam9m10g45_devices.c | 10 ++-- arch/arm/mach-rockchip/rk3328/syscon_rk3328.c | 4 +- board/davinci/da8xxevm/omapl138_lcdk.c | 2 +- board/sandbox/sandbox.c | 2 +- drivers/clk/at91/clk-master.c | 4 +- drivers/clk/at91/clk-peripheral.c | 4 +- drivers/clk/at91/pmc.c | 4 +- drivers/core/simple-bus.c | 4 +- drivers/gpio/at91_gpio.c | 4 +- drivers/gpio/da8xx_gpio.c | 4 +- drivers/gpio/mxs_gpio.c | 6 +-- drivers/gpio/rk_gpio.c | 4 +- drivers/gpio/sandbox.c | 4 +- drivers/i2c/rk_i2c.c | 4 +- drivers/input/cros_ec_keyb.c | 4 +- drivers/misc/cros_ec_sandbox.c | 4 +- drivers/mmc/davinci_mmc.c | 4 +- drivers/mmc/mxsmmc.c | 6 +-- drivers/mmc/rockchip_dw_mmc.c | 2 +- drivers/mtd/spi/sf-uclass.c | 2 +- drivers/mtd/spi/sf_probe.c | 4 +- drivers/pinctrl/nxp/pinctrl-mxs.c | 4 +- drivers/pinctrl/pinctrl-at91.c | 4 +- drivers/pinctrl/rockchip/pinctrl-rk3188.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3288.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3328.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3368.c | 2 +- drivers/power/pmic/rk8xx.c | 4 +- drivers/power/regulator/fixed.c | 4 +- drivers/ram/rockchip/dmc-rk3368.c | 2 +- drivers/ram/rockchip/sdram_rk3188.c | 2 +- drivers/ram/rockchip/sdram_rk3288.c | 2 +- drivers/ram/rockchip/sdram_rk3328.c | 2 +- drivers/serial/sandbox.c | 6 +-- drivers/spi/mxs_spi.c | 6 +-- drivers/spi/rk_spi.c | 6 +-- drivers/spi/sandbox_spi.c | 4 +- drivers/tpm/tpm_tis_sandbox.c | 4 +- drivers/video/rockchip/rk3288_vop.c | 4 +- drivers/video/sandbox_sdl.c | 4 +- drivers/watchdog/at91sam9_wdt.c | 4 +- test/dm/gpio.c | 2 +- test/dm/spi.c | 6 +-- test/py/tests/test_bind.py | 54 +++++++++---------- 45 files changed, 104 insertions(+), 120 deletions(-)
arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c +3 -3
@@ -220,7 +220,7 @@ static const struct at91_port_platdata at91sam9260_plat[] = { };U_BOOT_DEVICES (at91sam9260_gpios) = { - {"gpio_at91" , &at91sam9260_plat[0 ] }, - {"gpio_at91" , &at91sam9260_plat[1 ] }, - {"gpio_at91" , &at91sam9260_plat[2 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[0 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[1 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[2 ] }, };
arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c +5 -5
@@ -176,9 +176,9 @@ static const struct at91_port_platdata at91sam9260_plat[] = { };U_BOOT_DEVICES (at91sam9260_gpios) = { - {"gpio_at91" , &at91sam9260_plat[0 ] }, - {"gpio_at91" , &at91sam9260_plat[1 ] }, - {"gpio_at91" , &at91sam9260_plat[2 ] }, - {"gpio_at91" , &at91sam9260_plat[3 ] }, - {"gpio_at91" , &at91sam9260_plat[4 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[0 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[1 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[2 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[3 ] }, + {"atmel_at91rm9200_gpio" , &at91sam9260_plat[4 ] }, };
arch/arm/mach-rockchip/rk3328/syscon_rk3328.c +2 -2
@@ -13,8 +13,8 @@ static const struct udevice_id rk3328_syscon_ids[] = { { } }; -U_BOOT_DRIVER (syscon_rk3328) = { - .name ="rk3328_syscon" , +U_BOOT_DRIVER (rockchip_rk3328_grf) = { + .name ="rockchip_rk3328_grf" , .id =UCLASS_SYSCON , .of_match = rk3328_syscon_ids, };
board/davinci/da8xxevm/omapl138_lcdk.c +1 -1
@@ -368,7 +368,7 @@ U_BOOT_DEVICE(omapl138_uart) = { };U_BOOT_DEVICE (omapl138_mmc) = { - .name ="davinci_mmc" , + .name ="ti_da830_mmc" , };void spl_board_init (void )
board/sandbox/sandbox.c +1 -1
@@ -22,7 +22,7 @@ gd_t *gd;/* Add a simple GPIO device */ U_BOOT_DEVICE (gpio_sandbox) = { - .name ="gpio_sandbox" , + .name ="sandbox_gpio" , };void flush_cache (unsigned long start,unsigned long size)
drivers/clk/at91/clk-master.c +2 -2
@@ -25,8 +25,8 @@ static const struct udevice_id at91_master_clk_match[] = { {} }; -U_BOOT_DRIVER (at91_master_clk) = { - .name ="at91-master-clk" , +U_BOOT_DRIVER (atmel_at91rm9200_clk_master) = { + .name ="atmel_at91rm9200_clk_master" , .id =UCLASS_CLK , .of_match = at91_master_clk_match, .ops = &at91_master_clk_ops,
drivers/clk/at91/clk-peripheral.c +2 -2
@@ -43,8 +43,8 @@ static const struct udevice_id sam9x5_periph_clk_match[] = { {} }; -U_BOOT_DRIVER (sam9x5_periph_clk) = { - .name ="sam9x5-periph-clk" , +U_BOOT_DRIVER (atmel_at91rm9200_clk_peripheral) = { + .name ="atmel_at91rm9200_clk_peripheral" , .id =UCLASS_MISC , .of_match = sam9x5_periph_clk_match, .bind = sam9x5_periph_clk_bind,
drivers/clk/at91/pmc.c +2 -2
@@ -24,8 +24,8 @@ static const struct udevice_id at91_pmc_match[] = { {} }; -U_BOOT_DRIVER (at91_pmc) = { - .name ="at91-pmc" , +U_BOOT_DRIVER (atmel_at91rm9200_pmc) = { + .name ="atmel_at91rm9200_pmc" , .id =UCLASS_SIMPLE_BUS , .of_match = at91_pmc_match, };
drivers/core/simple-bus.c +2 -2
@@ -56,8 +56,8 @@ static const struct udevice_id generic_simple_bus_ids[] = { { } }; -U_BOOT_DRIVER (simple_bus_drv) = { - .name ="generic_simple_bus" , +U_BOOT_DRIVER (simple_bus) = { + .name ="simple_bus" , .id =UCLASS_SIMPLE_BUS , .of_match = generic_simple_bus_ids, .flags =DM_FLAG_PRE_RELOC ,
drivers/gpio/at91_gpio.c +2 -2
@@ -624,8 +624,8 @@ static const struct udevice_id at91_gpio_ids[] = { };#endif -U_BOOT_DRIVER (gpio_at91) = { - .name ="gpio_at91" , +U_BOOT_DRIVER (atmel_at91rm9200_gpio) = { + .name ="atmel_at91rm9200_gpio" , .id =UCLASS_GPIO , #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = at91_gpio_ids,
drivers/gpio/da8xx_gpio.c +2 -2
@@ -553,8 +553,8 @@ static int davinci_gpio_ofdata_to_platdata(struct udevice *dev)return 0 ; } -U_BOOT_DRIVER (gpio_davinci) = { - .name ="gpio_davinci" , +U_BOOT_DRIVER (ti_dm6441_gpio) = { + .name ="ti_dm6441_gpio" , .id =UCLASS_GPIO , .ops = &gpio_davinci_ops, .ofdata_to_platdata =of_match_ptr (davinci_gpio_ofdata_to_platdata),
drivers/gpio/mxs_gpio.c +1 -5
@@ -297,12 +297,8 @@ static const struct udevice_id mxs_gpio_ids[] = { };#endif -U_BOOT_DRIVER (gpio_mxs) = { -#ifdef CONFIG_MX28 - .name ="fsl_imx28_gpio" , -#else /* CONFIG_MX23 */ +U_BOOT_DRIVER (fsl_imx23_gpio) = { .name ="fsl_imx23_gpio" , -#endif .id =UCLASS_GPIO , .ops = &gpio_mxs_ops, .probe = mxs_gpio_probe,
drivers/gpio/rk_gpio.c +2 -2
@@ -172,8 +172,8 @@ static const struct udevice_id rockchip_gpio_ids[] = { { } }; -U_BOOT_DRIVER (gpio_rockchip) = { - .name ="gpio_rockchip" , +U_BOOT_DRIVER (rockchip_gpio_bank) = { + .name ="rockchip_gpio_bank" , .id =UCLASS_GPIO , .of_match = rockchip_gpio_ids, .ops = &gpio_rockchip_ops,
drivers/gpio/sandbox.c +2 -2
@@ -243,8 +243,8 @@ static const struct udevice_id sandbox_gpio_ids[] = { { } }; -U_BOOT_DRIVER (gpio_sandbox) = { - .name ="gpio_sandbox" , +U_BOOT_DRIVER (sandbox_gpio) = { + .name ="sandbox_gpio" , .id =UCLASS_GPIO , .of_match = sandbox_gpio_ids, .ofdata_to_platdata = sandbox_gpio_ofdata_to_platdata,
drivers/i2c/rk_i2c.c +2 -2
@@ -483,8 +483,8 @@ static const struct udevice_id rockchip_i2c_ids[] = { { } }; -U_BOOT_DRIVER (i2c_rockchip) = { - .name ="i2c_rockchip" , +U_BOOT_DRIVER (rockchip_rk3066_i2c) = { + .name ="rockchip_rk3066_i2c" , .id =UCLASS_I2C , .of_match = rockchip_i2c_ids, .ofdata_to_platdata = rockchip_i2c_ofdata_to_platdata,
drivers/input/cros_ec_keyb.c +2 -2
@@ -224,8 +224,8 @@ static const struct udevice_id cros_ec_kbd_ids[] = { { } }; -U_BOOT_DRIVER (cros_ec_kbd) = { - .name ="cros_ec_kbd" , +U_BOOT_DRIVER (google_cros_ec_keyb) = { + .name ="google_cros_ec_keyb" , .id =UCLASS_KEYBOARD , .of_match = cros_ec_kbd_ids, .probe = cros_ec_kbd_probe,
drivers/misc/cros_ec_sandbox.c +2 -2
@@ -571,8 +571,8 @@ static const struct udevice_id cros_ec_ids[] = { { } }; -U_BOOT_DRIVER (cros_ec_sandbox) = { - .name ="cros_ec_sandbox" , +U_BOOT_DRIVER (google_cros_ec_sandbox) = { + .name ="google_cros_ec_sandbox" , .id =UCLASS_CROS_EC , .of_match = cros_ec_ids, .probe = cros_ec_probe,
drivers/mmc/davinci_mmc.c +2 -2
@@ -538,8 +538,8 @@ static const struct udevice_id davinci_mmc_ids[] = { {}, }; -U_BOOT_DRIVER (davinci_mmc_drv) = { - .name ="davinci_mmc" , +U_BOOT_DRIVER (ti_da830_mmc) = { + .name ="ti_da830_mmc" , .id =UCLASS_MMC , .of_match = davinci_mmc_ids, #if CONFIG_BLK
drivers/mmc/mxsmmc.c +1 -5
@@ -708,12 +708,8 @@ static const struct udevice_id mxsmmc_ids[] = { };#endif -U_BOOT_DRIVER (mxsmmc) = { -#ifdef CONFIG_MX28 - .name ="fsl_imx28_mmc" , -#else /* CONFIG_MX23 */ +U_BOOT_DRIVER (fsl_imx23_mmc) = { .name ="fsl_imx23_mmc" , -#endif .id =UCLASS_MMC , #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = mxsmmc_ids,
drivers/mmc/rockchip_dw_mmc.c +1 -1
@@ -166,7 +166,7 @@ static const struct udevice_id rockchip_dwmmc_ids[] = { { } }; -U_BOOT_DRIVER (rockchip_dwmmc_drv) = { +U_BOOT_DRIVER (rockchip_rk3288_dw_mshc) = { .name ="rockchip_rk3288_dw_mshc" , .id =UCLASS_MMC , .of_match = rockchip_dwmmc_ids,
drivers/mtd/spi/sf-uclass.c +1 -1
@@ -76,7 +76,7 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, str =strdup (name);#endif ret =spi_get_bus_and_cs (busnum, cs, max_hz, spi_mode, -"spi_flash_std" , str, &bus, &slave); +"jedec_spi_nor" , str, &bus, &slave);if (ret)return ret;
drivers/mtd/spi/sf_probe.c +2 -2
@@ -170,8 +170,8 @@ static const struct udevice_id spi_flash_std_ids[] = { { } }; -U_BOOT_DRIVER (spi_flash_std) = { - .name ="spi_flash_std" , +U_BOOT_DRIVER (jedec_spi_nor) = { + .name ="jedec_spi_nor" , .id =UCLASS_SPI_FLASH , .of_match = spi_flash_std_ids, .probe = spi_flash_std_probe,
drivers/pinctrl/nxp/pinctrl-mxs.c +2 -2
@@ -179,8 +179,8 @@ static const struct udevice_id mxs_pinctrl_match[] = { {/* sentinel */ } }; -U_BOOT_DRIVER (mxs_pinctrl) = { - .name ="mxs-pinctrl" , +U_BOOT_DRIVER (fsl_imx23_pinctrl) = { + .name ="fsl_imx23_pinctrl" , .id =UCLASS_PINCTRL , .of_match =of_match_ptr (mxs_pinctrl_match), .probe = mxs_pinctrl_probe,
drivers/pinctrl/pinctrl-at91.c +2 -2
@@ -517,8 +517,8 @@ static const struct udevice_id at91_pinctrl_match[] = { {} }; -U_BOOT_DRIVER (at91_pinctrl) = { - .name ="pinctrl_at91" , +U_BOOT_DRIVER (atmel_sama5d3_pinctrl) = { + .name ="atmel_sama5d3_pinctrl" , .id =UCLASS_PINCTRL , .of_match = at91_pinctrl_match, .probe = at91_pinctrl_probe,
drivers/pinctrl/rockchip/pinctrl-rk3188.c +1 -1
@@ -119,7 +119,7 @@ static const struct udevice_id rk3188_pinctrl_ids[] = { { } }; -U_BOOT_DRIVER (pinctrl_rk3188) = { +U_BOOT_DRIVER (rockchip_rk3188_pinctrl) = { .name ="rockchip_rk3188_pinctrl" , .id =UCLASS_PINCTRL , .of_match = rk3188_pinctrl_ids,
drivers/pinctrl/rockchip/pinctrl-rk3288.c +1 -1
@@ -240,7 +240,7 @@ static const struct udevice_id rk3288_pinctrl_ids[] = { { } }; -U_BOOT_DRIVER (pinctrl_rk3288) = { +U_BOOT_DRIVER (rockchip_rk3288_pinctrl) = { .name ="rockchip_rk3288_pinctrl" , .id =UCLASS_PINCTRL , .of_match = rk3288_pinctrl_ids,
drivers/pinctrl/rockchip/pinctrl-rk3328.c +1 -1
@@ -315,7 +315,7 @@ static const struct udevice_id rk3328_pinctrl_ids[] = { { } }; -U_BOOT_DRIVER (pinctrl_rk3328) = { +U_BOOT_DRIVER (rockchip_rk3328_pinctrl) = { .name ="rockchip_rk3328_pinctrl" , .id =UCLASS_PINCTRL , .of_match = rk3328_pinctrl_ids,
drivers/pinctrl/rockchip/pinctrl-rk3368.c +1 -1
@@ -170,7 +170,7 @@ static const struct udevice_id rk3368_pinctrl_ids[] = { { } }; -U_BOOT_DRIVER (pinctrl_rk3368) = { +U_BOOT_DRIVER (rockchip_rk3368_pinctrl) = { .name ="rockchip_rk3368_pinctrl" , .id =UCLASS_PINCTRL , .of_match = rk3368_pinctrl_ids,
drivers/power/pmic/rk8xx.c +2 -2
@@ -182,8 +182,8 @@ static const struct udevice_id rk8xx_ids[] = { { } }; -U_BOOT_DRIVER (pmic_rk8xx) = { - .name ="rk8xx pmic" , +U_BOOT_DRIVER (rockchip_rk805) = { + .name ="rockchip_rk805" , .id =UCLASS_PMIC , .of_match = rk8xx_ids, #if CONFIG_IS_ENABLED(PMIC_CHILDREN)
drivers/power/regulator/fixed.c +2 -2
@@ -81,8 +81,8 @@ static const struct udevice_id fixed_regulator_ids[] = { { }, }; -U_BOOT_DRIVER (fixed_regulator) = { - .name ="fixed regulator" , +U_BOOT_DRIVER (regulator_fixed) = { + .name ="regulator_fixed" , .id =UCLASS_REGULATOR , .ops = &fixed_regulator_ops, .of_match = fixed_regulator_ids,
drivers/ram/rockchip/dmc-rk3368.c +1 -1
@@ -989,7 +989,7 @@ static const struct udevice_id rk3368_dmc_ids[] = { { } }; -U_BOOT_DRIVER (dmc_rk3368) = { +U_BOOT_DRIVER (rockchip_rk3368_dmc) = { .name ="rockchip_rk3368_dmc" , .id =UCLASS_RAM , .of_match = rk3368_dmc_ids,
drivers/ram/rockchip/sdram_rk3188.c +1 -1
@@ -942,7 +942,7 @@ static const struct udevice_id rk3188_dmc_ids[] = { { } }; -U_BOOT_DRIVER (dmc_rk3188) = { +U_BOOT_DRIVER (rockchip_rk3188_dmc) = { .name ="rockchip_rk3188_dmc" , .id =UCLASS_RAM , .of_match = rk3188_dmc_ids,
drivers/ram/rockchip/sdram_rk3288.c +1 -1
@@ -1110,7 +1110,7 @@ static const struct udevice_id rk3288_dmc_ids[] = { { } }; -U_BOOT_DRIVER (dmc_rk3288) = { +U_BOOT_DRIVER (rockchip_rk3288_dmc) = { .name ="rockchip_rk3288_dmc" , .id =UCLASS_RAM , .of_match = rk3288_dmc_ids,
drivers/ram/rockchip/sdram_rk3328.c +1 -1
@@ -603,7 +603,7 @@ static const struct udevice_id rk3328_dmc_ids[] = { { } }; -U_BOOT_DRIVER (dmc_rk3328) = { +U_BOOT_DRIVER (rockchip_rk3328_dmc) = { .name ="rockchip_rk3328_dmc" , .id =UCLASS_RAM , .of_match = rk3328_dmc_ids,
drivers/serial/sandbox.c +3 -3
@@ -252,8 +252,8 @@ static const struct udevice_id sandbox_serial_ids[] = { { } }; -U_BOOT_DRIVER (serial_sandbox) = { - .name ="serial_sandbox" , +U_BOOT_DRIVER (sandbox_serial) = { + .name ="sandbox_serial" , .id =UCLASS_SERIAL , .of_match = sandbox_serial_ids, .ofdata_to_platdata = sandbox_serial_ofdata_to_platdata,
@@ -270,7 +270,7 @@ static const struct sandbox_serial_platdata platdata_non_fdt = { };U_BOOT_DEVICE (serial_sandbox_non_fdt) = { - .name ="serial_sandbox" , + .name ="sandbox_serial" , .platdata = &platdata_non_fdt, };#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
drivers/spi/mxs_spi.c +1 -5
@@ -606,12 +606,8 @@ static const struct udevice_id mxs_spi_ids[] = { };#endif -U_BOOT_DRIVER (mxs_spi) = { -#ifdef CONFIG_MX28 - .name ="fsl_imx28_spi" , -#else /* CONFIG_MX23 */ +U_BOOT_DRIVER (fsl_imx23_spi) = { .name ="fsl_imx23_spi" , -#endif .id =UCLASS_SPI , #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = mxs_spi_ids,
drivers/spi/rk_spi.c +1 -5
@@ -551,12 +551,8 @@ static const struct udevice_id rockchip_spi_ids[] = { { } }; -U_BOOT_DRIVER (rockchip_spi) = { -#if CONFIG_IS_ENABLED(OF_PLATDATA) +U_BOOT_DRIVER (rockchip_rk3288_spi) = { .name ="rockchip_rk3288_spi" , -#else - .name ="rockchip_spi" , -#endif .id =UCLASS_SPI , .of_match = rockchip_spi_ids, .ops = &rockchip_spi_ops,
drivers/spi/sandbox_spi.c +2 -2
@@ -145,8 +145,8 @@ static const struct udevice_id sandbox_spi_ids[] = { { } }; -U_BOOT_DRIVER (spi_sandbox) = { - .name ="spi_sandbox" , +U_BOOT_DRIVER (sandbox_spi) = { + .name ="sandbox_spi" , .id =UCLASS_SPI , .of_match = sandbox_spi_ids, .ops = &sandbox_spi_ops,
drivers/tpm/tpm_tis_sandbox.c +2 -2
@@ -355,8 +355,8 @@ static const struct udevice_id sandbox_tpm_ids[] = { { } }; -U_BOOT_DRIVER (sandbox_tpm) = { - .name ="sandbox_tpm" , +U_BOOT_DRIVER (google_sandbox_tpm) = { + .name ="google_sandbox_tpm" , .id =UCLASS_TPM , .of_match = sandbox_tpm_ids, .ops = &sandbox_tpm_ops,
drivers/video/rockchip/rk3288_vop.c +2 -2
@@ -96,8 +96,8 @@ static const struct udevice_id rk3288_vop_ids[] = {static const struct video_ops rk3288_vop_ops = { }; -U_BOOT_DRIVER (rk_vop) = { - .name ="rk3288_vop" , +U_BOOT_DRIVER (rockchip_rk3288_vop) = { + .name ="rockchip_rk3288_vop" , .id =UCLASS_VIDEO , .of_match = rk3288_vop_ids, .ops = &rk3288_vop_ops,
drivers/video/sandbox_sdl.c +2 -2
@@ -63,8 +63,8 @@ static const struct udevice_id sandbox_sdl_ids[] = { { } }; -U_BOOT_DRIVER (sdl_sandbox) = { - .name ="sdl_sandbox" , +U_BOOT_DRIVER (sandbox_lcd_sdl) = { + .name ="sandbox_lcd_sdl" , .id =UCLASS_VIDEO , .of_match = sandbox_sdl_ids, .bind = sandbox_sdl_bind,
drivers/watchdog/at91sam9_wdt.c +2 -2
@@ -112,8 +112,8 @@ static int at91_wdt_probe(struct udevice *dev)return 0 ; } -U_BOOT_DRIVER (at91_wdt) = { - .name ="at91_wdt" , +U_BOOT_DRIVER (atmel_at91sam9260_wdt) = { + .name ="atmel_at91sam9260_wdt" , .id =UCLASS_WDT , .of_match = at91_wdt_ids, .priv_auto_alloc_size =sizeof (struct at91_wdt_priv ),
test/dm/gpio.c +1 -1
@@ -211,7 +211,7 @@ static int dm_test_gpio_anon(struct unit_test_state *uts)/* And the anonymous bank */ ut_assertok (gpio_lookup_name ("14" , &dev, &offset, &gpio)); -ut_asserteq_str (dev->name,"gpio_sandbox" ); +ut_asserteq_str (dev->name,"sandbox_gpio" );ut_asserteq (14 , offset);ut_asserteq (14 , gpio);
test/dm/spi.c +3 -3
@@ -58,7 +58,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)*/ ut_asserteq (-ENODEV ,spi_find_bus_and_cs (busnum, cs, &bus, &dev));ut_asserteq (-ENOENT ,spi_get_bus_and_cs (busnum, cs, speed, mode, -"spi_flash_std" ,"name" , &bus, +"jedec_spi_nor" ,"name" , &bus, &slave));sandbox_sf_unbind_emul (state_get_current (), busnum, cs);ut_assertok (spi_cs_info (bus, cs, &info));
@@ -69,7 +69,7 @@ static int dm_test_spi_find(struct unit_test_state *uts) "name"));ut_assertok (spi_find_bus_and_cs (busnum, cs, &bus, &dev));ut_assertok (spi_get_bus_and_cs (busnum, cs, speed, mode, -"spi_flash_std" ,"name" , &bus, &slave)); +"jedec_spi_nor" ,"name" , &bus, &slave));ut_assertok (spi_cs_info (bus, cs, &info));ut_asserteq_ptr (info.dev, slave->dev);
@@ -78,7 +78,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)ut_assertok (sandbox_sf_bind_emul (state, busnum, cs_b, bus, node,"name" ));ut_asserteq (-EINVAL ,spi_get_bus_and_cs (busnum, cs_b, speed, mode, -"spi_flash_std" ,"name" , &bus, &slave)); +"jedec_spi_nor" ,"name" , &bus, &slave));ut_asserteq (-EINVAL ,spi_cs_info (bus, cs_b, &info));ut_asserteq_ptr (NULL , info.dev);
test/py/tests/test_bind.py +27 -27
148 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 1/14 drivers: rename drivers to match compatible string
Quoted 52 lines · Walter Lozano
When using
OF_PLATDATA, the bind process between devices and drivers is performed trying to match compatible string with driver names. However driver names are not strictly defined, and also there are different names used when declaring a driver withU_BOOT_DRIVER, the name of the symbol used in the linker list and the used in the structdriver_info.In order to make things a bit more clear, rename the drivers names. This will also help for further
OF_PLATDATAimprovements, such as checking for valid driver names.Signed-off-by Walter Lozano <[email protected]>---
.../mach-at91/arm926ejs/at91sam9260_devices.c | 6 +-- .../arm926ejs/at91sam9m10g45_devices.c | 10 ++-- arch/arm/mach-rockchip/rk3328/syscon_rk3328.c | 4 +- board/davinci/da8xxevm/omapl138_lcdk.c | 2 +- board/sandbox/sandbox.c | 2 +- drivers/clk/at91/clk-master.c | 4 +- drivers/clk/at91/clk-peripheral.c | 4 +- drivers/clk/at91/pmc.c | 4 +- drivers/core/simple-bus.c | 4 +- drivers/gpio/at91_gpio.c | 4 +- drivers/gpio/da8xx_gpio.c | 4 +- drivers/gpio/mxs_gpio.c | 6 +-- drivers/gpio/rk_gpio.c | 4 +- drivers/gpio/sandbox.c | 4 +- drivers/i2c/rk_i2c.c | 4 +- drivers/input/cros_ec_keyb.c | 4 +- drivers/misc/cros_ec_sandbox.c | 4 +- drivers/mmc/davinci_mmc.c | 4 +- drivers/mmc/mxsmmc.c | 6 +-- drivers/mmc/rockchip_dw_mmc.c | 2 +- drivers/mtd/spi/sf-uclass.c | 2 +- drivers/mtd/spi/sf_probe.c | 4 +- drivers/pinctrl/nxp/pinctrl-mxs.c | 4 +- drivers/pinctrl/pinctrl-at91.c | 4 +- drivers/pinctrl/rockchip/pinctrl-rk3188.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3288.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3328.c | 2 +- drivers/pinctrl/rockchip/pinctrl-rk3368.c | 2 +- drivers/power/pmic/rk8xx.c | 4 +- drivers/power/regulator/fixed.c | 4 +- drivers/ram/rockchip/dmc-rk3368.c | 2 +- drivers/ram/rockchip/sdram_rk3188.c | 2 +- drivers/ram/rockchip/sdram_rk3288.c | 2 +- drivers/ram/rockchip/sdram_rk3328.c | 2 +- drivers/serial/sandbox.c | 6 +-- drivers/spi/mxs_spi.c | 6 +-- drivers/spi/rk_spi.c | 6 +-- drivers/spi/sandbox_spi.c | 4 +-
Quoted 8 lines
drivers/tpm/tpm_tis_sandbox.c | 4 +- drivers/video/rockchip/rk3288_vop.c | 4 +- drivers/video/sandbox_sdl.c | 4 +- drivers/watchdog/at91sam9_wdt.c | 4 +- test/dm/gpio.c | 2 +- test/dm/spi.c | 6 +-- test/py/tests/test_bind.py | 54 +++++++++---------- 45 files changed, 104 insertions(+), 120 deletions(-)
PATCH v4 2/14 dtoc: add missing code comments
In reply to Walter LozanoAdd missing information about internal class members in order to make the code easier to follow.
---
tools/dtoc/dtb_platdata.py | 3 +++ 1 file changed, 3 insertions(+)
tools/dtoc/dtb_platdata.py +3 -0
@@ -140,6 +140,9 @@ class DtbPlatdata(object): _include_disabled: true to include nodes marked status = "disabled" _outfile: The current output file (sys.stdout or a real file) _lines: Stashed list of output lines for outputting in the future + _aliases: Dict that hold aliases for compatible strings + key: First compatible string declared in a node + value: List of additional compatible strings declared in a node """ def __init__(self, dtb_fname, include_disabled): self._fdt = None
Signature · 1 line
2.20.1
PATCH v4 2/14 dtoc: add missing code comments
Quoted 10 lines · Walter Lozano
Add missing information about internal class members in order to make the code easier to follow.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 3 +++ 1 file changed, 3 insertions(+)
BTW if there was a review tag from last version, please add it to your commit.
PATCH v4 2/14 dtoc: add missing code comments
Hi Simon,
Quoted 7 lines · Simon Glass
Quoted 6 lines · Walter Lozano
Add missing information about internal class members in order to make the code easier to follow.
Signed-off-by Walter Lozano <[email protected]>---
Quoted 6 lines
Quoted 3 lines
tools/dtoc/dtb_platdata.py | 3 +++ 1 file changed, 3 insertions(+)Reviewed-by Simon Glass <[email protected]>BTW if there was a review tag from last version, please add it to your commit.
Thanks for pointing that, I'll take you advice for those commit that doesn't change at all. Also thank you for all the time you spent reviewing this series and sharing suggestions.
Regards,
Walter
PATCH v4 2/14 dtoc: add missing code comments
Hi Walter,
Quoted 14 lines · Walter Lozano
Hi Simon,
Quoted 10 lines · Simon Glass
Quoted 9 lines · Walter Lozano
Add missing information about internal class members in order to make the code easier to follow.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 3 +++ 1 file changed, 3 insertions(+)
Quoted 8 lines
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>BTW if there was a review tag from last version, please add it to your commit.
Thanks for pointing that, I'll take you advice for those commit that doesn't change at all. Also thank you for all the time you spent reviewing this series and sharing suggestions.
You're welcome. It's a great improvement to of-platdata! You can add it the tag unless you make a major change to a commit.
Regards,
Simon
PATCH v4 2/14 dtoc: add missing code comments
Hi Walter,
Quoted 14 lines · Walter Lozano
Hi Simon,
Quoted 10 lines · Simon Glass
Quoted 9 lines · Walter Lozano
Add missing information about internal class members in order to make the code easier to follow.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 3 +++ 1 file changed, 3 insertions(+)
Quoted 8 lines
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>BTW if there was a review tag from last version, please add it to your commit.
Thanks for pointing that, I'll take you advice for those commit that doesn't change at all. Also thank you for all the time you spent reviewing this series and sharing suggestions.
You're welcome. It's a great improvement to of-platdata! You can add it the tag unless you make a major change to a commit.
Regards,
Simon
Applied to u-boot-dm/next, thanks!
PATCH v4 3/14 core: add support for U_BOOT_DRIVER_ALIAS
In reply to Walter LozanoCurrently when using OF_PLATDATA the binding between devices and drivers is done trying to match the compatible string in the node with a driver name. However, usually a single driver supports multiple compatible strings which causes that only devices which its compatible string matches a driver name get bound.
To overcome this issue, this patch adds the U_BOOT_DRIVER_ALIAS macro, which generates no code at all, but allows an easy way to declare driver name aliases. Thanks to this, dtoc could be improve to look for the driver name based on its alias when it populates the U_BOOT_DEVICE entry.
---
drivers/clk/at91/pmc.c | 2 ++ drivers/gpio/mxs_gpio.c | 2 ++ drivers/gpio/sandbox.c | 2 ++ drivers/i2c/rk_i2c.c | 2 ++ drivers/mmc/mxsmmc.c | 1 + drivers/mmc/rockchip_dw_mmc.c | 3 +++ drivers/mtd/spi/sf_probe.c | 2 ++ drivers/pinctrl/nxp/pinctrl-mxs.c | 2 ++ drivers/pinctrl/pinctrl-at91.c | 2 ++ drivers/power/pmic/rk8xx.c | 2 ++ drivers/serial/ns16550.c | 4 ++++ drivers/spi/mxs_spi.c | 2 ++ drivers/spi/rk_spi.c | 2 ++ include/dm/device.h | 7 +++++++ 14 files changed, 35 insertions(+)
drivers/clk/at91/pmc.c +2 -0
@@ -30,6 +30,8 @@ U_BOOT_DRIVER(atmel_at91rm9200_pmc) = { .of_match = at91_pmc_match, }; +U_BOOT_DRIVER_ALIAS (atmel_at91rm9200_pmc, atmel_at91sam9260_pmc) + /*---------------------------------------------------------*/int at91_pmc_core_probe (struct udevice *dev)
drivers/gpio/mxs_gpio.c +2 -0
@@ -309,4 +309,6 @@ U_BOOT_DRIVER(fsl_imx23_gpio) = { .ofdata_to_platdata = mxs_ofdata_to_platdata, #endif }; + +U_BOOT_DRIVER_ALIAS(fsl_imx23_gpio, fsl_imx28_gpio)#endif /* DM_GPIO */
drivers/gpio/sandbox.c +2 -0
@@ -253,6 +253,8 @@ U_BOOT_DRIVER(sandbox_gpio) = { .ops = &gpio_sandbox_ops, }; +U_BOOT_DRIVER_ALIAS (sandbox_gpio, sandbox_gpio_alias) + /* pincontrol: used only to check GPIO pin configuration (pinmux command) */struct sb_pinctrl_priv {
drivers/i2c/rk_i2c.c +2 -0
@@ -492,3 +492,5 @@ U_BOOT_DRIVER(rockchip_rk3066_i2c) = { .priv_auto_alloc_size = sizeof(struct rk_i2c), .ops = &rockchip_i2c_ops, }; + +U_BOOT_DRIVER_ALIAS (rockchip_rk3066_i2c, rockchip_rk3288_i2c)
drivers/mmc/mxsmmc.c +1 -0
@@ -724,4 +724,5 @@ U_BOOT_DRIVER(fsl_imx23_mmc) = { .platdata_auto_alloc_size = sizeof(struct mxsmmc_platdata), }; +U_BOOT_DRIVER_ALIAS(fsl_imx23_mmc, fsl_imx28_mmc)#endif /* CONFIG_DM_MMC */
drivers/mmc/rockchip_dw_mmc.c +3 -0
@@ -178,6 +178,9 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = { .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), }; +U_BOOT_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) +U_BOOT_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc) +#ifdef CONFIG_PWRSEQ static int rockchip_dwmmc_pwrseq_set_power (struct udevice *dev,bool enable) {
drivers/mtd/spi/sf_probe.c +2 -0
@@ -180,4 +180,6 @@ U_BOOT_DRIVER(jedec_spi_nor) = { .ops = &spi_flash_std_ops, }; +U_BOOT_DRIVER_ALIAS(jedec_spi_nor, spansion_m25p16) +#endif /* CONFIG_DM_SPI_FLASH */
drivers/pinctrl/nxp/pinctrl-mxs.c +2 -0
@@ -190,3 +190,5 @@ U_BOOT_DRIVER(fsl_imx23_pinctrl) = { .priv_auto_alloc_size = sizeof(struct mxs_pinctrl_priv), .ops = &mxs_pinctrl_ops, }; + +U_BOOT_DRIVER_ALIAS (fsl_imx23_pinctrl, fsl_imx28_pinctrl)
drivers/pinctrl/pinctrl-at91.c +2 -0
@@ -525,3 +525,5 @@ U_BOOT_DRIVER(atmel_sama5d3_pinctrl) = { .priv_auto_alloc_size = sizeof(struct at91_pinctrl_priv), .ops = &at91_pinctrl_ops, }; + +U_BOOT_DRIVER_ALIAS (atmel_sama5d3_pinctrl, atmel_at91rm9200_pinctrl)
drivers/power/pmic/rk8xx.c +2 -0
@@ -193,3 +193,5 @@ U_BOOT_DRIVER(rockchip_rk805) = { .probe = rk8xx_probe, .ops = &rk8xx_ops, }; + +U_BOOT_DRIVER_ALIAS (rockchip_rk805, rockchip_rk808)
drivers/serial/ns16550.c +4 -0
@@ -619,6 +619,10 @@ U_BOOT_DRIVER(ns16550_serial) = { .flags = DM_FLAG_PRE_RELOC, #endif }; + +U_BOOT_DRIVER_ALIAS(ns16550_serial, rockchip_rk3328_uart) +U_BOOT_DRIVER_ALIAS(ns16550_serial, rockchip_rk3368_uart) +U_BOOT_DRIVER_ALIAS(ns16550_serial, ti_da830_uart)#endif #endif /* SERIAL_PRESENT */
drivers/spi/mxs_spi.c +2 -0
@@ -618,4 +618,6 @@ U_BOOT_DRIVER(fsl_imx23_spi) = { .priv_auto_alloc_size = sizeof(struct mxs_spi_priv), .probe = mxs_spi_probe, }; + +U_BOOT_DRIVER_ALIAS(fsl_imx23_spi, fsl_imx28_spi)#endif
drivers/spi/rk_spi.c +2 -0
@@ -561,3 +561,5 @@ U_BOOT_DRIVER(rockchip_rk3288_spi) = { .priv_auto_alloc_size = sizeof(struct rockchip_spi_priv), .probe = rockchip_spi_probe, }; + +U_BOOT_DRIVER_ALIAS (rockchip_rk3288_spi, rockchip_rk3368_spi)
include/dm/device.h +7 -0
@@ -282,6 +282,13 @@ struct driver {#define DM_GET_DRIVER (__name) \ ll_entry_get(struct driver, __name, driver) +/** +* Declare a macro to state a alias for a driver name. This macro will +* produce no code but its information will be parsed by tools like +* dtoc +*/ +#define U_BOOT_DRIVER_ALIAS (__name, __alias) +/** * dev_get_platdata() - Get the platform data for a device *
Signature · 1 line
2.20.1
PATCH v4 3/14 core: add support for U_BOOT_DRIVER_ALIAS
Quoted 15 lines · Walter Lozano
Currently when using
OF_PLATDATAthe binding between devices and drivers is done trying to match the compatible string in the node with a driver name. However, usually a single driver supports multiple compatible strings which causes that only devices which its compatible string matches a driver name get bound.To overcome this issue, this patch adds the
U_BOOT_DRIVER_ALIASmacro, which generates no code at all, but allows an easy way to declare driver name aliases. Thanks to this, dtoc could be improve to look for the driver name based on its alias when it populates theU_BOOT_DEVICEentry.Signed-off-by Walter Lozano <[email protected]>---
Quoted 16 lines
drivers/clk/at91/pmc.c | 2 ++ drivers/gpio/mxs_gpio.c | 2 ++ drivers/gpio/sandbox.c | 2 ++ drivers/i2c/rk_i2c.c | 2 ++ drivers/mmc/mxsmmc.c | 1 + drivers/mmc/rockchip_dw_mmc.c | 3 +++ drivers/mtd/spi/sf_probe.c | 2 ++ drivers/pinctrl/nxp/pinctrl-mxs.c | 2 ++ drivers/pinctrl/pinctrl-at91.c | 2 ++ drivers/power/pmic/rk8xx.c | 2 ++ drivers/serial/ns16550.c | 4 ++++ drivers/spi/mxs_spi.c | 2 ++ drivers/spi/rk_spi.c | 2 ++ include/dm/device.h | 7 +++++++ 14 files changed, 35 insertions(+)
PATCH v4 4/14 dtoc: add support to scan drivers
In reply to Walter LozanoCurrently dtoc scans dtbs to convert them to struct platdata and to generate U_BOOT_DEVICE entries. These entries need to be filled with the driver name, but at this moment the information used is the compatible name present in the dtb. This causes that only nodes with a compatible name that matches a driver name generate a working entry.
In order to improve this behaviour, this patch adds to dtoc the capability of scan drivers source code to generate a list of valid driver names and aliases. This allows to generate U_BOOT_DEVICE entries using valid driver names and rise a warning in the case a name is not valid.
---
tools/dtoc/dtb_platdata.py | 91 ++++++++++++++++++++++++++++++++++++-- tools/dtoc/test_dtoc.py | 33 ++++++++++++++ 2 files changed, 120 insertions(+), 4 deletions(-)
tools/dtoc/dtb_platdata.py +87 -4
@@ -13,6 +13,8 @@ static data. import collections import copy +import os +import re import sys from dtoc import fdt
@@ -143,6 +145,11 @@ class DtbPlatdata(object): _aliases: Dict that hold aliases for compatible strings key: First compatible string declared in a node value: List of additional compatible strings declared in a node + _drivers: List of valid driver names found in drivers/ + _driver_aliases: Dict that holds aliases for driver names + key: Driver alias declared with + U_BOOT_DRIVER_ALIAS(driver_alias, driver_name) + value: Driver name declared with U_BOOT_DRIVER(driver_name) """ def __init__(self, dtb_fname, include_disabled): self._fdt = None
@@ -152,6 +159,38 @@ class DtbPlatdata(object): self._outfile = None self._lines = [] self._aliases = {} + self._drivers = [] + self._driver_aliases = {} + + def get_normalized_compat_name(self, node): + """Get a node's normalized compat name + + Returns a valid driver name by retrieving node's first compatible + string as a C identifier and performing a check against _drivers + and a lookup in driver_aliases printing a warning in case of failure. + + Args: + node: Node object to check + Return: + Tuple: + Driver name associated with the first compatible string + List of C identifiers for all the other compatible strings + (possibly empty) + In case of no match found, the return will be the same as + get_compat_name() + """ + compat_c, aliases_c = get_compat_name(node) + if compat_c not in self._drivers: + compat_c_old = compat_c + compat_c = self._driver_aliases.get(compat_c) + if not compat_c: + print('WARNING: the driver %s was not found in the driver list' + % (compat_c_old)) + compat_c = compat_c_old + else: + aliases_c = [compat_c_old] + aliases_c + + return compat_c, aliases_c def setup_output(self, fname): """Set up the output destination
@@ -246,6 +285,49 @@ class DtbPlatdata(object): return PhandleInfo(max_args, args) return None + def scan_driver(self, fn): + """Scan a driver file to build a list of driver names and aliases + + This procedure will populate self._drivers and self._driver_aliases + + Args + fn: Driver filename to scan + """ + with open(fn) as fd: + buff = fd.read() + + # The following re will search for driver names declared as + # U_BOOT_DRIVER(driver_name) + drivers = re.findall('U_BOOT_DRIVER\((.*)\)', buff) + + for driver in drivers: + self._drivers.append(driver) + + # The following re will search for driver aliases declared as + # U_BOOT_DRIVER_ALIAS(alias, driver_name) + driver_aliases = re.findall('U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)', + buff) + + for alias in driver_aliases: # pragma: no cover + if len(alias) != 2: + continue + self._driver_aliases[alias[1]] = alias[0] + + def scan_drivers(self): + """Scan the driver folders to build a list of driver names and aliases + + This procedure will populate self._drivers and self._driver_aliases + + """ + basedir = sys.argv[0].replace('tools/dtoc/dtoc', '') + if basedir == '': + basedir = './' + for (dirpath, dirnames, filenames) in os.walk(basedir): + for fn in filenames: + if not fn.endswith('.c'): + continue + self.scan_driver(dirpath + '/' + fn) + def scan_dtb(self): """Scan the device tree to obtain a tree of nodes and properties
@@ -356,7 +438,7 @@ class DtbPlatdata(object): """ structs = {} for node in self._valid_nodes: - node_name, _ = get_compat_name(node) + node_name, _ = self.get_normalized_compat_name(node) fields = {} # Get a list of all the valid properties in this node.
@@ -380,14 +462,14 @@ class DtbPlatdata(object): upto = 0 for node in self._valid_nodes: - node_name, _ = get_compat_name(node) + node_name, _ = self.get_normalized_compat_name(node) struct = structs[node_name] for name, prop in node.props.items(): if name not in PROP_IGNORE_LIST and name[0] != '#': prop.Widen(struct[name]) upto += 1 - struct_name, aliases = get_compat_name(node) + struct_name, aliases = self.get_normalized_compat_name(node) for alias in aliases: self._aliases[alias] = struct_name
@@ -464,7 +546,7 @@ class DtbPlatdata(object): Args: node: node to output """ - struct_name, _ = get_compat_name(node) + struct_name, _ = self.get_normalized_compat_name(node) var_name = conv_name_to_c(node.name) self.buf('static const struct %s%s %s%s = {\n' % (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
@@ -565,6 +647,7 @@ def run_steps(args, dtb_file, include_disabled, output): raise ValueError('Please specify a command: struct, platdata') plat = DtbPlatdata(dtb_file, include_disabled) + plat.scan_drivers() plat.scan_dtb() plat.scan_tree() plat.scan_reg_sizes()
tools/dtoc/test_dtoc.py +33 -0
@@ -266,6 +266,39 @@ U_BOOT_DEVICE(pmic_at_9) = { \t.platdata_size\t= sizeof(dtv_pmic_at_9), }; +''', data) + + def test_driver_alias(self): + """Test output from a device tree file with a driver alias""" + dtb_file = get_dtb_file('dtoc_test_driver_alias.dts') + output = tools.GetOutputFilename('output') + dtb_platdata.run_steps(['struct'], dtb_file, False, output) + with open(output) as infile: + data = infile.read() + self._CheckStrings(HEADER + ''' +struct dtd_sandbox_gpio { +\tconst char *\tgpio_bank_name; +\tbool\t\tgpio_controller; +\tfdt32_t\t\tsandbox_gpio_count; +}; +#define dtd_sandbox_gpio_alias dtd_sandbox_gpio +''', data) + + dtb_platdata.run_steps(['platdata'], dtb_file, False, output) + with open(output) as infile: + data = infile.read() + self._CheckStrings(C_HEADER + ''' +static const struct dtd_sandbox_gpio dtv_gpios_at_0 = { +\t.gpio_bank_name\t\t= "a", +\t.gpio_controller\t= true, +\t.sandbox_gpio_count\t= 0x14, +}; +U_BOOT_DEVICE(gpios_at_0) = { +\t.name\t\t= "sandbox_gpio", +\t.platdata\t= &dtv_gpios_at_0, +\t.platdata_size\t= sizeof(dtv_gpios_at_0), +}; + ''', data) def test_phandle(self):
Signature · 1 line
2.20.1
PATCH v4 4/14 dtoc: add support to scan drivers
Quoted 13 lines · Walter Lozano
Currently dtoc scans dtbs to convert them to struct platdata and to generate
U_BOOT_DEVICEentries. These entries need to be filled with the driver name, but at this moment the information used is the compatible name present in the dtb. This causes that only nodes with a compatible name that matches a driver name generate a working entry.In order to improve this behaviour, this patch adds to dtoc the capability of scan drivers source code to generate a list of valid driver names and aliases. This allows to generate
U_BOOT_DEVICEentries using valid driver names and rise a warning in the case a name is not valid.
Quoted 7 lines
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 91 ++++++++++++++++++++++++++++++++++++-- tools/dtoc/test_dtoc.py | 33 ++++++++++++++ 2 files changed, 120 insertions(+), 4 deletions(-)
PATCH v4 4/14 dtoc: add support to scan drivers
Hi Walter,
Quoted 18 lines · Simon Glass
Quoted 16 lines · Walter Lozano
Currently dtoc scans dtbs to convert them to struct platdata and to generate
U_BOOT_DEVICEentries. These entries need to be filled with the driver name, but at this moment the information used is the compatible name present in the dtb. This causes that only nodes with a compatible name that matches a driver name generate a working entry.In order to improve this behaviour, this patch adds to dtoc the capability of scan drivers source code to generate a list of valid driver names and aliases. This allows to generate
U_BOOT_DEVICEentries using valid driver names and rise a warning in the case a name is not valid.Signed-off-by Walter Lozano <[email protected]>---
Quoted 6 lines
Quoted 4 lines
tools/dtoc/dtb_platdata.py | 91 ++++++++++++++++++++++++++++++++++++-- tools/dtoc/test_dtoc.py | 33 ++++++++++++++ 2 files changed, 120 insertions(+), 4 deletions(-)Reviewed-by Simon Glass <[email protected]>
Unfortunately this patch seems to be missing a file dtoc_test_driver_alias.dts without which the tests fail. Can you please resend just this patch?
Regards,
Simon
PATCH v4 4/14 dtoc: add support to scan drivers
Quoted 19 lines · Simon Glass
Hi Walter,
Quoted 16 lines · Simon Glass
Quoted 15 lines · Walter Lozano
Currently dtoc scans dtbs to convert them to struct platdata and to generate
U_BOOT_DEVICEentries. These entries need to be filled with the driver name, but at this moment the information used is the compatible name present in the dtb. This causes that only nodes with a compatible name that matches a driver name generate a working entry.In order to improve this behaviour, this patch adds to dtoc the capability of scan drivers source code to generate a list of valid driver names and aliases. This allows to generate
U_BOOT_DEVICEentries using valid driver names and rise a warning in the case a name is not valid.Signed-off-by Walter Lozano <[email protected]>---
Quoted 9 lines
Quoted 5 lines
Quoted 4 lines
tools/dtoc/dtb_platdata.py | 91 ++++++++++++++++++++++++++++++++++++-- tools/dtoc/test_dtoc.py | 33 ++++++++++++++ 2 files changed, 120 insertions(+), 4 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this patch seems to be missing a file
dtoc_test_driver_alias.dtswithout which the tests fail. Can you please resend just this patch?
Sorry for the mistake. I've just sent the patch.
Thanks for your time and deep review.
Regards,
Walter
PATCH v4 5/14 dtoc: add option to disable warnings
In reply to Walter LozanoAs dtoc now performs checks for valid driver names, when running dtoc tests several warnings arise as these tests don't use valid driver names.
This patch adds an option to disable those warning, which is only intended for running tests.
---
tools/dtoc/dtb_platdata.py | 13 ++-- tools/dtoc/dtoc_test_invalid_driver.dts | 15 ++++ tools/dtoc/test_dtoc.py | 91 +++++++++++++++++-------- 3 files changed, 85 insertions(+), 34 deletions(-) create mode 100644 tools/dtoc/dtoc_test_invalid_driver.dts
tools/dtoc/dtb_platdata.py +8 -5
@@ -141,6 +141,7 @@ class DtbPlatdata(object): _valid_nodes: A list of Node object with compatible strings _include_disabled: true to include nodes marked status = "disabled" _outfile: The current output file (sys.stdout or a real file) + _warning_disabled: true to disable warnings about driver names not found _lines: Stashed list of output lines for outputting in the future _aliases: Dict that hold aliases for compatible strings key: First compatible string declared in a node
@@ -151,12 +152,13 @@ class DtbPlatdata(object): U_BOOT_DRIVER_ALIAS(driver_alias, driver_name) value: Driver name declared with U_BOOT_DRIVER(driver_name) """ - def __init__(self, dtb_fname, include_disabled): + def __init__(self, dtb_fname, include_disabled, warning_disabled): self._fdt = None self._dtb_fname = dtb_fname self._valid_nodes = None self._include_disabled = include_disabled self._outfile = None + self._warning_disabled = warning_disabled self._lines = [] self._aliases = {} self._drivers = []
@@ -184,8 +186,9 @@ class DtbPlatdata(object): compat_c_old = compat_c compat_c = self._driver_aliases.get(compat_c) if not compat_c: - print('WARNING: the driver %s was not found in the driver list' - % (compat_c_old)) + if not self._warning_disabled: + print('WARNING: the driver %s was not found in the driver list' + % (compat_c_old)) compat_c = compat_c_old else: aliases_c = [compat_c_old] + aliases_c
@@ -634,7 +637,7 @@ class DtbPlatdata(object): nodes_to_output.remove(node) -def run_steps(args, dtb_file, include_disabled, output): +def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False): """Run all the steps of the dtoc tool Args:
@@ -646,7 +649,7 @@ def run_steps(args, dtb_file, include_disabled, output): if not args: raise ValueError('Please specify a command: struct, platdata') - plat = DtbPlatdata(dtb_file, include_disabled) + plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled) plat.scan_drivers() plat.scan_dtb() plat.scan_tree()
tools/dtoc/dtoc_test_invalid_driver.dts new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test device tree file for dtoc + * + * Copyright 2017 Google, Inc + */ + +/dts-v1/; + +/ { + spl-test { + u-boot,dm-pre-reloc; + compatible = "invalid"; + }; +};
tools/dtoc/test_dtoc.py +62 -29
278 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 5/14 dtoc: add option to disable warnings
Quoted 8 lines · Walter Lozano
As dtoc now performs checks for valid driver names, when running dtoc tests several warnings arise as these tests don't use valid driver names.
This patch adds an option to disable those warning, which is only intended for running tests.
Quoted 8 lines
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 13 ++-- tools/dtoc/dtoc_test_invalid_driver.dts | 15 ++++ tools/dtoc/test_dtoc.py | 91 +++++++++++++++++-------- 3 files changed, 85 insertions(+), 34 deletions(-) create mode 100644 tools/dtoc/dtoc_test_invalid_driver.dts
PATCH v4 5/14 dtoc: add option to disable warnings
Quoted 8 lines · Walter Lozano
As dtoc now performs checks for valid driver names, when running dtoc tests several warnings arise as these tests don't use valid driver names.
This patch adds an option to disable those warning, which is only intended for running tests.
Quoted 8 lines
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 13 ++-- tools/dtoc/dtoc_test_invalid_driver.dts | 15 ++++ tools/dtoc/test_dtoc.py | 91 +++++++++++++++++-------- 3 files changed, 85 insertions(+), 34 deletions(-) create mode 100644 tools/dtoc/dtoc_test_invalid_driver.dts
Applied to u-boot-dm/next, thanks!
PATCH v4 6/14 dm: doc: update of-plat with the support for driver aliases
In reply to Walter LozanoUpdate the documentation with the support for driver aliases using U_BOOT_DRIVER_ALIAS.
---
doc/driver-model/of-plat.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
doc/driver-model/of-plat.rst +13 -1
@@ -183,6 +183,17 @@ via U_BOOT_DRIVER(). This effectively means that a U_BOOT_DRIVER() with a it to a valid name for C) is needed, so a dedicated driver is required for each 'compatible' string. +In order to make this a bit more flexible U_BOOT_DRIVER_ALIAS macro can be +used to declare an alias for a driver name, typically a 'compatible' string. +This macro produces no code, but it is by dtoc tool. + +During the build process dtoc parses both U_BOOT_DRIVER and U_BOOT_DRIVER_ALIAS +to build a list of valid driver names and driver aliases. If the 'compatible' +string used for a device does not not match a valid driver name, it will be +checked against the list of driver aliases in order to get the right driver +name to use. If in this step there is no match found a warning is issued to +avoid run-time failures. + Where a node has multiple compatible strings, a #define is used to make them equivalent, e.g.:
@@ -269,7 +280,7 @@ For example: }; U_BOOT_DRIVER(mmc_drv) = { - .name = "vendor_mmc", /* matches compatible string */ + .name = "mmc_drv", .id = UCLASS_MMC, .of_match = mmc_ids, .ofdata_to_platdata = mmc_ofdata_to_platdata,
@@ -278,6 +289,7 @@ For example: .platdata_auto_alloc_size = sizeof(struct mmc_platdata), }; + U_BOOT_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */ Note that struct mmc_platdata is defined in the C file, not in a header. This is to avoid needing to include dt-structs.h in a header file. The idea is to
Signature · 1 line
2.20.1
PATCH v4 6/14 dm: doc: update of-plat with the support for driver aliases
Quoted 9 lines · Walter Lozano
Update the documentation with the support for driver aliases using
U_BOOT_DRIVER_ALIAS.Signed-off-by Walter Lozano <[email protected]>---
doc/driver-model/of-plat.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
PATCH v4 6/14 dm: doc: update of-plat with the support for driver aliases
Quoted 9 lines · Walter Lozano
Update the documentation with the support for driver aliases using
U_BOOT_DRIVER_ALIAS.Signed-off-by Walter Lozano <[email protected]>---
doc/driver-model/of-plat.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v4 7/14 core: drop const for struct driver_info
In reply to Walter LozanoIn order to prepare for a new support of phandle when OF_PLATDATA is used drop the const for struct driver_info as this struct will need to be updated on runtime.
---
drivers/core/device.c | 2 +- drivers/core/root.c | 2 +- include/dm/device-internal.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/core/device.c +1 -1
@@ -246,7 +246,7 @@ int device_bind_ofnode(struct udevice *parent, const struct driver *drv, }int device_bind_by_name (struct udevice *parent,bool pre_reloc_only, -const struct driver_info *info,struct udevice **devp) +struct driver_info *info,struct udevice **devp) {struct driver *drv;uint platdata_size =0 ;
drivers/core/root.c +1 -1
@@ -25,7 +25,7 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct driver_info root_info = { +static struct driver_info root_info = { .name ="root_driver" , };
include/dm/device-internal.h +1 -1
@@ -81,7 +81,7 @@ int device_bind_with_driver_data(struct udevice *parent,* @return 0 if OK, -ve on error */ int device_bind_by_name (struct udevice *parent,bool pre_reloc_only, -const struct driver_info *info,struct udevice **devp); +struct driver_info *info,struct udevice **devp);/** * device_ofdata_to_platdata() - Read platform data for a device
Signature · 1 line
2.20.1
PATCH v4 7/14 core: drop const for struct driver_info
Quoted 5 lines · Walter Lozano
In order to prepare for a new support of phandle when
OF_PLATDATAis used drop the const for structdriver_infoas this struct will need to be updated on runtime.
Quoted 7 lines
Signed-off-by Walter Lozano <[email protected]>---
drivers/core/device.c | 2 +- drivers/core/root.c | 2 +- include/dm/device-internal.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
PATCH v4 7/14 core: drop const for struct driver_info
Quoted 5 lines · Walter Lozano
In order to prepare for a new support of phandle when
OF_PLATDATAis used drop the const for structdriver_infoas this struct will need to be updated on runtime.
Quoted 7 lines
Signed-off-by Walter Lozano <[email protected]>---
drivers/core/device.c | 2 +- drivers/core/root.c | 2 +- include/dm/device-internal.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v4 8/14 core: extend struct driver_info to point to device
In reply to Walter LozanoCurrently when creating an U_BOOT_DEVICE entry a struct driver_info is declared, which contains the data needed to instantiate the device. However, the actual device is created at runtime and there is no proper way to get the device based on its struct driver_info.
This patch extends struct driver_info adding a pointer to udevice which is populated during the bind process, allowing to generate a set of functions to get the device based on its struct driver_info.
---
drivers/core/device.c | 26 +++++++++++++++++++++++--- drivers/core/root.c | 4 ++++ include/dm/device.h | 15 +++++++++++++++ include/dm/platdata.h | 14 ++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-)
drivers/core/device.c +23 -3
@@ -250,6 +250,7 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, {struct driver *drv;uint platdata_size =0 ; +int ret; drv =lists_driver_lookup_name (info->name);if (!drv)
@@ -260,9 +261,16 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,#if CONFIG_IS_ENABLED (OF_PLATDATA ) platdata_size = info->platdata_size;#endif -return device_bind_common (parent, drv, info->name, - (void *)info->platdata,0 ,ofnode_null (), platdata_size, - devp); + ret =device_bind_common (parent, drv, info->name, + (void *)info->platdata,0 ,ofnode_null (), + platdata_size, devp); +if (ret) +return ret; +#if CONFIG_IS_ENABLED (OF_PLATDATA ) + info->dev = *devp; +#endif + +return ret; }static void *alloc_priv (int size,uint flags)
@@ -727,6 +735,18 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp)return device_get_device_tail (dev, dev ?0 : -ENOENT , devp); } +#if CONFIG_IS_ENABLED (OF_PLATDATA ) +int device_get_by_driver_info (const struct driver_info *info, +struct udevice **devp) +{ +struct udevice *dev; + + dev = info->dev; + +return device_get_device_tail (dev, dev ?0 : -ENOENT , devp); +} +#endif +int device_find_first_child (const struct udevice *parent,struct udevice **devp) {if (list_empty (&parent->child_head)) {
drivers/core/root.c +4 -0
@@ -346,6 +346,10 @@ int dm_init_and_scan(bool pre_reloc_only) {int ret; +#if CONFIG_IS_ENABLED (OF_PLATDATA ) +dm_populate_phandle_data (); +#endif + ret =dm_init (IS_ENABLED (CONFIG_OF_LIVE ));if (ret) {debug ("dm_init() failed: %d\n" , ret);
include/dm/device.h +15 -0
@@ -538,6 +538,21 @@ int device_find_global_by_ofnode(ofnode node, struct udevice **devp);*/ int device_get_global_by_ofnode (ofnode node,struct udevice **devp); +/** +* device_get_by_driver_info() - Get a device based on driver_info +* +* Locates a device by its struct driver_info, by using its reference which +* is updated during the bind process. +* +* The device is probed to activate it ready for use. +* +* @info: Struct driver_info +* @devp: Returns pointer to device if found, otherwise this is set to NULL +* @return 0 if OK, -ve on error +*/ +int device_get_by_driver_info (const struct driver_info *info, +struct udevice **devp); +/** * device_find_first_child() - Find the first child of a device *
include/dm/platdata.h +14 -0
@@ -22,12 +22,14 @@* @name: Driver name * @platdata: Driver-specific platform data * @platdata_size: Size of platform data structure +* @dev: Device created from this structure data */ struct driver_info {const char *name;const void *platdata;#if CONFIG_IS_ENABLED (OF_PLATDATA )uint platdata_size; +struct udevice *dev;#endif };
@@ -43,4 +45,16 @@ struct driver_info {#define U_BOOT_DEVICES (__name) \ ll_entry_declare_list(struct driver_info, __name, driver_info) +/* Get a pointer to a given driver */ +#define DM_GET_DEVICE (__name) \ + ll_entry_get(struct driver_info, __name, driver_info) + +/** +* dm_populate_phandle_data() - Populates phandle data in platda +* +* This populates phandle data with an U_BOOT_DEVICE entry get by +* DM_GET_DEVICE. The implementation of this function will be done +* by dtoc when parsing dtb. +*/ +void dm_populate_phandle_data (void );#endif
Signature · 1 line
2.20.1
PATCH v4 8/14 core: extend struct driver_info to point to device
Quoted 10 lines · Walter Lozano
Currently when creating an
U_BOOT_DEVICEentry a structdriver_infois declared, which contains the data needed to instantiate the device. However, the actual device is created at runtime and there is no proper way to get the device based on its structdriver_info.This patch extends struct
driver_infoadding a pointer to udevice which is populated during the bind process, allowing to generate a set of functions to get the device based on its structdriver_info.
Quoted 8 lines
Signed-off-by Walter Lozano <[email protected]>---
drivers/core/device.c | 26 +++++++++++++++++++++++--- drivers/core/root.c | 4 ++++ include/dm/device.h | 15 +++++++++++++++ include/dm/platdata.h | 14 ++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-)
PATCH v4 8/14 core: extend struct driver_info to point to device
Quoted 10 lines · Walter Lozano
Currently when creating an
U_BOOT_DEVICEentry a structdriver_infois declared, which contains the data needed to instantiate the device. However, the actual device is created at runtime and there is no proper way to get the device based on its structdriver_info.This patch extends struct
driver_infoadding a pointer to udevice which is populated during the bind process, allowing to generate a set of functions to get the device based on its structdriver_info.
Quoted 8 lines
Signed-off-by Walter Lozano <[email protected]>---
drivers/core/device.c | 26 +++++++++++++++++++++++--- drivers/core/root.c | 4 ++++ include/dm/device.h | 15 +++++++++++++++ include/dm/platdata.h | 14 ++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v4 9/14 sandbox: Move section u_boot_list to make it RW
In reply to Walter LozanoIn order to be able to update data in u_boot_list, move this section to make it RW.
---
arch/sandbox/cpu/u-boot-spl.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sandbox/cpu/u-boot-spl.lds +1 -1
@@ -20,4 +20,4 @@ SECTIONS __bss_start = .; } -INSERT BEFORE .data; +INSERT AFTER .data;
Signature · 1 line
2.20.1
PATCH v4 9/14 sandbox: Move section u_boot_list to make it RW
Quoted 9 lines · Walter Lozano
In order to be able to update data in
u_boot_list, move this section to make it RW.Signed-off-by Walter Lozano <[email protected]>---
arch/sandbox/cpu/u-boot-spl.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v4 9/14 sandbox: Move section u_boot_list to make it RW
Quoted 9 lines · Walter Lozano
In order to be able to update data in
u_boot_list, move this section to make it RW.Signed-off-by Walter Lozano <[email protected]>---
arch/sandbox/cpu/u-boot-spl.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v4 10/14 dtoc: extend dtoc to use struct driver_info when linking nodes
In reply to Walter LozanoIn the current implementation, when dtoc parses a dtb to generate a struct platdata it converts the information related to linked nodes as pointers to struct platdata of destination nodes. By doing this, it makes difficult to get pointer to udevices created based on these information.
This patch extends dtoc to use struct driver_info when populating information about linked nodes, which makes it easier to later get the devices created. In this context, reimplement functions like clk_get_by_index_platdata() which made use of the previous approach.
---
drivers/clk/clk-uclass.c | 11 ++- drivers/misc/irq-uclass.c | 10 ++- drivers/mmc/ftsdc010_mci.c | 2 +- drivers/mmc/rockchip_dw_mmc.c | 2 +- drivers/mmc/rockchip_sdhci.c | 2 +- drivers/ram/rockchip/sdram_rk3399.c | 2 +- drivers/spi/rk_spi.c | 2 +- include/clk.h | 4 +- tools/dtoc/dtb_platdata.py | 26 ++++++- tools/dtoc/test_dtoc.py | 104 ++++++++++++++++------------ 10 files changed, 100 insertions(+), 65 deletions(-)
drivers/clk/clk-uclass.c +5 -6
@@ -25,17 +25,16 @@ static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)#if CONFIG_IS_ENABLED (OF_CONTROL )# if CONFIG_IS_ENABLED (OF_PLATDATA ) -int clk_get_by_index_platdata (struct udevice *dev,int index, -struct phandle_1_arg *cells,struct clk *clk) +int clk_get_by_driver_info (struct udevice *dev,struct phandle_1_arg *cells, +struct clk *clk) {int ret; -if (index !=0 ) -return -ENOSYS ; - ret =uclass_get_device (UCLASS_CLK ,0 , &clk->dev); + ret =device_get_by_driver_info ((struct driver_info *)cells->node, + &clk->dev);if (ret)return ret; - clk->id = cells[0 ].arg[0 ]; + clk->id = cells->arg[0 ];return 0 ; }
drivers/misc/irq-uclass.c +4 -6
@@ -63,17 +63,15 @@ int irq_read_and_clear(struct irq *irq) }#if CONFIG_IS_ENABLED (OF_PLATDATA ) -int irq_get_by_index_platdata (struct udevice *dev,int index, -struct phandle_1_arg *cells,struct irq *irq) +int irq_get_by_driver_info (struct udevice *dev, +struct phandle_1_arg *cells,struct irq *irq) {int ret; -if (index !=0 ) -return -ENOSYS ; - ret =uclass_get_device (UCLASS_IRQ ,0 , &irq->dev); + ret =device_get_by_driver_info (cells->node, &irq->dev);if (ret)return ret; - irq->id = cells[0 ].arg[0 ]; + irq->id = cells->arg[0 ];return 0 ; }
drivers/mmc/ftsdc010_mci.c +1 -1
@@ -437,7 +437,7 @@ static int ftsdc010_mmc_probe(struct udevice *dev) chip->priv = dev; chip->dev_index =1 ;memcpy (priv->minmax, dtplat->clock_freq_min_max,sizeof (priv->minmax)); - ret =clk_get_by_index_platdata (dev,0 , dtplat->clocks, &priv->clk); + ret =clk_get_by_driver_info (dev, dtplat->clocks, &priv->clk);if (ret <0 )return ret;#endif
drivers/mmc/rockchip_dw_mmc.c +1 -1
@@ -120,7 +120,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev) priv->minmax[0 ] =400000 ;/* 400 kHz */ priv->minmax[1 ] = dtplat->max_frequency; - ret =clk_get_by_index_platdata (dev,0 , dtplat->clocks, &priv->clk); + ret =clk_get_by_driver_info (dev, dtplat->clocks, &priv->clk);if (ret <0 )return ret;#else
drivers/mmc/rockchip_sdhci.c +1 -1
@@ -46,7 +46,7 @@ static int arasan_sdhci_probe(struct udevice *dev) host->name = dev->name; host->ioaddr =map_sysmem (dtplat->reg[0 ], dtplat->reg[1 ]); max_frequency = dtplat->max_frequency; - ret =clk_get_by_index_platdata (dev,0 , dtplat->clocks, &clk); + ret =clk_get_by_driver_info (dev, dtplat->clocks, &clk);#else max_frequency =dev_read_u32_default (dev,"max-frequency" ,0 ); ret =clk_get_by_index (dev,0 , &clk);
drivers/ram/rockchip/sdram_rk3399.c +1 -1
@@ -3125,7 +3125,7 @@ static int rk3399_dmc_init(struct udevice *dev) priv->cic, priv->pmugrf, priv->pmusgrf, priv->pmucru, priv->pmu);#if CONFIG_IS_ENABLED (OF_PLATDATA ) - ret =clk_get_by_index_platdata (dev,0 , dtplat->clocks, &priv->ddr_clk); + ret =clk_get_by_driver_info (dev, dtplat->clocks, &priv->ddr_clk);#else ret =clk_get_by_index (dev,0 , &priv->ddr_clk);#endif
drivers/spi/rk_spi.c +1 -1
@@ -181,7 +181,7 @@ static int conv_of_platdata(struct udevice *dev) plat->base = dtplat->reg[0 ]; plat->frequency =20000000 ; - ret =clk_get_by_index_platdata (dev,0 , dtplat->clocks, &priv->clk); + ret =clk_get_by_driver_info (dev, dtplat->clocks, &priv->clk);if (ret <0 )return ret; dev->req_seq =0 ;
include/clk.h +2 -2
@@ -89,8 +89,8 @@ struct clk_bulk {#if CONFIG_IS_ENABLED (OF_CONTROL ) &&CONFIG_IS_ENABLED (CLK )struct phandle_1_arg ; -int clk_get_by_index_platdata (struct udevice *dev,int index, -struct phandle_1_arg *cells,struct clk *clk); +int clk_get_by_driver_info (struct udevice *dev, +struct phandle_1_arg *cells,struct clk *clk);/** * clk_get_by_index - Get/request a clock by integer index.
tools/dtoc/dtb_platdata.py +23 -3
@@ -151,6 +151,7 @@ class DtbPlatdata(object): key: Driver alias declared with U_BOOT_DRIVER_ALIAS(driver_alias, driver_name) value: Driver name declared with U_BOOT_DRIVER(driver_name) + _links: List of links to be included in dm_populate_phandle_data() """ def __init__(self, dtb_fname, include_disabled, warning_disabled): self._fdt = None
@@ -163,6 +164,7 @@ class DtbPlatdata(object): self._aliases = {} self._drivers = [] self._driver_aliases = {} + self._links = [] def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -551,7 +553,7 @@ class DtbPlatdata(object): """ struct_name, _ = self.get_normalized_compat_name(node) var_name = conv_name_to_c(node.name) - self.buf('static const struct %s%s %s%s = {\n' % + self.buf('static struct %s%s %s%s = {\n' % (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name)) for pname in sorted(node.props): prop = node.props[pname]
@@ -570,6 +572,7 @@ class DtbPlatdata(object): if info: # Process the list as pairs of (phandle, id) pos = 0 + item = 0 for args in info.args: phandle_cell = prop.value[pos] phandle = fdt_util.fdt32_to_cpu(phandle_cell)
@@ -579,8 +582,16 @@ class DtbPlatdata(object): for i in range(args): arg_values.append(str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i]))) pos += 1 + args - vals.append('\t{&%s%s, {%s}}' % (VAL_PREFIX, name, - ', '.join(arg_values))) + # node member is filled with NULL as the real value + # will be update at run-time during dm_init_and_scan() + # by dm_populate_phandle_data() + vals.append('\t{NULL, {%s}}' % (', '.join(arg_values))) + var_node = '%s%s.%s[%d].node' % \ + (VAL_PREFIX, var_name, member_name, item) + # Save the the link information to be use to define + # dm_populate_phandle_data() + self._links.append({'var_node': var_node, 'dev_name': name}) + item += 1 for val in vals: self.buf('\n\t\t%s,' % val) else:
@@ -636,6 +647,15 @@ class DtbPlatdata(object): self.output_node(node) nodes_to_output.remove(node) + # Define dm_populate_phandle_data() which will add the linking between + # nodes using DM_GET_DEVICE + # dtv_dmc_at_xxx.clocks[0].node = DM_GET_DEVICE(clock_controller_at_xxx) + self.buf('void dm_populate_phandle_data(void) {\n') + for l in self._links: + self.buf('\t%s = DM_GET_DEVICE(%s);\n' % (l['var_node'], l['dev_name'])) + self.buf('}\n') + + self.out(''.join(self.get_buf())) def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False): """Run all the steps of the dtoc tool
tools/dtoc/test_dtoc.py +61 -43
359 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 10/14 dtoc: extend dtoc to use struct driver_info when linking nodes
Quoted 15 lines · Walter Lozano
In the current implementation, when dtoc parses a dtb to generate a struct platdata it converts the information related to linked nodes as pointers to struct platdata of destination nodes. By doing this, it makes difficult to get pointer to udevices created based on these information.
This patch extends dtoc to use struct
driver_infowhen populating information about linked nodes, which makes it easier to later get the devices created. In this context, reimplement functions likeclk_get_by_index_platdata()which made use of the previous approach.Signed-off-by Walter Lozano <[email protected]>---
Quoted 12 lines
drivers/clk/clk-uclass.c | 11 ++- drivers/misc/irq-uclass.c | 10 ++- drivers/mmc/ftsdc010_mci.c | 2 +- drivers/mmc/rockchip_dw_mmc.c | 2 +- drivers/mmc/rockchip_sdhci.c | 2 +- drivers/ram/rockchip/sdram_rk3399.c | 2 +- drivers/spi/rk_spi.c | 2 +- include/clk.h | 4 +- tools/dtoc/dtb_platdata.py | 26 ++++++- tools/dtoc/test_dtoc.py | 104 ++++++++++++++++------------ 10 files changed, 100 insertions(+), 65 deletions(-)
PATCH v4 11/14 dm: doc: update of-plat with new phandle support
In reply to Walter LozanoUpdate documentation to reflect the new phandle support when OF_PLATDATA is used. Now phandles are implemented as pointers to U_BOOT_DEVICE, which makes it possible to get a pointer to the actual device.
---
doc/driver-model/of-plat.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
doc/driver-model/of-plat.rst +16 -8
@@ -69,9 +69,8 @@ strictly necessary. Notable problems include: - Correct relations between nodes are not implemented. This means that parent/child relations (like bus device iteration) do not work yet. Some phandles (those that are recognised as such) are converted into - a pointer to platform data. This pointer can potentially be used to - access the referenced device (by searching for the pointer value). - This feature is not yet implemented, however. + a pointer to struct driver_info. This pointer can be used to access + the referenced device. How it works
@@ -146,10 +145,10 @@ and the following device declaration: .clock_freq_min_max = {0x61a80, 0x8f0d180}, .vmmc_supply = 0xb, .num_slots = 0x1, - .clocks = {{&dtv_clock_controller_at_ff760000, 456}, - {&dtv_clock_controller_at_ff760000, 68}, - {&dtv_clock_controller_at_ff760000, 114}, - {&dtv_clock_controller_at_ff760000, 118}}, + .clocks = {{NULL, 456}, + {NULL, 68}, + {NULL, 114}, + {NULL, 118}}, .cap_mmc_highspeed = true, .disable_wp = true, .bus_width = 0x4,
@@ -164,6 +163,13 @@ and the following device declaration: .platdata_size = sizeof(dtv_dwmmc_at_ff0c0000), }; + void dm_populate_phandle_data(void) { + dtv_dwmmc_at_ff0c0000.clocks[0].node = DM_GET_DEVICE(clock_controller_at_ff760000); + dtv_dwmmc_at_ff0c0000.clocks[1].node = DM_GET_DEVICE(clock_controller_at_ff760000); + dtv_dwmmc_at_ff0c0000.clocks[2].node = DM_GET_DEVICE(clock_controller_at_ff760000); + dtv_dwmmc_at_ff0c0000.clocks[3].node = DM_GET_DEVICE(clock_controller_at_ff760000); + } + The device is then instantiated at run-time and the platform data can be accessed using:
@@ -329,7 +335,9 @@ prevents them being used inadvertently. All usage must be bracketed with #if CONFIG_IS_ENABLED(OF_PLATDATA). The dt-platdata.c file contains the device declarations and is is built in -spl/dt-platdata.c. +spl/dt-platdata.c. It additionally contains the definition of +dm_populate_phandle_data() which is responsible of filling the phandle +information by adding references to U_BOOT_DEVICE by using DM_GET_DEVICE The beginnings of a libfdt Python module are provided. So far this only implements a subset of the features.
Signature · 1 line
2.20.1
PATCH v4 11/14 dm: doc: update of-plat with new phandle support
Quoted 11 lines · Walter Lozano
Update documentation to reflect the new phandle support when
OF_PLATDATAis used. Now phandles are implemented as pointers toU_BOOT_DEVICE, which makes it possible to get a pointer to the actual device.Signed-off-by Walter Lozano <[email protected]>---
doc/driver-model/of-plat.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
PATCH v4 11/14 dm: doc: update of-plat with new phandle support
Quoted 11 lines · Walter Lozano
Update documentation to reflect the new phandle support when
OF_PLATDATAis used. Now phandles are implemented as pointers toU_BOOT_DEVICE, which makes it possible to get a pointer to the actual device.Signed-off-by Walter Lozano <[email protected]>---
doc/driver-model/of-plat.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v4 12/14 arm: dts: include gpio nodes for card detect
In reply to Walter LozanoSeveral MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios.
This patch, fixes several ocurrence of this issue.
---
arch/arm/dts/da850-evm-u-boot.dtsi | 4 ++++ arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 +++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/rk3288-veyron-u-boot.dtsi
arch/arm/dts/da850-evm-u-boot.dtsi +4 -0
@@ -39,3 +39,7 @@ &spi1 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl; +};
arch/arm/dts/da850-lcdk-u-boot.dtsi +4 -0
@@ -28,3 +28,7 @@ &serial2 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl; +};
arch/arm/dts/rk3288-u-boot.dtsi +4 -0
@@ -43,3 +43,7 @@ &noc { u-boot,dm-pre-reloc; }; + +&gpio7 { + u-boot,dm-pre-reloc; +};
arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi +1 -1
@@ -3,7 +3,7 @@ * Copyright 2015 Google, Inc */ -#include "rk3288-u-boot.dtsi" +#include "rk3288-veyron-u-boot.dtsi" &dmc { rockchip,pctl-timing = <0x215 0xc8 0x0 0x35 0x26 0x2 0x70 0x2000d
arch/arm/dts/rk3288-veyron-u-boot.dtsi new file +11 -0
@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright 2015 Google, Inc + */ + +#include "rk3288-u-boot.dtsi" + +&gpio7 { + u-boot,dm-pre-reloc; +}; +
Signature · 1 line
2.20.1
PATCH v4 12/14 arm: dts: include gpio nodes for card detect
Quoted 12 lines · Walter Lozano
Several MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios.
This patch, fixes several ocurrence of this issue.
Signed-off-by Walter Lozano <[email protected]>---
Quoted 7 lines
arch/arm/dts/da850-evm-u-boot.dtsi | 4 ++++ arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 +++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/rk3288-veyron-u-boot.dtsi
PATCH v4 12/14 arm: dts: include gpio nodes for card detect
In reply to Walter LozanoQuoted 25 lines · Walter Lozano
Several MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios.
This patch, fixes several ocurrence of this issue.
Signed-off-by Walter Lozano <[email protected]>---
arch/arm/dts/da850-evm-u-boot.dtsi | 4 ++++ arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 +++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/rk3288-veyron-u-boot.dtsiarch/arm/dts/da850-evm-u-boot.dtsi +0
-0
arch/arm/dts/da850-evm-u-boot.dtsi line 45
Quoted 7 lines
arch/arm/dts/da850-evm-u-boot.dtsi +4
-0@@ -39,3 +39,7 @@ &spi1 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl; +};
I don't know that this is needed for the da850-evm since it doesn't boot from sd/mmc. It can boot from SPI, NAND or NOR Flash depending on the config option selected, but none of them need the gpio during SPL. The gpio is loaded during normal U-Boot. I will try to run some tests to make sure it still boots in the next few days. I know space is getting tight in SPL.
Quoted 57 lines
arch/arm/dts/da850-lcdk-u-boot.dtsi +4
-0@@ -28,3 +28,7 @@ &serial2 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl; +};arch/arm/dts/rk3288-u-boot.dtsi +4
-0@@ -43,3 +43,7 @@ &noc { u-boot,dm-pre-reloc; }; + +&gpio7 { + u-boot,dm-pre-reloc; +};arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi +1
-1@@ -3,7 +3,7 @@ * Copyright 2015 Google, Inc */ -#include "rk3288-u-boot.dtsi" +#include "rk3288-veyron-u-boot.dtsi" &dmc { rockchip,pctl-timing = <0x215 0xc8 0x0 0x35 0x26 0x2 0x70 0x2000darch/arm/dts/rk3288-veyron-u-boot.dtsi new file +11
-1@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright 2015 Google, Inc + */ + +#include "rk3288-u-boot.dtsi" + +&gpio7 { + u-boot,dm-pre-reloc; +}; + --2.20.1
PATCH v4 12/14 arm: dts: include gpio nodes for card detect
Quoted 34 lines · Adam Ford
Quoted 31 lines · Walter Lozano
Several MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios.
This patch, fixes several ocurrence of this issue.
Signed-off-by Walter Lozano <[email protected]>---
arch/arm/dts/da850-evm-u-boot.dtsi | 4 ++++ arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 +++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/rk3288-veyron-u-boot.dtsiarch/arm/dts/da850-evm-u-boot.dtsi +3
-0@@ -39,3 +39,7 @@ &spi1 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl;
Quoted 8 lines
arch/arm/dts/da850-evm-u-boot.dtsi line 45
Quoted 1 line
arch/arm/dts/da850-evm-u-boot.dtsi +1
-0+};I don't know that this is needed for the da850-evm since it doesn't boot from sd/mmc. It can boot from SPI, NAND or NOR Flash depending on the config option selected, but none of them need the gpio during SPL. The gpio is loaded during normal U-Boot. I will try to run some tests to make sure it still boots in the next few days. I know space is getting tight in SPL.
I applied your patches and built.
FYI, "git am" didn't let them apply nicely, but there could be some missing dependent patches I was missing. I was able to patch with "patch"
The board booted as expected.
I examined the generated dtb for SPL since this board doesn't use OF_PLATDATA. It looks like we could remove both the GPIO and the MMC modes from SPL, but I'm not going to worry about it unless we can't boot any more. If/when that happens, I'll spend more time trying to free up space in SPL.
For now,, for the series...
adam
Quoted 58 lines
Quoted 58 lines
arch/arm/dts/da850-lcdk-u-boot.dtsi +4
-0@@ -28,3 +28,7 @@ &serial2 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl; +};arch/arm/dts/rk3288-u-boot.dtsi +4
-0@@ -43,3 +43,7 @@ &noc { u-boot,dm-pre-reloc; }; + +&gpio7 { + u-boot,dm-pre-reloc; +};arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi +1
-1@@ -3,7 +3,7 @@ * Copyright 2015 Google, Inc */ -#include "rk3288-u-boot.dtsi" +#include "rk3288-veyron-u-boot.dtsi" &dmc { rockchip,pctl-timing = <0x215 0xc8 0x0 0x35 0x26 0x2 0x70 0x2000darch/arm/dts/rk3288-veyron-u-boot.dtsi new file +11
-1@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright 2015 Google, Inc + */ + +#include "rk3288-u-boot.dtsi" + +&gpio7 { + u-boot,dm-pre-reloc; +}; + --2.20.1
PATCH v4 12/14 arm: dts: include gpio nodes for card detect
Hi Adam,
Quoted 40 lines · Adam Ford
Quoted 31 lines · Adam Ford
Quoted 29 lines · Walter Lozano
Several MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios.
This patch, fixes several ocurrence of this issue.
Signed-off-by Walter Lozano <[email protected]>---
arch/arm/dts/da850-evm-u-boot.dtsi | 4 ++++ arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 +++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-)create mode 100644
arch/arm/dts/rk3288-veyron-u-boot.dtsiarch/arm/dts/da850-evm-u-boot.dtsi +2
-0@@ -39,3 +39,7 @@ &spi1 { u-boot,dm-spl; }; + +&gpio {Quoted 8 lines
arch/arm/dts/da850-evm-u-boot.dtsi line 45
Quoted 2 lines
arch/arm/dts/da850-evm-u-boot.dtsi +2
-0+ u-boot,dm-spl; +};I don't know that this is needed for the da850-evm since it doesn't boot from sd/mmc. It can boot from SPI, NAND or NOR Flash depending on the config option selected, but none of them need the gpio during SPL. The gpio is loaded during normal U-Boot. I will try to run some tests to make sure it still boots in the next few days. I know space is getting tight in SPL.
Quoted 5 lines
I applied your patches and built.
FYI, "git am" didn't let them apply nicely, but there could be some missing dependent patches I was missing. I was able to patch with "patch"
The board booted as expected.
Thanks for your feedback and testing.
Quoted 9 lines
I examined the generated dtb for SPL since this board doesn't use
OF_PLATDATA. It looks like we could remove both the GPIO and the MMC modes from SPL, but I'm not going to worry about it unless we can't boot any more. If/when that happens, I'll spend more time trying to free up space in SPL.
For now,, for the series...Tested-by Adam Ford <[email protected]> #da850-evm
I found this possible issue while testing different configurations, but it is more related to omapl138_lcdk_defconfig (da850-lcdk) which seems to use OF_PLATDATA. In the case of da850-evm, if there are issue with space in SPL, maybe we can consider removing both MMC and GPIO node and also enable OF_PLATDATA, hopefully if omapl138_lcdk_defconfig works as expected the effort would be little.
Regards,
Walter
Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
arch/arm/dts/da850-lcdk-u-boot.dtsi +4
-0@@ -28,3 +28,7 @@ &serial2 { u-boot,dm-spl; }; + +&gpio { + u-boot,dm-spl; +};arch/arm/dts/rk3288-u-boot.dtsi +4
-0@@ -43,3 +43,7 @@ &noc { u-boot,dm-pre-reloc; }; + +&gpio7 { + u-boot,dm-pre-reloc; +};arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi +1
-1@@ -3,7 +3,7 @@ * Copyright 2015 Google, Inc */ -#include "rk3288-u-boot.dtsi" +#include "rk3288-veyron-u-boot.dtsi" &dmc { rockchip,pctl-timing = <0x215 0xc8 0x0 0x35 0x26 0x2 0x70 0x2000darch/arm/dts/rk3288-veyron-u-boot.dtsi new file +11
-1@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright 2015 Google, Inc + */ + +#include "rk3288-u-boot.dtsi" + +&gpio7 { + u-boot,dm-pre-reloc; +}; + --2.20.1
PATCH v4 12/14 arm: dts: include gpio nodes for card detect
Hi Adam,
Quoted 14 lines · Adam Ford
Quoted 13 lines · Adam Ford
Quoted 11 lines · Walter Lozano
Several MMC drivers use GPIO for card detection with cd-gpios property in the MMC node pointing to a GPIO node. However, as U-Boot tries to save space by keeping only required nodes using u-boot* properties, several devices tree result in having only in the MMC node but not the GPIO node associated to cd-gpios.
This patch, fixes several ocurrence of this issue.
Signed-off-by Walter Lozano <[email protected]>---
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/dts/da850-evm-u-boot.dtsi | 4 ++++ arch/arm/dts/da850-lcdk-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-u-boot.dtsi | 4 ++++ arch/arm/dts/rk3288-veyron-speedy-u-boot.dtsi | 2 +- arch/arm/dts/rk3288-veyron-u-boot.dtsi | 11 +++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-)create mode 100644
arch/arm/dts/rk3288-veyron-u-boot.dtsi
Applied to u-boot-dm/next, thanks!
PATCH v4 13/14 dtoc: update dtb_platdata to support cd-gpios
In reply to Walter LozanoCurrently dtoc does not support the property cd-gpios used to declare the gpios for card detect in mmc.
This patch adds support to cd-gpios property.
---
tools/dtoc/dtb_platdata.py | 16 ++++++++++------ tools/dtoc/test_dtoc.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-)
tools/dtoc/dtb_platdata.py +10 -6
@@ -258,7 +258,7 @@ class DtbPlatdata(object): Return: Number of argument cells is this is a phandle, else None """ - if prop.name in ['clocks']: + if prop.name in ['clocks', 'cd-gpios']: if not isinstance(prop.value, list): prop.value = [prop.value] val = prop.value
@@ -278,11 +278,14 @@ class DtbPlatdata(object): if not target: raise ValueError("Cannot parse '%s' in node '%s'" % (prop.name, node_name)) - prop_name = '#clock-cells' - cells = target.props.get(prop_name) + cells = None + for prop_name in ['#clock-cells', '#gpio-cells']: + cells = target.props.get(prop_name) + if cells: + break if not cells: - raise ValueError("Node '%s' has no '%s' property" % - (target.name, prop_name)) + raise ValueError("Node '%s' has no cells property" % + (target.name)) num_args = fdt_util.fdt32_to_cpu(cells.value) max_args = max(max_args, num_args) args.append(num_args)
@@ -652,7 +655,8 @@ class DtbPlatdata(object): # dtv_dmc_at_xxx.clocks[0].node = DM_GET_DEVICE(clock_controller_at_xxx) self.buf('void dm_populate_phandle_data(void) {\n') for l in self._links: - self.buf('\t%s = DM_GET_DEVICE(%s);\n' % (l['var_node'], l['dev_name'])) + self.buf('\t%s = DM_GET_DEVICE(%s);\n' % + (l['var_node'], l['dev_name'])) self.buf('}\n') self.out(''.join(self.get_buf()))
tools/dtoc/test_dtoc.py +1 -1
@@ -485,7 +485,7 @@ void dm_populate_phandle_data(void) { output = tools.GetOutputFilename('output') with self.assertRaises(ValueError) as e: self.run_test(['struct'], dtb_file, output) - self.assertIn("Node 'phandle-target' has no '#clock-cells' property", + self.assertIn("Node 'phandle-target' has no cells property", str(e.exception)) def test_aliases(self):
Signature · 1 line
2.20.1
PATCH v4 13/14 dtoc: update dtb_platdata to support cd-gpios
Quoted 4 lines · Walter Lozano
Currently dtoc does not support the property cd-gpios used to declare the gpios for card detect in mmc.
Quoted 9 lines
This patch adds support to cd-gpios property.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 16 ++++++++++------ tools/dtoc/test_dtoc.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-)
PATCH v4 13/14 dtoc: update dtb_platdata to support cd-gpios
Quoted 4 lines · Walter Lozano
Currently dtoc does not support the property cd-gpios used to declare the gpios for card detect in mmc.
Quoted 9 lines
This patch adds support to cd-gpios property.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtb_platdata.py | 16 ++++++++++------ tools/dtoc/test_dtoc.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v4 14/14 dtoc: add test for cd-gpios
In reply to Walter LozanoAdd a test for dtoc taking into account the cd-gpios property.
---
tools/dtoc/dtoc_test_phandle_cd_gpios.dts | 42 ++++++++++++++ tools/dtoc/test_dtoc.py | 67 +++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 tools/dtoc/dtoc_test_phandle_cd_gpios.dts
tools/dtoc/dtoc_test_phandle_cd_gpios.dts new file +42 -0
@@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test device tree file for dtoc + * + * Copyright 2020 Collabora Ltd. + */ + +/dts-v1/; + +/ { + phandle: phandle-target { + u-boot,dm-pre-reloc; + compatible = "target"; + intval = <0>; + #gpio-cells = <0>; + }; + + phandle_1: phandle2-target { + u-boot,dm-pre-reloc; + compatible = "target"; + intval = <1>; + #gpio-cells = <1>; + }; + phandle_2: phandle3-target { + u-boot,dm-pre-reloc; + compatible = "target"; + intval = <2>; + #gpio-cells = <2>; + }; + + phandle-source { + u-boot,dm-pre-reloc; + compatible = "source"; + cd-gpios = <&phandle &phandle_1 11 &phandle_2 12 13 &phandle>; + }; + + phandle-source2 { + u-boot,dm-pre-reloc; + compatible = "source"; + cd-gpios = <&phandle>; + }; +};
tools/dtoc/test_dtoc.py +67 -0
73 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 14/14 dtoc: add test for cd-gpios
Quoted 10 lines · Walter Lozano
Add a test for dtoc taking into account the cd-gpios property.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtoc_test_phandle_cd_gpios.dts | 42 ++++++++++++++ tools/dtoc/test_dtoc.py | 67 +++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 tools/dtoc/dtoc_test_phandle_cd_gpios.dts
PATCH v4 14/14 dtoc: add test for cd-gpios
Quoted 10 lines · Walter Lozano
Add a test for dtoc taking into account the cd-gpios property.
Signed-off-by Walter Lozano <[email protected]>---
tools/dtoc/dtoc_test_phandle_cd_gpios.dts | 42 ++++++++++++++ tools/dtoc/test_dtoc.py | 67 +++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 tools/dtoc/dtoc_test_phandle_cd_gpios.dts
Applied to u-boot-dm, thanks!