dm: Add dtoc implementation of device instantiation (part D)
Subsystems (44)
cover dm: Add dtoc implementation of device instantiation (part D)
By way of background, in May[1] and July[2] two 'tiny-dm' series were sent out, showing a possible way to reduce the overhead of driver model in SPL. The potential impact of that work was described in the cover letter[3].
While this was a successful demonstration, all but eliminating the overhead of driver model, it was not very practical, since it would have required substantial effort to adapt drivers used in SPL to what was effectively a parallel driver model.
Instead, after much discussion [4], it was decided to try to use the tiny-dm methods to adapt the existing of-platdata infrastructure. This is considerably more work up front but should result in much less effort for maintainers, along with a single, more consistent driver model.
Of the options mentioned in [3], the following are implemented (in dtoc only, not driver model) as part of this series (CS=reduces code size, DS=reduces data size):
CS - drop driver_bind() and create devices (struct udevice) at
build-time
CS - allocate all device- and uclass-private data at build-time
In addition the following was largely completed in an earlier series:
CS / DS - Combine req_seq and seq and calculate the new value at
build-time
So this series updates dtoc to support generating devices and uclasses that are ready for use when SPL starts and don't need to be bound.
This 'build-time' instantiation helps to reduce the code-size overhead of driver model in SPL.
As part of this series, a new -i option is added to dtoc. This changes it to emit build-time-instantiated devices. Separate Kconfig options control instantiation and whether run-time binding is supported.
Several corner cases have come up in making this work on sandbox_spl and chromebook_coral. It is possible that others will come up in the future, but it should be possible to adapt things to address these, based on the work here.
A small tree-wide rename is included to make the naming more consistent. Without that, the new terminology would be hard to follow.
This is part D of the overall effort. The next series will focus on the the driver model implementation, as well as updating the documentation.
To find out what the new generated files look like, see the last four patches of this series.
It is available at u-boot-dm/prepd-working
The final result (WIP, not reviewable) is available at u-boot-dm/tin-working but note this only works for sandbox_spl and chromebook_coral
[1] http://patchwork.ozlabs.org/project/uboot/list/?series=179128&state=*
[2] http://patchwork.ozlabs.org/project/uboot/list/?series=187295&state=*
[3] https://lists.denx.de/pipermail/u-boot/2020-July/418433.html
[4] http://patchwork.ozlabs.org/project/uboot/patch/20200525093539.1.Ibf2d19439cde35e39192a9d4a8dad23539fae2e6 at changeid/
Simon Glass (49):
dtoc: Tidy up pylint warnings in test
dtoc: Use None to mean stdout
dtoc: Test the stdout output
dtoc: Allow providing a directory to write files to
dtoc: Allow outputing to multiple files
dtoc: Add an 'all' command
Makefile: Invoke dtoc only once
dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO()
dm: Rename DM_GET_DEVICE() to DM_DRVINFO_GET()
dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET()
dm: Rename U_BOOT_DRIVER_ALIAS to DM_DRIVER_ALIAS
concurrencytest: Fix Python3 warning
dtoc: Run tests using test_util
dtoc: Add a header comment to each generated file
dtoc: Rename dt-platdata.c to dt-plat.c
dtoc: Add the method for each command to OutputFile
dtoc: Allow specifying the base directory for tests
dtoc: Output nodes in order
dtoc: Drop dm_populate_phandle_data()
dtoc: Split source-code scanning to a separate file
dtoc: Move src_scan tests to a separate file
dtoc: Tidy up src_scan tests
dtoc: Scan drivers for available information
dtoc: Save scan information across test runs
dtoc: Ignore unwanted files when scanning for drivers
dtoc: Collect priv/plat struct info from drivers
dtoc: Support scanning of uclasses
dtoc: Support scanning of structs in header files
dtoc: Move test files into a test/ directory
dtoc: Rename sandbox_i2c_test and sandbox_pmic_test
dtoc: Add some extra properties to nodes
dtoc: Make use of node properties
dtoc: Process nodes to set up required properties
dtoc: Track nodes which are actually used
dtoc: Support tracking the phase of U-Boot
Makefile: Pass the U-Boot phase to dtoc
dtoc: Support headers needed for drivers
dtoc: Process driver aliases along with drivers
dtoc: Warn of duplicate drivers
dtoc: Read aliases for uclasses
dtoc: Assign a sequence number to each node
dtoc: Set up the uclasses that are used
dtoc: Support processing the root node
dtoc: Add an option for device instantiation
dm: of-platadata: Add option for device instantiation
dtoc: Add support for decl file
dtoc: Don't generate platform data with instantiation
dtoc: Generate uclass devices
dtoc: Generate device instances
arch/arm/lib/gic-v3-its.c | 10 +-
arch/arm/mach-aspeed/ast2500/clk_ast2500.c | 2 +-
.../mach-at91/arm926ejs/at91sam9260_devices.c | 2 +-
.../arm926ejs/at91sam9m10g45_devices.c | 2 +-
arch/arm/mach-imx/mx6/soc.c | 2 +-
arch/arm/mach-imx/mx7/soc.c | 2 +-
arch/arm/mach-k3/am6_init.c | 2 +-
arch/arm/mach-k3/common.c | 2 +-
arch/arm/mach-k3/j721e_init.c | 2 +-
arch/arm/mach-lpc32xx/devices.c | 4 +-
arch/arm/mach-mediatek/mt7629/init.c | 4 +-
arch/arm/mach-mediatek/mt8516/init.c | 2 +-
arch/arm/mach-omap2/am33xx/board.c | 10 +-
arch/arm/mach-omap2/omap3/board.c | 2 +-
arch/arm/mach-rockchip/misc.c | 4 +-
arch/arm/mach-rockchip/px30/clk_px30.c | 2 +-
arch/arm/mach-rockchip/rk3036/clk_rk3036.c | 2 +-
arch/arm/mach-rockchip/rk3128/clk_rk3128.c | 2 +-
arch/arm/mach-rockchip/rk3188/clk_rk3188.c | 2 +-
arch/arm/mach-rockchip/rk322x/clk_rk322x.c | 2 +-
arch/arm/mach-rockchip/rk3288/clk_rk3288.c | 2 +-
arch/arm/mach-rockchip/rk3308/clk_rk3308.c | 2 +-
arch/arm/mach-rockchip/rk3328/clk_rk3328.c | 2 +-
arch/arm/mach-rockchip/rk3368/clk_rk3368.c | 2 +-
arch/arm/mach-rockchip/rk3399/clk_rk3399.c | 4 +-
arch/arm/mach-rockchip/rv1108/clk_rv1108.c | 2 +-
arch/arm/mach-socfpga/clock_manager_agilex.c | 2 +-
arch/arm/mach-stm32mp/bsec.c | 2 +-
arch/arm/mach-stm32mp/cmd_stm32key.c | 2 +-
.../mach-stm32mp/cmd_stm32prog/stm32prog.c | 6 +-
arch/arm/mach-stm32mp/cpu.c | 6 +-
arch/arm/mach-tegra/board.c | 2 +-
arch/arm/mach-tegra/board2.c | 2 +-
arch/arm/mach-uniphier/micro-support-card.c | 2 +-
arch/arm/mach-zynq/clk.c | 4 +-
arch/arm/mach-zynq/timer.c | 2 +-
arch/mips/mach-mtmips/mt7628/init.c | 2 +-
arch/riscv/lib/sifive_clint.c | 2 +-
board/armltd/integrator/integrator.c | 2 +-
board/armltd/total_compute/total_compute.c | 2 +-
board/armltd/vexpress64/vexpress64.c | 2 +-
board/bluewater/gurnard/gurnard.c | 2 +-
board/bluewater/snapper9260/snapper9260.c | 2 +-
board/cadence/xtfpga/xtfpga.c | 4 +-
board/cavium/thunderx/thunderx.c | 4 +-
board/compulab/cm_fx6/cm_fx6.c | 2 +-
board/davinci/da8xxevm/omapl138_lcdk.c | 4 +-
board/dhelectronics/dh_stm32mp1/board.c | 6 +-
board/freescale/ls1012afrdm/eth.c | 4 +-
board/freescale/ls1012aqds/eth.c | 4 +-
board/freescale/ls1012ardb/eth.c | 4 +-
board/freescale/lx2160a/lx2160a.c | 4 +-
board/gateworks/gw_ventana/gw_ventana.c | 2 +-
board/google/gru/gru.c | 2 +-
board/hisilicon/hikey/hikey.c | 4 +-
board/hisilicon/hikey960/hikey960.c | 2 +-
board/hisilicon/poplar/poplar.c | 2 +-
board/isee/igep00x0/igep00x0.c | 2 +-
board/lg/sniper/sniper.c | 2 +-
board/nokia/rx51/rx51.c | 2 +-
board/nvidia/jetson-tk1/jetson-tk1.c | 2 +-
board/nvidia/nyan-big/nyan-big.c | 2 +-
board/renesas/ulcb/cpld.c | 2 +-
board/sandbox/sandbox.c | 2 +-
board/siemens/corvus/board.c | 2 +-
board/sifive/fu540/fu540.c | 2 +-
board/st/common/cmd_stboard.c | 2 +-
board/st/common/stm32mp_dfu.c | 4 +-
board/st/common/stpmic1.c | 4 +-
board/st/common/stusb160x.c | 2 +-
board/st/stm32mp1/stm32mp1.c | 12 +-
board/st/stv0991/stv0991.c | 2 +-
board/sysam/amcore/amcore.c | 2 +-
board/ti/am335x/board.c | 6 +-
board/ti/j721e/evm.c | 4 +-
board/timll/devkit8000/devkit8000.c | 2 +-
board/toradex/apalis-tk1/apalis-tk1.c | 4 +-
board/toradex/apalis_imx6/apalis_imx6.c | 2 +-
.../toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +-
board/toradex/colibri_imx6/colibri_imx6.c | 2 +-
board/toradex/colibri_pxa270/colibri_pxa270.c | 4 +-
doc/driver-model/design.rst | 18 +-
doc/driver-model/of-plat.rst | 35 +-
doc/driver-model/remoteproc-framework.rst | 2 +-
doc/driver-model/spi-howto.rst | 4 +-
drivers/clk/clk_stm32mp1.c | 2 +-
drivers/clk/clk_zynqmp.c | 2 +-
drivers/clk/imx/clk-imx8.c | 2 +-
drivers/clk/mediatek/clk-mtk.c | 6 +-
drivers/clk/sifive/fu540-prci.c | 2 +-
drivers/core/root.c | 3 -
drivers/crypto/fsl/fsl_rsa.c | 2 +-
drivers/crypto/rsa_mod_exp/mod_exp_sw.c | 2 +-
drivers/demo/demo-pdata.c | 10 +-
drivers/firmware/scmi/scmi_agent-uclass.c | 4 +-
drivers/gpio/gpio-uclass.c | 2 +-
drivers/gpio/imx_rgpio2p.c | 4 +-
drivers/gpio/mxc_gpio.c | 4 +-
drivers/gpio/mxs_gpio.c | 2 +-
drivers/gpio/sandbox.c | 2 +-
drivers/i2c/rk_i2c.c | 2 +-
drivers/misc/i2c_eeprom.c | 2 +-
drivers/misc/rockchip-efuse.c | 2 +-
drivers/misc/stm32mp_fuse.c | 16 +-
drivers/misc/test_drv.c | 11 +-
drivers/mmc/fsl_esdhc_imx.c | 2 +-
drivers/mmc/mxsmmc.c | 2 +-
drivers/mmc/rockchip_dw_mmc.c | 4 +-
drivers/mtd/nand/raw/arasan_nfc.c | 2 +-
drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c | 2 +-
drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c | 2 +-
drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c | 2 +-
drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c | 2 +-
drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c | 2 +-
drivers/mtd/nand/raw/davinci_nand.c | 2 +-
drivers/mtd/nand/raw/denali_dt.c | 2 +-
drivers/mtd/nand/raw/mxs_nand_dt.c | 2 +-
drivers/mtd/nand/raw/octeontx_nand.c | 6 +-
drivers/mtd/nand/raw/pxa3xx_nand.c | 2 +-
drivers/mtd/nand/raw/stm32_fmc2_nand.c | 2 +-
drivers/mtd/nand/raw/tegra_nand.c | 2 +-
drivers/mtd/nand/raw/vf610_nfc.c | 2 +-
drivers/mtd/nand/raw/zynq_nand.c | 2 +-
drivers/mtd/spi/sf_probe.c | 2 +-
drivers/pinctrl/nxp/pinctrl-imx6.c | 2 +-
drivers/pinctrl/nxp/pinctrl-mxs.c | 2 +-
drivers/pinctrl/pinctrl-at91.c | 2 +-
drivers/power/pmic/rk8xx.c | 2 +-
drivers/remoteproc/sandbox_testproc.c | 2 +-
drivers/reset/reset-ast2500.c | 2 +-
drivers/rtc/emul_rtc.c | 2 +-
drivers/serial/ns16550.c | 6 +-
drivers/serial/sandbox.c | 2 +-
drivers/spi/mxs_spi.c | 2 +-
drivers/spi/rk_spi.c | 2 +-
drivers/sysreset/sysreset_sandbox.c | 4 +-
drivers/timer/sandbox_timer.c | 2 +-
drivers/video/lg4573.c | 2 +-
drivers/video/sunxi/sunxi_de2.c | 2 +-
drivers/video/sunxi/sunxi_dw_hdmi.c | 2 +-
drivers/video/sunxi/sunxi_lcd.c | 2 +-
dts/Kconfig | 31 +-
include/dm/device.h | 42 +-
include/dm/lists.h | 2 +-
include/dm/platdata.h | 28 +-
include/dm/platform_data/spi_pl022.h | 2 +-
include/dm/test.h | 5 +
include/dm/uclass.h | 2 +-
include/linux/mtd/spi-nor.h | 2 +-
scripts/Makefile.spl | 27 +-
test/dm/core.c | 8 +-
test/dm/test-fdt.c | 6 +-
tools/concurrencytest/concurrencytest.py | 4 +-
tools/dtoc/dtb_platdata.py | 911 +++++++++----
tools/dtoc/dtoc_test_scan_drivers.cxx | 1 -
tools/dtoc/main.py | 56 +-
tools/dtoc/src_scan.py | 736 ++++++++++
tools/dtoc/{ => test}/dtoc_test.dts | 0
tools/dtoc/{ => test}/dtoc_test_add_prop.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr32.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr32_64.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr64.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr64_32.dts | 0
tools/dtoc/test/dtoc_test_alias_bad.dts | 58 +
tools/dtoc/test/dtoc_test_alias_bad_path.dts | 58 +
tools/dtoc/test/dtoc_test_alias_bad_uc.dts | 58 +
tools/dtoc/{ => test}/dtoc_test_aliases.dts | 0
tools/dtoc/{ => test}/dtoc_test_bad_reg.dts | 0
tools/dtoc/{ => test}/dtoc_test_bad_reg2.dts | 0
.../{ => test}/dtoc_test_driver_alias.dts | 0
tools/dtoc/{ => test}/dtoc_test_empty.dts | 0
tools/dtoc/test/dtoc_test_inst.dts | 58 +
.../{ => test}/dtoc_test_invalid_driver.dts | 0
tools/dtoc/{ => test}/dtoc_test_phandle.dts | 0
.../dtoc/{ => test}/dtoc_test_phandle_bad.dts | 0
.../{ => test}/dtoc_test_phandle_bad2.dts | 0
.../{ => test}/dtoc_test_phandle_cd_gpios.dts | 0
.../{ => test}/dtoc_test_phandle_reorder.dts | 0
.../{ => test}/dtoc_test_phandle_single.dts | 0
tools/dtoc/test/dtoc_test_scan_drivers.cxx | 5 +
tools/dtoc/{ => test}/dtoc_test_simple.dts | 4 +-
tools/dtoc/test_dtoc.py | 1190 ++++++++++++++---
tools/dtoc/test_fdt.py | 31 +-
tools/dtoc/test_src_scan.py | 492 +++++++
tools/patman/tools.py | 8 +
185 files changed, 3482 insertions(+), 808 deletions(-)
delete mode 100644 tools/dtoc/dtoc_test_scan_drivers.cxx
create mode 100644 tools/dtoc/src_scan.py
rename tools/dtoc/{ => test}/dtoc_test.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_add_prop.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr32.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr32_64.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr64.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr64_32.dts (100%)
create mode 100644 tools/dtoc/test/dtoc_test_alias_bad.dts
create mode 100644 tools/dtoc/test/dtoc_test_alias_bad_path.dts
create mode 100644 tools/dtoc/test/dtoc_test_alias_bad_uc.dts
rename tools/dtoc/{ => test}/dtoc_test_aliases.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_bad_reg.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_bad_reg2.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_driver_alias.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_empty.dts (100%)
create mode 100644 tools/dtoc/test/dtoc_test_inst.dts
rename tools/dtoc/{ => test}/dtoc_test_invalid_driver.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_bad.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_bad2.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_cd_gpios.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_reorder.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_single.dts (100%)
create mode 100644 tools/dtoc/test/dtoc_test_scan_drivers.cxx
rename tools/dtoc/{ => test}/dtoc_test_simple.dts (93%)
create mode 100644 tools/dtoc/test_src_scan.pySignature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 1/49 dtoc: Tidy up pylint warnings in test
Tidy up this file to reduce the number of pylint warnings.
---
tools/dtoc/test_dtoc.py | 156 ++++++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 71 deletions(-)
tools/dtoc/test_dtoc.py +85 -71
@@ -12,21 +12,20 @@ tool. import collections import os import struct -import sys import tempfile import unittest -from dtoc import dtb_platdata from dtb_platdata import conv_name_to_c from dtb_platdata import get_compat_name from dtb_platdata import get_value from dtb_platdata import tab_to +from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util from patman import test_util from patman import tools -our_path = os.path.dirname(os.path.realpath(__file__)) +OUR_PATH = os.path.dirname(os.path.realpath(__file__)) HEADER = '''/*
@@ -56,18 +55,21 @@ C_EMPTY_POPULATE_PHANDLE_DATA = '''void dm_populate_phandle_data(void) { } ''' +# This is a test so is allowed to access private things in the module it is +# testing +# pylint: disable=W0212 def get_dtb_file(dts_fname, capture_stderr=False): """Compile a .dts file to a .dtb Args: - dts_fname: Filename of .dts file in the current directory - capture_stderr: True to capture and discard stderr output + dts_fname (str): Filename of .dts file in the current directory + capture_stderr (bool): True to capture and discard stderr output Returns: - Filename of compiled file in output directory + str: Filename of compiled file in output directory """ - return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname), + return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, dts_fname), capture_stderr=capture_stderr)
@@ -80,20 +82,21 @@ class TestDtoc(unittest.TestCase): @classmethod def tearDownClass(cls): - tools._RemoveOutputDir() + tools.FinaliseOutputDir() - def _WritePythonString(self, fname, data): + @staticmethod + def _write_python_string(fname, data): """Write a string with tabs expanded as done in this Python file Args: - fname: Filename to write to - data: Raw string to convert + fname (str): Filename to write to + data (str): Raw string to convert """ data = data.replace('\t', '\\t') - with open(fname, 'w') as fd: - fd.write(data) + with open(fname, 'w') as fout: + fout.write(data) - def _CheckStrings(self, expected, actual): + def _check_strings(self, expected, actual): """Check that a string matches its expected value If the strings do not match, they are written to the /tmp directory in
@@ -101,17 +104,24 @@ class TestDtoc(unittest.TestCase): easy comparison and update of the tests. Args: - expected: Expected string - actual: Actual string + expected (str): Expected string + actual (str): Actual string """ if expected != actual: - self._WritePythonString('/tmp/binman.expected', expected) - self._WritePythonString('/tmp/binman.actual', actual) + self._write_python_string('/tmp/binman.expected', expected) + self._write_python_string('/tmp/binman.actual', actual) print('Failures written to /tmp/binman.{expected,actual}') - self.assertEquals(expected, actual) + self.assertEqual(expected, actual) + @staticmethod + def run_test(args, dtb_file, output): + """Run a test using dtoc - def run_test(self, args, dtb_file, output): + Args: + args (list of str): List of arguments for dtoc + dtb_file (str): Filename of .dtb file + output (str): Filename of output file + """ dtb_platdata.run_steps(args, dtb_file, False, output, True) def test_name(self):
@@ -160,7 +170,7 @@ class TestDtoc(unittest.TestCase): prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1', 'third']) node = Node({'compatible': prop}) self.assertEqual((['rockchip_rk3399_sdhci_5_1', - 'arasan_sdhci_5_1', 'third']), + 'arasan_sdhci_5_1', 'third']), get_compat_name(node)) def test_empty_file(self):
@@ -185,7 +195,7 @@ class TestDtoc(unittest.TestCase): self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_i2c_test { }; struct dtd_sandbox_pmic_test {
@@ -209,7 +219,7 @@ struct dtd_sandbox_spl_test { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /i2c at 0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { };
@@ -293,7 +303,7 @@ U_BOOT_DEVICE(spl_test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_gpio { \tconst char *\tgpio_bank_name; \tbool\t\tgpio_controller;
@@ -304,7 +314,7 @@ struct dtd_sandbox_gpio { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /gpios at 0 index 0 */ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { \t.gpio_bank_name\t\t= "a",
@@ -326,20 +336,20 @@ void dm_populate_phandle_data(void) { """Test output from a device tree file with an invalid driver""" dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_invalid { }; ''', data) - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /spl-test index 0 */ static struct dtd_invalid dtv_spl_test = { };
@@ -361,7 +371,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_source { \tstruct phandle_2_arg clocks[4]; };
@@ -373,7 +383,7 @@ struct dtd_target { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle2-target index 0 */ static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1,
@@ -445,7 +455,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_source { \tstruct phandle_0_arg clocks[1]; };
@@ -461,7 +471,7 @@ struct dtd_target { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle-target index 1 */ static struct dtd_target dtv_phandle_target = { };
@@ -495,7 +505,7 @@ void dm_populate_phandle_data(void) { dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle2-target index 0 */ static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1,
@@ -565,20 +575,20 @@ void dm_populate_phandle_data(void) { dtb_file = get_dtb_file('dtoc_test_phandle_bad.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Cannot parse 'clocks' in node 'phandle-source'", - str(e.exception)) + str(exc.exception)) def test_phandle_bad2(self): """Test a phandle target missing its #*-cells property""" dtb_file = get_dtb_file('dtoc_test_phandle_bad2.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Node 'phandle-target' has no cells property", - str(e.exception)) + str(exc.exception)) def test_addresses64(self): """Test output from a node with a 'reg' property with na=2, ns=2"""
@@ -587,7 +597,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; };
@@ -602,7 +612,7 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678},
@@ -645,7 +655,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt32_t\t\treg[2]; };
@@ -657,7 +667,7 @@ struct dtd_test2 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678},
@@ -689,7 +699,7 @@ U_BOOT_DEVICE(test2) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; };
@@ -704,7 +714,7 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x123400000000, 0x5678},
@@ -747,7 +757,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; };
@@ -762,7 +772,7 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000},
@@ -803,20 +813,21 @@ U_BOOT_DEVICE(test3) = { # Capture stderr since dtc will emit warnings for this file dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Node 'spl-test' reg property is not an int", - str(e.exception)) + str(exc.exception)) def test_bad_reg2(self): """Test that a reg property with an invalid cell count is detected""" # Capture stderr since dtc will emit warnings for this file dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) - self.assertIn("Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", - str(e.exception)) + self.assertIn( + "Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", + str(exc.exception)) def test_add_prop(self): """Test that a subequent node can add a new property to a struct"""
@@ -825,7 +836,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_spl_test { \tfdt32_t\t\tintarray; \tfdt32_t\t\tintval;
@@ -835,7 +846,7 @@ struct dtd_sandbox_spl_test { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /spl-test index 0 */ static struct dtd_sandbox_spl_test dtv_spl_test = { \t.intval\t\t\t= 0x1,
@@ -860,37 +871,40 @@ U_BOOT_DEVICE(spl_test2) = { ''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) - def testStdout(self): + def test_stdout(self): """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: self.run_test(['struct'], dtb_file, '-') - def testNoCommand(self): + def test_no_command(self): """Test running dtoc without a command""" - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test([], '', '') self.assertIn("Please specify a command: struct, platdata", - str(e.exception)) + str(exc.exception)) - def testBadCommand(self): + def test_bad_command(self): """Test running dtoc with an invalid command""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['invalid-cmd'], dtb_file, output) self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)", - str(e.exception)) + str(exc.exception)) - def testScanDrivers(self): + @staticmethod + def test_scan_drivers(): """Test running dtoc with additional drivers to scan""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as (stdout, stderr): - dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) + with test_util.capture_sys_output() as _: + dtb_platdata.run_steps( + ['struct'], dtb_file, False, output, True, + [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) - def testUnicodeError(self): + @staticmethod + def test_unicode_error(): """Test running dtoc with an invalid unicode file To be able to perform this test without adding a weird text file which
@@ -900,14 +914,14 @@ U_BOOT_DEVICE(spl_test2) = { dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') driver_fn = '/tmp/' + next(tempfile._get_candidate_names()) - with open(driver_fn, 'wb+') as df: - df.write(b'\x81') + with open(driver_fn, 'wb+') as fout: + fout.write(b'\x81') - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [driver_fn]) + [driver_fn]) - def testDriver(self): + def test_driver(self): """Test the Driver class""" drv1 = dtb_platdata.Driver('fred') drv2 = dtb_platdata.Driver('mary')
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 2/49 dtoc: Use None to mean stdout
In reply to Simon GlassAt present dtoc uses '-' internally to mean that output should go to stdout. This is not necessary and None is more convenient. Update it.
---
tools/dtoc/dtb_platdata.py | 10 +++++----- tools/dtoc/main.py | 2 +- tools/dtoc/test_dtoc.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
tools/dtoc/dtb_platdata.py +5 -5
@@ -237,12 +237,12 @@ class DtbPlatdata(): file. Args: - fname (str): Filename to send output to, or '-' for stdout + fname (str): Filename to send output to, or None for stdout """ - if fname == '-': - self._outfile = sys.stdout - else: + if fname: self._outfile = open(fname, 'w') + else: + self._outfile = sys.stdout def out(self, line): """Output a string to the output file
@@ -765,7 +765,7 @@ def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False, args (list): List of non-option arguments provided to the problem dtb_file (str): Filename of dtb file to process include_disabled (bool): True to include disabled nodes - output (str): Name of output file + output (str): Name of output file (None for stdout) warning_disabled (bool): True to avoid showing warnings about missing drivers drivers_additional (list): List of additional drivers to use during
tools/dtoc/main.py +1 -1
@@ -91,7 +91,7 @@ parser.add_option('-d', '--dtb-file', action='store', help='Specify the .dtb input file') parser.add_option('--include-disabled', action='store_true', help='Include disabled nodes') -parser.add_option('-o', '--output', action='store', default='-', +parser.add_option('-o', '--output', action='store', help='Select output filename') parser.add_option('-P', '--processes', type=int, help='set number of processes to use for running tests')
tools/dtoc/test_dtoc.py +1 -1
@@ -875,7 +875,7 @@ U_BOOT_DEVICE(spl_test2) = { """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') with test_util.capture_sys_output() as _: - self.run_test(['struct'], dtb_file, '-') + self.run_test(['struct'], dtb_file, None) def test_no_command(self): """Test running dtoc without a command"""
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 3/49 dtoc: Test the stdout output
In reply to Simon GlassNormally dtoc outputs to a file but it also offers a way to write output to stdout. At present the test for that does not actually check that the output is correct. Add this to the test.
This uses a member variable to hold the expected text, so it can be used in muitiple places.
---
tools/dtoc/test_dtoc.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
tools/dtoc/test_dtoc.py +22 -15
@@ -188,14 +188,7 @@ class TestDtoc(unittest.TestCase): self.assertEqual(C_HEADER.splitlines() + [''] + C_EMPTY_POPULATE_PHANDLE_DATA.splitlines(), lines) - def test_simple(self): - """Test output from some simple nodes with various types of data""" - dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - self.run_test(['struct'], dtb_file, output) - with open(output) as infile: - data = infile.read() - self._check_strings(HEADER + ''' + struct_text = HEADER + ''' struct dtd_sandbox_i2c_test { }; struct dtd_sandbox_pmic_test {
@@ -214,12 +207,9 @@ struct dtd_sandbox_spl_test { \tconst char *\tstringarray[3]; \tconst char *\tstringval; }; -''', data) +''' - self.run_test(['platdata'], dtb_file, output) - with open(output) as infile: - data = infile.read() - self._check_strings(C_HEADER + ''' + platdata_text = C_HEADER + ''' /* Node /i2c at 0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { };
@@ -294,7 +284,23 @@ U_BOOT_DEVICE(spl_test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''' + C_EMPTY_POPULATE_PHANDLE_DATA + + def test_simple(self): + """Test output from some simple nodes with various types of data""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + self.run_test(['struct'], dtb_file, output) + with open(output) as infile: + data = infile.read() + + self._check_strings(self.struct_text, data) + + self.run_test(['platdata'], dtb_file, output) + with open(output) as infile: + data = infile.read() + + self._check_strings(self.platdata_text, data) def test_driver_alias(self): """Test output from a device tree file with a driver alias"""
@@ -874,8 +880,9 @@ U_BOOT_DEVICE(spl_test2) = { def test_stdout(self): """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') - with test_util.capture_sys_output() as _: + with test_util.capture_sys_output() as (stdout, _): self.run_test(['struct'], dtb_file, None) + self._check_strings(self.struct_text, stdout.getvalue()) def test_no_command(self): """Test running dtoc without a command"""
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 4/49 dtoc: Allow providing a directory to write files to
In reply to Simon GlassAt present dtoc writes only a single file on each invocation. U-Boot writes the two files it needs by separate invocations of dtoc. Since dtoc now scans all U-Boot driver source, this is fairly slow (about 1 second per file).
It would be better if dtoc could write all the files at once.
In preparation for this, add a way to specify an output directory for the files.
---
tools/dtoc/dtb_platdata.py | 8 ++++++-- tools/dtoc/main.py | 7 ++++++- tools/dtoc/test_dtoc.py | 14 +++++++------- 3 files changed, 19 insertions(+), 10 deletions(-)
tools/dtoc/dtb_platdata.py +6 -2
@@ -757,8 +757,9 @@ class DtbPlatdata(): self.out(''.join(self.get_buf())) -def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False, - drivers_additional=None): + +def run_steps(args, dtb_file, include_disabled, output, output_dirs, + warning_disabled=False, drivers_additional=None): """Run all the steps of the dtoc tool Args:
@@ -766,6 +767,9 @@ def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False, dtb_file (str): Filename of dtb file to process include_disabled (bool): True to include disabled nodes output (str): Name of output file (None for stdout) + output_dirs (tuple of str): + Directory to put C output files + Directory to put H output files warning_disabled (bool): True to avoid showing warnings about missing drivers drivers_additional (list): List of additional drivers to use during
tools/dtoc/main.py +6 -1
@@ -87,6 +87,10 @@ if __name__ != '__main__': parser = OptionParser() parser.add_option('-B', '--build-dir', type='string', default='b', help='Directory containing the build output') +parser.add_option('-c', '--c-output-dir', action='store', + help='Select output directory for C files') +parser.add_option('-C', '--h-output-dir', action='store', + help='Select output directory for H files (defaults to --c-output-di)') parser.add_option('-d', '--dtb-file', action='store', help='Specify the .dtb input file') parser.add_option('--include-disabled', action='store_true',
@@ -111,4 +115,5 @@ elif options.test_coverage: else: dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled, - options.output) + options.output, + [options.c_output_dir, options.h_output_dir])
tools/dtoc/test_dtoc.py +7 -7
@@ -122,7 +122,7 @@ class TestDtoc(unittest.TestCase): dtb_file (str): Filename of .dtb file output (str): Filename of output file """ - dtb_platdata.run_steps(args, dtb_file, False, output, True) + dtb_platdata.run_steps(args, dtb_file, False, output, [], True) def test_name(self): """Test conversion of device tree names to C identifiers"""
@@ -343,7 +343,7 @@ void dm_populate_phandle_data(void) { dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output) + dtb_platdata.run_steps(['struct'], dtb_file, False, output, []) with open(output) as infile: data = infile.read() self._check_strings(HEADER + '''
@@ -352,7 +352,7 @@ struct dtd_invalid { ''', data) with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['platdata'], dtb_file, False, output) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, []) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -508,7 +508,7 @@ void dm_populate_phandle_data(void) { """Test that phandle targets are generated when unsing cd-gpios""" dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts') output = tools.GetOutputFilename('output') - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -907,7 +907,7 @@ U_BOOT_DEVICE(spl_test2) = { output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: dtb_platdata.run_steps( - ['struct'], dtb_file, False, output, True, + ['struct'], dtb_file, False, output, [], True, [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) @staticmethod
@@ -925,8 +925,8 @@ U_BOOT_DEVICE(spl_test2) = { fout.write(b'\x81') with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [driver_fn]) + dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], + True, [driver_fn]) def test_driver(self): """Test the Driver class"""
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 5/49 dtoc: Allow outputing to multiple files
In reply to Simon GlassImplement the 'output directory' feature, allowing dtoc to write the output files separately to the supplied directories. This allows us to handle the struct and platdata output in one run of dtoc.
---
tools/dtoc/dtb_platdata.py | 96 ++++++++++++++++++++++++++++++++++---- tools/dtoc/test_dtoc.py | 8 ++++ 2 files changed, 94 insertions(+), 10 deletions(-)
tools/dtoc/dtb_platdata.py +86 -10
@@ -15,6 +15,7 @@ See doc/driver-model/of-plat.rst for more informaiton import collections import copy +from enum import IntEnum import os import re import sys
@@ -49,6 +50,15 @@ TYPE_NAMES = { STRUCT_PREFIX = 'dtd_' VAL_PREFIX = 'dtv_' +class Ftype(IntEnum): + SOURCE, HEADER = range(2) + + +# This holds information about each type of output file dtoc can create +# type: Type of file (Ftype) +# fname: Filename excluding directory, e.g. 'dt-platdata.c' +OutputFile = collections.namedtuple('OutputFile', ['ftype', 'fname']) + # This holds information about a property which includes phandles. # # max_args: integer: Maximum number or arguments that any phandle uses (int).
@@ -180,6 +190,8 @@ class DtbPlatdata(): U_BOOT_DRIVER_ALIAS(driver_alias, driver_name) value: Driver name declared with U_BOOT_DRIVER(driver_name) _drivers_additional: List of additional drivers to use during scanning + _dirname: Directory to hold output files, or None for none (all files + go to stdout) """ def __init__(self, dtb_fname, include_disabled, warning_disabled, drivers_additional=None):
@@ -193,6 +205,7 @@ class DtbPlatdata(): self._drivers = {} self._driver_aliases = {} self._drivers_additional = drivers_additional or [] + self._dirnames = [None] * len(Ftype) def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -230,20 +243,68 @@ class DtbPlatdata(): return compat_list_c[0], compat_list_c[1:] - def setup_output(self, fname): + def setup_output_dirs(self, output_dirs): + """Set up the output directories + + This should be done before setup_output() is called + + Args: + output_dirs (tuple of str): + Directory to use for C output files. + Use None to write files relative current directory + Directory to use for H output files. + Defaults to the C output dir + """ + def process_dir(ftype, dirname): + if dirname: + os.makedirs(dirname, exist_ok=True) + self._dirnames[ftype] = dirname + + if output_dirs: + c_dirname = output_dirs[0] + h_dirname = output_dirs[1] if len(output_dirs) > 1 else c_dirname + process_dir(Ftype.SOURCE, c_dirname) + process_dir(Ftype.HEADER, h_dirname) + + def setup_output(self, ftype, fname): """Set up the output destination Once this is done, future calls to self.out() will output to this - file. + file. The file used is as follows: + + self._dirnames[ftype] is None: output to fname, or stdout if None + self._dirnames[ftype] is not None: output to fname in that directory + + Calling this function multiple times will close the old file and open + the new one. If they are the same file, nothing happens and output will + continue to the same file. Args: - fname (str): Filename to send output to, or None for stdout + ftype (str): Type of file to create ('c' or 'h') + fname (str): Filename to send output to. If there is a directory in + self._dirnames for this file type, it will be put in that + directory """ - if fname: - self._outfile = open(fname, 'w') + dirname = self._dirnames[ftype] + if dirname: + pathname = os.path.join(dirname, fname) + if self._outfile: + self._outfile.close() + self._outfile = open(pathname, 'w') + elif fname: + if not self._outfile: + self._outfile = open(fname, 'w') else: self._outfile = sys.stdout + def finish_output(self): + """Finish outputing to a file + + This closes the output file, if one is in use + """ + if self._outfile != sys.stdout: + self._outfile.close() + def out(self, line): """Output a string to the output file
@@ -758,6 +819,15 @@ class DtbPlatdata(): self.out(''.join(self.get_buf())) +# Types of output file we understand +# key: Command used to generate this file +# value: OutputFile for this command +OUTPUT_FILES = { + 'struct': OutputFile(Ftype.HEADER, 'dt-structs-gen.h'), + 'platdata': OutputFile(Ftype.SOURCE, 'dt-platdata.c'), + } + + def run_steps(args, dtb_file, include_disabled, output, output_dirs, warning_disabled=False, drivers_additional=None): """Run all the steps of the dtoc tool
@@ -778,7 +848,9 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, ValueError: if args has no command, or an unknown command """ if not args: - raise ValueError('Please specify a command: struct, platdata') + raise ValueError('Please specify a command: struct, platdata, all') + if output and output_dirs and any(output_dirs): + raise ValueError('Must specify either output or output_dirs, not both') plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled, drivers_additional)
@@ -786,15 +858,19 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, plat.scan_dtb() plat.scan_tree() plat.scan_reg_sizes() - plat.setup_output(output) + plat.setup_output_dirs(output_dirs) structs = plat.scan_structs() plat.scan_phandles() for cmd in args[0].split(','): + outfile = OUTPUT_FILES.get(cmd) + if not outfile: + raise ValueError("Unknown command '%s': (use: %s)" % + (cmd, ', '.join(OUTPUT_FILES.keys()))) + plat.setup_output(outfile.ftype, + outfile.fname if output_dirs else output) if cmd == 'struct': plat.generate_structs(structs) elif cmd == 'platdata': plat.generate_tables() - else: - raise ValueError("Unknown command '%s': (use: struct, platdata)" % - cmd) + plat.finish_output()
tools/dtoc/test_dtoc.py +8 -0
@@ -884,6 +884,14 @@ U_BOOT_DEVICE(spl_test2) = { self.run_test(['struct'], dtb_file, None) self._check_strings(self.struct_text, stdout.getvalue()) + def test_multi_to_file(self): + """Test output of multiple pieces to a single file""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + self.run_test(['struct,platdata'], dtb_file, output) + data = tools.ReadFile(output, binary=False) + self._check_strings(self.struct_text + self.platdata_text, data) + def test_no_command(self): """Test running dtoc without a command""" with self.assertRaises(ValueError) as exc:
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 6/49 dtoc: Add an 'all' command
In reply to Simon GlassWith upcoming changes, dtoc will output several files for different of-platdata components.
Add a way to output all ava!ilable files at once ('all'), to the appropriate directories, without needing to specify each one invidually.
This puts the commands in alphabetical order, so update the tests accordingly.
---
tools/dtoc/dtb_platdata.py | 7 +++++-- tools/dtoc/main.py | 6 +----- tools/dtoc/test_dtoc.py | 40 +++++++++++++++++++++++++++++++++++--- tools/patman/tools.py | 8 ++++++++ 4 files changed, 51 insertions(+), 10 deletions(-)
tools/dtoc/dtb_platdata.py +5 -2
@@ -862,11 +862,14 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, structs = plat.scan_structs() plat.scan_phandles() - for cmd in args[0].split(','): + cmds = args[0].split(',') + if 'all' in cmds: + cmds = sorted(OUTPUT_FILES.keys()) + for cmd in cmds: outfile = OUTPUT_FILES.get(cmd) if not outfile: raise ValueError("Unknown command '%s': (use: %s)" % - (cmd, ', '.join(OUTPUT_FILES.keys()))) + (cmd, ', '.join(sorted(OUTPUT_FILES.keys())))) plat.setup_output(outfile.ftype, outfile.fname if output_dirs else output) if cmd == 'struct':
tools/dtoc/main.py +1 -5
@@ -13,11 +13,7 @@ having to link against libfdt. By putting the data from the device tree into C structures, normal C code can be used. This helps to reduce the size of the compiled program. -Dtoc produces two output files: - - dt-structs.h - contains struct definitions - dt-platdata.c - contains data from the device tree using the struct - definitions, as well as U-Boot driver definitions. +Dtoc produces several output files - see OUTPUT_FILES in dtb_platdata.py This tool is used in U-Boot to provide device tree data to SPL without increasing the code size of SPL. This supports the CONFIG_SPL_OF_PLATDATA
tools/dtoc/test_dtoc.py +37 -3
@@ -10,6 +10,7 @@ tool. """ import collections +import glob import os import struct import tempfile
@@ -302,6 +303,11 @@ U_BOOT_DEVICE(spl_test3) = { self._check_strings(self.platdata_text, data) + # Try the 'all' command + self.run_test(['all'], dtb_file, output) + data = tools.ReadFile(output, binary=False) + self._check_strings(self.platdata_text + self.struct_text, 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')
@@ -888,9 +894,9 @@ U_BOOT_DEVICE(spl_test2) = { """Test output of multiple pieces to a single file""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - self.run_test(['struct,platdata'], dtb_file, output) + self.run_test(['all'], dtb_file, output) data = tools.ReadFile(output, binary=False) - self._check_strings(self.struct_text + self.platdata_text, data) + self._check_strings(self.platdata_text + self.struct_text, data) def test_no_command(self): """Test running dtoc without a command"""
@@ -905,7 +911,7 @@ U_BOOT_DEVICE(spl_test2) = { output = tools.GetOutputFilename('output') with self.assertRaises(ValueError) as exc: self.run_test(['invalid-cmd'], dtb_file, output) - self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)", + self.assertIn("Unknown command 'invalid-cmd': (use: platdata, struct)", str(exc.exception)) @staticmethod
@@ -945,3 +951,31 @@ U_BOOT_DEVICE(spl_test2) = { self.assertEqual(drv1, drv3) self.assertNotEqual(drv1, drv2) self.assertNotEqual(drv2, drv3) + + def test_output_conflict(self): + """Test a conflict between and output dirs and output file""" + with self.assertRaises(ValueError) as exc: + dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True) + self.assertIn("Must specify either output or output_dirs, not both", + str(exc.exception)) + + def test_output_dirs(self): + """Test outputting files to a directory""" + # Remove the directory so that files from other tests are not there + tools._RemoveOutputDir() + tools.PrepareOutputDir(None) + + # This should create the .dts and .dtb in the output directory + dtb_file = get_dtb_file('dtoc_test_simple.dts') + outdir = tools.GetOutputDir() + fnames = glob.glob(outdir + '/*') + self.assertEqual(2, len(fnames)) + + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True) + fnames = glob.glob(outdir + '/*') + self.assertEqual(4, len(fnames)) + + leafs = set(os.path.basename(fname) for fname in fnames) + self.assertEqual( + {'dt-structs-gen.h', 'source.dts', 'dt-platdata.c', 'source.dtb'}, + leafs)
tools/patman/tools.py +8 -0
@@ -94,6 +94,14 @@ def GetOutputFilename(fname): """ return os.path.join(outdir, fname) +def GetOutputDir(): + """Return the current output directory + + Returns: + str: The output directory + """ + return outdir + def _FinaliseForTest(): """Remove the output directory (for use by tests)""" global outdir
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 7/49 Makefile: Invoke dtoc only once
In reply to Simon GlassUpdate the Makefile to run dtoc only once, generating all required files. This saves time since there is a lot of processing in each invocation of dtoc.
We already have a variable for the object files to build, so use that instead of repeating the same filenames. Add a C version of this also, for the same reason.
This makes it easier to add new C files (generated by dtoc) to the build later, as needed.
---
scripts/Makefile.spl | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
scripts/Makefile.spl +9 -12
@@ -121,6 +121,7 @@ u-boot-spl-init := $(head-y) u-boot-spl-main := $(libs-y) ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA u-boot-spl-platdata := $(obj)/dts/dt-platdata.o +u-boot-spl-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-platdata)) endif # Linker Script
@@ -310,17 +311,15 @@ pythonpath = PYTHONPATH=scripts/dtc/pylibfdt DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \ -d $(obj)/$(SPL_BIN).dtb -quiet_cmd_dtocc = DTOC C $@ -cmd_dtocc = $(DTOC_ARGS) -o $@ platdata - -quiet_cmd_dtoch = DTOC H $@ -cmd_dtoch = $(DTOC_ARGS) -o $@ struct +quiet_cmd_dtoc = DTOC $@ +cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all quiet_cmd_plat = PLAT $@ cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@) -targets += $(obj)/dts/dt-platdata.o -$(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \ +targets += $(u-boot-spl-platdata) + +$(obj)/dts/dt-%.o: $(obj)/dts/dt-%.c \ include/generated/dt-structs-gen.h prepare FORCE $(call if_changed,plat)
@@ -328,11 +327,9 @@ PHONY += dts_dir dts_dir: $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts) -include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir FORCE - $(call if_changed,dtoch) - -$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir FORCE - $(call if_changed,dtocc) +include/generated/dt-structs-gen.h $(u-boot-spl-platdata_c) &: \ + $(obj)/$(SPL_BIN).dtb dts_dir FORCE + $(call if_changed,dtoc) ifdef CONFIG_SAMSUNG ifdef CONFIG_VAR_SIZE_SPL
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 8/49 dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO()
In reply to Simon GlassThe current macro is a misnomer since it does not declare a device directly. Instead, it declares driver_info record which U-Boot uses at runtime to create a device.
The distinction seems somewhat minor most of the time, but is becomes quite confusing when we actually want to declare a device, with of-platdata. We are left trying to distinguish between a device which isn't actually device, and a device that is (perhaps an 'instance'?)
It seems better to rename this macro to describe what it actually is. The macros is not widely used, since boards should use devicetree to declare devices.
Rename it to U_BOOT_DRVINFO(), which indicates clearly that this is declaring a new driver_info record, not a device.
---
.../mach-at91/arm926ejs/at91sam9260_devices.c | 2 +- .../arm926ejs/at91sam9m10g45_devices.c | 2 +- arch/arm/mach-imx/mx6/soc.c | 2 +- arch/arm/mach-imx/mx7/soc.c | 2 +- arch/arm/mach-lpc32xx/devices.c | 4 +- arch/arm/mach-omap2/am33xx/board.c | 10 +-- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-tegra/board.c | 2 +- arch/arm/mach-tegra/board2.c | 2 +- board/armltd/integrator/integrator.c | 2 +- board/armltd/total_compute/total_compute.c | 2 +- board/armltd/vexpress64/vexpress64.c | 2 +- board/bluewater/gurnard/gurnard.c | 2 +- board/bluewater/snapper9260/snapper9260.c | 2 +- board/cadence/xtfpga/xtfpga.c | 4 +- board/cavium/thunderx/thunderx.c | 4 +- board/compulab/cm_fx6/cm_fx6.c | 2 +- board/davinci/da8xxevm/omapl138_lcdk.c | 4 +- board/freescale/ls1012afrdm/eth.c | 4 +- board/freescale/ls1012aqds/eth.c | 4 +- board/freescale/ls1012ardb/eth.c | 4 +- board/freescale/lx2160a/lx2160a.c | 4 +- board/gateworks/gw_ventana/gw_ventana.c | 2 +- board/hisilicon/hikey/hikey.c | 4 +- board/hisilicon/hikey960/hikey960.c | 2 +- board/hisilicon/poplar/poplar.c | 2 +- board/isee/igep00x0/igep00x0.c | 2 +- board/lg/sniper/sniper.c | 2 +- board/nokia/rx51/rx51.c | 2 +- board/sandbox/sandbox.c | 2 +- board/siemens/corvus/board.c | 2 +- board/st/stv0991/stv0991.c | 2 +- board/sysam/amcore/amcore.c | 2 +- board/ti/am335x/board.c | 6 +- board/timll/devkit8000/devkit8000.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 2 +- .../toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 2 +- board/toradex/colibri_pxa270/colibri_pxa270.c | 4 +- doc/driver-model/design.rst | 18 ++--- doc/driver-model/of-plat.rst | 12 ++-- doc/driver-model/remoteproc-framework.rst | 2 +- doc/driver-model/spi-howto.rst | 4 +- drivers/crypto/fsl/fsl_rsa.c | 2 +- drivers/crypto/rsa_mod_exp/mod_exp_sw.c | 2 +- drivers/demo/demo-pdata.c | 10 +-- drivers/gpio/imx_rgpio2p.c | 4 +- drivers/gpio/mxc_gpio.c | 2 +- drivers/remoteproc/sandbox_testproc.c | 2 +- drivers/rtc/emul_rtc.c | 2 +- drivers/serial/sandbox.c | 2 +- drivers/sysreset/sysreset_sandbox.c | 4 +- drivers/timer/sandbox_timer.c | 2 +- drivers/video/sunxi/sunxi_de2.c | 2 +- drivers/video/sunxi/sunxi_dw_hdmi.c | 2 +- drivers/video/sunxi/sunxi_lcd.c | 2 +- dts/Kconfig | 8 +-- include/dm/device.h | 4 +- include/dm/lists.h | 2 +- include/dm/platdata.h | 16 ++--- include/dm/platform_data/spi_pl022.h | 2 +- test/dm/core.c | 6 +- tools/dtoc/dtb_platdata.py | 8 +-- tools/dtoc/test_dtoc.py | 66 +++++++++---------- 64 files changed, 148 insertions(+), 148 deletions(-)
arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c +1 -1
@@ -219,7 +219,7 @@ static const struct at91_port_plat at91sam9260_plat[] = { { ATMEL_BASE_PIOC, "PC" }, }; -U_BOOT_DEVICES (at91sam9260_gpios) = { +U_BOOT_DRVINFOS (at91sam9260_gpios) = { {"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 +1 -1
@@ -175,7 +175,7 @@ static const struct at91_port_plat at91sam9260_plat[] = { { ATMEL_BASE_PIOE, "PE" }, }; -U_BOOT_DEVICES (at91sam9260_gpios) = { +U_BOOT_DRVINFOS (at91sam9260_gpios) = { {"atmel_at91rm9200_gpio" , &at91sam9260_plat[0 ] }, {"atmel_at91rm9200_gpio" , &at91sam9260_plat[1 ] }, { "atmel_at91rm9200_gpio", &at91sam9260_plat[2] },
arch/arm/mach-imx/mx6/soc.c +1 -1
@@ -44,7 +44,7 @@ static const struct imx_thermal_plat imx6_thermal_plat = { .fuse_word = 6, }; -U_BOOT_DEVICE (imx6_thermal) = { +U_BOOT_DRVINFO (imx6_thermal) = { .name ="imx_thermal" , .plat = &imx6_thermal_plat, };
arch/arm/mach-imx/mx7/soc.c +1 -1
@@ -60,7 +60,7 @@ static const struct imx_thermal_plat imx7_thermal_plat = { .fuse_word = 3, }; -U_BOOT_DEVICE (imx7_thermal) = { +U_BOOT_DRVINFO (imx7_thermal) = { .name ="imx_thermal" , .plat = &imx7_thermal_plat, };
arch/arm/mach-lpc32xx/devices.c +2 -2
@@ -62,7 +62,7 @@ static const struct lpc32xx_hsuart_plat lpc32xx_hsuart[] = { };#endif -U_BOOT_DEVICES(lpc32xx_uarts) = { +U_BOOT_DRVINFOS(lpc32xx_uarts) = {#if defined(CONFIG_LPC32XX_HSUART ) { "lpc32xx_hsuart", &lpc32xx_hsuart[0], }, { "lpc32xx_hsuart", &lpc32xx_hsuart[1], },
@@ -124,7 +124,7 @@ void lpc32xx_i2c_init(unsigned int devnum)writel (ctrl, &clk->i2cclk_ctrl); } -U_BOOT_DEVICE (lpc32xx_gpios) = { +U_BOOT_DRVINFO (lpc32xx_gpios) = { .name ="gpio_lpc32xx" };
arch/arm/mach-omap2/am33xx/board.c +5 -5
@@ -99,7 +99,7 @@ static const struct ns16550_plat am33xx_serial[] = {# endif }; -U_BOOT_DEVICES (am33xx_uarts) = { +U_BOOT_DRVINFOS (am33xx_uarts) = { {"ns16550_serial" , &am33xx_serial[0 ] }, # ifdef CONFIG_SYS_NS16550_COM2 { "ns16550_serial", &am33xx_serial[1] },
@@ -119,7 +119,7 @@ static const struct omap_i2c_plat am33xx_i2c[] = { { I2C_BASE3, 100000, OMAP_I2C_REV_V2}, }; -U_BOOT_DEVICES (am33xx_i2c) = { +U_BOOT_DRVINFOS (am33xx_i2c) = { {"i2c_omap" , &am33xx_i2c[0 ] }, {"i2c_omap" , &am33xx_i2c[1 ] }, { "i2c_omap", &am33xx_i2c[2] },
@@ -138,7 +138,7 @@ static const struct omap_gpio_plat am33xx_gpio[] = {#endif }; -U_BOOT_DEVICES (am33xx_gpios) = { +U_BOOT_DRVINFOS (am33xx_gpios) = { {"gpio_omap" , &am33xx_gpio[0 ] }, {"gpio_omap" , &am33xx_gpio[1 ] }, {"gpio_omap" , &am33xx_gpio[2 ] },
@@ -155,7 +155,7 @@ static const struct omap3_spi_plat omap3_spi_pdata = { .pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT, }; -U_BOOT_DEVICE (am33xx_spi) = { +U_BOOT_DRVINFO (am33xx_spi) = { .name ="omap3_spi" , .plat = &omap3_spi_pdata, };
@@ -234,7 +234,7 @@ static struct ti_musb_plat usb1 = { }, }; -U_BOOT_DEVICES (am33xx_usbs) = { +U_BOOT_DRVINFOS (am33xx_usbs) = { #if CONFIG_AM335X_USB0_MODE == MUSB_PERIPHERAL {"ti-musb-peripheral" , &usb0 }, #elif CONFIG_AM335X_USB0_MODE == MUSB_HOST
arch/arm/mach-omap2/omap3/board.c +1 -1
@@ -47,7 +47,7 @@ static const struct omap_gpio_plat omap34xx_gpio[] = { { 5, OMAP34XX_GPIO6_BASE }, }; -U_BOOT_DEVICES (omap34xx_gpios) = { +U_BOOT_DRVINFOS (omap34xx_gpios) = { {"gpio_omap" , &omap34xx_gpio[0 ] }, {"gpio_omap" , &omap34xx_gpio[1 ] }, { "gpio_omap", &omap34xx_gpio[2] },
arch/arm/mach-tegra/board.c +1 -1
@@ -264,7 +264,7 @@ static struct ns16550_plat ns16550_com1_pdata = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (ns16550_com1) = { +U_BOOT_DRVINFO (ns16550_com1) = {"ns16550_serial" , &ns16550_com1_pdata };#endif
arch/arm/mach-tegra/board2.c +1 -1
@@ -42,7 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD /* TODO(sjg at chromium.org): Remove once SPL supports device tree */ -U_BOOT_DEVICE (tegra_gpios) = { +U_BOOT_DRVINFO (tegra_gpios) = {"gpio_tegra" };#endif
board/armltd/integrator/integrator.c +1 -1
@@ -43,7 +43,7 @@ static const struct pl01x_serial_plat serial_plat = {#endif }; -U_BOOT_DEVICE (integrator_serials) = { +U_BOOT_DRVINFO (integrator_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/armltd/total_compute/total_compute.c +1 -1
@@ -15,7 +15,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = CONFIG_PL011_CLOCK, }; -U_BOOT_DEVICE (total_compute_serials) = { +U_BOOT_DRVINFO (total_compute_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/armltd/vexpress64/vexpress64.c +1 -1
@@ -26,7 +26,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = CONFIG_PL011_CLOCK, }; -U_BOOT_DEVICE (vexpress_serials) = { +U_BOOT_DRVINFO (vexpress_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/bluewater/gurnard/gurnard.c +1 -1
@@ -420,7 +420,7 @@ static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE (at91sam9260_serial) = { +U_BOOT_DRVINFO (at91sam9260_serial) = { .name ="serial_atmel" , .plat = &at91sam9260_serial_plat, };
board/bluewater/snapper9260/snapper9260.c +1 -1
@@ -147,7 +147,7 @@ static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE (at91sam9260_serial) = { +U_BOOT_DRVINFO (at91sam9260_serial) = { .name ="serial_atmel" , .plat = &at91sam9260_serial_plat, };
board/cadence/xtfpga/xtfpga.c +2 -2
@@ -93,7 +93,7 @@ int misc_init_r(void)return 0 ; } -U_BOOT_DEVICE (sysreset) = { +U_BOOT_DRVINFO (sysreset) = { .name ="xtfpga_sysreset" , };
@@ -104,7 +104,7 @@ static struct ethoc_eth_pdata ethoc_pdata = { .packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR, }; -U_BOOT_DEVICE (ethoc) = { +U_BOOT_DRVINFO (ethoc) = { .name ="ethoc" , .plat = ðoc_pdata, };
board/cavium/thunderx/thunderx.c +2 -2
@@ -25,7 +25,7 @@ static const struct pl01x_serial_plat serial0 = { .skip_init = true, }; -U_BOOT_DEVICE (thunderx_serial0) = { +U_BOOT_DRVINFO (thunderx_serial0) = { .name ="serial_pl01x" , .plat = &serial0, };
@@ -37,7 +37,7 @@ static const struct pl01x_serial_plat serial1 = { .skip_init = true, }; -U_BOOT_DEVICE (thunderx_serial1) = { +U_BOOT_DRVINFO (thunderx_serial1) = { .name ="serial_pl01x" , .plat = &serial1, };
board/compulab/cm_fx6/cm_fx6.c +1 -1
@@ -728,7 +728,7 @@ static struct mxc_serial_plat cm_fx6_mxc_serial_plat = { .reg = (struct mxc_uart *)UART4_BASE, }; -U_BOOT_DEVICE (cm_fx6_serial) = { +U_BOOT_DRVINFO (cm_fx6_serial) = { .name ="serial_mxc" , .plat = &cm_fx6_mxc_serial_plat, };
board/davinci/da8xxevm/omapl138_lcdk.c +2 -2
@@ -363,7 +363,7 @@ static const struct ns16550_plat serial_pdata = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (omapl138_uart) = { +U_BOOT_DRVINFO (omapl138_uart) = { .name ="ns16550_serial" , .plat = &serial_pdata, };
@@ -379,7 +379,7 @@ static const struct davinci_mmc_plat mmc_plat = { .name = "da830-mmc", }, }; -U_BOOT_DEVICE (omapl138_mmc) = { +U_BOOT_DRVINFO (omapl138_mmc) = { .name ="ti_da830_mmc" , .plat = &mmc_plat, };
board/freescale/ls1012afrdm/eth.c +2 -2
@@ -114,12 +114,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE (ls1012a_pfe0) = { +U_BOOT_DRVINFO (ls1012a_pfe0) = { .name ="pfe_eth" , .plat = &pfe_pdata0, }; -U_BOOT_DEVICE (ls1012a_pfe1) = { +U_BOOT_DRVINFO (ls1012a_pfe1) = { .name ="pfe_eth" , .plat = &pfe_pdata1, };
board/freescale/ls1012aqds/eth.c +2 -2
@@ -298,12 +298,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE (ls1012a_pfe0) = { +U_BOOT_DRVINFO (ls1012a_pfe0) = { .name ="pfe_eth" , .plat = &pfe_pdata0, }; -U_BOOT_DEVICE (ls1012a_pfe1) = { +U_BOOT_DRVINFO (ls1012a_pfe1) = { .name ="pfe_eth" , .plat = &pfe_pdata1, };
board/freescale/ls1012ardb/eth.c +2 -2
@@ -160,12 +160,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE (ls1012a_pfe0) = { +U_BOOT_DRVINFO (ls1012a_pfe0) = { .name ="pfe_eth" , .plat = &pfe_pdata0, }; -U_BOOT_DEVICE (ls1012a_pfe1) = { +U_BOOT_DRVINFO (ls1012a_pfe1) = { .name ="pfe_eth" , .plat = &pfe_pdata1, };
board/freescale/lx2160a/lx2160a.c +2 -2
@@ -62,7 +62,7 @@ static struct pl01x_serial_plat serial0 = { .type = TYPE_PL011, }; -U_BOOT_DEVICE (nxp_serial0) = { +U_BOOT_DRVINFO (nxp_serial0) = { .name ="serial_pl01x" , .plat = &serial0, };
@@ -72,7 +72,7 @@ static struct pl01x_serial_plat serial1 = { .type = TYPE_PL011, }; -U_BOOT_DEVICE (nxp_serial1) = { +U_BOOT_DRVINFO (nxp_serial1) = { .name ="serial_pl01x" , .plat = &serial1, };
board/gateworks/gw_ventana/gw_ventana.c +1 -1
@@ -1375,7 +1375,7 @@ static struct mxc_serial_plat ventana_mxc_serial_plat = { .reg = (struct mxc_uart *)UART2_BASE, }; -U_BOOT_DEVICE (ventana_serial) = { +U_BOOT_DRVINFO (ventana_serial) = { .name ="serial_mxc" , .plat = &ventana_mxc_serial_plat, };
board/hisilicon/hikey/hikey.c +2 -2
@@ -50,7 +50,7 @@ static const struct hikey_gpio_plat hi6220_gpio[] = { }; -U_BOOT_DEVICES (hi6220_gpios) = { +U_BOOT_DRVINFOS (hi6220_gpios) = { {"gpio_hi6220" , &hi6220_gpio[0 ] }, {"gpio_hi6220" , &hi6220_gpio[1 ] }, {"gpio_hi6220" , &hi6220_gpio[2 ] },
@@ -89,7 +89,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 19200000 }; -U_BOOT_DEVICE (hikey_seriala) = { +U_BOOT_DRVINFO (hikey_seriala) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/hisilicon/hikey960/hikey960.c +1 -1
@@ -32,7 +32,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 19200000 }; -U_BOOT_DEVICE (hikey960_serial0) = { +U_BOOT_DRVINFO (hikey960_serial0) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/hisilicon/poplar/poplar.c +1 -1
@@ -46,7 +46,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 75000000, }; -U_BOOT_DEVICE (poplar_serial) = { +U_BOOT_DRVINFO (poplar_serial) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/isee/igep00x0/igep00x0.c +1 -1
@@ -36,7 +36,7 @@ static const struct ns16550_plat igep_serial = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (igep_uart) = { +U_BOOT_DRVINFO (igep_uart) = {"ns16550_serial" , &igep_serial };
board/lg/sniper/sniper.c +1 -1
@@ -37,7 +37,7 @@ static const struct ns16550_plat serial_omap_plat = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (sniper_serial) = { +U_BOOT_DRVINFO (sniper_serial) = { .name ="ns16550_serial" , .plat = &serial_omap_plat };
board/nokia/rx51/rx51.c +1 -1
@@ -709,7 +709,7 @@ static const struct omap_i2c_plat rx51_i2c[] = { { I2C_BASE3, 400000, OMAP_I2C_REV_V1 }, }; -U_BOOT_DEVICES (rx51_i2c) = { +U_BOOT_DRVINFOS (rx51_i2c) = { {"i2c_omap" , &rx51_i2c[0 ] }, {"i2c_omap" , &rx51_i2c[1 ] }, { "i2c_omap", &rx51_i2c[2] },
board/sandbox/sandbox.c +1 -1
@@ -23,7 +23,7 @@ gd_t *gd;#if !CONFIG_IS_ENABLED (OF_PLATDATA )/* Add a simple GPIO device */ -U_BOOT_DEVICE (gpio_sandbox) = { +U_BOOT_DRVINFO (gpio_sandbox) = { .name ="sandbox_gpio" , };#endif
board/siemens/corvus/board.c +1 -1
@@ -318,7 +318,7 @@ static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE (at91sam9260_serial) = { +U_BOOT_DRVINFO (at91sam9260_serial) = { .name ="serial_atmel" , .plat = &at91sam9260_serial_plat, };
board/st/stv0991/stv0991.c +1 -1
@@ -30,7 +30,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 2700 * 1000, }; -U_BOOT_DEVICE (stv09911_serials) = { +U_BOOT_DRVINFO (stv09911_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };
board/sysam/amcore/amcore.c +1 -1
@@ -113,7 +113,7 @@ static struct coldfire_serial_plat mcf5307_serial_plat = { .baudrate = CONFIG_BAUDRATE, }; -U_BOOT_DEVICE (coldfire_serial) = { +U_BOOT_DRVINFO (coldfire_serial) = { .name ="serial_coldfire" , .plat = &mcf5307_serial_plat, };
board/ti/am335x/board.c +3 -3
@@ -927,7 +927,7 @@ struct eth_pdata cpsw_pdata = { .priv_pdata = &am335_eth_data, }; -U_BOOT_DEVICE (am335x_eth) = { +U_BOOT_DRVINFO (am335x_eth) = { .name ="eth_cpsw" , .plat = &cpsw_pdata, };
@@ -972,7 +972,7 @@ static const struct omap_hsmmc_plat am335x_mmc0_plat = { .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, }; -U_BOOT_DEVICE (am335x_mmc0) = { +U_BOOT_DRVINFO (am335x_mmc0) = { .name ="omap_hsmmc" , .plat = &am335x_mmc0_plat, };
@@ -986,7 +986,7 @@ static const struct omap_hsmmc_plat am335x_mmc1_plat = { .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, }; -U_BOOT_DEVICE (am335x_mmc1) = { +U_BOOT_DRVINFO (am335x_mmc1) = { .name ="omap_hsmmc" , .plat = &am335x_mmc1_plat, };
board/timll/devkit8000/devkit8000.c +1 -1
@@ -54,7 +54,7 @@ static const struct ns16550_plat devkit8000_serial = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (devkit8000_uart) = { +U_BOOT_DRVINFO (devkit8000_uart) = {"ns16550_serial" , &devkit8000_serial };
board/toradex/apalis_imx6/apalis_imx6.c +1 -1
@@ -1149,7 +1149,7 @@ static struct mxc_serial_plat mxc_serial_plat = { .use_dte = true, }; -U_BOOT_DEVICE (mxc_serial) = { +U_BOOT_DRVINFO (mxc_serial) = { .name ="serial_mxc" , .plat = &mxc_serial_plat, };
board/toradex/colibri-imx6ull/colibri-imx6ull.c +1 -1
@@ -208,7 +208,7 @@ static struct mxc_serial_plat mxc_serial_plat = { .use_dte = 1, }; -U_BOOT_DEVICE (mxc_serial) = { +U_BOOT_DRVINFO (mxc_serial) = { .name ="serial_mxc" , .plat = &mxc_serial_plat, };
board/toradex/colibri_imx6/colibri_imx6.c +1 -1
@@ -1091,7 +1091,7 @@ static struct mxc_serial_plat mxc_serial_plat = { .use_dte = true, }; -U_BOOT_DEVICE (mxc_serial) = { +U_BOOT_DRVINFO (mxc_serial) = { .name ="serial_mxc" , .plat = &mxc_serial_plat, };
board/toradex/colibri_pxa270/colibri_pxa270.c +2 -2
@@ -133,7 +133,7 @@ static const struct pxa_mmc_plat mmc_plat = { .base = (struct pxa_mmc_regs *)MMC0_BASE, }; -U_BOOT_DEVICE (pxa_mmcs) = { +U_BOOT_DRVINFO (pxa_mmcs) = { .name ="pxa_mmc" , .plat = &mmc_plat, };
@@ -146,7 +146,7 @@ static const struct pxa_serial_plat serial_plat = { .baudrate = CONFIG_BAUDRATE, }; -U_BOOT_DEVICE (pxa_serials) = { +U_BOOT_DRVINFO (pxa_serials) = { .name ="serial_pxa" , .plat = &serial_plat, };
doc/driver-model/design.rst +9 -9
@@ -422,7 +422,7 @@ Device Tree While plat is useful, a more flexible way of providing device data is by using device tree. In U-Boot you should use this where possible. Avoid -sending patches which make use of the U_BOOT_DEVICE() macro unless strictly +sending patches which make use of the U_BOOT_DRVINFO() macro unless strictly necessary. With device tree we replace the above code with the following device tree
@@ -436,7 +436,7 @@ fragment: sides = <4>; }; -This means that instead of having lots of U_BOOT_DEVICE() declarations in +This means that instead of having lots of U_BOOT_DRVINFO() declarations in the board file, we put these in the device tree. This approach allows a lot more generality, since the same board file can support many types of boards (e,g. with the same SoC) just by using different device trees. An added
@@ -665,9 +665,9 @@ Bind stage U-Boot discovers devices using one of these two methods: -- Scan the U_BOOT_DEVICE() definitions. U-Boot looks up the name specified +- Scan the U_BOOT_DRVINFO() definitions. U-Boot looks up the name specified by each, to find the appropriate U_BOOT_DRIVER() definition. In this case, - there is no path by which driver_data may be provided, but the U_BOOT_DEVICE() + there is no path by which driver_data may be provided, but the U_BOOT_DRVINFO() may provide plat. - Scan through the device tree definitions. U-Boot looks at top-level
@@ -685,7 +685,7 @@ driver's bind() method if one is defined. At this point all the devices are known, and bound to their drivers. There is a 'struct udevice' allocated for all devices. However, nothing has been activated (except for the root device). Each bound device that was created -from a U_BOOT_DEVICE() declaration will hold the plat pointer specified +from a U_BOOT_DRVINFO() declaration will hold the plat pointer specified in that declaration. For a bound device created from the device tree, plat will be NULL, but of_offset will be the offset of the device tree node that caused the device to be created. The uclass is set correctly for
@@ -726,7 +726,7 @@ The steps are: 2. If plat_auto is non-zero, then the platform data space is allocated. This is only useful for device tree operation, since otherwise you would have to specific the platform data in the - U_BOOT_DEVICE() declaration. The space is allocated for the device and + U_BOOT_DRVINFO() declaration. The space is allocated for the device and zeroed. It will be accessible as dev->plat. 3. If the device's uclass specifies a non-zero per_device_auto,
@@ -746,7 +746,7 @@ The steps are: do various calls like dev_read_u32(dev, ...) to access the node and store the resulting information into dev->plat. After this point, the device works the same way whether it was bound using a device tree node or - U_BOOT_DEVICE() structure. In either case, the platform data is now stored + U_BOOT_DRVINFO() structure. In either case, the platform data is now stored in the plat structure. Typically you will use the plat_auto feature to specify the size of the platform data structure, and U-Boot will automatically allocate and zero it for you before
@@ -855,7 +855,7 @@ remove it. This performs the probe steps in reverse: 4. The device memory is freed (platform data, private data, uclass data, parent data). - Note: Because the platform data for a U_BOOT_DEVICE() is defined with a + Note: Because the platform data for a U_BOOT_DRVINFO() is defined with a static pointer, it is not de-allocated during the remove() method. For a device instantiated using the device tree data, the platform data will be dynamically allocated, and thus needs to be deallocated during the
@@ -931,7 +931,7 @@ property can provide better control granularity on which device is bound before relocation. While with DM_FLAG_PRE_RELOC flag of the driver all devices with the same driver are bound, which requires allocation a large amount of memory. When device tree is not used, DM_FLAG_PRE_RELOC is the -only way for statically declared devices via U_BOOT_DEVICE() to be bound +only way for statically declared devices via U_BOOT_DRVINFO() to be bound prior to relocation. It is possible to limit this to specific relocation steps, by using
doc/driver-model/of-plat.rst +6 -6
@@ -21,7 +21,7 @@ SoCs require a 16KB SPL image which must include a full MMC stack. In this case the overhead of device tree access may be too great. It is possible to create platform data manually by defining C structures -for it, and reference that data in a U_BOOT_DEVICE() declaration. This +for it, and reference that data in a U_BOOT_DRVINFO() declaration. This bypasses the use of device tree completely, effectively creating a parallel configuration mechanism. But it is an available option for SPL.
@@ -79,7 +79,7 @@ SPL/TPL and should be tested with: A new tool called 'dtoc' converts a device tree file either into a set of struct declarations, one for each compatible node, and a set of -U_BOOT_DEVICE() declarations along with the actual platform data for each +U_BOOT_DRVINFO() declarations along with the actual platform data for each device. As an example, consider this MMC node: .. code-block:: none
@@ -155,7 +155,7 @@ and the following device declarations: .card_detect_delay = 0xc8, }; - U_BOOT_DEVICE(dwmmc_at_ff0c0000) = { + U_BOOT_DRVINFO(dwmmc_at_ff0c0000) = { .name = "rockchip_rk3288_dw_mshc", .plat = &dtv_dwmmc_at_ff0c0000, .plat_size = sizeof(dtv_dwmmc_at_ff0c0000),
@@ -178,7 +178,7 @@ platform data in the driver. The of_to_plat() method should therefore do nothing in such a driver. Note that for the platform data to be matched with a driver, the 'name' -property of the U_BOOT_DEVICE() declaration has to match a driver declared +property of the U_BOOT_DRVINFO() declaration has to match a driver declared via U_BOOT_DRIVER(). This effectively means that a U_BOOT_DRIVER() with a 'name' corresponding to the devicetree 'compatible' string (after converting it to a valid name for C) is needed, so a dedicated driver is required for
@@ -189,7 +189,7 @@ used to declare an alias for a driver name, typically a 'compatible' string. This macro produces no code, but it is by dtoc tool. The parent_idx is the index of the parent driver_info structure within its -linker list (instantiated by the U_BOOT_DEVICE() macro). This is used to support +linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support dev_get_parent(). The dm_populate_phandle_data() is included to allow for fix-ups required by dtoc. It is not currently used. The values in 'clocks' are the index of the driver_info for the target device followed by any phandle
@@ -339,7 +339,7 @@ prevents them being used inadvertently. All usage must be bracketed with The dt-plat.c file contains the device declarations and is is built in spl/dt-plat.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 +information by adding references to U_BOOT_DRVINFO by using DM_GET_DEVICE The pylibfdt Python module is used to access the devicetree.
doc/driver-model/remoteproc-framework.rst +1 -1
@@ -125,7 +125,7 @@ a simplified definition of a device is as follows: .driver_plat_data = &mydriver_data; }; - U_BOOT_DEVICE(proc_3_demo) = { + U_BOOT_DRVINFO(proc_3_demo) = { .name = "sandbox_test_proc", .plat = &proc_3_test, };
doc/driver-model/spi-howto.rst +2 -2
@@ -270,7 +270,7 @@ fills in the fields from device tree. Add the platform data [non-device-tree only] -------------------------------------------- -Specify this data in a U_BOOT_DEVICE() declaration in your board file: +Specify this data in a U_BOOT_DRVINFO() declaration in your board file: .. code-block:: c
@@ -281,7 +281,7 @@ Specify this data in a U_BOOT_DEVICE() declaration in your board file: .deactivate_delay_us = ... }; - U_BOOT_DEVICE(board_spi0) = { + U_BOOT_DRVINFO(board_spi0) = { .name = "exynos_spi", .plat = &platdata_spi0, };
drivers/crypto/fsl/fsl_rsa.c +1 -1
@@ -55,6 +55,6 @@ U_BOOT_DRIVER(fsl_rsa_mod_exp) = { .ops = &fsl_mod_exp_ops, }; -U_BOOT_DEVICE (fsl_rsa) = { +U_BOOT_DRVINFO (fsl_rsa) = { .name ="fsl_rsa_mod_exp" , };
drivers/crypto/rsa_mod_exp/mod_exp_sw.c +1 -1
@@ -35,6 +35,6 @@ U_BOOT_DRIVER(mod_exp_sw) = { .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DEVICE (mod_exp_sw) = { +U_BOOT_DRVINFO (mod_exp_sw) = { .name ="mod_exp_sw" , };
drivers/demo/demo-pdata.c +5 -5
@@ -20,27 +20,27 @@ static const struct dm_demo_pdata yellow_hexagon = { .sides = 6. }; -U_BOOT_DEVICE (demo0) = { +U_BOOT_DRVINFO (demo0) = { .name ="demo_shape_drv" , .plat = &red_square, }; -U_BOOT_DEVICE (demo1) = { +U_BOOT_DRVINFO (demo1) = { .name ="demo_simple_drv" , .plat = &red_square, }; -U_BOOT_DEVICE (demo2) = { +U_BOOT_DRVINFO (demo2) = { .name ="demo_shape_drv" , .plat = &green_triangle, }; -U_BOOT_DEVICE (demo3) = { +U_BOOT_DRVINFO (demo3) = { .name ="demo_simple_drv" , .plat = &yellow_hexagon, }; -U_BOOT_DEVICE (demo4) = { +U_BOOT_DRVINFO (demo4) = { .name ="demo_shape_drv" , .plat = &yellow_hexagon, };
drivers/gpio/imx_rgpio2p.c +2 -2
@@ -158,7 +158,7 @@ static int imx_rgpio2p_bind(struct udevice *dev)/* * If plat already exsits, directly return. * Actually only when DT is not supported, plat -* is statically initialized in U_BOOT_DEVICES.Here +* is statically initialized in U_BOOT_DRVINFOS.Here * will return. */ if (plat)
@@ -216,7 +216,7 @@ static const struct imx_rgpio2p_plat imx_plat[] = { { 5, (struct gpio_regs *)RGPIO2P_GPIO6_BASE_ADDR }, }; -U_BOOT_DEVICES (imx_rgpio2ps) = { +U_BOOT_DRVINFOS (imx_rgpio2ps) = { {"imx_rgpio2p" , &imx_plat[0 ] }, {"imx_rgpio2p" , &imx_plat[1 ] }, { "imx_rgpio2p", &imx_plat[2] },
drivers/gpio/mxc_gpio.c +1 -1
@@ -372,7 +372,7 @@ static const struct mxc_gpio_plat mxc_plat[] = {#endif }; -U_BOOT_DEVICES (mxc_gpios) = { +U_BOOT_DRVINFOS (mxc_gpios) = { {"gpio_mxc" , &mxc_plat[0 ] }, {"gpio_mxc" , &mxc_plat[1 ] }, {"gpio_mxc" , &mxc_plat[2 ] },
drivers/remoteproc/sandbox_testproc.c +1 -1
@@ -352,7 +352,7 @@ static struct dm_rproc_uclass_pdata proc_3_test = { .mem_type = RPROC_INTERNAL_MEMORY_MAPPED, }; -U_BOOT_DEVICE (proc_3_demo) = { +U_BOOT_DRVINFO (proc_3_demo) = { .name ="sandbox_test_proc" , .plat = &proc_3_test, };
drivers/rtc/emul_rtc.c +1 -1
@@ -91,6 +91,6 @@ U_BOOT_DRIVER(rtc_emul) = { .priv_auto = sizeof(struct emul_rtc), }; -U_BOOT_DEVICE (rtc_emul) = { +U_BOOT_DRVINFO (rtc_emul) = { .name ="rtc_emul" , };
drivers/serial/sandbox.c +1 -1
@@ -241,7 +241,7 @@ static const struct sandbox_serial_plat platdata_non_fdt = { .colour = -1, }; -U_BOOT_DEVICE (serial_sandbox_non_fdt) = { +U_BOOT_DRVINFO (serial_sandbox_non_fdt) = { .name ="sandbox_serial" , .plat = &platdata_non_fdt, };
drivers/sysreset/sysreset_sandbox.c +2 -2
@@ -47,7 +47,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)/* * If we have a device tree, the device we created from platform data -* (see the U_BOOT_DEVICE() declaration below) should not do anything. +* (see the U_BOOT_DRVINFO() declaration below) should not do anything. * If we are that device, return an error. */ if (state->fdt_fname && !dev_has_ofnode (dev))
@@ -135,7 +135,7 @@ U_BOOT_DRIVER(warm_sysreset_sandbox) = {#if !CONFIG_IS_ENABLED (OF_PLATDATA )/* This is here in case we don't have a device tree */ -U_BOOT_DEVICE (sysreset_sandbox_non_fdt) = { +U_BOOT_DRVINFO (sysreset_sandbox_non_fdt) = { .name ="sysreset_sandbox" , };#endif
drivers/timer/sandbox_timer.c +1 -1
@@ -65,6 +65,6 @@ U_BOOT_DRIVER(sandbox_timer) = { };/* This is here in case we don't have a device tree */ -U_BOOT_DEVICE (sandbox_timer_non_fdt) = { +U_BOOT_DRVINFO (sandbox_timer_non_fdt) = { .name ="sandbox_timer" , };
drivers/video/sunxi/sunxi_de2.c +1 -1
@@ -319,7 +319,7 @@ U_BOOT_DRIVER(sunxi_de2) = { .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DEVICE (sunxi_de2) = { +U_BOOT_DRVINFO (sunxi_de2) = { .name ="sunxi_de2" };
drivers/video/sunxi/sunxi_dw_hdmi.c +1 -1
@@ -398,6 +398,6 @@ U_BOOT_DRIVER(sunxi_dw_hdmi) = { .priv_auto = sizeof(struct sunxi_dw_hdmi_priv), }; -U_BOOT_DEVICE (sunxi_dw_hdmi) = { +U_BOOT_DRVINFO (sunxi_dw_hdmi) = { .name ="sunxi_dw_hdmi" };
drivers/video/sunxi/sunxi_lcd.c +1 -1
@@ -146,7 +146,7 @@ U_BOOT_DRIVER(sunxi_lcd) = { };#ifdef CONFIG_MACH_SUN50I -U_BOOT_DEVICE (sunxi_lcd) = { +U_BOOT_DRVINFO (sunxi_lcd) = { .name ="sunxi_lcd" };#endif
dts/Kconfig +4 -4
@@ -346,13 +346,13 @@ config SPL_OF_PLATDATA former can add 3KB or more to a Thumb 2 Image. This option enables generation of platform data from the device - tree as C code. This code creates devices using U_BOOT_DEVICE() + tree as C code. This code creates devices using U_BOOT_DRVINFO() declarations. The benefit is that it allows driver code to access the platform data directly in C structures, avoidin the libfdt overhead. This option works by generating C structure declarations for each - compatible string, then adding platform data and U_BOOT_DEVICE + compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. config SPL_OF_PLATDATA_PARENT
@@ -376,13 +376,13 @@ config TPL_OF_PLATDATA former can add 3KB or more to a Thumb 2 Image. This option enables generation of platform data from the device - tree as C code. This code creates devices using U_BOOT_DEVICE() + tree as C code. This code creates devices using U_BOOT_DRVINFO() declarations. The benefit is that it allows driver code to access the platform data directly in C structures, avoidin the libfdt overhead. This option works by generating C structure declarations for each - compatible string, then adding platform data and U_BOOT_DEVICE + compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. config TPL_OF_PLATDATA_PARENT
include/dm/device.h +2 -2
@@ -104,7 +104,7 @@ enum {* particular port or peripheral (essentially a driver instance). * * A device will come into existence through a 'bind' call, either due to -* a U_BOOT_DEVICE() macro (in which case plat is non-NULL) or a node +* a U_BOOT_DRVINFO() macro (in which case plat is non-NULL) or a node * in the device tree (in which case of_offset is >= 0). In the latter case * we translate the device tree information into plat in a function * implemented by the driver of_to_plat method (called just before the
@@ -293,7 +293,7 @@ struct udevice_id {* platform data to be allocated in the device's ->plat pointer. * This is typically only useful for device-tree-aware drivers (those with * an of_match), since drivers which use plat will have the data -* provided in the U_BOOT_DEVICE() instantiation. +* provided in the U_BOOT_DRVINFO() instantiation. * @per_child_auto: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero.
include/dm/lists.h +1 -1
@@ -35,7 +35,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id);/** * lists_bind_drivers() - search for and bind all drivers to parent * -* This searches the U_BOOT_DEVICE() structures and creates new devices for +* This searches the U_BOOT_DRVINFO() structures and creates new devices for * each one. The devices will have @parent as their parent. * * @parent: parent device (root)
include/dm/platdata.h +8 -8
@@ -56,31 +56,31 @@ struct driver_rt {* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is * available). U-Boot's driver model uses device tree for configuration. * -* When of-platdata is in use, U_BOOT_DEVICE() cannot be used outside of the +* When of-platdata is in use, U_BOOT_DRVINFO() cannot be used outside of the * dt-plat.c file created by dtoc */ #if CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(DT_PLATDATA_C ) -#define U_BOOT_DEVICE (__name) _Static_assert(false, \ - "Cannot use U_BOOT_DEVICE with of-platdata. Please use devicetree instead") +#define U_BOOT_DRVINFO (__name) _Static_assert(false, \ + "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead")#else -#define U_BOOT_DEVICE (__name) \ +#define U_BOOT_DRVINFO (__name) \ ll_entry_declare(struct driver_info, __name, driver_info)#endif /* Declare a list of devices. The argument is a driver_info[] array */ -#define U_BOOT_DEVICES (__name) \ +#define U_BOOT_DRVINFOS (__name) \ ll_entry_declare_list(struct driver_info, __name, driver_info)/** * Get a pointer to a given device info given its name * -* With the declaration U_BOOT_DEVICE(name), DM_GET_DEVICE(name) will return a +* With the declaration U_BOOT_DRVINFO(name), DM_GET_DEVICE(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * -* TODO(sjg at chromium.org): U_BOOT_DEVICE() tells U-Boot to create a device, so +* TODO(sjg at chromium.org): U_BOOT_DRVINFO() tells U-Boot to create a device, so * the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it * finds the driver_info record, not the device. *
@@ -93,7 +93,7 @@ struct driver_rt {/** * dm_populate_phandle_data() - Populates phandle data in platda * -* This populates phandle data with an U_BOOT_DEVICE entry get by +* This populates phandle data with an U_BOOT_DRVINFO entry get by * DM_GET_DEVICE. The implementation of this function will be done * by dtoc when parsing dtb. */
include/dm/platform_data/spi_pl022.h +1 -1
@@ -3,7 +3,7 @@* (C) Copyright 2018 * Quentin Schulz, Bootlin, [email protected] * -* Structure for use with U_BOOT_DEVICE for pl022 SPI devices or to use +* Structure for use with U_BOOT_DRVINFO for pl022 SPI devices or to use * in of_to_plat. */
test/dm/core.c +3 -3
@@ -43,17 +43,17 @@ static const struct dm_test_pdata test_pdata_pre_reloc = { .ping_add = TEST_INTVAL_PRE_RELOC, }; -U_BOOT_DEVICE (dm_test_info1) = { +U_BOOT_DRVINFO (dm_test_info1) = { .name ="test_drv" , .plat = &test_pdata[0 ], }; -U_BOOT_DEVICE (dm_test_info2) = { +U_BOOT_DRVINFO (dm_test_info2) = { .name ="test_drv" , .plat = &test_pdata[1 ], }; -U_BOOT_DEVICE (dm_test_info3) = { +U_BOOT_DRVINFO (dm_test_info3) = { .name ="test_drv" , .plat = &test_pdata[2 ], };
tools/dtoc/dtb_platdata.py +4 -4
@@ -713,14 +713,14 @@ class DtbPlatdata(): def _declare_device(self, var_name, struct_name, node_parent): """Add a device declaration to the output - This declares a U_BOOT_DEVICE() for the device being processed + This declares a U_BOOT_DRVINFO() for the device being processed Args: var_name (str): C name for the node struct_name (str): Name for the dt struct associated with the node node_parent (Node): Parent of the node (or None if none) """ - self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name) + self.buf('U_BOOT_DRVINFO(%s) = {\n' % var_name) self.buf('\t.name\t\t= "%s",\n' % struct_name) self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name)) self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))
@@ -783,14 +783,14 @@ class DtbPlatdata(): """Generate device defintions for the platform data This writes out C platform data initialisation data and - U_BOOT_DEVICE() declarations for each valid node. Where a node has + U_BOOT_DRVINFO() declarations for each valid node. Where a node has multiple compatible strings, a #define is used to make them equivalent. See the documentation in doc/driver-model/of-plat.rst for more information. """ self.out_header() - self.out('/* Allow use of U_BOOT_DEVICE() in this file */\n') + self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') self.out('#define DT_PLATDATA_C\n') self.out('\n') self.out('#include <common.h>\n')
tools/dtoc/test_dtoc.py +33 -33
264 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 9/49 dm: Rename DM_GET_DEVICE() to DM_DRVINFO_GET()
In reply to Simon GlassThis does not get a device (struct udevice *) but a struct driver_info * so the name is confusing.
Rename it accordingly. Since we plan to have several various of these macros, put GET at the end instead of the middle, so it is easier to spot the related macros.
---
doc/driver-model/of-plat.rst | 2 +- include/dm/platdata.h | 10 +++------- tools/dtoc/dtb_platdata.py | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-)
doc/driver-model/of-plat.rst +1 -1
@@ -339,7 +339,7 @@ prevents them being used inadvertently. All usage must be bracketed with The dt-plat.c file contains the device declarations and is is built in spl/dt-plat.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_DRVINFO by using DM_GET_DEVICE +information by adding references to U_BOOT_DRVINFO by using DM_DRVINFO_GET The pylibfdt Python module is used to access the devicetree.
include/dm/platdata.h +3 -7
@@ -74,27 +74,23 @@ struct driver_rt {/** * Get a pointer to a given device info given its name * -* With the declaration U_BOOT_DRVINFO(name), DM_GET_DEVICE(name) will return a +* With the declaration U_BOOT_DRVINFO(name), DM_DRVINFO_GET(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * -* TODO(sjg at chromium.org): U_BOOT_DRVINFO() tells U-Boot to create a device, so -* the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it -* finds the driver_info record, not the device. -* * @__name: Driver name (C identifier, not a string. E.g. gpio7_at_ff7e0000) * @return struct driver_info * to the driver that created the device */ -#define DM_GET_DEVICE (__name) \ +#define DM_DRVINFO_GET (__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_DRVINFO entry get by -* DM_GET_DEVICE. The implementation of this function will be done +* DM_DRVINFO_GET. The implementation of this function will be done * by dtoc when parsing dtb. */ void dm_populate_phandle_data (void );
tools/dtoc/dtb_platdata.py +2 -2
@@ -811,8 +811,8 @@ class DtbPlatdata(): 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) + # nodes using DM_DRVINFO_GET + # dtv_dmc_at_xxx.clocks[0].node = DM_DRVINFO_GET(clock_controller_at_xxx) self.buf('void dm_populate_phandle_data(void) {\n') self.buf('}\n')
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 10/49 dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET()
In reply to Simon GlassIn the spirit of using the same base name for all of these related macros, rename this to have the operation at the end. This is not widely used so the impact is fairly small.
---
arch/arm/lib/gic-v3-its.c | 10 +++++----- arch/arm/mach-aspeed/ast2500/clk_ast2500.c | 2 +- arch/arm/mach-k3/am6_init.c | 2 +- arch/arm/mach-k3/common.c | 2 +- arch/arm/mach-k3/j721e_init.c | 2 +- arch/arm/mach-mediatek/mt7629/init.c | 4 ++-- arch/arm/mach-mediatek/mt8516/init.c | 2 +- arch/arm/mach-rockchip/misc.c | 4 ++-- arch/arm/mach-rockchip/px30/clk_px30.c | 2 +- arch/arm/mach-rockchip/rk3036/clk_rk3036.c | 2 +- arch/arm/mach-rockchip/rk3128/clk_rk3128.c | 2 +- arch/arm/mach-rockchip/rk3188/clk_rk3188.c | 2 +- arch/arm/mach-rockchip/rk322x/clk_rk322x.c | 2 +- arch/arm/mach-rockchip/rk3288/clk_rk3288.c | 2 +- arch/arm/mach-rockchip/rk3308/clk_rk3308.c | 2 +- arch/arm/mach-rockchip/rk3328/clk_rk3328.c | 2 +- arch/arm/mach-rockchip/rk3368/clk_rk3368.c | 2 +- arch/arm/mach-rockchip/rk3399/clk_rk3399.c | 4 ++-- arch/arm/mach-rockchip/rv1108/clk_rv1108.c | 2 +- arch/arm/mach-socfpga/clock_manager_agilex.c | 2 +- arch/arm/mach-stm32mp/bsec.c | 2 +- arch/arm/mach-stm32mp/cmd_stm32key.c | 2 +- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 6 +++--- arch/arm/mach-stm32mp/cpu.c | 6 +++--- arch/arm/mach-uniphier/micro-support-card.c | 2 +- arch/arm/mach-zynq/clk.c | 4 ++-- arch/arm/mach-zynq/timer.c | 2 +- arch/mips/mach-mtmips/mt7628/init.c | 2 +- arch/riscv/lib/sifive_clint.c | 2 +- board/dhelectronics/dh_stm32mp1/board.c | 6 +++--- board/google/gru/gru.c | 2 +- board/nvidia/jetson-tk1/jetson-tk1.c | 2 +- board/nvidia/nyan-big/nyan-big.c | 2 +- board/renesas/ulcb/cpld.c | 2 +- board/sifive/fu540/fu540.c | 2 +- board/st/common/cmd_stboard.c | 2 +- board/st/common/stm32mp_dfu.c | 4 ++-- board/st/common/stpmic1.c | 4 ++-- board/st/common/stusb160x.c | 2 +- board/st/stm32mp1/stm32mp1.c | 12 ++++++------ board/ti/j721e/evm.c | 4 ++-- board/toradex/apalis-tk1/apalis-tk1.c | 4 ++-- drivers/clk/clk_stm32mp1.c | 2 +- drivers/clk/clk_zynqmp.c | 2 +- drivers/clk/imx/clk-imx8.c | 2 +- drivers/clk/mediatek/clk-mtk.c | 6 +++--- drivers/clk/sifive/fu540-prci.c | 2 +- drivers/firmware/scmi/scmi_agent-uclass.c | 4 ++-- drivers/gpio/gpio-uclass.c | 2 +- drivers/misc/i2c_eeprom.c | 2 +- drivers/misc/rockchip-efuse.c | 2 +- drivers/misc/stm32mp_fuse.c | 16 ++++++++-------- drivers/mtd/nand/raw/arasan_nfc.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 2 +- drivers/mtd/nand/raw/denali_dt.c | 2 +- drivers/mtd/nand/raw/mxs_nand_dt.c | 2 +- drivers/mtd/nand/raw/octeontx_nand.c | 6 +++--- drivers/mtd/nand/raw/pxa3xx_nand.c | 2 +- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 2 +- drivers/mtd/nand/raw/tegra_nand.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 2 +- drivers/mtd/nand/raw/zynq_nand.c | 2 +- drivers/reset/reset-ast2500.c | 2 +- drivers/video/lg4573.c | 2 +- include/dm/device.h | 2 +- include/dm/uclass.h | 2 +- test/dm/core.c | 2 +- test/dm/test-fdt.c | 6 +++--- 73 files changed, 110 insertions(+), 110 deletions(-)
arch/arm/lib/gic-v3-its.c +5 -5
@@ -43,10 +43,10 @@ static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv)int ret; ret =uclass_get_device_by_driver (UCLASS_IRQ , -DM_GET_DRIVER (arm_gic_v3_its), &dev); +DM_DRIVER_GET (arm_gic_v3_its), &dev);if (ret) {pr_err ("%s: failed to get %s irq device\n" , __func__, -DM_GET_DRIVER (arm_gic_v3_its)->name); +DM_DRIVER_GET (arm_gic_v3_its)->name);return ret; }
@@ -74,17 +74,17 @@ static int gic_v3_its_get_gic_lpi_addr(struct gic_v3_its_priv *priv)int ret; ret =uclass_get_device_by_driver (UCLASS_SYSCON , -DM_GET_DRIVER (gic_lpi_syscon), &dev); +DM_DRIVER_GET (gic_lpi_syscon), &dev);if (ret) {pr_err ("%s: failed to get %s syscon device\n" , __func__, -DM_GET_DRIVER (gic_lpi_syscon)->name); +DM_DRIVER_GET (gic_lpi_syscon)->name);return ret; } regmap =syscon_get_regmap (dev);if (!regmap) {pr_err ("%s: failed to regmap for %s syscon device\n" , __func__, -DM_GET_DRIVER (gic_lpi_syscon)->name); +DM_DRIVER_GET (gic_lpi_syscon)->name);return -ENODEV ; } priv->lpi_base = regmap->ranges[0 ].start;
arch/arm/mach-aspeed/ast2500/clk_ast2500.c +1 -1
@@ -12,7 +12,7 @@int ast_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (aspeed_ast2500_scu), devp); +DM_DRIVER_GET (aspeed_ast2500_scu), devp); }void *ast_get_scu (void )
arch/arm/mach-k3/am6_init.c +1 -1
@@ -238,7 +238,7 @@ void board_init_f(ulong dummy)do_board_detect ();#if defined(CONFIG_CPU_V7R ) && defined(CONFIG_K3_AVS0 ) - ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_GET_DRIVER (k3_avs), + ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_DRIVER_GET (k3_avs), &dev);if (ret)printf ("AVS init failed: %d\n" , ret);
arch/arm/mach-k3/common.c +1 -1
@@ -33,7 +33,7 @@ struct ti_sci_handle *get_ti_sci_handle(void)int ret; ret =uclass_get_device_by_driver (UCLASS_FIRMWARE , -DM_GET_DRIVER (ti_sci), &dev); +DM_DRIVER_GET (ti_sci), &dev);if (ret)panic ("Failed to get SYSFW (%d)\n" , ret);
arch/arm/mach-k3/j721e_init.c +1 -1
@@ -206,7 +206,7 @@ void board_init_f(ulong dummy)do_board_detect ();#if defined(CONFIG_CPU_V7R ) && defined(CONFIG_K3_AVS0 ) - ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_GET_DRIVER (k3_avs), + ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_DRIVER_GET (k3_avs), &dev);if (ret)printf ("AVS init failed: %d\n" , ret);
arch/arm/mach-mediatek/mt7629/init.c +2 -2
@@ -40,7 +40,7 @@ int mtk_pll_early_init(void)int ret, i; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (mtk_clk_apmixedsys), &dev); +DM_DRIVER_GET (mtk_clk_apmixedsys), &dev);if (ret)return ret;
@@ -59,7 +59,7 @@ int mtk_pll_early_init(void)/* setup mcu bus */ ret =uclass_get_device_by_driver (UCLASS_SYSCON , -DM_GET_DRIVER (mtk_mcucfg), &dev); +DM_DRIVER_GET (mtk_mcucfg), &dev);if (ret)return ret;
arch/arm/mach-mediatek/mt8516/init.c +1 -1
@@ -52,7 +52,7 @@ int mtk_pll_early_init(void)int ret, i; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (mtk_clk_apmixedsys), &dev); +DM_DRIVER_GET (mtk_clk_apmixedsys), &dev);if (ret)return ret;
arch/arm/mach-rockchip/misc.c +2 -2
@@ -67,10 +67,10 @@ int rockchip_cpuid_from_efuse(const u32 cpuid_offset,/* retrieve the device */ #if CONFIG_IS_ENABLED (ROCKCHIP_EFUSE ) ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (rockchip_efuse), &dev); +DM_DRIVER_GET (rockchip_efuse), &dev);#elif CONFIG_IS_ENABLED (ROCKCHIP_OTP ) ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (rockchip_otp), &dev); +DM_DRIVER_GET (rockchip_otp), &dev);#endif if (ret) {debug ("%s: could not find efuse device\n" , __func__);
arch/arm/mach-rockchip/px30/clk_px30.c +1 -1
@@ -13,7 +13,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_px30_cru), devp); +DM_DRIVER_GET (rockchip_px30_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3036/clk_rk3036.c +1 -1
@@ -14,7 +14,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3036_cru), devp); +DM_DRIVER_GET (rockchip_rk3036_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3128/clk_rk3128.c +1 -1
@@ -13,7 +13,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3128_cru), devp); +DM_DRIVER_GET (rockchip_rk3128_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3188/clk_rk3188.c +1 -1
@@ -14,7 +14,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3188_cru), devp); +DM_DRIVER_GET (rockchip_rk3188_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk322x/clk_rk322x.c +1 -1
@@ -13,7 +13,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk322x_cru), devp); +DM_DRIVER_GET (rockchip_rk322x_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3288/clk_rk3288.c +1 -1
@@ -14,7 +14,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3288_cru), devp); +DM_DRIVER_GET (rockchip_rk3288_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3308/clk_rk3308.c +1 -1
@@ -13,7 +13,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3308_cru), devp); +DM_DRIVER_GET (rockchip_rk3308_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3328/clk_rk3328.c +1 -1
@@ -12,7 +12,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3328_cru), devp); +DM_DRIVER_GET (rockchip_rk3328_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3368/clk_rk3368.c +1 -1
@@ -14,7 +14,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3368_cru), devp); +DM_DRIVER_GET (rockchip_rk3368_cru), devp); }void *rockchip_get_cru (void )
arch/arm/mach-rockchip/rk3399/clk_rk3399.c +2 -2
@@ -14,7 +14,7 @@static int rockchip_get_cruclk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (clk_rk3399), devp); +DM_DRIVER_GET (clk_rk3399), devp); }void *rockchip_get_cru (void )
@@ -35,7 +35,7 @@ void *rockchip_get_cru(void)static int rockchip_get_pmucruclk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (rockchip_rk3399_pmuclk), devp); +DM_DRIVER_GET (rockchip_rk3399_pmuclk), devp); }void *rockchip_get_pmucru (void )
arch/arm/mach-rockchip/rv1108/clk_rv1108.c +1 -1
@@ -14,7 +14,7 @@int rockchip_get_clk (struct udevice **devp) {return uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (clk_rv1108), devp); +DM_DRIVER_GET (clk_rv1108), devp); }void *rockchip_get_cru (void )
arch/arm/mach-socfpga/clock_manager_agilex.c +1 -1
@@ -24,7 +24,7 @@ static ulong cm_get_rate_dm(u32 id)int ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (socfpga_agilex_clk), +DM_DRIVER_GET (socfpga_agilex_clk), &dev);if (ret)return 0 ;
arch/arm/mach-stm32mp/bsec.c +1 -1
@@ -525,7 +525,7 @@ bool bsec_dbgswenable(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), &dev); +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret || !dev) {pr_debug ("bsec driver not available\n" );return false;
arch/arm/mach-stm32mp/cmd_stm32key.c +1 -1
@@ -31,7 +31,7 @@ static void fuse_hash_value(u32 addr, bool print)int i, ret; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret) {pr_err ("Can't find stm32mp_bsec driver\n" );
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +3 -3
@@ -1340,7 +1340,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset, u8 *buffer,pr_debug ("%s: %x %lx\n" , __func__, offset, *size); ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
@@ -1351,7 +1351,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset, u8 *buffer,memset (data->pmic_part,0 ,PMIC_SIZE ); ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
@@ -1389,7 +1389,7 @@ int stm32prog_pmic_start(struct stm32prog_data *data) } ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
arch/arm/mach-stm32mp/cpu.c +3 -3
@@ -318,7 +318,7 @@ static u32 get_otp(int index, int shift, int mask)u32 otp =0 ; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (!ret)
@@ -563,7 +563,7 @@ __weak int setup_mac_address(void)return 0 ; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
@@ -601,7 +601,7 @@ static int setup_serial_number(void)return 0 ; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
arch/arm/mach-uniphier/micro-support-card.c +1 -1
@@ -95,7 +95,7 @@ void support_card_init(void)/* The system bus must be initialized for access to the support card. */ ret =uclass_get_device_by_driver (UCLASS_SIMPLE_BUS , -DM_GET_DRIVER (uniphier_system_bus_driver), +DM_DRIVER_GET (uniphier_system_bus_driver), &dev);if (ret)return ;
arch/arm/mach-zynq/clk.c +2 -2
@@ -40,7 +40,7 @@ int set_cpu_clk_info(void)int i, ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (zynq_clk), &dev); +DM_DRIVER_GET (zynq_clk), &dev);if (ret)return ret;
@@ -75,7 +75,7 @@ int soc_clk_dump(void)int i, ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (zynq_clk), &dev); +DM_DRIVER_GET (zynq_clk), &dev);if (ret)return ret;
arch/arm/mach-zynq/timer.c +1 -1
@@ -68,7 +68,7 @@ int timer_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (zynq_clk), &dev); +DM_DRIVER_GET (zynq_clk), &dev);if (ret)return ret;
arch/mips/mach-mtmips/mt7628/init.c +1 -1
@@ -74,7 +74,7 @@ int print_cpuinfo(void) ddr ?"" :"2" , chipmode &0x01 ?4 :3 , chipmode & 0x02 ? "XTAL" : "CPLL"); - ret =uclass_get_device_by_driver (UCLASS_CLK ,DM_GET_DRIVER (mt7628_clk), + ret =uclass_get_device_by_driver (UCLASS_CLK ,DM_DRIVER_GET (mt7628_clk), &clkdev);if (ret)return ret;
arch/riscv/lib/sifive_clint.c +1 -1
@@ -25,7 +25,7 @@ int riscv_init_ipi(void)struct udevice *dev; ret =uclass_get_device_by_driver (UCLASS_TIMER , -DM_GET_DRIVER (sifive_clint), &dev); +DM_DRIVER_GET (sifive_clint), &dev);if (ret)return ret;
board/dhelectronics/dh_stm32mp1/board.c +3 -3
@@ -343,7 +343,7 @@ int g_dnl_board_usb_cable_connected(void)int ret; ret =uclass_get_device_by_driver (UCLASS_USB_GADGET_GENERIC , -DM_GET_DRIVER (dwc2_udc_otg), +DM_DRIVER_GET (dwc2_udc_otg), &dwc2_udc_otg);if (!ret)debug ("dwc2_udc_otg init failed\n" );
@@ -475,11 +475,11 @@ static void sysconf_init(void)* but this value need to be consistent with board design */ ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (stm32mp_pwr_pmic), +DM_DRIVER_GET (stm32mp_pwr_pmic), &pwr_dev);if (!ret) { ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret) {pr_err ("Can't find stm32mp_bsec driver\n" );
board/google/gru/gru.c +1 -1
@@ -45,7 +45,7 @@ int board_early_init_r(void)* setting up. */ ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (clk_rk3399), &clk); +DM_DRIVER_GET (clk_rk3399), &clk);if (ret) {debug ("%s: CLK init failed: %d\n" , __func__, ret);return ret;
board/nvidia/jetson-tk1/jetson-tk1.c +1 -1
@@ -60,7 +60,7 @@ int tegra_pcie_board_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_as3722), &dev); +DM_DRIVER_GET (pmic_as3722), &dev);if (ret) {debug ("%s: Failed to find PMIC\n" , __func__);return ret;
board/nvidia/nyan-big/nyan-big.c +1 -1
@@ -52,7 +52,7 @@ int tegra_lcd_pmic_init(int board_id)int ret; ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_as3722), &dev); +DM_DRIVER_GET (pmic_as3722), &dev);if (ret) {debug ("%s: Failed to find PMIC\n" , __func__);return ret;
board/renesas/ulcb/cpld.c +1 -1
@@ -91,7 +91,7 @@ static int do_cpld(struct cmd_tbl *cmdtp, int flag, int argc,int ret; ret =uclass_get_device_by_driver (UCLASS_SYSRESET , -DM_GET_DRIVER (sysreset_renesas_ulcb), +DM_DRIVER_GET (sysreset_renesas_ulcb), &dev);if (ret)return ret;
board/sifive/fu540/fu540.c +1 -1
@@ -58,7 +58,7 @@ static u32 fu540_read_serialnum(void)/* init OTP */ ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (sifive_otp), &dev); +DM_DRIVER_GET (sifive_otp), &dev);if (ret) {debug ("%s: could not find otp device\n" , __func__);
board/st/common/cmd_stboard.c +1 -1
@@ -85,7 +85,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, int argc,return CMD_RET_USAGE ; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev); ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD),
board/st/common/stm32mp_dfu.c +2 -2
@@ -163,7 +163,7 @@ static int dfu_otp_read(u64 offset, u8 *buffer, long *size)int ret; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
@@ -184,7 +184,7 @@ static int dfu_pmic_read(u64 offset, u8 *buffer, long *size)struct udevice *dev; ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
board/st/common/stpmic1.c +2 -2
@@ -20,7 +20,7 @@ int board_ddr_power_init(enum ddr_type ddr_type)u32 buck2; ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_stpmic1), &dev); +DM_DRIVER_GET (pmic_stpmic1), &dev);if (ret)/* No PMIC on board */ return 0 ;
@@ -187,7 +187,7 @@ void stpmic1_init(u32 voltage_mv)struct udevice *dev;if (uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_stpmic1), &dev)) +DM_DRIVER_GET (pmic_stpmic1), &dev))return ;/* update VDDCORE = BUCK1 */
board/st/common/stusb160x.c +1 -1
@@ -22,7 +22,7 @@ int stusb160x_cable_connected(void)int ret; ret =uclass_get_device_by_driver (UCLASS_I2C_GENERIC , -DM_GET_DRIVER (stusb160x), +DM_DRIVER_GET (stusb160x), &dev);if (ret <0 )return ret;
board/st/stm32mp1/stm32mp1.c +6 -6
@@ -116,7 +116,7 @@ int checkboard(void)/* display the STMicroelectronics board identification */ if (CONFIG_IS_ENABLED (CMD_STBOARD )) { ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (!ret) ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
@@ -196,7 +196,7 @@ int g_dnl_board_usb_cable_connected(void)return ret; ret =uclass_get_device_by_driver (UCLASS_USB_GADGET_GENERIC , -DM_GET_DRIVER (dwc2_udc_otg), +DM_DRIVER_GET (dwc2_udc_otg), &dwc2_udc_otg);if (!ret)debug ("dwc2_udc_otg init failed\n" );
@@ -464,11 +464,11 @@ static void sysconf_init(void)* but this value need to be consistent with board design */ ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (stm32mp_pwr_pmic), +DM_DRIVER_GET (stm32mp_pwr_pmic), &pwr_dev);if (!ret &&IS_ENABLED (CONFIG_DM_REGULATOR )) { ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret) {pr_err ("Can't find stm32mp_bsec driver\n" );
@@ -618,7 +618,7 @@ static void board_ev1_init(void)struct udevice *dev;/* configure IRQ line on EV1 for touchscreen before LCD reset */ -uclass_get_device_by_driver (UCLASS_NOP ,DM_GET_DRIVER (goodix), &dev); +uclass_get_device_by_driver (UCLASS_NOP ,DM_DRIVER_GET (goodix), &dev); }/* board dependent setup after realloc */
@@ -680,7 +680,7 @@ int board_late_init(void) } } ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (!ret)
board/ti/j721e/evm.c +2 -2
@@ -411,7 +411,7 @@ void spl_board_init(void)#ifdef CONFIG_ESM_K3 if (board_ti_k3_is ("J721EX-PM2-SOM" )) { ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (k3_esm), &dev); +DM_DRIVER_GET (k3_esm), &dev);if (ret)printf ("ESM init failed: %d\n" , ret); }
@@ -420,7 +420,7 @@ void spl_board_init(void)#ifdef CONFIG_ESM_PMIC if (board_ti_k3_is ("J721EX-PM2-SOM" )) { ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (pmic_esm), +DM_DRIVER_GET (pmic_esm), &dev);if (ret)printf ("ESM PMIC init failed: %d\n" , ret);
board/toradex/apalis-tk1/apalis-tk1.c +2 -2
@@ -155,7 +155,7 @@ int tegra_pcie_board_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_as3722), &dev); +DM_DRIVER_GET (pmic_as3722), &dev);if (ret) {pr_err ("failed to find AS3722 PMIC: %d\n" , ret);return ret;
@@ -194,7 +194,7 @@ void tegra_pcie_board_port_reset(struct tegra_pcie_port *port)int ret; ret =uclass_get_device_by_driver (UCLASS_PMIC , -DM_GET_DRIVER (pmic_as3722), +DM_DRIVER_GET (pmic_as3722), &dev);if (ret) {debug ("%s: Failed to find PMIC\n" , __func__);
drivers/clk/clk_stm32mp1.c +1 -1
@@ -2253,7 +2253,7 @@ int soc_clk_dump(void)int ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (stm32mp1_clock), +DM_DRIVER_GET (stm32mp1_clock), &dev);if (ret)return ret;
drivers/clk/clk_zynqmp.c +1 -1
@@ -617,7 +617,7 @@ int soc_clk_dump(void)int i, ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (zynqmp_clk), &dev); +DM_DRIVER_GET (zynqmp_clk), &dev);if (ret)return ret;
drivers/clk/imx/clk-imx8.c +1 -1
@@ -51,7 +51,7 @@ int soc_clk_dump(void)int i, ret; ret =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (imx8_clk), &dev); +DM_DRIVER_GET (imx8_clk), &dev);if (ret)return ret;
drivers/clk/mediatek/clk-mtk.c +3 -3
@@ -296,7 +296,7 @@ static ulong mtk_topckgen_get_factor_rate(struct clk *clk, u32 off)switch (fdiv->flags &CLK_PARENT_MASK ) {case CLK_PARENT_APMIXED : rate =mtk_clk_find_parent_rate (clk, fdiv->parent, -DM_GET_DRIVER (mtk_clk_apmixedsys)); +DM_DRIVER_GET (mtk_clk_apmixedsys));break ;case CLK_PARENT_TOPCKGEN : rate =mtk_clk_find_parent_rate (clk, fdiv->parent,NULL );
@@ -474,11 +474,11 @@ static ulong mtk_clk_gate_get_rate(struct clk *clk)switch (gate->flags &CLK_PARENT_MASK ) {case CLK_PARENT_APMIXED :return mtk_clk_find_parent_rate (clk, gate->parent, -DM_GET_DRIVER (mtk_clk_apmixedsys)); +DM_DRIVER_GET (mtk_clk_apmixedsys));break ;case CLK_PARENT_TOPCKGEN :return mtk_clk_find_parent_rate (clk, gate->parent, -DM_GET_DRIVER (mtk_clk_topckgen)); +DM_DRIVER_GET (mtk_clk_topckgen));break ;default :
drivers/clk/sifive/fu540-prci.c +1 -1
@@ -537,7 +537,7 @@ static int __prci_consumer_reset(const char *rst_name, bool trigger)int ret; ret =uclass_get_device_by_driver (UCLASS_RESET , -DM_GET_DRIVER (sifive_reset), +DM_DRIVER_GET (sifive_reset), &dev);if (ret) {dev_err (dev,"Reset driver not found: %d\n" , ret);
drivers/firmware/scmi/scmi_agent-uclass.c +2 -2
@@ -73,11 +73,11 @@ static int scmi_bind_protocols(struct udevice *dev)switch (protocol_id) {case SCMI_PROTOCOL_ID_CLOCK :if (IS_ENABLED (CONFIG_CLK_SCMI )) - drv =DM_GET_DRIVER (scmi_clock); + drv =DM_DRIVER_GET (scmi_clock);break ;case SCMI_PROTOCOL_ID_RESET_DOMAIN :if (IS_ENABLED (CONFIG_RESET_SCMI )) - drv =DM_GET_DRIVER (scmi_reset_domain); + drv =DM_DRIVER_GET (scmi_reset_domain);break ;default :break ;
drivers/gpio/gpio-uclass.c +1 -1
@@ -306,7 +306,7 @@ int gpio_hog_probe_all(void)for (uclass_first_device (UCLASS_NOP , &dev); dev;uclass_find_next_device (&dev)) { -if (dev->driver ==DM_GET_DRIVER (gpio_hog)) { +if (dev->driver ==DM_DRIVER_GET (gpio_hog)) { ret =device_probe (dev);if (ret) { printf("Failed to probe device %s err: %d\n",
drivers/misc/i2c_eeprom.c +1 -1
@@ -131,7 +131,7 @@ static int i2c_eeprom_std_bind(struct udevice *dev)if (!name)continue ; -device_bind (dev,DM_GET_DRIVER (i2c_eeprom_partition), name, +device_bind (dev,DM_DRIVER_GET (i2c_eeprom_partition), name,NULL , partition,NULL ); }
drivers/misc/rockchip-efuse.c +1 -1
@@ -58,7 +58,7 @@ static int dump_efuses(struct cmd_tbl *cmdtp, int flag,/* retrieve the device */ ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (rockchip_efuse), &dev); +DM_DRIVER_GET (rockchip_efuse), &dev);if (ret) {printf ("%s: no misc-device found\n" , __func__);return 0 ;
drivers/misc/stm32mp_fuse.c +8 -8
@@ -26,7 +26,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)switch (bank) {case STM32MP_OTP_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
@@ -41,7 +41,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
@@ -71,7 +71,7 @@ int fuse_prog(u32 bank, u32 word, u32 val)switch (bank) {case STM32MP_OTP_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
@@ -86,7 +86,7 @@ int fuse_prog(u32 bank, u32 word, u32 val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
@@ -115,7 +115,7 @@ int fuse_sense(u32 bank, u32 word, u32 *val)switch (bank) {case STM32MP_OTP_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
@@ -129,7 +129,7 @@ int fuse_sense(u32 bank, u32 word, u32 *val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
@@ -159,7 +159,7 @@ int fuse_override(u32 bank, u32 word, u32 val)switch (bank) {case STM32MP_OTP_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), +DM_DRIVER_GET (stm32mp_bsec), &dev);if (ret)return ret;
@@ -174,7 +174,7 @@ int fuse_override(u32 bank, u32 word, u32 val)#ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK : ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stpmic1_nvm), +DM_DRIVER_GET (stpmic1_nvm), &dev);if (ret)return ret;
drivers/mtd/nand/raw/arasan_nfc.c +1 -1
@@ -1319,7 +1319,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (arasan_nand), &dev); +DM_DRIVER_GET (arasan_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret); }
drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c +1 -1
@@ -118,7 +118,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (bcm63158_nand), &dev); +DM_DRIVER_GET (bcm63158_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c +1 -1
@@ -111,7 +111,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (bcm6368_nand), &dev); +DM_DRIVER_GET (bcm6368_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c +1 -1
@@ -117,7 +117,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (bcm68360_nand), &dev); +DM_DRIVER_GET (bcm68360_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c +1 -1
@@ -117,7 +117,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (bcm6838_nand), &dev); +DM_DRIVER_GET (bcm6838_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c +1 -1
@@ -118,7 +118,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (bcm6858_nand), &dev); +DM_DRIVER_GET (bcm6858_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/davinci_nand.c +1 -1
@@ -825,7 +825,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (davinci_nand), &dev); +DM_DRIVER_GET (davinci_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s: %d\n" , dev->name, ret); }
drivers/mtd/nand/raw/denali_dt.c +1 -1
@@ -181,7 +181,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (denali_nand_dt), +DM_DRIVER_GET (denali_nand_dt), &dev);if (ret && ret != -ENODEV ) pr_err("Failed to initialize Denali NAND controller. (error %d)\n",
drivers/mtd/nand/raw/mxs_nand_dt.c +1 -1
@@ -177,7 +177,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (mxs_nand_dt), +DM_DRIVER_GET (mxs_nand_dt), &dev);if (ret && ret != -ENODEV ) pr_err("Failed to initialize MXS NAND controller. (error %d)\n",
drivers/mtd/nand/raw/octeontx_nand.c +3 -3
@@ -2233,14 +2233,14 @@ void board_nand_init(void)if (IS_ENABLED (CONFIG_NAND_OCTEONTX_HW_ECC )) { ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (octeontx_pci_bchpf), +DM_DRIVER_GET (octeontx_pci_bchpf), &dev);if (ret && ret != -ENODEV ) {pr_err ("Failed to initialize OcteonTX BCH PF controller. (error %d)\n" , ret); } ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (octeontx_pci_bchvf), +DM_DRIVER_GET (octeontx_pci_bchvf), &dev);if (ret && ret != -ENODEV ) { pr_err("Failed to initialize OcteonTX BCH VF controller. (error %d)\n",
@@ -2249,7 +2249,7 @@ void board_nand_init(void) } ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (octeontx_pci_nand), +DM_DRIVER_GET (octeontx_pci_nand), &dev);if (ret && ret != -ENODEV ) pr_err("Failed to initialize OcteonTX NAND controller. (error %d)\n",
drivers/mtd/nand/raw/pxa3xx_nand.c +1 -1
@@ -1947,7 +1947,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (pxa3xx_nand), &dev); +DM_DRIVER_GET (pxa3xx_nand), &dev);if (ret && ret != -ENODEV ) {pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/stm32_fmc2_nand.c +1 -1
@@ -1042,7 +1042,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (stm32_fmc2_nfc), +DM_DRIVER_GET (stm32_fmc2_nfc), &dev);if (ret && ret != -ENODEV ) pr_err("Failed to initialize STM32 FMC2 NFC controller. (error %d)\n",
drivers/mtd/nand/raw/tegra_nand.c +1 -1
@@ -999,7 +999,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (tegra_nand), &dev); +DM_DRIVER_GET (tegra_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret);
drivers/mtd/nand/raw/vf610_nfc.c +1 -1
@@ -794,7 +794,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (vf610_nfc_dt), +DM_DRIVER_GET (vf610_nfc_dt), &dev);if (ret && ret != -ENODEV ) pr_err("Failed to initialize NAND controller. (error %d)\n",
drivers/mtd/nand/raw/zynq_nand.c +1 -1
@@ -1295,7 +1295,7 @@ void board_nand_init(void)int ret; ret =uclass_get_device_by_driver (UCLASS_MTD , -DM_GET_DRIVER (zynq_nand), &dev); +DM_DRIVER_GET (zynq_nand), &dev);if (ret && ret != -ENODEV )pr_err ("Failed to initialize %s. (error %d)\n" , dev->name, ret); }
drivers/reset/reset-ast2500.c +1 -1
@@ -72,7 +72,7 @@ static int ast2500_reset_probe(struct udevice *dev)/* get SCU base from clock device */ rc =uclass_get_device_by_driver (UCLASS_CLK , -DM_GET_DRIVER (aspeed_ast2500_scu), &scu_dev); +DM_DRIVER_GET (aspeed_ast2500_scu), &scu_dev);if (rc) {debug ("%s: clock device not found, rc=%d\n" , __func__, rc);return rc;
drivers/video/lg4573.c +1 -1
@@ -219,7 +219,7 @@ static int do_lgset(struct cmd_tbl *cmdtp, int flag, int argc,int ret; ret =uclass_get_device_by_driver (UCLASS_DISPLAY , -DM_GET_DRIVER (lg4573_lcd), &dev); +DM_DRIVER_GET (lg4573_lcd), &dev);if (ret) {printf ("%s: Could not get lg4573 device\n" , __func__);return ret;
include/dm/device.h +1 -1
@@ -335,7 +335,7 @@ struct driver { ll_entry_declare(struct driver, __name, driver)/* Get a pointer to a given driver */ -#define DM_GET_DRIVER (__name) \ +#define DM_DRIVER_GET (__name) \ ll_entry_get(struct driver, __name, driver)/**
include/dm/uclass.h +1 -1
@@ -264,7 +264,7 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,* uclass_get_device_by_driver() - Get a uclass device for a driver * * This searches the devices in the uclass for one that uses the given -* driver. Use DM_GET_DRIVER(name) for the @drv argument, where 'name' is +* driver. Use DM_DRIVER_GET(name) for the @drv argument, where 'name' is * the driver name - as used in U_BOOT_DRIVER(name). * * The device is probed to activate it ready for use.
test/dm/core.c +1 -1
@@ -1052,7 +1052,7 @@ static int dm_test_inactive_child(struct unit_test_state *uts)*/ ut_asserteq (-ENODEV ,device_find_first_inactive_child (parent,UCLASS_TEST , &dev1)); -ut_assertok (device_bind (parent,DM_GET_DRIVER (test_drv), +ut_assertok (device_bind (parent,DM_DRIVER_GET (test_drv),"test_child" ,0 ,ofnode_null (), &dev1)); ut_assertok(device_find_first_inactive_child(parent, UCLASS_TEST,
test/dm/test-fdt.c +3 -3
@@ -328,7 +328,7 @@ static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts)/* Check creating a device with an alias */ node =ofnode_path ("/some-bus/c-test at 1" ); -ut_assertok (device_bind (dm_root (),DM_GET_DRIVER (testfdt_drv), +ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (testfdt_drv),"c-test at 1" ,NULL , node, &dev));ut_asserteq (12 ,dev_seq (dev));ut_assertok (uclass_get_device_by_seq (UCLASS_TEST_FDT ,12 , &dev));
@@ -348,11 +348,11 @@ static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts)* * So next available is 19 */ -ut_assertok (device_bind (dm_root (),DM_GET_DRIVER (testfdt_drv), +ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (testfdt_drv),"fred" ,NULL ,ofnode_null (), &dev));ut_asserteq (19 ,dev_seq (dev)); -ut_assertok (device_bind (dm_root (),DM_GET_DRIVER (testfdt_drv), +ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (testfdt_drv),"fred2" ,NULL ,ofnode_null (), &dev));ut_asserteq (20 ,dev_seq (dev));
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 11/49 dm: Rename U_BOOT_DRIVER_ALIAS to DM_DRIVER_ALIAS
In reply to Simon GlassWe use the U_BOOT_ prefix (i.e. U_BOOT_DRIVER) to declare a driver but in every other case we just use DM_. Update the alias macros to use the DM_ prefix.
We could perhaps rename U_BOOT_DRIVER() to DM_DRIVER(), but this macro is widely used and there is at least some benefit to indicating it us a U-Boot driver, particularly for code ported from Linux. So for now, let's keep that name.
---
doc/driver-model/of-plat.rst | 6 +++--- drivers/gpio/mxc_gpio.c | 2 +- drivers/gpio/mxs_gpio.c | 2 +- drivers/gpio/sandbox.c | 2 +- drivers/i2c/rk_i2c.c | 2 +- drivers/mmc/fsl_esdhc_imx.c | 2 +- drivers/mmc/mxsmmc.c | 2 +- drivers/mmc/rockchip_dw_mmc.c | 4 ++-- drivers/mtd/spi/sf_probe.c | 2 +- drivers/pinctrl/nxp/pinctrl-imx6.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 | 6 +++--- drivers/spi/mxs_spi.c | 2 +- drivers/spi/rk_spi.c | 2 +- include/dm/device.h | 2 +- tools/dtoc/dtb_platdata.py | 6 +++--- tools/dtoc/dtoc_test_scan_drivers.cxx | 2 +- 19 files changed, 26 insertions(+), 26 deletions(-)
doc/driver-model/of-plat.rst +3 -3
@@ -184,7 +184,7 @@ 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 +In order to make this a bit more flexible DM_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.
@@ -195,7 +195,7 @@ fix-ups required by dtoc. It is not currently used. The values in 'clocks' are the index of the driver_info for the target device followed by any phandle arguments. This is used to support device_get_by_driver_info_idx(). -During the build process dtoc parses both U_BOOT_DRIVER and U_BOOT_DRIVER_ALIAS +During the build process dtoc parses both U_BOOT_DRIVER and DM_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
@@ -297,7 +297,7 @@ For example: .plat_auto = sizeof(struct mmc_plat), }; - U_BOOT_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */ + DM_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */ Note that struct mmc_plat 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
drivers/gpio/mxc_gpio.c +1 -1
@@ -345,7 +345,7 @@ U_BOOT_DRIVER(gpio_mxc) = { .bind = mxc_gpio_bind, }; -U_BOOT_DRIVER_ALIAS(gpio_mxc, fsl_imx6q_gpio) +DM_DRIVER_ALIAS(gpio_mxc, fsl_imx6q_gpio)#if !CONFIG_IS_ENABLED (OF_CONTROL ) static const struct mxc_gpio_plat mxc_plat[] = {
drivers/gpio/mxs_gpio.c +1 -1
@@ -306,5 +306,5 @@ U_BOOT_DRIVER(fsl_imx23_gpio) = {#endif }; -U_BOOT_DRIVER_ALIAS(fsl_imx23_gpio, fsl_imx28_gpio) +DM_DRIVER_ALIAS(fsl_imx23_gpio, fsl_imx28_gpio)#endif /* DM_GPIO */
drivers/gpio/sandbox.c +1 -1
@@ -327,7 +327,7 @@ U_BOOT_DRIVER(sandbox_gpio) = { ACPI_OPS_PTR(&gpio_sandbox_acpi_ops) }; -U_BOOT_DRIVER_ALIAS (sandbox_gpio, sandbox_gpio_alias) +DM_DRIVER_ALIAS (sandbox_gpio, sandbox_gpio_alias)/* pincontrol: used only to check GPIO pin configuration (pinmux command) */
drivers/i2c/rk_i2c.c +1 -1
@@ -495,4 +495,4 @@ U_BOOT_DRIVER(rockchip_rk3066_i2c) = { .ops = &rockchip_i2c_ops, }; -U_BOOT_DRIVER_ALIAS (rockchip_rk3066_i2c, rockchip_rk3288_i2c) +DM_DRIVER_ALIAS (rockchip_rk3066_i2c, rockchip_rk3288_i2c)
drivers/mmc/fsl_esdhc_imx.c +1 -1
@@ -1711,5 +1711,5 @@ U_BOOT_DRIVER(fsl_esdhc) = { .priv_auto = sizeof(struct fsl_esdhc_priv), }; -U_BOOT_DRIVER_ALIAS(fsl_esdhc, fsl_imx6q_usdhc) +DM_DRIVER_ALIAS(fsl_esdhc, fsl_imx6q_usdhc)#endif
drivers/mmc/mxsmmc.c +1 -1
@@ -722,5 +722,5 @@ U_BOOT_DRIVER(fsl_imx23_mmc) = { .plat_auto = sizeof(struct mxsmmc_plat), }; -U_BOOT_DRIVER_ALIAS(fsl_imx23_mmc, fsl_imx28_mmc) +DM_DRIVER_ALIAS(fsl_imx23_mmc, fsl_imx28_mmc)#endif /* CONFIG_DM_MMC */
drivers/mmc/rockchip_dw_mmc.c +2 -2
@@ -180,8 +180,8 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = { .plat_auto = 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) +DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) +DM_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 +1 -1
@@ -170,6 +170,6 @@ U_BOOT_DRIVER(jedec_spi_nor) = { .ops = &spi_flash_std_ops, }; -U_BOOT_DRIVER_ALIAS(jedec_spi_nor, spansion_m25p16) +DM_DRIVER_ALIAS(jedec_spi_nor, spansion_m25p16)#endif /* CONFIG_DM_SPI_FLASH */
drivers/pinctrl/nxp/pinctrl-imx6.c +1 -1
@@ -52,4 +52,4 @@ U_BOOT_DRIVER(fsl_imx6q_iomuxc) = { .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRIVER_ALIAS (fsl_imx6q_iomuxc, fsl_imx6dl_iomuxc) +DM_DRIVER_ALIAS (fsl_imx6q_iomuxc, fsl_imx6dl_iomuxc)
drivers/pinctrl/nxp/pinctrl-mxs.c +1 -1
@@ -192,4 +192,4 @@ U_BOOT_DRIVER(fsl_imx23_pinctrl) = { .ops = &mxs_pinctrl_ops, }; -U_BOOT_DRIVER_ALIAS (fsl_imx23_pinctrl, fsl_imx28_pinctrl) +DM_DRIVER_ALIAS (fsl_imx23_pinctrl, fsl_imx28_pinctrl)
drivers/pinctrl/pinctrl-at91.c +1 -1
@@ -528,4 +528,4 @@ U_BOOT_DRIVER(atmel_sama5d3_pinctrl) = { .ops = &at91_pinctrl_ops, }; -U_BOOT_DRIVER_ALIAS (atmel_sama5d3_pinctrl, atmel_at91rm9200_pinctrl) +DM_DRIVER_ALIAS (atmel_sama5d3_pinctrl, atmel_at91rm9200_pinctrl)
drivers/power/pmic/rk8xx.c +1 -1
@@ -195,4 +195,4 @@ U_BOOT_DRIVER(rockchip_rk805) = { .ops = &rk8xx_ops, }; -U_BOOT_DRIVER_ALIAS (rockchip_rk805, rockchip_rk808) +DM_DRIVER_ALIAS (rockchip_rk805, rockchip_rk808)
drivers/serial/ns16550.c +3 -3
@@ -621,9 +621,9 @@ U_BOOT_DRIVER(ns16550_serial) = {#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) +DM_DRIVER_ALIAS(ns16550_serial, rockchip_rk3328_uart) +DM_DRIVER_ALIAS(ns16550_serial, rockchip_rk3368_uart) +DM_DRIVER_ALIAS(ns16550_serial, ti_da830_uart)#endif #endif /* SERIAL_PRESENT */
drivers/spi/mxs_spi.c +1 -1
@@ -493,4 +493,4 @@ U_BOOT_DRIVER(fsl_imx23_spi) = { .probe = mxs_spi_probe, }; -U_BOOT_DRIVER_ALIAS (fsl_imx23_spi, fsl_imx28_spi) +DM_DRIVER_ALIAS (fsl_imx23_spi, fsl_imx28_spi)
drivers/spi/rk_spi.c +1 -1
@@ -565,4 +565,4 @@ U_BOOT_DRIVER(rockchip_rk3288_spi) = { .probe = rockchip_spi_probe, }; -U_BOOT_DRIVER_ALIAS (rockchip_rk3288_spi, rockchip_rk3368_spi) +DM_DRIVER_ALIAS (rockchip_rk3288_spi, rockchip_rk3368_spi)
include/dm/device.h +1 -1
@@ -343,7 +343,7 @@ struct driver {* produce no code but its information will be parsed by tools like * dtoc */ -#define U_BOOT_DRIVER_ALIAS (__name, __alias) +#define DM_DRIVER_ALIAS (__name, __alias)/** * dev_get_plat() - Get the platform data for a device
tools/dtoc/dtb_platdata.py +3 -3
@@ -187,7 +187,7 @@ class DtbPlatdata(): value: Driver for that driver _driver_aliases: Dict that holds aliases for driver names key: Driver alias declared with - U_BOOT_DRIVER_ALIAS(driver_alias, driver_name) + DM_DRIVER_ALIAS(driver_alias, driver_name) value: Driver name declared with U_BOOT_DRIVER(driver_name) _drivers_additional: List of additional drivers to use during scanning _dirname: Directory to hold output files, or None for none (all files
@@ -416,9 +416,9 @@ class DtbPlatdata(): self._drivers[driver] = Driver(driver) # The following re will search for driver aliases declared as - # U_BOOT_DRIVER_ALIAS(alias, driver_name) + # DM_DRIVER_ALIAS(alias, driver_name) driver_aliases = re.findall( - r'U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)', + r'DM_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)', buff) for alias in driver_aliases: # pragma: no cover
tools/dtoc/dtoc_test_scan_drivers.cxx +1 -1
@@ -1 +1 @@ -U_BOOT_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2) +DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 12/49 concurrencytest: Fix Python3 warning
In reply to Simon GlassThis gives a warning in some situations:
File "tools/dtoc/../concurrencytest/concurrencytest.py", line 95,
in do_fork
stream = os.fdopen(c2pread, 'rb', 1) File "/usr/lib/python3.8/os.py", line 1023, in fdopen
return io.open(fd, *args, **kwargs)
RuntimeWarning: line buffering (buffering=1) isn't supported in binary
mode, the default buffer size will be used
Fix this by dropping the line-buffer parameter.
---
tools/concurrencytest/concurrencytest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/concurrencytest/concurrencytest.py +2 -2
@@ -68,7 +68,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT): pid = os.fork() if pid == 0: try: - stream = os.fdopen(c2pwrite, 'wb', 1) + stream = os.fdopen(c2pwrite, 'wb') os.close(c2pread) # Leave stderr and stdout open so we can see test noise # Close stdin so that the child goes away if it decides to
@@ -92,7 +92,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT): os._exit(0) else: os.close(c2pwrite) - stream = os.fdopen(c2pread, 'rb', 1) + stream = os.fdopen(c2pread, 'rb') test = ProtocolTestCase(stream) result.append(test) return result
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 13/49 dtoc: Run tests using test_util
In reply to Simon GlassUse the standard function for running tests and reported results. This allows the tests to run in parallel, which is a significant speed-up on most machines (e.g. 4.5 seconds -> 1.5s on mine).
---
tools/dtoc/main.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
tools/dtoc/main.py +10 -21
@@ -38,10 +38,11 @@ sys.path.insert(0, os.path.join(our_path, from dtoc import dtb_platdata from patman import test_util -def run_tests(args): +def run_tests(processes, args): """Run all the test we have for dtoc Args: + processes: Number of processes to use to run tests (None=same as #CPUs) args: List of positional args provided to dtoc. This can hold a test name to execute (as in 'dtoc -t test_empty_file', for example) """
@@ -50,25 +51,13 @@ def run_tests(args): result = unittest.TestResult() sys.argv = [sys.argv[0]] test_name = args and args[0] or None - for module in (test_dtoc.TestDtoc,): - if test_name: - try: - suite = unittest.TestLoader().loadTestsFromName(test_name, module) - except AttributeError: - continue - else: - suite = unittest.TestLoader().loadTestsFromTestCase(module) - suite.run(result) - - print(result) - for _, err in result.errors: - print(err) - for _, err in result.failures: - print(err) - if result.errors or result.failures: - print('dtoc tests FAILED') - return 1 - return 0 + + test_util.RunTestSuites( + result, debug=True, verbosity=1, test_preserve_dirs=False, + processes=processes, test_name=test_name, toolpath=[], + test_class_list=[test_dtoc.TestDtoc,]) + + return test_util.ReportResult('binman', test_name, result) def RunTestCoverage(): """Run the tests and check that we get 100% coverage"""
@@ -103,7 +92,7 @@ parser.add_option('-T', '--test-coverage', action='store_true', # Run our meagre tests if options.test: - ret_code = run_tests(args) + ret_code = run_tests(options.processes, args) sys.exit(ret_code) elif options.test_coverage:
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 14/49 dtoc: Add a header comment to each generated file
In reply to Simon GlassIt is currently fairly obvious what the two generated files are for, but this will change as more are added. It is helpful for readers to describe the purpose of each file.
Add a header commment field to OutputFile and use it to generate a comment at the top of each file.
---
tools/dtoc/dtb_platdata.py | 30 ++++++++++++++++++++---------- tools/dtoc/test_dtoc.py | 6 ++++-- 2 files changed, 24 insertions(+), 12 deletions(-)
tools/dtoc/dtb_platdata.py +20 -10
@@ -56,8 +56,10 @@ class Ftype(IntEnum): # This holds information about each type of output file dtoc can create # type: Type of file (Ftype) -# fname: Filename excluding directory, e.g. 'dt-platdata.c' -OutputFile = collections.namedtuple('OutputFile', ['ftype', 'fname']) +# fname: Filename excluding directory, e.g. 'dt-plat.c' +# hdr_comment: Comment explaining the purpose of the file +OutputFile = collections.namedtuple('OutputFile', + ['ftype', 'fname', 'hdr_comment']) # This holds information about a property which includes phandles. #
@@ -331,15 +333,20 @@ class DtbPlatdata(): self._lines = [] return lines - def out_header(self): - """Output a message indicating that this is an auto-generated file""" + def out_header(self, outfile): + """Output a message indicating that this is an auto-generated file + + Args: + outfile: OutputFile describing the file being generated + """ self.out('''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * %s. + * This was generated by dtoc from a .dtb (device tree binary) file. */ -''') +''' % outfile.hdr_comment) def get_phandle_argc(self, prop, node_name): """Check if a node contains phandles
@@ -646,7 +653,6 @@ class DtbPlatdata(): value: Prop object with field information """ - self.out_header() self.out('#include <stdbool.h>\n') self.out('#include <linux/libfdt.h>\n')
@@ -789,7 +795,6 @@ class DtbPlatdata(): See the documentation in doc/driver-model/of-plat.rst for more information. """ - self.out_header() self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') self.out('#define DT_PLATDATA_C\n') self.out('\n')
@@ -823,8 +828,12 @@ class DtbPlatdata(): # key: Command used to generate this file # value: OutputFile for this command OUTPUT_FILES = { - 'struct': OutputFile(Ftype.HEADER, 'dt-structs-gen.h'), - 'platdata': OutputFile(Ftype.SOURCE, 'dt-platdata.c'), + 'struct': + OutputFile(Ftype.HEADER, 'dt-structs-gen.h', + 'Defines the structs used to hold devicetree data'), + 'platdata': + OutputFile(Ftype.SOURCE, 'dt-platdata.c', + 'Declares the U_BOOT_DRIVER() records and platform data'), }
@@ -872,6 +881,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, (cmd, ', '.join(sorted(OUTPUT_FILES.keys())))) plat.setup_output(outfile.ftype, outfile.fname if output_dirs else output) + plat.out_header(outfile) if cmd == 'struct': plat.generate_structs(structs) elif cmd == 'platdata':
tools/dtoc/test_dtoc.py +4 -2
@@ -32,7 +32,8 @@ OUR_PATH = os.path.dirname(os.path.realpath(__file__)) HEADER = '''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * Defines the structs used to hold devicetree data. + * This was generated by dtoc from a .dtb (device tree binary) file. */ #include <stdbool.h>
@@ -41,7 +42,8 @@ HEADER = '''/* C_HEADER = '''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * Declares the U_BOOT_DRIVER() records and platform data. + * This was generated by dtoc from a .dtb (device tree binary) file. */ /* Allow use of U_BOOT_DRVINFO() in this file */
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 15/49 dtoc: Rename dt-platdata.c to dt-plat.c
In reply to Simon GlassUse this new name to be consistent with the rest of U-Boot, which talks about 'plat' for the platform data, which is what this file holds.
---
include/dm/platdata.h | 2 +- include/linux/mtd/spi-nor.h | 2 +- scripts/Makefile.spl | 2 +- tools/dtoc/dtb_platdata.py | 4 ++-- tools/dtoc/test_dtoc.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)
include/dm/platdata.h +1 -1
@@ -59,7 +59,7 @@ struct driver_rt {* When of-platdata is in use, U_BOOT_DRVINFO() cannot be used outside of the * dt-plat.c file created by dtoc */ -#if CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(DT_PLATDATA_C ) +#if CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(DT_PLAT_C )#define U_BOOT_DRVINFO (__name) _Static_assert(false, \ "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead")#else
include/linux/mtd/spi-nor.h +1 -1
@@ -262,7 +262,7 @@ struct spi_flash {* Defined below (keep this text to enable searching for spi_flash decl) * } */ -#ifndef DT_PLATDATA_C +#ifndef DT_PLAT_C #define spi_flash spi_nor#endif
scripts/Makefile.spl +1 -1
@@ -120,7 +120,7 @@ endif u-boot-spl-init := $(head-y) u-boot-spl-main := $(libs-y) ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA -u-boot-spl-platdata := $(obj)/dts/dt-platdata.o +u-boot-spl-platdata := $(obj)/dts/dt-plat.o u-boot-spl-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-platdata)) endif
tools/dtoc/dtb_platdata.py +2 -2
@@ -796,7 +796,7 @@ class DtbPlatdata(): information. """ self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') - self.out('#define DT_PLATDATA_C\n') + self.out('#define DT_PLAT_C\n') self.out('\n') self.out('#include <common.h>\n') self.out('#include <dm.h>\n')
@@ -832,7 +832,7 @@ OUTPUT_FILES = { OutputFile(Ftype.HEADER, 'dt-structs-gen.h', 'Defines the structs used to hold devicetree data'), 'platdata': - OutputFile(Ftype.SOURCE, 'dt-platdata.c', + OutputFile(Ftype.SOURCE, 'dt-plat.c', 'Declares the U_BOOT_DRIVER() records and platform data'), }
tools/dtoc/test_dtoc.py +2 -2
@@ -47,7 +47,7 @@ C_HEADER = '''/* */ /* Allow use of U_BOOT_DRVINFO() in this file */ -#define DT_PLATDATA_C +#define DT_PLAT_C #include <common.h> #include <dm.h>
@@ -979,5 +979,5 @@ U_BOOT_DRVINFO(spl_test2) = { leafs = set(os.path.basename(fname) for fname in fnames) self.assertEqual( - {'dt-structs-gen.h', 'source.dts', 'dt-platdata.c', 'source.dtb'}, + {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'}, leafs)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 16/49 dtoc: Add the method for each command to OutputFile
In reply to Simon GlassRather than the if/else construct, update OutputFile with the method to call to process each command. This is easier to maintain as the number of commands increases.
Rename generate_tables to generate_plat since it better describes what is being generated ('plat' is the U-Boot name for platform data).
With this, each output method needs to have the same signature. Store the output structures in a member variable instead of using parameters, to accomplish this.
---
tools/dtoc/dtb_platdata.py | 42 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-)
tools/dtoc/dtb_platdata.py +16 -26
@@ -59,7 +59,7 @@ class Ftype(IntEnum): # fname: Filename excluding directory, e.g. 'dt-plat.c' # hdr_comment: Comment explaining the purpose of the file OutputFile = collections.namedtuple('OutputFile', - ['ftype', 'fname', 'hdr_comment']) + ['ftype', 'fname', 'method', 'hdr_comment']) # This holds information about a property which includes phandles. #
@@ -194,6 +194,11 @@ class DtbPlatdata(): _drivers_additional: List of additional drivers to use during scanning _dirname: Directory to hold output files, or None for none (all files go to stdout) + _struct_data (dict): OrderedDict of dtplat structures to output + key (str): Node name, as a C identifier + value: dict containing structure fields: + key (str): Field name + value: Prop object with field information """ def __init__(self, dtb_fname, include_disabled, warning_disabled, drivers_additional=None):
@@ -208,6 +213,7 @@ class DtbPlatdata(): self._driver_aliases = {} self._drivers_additional = drivers_additional or [] self._dirnames = [None] * len(Ftype) + self._struct_data = collections.OrderedDict() def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -570,14 +576,9 @@ class DtbPlatdata(): Once the widest property is determined, all other properties are updated to match that width. - Returns: - dict of dict: dict containing structures: - key (str): Node name, as a C identifier - value: dict containing structure fields: - key (str): Field name - value: Prop object with field information + The results are written to self._struct_data """ - structs = collections.OrderedDict() + structs = self._struct_data for node in self._valid_nodes: node_name, _ = self.get_normalized_compat_name(node) fields = {}
@@ -608,8 +609,6 @@ class DtbPlatdata(): if name not in PROP_IGNORE_LIST and name[0] != '#': prop.Widen(struct[name]) - return structs - def scan_phandles(self): """Figure out what phandles each node uses
@@ -638,21 +637,14 @@ class DtbPlatdata(): pos += 1 + args - def generate_structs(self, structs): + def generate_structs(self): """Generate struct defintions for the platform data This writes out the body of a header file consisting of structure definitions for node in self._valid_nodes. See the documentation in doc/driver-model/of-plat.rst for more information. - - Args: - structs (dict): dict containing structures: - key (str): Node name, as a C identifier - value: dict containing structure fields: - key (str): Field name - value: Prop object with field information - """ + structs = self._struct_data self.out('#include <stdbool.h>\n') self.out('#include <linux/libfdt.h>\n')
@@ -785,7 +777,7 @@ class DtbPlatdata(): self.out(''.join(self.get_buf())) - def generate_tables(self): + def generate_plat(self): """Generate device defintions for the platform data This writes out C platform data initialisation data and
@@ -830,9 +822,10 @@ class DtbPlatdata(): OUTPUT_FILES = { 'struct': OutputFile(Ftype.HEADER, 'dt-structs-gen.h', + DtbPlatdata.generate_structs, 'Defines the structs used to hold devicetree data'), 'platdata': - OutputFile(Ftype.SOURCE, 'dt-plat.c', + OutputFile(Ftype.SOURCE, 'dt-plat.c', DtbPlatdata.generate_plat, 'Declares the U_BOOT_DRIVER() records and platform data'), }
@@ -868,7 +861,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, plat.scan_tree() plat.scan_reg_sizes() plat.setup_output_dirs(output_dirs) - structs = plat.scan_structs() + plat.scan_structs() plat.scan_phandles() cmds = args[0].split(',')
@@ -882,8 +875,5 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, plat.setup_output(outfile.ftype, outfile.fname if output_dirs else output) plat.out_header(outfile) - if cmd == 'struct': - plat.generate_structs(structs) - elif cmd == 'platdata': - plat.generate_tables() + outfile.method(plat) plat.finish_output()
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 17/49 dtoc: Allow specifying the base directory for tests
In reply to Simon GlassThe base directory of U-Boot, where the source is, it currently calculated from the directory of the dtb_platdata.py script. If this is installed elsewhere that will not work. Also it is inconvenient for tests.
Add a parameter to allow specifying this base directory.
To test this, pass a temporary directory with some files in it and check that they are passed to scan_driver().
---
tools/dtoc/dtb_platdata.py | 18 ++++++++++++------ tools/dtoc/test_dtoc.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-)
tools/dtoc/dtb_platdata.py +12 -6
@@ -199,6 +199,7 @@ class DtbPlatdata(): value: dict containing structure fields: key (str): Field name value: Prop object with field information + _basedir (str): Base directory of source tree """ def __init__(self, dtb_fname, include_disabled, warning_disabled, drivers_additional=None):
@@ -214,6 +215,7 @@ class DtbPlatdata(): self._drivers_additional = drivers_additional or [] self._dirnames = [None] * len(Ftype) self._struct_data = collections.OrderedDict() + self._basedir = None def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -439,15 +441,17 @@ class DtbPlatdata(): continue self._driver_aliases[alias[1]] = alias[0] - def scan_drivers(self): + def scan_drivers(self, basedir=None): """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 = './' + if not basedir: + basedir = sys.argv[0].replace('tools/dtoc/dtoc', '') + if basedir == '': + basedir = './' + self._basedir = basedir for (dirpath, _, filenames) in os.walk(basedir): for fname in filenames: if not fname.endswith('.c'):
@@ -831,7 +835,7 @@ OUTPUT_FILES = { def run_steps(args, dtb_file, include_disabled, output, output_dirs, - warning_disabled=False, drivers_additional=None): + warning_disabled=False, drivers_additional=None, basedir=None): """Run all the steps of the dtoc tool Args:
@@ -846,6 +850,8 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, drivers drivers_additional (list): List of additional drivers to use during scanning + basedir (str): Base directory of U-Boot source code. Defaults to the + grandparent of this file's directory Raises: ValueError: if args has no command, or an unknown command """
@@ -856,7 +862,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled, drivers_additional) - plat.scan_drivers() + plat.scan_drivers(basedir) plat.scan_dtb() plat.scan_tree() plat.scan_reg_sizes()
tools/dtoc/test_dtoc.py +34 -0
@@ -12,9 +12,11 @@ tool. import collections import glob import os +import shutil import struct import tempfile import unittest +from unittest import mock from dtb_platdata import conv_name_to_c from dtb_platdata import get_compat_name
@@ -981,3 +983,35 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertEqual( {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'}, leafs) + + def test_scan_dirs(self): + """Test scanning of source directories""" + def add_file(fname): + pathname = os.path.join(indir, fname) + dirname = os.path.dirname(pathname) + os.makedirs(dirname, exist_ok=True) + tools.WriteFile(pathname, '', binary=False) + fname_list.append(pathname) + + try: + outdir = tools.GetOutputDir() + indir = tempfile.mkdtemp(prefix='dtoc.') + dtb_file = get_dtb_file('dtoc_test_simple.dts') + + fname_list = [] + add_file('fname.c') + add_file('dir/fname2.c') + + # Mock out scan_driver and check that it is called with the + # expected files + with mock.patch.object(dtb_platdata.DtbPlatdata, "scan_driver") \ + as mocked: + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], + True, basedir=indir) + self.assertEqual(2, len(mocked.mock_calls)) + self.assertEqual(mock.call(fname_list[0]), + mocked.mock_calls[0]) + self.assertEqual(mock.call(fname_list[1]), + mocked.mock_calls[1]) + finally: + shutil.rmtree(indir)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 18/49 dtoc: Output nodes in order
In reply to Simon GlassPreviously we had to worry about nodes being output before those that they depended on, thus causing build errors. So the current algorithm is careful to output nodes in the right order.
We now use a different method for outputting phandles that does not involve pointers. Also we plan to add a 'declarations' header file to declare all drivers as 'extern'.
Update the code to drop the dependency checking and output in a simple loop. This makes the output easier to follow since drivers are in order of thier indices (0, 1, ...), which is also the order it appears in in the linker list.
---
tools/dtoc/dtb_platdata.py | 13 ++------ tools/dtoc/test_dtoc.py | 64 +++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 43 deletions(-)
tools/dtoc/dtb_platdata.py +2 -11
@@ -798,18 +798,9 @@ class DtbPlatdata(): self.out('#include <dm.h>\n') self.out('#include <dt-structs.h>\n') self.out('\n') - nodes_to_output = list(self._valid_nodes) - - # Keep outputing nodes until there is none left - while nodes_to_output: - node = nodes_to_output[0] - # Output all the node's dependencies first - for req_node in node.phandles: - if req_node in nodes_to_output: - self.output_node(req_node) - nodes_to_output.remove(req_node) + + for node in self._valid_nodes: self.output_node(node) - nodes_to_output.remove(node) # Define dm_populate_phandle_data() which will add the linking between # nodes using DM_DRVINFO_GET
tools/dtoc/test_dtoc.py +32 -32
100 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 19/49 dtoc: Drop dm_populate_phandle_data()
In reply to Simon GlassThis has not been needed since parent information was added and we started using indicies for references to other drivers instead of pointers. It was kept around in the expectation that it might be needed later.
However with the latest updates, it doesn't seem likely that we'll need this in the foreseeable future.
Drop dm_populate_phandle_data() from dtoc and driver model.
---
doc/driver-model/of-plat.rst | 16 ++++++---------- drivers/core/root.c | 3 --- include/dm/platdata.h | 8 -------- tools/dtoc/dtb_platdata.py | 6 ------ tools/dtoc/test_dtoc.py | 29 +++++++---------------------- 5 files changed, 13 insertions(+), 49 deletions(-)
doc/driver-model/of-plat.rst +6 -10
@@ -162,9 +162,6 @@ and the following device declarations: .parent_idx = -1, }; - void dm_populate_phandle_data(void) { - } - The device is then instantiated at run-time and the platform data can be accessed using:
@@ -190,10 +187,7 @@ This macro produces no code, but it is by dtoc tool. The parent_idx is the index of the parent driver_info structure within its linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support -dev_get_parent(). The dm_populate_phandle_data() is included to allow for -fix-ups required by dtoc. It is not currently used. The values in 'clocks' are -the index of the driver_info for the target device followed by any phandle -arguments. This is used to support device_get_by_driver_info_idx(). +dev_get_parent(). During the build process dtoc parses both U_BOOT_DRIVER and DM_DRIVER_ALIAS to build a list of valid driver names and driver aliases. If the 'compatible'
@@ -337,9 +331,11 @@ prevents them being used inadvertently. All usage must be bracketed with #if CONFIG_IS_ENABLED(OF_PLATDATA). The dt-plat.c file contains the device declarations and is is built in -spl/dt-plat.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_DRVINFO by using DM_DRVINFO_GET +spl/dt-plat.c. + +The dm_populate_phandle_data() function that was previous needed has now been +removed, since dtoc can address the drivers directly from dt-plat.c and does +not need to fix up things at runtime. The pylibfdt Python module is used to access the devicetree.
drivers/core/root.c +0 -3
@@ -336,9 +336,6 @@ int dm_init_and_scan(bool pre_reloc_only) {int ret; -if (CONFIG_IS_ENABLED (OF_PLATDATA )) -dm_populate_phandle_data (); - ret =dm_init (CONFIG_IS_ENABLED (OF_LIVE ));if (ret) {debug ("dm_init() failed: %d\n" , ret);
include/dm/platdata.h +0 -8
@@ -86,12 +86,4 @@ struct driver_rt {#define DM_DRVINFO_GET (__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_DRVINFO entry get by -* DM_DRVINFO_GET. The implementation of this function will be done -* by dtoc when parsing dtb. -*/ -void dm_populate_phandle_data (void );#endif
tools/dtoc/dtb_platdata.py +0 -6
@@ -802,12 +802,6 @@ class DtbPlatdata(): for node in self._valid_nodes: self.output_node(node) - # Define dm_populate_phandle_data() which will add the linking between - # nodes using DM_DRVINFO_GET - # dtv_dmc_at_xxx.clocks[0].node = DM_DRVINFO_GET(clock_controller_at_xxx) - self.buf('void dm_populate_phandle_data(void) {\n') - self.buf('}\n') - self.out(''.join(self.get_buf()))
tools/dtoc/test_dtoc.py +7 -22
@@ -56,10 +56,6 @@ C_HEADER = '''/* #include <dt-structs.h> ''' -C_EMPTY_POPULATE_PHANDLE_DATA = '''void dm_populate_phandle_data(void) { -} -''' - # This is a test so is allowed to access private things in the module it is # testing # pylint: disable=W0212
@@ -190,8 +186,7 @@ class TestDtoc(unittest.TestCase): self.run_test(['platdata'], dtb_file, output) with open(output) as infile: lines = infile.read().splitlines() - self.assertEqual(C_HEADER.splitlines() + [''] + - C_EMPTY_POPULATE_PHANDLE_DATA.splitlines(), lines) + self.assertEqual(C_HEADER.splitlines() + [''], lines) struct_text = HEADER + ''' struct dtd_sandbox_i2c_test {
@@ -289,7 +284,7 @@ U_BOOT_DRVINFO(spl_test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA +''' def test_simple(self): """Test output from some simple nodes with various types of data"""
@@ -344,8 +339,6 @@ U_BOOT_DRVINFO(gpios_at_0) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_invalid_driver(self):
@@ -376,8 +369,6 @@ U_BOOT_DRVINFO(spl_test) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle(self):
@@ -460,8 +451,6 @@ U_BOOT_DRVINFO(phandle_target) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_single(self):
@@ -510,8 +499,6 @@ U_BOOT_DRVINFO(phandle_target) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_cd_gpio(self):
@@ -582,8 +569,6 @@ U_BOOT_DRVINFO(phandle_target) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_bad(self):
@@ -662,7 +647,7 @@ U_BOOT_DRVINFO(test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses32(self): """Test output from a node with a 'reg' property with na=1, ns=1"""
@@ -706,7 +691,7 @@ U_BOOT_DRVINFO(test2) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses64_32(self): """Test output from a node with a 'reg' property with na=2, ns=1"""
@@ -764,7 +749,7 @@ U_BOOT_DRVINFO(test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses32_64(self): """Test output from a node with a 'reg' property with na=1, ns=2"""
@@ -822,7 +807,7 @@ U_BOOT_DRVINFO(test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_bad_reg(self): """Test that a reg property with an invalid type generates an error"""
@@ -885,7 +870,7 @@ U_BOOT_DRVINFO(spl_test2) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_stdout(self): """Test output to stdout"""
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 20/49 dtoc: Split source-code scanning to a separate file
In reply to Simon GlassBefore expanding the scanning features any more, move this into a separate file. This will make it easier to maintain in the future. In particular, it reduces the size of dtb_platdata.py and allows us to add tests specifically for scanning, without going through that file.
The pieces moved are the Driver class, the scanning code and the various naming functions, since they mostly depend on the scanning results.
So far there is are no separate tests for src_scan. These will be added as new functionality appears.
This introduces no functional change.
---
tools/dtoc/dtb_platdata.py | 174 +++------------------------------- tools/dtoc/src_scan.py | 185 +++++++++++++++++++++++++++++++++++++ tools/dtoc/test_dtoc.py | 14 +-- 3 files changed, 204 insertions(+), 169 deletions(-) create mode 100644 tools/dtoc/src_scan.py
tools/dtoc/dtb_platdata.py +12 -162
@@ -22,6 +22,8 @@ import sys from dtoc import fdt from dtoc import fdt_util +from dtoc import src_scan +from dtoc.src_scan import conv_name_to_c # When we see these properties we ignore them - i.e. do not create a structure # member
@@ -76,39 +78,6 @@ PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args']) PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_name']) -class Driver: - """Information about a driver in U-Boot - - Attributes: - name: Name of driver. For U_BOOT_DRIVER(x) this is 'x' - """ - def __init__(self, name): - self.name = name - - def __eq__(self, other): - return self.name == other.name - - def __repr__(self): - return "Driver(name='%s')" % self.name - - -def conv_name_to_c(name): - """Convert a device-tree name to a C identifier - - This uses multiple replace() calls instead of re.sub() since it is faster - (400ms for 1m calls versus 1000ms for the 're' version). - - Args: - name (str): Name to convert - Return: - str: String containing the C version of this name - """ - new = name.replace('@', '_at_') - new = new.replace('-', '_') - new = new.replace(',', '_') - new = new.replace('.', '_') - return new - def tab_to(num_tabs, line): """Append tabs to a line of text to reach a tab stop.
@@ -154,19 +123,6 @@ def get_value(ftype, value): val = '%#x' % value return val -def get_compat_name(node): - """Get the node's list of compatible string as a C identifiers - - Args: - node (fdt.Node): Node object to check - Return: - list of str: List of C identifiers for all the compatible strings - """ - compat = node.props['compatible'].value - if not isinstance(compat, list): - compat = [compat] - return [conv_name_to_c(c) for c in compat] - class DtbPlatdata(): """Provide a means to convert device tree binary data to platform data
@@ -176,22 +132,15 @@ class DtbPlatdata(): code is not affordable. Properties: + _scan: Scan object, for scanning and reporting on useful information + from the U-Boot source code _fdt: Fdt object, referencing the device tree _dtb_fname: Filename of the input device tree binary file _valid_nodes: A list of Node object with compatible strings. The list is ordered by conv_name_to_c(node.name) _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 - _drivers: Dict of valid driver names found in drivers/ - key: Driver name - value: Driver for that driver - _driver_aliases: Dict that holds aliases for driver names - key: Driver alias declared with - DM_DRIVER_ALIAS(driver_alias, driver_name) - value: Driver name declared with U_BOOT_DRIVER(driver_name) - _drivers_additional: List of additional drivers to use during scanning _dirname: Directory to hold output files, or None for none (all files go to stdout) _struct_data (dict): OrderedDict of dtplat structures to output
@@ -201,58 +150,18 @@ class DtbPlatdata(): value: Prop object with field information _basedir (str): Base directory of source tree """ - def __init__(self, dtb_fname, include_disabled, warning_disabled, - drivers_additional=None): + def __init__(self, scan, dtb_fname, include_disabled): + self._scan = scan 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._drivers = {} - self._driver_aliases = {} - self._drivers_additional = drivers_additional or [] self._dirnames = [None] * len(Ftype) self._struct_data = collections.OrderedDict() self._basedir = None - def get_normalized_compat_name(self, node): - """Get a node's normalized compat name - - Returns a valid driver name by retrieving node's list of 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): 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_list_c = get_compat_name(node) - - for compat_c in compat_list_c: - if not compat_c in self._drivers.keys(): - compat_c = self._driver_aliases.get(compat_c) - if not compat_c: - continue - - aliases_c = compat_list_c - if compat_c in aliases_c: - aliases_c.remove(compat_c) - return compat_c, aliases_c - - if not self._warning_disabled: - print('WARNING: the driver %s was not found in the driver list' - % (compat_list_c[0])) - - return compat_list_c[0], compat_list_c[1:] - def setup_output_dirs(self, output_dirs): """Set up the output directories
@@ -407,65 +316,6 @@ class DtbPlatdata(): return PhandleInfo(max_args, args) return None - def scan_driver(self, fname): - """Scan a driver file to build a list of driver names and aliases - - This procedure will populate self._drivers and self._driver_aliases - - Args - fname: Driver filename to scan - """ - with open(fname, encoding='utf-8') as inf: - try: - buff = inf.read() - except UnicodeDecodeError: - # This seems to happen on older Python versions - print("Skipping file '%s' due to unicode error" % fname) - return - - # The following re will search for driver names declared as - # U_BOOT_DRIVER(driver_name) - drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff) - - for driver in drivers: - self._drivers[driver] = Driver(driver) - - # The following re will search for driver aliases declared as - # DM_DRIVER_ALIAS(alias, driver_name) - driver_aliases = re.findall( - r'DM_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, basedir=None): - """Scan the driver folders to build a list of driver names and aliases - - This procedure will populate self._drivers and self._driver_aliases - - """ - if not basedir: - basedir = sys.argv[0].replace('tools/dtoc/dtoc', '') - if basedir == '': - basedir = './' - self._basedir = basedir - for (dirpath, _, filenames) in os.walk(basedir): - for fname in filenames: - if not fname.endswith('.c'): - continue - self.scan_driver(dirpath + '/' + fname) - - for fname in self._drivers_additional: - if not isinstance(fname, str) or len(fname) == 0: - continue - if fname[0] == '/': - self.scan_driver(fname) - else: - self.scan_driver(basedir + '/' + fname) - def scan_dtb(self): """Scan the device tree to obtain a tree of nodes and properties
@@ -584,7 +434,7 @@ class DtbPlatdata(): """ structs = self._struct_data for node in self._valid_nodes: - node_name, _ = self.get_normalized_compat_name(node) + node_name, _ = self._scan.get_normalized_compat_name(node) fields = {} # Get a list of all the valid properties in this node.
@@ -607,7 +457,7 @@ class DtbPlatdata(): structs[node_name] = fields for node in self._valid_nodes: - node_name, _ = self.get_normalized_compat_name(node) + node_name, _ = self._scan.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] != '#':
@@ -772,7 +622,7 @@ class DtbPlatdata(): Args: node (fdt.Node): node to output """ - struct_name, _ = self.get_normalized_compat_name(node) + struct_name, _ = self._scan.get_normalized_compat_name(node) var_name = conv_name_to_c(node.name) self.buf('/* Node %s index %d */\n' % (node.path, node.idx))
@@ -845,9 +695,9 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, if output and output_dirs and any(output_dirs): raise ValueError('Must specify either output or output_dirs, not both') - plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled, - drivers_additional) - plat.scan_drivers(basedir) + scan = src_scan.Scanner(basedir, drivers_additional, warning_disabled) + plat = DtbPlatdata(scan, dtb_file, include_disabled) + scan.scan_drivers() plat.scan_dtb() plat.scan_tree() plat.scan_reg_sizes()
tools/dtoc/src_scan.py new file +185 -0
185 lines not on this page · raw message
tools/dtoc/test_dtoc.py +7 -7
@@ -18,13 +18,14 @@ import tempfile import unittest from unittest import mock -from dtb_platdata import conv_name_to_c -from dtb_platdata import get_compat_name from dtb_platdata import get_value from dtb_platdata import tab_to from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util +from dtoc import src_scan +from dtoc.src_scan import conv_name_to_c +from dtoc.src_scan import get_compat_name from patman import test_util from patman import tools
@@ -933,9 +934,9 @@ U_BOOT_DRVINFO(spl_test2) = { def test_driver(self): """Test the Driver class""" - drv1 = dtb_platdata.Driver('fred') - drv2 = dtb_platdata.Driver('mary') - drv3 = dtb_platdata.Driver('fred') + drv1 = src_scan.Driver('fred') + drv2 = src_scan.Driver('mary') + drv3 = src_scan.Driver('fred') self.assertEqual("Driver(name='fred')", str(drv1)) self.assertEqual(drv1, drv3) self.assertNotEqual(drv1, drv2)
@@ -989,8 +990,7 @@ U_BOOT_DRVINFO(spl_test2) = { # Mock out scan_driver and check that it is called with the # expected files - with mock.patch.object(dtb_platdata.DtbPlatdata, "scan_driver") \ - as mocked: + with mock.patch.object(src_scan.Scanner, "scan_driver") as mocked: dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True, basedir=indir) self.assertEqual(2, len(mocked.mock_calls))
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 21/49 dtoc: Move src_scan tests to a separate file
In reply to Simon GlassMove the tests related to scanning into their own class, updating them to avoid using dtb_platdata as a pass-through.
---
tools/dtoc/dtb_platdata.py | 2 +- tools/dtoc/main.py | 5 +- tools/dtoc/src_scan.py | 4 +- tools/dtoc/test_dtoc.py | 73 ----------------------------- tools/dtoc/test_src_scan.py | 91 +++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 78 deletions(-) create mode 100644 tools/dtoc/test_src_scan.py
tools/dtoc/dtb_platdata.py +1 -1
@@ -695,7 +695,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, if output and output_dirs and any(output_dirs): raise ValueError('Must specify either output or output_dirs, not both') - scan = src_scan.Scanner(basedir, drivers_additional, warning_disabled) + scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional) plat = DtbPlatdata(scan, dtb_file, include_disabled) scan.scan_drivers() plat.scan_dtb()
tools/dtoc/main.py +3 -2
@@ -46,7 +46,8 @@ def run_tests(processes, args): args: List of positional args provided to dtoc. This can hold a test name to execute (as in 'dtoc -t test_empty_file', for example) """ - import test_dtoc + from dtoc import test_src_scan + from dtoc import test_dtoc result = unittest.TestResult() sys.argv = [sys.argv[0]]
@@ -55,7 +56,7 @@ def run_tests(processes, args): test_util.RunTestSuites( result, debug=True, verbosity=1, test_preserve_dirs=False, processes=processes, test_name=test_name, toolpath=[], - test_class_list=[test_dtoc.TestDtoc,]) + test_class_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan]) return test_util.ReportResult('binman', test_name, result)
tools/dtoc/src_scan.py +2 -2
@@ -78,11 +78,11 @@ class Scanner: key: Driver alias declared with DM_DRIVER_ALIAS(driver_alias, driver_name) value: Driver name declared with U_BOOT_DRIVER(driver_name) + _warning_disabled: true to disable warnings about driver names not found _drivers_additional (list or str): List of additional drivers to use during scanning - _warning_disabled: true to disable warnings about driver names not found """ - def __init__(self, basedir, drivers_additional, warning_disabled): + def __init__(self, basedir, warning_disabled, drivers_additional): """Set up a new Scanner """ if not basedir:
tools/dtoc/test_dtoc.py +0 -73
96 lines not on this page · raw message
tools/dtoc/test_src_scan.py new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 22/49 dtoc: Tidy up src_scan tests
In reply to Simon GlassSome of these tests don't actually check anything. Add a few more checks to complete the tests.
Also add a simple scan test that does the basics.
---
tools/dtoc/test_src_scan.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
tools/dtoc/test_src_scan.py +22 -6
@@ -14,6 +14,7 @@ import unittest from unittest import mock from dtoc import src_scan +from patman import test_util from patman import tools # This is a test so is allowed to access private things in the module it is
@@ -30,15 +31,26 @@ class TestSrcScan(unittest.TestCase): def tearDownClass(cls): tools.FinaliseOutputDir() - @classmethod - def test_scan_drivers(cls): - """Test running dtoc with additional drivers to scan""" + def test_simple(self): + """Simple test of scanning drivers""" + scan = src_scan.Scanner(None, True, None) + scan.scan_drivers() + self.assertIn('sandbox_gpio', scan._drivers) + self.assertIn('sandbox_gpio_alias', scan._driver_aliases) + self.assertEqual('sandbox_gpio', + scan._driver_aliases['sandbox_gpio_alias']) + self.assertNotIn('sandbox_gpio_alias2', scan._driver_aliases) + + def test_additional(self): + """Test with additional drivers to scan""" scan = src_scan.Scanner( None, True, [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) scan.scan_drivers() + self.assertIn('sandbox_gpio_alias2', scan._driver_aliases) + self.assertEqual('sandbox_gpio', + scan._driver_aliases['sandbox_gpio_alias2']) - @classmethod - def test_unicode_error(cls): + def test_unicode_error(self): """Test running dtoc with an invalid unicode file To be able to perform this test without adding a weird text file which
@@ -49,7 +61,11 @@ class TestSrcScan(unittest.TestCase): with open(driver_fn, 'wb+') as fout: fout.write(b'\x81') - src_scan.Scanner(None, True, [driver_fn]) + scan = src_scan.Scanner(None, True, [driver_fn]) + with test_util.capture_sys_output() as (stdout, _): + scan.scan_drivers() + self.assertRegex(stdout.getvalue(), + r"Skipping file '.*' due to unicode error\s*") def test_driver(self): """Test the Driver class"""
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 23/49 dtoc: Scan drivers for available information
In reply to Simon GlassAt present we simply record the name of a driver parsed from its implementation file. We also need to get the uclass and a few other things so we can instantiate devices at build time. Add support for collecting this information. This requires parsing each driver file.
---
tools/dtoc/src_scan.py | 194 ++++++++++++++++++++++++++++++++++-- tools/dtoc/test_src_scan.py | 131 +++++++++++++++++++++++- 2 files changed, 311 insertions(+), 14 deletions(-)
tools/dtoc/src_scan.py +184 -10
@@ -54,15 +54,30 @@ class Driver: Attributes: name: Name of driver. For U_BOOT_DRIVER(x) this is 'x' + fname: Filename where the driver was found + uclass_id: Name of uclass, e.g. 'UCLASS_I2C' + compat: Driver data for each compatible string: + key: Compatible string, e.g. 'rockchip,rk3288-grf' + value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None + fname: Filename where the driver was found + priv (str): struct name of the priv_auto member, e.g. 'serial_priv' """ - def __init__(self, name): + def __init__(self, name, fname): self.name = name + self.fname = fname + self.uclass_id = None + self.compat = None + self.priv = '' def __eq__(self, other): - return self.name == other.name + return (self.name == other.name and + self.uclass_id == other.uclass_id and + self.compat == other.compat and + self.priv == other.priv) def __repr__(self): - return "Driver(name='%s')" % self.name + return ("Driver(name='%s', uclass_id='%s', compat=%s, priv=%s)" % + (self.name, self.uclass_id, self.compat, self.priv)) class Scanner:
@@ -81,6 +96,12 @@ class Scanner: _warning_disabled: true to disable warnings about driver names not found _drivers_additional (list or str): List of additional drivers to use during scanning + _of_match: Dict holding information about compatible strings + key: Name of struct udevice_id variable + value: Dict of compatible info in that variable: + key: Compatible string, e.g. 'rockchip,rk3288-grf' + value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None + _compat_to_driver: Maps compatible strings to Driver """ def __init__(self, basedir, warning_disabled, drivers_additional): """Set up a new Scanner
@@ -94,6 +115,8 @@ class Scanner: self._driver_aliases = {} self._drivers_additional = drivers_additional or [] self._warning_disabled = warning_disabled + self._of_match = {} + self._compat_to_driver = {} def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -131,10 +154,163 @@ class Scanner: return compat_list_c[0], compat_list_c[1:] + @classmethod + def _get_re_for_member(cls, member): + """_get_re_for_member: Get a compiled regular expression + + Args: + member (str): Struct member name, e.g. 'priv_auto' + + Returns: + re.Pattern: Compiled regular expression that parses: + + .member = sizeof(struct fred), + + and returns "fred" as group 1 + """ + return re.compile(r'^\s*.%s\s*=\s*sizeof\(struct\s+(.*)\),$' % member) + + def _parse_driver(self, fname, buff): + """Parse a C file to extract driver information contained within + + This parses U_BOOT_DRIVER() structs to obtain various pieces of useful + information. + + It updates the following members: + _drivers - updated with new Driver records for each driver found + in the file + _of_match - updated with each compatible string found in the file + _compat_to_driver - Maps compatible string to Driver + + Args: + fname (str): Filename being parsed (used for warnings) + buff (str): Contents of file + + Raises: + ValueError: Compatible variable is mentioned in .of_match in + U_BOOT_DRIVER() but not found in the file + """ + # Dict holding information about compatible strings collected in this + # function so far + # key: Name of struct udevice_id variable + # value: Dict of compatible info in that variable: + # key: Compatible string, e.g. 'rockchip,rk3288-grf' + # value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None + of_match = {} + + # Dict holding driver information collected in this function so far + # key: Driver name (C name as in U_BOOT_DRIVER(xxx)) + # value: Driver + drivers = {} + + # Collect the driver info + driver = None + re_driver = re.compile(r'U_BOOT_DRIVER\((.*)\)') + + # Collect the uclass ID, e.g. 'UCLASS_SPI' + re_id = re.compile(r'\s*\.id\s*=\s*(UCLASS_[A-Z0-9_]+)') + + # Collect the compatible string, e.g. 'rockchip,rk3288-grf' + compat = None + re_compat = re.compile(r'{\s*.compatible\s*=\s*"(.*)"\s*' + r'(,\s*.data\s*=\s*(\S*))?\s*},') + + # This is a dict of compatible strings that were found: + # key: Compatible string, e.g. 'rockchip,rk3288-grf' + # value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None + compat_dict = {} + + # Holds the var nane of the udevice_id list, e.g. + # 'rk3288_syscon_ids_noc' in + # static const struct udevice_id rk3288_syscon_ids_noc[] = { + ids_name = None + re_ids = re.compile(r'struct udevice_id (.*)\[\]\s*=') + + # Matches the references to the udevice_id list + re_of_match = re.compile( + r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,') + + # Matches the struct name for priv + re_priv = self._get_re_for_member('priv_auto') + + prefix = '' + for line in buff.splitlines(): + # Handle line continuation + if prefix: + line = prefix + line + prefix = '' + if line.endswith('\\'): + prefix = line[:-1] + continue + + driver_match = re_driver.search(line) + + # If this line contains U_BOOT_DRIVER()... + if driver: + m_id = re_id.search(line) + m_of_match = re_of_match.search(line) + m_priv = re_priv.match(line) + if m_priv: + driver.priv = m_priv.group(1) + elif m_id: + driver.uclass_id = m_id.group(1) + elif m_of_match: + compat = m_of_match.group(2) + elif '};' in line: + if driver.uclass_id and compat: + if compat not in of_match: + raise ValueError( + "%s: Unknown compatible var '%s' (found: %s)" % + (fname, compat, ','.join(of_match.keys()))) + driver.compat = of_match[compat] + + # This needs to be deterministic, since a driver may + # have multiple compatible strings pointing to it. + # We record the one earliest in the alphabet so it + # will produce the same result on all machines. + for compat_id in of_match[compat]: + old = self._compat_to_driver.get(compat_id) + if not old or driver.name < old.name: + self._compat_to_driver[compat_id] = driver + drivers[driver.name] = driver + else: + # The driver does not have a uclass or compat string. + # The first is required but the second is not, so just + # ignore this. + pass + driver = None + ids_name = None + compat = None + compat_dict = {} + + elif ids_name: + compat_m = re_compat.search(line) + if compat_m: + compat_dict[compat_m.group(1)] = compat_m.group(3) + elif '};' in line: + of_match[ids_name] = compat_dict + ids_name = None + elif driver_match: + driver_name = driver_match.group(1) + driver = Driver(driver_name, fname) + else: + ids_m = re_ids.search(line) + if ids_m: + ids_name = ids_m.group(1) + + # Make the updates based on what we found + self._drivers.update(drivers) + self._of_match.update(of_match) + def scan_driver(self, fname): """Scan a driver file to build a list of driver names and aliases - This procedure will populate self._drivers and self._driver_aliases + It updates the following members: + _drivers - updated with new Driver records for each driver found + in the file + _of_match - updated with each compatible string found in the file + _compat_to_driver - Maps compatible string to Driver + _driver_aliases - Maps alias names to driver name Args fname: Driver filename to scan
@@ -147,12 +323,10 @@ class Scanner: print("Skipping file '%s' due to unicode error" % fname) return - # The following re will search for driver names declared as - # U_BOOT_DRIVER(driver_name) - drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff) - - for driver in drivers: - self._drivers[driver] = Driver(driver) + # If this file has any U_BOOT_DRIVER() declarations, process it to + # obtain driver information + if 'U_BOOT_DRIVER' in buff: + self._parse_driver(fname, buff) # The following re will search for driver aliases declared as # DM_DRIVER_ALIAS(alias, driver_name)
tools/dtoc/test_src_scan.py +127 -4
146 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 24/49 dtoc: Save scan information across test runs
In reply to Simon GlassAt present most of the tests scan the U-Boot source tree as part of their run. This information does not change across tests, so we can save time by remembering it.
Add a way to set up this information and use it for each test, taking a copy first, so as not to mess up the original.
This reduces the run time from about 1.6 seconds to 1.5 seconds on my machine. For code coverage (which cannot run in parallel), it reduces from 33 seconds to 5.
---
tools/dtoc/dtb_platdata.py | 11 ++++++++--- tools/dtoc/main.py | 2 ++ tools/dtoc/test_dtoc.py | 40 +++++++++++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 10 deletions(-)
tools/dtoc/dtb_platdata.py +8 -3
@@ -670,7 +670,8 @@ OUTPUT_FILES = { def run_steps(args, dtb_file, include_disabled, output, output_dirs, - warning_disabled=False, drivers_additional=None, basedir=None): + warning_disabled=False, drivers_additional=None, basedir=None, + scan=None): """Run all the steps of the dtoc tool Args:
@@ -687,6 +688,9 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, scanning basedir (str): Base directory of U-Boot source code. Defaults to the grandparent of this file's directory + scan (src_src.Scanner): Scanner from a previous run. This can help speed + up tests. Use None for normal operation + Raises: ValueError: if args has no command, or an unknown command """
@@ -695,9 +699,10 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, if output and output_dirs and any(output_dirs): raise ValueError('Must specify either output or output_dirs, not both') - scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional) + if not scan: + scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional) + scan.scan_drivers() plat = DtbPlatdata(scan, dtb_file, include_disabled) - scan.scan_drivers() plat.scan_dtb() plat.scan_tree() plat.scan_reg_sizes()
tools/dtoc/main.py +2 -0
@@ -53,6 +53,8 @@ def run_tests(processes, args): sys.argv = [sys.argv[0]] test_name = args and args[0] or None + test_dtoc.setup() + test_util.RunTestSuites( result, debug=True, verbosity=1, test_preserve_dirs=False, processes=processes, test_name=test_name, toolpath=[],
tools/dtoc/test_dtoc.py +33 -7
@@ -10,6 +10,7 @@ tool. """ import collections +import copy import glob import os import struct
@@ -20,6 +21,7 @@ from dtb_platdata import tab_to from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util +from dtoc import src_scan from dtoc.src_scan import conv_name_to_c from dtoc.src_scan import get_compat_name from patman import test_util
@@ -53,6 +55,9 @@ C_HEADER = '''/* #include <dt-structs.h> ''' +# Scanner saved from a previous run of the tests (to speed things up) +saved_scan = None + # This is a test so is allowed to access private things in the module it is # testing # pylint: disable=W0212
@@ -71,6 +76,19 @@ def get_dtb_file(dts_fname, capture_stderr=False): capture_stderr=capture_stderr) +def setup(): + global saved_scan + + # Disable warnings so that calls to get_normalized_compat_name() will not + # output things. + saved_scan = src_scan.Scanner(None, True, False) + saved_scan.scan_drivers() + +def copy_scan(): + """Get a copy of saved_scan so that each test can start clean""" + return copy.deepcopy(saved_scan) + + class TestDtoc(unittest.TestCase): """Tests for dtoc""" @classmethod
@@ -120,7 +138,8 @@ class TestDtoc(unittest.TestCase): dtb_file (str): Filename of .dtb file output (str): Filename of output file """ - dtb_platdata.run_steps(args, dtb_file, False, output, [], True) + dtb_platdata.run_steps(args, dtb_file, False, output, [], True, + None, None, scan=copy_scan()) def test_name(self): """Test conversion of device tree names to C identifiers"""
@@ -175,7 +194,9 @@ class TestDtoc(unittest.TestCase): """Test output from a device tree file with no nodes""" dtb_file = get_dtb_file('dtoc_test_empty.dts') output = tools.GetOutputFilename('output') - self.run_test(['struct'], dtb_file, output) + + # Run this one without saved_scan to complete test coverage + dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], True) with open(output) as infile: lines = infile.read().splitlines() self.assertEqual(HEADER.splitlines(), lines)
@@ -343,7 +364,8 @@ U_BOOT_DRVINFO(gpios_at_0) = { dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output, []) + dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], + scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(HEADER + '''
@@ -352,7 +374,8 @@ struct dtd_invalid { ''', data) with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, []) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], + scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -502,7 +525,8 @@ U_BOOT_DRVINFO(phandle_target) = { """Test that phandle targets are generated when unsing cd-gpios""" dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts') output = tools.GetOutputFilename('output') - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True, + scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -903,7 +927,8 @@ U_BOOT_DRVINFO(spl_test2) = { def test_output_conflict(self): """Test a conflict between and output dirs and output file""" with self.assertRaises(ValueError) as exc: - dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True) + dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True, + scan=copy_scan()) self.assertIn("Must specify either output or output_dirs, not both", str(exc.exception))
@@ -919,7 +944,8 @@ U_BOOT_DRVINFO(spl_test2) = { fnames = glob.glob(outdir + '/*') self.assertEqual(2, len(fnames)) - dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True) + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True, + scan=copy_scan()) fnames = glob.glob(outdir + '/*') self.assertEqual(4, len(fnames))
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 25/49 dtoc: Ignore unwanted files when scanning for drivers
In reply to Simon GlassWe should ignore anything in the .git directory or any of the build-sandbox, etc. directories created by 'make check'. These can confuse dtoc. Update the code to ignore these.
---
tools/dtoc/src_scan.py | 5 +++++ tools/dtoc/test_src_scan.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-)
tools/dtoc/src_scan.py +5 -0
@@ -345,6 +345,11 @@ class Scanner: This procedure will populate self._drivers and self._driver_aliases """ for (dirpath, _, filenames) in os.walk(self._basedir): + rel_path = dirpath[len(self._basedir):] + if rel_path.startswith('/'): + rel_path = rel_path[1:] + if rel_path.startswith('build') or rel_path.startswith('.git'): + continue for fname in filenames: if not fname.endswith('.c'): continue
tools/dtoc/test_src_scan.py +4 -1
@@ -117,7 +117,9 @@ class TestSrcScan(unittest.TestCase): fname_list = [] add_file('fname.c') + add_file('.git/ignoreme.c') add_file('dir/fname2.c') + add_file('build-sandbox/ignoreme2.c') # Mock out scan_driver and check that it is called with the # expected files
@@ -127,7 +129,8 @@ class TestSrcScan(unittest.TestCase): self.assertEqual(2, len(mocked.mock_calls)) self.assertEqual(mock.call(fname_list[0]), mocked.mock_calls[0]) - self.assertEqual(mock.call(fname_list[1]), + # .git file should be ignored + self.assertEqual(mock.call(fname_list[2]), mocked.mock_calls[1]) finally: shutil.rmtree(indir)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 26/49 dtoc: Collect priv/plat struct info from drivers
In reply to Simon GlassIn order to output variables to hold the priv/plat information used by each device, dtoc needs to know the struct for each. With this, it can declare this at build time:
u8 xxx_priv [sizeof(struct <name>)];
Collect the various struct names from the drivers.
---
tools/dtoc/src_scan.py | 25 +++++++++++++++++++++++-- tools/dtoc/test_src_scan.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-)
tools/dtoc/src_scan.py +23 -2
@@ -61,6 +61,11 @@ class Driver: value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None fname: Filename where the driver was found priv (str): struct name of the priv_auto member, e.g. 'serial_priv' + plat (str): struct name of the plat_auto member, e.g. 'serial_plat' + child_priv (str): struct name of the per_child_auto member, + e.g. 'pci_child_priv' + child_plat (str): struct name of the per_child_plat_auto member, + e.g. 'pci_child_plat' """ def __init__(self, name, fname): self.name = name
@@ -68,12 +73,16 @@ class Driver: self.uclass_id = None self.compat = None self.priv = '' + self.plat = '' + self.child_priv = '' + self.child_plat = '' def __eq__(self, other): return (self.name == other.name and self.uclass_id == other.uclass_id and self.compat == other.compat and - self.priv == other.priv) + self.priv == other.priv and + self.plat == other.plat) def __repr__(self): return ("Driver(name='%s', uclass_id='%s', compat=%s, priv=%s)" %
@@ -230,8 +239,11 @@ class Scanner: re_of_match = re.compile( r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,') - # Matches the struct name for priv + # Matches the struct name for priv, plat re_priv = self._get_re_for_member('priv_auto') + re_plat = self._get_re_for_member('plat_auto') + re_child_priv = self._get_re_for_member('per_child_auto') + re_child_plat = self._get_re_for_member('per_child_plat_auto') prefix = '' for line in buff.splitlines():
@@ -250,8 +262,17 @@ class Scanner: m_id = re_id.search(line) m_of_match = re_of_match.search(line) m_priv = re_priv.match(line) + m_plat = re_plat.match(line) + m_cplat = re_child_plat.match(line) + m_cpriv = re_child_priv.match(line) if m_priv: driver.priv = m_priv.group(1) + elif m_plat: + driver.plat = m_plat.group(1) + elif m_cplat: + driver.child_plat = m_cplat.group(1) + elif m_cpriv: + driver.child_priv = m_cpriv.group(1) elif m_id: driver.uclass_id = m_id.group(1) elif m_of_match:
tools/dtoc/test_src_scan.py +32 -0
@@ -231,3 +231,35 @@ U_BOOT_DRIVER(i2c_tegra) = { self.assertIn('i2c_tegra', scan._drivers) drv = scan._drivers['i2c_tegra'] self.assertEqual('i2c_tegra', drv.name) + + def test_priv(self): + """Test collection of struct info from drivers""" + buff = ''' +static const struct udevice_id test_ids[] = { + { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 }, + { } +}; + +U_BOOT_DRIVER(testing) = { + .name = "testing", + .id = UCLASS_I2C, + .of_match = test_ids, + .priv_auto = sizeof(struct some_priv), + .plat_auto = sizeof(struct some_plat), + .per_child_auto = sizeof(struct some_cpriv), + .per_child_plat_auto = sizeof(struct some_cplat), +}; +''' + scan = src_scan.Scanner(None, False, None) + scan._parse_driver('file.c', buff) + self.assertIn('testing', scan._drivers) + drv = scan._drivers['testing'] + self.assertEqual('testing', drv.name) + self.assertEqual('UCLASS_I2C', drv.uclass_id) + self.assertEqual( + {'nvidia,tegra114-i2c': 'TYPE_114'}, drv.compat) + self.assertEqual('some_priv', drv.priv) + self.assertEqual('some_plat', drv.plat) + self.assertEqual('some_cpriv', drv.child_priv) + self.assertEqual('some_cplat', drv.child_plat) + self.assertEqual(1, len(scan._drivers))
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 27/49 dtoc: Support scanning of uclasses
In reply to Simon GlassUclasses can have per-device private / platform data so dtoc needs to scan these drivers. This allows it to find out the size of this data so it can be allocated a build time.
Add a parser for uclass information, similar to drivers. Keep a dict of the uclasses that were found.
---
tools/dtoc/src_scan.py | 122 ++++++++++++++++++++++++++++++++++++ tools/dtoc/test_src_scan.py | 55 ++++++++++++++++ 2 files changed, 177 insertions(+)
tools/dtoc/src_scan.py +122 -0
@@ -89,6 +89,43 @@ class Driver: (self.name, self.uclass_id, self.compat, self.priv)) +class UclassDriver: + """Holds information about a uclass driver + + Attributes: + name: Uclass name, e.g. 'i2c' if the driver is for UCLASS_I2C + uclass_id: Uclass ID, e.g. 'UCLASS_I2C' + priv: struct name of the private data, e.g. 'i2c_priv' + per_dev_priv (str): struct name of the priv_auto member, e.g. 'spi_info' + per_dev_plat (str): struct name of the plat_auto member, e.g. 'i2c_chip' + per_child_priv (str): struct name of the per_child_auto member, + e.g. 'pci_child_priv' + per_child_plat (str): struct name of the per_child_plat_auto member, + e.g. 'pci_child_plat' + """ + def __init__(self, name): + self.name = name + self.uclass_id = None + self.priv = '' + self.per_dev_priv = '' + self.per_dev_plat = '' + self.per_child_priv = '' + self.per_child_plat = '' + + def __eq__(self, other): + return (self.name == other.name and + self.uclass_id == other.uclass_id and + self.priv == other.priv) + + def __repr__(self): + return ("UclassDriver(name='%s', uclass_id='%s')" % + (self.name, self.uclass_id)) + + def __hash__(self): + # We can use the uclass ID since it is unique among uclasses + return hash(self.uclass_id) + + class Scanner: """Scanning of the U-Boot source tree
@@ -111,6 +148,9 @@ class Scanner: key: Compatible string, e.g. 'rockchip,rk3288-grf' value: Driver data, e,g, 'ROCKCHIP_SYSCON_GRF', or None _compat_to_driver: Maps compatible strings to Driver + _uclass: Dict of uclass information + key: uclass name, e.g. 'UCLASS_I2C' + value: UClassDriver """ def __init__(self, basedir, warning_disabled, drivers_additional): """Set up a new Scanner
@@ -126,6 +166,7 @@ class Scanner: self._warning_disabled = warning_disabled self._of_match = {} self._compat_to_driver = {} + self._uclass = {} def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -179,6 +220,85 @@ class Scanner: """ return re.compile(r'^\s*.%s\s*=\s*sizeof\(struct\s+(.*)\),$' % member) + def _parse_uclass_driver(self, fname, buff): + """Parse a C file to extract uclass driver information contained within + + This parses UCLASS_DRIVER() structs to obtain various pieces of useful + information. + + It updates the following member: + _uclass: Dict of uclass information + key: uclass name, e.g. 'UCLASS_I2C' + value: UClassDriver + + Args: + fname (str): Filename being parsed (used for warnings) + buff (str): Contents of file + """ + uc_drivers = {} + + # Collect the driver name and associated Driver + driver = None + re_driver = re.compile(r'UCLASS_DRIVER\((.*)\)') + + # Collect the uclass ID, e.g. 'UCLASS_SPI' + re_id = re.compile(r'\s*\.id\s*=\s*(UCLASS_[A-Z0-9_]+)') + + # Matches the header/size information for uclass-private data + re_priv = self._get_re_for_member('priv_auto') + + # Set up parsing for the auto members + re_per_device_priv = self._get_re_for_member('per_device_auto') + re_per_device_plat = self._get_re_for_member('per_device_plat_auto') + re_per_child_priv = self._get_re_for_member('per_child_auto') + re_per_child_plat = self._get_re_for_member('per_child_plat_auto') + + prefix = '' + for line in buff.splitlines(): + # Handle line continuation + if prefix: + line = prefix + line + prefix = '' + if line.endswith('\\'): + prefix = line[:-1] + continue + + driver_match = re_driver.search(line) + + # If we have seen UCLASS_DRIVER()... + if driver: + m_id = re_id.search(line) + m_priv = re_priv.match(line) + m_per_dev_priv = re_per_device_priv.match(line) + m_per_dev_plat = re_per_device_plat.match(line) + m_per_child_priv = re_per_child_priv.match(line) + m_per_child_plat = re_per_child_plat.match(line) + if m_id: + driver.uclass_id = m_id.group(1) + elif m_priv: + driver.priv = m_priv.group(1) + elif m_per_dev_priv: + driver.per_dev_priv = m_per_dev_priv.group(1) + elif m_per_dev_plat: + driver.per_dev_plat = m_per_dev_plat.group(1) + elif m_per_child_priv: + driver.per_child_priv = m_per_child_priv.group(1) + elif m_per_child_plat: + driver.per_child_plat = m_per_child_plat.group(1) + elif '};' in line: + if not driver.uclass_id: + raise ValueError( + "%s: Cannot parse uclass ID in driver '%s'" % + (fname, driver.name)) + uc_drivers[driver.uclass_id] = driver + driver = None + + elif driver_match: + driver_name = driver_match.group(1) + driver = UclassDriver(driver_name) + + self._uclass.update(uc_drivers) + def _parse_driver(self, fname, buff): """Parse a C file to extract driver information contained within
@@ -348,6 +468,8 @@ class Scanner: # obtain driver information if 'U_BOOT_DRIVER' in buff: self._parse_driver(fname, buff) + if 'UCLASS_DRIVER' in buff: + self._parse_uclass_driver(fname, buff) # The following re will search for driver aliases declared as # DM_DRIVER_ALIAS(alias, driver_name)
tools/dtoc/test_src_scan.py +55 -0
64 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 28/49 dtoc: Support scanning of structs in header files
In reply to Simon GlassDrivers can have private / platform data contained in structs and these struct definitions are generally kept in header files. In order to generate build-time devices, dtoc needs to generate code that declares the data contained in those structs. This generated code must include the relevant header file, to avoid a build error.
We need a way for dtoc to scan header files for struct definitions. Then, when it wants to generate code that uses a struct, it can make sure it includes the correct header file, first.
Add a parser for struct information, similar to drivers. Keep a dict of the structs that were found.
---
tools/dtoc/src_scan.py | 86 +++++++++++++++++++++++++++++++++++-- tools/dtoc/test_src_scan.py | 45 +++++++++++++++++++ 2 files changed, 128 insertions(+), 3 deletions(-)
tools/dtoc/src_scan.py +83 -3
@@ -126,6 +126,22 @@ class UclassDriver: return hash(self.uclass_id) +class Struct: + """Holds information about a struct definition + + Attributes: + name: Struct name, e.g. 'fred' if the struct is 'struct fred' + fname: Filename containing the struct, in a format that C files can + include, e.g. 'asm/clk.h' + """ + def __init__(self, name, fname): + self.name = name + self.fname =fname + + def __repr__(self): + return ("Struct(name='%s', fname='%s')" % (self.name, self.fname)) + + class Scanner: """Scanning of the U-Boot source tree
@@ -151,6 +167,9 @@ class Scanner: _uclass: Dict of uclass information key: uclass name, e.g. 'UCLASS_I2C' value: UClassDriver + _structs: Dict of all structs found in U-Boot: + key: Name of struct + value: Struct object """ def __init__(self, basedir, warning_disabled, drivers_additional): """Set up a new Scanner
@@ -167,6 +186,7 @@ class Scanner: self._of_match = {} self._compat_to_driver = {} self._uclass = {} + self._structs = {} def get_normalized_compat_name(self, node): """Get a node's normalized compat name
@@ -204,6 +224,41 @@ class Scanner: return compat_list_c[0], compat_list_c[1:] + def _parse_structs(self, fname, buff): + """Parse a H file to extract struct definitions contained within + + This parses 'struct xx {' definitions to figure out what structs this + header defines. + + Args: + buff (str): Contents of file + fname (str): Filename (to use when printing errors) + """ + structs = {} + + re_struct = re.compile('^struct ([a-z0-9_]+) {$') + re_asm = re.compile('../arch/[a-z0-9]+/include/asm/(.*)') + prefix = '' + for line in buff.splitlines(): + # Handle line continuation + if prefix: + line = prefix + line + prefix = '' + if line.endswith('\\'): + prefix = line[:-1] + continue + + m_struct = re_struct.match(line) + if m_struct: + name = m_struct.group(1) + include_dir = os.path.join(self._basedir, 'include') + rel_fname = os.path.relpath(fname, include_dir) + m_asm = re_asm.match(rel_fname) + if m_asm: + rel_fname = 'asm/' + m_asm.group(1) + structs[name] = Struct(name, rel_fname) + self._structs.update(structs) + @classmethod def _get_re_for_member(cls, member): """_get_re_for_member: Get a compiled regular expression
@@ -482,6 +537,29 @@ class Scanner: continue self._driver_aliases[alias[1]] = alias[0] + def scan_header(self, fname): + """Scan a header file to build a list of struct definitions + + It updates the following members: + _structs - updated with new Struct records for each struct found + in the file + + Args + fname: header filename to scan + """ + with open(fname, encoding='utf-8') as inf: + try: + buff = inf.read() + except UnicodeDecodeError: + # This seems to happen on older Python versions + print("Skipping file '%s' due to unicode error" % fname) + return + + # If this file has any U_BOOT_DRIVER() declarations, process it to + # obtain driver information + if 'struct' in buff: + self._parse_structs(fname, buff) + def scan_drivers(self): """Scan the driver folders to build a list of driver names and aliases
@@ -494,9 +572,11 @@ class Scanner: if rel_path.startswith('build') or rel_path.startswith('.git'): continue for fname in filenames: - if not fname.endswith('.c'): - continue - self.scan_driver(dirpath + '/' + fname) + pathname = dirpath + '/' + fname + if fname.endswith('.c'): + self.scan_driver(pathname) + elif fname.endswith('.h'): + self.scan_header(pathname) for fname in self._drivers_additional: if not isinstance(fname, str) or len(fname) == 0:
tools/dtoc/test_src_scan.py +45 -0
48 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 29/49 dtoc: Move test files into a test/ directory
In reply to Simon GlassIt is confusing to have the test files in the same places as the implementation. Move them into a separate directory.
Add a helper function for test_dtoc, to avoid repeating the same path.
---
tools/dtoc/{ => test}/dtoc_test.dts | 0
tools/dtoc/{ => test}/dtoc_test_add_prop.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr32.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr32_64.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr64.dts | 0
tools/dtoc/{ => test}/dtoc_test_addr64_32.dts | 0
tools/dtoc/{ => test}/dtoc_test_aliases.dts | 0
tools/dtoc/{ => test}/dtoc_test_bad_reg.dts | 0
tools/dtoc/{ => test}/dtoc_test_bad_reg2.dts | 0
.../{ => test}/dtoc_test_driver_alias.dts | 0
tools/dtoc/{ => test}/dtoc_test_empty.dts | 0
.../{ => test}/dtoc_test_invalid_driver.dts | 0
tools/dtoc/{ => test}/dtoc_test_phandle.dts | 0
.../dtoc/{ => test}/dtoc_test_phandle_bad.dts | 0
.../{ => test}/dtoc_test_phandle_bad2.dts | 0
.../{ => test}/dtoc_test_phandle_cd_gpios.dts | 0
.../{ => test}/dtoc_test_phandle_reorder.dts | 0
.../{ => test}/dtoc_test_phandle_single.dts | 0
.../{ => test}/dtoc_test_scan_drivers.cxx | 0
tools/dtoc/{ => test}/dtoc_test_simple.dts | 0
tools/dtoc/test_dtoc.py | 2 +-
tools/dtoc/test_fdt.py | 31 +++++++++++++------
tools/dtoc/test_src_scan.py | 3 +-
23 files changed, 24 insertions(+), 12 deletions(-)
rename tools/dtoc/{ => test}/dtoc_test.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_add_prop.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr32.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr32_64.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr64.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_addr64_32.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_aliases.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_bad_reg.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_bad_reg2.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_driver_alias.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_empty.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_invalid_driver.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_bad.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_bad2.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_cd_gpios.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_reorder.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_phandle_single.dts (100%)
rename tools/dtoc/{ => test}/dtoc_test_scan_drivers.cxx (100%)
rename tools/dtoc/{ => test}/dtoc_test_simple.dts (100%)tools/dtoc/test/dtoc_test.dts renamed from tools/dtoc/dtoc_test.dts +0 -0
tools/dtoc/test/dtoc_test_add_prop.dts renamed from tools/dtoc/dtoc_test_add_prop.dts +0 -0
tools/dtoc/test/dtoc_test_addr32.dts renamed from tools/dtoc/dtoc_test_addr32.dts +0 -0
tools/dtoc/test/dtoc_test_addr32_64.dts renamed from tools/dtoc/dtoc_test_addr32_64.dts +0 -0
tools/dtoc/test/dtoc_test_addr64.dts renamed from tools/dtoc/dtoc_test_addr64.dts +0 -0
tools/dtoc/test/dtoc_test_addr64_32.dts renamed from tools/dtoc/dtoc_test_addr64_32.dts +0 -0
tools/dtoc/test/dtoc_test_aliases.dts renamed from tools/dtoc/dtoc_test_aliases.dts +0 -0
tools/dtoc/test/dtoc_test_bad_reg.dts renamed from tools/dtoc/dtoc_test_bad_reg.dts +0 -0
tools/dtoc/test/dtoc_test_bad_reg2.dts renamed from tools/dtoc/dtoc_test_bad_reg2.dts +0 -0
tools/dtoc/test/dtoc_test_driver_alias.dts renamed from tools/dtoc/dtoc_test_driver_alias.dts +0 -0
tools/dtoc/test/dtoc_test_empty.dts renamed from tools/dtoc/dtoc_test_empty.dts +0 -0
tools/dtoc/test/dtoc_test_invalid_driver.dts renamed from tools/dtoc/dtoc_test_invalid_driver.dts +0 -0
tools/dtoc/test/dtoc_test_phandle.dts renamed from tools/dtoc/dtoc_test_phandle.dts +0 -0
tools/dtoc/test/dtoc_test_phandle_bad.dts renamed from tools/dtoc/dtoc_test_phandle_bad.dts +0 -0
tools/dtoc/test/dtoc_test_phandle_bad2.dts renamed from tools/dtoc/dtoc_test_phandle_bad2.dts +0 -0
tools/dtoc/test/dtoc_test_phandle_cd_gpios.dts renamed from tools/dtoc/dtoc_test_phandle_cd_gpios.dts +0 -0
tools/dtoc/test/dtoc_test_phandle_reorder.dts renamed from tools/dtoc/dtoc_test_phandle_reorder.dts +0 -0
tools/dtoc/test/dtoc_test_phandle_single.dts renamed from tools/dtoc/dtoc_test_phandle_single.dts +0 -0
tools/dtoc/test/dtoc_test_scan_drivers.cxx renamed from tools/dtoc/dtoc_test_scan_drivers.cxx +0 -0
tools/dtoc/test/dtoc_test_simple.dts renamed from tools/dtoc/dtoc_test_simple.dts +0 -0
tools/dtoc/test_dtoc.py +1 -1
@@ -72,7 +72,7 @@ def get_dtb_file(dts_fname, capture_stderr=False): Returns: str: Filename of compiled file in output directory """ - return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, dts_fname), + return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, 'test', dts_fname), capture_stderr=capture_stderr)
tools/dtoc/test_fdt.py +21 -10
@@ -48,6 +48,17 @@ def _GetPropertyValue(dtb, node, prop_name): data = dtb.GetContents()[offset:offset + len(prop.value)] return prop, [chr(x) for x in data] +def find_dtb_file(dts_fname): + """Locate a test file in the test/ directory + + Args: + dts_fname (str): Filename to find, e.g. 'dtoc_test_simple.dts] + + Returns: + str: Path to the test filename + """ + return os.path.join('tools/dtoc/test', dts_fname) + class TestFdt(unittest.TestCase): """Tests for the Fdt module
@@ -64,7 +75,7 @@ class TestFdt(unittest.TestCase): tools.FinaliseOutputDir() def setUp(self): - self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts') + self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts')) def testFdt(self): """Test that we can open an Fdt"""
@@ -141,7 +152,7 @@ class TestNode(unittest.TestCase): tools.FinaliseOutputDir() def setUp(self): - self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts') + self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts')) self.node = self.dtb.GetNode('/spl-test') def testOffset(self):
@@ -203,7 +214,7 @@ class TestNode(unittest.TestCase): def testLookupPhandle(self): """Test looking up a single phandle""" - dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts') + dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts')) node = dtb.GetNode('/phandle-source2') prop = node.props['clocks'] target = dtb.GetNode('/phandle-target')
@@ -222,7 +233,7 @@ class TestProp(unittest.TestCase): tools.FinaliseOutputDir() def setUp(self): - self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts') + self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts')) self.node = self.dtb.GetNode('/spl-test') self.fdt = self.dtb.GetFdtObj()
@@ -230,7 +241,7 @@ class TestProp(unittest.TestCase): self.assertEqual(None, self.dtb.GetNode('missing')) def testPhandle(self): - dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts') + dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts')) node = dtb.GetNode('/phandle-source2') prop = node.props['clocks'] self.assertTrue(fdt32_to_cpu(prop.value) > 0)
@@ -482,7 +493,7 @@ class TestFdtUtil(unittest.TestCase): tools.FinaliseOutputDir() def setUp(self): - self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts') + self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts')) self.node = self.dtb.GetNode('/spl-test') def testGetInt(self):
@@ -525,7 +536,7 @@ class TestFdtUtil(unittest.TestCase): str(e.exception)) def testGetPhandleList(self): - dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts') + dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts')) node = dtb.GetNode('/phandle-source2') self.assertEqual([1], fdt_util.GetPhandleList(node, 'clocks')) node = dtb.GetNode('/phandle-source')
@@ -545,7 +556,7 @@ class TestFdtUtil(unittest.TestCase): self.assertEqual(0, fdt_util.fdt_cells_to_cpu(val, 0)) self.assertEqual(2, fdt_util.fdt_cells_to_cpu(val, 1)) - dtb2 = fdt.FdtScan('tools/dtoc/dtoc_test_addr64.dts') + dtb2 = fdt.FdtScan(find_dtb_file('dtoc_test_addr64.dts')) node1 = dtb2.GetNode('/test1') val = node1.props['reg'].value self.assertEqual(0x1234, fdt_util.fdt_cells_to_cpu(val, 2))
@@ -559,7 +570,7 @@ class TestFdtUtil(unittest.TestCase): def testEnsureCompiled(self): """Test a degenerate case of this function (file already compiled)""" - dtb = fdt_util.EnsureCompiled('tools/dtoc/dtoc_test_simple.dts') + dtb = fdt_util.EnsureCompiled(find_dtb_file('dtoc_test_simple.dts')) self.assertEqual(dtb, fdt_util.EnsureCompiled(dtb)) def testEnsureCompiledTmpdir(self):
@@ -568,7 +579,7 @@ class TestFdtUtil(unittest.TestCase): old_outdir = tools.outdir tools.outdir= None tmpdir = tempfile.mkdtemp(prefix='test_fdt.') - dtb = fdt_util.EnsureCompiled('tools/dtoc/dtoc_test_simple.dts', + dtb = fdt_util.EnsureCompiled(find_dtb_file('dtoc_test_simple.dts'), tmpdir) self.assertEqual(tmpdir, os.path.dirname(dtb)) shutil.rmtree(tmpdir)
tools/dtoc/test_src_scan.py +2 -1
@@ -59,7 +59,8 @@ class TestSrcScan(unittest.TestCase): def test_additional(self): """Test with additional drivers to scan""" scan = src_scan.Scanner( - None, True, [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) + None, True, + [None, '', 'tools/dtoc/test/dtoc_test_scan_drivers.cxx']) scan.scan_drivers() self.assertIn('sandbox_gpio_alias2', scan._driver_aliases) self.assertEqual('sandbox_gpio',
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 30/49 dtoc: Rename sandbox_i2c_test and sandbox_pmic_test
In reply to Simon GlassThese have '_test' suffixes which are not present on the drivers in the source code. Drop the suffixes to avoid a mismatch when scanning.
---
tools/dtoc/test/dtoc_test_simple.dts | 4 ++-- tools/dtoc/test_dtoc.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
tools/dtoc/test/dtoc_test_simple.dts +2 -2
@@ -45,12 +45,12 @@ }; i2c at 0 { - compatible = "sandbox,i2c-test"; + compatible = "sandbox,i2c"; u-boot,dm-pre-reloc; #address-cells = <1>; #size-cells = <0>; pmic at 9 { - compatible = "sandbox,pmic-test"; + compatible = "sandbox,pmic"; u-boot,dm-pre-reloc; reg = <9>; low-power;
tools/dtoc/test_dtoc.py +6 -6
@@ -207,9 +207,9 @@ class TestDtoc(unittest.TestCase): self.assertEqual(C_HEADER.splitlines() + [''], lines) struct_text = HEADER + ''' -struct dtd_sandbox_i2c_test { +struct dtd_sandbox_i2c { }; -struct dtd_sandbox_pmic_test { +struct dtd_sandbox_pmic { \tbool\t\tlow_power; \tfdt64_t\t\treg[2]; };
@@ -229,22 +229,22 @@ struct dtd_sandbox_spl_test { platdata_text = C_HEADER + ''' /* Node /i2c at 0 index 0 */ -static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { +static struct dtd_sandbox_i2c dtv_i2c_at_0 = { }; U_BOOT_DRVINFO(i2c_at_0) = { -\t.name\t\t= "sandbox_i2c_test", +\t.name\t\t= "sandbox_i2c", \t.plat\t= &dtv_i2c_at_0, \t.plat_size\t= sizeof(dtv_i2c_at_0), \t.parent_idx\t= -1, }; /* Node /i2c at 0/pmic at 9 index 1 */ -static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = { +static struct dtd_sandbox_pmic dtv_pmic_at_9 = { \t.low_power\t\t= true, \t.reg\t\t\t= {0x9, 0x0}, }; U_BOOT_DRVINFO(pmic_at_9) = { -\t.name\t\t= "sandbox_pmic_test", +\t.name\t\t= "sandbox_pmic", \t.plat\t= &dtv_pmic_at_9, \t.plat_size\t= sizeof(dtv_pmic_at_9), \t.parent_idx\t= 0,
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 31/49 dtoc: Add some extra properties to nodes
In reply to Simon GlassIt is convenient to attach drivers, etc. to nodes so that we can use the Node object as the main data structure in this module.
Add a function which adds the new properties, along with documentation.
---
tools/dtoc/dtb_platdata.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
tools/dtoc/dtb_platdata.py +37 -0
@@ -354,8 +354,44 @@ class DtbPlatdata(): self.scan_node(self._fdt.GetRoot(), valid_nodes) self._valid_nodes = sorted(valid_nodes, key=lambda x: conv_name_to_c(x.name)) + + def prepare_nodes(self): + """Add extra properties to the nodes we are using + + The following properties are added for use by dtoc: + idx: Index number of this node (0=first, etc.) + struct_name: Name of the struct dtd used by this node + var_name: C name for this node + child_devs: List of child devices for this node, each a None + child_refs: Dict of references for each child: + key: Position in child list (-1=head, 0=first, 1=second, ... + n-1=last, n=head) + seq: Sequence number of the device (unique within its uclass), or + -1 not not known yet + dev_ref: Reference to this device, e.g. 'DM_DEVICE_REF(serial)' + driver: Driver record for this node, or None if not known + uclass: Uclass record for this node, or None if not known + uclass_seq: Position of this device within the uclass list (0=first, + n-1=last) + parent_seq: Position of this device within it siblings (0=first, + n-1=last) + parent_driver: Driver record of the node's parent, or None if none. + We don't use node.parent.driver since node.parent may not be in + the list of valid nodes + """ for idx, node in enumerate(self._valid_nodes): node.idx = idx + node.struct_name, _ = self._scan.get_normalized_compat_name(node) + node.var_name = conv_name_to_c(node.name) + node.child_devs = [] + node.child_refs = {} + node.seq = -1 + node.dev_ref = None + node.driver = None + node.uclass = None + node.uclass_seq = None + node.parent_seq = None + node.parent_driver = None @staticmethod def get_num_cells(node):
@@ -705,6 +741,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, plat = DtbPlatdata(scan, dtb_file, include_disabled) plat.scan_dtb() plat.scan_tree() + plat.prepare_nodes() plat.scan_reg_sizes() plat.setup_output_dirs(output_dirs) plat.scan_structs()
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 32/49 dtoc: Make use of node properties
In reply to Simon GlassNow that we have these available, use them instead of recalculating things each time.
---
tools/dtoc/dtb_platdata.py | 45 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 26 deletions(-)
tools/dtoc/dtb_platdata.py +19 -26
@@ -470,7 +470,6 @@ class DtbPlatdata(): """ structs = self._struct_data for node in self._valid_nodes: - node_name, _ = self._scan.get_normalized_compat_name(node) fields = {} # Get a list of all the valid properties in this node.
@@ -478,9 +477,9 @@ class DtbPlatdata(): if name not in PROP_IGNORE_LIST and name[0] != '#': fields[name] = copy.deepcopy(prop) - # If we've seen this node_name before, update the existing struct. - if node_name in structs: - struct = structs[node_name] + # If we've seen this struct_name before, update the existing struct + if node.struct_name in structs: + struct = structs[node.struct_name] for name, prop in fields.items(): oldprop = struct.get(name) if oldprop:
@@ -490,11 +489,10 @@ class DtbPlatdata(): # Otherwise store this as a new struct. else: - structs[node_name] = fields + structs[node.struct_name] = fields for node in self._valid_nodes: - node_name, _ = self._scan.get_normalized_compat_name(node) - struct = structs[node_name] + struct = structs[node.struct_name] for name, prop in node.props.items(): if name not in PROP_IGNORE_LIST and name[0] != '#': prop.Widen(struct[name])
@@ -598,23 +596,22 @@ class DtbPlatdata(): self.buf(', '.join(vals[i:i + 8])) self.buf('}') - def _declare_device(self, var_name, struct_name, node_parent): + def _declare_device(self, node): """Add a device declaration to the output This declares a U_BOOT_DRVINFO() for the device being processed Args: - var_name (str): C name for the node - struct_name (str): Name for the dt struct associated with the node - node_parent (Node): Parent of the node (or None if none) + node: Node to process """ - self.buf('U_BOOT_DRVINFO(%s) = {\n' % var_name) - self.buf('\t.name\t\t= "%s",\n' % struct_name) - self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name)) - self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name)) + self.buf('U_BOOT_DRVINFO(%s) = {\n' % node.var_name) + self.buf('\t.name\t\t= "%s",\n' % node.struct_name) + self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, node.var_name)) + self.buf('\t.plat_size\t= sizeof(%s%s),\n' % + (VAL_PREFIX, node.var_name)) idx = -1 - if node_parent and node_parent in self._valid_nodes: - idx = node_parent.idx + if node.parent and node.parent in self._valid_nodes: + idx = node.parent.idx self.buf('\t.parent_idx\t= %d,\n' % idx) self.buf('};\n') self.buf('\n')
@@ -638,16 +635,14 @@ class DtbPlatdata(): self.buf(get_value(prop.type, prop.value)) self.buf(',\n') - def _output_values(self, var_name, struct_name, node): + def _output_values(self, node): """Output the definition of a device's struct values Args: - var_name (str): C name for the node - struct_name (str): Name for the dt struct associated with the node - node (Node): Node being output + node (Node): Node to output """ self.buf('static struct %s%s %s%s = {\n' % - (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name)) + (STRUCT_PREFIX, node.struct_name, VAL_PREFIX, node.var_name)) for pname in sorted(node.props): self._output_prop(node, node.props[pname]) self.buf('};\n')
@@ -658,12 +653,10 @@ class DtbPlatdata(): Args: node (fdt.Node): node to output """ - struct_name, _ = self._scan.get_normalized_compat_name(node) - var_name = conv_name_to_c(node.name) self.buf('/* Node %s index %d */\n' % (node.path, node.idx)) - self._output_values(var_name, struct_name, node) - self._declare_device(var_name, struct_name, node.parent) + self._output_values(node) + self._declare_device(node) self.out(''.join(self.get_buf()))
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 33/49 dtoc: Process nodes to set up required properties
In reply to Simon GlassAdd logic to assign property values to nodes as required by dtoc. The references allow nodes to refer to each other in C code. The macros used by dtoc are not yet defined in driver model. They will be added along with the actual driver model implementation.
---
tools/dtoc/dtb_platdata.py | 37 +++++++++++++++++++ tools/dtoc/src_scan.py | 11 ++++++ tools/dtoc/test_dtoc.py | 76 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+)
tools/dtoc/dtb_platdata.py +37 -0
@@ -647,6 +647,38 @@ class DtbPlatdata(): self._output_prop(node, node.props[pname]) self.buf('};\n') + def process_nodes(self, need_drivers): + nodes_to_output = list(self._valid_nodes) + + for node in nodes_to_output: + node.dev_ref = 'DM_DEVICE_REF(%s)' % node.var_name + driver = self._scan.get_driver(node.struct_name) + if not driver: + if not need_drivers: + continue + raise ValueError("Cannot parse/find driver for '%s'" % + node.struct_name) + node.driver = driver + parent_driver = None + if node.parent in self._valid_nodes: + parent_driver = self._scan.get_driver(node.parent.struct_name) + if not parent_driver: + if not need_drivers: + continue + raise ValueError( + "Cannot parse/find parent driver '%s' for '%s'" % + (node.parent.struct_name, node.struct_name)) + node.parent_seq = len(node.parent.child_devs) + node.parent.child_devs.append(node) + node.parent.child_refs[node.parent_seq] = \ + '&%s->sibling_node' % node.dev_ref + node.parent_driver = parent_driver + + for node in nodes_to_output: + ref = '&%s->child_head' % node.dev_ref + node.child_refs[-1] = ref + node.child_refs[len(node.child_devs)] = ref + def output_node(self, node): """Output the C code for a node
@@ -731,6 +763,9 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, if not scan: scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional) scan.scan_drivers() + do_process = True + else: + do_process = False plat = DtbPlatdata(scan, dtb_file, include_disabled) plat.scan_dtb() plat.scan_tree()
@@ -739,6 +774,8 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, plat.setup_output_dirs(output_dirs) plat.scan_structs() plat.scan_phandles() + if do_process: + plat.process_nodes(False) cmds = args[0].split(',') if 'all' in cmds:
tools/dtoc/src_scan.py +11 -0
@@ -188,6 +188,17 @@ class Scanner: self._uclass = {} self._structs = {} + def get_driver(self, name): + """Get a driver given its name + + Args: + name (str): Driver name + + Returns: + Driver: Driver or None if not found + """ + return self._drivers.get(name) + def get_normalized_compat_name(self, node): """Get a node's normalized compat name
tools/dtoc/test_dtoc.py +76 -0
79 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 34/49 dtoc: Track nodes which are actually used
In reply to Simon GlassMark all nodes that are actually used, so we can perform extra checks on them.
---
tools/dtoc/dtb_platdata.py | 3 +++ tools/dtoc/src_scan.py | 25 ++++++++++++++++++++++--- tools/dtoc/test_dtoc.py | 11 +++++++++++ tools/dtoc/test_src_scan.py | 2 +- 4 files changed, 37 insertions(+), 4 deletions(-)
tools/dtoc/dtb_platdata.py +3 -0
@@ -650,6 +650,9 @@ class DtbPlatdata(): def process_nodes(self, need_drivers): nodes_to_output = list(self._valid_nodes) + # Figure out which drivers we actually use + self._scan.mark_used(nodes_to_output) + for node in nodes_to_output: node.dev_ref = 'DM_DEVICE_REF(%s)' % node.var_name driver = self._scan.get_driver(node.struct_name)
tools/dtoc/src_scan.py +22 -3
@@ -66,6 +66,7 @@ class Driver: e.g. 'pci_child_priv' child_plat (str): struct name of the per_child_plat_auto member, e.g. 'pci_child_plat' + used (bool): True if the driver is used by the structs being output """ def __init__(self, name, fname): self.name = name
@@ -76,17 +77,19 @@ class Driver: self.plat = '' self.child_priv = '' self.child_plat = '' + self.used = False def __eq__(self, other): return (self.name == other.name and self.uclass_id == other.uclass_id and self.compat == other.compat and self.priv == other.priv and - self.plat == other.plat) + self.plat == other.plat and + self.used == other.used) def __repr__(self): - return ("Driver(name='%s', uclass_id='%s', compat=%s, priv=%s)" % - (self.name, self.uclass_id, self.compat, self.priv)) + return ("Driver(name='%s', used=%s, uclass_id='%s', compat=%s, priv=%s)" % + (self.name, self.used, self.uclass_id, self.compat, self.priv)) class UclassDriver:
@@ -596,3 +599,19 @@ class Scanner: self.scan_driver(fname) else: self.scan_driver(self._basedir + '/' + fname) + + def mark_used(self, nodes): + """Mark the drivers associated with a list of nodes as 'used' + + This takes a list of nodes, finds the driver for each one and marks it + as used. + + Args: + nodes (list of None): Nodes that are in use + """ + # Figure out which drivers we actually use + for node in nodes: + struct_name, _ = self.get_normalized_compat_name(node) + driver = self._drivers.get(struct_name) + if driver: + driver.used = True
tools/dtoc/test_dtoc.py +11 -0
@@ -1029,3 +1029,14 @@ U_BOOT_DRVINFO(spl_test2) = { plat.process_nodes(True) self.assertIn("Cannot parse/find driver for 'sandbox_pmic", str(exc.exception)) + + def test_process_nodes_used(self): + """Test processing nodes to add various info""" + plat, scan = self.setup_process_test() + plat.process_nodes(True) + + pmic = scan._drivers['sandbox_pmic'] + self.assertTrue(pmic.used) + + gpio = scan._drivers['sandbox_gpio'] + self.assertFalse(gpio.used)
tools/dtoc/test_src_scan.py +1 -1
@@ -98,7 +98,7 @@ class TestSrcScan(unittest.TestCase): drv3.uclass_id = i2c drv3.compat = compat self.assertEqual( - "Driver(name='fred', uclass_id='I2C_UCLASS', " + "Driver(name='fred', used=False, uclass_id='I2C_UCLASS', " "compat={'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF', " "'rockchip,rk3288-srf': None}, priv=)", str(drv1)) self.assertEqual(drv1, drv3)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 35/49 dtoc: Support tracking the phase of U-Boot
In reply to Simon GlassU-Boot operates in several phases, typically TPL, SPL and U-Boot proper. The latter does not use dtoc.
In some rare cases different drivers are used for two phases. For example, in TPL it may not be necessary to use the full PCI subsystem, so a simple driver can be used instead.
This works in the build system simply by compiling in one driver or the other (e.g. PCI driver + uclass for SPL; simple_bus for TPL). But dtoc has no way of knowing which code is compiled in for which phase, since it does not inspect Makefiles or dependency graphs.
So to make this work for dtoc, we need to be able to explicitly mark drivers with their phase. This is done by adding an empty macro to the driver. Add support for this in dtoc.
---
include/dm/device.h | 16 ++++++++++++++++ tools/dtoc/dtb_platdata.py | 7 +++++-- tools/dtoc/main.py | 5 ++++- tools/dtoc/src_scan.py | 12 +++++++++++- tools/dtoc/test_dtoc.py | 16 ++++++++-------- tools/dtoc/test_src_scan.py | 3 +++ 6 files changed, 47 insertions(+), 12 deletions(-)
include/dm/device.h +16 -0
@@ -345,6 +345,22 @@ struct driver {*/ #define DM_DRIVER_ALIAS (__name, __alias) +/** +* Declare a macro to indicate which phase of U-Boot this driver is fore. +* +* +* This macro produces no code but its information will be parsed by dtoc. The +* macro can be only be used once in a driver. Put it within the U_BOOT_DRIVER() +* declaration, e.g.: +* +* U_BOOT_DRIVER(cpu) = { +* .name = ... +* ... +* DM_PHASE(tpl) +* }; +*/ +#define DM_PHASE (_phase) +/** * dev_get_plat() - Get the platform data for a device *
tools/dtoc/dtb_platdata.py +5 -2
@@ -733,7 +733,7 @@ OUTPUT_FILES = { } -def run_steps(args, dtb_file, include_disabled, output, output_dirs, +def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, warning_disabled=False, drivers_additional=None, basedir=None, scan=None): """Run all the steps of the dtoc tool
@@ -746,6 +746,8 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, output_dirs (tuple of str): Directory to put C output files Directory to put H output files + phase: The phase of U-Boot that we are generating data for, e.g. 'spl' + or 'tpl'. None if not known warning_disabled (bool): True to avoid showing warnings about missing drivers drivers_additional (list): List of additional drivers to use during
@@ -764,7 +766,8 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, raise ValueError('Must specify either output or output_dirs, not both') if not scan: - scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional) + scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional, + phase) scan.scan_drivers() do_process = True else:
tools/dtoc/main.py +4 -1
@@ -85,6 +85,8 @@ parser.add_option('--include-disabled', action='store_true', help='Include disabled nodes') parser.add_option('-o', '--output', action='store', help='Select output filename') +parser.add_option('-p', '--phase', type=str, + help='set phase of U-Boot this invocation is for (spl/tpl)') parser.add_option('-P', '--processes', type=int, help='set number of processes to use for running tests') parser.add_option('-t', '--test', action='store_true', dest='test',
@@ -104,4 +106,5 @@ elif options.test_coverage: else: dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled, options.output, - [options.c_output_dir, options.h_output_dir]) + [options.c_output_dir, options.h_output_dir], + phase=options.phase)
tools/dtoc/src_scan.py +11 -1
@@ -67,6 +67,7 @@ class Driver: child_plat (str): struct name of the per_child_plat_auto member, e.g. 'pci_child_plat' used (bool): True if the driver is used by the structs being output + phase (str): Which phase of U-Boot to use this driver """ def __init__(self, name, fname): self.name = name
@@ -78,6 +79,7 @@ class Driver: self.child_priv = '' self.child_plat = '' self.used = False + self.phase = '' def __eq__(self, other): return (self.name == other.name and
@@ -173,8 +175,10 @@ class Scanner: _structs: Dict of all structs found in U-Boot: key: Name of struct value: Struct object + _phase: The phase of U-Boot that we are generating data for, e.g. 'spl' + or 'tpl'. None if not known """ - def __init__(self, basedir, warning_disabled, drivers_additional): + def __init__(self, basedir, warning_disabled, drivers_additional, phase=''): """Set up a new Scanner """ if not basedir:
@@ -190,6 +194,7 @@ class Scanner: self._compat_to_driver = {} self._uclass = {} self._structs = {} + self._phase = phase def get_driver(self, name): """Get a driver given its name
@@ -428,6 +433,8 @@ class Scanner: re_of_match = re.compile( r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,') + re_phase = re.compile('^\s*DM_PHASE\((.*)\).*$') + # Matches the struct name for priv, plat re_priv = self._get_re_for_member('priv_auto') re_plat = self._get_re_for_member('plat_auto')
@@ -454,6 +461,7 @@ class Scanner: m_plat = re_plat.match(line) m_cplat = re_child_plat.match(line) m_cpriv = re_child_priv.match(line) + m_phase = re_phase.match(line) if m_priv: driver.priv = m_priv.group(1) elif m_plat:
@@ -466,6 +474,8 @@ class Scanner: driver.uclass_id = m_id.group(1) elif m_of_match: compat = m_of_match.group(2) + elif m_phase: + driver.phase = m_phase.group(1) elif '};' in line: if driver.uclass_id and compat: if compat not in of_match:
tools/dtoc/test_dtoc.py +8 -8
@@ -138,8 +138,8 @@ class TestDtoc(unittest.TestCase): dtb_file (str): Filename of .dtb file output (str): Filename of output file """ - dtb_platdata.run_steps(args, dtb_file, False, output, [], True, - None, None, scan=copy_scan()) + dtb_platdata.run_steps(args, dtb_file, False, output, [], None, + warning_disabled=True, scan=copy_scan()) def test_name(self): """Test conversion of device tree names to C identifiers"""
@@ -365,7 +365,7 @@ U_BOOT_DRVINFO(gpios_at_0) = { output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], - scan=copy_scan()) + None, scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(HEADER + '''
@@ -375,7 +375,7 @@ struct dtd_invalid { with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], - scan=copy_scan()) + None, scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -927,8 +927,8 @@ U_BOOT_DRVINFO(spl_test2) = { def test_output_conflict(self): """Test a conflict between and output dirs and output file""" with self.assertRaises(ValueError) as exc: - dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True, - scan=copy_scan()) + dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], None, + warning_disabled=True, scan=copy_scan()) self.assertIn("Must specify either output or output_dirs, not both", str(exc.exception))
@@ -944,8 +944,8 @@ U_BOOT_DRVINFO(spl_test2) = { fnames = glob.glob(outdir + '/*') self.assertEqual(2, len(fnames)) - dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True, - scan=copy_scan()) + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], None, + warning_disabled=True, scan=copy_scan()) fnames = glob.glob(outdir + '/*') self.assertEqual(4, len(fnames))
tools/dtoc/test_src_scan.py +3 -0
@@ -233,6 +233,7 @@ U_BOOT_DRIVER(i2c_tegra) = { self.assertIn('i2c_tegra', scan._drivers) drv = scan._drivers['i2c_tegra'] self.assertEqual('i2c_tegra', drv.name) + self.assertEqual('', drv.phase) def test_priv(self): """Test collection of struct info from drivers"""
@@ -250,6 +251,7 @@ U_BOOT_DRIVER(testing) = { .plat_auto = sizeof(struct some_plat), .per_child_auto = sizeof(struct some_cpriv), .per_child_plat_auto = sizeof(struct some_cplat), + DM_PHASE(tpl) }; ''' scan = src_scan.Scanner(None, False, None)
@@ -264,6 +266,7 @@ U_BOOT_DRIVER(testing) = { self.assertEqual('some_plat', drv.plat) self.assertEqual('some_cpriv', drv.child_priv) self.assertEqual('some_cplat', drv.child_plat) + self.assertEqual('tpl', drv.phase) self.assertEqual(1, len(scan._drivers)) def test_uclass_scan(self):
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 36/49 Makefile: Pass the U-Boot phase to dtoc
In reply to Simon GlassPass the U-Boot phase as a parameter so dtoc can use it. At present it is ether "spl" or "tpl".
---
scripts/Makefile.spl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.spl +1 -1
@@ -309,7 +309,7 @@ $(obj)/$(SPL_BIN).dtb: $(obj)/dts/dt-$(SPL_NAME).dtb FORCE pythonpath = PYTHONPATH=scripts/dtc/pylibfdt DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \ - -d $(obj)/$(SPL_BIN).dtb + -d $(obj)/$(SPL_BIN).dtb -p $(SPL_NAME) quiet_cmd_dtoc = DTOC $@ cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 37/49 dtoc: Support headers needed for drivers
In reply to Simon GlassTypically dtoc can detect the header file needed for a driver by looking for the structs that it uses. For example, if a driver as a .priv_auto that uses 'struct serial_priv', then dtoc can search header files for the definition of that struct and use the file.
In some cases, enums are used in drivers, typically with the .data field of struct udevice_id. Since dtoc does not support searching for these, add a way to tell dtoc which header to use. This works as a macro included in the driver definition.
---
include/dm/device.h | 18 ++++++++++++++++++ tools/dtoc/src_scan.py | 7 +++++++ tools/dtoc/test_src_scan.py | 4 ++++ 3 files changed, 29 insertions(+)
include/dm/device.h +18 -0
@@ -361,6 +361,24 @@ struct driver {*/ #define DM_PHASE (_phase) +/** +* Declare a macro to declare a header needed for a driver. Often the correct +* header can be found automatically, but only for struct declarations. For +* enums and #defines used in the driver declaration and declared in a different +* header from the structs, this macro must be used. +* +* This macro produces no code but its information will be parsed by dtoc. The +* macro can be used multiple times with different headers, for the same driver. +* Put it within the U_BOOT_DRIVER() declaration, e.g.: +* +* U_BOOT_DRIVER(cpu) = { +* .name = ... +* ... +* DM_HEADER(<asm/cpu.h>) +* }; +*/ +#define DM_HEADER (_hdr) +/** * dev_get_plat() - Get the platform data for a device *
tools/dtoc/src_scan.py +7 -0
@@ -68,6 +68,8 @@ class Driver: e.g. 'pci_child_plat' used (bool): True if the driver is used by the structs being output phase (str): Which phase of U-Boot to use this driver + headers (list): List of header files needed for this driver (each a str) + e.g. ['<asm/cpu.h>'] """ def __init__(self, name, fname): self.name = name
@@ -80,6 +82,7 @@ class Driver: self.child_plat = '' self.used = False self.phase = '' + self.headers = [] def __eq__(self, other): return (self.name == other.name and
@@ -434,6 +437,7 @@ class Scanner: r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,') re_phase = re.compile('^\s*DM_PHASE\((.*)\).*$') + re_hdr = re.compile('^\s*DM_HEADER\((.*)\).*$') # Matches the struct name for priv, plat re_priv = self._get_re_for_member('priv_auto')
@@ -462,6 +466,7 @@ class Scanner: m_cplat = re_child_plat.match(line) m_cpriv = re_child_priv.match(line) m_phase = re_phase.match(line) + m_hdr = re_hdr.match(line) if m_priv: driver.priv = m_priv.group(1) elif m_plat:
@@ -476,6 +481,8 @@ class Scanner: compat = m_of_match.group(2) elif m_phase: driver.phase = m_phase.group(1) + elif m_hdr: + driver.headers.append(m_hdr.group(1)) elif '};' in line: if driver.uclass_id and compat: if compat not in of_match:
tools/dtoc/test_src_scan.py +4 -0
@@ -234,6 +234,7 @@ U_BOOT_DRIVER(i2c_tegra) = { drv = scan._drivers['i2c_tegra'] self.assertEqual('i2c_tegra', drv.name) self.assertEqual('', drv.phase) + self.assertEqual([], drv.headers) def test_priv(self): """Test collection of struct info from drivers"""
@@ -252,6 +253,8 @@ U_BOOT_DRIVER(testing) = { .per_child_auto = sizeof(struct some_cpriv), .per_child_plat_auto = sizeof(struct some_cplat), DM_PHASE(tpl) + DM_HEADER(<i2c.h>) + DM_HEADER(<asm/clk.h>) }; ''' scan = src_scan.Scanner(None, False, None)
@@ -267,6 +270,7 @@ U_BOOT_DRIVER(testing) = { self.assertEqual('some_cpriv', drv.child_priv) self.assertEqual('some_cplat', drv.child_plat) self.assertEqual('tpl', drv.phase) + self.assertEqual(['<i2c.h>', '<asm/clk.h>'], drv.headers) self.assertEqual(1, len(scan._drivers)) def test_uclass_scan(self):
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 38/49 dtoc: Process driver aliases along with drivers
In reply to Simon GlassInstead of using a separate step for this processing, handle it while scanning its associated driver. This allows us to drop the code coverage exception in this case.
Note that only files containing drivers are scanned by dtoc, so aliases declared in a file that doesn't hold a driver will not be noticed. It would be confusing to put them anywhere other than in the driver that they relate to, but update the documentation to say this explicitly, just in case.
---
doc/driver-model/of-plat.rst | 3 ++- tools/dtoc/src_scan.py | 16 +++++----------- tools/dtoc/test/dtoc_test_scan_drivers.cxx | 4 ++++ 3 files changed, 11 insertions(+), 12 deletions(-)
doc/driver-model/of-plat.rst +2 -1
@@ -183,7 +183,8 @@ each 'compatible' string. In order to make this a bit more flexible DM_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. +This macro produces no code, but it is by dtoc tool. It must be located in the +same file as its associated driver, ideally just after it. The parent_idx is the index of the parent driver_info structure within its linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support
tools/dtoc/src_scan.py +5 -11
@@ -387,6 +387,7 @@ class Scanner: in the file _of_match - updated with each compatible string found in the file _compat_to_driver - Maps compatible string to Driver + _driver_aliases - Maps alias names to driver name Args: fname (str): Filename being parsed (used for warnings)
@@ -438,6 +439,7 @@ class Scanner: re_phase = re.compile('^\s*DM_PHASE\((.*)\).*$') re_hdr = re.compile('^\s*DM_HEADER\((.*)\).*$') + re_alias = re.compile(r'DM_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)') # Matches the struct name for priv, plat re_priv = self._get_re_for_member('priv_auto')
@@ -522,8 +524,11 @@ class Scanner: driver = Driver(driver_name, fname) else: ids_m = re_ids.search(line) + m_alias = re_alias.match(line) if ids_m: ids_name = ids_m.group(1) + elif m_alias: + self._driver_aliases[m_alias[2]] = m_alias[1] # Make the updates based on what we found self._drivers.update(drivers)
@@ -557,17 +562,6 @@ class Scanner: if 'UCLASS_DRIVER' in buff: self._parse_uclass_driver(fname, buff) - # The following re will search for driver aliases declared as - # DM_DRIVER_ALIAS(alias, driver_name) - driver_aliases = re.findall( - r'DM_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_header(self, fname): """Scan a header file to build a list of struct definitions
tools/dtoc/test/dtoc_test_scan_drivers.cxx +4 -0
@@ -1 +1,5 @@ +/* Aliases must be in driver files */ +U_BOOT_DRIVER(sandbox_gpio) { +}; + DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 39/49 dtoc: Warn of duplicate drivers
In reply to Simon GlassIf drivers have the same name then we cannot distinguish them. This only matters if the driver is actually used by dtoc, but in that case, issue a warning.
---
tools/dtoc/src_scan.py | 28 ++++++++++- tools/dtoc/test_src_scan.py | 95 +++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-)
tools/dtoc/src_scan.py +27 -1
@@ -70,6 +70,10 @@ class Driver: phase (str): Which phase of U-Boot to use this driver headers (list): List of header files needed for this driver (each a str) e.g. ['<asm/cpu.h>'] + dups (list): Driver objects with the same name as this one, that were + found after this one + warn_dups (bool): True if the duplicates are not distinguisble using + the phase """ def __init__(self, name, fname): self.name = name
@@ -83,6 +87,8 @@ class Driver: self.used = False self.phase = '' self.headers = [] + self.dups = [] + self.warn_dups = False def __eq__(self, other): return (self.name == other.name and
@@ -531,7 +537,21 @@ class Scanner: self._driver_aliases[m_alias[2]] = m_alias[1] # Make the updates based on what we found - self._drivers.update(drivers) + for driver in drivers.values(): + if driver.name in self._drivers: + orig = self._drivers[driver.name] + if self._phase: + # If the original driver matches our phase, use it + if orig.phase == self._phase: + orig.dups.append(driver) + continue + + # Otherwise use the new driver, which is assumed to match + else: + # We have no way of distinguishing them + driver.warn_dups = True + driver.dups.append(orig) + self._drivers[driver.name] = driver self._of_match.update(of_match) def scan_driver(self, fname):
@@ -617,6 +637,8 @@ class Scanner: This takes a list of nodes, finds the driver for each one and marks it as used. + If two used drivers have the same name, issue a warning. + Args: nodes (list of None): Nodes that are in use """
@@ -626,3 +648,7 @@ class Scanner: driver = self._drivers.get(struct_name) if driver: driver.used = True + if driver.dups and driver.warn_dups: + print("Warning: Duplicate driver name '%s' (orig=%s, dups=%s)" % + (driver.name, driver.fname, + ', '.join([drv.fname for drv in driver.dups])))
tools/dtoc/test_src_scan.py +95 -0
98 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 40/49 dtoc: Read aliases for uclasses
In reply to Simon GlassScan the aliases in the device tree to establish the number of devices within each uclass, and the sequence number of each.
---
tools/dtoc/dtb_platdata.py | 28 ++++++++++ tools/dtoc/src_scan.py | 32 ++++++++++- tools/dtoc/test/dtoc_test_alias_bad.dts | 58 ++++++++++++++++++++ tools/dtoc/test/dtoc_test_alias_bad_path.dts | 58 ++++++++++++++++++++ tools/dtoc/test/dtoc_test_alias_bad_uc.dts | 58 ++++++++++++++++++++ tools/dtoc/test/dtoc_test_inst.dts | 58 ++++++++++++++++++++ tools/dtoc/test_dtoc.py | 56 ++++++++++++++++++- 7 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 tools/dtoc/test/dtoc_test_alias_bad.dts create mode 100644 tools/dtoc/test/dtoc_test_alias_bad_path.dts create mode 100644 tools/dtoc/test/dtoc_test_alias_bad_uc.dts create mode 100644 tools/dtoc/test/dtoc_test_inst.dts
tools/dtoc/dtb_platdata.py +28 -0
@@ -647,6 +647,29 @@ class DtbPlatdata(): self._output_prop(node, node.props[pname]) self.buf('};\n') + def read_aliases(self): + """Read the aliases and attach the information to self._alias + + Raises: + ValueError: The alias path is not found + """ + alias_node = self._fdt.GetNode('/aliases') + if not alias_node: + return + re_num = re.compile('(^[a-z0-9-]+[a-z]+)([0-9]+)$') + for prop in alias_node.props.values(): + m_alias = re_num.match(prop.name) + if not m_alias: + raise ValueError("Cannot decode alias '%s'" % prop.name) + name, num = m_alias.groups() + node = self._fdt.GetNode(prop.value) + result = self._scan.add_uclass_alias(name, num, node) + if result is None: + raise ValueError("Alias '%s' path '%s' not found" % + (prop.name, prop.value)) + elif result is False: + print("Could not find uclass for alias '%s'" % prop.name) + def process_nodes(self, need_drivers): nodes_to_output = list(self._valid_nodes)
@@ -757,6 +780,9 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, scan (src_src.Scanner): Scanner from a previous run. This can help speed up tests. Use None for normal operation + Returns: + DtbPlatdata object + Raises: ValueError: if args has no command, or an unknown command """
@@ -782,6 +808,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, plat.scan_phandles() if do_process: plat.process_nodes(False) + plat.read_aliases() cmds = args[0].split(',') if 'all' in cmds:
@@ -796,3 +823,4 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, plat.out_header(outfile) outfile.method(plat) plat.finish_output() + return plat
tools/dtoc/src_scan.py +31 -1
@@ -116,6 +116,13 @@ class UclassDriver: e.g. 'pci_child_priv' per_child_plat (str): struct name of the per_child_plat_auto member, e.g. 'pci_child_plat' + alias_num_to_node (dict): Aliases for this uclasses (for sequence + numbers) + key (int): Alias number, e.g. 2 for "pci2" + value (str): Node the alias points to + alias_path_to_num (dict): Convert a path to an alias number + key (str): Full path to node (e.g. '/soc/pci') + seq (int): Alias number, e.g. 2 for "pci2" """ def __init__(self, name): self.name = name
@@ -125,6 +132,8 @@ class UclassDriver: self.per_dev_plat = '' self.per_child_priv = '' self.per_child_plat = '' + self.alias_num_to_node = {} + self.alias_path_to_num = {} def __eq__(self, other): return (self.name == other.name and
@@ -622,7 +631,6 @@ class Scanner: self.scan_driver(pathname) elif fname.endswith('.h'): self.scan_header(pathname) - for fname in self._drivers_additional: if not isinstance(fname, str) or len(fname) == 0: continue
@@ -652,3 +660,25 @@ class Scanner: print("Warning: Duplicate driver name '%s' (orig=%s, dups=%s)" % (driver.name, driver.fname, ', '.join([drv.fname for drv in driver.dups]))) + + def add_uclass_alias(self, name, num, node): + """Add an alias to a uclass + + Args: + name: Name of uclass, e.g. 'i2c' + num: Alias number, e.g. 2 for alias 'i2c2' + node: Node the alias points to, or None if None + + Returns: + True if the node was added + False if the node was not added (uclass of that name not found) + None if the node could not be added because it was None + """ + for uclass in self._uclass.values(): + if uclass.name == name: + if node is None: + return None + uclass.alias_num_to_node[int(num)] = node + uclass.alias_path_to_num[node.path] = int(num) + return True + return False
tools/dtoc/test/dtoc_test_alias_bad.dts new file +58 -0
58 lines not on this page · raw message
tools/dtoc/test/dtoc_test_alias_bad_path.dts new file +58 -0
58 lines not on this page · raw message
tools/dtoc/test/dtoc_test_alias_bad_uc.dts new file +58 -0
58 lines not on this page · raw message
tools/dtoc/test/dtoc_test_inst.dts new file +58 -0
58 lines not on this page · raw message
tools/dtoc/test_dtoc.py +54 -2
66 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 41/49 dtoc: Assign a sequence number to each node
In reply to Simon GlassNow that we have the alias information we can assign a sequence number to each device in the uclass. Store this in the node associated with each device.
This requires renaming the sandbox test drivers to have the right name. Note that test coverage is broken with this patch, but fixed in the next one.
---
drivers/misc/test_drv.c | 6 +++-- test/dm/test-fdt.c | 6 ++--- tools/dtoc/dtb_platdata.py | 55 +++++++++++++++++++++++++++----------- tools/dtoc/test_dtoc.py | 6 +++++ 4 files changed, 53 insertions(+), 20 deletions(-)
drivers/misc/test_drv.c +4 -2
@@ -85,7 +85,7 @@ static const struct udevice_id testbus_ids[] = { { } }; -U_BOOT_DRIVER (testbus_drv) = { +U_BOOT_DRIVER (denx_u_boot_test_bus) = { .name ="testbus_drv" , .of_match = testbus_ids, .id =UCLASS_TEST_BUS ,
@@ -159,7 +159,9 @@ static const struct udevice_id testfdt_ids[] = { { } }; -U_BOOT_DRIVER (testfdt_drv) = { +DM_DRIVER_ALIAS(denx_u_boot_fdt_test, google_another_fdt_test) + +U_BOOT_DRIVER (denx_u_boot_fdt_test) = { .name ="testfdt_drv" , .of_match = testfdt_ids, .id =UCLASS_TEST_FDT ,
test/dm/test-fdt.c +3 -3
@@ -328,7 +328,7 @@ static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts)/* Check creating a device with an alias */ node =ofnode_path ("/some-bus/c-test at 1" ); -ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (testfdt_drv), +ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (denx_u_boot_fdt_test),"c-test at 1" ,NULL , node, &dev));ut_asserteq (12 ,dev_seq (dev));ut_assertok (uclass_get_device_by_seq (UCLASS_TEST_FDT ,12 , &dev));
@@ -348,11 +348,11 @@ static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts)* * So next available is 19 */ -ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (testfdt_drv), +ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (denx_u_boot_fdt_test),"fred" ,NULL ,ofnode_null (), &dev));ut_asserteq (19 ,dev_seq (dev)); -ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (testfdt_drv), +ut_assertok (device_bind (dm_root (),DM_DRIVER_GET (denx_u_boot_fdt_test),"fred2" ,NULL ,ofnode_null (), &dev));ut_asserteq (20 ,dev_seq (dev));
tools/dtoc/dtb_platdata.py +40 -15
103 lines not on this page · raw message
tools/dtoc/test_dtoc.py +6 -0
@@ -1092,3 +1092,9 @@ U_BOOT_DRVINFO(spl_test2) = { plat = self.run_test(['struct'], dtb_file, output) self.assertEqual("Could not find uclass for alias 'other1'", stdout.getvalue().strip()) + + def test_sequence(self): + """Test assignment of sequence numnbers""" + dtb_file = get_dtb_file('dtoc_test_inst.dts') + output = tools.GetOutputFilename('output') + plat = self.run_test(['struct'], dtb_file, output)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 42/49 dtoc: Set up the uclasses that are used
In reply to Simon GlassWe only care about uclasses that are actually used. This is determined by the drivers that use them. Check all the used drivers and build a list of 'valid' uclasses.
Also add references to the uclasses so we can generate C code that uses them. Attach a uclass to each valid driver.
For the tests, now that we have uclasses we must create an explicit test for the case where a node does not have one. This should only happen if the source code does not build, or the source-code scanning fails to find it.
---
tools/dtoc/dtb_platdata.py | 46 ++++++++++++++++++++++++------------- tools/dtoc/src_scan.py | 45 ++++++++++++++++++++++++++++++++++++ tools/dtoc/test_dtoc.py | 27 ++++++++++++++++++++-- tools/dtoc/test_src_scan.py | 17 ++++++++++++++ 4 files changed, 117 insertions(+), 18 deletions(-)
tools/dtoc/dtb_platdata.py +30 -16
@@ -151,6 +151,8 @@ class DtbPlatdata(): key (str): Field name value: Prop object with field information _basedir (str): Base directory of source tree + _valid_uclasses (list of src_scan.Uclass): List of uclasses needed for + the selected devices (see _valid_node), in alphabetical order """ def __init__(self, scan, dtb_fname, include_disabled): self._scan = scan
@@ -164,6 +166,7 @@ class DtbPlatdata(): self._dirnames = [None] * len(Ftype) self._struct_data = collections.OrderedDict() self._basedir = None + self._valid_uclasses = None def setup_output_dirs(self, output_dirs): """Set up the output directories
@@ -677,23 +680,12 @@ class DtbPlatdata(): elif result is False: print("Could not find uclass for alias '%s'" % prop.name) - def assign_seq(self): + def assign_seqs(self): """Assign a sequence number to each node""" for node in self._valid_nodes_unsorted: - if node.driver and node.seq == -1 and node.uclass: - uclass = node.uclass - num = uclass.alias_path_to_num.get(node.path) - if num is not None: - node.seq = num - else: - # Dynamically allocate the next available value after all - # existing ones - for seq in range(1000): - if seq not in uclass.alias_num_to_node: - break - node.seq = seq - uclass.alias_path_to_num[node.path] = seq - uclass.alias_num_to_node[seq] = node + seq = self._scan.assign_seq(node) + if seq is not None: + node.seq = seq def process_nodes(self, need_drivers): nodes_to_output = list(self._valid_nodes)
@@ -710,6 +702,16 @@ class DtbPlatdata(): raise ValueError("Cannot parse/find driver for '%s'" % node.struct_name) node.driver = driver + uclass = self._scan._uclass.get(driver.uclass_id) + if not uclass: + raise ValueError("Cannot parse/find uclass '%s' for driver '%s'" % + (driver.uclass_id, node.struct_name)) + node.uclass = uclass + node.uclass_seq = len(node.uclass.devs) + node.uclass.devs.append(node) + uclass.node_refs[node.uclass_seq] = \ + '&%s->uclass_node' % node.dev_ref + parent_driver = None if node.parent in self._valid_nodes: parent_driver = self._scan.get_driver(node.parent.struct_name)
@@ -730,6 +732,18 @@ class DtbPlatdata(): node.child_refs[-1] = ref node.child_refs[len(node.child_devs)] = ref + uclass_set = set() + for driver in self._scan._drivers.values(): + if driver.used and driver.uclass: + uclass_set.add(driver.uclass) + self._valid_uclasses = sorted(list(uclass_set), + key=lambda uc: uc.uclass_id) + + for seq, uclass in enumerate(uclass_set): + ref = '&DM_UCLASS_REF(%s)->dev_head' % uclass.name + uclass.node_refs[-1] = ref + uclass.node_refs[len(uclass.devs)] = ref + def output_node(self, node): """Output the C code for a node
@@ -833,7 +847,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, plat.scan_phandles() plat.process_nodes(False) plat.read_aliases() - plat.assign_seq() + plat.assign_seqs() cmds = args[0].split(',') if 'all' in cmds:
tools/dtoc/src_scan.py +45 -0
78 lines not on this page · raw message
tools/dtoc/test_dtoc.py +25 -2
@@ -141,6 +141,8 @@ class TestDtoc(unittest.TestCase): Returns: DtbPlatdata object """ + # Make a copy of the 'scan' object, since it includes uclasses and + # drivers, which get updated during execution. return dtb_platdata.run_steps(args, dtb_file, False, output, [], None, warning_disabled=True, scan=copy_scan())
@@ -1033,6 +1035,16 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertIn("Cannot parse/find driver for 'sandbox_pmic", str(exc.exception)) + def test_process_nodes_bad_uclass(self): + plat, scan = self.setup_process_test() + + self.assertIn('UCLASS_I2C', scan._uclass) + del scan._uclass['UCLASS_I2C'] + with self.assertRaises(ValueError) as exc: + plat.process_nodes(True) + self.assertIn("Cannot parse/find uclass 'UCLASS_I2C' for driver 'sandbox_i2c'", + str(exc.exception)) + def test_process_nodes_used(self): """Test processing nodes to add various info""" plat, scan = self.setup_process_test()
@@ -1052,10 +1064,13 @@ U_BOOT_DRVINFO(spl_test2) = { scan = plat._scan testfdt_node = plat._fdt.GetNode('/some-bus/test') + test0_node = plat._fdt.GetNode('/some-bus/test0') self.assertIn('UCLASS_TEST_FDT', scan._uclass) uc = scan._uclass['UCLASS_TEST_FDT'] - self.assertEqual({1: testfdt_node}, uc.alias_num_to_node) - self.assertEqual({'/some-bus/test': 1}, uc.alias_path_to_num) + self.assertEqual({1: testfdt_node, 2: test0_node}, + uc.alias_num_to_node) + self.assertEqual({'/some-bus/test': 1, '/some-bus/test0': 2}, + uc.alias_path_to_num) # Try adding an alias that doesn't exist self.assertFalse(scan.add_uclass_alias('fred', 3, None))
@@ -1098,3 +1113,11 @@ U_BOOT_DRVINFO(spl_test2) = { dtb_file = get_dtb_file('dtoc_test_inst.dts') output = tools.GetOutputFilename('output') plat = self.run_test(['struct'], dtb_file, output) + + scan = plat._scan + testfdt = plat._fdt.GetNode('/some-bus/test') + self.assertEqual(1, testfdt.seq) + i2c = plat._fdt.GetNode('/i2c') + self.assertEqual(4, i2c.seq) + spl = plat._fdt.GetNode('/spl-test') + self.assertEqual(0, spl.seq)
tools/dtoc/test_src_scan.py +17 -0
@@ -466,3 +466,20 @@ U_BOOT_DRIVER(%s) = { with test_util.capture_sys_output() as (stdout, _): scan.mark_used([node]) self.assertEqual('', stdout.getvalue().strip()) + + def test_sequence(self): + """Test assignment of sequence numnbers""" + scan = src_scan.Scanner(None, False, None, '') + node = FakeNode() + uc = src_scan.UclassDriver('UCLASS_I2C') + node.uclass = uc + node.driver = True + node.seq = -1 + node.path = 'mypath' + uc.alias_num_to_node[2] = node + + # This should assign 3 (after the 2 that exists) + seq = scan.assign_seq(node) + self.assertEqual(3, seq) + self.assertEqual({'mypath': 3}, uc.alias_path_to_num) + self.assertEqual({2: node, 3: node}, uc.alias_num_to_node)
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 43/49 dtoc: Support processing the root node
In reply to Simon GlassThe device for the root node is normally bound by driver model on init. With devices being instantiated at build time, we must handle the root device also.
Add support for processing the root node, which may not have a compatible string.
---
tools/dtoc/dtb_platdata.py | 10 ++++++++-- tools/dtoc/src_scan.py | 39 ++++++++++++++++++++++--------------- tools/dtoc/test_dtoc.py | 23 ++++++++++++++++++++-- tools/dtoc/test_src_scan.py | 7 +++++++ 4 files changed, 59 insertions(+), 20 deletions(-)
tools/dtoc/dtb_platdata.py +8 -2
@@ -350,16 +350,22 @@ class DtbPlatdata(): # recurse to handle any subnodes self.scan_node(subnode, valid_nodes) - def scan_tree(self): + def scan_tree(self, add_root): """Scan the device tree for useful information This fills in the following properties: _valid_nodes_unsorted: A list of nodes we wish to consider include in the platform data (in devicetree node order) _valid_nodes: Sorted version of _valid_nodes_unsorted + + Args: + add_root: True to add the root node also (which wouldn't normally + be added as it may not have a compatible string) """ root = self._fdt.GetRoot() valid_nodes = [] + if add_root: + valid_nodes.append(root) self.scan_node(root, valid_nodes) self._valid_nodes_unsorted = valid_nodes self._valid_nodes = sorted(valid_nodes,
@@ -839,7 +845,7 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, do_process = False plat = DtbPlatdata(scan, dtb_file, include_disabled) plat.scan_dtb() - plat.scan_tree() + plat.scan_tree(add_root=False) plat.prepare_nodes() plat.scan_reg_sizes() plat.setup_output_dirs(output_dirs)
tools/dtoc/src_scan.py +23 -16
@@ -33,6 +33,8 @@ def conv_name_to_c(name): new = new.replace('-', '_') new = new.replace(',', '_') new = new.replace('.', '_') + if new == '/': + return 'root' return new def get_compat_name(node):
@@ -250,7 +252,10 @@ class Scanner: In case of no match found, the return will be the same as get_compat_name() """ - compat_list_c = get_compat_name(node) + if not node.parent: + compat_list_c = ['root_driver'] + else: + compat_list_c = get_compat_name(node) for compat_c in compat_list_c: if not compat_c in self._drivers.keys():
@@ -509,21 +514,23 @@ class Scanner: elif m_hdr: driver.headers.append(m_hdr.group(1)) elif '};' in line: - if driver.uclass_id and compat: - if compat not in of_match: - raise ValueError( - "%s: Unknown compatible var '%s' (found: %s)" % - (fname, compat, ','.join(of_match.keys()))) - driver.compat = of_match[compat] - - # This needs to be deterministic, since a driver may - # have multiple compatible strings pointing to it. - # We record the one earliest in the alphabet so it - # will produce the same result on all machines. - for compat_id in of_match[compat]: - old = self._compat_to_driver.get(compat_id) - if not old or driver.name < old.name: - self._compat_to_driver[compat_id] = driver + is_root = driver.name == 'root_driver' + if driver.uclass_id and (compat or is_root): + if not is_root: + if compat not in of_match: + raise ValueError( + "%s: Unknown compatible var '%s' (found: %s)" % + (fname, compat, ','.join(of_match.keys()))) + driver.compat = of_match[compat] + + # This needs to be deterministic, since a driver may + # have multiple compatible strings pointing to it. + # We record the one earliest in the alphabet so it + # will produce the same result on all machines. + for compat_id in of_match[compat]: + old = self._compat_to_driver.get(compat_id) + if not old or driver.name < old.name: + self._compat_to_driver[compat_id] = driver drivers[driver.name] = driver else: # The driver does not have a uclass or compat string.
tools/dtoc/test_dtoc.py +21 -2
@@ -974,10 +974,10 @@ U_BOOT_DRVINFO(spl_test2) = { output = tools.GetOutputFilename('output') # Take a copy before messing with it - scan = copy.deepcopy(saved_scan) + scan = copy_scan() plat = dtb_platdata.DtbPlatdata(scan, dtb_file, False) plat.scan_dtb() - plat.scan_tree() + plat.scan_tree(False) plat.prepare_nodes() return plat, scan
@@ -1121,3 +1121,22 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertEqual(4, i2c.seq) spl = plat._fdt.GetNode('/spl-test') self.assertEqual(0, spl.seq) + + def test_process_root(self): + """Test assignment of sequence numnbers""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + + # Take a copy before messing with it + scan = copy_scan() + plat = dtb_platdata.DtbPlatdata(scan, dtb_file, False) + plat.scan_dtb() + root = plat._fdt.GetRoot() + + plat.scan_tree(False) + self.assertNotIn(root, plat._valid_nodes) + + plat.scan_tree(True) + self.assertIn(root, plat._valid_nodes) + self.assertEqual('root_driver', + scan.get_normalized_compat_name(root)[0])
tools/dtoc/test_src_scan.py +7 -0
@@ -161,6 +161,10 @@ class TestSrcScan(unittest.TestCase): prop.value = 'rockchip,rk3288-grf' node = FakeNode() node.props = {'compatible': prop} + + # get_normalized_compat_name() uses this to check for root node + node.parent = FakeNode() + scan = src_scan.Scanner(None, False, None) with test_util.capture_sys_output() as (stdout, _): name, aliases = scan.get_normalized_compat_name(node)
@@ -419,6 +423,9 @@ U_BOOT_DRIVER(%s) = { node.name = 'testing' node.props = {'compatible': prop} + # get_normalized_compat_name() uses this to check for root node + node.parent = FakeNode() + return scan, drv1, driver2, node def test_dup_drivers(self):
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 44/49 dtoc: Add an option for device instantiation
In reply to Simon GlassAdd an option to instantiate devices at build time. For now this just parses the option and sets up a few parameters.
---
tools/dtoc/dtb_platdata.py | 17 +++++++++++------ tools/dtoc/main.py | 4 +++- tools/dtoc/test_dtoc.py | 37 ++++++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 22 deletions(-)
tools/dtoc/dtb_platdata.py +11 -6
@@ -153,8 +153,10 @@ class DtbPlatdata(): _basedir (str): Base directory of source tree _valid_uclasses (list of src_scan.Uclass): List of uclasses needed for the selected devices (see _valid_node), in alphabetical order + _instantiate: Instantiate devices so they don't need to be bound at + run-time """ - def __init__(self, scan, dtb_fname, include_disabled): + def __init__(self, scan, dtb_fname, include_disabled, instantiate=False): self._scan = scan self._fdt = None self._dtb_fname = dtb_fname
@@ -167,6 +169,7 @@ class DtbPlatdata(): self._struct_data = collections.OrderedDict() self._basedir = None self._valid_uclasses = None + self._instantiate = instantiate def setup_output_dirs(self, output_dirs): """Set up the output directories
@@ -802,8 +805,8 @@ OUTPUT_FILES = { def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, - warning_disabled=False, drivers_additional=None, basedir=None, - scan=None): + instantiate, warning_disabled=False, drivers_additional=None, + basedir=None, scan=None): """Run all the steps of the dtoc tool Args:
@@ -816,6 +819,8 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, Directory to put H output files phase: The phase of U-Boot that we are generating data for, e.g. 'spl' or 'tpl'. None if not known + instantiate: Instantiate devices so they don't need to be bound at + run-time warning_disabled (bool): True to avoid showing warnings about missing drivers drivers_additional (list): List of additional drivers to use during
@@ -843,15 +848,15 @@ def run_steps(args, dtb_file, include_disabled, output, output_dirs, phase, do_process = True else: do_process = False - plat = DtbPlatdata(scan, dtb_file, include_disabled) + plat = DtbPlatdata(scan, dtb_file, include_disabled, instantiate) plat.scan_dtb() - plat.scan_tree(add_root=False) + plat.scan_tree(add_root=instantiate) plat.prepare_nodes() plat.scan_reg_sizes() plat.setup_output_dirs(output_dirs) plat.scan_structs() plat.scan_phandles() - plat.process_nodes(False) + plat.process_nodes(instantiate) plat.read_aliases() plat.assign_seqs()
tools/dtoc/main.py +3 -1
@@ -81,6 +81,8 @@ parser.add_option('-C', '--h-output-dir', action='store', help='Select output directory for H files (defaults to --c-output-di)') parser.add_option('-d', '--dtb-file', action='store', help='Specify the .dtb input file') +parser.add_option('-i', '--instantiate', action='store_true', default=False, + help='Instantiate devices to avoid needing device_bind()') parser.add_option('--include-disabled', action='store_true', help='Include disabled nodes') parser.add_option('-o', '--output', action='store',
@@ -107,4 +109,4 @@ else: dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled, options.output, [options.c_output_dir, options.h_output_dir], - phase=options.phase) + options.phase, instantiate=options.instantiate)
tools/dtoc/test_dtoc.py +22 -15
@@ -130,7 +130,7 @@ class TestDtoc(unittest.TestCase): self.assertEqual(expected, actual) @staticmethod - def run_test(args, dtb_file, output): + def run_test(args, dtb_file, output, instantiate=False): """Run a test using dtoc Args:
@@ -143,8 +143,9 @@ class TestDtoc(unittest.TestCase): """ # Make a copy of the 'scan' object, since it includes uclasses and # drivers, which get updated during execution. - return dtb_platdata.run_steps(args, dtb_file, False, output, [], None, - warning_disabled=True, scan=copy_scan()) + return dtb_platdata.run_steps( + args, dtb_file, False, output, [], None, instantiate, + warning_disabled=True, scan=copy_scan()) def test_name(self): """Test conversion of device tree names to C identifiers"""
@@ -201,7 +202,8 @@ class TestDtoc(unittest.TestCase): output = tools.GetOutputFilename('output') # Run this one without saved_scan to complete test coverage - dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], True) + dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], None, + False) with open(output) as infile: lines = infile.read().splitlines() self.assertEqual(HEADER.splitlines(), lines)
@@ -369,8 +371,9 @@ U_BOOT_DRVINFO(gpios_at_0) = { dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], - None, scan=copy_scan()) + dtb_platdata.run_steps( + ['struct'], dtb_file, False, output, [], None, False, + scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(HEADER + '''
@@ -379,8 +382,9 @@ struct dtd_invalid { ''', data) with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], - None, scan=copy_scan()) + dtb_platdata.run_steps( + ['platdata'], dtb_file, False, output, [], None, False, + scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -530,8 +534,9 @@ U_BOOT_DRVINFO(phandle_target) = { """Test that phandle targets are generated when unsing cd-gpios""" dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts') output = tools.GetOutputFilename('output') - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True, - scan=copy_scan()) + dtb_platdata.run_steps( + ['platdata'], dtb_file, False, output, [], None, False, + warning_disabled=True, scan=copy_scan()) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + '''
@@ -925,15 +930,16 @@ U_BOOT_DRVINFO(spl_test2) = { dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') with self.assertRaises(ValueError) as exc: - self.run_test(['invalid-cmd'], dtb_file, output) + self.run_test(['invalid-cmd'], dtb_file, output, False) self.assertIn("Unknown command 'invalid-cmd': (use: platdata, struct)", str(exc.exception)) def test_output_conflict(self): """Test a conflict between and output dirs and output file""" with self.assertRaises(ValueError) as exc: - dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], None, - warning_disabled=True, scan=copy_scan()) + dtb_platdata.run_steps( + ['all'], None, False, 'out', ['cdir'], None, False, + warning_disabled=True, scan=copy_scan()) self.assertIn("Must specify either output or output_dirs, not both", str(exc.exception))
@@ -949,8 +955,9 @@ U_BOOT_DRVINFO(spl_test2) = { fnames = glob.glob(outdir + '/*') self.assertEqual(2, len(fnames)) - dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], None, - warning_disabled=True, scan=copy_scan()) + dtb_platdata.run_steps( + ['all'], dtb_file, False, None, [outdir], None, False, + warning_disabled=True, scan=copy_scan()) fnames = glob.glob(outdir + '/*') self.assertEqual(4, len(fnames))
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 45/49 dm: of-platadata: Add option for device instantiation
In reply to Simon GlassAdd Kconfig options to support build-time device instantiation. When fully implemented, this will allow dtoc to create U-Boot devices (i.e. struct udevice records) at build time, thus reducing code space in SPL.
For now this defaults to off, but will be enabled when the rest of the implementation is in place.
---
dts/Kconfig | 23 +++++++++++++++++++++-- scripts/Makefile.spl | 4 ++++ 2 files changed, 25 insertions(+), 2 deletions(-)
dts/Kconfig +21 -2
@@ -355,15 +355,24 @@ config SPL_OF_PLATDATA compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. +if SPL_OF_PLATDATA + config SPL_OF_PLATDATA_PARENT bool "Support parent information in devices" - depends on SPL_OF_PLATDATA default y help Generally it is useful to be able to access the parent of a device with of-platdata. To save space this can be disabled, but in that case dev_get_parent() will always return NULL; +config SPL_OF_PLATDATA_INST + bool "Declare devices at build time" + help + Declare devices as udevice instances so that they do not need to be + bound when U-Boot starts. This can save time and code space. + +endif + config TPL_OF_PLATDATA bool "Generate platform data for use in TPL" depends on TPL_OF_CONTROL
@@ -385,13 +394,23 @@ config TPL_OF_PLATDATA compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. +if TPL_OF_PLATDATA + config TPL_OF_PLATDATA_PARENT bool "Support parent information in devices" - depends on TPL_OF_PLATDATA default y help Generally it is useful to be able to access the parent of a device with of-platdata. To save space this can be disabled, but in that case dev_get_parent() will always return NULL; +config TPL_OF_PLATDATA_INST + bool "Declare devices at build time" + + help + Declare devices as udevice instances so that they do not need to be + bound when U-Boot starts. This can save time and code space. + +endif + endmenu
scripts/Makefile.spl +4 -0
@@ -311,6 +311,10 @@ pythonpath = PYTHONPATH=scripts/dtc/pylibfdt DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \ -d $(obj)/$(SPL_BIN).dtb -p $(SPL_NAME) +ifneq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA_INST),) +DTOC_ARGS += -i +endif + quiet_cmd_dtoc = DTOC $@ cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 46/49 dtoc: Add support for decl file
In reply to Simon GlassAdd an option to generate the declaration file, which declares all drivers and uclasses, so references can be used in the code.
---
tools/dtoc/dtb_platdata.py | 36 +++++++++++++++ tools/dtoc/test_dtoc.py | 91 +++++++++++++++++++++++++++++++++++--- 2 files changed, 120 insertions(+), 7 deletions(-)
tools/dtoc/dtb_platdata.py +36 -0
@@ -689,6 +689,39 @@ class DtbPlatdata(): elif result is False: print("Could not find uclass for alias '%s'" % prop.name) + def generate_decl(self): + nodes_to_output = list(self._valid_nodes) + + self.buf('#include <dm/device-internal.h>\n') + self.buf('#include <dm/uclass-internal.h>\n') + self.buf('\n') + self.buf( + '/* driver declarations - these allow DM_DRIVER_GET() to be used */\n') + for node in nodes_to_output: + self.buf('DM_DRIVER_DECL(%s);\n' % node.struct_name); + self.buf('\n') + + if self._instantiate: + self.buf( + '/* device declarations - these allow DM_DEVICE_REF() to be used */\n') + for node in nodes_to_output: + self.buf('DM_DEVICE_DECL(%s);\n' % node.var_name) + self.buf('\n') + + uclass_list = self._valid_uclasses + + self.buf( + '/* uclass driver declarations - needed for DM_UCLASS_DRIVER_REF() */\n') + for uclass in uclass_list: + self.buf('DM_UCLASS_DRIVER_DECL(%s);\n' % uclass.name) + + if self._instantiate: + self.buf('\n') + self.buf('/* uclass declarations - needed for DM_UCLASS_REF() */\n') + for uclass in uclass_list: + self.buf('DM_UCLASS_DECL(%s);\n' % uclass.name) + self.out(''.join(self.get_buf())) + def assign_seqs(self): """Assign a sequence number to each node""" for node in self._valid_nodes_unsorted:
@@ -794,6 +827,9 @@ class DtbPlatdata(): # key: Command used to generate this file # value: OutputFile for this command OUTPUT_FILES = { + 'decl': + OutputFile(Ftype.HEADER, 'dt-decl.h', DtbPlatdata.generate_decl, + 'Declares externs for all device/uclass instances'), 'struct': OutputFile(Ftype.HEADER, 'dt-structs-gen.h', DtbPlatdata.generate_structs,
tools/dtoc/test_dtoc.py +84 -7
136 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 47/49 dtoc: Don't generate platform data with instantiation
In reply to Simon GlassThis file is not used when instantiating devices. Update dtoc to skip generating its contents and just add a comment instead.
Also it is useful to see the driver name and parent for each device. Update the file to show that information, to avoid updating the same tests twice.
---
tools/dtoc/dtb_platdata.py | 35 ++++++++++++++++++++++--- tools/dtoc/test_dtoc.py | 53 +++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 13 deletions(-)
tools/dtoc/dtb_platdata.py +32 -3
@@ -786,19 +786,46 @@ class DtbPlatdata(): uclass.node_refs[-1] = ref uclass.node_refs[len(uclass.devs)] = ref - def output_node(self, node): + def output_node_plat(self, node): """Output the C code for a node Args: node (fdt.Node): node to output """ - self.buf('/* Node %s index %d */\n' % (node.path, node.idx)) + driver = node.driver + parent_driver = node.parent_driver + + line1 = 'Node %s index %d' % (node.path, node.idx) + if driver: + self.buf('/*\n') + self.buf(' * %s\n' % line1) + self.buf(' * driver %s parent %s\n' % (driver.name, + parent_driver.name if parent_driver else 'None')) + self.buf(' */\n') + else: + self.buf('/* %s */\n' % line1) self._output_values(node) self._declare_device(node) self.out(''.join(self.get_buf())) + def check_instantiate(self, require): + """Check if self._instantiate is set to the required value + + If not, this outputs a message into the current file + + Args: + require: True to require --instantiate, False to require that it not + be enabled + """ + if require != self._instantiate: + self.out( + '/* This file is not used: --instantiate was %senabled */\n' % + ('not ' if require else '')) + return False + return True + def generate_plat(self): """Generate device defintions for the platform data
@@ -809,6 +836,8 @@ class DtbPlatdata(): See the documentation in doc/driver-model/of-plat.rst for more information. """ + if not self.check_instantiate(False): + return self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') self.out('#define DT_PLAT_C\n') self.out('\n')
@@ -818,7 +847,7 @@ class DtbPlatdata(): self.out('\n') for node in self._valid_nodes: - self.output_node(node) + self.output_node_plat(node) self.out(''.join(self.get_buf()))
tools/dtoc/test_dtoc.py +43 -10
117 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 48/49 dtoc: Generate uclass devices
In reply to Simon GlassAdd support for generating a file containing uclass instances. This avoids the need to create these at run time.
Update a test uclass to include a 'priv_auto' member, to increase test coverage.
---
drivers/misc/test_drv.c | 1 + include/dm/test.h | 5 ++ tools/dtoc/dtb_platdata.py | 93 +++++++++++++++++++++ tools/dtoc/test_dtoc.py | 164 ++++++++++++++++++++++++++++++++++--- 4 files changed, 250 insertions(+), 13 deletions(-)
drivers/misc/test_drv.c +1 -0
@@ -204,6 +204,7 @@ UCLASS_DRIVER(testfdt) = { .name = "testfdt", .id = UCLASS_TEST_FDT, .flags = DM_UC_FLAG_SEQ_ALIAS, + .priv_auto = sizeof(struct dm_test_uc_priv), };static const struct udevice_id testfdtm_ids[] = {
include/dm/test.h +5 -0
@@ -71,6 +71,11 @@ struct dm_test_priv {int uclass_postp; }; +/* struct dm_test_uc_priv - private data for the testdrv uclass */ +struct dm_test_uc_priv { +int dummy; +}; +/** * struct dm_test_perdev_class_priv - private per-device data for test uclass */
tools/dtoc/dtb_platdata.py +93 -0
117 lines not on this page · raw message
tools/dtoc/test_dtoc.py +151 -13
243 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 49/49 dtoc: Generate device instances
In reply to Simon GlassAdd support for generating a file containing udevice instances. This avoids the need to create these at run time.
Update a test uclass to include a 'per_device_plat_auto' member, to increase test coverage.
---
drivers/misc/test_drv.c | 4 + tools/dtoc/dtb_platdata.py | 145 +++++++++++++++++- tools/dtoc/test_dtoc.py | 303 ++++++++++++++++++++++++++++++++++++- 3 files changed, 442 insertions(+), 10 deletions(-)
drivers/misc/test_drv.c +4 -0
@@ -97,6 +97,7 @@ U_BOOT_DRIVER(denx_u_boot_test_bus) = { .per_child_plat_auto = sizeof(struct dm_test_parent_plat), .child_pre_probe = testbus_child_pre_probe, .child_post_remove = testbus_child_post_remove, + DM_HEADER(<test.h>) };UCLASS_DRIVER (testbus) = {
@@ -105,6 +106,9 @@ UCLASS_DRIVER(testbus) = { .flags = DM_UC_FLAG_SEQ_ALIAS, .child_pre_probe = testbus_child_pre_probe_uclass, .child_post_probe = testbus_child_post_probe_uclass, + +/* This is for dtoc testing only */ + .per_device_plat_auto = sizeof(struct dm_test_uclass_priv), };static int testfdt_drv_ping (struct udevice *dev,int pingval,int *pingret)
tools/dtoc/dtb_platdata.py +143 -2
175 lines not on this page · raw message
tools/dtoc/test_dtoc.py +295 -8
344 lines not on this page · raw message
Signature · 1 line
2.29.2.729.g45daf8777d-goog
PATCH 45/49 dm: of-platadata: Add option for device instantiation
In reply to Simon GlassQuoted 25 lines · Simon Glass
Add
Kconfigoptions to support build-time device instantiation. When fully implemented, this will allow dtoc to create U-Boot devices (i.e. struct udevice records) at build time, thus reducing code space in SPL.For now this defaults to off, but will be enabled when the rest of the implementation is in place.
Signed-off-by Simon Glass <[email protected]>---
dts/Kconfig | 23 +++++++++++++++++++++-- scripts/Makefile.spl | 4 ++++ 2 files changed, 25 insertions(+), 2 deletions(-)dts/Kconfig +2
-0@@ -355,15 +355,24 @@ config SPL_OF_PLATDATA compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. +if SPL_OF_PLATDATA +
dts/Kconfig config SPL_OF_PLATDATA · line 368
Quoted 10 lines
dts/Kconfig +1
-1config SPL_OF_PLATDATA_PARENT bool "Support parent information in devices" - depends on SPL_OF_PLATDATA default y help Generally it is useful to be able to access the parent of a device with of-platdata. To save space this can be disabled, but in that case dev_get_parent() will always return NULL; +config SPL_OF_PLATDATA_INST
Not sure about the limits to config names, I understand that SPL_OF_PLATDATA_INST means SPL_OF_PLATDATA_INSTANCE? I'm not sure but maybe a better name could be SPL_OF_PLATDATA_BTIME_DEV. To be honest I find it difficult to come with nice name.
Quoted 16 lines
dts/Kconfig +9
-0+ bool "Declare devices at build time" + help + Declare devices as udevice instances so that they do not need to be + bound when U-Boot starts. This can save time and code space. + +endif + config TPL_OF_PLATDATA bool "Generate platform data for use in TPL" depends on TPL_OF_CONTROL@@ -385,13 +394,23 @@ config TPL_OF_PLATDATA compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. +if TPL_OF_PLATDATA +
dts/Kconfig config TPL_OF_PLATDATA · line 407
Quoted 10 lines
dts/Kconfig +1
-1config TPL_OF_PLATDATA_PARENT bool "Support parent information in devices" - depends on TPL_OF_PLATDATA default y help Generally it is useful to be able to access the parent of a device with of-platdata. To save space this can be disabled, but in that case dev_get_parent() will always return NULL; +config TPL_OF_PLATDATA_INST
Same here. Also I have a question, in which case TPL_OF_PLATDATA_INST and SPL_OF_PLATDATA_INST would have different values. Which is the value of decoupling the TPL and SPL behavior? Or is use for consistency with SPL_OF_PLATDATA_PARENT and TPL_OF_PLATDATA_PARENT (which also not sure if needed to have two different options).
Quoted 24 lines
dts/Kconfig +8
-0+ bool "Declare devices at build time" + + help + Declare devices as udevice instances so that they do not need to be + bound when U-Boot starts. This can save time and code space. + +endif + endmenuscripts/Makefile.spl +4
-0@@ -311,6 +311,10 @@ pythonpath = PYTHONPATH=scripts/dtc/pylibfdt DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \ -d $(obj)/$(SPL_BIN).dtb -p $(SPL_NAME) +ifneq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA_INST),) +DTOC_ARGS += -i +endif + quiet_cmd_dtoc = DTOC $@ cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all
PATCH 9/49 dm: Rename DM_GET_DEVICE() to DM_DRVINFO_GET()
In reply to Simon GlassQuoted 8 lines · Simon Glass
This does not get a device (struct udevice *) but a struct
driver_info* so the name is confusing.Rename it accordingly. Since we plan to have several various of these macros, put GET at the end instead of the middle, so it is easier to spot the related macros.
Signed-off-by Simon Glass<[email protected]>
Thanks,
Quoted 70 lines
---
doc/driver-model/of-plat.rst | 2 +- include/dm/platdata.h | 10 +++------- tools/dtoc/dtb_platdata.py | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-)doc/driver-model/of-plat.rst +1
-1@@ -339,7 +339,7 @@ prevents them being used inadvertently. All usage must be bracketed with The dt-plat.c file contains the device declarations and is is built in spl/dt-plat.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_DRVINFO by using DM_GET_DEVICE +information by adding references to U_BOOT_DRVINFO by using DM_DRVINFO_GET The pylibfdt Python module is used to access the devicetree.include/dm/platdata.h +3
-7@@ -74,27 +74,23 @@ struct driver_rt {/** * Get a pointer to a given device info given its name * -* With the declaration U_BOOT_DRVINFO(name), DM_GET_DEVICE(name) will return a +* With the declaration U_BOOT_DRVINFO(name), DM_DRVINFO_GET(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * -* TODO(sjg at chromium.org): U_BOOT_DRVINFO() tells U-Boot to create a device, so -* the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it -* finds the driver_info record, not the device. -* * @__name: Driver name (C identifier, not a string. E.g. gpio7_at_ff7e0000) * @return struct driver_info * to the driver that created the device */ -#define DM_GET_DEVICE (__name) \ +#define DM_DRVINFO_GET (__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_DRVINFO entry get by -* DM_GET_DEVICE. The implementation of this function will be done +* DM_DRVINFO_GET. The implementation of this function will be done * by dtoc when parsing dtb. */ void dm_populate_phandle_data (void );tools/dtoc/dtb_platdata.py +2
-2@@ -811,8 +811,8 @@ class DtbPlatdata(): 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) + # nodes using DM_DRVINFO_GET + # dtv_dmc_at_xxx.clocks[0].node = DM_DRVINFO_GET(clock_controller_at_xxx) self.buf('void dm_populate_phandle_data(void) {\n') self.buf('}\n')
PATCH 8/49 dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO()
In reply to Simon GlassQuoted 9 lines · Simon Glass
The current macro is a misnomer since it does not declare a device directly. Instead, it declares
driver_inforecord which U-Boot uses at runtime to create a device.The distinction seems somewhat minor most of the time, but is becomes quite confusing when we actually want to declare a device, with of-platdata. We are left trying to distinguish between a device which isn't actually device, and a device that is (perhaps an 'instance'?)
Quoted 8 lines
It seems better to rename this macro to describe what it actually is. The macros is not widely used, since boards should use devicetree to declare devices.
Rename it to
U_BOOT_DRVINFO(), which indicates clearly that this is declaring a newdriver_inforecord, not a device.Signed-off-by Simon Glass<[email protected]>
I couldn't agree more.
Thanks,
Quoted 1,542 lines
---
.../mach-at91/arm926ejs/at91sam9260_devices.c | 2 +- .../arm926ejs/at91sam9m10g45_devices.c | 2 +- arch/arm/mach-imx/mx6/soc.c | 2 +- arch/arm/mach-imx/mx7/soc.c | 2 +- arch/arm/mach-lpc32xx/devices.c | 4 +- arch/arm/mach-omap2/am33xx/board.c | 10 +-- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-tegra/board.c | 2 +- arch/arm/mach-tegra/board2.c | 2 +- board/armltd/integrator/integrator.c | 2 +- board/armltd/total_compute/total_compute.c | 2 +- board/armltd/vexpress64/vexpress64.c | 2 +- board/bluewater/gurnard/gurnard.c | 2 +- board/bluewater/snapper9260/snapper9260.c | 2 +- board/cadence/xtfpga/xtfpga.c | 4 +- board/cavium/thunderx/thunderx.c | 4 +- board/compulab/cm_fx6/cm_fx6.c | 2 +- board/davinci/da8xxevm/omapl138_lcdk.c | 4 +- board/freescale/ls1012afrdm/eth.c | 4 +- board/freescale/ls1012aqds/eth.c | 4 +- board/freescale/ls1012ardb/eth.c | 4 +- board/freescale/lx2160a/lx2160a.c | 4 +- board/gateworks/gw_ventana/gw_ventana.c | 2 +- board/hisilicon/hikey/hikey.c | 4 +- board/hisilicon/hikey960/hikey960.c | 2 +- board/hisilicon/poplar/poplar.c | 2 +- board/isee/igep00x0/igep00x0.c | 2 +- board/lg/sniper/sniper.c | 2 +- board/nokia/rx51/rx51.c | 2 +- board/sandbox/sandbox.c | 2 +- board/siemens/corvus/board.c | 2 +- board/st/stv0991/stv0991.c | 2 +- board/sysam/amcore/amcore.c | 2 +- board/ti/am335x/board.c | 6 +- board/timll/devkit8000/devkit8000.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 2 +- .../toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 2 +- board/toradex/colibri_pxa270/colibri_pxa270.c | 4 +- doc/driver-model/design.rst | 18 ++--- doc/driver-model/of-plat.rst | 12 ++-- doc/driver-model/remoteproc-framework.rst | 2 +- doc/driver-model/spi-howto.rst | 4 +- drivers/crypto/fsl/fsl_rsa.c | 2 +- drivers/crypto/rsa_mod_exp/mod_exp_sw.c | 2 +- drivers/demo/demo-pdata.c | 10 +-- drivers/gpio/imx_rgpio2p.c | 4 +- drivers/gpio/mxc_gpio.c | 2 +- drivers/remoteproc/sandbox_testproc.c | 2 +- drivers/rtc/emul_rtc.c | 2 +- drivers/serial/sandbox.c | 2 +- drivers/sysreset/sysreset_sandbox.c | 4 +- drivers/timer/sandbox_timer.c | 2 +- drivers/video/sunxi/sunxi_de2.c | 2 +- drivers/video/sunxi/sunxi_dw_hdmi.c | 2 +- drivers/video/sunxi/sunxi_lcd.c | 2 +- dts/Kconfig | 8 +-- include/dm/device.h | 4 +- include/dm/lists.h | 2 +- include/dm/platdata.h | 16 ++--- include/dm/platform_data/spi_pl022.h | 2 +- test/dm/core.c | 6 +- tools/dtoc/dtb_platdata.py | 8 +-- tools/dtoc/test_dtoc.py | 66 +++++++++---------- 64 files changed, 148 insertions(+), 148 deletions(-)arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c +1
-1@@ -219,7 +219,7 @@ static const struct at91_port_plat at91sam9260_plat[] = { { ATMEL_BASE_PIOC, "PC" }, }; -U_BOOT_DEVICES (at91sam9260_gpios) = { +U_BOOT_DRVINFOS (at91sam9260_gpios) = { {"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 +1
-1@@ -175,7 +175,7 @@ static const struct at91_port_plat at91sam9260_plat[] = { { ATMEL_BASE_PIOE, "PE" }, }; -U_BOOT_DEVICES (at91sam9260_gpios) = { +U_BOOT_DRVINFOS (at91sam9260_gpios) = { {"atmel_at91rm9200_gpio" , &at91sam9260_plat[0 ] }, {"atmel_at91rm9200_gpio" , &at91sam9260_plat[1 ] }, { "atmel_at91rm9200_gpio", &at91sam9260_plat[2] },arch/arm/mach-imx/mx6/soc.c +1
-1@@ -44,7 +44,7 @@ static const struct imx_thermal_plat imx6_thermal_plat = { .fuse_word = 6, }; -U_BOOT_DEVICE (imx6_thermal) = { +U_BOOT_DRVINFO (imx6_thermal) = { .name ="imx_thermal" , .plat = &imx6_thermal_plat, };arch/arm/mach-imx/mx7/soc.c +1
-1@@ -60,7 +60,7 @@ static const struct imx_thermal_plat imx7_thermal_plat = { .fuse_word = 3, }; -U_BOOT_DEVICE (imx7_thermal) = { +U_BOOT_DRVINFO (imx7_thermal) = { .name ="imx_thermal" , .plat = &imx7_thermal_plat, };arch/arm/mach-lpc32xx/devices.c +2
-2@@ -62,7 +62,7 @@ static const struct lpc32xx_hsuart_plat lpc32xx_hsuart[] = { };#endif -U_BOOT_DEVICES(lpc32xx_uarts) = { +U_BOOT_DRVINFOS(lpc32xx_uarts) = {#if defined(CONFIG_LPC32XX_HSUART ) { "lpc32xx_hsuart", &lpc32xx_hsuart[0], }, { "lpc32xx_hsuart", &lpc32xx_hsuart[1], },@@ -124,7 +124,7 @@ void lpc32xx_i2c_init(unsigned int devnum)writel (ctrl, &clk->i2cclk_ctrl); } -U_BOOT_DEVICE (lpc32xx_gpios) = { +U_BOOT_DRVINFO (lpc32xx_gpios) = { .name ="gpio_lpc32xx" };arch/arm/mach-omap2/am33xx/board.c +5
-5@@ -99,7 +99,7 @@ static const struct ns16550_plat am33xx_serial[] = {# endif }; -U_BOOT_DEVICES (am33xx_uarts) = { +U_BOOT_DRVINFOS (am33xx_uarts) = { {"ns16550_serial" , &am33xx_serial[0 ] }, # ifdef CONFIG_SYS_NS16550_COM2 { "ns16550_serial", &am33xx_serial[1] },@@ -119,7 +119,7 @@ static const struct omap_i2c_plat am33xx_i2c[] = { { I2C_BASE3, 100000, OMAP_I2C_REV_V2}, }; -U_BOOT_DEVICES (am33xx_i2c) = { +U_BOOT_DRVINFOS (am33xx_i2c) = { {"i2c_omap" , &am33xx_i2c[0 ] }, {"i2c_omap" , &am33xx_i2c[1 ] }, { "i2c_omap", &am33xx_i2c[2] },@@ -138,7 +138,7 @@ static const struct omap_gpio_plat am33xx_gpio[] = {#endif }; -U_BOOT_DEVICES (am33xx_gpios) = { +U_BOOT_DRVINFOS (am33xx_gpios) = { {"gpio_omap" , &am33xx_gpio[0 ] }, {"gpio_omap" , &am33xx_gpio[1 ] }, {"gpio_omap" , &am33xx_gpio[2 ] },@@ -155,7 +155,7 @@ static const struct omap3_spi_plat omap3_spi_pdata = { .pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT, }; -U_BOOT_DEVICE (am33xx_spi) = { +U_BOOT_DRVINFO (am33xx_spi) = { .name ="omap3_spi" , .plat = &omap3_spi_pdata, };@@ -234,7 +234,7 @@ static struct ti_musb_plat usb1 = { }, }; -U_BOOT_DEVICES (am33xx_usbs) = { +U_BOOT_DRVINFOS (am33xx_usbs) = { #if CONFIG_AM335X_USB0_MODE == MUSB_PERIPHERAL {"ti-musb-peripheral" , &usb0 }, #elif CONFIG_AM335X_USB0_MODE == MUSB_HOSTarch/arm/mach-omap2/omap3/board.c +1
-1@@ -47,7 +47,7 @@ static const struct omap_gpio_plat omap34xx_gpio[] = { { 5, OMAP34XX_GPIO6_BASE }, }; -U_BOOT_DEVICES (omap34xx_gpios) = { +U_BOOT_DRVINFOS (omap34xx_gpios) = { {"gpio_omap" , &omap34xx_gpio[0 ] }, {"gpio_omap" , &omap34xx_gpio[1 ] }, { "gpio_omap", &omap34xx_gpio[2] }, diff --git a/arch/arm/mach-tegra/board.c
b/arch/arm/mach-tegra/board.cindexbf01aa5ee8f..9de9836c8d2100644 ---a/arch/arm/mach-tegra/board.c+++b/arch/arm/mach-tegra/board.c@@ -264,7 +264,7 @@ static structns16550_platns16550_com1_pdata= { .fcr =UART_FCR_DEFVAL, }; -U_BOOT_DEVICE(ns16550_com1) = {arch/arm/mach-omap2/omap3/board.c +1
-0+U_BOOT_DRVINFO (ns16550_com1) = {"ns16550_serial" , &ns16550_com1_pdata };#endif arch/arm/mach-tegra/board2.c +1
-1@@ -42,7 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD /* TODO(sjg at chromium.org): Remove once SPL supports device tree */ -U_BOOT_DEVICE (tegra_gpios) = { +U_BOOT_DRVINFO (tegra_gpios) = {"gpio_tegra" };#endif board/armltd/integrator/integrator.c +1
-1@@ -43,7 +43,7 @@ static const struct pl01x_serial_plat serial_plat = {#endif }; -U_BOOT_DEVICE (integrator_serials) = { +U_BOOT_DRVINFO (integrator_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/armltd/total_compute/total_compute.c +1
-1@@ -15,7 +15,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = CONFIG_PL011_CLOCK, }; -U_BOOT_DEVICE (total_compute_serials) = { +U_BOOT_DRVINFO (total_compute_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/armltd/vexpress64/vexpress64.c +1
-1@@ -26,7 +26,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = CONFIG_PL011_CLOCK, }; -U_BOOT_DEVICE (vexpress_serials) = { +U_BOOT_DRVINFO (vexpress_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/bluewater/gurnard/gurnard.c +1
-1@@ -420,7 +420,7 @@ static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE (at91sam9260_serial) = { +U_BOOT_DRVINFO (at91sam9260_serial) = { .name ="serial_atmel" , .plat = &at91sam9260_serial_plat, };board/bluewater/snapper9260/snapper9260.c +1
-1@@ -147,7 +147,7 @@ static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE (at91sam9260_serial) = { +U_BOOT_DRVINFO (at91sam9260_serial) = { .name ="serial_atmel" , .plat = &at91sam9260_serial_plat, };board/cadence/xtfpga/xtfpga.c +2
-2@@ -93,7 +93,7 @@ int misc_init_r(void)return 0 ; } -U_BOOT_DEVICE (sysreset) = { +U_BOOT_DRVINFO (sysreset) = { .name ="xtfpga_sysreset" , };@@ -104,7 +104,7 @@ static struct ethoc_eth_pdata ethoc_pdata = { .packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR, }; -U_BOOT_DEVICE (ethoc) = { +U_BOOT_DRVINFO (ethoc) = { .name ="ethoc" , .plat = ðoc_pdata, };board/cavium/thunderx/thunderx.c +2
-2@@ -25,7 +25,7 @@ static const struct pl01x_serial_plat serial0 = { .skip_init = true, }; -U_BOOT_DEVICE (thunderx_serial0) = { +U_BOOT_DRVINFO (thunderx_serial0) = { .name ="serial_pl01x" , .plat = &serial0, };@@ -37,7 +37,7 @@ static const struct pl01x_serial_plat serial1 = { .skip_init = true, }; -U_BOOT_DEVICE (thunderx_serial1) = { +U_BOOT_DRVINFO (thunderx_serial1) = { .name ="serial_pl01x" , .plat = &serial1, };board/compulab/cm_fx6/cm_fx6.c +1
-1@@ -728,7 +728,7 @@ static struct mxc_serial_plat cm_fx6_mxc_serial_plat = { .reg = (struct mxc_uart *)UART4_BASE, }; -U_BOOT_DEVICE (cm_fx6_serial) = { +U_BOOT_DRVINFO (cm_fx6_serial) = { .name ="serial_mxc" , .plat = &cm_fx6_mxc_serial_plat, };board/davinci/da8xxevm/omapl138_lcdk.c +2
-2@@ -363,7 +363,7 @@ static const struct ns16550_plat serial_pdata = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (omapl138_uart) = { +U_BOOT_DRVINFO (omapl138_uart) = { .name ="ns16550_serial" , .plat = &serial_pdata, };@@ -379,7 +379,7 @@ static const struct davinci_mmc_plat mmc_plat = { .name = "da830-mmc", }, }; -U_BOOT_DEVICE (omapl138_mmc) = { +U_BOOT_DRVINFO (omapl138_mmc) = { .name ="ti_da830_mmc" , .plat = &mmc_plat, };board/freescale/ls1012afrdm/eth.c +2
-2@@ -114,12 +114,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE (ls1012a_pfe0) = { +U_BOOT_DRVINFO (ls1012a_pfe0) = { .name ="pfe_eth" , .plat = &pfe_pdata0, }; -U_BOOT_DEVICE (ls1012a_pfe1) = { +U_BOOT_DRVINFO (ls1012a_pfe1) = { .name ="pfe_eth" , .plat = &pfe_pdata1, };board/freescale/ls1012aqds/eth.c +2
-2@@ -298,12 +298,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE (ls1012a_pfe0) = { +U_BOOT_DRVINFO (ls1012a_pfe0) = { .name ="pfe_eth" , .plat = &pfe_pdata0, }; -U_BOOT_DEVICE (ls1012a_pfe1) = { +U_BOOT_DRVINFO (ls1012a_pfe1) = { .name ="pfe_eth" , .plat = &pfe_pdata1, };board/freescale/ls1012ardb/eth.c +2
-2@@ -160,12 +160,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE (ls1012a_pfe0) = { +U_BOOT_DRVINFO (ls1012a_pfe0) = { .name ="pfe_eth" , .plat = &pfe_pdata0, }; -U_BOOT_DEVICE (ls1012a_pfe1) = { +U_BOOT_DRVINFO (ls1012a_pfe1) = { .name ="pfe_eth" , .plat = &pfe_pdata1, };board/freescale/lx2160a/lx2160a.c +2
-2@@ -62,7 +62,7 @@ static struct pl01x_serial_plat serial0 = { .type = TYPE_PL011, }; -U_BOOT_DEVICE (nxp_serial0) = { +U_BOOT_DRVINFO (nxp_serial0) = { .name ="serial_pl01x" , .plat = &serial0, };@@ -72,7 +72,7 @@ static struct pl01x_serial_plat serial1 = { .type = TYPE_PL011, }; -U_BOOT_DEVICE (nxp_serial1) = { +U_BOOT_DRVINFO (nxp_serial1) = { .name ="serial_pl01x" , .plat = &serial1, };board/gateworks/gw_ventana/gw_ventana.c +1
-1@@ -1375,7 +1375,7 @@ static struct mxc_serial_plat ventana_mxc_serial_plat = { .reg = (struct mxc_uart *)UART2_BASE, }; -U_BOOT_DEVICE (ventana_serial) = { +U_BOOT_DRVINFO (ventana_serial) = { .name ="serial_mxc" , .plat = &ventana_mxc_serial_plat, };board/hisilicon/hikey/hikey.c +2
-2@@ -50,7 +50,7 @@ static const struct hikey_gpio_plat hi6220_gpio[] = { }; -U_BOOT_DEVICES (hi6220_gpios) = { +U_BOOT_DRVINFOS (hi6220_gpios) = { {"gpio_hi6220" , &hi6220_gpio[0 ] }, {"gpio_hi6220" , &hi6220_gpio[1 ] }, {"gpio_hi6220" , &hi6220_gpio[2 ] },@@ -89,7 +89,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 19200000 }; -U_BOOT_DEVICE (hikey_seriala) = { +U_BOOT_DRVINFO (hikey_seriala) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/hisilicon/hikey960/hikey960.c +1
-1@@ -32,7 +32,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 19200000 }; -U_BOOT_DEVICE (hikey960_serial0) = { +U_BOOT_DRVINFO (hikey960_serial0) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/hisilicon/poplar/poplar.c +1
-1@@ -46,7 +46,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 75000000, }; -U_BOOT_DEVICE (poplar_serial) = { +U_BOOT_DRVINFO (poplar_serial) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/isee/igep00x0/igep00x0.c +1
-1@@ -36,7 +36,7 @@ static const struct ns16550_plat igep_serial = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (igep_uart) = { +U_BOOT_DRVINFO (igep_uart) = {"ns16550_serial" , &igep_serial };board/lg/sniper/sniper.c +1
-1@@ -37,7 +37,7 @@ static const struct ns16550_plat serial_omap_plat = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (sniper_serial) = { +U_BOOT_DRVINFO (sniper_serial) = { .name ="ns16550_serial" , .plat = &serial_omap_plat };board/nokia/rx51/rx51.c +1
-1@@ -709,7 +709,7 @@ static const struct omap_i2c_plat rx51_i2c[] = { { I2C_BASE3, 400000, OMAP_I2C_REV_V1 }, }; -U_BOOT_DEVICES (rx51_i2c) = { +U_BOOT_DRVINFOS (rx51_i2c) = { {"i2c_omap" , &rx51_i2c[0 ] }, {"i2c_omap" , &rx51_i2c[1 ] }, { "i2c_omap", &rx51_i2c[2] },board/sandbox/sandbox.c +1
-1@@ -23,7 +23,7 @@ gd_t *gd;#if !CONFIG_IS_ENABLED (OF_PLATDATA )/* Add a simple GPIO device */ -U_BOOT_DEVICE (gpio_sandbox) = { +U_BOOT_DRVINFO (gpio_sandbox) = { .name ="sandbox_gpio" , };#endif board/siemens/corvus/board.c +1
-1@@ -318,7 +318,7 @@ static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE (at91sam9260_serial) = { +U_BOOT_DRVINFO (at91sam9260_serial) = { .name ="serial_atmel" , .plat = &at91sam9260_serial_plat, };board/st/stv0991/stv0991.c +1
-1@@ -30,7 +30,7 @@ static const struct pl01x_serial_plat serial_plat = { .clock = 2700 * 1000, }; -U_BOOT_DEVICE (stv09911_serials) = { +U_BOOT_DRVINFO (stv09911_serials) = { .name ="serial_pl01x" , .plat = &serial_plat, };board/sysam/amcore/amcore.c +1
-1@@ -113,7 +113,7 @@ static struct coldfire_serial_plat mcf5307_serial_plat = { .baudrate = CONFIG_BAUDRATE, }; -U_BOOT_DEVICE (coldfire_serial) = { +U_BOOT_DRVINFO (coldfire_serial) = { .name ="serial_coldfire" , .plat = &mcf5307_serial_plat, };board/ti/am335x/board.c +3
-3@@ -927,7 +927,7 @@ struct eth_pdata cpsw_pdata = { .priv_pdata = &am335_eth_data, }; -U_BOOT_DEVICE (am335x_eth) = { +U_BOOT_DRVINFO (am335x_eth) = { .name ="eth_cpsw" , .plat = &cpsw_pdata, };@@ -972,7 +972,7 @@ static const struct omap_hsmmc_plat am335x_mmc0_plat = { .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, }; -U_BOOT_DEVICE (am335x_mmc0) = { +U_BOOT_DRVINFO (am335x_mmc0) = { .name ="omap_hsmmc" , .plat = &am335x_mmc0_plat, };@@ -986,7 +986,7 @@ static const struct omap_hsmmc_plat am335x_mmc1_plat = { .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, }; -U_BOOT_DEVICE (am335x_mmc1) = { +U_BOOT_DRVINFO (am335x_mmc1) = { .name ="omap_hsmmc" , .plat = &am335x_mmc1_plat, };board/timll/devkit8000/devkit8000.c +1
-1@@ -54,7 +54,7 @@ static const struct ns16550_plat devkit8000_serial = { .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE (devkit8000_uart) = { +U_BOOT_DRVINFO (devkit8000_uart) = { "ns16550_serial", &devkit8000_serial }; diff --git
a/board/toradex/apalis_imx6/apalis_imx6.cb/board/toradex/apalis_imx6/apalis_imx6.cindex362a750b199..5ae5274584a100644 ---a/board/toradex/apalis_imx6/apalis_imx6.c+++b/board/toradex/apalis_imx6/apalis_imx6.c@@ -1149,7 +1149,7 @@ static structmxc_serial_platmxc_serial_plat= { .use_dte = true, };board/timll/devkit8000/devkit8000.c +0
-1-U_BOOT_DEVICE(mxc_serial) = { +U_BOOT_DRVINFO(mxc_serial) = { .name = "serial_mxc", .plat = &mxc_serial_plat, };board/toradex/colibri-imx6ull/colibri-imx6ull.c +1
-1@@ -208,7 +208,7 @@ static struct mxc_serial_plat mxc_serial_plat = { .use_dte = 1, }; -U_BOOT_DEVICE (mxc_serial) = { +U_BOOT_DRVINFO (mxc_serial) = { .name ="serial_mxc" , .plat = &mxc_serial_plat, };board/toradex/colibri_imx6/colibri_imx6.c +1
-1@@ -1091,7 +1091,7 @@ static struct mxc_serial_plat mxc_serial_plat = { .use_dte = true, }; -U_BOOT_DEVICE (mxc_serial) = { +U_BOOT_DRVINFO (mxc_serial) = { .name ="serial_mxc" , .plat = &mxc_serial_plat, };board/toradex/colibri_pxa270/colibri_pxa270.c +2
-2@@ -133,7 +133,7 @@ static const struct pxa_mmc_plat mmc_plat = { .base = (struct pxa_mmc_regs *)MMC0_BASE, }; -U_BOOT_DEVICE (pxa_mmcs) = { +U_BOOT_DRVINFO (pxa_mmcs) = { .name ="pxa_mmc" , .plat = &mmc_plat, };@@ -146,7 +146,7 @@ static const struct pxa_serial_plat serial_plat = { .baudrate = CONFIG_BAUDRATE, }; -U_BOOT_DEVICE (pxa_serials) = { +U_BOOT_DRVINFO (pxa_serials) = { .name ="serial_pxa" , .plat = &serial_plat, };doc/driver-model/design.rst +9
-9@@ -422,7 +422,7 @@ Device Tree While plat is useful, a more flexible way of providing device data is by using device tree. In U-Boot you should use this where possible. Avoid -sending patches which make use of the U_BOOT_DEVICE() macro unless strictly +sending patches which make use of the U_BOOT_DRVINFO() macro unless strictly necessary. With device tree we replace the above code with the following device tree@@ -436,7 +436,7 @@ fragment: sides = <4>; }; -This means that instead of having lots of U_BOOT_DEVICE() declarations in +This means that instead of having lots of U_BOOT_DRVINFO() declarations in the board file, we put these in the device tree. This approach allows a lot more generality, since the same board file can support many types of boards (e,g. with the same SoC) just by using different device trees. An added@@ -665,9 +665,9 @@ Bind stage U-Boot discovers devices using one of these two methods: -- Scan the U_BOOT_DEVICE() definitions. U-Boot looks up the name specified +- Scan the U_BOOT_DRVINFO() definitions. U-Boot looks up the name specified by each, to find the appropriate U_BOOT_DRIVER() definition. In this case, - there is no path by which driver_data may be provided, but the U_BOOT_DEVICE() + there is no path by which driver_data may be provided, but the U_BOOT_DRVINFO() may provide plat. - Scan through the device tree definitions. U-Boot looks at top-level@@ -685,7 +685,7 @@ driver's bind() method if one is defined. At this point all the devices are known, and bound to their drivers. There is a 'struct udevice' allocated for all devices. However, nothing has been activated (except for the root device). Each bound device that was created -from a U_BOOT_DEVICE() declaration will hold the plat pointer specified +from a U_BOOT_DRVINFO() declaration will hold the plat pointer specified in that declaration. For a bound device created from the device tree, plat will be NULL, but of_offset will be the offset of the device tree node that caused the device to be created. The uclass is set correctly for@@ -726,7 +726,7 @@ The steps are: 2. If plat_auto is non-zero, then the platform data space is allocated. This is only useful for device tree operation, since otherwise you would have to specific the platform data in the - U_BOOT_DEVICE() declaration. The space is allocated for the device and + U_BOOT_DRVINFO() declaration. The space is allocated for the device and zeroed. It will be accessible as dev->plat. 3. If the device's uclass specifies a non-zero per_device_auto,@@ -746,7 +746,7 @@ The steps are: do various calls like dev_read_u32(dev, ...) to access the node and store the resulting information into dev->plat. After this point, the device works the same way whether it was bound using a device tree node or - U_BOOT_DEVICE() structure. In either case, the platform data is now stored + U_BOOT_DRVINFO() structure. In either case, the platform data is now stored in the plat structure. Typically you will use the plat_auto feature to specify the size of the platform data structure, and U-Boot will automatically allocate and zero it for you before@@ -855,7 +855,7 @@ remove it. This performs the probe steps in reverse: 4. The device memory is freed (platform data, private data, uclass data, parent data). - Note: Because the platform data for a U_BOOT_DEVICE() is defined with a + Note: Because the platform data for a U_BOOT_DRVINFO() is defined with a static pointer, it is not de-allocated during the remove() method. For a device instantiated using the device tree data, the platform data will be dynamically allocated, and thus needs to be deallocated during the@@ -931,7 +931,7 @@ property can provide better control granularity on which device is bound before relocation. While with DM_FLAG_PRE_RELOC flag of the driver all devices with the same driver are bound, which requires allocation a large amount of memory. When device tree is not used, DM_FLAG_PRE_RELOC is the -only way for statically declared devices via U_BOOT_DEVICE() to be bound +only way for statically declared devices via U_BOOT_DRVINFO() to be bound prior to relocation. It is possible to limit this to specific relocation steps, by usingdoc/driver-model/of-plat.rst +6
-6@@ -21,7 +21,7 @@ SoCs require a 16KB SPL image which must include a full MMC stack. In this case the overhead of device tree access may be too great. It is possible to create platform data manually by defining C structures -for it, and reference that data in a U_BOOT_DEVICE() declaration. This +for it, and reference that data in a U_BOOT_DRVINFO() declaration. This bypasses the use of device tree completely, effectively creating a parallel configuration mechanism. But it is an available option for SPL.@@ -79,7 +79,7 @@ SPL/TPL and should be tested with: A new tool called 'dtoc' converts a device tree file either into a set of struct declarations, one for each compatible node, and a set of -U_BOOT_DEVICE() declarations along with the actual platform data for each +U_BOOT_DRVINFO() declarations along with the actual platform data for each device. As an example, consider this MMC node: .. code-block:: none@@ -155,7 +155,7 @@ and the following device declarations: .card_detect_delay = 0xc8, }; - U_BOOT_DEVICE(dwmmc_at_ff0c0000) = { + U_BOOT_DRVINFO(dwmmc_at_ff0c0000) = { .name = "rockchip_rk3288_dw_mshc", .plat = &dtv_dwmmc_at_ff0c0000, .plat_size = sizeof(dtv_dwmmc_at_ff0c0000),@@ -178,7 +178,7 @@ platform data in the driver. The of_to_plat() method should therefore do nothing in such a driver. Note that for the platform data to be matched with a driver, the 'name' -property of the U_BOOT_DEVICE() declaration has to match a driver declared +property of the U_BOOT_DRVINFO() declaration has to match a driver declared via U_BOOT_DRIVER(). This effectively means that a U_BOOT_DRIVER() with a 'name' corresponding to the devicetree 'compatible' string (after converting it to a valid name for C) is needed, so a dedicated driver is required for@@ -189,7 +189,7 @@ used to declare an alias for a driver name, typically a 'compatible' string. This macro produces no code, but it is by dtoc tool. The parent_idx is the index of the parent driver_info structure within its -linker list (instantiated by the U_BOOT_DEVICE() macro). This is used to support +linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support dev_get_parent(). The dm_populate_phandle_data() is included to allow for fix-ups required by dtoc. It is not currently used. The values in 'clocks' are the index of the driver_info for the target device followed by any phandle@@ -339,7 +339,7 @@ prevents them being used inadvertently. All usage must be bracketed with The dt-plat.c file contains the device declarations and is is built in spl/dt-plat.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 +information by adding references to U_BOOT_DRVINFO by using DM_GET_DEVICE The pylibfdt Python module is used to access the devicetree.doc/driver-model/remoteproc-framework.rst +1
-1@@ -125,7 +125,7 @@ a simplified definition of a device is as follows: .driver_plat_data = &mydriver_data; }; - U_BOOT_DEVICE(proc_3_demo) = { + U_BOOT_DRVINFO(proc_3_demo) = { .name = "sandbox_test_proc", .plat = &proc_3_test, };doc/driver-model/spi-howto.rst +2
-2@@ -270,7 +270,7 @@ fills in the fields from device tree. Add the platform data [non-device-tree only] -------------------------------------------- -Specify this data in a U_BOOT_DEVICE() declaration in your board file: +Specify this data in a U_BOOT_DRVINFO() declaration in your board file: .. code-block:: c@@ -281,7 +281,7 @@ Specify this data in a U_BOOT_DEVICE() declaration in your board file: .deactivate_delay_us = ... }; - U_BOOT_DEVICE(board_spi0) = { + U_BOOT_DRVINFO(board_spi0) = { .name = "exynos_spi", .plat = &platdata_spi0, };drivers/crypto/fsl/fsl_rsa.c +1
-1@@ -55,6 +55,6 @@ U_BOOT_DRIVER(fsl_rsa_mod_exp) = { .ops = &fsl_mod_exp_ops, }; -U_BOOT_DEVICE (fsl_rsa) = { +U_BOOT_DRVINFO (fsl_rsa) = { .name ="fsl_rsa_mod_exp" , };drivers/crypto/rsa_mod_exp/mod_exp_sw.c +1
-1@@ -35,6 +35,6 @@ U_BOOT_DRIVER(mod_exp_sw) = { .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DEVICE (mod_exp_sw) = { +U_BOOT_DRVINFO (mod_exp_sw) = { .name = "mod_exp_sw", }; diff --git a/drivers/demo/demo-pdata.c
b/drivers/demo/demo-pdata.cindexb504c31373c..818f77503a3100644 ---a/drivers/demo/demo-pdata.c+++b/drivers/demo/demo-pdata.c@@ -20,27 +20,27 @@ static const structdm_demo_pdatayellow_hexagon= { .sides
= 6. }; -U_BOOT_DEVICE(demo0) = { +U_BOOT_DRVINFO(demo0) = { .name = "demo_shape_drv",
.plat =&red_square,
};drivers/crypto/rsa_mod_exp/mod_exp_sw.c +4
-4-U_BOOT_DEVICE (demo1) = { +U_BOOT_DRVINFO (demo1) = { .name ="demo_simple_drv" , .plat = &red_square, }; -U_BOOT_DEVICE (demo2) = { +U_BOOT_DRVINFO (demo2) = { .name ="demo_shape_drv" , .plat = &green_triangle, }; -U_BOOT_DEVICE (demo3) = { +U_BOOT_DRVINFO (demo3) = { .name ="demo_simple_drv" , .plat = &yellow_hexagon, }; -U_BOOT_DEVICE (demo4) = { +U_BOOT_DRVINFO (demo4) = { .name ="demo_shape_drv" , .plat = &yellow_hexagon, };drivers/gpio/imx_rgpio2p.c +2
-2@@ -158,7 +158,7 @@ static int imx_rgpio2p_bind(struct udevice *dev)/* * If plat already exsits, directly return. * Actually only when DT is not supported, plat -* is statically initialized in U_BOOT_DEVICES.Here +* is statically initialized in U_BOOT_DRVINFOS.Here * will return. */ if (plat)@@ -216,7 +216,7 @@ static const struct imx_rgpio2p_plat imx_plat[] = { { 5, (struct gpio_regs *)RGPIO2P_GPIO6_BASE_ADDR }, }; -U_BOOT_DEVICES (imx_rgpio2ps) = { +U_BOOT_DRVINFOS (imx_rgpio2ps) = { {"imx_rgpio2p" , &imx_plat[0 ] }, {"imx_rgpio2p" , &imx_plat[1 ] }, { "imx_rgpio2p", &imx_plat[2] },drivers/gpio/mxc_gpio.c +1
-1@@ -372,7 +372,7 @@ static const struct mxc_gpio_plat mxc_plat[] = {#endif }; -U_BOOT_DEVICES (mxc_gpios) = { +U_BOOT_DRVINFOS (mxc_gpios) = { {"gpio_mxc" , &mxc_plat[0 ] }, {"gpio_mxc" , &mxc_plat[1 ] }, { "gpio_mxc", &mxc_plat[2] }, diff --git a/drivers/remoteproc/sandbox_testproc.c
b/drivers/remoteproc/sandbox_testproc.cindexee2ee730712..6836eca4c55100644 ---a/drivers/remoteproc/sandbox_testproc.c+++b/drivers/remoteproc/sandbox_testproc.c@@ -352,7 +352,7 @@ static structdm_rproc_uclass_pdataproc_3_test= { .mem_type =RPROC_INTERNAL_MEMORY_MAPPED, }; -U_BOOT_DEVICE(proc_3_demo) = {drivers/gpio/mxc_gpio.c +1
-0+U_BOOT_DRVINFO (proc_3_demo) = { .name ="sandbox_test_proc" , .plat = &proc_3_test, };drivers/rtc/emul_rtc.c +1
-1@@ -91,6 +91,6 @@ U_BOOT_DRIVER(rtc_emul) = { .priv_auto = sizeof(struct emul_rtc), }; -U_BOOT_DEVICE (rtc_emul) = { +U_BOOT_DRVINFO (rtc_emul) = { .name = "rtc_emul", }; diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.cindex
19368ba2560..756738c2d21100644 ---a/drivers/serial/sandbox.c+++b/drivers/serial/sandbox.c@@ -241,7 +241,7 @@ static const structsandbox_serial_platplatdata_non_fdt= { .colour = -1, };drivers/rtc/emul_rtc.c +1
-1-U_BOOT_DEVICE (serial_sandbox_non_fdt) = { +U_BOOT_DRVINFO (serial_sandbox_non_fdt) = { .name ="sandbox_serial" , .plat = &platdata_non_fdt, };drivers/sysreset/sysreset_sandbox.c +2
-2@@ -47,7 +47,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)/* * If we have a device tree, the device we created from platform data -* (see the U_BOOT_DEVICE() declaration below) should not do anything. +* (see the U_BOOT_DRVINFO() declaration below) should not do anything. * If we are that device, return an error. */ if (state->fdt_fname && !dev_has_ofnode (dev))@@ -135,7 +135,7 @@ U_BOOT_DRIVER(warm_sysreset_sandbox) = {#if !CONFIG_IS_ENABLED (OF_PLATDATA )/* This is here in case we don't have a device tree */ -U_BOOT_DEVICE (sysreset_sandbox_non_fdt) = { +U_BOOT_DRVINFO (sysreset_sandbox_non_fdt) = { .name ="sysreset_sandbox" , };#endif drivers/timer/sandbox_timer.c +1
-1@@ -65,6 +65,6 @@ U_BOOT_DRIVER(sandbox_timer) = { };/* This is here in case we don't have a device tree */ -U_BOOT_DEVICE (sandbox_timer_non_fdt) = { +U_BOOT_DRVINFO (sandbox_timer_non_fdt) = { .name = "sandbox_timer", }; diff --git a/drivers/video/sunxi/sunxi_de2.c
b/drivers/video/sunxi/sunxi_de2.cindex50657a77d36..a3e21aa5f13100644 ---a/drivers/video/sunxi/sunxi_de2.c+++b/drivers/video/sunxi/sunxi_de2.c@@ -319,7 +319,7 @@U_BOOT_DRIVER(sunxi_de2)= { .flags =DM_FLAG_PRE_RELOC, };drivers/timer/sandbox_timer.c +0
-1-U_BOOT_DEVICE(sunxi_de2) = { +U_BOOT_DRVINFO(sunxi_de2) = { .name = "sunxi_de2" };drivers/video/sunxi/sunxi_dw_hdmi.c +1
-1@@ -398,6 +398,6 @@ U_BOOT_DRIVER(sunxi_dw_hdmi) = { .priv_auto = sizeof(struct sunxi_dw_hdmi_priv), }; -U_BOOT_DEVICE (sunxi_dw_hdmi) = { +U_BOOT_DRVINFO (sunxi_dw_hdmi) = { .name = "sunxi_dw_hdmi" }; diff --git a/drivers/video/sunxi/sunxi_lcd.c
b/drivers/video/sunxi/sunxi_lcd.cindexdd2bb1f5fc5..635edf6dd3b100644 ---a/drivers/video/sunxi/sunxi_lcd.c+++b/drivers/video/sunxi/sunxi_lcd.c@@ -146,7 +146,7 @@U_BOOT_DRIVER(sunxi_lcd)= { }; #ifdefCONFIG_MACH_SUN50Idrivers/video/sunxi/sunxi_dw_hdmi.c +0
-1-U_BOOT_DEVICE(sunxi_lcd) = { +U_BOOT_DRVINFO(sunxi_lcd) = { .name = "sunxi_lcd" };#endif dts/Kconfig +4
-4@@ -346,13 +346,13 @@ config SPL_OF_PLATDATA former can add 3KB or more to a Thumb 2 Image. This option enables generation of platform data from the device - tree as C code. This code creates devices using U_BOOT_DEVICE() + tree as C code. This code creates devices using U_BOOT_DRVINFO() declarations. The benefit is that it allows driver code to access the platform data directly in C structures, avoidin the libfdt overhead. This option works by generating C structure declarations for each - compatible string, then adding platform data and U_BOOT_DEVICE + compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. config SPL_OF_PLATDATA_PARENT@@ -376,13 +376,13 @@ config TPL_OF_PLATDATA former can add 3KB or more to a Thumb 2 Image. This option enables generation of platform data from the device - tree as C code. This code creates devices using U_BOOT_DEVICE() + tree as C code. This code creates devices using U_BOOT_DRVINFO() declarations. The benefit is that it allows driver code to access the platform data directly in C structures, avoidin the libfdt overhead. This option works by generating C structure declarations for each - compatible string, then adding platform data and U_BOOT_DEVICE + compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. config TPL_OF_PLATDATA_PARENTinclude/dm/device.h +2
-2@@ -104,7 +104,7 @@ enum {* particular port or peripheral (essentially a driver instance). * * A device will come into existence through a 'bind' call, either due to -* a U_BOOT_DEVICE() macro (in which case plat is non-NULL) or a node +* a U_BOOT_DRVINFO() macro (in which case plat is non-NULL) or a node * in the device tree (in which case of_offset is >= 0). In the latter case * we translate the device tree information into plat in a function * implemented by the driver of_to_plat method (called just before the @@ -293,7 +293,7 @@ struct udevice_id {* platform data to be allocated in the device's ->plat pointer. * This is typically only useful for device-tree-aware drivers (those with * an of_match), since drivers which use plat will have the data -* provided in the U_BOOT_DEVICE() instantiation. +* provided in the U_BOOT_DRVINFO() instantiation. * @per_child_auto: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. include/dm/lists.h +1
-1@@ -35,7 +35,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id);/** * lists_bind_drivers() - search for and bind all drivers to parent * -* This searches the U_BOOT_DEVICE() structures and creates new devices for +* This searches the U_BOOT_DRVINFO() structures and creates new devices for * each one. The devices will have @parent as their parent. * * @parent: parent device (root) include/dm/platdata.h +8
-8@@ -56,31 +56,31 @@ struct driver_rt {* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is * available). U-Boot's driver model uses device tree for configuration. * -* When of-platdata is in use, U_BOOT_DEVICE() cannot be used outside of the +* When of-platdata is in use, U_BOOT_DRVINFO() cannot be used outside of the * dt-plat.c file created by dtoc */ #if CONFIG_IS_ENABLED (OF_PLATDATA ) && !defined(DT_PLATDATA_C ) -#define U_BOOT_DEVICE (__name) _Static_assert(false, \ - "Cannot use U_BOOT_DEVICE with of-platdata. Please use devicetree instead") +#define U_BOOT_DRVINFO (__name) _Static_assert(false, \ + "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead")#else -#define U_BOOT_DEVICE (__name) \ +#define U_BOOT_DRVINFO (__name) \ ll_entry_declare(struct driver_info, __name, driver_info)#endif /* Declare a list of devices. The argument is a driver_info[] array */ -#define U_BOOT_DEVICES (__name) \ +#define U_BOOT_DRVINFOS (__name) \ ll_entry_declare_list(struct driver_info, __name, driver_info)/** * Get a pointer to a given device info given its name * -* With the declaration U_BOOT_DEVICE(name), DM_GET_DEVICE(name) will return a +* With the declaration U_BOOT_DRVINFO(name), DM_GET_DEVICE(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * -* TODO(sjg at chromium.org): U_BOOT_DEVICE() tells U-Boot to create a device, so +* TODO(sjg at chromium.org): U_BOOT_DRVINFO() tells U-Boot to create a device, so * the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it * finds the driver_info record, not the device. * @@ -93,7 +93,7 @@ struct driver_rt {/** * dm_populate_phandle_data() - Populates phandle data in platda * -* This populates phandle data with an U_BOOT_DEVICE entry get by +* This populates phandle data with an U_BOOT_DRVINFO entry get by * DM_GET_DEVICE. The implementation of this function will be done * by dtoc when parsing dtb. */ include/dm/platform_data/spi_pl022.h +1
-1@@ -3,7 +3,7 @@* (C) Copyright 2018 * Quentin Schulz, Bootlin,quentin.schulz at bootlin.com * -* Structure for use with U_BOOT_DEVICE for pl022 SPI devices or to use +* Structure for use with U_BOOT_DRVINFO for pl022 SPI devices or to use * in of_to_plat. */ test/dm/core.c +3
-3@@ -43,17 +43,17 @@ static const struct dm_test_pdata test_pdata_pre_reloc = { .ping_add = TEST_INTVAL_PRE_RELOC, }; -U_BOOT_DEVICE (dm_test_info1) = { +U_BOOT_DRVINFO (dm_test_info1) = { .name ="test_drv" , .plat = &test_pdata[0 ], }; -U_BOOT_DEVICE (dm_test_info2) = { +U_BOOT_DRVINFO (dm_test_info2) = { .name ="test_drv" , .plat = &test_pdata[1 ], }; -U_BOOT_DEVICE (dm_test_info3) = { +U_BOOT_DRVINFO (dm_test_info3) = { .name ="test_drv" , .plat = &test_pdata[2 ], };tools/dtoc/dtb_platdata.py +4
-4@@ -713,14 +713,14 @@ class DtbPlatdata(): def _declare_device(self, var_name, struct_name, node_parent): """Add a device declaration to the output - This declares a U_BOOT_DEVICE() for the device being processed + This declares a U_BOOT_DRVINFO() for the device being processed Args: var_name (str): C name for the node struct_name (str): Name for the dt struct associated with the node node_parent (Node): Parent of the node (or None if none) """ - self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name) + self.buf('U_BOOT_DRVINFO(%s) = {\n' % var_name) self.buf('\t.name\t\t= "%s",\n' % struct_name) self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name)) self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))@@ -783,14 +783,14 @@ class DtbPlatdata(): """Generate device defintions for the platform data This writes out C platform data initialisation data and - U_BOOT_DEVICE() declarations for each valid node. Where a node has + U_BOOT_DRVINFO() declarations for each valid node. Where a node has multiple compatible strings, a #define is used to make them equivalent. See the documentation in doc/driver-model/of-plat.rst for more information. """ self.out_header() - self.out('/* Allow use of U_BOOT_DEVICE() in this file */\n') + self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') self.out('#define DT_PLATDATA_C\n') self.out('\n') self.out('#include <common.h>\n')tools/dtoc/test_dtoc.py +33
-33@@ -44,7 +44,7 @@ C_HEADER = '''/* * This file was generated by dtoc from a .dtb (device tree binary) file. */ -/* Allow use of U_BOOT_DEVICE() in this file */ +/* Allow use of U_BOOT_DRVINFO() in this file */ #define DT_PLATDATA_C #include <common.h>@@ -214,7 +214,7 @@ struct dtd_sandbox_spl_test { /* Node /i2c at 0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { }; -U_BOOT_DEVICE(i2c_at_0) = { +U_BOOT_DRVINFO(i2c_at_0) = { \t.name\t\t= "sandbox_i2c_test", \t.plat\t= &dtv_i2c_at_0, \t.plat_size\t= sizeof(dtv_i2c_at_0),@@ -226,7 +226,7 @@ static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = { \t.low_power\t\t= true, \t.reg\t\t\t= {0x9, 0x0}, }; -U_BOOT_DEVICE(pmic_at_9) = { +U_BOOT_DRVINFO(pmic_at_9) = { \t.name\t\t= "sandbox_pmic_test", \t.plat\t= &dtv_pmic_at_9, \t.plat_size\t= sizeof(dtv_pmic_at_9),@@ -246,7 +246,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { \t.stringarray\t\t= {"multi-word", "message", ""}, \t.stringval\t\t= "message", }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test, \t.plat_size\t= sizeof(dtv_spl_test),@@ -265,7 +265,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { \t.stringarray\t\t= {"another", "multi-word", "message"}, \t.stringval\t\t= "message2", }; -U_BOOT_DEVICE(spl_test2) = { +U_BOOT_DRVINFO(spl_test2) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test2, \t.plat_size\t= sizeof(dtv_spl_test2),@@ -278,7 +278,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test3 = { \t\t0x0}, \t.stringarray\t\t= {"one", "", ""}, }; -U_BOOT_DEVICE(spl_test3) = { +U_BOOT_DRVINFO(spl_test3) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test3, \t.plat_size\t= sizeof(dtv_spl_test3),@@ -333,7 +333,7 @@ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { \t.gpio_controller\t= true, \t.sandbox_gpio_count\t= 0x14, }; -U_BOOT_DEVICE(gpios_at_0) = { +U_BOOT_DRVINFO(gpios_at_0) = { \t.name\t\t= "sandbox_gpio", \t.plat\t= &dtv_gpios_at_0, \t.plat_size\t= sizeof(dtv_gpios_at_0),@@ -365,7 +365,7 @@ struct dtd_invalid { /* Node /spl-test index 0 */ static struct dtd_invalid dtv_spl_test = { }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "invalid", \t.plat\t= &dtv_spl_test, \t.plat_size\t= sizeof(dtv_spl_test),@@ -400,7 +400,7 @@ struct dtd_target { static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(phandle2_target) = { +U_BOOT_DRVINFO(phandle2_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle2_target, \t.plat_size\t= sizeof(dtv_phandle2_target),@@ -411,7 +411,7 @@ U_BOOT_DEVICE(phandle2_target) = { static struct dtd_target dtv_phandle3_target = { \t.intval\t\t\t= 0x2, }; -U_BOOT_DEVICE(phandle3_target) = { +U_BOOT_DRVINFO(phandle3_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle3_target, \t.plat_size\t= sizeof(dtv_phandle3_target),@@ -422,7 +422,7 @@ U_BOOT_DEVICE(phandle3_target) = { static struct dtd_target dtv_phandle_target = { \t.intval\t\t\t= 0x0, }; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, \t.plat_size\t= sizeof(dtv_phandle_target),@@ -437,7 +437,7 @@ static struct dtd_source dtv_phandle_source = { \t\t\t{1, {12, 13}}, \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source) = { +U_BOOT_DRVINFO(phandle_source) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source, \t.plat_size\t= sizeof(dtv_phandle_source),@@ -449,7 +449,7 @@ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, \t.plat_size\t= sizeof(dtv_phandle_source2),@@ -487,7 +487,7 @@ struct dtd_target { /* Node /phandle-target index 1 */ static struct dtd_target dtv_phandle_target = { }; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, \t.plat_size\t= sizeof(dtv_phandle_target),@@ -499,7 +499,7 @@ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { \t\t\t{1, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, \t.plat_size\t= sizeof(dtv_phandle_source2),@@ -522,7 +522,7 @@ void dm_populate_phandle_data(void) { static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(phandle2_target) = { +U_BOOT_DRVINFO(phandle2_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle2_target, \t.plat_size\t= sizeof(dtv_phandle2_target),@@ -533,7 +533,7 @@ U_BOOT_DEVICE(phandle2_target) = { static struct dtd_target dtv_phandle3_target = { \t.intval\t\t\t= 0x2, }; -U_BOOT_DEVICE(phandle3_target) = { +U_BOOT_DRVINFO(phandle3_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle3_target, \t.plat_size\t= sizeof(dtv_phandle3_target),@@ -544,7 +544,7 @@ U_BOOT_DEVICE(phandle3_target) = { static struct dtd_target dtv_phandle_target = { \t.intval\t\t\t= 0x0, }; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, \t.plat_size\t= sizeof(dtv_phandle_target),@@ -559,7 +559,7 @@ static struct dtd_source dtv_phandle_source = { \t\t\t{1, {12, 13}}, \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source) = { +U_BOOT_DRVINFO(phandle_source) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source, \t.plat_size\t= sizeof(dtv_phandle_source),@@ -571,7 +571,7 @@ static struct dtd_source dtv_phandle_source2 = { \t.cd_gpios\t\t= { \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, \t.plat_size\t= sizeof(dtv_phandle_source2),@@ -629,7 +629,7 @@ struct dtd_test3 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1),@@ -640,7 +640,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2),@@ -651,7 +651,7 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, \t.plat_size\t= sizeof(dtv_test3),@@ -684,7 +684,7 @@ struct dtd_test2 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1),@@ -695,7 +695,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x12345678, 0x98765432, 0x2, 0x3}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2),@@ -731,7 +731,7 @@ struct dtd_test3 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x123400000000, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1),@@ -742,7 +742,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x1234567890123456, 0x98765432}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2),@@ -753,7 +753,7 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x1234567890123456, 0x98765432, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, \t.plat_size\t= sizeof(dtv_test3),@@ -789,7 +789,7 @@ struct dtd_test3 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1),@@ -800,7 +800,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x12345678, 0x9876543210987654}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2),@@ -811,7 +811,7 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x12345678, 0x9876543210987654, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, \t.plat_size\t= sizeof(dtv_test3),@@ -863,7 +863,7 @@ struct dtd_sandbox_spl_test { static struct dtd_sandbox_spl_test dtv_spl_test = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test, \t.plat_size\t= sizeof(dtv_spl_test),@@ -874,7 +874,7 @@ U_BOOT_DEVICE(spl_test) = { static struct dtd_sandbox_spl_test dtv_spl_test2 = { \t.intarray\t\t= 0x5, }; -U_BOOT_DEVICE(spl_test2) = { +U_BOOT_DRVINFO(spl_test2) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test2, \t.plat_size\t= sizeof(dtv_spl_test2),
PATCH 22/49 dtoc: Tidy up src_scan tests
In reply to Simon GlassSome of these tests don't actually check anything. Add a few more checks to complete the tests.
Also add a simple scan test that does the basics.
---
tools/dtoc/test_src_scan.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 21/49 dtoc: Move src_scan tests to a separate file
In reply to Simon GlassMove the tests related to scanning into their own class, updating them to avoid using dtb_platdata as a pass-through.
---
tools/dtoc/dtb_platdata.py | 2 +- tools/dtoc/main.py | 5 +- tools/dtoc/src_scan.py | 4 +- tools/dtoc/test_dtoc.py | 73 ----------------------------- tools/dtoc/test_src_scan.py | 91 +++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 78 deletions(-) create mode 100644 tools/dtoc/test_src_scan.py
Applied to u-boot-dm/next, thanks!
PATCH 20/49 dtoc: Split source-code scanning to a separate file
In reply to Simon GlassBefore expanding the scanning features any more, move this into a separate file. This will make it easier to maintain in the future. In particular, it reduces the size of dtb_platdata.py and allows us to add tests specifically for scanning, without going through that file.
The pieces moved are the Driver class, the scanning code and the various naming functions, since they mostly depend on the scanning results.
So far there is are no separate tests for src_scan. These will be added as new functionality appears.
This introduces no functional change.
---
tools/dtoc/dtb_platdata.py | 174 +++------------------------------- tools/dtoc/src_scan.py | 185 +++++++++++++++++++++++++++++++++++++ tools/dtoc/test_dtoc.py | 14 +-- 3 files changed, 204 insertions(+), 169 deletions(-) create mode 100644 tools/dtoc/src_scan.py
Applied to u-boot-dm/next, thanks!
PATCH 19/49 dtoc: Drop dm_populate_phandle_data()
In reply to Simon GlassThis has not been needed since parent information was added and we started using indicies for references to other drivers instead of pointers. It was kept around in the expectation that it might be needed later.
However with the latest updates, it doesn't seem likely that we'll need this in the foreseeable future.
Drop dm_populate_phandle_data() from dtoc and driver model.
---
doc/driver-model/of-plat.rst | 16 ++++++---------- drivers/core/root.c | 3 --- include/dm/platdata.h | 8 -------- tools/dtoc/dtb_platdata.py | 6 ------ tools/dtoc/test_dtoc.py | 29 +++++++---------------------- 5 files changed, 13 insertions(+), 49 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 18/49 dtoc: Output nodes in order
In reply to Simon GlassPreviously we had to worry about nodes being output before those that they depended on, thus causing build errors. So the current algorithm is careful to output nodes in the right order.
We now use a different method for outputting phandles that does not involve pointers. Also we plan to add a 'declarations' header file to declare all drivers as 'extern'.
Update the code to drop the dependency checking and output in a simple loop. This makes the output easier to follow since drivers are in order of thier indices (0, 1, ...), which is also the order it appears in in the linker list.
---
tools/dtoc/dtb_platdata.py | 13 ++------ tools/dtoc/test_dtoc.py | 64 +++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 43 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 17/49 dtoc: Allow specifying the base directory for tests
In reply to Simon GlassThe base directory of U-Boot, where the source is, it currently calculated from the directory of the dtb_platdata.py script. If this is installed elsewhere that will not work. Also it is inconvenient for tests.
Add a parameter to allow specifying this base directory.
To test this, pass a temporary directory with some files in it and check that they are passed to scan_driver().
---
tools/dtoc/dtb_platdata.py | 18 ++++++++++++------ tools/dtoc/test_dtoc.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 16/49 dtoc: Add the method for each command to OutputFile
In reply to Simon GlassRather than the if/else construct, update OutputFile with the method to call to process each command. This is easier to maintain as the number of commands increases.
Rename generate_tables to generate_plat since it better describes what is being generated ('plat' is the U-Boot name for platform data).
With this, each output method needs to have the same signature. Store the output structures in a member variable instead of using parameters, to accomplish this.
---
tools/dtoc/dtb_platdata.py | 42 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 15/49 dtoc: Rename dt-platdata.c to dt-plat.c
In reply to Simon GlassUse this new name to be consistent with the rest of U-Boot, which talks about 'plat' for the platform data, which is what this file holds.
---
include/dm/platdata.h | 2 +- include/linux/mtd/spi-nor.h | 2 +- scripts/Makefile.spl | 2 +- tools/dtoc/dtb_platdata.py | 4 ++-- tools/dtoc/test_dtoc.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 14/49 dtoc: Add a header comment to each generated file
In reply to Simon GlassIt is currently fairly obvious what the two generated files are for, but this will change as more are added. It is helpful for readers to describe the purpose of each file.
Add a header commment field to OutputFile and use it to generate a comment at the top of each file.
---
tools/dtoc/dtb_platdata.py | 30 ++++++++++++++++++++---------- tools/dtoc/test_dtoc.py | 6 ++++-- 2 files changed, 24 insertions(+), 12 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 13/49 dtoc: Run tests using test_util
In reply to Simon GlassUse the standard function for running tests and reported results. This allows the tests to run in parallel, which is a significant speed-up on most machines (e.g. 4.5 seconds -> 1.5s on mine).
---
tools/dtoc/main.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 12/49 concurrencytest: Fix Python3 warning
In reply to Simon GlassThis gives a warning in some situations:
File "tools/dtoc/../concurrencytest/concurrencytest.py", line 95,
in do_fork
stream = os.fdopen(c2pread, 'rb', 1) File "/usr/lib/python3.8/os.py", line 1023, in fdopen
return io.open(fd, *args, **kwargs)
RuntimeWarning: line buffering (buffering=1) isn't supported in binary
mode, the default buffer size will be used
Fix this by dropping the line-buffer parameter.
---
tools/concurrencytest/concurrencytest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 11/49 dm: Rename U_BOOT_DRIVER_ALIAS to DM_DRIVER_ALIAS
In reply to Simon GlassWe use the U_BOOT_ prefix (i.e. U_BOOT_DRIVER) to declare a driver but in every other case we just use DM_. Update the alias macros to use the DM_ prefix.
We could perhaps rename U_BOOT_DRIVER() to DM_DRIVER(), but this macro is widely used and there is at least some benefit to indicating it us a U-Boot driver, particularly for code ported from Linux. So for now, let's keep that name.
---
doc/driver-model/of-plat.rst | 6 +++--- drivers/gpio/mxc_gpio.c | 2 +- drivers/gpio/mxs_gpio.c | 2 +- drivers/gpio/sandbox.c | 2 +- drivers/i2c/rk_i2c.c | 2 +- drivers/mmc/fsl_esdhc_imx.c | 2 +- drivers/mmc/mxsmmc.c | 2 +- drivers/mmc/rockchip_dw_mmc.c | 4 ++-- drivers/mtd/spi/sf_probe.c | 2 +- drivers/pinctrl/nxp/pinctrl-imx6.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 | 6 +++--- drivers/spi/mxs_spi.c | 2 +- drivers/spi/rk_spi.c | 2 +- include/dm/device.h | 2 +- tools/dtoc/dtb_platdata.py | 6 +++--- tools/dtoc/dtoc_test_scan_drivers.cxx | 2 +- 19 files changed, 26 insertions(+), 26 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 10/49 dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET()
In reply to Simon GlassIn the spirit of using the same base name for all of these related macros, rename this to have the operation at the end. This is not widely used so the impact is fairly small.
---
arch/arm/lib/gic-v3-its.c | 10 +++++----- arch/arm/mach-aspeed/ast2500/clk_ast2500.c | 2 +- arch/arm/mach-k3/am6_init.c | 2 +- arch/arm/mach-k3/common.c | 2 +- arch/arm/mach-k3/j721e_init.c | 2 +- arch/arm/mach-mediatek/mt7629/init.c | 4 ++-- arch/arm/mach-mediatek/mt8516/init.c | 2 +- arch/arm/mach-rockchip/misc.c | 4 ++-- arch/arm/mach-rockchip/px30/clk_px30.c | 2 +- arch/arm/mach-rockchip/rk3036/clk_rk3036.c | 2 +- arch/arm/mach-rockchip/rk3128/clk_rk3128.c | 2 +- arch/arm/mach-rockchip/rk3188/clk_rk3188.c | 2 +- arch/arm/mach-rockchip/rk322x/clk_rk322x.c | 2 +- arch/arm/mach-rockchip/rk3288/clk_rk3288.c | 2 +- arch/arm/mach-rockchip/rk3308/clk_rk3308.c | 2 +- arch/arm/mach-rockchip/rk3328/clk_rk3328.c | 2 +- arch/arm/mach-rockchip/rk3368/clk_rk3368.c | 2 +- arch/arm/mach-rockchip/rk3399/clk_rk3399.c | 4 ++-- arch/arm/mach-rockchip/rv1108/clk_rv1108.c | 2 +- arch/arm/mach-socfpga/clock_manager_agilex.c | 2 +- arch/arm/mach-stm32mp/bsec.c | 2 +- arch/arm/mach-stm32mp/cmd_stm32key.c | 2 +- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 6 +++--- arch/arm/mach-stm32mp/cpu.c | 6 +++--- arch/arm/mach-uniphier/micro-support-card.c | 2 +- arch/arm/mach-zynq/clk.c | 4 ++-- arch/arm/mach-zynq/timer.c | 2 +- arch/mips/mach-mtmips/mt7628/init.c | 2 +- arch/riscv/lib/sifive_clint.c | 2 +- board/dhelectronics/dh_stm32mp1/board.c | 6 +++--- board/google/gru/gru.c | 2 +- board/nvidia/jetson-tk1/jetson-tk1.c | 2 +- board/nvidia/nyan-big/nyan-big.c | 2 +- board/renesas/ulcb/cpld.c | 2 +- board/sifive/fu540/fu540.c | 2 +- board/st/common/cmd_stboard.c | 2 +- board/st/common/stm32mp_dfu.c | 4 ++-- board/st/common/stpmic1.c | 4 ++-- board/st/common/stusb160x.c | 2 +- board/st/stm32mp1/stm32mp1.c | 12 ++++++------ board/ti/j721e/evm.c | 4 ++-- board/toradex/apalis-tk1/apalis-tk1.c | 4 ++-- drivers/clk/clk_stm32mp1.c | 2 +- drivers/clk/clk_zynqmp.c | 2 +- drivers/clk/imx/clk-imx8.c | 2 +- drivers/clk/mediatek/clk-mtk.c | 6 +++--- drivers/clk/sifive/fu540-prci.c | 2 +- drivers/firmware/scmi/scmi_agent-uclass.c | 4 ++-- drivers/gpio/gpio-uclass.c | 2 +- drivers/misc/i2c_eeprom.c | 2 +- drivers/misc/rockchip-efuse.c | 2 +- drivers/misc/stm32mp_fuse.c | 16 ++++++++-------- drivers/mtd/nand/raw/arasan_nfc.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c | 2 +- drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 2 +- drivers/mtd/nand/raw/denali_dt.c | 2 +- drivers/mtd/nand/raw/mxs_nand_dt.c | 2 +- drivers/mtd/nand/raw/octeontx_nand.c | 6 +++--- drivers/mtd/nand/raw/pxa3xx_nand.c | 2 +- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 2 +- drivers/mtd/nand/raw/tegra_nand.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 2 +- drivers/mtd/nand/raw/zynq_nand.c | 2 +- drivers/reset/reset-ast2500.c | 2 +- drivers/video/lg4573.c | 2 +- include/dm/device.h | 2 +- include/dm/uclass.h | 2 +- test/dm/core.c | 2 +- test/dm/test-fdt.c | 6 +++--- 73 files changed, 110 insertions(+), 110 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 9/49 dm: Rename DM_GET_DEVICE() to DM_DRVINFO_GET()
In reply to Walter LozanoQuoted 8 lines · Simon Glass
This does not get a device (struct udevice *) but a struct
driver_info* so the name is confusing.Rename it accordingly. Since we plan to have several various of these macros, put GET at the end instead of the middle, so it is easier to spot the related macros.
Signed-off-by Simon Glass<[email protected]>
Thanks,
Quoted 7 lines
---
doc/driver-model/of-plat.rst | 2 +- include/dm/platdata.h | 10 +++------- tools/dtoc/dtb_platdata.py | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 8/49 dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO()
In reply to Walter LozanoQuoted 9 lines · Simon Glass
The current macro is a misnomer since it does not declare a device directly. Instead, it declares
driver_inforecord which U-Boot uses at runtime to create a device.The distinction seems somewhat minor most of the time, but is becomes quite confusing when we actually want to declare a device, with of-platdata. We are left trying to distinguish between a device which isn't actually device, and a device that is (perhaps an 'instance'?)
Quoted 8 lines
It seems better to rename this macro to describe what it actually is. The macros is not widely used, since boards should use devicetree to declare devices.
Rename it to
U_BOOT_DRVINFO(), which indicates clearly that this is declaring a newdriver_inforecord, not a device.Signed-off-by Simon Glass<[email protected]>
I couldn't agree more.
Thanks,
Quoted 59 lines
---
.../mach-at91/arm926ejs/at91sam9260_devices.c | 2 +- .../arm926ejs/at91sam9m10g45_devices.c | 2 +- arch/arm/mach-imx/mx6/soc.c | 2 +- arch/arm/mach-imx/mx7/soc.c | 2 +- arch/arm/mach-lpc32xx/devices.c | 4 +- arch/arm/mach-omap2/am33xx/board.c | 10 +-- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-tegra/board.c | 2 +- arch/arm/mach-tegra/board2.c | 2 +- board/armltd/integrator/integrator.c | 2 +- board/armltd/total_compute/total_compute.c | 2 +- board/armltd/vexpress64/vexpress64.c | 2 +- board/bluewater/gurnard/gurnard.c | 2 +- board/bluewater/snapper9260/snapper9260.c | 2 +- board/cadence/xtfpga/xtfpga.c | 4 +- board/cavium/thunderx/thunderx.c | 4 +- board/compulab/cm_fx6/cm_fx6.c | 2 +- board/davinci/da8xxevm/omapl138_lcdk.c | 4 +- board/freescale/ls1012afrdm/eth.c | 4 +- board/freescale/ls1012aqds/eth.c | 4 +- board/freescale/ls1012ardb/eth.c | 4 +- board/freescale/lx2160a/lx2160a.c | 4 +- board/gateworks/gw_ventana/gw_ventana.c | 2 +- board/hisilicon/hikey/hikey.c | 4 +- board/hisilicon/hikey960/hikey960.c | 2 +- board/hisilicon/poplar/poplar.c | 2 +- board/isee/igep00x0/igep00x0.c | 2 +- board/lg/sniper/sniper.c | 2 +- board/nokia/rx51/rx51.c | 2 +- board/sandbox/sandbox.c | 2 +- board/siemens/corvus/board.c | 2 +- board/st/stv0991/stv0991.c | 2 +- board/sysam/amcore/amcore.c | 2 +- board/ti/am335x/board.c | 6 +- board/timll/devkit8000/devkit8000.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 2 +- .../toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 2 +- board/toradex/colibri_pxa270/colibri_pxa270.c | 4 +- doc/driver-model/design.rst | 18 ++--- doc/driver-model/of-plat.rst | 12 ++-- doc/driver-model/remoteproc-framework.rst | 2 +- doc/driver-model/spi-howto.rst | 4 +- drivers/crypto/fsl/fsl_rsa.c | 2 +- drivers/crypto/rsa_mod_exp/mod_exp_sw.c | 2 +- drivers/demo/demo-pdata.c | 10 +-- drivers/gpio/imx_rgpio2p.c | 4 +- drivers/gpio/mxc_gpio.c | 2 +- drivers/remoteproc/sandbox_testproc.c | 2 +- drivers/rtc/emul_rtc.c | 2 +- drivers/serial/sandbox.c | 2 +- drivers/sysreset/sysreset_sandbox.c | 4 +- drivers/timer/sandbox_timer.c | 2 +- drivers/video/sunxi/sunxi_de2.c | 2 +- drivers/video/sunxi/sunxi_dw_hdmi.c | 2 +- drivers/video/sunxi/sunxi_lcd.c | 2 +- dts/Kconfig | 8 +--
Quoted 9 lines
include/dm/device.h | 4 +- include/dm/lists.h | 2 +- include/dm/platdata.h | 16 ++--- include/dm/platform_data/spi_pl022.h | 2 +- test/dm/core.c | 6 +- tools/dtoc/dtb_platdata.py | 8 +-- tools/dtoc/test_dtoc.py | 66 +++++++++---------- 64 files changed, 148 insertions(+), 148 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 7/49 Makefile: Invoke dtoc only once
In reply to Simon GlassUpdate the Makefile to run dtoc only once, generating all required files. This saves time since there is a lot of processing in each invocation of dtoc.
We already have a variable for the object files to build, so use that instead of repeating the same filenames. Add a C version of this also, for the same reason.
This makes it easier to add new C files (generated by dtoc) to the build later, as needed.
---
scripts/Makefile.spl | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 5/49 dtoc: Allow outputing to multiple files
In reply to Simon GlassImplement the 'output directory' feature, allowing dtoc to write the output files separately to the supplied directories. This allows us to handle the struct and platdata output in one run of dtoc.
---
tools/dtoc/dtb_platdata.py | 96 ++++++++++++++++++++++++++++++++++---- tools/dtoc/test_dtoc.py | 8 ++++ 2 files changed, 94 insertions(+), 10 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 6/49 dtoc: Add an 'all' command
In reply to Simon GlassWith upcoming changes, dtoc will output several files for different of-platdata components.
Add a way to output all ava!ilable files at once ('all'), to the appropriate directories, without needing to specify each one invidually.
This puts the commands in alphabetical order, so update the tests accordingly.
---
tools/dtoc/dtb_platdata.py | 7 +++++-- tools/dtoc/main.py | 6 +----- tools/dtoc/test_dtoc.py | 40 +++++++++++++++++++++++++++++++++++--- tools/patman/tools.py | 8 ++++++++ 4 files changed, 51 insertions(+), 10 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 4/49 dtoc: Allow providing a directory to write files to
In reply to Simon GlassAt present dtoc writes only a single file on each invocation. U-Boot writes the two files it needs by separate invocations of dtoc. Since dtoc now scans all U-Boot driver source, this is fairly slow (about 1 second per file).
It would be better if dtoc could write all the files at once.
In preparation for this, add a way to specify an output directory for the files.
---
tools/dtoc/dtb_platdata.py | 8 ++++++-- tools/dtoc/main.py | 7 ++++++- tools/dtoc/test_dtoc.py | 14 +++++++------- 3 files changed, 19 insertions(+), 10 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 3/49 dtoc: Test the stdout output
In reply to Simon GlassNormally dtoc outputs to a file but it also offers a way to write output to stdout. At present the test for that does not actually check that the output is correct. Add this to the test.
This uses a member variable to hold the expected text, so it can be used in muitiple places.
---
tools/dtoc/test_dtoc.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 2/49 dtoc: Use None to mean stdout
In reply to Simon GlassAt present dtoc uses '-' internally to mean that output should go to stdout. This is not necessary and None is more convenient. Update it.
---
tools/dtoc/dtb_platdata.py | 10 +++++----- tools/dtoc/main.py | 2 +- tools/dtoc/test_dtoc.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 1/49 dtoc: Tidy up pylint warnings in test
In reply to Simon GlassTidy up this file to reduce the number of pylint warnings.
---
tools/dtoc/test_dtoc.py | 156 ++++++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 71 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH 45/49 dm: of-platadata: Add option for device instantiation
In reply to Walter LozanoHi Walter,
Quoted 37 lines · Walter Lozano
Quoted 34 lines · Simon Glass
Add
Kconfigoptions to support build-time device instantiation. When fully implemented, this will allow dtoc to create U-Boot devices (i.e. struct udevice records) at build time, thus reducing code space in SPL.For now this defaults to off, but will be enabled when the rest of the implementation is in place.
Signed-off-by Simon Glass <[email protected]>---
dts/Kconfig | 23 +++++++++++++++++++++-- scripts/Makefile.spl | 4 ++++ 2 files changed, 25 insertions(+), 2 deletions(-)dts/Kconfig +2
-1@@ -355,15 +355,24 @@ config SPL_OF_PLATDATA compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. +if SPL_OF_PLATDATA + config SPL_OF_PLATDATA_PARENT bool "Support parent information in devices" - depends on SPL_OF_PLATDATA default y help Generally it is useful to be able to access the parent of a device with of-platdata. To save space this can be disabled, but in that case dev_get_parent() will always return NULL;
Quoted 6 lines
dts/Kconfig config SPL_OF_PLATDATA · line 368
Quoted 1 line
dts/Kconfig +1
-0+config SPL_OF_PLATDATA_INSTNot sure about the limits to config names, I understand that
SPL_OF_PLATDATA_INSTmeansSPL_OF_PLATDATA_INSTANCE? I'm not sure but maybe a better name could beSPL_OF_PLATDATA_BTIME_DEV. To be honest I find it difficult to come with nice name.
Yes that's right - INST standards for instantiate. I don't think there is a limit to the name length, but obviously longer names are harder to read. BTIME doesn't seem any more enlightening that INST though.
I will try out SPL_OF_PLATDATA_INSTANTIATE and see how long it looks!
Quoted 26 lines
Quoted 26 lines
dts/Kconfig +9
-1+ bool "Declare devices at build time" + help + Declare devices as udevice instances so that they do not need to be + bound when U-Boot starts. This can save time and code space. + +endif + config TPL_OF_PLATDATA bool "Generate platform data for use in TPL" depends on TPL_OF_CONTROL@@ -385,13 +394,23 @@ config TPL_OF_PLATDATA compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. +if TPL_OF_PLATDATA + config TPL_OF_PLATDATA_PARENT bool "Support parent information in devices" - depends on TPL_OF_PLATDATA default y help Generally it is useful to be able to access the parent of a device with of-platdata. To save space this can be disabled, but in that case dev_get_parent() will always return NULL;
Quoted 7 lines
dts/Kconfig config TPL_OF_PLATDATA · line 407
Quoted 1 line
dts/Kconfig +1
-0+config TPL_OF_PLATDATA_INSTSame here. Also I have a question, in which case
TPL_OF_PLATDATA_INSTandSPL_OF_PLATDATA_INSTwould have different values. Which is the value of decoupling the TPL and SPL behavior? Or is use for consistency withSPL_OF_PLATDATA_PARENTandTPL_OF_PLATDATA_PARENT(which also not sure if needed to have two different options).
It is partly consistency, but also just that CONFIG_IS_ENABLED() only works if you define them separately. Also I want to be able to check TPL_OF_PLATDATA_INST by itself without having to check TPL_OF_PLATDATA first.
Regards,
Simon