]> Git Repo - J-u-boot.git/commitdiff
Merge tag 'dm-pull-5jan21' of git://git.denx.de/u-boot-dm into next
authorTom Rini <[email protected]>
Wed, 6 Jan 2021 03:34:43 +0000 (22:34 -0500)
committerTom Rini <[email protected]>
Wed, 6 Jan 2021 03:34:43 +0000 (22:34 -0500)
Driver model: make some udevice fields private
Driver model: Rename U_BOOT_DEVICE et al.
dtoc: Tidy up and add more tests
ns16550 code clean-up
x86 and sandbox minor fixes for of-platdata
dtoc prepration for adding build-time instantiation

410 files changed:
arch/arc/include/asm/spl.h [new file with mode: 0644]
arch/arm/cpu/armv7/ls102xa/fdt.c
arch/arm/cpu/armv8/fsl-layerscape/spl.c
arch/arm/lib/gic-v3-its.c
arch/arm/mach-aspeed/ast2500/clk_ast2500.c
arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c
arch/arm/mach-davinci/da850_lowlevel.c
arch/arm/mach-davinci/spl.c
arch/arm/mach-imx/mx6/soc.c
arch/arm/mach-imx/mx7/soc.c
arch/arm/mach-k3/am6_init.c
arch/arm/mach-k3/common.c
arch/arm/mach-k3/j721e_init.c
arch/arm/mach-keystone/init.c
arch/arm/mach-lpc32xx/devices.c
arch/arm/mach-mediatek/mt7629/init.c
arch/arm/mach-mediatek/mt8516/init.c
arch/arm/mach-omap2/am33xx/board.c
arch/arm/mach-omap2/omap3/board.c
arch/arm/mach-rockchip/misc.c
arch/arm/mach-rockchip/px30/clk_px30.c
arch/arm/mach-rockchip/rk3036/clk_rk3036.c
arch/arm/mach-rockchip/rk3128/clk_rk3128.c
arch/arm/mach-rockchip/rk3188/clk_rk3188.c
arch/arm/mach-rockchip/rk322x/clk_rk322x.c
arch/arm/mach-rockchip/rk3288/clk_rk3288.c
arch/arm/mach-rockchip/rk3308/clk_rk3308.c
arch/arm/mach-rockchip/rk3328/clk_rk3328.c
arch/arm/mach-rockchip/rk3368/clk_rk3368.c
arch/arm/mach-rockchip/rk3399/clk_rk3399.c
arch/arm/mach-rockchip/rv1108/clk_rv1108.c
arch/arm/mach-socfpga/clock_manager_agilex.c
arch/arm/mach-stm32mp/bsec.c
arch/arm/mach-stm32mp/cmd_stm32key.c
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
arch/arm/mach-stm32mp/cpu.c
arch/arm/mach-stm32mp/pwr_regulator.c
arch/arm/mach-tegra/board.c
arch/arm/mach-tegra/board2.c
arch/arm/mach-uniphier/micro-support-card.c
arch/arm/mach-zynq/clk.c
arch/arm/mach-zynq/timer.c
arch/m68k/include/asm/spl.h [new file with mode: 0644]
arch/mips/mach-mtmips/mt7628/init.c
arch/nds32/include/asm/spl.h [new file with mode: 0644]
arch/nios2/include/asm/spl.h [new file with mode: 0644]
arch/riscv/lib/sifive_clint.c
arch/sandbox/cpu/os.c
arch/sandbox/cpu/start.c
arch/sandbox/cpu/state.c
arch/sandbox/dts/sandbox.dts
arch/sandbox/dts/sandbox.dtsi
arch/sandbox/include/asm/i2c.h [new file with mode: 0644]
arch/sandbox/include/asm/serial.h [new file with mode: 0644]
arch/sh/include/asm/spl.h [new file with mode: 0644]
arch/x86/cpu/apollolake/Kconfig
arch/x86/cpu/apollolake/fsp_m.c
arch/x86/cpu/apollolake/hostbridge.c
arch/x86/cpu/apollolake/lpc.c
arch/x86/cpu/apollolake/pch.c
arch/x86/cpu/apollolake/pmc.c
arch/x86/cpu/apollolake/spl.c
arch/x86/cpu/apollolake/uart.c
arch/x86/cpu/i386/call64.S
arch/x86/cpu/intel_common/Makefile
arch/x86/cpu/intel_common/itss.c
arch/x86/cpu/intel_common/p2sb.c
arch/x86/cpu/slimbootloader/serial.c
arch/x86/cpu/turbo.c
arch/x86/dts/chromebook_coral.dts
arch/x86/dts/rtc.dtsi
arch/x86/include/asm/arch-apollolake/gpio.h
arch/x86/include/asm/arch-apollolake/hostbridge.h [new file with mode: 0644]
arch/x86/include/asm/arch-apollolake/pmc.h [new file with mode: 0644]
arch/x86/include/asm/arch-apollolake/uart.h
arch/x86/include/asm/itss.h
arch/x86/include/asm/p2sb.h [new file with mode: 0644]
arch/x86/include/asm/pmu.h
arch/x86/include/asm/sysreset.h [new file with mode: 0644]
arch/x86/lib/tpl.c
arch/xtensa/include/asm/spl.h [new file with mode: 0644]
board/Arcturus/ucp1020/spl.c
board/Arcturus/ucp1020/spl_minimal.c
board/Synology/ds109/ds109.c
board/armltd/integrator/integrator.c
board/armltd/total_compute/total_compute.c
board/armltd/vexpress64/vexpress64.c
board/bluewater/gurnard/gurnard.c
board/bluewater/snapper9260/snapper9260.c
board/cadence/xtfpga/xtfpga.c
board/cavium/thunderx/thunderx.c
board/compulab/cm_fx6/cm_fx6.c
board/davinci/da8xxevm/omapl138_lcdk.c
board/dhelectronics/dh_stm32mp1/board.c
board/freescale/ls1012afrdm/eth.c
board/freescale/ls1012aqds/eth.c
board/freescale/ls1012ardb/eth.c
board/freescale/lx2160a/lx2160a.c
board/freescale/mpc8313erdb/mpc8313erdb.c
board/freescale/mpc8315erdb/mpc8315erdb.c
board/freescale/p1010rdb/spl.c
board/freescale/p1010rdb/spl_minimal.c
board/freescale/p1_p2_rdb_pc/spl.c
board/freescale/p1_p2_rdb_pc/spl_minimal.c
board/freescale/t102xrdb/spl.c
board/freescale/t104xrdb/spl.c
board/freescale/t208xqds/spl.c
board/freescale/t208xrdb/spl.c
board/freescale/t4rdb/spl.c
board/gateworks/gw_ventana/gw_ventana.c
board/google/chromebook_coral/coral.c
board/google/gru/gru.c
board/hisilicon/hikey/hikey.c
board/hisilicon/hikey960/hikey960.c
board/hisilicon/poplar/poplar.c
board/isee/igep00x0/igep00x0.c
board/lg/sniper/sniper.c
board/nokia/rx51/rx51.c
board/nvidia/jetson-tk1/jetson-tk1.c
board/nvidia/nyan-big/nyan-big.c
board/renesas/ulcb/cpld.c
board/sandbox/sandbox.c
board/siemens/corvus/board.c
board/sifive/fu540/fu540.c
board/st/common/cmd_stboard.c
board/st/common/stm32mp_dfu.c
board/st/common/stpmic1.c
board/st/common/stusb160x.c
board/st/stm32mp1/stm32mp1.c
board/st/stv0991/stv0991.c
board/synopsys/hsdk/clk-lib.c
board/sysam/amcore/amcore.c
board/ti/am335x/board.c
board/ti/j721e/evm.c
board/timll/devkit8000/devkit8000.c
board/toradex/apalis-tk1/apalis-tk1.c
board/toradex/apalis_imx6/apalis_imx6.c
board/toradex/colibri-imx6ull/colibri-imx6ull.c
board/toradex/colibri_imx6/colibri_imx6.c
board/toradex/colibri_pxa270/colibri_pxa270.c
cmd/remoteproc.c
common/spl/Kconfig
common/spl/spl.c
doc/driver-model/design.rst
doc/driver-model/of-plat.rst
doc/driver-model/remoteproc-framework.rst
doc/driver-model/spi-howto.rst
drivers/ata/mtk_ahci.c
drivers/clk/clk-uclass.c
drivers/clk/clk.c
drivers/clk/clk_fixed_rate.c
drivers/clk/clk_stm32mp1.c
drivers/clk/clk_zynqmp.c
drivers/clk/imx/clk-imx8.c
drivers/clk/mediatek/clk-mtk.c
drivers/clk/meson/axg.c
drivers/clk/meson/g12a.c
drivers/clk/meson/gxbb.c
drivers/clk/rockchip/clk_px30.c
drivers/clk/rockchip/clk_rk3036.c
drivers/clk/rockchip/clk_rk3128.c
drivers/clk/rockchip/clk_rk3188.c
drivers/clk/rockchip/clk_rk322x.c
drivers/clk/rockchip/clk_rk3288.c
drivers/clk/rockchip/clk_rk3308.c
drivers/clk/rockchip/clk_rk3328.c
drivers/clk/rockchip/clk_rk3368.c
drivers/clk/rockchip/clk_rk3399.c
drivers/clk/rockchip/clk_rv1108.c
drivers/clk/sifive/fu540-prci.c
drivers/core/device-remove.c
drivers/core/device.c
drivers/core/devres.c
drivers/core/dump.c
drivers/core/lists.c
drivers/core/root.c
drivers/core/simple-bus.c
drivers/core/uclass.c
drivers/crypto/fsl/fsl_rsa.c
drivers/crypto/rsa_mod_exp/mod_exp_sw.c
drivers/ddr/altera/sdram_agilex.c
drivers/ddr/altera/sdram_gen5.c
drivers/ddr/altera/sdram_s10.c
drivers/ddr/altera/sdram_soc64.c
drivers/demo/demo-pdata.c
drivers/firmware/scmi/scmi_agent-uclass.c
drivers/gpio/dwapb_gpio.c
drivers/gpio/gpio-uclass.c
drivers/gpio/hi6220_gpio.c
drivers/gpio/imx_rgpio2p.c
drivers/gpio/intel_gpio.c
drivers/gpio/lpc32xx_gpio.c
drivers/gpio/mpc8xxx_gpio.c
drivers/gpio/mt7621_gpio.c
drivers/gpio/mxc_gpio.c
drivers/gpio/mxs_gpio.c
drivers/gpio/octeon_gpio.c
drivers/gpio/omap_gpio.c
drivers/gpio/s5p_gpio.c
drivers/gpio/sandbox.c
drivers/gpio/sunxi_gpio.c
drivers/gpio/tegra186_gpio.c
drivers/gpio/tegra_gpio.c
drivers/i2c/designware_i2c_pci.c
drivers/i2c/i2c-uclass.c
drivers/i2c/rk_i2c.c
drivers/i2c/sandbox_i2c.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/altera_sysid.c
drivers/misc/cros_ec_sandbox.c
drivers/misc/fs_loader.c
drivers/misc/i2c_eeprom.c
drivers/misc/p2sb-uclass.c
drivers/misc/rockchip-efuse.c
drivers/misc/spltest_sandbox.c
drivers/misc/stm32mp_fuse.c
drivers/misc/swap_case.c
drivers/misc/test_drv.c [new file with mode: 0644]
drivers/misc/vexpress_config.c
drivers/mmc/arm_pl180_mmci.c
drivers/mmc/fsl_esdhc_imx.c
drivers/mmc/mxsmmc.c
drivers/mmc/octeontx_hsmmc.c
drivers/mmc/pci_mmc.c
drivers/mmc/rockchip_dw_mmc.c
drivers/mtd/nand/raw/arasan_nfc.c
drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c
drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c
drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
drivers/mtd/nand/raw/davinci_nand.c
drivers/mtd/nand/raw/denali_dt.c
drivers/mtd/nand/raw/mxs_nand_dt.c
drivers/mtd/nand/raw/octeontx_nand.c
drivers/mtd/nand/raw/pxa3xx_nand.c
drivers/mtd/nand/raw/stm32_fmc2_nand.c
drivers/mtd/nand/raw/tegra_nand.c
drivers/mtd/nand/raw/vf610_nfc.c
drivers/mtd/nand/raw/zynq_nand.c
drivers/mtd/nand/spi/core.c
drivers/mtd/spi/sf-uclass.c
drivers/mtd/spi/sf_probe.c
drivers/mux/mmio.c
drivers/net/eth-phy-uclass.c
drivers/net/fm/eth.c
drivers/net/fsl_enetc.c
drivers/net/fsl_enetc_mdio.c
drivers/net/fsl_mcdmafec.c
drivers/net/mcffec.c
drivers/net/mcfmii.c
drivers/net/mdio-ipq4019.c
drivers/net/mdio_mux_i2creg.c
drivers/net/mvmdio.c
drivers/net/octeontx/smi.c
drivers/net/pfe_eth/pfe_eth.c
drivers/net/sunxi_emac.c
drivers/net/tsec.c
drivers/net/xilinx_emaclite.c
drivers/pci/pci-emul-uclass.c
drivers/pci/pci-uclass.c
drivers/phy/phy-ti-am654.c
drivers/pinctrl/intel/pinctrl.c
drivers/pinctrl/intel/pinctrl_apl.c
drivers/pinctrl/nxp/pinctrl-imx6.c
drivers/pinctrl/nxp/pinctrl-mxs.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-qe-io.c
drivers/pinctrl/pinctrl-single.c
drivers/pinctrl/pinctrl-uclass.c
drivers/power/acpi_pmc/acpi-pmc-uclass.c
drivers/power/domain/meson-ee-pwrc.c
drivers/power/domain/meson-gx-pwrc-vpu.c
drivers/power/pmic/rk8xx.c
drivers/power/regulator/da9063.c
drivers/power/regulator/pbias_regulator.c
drivers/pwm/pwm-meson.c
drivers/remoteproc/rproc-uclass.c
drivers/remoteproc/sandbox_testproc.c
drivers/reset/reset-ast2500.c
drivers/reset/reset-mediatek.c
drivers/reset/reset-rockchip.c
drivers/reset/reset-sifive.c
drivers/reset/reset-socfpga.c
drivers/reset/reset-sunxi.c
drivers/rtc/emul_rtc.c
drivers/serial/altera_jtag_uart.c
drivers/serial/altera_uart.c
drivers/serial/atmel_usart.c
drivers/serial/ns16550.c
drivers/serial/sandbox.c
drivers/serial/serial-uclass.c
drivers/serial/serial_arc.c
drivers/serial/serial_coreboot.c
drivers/serial/serial_intel_mid.c
drivers/serial/serial_linflexuart.c
drivers/serial/serial_lpuart.c
drivers/serial/serial_mcf.c
drivers/serial/serial_meson.c
drivers/serial/serial_mxc.c
drivers/serial/serial_ns16550.c
drivers/serial/serial_omap.c
drivers/serial/serial_pxa.c
drivers/serial/serial_rockchip.c
drivers/serial/serial_s5p.c
drivers/spi/cadence_qspi.c
drivers/spi/cf_spi.c
drivers/spi/davinci_spi.c
drivers/spi/designware_spi.c
drivers/spi/exynos_spi.c
drivers/spi/fsl_dspi.c
drivers/spi/fsl_espi.c
drivers/spi/fsl_qspi.c
drivers/spi/ich.c
drivers/spi/ich.h
drivers/spi/mxs_spi.c
drivers/spi/pl022_spi.c
drivers/spi/rk_spi.c
drivers/spi/soft_spi.c
drivers/spi/spi-uclass.c
drivers/spi/tegra114_spi.c
drivers/spi/tegra20_sflash.c
drivers/spi/tegra20_slink.c
drivers/spi/tegra210_qspi.c
drivers/spi/uniphier_spi.c
drivers/spi/zynq_qspi.c
drivers/spi/zynq_spi.c
drivers/spi/zynqmp_gqspi.c
drivers/sysreset/sysreset-uclass.c
drivers/sysreset/sysreset_sandbox.c
drivers/sysreset/sysreset_x86.c
drivers/tee/optee/core.c
drivers/timer/ag101p_timer.c
drivers/timer/altera_timer.c
drivers/timer/andes_plmt_timer.c
drivers/timer/mpc83xx_timer.c
drivers/timer/sandbox_timer.c
drivers/timer/sifive_clint_timer.c
drivers/timer/timer-uclass.c
drivers/timer/tsc_timer.c
drivers/usb/cdns3/core.c
drivers/usb/dwc3/core.c
drivers/usb/dwc3/dwc3-generic.c
drivers/usb/dwc3/dwc3-meson-g12a.c
drivers/usb/dwc3/dwc3-meson-gxl.c
drivers/usb/gadget/dwc2_udc_otg.c
drivers/usb/gadget/ether.c
drivers/usb/host/dwc3-octeon-glue.c
drivers/usb/host/dwc3-sti-glue.c
drivers/usb/host/ehci-mx6.c
drivers/usb/host/usb-uclass.c
drivers/usb/host/xhci-dwc3.c
drivers/usb/mtu3/mtu3_core.c
drivers/usb/mtu3/mtu3_plat.c
drivers/usb/musb-new/ti-musb.c
drivers/video/lg4573.c
drivers/video/nexell_display.c
drivers/video/rockchip/rk_mipi.c
drivers/video/sunxi/sunxi_de2.c
drivers/video/sunxi/sunxi_dw_hdmi.c
drivers/video/sunxi/sunxi_lcd.c
drivers/video/video-uclass.c
dts/Kconfig
dts/Makefile
include/asm-generic/global_data.h
include/dm/device-internal.h
include/dm/device.h
include/dm/lists.h
include/dm/platdata.h
include/dm/platform_data/spi_pl022.h
include/dm/read.h
include/dm/simple_bus.h [new file with mode: 0644]
include/dm/test.h
include/dm/uclass-internal.h
include/dm/uclass.h
include/linux/mtd/mtd.h
include/linux/mtd/nand.h
include/linux/mtd/spi-nor.h
include/linux/mtd/spinand.h
include/ns16550.h
include/spl.h
include/test/test.h
include/virtio.h
lib/efi/efi_stub.c
lib/efi_loader/efi_device_path.c
lib/time.c
net/eth-uclass.c
net/mdio-mux-uclass.c
net/mdio-uclass.c
scripts/Makefile.spl
test/dm/bus.c
test/dm/core.c
test/dm/cpu.c
test/dm/pci.c
test/dm/test-driver.c
test/dm/test-fdt.c
test/dm/test-uclass.c
test/dm/virtio.c
test/py/tests/test_ofplatdata.py
tools/concurrencytest/concurrencytest.py
tools/dtoc/dtb_platdata.py
tools/dtoc/dtoc_test_scan_drivers.cxx
tools/dtoc/dtoc_test_simple.dts
tools/dtoc/main.py
tools/dtoc/src_scan.py [new file with mode: 0644]
tools/dtoc/test_dtoc.py
tools/dtoc/test_src_scan.py [new file with mode: 0644]
tools/patman/tools.py

diff --git a/arch/arc/include/asm/spl.h b/arch/arc/include/asm/spl.h
new file mode 100644 (file)
index 0000000..e69de29
index d8cb78ecc675ac1bbec759e7c04a1ad2376c8dea..2556980cde6735faddd56196e173b1ae755060b3 100644 (file)
@@ -52,7 +52,11 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
                        continue;
                }
 
+#ifdef CONFIG_DM_ETH
+               priv = dev_get_priv(dev);
+#else
                priv = dev->priv;
+#endif
                if (priv->flags & TSEC_SGMII)
                        continue;
 
index 77724336d62c1c7dc5be5a39dfb3927a7606b9c0..215ed9759e324df9a6cea8d9fe55dc2672385731 100644 (file)
@@ -38,6 +38,9 @@ u32 spl_boot_device(void)
 
 #ifdef CONFIG_SPL_BUILD
 
+/* Define board data structure */
+static struct bd_info bdata __attribute__ ((section(".data")));
+
 void spl_board_init(void)
 {
 #if defined(CONFIG_NXP_ESBC) && defined(CONFIG_FSL_LSCH2)
@@ -74,7 +77,7 @@ void board_init_f(ulong dummy)
        get_clocks();
 
        preloader_console_init();
-       spl_set_bd();
+       gd->bd = &bdata;
 
 #ifdef CONFIG_SYS_I2C
 #ifdef CONFIG_SPL_I2C_SUPPORT
index a1657e385366478d5a8eff6042003f75bdbf8bf7..f5a921b3d1befe3721fe7af63919c111facca7b9 100644 (file)
@@ -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;
index 3e9f5e57ed012c9c34104027d82109b1093208f6..02bd3f67c96aeee166f641101ce2d15f51f57537 100644 (file)
@@ -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)
index 9d787197f35fb57fd22b2f9a9e5bab20062ba461..c10571fa28a0386dabbe6e890a13f0a3819d2f93 100644 (file)
@@ -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] },
index f503553b9269ad0f055e50c2fdf690e00877e9ae..d517810c991ad9edf97afe4ebd4b4469ec7f7211 100644 (file)
@@ -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] },
index 07bf19b5e42e60376fce688c74b02c6984fd454f..759c93747c75333172c8902162026fb0cbebb17f 100644 (file)
@@ -290,8 +290,8 @@ int arch_cpu_init(void)
        board_gpio_init();
 
 #if !CONFIG_IS_ENABLED(DM_SERIAL)
-       NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1),
-                       CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
+       ns16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM1),
+                    CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
 #endif
        /*
         * Fix Power and Emulation Management Register
index 5fea935d6e4e7c6ed5a6c3feae2e120c3cf11e30..d0d7a814713abc23036b4baaceb52e503ea410af 100644 (file)
@@ -27,9 +27,9 @@ void puts(const char *str)
 void putc(char c)
 {
        if (c == '\n')
-               NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
+               ns16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), '\r');
 
-       NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
+       ns16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), c);
 }
 #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
 
index 1649f6d9480feef7d54cb370a5977ac5e96e5995..bf6dddfdc9db3373e22f52ef5bb67f773ee42ab3 100644 (file)
@@ -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,
 };
index 13593994f14a849d0568c8f58de888b4f1cf13f0..fda25ba66a365f6c858ea771a8d8322d4a72645d 100644 (file)
@@ -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,
 };
index 0fed5aec59d26d8d4127523bf6cbbb3a018e7e6b..dea470c02f70dcc10124d56e916751953453ed18 100644 (file)
@@ -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);
index 8c903f14ff879fb57a5e0359c509be2c734f39c2..8b54e0cf52966de4ef57947613b02cc3194350f1 100644 (file)
@@ -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);
 
index 0201690f93cea396385c09d1ba62ee3578da9b33..1a4f796e5efa6924cd5ed77f596f03f4d03557bb 100644 (file)
@@ -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);
index 88e8912959fa83f14cd09144498624dc6ce3f910..4950f14655072c3d9294ab7a93891e6442dbcc7f 100644 (file)
@@ -185,7 +185,7 @@ int arch_cpu_init(void)
         * driver doesn't handle this.
         */
 #ifndef CONFIG_DM_SERIAL
-       NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM2),
+       ns16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM2),
                     CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
 #endif
 
index 04e026a8b7748a22ca8b303cf5deb05ea6fdc6da..e1e2e0d09497e664a00778329edc608a3ebe87e1 100644 (file)
@@ -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"
 };
 
index c260413a57a16af5ce5bdff78fedc1ee81ea4fb7..1f102dddd4f9fad62e2e3052794655153864a0f3 100644 (file)
@@ -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;
 
index 13be39122115c73952e8fa3e48d797138fed83e3..2ffa5595cfc2c821b16a602c5c5fb3b055d6de51 100644 (file)
@@ -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;
 
index b5f2b75e2448f314f4199ab1da8cfa8470d432f6..e17898d8fbfe6615207d19ee2708d8426583ac08 100644 (file)
@@ -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
index 6ffedd1769fd2011b47df901c6f628743f577d82..4da8df47cc69bc4f0d941ff8a07023312a00862d 100644 (file)
@@ -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] },
index 28c7c7214cbc8d161049edfc732a893ebf15be40..87eebd9872def4575fbecd734328f899d1e51117 100644 (file)
@@ -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__);
index 98a1bcd224fafc84064e31825847e225c63d839d..7edf1321feb339f882139e9e48a5fd4933da8417 100644 (file)
@@ -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)
index 5d0def3b524c71c7515fcd2947776df990fd36aa..116dccd7b87a7a8cdee5ae4d83728bd8191a4038 100644 (file)
@@ -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)
index f9ce1f723488d276a9a89104a618c8ea4e0c658d..a1b038c64866f1d013267e32c802ed73b46c4ce1 100644 (file)
@@ -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)
index a0dcac373248732a9330115a1f4ad0ed2a6af6f1..94d1d23e1f457b82ad6adf0483acdebb144d11a0 100644 (file)
@@ -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)
index fc5abd736e8e09451225750f2880c3dee37b578c..2e57672b246d438bca3dc793d4d9b96d38b0c7f9 100644 (file)
@@ -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)
index e05bd06a8d2e95648083013abb7f058bf7812806..fb4c0891d0dcdb957ece5ef172dbc0a62dbd98cf 100644 (file)
@@ -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)
index 1feb23722408e008edb7259e15aef40befc6e4c9..ccda53380c6fb49a6bd48d7cfee6632fa02404ec 100644 (file)
@@ -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)
index e5375514def68032edfe83374cf3b3eea8a83161..70c0eb6f98e7419610229c786c0e1df1fb4002f9 100644 (file)
@@ -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)
index 9a33c67bc94df70efe8705d9355e989e87e5bad8..b075319720d9230e59b1996b637cdad216a2ca88 100644 (file)
@@ -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)
index d23a5e9435cb8fb0554624f4dad884fc8234e4d1..9d9a837fc7489e09ce66ffa29f4619d913b359bb 100644 (file)
@@ -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)
index b37ae1c494569ab9934d1a7a38bd91ec729d5e25..44b53c407a78ca5839a8d24a6d154aad765b4d40 100644 (file)
@@ -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)
index 6188a8c3d2db2c56c87c908fee203eed173bda42..a960176da77ce6adb8ec4bcc119634ced3321c16 100644 (file)
@@ -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;
index 85a9e6f84e73e3b72f6ac26eac3d75cfcdb725e1..84e0bddcd44c57b45ec7856d8d25464b02869a5f 100644 (file)
@@ -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;
index f191085a12d074d345edc432ab5a76649ab919a9..544bab38480f68b0cc7704cfa691b64875dc2127 100644 (file)
@@ -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");
index a777827c55ea09d62997d24b328f7a10c264700a..fc9a2af545940fb14c5eeb256b2d12c64778865b 100644 (file)
@@ -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;
index 1520c6eaed6fb38e1a5ef7837679ceadf96b1cb9..29c0d92195ce6d8c66e59ac198b53efd1155acca 100644 (file)
@@ -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;
index 74a5df5948719674c986e36db458fca52e9ecfcb..766ed95f1a6f853376b599552543d3974dbaf46e 100644 (file)
@@ -9,6 +9,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <dm/device_compat.h>
+#include <dm/device-internal.h>
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <power/pmic.h>
@@ -80,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev)
 {
        int children;
 
-       children = pmic_bind_children(dev, dev->node, pwr_children_info);
+       children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info);
        if (!children)
                dev_dbg(dev, "no child found\n");
 
@@ -165,7 +166,7 @@ static int stm32mp_pwr_regulator_probe(struct udevice *dev)
        }
 
        uc_pdata->type = REGULATOR_TYPE_FIXED;
-       dev->priv = (void *)*p;
+       dev_set_priv(dev, (void *)*p);
 
        return 0;
 }
index bf01aa5ee8fb155091c20b141ee939177039cc77..9de9836c8d253ee4c929d83a609abcca890d369c 100644 (file)
@@ -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
index 48c4f32d6f982ecd769b3d36850fd0696352baa5..8569ad7c6fcb98f8850792864744685b149bd07a 100644 (file)
@@ -42,7 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_SPL_BUILD
 /* TODO([email protected]): Remove once SPL supports device tree */
-U_BOOT_DEVICE(tegra_gpios) = {
+U_BOOT_DRVINFO(tegra_gpios) = {
        "gpio_tegra"
 };
 #endif
index dbd156ffceca25cc80c4791d80e4c8b120e03ef9..95780f79c2c3b002645896177bf4e83497b88b61 100644 (file)
@@ -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;
index 1ace117fc8e59ea897b057345a05bd32323a793b..856047613c198860d4ca22ad1695aaf83a026c69 100644 (file)
@@ -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;
 
index cc0e24cbfede723373718ebe6177db15374cffe8..37193157d9ecd8c1e9468148ab093d7b06a527ad 100644 (file)
@@ -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;
 
diff --git a/arch/m68k/include/asm/spl.h b/arch/m68k/include/asm/spl.h
new file mode 100644 (file)
index 0000000..e69de29
index 77d1f2ea0dc5049d5f3ad009e18c953488097b50..33538647a2d6cdf8035f942b59e2e3df7fb9e1c5 100644 (file)
@@ -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;
diff --git a/arch/nds32/include/asm/spl.h b/arch/nds32/include/asm/spl.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/arch/nios2/include/asm/spl.h b/arch/nios2/include/asm/spl.h
new file mode 100644 (file)
index 0000000..e69de29
index c8079dc510c271722163a771b249a4513981436e..cfa288a01a84b0268aac8b1cb48412c49b7e436e 100644 (file)
@@ -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;
 
index b56fa04a34b5cd497a04c79ffd4200e11767ad1c..80996a91ce7f20db30801fe0bd9c38c694ccf4ae 100644 (file)
@@ -790,6 +790,11 @@ int os_find_u_boot(char *fname, int maxlen)
 
 int os_spl_to_uboot(const char *fname)
 {
+       struct sandbox_state *state = state_get_current();
+
+       printf("%s\n", __func__);
+       /* U-Boot will delete ram buffer after read: "--rm_memory"*/
+       state->ram_buf_rm = true;
        return os_jump_to_file(fname);
 }
 
index fe494aef752d038b8e48aa37ab446831a424b3ad..8322ed7a1fe135ddab0edfa386c61f7eb1e917f7 100644 (file)
@@ -457,6 +457,13 @@ int main(int argc, char *argv[])
        if (os_parse_args(state, argc, argv))
                return 1;
 
+       /* Remove old memory file if required */
+       if (state->ram_buf_rm && state->ram_buf_fname) {
+               os_unlink(state->ram_buf_fname);
+               state->write_ram_buf = false;
+               state->ram_buf_fname = NULL;
+       }
+
        ret = sandbox_read_state(state, state->state_fname);
        if (ret)
                goto err;
index 59f37fab0b8735488cff49469ed6476777da871b..b2901b7a8ca454859a240c3e565129f89edb1878 100644 (file)
@@ -415,10 +415,6 @@ int state_uninit(void)
                }
        }
 
-       /* Remove old memory file if required */
-       if (state->ram_buf_rm && state->ram_buf_fname)
-               os_unlink(state->ram_buf_fname);
-
        /* Delete this at the last moment so as not to upset gdb too much */
        if (state->jumped_fname)
                os_unlink(state->jumped_fname);
index 8b50a4028983b3222008e848d7a0a45d85b5f497..a8938a3accb25275e8e137ac494adb946fe1a0cb 100644 (file)
@@ -41,7 +41,7 @@
 
        cros_ec: cros-ec {
                reg = <0 0>;
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                compatible = "google,cros-ec-sandbox";
        };
 
@@ -83,7 +83,7 @@
        };
 
        spi: spi@0 {
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <0 0>;
index 81cdc55b0d4d10205bc7c7f052ac9c91e2a4cf1a..d842f021760d29d1ab6afe9edcaeec9814904d4d 100644 (file)
@@ -56,7 +56,7 @@
        };
 
        gpio_a: gpios@0 {
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                gpio-controller;
                compatible = "sandbox,gpio";
                #gpio-cells = <1>;
@@ -65,7 +65,7 @@
        };
 
        gpio_b: gpios@1 {
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                gpio-controller;
                compatible = "sandbox,gpio";
                #gpio-cells = <2>;
        };
 
        lcd {
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                compatible = "sandbox,lcd-sdl";
                xres = <1366>;
                yres = <768>;
 
        spi@0 {
                firmware_storage_spi: flash@0 {
-                       u-boot,dm-pre-reloc;
+                       u-boot,dm-pre-proper;
                        reg = <0>;
                        compatible = "spansion,m25p16", "jedec,spi-nor";
                        spi-max-frequency = <40000000>;
                stringarray = "one";
        };
 
-       spl-test4 {
-               u-boot,dm-pre-reloc;
-               compatible = "sandbox,spl-test.2";
-       };
-
        spl-test5 {
                u-boot,dm-tpl;
                compatible = "sandbox,spl-test";
        };
 
        tpm {
-               u-boot,dm-pre-reloc;
                compatible = "google,sandbox-tpm";
        };
 
        };
 
        keyboard-controller {
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
        };
 };
diff --git a/arch/sandbox/include/asm/i2c.h b/arch/sandbox/include/asm/i2c.h
new file mode 100644 (file)
index 0000000..b482be4
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <[email protected]>
+ */
+
+#ifndef __asn_i2c_h
+#define __asn_i2c_h
+
+struct sandbox_i2c_priv {
+       bool test_mode;
+};
+
+#endif /* __asn_i2c_h */
diff --git a/arch/sandbox/include/asm/serial.h b/arch/sandbox/include/asm/serial.h
new file mode 100644 (file)
index 0000000..bc82aeb
--- /dev/null
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <[email protected]>
+ */
+
+#ifndef __asm_serial_h
+#define __asm_serial_h
+
+#include <dt-structs.h>
+
+struct sandbox_serial_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_sandbox_serial dtplat;
+#endif
+       int colour;     /* Text colour to use for output, -1 for none */
+};
+
+/**
+ * struct sandbox_serial_priv - Private data for this driver
+ *
+ * @buf: holds input characters available to be read by this driver
+ */
+struct sandbox_serial_priv {
+       struct membuff buf;
+       char serial_buf[16];
+       bool start_of_line;
+};
+
+#endif /* __asm_serial_h */
diff --git a/arch/sh/include/asm/spl.h b/arch/sh/include/asm/spl.h
new file mode 100644 (file)
index 0000000..e69de29
index c6c1350f4f082a16049bb9326158aef10b746fd4..f5dbd6cbd349d3c68d24e48005d263f8cf874901 100644 (file)
@@ -19,6 +19,7 @@ config INTEL_APOLLOLAKE
        select SMP_AP_WORK
        select INTEL_GMA_SWSMISCI
        select ACPI_GNVS_EXTERNAL
+       select TPL_OF_PLATDATA_PARENT
        imply ENABLE_MRC_CACHE
        imply AHCI_PCI
        imply SCSI
index cef937573b0cff80214fde87b68f9845ad24a74f..c6be707e4eaf537ca92ae3921bac2902cd10456f 100644 (file)
@@ -32,7 +32,10 @@ int fspm_update_config(struct udevice *dev, struct fspm_upd *upd)
 
        node = dev_ofnode(dev);
        if (!ofnode_valid(node))
-               return log_msg_ret("fsp-m settings", -ENOENT);
+               return log_msg_ret("node", -ENOENT);
+       node = ofnode_find_subnode(node, "fsp-m");
+       if (!ofnode_valid(node))
+               return log_msg_ret("fspm", -ENOENT);
 
        ret = fsp_m_update_config_from_dtb(node, cfg);
        if (ret)
index e4674f3788a0291d23a0c90fd59fc2d250bb8313..9decab7aa332f18f70ac9a3334c8f7a9262f7114 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/io.h>
 #include <asm/pci.h>
 #include <asm/arch/acpi.h>
+#include <asm/arch/hostbridge.h>
 #include <asm/arch/systemagent.h>
 #include <dt-bindings/sound/nhlt.h>
 #include <dm/acpi.h>
@@ -41,25 +42,7 @@ enum {
        TOLUD                   = 0xbc,
 };
 
-/**
- * struct apl_hostbridge_plat - platform data for hostbridge
- *
- * @dtplat: Platform data for of-platdata
- * @early_pads: Early pad data to set up, each (pad, cfg0, cfg1)
- * @early_pads_count: Number of pads to process
- * @pciex_region_size: BAR length in bytes
- * @bdf: Bus/device/function of hostbridge
- */
-struct apl_hostbridge_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       struct dtd_intel_apl_hostbridge dtplat;
-#endif
-       u32 *early_pads;
-       int early_pads_count;
-       uint pciex_region_size;
-       pci_dev_t bdf;
-};
-
+#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
 static const struct nhlt_format_config dmic_1ch_formats[] = {
        /* 48 KHz 16-bits per sample. */
        {
@@ -155,6 +138,7 @@ static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
                .num_formats = ARRAY_SIZE(dmic_4ch_formats),
        },
 };
+#endif
 
 static int apl_hostbridge_early_init_pinctrl(struct udevice *dev)
 {
@@ -283,7 +267,7 @@ static int apl_acpi_hb_get_name(const struct udevice *dev, char *out_name)
        return acpi_copy_name(out_name, "RHUB");
 }
 
-#ifdef CONFIG_GENERATE_ACPI_TABLE
+#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
 static int apl_acpi_hb_write_tables(const struct udevice *dev,
                                    struct acpi_ctx *ctx)
 {
@@ -322,7 +306,6 @@ static int apl_acpi_hb_write_tables(const struct udevice *dev,
 
        return 0;
 }
-#endif
 
 static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx)
 {
@@ -347,6 +330,7 @@ static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx)
 
        return log_msg_ret("channels", -EINVAL);
 }
+#endif
 
 static int apl_hostbridge_remove(struct udevice *dev)
 {
@@ -385,21 +369,23 @@ ulong sa_get_tseg_base(struct udevice *dev)
 
 struct acpi_ops apl_hostbridge_acpi_ops = {
        .get_name       = apl_acpi_hb_get_name,
-#ifdef CONFIG_GENERATE_ACPI_TABLE
+#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
        .write_tables   = apl_acpi_hb_write_tables,
-#endif
        .setup_nhlt     = apl_acpi_setup_nhlt,
+#endif
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_hostbridge_ids[] = {
        { .compatible = "intel,apl-hostbridge" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_hostbridge) = {
        .name           = "intel_apl_hostbridge",
        .id             = UCLASS_NORTHBRIDGE,
-       .of_match       = apl_hostbridge_ids,
+       .of_match       = of_match_ptr(apl_hostbridge_ids),
        .of_to_plat = apl_hostbridge_of_to_plat,
        .probe          = apl_hostbridge_probe,
        .remove         = apl_hostbridge_remove,
index d8e05f6a8f46d15274f64b56abfe83830633134a..e085890d638d766e664bc1497a8c4e3018bded7c 100644 (file)
@@ -81,10 +81,11 @@ int lpc_open_pmio_window(uint base, uint size)
 
                lgir_reg_num = find_unused_pmio_window();
                if (lgir_reg_num < 0) {
-                       log_err("LPC: Cannot open IO window: %lx size %lx\n",
-                               bridge_base, size - bridged_size);
-                       log_err("No more IO windows\n");
-
+                       if (spl_phase() > PHASE_TPL) {
+                               log_err("LPC: Cannot open IO window: %lx size %lx\n",
+                                       bridge_base, size - bridged_size);
+                               log_err("No more IO windows\n");
+                       }
                        return -ENOSPC;
                }
                lgir_reg_offset = LPC_GENERIC_IO_RANGE(lgir_reg_num);
@@ -127,15 +128,17 @@ struct acpi_ops apl_lpc_acpi_ops = {
        .inject_dsdt    = southbridge_inject_dsdt,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_lpc_ids[] = {
        { .compatible = "intel,apl-lpc" },
        { }
 };
+#endif
 
 /* All pads are LPC already configured by the hostbridge, so no probing here */
 U_BOOT_DRIVER(intel_apl_lpc) = {
        .name           = "intel_apl_lpc",
        .id             = UCLASS_LPC,
-       .of_match       = apl_lpc_ids,
+       .of_match       = of_match_ptr(apl_lpc_ids),
        ACPI_OPS_PTR(&apl_lpc_acpi_ops)
 };
index d9832ff24966a6f05830301a216a75da559f615c..39d6ad5ed49aa39aaeb9417dc13cb7991fc292ce 100644 (file)
@@ -23,14 +23,16 @@ static const struct pch_ops apl_pch_ops = {
        .set_spi_protect = apl_set_spi_protect,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_pch_ids[] = {
        { .compatible = "intel,apl-pch" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_pch) = {
        .name           = "intel_apl_pch",
        .id             = UCLASS_PCH,
-       .of_match       = apl_pch_ids,
+       .of_match       = of_match_ptr(apl_pch_ids),
        .ops            = &apl_pch_ops,
 };
index 290b2cb3e71cce691e45c53a6cd78ba71b377d5a..e23d38ea0729ac8b7f36efbf187e3bdb51173e5a 100644 (file)
@@ -16,6 +16,7 @@
 #include <acpi/acpi_s3.h>
 #include <asm/io.h>
 #include <asm/pci.h>
+#include <asm/arch/pmc.h>
 #include <linux/bitops.h>
 #include <power/acpi_pmc.h>
 
@@ -53,13 +54,6 @@ enum {
        CF9_GLB_RST     = 1 << 20,
 };
 
-struct apl_pmc_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       struct dtd_intel_apl_pmc dtplat;
-#endif
-       pci_dev_t bdf;
-};
-
 static int apl_pmc_fill_power_state(struct udevice *dev)
 {
        struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev);
@@ -205,22 +199,24 @@ static int apl_pmc_probe(struct udevice *dev)
        return 0;
 }
 
-static struct acpi_pmc_ops apl_pmc_ops = {
+static const struct acpi_pmc_ops apl_pmc_ops = {
        .init                   = apl_pmc_fill_power_state,
        .prev_sleep_state       = apl_prev_sleep_state,
        .disable_tco            = apl_disable_tco,
        .global_reset_set_enable = apl_global_reset_set_enable,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_pmc_ids[] = {
        { .compatible = "intel,apl-pmc" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_pmc) = {
        .name           = "intel_apl_pmc",
        .id             = UCLASS_ACPI_PMC,
-       .of_match       = apl_pmc_ids,
+       .of_match       = of_match_ptr(apl_pmc_ids),
        .of_to_plat = apl_pmc_ofdata_to_uc_plat,
        .probe          = apl_pmc_probe,
        .ops            = &apl_pmc_ops,
index 3a1588bbd8b98894a29a3c03a66954ec36d19e4c..8991d5e648e6f7b3a6de55e67d3da3a1df713ef3 100644 (file)
@@ -83,33 +83,6 @@ static int apl_flash_probe(struct udevice *dev)
        return spi_flash_std_probe(dev);
 }
 
-/*
- * Manually set the parent of the SPI flash to SPI, since dtoc doesn't. We also
- * need to allocate the parent_plat since by the time this function is
- * called device_bind() has already gone past that step.
- */
-static int apl_flash_bind(struct udevice *dev)
-{
-       if (CONFIG_IS_ENABLED(OF_PLATDATA) &&
-           !CONFIG_IS_ENABLED(OF_PLATDATA_PARENT)) {
-               struct dm_spi_slave_plat *plat;
-               struct udevice *spi;
-               int ret;
-
-               ret = uclass_first_device_err(UCLASS_SPI, &spi);
-               if (ret)
-                       return ret;
-               dev->parent = spi;
-
-               plat = calloc(sizeof(*plat), 1);
-               if (!plat)
-                       return -ENOMEM;
-               dev->parent_plat = plat;
-       }
-
-       return 0;
-}
-
 static const struct dm_spi_flash_ops apl_flash_ops = {
        .read           = apl_flash_std_read,
 };
@@ -123,9 +96,8 @@ U_BOOT_DRIVER(winbond_w25q128fw) = {
        .name           = "winbond_w25q128fw",
        .id             = UCLASS_SPI_FLASH,
        .of_match       = apl_flash_ids,
-       .bind           = apl_flash_bind,
        .probe          = apl_flash_probe,
-       .priv_auto      = sizeof(struct spi_flash),
+       .priv_auto      = sizeof(struct spi_nor),
        .ops            = &apl_flash_ops,
 };
 
index 26aef655bef4f2ddd6996aa137ce7005de8ade55..876fa592b8d999a3c13ff10cdbba96121764e6c3 100644 (file)
@@ -16,6 +16,8 @@
 #include <asm/io.h>
 #include <asm/pci.h>
 #include <asm/lpss.h>
+#include <dm/device-internal.h>
+#include <asm/arch/uart.h>
 
 /* Low-power Subsystem (LPSS) clock register */
 enum {
@@ -68,7 +70,7 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
  * This driver uses its own compatible string but almost everything else from
  * the standard ns16550 driver. This allows us to provide an of-platdata
  * implementation, since the platdata produced by of-platdata does not match
- * struct ns16550_plat.
+ * struct apl_ns16550_plat.
  *
  * When running with of-platdata (generally TPL), the platdata is converted to
  * something that ns16550 expects. When running withoutof-platdata (SPL, U-Boot
@@ -77,10 +79,10 @@ void apl_uart_init(pci_dev_t bdf, ulong base)
 
 static int apl_ns16550_probe(struct udevice *dev)
 {
-       struct ns16550_plat *plat = dev_get_plat(dev);
+       struct apl_ns16550_plat *plat = dev_get_plat(dev);
 
        if (!CONFIG_IS_ENABLED(PCI))
-               apl_uart_init(plat->bdf, plat->base);
+               apl_uart_init(plat->ns16550.bdf, plat->ns16550.base);
 
        return ns16550_serial_probe(dev);
 }
@@ -88,24 +90,28 @@ static int apl_ns16550_probe(struct udevice *dev)
 static int apl_ns16550_of_to_plat(struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-       struct dtd_intel_apl_ns16550 *dtplat = dev_get_plat(dev);
-       struct ns16550_plat *plat;
+       struct dtd_intel_apl_ns16550 *dtplat;
+       struct apl_ns16550_plat *plat = dev_get_plat(dev);
+       struct ns16550_plat ns;
 
        /*
-        * Convert our plat to the ns16550's plat, so we can just use
-        * that driver
+        * The device's plat uses struct apl_ns16550_plat which starts with the
+        * dtd struct, but the ns16550 driver expects it to be struct ns16550.
+        * Set up what that driver expects. Note that this means that the values
+        * cannot be read in this driver when using of-platdata.
+        *
+        * TODO([email protected]): Consider having a separate plat pointer for
+        * of-platdata so that it is not necessary to overwrite this.
         */
-       plat = malloc(sizeof(*plat));
-       if (!plat)
-               return -ENOMEM;
-       plat->base = dtplat->early_regs[0];
-       plat->reg_width = 1;
-       plat->reg_shift = dtplat->reg_shift;
-       plat->reg_offset = 0;
-       plat->clock = dtplat->clock_frequency;
-       plat->fcr = UART_FCR_DEFVAL;
-       plat->bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
-       dev->plat = plat;
+       dtplat = &plat->dtplat;
+       ns.base = dtplat->early_regs[0];
+       ns.reg_width = 1;
+       ns.reg_shift = dtplat->reg_shift;
+       ns.reg_offset = 0;
+       ns.clock = dtplat->clock_frequency;
+       ns.fcr = UART_FCR_DEFVAL;
+       ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]);
+       memcpy(plat, &ns, sizeof(ns));
 #else
        int ret;
 
@@ -117,17 +123,19 @@ static int apl_ns16550_of_to_plat(struct udevice *dev)
        return 0;
 }
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_ns16550_serial_ids[] = {
        { .compatible = "intel,apl-ns16550" },
        { },
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_ns16550) = {
        .name   = "intel_apl_ns16550",
        .id     = UCLASS_SERIAL,
-       .of_match = apl_ns16550_serial_ids,
-       .plat_auto      = sizeof(struct ns16550_plat),
-       .priv_auto      = sizeof(struct NS16550),
+       .of_match = of_match_ptr(apl_ns16550_serial_ids),
+       .plat_auto      = sizeof(struct apl_ns16550_plat),
+       .priv_auto      = sizeof(struct ns16550),
        .ops    = &ns16550_serial_ops,
        .of_to_plat = apl_ns16550_of_to_plat,
        .probe = apl_ns16550_probe,
index 275063c4af8c17fb78074003478daf0ef892da2c..0ffc1006bbf79110dcaa262429f3f904ce704388 100644 (file)
@@ -11,6 +11,7 @@
 #include <asm/processor-flags.h>
 
 .code32
+.section .text_call64
 .globl cpu_call64
 cpu_call64:
        /*
index 4a5cf17e41df5ff3d253ec7c97b6c9eb17b6e488..8b9a810f66db9fcb4e7957783628ab7ab2c2b099 100644 (file)
@@ -26,7 +26,7 @@ obj-y += cpu.o
 obj-y += fast_spi.o
 obj-y += lpc.o
 obj-y += lpss.o
-obj-$(CONFIG_INTEL_GENERIC_WIFI) += generic_wifi.o
+obj-$(CONFIG_$(SPL_)INTEL_GENERIC_WIFI) += generic_wifi.o
 ifndef CONFIG_TARGET_EFI_APP
 obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o
 ifndef CONFIG_$(SPL_)X86_64
index e71ea029e51fac4ee6d665a8c3304c51fe85c383..ae4de4ca8c6c4bcb36e738db3312806203ff2adf 100644 (file)
 #include <spl.h>
 #include <asm/itss.h>
 
-struct itss_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       /* Put this first since driver model will copy the data here */
-       struct dtd_intel_itss dtplat;
-#endif
-};
-
-/* struct pmc_route - Routing for PMC to GPIO */
-struct pmc_route {
-       u32 pmc;
-       u32 gpio;
-};
-
-struct itss_priv {
-       struct pmc_route *route;
-       uint route_count;
-       u32 irq_snapshot[NUM_IPC_REGS];
-};
-
 static int set_polarity(struct udevice *dev, uint irq, bool active_low)
 {
        u32 mask;
@@ -230,15 +211,17 @@ static const struct irq_ops itss_ops = {
 #endif
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id itss_ids[] = {
        { .compatible = "intel,itss", .data = X86_IRQT_ITSS },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_itss) = {
        .name           = "intel_itss",
        .id             = UCLASS_IRQ,
-       .of_match       = itss_ids,
+       .of_match       = of_match_ptr(itss_ids),
        .ops            = &itss_ops,
        .bind           = itss_bind,
        .of_to_plat = itss_of_to_plat,
index e6edab0b0560b1c7721f899ee69bac09c4afac99..d73ae438bbb07f4de7c6f888d0c269c16fb5dca1 100644 (file)
 #include <log.h>
 #include <p2sb.h>
 #include <spl.h>
+#include <asm/p2sb.h>
 #include <asm/pci.h>
 #include <linux/bitops.h>
 
 #define PCH_P2SB_E0            0xe0
 #define HIDE_BIT               BIT(0)
 
-struct p2sb_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       struct dtd_intel_p2sb dtplat;
-#endif
-       ulong mmio_base;
-       pci_dev_t bdf;
-};
-
 /* PCI config space registers */
 #define HPTC_OFFSET            0x60
 #define HPTC_ADDR_ENABLE_BIT   BIT(7)
@@ -180,19 +173,21 @@ static int p2sb_child_post_bind(struct udevice *dev)
        return 0;
 }
 
-struct p2sb_ops p2sb_ops = {
+static const struct p2sb_ops p2sb_ops = {
        .set_hide       = intel_p2sb_set_hide,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id p2sb_ids[] = {
        { .compatible = "intel,p2sb" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_p2sb) = {
        .name           = "intel_p2sb",
        .id             = UCLASS_P2SB,
-       .of_match       = p2sb_ids,
+       .of_match       = of_match_ptr(p2sb_ids),
        .probe          = p2sb_probe,
        .remove         = p2sb_remove,
        .ops            = &p2sb_ops,
index 5d8963220da104b1051028e29772ca03f98565cd..772a94c31cb74895b59c1caba0fe6fdc2ae04ce2 100644 (file)
@@ -18,7 +18,7 @@ static int slimbootloader_serial_of_to_plat(struct udevice *dev)
 {
        const efi_guid_t guid = SBL_SERIAL_PORT_INFO_GUID;
        struct sbl_serial_port_info *data;
-       struct ns16550_plat *plat = dev->plat;
+       struct ns16550_plat *plat = dev_get_plat(dev);
 
        if (!gd->arch.hob_list)
                panic("hob list not found!");
@@ -59,7 +59,7 @@ U_BOOT_DRIVER(serial_slimbootloader) = {
        .of_match = slimbootloader_serial_ids,
        .of_to_plat = slimbootloader_serial_of_to_plat,
        .plat_auto      = sizeof(struct ns16550_plat),
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .probe  = ns16550_serial_probe,
        .ops    = &ns16550_serial_ops,
 };
index f8d85d5a339b2db5f1b032335736e060b9ed39bb..4a73cb240dac77d46669481d26d5fab5cb8b4aa0 100644 (file)
@@ -35,12 +35,15 @@ static inline void set_global_turbo_state(int state)
 }
 #endif
 
+/* gcc 7.3 does not wwant to drop strings, so use #ifdef */
+#ifndef CONFIG_TPL_BUILD
 static const char *const turbo_state_desc[] = {
        [TURBO_UNKNOWN]         = "unknown",
        [TURBO_UNAVAILABLE]     = "unavailable",
        [TURBO_DISABLED]        = "available but hidden",
        [TURBO_ENABLED]         = "available and visible"
 };
+#endif
 
 /*
  * Determine the current state of Turbo and cache it for later.
@@ -76,7 +79,9 @@ int turbo_get_state(void)
        }
 
        set_global_turbo_state(turbo_state);
+#ifndef CONFIG_TPL_BUILD
        debug("Turbo is %s\n", turbo_state_desc[turbo_state]);
+#endif
        return turbo_state;
 }
 
index d66e128ae62d01bb6b5604a365ca3832d1a43cc2..a84602209576e9d3e3852561d743b160eea9cad8 100644 (file)
        };
 
        cpus {
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                #address-cells = <1>;
                #size-cells = <0>;
 
                cpu_0: cpu@0 {
-                       u-boot,dm-pre-reloc;
+                       u-boot,dm-pre-proper;
+                       u-boot,dm-spl;
                        device_type = "cpu";
                        compatible = "intel,apl-cpu";
                        reg = <0>;
                         */
                        fsp_s: fsp-s {
                        };
+                       fsp_m: fsp-m {
+                               u-boot,dm-spl;
+                       };
 
                        nhlt {
                                intel,dmic-channels = <4>;
                };
 
                punit@0,1 {
-                       u-boot,dm-pre-reloc;
+                       u-boot,dm-pre-proper;
+                       u-boot,dm-spl;
                        reg = <0x00000800 0 0 0 0>;
                        compatible = "intel,apl-punit";
                };
 
                gma@2,0 {
+                       u-boot,dm-pre-proper;
                        reg = <0x00001000 0 0 0 0>;
                        compatible = "fsp-fb";
                };
                };
 
                spi: fast-spi@d,2 {
-                       u-boot,dm-pre-reloc;
+                       u-boot,dm-pre-proper;
+                       u-boot,dm-spl;
                        reg = <0x02006a10 0 0 0 0>;
                        #address-cells = <1>;
                        #size-cells = <0>;
                        fwstore_spi: spi-flash@0 {
                                #size-cells = <1>;
                                #address-cells = <1>;
-                               u-boot,dm-pre-reloc;
+                               u-boot,dm-pre-proper;
+                               u-boot,dm-spl;
                                reg = <0>;
                                compatible = "winbond,w25q128fw",
                                         "jedec,spi-nor";
                                #size-cells = <0>;
                                u-boot,dm-pre-reloc;
                                cros_ec: cros-ec {
-                                       u-boot,dm-pre-reloc;
+                                       u-boot,dm-pre-proper;
                                        compatible = "google,cros-ec-lpc";
                                        reg = <0x204 1 0x200 1 0x880 0x80>;
 
                PAD_CFG_NF(LPC_CLKRUNB, UP_20K, DEEP, NF1) /* LPC_CLKRUN_N */
                PAD_CFG_NF(LPC_FRAMEB, NATIVE, DEEP, NF1) /* LPC_FRAME_N */
                >;
+};
 
+&fsp_m {
        fspm,package = <PACKAGE_BGA>;
        fspm,profile = <PROFILE_LPDDR4_2400_24_22_22>;
        fspm,memory-down = <MEMORY_DOWN_YES>;
index d0bbd84e5095453402be0dd10016b541b875156c..942cc937dc4e54d38812f88201a87c7f7237415c 100644 (file)
@@ -1,7 +1,7 @@
 / {
        rtc: rtc {
                compatible = "motorola,mc146818";
-               u-boot,dm-pre-reloc;
+               u-boot,dm-pre-proper;
                reg = <0x70 2>;
        };
 };
index ab5860c0fd0ebd62c0bf447db24093e090111634..762160da88203907e5cb5837239fb1001178a4c9 100644 (file)
 /* This is needed by ACPI */
 #define GPIO_NUM_PAD_CFG_REGS   2 /* DW0, DW1 */
 
+#ifndef __ASSEMBLY__
+
+#include <dt-structs.h>
+
+/**
+ * struct apl_gpio_plat - platform data for each device
+ *
+ * @dtplat: of-platdata data from C struct
+ */
+struct apl_gpio_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       /* Put this first since driver model will copy the data here */
+       struct dtd_intel_apl_pinctrl dtplat;
+#endif
+};
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* _ASM_ARCH_GPIO_H_ */
diff --git a/arch/x86/include/asm/arch-apollolake/hostbridge.h b/arch/x86/include/asm/arch-apollolake/hostbridge.h
new file mode 100644 (file)
index 0000000..f4dce0d
--- /dev/null
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef _ASM_ARCH_HOSTBRIDGE_H_
+#define _ASM_ARCH_HOSTBRIDGE_H_
+
+/**
+ * struct apl_hostbridge_plat - platform data for hostbridge
+ *
+ * @dtplat: Platform data for of-platdata
+ * @early_pads: Early pad data to set up, each (pad, cfg0, cfg1)
+ * @early_pads_count: Number of pads to process
+ * @pciex_region_size: BAR length in bytes
+ * @bdf: Bus/device/function of hostbridge
+ */
+struct apl_hostbridge_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_intel_apl_hostbridge dtplat;
+#endif
+       u32 *early_pads;
+       int early_pads_count;
+       uint pciex_region_size;
+       pci_dev_t bdf;
+};
+
+#endif /* _ASM_ARCH_HOSTBRIDGE_H_ */
diff --git a/arch/x86/include/asm/arch-apollolake/pmc.h b/arch/x86/include/asm/arch-apollolake/pmc.h
new file mode 100644 (file)
index 0000000..23ac8fe
--- /dev/null
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef ASM_ARCH_PMC_H
+#define ASM_ARCH_PMC_H
+
+struct apl_pmc_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_intel_apl_pmc dtplat;
+#endif
+       pci_dev_t bdf;
+};
+
+#endif /* ASM_ARCH_PMC_H */
index d4fffe6525c70c1e110ae60653842eca0b47f050..38335b04903d6b950e605924f8a0d29c991ab6d8 100644 (file)
@@ -6,6 +6,23 @@
 #ifndef _ASM_ARCH_UART_H
 #define _ASM_ARCH_UART_H
 
+#include <ns16550.h>
+
+/**
+ * struct apl_ns16550_plat - platform data for the APL UART
+ *
+ * Note that when of-platdata is in use, apl_ns16550_of_to_plat() actually
+ * copies the ns16550_plat contents to the start of this struct, meaning that
+ * dtplat is no-longer valid. This is done so that the ns16550 driver can use
+ * dev_get_plat() without any offsets or adjustments.
+ */
+struct apl_ns16550_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_intel_apl_ns16550 dtplat;
+#endif
+       struct ns16550_plat ns16550;
+};
+
 /**
  * apl_uart_init() - Set up the APL UART device and clock
  *
@@ -15,6 +32,6 @@
  * The UART won't actually work unless the GPIO settings are correct and the
  * signals actually exit the SoC. See board_debug_uart_init() for that.
  */
-int apl_uart_init(pci_dev_t bdf, ulong base);
+void apl_uart_init(pci_dev_t bdf, ulong base);
 
 #endif
index f7d32403849fac316286e08fdb4acced0b386ef7..6d4793277e675f03e3e9c17fcc33036b2845a2a2 100644 (file)
@@ -11,6 +11,8 @@
 #ifndef _ASM_ARCH_ITSS_H
 #define _ASM_ARCH_ITSS_H
 
+#include <irq.h>
+
 #define GPIO_IRQ_START 50
 #define GPIO_IRQ_END   ITSS_MAX_IRQ
 
 /* ITSS Power reduction control */
 #define PCR_ITSS_ITSSPRC       0x3300
 
+struct itss_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       /* Put this first since driver model will copy the data here */
+       struct dtd_intel_itss dtplat;
+#endif
+};
+
+/* struct pmc_route - Routing for PMC to GPIO */
+struct pmc_route {
+       u32 pmc;
+       u32 gpio;
+};
+
+struct itss_priv {
+       struct pmc_route *route;
+       uint route_count;
+       u32 irq_snapshot[NUM_IPC_REGS];
+};
+
 #endif /* _ASM_ARCH_ITSS_H */
diff --git a/arch/x86/include/asm/p2sb.h b/arch/x86/include/asm/p2sb.h
new file mode 100644 (file)
index 0000000..6f63eae
--- /dev/null
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef ASM_P2SB_H
+#define ASM_P2SB_H
+
+/* Platform data for the P2SB */
+struct p2sb_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_intel_p2sb dtplat;
+#endif
+       ulong mmio_base;
+       pci_dev_t bdf;
+};
+
+#endif /* ASM_P2SB_H */
index b76bdf64a3097f9f01de7952eb49e9a952d73b6e..818e80881eca233fba548d41276cfa2247b6eeb3 100644 (file)
@@ -2,9 +2,9 @@
 /*
  * Copyright (c) 2017 Intel Corporation
  */
-#ifndef _X86_ASM_PMU_IPC_H_
-#define _X86_ASM_PMU_IPC_H_
+#ifndef _X86_ASM_PMU_H_
+#define _X86_ASM_PMU_H_
 
 int pmu_turn_power(unsigned int lss, bool on);
 
-#endif /* _X86_ASM_PMU_IPC_H_ */
+#endif /* _X86_ASM_PMU_H_ */
diff --git a/arch/x86/include/asm/sysreset.h b/arch/x86/include/asm/sysreset.h
new file mode 100644 (file)
index 0000000..5e586f5
--- /dev/null
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+#ifndef _X86_ASM_SYSRESET_H_
+#define _X86_ASM_SYSRESET_H_
+
+#include <dt-structs.h>
+
+struct x86_sysreset_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_x86_reset dtplat;
+#endif
+
+       struct udevice *pch;
+};
+
+#endif /* _X86_ASM_SYSRESET_H_ */
index 15b0212d190a3346a042f0eb3c742c6b1b42821e..04ff32277fd0fbb274fe8ff425d35966f102b077 100644 (file)
@@ -133,14 +133,16 @@ void spl_board_init(void)
  * for devices, so the TPL BARs continue to be used. Once U-Boot starts it does
  * the auto allocation (after relocation).
  */
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id tpl_fake_pci_ids[] = {
        { .compatible = "pci-x86" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(pci_x86) = {
        .name   = "pci_x86",
        .id     = UCLASS_SIMPLE_BUS,
-       .of_match = tpl_fake_pci_ids,
+       .of_match = of_match_ptr(tpl_fake_pci_ids),
 };
 #endif
diff --git a/arch/xtensa/include/asm/spl.h b/arch/xtensa/include/asm/spl.h
new file mode 100644 (file)
index 0000000..e69de29
index 0fd9532d7484d94462aef765c820a73c260e73d5..4ed06a80b798840f968d22ffcb1766a5ef595052 100644 (file)
@@ -58,7 +58,7 @@ void board_init_f(ulong bootflag)
        bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
        gd->bus_clk = bus_clk;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     bus_clk / 16 / CONFIG_BAUDRATE);
 #ifdef CONFIG_SPL_MMC_BOOT
        puts("\nSD boot...\n");
index cd0022a73e17e4b1136f211c147ee68a81b1180a..90abec9cce5fae700c7ff86c3b8ed2a0fc3bb5a6 100644 (file)
@@ -34,7 +34,7 @@ void board_init_f(ulong bootflag)
        plat_ratio >>= 1;
        gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     gd->bus_clk / 16 / CONFIG_BAUDRATE);
 
        puts("\nNAND boot... ");
@@ -55,9 +55,9 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 void putc(char c)
 {
        if (c == '\n')
-               NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
+               ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r');
 
-       NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
+       ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c);
 }
 
 void puts(const char *str)
index aa2987d924f200cc8cf1ddb8c205a642c3d5f801..fe3b0eb554fff5131cfd1954c809aed9755ffe65 100644 (file)
@@ -106,10 +106,11 @@ void reset_misc(void)
        printf("Synology reset...");
        udelay(50000);
 
-       b_d = ns16550_calc_divisor((NS16550_t)CONFIG_SYS_NS16550_COM2,
-               CONFIG_SYS_NS16550_CLK, 9600);
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM2, b_d);
-       NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM2, SOFTWARE_REBOOT);
+       b_d = ns16550_calc_divisor((struct ns16550 *)CONFIG_SYS_NS16550_COM2,
+                                  CONFIG_SYS_NS16550_CLK, 9600);
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM2, b_d);
+       ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM2,
+                    SOFTWARE_REBOOT);
 }
 
 /* Support old kernels */
index 21bea62e9b7364fced07dafca3a0406d67677ed7..3c56fa1c019ff99fce31b8cc080beb519d319b8d 100644 (file)
@@ -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,
 };
index 6263d0c36123e6e954c76086188080bc3370d878..da24b32333bb1922b971acdfb453a73b759cc231 100644 (file)
@@ -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,
 };
index 6df6bcd3cf56f3fcbd4be89fc46c2e0dad00b843..bd66d52cb7b42b95a1c754d11bc0072ec7f771dd 100644 (file)
@@ -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,
 };
index a71b4eb7339984a3a5989449518c344cc173cef0..17ecdb679e106d895114a3d0b2b57b61d03959e0 100644 (file)
@@ -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,
 };
index 9e41a42263dccb9847a153ab39df99213982f785..58fab15c112638acb420d51afc41fab4bb0bfd48 100644 (file)
@@ -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,
 };
index 29db51b02607fe8ab67fdaa5f136a547b93d8b05..c26793d76cc8325fe15e3b9708e9297b670f347f 100644 (file)
@@ -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 = &ethoc_pdata,
 };
index 22c4c72361ef402c7da30f0dcf6551ec72b4fff9..fd234728980fcb204d752f200f2ab55f8f3e76a9 100644 (file)
@@ -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,
 };
index bc3ce4d16c977256f0ceb3c94d85cf43d1317407..7520e96e078e3deafa33b4682c428cefa7c14244 100644 (file)
@@ -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,
 };
index a8ece170ce304768f4e0cbd99c1342f1cdd768e4..a08858550d49ccded35d19327e2b1d178c3cb5b6 100644 (file)
@@ -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,
 };
index f42d395098bcc5c03bcfb6aec2afe51c1050b70c..35669c252bf625dd19908832c62cc7540142748e 100644 (file)
@@ -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");
index 85104ab22c8efcaf5d9589c488eb489fd1b4c621..d2df9351eaccd49637118fb921f383b6cc928d16 100644 (file)
@@ -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,
 };
index f6f43d2b1373df4916b10b4f3a7d3b1743c23d87..8189f41becb32036289695d31a6cf760681215c2 100644 (file)
@@ -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,
 };
index 5e923e525270a340766f66a1d4c84098ef82c941..2241d061dd8eb944d9ca0b8bce9eb8bc14ddcc91 100644 (file)
@@ -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,
 };
index 99417aa40d70956c1b3ea693c2578a67daad5d9f..ea027bec5676fc6ecd709f6ec43a74f3ec2d84b7 100644 (file)
@@ -63,7 +63,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,
 };
@@ -73,7 +73,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,
 };
index 65a10c345aec40b3232e8bdb45a9338e7b129f54..7e1a31f2650df7acb7aa2c5945c20d506b2115c5 100644 (file)
@@ -132,7 +132,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 void board_init_f(ulong bootflag)
 {
        board_early_init_f();
-       NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
+       ns16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500),
                     CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
        puts("NAND boot... ");
        timer_init();
@@ -152,8 +152,8 @@ void putc(char c)
                return;
 
        if (c == '\n')
-               NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
+               ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r');
 
-       NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
+       ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c);
 }
 #endif
index f8e4599f13f7634053b8dcaa3df5e6225bdd3089..05b983a3f26f92eabf7d7bc465e45e12d1336205 100644 (file)
@@ -220,7 +220,7 @@ int checkboard(void)
 void board_init_f(ulong bootflag)
 {
        board_early_init_f();
-       NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
+       ns16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500),
                     CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
        puts("NAND boot... ");
        timer_init();
@@ -240,9 +240,9 @@ void putc(char c)
                return;
 
        if (c == '\n')
-               NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
+               ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r');
 
-       NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
+       ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c);
 }
 
 #endif /* CONFIG_NAND_SPL */
index fbaa6a65142ed4e67017000dcce5d0bf62e4e92d..35b95e083890d6e19e397497eb0b13eb758db96e 100644 (file)
@@ -44,7 +44,7 @@ void board_init_f(ulong bootflag)
        plat_ratio >>= 1;
        gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     gd->bus_clk / 16 / CONFIG_BAUDRATE);
 
 #ifdef CONFIG_SPL_MMC_BOOT
index 0bb2c83872040a691bb4fecfd37a98aceb45f324..989c5b139aca9b8e41ddab0611932d75cd0944a1 100644 (file)
@@ -31,8 +31,8 @@ void board_init_f(ulong bootflag)
        plat_ratio >>= 1;
        gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
-                       gd->bus_clk / 16 / CONFIG_BAUDRATE);
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
+                    gd->bus_clk / 16 / CONFIG_BAUDRATE);
 
        puts("\nNAND boot... ");
 
@@ -53,9 +53,9 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 void putc(char c)
 {
        if (c == '\n')
-               NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
+               ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r');
 
-       NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
+       ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c);
 }
 
 void puts(const char *str)
index 8aceceb56a37cdf1d3d26c1561b0f7961383b73c..b16f701ae1a6c113dbf070232b6da96f49937687 100644 (file)
@@ -50,7 +50,7 @@ void board_init_f(ulong bootflag)
        bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
        gd->bus_clk = bus_clk;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     bus_clk / 16 / CONFIG_BAUDRATE);
 #ifdef CONFIG_SPL_MMC_BOOT
        puts("\nSD boot...\n");
index ced5f3c3b5d53a5dda214c53135b0eaa33180ea6..eb3f2c83fa2636955adc3dad978e1a68a75e467e 100644 (file)
@@ -30,8 +30,8 @@ void board_init_f(ulong bootflag)
        plat_ratio >>= 1;
        gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
-                       gd->bus_clk / 16 / CONFIG_BAUDRATE);
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
+                    gd->bus_clk / 16 / CONFIG_BAUDRATE);
 
        puts("\nNAND boot... ");
 
@@ -51,9 +51,9 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 void putc(char c)
 {
        if (c == '\n')
-               NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
+               ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r');
 
-       NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
+       ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c);
 }
 
 void puts(const char *str)
index 09dd88ac4ea6634eed762a3928dca3bbc96d82b7..66d2f3bda7bcb71786ff979c491eec1fc3c6dd36 100644 (file)
@@ -82,7 +82,7 @@ void board_init_f(ulong bootflag)
        plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
        ccb_clk = sys_clk * plat_ratio / 2;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     ccb_clk / 16 / CONFIG_BAUDRATE);
 
 #if defined(CONFIG_SPL_MMC_BOOT)
index e7922954de70decd088a1ae15acb504ed4ca821b..28ac12a1fd0d2e01e44acf97d84767a31697c5bd 100644 (file)
@@ -81,7 +81,7 @@ void board_init_f(ulong bootflag)
        plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
        uart_clk = sys_clk * plat_ratio / 2;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     uart_clk / 16 / CONFIG_BAUDRATE);
 
        relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0);
index d8c2bbe28df1d95303e091599c462bf99719c18f..13e61f083f6b1a616d8f9dd5a4f3e99ee9297ae3 100644 (file)
@@ -81,7 +81,7 @@ void board_init_f(ulong bootflag)
        plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
        ccb_clk = sys_clk * plat_ratio / 2;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     ccb_clk / 16 / CONFIG_BAUDRATE);
 
 #if defined(CONFIG_SPL_MMC_BOOT)
index c64bd8711593f9eaadb135f13f6df1a2c1307e2f..2bba94da7bc40de9348b25cf2e6678c5305c2286 100644 (file)
@@ -51,7 +51,7 @@ void board_init_f(ulong bootflag)
        plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
        ccb_clk = sys_clk * plat_ratio / 2;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     ccb_clk / 16 / CONFIG_BAUDRATE);
 
 #if defined(CONFIG_SPL_MMC_BOOT)
index 9aa0a9b05233761afe20793c3007b13ee8b187c8..fc624efbe6328f51c2bfbc2e9142ad2348843ca1 100644 (file)
@@ -60,7 +60,7 @@ void board_init_f(ulong bootflag)
        plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
        ccb_clk = sys_clk * plat_ratio / 2;
 
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
+       ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
                     ccb_clk / 16 / CONFIG_BAUDRATE);
 
        puts("\nSD boot...\n");
index c7224d1efe31d7ee9c177231074eba3588e9fb6b..048f624c3529b97c2f1fb98e9e157ec50a4e3eaa 100644 (file)
@@ -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,
 };
index b8b923c139eea5944c52777115fb1797cc1c27ec..34b2c2ac5d5828e7f07b45cf588545ccf15fb6f4 100644 (file)
@@ -143,14 +143,16 @@ struct acpi_ops coral_acpi_ops = {
        .inject_dsdt    = chromeos_acpi_gpio_generate,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id coral_ids[] = {
        { .compatible = "google,coral" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(coral_drv) = {
        .name           = "coral",
        .id             = UCLASS_SYSINFO,
-       .of_match       = coral_ids,
+       .of_match       = of_match_ptr(coral_ids),
        ACPI_OPS_PTR(&coral_acpi_ops)
 };
index 441a1a376a9a2a8566a66dec2dfe2abcc73a1f9a..23080c1798b78f7bd5901e026cdfb5130e52165d 100644 (file)
@@ -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;
index 0ac88306d09afc30d8f9c0b293179ba8c897f624..65a8179adbfbd3b92a85011ee9252d259a231344 100644 (file)
@@ -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,
 };
index 04b8cde1363f806fd5dd44e2a3a35482a2e4457c..3fe4c60d02eeaced692f11059cd103adbab9ce6b 100644 (file)
@@ -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,
 };
index b8be4ce45a68c6e6d5fdc9a61c7d64d5b2999c60..bfb2c66a17a365208b9ce8b997179e09e08e3a79 100644 (file)
@@ -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,
 };
index 6a7da502dda66c3688b0fb562fe696b025c73cc5..0932f62b9bebed4192f1bc96a706eb3b64f23c09 100644 (file)
@@ -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
 };
index d11630b95433901e8859b5d6421f9cc1f39a2ddc..118ab269d6fcfde2bcb2111503c69080196654bb 100644 (file)
@@ -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
 };
index bafb6205bd842f421b04de2c200e5ba3d49b4f1c..253ee3c7b296f5bd00cc5c71332d678889cf1f79 100644 (file)
@@ -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] },
index 9eccdc4a832feabbdabe605d068403989c199048..d349531261ed09695fdd88c58c7c67d697a35861 100644 (file)
@@ -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;
index 71c71ed6ec231e26e6bd5bf597013ca1f0adb98b..06a36f8ed3871920702999ebc2958feff7ba2284 100644 (file)
@@ -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;
index e3fa3526b75d773fc6e2b945cf950fc30cb0adac..ebb2d6f7420f01053cc725960f33bb8d3c5f8779 100644 (file)
@@ -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;
index 3235541a7d572709d335a863e4b5f53506154e4a..d152703b1540ed5c1238e12d6b5ce9c52ccf40a6 100644 (file)
@@ -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
index 1613c449294b3f30729b184c97d826a323f0bbb3..25d85a8f1705415e6c4d39bc46bb8772796ef433 100644 (file)
@@ -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,
 };
index 54e5a4c16739e46ca97f2bf74719278a71270d76..a4e78220cbaefc582c42357ac98b13e1d6d17b0b 100644 (file)
@@ -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__);
index e1038619f0c957210c39941f6c36800fe495cdd9..2fba3831685af139a44d51122f1c89a616f1c277 100644 (file)
@@ -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),
index aab7d741ac609fee8613d38cdc9883b1920090b3..9c3d115dce7384e3e8144daed93303ee6271d467 100644 (file)
@@ -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;
index 3aa379e8a50f8de820c18bd52a7e3170fd097efc..a313b817c57290f1d3e3e0c2ace443025ce1ea97 100644 (file)
@@ -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 */
index f1197f9faa48ece7c7a763ac41f29fbffc329f81..e0a2b76353afb0660dcc75a41e2a30b4f1e5f423 100644 (file)
@@ -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;
index d3cffdd770a1e2f9ba397e62ab5e415e92d04811..df353cb5ec359f90edff48a048e702618b1f036c 100644 (file)
@@ -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)
index 3371973600aa3bfa17cb85b2dbbc3e78bc2fe38b..95e203ff0ea4e16aeb92690f19366e2e07709f1a 100644 (file)
@@ -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,
 };
index 1c74bfb93a3b6762fcd88e3b7833f797dd244fa4..bd43179fc796c29ffe382b01da5ce51be914817d 100644 (file)
@@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl)
        /* Dummy fmeas device, just to be able to use standard clk_* api */
        struct udevice fmeas = {
                .name = "clk-fmeas",
-               .node = ofnode_path("/clk-fmeas"),
        };
+       dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas"));
 
        ret = clk_get_by_name(&fmeas, name, &clk);
        if (ret) {
index 42e1a80ec5fa2d0b1d0d48131ff92d73519bc2c3..65fc60e2b46d185e0c42de1e51a8b9d33e9365c0 100644 (file)
@@ -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,
 };
index 2aa385a937bd515637428260e483dfaf118b3355..40d2e0238fd524381bd180b22cc50f4ab1a1eec7 100644 (file)
@@ -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,
 };
index d8711eb90050d55ea762a88eb8a23aacbccd479a..44969e80b4d59d8eda85a8b60b39acdbc05808e4 100644 (file)
@@ -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);
index 875383625d45ed3387c09890a3cd0f222864eea7..0731fb764569feb5a76479092d2faad2dc2d48e7 100644 (file)
@@ -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
 };
index e7a2186c2c42cd8228aa82ac641ff84ce12ed205..b97617cfca363aadbc10ced5c1eb6fe472403696 100644 (file)
@@ -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__);
index 362a750b199f67757f08a0bf1d9704831c97483a..5ae5274584a49ceeb0e62fda807f940a23c84bbd 100644 (file)
@@ -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,
 };
index 056064f6b97107f9256deb6935a486ca648ea96d..6ff55ce57b952b6b3891ef4caf8a9aeb5d04b007 100644 (file)
@@ -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,
 };
index a82daad739585d8a8b3960a144faade76929fab3..57d3e526b4c00f847ff0ed887dae34356b313cf0 100644 (file)
@@ -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,
 };
index b9d0fb98af35b76caff732280d07550022d5d8ba..645751a37ec85403afdb4765445fdc53d0019be5 100644 (file)
@@ -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,
 };
index 5f9ba925609fc97df81e4ac1716f89006b64d1b0..b3ddcebe314268ed601ae1667d7867ec1b2344cc 100644 (file)
@@ -35,7 +35,7 @@ static int print_remoteproc_list(void)
                uc_pdata = dev_get_uclass_plat(dev);
 
                /* Do not print if rproc is not probed */
-               if (!(dev->flags & DM_FLAG_ACTIVATED))
+               if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
                        continue;
 
                switch (uc_pdata->mem_type) {
index 6d980be0b723107a19387f4b6c598048961523f4..6b0186763b236cb43e07b87f082a8a1bc8c65754 100644 (file)
@@ -113,6 +113,15 @@ config SPL_FSL_PBL
          Create boot binary having SPL binary in PBI format concatenated with
          u-boot binary.
 
+config SPL_ALLOC_BD
+       bool "Allocate memory for bd_info"
+       default y if X86 || SANDBOX
+       help
+         Some boards don't allocate space for this in their board_init_f()
+         code. In this case U-Boot can allocate space for gd->bd in the
+         standard SPL flow (board_init_r()). Enable this option to support
+         this feature.
+
 endmenu
 
 config HANDOFF
index 63c48fbf33df75a48ce3e4d52c1810761e411711..835c53deaa8f8a2b4d02729ee08fb3be168c4239 100644 (file)
@@ -53,9 +53,6 @@ binman_sym_declare(ulong, spl, image_pos);
 binman_sym_declare(ulong, spl, size);
 #endif
 
-/* Define board data structure */
-static struct bd_info bdata __attribute__ ((section(".data")));
-
 /*
  * Board-specific Platform code can reimplement show_boot_progress () if needed
  */
@@ -443,14 +440,19 @@ static int spl_common_init(bool setup_malloc)
        return 0;
 }
 
-void spl_set_bd(void)
+int spl_alloc_bd(void)
 {
        /*
         * NOTE: On some platforms (e.g. x86) bdata may be in flash and not
         * writeable.
         */
-       if (!gd->bd)
-               gd->bd = &bdata;
+       if (!gd->bd) {
+               gd->bd = malloc(sizeof(*gd->bd));
+               if (!gd->bd)
+                       return -ENOMEM;
+       }
+
+       return 0;
 }
 
 int spl_early_init(void)
@@ -600,8 +602,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
        debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
 
-       spl_set_bd();
-
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
        mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
                        CONFIG_SYS_SPL_MALLOC_SIZE);
@@ -611,6 +611,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                if (spl_init())
                        hang();
        }
+       if (IS_ENABLED(CONFIG_SPL_ALLOC_BD) && spl_alloc_bd()) {
+               puts("Cannot alloc bd\n");
+               hang();
+       }
 #if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6)
        /*
         * timer_init() does not exist on PPC systems. The timer is initialized
index f26e4f14df0e3c1b216a1e5782fe687c1feb4e5d..ffed7d5f79ae47b0ce4a2a60e5da9cd560896b0b 100644 (file)
@@ -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
index afa27c211ccb24a58a31847cd1d7a61be2307c2d..4ef2fe699a4eec6503845c5d18df4f042f1a0be1 100644 (file)
@@ -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,16 +155,13 @@ 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),
             .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:
 
@@ -178,24 +175,21 @@ 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
 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.
 
 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
-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().
+linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support
+dev_get_parent().
 
-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 +291,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
@@ -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_DEVICE by using DM_GET_DEVICE
+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.
 
index edb09cc1057d1f6a58d0314aadad8a3181e5417e..566495a21c43b2103f6147610cffbec26b4bf7fe 100644 (file)
@@ -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,
        };
index f1c416713909d2d2231ffb35fc7ef719464c7d5b..97fbf750cb6cd2016672a4eb970b1137cf7ec5a3 100644 (file)
@@ -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,
        };
index cd28e0cae37de72e51a667dc7b58329b70da0321..46b7677783fe6acfe3608aa887affab358115027 100644 (file)
@@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv,
                                   SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN);
        }
 
-       ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map);
+       ofnode_read_u32(dev_ofnode(dev), "ports-implemented",
+                       &hpriv->port_map);
        return 0;
 }
 
index ac954a34d27ffd7a1c1cfbd34a1e0a4fbb4354ae..5cfd00ce7710440fe377abd5af2624ce74d4457c 100644 (file)
@@ -345,7 +345,7 @@ int clk_set_defaults(struct udevice *dev, int stage)
 {
        int ret;
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        /* If this not in SPL and pre-reloc state, don't take any action. */
index 928ad13641a263bc0c0f28821edc9c39ca8a284a..1efb7fe9f3e305c7114e77709a2515e9ba1dcc81 100644 (file)
@@ -44,8 +44,10 @@ int clk_register(struct clk *clk, const char *drv_name,
        }
 
        clk->enable_count = 0;
+
        /* Store back pointer to clk from udevice */
-       clk->dev->uclass_priv = clk;
+       /* FIXME: This is not allowed...should be allocated by driver model */
+       dev_set_uclass_priv(clk->dev, clk);
 
        return 0;
 }
@@ -65,7 +67,7 @@ const char *clk_hw_get_name(const struct clk *hw)
 
 bool clk_dev_binded(struct clk *clk)
 {
-       if (clk->dev && (clk->dev->flags & DM_FLAG_BOUND))
+       if (clk->dev && (dev_get_flags(clk->dev) & DM_FLAG_BOUND))
                return true;
 
        return false;
index 12d81a7ff7a77691db5b826fc1208df28161ec41..3c5a83c523c102c54e5331c29500a49aa3cd6ce9 100644 (file)
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device-internal.h>
 #include <linux/clk-provider.h>
 
 static ulong clk_fixed_rate_get_rate(struct clk *clk)
@@ -32,7 +33,8 @@ static int clk_fixed_rate_of_to_plat(struct udevice *dev)
                dev_read_u32_default(dev, "clock-frequency", 0);
 #endif
        /* Make fixed rate clock accessible from higher level struct clk */
-       dev->uclass_priv = clk;
+       /* FIXME: This is not allowed */
+       dev_set_uclass_priv(dev, clk);
        clk->dev = dev;
        clk->enable_count = 0;
 
index 72cbcdf6a21a75adaf5075b67f7ccbbed086d428..5bea2b60b9baa377c98a2f2defb17cb3ff4792b2 100644 (file)
@@ -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;
index a9988d8f1a82dcbabcae05b363150118afff9328..e8acca00660df06ae8b87d2ad27cf2a1677676e5 100644 (file)
@@ -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;
 
index 27a652a625ab0f2498422b8bca05a21bfbc72548..8484613eed5c37f5c0cc247e12eeb91c6d8e7656 100644 (file)
@@ -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;
 
index 388471b03a90af150ae1515201130e8f3b7d13b9..d43b8a0648c2f2ac09df890a5b16bae69d306b55 100644 (file)
@@ -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:
index 82068578ffb990099de19134d22f82de95e1cccb..d6da59d269b0e09862ddf5dae45192d8ea4330f6 100644 (file)
@@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
        struct meson_clk *priv = dev_get_priv(dev);
 
-       priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->map))
                return PTR_ERR(priv->map);
 
index 01b22abc34d17e8990dd3e806e433397705bc287..5058db1a47b976cbde7a5a927fe3dbab2b7f1f09 100644 (file)
@@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
        struct meson_clk *priv = dev_get_priv(dev);
 
-       priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->map))
                return PTR_ERR(priv->map);
 
index 2a20541dcb466254ad071b5e778ca5e861a10f7f..e379540deee77bff47e29310cff6a56394c64e02 100644 (file)
@@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
        struct meson_clk *priv = dev_get_priv(dev);
 
-       priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->map))
                return PTR_ERR(priv->map);
 
index 355362dd67879b8e903a906da03eb471a44d8f81..a2a5939d4b122f5d8122d467fc86f4da71042853 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/arch-rockchip/cru_px30.h>
 #include <asm/arch-rockchip/hardware.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/px30-cru.h>
 #include <linux/bitops.h>
@@ -1458,7 +1459,7 @@ static int px30_clk_bind(struct udevice *dev)
                                                    glb_srst_fst);
                priv->glb_srst_snd_value = offsetof(struct px30_cru,
                                                    glb_srst_snd);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 07ef6133f29fddd35a4622ab412ce0d873f2a5c1..026858459e3df5aac27919437cd88f0aaf37edc3 100644 (file)
@@ -14,6 +14,7 @@
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk3036.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3036-cru.h>
 #include <linux/delay.h>
@@ -353,7 +354,7 @@ static int rk3036_clk_bind(struct udevice *dev)
                                                    cru_glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rk3036_cru,
                                                    cru_glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 9349e14830e28dc60c32779ed3f7752ea659048b..d5b2b63dd795cd712f6369d28ab753ad0e075825 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/arch-rockchip/cru_rk3128.h>
 #include <asm/arch-rockchip/hardware.h>
 #include <bitfield.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3128-cru.h>
 #include <linux/delay.h>
@@ -581,7 +582,7 @@ static int rk3128_clk_bind(struct udevice *dev)
                                                    cru_glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rk3128_cru,
                                                    cru_glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
        return 0;
index 48bfe09b11f84747da697589431797afa07e33c0..1b62d8d2898be7aad3da436fd49b6db6d4f29f17 100644 (file)
@@ -593,7 +593,7 @@ static int rk3188_clk_bind(struct udevice *dev)
                                                    cru_glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rk3188_cru,
                                                    cru_glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index c2f5fc0fd7580526b5ccfb7d55d2ede10c335975..dbef606d8875187f83c0d3684416eda4811fd0b8 100644 (file)
@@ -14,6 +14,7 @@
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rk322x.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3228-cru.h>
 #include <linux/bitops.h>
@@ -510,7 +511,7 @@ static int rk322x_clk_bind(struct udevice *dev)
                                                    cru_glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rk322x_cru,
                                                    cru_glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index e87fdfc54dd249ec8b0c8f9e3692d34350fcd3c0..6226d55658eada14d9768468bff0de0a551958a1 100644 (file)
@@ -1018,7 +1018,7 @@ static int rk3288_clk_bind(struct udevice *dev)
                                                    cru_glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rockchip_cru,
                                                    cru_glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 30589512ecc6a7d5db054dc6c7678f6510890472..a05efcfbabaf76a039d5e77f3424ba59fa964f1b 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/arch/cru_rk3308.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3308-cru.h>
 #include <linux/bitops.h>
@@ -1045,7 +1046,7 @@ static int rk3308_clk_bind(struct udevice *dev)
                                                    glb_srst_fst);
                priv->glb_srst_snd_value = offsetof(struct rk3308_cru,
                                                    glb_srst_snd);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index e2df71290f419475234a1e23e71f9b7b5afae253..b825ff4cf8366ec62631ec8d229cae1fcd5e0ae8 100644 (file)
@@ -16,6 +16,7 @@
 #include <asm/arch-rockchip/hardware.h>
 #include <asm/arch-rockchip/grf_rk3328.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3328-cru.h>
 #include <linux/bitops.h>
@@ -823,7 +824,7 @@ static int rk3328_clk_bind(struct udevice *dev)
                                                    glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rk3328_cru,
                                                    glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 9267cac6bcd50712c54bef9752c1b49e73ee477e..780b49ccd89b68119e64866118cb480b435f498a 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/arch-rockchip/cru_rk3368.h>
 #include <asm/arch-rockchip/hardware.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3368-cru.h>
 #include <linux/delay.h>
@@ -621,7 +622,7 @@ static int rk3368_clk_bind(struct udevice *dev)
                                                    glb_srst_fst_val);
                priv->glb_srst_snd_value = offsetof(struct rk3368_cru,
                                                    glb_srst_snd_val);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 68d5dbb581cd0c03714f544aa31107d3f1c71e17..55ebac7057d141291212468524f6469aad0c48d0 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rk3399-cru.h>
 #include <linux/bitops.h>
@@ -1425,7 +1426,7 @@ static int rk3399_clk_bind(struct udevice *dev)
                                                    glb_srst_fst_value);
                priv->glb_srst_snd_value = offsetof(struct rockchip_cru,
                                                    glb_srst_snd_value);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 62bcf5a2ab345b45623e147e8e5853465ab36701..1e22db0cb71d79b44f9ff18edaf575bc2ec29a7d 100644 (file)
@@ -16,6 +16,7 @@
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru_rv1108.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dt-bindings/clock/rv1108-cru.h>
 #include <linux/delay.h>
@@ -697,7 +698,7 @@ static int rv1108_clk_bind(struct udevice *dev)
                                                    glb_srst_fst_val);
                priv->glb_srst_snd_value = offsetof(struct rv1108_cru,
                                                    glb_srst_snd_val);
-               sys_child->priv = priv;
+               dev_set_priv(sys_child, priv);
        }
 
 #if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
index 9a08c148a0d632745fa8e995f79a6395fa26ddd4..b3882d0b77d13be66a63f2149bda2082b7901f47 100644 (file)
@@ -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);
index 8a5f95806a040489f27b4339e175dd9fbe255738..7e8f3afb2d60db1c126586552a1236c0ba583562 100644 (file)
@@ -69,10 +69,10 @@ int device_unbind(struct udevice *dev)
        if (!dev)
                return log_msg_ret("dev", -EINVAL);
 
-       if (dev->flags & DM_FLAG_ACTIVATED)
+       if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
                return log_msg_ret("active", -EINVAL);
 
-       if (!(dev->flags & DM_FLAG_BOUND))
+       if (!(dev_get_flags(dev) & DM_FLAG_BOUND))
                return log_msg_ret("not-bound", -EINVAL);
 
        drv = dev->driver;
@@ -88,17 +88,17 @@ int device_unbind(struct udevice *dev)
        if (ret)
                return log_msg_ret("child unbind", ret);
 
-       if (dev->flags & DM_FLAG_ALLOC_PDATA) {
-               free(dev->plat);
-               dev->plat = NULL;
+       if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
+               free(dev_get_plat(dev));
+               dev_set_plat(dev, NULL);
        }
-       if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) {
-               free(dev->uclass_plat);
-               dev->uclass_plat = NULL;
+       if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
+               free(dev_get_uclass_plat(dev));
+               dev_set_uclass_plat(dev, NULL);
        }
-       if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
-               free(dev->parent_plat);
-               dev->parent_plat = NULL;
+       if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) {
+               free(dev_get_parent_plat(dev));
+               dev_set_parent_plat(dev, NULL);
        }
        ret = uclass_unbind_device(dev);
        if (ret)
@@ -109,7 +109,7 @@ int device_unbind(struct udevice *dev)
 
        devres_release_all(dev);
 
-       if (dev->flags & DM_FLAG_NAME_ALLOCED)
+       if (dev_get_flags(dev) & DM_FLAG_NAME_ALLOCED)
                free((char *)dev->name);
        free(dev);
 
@@ -125,13 +125,13 @@ void device_free(struct udevice *dev)
        int size;
 
        if (dev->driver->priv_auto) {
-               free(dev->priv);
-               dev->priv = NULL;
+               free(dev_get_priv(dev));
+               dev_set_priv(dev, NULL);
        }
        size = dev->uclass->uc_drv->per_device_auto;
        if (size) {
-               free(dev->uclass_priv);
-               dev->uclass_priv = NULL;
+               free(dev_get_uclass_priv(dev));
+               dev_set_uclass_priv(dev, NULL);
        }
        if (dev->parent) {
                size = dev->parent->driver->per_child_auto;
@@ -140,11 +140,11 @@ void device_free(struct udevice *dev)
                                        per_child_auto;
                }
                if (size) {
-                       free(dev->parent_priv);
-                       dev->parent_priv = NULL;
+                       free(dev_get_parent_priv(dev));
+                       dev_set_parent_priv(dev, NULL);
                }
        }
-       dev->flags &= ~DM_FLAG_PLATDATA_VALID;
+       dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID);
 
        devres_release_probe(dev);
 }
@@ -166,7 +166,7 @@ int device_remove(struct udevice *dev, uint flags)
        if (!dev)
                return -EINVAL;
 
-       if (!(dev->flags & DM_FLAG_ACTIVATED))
+       if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
                return 0;
 
        drv = dev->driver;
@@ -207,7 +207,7 @@ int device_remove(struct udevice *dev, uint flags)
        if (flags_remove(flags, drv->flags)) {
                device_free(dev);
 
-               dev->flags &= ~DM_FLAG_ACTIVATED;
+               dev_bic_flags(dev, DM_FLAG_ACTIVATED);
        }
 
        return ret;
index d1a08ce78344c62b35a281c18cf1d470f5a042a2..aeab3836ed768a8a5b53dc4ac24a57334f0a569b 100644 (file)
@@ -42,6 +42,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
        struct uclass *uc;
        int size, ret = 0;
        bool auto_seq = true;
+       void *ptr;
 
        if (devp)
                *devp = NULL;
@@ -64,15 +65,15 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 #ifdef CONFIG_DEVRES
        INIT_LIST_HEAD(&dev->devres_head);
 #endif
-       dev->plat = plat;
+       dev_set_plat(dev, plat);
        dev->driver_data = driver_data;
        dev->name = name;
-       dev->node = node;
+       dev_set_ofnode(dev, node);
        dev->parent = parent;
        dev->driver = drv;
        dev->uclass = uc;
 
-       dev->sqq = -1;
+       dev->seq_ = -1;
        if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
            (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
                /*
@@ -82,45 +83,46 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
                if (CONFIG_IS_ENABLED(OF_CONTROL) &&
                    !CONFIG_IS_ENABLED(OF_PLATDATA)) {
                        if (uc->uc_drv->name && ofnode_valid(node)) {
-                               if (!dev_read_alias_seq(dev, &dev->sqq))
+                               if (!dev_read_alias_seq(dev, &dev->seq_))
                                        auto_seq = false;
                        }
                }
        }
        if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
-               dev->sqq = uclass_find_next_free_seq(uc);
+               dev->seq_ = uclass_find_next_free_seq(uc);
 
        if (drv->plat_auto) {
                bool alloc = !plat;
 
                if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
                        if (of_plat_size) {
-                               dev->flags |= DM_FLAG_OF_PLATDATA;
+                               dev_or_flags(dev, DM_FLAG_OF_PLATDATA);
                                if (of_plat_size < drv->plat_auto)
                                        alloc = true;
                        }
                }
                if (alloc) {
-                       dev->flags |= DM_FLAG_ALLOC_PDATA;
-                       dev->plat = calloc(1, drv->plat_auto);
-                       if (!dev->plat) {
+                       dev_or_flags(dev, DM_FLAG_ALLOC_PDATA);
+                       ptr = calloc(1, drv->plat_auto);
+                       if (!ptr) {
                                ret = -ENOMEM;
                                goto fail_alloc1;
                        }
-                       if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat) {
-                               memcpy(dev->plat, plat, of_plat_size);
-                       }
+                       if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat)
+                               memcpy(ptr, plat, of_plat_size);
+                       dev_set_plat(dev, ptr);
                }
        }
 
        size = uc->uc_drv->per_device_plat_auto;
        if (size) {
-               dev->flags |= DM_FLAG_ALLOC_UCLASS_PDATA;
-               dev->uclass_plat = calloc(1, size);
-               if (!dev->uclass_plat) {
+               dev_or_flags(dev, DM_FLAG_ALLOC_UCLASS_PDATA);
+               ptr = calloc(1, size);
+               if (!ptr) {
                        ret = -ENOMEM;
                        goto fail_alloc2;
                }
+               dev_set_uclass_plat(dev, ptr);
        }
 
        if (parent) {
@@ -129,12 +131,13 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
                        size = parent->uclass->uc_drv->per_child_plat_auto;
                }
                if (size) {
-                       dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA;
-                       dev->parent_plat = calloc(1, size);
-                       if (!dev->parent_plat) {
+                       dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA);
+                       ptr = calloc(1, size);
+                       if (!ptr) {
                                ret = -ENOMEM;
                                goto fail_alloc3;
                        }
+                       dev_set_parent_plat(dev, ptr);
                }
                /* put dev into parent's successor list */
                list_add_tail(&dev->sibling_node, &parent->child_head);
@@ -166,7 +169,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
        if (devp)
                *devp = dev;
 
-       dev->flags |= DM_FLAG_BOUND;
+       dev_or_flags(dev, DM_FLAG_BOUND);
 
        return 0;
 
@@ -190,20 +193,20 @@ fail_bind:
 fail_uclass_bind:
        if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
                list_del(&dev->sibling_node);
-               if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
-                       free(dev->parent_plat);
-                       dev->parent_plat = NULL;
+               if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) {
+                       free(dev_get_parent_plat(dev));
+                       dev_set_parent_plat(dev, NULL);
                }
        }
 fail_alloc3:
-       if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) {
-               free(dev->uclass_plat);
-               dev->uclass_plat = NULL;
+       if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
+               free(dev_get_uclass_plat(dev));
+               dev_set_uclass_plat(dev, NULL);
        }
 fail_alloc2:
-       if (dev->flags & DM_FLAG_ALLOC_PDATA) {
-               free(dev->plat);
-               dev->plat = NULL;
+       if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
+               free(dev_get_plat(dev));
+               dev_set_plat(dev, NULL);
        }
 fail_alloc1:
        devres_release_all(dev);
@@ -320,16 +323,63 @@ static void *alloc_priv(int size, uint flags)
        return priv;
 }
 
+/**
+ * device_alloc_priv() - Allocate priv/plat data required by the device
+ *
+ * @dev: Device to process
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+static int device_alloc_priv(struct udevice *dev)
+{
+       const struct driver *drv;
+       void *ptr;
+       int size;
+
+       drv = dev->driver;
+       assert(drv);
+
+       /* Allocate private data if requested and not reentered */
+       if (drv->priv_auto && !dev_get_priv(dev)) {
+               ptr = alloc_priv(drv->priv_auto, drv->flags);
+               if (!ptr)
+                       return -ENOMEM;
+               dev_set_priv(dev, ptr);
+       }
+
+       /* Allocate private data if requested and not reentered */
+       size = dev->uclass->uc_drv->per_device_auto;
+       if (size && !dev_get_uclass_priv(dev)) {
+               ptr = alloc_priv(size, dev->uclass->uc_drv->flags);
+               if (!ptr)
+                       return -ENOMEM;
+               dev_set_uclass_priv(dev, ptr);
+       }
+
+       /* Allocate parent data for this child */
+       if (dev->parent) {
+               size = dev->parent->driver->per_child_auto;
+               if (!size)
+                       size = dev->parent->uclass->uc_drv->per_child_auto;
+               if (size && !dev_get_parent_priv(dev)) {
+                       ptr = alloc_priv(size, drv->flags);
+                       if (!ptr)
+                               return -ENOMEM;
+                       dev_set_parent_priv(dev, ptr);
+               }
+       }
+
+       return 0;
+}
+
 int device_of_to_plat(struct udevice *dev)
 {
        const struct driver *drv;
-       int size = 0;
        int ret;
 
        if (!dev)
                return -EINVAL;
 
-       if (dev->flags & DM_FLAG_PLATDATA_VALID)
+       if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
                return 0;
 
        /* Ensure all parents have ofdata */
@@ -344,55 +394,25 @@ int device_of_to_plat(struct udevice *dev)
                 * (e.g. PCI bridge devices). Test the flags again
                 * so that we don't mess up the device.
                 */
-               if (dev->flags & DM_FLAG_PLATDATA_VALID)
+               if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
                        return 0;
        }
 
+       ret = device_alloc_priv(dev);
+       if (ret)
+               goto fail;
+
        drv = dev->driver;
        assert(drv);
 
-       /* Allocate private data if requested and not reentered */
-       if (drv->priv_auto && !dev->priv) {
-               dev->priv = alloc_priv(drv->priv_auto, drv->flags);
-               if (!dev->priv) {
-                       ret = -ENOMEM;
-                       goto fail;
-               }
-       }
-       /* Allocate private data if requested and not reentered */
-       size = dev->uclass->uc_drv->per_device_auto;
-       if (size && !dev->uclass_priv) {
-               dev->uclass_priv = alloc_priv(size,
-                                             dev->uclass->uc_drv->flags);
-               if (!dev->uclass_priv) {
-                       ret = -ENOMEM;
-                       goto fail;
-               }
-       }
-
-       /* Allocate parent data for this child */
-       if (dev->parent) {
-               size = dev->parent->driver->per_child_auto;
-               if (!size) {
-                       size = dev->parent->uclass->uc_drv->per_child_auto;
-               }
-               if (size && !dev->parent_priv) {
-                       dev->parent_priv = alloc_priv(size, drv->flags);
-                       if (!dev->parent_priv) {
-                               ret = -ENOMEM;
-                               goto fail;
-                       }
-               }
-       }
-
        if (drv->of_to_plat &&
-           (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
+           (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_ofnode(dev))) {
                ret = drv->of_to_plat(dev);
                if (ret)
                        goto fail;
        }
 
-       dev->flags |= DM_FLAG_PLATDATA_VALID;
+       dev_or_flags(dev, DM_FLAG_PLATDATA_VALID);
 
        return 0;
 fail:
@@ -409,7 +429,7 @@ int device_probe(struct udevice *dev)
        if (!dev)
                return -EINVAL;
 
-       if (dev->flags & DM_FLAG_ACTIVATED)
+       if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
                return 0;
 
        drv = dev->driver;
@@ -431,11 +451,11 @@ int device_probe(struct udevice *dev)
                 * (e.g. PCI bridge devices). Test the flags again
                 * so that we don't mess up the device.
                 */
-               if (dev->flags & DM_FLAG_ACTIVATED)
+               if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
                        return 0;
        }
 
-       dev->flags |= DM_FLAG_ACTIVATED;
+       dev_or_flags(dev, DM_FLAG_ACTIVATED);
 
        /*
         * Process pinctrl for everything except the root device, and
@@ -465,7 +485,7 @@ int device_probe(struct udevice *dev)
        }
 
        /* Only handle devices that have a valid ofnode */
-       if (dev_of_valid(dev)) {
+       if (dev_has_ofnode(dev)) {
                /*
                 * Process 'assigned-{clocks/clock-parents/clock-rates}'
                 * properties
@@ -495,7 +515,7 @@ fail_uclass:
                        __func__, dev->name);
        }
 fail:
-       dev->flags &= ~DM_FLAG_ACTIVATED;
+       dev_bic_flags(dev, DM_FLAG_ACTIVATED);
 
        device_free(dev);
 
@@ -509,7 +529,7 @@ void *dev_get_plat(const struct udevice *dev)
                return NULL;
        }
 
-       return dev->plat;
+       return dev->plat_;
 }
 
 void *dev_get_parent_plat(const struct udevice *dev)
@@ -519,7 +539,7 @@ void *dev_get_parent_plat(const struct udevice *dev)
                return NULL;
        }
 
-       return dev->parent_plat;
+       return dev->parent_plat_;
 }
 
 void *dev_get_uclass_plat(const struct udevice *dev)
@@ -529,7 +549,7 @@ void *dev_get_uclass_plat(const struct udevice *dev)
                return NULL;
        }
 
-       return dev->uclass_plat;
+       return dev->uclass_plat_;
 }
 
 void *dev_get_priv(const struct udevice *dev)
@@ -539,7 +559,7 @@ void *dev_get_priv(const struct udevice *dev)
                return NULL;
        }
 
-       return dev->priv;
+       return dev->priv_;
 }
 
 void *dev_get_uclass_priv(const struct udevice *dev)
@@ -549,7 +569,7 @@ void *dev_get_uclass_priv(const struct udevice *dev)
                return NULL;
        }
 
-       return dev->uclass_priv;
+       return dev->uclass_priv_;
 }
 
 void *dev_get_parent_priv(const struct udevice *dev)
@@ -559,7 +579,7 @@ void *dev_get_parent_priv(const struct udevice *dev)
                return NULL;
        }
 
-       return dev->parent_priv;
+       return dev->parent_priv_;
 }
 
 static int device_get_device_tail(struct udevice *dev, int ret,
@@ -593,7 +613,7 @@ static int device_find_by_ofnode(ofnode node, struct udevice **devp)
        struct udevice *dev;
        int ret;
 
-       list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+       list_for_each_entry(uc, gd->uclass_root, sibling_node) {
                ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node,
                                                   &dev);
                if (!ret || dev) {
@@ -638,7 +658,7 @@ int device_find_child_by_seq(const struct udevice *parent, int seq,
        *devp = NULL;
 
        list_for_each_entry(dev, &parent->child_head, sibling_node) {
-               if (dev->sqq == seq) {
+               if (dev->seq_ == seq) {
                        *devp = dev;
                        return 0;
                }
@@ -945,7 +965,7 @@ bool device_is_last_sibling(const struct udevice *dev)
 
 void device_set_name_alloced(struct udevice *dev)
 {
-       dev->flags |= DM_FLAG_NAME_ALLOCED;
+       dev_or_flags(dev, DM_FLAG_NAME_ALLOCED);
 }
 
 int device_set_name(struct udevice *dev, const char *name)
@@ -959,6 +979,36 @@ int device_set_name(struct udevice *dev, const char *name)
        return 0;
 }
 
+void dev_set_priv(struct udevice *dev, void *priv)
+{
+       dev->priv_ = priv;
+}
+
+void dev_set_parent_priv(struct udevice *dev, void *parent_priv)
+{
+       dev->parent_priv_ = parent_priv;
+}
+
+void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv)
+{
+       dev->uclass_priv_ = uclass_priv;
+}
+
+void dev_set_plat(struct udevice *dev, void *plat)
+{
+       dev->plat_ = plat;
+}
+
+void dev_set_parent_plat(struct udevice *dev, void *parent_plat)
+{
+       dev->parent_plat_ = parent_plat;
+}
+
+void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat)
+{
+       dev->uclass_plat_ = uclass_plat;
+}
+
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 bool device_is_compatible(const struct udevice *dev, const char *compat)
 {
@@ -982,7 +1032,7 @@ int dev_disable_by_path(const char *path)
        if (!of_live_active())
                return -ENOSYS;
 
-       list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+       list_for_each_entry(uc, gd->uclass_root, sibling_node) {
                ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node, &dev);
                if (!ret)
                        break;
index 522b07d613f8b88110da9fe5d7b875e28f99f965..313ddc7089c967288887c53a2280a3d3e7caf4e0 100644 (file)
@@ -107,9 +107,9 @@ void devres_add(struct udevice *dev, void *res)
 
        devres_log(dev, dr, "ADD");
        assert_noisy(list_empty(&dr->entry));
-       if (dev->flags & DM_FLAG_PLATDATA_VALID)
+       if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
                dr->phase = DEVRES_PHASE_PROBE;
-       else if (dev->flags & DM_FLAG_BOUND)
+       else if (dev_get_flags(dev) & DM_FLAG_BOUND)
                dr->phase = DEVRES_PHASE_OFDATA;
        else
                dr->phase = DEVRES_PHASE_BIND;
index 201254732124b7595404be1e789b504947348585..f8afea30a9351cd83243e221bdb2d4dfb84a967a 100644 (file)
@@ -14,11 +14,13 @@ static void show_devices(struct udevice *dev, int depth, int last_flag)
 {
        int i, is_last;
        struct udevice *child;
+       u32 flags = dev_get_flags(dev);
 
        /* print the first 20 characters to not break the tree-format. */
-       printf(" %-10.10s  %3d  [ %c ]   %-20.20s  ", dev->uclass->uc_drv->name,
+       printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s  %d  [ %c ]   %s  " :
+              " %-10.10s  %3d  [ %c ]   %-20.20s  ", dev->uclass->uc_drv->name,
               dev_get_uclass_index(dev, NULL),
-              dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
+              flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
 
        for (i = depth; i >= 0; i--) {
                is_last = (last_flag >> i) & 1;
@@ -65,9 +67,9 @@ void dm_dump_all(void)
 static void dm_display_line(struct udevice *dev, int index)
 {
        printf("%-3i %c %s @ %08lx", index,
-              dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
+              dev_get_flags(dev) & DM_FLAG_ACTIVATED ? '*' : ' ',
               dev->name, (ulong)map_to_sysmem(dev));
-       if (dev->sqq != -1)
+       if (dev->seq_ != -1)
                printf(", seq %d", dev_seq(dev));
        puts("\n");
 }
index b23ee3030e5861e90e88008eae96c68374cd4d90..e214306b904bc0032f333d7ad15a6ff74bde7ba3 100644 (file)
@@ -39,8 +39,8 @@ struct driver *lists_driver_lookup_name(const char *name)
 struct uclass_driver *lists_uclass_lookup(enum uclass_id id)
 {
        struct uclass_driver *uclass =
-               ll_entry_start(struct uclass_driver, uclass);
-       const int n_ents = ll_entry_count(struct uclass_driver, uclass);
+               ll_entry_start(struct uclass_driver, uclass_driver);
+       const int n_ents = ll_entry_count(struct uclass_driver, uclass_driver);
        struct uclass_driver *entry;
 
        for (entry = uclass; entry != uclass + n_ents; entry++) {
@@ -251,7 +251,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
                if (ret) {
                        dm_warn("Error binding driver '%s': %d\n", entry->name,
                                ret);
-                       return ret;
+                       return log_msg_ret("bind", ret);
                } else {
                        found = true;
                        if (devp)
index f2fba5883aae1f2de6e768743f5608203fce2e04..78de7cdf8754d69b2e95ac8a0fe0403ca6a176ca 100644 (file)
@@ -45,8 +45,8 @@ void dm_fixup_for_gd_move(struct global_data *new_gd)
 {
        /* The sentinel node has moved, so update things that point to it */
        if (gd->dm_root) {
-               new_gd->uclass_root.next->prev = &new_gd->uclass_root;
-               new_gd->uclass_root.prev->next = &new_gd->uclass_root;
+               new_gd->uclass_root->next->prev = new_gd->uclass_root;
+               new_gd->uclass_root->prev->next = new_gd->uclass_root;
        }
 }
 
@@ -86,8 +86,8 @@ void fix_drivers(void)
 void fix_uclass(void)
 {
        struct uclass_driver *uclass =
-               ll_entry_start(struct uclass_driver, uclass);
-       const int n_ents = ll_entry_count(struct uclass_driver, uclass);
+               ll_entry_start(struct uclass_driver, uclass_driver);
+       const int n_ents = ll_entry_count(struct uclass_driver, uclass_driver);
        struct uclass_driver *entry;
 
        for (entry = uclass; entry != uclass + n_ents; entry++) {
@@ -136,7 +136,8 @@ int dm_init(bool of_live)
                dm_warn("Virtual root driver already exists!\n");
                return -EINVAL;
        }
-       INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
+       gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST;
+       INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
 
        if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
                fix_drivers();
@@ -148,7 +149,7 @@ int dm_init(bool of_live)
        if (ret)
                return ret;
        if (CONFIG_IS_ENABLED(OF_CONTROL))
-               DM_ROOT_NON_CONST->node = ofnode_root();
+               dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
        ret = device_probe(DM_ROOT_NON_CONST);
        if (ret)
                return ret;
@@ -296,39 +297,57 @@ __weak int dm_scan_other(bool pre_reloc_only)
        return 0;
 }
 
-int dm_init_and_scan(bool pre_reloc_only)
+/**
+ * dm_scan() - Scan tables to bind devices
+ *
+ * Runs through the driver_info tables and binds the devices it finds. Then runs
+ * through the devicetree nodes. Finally calls dm_scan_other() to add any
+ * special devices
+ *
+ * @pre_reloc_only: If true, bind only nodes with special devicetree properties,
+ * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers.
+ */
+static int dm_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);
-               return ret;
-       }
        ret = dm_scan_plat(pre_reloc_only);
        if (ret) {
                debug("dm_scan_plat() failed: %d\n", ret);
-               goto fail;
+               return ret;
        }
 
        if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
                ret = dm_extended_scan(pre_reloc_only);
                if (ret) {
                        debug("dm_extended_scan() failed: %d\n", ret);
-                       goto fail;
+                       return ret;
                }
        }
 
        ret = dm_scan_other(pre_reloc_only);
        if (ret)
-               goto fail;
+               return ret;
+
+       return 0;
+}
+
+int dm_init_and_scan(bool pre_reloc_only)
+{
+       int ret;
+
+       ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE));
+       if (ret) {
+               debug("dm_init() failed: %d\n", ret);
+               return ret;
+       }
+       ret = dm_scan(pre_reloc_only);
+       if (ret) {
+               log_debug("dm_scan() failed: %d\n", ret);
+               return ret;
+       }
 
        return 0;
-fail:
-       return ret;
 }
 
 #ifdef CONFIG_ACPIGEN
index c45212a0d3a3724413e365e2be08726d38aa2c70..b0c2c20958718bec7e6ba6decfbdd02fd99fa622 100644 (file)
@@ -5,12 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
-
-struct simple_bus_plat {
-       u32 base;
-       u32 size;
-       u32 target;
-};
+#include <dm/simple_bus.h>
 
 fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr)
 {
@@ -50,15 +45,17 @@ UCLASS_DRIVER(simple_bus) = {
        .per_device_plat_auto   = sizeof(struct simple_bus_plat),
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id generic_simple_bus_ids[] = {
        { .compatible = "simple-bus" },
        { .compatible = "simple-mfd" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(simple_bus) = {
        .name   = "simple_bus",
        .id     = UCLASS_SIMPLE_BUS,
-       .of_match = generic_simple_bus_ids,
+       .of_match = of_match_ptr(generic_simple_bus_ids),
        .flags  = DM_FLAG_PRE_RELOC,
 };
index 6409457fa962cd7bbcfc3b0f126f14dbb193a100..cdb975d5b316fa2e4768e644384968a5707478d3 100644 (file)
@@ -33,7 +33,7 @@ struct uclass *uclass_find(enum uclass_id key)
         * node to the start of the list, or creating a linear array mapping
         * id to node.
         */
-       list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+       list_for_each_entry(uc, gd->uclass_root, sibling_node) {
                if (uc->uc_drv->id == key)
                        return uc;
        }
@@ -72,16 +72,19 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
        if (!uc)
                return -ENOMEM;
        if (uc_drv->priv_auto) {
-               uc->priv = calloc(1, uc_drv->priv_auto);
-               if (!uc->priv) {
+               void *ptr;
+
+               ptr = calloc(1, uc_drv->priv_auto);
+               if (!ptr) {
                        ret = -ENOMEM;
                        goto fail_mem;
                }
+               uclass_set_priv(uc, ptr);
        }
        uc->uc_drv = uc_drv;
        INIT_LIST_HEAD(&uc->sibling_node);
        INIT_LIST_HEAD(&uc->dev_head);
-       list_add(&uc->sibling_node, &DM_UCLASS_ROOT_NON_CONST);
+       list_add(&uc->sibling_node, DM_UCLASS_ROOT_NON_CONST);
 
        if (uc_drv->init) {
                ret = uc_drv->init(uc);
@@ -94,8 +97,8 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
        return 0;
 fail:
        if (uc_drv->priv_auto) {
-               free(uc->priv);
-               uc->priv = NULL;
+               free(uclass_get_priv(uc));
+               uclass_set_priv(uc, NULL);
        }
        list_del(&uc->sibling_node);
 fail_mem:
@@ -132,7 +135,7 @@ int uclass_destroy(struct uclass *uc)
                uc_drv->destroy(uc);
        list_del(&uc->sibling_node);
        if (uc_drv->priv_auto)
-               free(uc->priv);
+               free(uclass_get_priv(uc));
        free(uc);
 
        return 0;
@@ -160,6 +163,16 @@ const char *uclass_get_name(enum uclass_id id)
        return uc->uc_drv->name;
 }
 
+void *uclass_get_priv(const struct uclass *uc)
+{
+       return uc->priv_;
+}
+
+void uclass_set_priv(struct uclass *uc, void *priv)
+{
+       uc->priv_ = priv;
+}
+
 enum uclass_id uclass_get_by_name(const char *name)
 {
        int i;
@@ -284,8 +297,8 @@ int uclass_find_next_free_seq(struct uclass *uc)
 
        /* Avoid conflict with existing devices */
        list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-               if (dev->sqq > max)
-                       max = dev->sqq;
+               if (dev->seq_ > max)
+                       max = dev->seq_;
        }
        /*
         * At this point, max will be -1 if there are no existing aliases or
@@ -310,8 +323,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq, struct udevice **devp)
                return ret;
 
        uclass_foreach_dev(dev, uc) {
-               log_debug("   - %d '%s'\n", dev->sqq, dev->name);
-               if (dev->sqq == seq) {
+               log_debug("   - %d '%s'\n", dev->seq_, dev->name);
+               if (dev->seq_ == seq) {
                        *devp = dev;
                        log_debug("   - found\n");
                        return 0;
index ed2a54f6ec20f3ba75141f2f156b8999de765b03..897ee855eadee38ee472f5868d93d0cf860bd6f1 100644 (file)
@@ -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",
 };
index 4ce85b322446ba9cef2c45395ea395e7421c2b36..7bed444c3fbf2440c47b97e477ae2f86af4af40a 100644 (file)
@@ -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",
 };
index 868bf142b4d6fe893c641d6d7df66c006a1d0e48..a4ceb36461dcfb00e05d3d0ded3c1ba1ff27736d 100644 (file)
@@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int sdram_mmr_init_full(struct udevice *dev)
 {
-       struct altera_sdram_plat *plat = dev->plat;
+       struct altera_sdram_plat *plat = dev_get_plat(dev);
        struct altera_sdram_priv *priv = dev_get_priv(dev);
        u32 i;
        int ret;
index 3ffe057543fd23599b5e022c61fa348a8da510e5..8d3ce495dead7f9c3a980f64078967ab4b8af37c 100644 (file)
@@ -565,7 +565,7 @@ static unsigned long sdram_calculate_size(struct socfpga_sdr_ctrl *sdr_ctrl)
 
 static int altera_gen5_sdram_of_to_plat(struct udevice *dev)
 {
-       struct altera_gen5_sdram_plat *plat = dev->plat;
+       struct altera_gen5_sdram_plat *plat = dev_get_plat(dev);
 
        plat->sdr = (struct socfpga_sdr *)devfdt_get_addr_index(dev, 0);
        if (!plat->sdr)
@@ -578,7 +578,7 @@ static int altera_gen5_sdram_probe(struct udevice *dev)
 {
        int ret;
        unsigned long sdram_size;
-       struct altera_gen5_sdram_plat *plat = dev->plat;
+       struct altera_gen5_sdram_plat *plat = dev_get_plat(dev);
        struct altera_gen5_sdram_priv *priv = dev_get_priv(dev);
        struct socfpga_sdr_ctrl *sdr_ctrl = &plat->sdr->sdr_ctrl;
        struct reset_ctl_bulk resets;
index 984dc32442d0ad4f1a16976b903fe407fa9d4560..03a270f2639b4808364c091cc9ea8461325e24ea 100644 (file)
@@ -70,7 +70,7 @@ int match_ddr_conf(u32 ddr_conf)
  */
 int sdram_mmr_init_full(struct udevice *dev)
 {
-       struct altera_sdram_plat *plat = dev->plat;
+       struct altera_sdram_plat *plat = dev_get_plat(dev);
        struct altera_sdram_priv *priv = dev_get_priv(dev);
        u32 update_value, io48_value, ddrioctl;
        u32 i;
index 7e77c7b07333a76a0fb5f3f8a81009d316b5767d..5aba655e5f1f5a2e7f091bfc805f42a340f3e356 100644 (file)
@@ -232,7 +232,7 @@ phys_size_t sdram_calculate_size(struct altera_sdram_plat *plat)
 
 static int altera_sdram_of_to_plat(struct udevice *dev)
 {
-       struct altera_sdram_plat *plat = dev->plat;
+       struct altera_sdram_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
 
        addr = dev_read_addr_index(dev, 0);
index b504c31373cbab064ebd9e7c0ce9d46beb1c2259..818f77503a31032e1853a056ab27044f6dee4549 100644 (file)
@@ -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,
 };
index b3d3f0a51b098c39b7260fde731342534abe736f..516e690ac2d5496a98a2731fef70c5369af008e8 100644 (file)
@@ -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;
index acd77b6892ef05c09e47ab42e659e1f32cb89fb9..e6e919444f5fa5fcda9f64030a2949ecb253ea06 100644 (file)
@@ -141,7 +141,7 @@ static int gpio_dwapb_reset(struct udevice *dev)
 static int gpio_dwapb_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *priv = dev_get_uclass_priv(dev);
-       struct gpio_dwapb_plat *plat = dev->plat;
+       struct gpio_dwapb_plat *plat = dev_get_plat(dev);
 
        if (!plat) {
                /* Reset on parent device only */
index 65b18ce6c813aa0e724c74d572772684a79ee552..bad6b71e0c38b78d1c115ad09085808aa95aacbe 100644 (file)
@@ -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",
@@ -1165,7 +1165,7 @@ int gpio_get_number(const struct gpio_desc *desc)
 
        if (!dev)
                return -1;
-       uc_priv = dev->uclass_priv;
+       uc_priv = dev_get_uclass_priv(dev);
 
        return uc_priv->gpio_base + desc->offset;
 }
index f5e5fc6e48a1cb36fe512fde9283e4ed0bdcdb98..04f8d904a2f49100a573954889ca73d9d7f53f85 100644 (file)
@@ -67,7 +67,7 @@ static int hi6220_gpio_probe(struct udevice *dev)
 {
        struct gpio_bank *bank = dev_get_priv(dev);
        struct hikey_gpio_plat *plat = dev_get_plat(dev);
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
        char name[18], *str;
 
        sprintf(name, "GPIO%d_", plat->bank_index);
index 17edd40c5c56c1c847a1b5aa973aa110272ca70c..0e2874ca95c0d2dc4ca2f7e57f4bf486a0a56242 100644 (file)
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <malloc.h>
 
 enum imx_rgpio2p_direction {
@@ -151,13 +152,13 @@ static int imx_rgpio2p_probe(struct udevice *dev)
 
 static int imx_rgpio2p_bind(struct udevice *dev)
 {
-       struct imx_rgpio2p_plat *plat = dev->plat;
+       struct imx_rgpio2p_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
 
        /*
         * 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)
@@ -184,7 +185,7 @@ static int imx_rgpio2p_bind(struct udevice *dev)
 
        plat->regs = (struct gpio_regs *)addr;
        plat->bank_index = dev_seq(dev);
-       dev->plat = plat;
+       dev_set_plat(dev, plat);
 
        return 0;
 }
@@ -215,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] },
index 41540d8ebc63e07206eb73e2b87c6236ae99a296..eda95485c932f7d23a2fba5e46b8853bddc91556 100644 (file)
@@ -188,15 +188,17 @@ static const struct dm_gpio_ops gpio_intel_ops = {
 #endif
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id intel_intel_gpio_ids[] = {
        { .compatible = "intel,gpio" },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_gpio) = {
        .name   = "intel_gpio",
        .id     = UCLASS_GPIO,
-       .of_match = intel_intel_gpio_ids,
+       .of_match = of_match_ptr(intel_intel_gpio_ids),
        .ops    = &gpio_intel_ops,
        .of_to_plat     = intel_gpio_of_to_plat,
        .probe  = intel_gpio_probe,
index ffaec32ac2ba40b808791e85485f9e79a59bee60..de66c765d11e4afcf7d2355c810205e6f16d5df6 100644 (file)
@@ -295,7 +295,7 @@ static const struct dm_gpio_ops gpio_lpc32xx_ops = {
 static int lpc32xx_gpio_probe(struct udevice *dev)
 {
        struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev);
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
        if (dev_of_offset(dev) == -1) {
                /* Tell the uclass how many GPIOs we have */
index 2bc1a0d57160a9a1f3d6d3d3491500833059aa9d..a964347fa32c014f33981170fcb1effcd56eeb6f 100644 (file)
@@ -191,7 +191,7 @@ static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
        u32 i;
        u32 reg[4];
 
-       if (ofnode_read_bool(dev->node, "little-endian"))
+       if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))
                data->little_endian = true;
 
        if (data->little_endian)
@@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev)
        if (!str)
                return -ENOMEM;
 
-       if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) {
+       if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
                unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
                        - sizeof(u32);
 
index 65b4cbf61b9df394d1425ffce15cf0d8195bef2d..43bb4df4da72384319d6afe3dee9e058ed22d0bc 100644 (file)
@@ -130,7 +130,7 @@ static int gpio_mediatek_probe(struct udevice *dev)
  */
 static int gpio_mediatek_bind(struct udevice *parent)
 {
-       struct mediatek_gpio_plat *plat = parent->plat;
+       struct mediatek_gpio_plat *plat = dev_get_plat(parent);
        ofnode node;
        int bank = 0;
        int ret;
index 9fc217ae6ae8d1d45c092e81bc07f0f71c3368ea..06e6b2279f6e3ab6f87521bf9c6319a8dda23773 100644 (file)
@@ -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[] = {
@@ -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] },
index 5ad65e4ee0b0e3dfa43f833a16176ae0b0da1440..4b2b18fdb53878636484c42bb2650dbb6c529fb6 100644 (file)
@@ -264,7 +264,7 @@ static int mxs_gpio_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int mxs_of_to_plat(struct udevice *dev)
 {
-       struct mxs_gpio_plat *plat = dev->plat;
+       struct mxs_gpio_plat *plat = dev_get_plat(dev);
        struct fdtdec_phandle_args args;
        int node = dev_of_offset(dev);
        int ret;
@@ -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 */
index 958516d8f8e3b8b62e66b192b04f9064fd8b5bad..42eae79d8c4227098150e0b4ed61433fbe18a5e9 100644 (file)
@@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev)
                        GPIO_CONST_GPIOS_MASK;
        } else {
                priv->base = dev_remap_addr(dev);
-               uc_priv->gpio_count = ofnode_read_u32_default(dev->node,
+               uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev),
                                                              "nr-gpios", 32);
        }
 
index 400c6ca47241bdbbf29cd581ab7e1c2a136e86bf..336ece47785b9e8d4acf19d471f1af6633fd4d5b 100644 (file)
@@ -22,6 +22,7 @@
 #include <fdtdec.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <linux/errno.h>
 #include <malloc.h>
 
@@ -328,7 +329,7 @@ static int omap_gpio_bind(struct udevice *dev)
 
        plat->base = base_addr;
        plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
-       dev->plat = plat;
+       dev_set_plat(dev, plat);
 
        return 0;
 }
index 9de9541c8757bfbf3234e79fbbfc3c5a52ea4024..796fe3e110431e7dfc694b92af8d22e65c06efad 100644 (file)
@@ -286,8 +286,8 @@ static const struct dm_gpio_ops gpio_exynos_ops = {
 static int gpio_exynos_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
-       struct exynos_bank_info *priv = dev->priv;
-       struct exynos_gpio_plat *plat = dev->plat;
+       struct exynos_bank_info *priv = dev_get_priv(dev);
+       struct exynos_gpio_plat *plat = dev_get_plat(dev);
 
        /* Only child devices have ports */
        if (!plat)
@@ -307,7 +307,7 @@ static int gpio_exynos_probe(struct udevice *dev)
  */
 static int gpio_exynos_bind(struct udevice *parent)
 {
-       struct exynos_gpio_plat *plat = parent->plat;
+       struct exynos_gpio_plat *plat = dev_get_plat(parent);
        struct s5p_gpio_bank *bank, *base;
        const void *blob = gd->fdt_blob;
        int node;
index 2708838adf647bffb2fb2dec4d9a8817fd7eadd4..dc8d506e8d4435e0a6912c6238d0a938383add80 100644 (file)
@@ -11,6 +11,7 @@
 #include <acpi/acpi_device.h>
 #include <asm/gpio.h>
 #include <dm/acpi.h>
+#include <dm/device-internal.h>
 #include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/of.h>
@@ -293,18 +294,19 @@ static int gpio_sandbox_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                /* Tell the uclass how many GPIOs we have */
                uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
 
-       dev->priv = calloc(sizeof(struct gpio_state), uc_priv->gpio_count);
+       dev_set_priv(dev,
+                    calloc(sizeof(struct gpio_state), uc_priv->gpio_count));
 
        return 0;
 }
 
 static int gpio_sandbox_remove(struct udevice *dev)
 {
-       free(dev->priv);
+       free(dev_get_priv(dev));
 
        return 0;
 }
@@ -325,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) */
 
index 75494c78283ff55dce1744f1d97585a7daf7b15f..7633422b0bb81575370627526c28dd01ccc4d6cc 100644 (file)
@@ -285,7 +285,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
 {
        struct sunxi_gpio_soc_data *soc_data =
                (struct sunxi_gpio_soc_data *)dev_get_driver_data(parent);
-       struct sunxi_gpio_plat *plat = parent->plat;
+       struct sunxi_gpio_plat *plat = dev_get_plat(parent);
        struct sunxi_gpio_reg *ctlr;
        int bank, ret;
 
index cd1fb65a55c3418d9f02570e647358f67eb5af50..82dcaf96312ae9a92dcecf4cbfc6fe7416daf439 100644 (file)
@@ -34,7 +34,7 @@ struct tegra186_gpio_plat {
 static uint32_t *tegra186_gpio_reg(struct udevice *dev, uint32_t reg,
                                   uint32_t gpio)
 {
-       struct tegra186_gpio_plat *plat = dev->plat;
+       struct tegra186_gpio_plat *plat = dev_get_plat(dev);
        uint32_t index = (reg + (gpio * TEGRA186_GPIO_PER_GPIO_STRIDE)) / 4;
 
        return &(plat->regs[index]);
@@ -166,7 +166,7 @@ static const struct dm_gpio_ops tegra186_gpio_ops = {
  */
 static int tegra186_gpio_bind(struct udevice *parent)
 {
-       struct tegra186_gpio_plat *parent_plat = parent->plat;
+       struct tegra186_gpio_plat *parent_plat = dev_get_plat(parent);
        struct tegra186_gpio_ctlr_data *ctlr_data =
                (struct tegra186_gpio_ctlr_data *)dev_get_driver_data(parent);
        uint32_t *regs;
@@ -201,7 +201,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
 
 static int tegra186_gpio_probe(struct udevice *dev)
 {
-       struct tegra186_gpio_plat *plat = dev->plat;
+       struct tegra186_gpio_plat *plat = dev_get_plat(dev);
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
        /* Only child devices have ports */
index c489796f77c4c44649d6b26430b7ac997d24d579..5d3af8a016da431fb084bb8383accc3900234228 100644 (file)
@@ -291,8 +291,8 @@ static const struct udevice_id tegra_gpio_ids[] = {
 static int gpio_tegra_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
-       struct tegra_port_info *priv = dev->priv;
-       struct tegra_gpio_plat *plat = dev->plat;
+       struct tegra_port_info *priv = dev_get_priv(dev);
+       struct tegra_gpio_plat *plat = dev_get_plat(dev);
 
        /* Only child devices have ports */
        if (!plat)
@@ -313,7 +313,7 @@ static int gpio_tegra_probe(struct udevice *dev)
  */
 static int gpio_tegra_bind(struct udevice *parent)
 {
-       struct tegra_gpio_plat *plat = parent->plat;
+       struct tegra_gpio_plat *plat = dev_get_plat(parent);
        struct gpio_ctlr *ctlr;
        int bank_count;
        int bank;
index 18eef625f0f2faf7fd8c11b63455aff2b1529555..ec0cdf622076e84c11b9db7ee295ffc355963240 100644 (file)
@@ -92,7 +92,7 @@ static int designware_i2c_pci_bind(struct udevice *dev)
 {
        char name[20];
 
-       if (dev_of_valid(dev))
+       if (dev_has_ofnode(dev))
                return 0;
 
        sprintf(name, "i2c_designware#%u", dev_seq(dev));
@@ -152,7 +152,7 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
        int ret;
 
        /* If no device-tree node, ignore this since we assume it isn't used */
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        ret = acpi_device_path(dev, path, sizeof(path));
index 456cf3b85fb2800fb5d6bafa1e334a98d47461bf..be56785217c3bc51d7da1e7647a845034f2b05eb 100644 (file)
@@ -678,7 +678,7 @@ static int i2c_child_post_bind(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
        struct dm_i2c_chip *plat = dev_get_parent_plat(dev);
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
        return i2c_chip_of_to_plat(dev, plat);
 #else
index 704bafe23890bf7300b10f4506aa67f4db1b3574..f8fac45b6ca0b8786e00e080b63731fd993ca783 100644 (file)
@@ -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)
index a61dfc096b3fa4b399dbc1366b7d9cc012bd5a75..c99e6de933279f1925be81042037ea957c7b66d6 100644 (file)
 #include <errno.h>
 #include <i2c.h>
 #include <log.h>
+#include <asm/i2c.h>
 #include <asm/test.h>
 #include <dm/acpi.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 
-struct sandbox_i2c_priv {
-       bool test_mode;
-};
-
 static int get_emul(struct udevice *dev, struct udevice **devp,
                    struct dm_i2c_ops **opsp)
 {
index 29432ae7eb43ac851a4688543769fb6a9d8f8ae6..7d2a2997797fdd8a6e1c9825dbaca95e793612eb 100644 (file)
@@ -343,6 +343,15 @@ config TEGRA186_BPMP
          can make requests to the BPMP. This driver is similar to an MFD
          driver in the Linux kernel.
 
+config TEST_DRV
+       bool "Enable support for test drivers"
+       default y if SANDBOX
+       help
+         This enables drivers and uclasses that provides a way of testing the
+         operations of memory allocation and driver/uclass methods in driver
+         model. This should only be enabled for testing as it is not useful for
+         anything else.
+
 config TWL4030_LED
        bool "Enable TWL4030 LED controller"
        help
index 947bd3a647f33a5c1f93bb09fceb23cc6948c209..d7372037045b99aa9e06b82217050adc34beba43 100644 (file)
@@ -67,6 +67,7 @@ obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
 obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
 obj-$(CONFIG_TEGRA186_BPMP) += tegra186_bpmp.o
 obj-$(CONFIG_TEGRA_CAR) += tegra_car.o
+obj-$(CONFIG_TEST_DRV) += test_drv.o
 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
 obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o
 obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
index 057b431c2545f64a2dfce7d45c58d0dc14257b9e..878df12771c8d72907e1ee86d2de5cb068fd2039 100644 (file)
@@ -59,7 +59,7 @@ U_BOOT_CMD(
 static int altera_sysid_read(struct udevice *dev,
                             int offset, void *buf, int size)
 {
-       struct altera_sysid_plat *plat = dev->plat;
+       struct altera_sysid_plat *plat = dev_get_plat(dev);
        struct altera_sysid_regs *const regs = plat->regs;
        u32 *sysid = buf;
 
index b3bb537c59b19a841ff91291fb3d07159141929d..9fd6cc2086ccab1b50c18700f0f2a593848e3f24 100644 (file)
@@ -520,8 +520,8 @@ void cros_ec_check_keyboard(struct udevice *dev)
 
 int cros_ec_probe(struct udevice *dev)
 {
-       struct ec_state *ec = dev->priv;
-       struct cros_ec_dev *cdev = dev->uclass_priv;
+       struct ec_state *ec = dev_get_priv(dev);
+       struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
        struct udevice *keyb_dev;
        ofnode node;
        int err;
index 5ed8ab6530f504826f47b6fd7df2125e56fa9579..f460b1a64c8a785b152d67543020c565cf14970d 100644 (file)
@@ -161,7 +161,7 @@ static int fw_get_filesystem_firmware(struct udevice *dev)
                else
                        ret = -ENODEV;
        } else {
-               ret = select_fs_dev(dev->plat);
+               ret = select_fs_dev(dev_get_plat(dev));
        }
 
        if (ret)
@@ -228,7 +228,7 @@ static int fs_loader_of_to_plat(struct udevice *dev)
        if (ofnode_valid(fs_loader_node)) {
                struct device_plat *plat;
 
-               plat = dev->plat;
+               plat = dev_get_plat(dev);
                if (!ofnode_read_u32_array(fs_loader_node,
                                          "phandlepart",
                                          phandlepart, 2)) {
@@ -250,7 +250,7 @@ static int fs_loader_probe(struct udevice *dev)
 {
 #if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(BLK)
        int ret;
-       struct device_plat *plat = dev->plat;
+       struct device_plat *plat = dev_get_plat(dev);
 
        if (plat->phandlepart.phandle) {
                ofnode node = ofnode_get_by_phandle(plat->phandlepart.phandle);
index 9ffd28f597d941f729d9da42f738c883ce29e59c..5926c91a2ec9c777e053ee76a0aff25aed233b59 100644 (file)
@@ -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);
        }
 
index 8f9ec027a2e87c7693216b56413d02c2b531639f..ac2852559f57cf629ce5e25bf2a2d4cfddb5c273 100644 (file)
@@ -168,26 +168,11 @@ int p2sb_get_port_id(struct udevice *dev)
 
 int p2sb_set_port_id(struct udevice *dev, int portid)
 {
-       struct udevice *ps2b;
        struct p2sb_child_plat *pplat;
 
        if (!CONFIG_IS_ENABLED(OF_PLATDATA))
                return -ENOSYS;
 
-       if (!CONFIG_IS_ENABLED(OF_PLATDATA_PARENT)) {
-               uclass_find_first_device(UCLASS_P2SB, &ps2b);
-               if (!ps2b)
-                       return -EDEADLK;
-               dev->parent = ps2b;
-
-               /*
-                * We must allocate this, since when the device was bound it did
-                * not have a parent.
-                */
-               dev->parent_plat = malloc(sizeof(*pplat));
-               if (!dev->parent_plat)
-                       return -ENOMEM;
-       }
        pplat = dev_get_parent_plat(dev);
        pplat->pid = portid;
 
index be25389e0e35d0b0b3fde91ce8e3215290e77ce1..083ee65e0ad71f6e9a9ec94ed077bdfeca69d209 100644 (file)
@@ -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;
index 3ae6707593e57bf3a738af7f227655e711644014..6b9701a06aee68aec7b981fdba3971831f421941 100644 (file)
@@ -8,8 +8,14 @@
 #include <dm.h>
 #include <dt-structs.h>
 
+static const struct udevice_id sandbox_spl_ids[] = {
+       { .compatible = "sandbox,spl-test", },
+       {}  /* sentinel */
+};
+
 U_BOOT_DRIVER(sandbox_spl_test) = {
        .name   = "sandbox_spl_test",
        .id     = UCLASS_MISC,
+       .of_match = sandbox_spl_ids,
        .flags  = DM_FLAG_PRE_RELOC,
 };
index 0eed3459734b0a0711eb2f17f975b871447df80b..9fd6c367dc61bc4d58e5742f8cebb09648484131 100644 (file)
@@ -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;
index abea0e761397d4879eda4b513d26d008819e9958..3cbc8f37ec5025758240a5d87b39335b709f58fc 100644 (file)
@@ -54,7 +54,7 @@ struct swap_case_priv {
 
 static int sandbox_swap_case_use_ea(const struct udevice *dev)
 {
-       return !!ofnode_get_property(dev->node, "use-ea", NULL);
+       return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL);
 }
 
 /* Please keep these macros in sync with ea_regs below */
diff --git a/drivers/misc/test_drv.c b/drivers/misc/test_drv.c
new file mode 100644 (file)
index 0000000..7dd3de3
--- /dev/null
@@ -0,0 +1,222 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2014 Google, Inc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+
+/* Records the last testbus device that was removed */
+static struct udevice *testbus_removed;
+
+struct udevice *testbus_get_clear_removed(void)
+{
+       struct udevice *removed = testbus_removed;
+
+       testbus_removed = NULL;
+
+       return removed;
+}
+
+static int testbus_drv_probe(struct udevice *dev)
+{
+       if (!CONFIG_IS_ENABLED(OF_PLATDATA)) {
+               int ret;
+
+               ret = dm_scan_fdt_dev(dev);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
+static int testbus_child_post_bind(struct udevice *dev)
+{
+       struct dm_test_parent_plat *plat;
+
+       plat = dev_get_parent_plat(dev);
+       plat->bind_flag = 1;
+       plat->uclass_bind_flag = 2;
+
+       return 0;
+}
+
+static int testbus_child_pre_probe(struct udevice *dev)
+{
+       struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
+
+       parent_data->flag += TEST_FLAG_CHILD_PROBED;
+
+       return 0;
+}
+
+static int testbus_child_pre_probe_uclass(struct udevice *dev)
+{
+       struct dm_test_priv *priv = dev_get_priv(dev);
+
+       priv->uclass_flag++;
+
+       return 0;
+}
+
+static int testbus_child_post_probe_uclass(struct udevice *dev)
+{
+       struct dm_test_priv *priv = dev_get_priv(dev);
+
+       priv->uclass_postp++;
+
+       return 0;
+}
+
+static int testbus_child_post_remove(struct udevice *dev)
+{
+       struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
+
+       parent_data->flag += TEST_FLAG_CHILD_REMOVED;
+       testbus_removed = dev;
+
+       return 0;
+}
+
+static const struct udevice_id testbus_ids[] = {
+       { .compatible = "denx,u-boot-test-bus", .data = DM_TEST_TYPE_FIRST },
+       { }
+};
+
+U_BOOT_DRIVER(testbus_drv) = {
+       .name   = "testbus_drv",
+       .of_match       = testbus_ids,
+       .id     = UCLASS_TEST_BUS,
+       .probe  = testbus_drv_probe,
+       .child_post_bind = testbus_child_post_bind,
+       .priv_auto      = sizeof(struct dm_test_priv),
+       .plat_auto      = sizeof(struct dm_test_pdata),
+       .per_child_auto = sizeof(struct dm_test_parent_data),
+       .per_child_plat_auto    = sizeof(struct dm_test_parent_plat),
+       .child_pre_probe = testbus_child_pre_probe,
+       .child_post_remove = testbus_child_post_remove,
+};
+
+UCLASS_DRIVER(testbus) = {
+       .name           = "testbus",
+       .id             = UCLASS_TEST_BUS,
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
+       .child_pre_probe = testbus_child_pre_probe_uclass,
+       .child_post_probe = testbus_child_post_probe_uclass,
+};
+
+static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
+{
+       const struct dm_test_pdata *pdata = dev_get_plat(dev);
+       struct dm_test_priv *priv = dev_get_priv(dev);
+
+       *pingret = pingval + pdata->ping_add;
+       priv->ping_total += *pingret;
+
+       return 0;
+}
+
+static const struct test_ops test_ops = {
+       .ping = testfdt_drv_ping,
+};
+
+static int testfdt_of_to_plat(struct udevice *dev)
+{
+       struct dm_test_pdata *pdata = dev_get_plat(dev);
+
+       pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                                        "ping-add", -1);
+       pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
+                                     "ping-expect");
+
+       return 0;
+}
+
+static int testfdt_drv_probe(struct udevice *dev)
+{
+       struct dm_test_priv *priv = dev_get_priv(dev);
+
+       priv->ping_total += DM_TEST_START_TOTAL;
+
+       /*
+        * If this device is on a bus, the uclass_flag will be set before
+        * calling this function. In the meantime the uclass_postp is
+        * initlized to a value -1. These are used respectively by
+        * dm_test_bus_child_pre_probe_uclass() and
+        * dm_test_bus_child_post_probe_uclass().
+        */
+       priv->uclass_total += priv->uclass_flag;
+       priv->uclass_postp = -1;
+
+       return 0;
+}
+
+static const struct udevice_id testfdt_ids[] = {
+       { .compatible = "denx,u-boot-fdt-test", .data = DM_TEST_TYPE_FIRST },
+       { .compatible = "google,another-fdt-test", .data = DM_TEST_TYPE_SECOND },
+       { }
+};
+
+U_BOOT_DRIVER(testfdt_drv) = {
+       .name   = "testfdt_drv",
+       .of_match       = testfdt_ids,
+       .id     = UCLASS_TEST_FDT,
+       .of_to_plat = testfdt_of_to_plat,
+       .probe  = testfdt_drv_probe,
+       .ops    = &test_ops,
+       .priv_auto      = sizeof(struct dm_test_priv),
+       .plat_auto      = sizeof(struct dm_test_pdata),
+};
+
+static const struct udevice_id testfdt1_ids[] = {
+       { .compatible = "denx,u-boot-fdt-test1", .data = DM_TEST_TYPE_FIRST },
+       { }
+};
+
+U_BOOT_DRIVER(testfdt1_drv) = {
+       .name   = "testfdt1_drv",
+       .of_match       = testfdt1_ids,
+       .id     = UCLASS_TEST_FDT,
+       .of_to_plat = testfdt_of_to_plat,
+       .probe  = testfdt_drv_probe,
+       .ops    = &test_ops,
+       .priv_auto      = sizeof(struct dm_test_priv),
+       .plat_auto      = sizeof(struct dm_test_pdata),
+       .flags = DM_FLAG_PRE_RELOC,
+};
+
+/* From here is the testfdt uclass code */
+int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
+{
+       const struct test_ops *ops = device_get_ops(dev);
+
+       if (!ops->ping)
+               return -ENOSYS;
+
+       return ops->ping(dev, pingval, pingret);
+}
+
+UCLASS_DRIVER(testfdt) = {
+       .name           = "testfdt",
+       .id             = UCLASS_TEST_FDT,
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
+};
+
+static const struct udevice_id testfdtm_ids[] = {
+       { .compatible = "denx,u-boot-fdtm-test" },
+       { }
+};
+
+U_BOOT_DRIVER(testfdtm_drv) = {
+       .name   = "testfdtm_drv",
+       .of_match       = testfdtm_ids,
+       .id     = UCLASS_TEST_FDT_MANUAL,
+};
+
+UCLASS_DRIVER(testfdtm) = {
+       .name           = "testfdtm",
+       .id             = UCLASS_TEST_FDT_MANUAL,
+       .flags          = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
+};
index 02e5b586e2971ac9ba8394e885d1267ccb81767f..2baca48109f9155cd08369de9b4bc5da6a8dbc6f 100644 (file)
@@ -109,7 +109,7 @@ static int vexpress_config_probe(struct udevice *dev)
        if (!priv)
                return -ENOMEM;
 
-       dev->uclass_priv = priv;
+       dev_get_uclass_priv(dev) = priv;
        priv->addr = ofnode_get_addr(args.node);
 
        return dev_read_u32(dev, "arm,vexpress,site", &priv->site);
index fe406fe4ad769f014f799890f150fc8ad96b6b70..b2d1b4f9aa9a9a077bd79708c0cec1f2818f27c1 100644 (file)
@@ -421,7 +421,7 @@ static int arm_pl180_mmc_probe(struct udevice *dev)
        struct arm_pl180_mmc_plat *pdata = dev_get_plat(dev);
        struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
        struct mmc *mmc = &pdata->mmc;
-       struct pl180_mmc_host *host = dev->priv;
+       struct pl180_mmc_host *host = dev_get_priv(dev);
        struct mmc_config *cfg = &pdata->cfg;
        struct clk clk;
        u32 bus_width;
@@ -508,7 +508,7 @@ static int dm_host_set_ios(struct udevice *dev)
 
 static int dm_mmc_getcd(struct udevice *dev)
 {
-       struct pl180_mmc_host *host = dev->priv;
+       struct pl180_mmc_host *host = dev_get_priv(dev);
        int value = 1;
 
        if (dm_gpio_is_valid(&host->cd_gpio))
@@ -525,7 +525,7 @@ static const struct dm_mmc_ops arm_pl180_dm_mmc_ops = {
 
 static int arm_pl180_mmc_of_to_plat(struct udevice *dev)
 {
-       struct pl180_mmc_host *host = dev->priv;
+       struct pl180_mmc_host *host = dev_get_priv(dev);
        fdt_addr_t addr;
 
        addr = dev_read_addr(dev);
index 01a94428e70d6329513942b3aec43751fe059d15..f47a095c50fb38227272c4977dd926fb095c82c6 100644 (file)
@@ -1742,5 +1742,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
index 143818d4018a2d931f545e559ef683b8ac9bfeba..8fd41764152fa291e6908057a097e008f139aa6a 100644 (file)
@@ -668,7 +668,7 @@ static const struct dm_mmc_ops mxsmmc_ops = {
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int mxsmmc_of_to_plat(struct udevice *bus)
 {
-       struct mxsmmc_plat *plat = bus->plat;
+       struct mxsmmc_plat *plat = dev_get_plat(bus);
        u32 prop[2];
        int ret;
 
@@ -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 */
index 5552342f8d9e441ac9d1488c80479f1b458001be..442ca493d76b75b982fa02b36de62fb7896141a4 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/csrs/csrs-mio_emm.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 
 #include <power/regulator.h>
 
@@ -3438,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage)
  */
 static bool octeontx_mmc_get_valid(struct udevice *dev)
 {
-       const char *stat = ofnode_read_string(dev->node, "status");
+       const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
 
        if (!stat || !strncmp(stat, "ok", 2))
                return true;
@@ -3460,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev)
        uint low, high;
        char env_name[32];
        int err;
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
        int bus_width = 1;
        ulong new_max_freq;
 
        debug("%s(%s)", __func__, dev->name);
        slot->cfg.name = dev->name;
 
-       slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency",
+       slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
+                                                 "max-frequency",
                                                  26000000);
        snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
                 slot->bus_id);
@@ -3485,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 
        if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
                slot->hs400_tuning_block =
-                       ofnode_read_s32_default(dev->node,
+                       ofnode_read_s32_default(dev_ofnode(dev),
                                                "marvell,hs400-tuning-block",
                                                -1);
                debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
                      dev->name, slot->hs400_tuning_block);
 
                slot->hs200_tap_adj =
-                       ofnode_read_s32_default(dev->node,
+                       ofnode_read_s32_default(dev_ofnode(dev),
                                                "marvell,hs200-tap-adjust", 0);
                debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
                      slot->hs200_tap_adj);
                slot->hs400_tap_adj =
-                       ofnode_read_s32_default(dev->node,
+                       ofnode_read_s32_default(dev_ofnode(dev),
                                                "marvell,hs400-tap-adjust", 0);
                debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
                      slot->hs400_tap_adj);
        }
 
-       err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2);
+       err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
+                                   voltages, 2);
        if (err) {
                slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
        } else {
@@ -3751,18 +3754,19 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
        host->dev = dev;
        debug("%s(%s): Base address: %p\n", __func__, dev->name,
              host->base_addr);
-       if (!dev_has_of_node(dev)) {
+       if (!dev_has_ofnode(dev)) {
                pr_err("%s: No device tree information found\n", __func__);
                return -1;
        }
-       host->node = dev->node;
+       host->node = dev_ofnode(dev);
        host->last_slotid = -1;
        if (otx_is_platform(PLATFORM_ASIM))
                host->is_asim = true;
        if (otx_is_platform(PLATFORM_EMULATOR))
                host->is_emul = true;
        host->dma_wait_delay =
-               ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1);
+               ofnode_read_u32_default(dev_ofnode(dev),
+                                       "marvell,dma-wait-delay", 1);
        /* Force reset of eMMC */
        writeq(0, host->base_addr + MIO_EMM_CFG());
        debug("%s: Clearing MIO_EMM_CFG\n", __func__);
@@ -3823,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
        struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
        struct octeontx_mmc_slot *slot;
        struct mmc_uclass_priv *upriv;
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
        u32 bus_id;
        char name[16];
        int err;
@@ -3841,7 +3845,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
        }
 
        slot = &host->slots[bus_id];
-       dev->priv = slot;
+       dev_set_priv(dev, slot);
        slot->host = host;
        slot->bus_id = bus_id;
        slot->dev = dev;
@@ -3852,16 +3856,21 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
        snprintf(name, sizeof(name), "octeontx-mmc%d", bus_id);
        err = device_set_name(dev, name);
 
-       if (!dev->uclass_priv) {
+       /* FIXME: This code should not be needed */
+       if (!dev_get_uclass_priv(dev)) {
                debug("%s(%s): Allocating uclass priv\n", __func__,
                      dev->name);
                upriv = calloc(1, sizeof(struct mmc_uclass_priv));
                if (!upriv)
                        return -ENOMEM;
-               dev->uclass_priv = upriv;
-               dev->uclass->priv = upriv;
+
+               /*
+                * FIXME: This is not allowed
+                * dev_set_uclass_priv(dev, upriv);
+                * uclass_set_priv(dev->uclass, upriv);
+                */
        } else {
-               upriv = dev->uclass_priv;
+               upriv = dev_get_uclass_priv(dev);
        }
 
        upriv->mmc = &slot->mmc;
@@ -3878,6 +3887,7 @@ static const struct udevice_id octeontx_hsmmc_host_ids[] = {
 
 U_BOOT_DRIVER(octeontx_hsmmc_host) = {
        .name   = "octeontx_hsmmc_host",
+       /* FIXME: Why is this not UCLASS_MMC? */
        .id     = UCLASS_MISC,
        .of_match = of_match_ptr(octeontx_hsmmc_host_ids),
        .probe  = octeontx_mmc_host_probe,
index fc09ad99e5ead95002d3889808b603e7fb54df76..c71c495d581f2ac6bc7ea4dd597e9c2748a6898d 100644 (file)
@@ -75,7 +75,7 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
        struct acpi_dp *dp;
        int ret;
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        ret = gpio_get_acpi(&priv->cd_gpio, &gpio);
index 75db81ba4caadcd7eb3cd509fc755c8815449889..1be3c1741fd4db2d27d606030e189901fe0be061 100644 (file)
@@ -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)
index d4e8f8df87d83a964e6fd777100e3b2d27ef3d52..4621bfb03e385c3b4be9a731aece8a323918340d 100644 (file)
@@ -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);
 }
index 71682cb6e79a28e3c2e0531a59967b06d2dcbb29..aa095c439ba1b4b55624295d32e64cddd94fcf38 100644 (file)
@@ -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);
index f424194ecca7bf09691a8fc69e3d0a9eb68b004d..e4bf1936810a52bfd685d338459fcf12a3accf5e 100644 (file)
@@ -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);
index 47ddde4f9b0c13db82cab43fd4750af747131d83..586ea3d8fbb48aea67aaab2b189d60e97ccaf63a 100644 (file)
@@ -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);
index 646495096c2d61c9519ab496b94371f952f56625..85f318bd779a7a4ad5784bf0c88e16aa998e9209 100644 (file)
@@ -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);
index 7573cd944ff56e1d7a86134402350a371c9d5267..a5e159ad521fc2cd753f99f0d66b52bc674cf967 100644 (file)
@@ -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);
index 4645cc16997dc2782356b537903b4a548440013d..9ad3a57690e5be6b063fd6069d390550b74232da 100644 (file)
@@ -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);
 }
index 140ef7f725ee71e60a87a593b25d8ad70c21616f..cf4df0168a31e1754c080bea33362bc208a0c2cd 100644 (file)
@@ -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",
index 78a423dbbf4ae6f649d096f8c1b54b534770f410..878796d5552aadc6b214e4dcf4e88107962d4204 100644 (file)
@@ -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",
index b1ed4d910a76e95bb2aa4f2162567ec745f4c0a0..9997135ef937c4f5a3d53eaeef294034fff1b42a 100644 (file)
@@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev,
 static int octeontx_nfc_chips_init(struct octeontx_nfc *tn)
 {
        struct udevice *dev = tn->dev;
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
        ofnode nand_node;
        int nr_chips = of_get_child_count(node);
        int ret;
@@ -2187,7 +2187,7 @@ int octeontx_pci_nand_deferred_probe(void)
        debug("%s: Performing deferred probing\n", __func__);
        list_for_each_entry(pdev, &octeontx_pci_nand_deferred_devices, list) {
                debug("%s: Probing %s\n", __func__, pdev->dev->name);
-               pdev->dev->flags &= ~DM_FLAG_ACTIVATED;
+               dev_get_flags(pdev->dev) &= ~DM_FLAG_ACTIVATED;
                rc = device_probe(pdev->dev);
                if (rc && rc != -ENODEV) {
                        printf("%s: Error %d with deferred probe of %s\n",
@@ -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",
index e923ce363a0879c268f71c8144ab347d28327ff3..f6233756d853dc555eb29a575756b60a3f035ec0 100644 (file)
@@ -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);
index 8fe7ec1343e62d15128b3e49a6774e0aa9671e8a..b8561b2516c523eea8272ba23613a0bb8a0a45c2 100644 (file)
@@ -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",
index 797fc23050442385259223d25aa5d33220497719..a530127cb7793d06ecba587be5b30cfa5a810127 100644 (file)
@@ -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);
index 422b9c57a88c54348094cd33fb9e8d8a91a1a047..e33953ec7c64b5f747d8af394288abef162e9150 100644 (file)
@@ -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",
index 7cf0ccb656c283a85ec97aaae4b923004b7335b4..15d4a238e6f3afb11aaf66341a4a37e8c9c2e157 100644 (file)
@@ -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);
 }
index 09bfde66853def948cab1f59b3a769468aff4663..68ef5d1af8dabb6b51e057ba60562df12f103ed1 100644 (file)
@@ -1165,7 +1165,7 @@ static int spinand_probe(struct udevice *dev)
                return -ENOMEM;
        sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
        spinand->slave = slave;
-       spinand_set_of_node(spinand, dev->node.np);
+       spinand_set_ofnode(spinand, dev_ofnode(dev));
 #endif
 
        ret = spinand_init(spinand);
index ed629f1d4581f8051cb63a18a069ef6fcc114ffd..3017022abbbc193a64b5050d7ca27097b39b9494 100644 (file)
@@ -100,5 +100,5 @@ UCLASS_DRIVER(spi_flash) = {
        .id             = UCLASS_SPI_FLASH,
        .name           = "spi_flash",
        .post_bind      = spi_flash_post_bind,
-       .per_device_auto        = sizeof(struct spi_flash),
+       .per_device_auto        = sizeof(struct spi_nor),
 };
index c8bcec3c5890c7654211c9b49ee2361f5b9fb1b2..6c874348676af130fab8e7bf947c1792ba829824 100644 (file)
@@ -166,10 +166,10 @@ U_BOOT_DRIVER(jedec_spi_nor) = {
        .of_match       = spi_flash_std_ids,
        .probe          = spi_flash_std_probe,
        .remove         = spi_flash_std_remove,
-       .priv_auto      = sizeof(struct spi_flash),
+       .priv_auto      = sizeof(struct 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 */
index b9868505a3be5bcec0e0612475b4e6d44c0f6966..00e0282dcc0e194dc03739bd090979734e5206b6 100644 (file)
@@ -12,6 +12,7 @@
 #include <regmap.h>
 #include <syscon.h>
 #include <dm/device.h>
+#include <dm/device-internal.h>
 #include <dm/device_compat.h>
 #include <dm/read.h>
 #include <dm/devres.h>
@@ -68,7 +69,7 @@ static int mmio_mux_probe(struct udevice *dev)
        fields = devm_kmalloc(dev, num_fields * sizeof(*fields), __GFP_ZERO);
        if (!fields)
                return -ENOMEM;
-       dev->priv = fields;
+       dev_set_priv(dev, fields);
 
        mux_reg_masks = devm_kmalloc(dev, num_fields * 2 * sizeof(u32),
                                     __GFP_ZERO);
index 65615f131034ccf93ec9a62279f2d29aba1e821d..07aebd935e67005c742e277e928eca65790133af 100644 (file)
@@ -54,7 +54,7 @@ int eth_phy_set_mdio_bus(struct udevice *eth_dev, struct mii_dev *mdio_bus)
        for (uclass_first_device(UCLASS_ETH_PHY, &dev); dev;
             uclass_next_device(&dev)) {
                if (dev->parent == eth_dev) {
-                       uc_priv = (struct eth_phy_device_priv *)(dev->uclass_priv);
+                       uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(dev));
 
                        if (!uc_priv->mdio_bus)
                                uc_priv->mdio_bus = mdio_bus;
@@ -79,7 +79,7 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)
                         * phy_dev is shared and controlled by
                         * other eth controller
                         */
-                       uc_priv = (struct eth_phy_device_priv *)(phy_dev->uclass_priv);
+                       uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(phy_dev));
                        if (uc_priv->mdio_bus)
                                printf("Get shared mii bus on %s\n", eth_dev->name);
                        else
index 02ccf1efc3b3171edf9db5ff0212e8be05137475..0e89e663f716cbf977dd9707d6eb5f25c529243e 100644 (file)
@@ -547,7 +547,11 @@ static void fm_eth_halt(struct udevice *dev)
        struct fm_eth *fm_eth;
        struct fsl_enet_mac *mac;
 
+#ifndef CONFIG_DM_ETH
        fm_eth = (struct fm_eth *)dev->priv;
+#else
+       fm_eth = dev_get_priv(dev);
+#endif
        mac = fm_eth->mac;
 
        /* graceful stop the transmission of frames */
@@ -577,7 +581,11 @@ static int fm_eth_send(struct udevice *dev, void *buf, int len)
        u16 offset_in;
        int i;
 
+#ifndef CONFIG_DM_ETH
        fm_eth = (struct fm_eth *)dev->priv;
+#else
+       fm_eth = dev_get_priv(dev);
+#endif
        pram = fm_eth->tx_pram;
        txbd = fm_eth->cur_txbd;
 
@@ -664,13 +672,19 @@ static int fm_eth_recv(struct eth_device *dev)
 static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 #endif
 {
-       struct fm_eth *fm_eth = (struct fm_eth *)dev->priv;
-       struct fm_port_bd *rxbd = fm_eth->cur_rxbd;
+       struct fm_eth *fm_eth;
+       struct fm_port_bd *rxbd;
        u32 buf_lo, buf_hi;
        u16 status, len;
        int ret = -1;
        u8 *data;
 
+#ifndef CONFIG_DM_ETH
+       fm_eth = (struct fm_eth *)dev->priv;
+#else
+       fm_eth = dev_get_priv(dev);
+#endif
+       rxbd = fm_eth->cur_rxbd;
        status = muram_readw(&rxbd->status);
 
        while (!(status & RxBD_EMPTY)) {
@@ -704,7 +718,7 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 #ifdef CONFIG_DM_ETH
 static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length)
 {
-       struct fm_eth *fm_eth = (struct fm_eth *)dev->priv;
+       struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev);
 
        fm_eth->cur_rxbd = fm_eth_free_one(fm_eth, fm_eth->cur_rxbd);
 
@@ -943,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev)
 {
        const char *if_str;
 
-       if_str = ofnode_read_string(dev->node, "phy-connection-type");
+       if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
        debug("MAC system interface mode %s\n", if_str);
 
        return phy_get_interface_by_name(if_str);
@@ -955,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev)
        char mac_name[11];
        u32 fm, num;
 
-       if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) {
+       if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) {
                printf("FMan node property cell-index missing\n");
                return -EINVAL;
        }
@@ -1004,7 +1018,7 @@ static struct udevice *fm_get_internal_mdio(struct udevice *dev)
 
 static int fm_eth_probe(struct udevice *dev)
 {
-       struct fm_eth *fm_eth = (struct fm_eth *)dev->priv;
+       struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev);
        struct ofnode_phandle_args args;
        void *reg;
        int ret, index;
index 2e684e58393ea410e7c725c52df358e8001e2263..f6fc7801b95bca2c2d4622f76a915dec8c462955 100644 (file)
@@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev)
         * and some are not, use different naming scheme - enetc-N based on
         * PCI function # and enetc#N based on interface count
         */
-       if (ofnode_valid(dev->node))
+       if (ofnode_valid(dev_ofnode(dev)))
                sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
        else
                sprintf(name, "enetc#%u", eth_num_devices++);
@@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev)
                        mdio_register(&priv->imdio);
        }
 
-       if (!ofnode_valid(dev->node)) {
+       if (!ofnode_valid(dev_ofnode(dev))) {
                enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
                return;
        }
 
-       if_str = ofnode_read_string(dev->node, "phy-mode");
+       if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
        if (if_str)
                priv->if_type = phy_get_interface_by_name(if_str);
        else
@@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev)
 {
        struct enetc_priv *priv = dev_get_priv(dev);
 
-       if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
+       if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
                enetc_dbg(dev, "interface disabled\n");
                return -ENODEV;
        }
index 4da97b61d173c36f37c7762c5c6bcf58215e4bf8..3eb6ac9fc8f036c40dcad7a70d36873017a63b0e 100644 (file)
@@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev)
         * and some are not, use different naming scheme - enetc-N based on
         * PCI function # and enetc#N based on interface count
         */
-       if (ofnode_valid(dev->node))
+       if (ofnode_valid(dev_ofnode(dev)))
                sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev)));
        else
                sprintf(name, "emdio#%u", eth_num_devices++);
index 0196462beb4ca53480f9aa6e6ca75ac485376aee..c36d40c911129d20aef4154c547db8122da2f7a4 100644 (file)
@@ -79,7 +79,7 @@ static void init_eth_info(struct fec_info_dma *info)
 
 static void fec_halt(struct udevice *dev)
 {
-       struct fec_info_dma *info = dev->priv;
+       struct fec_info_dma *info = dev_get_priv(dev);
        volatile fecdma_t *fecp = (fecdma_t *)info->iobase;
        int counter = 0xffff;
 
@@ -230,7 +230,7 @@ static void fec_set_hwaddr(volatile fecdma_t *fecp, u8 *mac)
 
 static int fec_init(struct udevice *dev)
 {
-       struct fec_info_dma *info = dev->priv;
+       struct fec_info_dma *info = dev_get_priv(dev);
        volatile fecdma_t *fecp = (fecdma_t *)info->iobase;
        int rval, i;
        uchar enetaddr[6];
@@ -352,7 +352,7 @@ static int mcdmafec_init(struct udevice *dev)
 
 static int mcdmafec_send(struct udevice *dev, void *packet, int length)
 {
-       struct fec_info_dma *info = dev->priv;
+       struct fec_info_dma *info = dev_get_priv(dev);
        cbd_t *p_tbd, *p_used_tbd;
        u16 phy_status;
 
@@ -412,7 +412,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length)
 
 static int mcdmafec_recv(struct udevice *dev, int flags, uchar **packetp)
 {
-       struct fec_info_dma *info = dev->priv;
+       struct fec_info_dma *info = dev_get_priv(dev);
        volatile fecdma_t *fecp = (fecdma_t *)info->iobase;
 
        cbd_t *prbd = &info->rxbd[info->rx_idx];
@@ -496,7 +496,7 @@ static const struct eth_ops mcdmafec_ops = {
  */
 static int mcdmafec_probe(struct udevice *dev)
 {
-       struct fec_info_dma *info = dev->priv;
+       struct fec_info_dma *info = dev_get_priv(dev);
        struct eth_pdata *pdata = dev_get_plat(dev);
        int node = dev_of_offset(dev);
        int retval;
index 4fa71360cf41536a0b8b3b6272acc0efe9841e72..cb343b446f59e5d4dfae3cf46b243c19d5c1f18c 100644 (file)
@@ -125,7 +125,7 @@ static void set_fec_duplex_speed(volatile fec_t *fecp, int dup_spd)
 #ifdef ET_DEBUG
 static void dbg_fec_regs(struct udevice *dev)
 {
-       struct fec_info_s *info = dev->priv;
+       struct fec_info_s *info = dev_get_priv(dev);
        volatile fec_t *fecp = (fec_t *)(info->iobase);
 
        printf("=====\n");
@@ -275,7 +275,7 @@ static void dbg_fec_regs(struct udevice *dev)
 
 int mcffec_init(struct udevice *dev)
 {
-       struct fec_info_s *info = dev->priv;
+       struct fec_info_s *info = dev_get_priv(dev);
        volatile fec_t *fecp = (fec_t *) (info->iobase);
        int rval, i;
        uchar ea[6];
@@ -374,7 +374,7 @@ int mcffec_init(struct udevice *dev)
 
 static int mcffec_send(struct udevice *dev, void *packet, int length)
 {
-       struct fec_info_s *info = dev->priv;
+       struct fec_info_s *info = dev_get_priv(dev);
        volatile fec_t *fecp = (fec_t *)info->iobase;
        int j, rc;
        u16 phy_status;
@@ -440,7 +440,7 @@ static int mcffec_send(struct udevice *dev, void *packet, int length)
 
 static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp)
 {
-       struct fec_info_s *info = dev->priv;
+       struct fec_info_s *info = dev_get_priv(dev);
        volatile fec_t *fecp = (fec_t *)info->iobase;
        int length = -1;
 
@@ -492,7 +492,7 @@ static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp)
 
 static void mcffec_halt(struct udevice *dev)
 {
-       struct fec_info_s *info = dev->priv;
+       struct fec_info_s *info = dev_get_priv(dev);
 
        fec_reset(info);
        fecpin_setclear(info, 0);
@@ -519,7 +519,7 @@ static const struct eth_ops mcffec_ops = {
 static int mcffec_probe(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_plat(dev);
-       struct fec_info_s *info = dev->priv;
+       struct fec_info_s *info = dev_get_priv(dev);
        int node = dev_of_offset(dev);
        int retval, fec_idx;
        const u32 *val;
index 393605512d980abf7cb3c181d91a9797b8f3844e..ec81320a86d177bab164893a3ff5020eee8b5444 100644 (file)
@@ -100,7 +100,11 @@ uint mii_send(uint mii_cmd)
 
        /* retrieve from register structure */
        dev = eth_get_dev();
+#ifdef CONFIG_DM_ETH
+       info = dev_get_priv(dev);
+#else
        info = dev->priv;
+#endif
 
        ep = (FEC_T *) info->miibase;
 
@@ -216,7 +220,11 @@ void __mii_init(void)
 
        /* retrieve from register structure */
        dev = eth_get_dev();
+#ifdef CONFIG_DM_ETH
+       info = dev_get_priv(dev);
+#else
        info = dev->priv;
+#endif
 
        fecp = (FEC_T *) info->miibase;
 
index 13a8856286a29decc9a48fc34841acd1e6db3ef1..50134b4d9b6a17869bd055bf1e8d1cb3f3cf6318 100644 (file)
@@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = {
 
 static int ipq4019_mdio_bind(struct udevice *dev)
 {
-       if (ofnode_valid(dev->node))
-               device_set_name(dev, ofnode_get_name(dev->node));
+       if (ofnode_valid(dev_ofnode(dev)))
+               device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
        return 0;
 }
index f8557dd2c49c11d31503104719f764bacebd0367..3654230118f12c62af40b3f3e0e1c98996d4ac3f 100644 (file)
@@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev)
        }
 
        /* parent should be an I2C chip, grandparent should be an I2C bus */
-       chip_node = ofnode_get_parent(dev->node);
+       chip_node = ofnode_get_parent(dev_ofnode(dev));
        bus_node = ofnode_get_parent(chip_node);
 
        err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus);
index 005f28f1b25400520614f10aba977ad666abce32..96f8dc62b5693a6893720a3d1f5b3ef4a783ef76 100644 (file)
@@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg,
  */
 static int mvmdio_bind(struct udevice *dev)
 {
-       if (ofnode_valid(dev->node))
-               device_set_name(dev, ofnode_get_name(dev->node));
+       if (ofnode_valid(dev_ofnode(dev)))
+               device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
        return 0;
 }
index d1582b968bfade3f69cfa3ace76a92bfb8b38191..58436419f1b946e1fc84c11f894047e74eb414fe 100644 (file)
@@ -313,7 +313,7 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-       int ret, subnode, cnt = 0, node = dev->node.of_offset;
+       int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
        struct mii_dev *bus;
        struct octeontx_smi_priv *priv;
        pci_dev_t bdf = dm_pci_get_bdf(dev);
index 3d14571114749a5753df6c0b85248f64b05d161a..0c27a668b5980397793ce67d09fec7c93bcaf5bb 100644 (file)
@@ -157,7 +157,7 @@ static int pfe_eth_start(struct udevice *dev)
 
 static int pfe_eth_send(struct udevice *dev, void *packet, int length)
 {
-       struct pfe_eth_dev *priv = (struct pfe_eth_dev *)dev->priv;
+       struct pfe_eth_dev *priv = (struct pfe_eth_dev *)dev_get_priv(dev);
 
        int rc;
        int i = 0;
index 7c6ae3cb81461cfeb1a8de6e7f9f08cb1862b2e9..17ad88e732ede102d5e5880d97c3198c2285b086 100644 (file)
@@ -537,7 +537,7 @@ static int sunxi_emac_eth_start(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_plat(dev);
 
-       return _sunxi_emac_eth_init(dev->priv, pdata->enetaddr);
+       return _sunxi_emac_eth_init(dev_get_priv(dev), pdata->enetaddr);
 }
 
 static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)
index 2271eb825161fe9ba5089763a55dbf54caa3169b..ec486893725753a84425641c5bfa4ac609b2909b 100644 (file)
@@ -131,11 +131,17 @@ static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac,
 static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
 #endif
 {
-       struct tsec_private *priv = (struct tsec_private *)dev->priv;
-       struct tsec __iomem *regs = priv->regs;
+       struct tsec_private *priv;
+       struct tsec __iomem *regs;
        u32 result, value;
        u8 whichbit, whichreg;
 
+#ifndef CONFIG_DM_ETH
+       priv = (struct tsec_private *)dev->priv;
+#else
+       priv = dev_get_priv(dev);
+#endif
+       regs = priv->regs;
        result = ether_crc(MAC_ADDR_LEN, mcast_mac);
        whichbit = (result >> 24) & 0x1f; /* the 5 LSB = which bit to set */
        whichreg = result >> 29; /* the 3 MSB = which reg to set it in */
@@ -260,12 +266,18 @@ static int tsec_send(struct eth_device *dev, void *packet, int length)
 static int tsec_send(struct udevice *dev, void *packet, int length)
 #endif
 {
-       struct tsec_private *priv = (struct tsec_private *)dev->priv;
-       struct tsec __iomem *regs = priv->regs;
+       struct tsec_private *priv;
+       struct tsec __iomem *regs;
        int result = 0;
        u16 status;
        int i;
 
+#ifndef CONFIG_DM_ETH
+       priv = (struct tsec_private *)dev->priv;
+#else
+       priv = dev_get_priv(dev);
+#endif
+       regs = priv->regs;
        /* Find an empty buffer descriptor */
        for (i = 0;
             in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_READY;
@@ -339,7 +351,7 @@ static int tsec_recv(struct eth_device *dev)
 #else
 static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
 {
-       struct tsec_private *priv = (struct tsec_private *)dev->priv;
+       struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
        struct tsec __iomem *regs = priv->regs;
        int ret = -1;
 
@@ -368,7 +380,7 @@ static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
 
 static int tsec_free_pkt(struct udevice *dev, uchar *packet, int length)
 {
-       struct tsec_private *priv = (struct tsec_private *)dev->priv;
+       struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
        u16 status;
 
        out_be16(&priv->rxbd[priv->rx_idx].length, 0);
@@ -392,8 +404,14 @@ static void tsec_halt(struct eth_device *dev)
 static void tsec_halt(struct udevice *dev)
 #endif
 {
-       struct tsec_private *priv = (struct tsec_private *)dev->priv;
-       struct tsec __iomem *regs = priv->regs;
+       struct tsec_private *priv;
+       struct tsec __iomem *regs;
+#ifndef CONFIG_DM_ETH
+       priv = (struct tsec_private *)dev->priv;
+#else
+       priv = dev_get_priv(dev);
+#endif
+       regs = priv->regs;
 
        clrbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
        setbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
@@ -560,16 +578,22 @@ static int tsec_init(struct eth_device *dev, struct bd_info *bd)
 static int tsec_init(struct udevice *dev)
 #endif
 {
-       struct tsec_private *priv = (struct tsec_private *)dev->priv;
+       struct tsec_private *priv;
+       struct tsec __iomem *regs;
 #ifdef CONFIG_DM_ETH
        struct eth_pdata *pdata = dev_get_plat(dev);
 #else
        struct eth_device *pdata = dev;
 #endif
-       struct tsec __iomem *regs = priv->regs;
        u32 tempval;
        int ret;
 
+#ifndef CONFIG_DM_ETH
+       priv = (struct tsec_private *)dev->priv;
+#else
+       priv = dev_get_priv(dev);
+#endif
+       regs = priv->regs;
        /* Make sure the controller is stopped */
        tsec_halt(dev);
 
@@ -683,7 +707,8 @@ static int init_phy(struct tsec_private *priv)
                tsec_configure_serdes(priv);
 
 #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
-       if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
+       if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
+                                            "fixed-link")))
                phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
        else
                phydev = dm_eth_phy_connect(priv->dev);
@@ -865,7 +890,7 @@ int tsec_probe(struct udevice *dev)
 
 int tsec_remove(struct udevice *dev)
 {
-       struct tsec_private *priv = dev->priv;
+       struct tsec_private *priv = dev_get_priv(dev);
 
        free(priv->phydev);
        mdio_unregister(priv->bus);
index 5c7688751997a39bc8cff76f2ecfbda957c1c1df..6b447537f66dd07c229bb43d4155b81abc770552 100644 (file)
@@ -457,7 +457,7 @@ static int emaclite_recv(struct udevice *dev, int flags, uchar **packetp)
 {
        u32 length, first_read, reg, attempt = 0;
        void *addr, *ack;
-       struct xemaclite *emaclite = dev->priv;
+       struct xemaclite *emaclite = dev_get_priv(dev);
        struct emaclite_regs *regs = emaclite->regs;
        struct ethernet_hdr *eth;
        struct ip_udp_hdr *ip;
index 756d8ad74496fa40435640ef6697203535eb19fd..a0b8afb87a012fd52bdad5ade62ff5dd7c4534c6 100644 (file)
@@ -82,7 +82,7 @@ uint sandbox_pci_read_bar(u32 barval, int type, uint size)
 
 static int sandbox_pci_emul_post_probe(struct udevice *dev)
 {
-       struct sandbox_pci_emul_priv *priv = dev->uclass->priv;
+       struct sandbox_pci_emul_priv *priv = uclass_get_priv(dev->uclass);
 
        priv->dev_count++;
        sandbox_set_enable_pci_map(true);
@@ -92,7 +92,7 @@ static int sandbox_pci_emul_post_probe(struct udevice *dev)
 
 static int sandbox_pci_emul_pre_remove(struct udevice *dev)
 {
-       struct sandbox_pci_emul_priv *priv = dev->uclass->priv;
+       struct sandbox_pci_emul_priv *priv = uclass_get_priv(dev->uclass);
 
        priv->dev_count--;
        sandbox_set_enable_pci_map(priv->dev_count > 0);
index 914217d0c9af1e134736a6210e934f8a3e9a5006..4cdd06b1257d00ccee3727b88c18c33daf5ed52f 100644 (file)
@@ -524,7 +524,7 @@ static void set_vga_bridge_bits(struct udevice *dev)
 
 int pci_auto_config_devices(struct udevice *bus)
 {
-       struct pci_controller *hose = bus->uclass_priv;
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
        struct pci_child_plat *pplat;
        unsigned int sub_bus;
        struct udevice *dev;
@@ -540,7 +540,7 @@ int pci_auto_config_devices(struct udevice *bus)
                int ret;
 
                debug("%s: device %s\n", __func__, dev->name);
-               if (dev_of_valid(dev) &&
+               if (dev_has_ofnode(dev) &&
                    dev_read_bool(dev, "pci,no-autoconfig"))
                        continue;
                ret = dm_pciauto_config_device(dev);
@@ -1007,7 +1007,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 
        debug("%s, bus=%d/%s, parent=%s\n", __func__, dev_seq(bus), bus->name,
              bus->parent->name);
-       hose = bus->uclass_priv;
+       hose = dev_get_uclass_priv(bus);
 
        /*
         * Set the sequence number, if device_bind() doesn't. We want control
@@ -1019,7 +1019,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
                ret = uclass_get(UCLASS_PCI, &uc);
                if (ret)
                        return ret;
-               bus->sqq = uclass_find_next_free_seq(uc);
+               bus->seq_ = uclass_find_next_free_seq(uc);
        }
 
        /* For bridges, use the top-level PCI controller */
@@ -1036,7 +1036,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
        hose->bus = bus;
        hose->first_busno = dev_seq(bus);
        hose->last_busno = dev_seq(bus);
-       if (dev_of_valid(bus)) {
+       if (dev_has_ofnode(bus)) {
                hose->skip_auto_config_until_reloc =
                        dev_read_bool(bus,
                                      "u-boot,skip-auto-config-until-reloc");
@@ -1091,7 +1091,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
 {
        struct pci_child_plat *pplat;
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        pplat = dev_get_parent_plat(dev);
@@ -1109,7 +1109,7 @@ static int pci_bridge_read_config(const struct udevice *bus, pci_dev_t bdf,
                                  uint offset, ulong *valuep,
                                  enum pci_size_t size)
 {
-       struct pci_controller *hose = bus->uclass_priv;
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
 
        return pci_bus_read_config(hose->ctlr, bdf, offset, valuep, size);
 }
@@ -1118,7 +1118,7 @@ static int pci_bridge_write_config(struct udevice *bus, pci_dev_t bdf,
                                   uint offset, ulong value,
                                   enum pci_size_t size)
 {
-       struct pci_controller *hose = bus->uclass_priv;
+       struct pci_controller *hose = dev_get_uclass_priv(bus);
 
        return pci_bus_write_config(hose->ctlr, bdf, offset, value, size);
 }
index 8e35ea14750ada3756a3c71c74e6b8b73a7c6c6a..82010e7c96e7061de72efbb96f73b6aca477922b 100644 (file)
@@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev)
 
        ret = device_bind_driver_to_node(dev->parent,
                                         "ti-serdes-am654-mux-clk",
-                                        dev_read_name(dev), dev->node,
+                                        dev_read_name(dev), dev_ofnode(dev),
                                         NULL);
        if (ret) {
                dev_err(dev, "%s: not able to bind clock driver\n", __func__);
index 9f96505dd5a5dfaa87db0292be1652333a0bfe04..987a56b715ec135bfa72b2d3dda00290ce5a8b6b 100644 (file)
@@ -274,7 +274,9 @@ static int pinctrl_configure_itss(struct udevice *dev,
        irq = pcr_read32(dev, PAD_CFG1_OFFSET(pad_cfg_offset));
        irq &= PAD_CFG1_IRQ_MASK;
        if (!irq) {
-               log_err("GPIO %u doesn't support APIC routing\n", cfg->pad);
+               if (spl_phase() > PHASE_TPL)
+                       log_err("GPIO %u doesn't support APIC routing\n",
+                               cfg->pad);
 
                return -EPROTONOSUPPORT;
        }
@@ -314,7 +316,8 @@ static int pinctrl_pad_reset_config_override(const struct pad_community *comm,
                        return config_value;
                }
        }
-       log_err("Logical-to-Chipset mapping not found\n");
+       if (spl_phase() > PHASE_TPL)
+               log_err("Logical-to-Chipset mapping not found\n");
 
        return -ENOENT;
 }
@@ -620,7 +623,9 @@ int intel_pinctrl_of_to_plat(struct udevice *dev,
        struct intel_pinctrl_priv *priv = dev_get_priv(dev);
 
        if (!comm) {
-               log_err("Cannot find community for pid %d\n", pplat->pid);
+               if (spl_phase() > PHASE_TPL)
+                       log_err("Cannot find community for pid %d\n",
+                               pplat->pid);
                return -EDOM;
        }
        priv->comm = comm;
index 48b0e9a161b2673c4980318d12b80ac172be2936..acaa55d2e7fe030a2336dd82ffe227274359c122 100644 (file)
 #include <asm-generic/gpio.h>
 #include <asm/intel_pinctrl_defs.h>
 
-/**
- * struct apl_gpio_plat - platform data for each device
- *
- * @dtplat: of-platdata data from C struct
- */
-struct apl_gpio_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       /* Put this first since driver model will copy the data here */
-       struct dtd_intel_apl_pinctrl dtplat;
-#endif
-};
-
 static const struct reset_mapping rst_map[] = {
        { .logical = PAD_CFG0_LOGICAL_RESET_PWROK, .chipset = 0U << 30 },
        { .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30 },
@@ -152,8 +140,6 @@ static int apl_pinctrl_of_to_plat(struct udevice *dev)
         * linker list (i.e. alphabetical order by driver name). So the GPIO
         * device may well be bound before its parent (p2sb), and this call
         * will fail if p2sb is not bound yet.
-        *
-        * TODO([email protected]): Add a parent pointer to child devices in dtoc
         */
        ret = p2sb_set_port_id(dev, plat->dtplat.intel_p2sb_port_id);
        if (ret)
@@ -169,15 +155,17 @@ static int apl_pinctrl_of_to_plat(struct udevice *dev)
        return intel_pinctrl_of_to_plat(dev, comm, 2);
 }
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id apl_gpio_ids[] = {
        { .compatible = "intel,apl-pinctrl"},
        { }
 };
+#endif
 
 U_BOOT_DRIVER(intel_apl_pinctrl) = {
        .name           = "intel_apl_pinctrl",
        .id             = UCLASS_PINCTRL,
-       .of_match       = apl_gpio_ids,
+       .of_match       = of_match_ptr(apl_gpio_ids),
        .probe          = intel_pinctrl_probe,
        .ops            = &intel_pinctrl_ops,
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
index 3cb0bf3b5afaeb9f8d2c84fae4875d004f75a5ea..6994dbb61a3ddf74126f28e708b1175305604089 100644 (file)
@@ -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)
index 5ada2ac4052562b628e2635c6e103ff76b9aa371..449a0aa8b5fb9764c63c6eb803f6c50ba7e239a0 100644 (file)
@@ -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)
index 74bfd3c3dcab930f7b8c422f21ed1bfac92f44d7..ddaad55ddc512de17ee3e1e72b68065f88ad6c55 100644 (file)
@@ -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)
index 690e5c770621343a9978e5b086bc77a4f0c19850..e129ab2f8311639cfda4cdd3f4f159a858aa72fd 100644 (file)
@@ -122,7 +122,7 @@ void qe_config_iopin(u8 port, u8 pin, int dir, int open_drain, int assign)
 #else
 static int qe_io_of_to_plat(struct udevice *dev)
 {
-       struct qe_io_plat *plat = dev->plat;
+       struct qe_io_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
 
        addr = dev_read_addr(dev);
@@ -143,7 +143,7 @@ static int qe_io_of_to_plat(struct udevice *dev)
  */
 static int par_io_of_config_node(struct udevice *dev, ofnode pio)
 {
-       struct qe_io_plat *plat = dev->plat;
+       struct qe_io_plat *plat = dev_get_plat(dev);
        qepio83xx_t *par_io = plat->base;
        const unsigned int *pio_map;
        int pio_map_len;
index 25d646a26f75d0d724f46dfa26481821456db923..20c3c82aa98a83557119e5e8ecbeaf350c789fd6 100644 (file)
@@ -47,7 +47,7 @@ static int single_configure_pins(struct udevice *dev,
                                 const struct single_fdt_pin_cfg *pins,
                                 int size)
 {
-       struct single_pdata *pdata = dev->plat;
+       struct single_pdata *pdata = dev_get_plat(dev);
        int count = size / sizeof(struct single_fdt_pin_cfg);
        phys_addr_t n, reg;
        u32 val;
@@ -81,7 +81,7 @@ static int single_configure_bits(struct udevice *dev,
                                 const struct single_fdt_bits_cfg *pins,
                                 int size)
 {
-       struct single_pdata *pdata = dev->plat;
+       struct single_pdata *pdata = dev_get_plat(dev);
        int count = size / sizeof(struct single_fdt_bits_cfg);
        phys_addr_t n, reg;
        u32 val, mask;
@@ -153,7 +153,7 @@ static int single_of_to_plat(struct udevice *dev)
        fdt_addr_t addr;
        u32 of_reg[2];
        int res;
-       struct single_pdata *pdata = dev->plat;
+       struct single_pdata *pdata = dev_get_plat(dev);
 
        pdata->width =
                dev_read_u32_default(dev, "pinctrl-single,register-width", 0);
index aba881047479849b95f5866b04f723a69791f0c7..7919e54e8de8d72323f137821e7f41186df65324 100644 (file)
@@ -112,7 +112,7 @@ static int pinconfig_post_bind(struct udevice *dev)
        ofnode node;
        int ret;
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        dev_for_each_subnode(node, dev) {
@@ -305,7 +305,7 @@ int pinctrl_select_state(struct udevice *dev, const char *statename)
         * Some device which is logical like mmc.blk, do not have
         * a valid ofnode.
         */
-       if (!ofnode_valid(dev->node))
+       if (!dev_has_ofnode(dev))
                return 0;
        /*
         * Try full-implemented pinctrl first.
@@ -416,7 +416,9 @@ static int __maybe_unused pinctrl_post_bind(struct udevice *dev)
 
 UCLASS_DRIVER(pinctrl) = {
        .id = UCLASS_PINCTRL,
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
        .post_bind = pinctrl_post_bind,
+#endif
        .flags = DM_UC_FLAG_SEQ_ALIAS,
        .name = "pinctrl",
 };
index 32a2836f0bf15a58ea4286c01dabceb0dbc01378..34446a34e60d21778deae3938d8294f6aba8b20c 100644 (file)
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <dm.h>
 #include <log.h>
+#include <spl.h>
 #include <acpi/acpi_s3.h>
 #ifdef CONFIG_X86
 #include <asm/intel_pinctrl.h>
@@ -60,7 +61,8 @@ int pmc_gpe_init(struct udevice *dev)
         * are different and if they aren't, use the reset values.
         */
        if (dw[0] == dw[1] || dw[1] == dw[2]) {
-               log_info("PMC: Using default GPE route");
+               if (spl_phase() > PHASE_TPL)
+                       log_info("PMC: Using default GPE route");
                gpio_cfg = readl(upriv->gpe_cfg);
                for (i = 0; i < upriv->gpe0_count; i++)
                        dw[i] = gpio_cfg >> gpe0_shift(upriv, i);
index 2e7ab671286f298e98f24b6ebe4ec50dc68545a0..ef8274ce96d796f91ab20f2bab8545a9415bb6e1 100644 (file)
@@ -397,11 +397,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
        if (!priv->data)
                return -EINVAL;
 
-       priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->regmap_hhi))
                return PTR_ERR(priv->regmap_hhi);
 
-       ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl",
+       ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
                              &ao_phandle);
        if (ret)
                return ret;
index 40947c66f3113ccc58d37f0d6b31833d3f9baa12..eb94af2cf839242b8ebcc5972c0b6223632d7a0a 100644 (file)
@@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
        ofnode hhi_node;
        int ret;
 
-       priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->regmap_ao))
                return PTR_ERR(priv->regmap_ao);
 
-       ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
+       ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
                              &hhi_phandle);
        if (ret)
                return ret;
index 2f547a314d90b19bf56898c52f97f140b1f961c7..5f442fea689d3075f40d35dc1e583170a07b52a1 100644 (file)
@@ -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)
index 32be59e49e9414a422548cac134fc939f1ad7766..8df1abcf7885cb38fdf0054586902773acb54128 100644 (file)
@@ -135,7 +135,7 @@ static const struct da9063_reg_info da9063_buck_info[] = {
 
 static int da9063_get_enable(struct udevice *dev)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        int ret;
 
@@ -148,7 +148,7 @@ static int da9063_get_enable(struct udevice *dev)
 
 static int da9063_set_enable(struct udevice *dev, bool enable)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
 
        return pmic_clrsetbits(dev->parent, info->en_reg,
@@ -157,7 +157,7 @@ static int da9063_set_enable(struct udevice *dev, bool enable)
 
 static int da9063_get_voltage(struct udevice *dev)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        int ret;
 
@@ -170,7 +170,7 @@ static int da9063_get_voltage(struct udevice *dev)
 
 static int da9063_set_voltage(struct udevice *dev, int uV)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        uint sel;
 
@@ -198,7 +198,7 @@ static const struct dm_regulator_mode
 
 static int ldo_get_mode(struct udevice *dev)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        int val;
 
@@ -214,7 +214,7 @@ static int ldo_get_mode(struct udevice *dev)
 
 static int ldo_set_mode(struct udevice *dev, int mode_id)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        const struct dm_regulator_mode *mode;
 
@@ -230,7 +230,7 @@ static int ldo_set_mode(struct udevice *dev, int mode_id)
 
 static int buck_get_mode(struct udevice *dev)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        int i;
        int val;
@@ -261,7 +261,7 @@ static int buck_get_mode(struct udevice *dev)
 
 static int buck_set_mode(struct udevice *dev, int mode_id)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        const struct dm_regulator_mode *mode;
 
@@ -277,7 +277,7 @@ static int buck_set_mode(struct udevice *dev, int mode_id)
 
 static int buck_get_current_limit(struct udevice *dev)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        int val;
 
@@ -293,7 +293,7 @@ static int buck_get_current_limit(struct udevice *dev)
 
 static int buck_set_current_limit(struct udevice *dev, int uA)
 {
-       const struct da9063_priv *priv = dev->priv;
+       const struct da9063_priv *priv = dev_get_priv(dev);
        const struct da9063_reg_info *info = priv->reg_info;
        int val;
 
@@ -310,7 +310,7 @@ static int buck_set_current_limit(struct udevice *dev, int uA)
 static int da9063_ldo_probe(struct udevice *dev)
 {
        struct dm_regulator_uclass_plat *uc_pdata;
-       struct da9063_priv *priv = dev->priv;
+       struct da9063_priv *priv = dev_get_priv(dev);
 
        /* LDOs are named numerically in DT so can directly index */
        if (dev->driver_data < 1 ||
@@ -329,7 +329,7 @@ static int da9063_ldo_probe(struct udevice *dev)
 static int da9063_buck_probe(struct udevice *dev)
 {
        struct dm_regulator_uclass_plat *uc_pdata;
-       struct da9063_priv *priv = dev->priv;
+       struct da9063_priv *priv = dev_get_priv(dev);
        int i;
 
        /* Bucks have names rather than numbers so need to match with DT */
index c3df156749fc6af5006b54e263b7e60acbde29f1..5bf186e4d4c1b4739baad4b2ce5aa489f9dbb2b0 100644 (file)
@@ -16,6 +16,7 @@
 #include <syscon.h>
 #include <linux/bitops.h>
 #include <linux/ioport.h>
+#include <dm/device-internal.h>
 #include <dm/read.h>
 #ifdef CONFIG_MMC_OMAP36XX_PINS
 #include <asm/arch/sys_proto.h>
@@ -102,7 +103,8 @@ static int pbias_bind(struct udevice *dev)
 {
        int children;
 
-       children = pmic_bind_children(dev, dev->node, pmic_children_info);
+       children = pmic_bind_children(dev, dev_ofnode(dev),
+                                     pmic_children_info);
        if (!children)
                debug("%s: %s - no child found\n", __func__, dev->name);
 
@@ -208,7 +210,7 @@ static int pbias_regulator_probe(struct udevice *dev)
        }
 
        uc_pdata->type = REGULATOR_TYPE_OTHER;
-       dev->priv = (void *)*p;
+       dev_set_priv(dev, (void *)*p);
 
        return 0;
 }
index 58b7469f977abc8c22a8afc5140eeb718ff72096..03eeacc286d766ff2b9a2a1e073c7d7bcdb21b8f 100644 (file)
@@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev)
                                        if (strcmp(cdev->driver->name, "fixed_rate_clock"))
                                                continue;
 
-                                       str = ofnode_read_string(cdev->node, "clock-output-names");
+                                       str = ofnode_read_string(dev_ofnode(cdev),
+                                                                "clock-output-names");
                                        if (!str)
                                                continue;
 
                                        if (!strcmp(str, "xtal")) {
                                                err = uclass_get_device_by_ofnode(UCLASS_CLK,
-                                                                                 cdev->node,
+                                                                                 dev_ofnode(cdev),
                                                                                  &cdev);
                                                if (err) {
                                                        printf("%s%d: Failed to get xtal clk\n", __func__, i);
@@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev)
                                        return -EINVAL;
                                }
 
-                               err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev);
+                               err = uclass_get_device_by_ofnode(UCLASS_CLK,
+                                                                 dev_ofnode(cdev),
+                                                                 &cdev);
                                if (err) {
                                        printf("%s%d: Failed to get clk controller\n", __func__, i);
                                        return err;
index ccc910e7c74f51073b6d8d93e5a43b04727a26cb..c2d6a4e0c17ed74c687a715118bdd3f87fcf4b8a 100644 (file)
@@ -115,7 +115,7 @@ static int rproc_pre_probe(struct udevice *dev)
 
        /* See if we need to populate via fdt */
 
-       if (!dev->plat) {
+       if (!dev_get_plat(dev)) {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
                int node = dev_of_offset(dev);
                const void *blob = gd->fdt_blob;
@@ -140,7 +140,7 @@ static int rproc_pre_probe(struct udevice *dev)
 #endif
 
        } else {
-               struct dm_rproc_uclass_pdata *pdata = dev->plat;
+               struct dm_rproc_uclass_pdata *pdata = dev_get_plat(dev);
 
                debug("'%s': using legacy data\n", dev->name);
                if (pdata->name)
@@ -247,7 +247,7 @@ static int _rproc_dev_is_probed(struct udevice *dev,
                            struct dm_rproc_uclass_pdata *uc_pdata,
                            const void *data)
 {
-       if (dev->flags & DM_FLAG_ACTIVATED)
+       if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
                return 0;
 
        return -EAGAIN;
index ee2ee730712e7de275aa52f3a072f235611a3151..6836eca4c55fc971f6e38d66c40b3cb7b1aa2d43 100644 (file)
@@ -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,
 };
index a229d490f36dd811fbe01c5735fa15e7a884ca86..c3d650fc6b0848a961e3b44843ab98b15cbda5da 100644 (file)
@@ -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;
index b97a21f671725d8291d8a33ebb7648fc453322c7..7427013ab60613dc3bcf7943a7a3395242142f24 100644 (file)
@@ -14,6 +14,7 @@
 #include <regmap.h>
 #include <reset-uclass.h>
 #include <syscon.h>
+#include <dm/device-internal.h>
 #include <linux/bitops.h>
 #include <linux/err.h>
 
@@ -92,7 +93,7 @@ int mediatek_reset_bind(struct udevice *pdev, u32 regofs, u32 num_regs)
        priv = malloc(sizeof(struct mediatek_reset_priv));
        priv->regofs = regofs;
        priv->nr_resets = num_regs * 32;
-       rst_dev->priv = priv;
+       dev_set_priv(rst_dev, priv);
 
        return 0;
 }
index e5e9918c0c1cf3ce68152609738393c327d9b9bb..eeb3d2eea7748fb6456a7f88f58f26d0e3080416 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <asm/arch-rockchip/hardware.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 /*
  * Each reg has 16 bits reset signal for devices
@@ -121,7 +122,7 @@ int rockchip_reset_bind(struct udevice *pdev, u32 reg_offset, u32 reg_number)
        priv = malloc(sizeof(struct rockchip_reset_priv));
        priv->reset_reg_offset = reg_offset;
        priv->reset_reg_num = reg_number;
-       rst_dev->priv = priv;
+       dev_set_priv(rst_dev, priv);
 
        return 0;
 }
index f6110d85f9ff8acaf4416db91d3f9cc7e001787e..eec840d677fb4142101d3c1ec32ec111cf2c737f 100644 (file)
@@ -9,6 +9,7 @@
 #include <reset-uclass.h>
 #include <asm/io.h>
 #include <dm/device_compat.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <linux/bitops.h>
 
@@ -97,7 +98,7 @@ int sifive_reset_bind(struct udevice *dev, ulong count)
        }
        priv = malloc(sizeof(struct sifive_reset_priv));
        priv->nr_reset = count;
-       rst_dev->priv = priv;
+       dev_set_priv(rst_dev, priv);
 
        return 0;
 }
index c64c9b5917cc61619e8dff330cbb4aed76a56f01..98450db94b2020f9481eb89afe2c40a7738eb45d 100644 (file)
@@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev)
         * Bind it to the node, too, so that it can get its base address.
         */
        ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
-                                        dev->node, &sys_child);
+                                        dev_ofnode(dev), &sys_child);
        if (ret)
                debug("Warning: No sysreset driver: ret=%d\n", ret);
 
index 1db321ce1fdc3bdf0a21e83065fbfbc2554ff46a..264337ed803df32a0d490b95511471ae32563558 100644 (file)
@@ -11,6 +11,7 @@
 #include <malloc.h>
 #include <reset-uclass.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <linux/bitops.h>
 #include <linux/log2.h>
@@ -113,7 +114,7 @@ int sunxi_reset_bind(struct udevice *dev, ulong count)
        priv = malloc(sizeof(struct sunxi_reset_priv));
        priv->count = count;
        priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
-       rst_dev->priv = priv;
+       dev_set_priv(rst_dev, priv);
 
        return 0;
 }
index 1dc80ca1274321b322700170a3b4dc71e805a5a7..8f0e1ab5ac63ba69a2740b105cee094c849128b5 100644 (file)
@@ -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",
 };
index 0d3ccd880cae6359f81ba6ebbbaf0de81c2d37ba..4435fcf56b9a329d0e594180b4273b1669d8b035 100644 (file)
@@ -37,7 +37,7 @@ static int altera_jtaguart_setbrg(struct udevice *dev, int baudrate)
 
 static int altera_jtaguart_putc(struct udevice *dev, const char ch)
 {
-       struct altera_jtaguart_plat *plat = dev->plat;
+       struct altera_jtaguart_plat *plat = dev_get_plat(dev);
        struct altera_jtaguart_regs *const regs = plat->regs;
        u32 st = readl(&regs->control);
 
@@ -56,7 +56,7 @@ static int altera_jtaguart_putc(struct udevice *dev, const char ch)
 
 static int altera_jtaguart_pending(struct udevice *dev, bool input)
 {
-       struct altera_jtaguart_plat *plat = dev->plat;
+       struct altera_jtaguart_plat *plat = dev_get_plat(dev);
        struct altera_jtaguart_regs *const regs = plat->regs;
        u32 st = readl(&regs->control);
 
@@ -68,7 +68,7 @@ static int altera_jtaguart_pending(struct udevice *dev, bool input)
 
 static int altera_jtaguart_getc(struct udevice *dev)
 {
-       struct altera_jtaguart_plat *plat = dev->plat;
+       struct altera_jtaguart_plat *plat = dev_get_plat(dev);
        struct altera_jtaguart_regs *const regs = plat->regs;
        u32 val;
 
@@ -83,7 +83,7 @@ static int altera_jtaguart_getc(struct udevice *dev)
 static int altera_jtaguart_probe(struct udevice *dev)
 {
 #ifdef CONFIG_ALTERA_JTAG_UART_BYPASS
-       struct altera_jtaguart_plat *plat = dev->plat;
+       struct altera_jtaguart_plat *plat = dev_get_plat(dev);
        struct altera_jtaguart_regs *const regs = plat->regs;
 
        writel(ALTERA_JTAG_AC, &regs->control); /* clear AC flag */
index a3efa1ee1b5262fcea8cce30145e38cb22e6c8c4..b18be6e245490ab65cdc6c707a6594e13d2bc977 100644 (file)
@@ -32,7 +32,7 @@ struct altera_uart_plat {
 
 static int altera_uart_setbrg(struct udevice *dev, int baudrate)
 {
-       struct altera_uart_plat *plat = dev->plat;
+       struct altera_uart_plat *plat = dev_get_plat(dev);
        struct altera_uart_regs *const regs = plat->regs;
        u32 div;
 
@@ -44,7 +44,7 @@ static int altera_uart_setbrg(struct udevice *dev, int baudrate)
 
 static int altera_uart_putc(struct udevice *dev, const char ch)
 {
-       struct altera_uart_plat *plat = dev->plat;
+       struct altera_uart_plat *plat = dev_get_plat(dev);
        struct altera_uart_regs *const regs = plat->regs;
 
        if (!(readl(&regs->status) & ALTERA_UART_TRDY))
@@ -57,7 +57,7 @@ static int altera_uart_putc(struct udevice *dev, const char ch)
 
 static int altera_uart_pending(struct udevice *dev, bool input)
 {
-       struct altera_uart_plat *plat = dev->plat;
+       struct altera_uart_plat *plat = dev_get_plat(dev);
        struct altera_uart_regs *const regs = plat->regs;
        u32 st = readl(&regs->status);
 
@@ -69,7 +69,7 @@ static int altera_uart_pending(struct udevice *dev, bool input)
 
 static int altera_uart_getc(struct udevice *dev)
 {
-       struct altera_uart_plat *plat = dev->plat;
+       struct altera_uart_plat *plat = dev_get_plat(dev);
        struct altera_uart_regs *const regs = plat->regs;
 
        if (!(readl(&regs->status) & ALTERA_UART_RRDY))
index 7eabf76d92e73574dc8b4b4b2dba6993e27777f4..7edec23e6482e650a36f877635c558e8f0221176 100644 (file)
@@ -262,7 +262,7 @@ static int atmel_serial_enable_clk(struct udevice *dev)
 
 static int atmel_serial_probe(struct udevice *dev)
 {
-       struct atmel_serial_plat *plat = dev->plat;
+       struct atmel_serial_plat *plat = dev_get_plat(dev);
        struct atmel_serial_priv *priv = dev_get_priv(dev);
        int ret;
 #if CONFIG_IS_ENABLED(OF_CONTROL)
index 8dd81ad7948610ac1a486a618a1c8a4ff7de86c3..65c6db073ec400ced49d7f423813b5aa492b2ed0 100644 (file)
@@ -156,7 +156,7 @@ static inline int serial_in_dynamic(struct ns16550_plat *plat, u8 *addr)
 
 #endif /* CONFIG_NS16550_DYNAMIC */
 
-static void ns16550_writeb(NS16550_t port, int offset, int value)
+static void ns16550_writeb(struct ns16550 *port, int offset, int value)
 {
        struct ns16550_plat *plat = port->plat;
        unsigned char *addr;
@@ -170,7 +170,7 @@ static void ns16550_writeb(NS16550_t port, int offset, int value)
                serial_out_shift(addr, plat->reg_shift, value);
 }
 
-static int ns16550_readb(NS16550_t port, int offset)
+static int ns16550_readb(struct ns16550 *port, int offset)
 {
        struct ns16550_plat *plat = port->plat;
        unsigned char *addr;
@@ -184,7 +184,7 @@ static int ns16550_readb(NS16550_t port, int offset)
                return serial_in_shift(addr, plat->reg_shift);
 }
 
-static u32 ns16550_getfcr(NS16550_t port)
+static u32 ns16550_getfcr(struct ns16550 *port)
 {
        struct ns16550_plat *plat = port->plat;
 
@@ -199,20 +199,20 @@ static u32 ns16550_getfcr(NS16550_t port)
        ns16550_readb(com_port, \
                (unsigned char *)addr - (unsigned char *)com_port)
 #else
-static u32 ns16550_getfcr(NS16550_t port)
+static u32 ns16550_getfcr(struct ns16550 *port)
 {
        return UART_FCR_DEFVAL;
 }
 #endif
 
-int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate)
+int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate)
 {
        const unsigned int mode_x_div = 16;
 
        return DIV_ROUND_CLOSEST(clock, mode_x_div * baudrate);
 }
 
-static void NS16550_setbrg(NS16550_t com_port, int baud_divisor)
+static void ns16550_setbrg(struct ns16550 *com_port, int baud_divisor)
 {
        /* to keep serial format, read lcr before writing BKSE */
        int lcr_val = serial_in(&com_port->lcr) & ~UART_LCR_BKSE;
@@ -223,7 +223,7 @@ static void NS16550_setbrg(NS16550_t com_port, int baud_divisor)
        serial_out(lcr_val, &com_port->lcr);
 }
 
-void NS16550_init(NS16550_t com_port, int baud_divisor)
+void ns16550_init(struct ns16550 *com_port, int baud_divisor)
 {
 #if (defined(CONFIG_SPL_BUILD) && \
                (defined(CONFIG_OMAP34XX) || defined(CONFIG_OMAP44XX)))
@@ -235,13 +235,13 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
        if ((serial_in(&com_port->lsr) & (UART_LSR_TEMT | UART_LSR_THRE))
             == UART_LSR_THRE) {
                if (baud_divisor != -1)
-                       NS16550_setbrg(com_port, baud_divisor);
+                       ns16550_setbrg(com_port, baud_divisor);
                else {
                        // Re-use old baud rate divisor to flush transmit reg.
                        const int dll = serial_in(&com_port->dll);
                        const int dlm = serial_in(&com_port->dlm);
                        const int divisor = dll | (dlm << 8);
-                       NS16550_setbrg(com_port, divisor);
+                       ns16550_setbrg(com_port, divisor);
                }
                serial_out(0, &com_port->mdr1);
        }
@@ -260,7 +260,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
        /* initialize serial config to 8N1 before writing baudrate */
        serial_out(UART_LCRVAL, &com_port->lcr);
        if (baud_divisor != -1)
-               NS16550_setbrg(com_port, baud_divisor);
+               ns16550_setbrg(com_port, baud_divisor);
 #if defined(CONFIG_ARCH_OMAP2PLUS) || defined(CONFIG_SOC_DA8XX) || \
        defined(CONFIG_OMAP_SERIAL)
        /* /16 is proper to hit 115200 with 48MHz */
@@ -272,17 +272,17 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 }
 
 #ifndef CONFIG_NS16550_MIN_FUNCTIONS
-void NS16550_reinit(NS16550_t com_port, int baud_divisor)
+void ns16550_reinit(struct ns16550 *com_port, int baud_divisor)
 {
        serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
-       NS16550_setbrg(com_port, 0);
+       ns16550_setbrg(com_port, 0);
        serial_out(UART_MCRVAL, &com_port->mcr);
        serial_out(ns16550_getfcr(com_port), &com_port->fcr);
-       NS16550_setbrg(com_port, baud_divisor);
+       ns16550_setbrg(com_port, baud_divisor);
 }
 #endif /* CONFIG_NS16550_MIN_FUNCTIONS */
 
-void NS16550_putc(NS16550_t com_port, char c)
+void ns16550_putc(struct ns16550 *com_port, char c)
 {
        while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0)
                ;
@@ -299,7 +299,7 @@ void NS16550_putc(NS16550_t com_port, char c)
 }
 
 #ifndef CONFIG_NS16550_MIN_FUNCTIONS
-char NS16550_getc(NS16550_t com_port)
+char ns16550_getc(struct ns16550 *com_port)
 {
        while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) {
 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB_TTY)
@@ -311,7 +311,7 @@ char NS16550_getc(NS16550_t com_port)
        return serial_in(&com_port->rbr);
 }
 
-int NS16550_tstc(NS16550_t com_port)
+int ns16550_tstc(struct ns16550 *com_port)
 {
        return (serial_in(&com_port->lsr) & UART_LSR_DR) != 0;
 }
@@ -324,7 +324,7 @@ int NS16550_tstc(NS16550_t com_port)
 
 static inline void _debug_uart_init(void)
 {
-       struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+       struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE;
        int baud_divisor;
 
        /*
@@ -345,7 +345,7 @@ static inline void _debug_uart_init(void)
        serial_dout(&com_port->lcr, UART_LCRVAL);
 }
 
-static inline int NS16550_read_baud_divisor(struct NS16550 *com_port)
+static inline int NS16550_read_baud_divisor(struct ns16550 *com_port)
 {
        int ret;
 
@@ -359,7 +359,7 @@ static inline int NS16550_read_baud_divisor(struct NS16550 *com_port)
 
 static inline void _debug_uart_putc(int ch)
 {
-       struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+       struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE;
 
        while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) {
 #ifdef CONFIG_DEBUG_UART_NS16550_CHECK_ENABLED
@@ -377,7 +377,7 @@ DEBUG_UART_FUNCS
 #if CONFIG_IS_ENABLED(DM_SERIAL)
 static int ns16550_serial_putc(struct udevice *dev, const char ch)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
 
        if (!(serial_in(&com_port->lsr) & UART_LSR_THRE))
                return -EAGAIN;
@@ -397,7 +397,7 @@ static int ns16550_serial_putc(struct udevice *dev, const char ch)
 
 static int ns16550_serial_pending(struct udevice *dev, bool input)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
 
        if (input)
                return (serial_in(&com_port->lsr) & UART_LSR_DR) ? 1 : 0;
@@ -407,7 +407,7 @@ static int ns16550_serial_pending(struct udevice *dev, bool input)
 
 static int ns16550_serial_getc(struct udevice *dev)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
 
        if (!(serial_in(&com_port->lsr) & UART_LSR_DR))
                return -EAGAIN;
@@ -417,20 +417,20 @@ static int ns16550_serial_getc(struct udevice *dev)
 
 static int ns16550_serial_setbrg(struct udevice *dev, int baudrate)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
        struct ns16550_plat *plat = com_port->plat;
        int clock_divisor;
 
        clock_divisor = ns16550_calc_divisor(com_port, plat->clock, baudrate);
 
-       NS16550_setbrg(com_port, clock_divisor);
+       ns16550_setbrg(com_port, clock_divisor);
 
        return 0;
 }
 
 static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
        int lcr_val = UART_LCR_WLS_8;
        uint parity = SERIAL_GET_PARITY(serial_config);
        uint bits = SERIAL_GET_BITS(serial_config);
@@ -464,7 +464,7 @@ static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config)
 static int ns16550_serial_getinfo(struct udevice *dev,
                                  struct serial_device_info *info)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
        struct ns16550_plat *plat = com_port->plat;
 
        info->type = SERIAL_CHIP_16550_COMPATIBLE;
@@ -498,8 +498,8 @@ static int ns16550_serial_assign_base(struct ns16550_plat *plat, ulong base)
 
 int ns16550_serial_probe(struct udevice *dev)
 {
-       struct ns16550_plat *plat = dev->plat;
-       struct NS16550 *const com_port = dev_get_priv(dev);
+       struct ns16550_plat *plat = dev_get_plat(dev);
+       struct ns16550 *const com_port = dev_get_priv(dev);
        struct reset_ctl_bulk reset_bulk;
        fdt_addr_t addr;
        int ret;
@@ -520,7 +520,7 @@ int ns16550_serial_probe(struct udevice *dev)
                reset_deassert_bulk(&reset_bulk);
 
        com_port->plat = dev_get_plat(dev);
-       NS16550_init(com_port, -1);
+       ns16550_init(com_port, -1);
 
        return 0;
 }
@@ -535,7 +535,7 @@ enum {
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 int ns16550_serial_of_to_plat(struct udevice *dev)
 {
-       struct ns16550_plat *plat = dev->plat;
+       struct ns16550_plat *plat = dev_get_plat(dev);
        const u32 port_type = dev_get_driver_data(dev);
        fdt_addr_t addr;
        struct clk clk;
@@ -613,7 +613,7 @@ U_BOOT_DRIVER(ns16550_serial) = {
        .of_to_plat = ns16550_serial_of_to_plat,
        .plat_auto      = sizeof(struct ns16550_plat),
 #endif
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .probe = ns16550_serial_probe,
        .ops    = &ns16550_serial_ops,
 #if !CONFIG_IS_ENABLED(OF_CONTROL)
@@ -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 */
 
index c7d5390b435712aff77de19dc7924e35876c5ced..756738c2d2128eb2f0ba98685ee0487a3e777290 100644 (file)
 #include <serial.h>
 #include <video.h>
 #include <linux/compiler.h>
+#include <asm/serial.h>
 #include <asm/state.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct sandbox_serial_plat {
-       int colour;     /* Text colour to use for output, -1 for none */
-};
-
-/**
- * struct sandbox_serial_priv - Private data for this driver
- *
- * @buf: holds input characters available to be read by this driver
- */
-struct sandbox_serial_priv {
-       struct membuff buf;
-       char serial_buf[16];
-       bool start_of_line;
-};
-
 /**
  * output_ansi_colour() - Output an ANSI colour code
  *
@@ -72,7 +58,7 @@ static int sandbox_serial_probe(struct udevice *dev)
 
 static int sandbox_serial_remove(struct udevice *dev)
 {
-       struct sandbox_serial_plat *plat = dev->plat;
+       struct sandbox_serial_plat *plat = dev_get_plat(dev);
 
        if (plat->colour != -1)
                output_ansi_reset();
@@ -83,7 +69,7 @@ static int sandbox_serial_remove(struct udevice *dev)
 static int sandbox_serial_putc(struct udevice *dev, const char ch)
 {
        struct sandbox_serial_priv *priv = dev_get_priv(dev);
-       struct sandbox_serial_plat *plat = dev->plat;
+       struct sandbox_serial_plat *plat = dev_get_plat(dev);
 
        /* With of-platdata we don't real the colour correctly, so disable it */
        if (!CONFIG_IS_ENABLED(OF_PLATDATA) && priv->start_of_line &&
@@ -203,7 +189,7 @@ static const char * const ansi_colour[] = {
 
 static int sandbox_serial_of_to_plat(struct udevice *dev)
 {
-       struct sandbox_serial_plat *plat = dev->plat;
+       struct sandbox_serial_plat *plat = dev_get_plat(dev);
        const char *colour;
        int i;
 
@@ -255,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,
 };
index b6457242dea0ac9f891cea569163554e7d9c4188..58a6541d8cc31ea0121a81e5fa2932d1ac55f4c7 100644 (file)
@@ -123,7 +123,7 @@ static void serial_find_console_or_panic(void)
 #ifdef CONFIG_SERIAL_SEARCH_ALL
                if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
                    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
-                       if (dev->flags & DM_FLAG_ACTIVATED) {
+                       if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) {
                                gd->cur_serial_dev = dev;
                                return;
                        }
index 022e37748c869e730b19ae5b230fb001986c1bf6..445eacc8aac637eff48826d59183090ef4979b40 100644 (file)
@@ -37,7 +37,7 @@ struct arc_serial_plat {
 
 static int arc_serial_setbrg(struct udevice *dev, int baudrate)
 {
-       struct arc_serial_plat *plat = dev->plat;
+       struct arc_serial_plat *plat = dev_get_plat(dev);
        struct arc_serial_regs *const regs = plat->reg;
        int arc_console_baud = gd->cpu_clk / (baudrate * 4) - 1;
 
@@ -49,7 +49,7 @@ static int arc_serial_setbrg(struct udevice *dev, int baudrate)
 
 static int arc_serial_putc(struct udevice *dev, const char c)
 {
-       struct arc_serial_plat *plat = dev->plat;
+       struct arc_serial_plat *plat = dev_get_plat(dev);
        struct arc_serial_regs *const regs = plat->reg;
 
        while (!(readb(&regs->status) & UART_TXEMPTY))
@@ -67,7 +67,7 @@ static int arc_serial_tstc(struct arc_serial_regs *const regs)
 
 static int arc_serial_pending(struct udevice *dev, bool input)
 {
-       struct arc_serial_plat *plat = dev->plat;
+       struct arc_serial_plat *plat = dev_get_plat(dev);
        struct arc_serial_regs *const regs = plat->reg;
        uint32_t status = readb(&regs->status);
 
@@ -79,7 +79,7 @@ static int arc_serial_pending(struct udevice *dev, bool input)
 
 static int arc_serial_getc(struct udevice *dev)
 {
-       struct arc_serial_plat *plat = dev->plat;
+       struct arc_serial_plat *plat = dev_get_plat(dev);
        struct arc_serial_regs *const regs = plat->reg;
 
        while (!arc_serial_tstc(regs))
index 904e1b306e0bb557c98e90287536ff4d6c970e3d..88c8209c5db8360f172de11dc4b17bbae5ddf92a 100644 (file)
@@ -37,7 +37,7 @@ U_BOOT_DRIVER(coreboot_uart) = {
        .name   = "coreboot_uart",
        .id     = UCLASS_SERIAL,
        .of_match       = coreboot_serial_ids,
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .plat_auto      = sizeof(struct ns16550_plat),
        .of_to_plat  = coreboot_of_to_plat,
        .probe  = ns16550_serial_probe,
index be9bf662fd2a85a7e4e4cdf5a57c2038ae5b137f..bbf19057c4d12f76ce559ed9a7b35ee1f58eb875 100644 (file)
@@ -61,7 +61,7 @@ U_BOOT_DRIVER(serial_intel_mid) = {
        .of_match = mid_serial_ids,
        .of_to_plat = ns16550_serial_of_to_plat,
        .plat_auto      = sizeof(struct ns16550_plat),
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .probe  = mid_serial_probe,
        .ops    = &ns16550_serial_ops,
 };
index ced005706aed6866e5c256c0f3711cc65efd86b0..c3714e1e1ec22857e95965e32e1950f1a4f6ced2 100644 (file)
@@ -168,7 +168,7 @@ static void linflex_serial_init_internal(struct linflex_fsl *lfuart)
 
 static int linflex_serial_probe(struct udevice *dev)
 {
-       struct linflex_serial_plat *plat = dev->plat;
+       struct linflex_serial_plat *plat = dev_get_plat(dev);
        struct linflex_serial_priv *priv = dev_get_priv(dev);
 
        priv->lfuart = (struct linflex_fsl *)plat->base_addr;
index 5beb5f2ce640d5a9f2709560b0bb2f6696b392f8..a35e5be303f6fa9e76c99c95a76c9c6c250ee97f 100644 (file)
@@ -138,7 +138,7 @@ static inline int get_lpuart_clk_rate(struct udevice *dev, u32 *clk)
 
 static bool is_lpuart32(struct udevice *dev)
 {
-       struct lpuart_serial_plat *plat = dev->plat;
+       struct lpuart_serial_plat *plat = dev_get_plat(dev);
 
        return plat->flags & LPUART_FLAG_REGMAP_32BIT_REG;
 }
@@ -445,7 +445,7 @@ static int lpuart_serial_setbrg(struct udevice *dev, int baudrate)
 
 static int lpuart_serial_getc(struct udevice *dev)
 {
-       struct lpuart_serial_plat *plat = dev->plat;
+       struct lpuart_serial_plat *plat = dev_get_plat(dev);
 
        if (is_lpuart32(dev))
                return _lpuart32_serial_getc(plat);
@@ -455,7 +455,7 @@ static int lpuart_serial_getc(struct udevice *dev)
 
 static int lpuart_serial_putc(struct udevice *dev, const char c)
 {
-       struct lpuart_serial_plat *plat = dev->plat;
+       struct lpuart_serial_plat *plat = dev_get_plat(dev);
 
        if (is_lpuart32(dev))
                _lpuart32_serial_putc(plat, c);
@@ -467,7 +467,7 @@ static int lpuart_serial_putc(struct udevice *dev, const char c)
 
 static int lpuart_serial_pending(struct udevice *dev, bool input)
 {
-       struct lpuart_serial_plat *plat = dev->plat;
+       struct lpuart_serial_plat *plat = dev_get_plat(dev);
        struct lpuart_fsl *reg = plat->reg;
        struct lpuart_fsl_reg32 *reg32 = plat->reg;
        u32 stat;
@@ -513,7 +513,7 @@ static int lpuart_serial_probe(struct udevice *dev)
 
 static int lpuart_serial_of_to_plat(struct udevice *dev)
 {
-       struct lpuart_serial_plat *plat = dev->plat;
+       struct lpuart_serial_plat *plat = dev_get_plat(dev);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(dev);
        fdt_addr_t addr;
index 4ba6dc32f922fe577b26e4d91b29a15ac27a9f9d..e6e21b2ce8c7cc6d5812404420da7be9f39d6286 100644 (file)
@@ -83,7 +83,7 @@ static void mcf_serial_setbrg_common(uart_t *uart, int baudrate)
 
 static int coldfire_serial_probe(struct udevice *dev)
 {
-       struct coldfire_serial_plat *plat = dev->plat;
+       struct coldfire_serial_plat *plat = dev_get_plat(dev);
 
        plat->port = dev_seq(dev);
 
@@ -93,7 +93,7 @@ static int coldfire_serial_probe(struct udevice *dev)
 
 static int coldfire_serial_putc(struct udevice *dev, const char ch)
 {
-       struct coldfire_serial_plat *plat = dev->plat;
+       struct coldfire_serial_plat *plat = dev_get_plat(dev);
        uart_t *uart = (uart_t *)plat->base;
 
        /* Wait for last character to go. */
@@ -107,7 +107,7 @@ static int coldfire_serial_putc(struct udevice *dev, const char ch)
 
 static int coldfire_serial_getc(struct udevice *dev)
 {
-       struct coldfire_serial_plat *plat = dev->plat;
+       struct coldfire_serial_plat *plat = dev_get_plat(dev);
        uart_t *uart = (uart_t *)(plat->base);
 
        /* Wait for a character to arrive. */
@@ -119,7 +119,7 @@ static int coldfire_serial_getc(struct udevice *dev)
 
 int coldfire_serial_setbrg(struct udevice *dev, int baudrate)
 {
-       struct coldfire_serial_plat *plat = dev->plat;
+       struct coldfire_serial_plat *plat = dev_get_plat(dev);
        uart_t *uart = (uart_t *)(plat->base);
 
        mcf_serial_setbrg_common(uart, baudrate);
@@ -129,7 +129,7 @@ int coldfire_serial_setbrg(struct udevice *dev, int baudrate)
 
 static int coldfire_serial_pending(struct udevice *dev, bool input)
 {
-       struct coldfire_serial_plat *plat = dev->plat;
+       struct coldfire_serial_plat *plat = dev_get_plat(dev);
        uart_t *uart = (uart_t *)(plat->base);
 
        if (input)
index 40d9bfe7c6f2bd83577cd218f2e7cbe6a9ff7d2b..d69ec221e4567800cbe95b1075b3d61260475c00 100644 (file)
@@ -57,7 +57,7 @@ static void meson_serial_init(struct meson_uart *uart)
 
 static int meson_serial_probe(struct udevice *dev)
 {
-       struct meson_serial_plat *plat = dev->plat;
+       struct meson_serial_plat *plat = dev_get_plat(dev);
        struct meson_uart *const uart = plat->reg;
 
        meson_serial_init(uart);
@@ -67,7 +67,7 @@ static int meson_serial_probe(struct udevice *dev)
 
 static void meson_serial_rx_error(struct udevice *dev)
 {
-       struct meson_serial_plat *plat = dev->plat;
+       struct meson_serial_plat *plat = dev_get_plat(dev);
        struct meson_uart *const uart = plat->reg;
        u32 val = readl(&uart->control);
 
@@ -83,7 +83,7 @@ static void meson_serial_rx_error(struct udevice *dev)
 
 static int meson_serial_getc(struct udevice *dev)
 {
-       struct meson_serial_plat *plat = dev->plat;
+       struct meson_serial_plat *plat = dev_get_plat(dev);
        struct meson_uart *const uart = plat->reg;
        uint32_t status = readl(&uart->status);
 
@@ -100,7 +100,7 @@ static int meson_serial_getc(struct udevice *dev)
 
 static int meson_serial_putc(struct udevice *dev, const char ch)
 {
-       struct meson_serial_plat *plat = dev->plat;
+       struct meson_serial_plat *plat = dev_get_plat(dev);
        struct meson_uart *const uart = plat->reg;
 
        if (readl(&uart->status) & AML_UART_TX_FULL)
@@ -113,7 +113,7 @@ static int meson_serial_putc(struct udevice *dev, const char ch)
 
 static int meson_serial_pending(struct udevice *dev, bool input)
 {
-       struct meson_serial_plat *plat = dev->plat;
+       struct meson_serial_plat *plat = dev_get_plat(dev);
        struct meson_uart *const uart = plat->reg;
        uint32_t status = readl(&uart->status);
 
@@ -138,7 +138,7 @@ static int meson_serial_pending(struct udevice *dev, bool input)
 
 static int meson_serial_of_to_plat(struct udevice *dev)
 {
-       struct meson_serial_plat *plat = dev->plat;
+       struct meson_serial_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
 
        addr = dev_read_addr(dev);
index 2603fa8611a35bde6a559afc28c8d71869175a68..e5795da99d958a617fa9ee89a1235d9da4a71b4c 100644 (file)
@@ -264,7 +264,7 @@ __weak struct serial_device *default_serial_console(void)
 
 int mxc_serial_setbrg(struct udevice *dev, int baudrate)
 {
-       struct mxc_serial_plat *plat = dev->plat;
+       struct mxc_serial_plat *plat = dev_get_plat(dev);
        u32 clk = imx_get_uartclk();
 
        _mxc_serial_setbrg(plat->reg, clk, baudrate, plat->use_dte);
@@ -274,7 +274,7 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate)
 
 static int mxc_serial_probe(struct udevice *dev)
 {
-       struct mxc_serial_plat *plat = dev->plat;
+       struct mxc_serial_plat *plat = dev_get_plat(dev);
 
        _mxc_serial_init(plat->reg, plat->use_dte);
 
@@ -283,7 +283,7 @@ static int mxc_serial_probe(struct udevice *dev)
 
 static int mxc_serial_getc(struct udevice *dev)
 {
-       struct mxc_serial_plat *plat = dev->plat;
+       struct mxc_serial_plat *plat = dev_get_plat(dev);
        struct mxc_uart *const uart = plat->reg;
 
        if (readl(&uart->ts) & UTS_RXEMPTY)
@@ -294,7 +294,7 @@ static int mxc_serial_getc(struct udevice *dev)
 
 static int mxc_serial_putc(struct udevice *dev, const char ch)
 {
-       struct mxc_serial_plat *plat = dev->plat;
+       struct mxc_serial_plat *plat = dev_get_plat(dev);
        struct mxc_uart *const uart = plat->reg;
 
        if (!(readl(&uart->ts) & UTS_TXEMPTY))
@@ -307,7 +307,7 @@ static int mxc_serial_putc(struct udevice *dev, const char ch)
 
 static int mxc_serial_pending(struct udevice *dev, bool input)
 {
-       struct mxc_serial_plat *plat = dev->plat;
+       struct mxc_serial_plat *plat = dev_get_plat(dev);
        struct mxc_uart *const uart = plat->reg;
        uint32_t sr2 = readl(&uart->sr2);
 
@@ -327,7 +327,7 @@ static const struct dm_serial_ops mxc_serial_ops = {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 static int mxc_serial_of_to_plat(struct udevice *dev)
 {
-       struct mxc_serial_plat *plat = dev->plat;
+       struct mxc_serial_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
 
        addr = dev_read_addr(dev);
index ef394b72350915bdc247c812c693b32cd80c8187..b5beca976d35b4f805939faa996906e461e50135 100644 (file)
@@ -36,34 +36,34 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Note: The port number specified in the functions is 1 based.
  *      the array is 0 based.
  */
-static NS16550_t serial_ports[6] = {
+static struct ns16550 *serial_ports[6] = {
 #ifdef CONFIG_SYS_NS16550_COM1
-       (NS16550_t)CONFIG_SYS_NS16550_COM1,
+       (struct ns16550 *)CONFIG_SYS_NS16550_COM1,
 #else
        NULL,
 #endif
 #ifdef CONFIG_SYS_NS16550_COM2
-       (NS16550_t)CONFIG_SYS_NS16550_COM2,
+       (struct ns16550 *)CONFIG_SYS_NS16550_COM2,
 #else
        NULL,
 #endif
 #ifdef CONFIG_SYS_NS16550_COM3
-       (NS16550_t)CONFIG_SYS_NS16550_COM3,
+       (struct ns16550 *)CONFIG_SYS_NS16550_COM3,
 #else
        NULL,
 #endif
 #ifdef CONFIG_SYS_NS16550_COM4
-       (NS16550_t)CONFIG_SYS_NS16550_COM4,
+       (struct ns16550 *)CONFIG_SYS_NS16550_COM4,
 #else
        NULL,
 #endif
 #ifdef CONFIG_SYS_NS16550_COM5
-       (NS16550_t)CONFIG_SYS_NS16550_COM5,
+       (struct ns16550 *)CONFIG_SYS_NS16550_COM5,
 #else
        NULL,
 #endif
 #ifdef CONFIG_SYS_NS16550_COM6
-       (NS16550_t)CONFIG_SYS_NS16550_COM6
+       (struct ns16550 *)CONFIG_SYS_NS16550_COM6
 #else
        NULL
 #endif
@@ -78,7 +78,7 @@ static NS16550_t serial_ports[6] = {
                int clock_divisor; \
                clock_divisor = ns16550_calc_divisor(serial_ports[port-1], \
                                CONFIG_SYS_NS16550_CLK, gd->baudrate); \
-               NS16550_init(serial_ports[port-1], clock_divisor); \
+               ns16550_init(serial_ports[port - 1], clock_divisor); \
                return 0 ; \
        } \
        static void eserial##port##_setbrg(void) \
@@ -117,9 +117,9 @@ static NS16550_t serial_ports[6] = {
 static void _serial_putc(const char c, const int port)
 {
        if (c == '\n')
-               NS16550_putc(PORT, '\r');
+               ns16550_putc(PORT, '\r');
 
-       NS16550_putc(PORT, c);
+       ns16550_putc(PORT, c);
 }
 
 static void _serial_puts(const char *s, const int port)
@@ -131,12 +131,12 @@ static void _serial_puts(const char *s, const int port)
 
 static int _serial_getc(const int port)
 {
-       return NS16550_getc(PORT);
+       return ns16550_getc(PORT);
 }
 
 static int _serial_tstc(const int port)
 {
-       return NS16550_tstc(PORT);
+       return ns16550_tstc(PORT);
 }
 
 static void _serial_setbrg(const int port)
@@ -145,7 +145,7 @@ static void _serial_setbrg(const int port)
 
        clock_divisor = ns16550_calc_divisor(PORT, CONFIG_SYS_NS16550_CLK,
                                             gd->baudrate);
-       NS16550_reinit(PORT, clock_divisor);
+       ns16550_reinit(PORT, clock_divisor);
 }
 
 static inline void
index 2f38e1b8901406178b7d2b05e2d8afebc9d2dd26..2b23ece442e5e6c4ded4fa168548622c207c9a34 100644 (file)
@@ -66,7 +66,7 @@ static inline int serial_in_shift(void *addr, int shift)
 
 static inline void _debug_uart_init(void)
 {
-       struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+       struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE;
        int baud_divisor;
 
        baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
@@ -85,7 +85,7 @@ static inline void _debug_uart_init(void)
 
 static inline void _debug_uart_putc(int ch)
 {
-       struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+       struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE;
 
        while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
                ;
@@ -101,7 +101,7 @@ DEBUG_UART_FUNCS
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int omap_serial_of_to_plat(struct udevice *dev)
 {
-       struct ns16550_plat *plat = dev->plat;
+       struct ns16550_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
        struct clk clk;
        int err;
@@ -160,7 +160,7 @@ U_BOOT_DRIVER(omap_serial) = {
        .of_to_plat = omap_serial_of_to_plat,
        .plat_auto      = sizeof(struct ns16550_plat),
 #endif
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .probe = ns16550_serial_probe,
        .ops    = &ns16550_serial_ops,
 #if !CONFIG_IS_ENABLED(OF_CONTROL)
index d82f3b975292203abd8dd2066f5bb37ef4f950a7..669841ede4d7d6d58ecd350df1b26f205a2d92db 100644 (file)
@@ -268,7 +268,7 @@ void pxa_serial_initialize(void)
 #ifdef CONFIG_DM_SERIAL
 static int pxa_serial_probe(struct udevice *dev)
 {
-       struct pxa_serial_plat *plat = dev->plat;
+       struct pxa_serial_plat *plat = dev_get_plat(dev);
 
        pxa_setbrg_common((struct pxa_uart_regs *)plat->base, plat->port,
                          plat->baudrate);
@@ -277,7 +277,7 @@ static int pxa_serial_probe(struct udevice *dev)
 
 static int pxa_serial_putc(struct udevice *dev, const char ch)
 {
-       struct pxa_serial_plat *plat = dev->plat;
+       struct pxa_serial_plat *plat = dev_get_plat(dev);
        struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base;
 
        /* Wait for last character to go. */
@@ -291,7 +291,7 @@ static int pxa_serial_putc(struct udevice *dev, const char ch)
 
 static int pxa_serial_getc(struct udevice *dev)
 {
-       struct pxa_serial_plat *plat = dev->plat;
+       struct pxa_serial_plat *plat = dev_get_plat(dev);
        struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base;
 
        /* Wait for a character to arrive. */
@@ -303,7 +303,7 @@ static int pxa_serial_getc(struct udevice *dev)
 
 int pxa_serial_setbrg(struct udevice *dev, int baudrate)
 {
-       struct pxa_serial_plat *plat = dev->plat;
+       struct pxa_serial_plat *plat = dev_get_plat(dev);
        struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base;
        int port = plat->port;
 
@@ -314,7 +314,7 @@ int pxa_serial_setbrg(struct udevice *dev, int baudrate)
 
 static int pxa_serial_pending(struct udevice *dev, bool input)
 {
-       struct pxa_serial_plat *plat = dev->plat;
+       struct pxa_serial_plat *plat = dev_get_plat(dev);
        struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base;
 
        if (input)
index 4c0548ed0f38de3fde4262729e24beaa072ff0a9..97d40869a2a37d07274dc613a100a4d79fc80807 100644 (file)
@@ -10,6 +10,7 @@
 #include <ns16550.h>
 #include <serial.h>
 #include <asm/arch-rockchip/clock.h>
+#include <dm/device-internal.h>
 
 #if defined(CONFIG_ROCKCHIP_RK3188)
 struct rockchip_uart_plat {
@@ -34,7 +35,7 @@ static int rockchip_serial_probe(struct udevice *dev)
        plat->plat.reg_shift = plat->dtplat.reg_shift;
        plat->plat.clock = plat->dtplat.clock_frequency;
        plat->plat.fcr = UART_FCR_DEFVAL;
-       dev->plat = &plat->plat;
+       dev_set_plat(dev, &plat->plat);
 
        return ns16550_serial_probe(dev);
 }
@@ -42,7 +43,7 @@ static int rockchip_serial_probe(struct udevice *dev)
 U_BOOT_DRIVER(rockchip_rk3188_uart) = {
        .name   = "rockchip_rk3188_uart",
        .id     = UCLASS_SERIAL,
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .plat_auto      = sizeof(struct rockchip_uart_plat),
        .probe  = rockchip_serial_probe,
        .ops    = &ns16550_serial_ops,
@@ -52,7 +53,7 @@ U_BOOT_DRIVER(rockchip_rk3188_uart) = {
 U_BOOT_DRIVER(rockchip_rk3288_uart) = {
        .name   = "rockchip_rk3288_uart",
        .id     = UCLASS_SERIAL,
-       .priv_auto      = sizeof(struct NS16550),
+       .priv_auto      = sizeof(struct ns16550),
        .plat_auto      = sizeof(struct rockchip_uart_plat),
        .probe  = rockchip_serial_probe,
        .ops    = &ns16550_serial_ops,
index 120df835dbdd71c42214d4cc8dcf35be11ecacec..0eac0d53a50a72e965d510bde24864211eed4617 100644 (file)
@@ -88,7 +88,7 @@ static void __maybe_unused s5p_serial_baud(struct s5p_uart *uart, uint uclk,
 #ifndef CONFIG_SPL_BUILD
 int s5p_serial_setbrg(struct udevice *dev, int baudrate)
 {
-       struct s5p_serial_plat *plat = dev->plat;
+       struct s5p_serial_plat *plat = dev_get_plat(dev);
        struct s5p_uart *const uart = plat->reg;
        u32 uclk;
 
@@ -111,7 +111,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate)
 
 static int s5p_serial_probe(struct udevice *dev)
 {
-       struct s5p_serial_plat *plat = dev->plat;
+       struct s5p_serial_plat *plat = dev_get_plat(dev);
        struct s5p_uart *const uart = plat->reg;
 
        s5p_serial_init(uart);
@@ -140,7 +140,7 @@ static int serial_err_check(const struct s5p_uart *const uart, int op)
 
 static int s5p_serial_getc(struct udevice *dev)
 {
-       struct s5p_serial_plat *plat = dev->plat;
+       struct s5p_serial_plat *plat = dev_get_plat(dev);
        struct s5p_uart *const uart = plat->reg;
 
        if (!(readl(&uart->ufstat) & RX_FIFO_COUNT_MASK))
@@ -152,7 +152,7 @@ static int s5p_serial_getc(struct udevice *dev)
 
 static int s5p_serial_putc(struct udevice *dev, const char ch)
 {
-       struct s5p_serial_plat *plat = dev->plat;
+       struct s5p_serial_plat *plat = dev_get_plat(dev);
        struct s5p_uart *const uart = plat->reg;
 
        if (readl(&uart->ufstat) & TX_FIFO_FULL)
@@ -166,7 +166,7 @@ static int s5p_serial_putc(struct udevice *dev, const char ch)
 
 static int s5p_serial_pending(struct udevice *dev, bool input)
 {
-       struct s5p_serial_plat *plat = dev->plat;
+       struct s5p_serial_plat *plat = dev_get_plat(dev);
        struct s5p_uart *const uart = plat->reg;
        uint32_t ufstat = readl(&uart->ufstat);
 
@@ -178,7 +178,7 @@ static int s5p_serial_pending(struct udevice *dev, bool input)
 
 static int s5p_serial_of_to_plat(struct udevice *dev)
 {
-       struct s5p_serial_plat *plat = dev->plat;
+       struct s5p_serial_plat *plat = dev_get_plat(dev);
        fdt_addr_t addr;
 
        addr = dev_read_addr(dev);
index b746501f5fff910bddc8ec7a1dc08fff27da537b..67980431ba0fe518dd5b2b25de9c92ecb81c72f4 100644 (file)
@@ -27,7 +27,7 @@
 
 static int cadence_spi_write_speed(struct udevice *bus, uint hz)
 {
-       struct cadence_spi_plat *plat = bus->plat;
+       struct cadence_spi_plat *plat = dev_get_plat(bus);
        struct cadence_spi_priv *priv = dev_get_priv(bus);
 
        cadence_qspi_apb_config_baudrate_div(priv->regbase,
@@ -130,7 +130,7 @@ static int spi_calibration(struct udevice *bus, uint hz)
 
 static int cadence_spi_set_speed(struct udevice *bus, uint hz)
 {
-       struct cadence_spi_plat *plat = bus->plat;
+       struct cadence_spi_plat *plat = dev_get_plat(bus);
        struct cadence_spi_priv *priv = dev_get_priv(bus);
        int err;
 
@@ -165,7 +165,7 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz)
 
 static int cadence_spi_probe(struct udevice *bus)
 {
-       struct cadence_spi_plat *plat = bus->plat;
+       struct cadence_spi_plat *plat = dev_get_plat(bus);
        struct cadence_spi_priv *priv = dev_get_priv(bus);
        struct clk clk;
        int ret;
@@ -212,7 +212,7 @@ static int cadence_spi_remove(struct udevice *dev)
 
 static int cadence_spi_set_mode(struct udevice *bus, uint mode)
 {
-       struct cadence_spi_plat *plat = bus->plat;
+       struct cadence_spi_plat *plat = dev_get_plat(bus);
        struct cadence_spi_priv *priv = dev_get_priv(bus);
 
        /* Disable QSPI */
@@ -235,7 +235,7 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi,
                                   const struct spi_mem_op *op)
 {
        struct udevice *bus = spi->dev->parent;
-       struct cadence_spi_plat *plat = bus->plat;
+       struct cadence_spi_plat *plat = dev_get_plat(bus);
        struct cadence_spi_priv *priv = dev_get_priv(bus);
        void *base = priv->regbase;
        int err = 0;
@@ -284,7 +284,7 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi,
 
 static int cadence_spi_of_to_plat(struct udevice *bus)
 {
-       struct cadence_spi_plat *plat = bus->plat;
+       struct cadence_spi_plat *plat = dev_get_plat(bus);
        ofnode subnode;
 
        plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
index 8adff63edc6aca556b7665387b366e46c32a588a..298f350ef3983753f3448dc478ed3a24ee1009ea 100644 (file)
@@ -387,7 +387,7 @@ static int coldfire_spi_probe(struct udevice *bus)
 static int coldfire_dspi_of_to_plat(struct udevice *bus)
 {
        fdt_addr_t addr;
-       struct coldfire_spi_plat *plat = bus->plat;
+       struct coldfire_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
        int *ctar, len;
index ea088ebd2cb6a619befae8e8ada9d41eab35add4..53a791ea292ef546ca43785ff1fb386bdde03ad7 100644 (file)
@@ -383,7 +383,7 @@ static const struct dm_spi_ops davinci_spi_ops = {
 static int davinci_spi_probe(struct udevice *bus)
 {
        struct davinci_spi_slave *ds = dev_get_priv(bus);
-       struct davinci_spi_plat *plat = bus->plat;
+       struct davinci_spi_plat *plat = dev_get_plat(bus);
        ds->regs = plat->regs;
        ds->num_cs = plat->num_cs;
 
@@ -393,7 +393,7 @@ static int davinci_spi_probe(struct udevice *bus)
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int davinci_ofdata_to_platadata(struct udevice *bus)
 {
-       struct davinci_spi_plat *plat = bus->plat;
+       struct davinci_spi_plat *plat = dev_get_plat(bus);
        fdt_addr_t addr;
 
        addr = dev_read_addr(bus);
index 88e638c950c56e849859b5eed0ff27bd9c3fc90b..742121140dee4f25496ddbc23e224fc292bdb6f1 100644 (file)
@@ -230,7 +230,7 @@ static int request_gpio_cs(struct udevice *bus)
 
 static int dw_spi_of_to_plat(struct udevice *bus)
 {
-       struct dw_spi_plat *plat = bus->plat;
+       struct dw_spi_plat *plat = dev_get_plat(bus);
 
        plat->regs = dev_read_addr_ptr(bus);
        if (!plat->regs)
@@ -665,7 +665,7 @@ static const struct spi_controller_mem_ops dw_spi_mem_ops = {
 
 static int dw_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct dw_spi_plat *plat = bus->plat;
+       struct dw_spi_plat *plat = dev_get_plat(bus);
        struct dw_spi_priv *priv = dev_get_priv(bus);
        u16 clk_div;
 
index e4d2bade0f0d8df008aece7c62682f9857da1b59..30b1a77a732896adb593c1ccfc0dd4a471d947ba 100644 (file)
@@ -253,7 +253,7 @@ static void spi_cs_deactivate(struct udevice *dev)
 
 static int exynos_spi_of_to_plat(struct udevice *bus)
 {
-       struct exynos_spi_plat *plat = bus->plat;
+       struct exynos_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
@@ -368,7 +368,7 @@ static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int exynos_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct exynos_spi_plat *plat = bus->plat;
+       struct exynos_spi_plat *plat = dev_get_plat(bus);
        struct exynos_spi_priv *priv = dev_get_priv(bus);
        int ret;
 
index ddf4a9e413ff5f2e1d1091887aed1cbc9da3d868..c17a5522bccd06156cac4cea967472966860a03b 100644 (file)
@@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
                return -EINVAL;
        }
 
-       ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay);
-       ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay);
+       ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay",
+                       &cs_sck_delay);
+       ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay",
+                       &sck_cs_delay);
 
        /* Set PCS to SCK delay scale values */
        ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk);
@@ -486,7 +488,7 @@ static int fsl_dspi_probe(struct udevice *bus)
        struct dm_spi_bus *dm_spi_bus;
        uint mcr_cfg_val;
 
-       dm_spi_bus = bus->uclass_priv;
+       dm_spi_bus = dev_get_uclass_priv(bus);
 
        /* cpu speical pin muxing configure */
        cpu_dspi_port_conf();
@@ -576,7 +578,7 @@ static int fsl_dspi_bind(struct udevice *bus)
 static int fsl_dspi_of_to_plat(struct udevice *bus)
 {
        fdt_addr_t addr;
-       struct fsl_dspi_plat *plat = bus->plat;
+       struct fsl_dspi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
index e9e7ffd6b536689e8eeb7a46a175dfae3c9465ad..abc28e37d2aed0b9a45e6e706789456b282adbbf 100644 (file)
@@ -544,7 +544,7 @@ static const struct dm_spi_ops fsl_espi_ops = {
 static int fsl_espi_of_to_plat(struct udevice *bus)
 {
        fdt_addr_t addr;
-       struct fsl_espi_plat   *plat = bus->plat;
+       struct fsl_espi_plat   *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
index fc3b844370c92c087b2eb51f065149c0bea0add6..8bc7038a82ad1345b0eaa1cc592c522137b599d0 100644 (file)
@@ -795,7 +795,7 @@ static const struct spi_controller_mem_ops fsl_qspi_mem_ops = {
 
 static int fsl_qspi_probe(struct udevice *bus)
 {
-       struct dm_spi_bus *dm_bus = bus->uclass_priv;
+       struct dm_spi_bus *dm_bus = dev_get_uclass_priv(bus);
        struct fsl_qspi *q = dev_get_priv(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
index e02850e9f22063fcedf8385a13683bc916e09855..1cd410493b099c6e8d30efb98bf1f251beb86718 100644 (file)
 #define debug_trace(x, args...)
 #endif
 
-struct ich_spi_plat {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-       struct dtd_intel_fast_spi dtplat;
-#endif
-       enum ich_version ich_version;   /* Controller version, 7 or 9 */
-       bool lockdown;                  /* lock down controller settings? */
-       ulong mmio_base;                /* Base of MMIO registers */
-       pci_dev_t bdf;                  /* PCI address used by of-platdata */
-       bool hwseq;                     /* Use hardware sequencing (not s/w) */
-};
-
 static u8 ich_readb(struct ich_spi_priv *priv, int reg)
 {
        u8 value = readb(priv->base + reg);
index 23c7827740bb9b33a0d5f8b495c3e733dcaf327a..8fd150d44a4c35214d4f92b8eb4fb76b88dac129 100644 (file)
@@ -230,4 +230,15 @@ struct ich_spi_priv {
        struct udevice *pch;    /* PCH, used to control SPI access */
 };
 
+struct ich_spi_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct dtd_intel_fast_spi dtplat;
+#endif
+       enum ich_version ich_version;   /* Controller version, 7 or 9 */
+       bool lockdown;                  /* lock down controller settings? */
+       ulong mmio_base;                /* Base of MMIO registers */
+       pci_dev_t bdf;                  /* PCI address used by of-platdata */
+       bool hwseq;                     /* Use hardware sequencing (not s/w) */
+};
+
 #endif /* _ICH_H_ */
index 4fafe33af5722a18f868531a89d26d7ab7350365..d41352a0bb8ce29d377dbe4dfa1a5ef14150e892 100644 (file)
@@ -443,7 +443,7 @@ static const struct dm_spi_ops mxs_spi_ops = {
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int mxs_of_to_plat(struct udevice *bus)
 {
-       struct mxs_spi_plat *plat = bus->plat;
+       struct mxs_spi_plat *plat = dev_get_plat(bus);
        u32 prop[2];
        int ret;
 
@@ -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)
index 179582cad7d0fa173939206d2cd546c51a93fcf7..133363ea7d9ea029a7b04a7bb5d89027686abc9c 100644 (file)
@@ -288,7 +288,7 @@ static const struct dm_spi_ops pl022_spi_ops = {
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int pl022_spi_of_to_plat(struct udevice *bus)
 {
-       struct pl022_spi_pdata *plat = bus->plat;
+       struct pl022_spi_pdata *plat = dev_get_plat(bus);
        const void *fdt = gd->fdt_blob;
        int node = dev_of_offset(bus);
        struct clk clkdev;
index 44ac475c11d3d9eaf2c78efe481983022c096965..40bd8851b7c071ec6de2c777ebc1b931d21f40f5 100644 (file)
@@ -135,7 +135,7 @@ static int rkspi_wait_till_not_busy(struct rockchip_spi *regs)
 static void spi_cs_activate(struct udevice *dev, uint cs)
 {
        struct udevice *bus = dev->parent;
-       struct rockchip_spi_plat *plat = bus->plat;
+       struct rockchip_spi_plat *plat = dev_get_plat(bus);
        struct rockchip_spi_priv *priv = dev_get_priv(bus);
        struct rockchip_spi *regs = priv->regs;
 
@@ -161,7 +161,7 @@ static void spi_cs_activate(struct udevice *dev, uint cs)
 static void spi_cs_deactivate(struct udevice *dev, uint cs)
 {
        struct udevice *bus = dev->parent;
-       struct rockchip_spi_plat *plat = bus->plat;
+       struct rockchip_spi_plat *plat = dev_get_plat(bus);
        struct rockchip_spi_priv *priv = dev_get_priv(bus);
        struct rockchip_spi *regs = priv->regs;
 
@@ -176,7 +176,7 @@ static void spi_cs_deactivate(struct udevice *dev, uint cs)
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 static int conv_of_plat(struct udevice *dev)
 {
-       struct rockchip_spi_plat *plat = dev->plat;
+       struct rockchip_spi_plat *plat = dev_get_plat(dev);
        struct dtd_rockchip_rk3288_spi *dtplat = &plat->of_plat;
        struct rockchip_spi_priv *priv = dev_get_priv(dev);
        int ret;
@@ -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)
index afc98bfb663a21e780462f0ae66140f22225f175..3425d9950a81b2a43e8c9c0f7d530ce4a3a4587a 100644 (file)
@@ -228,7 +228,7 @@ static const struct dm_spi_ops soft_spi_ops = {
 
 static int soft_spi_of_to_plat(struct udevice *dev)
 {
-       struct soft_spi_plat *plat = dev->plat;
+       struct soft_spi_plat *plat = dev_get_plat(dev);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(dev);
 
@@ -240,7 +240,7 @@ static int soft_spi_of_to_plat(struct udevice *dev)
 static int soft_spi_probe(struct udevice *dev)
 {
        struct spi_slave *slave = dev_get_parent_priv(dev);
-       struct soft_spi_plat *plat = dev->plat;
+       struct soft_spi_plat *plat = dev_get_plat(dev);
        int cs_flags, clk_flags;
        int ret;
 
index 5d801fa54ba0c3f5f8ccbc8098163e293f700555..3fe351f8a7064bfc2f9fcf6b884523e4dea1d98c 100644 (file)
@@ -165,7 +165,7 @@ static int spi_child_post_bind(struct udevice *dev)
 {
        struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev);
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        return spi_slave_of_to_plat(dev, plat);
index e1fd82bdfa354fe835b55699f887b7c928b9b637..f0256d8e6641516f37384b5e9dcac04e1af38f41 100644 (file)
@@ -99,7 +99,7 @@ struct tegra114_spi_priv {
 
 static int tegra114_spi_of_to_plat(struct udevice *bus)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
 
        plat->base = dev_read_addr(bus);
        plat->periph_id = clock_decode_periph_id(bus);
@@ -352,7 +352,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int tegra114_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra114_spi_priv *priv = dev_get_priv(bus);
 
        if (speed > plat->frequency)
index d38606100d04cad2d303cd414e94bea03fdbb96b..4384a48ec84944002c38fb00aaca658b8c962504 100644 (file)
@@ -89,7 +89,7 @@ int tegra20_sflash_cs_info(struct udevice *bus, unsigned int cs,
 
 static int tegra20_sflash_of_to_plat(struct udevice *bus)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
@@ -314,7 +314,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int tegra20_sflash_set_speed(struct udevice *bus, uint speed)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra20_sflash_priv *priv = dev_get_priv(bus);
 
        if (speed > plat->frequency)
index b99ef38a1438a60510456899c725d1ccd7b9c54f..3057fe1a222632d7d44dfeb0f79a70fc7501e704 100644 (file)
@@ -95,7 +95,7 @@ struct tegra_spi_slave {
 
 static int tegra30_spi_of_to_plat(struct udevice *bus)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
@@ -314,7 +314,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int tegra30_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra30_spi_priv *priv = dev_get_priv(bus);
 
        if (speed > plat->frequency)
index a2a7f4614cb15eccf0973a7ee81aaf6cbcfeb2fa..b464b9ccb0ef3281e2078ad606173fc486fcfddf 100644 (file)
@@ -99,7 +99,7 @@ struct tegra210_qspi_priv {
 
 static int tegra210_qspi_of_to_plat(struct udevice *bus)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
 
        plat->base = dev_read_addr(bus);
        plat->periph_id = clock_decode_periph_id(bus);
@@ -380,7 +380,7 @@ static int tegra210_qspi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int tegra210_qspi_set_speed(struct udevice *bus, uint speed)
 {
-       struct tegra_spi_plat *plat = bus->plat;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra210_qspi_priv *priv = dev_get_priv(bus);
 
        if (speed > plat->frequency)
index 48b8430d3d86ab17e41da1390de856c48f7ccbc7..e47ed5b221b2ec62287198a9a145482d4de5a7de 100644 (file)
@@ -113,7 +113,7 @@ static void uniphier_spi_regdump(struct uniphier_spi_priv *priv)
 static void spi_cs_activate(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
-       struct uniphier_spi_plat *plat = bus->plat;
+       struct uniphier_spi_plat *plat = dev_get_plat(bus);
        struct uniphier_spi_priv *priv = dev_get_priv(bus);
        ulong delay_us;         /* The delay completed so far */
        u32 val;
@@ -139,7 +139,7 @@ static void spi_cs_activate(struct udevice *dev)
 static void spi_cs_deactivate(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
-       struct uniphier_spi_plat *plat = bus->plat;
+       struct uniphier_spi_plat *plat = dev_get_plat(bus);
        struct uniphier_spi_priv *priv = dev_get_priv(bus);
        u32 val;
 
@@ -279,7 +279,7 @@ static int uniphier_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int uniphier_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct uniphier_spi_plat *plat = bus->plat;
+       struct uniphier_spi_plat *plat = dev_get_plat(bus);
        struct uniphier_spi_priv *priv = dev_get_priv(bus);
        u32 val, ckdiv;
 
@@ -364,7 +364,7 @@ static int uniphier_spi_set_mode(struct udevice *bus, uint mode)
 
 static int uniphier_spi_of_to_plat(struct udevice *bus)
 {
-       struct uniphier_spi_plat *plat = bus->plat;
+       struct uniphier_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
index 2fc28b6bee2b4c45083eb4e2cd7bb0347d5768f6..845f2d2f5f41ab1594c8960546fc90239db8191c 100644 (file)
@@ -100,7 +100,7 @@ struct zynq_qspi_priv {
 
 static int zynq_qspi_of_to_plat(struct udevice *bus)
 {
-       struct zynq_qspi_plat *plat = bus->plat;
+       struct zynq_qspi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
@@ -592,7 +592,7 @@ static int zynq_qspi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int zynq_qspi_set_speed(struct udevice *bus, uint speed)
 {
-       struct zynq_qspi_plat *plat = bus->plat;
+       struct zynq_qspi_plat *plat = dev_get_plat(bus);
        struct zynq_qspi_priv *priv = dev_get_priv(bus);
        struct zynq_qspi_regs *regs = priv->regs;
        uint32_t confr;
index a6efa4a1c836ddb643628df206db1f679dd45940..2971e55f41b101bb965cae30773d4bcf86ec7415 100644 (file)
@@ -75,7 +75,7 @@ struct zynq_spi_priv {
 
 static int zynq_spi_of_to_plat(struct udevice *bus)
 {
-       struct zynq_spi_plat *plat = bus->plat;
+       struct zynq_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
@@ -162,7 +162,7 @@ static int zynq_spi_probe(struct udevice *bus)
 static void spi_cs_activate(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
-       struct zynq_spi_plat *plat = bus->plat;
+       struct zynq_spi_plat *plat = dev_get_plat(bus);
        struct zynq_spi_priv *priv = dev_get_priv(bus);
        struct zynq_spi_regs *regs = priv->regs;
        u32 cr;
@@ -193,7 +193,7 @@ static void spi_cs_activate(struct udevice *dev)
 static void spi_cs_deactivate(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
-       struct zynq_spi_plat *plat = bus->plat;
+       struct zynq_spi_plat *plat = dev_get_plat(bus);
        struct zynq_spi_priv *priv = dev_get_priv(bus);
        struct zynq_spi_regs *regs = priv->regs;
 
@@ -296,7 +296,7 @@ static int zynq_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int zynq_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct zynq_spi_plat *plat = bus->plat;
+       struct zynq_spi_plat *plat = dev_get_plat(bus);
        struct zynq_spi_priv *priv = dev_get_priv(bus);
        struct zynq_spi_regs *regs = priv->regs;
        uint32_t confr;
index f09c50757d4ddaca54ad80bdad5f7a026a86e696..c9e476eefac3e11e3a461885a13ebfb6f861b41d 100644 (file)
@@ -177,7 +177,7 @@ struct zynqmp_qspi_priv {
 
 static int zynqmp_qspi_of_to_plat(struct udevice *bus)
 {
-       struct zynqmp_qspi_plat *plat = bus->plat;
+       struct zynqmp_qspi_plat *plat = dev_get_plat(bus);
 
        debug("%s\n", __func__);
 
@@ -255,7 +255,7 @@ static void zynqmp_qspi_chipselect(struct zynqmp_qspi_priv *priv, int is_on)
 
 void zynqmp_qspi_set_tapdelay(struct udevice *bus, u32 baudrateval)
 {
-       struct zynqmp_qspi_plat *plat = bus->plat;
+       struct zynqmp_qspi_plat *plat = dev_get_plat(bus);
        struct zynqmp_qspi_priv *priv = dev_get_priv(bus);
        struct zynqmp_qspi_regs *regs = priv->regs;
        u32 tapdlybypass = 0, lpbkdlyadj = 0, datadlyadj = 0, clk_rate;
@@ -295,7 +295,7 @@ void zynqmp_qspi_set_tapdelay(struct udevice *bus, u32 baudrateval)
 
 static int zynqmp_qspi_set_speed(struct udevice *bus, uint speed)
 {
-       struct zynqmp_qspi_plat *plat = bus->plat;
+       struct zynqmp_qspi_plat *plat = dev_get_plat(bus);
        struct zynqmp_qspi_priv *priv = dev_get_priv(bus);
        struct zynqmp_qspi_regs *regs = priv->regs;
        u32 confr;
index 3f5414ed1f8a5660c76daabd77bb776d6ce1fff8..e69fb2255b6ac30e69b52d6d16366ddefa249183 100644 (file)
@@ -9,12 +9,13 @@
 #include <common.h>
 #include <command.h>
 #include <cpu_func.h>
-#include <hang.h>
-#include <log.h>
-#include <sysreset.h>
 #include <dm.h>
 #include <errno.h>
+#include <hang.h>
+#include <log.h>
 #include <regmap.h>
+#include <spl.h>
+#include <sysreset.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/root.h>
@@ -101,7 +102,10 @@ void sysreset_walk_halt(enum sysreset_t type)
                mdelay(100);
 
        /* Still no reset? Give up */
-       log_err("System reset not supported on this platform\n");
+       if (spl_phase() <= PHASE_SPL)
+               log_err("no sysreset\n");
+       else
+               log_err("System reset not supported on this platform\n");
        hang();
 }
 
index 7026a48c4b23be7e1ceff7721211775debd52177..08685823e99dffe0f1eca3a6156a687ba5a79b41 100644 (file)
@@ -47,10 +47,10 @@ 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_of_valid(dev))
+       if (state->fdt_fname && !dev_has_ofnode(dev))
                return -ENODEV;
 
        switch (type) {
@@ -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
index 8f9970301e50cbc403d353a5737b8d7c6526ecf3..8042f3994fe2e0f1be9048f3400504b97b653b19 100644 (file)
 #include <acpi/acpi_s3.h>
 #include <asm/io.h>
 #include <asm/processor.h>
-
-struct x86_sysreset_plat {
-       struct udevice *pch;
-};
+#include <asm/sysreset.h>
 
 /*
  * Power down the machine by using the power management sleep control
index 7c38d6e0527231069f0c4e832952bb2b9f412ba5..b898c32edc0b61c3d2e4875d3c9061acb3781455 100644 (file)
@@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)
        const char *method;
 
        debug("optee: looking for conduit method in DT.\n");
-       method = ofnode_get_property(dev->node, "method", NULL);
+       method = ofnode_get_property(dev_ofnode(dev), "method", NULL);
        if (!method) {
                debug("optee: missing \"method\" property\n");
                return ERR_PTR(-ENXIO);
index 17174345e369768a794555967bc41dbc564a1ef6..27cf9b02471e2e104b111f592b6df8a1e6513a31 100644 (file)
@@ -64,7 +64,7 @@ struct atftmr_timer_plat {
 
 static u64 atftmr_timer_get_count(struct udevice *dev)
 {
-       struct atftmr_timer_plat *plat = dev->plat;
+       struct atftmr_timer_plat *plat = dev_get_plat(dev);
        struct atftmr_timer_regs *const regs = plat->regs;
        u32 val;
        val = readl(&regs->t3_counter);
@@ -73,7 +73,7 @@ static u64 atftmr_timer_get_count(struct udevice *dev)
 
 static int atftmr_timer_probe(struct udevice *dev)
 {
-       struct atftmr_timer_plat *plat = dev->plat;
+       struct atftmr_timer_plat *plat = dev_get_plat(dev);
        struct atftmr_timer_regs *const regs = plat->regs;
        u32 cr;
        writel(0, &regs->t3_load);
index 7e9abee0efc77df5b0a1368be9f7a83101fcd307..040dc65f48aaa27d5da68d1cbe8f1f92d89cb7db 100644 (file)
@@ -34,7 +34,7 @@ struct altera_timer_plat {
 
 static u64 altera_timer_get_count(struct udevice *dev)
 {
-       struct altera_timer_plat *plat = dev->plat;
+       struct altera_timer_plat *plat = dev_get_plat(dev);
        struct altera_timer_regs *const regs = plat->regs;
        u32 val;
 
@@ -49,7 +49,7 @@ static u64 altera_timer_get_count(struct udevice *dev)
 
 static int altera_timer_probe(struct udevice *dev)
 {
-       struct altera_timer_plat *plat = dev->plat;
+       struct altera_timer_plat *plat = dev_get_plat(dev);
        struct altera_timer_regs *const regs = plat->regs;
 
        writel(0, &regs->status);
index cec86718c7f73566e032c8e59d14d983b3c826c3..db2cf86f638a1b016b8bd1d8f5ae2acc8e16c716 100644 (file)
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <timer.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <linux/err.h>
 
 /* mtime register */
@@ -19,7 +20,7 @@
 
 static u64 andes_plmt_get_count(struct udevice *dev)
 {
-       return readq((void __iomem *)MTIME_REG(dev->priv));
+       return readq((void __iomem *)MTIME_REG(dev_get_priv(dev)));
 }
 
 static const struct timer_ops andes_plmt_ops = {
@@ -28,8 +29,8 @@ static const struct timer_ops andes_plmt_ops = {
 
 static int andes_plmt_probe(struct udevice *dev)
 {
-       dev->priv = dev_read_addr_ptr(dev);
-       if (!dev->priv)
+       dev_set_priv(dev, dev_read_addr_ptr(dev));
+       if (!dev_get_priv(dev))
                return -EINVAL;
 
        return timer_timebase_fallback(dev);
index 9b1daaadebf825752238d0546a96b60c9e692bb2..2f2b8be3dca971f09aa8916d5ed22eed2d94a2f8 100644 (file)
@@ -206,7 +206,7 @@ static u64 mpc83xx_timer_get_count(struct udevice *dev)
 
 static int mpc83xx_timer_probe(struct udevice *dev)
 {
-       struct timer_dev_priv *uc_priv = dev->uclass_priv;
+       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
        struct clk clock;
        int ret;
 
index 135c0f38a4d69ccdfd8218158314ec73e16d9717..2075cd4edda8d73924ce66e1622e9e82665ed615 100644 (file)
@@ -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",
 };
index 00ce0f08d6ee5c134f3fc3d06c8599d10a967562..de23b85404b66cf2a4cb91beb6b68ad7ed70289c 100644 (file)
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <timer.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <linux/err.h>
 
 /* mtime register */
@@ -16,7 +17,7 @@
 
 static u64 sifive_clint_get_count(struct udevice *dev)
 {
-       return readq((void __iomem *)MTIME_REG(dev->priv));
+       return readq((void __iomem *)MTIME_REG(dev_get_priv(dev)));
 }
 
 static const struct timer_ops sifive_clint_ops = {
@@ -25,8 +26,8 @@ static const struct timer_ops sifive_clint_ops = {
 
 static int sifive_clint_probe(struct udevice *dev)
 {
-       dev->priv = dev_read_addr_ptr(dev);
-       if (!dev->priv)
+       dev_set_priv(dev, dev_read_addr_ptr(dev));
+       if (!dev_get_priv(dev))
                return -EINVAL;
 
        return timer_timebase_fallback(dev);
index ab5355532735a8ac75c8b1737d66174dbfdcc890..da1a72f0252bb8a0ca5cac54a064c9c995c7db5b 100644 (file)
@@ -40,7 +40,7 @@ int notrace timer_get_count(struct udevice *dev, u64 *count)
 
 unsigned long notrace timer_get_rate(struct udevice *dev)
 {
-       struct timer_dev_priv *uc_priv = dev->uclass_priv;
+       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
        return uc_priv->clock_rate;
 }
@@ -54,7 +54,7 @@ static int timer_pre_probe(struct udevice *dev)
        ulong ret;
 
        /* It is possible that a timer device has a null ofnode */
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        err = clk_get_by_index(dev, 0, &timer_clk);
index e3677704b33ddd62e9f5b3c0c5dd3afdc9fc21f9..706d52b830a5f161d6a5825c4f8fbd7e7f6a4173 100644 (file)
@@ -477,15 +477,17 @@ static const struct timer_ops tsc_timer_ops = {
        .get_count = tsc_timer_get_count,
 };
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 static const struct udevice_id tsc_timer_ids[] = {
        { .compatible = "x86,tsc-timer", },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(x86_tsc_timer) = {
        .name   = "x86_tsc_timer",
        .id     = UCLASS_TIMER,
-       .of_match = tsc_timer_ids,
+       .of_match = of_match_ptr(tsc_timer_ids),
        .probe = tsc_timer_probe,
        .ops    = &tsc_timer_ops,
 };
index e861c82f7e17aca3fa018ecda18a263885c772f0..798a21793f711c890abaedb9c7942ceb1e5d8a4e 100644 (file)
@@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
        enum usb_dr_mode dr_mode;
        int ret = 0;
 
-       dr_mode = usb_get_dr_mode(dev->node);
+       dr_mode = usb_get_dr_mode(dev_ofnode(dev));
        cdns->role = USB_ROLE_NONE;
 
        /*
@@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       node = ofnode_by_compatible(parent->node, "cdns,usb3");
+       node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3");
        if (!ofnode_valid(node)) {
                ret = -ENODEV;
                goto fail;
index 2e003530a15eb2ccfb182e11289ebb592f1c049e..dfd7cf683f723b3f2e0b2f86a185c55e8e74cdc7 100644 (file)
@@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc)
         */
        hird_threshold = 12;
 
-       dwc->hsphy_mode = usb_get_phy_mode(dev->node);
+       dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev));
 
        dwc->has_lpm_erratum = dev_read_bool(dev,
                                "snps,has-lpm-erratum");
index ba9f9a4e0b699245345b117e35bd493e80a662ee..30f835e1e3d01de4278051eb7d24f102b4e40541 100644 (file)
@@ -108,7 +108,7 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_of_to_plat(struct udevice *dev)
 {
        struct dwc3_generic_plat *plat = dev_get_plat(dev);
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
 
        plat->base = dev_read_addr(dev);
 
@@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       ofnode_for_each_subnode(node, parent->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(parent)) {
                const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
                struct udevice *dev;
@@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev)
        while (child) {
                enum usb_dr_mode dr_mode;
 
-               dr_mode = usb_get_dr_mode(child->node);
+               dr_mode = usb_get_dr_mode(dev_ofnode(child));
                device_find_next_child(&child);
                if (ops && ops->select_dr_mode)
                        ops->select_dr_mode(dev, index, dr_mode);
index 36955b5b6983b4723af143745941475edf78bf66..bd8bf227c8bf0a4258dfaea5ee849c852654412b 100644 (file)
@@ -392,7 +392,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
        }
 #endif
 
-       priv->otg_mode = usb_get_dr_mode(dev->node);
+       priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
        ret = dwc3_meson_g12a_usb_init(priv);
        if (ret)
index b63cc235f7e0b8139a08ecf7d9cfc9160e96dfc2..08467d6210b688726870ab17bdf7700d5dce567b 100644 (file)
@@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
        if (ret)
                return ret;
 
-       priv->otg_mode = usb_get_dr_mode(dev->node);
+       priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
        if (priv->otg_mode == USB_DR_MODE_PERIPHERAL)
                priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL;
index 4771b1e931234624228c611e150e963e59e78b91..e3871e381e1493633432162532367e7717c63199 100644 (file)
@@ -987,8 +987,8 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
        void (*set_params)(struct dwc2_plat_otg_data *data);
        int ret;
 
-       if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
-           usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
+       if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL &&
+           usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) {
                dev_dbg(dev, "Invalid mode\n");
                return -ENODEV;
        }
index 7830a4aee9422e0b8d103c7965ca0d924871df3c..16922ff15c691bff411b56da24f1ba114c02cd7a 100644 (file)
@@ -1860,10 +1860,18 @@ static int rndis_control_ack(struct eth_device *net)
 static int rndis_control_ack(struct udevice *net)
 #endif
 {
-       struct ether_priv       *priv = (struct ether_priv *)net->priv;
-       struct eth_dev          *dev = &priv->ethdev;
-       int                     length;
-       struct usb_request      *resp = dev->stat_req;
+       struct ether_priv *priv;
+       struct eth_dev *dev;
+       int length;
+       struct usb_request *resp;
+
+#ifndef CONFIG_DM_ETH
+       priv = (struct ether_priv *)net->priv;
+#else
+       priv = dev_get_priv(net);
+#endif
+       dev = &priv->ethdev;
+       resp = dev->stat_req;
 
        /* in case RNDIS calls this after disconnect */
        if (!dev->status) {
index c3cac9c5abdbb691bf666b33604b5aef9da2e76e..742e156cbb94cdd78b0346dc54be5a8e62794ed3 100644 (file)
@@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev)
 
        /* Find snps,dwc3 node from subnode */
        dwc3_node = ofnode_null();
-       ofnode_for_each_subnode(node, dev->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(dev)) {
                if (ofnode_device_is_compatible(node, "snps,dwc3"))
                        dwc3_node = node;
        }
index 80e543496d93d489765a0798dfe62576b8681a5d..1234399f33b36ef6695f66b4dfb240fabfcdc555 100644 (file)
@@ -108,7 +108,8 @@ static int sti_dwc3_glue_of_to_plat(struct udevice *dev)
        int ret;
        u32 reg[4];
 
-       ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
+       ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg,
+                                   ARRAY_SIZE(reg));
        if (ret) {
                pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
                return ret;
@@ -154,7 +155,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
        ofnode node, dwc3_node;
 
        /* Find snps,dwc3 node from subnode */
-       ofnode_for_each_subnode(node, dev->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(dev)) {
                if (ofnode_device_is_compatible(node, "snps,dwc3"))
                        dwc3_node = node;
        }
index d2f49cf4690101e58f3202c1e9816ac4c1c4917e..ef3a63afa4406f9a0418eb54aa2fe0adf656f818 100644 (file)
@@ -523,7 +523,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
        struct usb_plat *plat = dev_get_plat(dev);
        enum usb_dr_mode dr_mode;
 
-       dr_mode = usb_get_dr_mode(dev->node);
+       dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 
        switch (dr_mode) {
        case USB_DR_MODE_HOST:
index a2bd7436f425ee3c9f29ff608e6af06817402617..e3b616c3266ae7ffa6c4843bd09a9c027aefdb17 100644 (file)
@@ -60,7 +60,7 @@ int submit_control_msg(struct usb_device *udev, unsigned long pipe,
 {
        struct udevice *bus = udev->controller_dev;
        struct dm_usb_ops *ops = usb_get_ops(bus);
-       struct usb_uclass_priv *uc_priv = bus->uclass->priv;
+       struct usb_uclass_priv *uc_priv = uclass_get_priv(bus->uclass);
        int err;
 
        if (!ops->control)
@@ -184,7 +184,7 @@ int usb_stop(void)
        if (ret)
                return ret;
 
-       uc_priv = uc->priv;
+       uc_priv = uclass_get_priv(uc);
 
        uclass_foreach_dev(bus, uc) {
                ret = device_remove(bus, DM_REMOVE_NORMAL);
@@ -263,7 +263,7 @@ int usb_init(void)
        if (ret)
                return ret;
 
-       uc_priv = uc->priv;
+       uc_priv = uclass_get_priv(uc);
 
        uclass_foreach_dev(bus, uc) {
                /* init low_level USB */
@@ -517,7 +517,7 @@ static ofnode usb_get_ofnode(struct udevice *hub, int port)
        ofnode node;
        u32 reg;
 
-       if (!dev_has_of_node(hub))
+       if (!dev_has_ofnode(hub))
                return ofnode_null();
 
        /*
@@ -773,7 +773,7 @@ static int usb_child_post_bind(struct udevice *dev)
        struct usb_dev_plat *plat = dev_get_parent_plat(dev);
        int val;
 
-       if (!dev_of_valid(dev))
+       if (!dev_has_ofnode(dev))
                return 0;
 
        /* We only support matching a few things */
index 59408e4e50ec38650f9ed4e5b159d6aeb55b9691..3e0ae80cece076a40457bded275540f9d1afab4a 100644 (file)
@@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
        writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
-       dr_mode = usb_get_dr_mode(dev->node);
+       dr_mode = usb_get_dr_mode(dev_ofnode(dev));
        if (dr_mode == USB_DR_MODE_UNKNOWN)
                /* by default set dual role mode to HOST */
                dr_mode = USB_DR_MODE_HOST;
index 28136f88f450f35d8ac2415163ba048185adc793..2f5cc9b1480385ac0c2ef09c541dd50dc93e448e 100644 (file)
@@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
        mtu->ippc_base = ssusb->ippc_base;
        mtu->mac_base = ssusb->mac_base;
        mtu->ssusb = ssusb;
-       mtu->max_speed = usb_get_maximum_speed(dev->node);
+       mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev));
        mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus");
 
        ret = mtu3_hw_init(mtu);
index c951107b20133444a44e3d236071ca881add8500..b097471f3d4e9b2f0b4a920f571a747f0a3adcde 100644 (file)
@@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
                return -ENODEV;
        }
 
-       ssusb->dr_mode = usb_get_dr_mode(child->node);
+       ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child));
 
        if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN ||
                ssusb->dr_mode == USB_DR_MODE_OTG)
@@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       node = ofnode_by_compatible(parent->node, "mediatek,ssusb");
+       node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb");
        if (!ofnode_valid(node))
                return -ENODEV;
 
index 81b12fadfc1c47d42d744ee54e3159e5e50265b5..75cf1811f7aa11aabfc6f8c74beb6a911ea77614 100644 (file)
@@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       ofnode_for_each_subnode(node, parent->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(parent)) {
                struct udevice *dev;
                const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
index abf40bddfbe7f2c52889510e0389e1619800bebb..dd87fc461b95417fe3d14b7dd5029b55392c7408 100644 (file)
@@ -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;
index 00e2c36f376bc80145ba8441988681908d1d1cc7..b47bef3578f7d5dbe0d586d31209d985b4fc5636 100644 (file)
@@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void)
                      __func__);
                return NULL;
        }
-       node = dev->node.of_offset;
+       node = dev_ofnode(dev).of_offset;
 
        if (CONFIG_IS_ENABLED(OF_CONTROL)) {
                ret = nx_display_parse_dt(dev, dp, plat);
index d125a5ba737456125da77444f95378a8d18ae268..159201a59168ae3537042d0c07d686047e9b537c 100644 (file)
@@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev,
        rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
        /* Set dpi color coding depth 24 bit */
-       timing_node = ofnode_find_subnode(dev->node, "display-timings");
+       timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings");
        node = ofnode_first_subnode(timing_node);
 
        val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
index 50657a77d368b3fc7dfe2e157fc7bf78cf68c65d..a3e21aa5f13e3698de791a81caea268430277d82 100644 (file)
@@ -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"
 };
 
index 3e8d71538f2e7c5de6b18c09bb2b7b9feb599fe7..0b8cefc311ef03219b1c27a3025bec07fe77f7b1 100644 (file)
@@ -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"
 };
index dd2bb1f5fc58200673b24c27c6ccc47b4bdb88d9..635edf6dd3bbb9d0fc7d8f0a7e183c4902ef604c 100644 (file)
@@ -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
index 20f6973b4b673e06dde47ee32c4603d67fe3fe8e..8883e2903570612617b571f66cd96b25beaac646 100644 (file)
@@ -378,7 +378,7 @@ static int video_post_bind(struct udevice *dev)
                return 0;
 
        /* Set up the video pointer, if this is the first device */
-       uc_priv = dev->uclass->priv;
+       uc_priv = uclass_get_priv(dev->uclass);
        if (!uc_priv->video_ptr)
                uc_priv->video_ptr = gd->video_top;
 
index aeda542f985707a0cfef7fbfa29f2f738122e92f..71f50552e4fe1ee020863244df4b89f9527407d5 100644 (file)
@@ -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
index a20930eb9a5e656bbdedf924e4f754c7da7552e4..94967cf656ca7f8492a6ebd8ec6ab7fc2b0d51e5 100644 (file)
@@ -16,7 +16,8 @@ else
 DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
 endif
 
-$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
+$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
+       mkdir -p $(dir $@)
        $(call if_changed,fdtgrep)
 
 ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
@@ -27,7 +28,7 @@ $(obj)/dt.dtb: $(DTB) FORCE
        $(call if_changed,shipped)
 endif
 
-targets += dt.dtb dt-spl.dtb
+targets += dt.dtb
 
 $(DTB): arch-dtbs
        $(Q)test -e $@ || (                                             \
@@ -51,10 +52,15 @@ else
 obj-$(CONFIG_OF_EMBED) := dt.dtb.o
 endif
 
-dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb
+# Target for U-Boot proper
+dtbs: $(obj)/dt.dtb
        @:
 
-clean-files := dt.dtb.S dt-spl.dtb.S
+# Target for SPL/TPL
+spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
+       @:
+
+clean-files := dt.dtb.S
 
 # Let clean descend into dts directories
 subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts
index 887b5c268de2f3393c180fd297bf01f0618b6b2d..31e249177c3aa7279772f5dd99598f5f741334cc 100644 (file)
@@ -194,7 +194,13 @@ struct global_data {
        /**
         * @uclass_root: head of core tree
         */
-       struct list_head uclass_root;
+       struct list_head uclass_root_s;
+       /**
+        * @uclass_root: pointer to head of core tree, if uclasses are in
+        * read-only memory and cannot be adjusted to use @uclass_root as a
+        * list head.
+        */
+       struct list_head *uclass_root;
 # if CONFIG_IS_ENABLED(OF_PLATDATA)
        /** @dm_driver_rt: Dynamic info about the driver */
        struct driver_rt *dm_driver_rt;
index af3b6b2b054c8c054baca63145a41ad28b1f12c0..639bbd293d924ab245955c827d769d057fb18784 100644 (file)
@@ -189,6 +189,90 @@ static inline int device_chld_remove(struct udevice *dev, struct driver *drv,
 }
 #endif
 
+/**
+ * dev_set_priv() - Set the private data for a device
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * private data when an 'auto' size if provided by the driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @dev                Device to check
+ * @priv       New private-data pointer
+ */
+void dev_set_priv(struct udevice *dev, void *priv);
+
+/**
+ * dev_set_parent_priv() - Set the parent-private data for a device
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * parent-private data when an 'auto' size if provided by the driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @dev:       Device to update
+ * @parent_priv: New parent-private data
+ */
+void dev_set_parent_priv(struct udevice *dev, void *parent_priv);
+
+/**
+ * dev_set_uclass_priv() - Set the uclass private data for a device
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * uclass-private data when an 'auto' size if provided by the driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @dev:       Device to update
+ * @uclass_priv: New uclass private data
+ */
+void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv);
+
+/**
+ * dev_set_plat() - Set the platform data for a device
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * platform data when an 'auto' size if provided by the driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @dev                Device to check
+ * @plat       New platform-data pointer
+ */
+void dev_set_plat(struct udevice *dev, void *priv);
+
+/**
+ * dev_set_parent_plat() - Set the parent platform data for a device
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * parent platform data when an 'auto' size if provided by the driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @dev:       Device to update
+ * @parent_plat: New parent platform data
+ */
+void dev_set_parent_plat(struct udevice *dev, void *parent_plat);
+
+/**
+ * dev_set_uclass_plat() - Set the uclass platform data for a device
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * uclass platform data when an 'auto' size if provided by the driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @dev:       Device to update
+ * @uclass_plat: New uclass platform data
+ */
+void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat);
+
 /**
  * simple_bus_translate() - translate a bus address to a system address
  *
@@ -204,6 +288,7 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr);
 /* Cast away any volatile pointer */
 #define DM_ROOT_NON_CONST              (((gd_t *)gd)->dm_root)
 #define DM_UCLASS_ROOT_NON_CONST       (((gd_t *)gd)->uclass_root)
+#define DM_UCLASS_ROOT_S_NON_CONST     (((gd_t *)gd)->uclass_root_s)
 
 /* device resource management */
 #ifdef CONFIG_DEVRES
index 30fc98dc3451dbf0886c9b3a97735a35d966c930..f5b4cd6876e975f52a27948784f97ad943156242 100644 (file)
@@ -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
@@ -116,26 +116,34 @@ enum {
  *
  * @driver: The driver used by this device
  * @name: Name of device, typically the FDT node name
- * @plat: Configuration data for this device
- * @parent_plat: The parent bus's configuration data for this device
- * @uclass_plat: The uclass's configuration data for this device
- * @node: Reference to device tree node for this device
+ * @plat_: Configuration data for this device (do not access outside driver
+ *     model)
+ * @parent_plat_: The parent bus's configuration data for this device (do not
+ *     access outside driver model)
+ * @uclass_plat_: The uclass's configuration data for this device (do not access
+ *     outside driver model)
  * @driver_data: Driver data word for the entry that matched this device with
  *             its driver
  * @parent: Parent of this device, or NULL for the top level device
- * @priv: Private data for this device
+ * @priv_: Private data for this device (do not access outside driver model)
  * @uclass: Pointer to uclass for this device
- * @uclass_priv: The uclass's private data for this device
- * @parent_priv: The parent's private data for this device
+ * @uclass_priv_: The uclass's private data for this device (do not access
+ *     outside driver model)
+ * @parent_priv_: The parent's private data for this device (do not access
+ *     outside driver model)
  * @uclass_node: Used by uclass to link its devices
  * @child_head: List of children of this device
  * @sibling_node: Next device in list of all devices
- * @flags: Flags for this device DM_FLAG_...
- * @seq: Allocated sequence number for this device (-1 = none). This is set up
+ * @flags_: Flags for this device DM_FLAG_... (do not access outside driver
+ *     model)
+ * @seq_: Allocated sequence number for this device (-1 = none). This is set up
  * when the device is bound and is unique within the device's uclass. If the
  * device has an alias in the devicetree then that is used to set the sequence
  * number. Otherwise, the next available number is used. Sequence numbers are
- * used by certain commands that need device to be numbered (e.g. 'mmc dev')
+ * used by certain commands that need device to be numbered (e.g. 'mmc dev').
+ * (do not access outside driver model)
+ * @node_: Reference to device tree node for this device (do not access outside
+ *     driver model)
  * @devres_head: List of memory allocations associated with this device.
  *             When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
  *             add to this list. Memory so-allocated will be freed
@@ -144,21 +152,23 @@ enum {
 struct udevice {
        const struct driver *driver;
        const char *name;
-       void *plat;
-       void *parent_plat;
-       void *uclass_plat;
-       ofnode node;
+       void *plat_;
+       void *parent_plat_;
+       void *uclass_plat_;
        ulong driver_data;
        struct udevice *parent;
-       void *priv;
+       void *priv_;
        struct uclass *uclass;
-       void *uclass_priv;
-       void *parent_priv;
+       void *uclass_priv_;
+       void *parent_priv_;
        struct list_head uclass_node;
        struct list_head child_head;
        struct list_head sibling_node;
-       uint32_t flags;
-       int sqq;
+       u32 flags_;
+       int seq_;
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       ofnode node_;
+#endif
 #ifdef CONFIG_DEVRES
        struct list_head devres_head;
 #endif
@@ -170,22 +180,67 @@ struct udevice {
 /* Returns the operations for a device */
 #define device_get_ops(dev)    (dev->driver->ops)
 
+static inline u32 dev_get_flags(const struct udevice *dev)
+{
+       return dev->flags_;
+}
+
+static inline void dev_or_flags(struct udevice *dev, u32 or)
+{
+       dev->flags_ |= or;
+}
+
+static inline void dev_bic_flags(struct udevice *dev, u32 bic)
+{
+       dev->flags_ &= ~bic;
+}
+
+/**
+ * dev_ofnode() - get the DT node reference associated with a udevice
+ *
+ * @dev:       device to check
+ * @return reference of the the device's DT node
+ */
+static inline ofnode dev_ofnode(const struct udevice *dev)
+{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       return dev->node_;
+#else
+       return ofnode_null();
+#endif
+}
+
 /* Returns non-zero if the device is active (probed and not removed) */
-#define device_active(dev)     ((dev)->flags & DM_FLAG_ACTIVATED)
+#define device_active(dev)     (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 
 static inline int dev_of_offset(const struct udevice *dev)
 {
-       return ofnode_to_offset(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       return ofnode_to_offset(dev_ofnode(dev));
+#else
+       return -1;
+#endif
 }
 
-static inline bool dev_has_of_node(struct udevice *dev)
+static inline bool dev_has_ofnode(const struct udevice *dev)
 {
-       return ofnode_valid(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       return ofnode_valid(dev_ofnode(dev));
+#else
+       return false;
+#endif
+}
+
+static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
+{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       dev->node_ = node;
+#endif
 }
 
 static inline int dev_seq(const struct udevice *dev)
 {
-       return dev->sqq;
+       return dev->seq_;
 }
 
 /**
@@ -238,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.
@@ -280,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)
 
 /**
@@ -288,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
index 070bc9c19f61c8eff76590365653530651be7bad..1a86552546169f11c465351774065f0ee764220d 100644 (file)
@@ -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)
index d650fb39190ebc6cece502ffbc24e517aa334a2c..3821a56f2ca145f620056afd553ee55be9e1346a 100644 (file)
@@ -56,46 +56,34 @@ 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")
+#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
-#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_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([email protected]): U_BOOT_DEVICE() 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_DEVICE entry get by
- * DM_GET_DEVICE. The implementation of this function will be done
- * by dtoc when parsing dtb.
- */
-void dm_populate_phandle_data(void);
 #endif
index c5aa3212915a746183409d34f1e43b8e8da1706d..7f74b3cbc5c6467f126fc2cdc472e7ae7804c062 100644 (file)
@@ -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.
  */
 
index 0585eb12281c792761404885728f891fb18a816e..fc987f775986f6c61a701de479558730759cf495 100644 (file)
@@ -21,7 +21,7 @@ struct resource;
 #if CONFIG_IS_ENABLED(OF_LIVE)
 static inline const struct device_node *dev_np(const struct udevice *dev)
 {
-       return ofnode_to_np(dev->node);
+       return ofnode_to_np(dev_ofnode(dev));
 }
 #else
 static inline const struct device_node *dev_np(const struct udevice *dev)
@@ -30,22 +30,6 @@ static inline const struct device_node *dev_np(const struct udevice *dev)
 }
 #endif
 
-/**
- * dev_ofnode() - get the DT node reference associated with a udevice
- *
- * @dev:       device to check
- * @return reference of the the device's DT node
- */
-static inline ofnode dev_ofnode(const struct udevice *dev)
-{
-       return dev->node;
-}
-
-static inline bool dev_of_valid(const struct udevice *dev)
-{
-       return ofnode_valid(dev_ofnode(dev));
-}
-
 #ifndef CONFIG_DM_DEV_READ_INLINE
 
 /**
diff --git a/include/dm/simple_bus.h b/include/dm/simple_bus.h
new file mode 100644 (file)
index 0000000..4ad4cc4
--- /dev/null
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef __DM_SIMPLE_BUS_H
+#define __DM_SIMPLE_BUS_H
+
+struct simple_bus_plat {
+       u32 base;
+       u32 size;
+       u32 target;
+};
+
+#endif
index b2adce730adb07077fc354674883dc66505386d0..6ac6672cd6f663467d3d88b1731c297ab4db108a 100644 (file)
@@ -134,14 +134,12 @@ extern struct unit_test_state global_dm_test_state;
  * @testdev: Test device
  * @force_fail_alloc: Force all memory allocs to fail
  * @skip_post_probe: Skip uclass post-probe processing
- * @removed: Used to keep track of a device that was removed
  */
 struct dm_test_state {
        struct udevice *root;
        struct udevice *testdev;
        int force_fail_alloc;
        int skip_post_probe;
-       struct udevice *removed;
 };
 
 /* Declare a new driver model test */
@@ -169,6 +167,24 @@ struct sandbox_sdl_plat {
        int font_size;
 };
 
+/**
+ * struct dm_test_parent_plat - Used to track state in bus tests
+ *
+ * @count:
+ * @bind_flag: Indicates that the child post-bind method was called
+ * @uclass_bind_flag: Also indicates that the child post-bind method was called
+ */
+struct dm_test_parent_plat {
+       int count;
+       int bind_flag;
+       int uclass_bind_flag;
+};
+
+enum {
+       TEST_FLAG_CHILD_PROBED  = 10,
+       TEST_FLAG_CHILD_REMOVED = -7,
+};
+
 /* Declare ping methods for the drivers */
 int test_ping(struct udevice *dev, int pingval, int *pingret);
 int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
index 3e052f95d324bcbe052a516eaf19fe185f7286a2..c5a464be7c44c4187960fea4c845f6d5a7c8b67c 100644 (file)
 
 #include <dm/ofnode.h>
 
+/**
+ * uclass_set_priv() - Set the private data for a uclass
+ *
+ * This is normally handled by driver model, which automatically allocates
+ * private data when an 'auto' size if provided by the uclass driver.
+ *
+ * Use this function to override normal operation for special situations, such
+ * as needing to allocate a variable amount of data.
+ *
+ * @uc         Uclass to update
+ * @priv       New private-data pointer
+ */
+void uclass_set_priv(struct uclass *uc, void *priv);
+
 /**
  * uclass_find_next_free_seq() - Get the next free sequence number
  *
index 91edbfb47d4265a3998f43af4667daa3e8c128b7..b5f066dbf48bf3da2de23a96c97741a0b5315dbb 100644 (file)
@@ -24,7 +24,7 @@
  * There may be drivers for on-chip SoC GPIO banks, I2C GPIO expanders and
  * PMIC IO lines, all made available in a unified way through the uclass.
  *
- * @priv: Private data for this uclass
+ * @priv_: Private data for this uclass (do not access outside driver model)
  * @uc_drv: The driver for the uclass itself, not to be confused with a
  * 'struct driver'
  * @dev_head: List of devices in this uclass (devices are attached to their
@@ -32,7 +32,7 @@
  * @sibling_node: Next uclass in the linked list of uclasses
  */
 struct uclass {
-       void *priv;
+       void *priv_;
        struct uclass_driver *uc_drv;
        struct list_head dev_head;
        struct list_head sibling_node;
@@ -112,7 +112,15 @@ struct uclass_driver {
 
 /* Declare a new uclass_driver */
 #define UCLASS_DRIVER(__name)                                          \
-       ll_entry_declare(struct uclass_driver, __name, uclass)
+       ll_entry_declare(struct uclass_driver, __name, uclass_driver)
+
+/**
+ * uclass_get_priv() - Get the private data for a uclass
+ *
+ * @uc         Uclass to check
+ * @return private data, or NULL if none
+ */
+void *uclass_get_priv(const struct uclass *uc);
 
 /**
  * uclass_get() - Get a uclass based on an ID, creating it if needed
@@ -256,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.
index 1b9151714c0bf11828c8779f3555887b29cae4c8..927854950a03ef93b26351d65039aaef8b937f14 100644 (file)
@@ -332,15 +332,14 @@ struct mtd_info {
 };
 
 #if IS_ENABLED(CONFIG_DM)
-static inline void mtd_set_of_node(struct mtd_info *mtd,
-                                  const struct device_node *np)
+static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
 {
-       mtd->dev->node.np = np;
+       dev_set_ofnode(mtd->dev, node);
 }
 
-static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
 {
-       return mtd->dev->node.np;
+       return dev_ofnode(mtd->dev);
 }
 #else
 struct device_node;
index 13e8dd110352404ed66a95d3b10989a5b2a314bd..7774c17ad5d5e7e4a79cadff8eaa4adcb62c8649 100644 (file)
@@ -389,6 +389,7 @@ static inline int nanddev_unregister(struct nand_device *nand)
        return mtd_device_unregister(nand->mtd);
 }
 
+#ifndef __UBOOT__
 /**
  * nanddev_set_of_node() - Attach a DT node to a NAND device
  * @nand: NAND device
@@ -412,6 +413,19 @@ static inline const struct device_node *nanddev_get_of_node(struct nand_device *
 {
        return mtd_get_of_node(nand->mtd);
 }
+#else
+/**
+ * nanddev_set_of_node() - Attach a DT node to a NAND device
+ * @nand: NAND device
+ * @node: ofnode
+ *
+ * Attach a DT node to a NAND device.
+ */
+static inline void nanddev_set_ofnode(struct nand_device *nand, ofnode node)
+{
+       mtd_set_ofnode(nand->mtd, node);
+}
+#endif /* __UBOOT__ */
 
 /**
  * nanddev_offs_to_pos() - Convert an absolute NAND offset into a NAND position
index 233fdc341a782128d995616f197269497509e160..4a8e19ee4f9661df46cdd37de160510531c1742c 100644 (file)
@@ -258,11 +258,13 @@ struct flash_info;
 /*
  * TODO: Remove, once all users of spi_flash interface are moved to MTD
  *
- * struct spi_flash {
+struct spi_flash {
  *     Defined below (keep this text to enable searching for spi_flash decl)
  * }
  */
+#ifndef DT_PLAT_C
 #define spi_flash spi_nor
+#endif
 
 /**
  * struct spi_nor - Structure for defining a the SPI NOR layer
@@ -352,6 +354,7 @@ struct spi_nor {
        u32 erase_size;
 };
 
+#ifndef __UBOOT__
 static inline void spi_nor_set_flash_node(struct spi_nor *nor,
                                          const struct device_node *np)
 {
@@ -363,6 +366,7 @@ device_node *spi_nor_get_flash_node(struct spi_nor *nor)
 {
        return mtd_get_of_node(&nor->mtd);
 }
+#endif /* __UBOOT__ */
 
 /**
  * struct spi_nor_hwcaps - Structure for describing the hardware capabilies
index 88bacde91e53531c7fede3c5bbcf0d4a18f052b5..15bcd59f3417d066911fcbfb9fb1b768dbc0011c 100644 (file)
@@ -412,6 +412,7 @@ spinand_to_nand(struct spinand_device *spinand)
        return &spinand->base;
 }
 
+#ifndef __UBOOT__
 /**
  * spinand_set_of_node - Attach a DT node to a SPI NAND device
  * @spinand: SPI NAND device
@@ -424,6 +425,20 @@ static inline void spinand_set_of_node(struct spinand_device *spinand,
 {
        nanddev_set_of_node(&spinand->base, np);
 }
+#else
+/**
+ * spinand_set_of_node - Attach a DT node to a SPI NAND device
+ * @spinand: SPI NAND device
+ * @node: ofnode
+ *
+ * Attach a DT node to a SPI NAND device.
+ */
+static inline void spinand_set_ofnode(struct spinand_device *spinand,
+                                     ofnode node)
+{
+       nanddev_set_ofnode(&spinand->base, node);
+}
+#endif /* __UBOOT__ */
 
 int spinand_match_and_init(struct spinand_device *dev,
                           const struct spinand_info *table,
index bef29610325751c71b267381dc36f38146351d43..bef20719980676df2c1b7e5de7fbe58c490825f1 100644 (file)
@@ -21,6 +21,9 @@
  * will not allocate storage for arrays of size 0
  */
 
+#ifndef __ns16550_h
+#define __ns16550_h
+
 #include <linux/types.h>
 
 #ifdef CONFIG_DM_SERIAL
@@ -82,7 +85,7 @@ struct ns16550_plat {
 
 struct udevice;
 
-struct NS16550 {
+struct ns16550 {
        UART_REG(rbr);          /* 0 */
        UART_REG(ier);          /* 1 */
        UART_REG(fcr);          /* 2 */
@@ -120,8 +123,6 @@ struct NS16550 {
 #define dll rbr
 #define dlm ier
 
-typedef struct NS16550 *NS16550_t;
-
 /*
  * These are the definitions for the FIFO Control Register
  */
@@ -221,11 +222,11 @@ typedef struct NS16550 *NS16550_t;
 /* useful defaults for LCR */
 #define UART_LCR_8N1   0x03
 
-void NS16550_init(NS16550_t com_port, int baud_divisor);
-void NS16550_putc(NS16550_t com_port, char c);
-char NS16550_getc(NS16550_t com_port);
-int NS16550_tstc(NS16550_t com_port);
-void NS16550_reinit(NS16550_t com_port, int baud_divisor);
+void ns16550_init(struct ns16550 *com_port, int baud_divisor);
+void ns16550_putc(struct ns16550 *com_port, char c);
+char ns16550_getc(struct ns16550 *com_port);
+int ns16550_tstc(struct ns16550 *com_port);
+void ns16550_reinit(struct ns16550 *com_port, int baud_divisor);
 
 /**
  * ns16550_calc_divisor() - calculate the divisor given clock and baud rate
@@ -238,7 +239,7 @@ void NS16550_reinit(NS16550_t com_port, int baud_divisor);
  * @baudrate:  Required baud rate
  * @return baud rate divisor that should be used
  */
-int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate);
+int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate);
 
 /**
  * ns16550_serial_of_to_plat() - convert DT to platform data
@@ -266,3 +267,5 @@ int ns16550_serial_probe(struct udevice *dev);
  * These should be used by the client driver for the driver's 'ops' member
  */
 extern const struct dm_serial_ops ns16550_serial_ops;
+
+#endif /* __ns16550_h */
index 374a295fa369c1b63f660f9d3511f16ddc7f1fcc..a7648787b7428970a47e73b70f1dd46540e66946 100644 (file)
@@ -285,7 +285,15 @@ u32 spl_mmc_boot_mode(const u32 boot_device);
  * If not overridden, it is weakly defined in common/spl/spl_mmc.c.
  */
 int spl_mmc_boot_partition(const u32 boot_device);
-void spl_set_bd(void);
+
+/**
+ * spl_alloc_bd() - Allocate space for bd_info
+ *
+ * This sets up the gd->bd pointer by allocating memory for it
+ *
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+int spl_alloc_bd(void);
 
 /**
  * spl_set_header_raw_uboot() - Set up a standard SPL image structure
index 03e29290bf433724f100bafcada5900955b90fe5..3fdaa2b5e51780edc8b2aee6bf7501278944616b 100644 (file)
@@ -94,6 +94,15 @@ enum {
        TEST_DEVRES_SIZE3       = 37,
 };
 
+/**
+ * testbus_get_clear_removed() - Test function to obtain removed device
+ *
+ * This is used in testbus to find out which device was removed. Calling this
+ * function returns a pointer to the device and then clears it back to NULL, so
+ * that a future test can check it.
+ */
+struct udevice *testbus_get_clear_removed(void);
+
 /**
  * dm_test_main() - Run driver model tests
  *
index 10a9c073ba1183547054b3cf5ec4bcebc60f85a0..a42bdad6b871799fe1aa8b03668ad3c88221d36c 100644 (file)
@@ -492,7 +492,7 @@ static inline void __virtio_clear_bit(struct udevice *udev, unsigned int fbit)
  */
 static inline bool virtio_has_feature(struct udevice *vdev, unsigned int fbit)
 {
-       if (!(vdev->flags & DM_FLAG_BOUND))
+       if (!(dev_get_flags(vdev) & DM_FLAG_BOUND))
                WARN_ON(true);
 
        return __virtio_test_bit(vdev->parent, fbit);
index 7d650d512e30b142b0869adb5c3fd0e81cab496f..b3393e47fae0daf286e645b73b85506d5f474b8a 100644 (file)
@@ -67,7 +67,7 @@ void putc(const char ch)
                putc('\r');
 
        if (use_uart) {
-               NS16550_t com_port = (NS16550_t)0x3f8;
+               struct ns16550 *com_port = (struct ns16550 *)0x3f8;
 
                while ((inb((ulong)&com_port->lsr) & UART_LSR_THRE) == 0)
                        ;
index 99b50780063a03f92f2f7514aa5a367797a700ae..c9315dd4585767af696437a40739390cb514c6cd 100644 (file)
@@ -531,7 +531,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
        case UCLASS_ETH: {
                struct efi_device_path_mac_addr *dp =
                        dp_fill(buf, dev->parent);
-               struct eth_pdata *pdata = dev->plat;
+               struct eth_pdata *pdata = dev_get_plat(dev);
 
                dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
                dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR;
index 88bc50405ff39df143db028cfc6a90d988120506..cc6944ec345d8358af96da4a9be46ca76dae7c5d 100644 (file)
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <init.h>
+#include <spl.h>
 #include <time.h>
 #include <timer.h>
 #include <watchdog.h>
@@ -96,8 +97,13 @@ uint64_t notrace get_ticks(void)
        }
 
        ret = timer_get_count(gd->timer, &count);
-       if (ret)
-               panic("Could not read count from timer (err %d)\n", ret);
+       if (ret) {
+               if (spl_phase() > PHASE_TPL)
+                       panic("Could not read count from timer (err %d)\n",
+                             ret);
+               else
+                       panic("no timer (err %d)\n", ret);
+       }
 
        return count;
 }
index e2d6731975a2f2ef8e4b2632b22c9d21c7156629..0156324032bf3ed450084a02504d9908a9f4f3f6 100644 (file)
@@ -50,7 +50,7 @@ static struct eth_uclass_priv *eth_get_uclass_priv(void)
                return NULL;
 
        assert(uc);
-       return uc->priv;
+       return uclass_get_priv(uc);
 }
 
 void eth_set_current_to_next(void)
@@ -146,7 +146,7 @@ unsigned char *eth_get_ethaddr(void)
        struct eth_pdata *pdata;
 
        if (eth_get_dev()) {
-               pdata = eth_get_dev()->plat;
+               pdata = dev_get_plat(eth_get_dev());
                return pdata->enetaddr;
        }
 
@@ -163,7 +163,7 @@ int eth_init_state_only(void)
        if (!current || !device_active(current))
                return -EINVAL;
 
-       priv = current->uclass_priv;
+       priv = dev_get_uclass_priv(current);
        priv->state = ETH_STATE_ACTIVE;
 
        return 0;
@@ -179,7 +179,7 @@ void eth_halt_state_only(void)
        if (!current || !device_active(current))
                return;
 
-       priv = current->uclass_priv;
+       priv = dev_get_uclass_priv(current);
        priv->state = ETH_STATE_PASSIVE;
 }
 
@@ -200,7 +200,7 @@ static int eth_write_hwaddr(struct udevice *dev)
 
        /* seq is valid since the device is active */
        if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev_seq(dev))) {
-               pdata = dev->plat;
+               pdata = dev_get_plat(dev);
                if (!is_valid_ethaddr(pdata->enetaddr)) {
                        printf("\nError: %s address %pM illegal value\n",
                               dev->name, pdata->enetaddr);
@@ -234,7 +234,7 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op,
 
        retval = uclass_find_device_by_seq(UCLASS_ETH, index, &dev);
        if (!retval) {
-               struct eth_pdata *pdata = dev->plat;
+               struct eth_pdata *pdata = dev_get_plat(dev);
                switch (op) {
                case env_op_create:
                case env_op_overwrite:
@@ -287,7 +287,7 @@ int eth_init(void)
                                ret = eth_get_ops(current)->start(current);
                                if (ret >= 0) {
                                        struct eth_device_priv *priv =
-                                               current->uclass_priv;
+                                               dev_get_uclass_priv(current);
 
                                        priv->state = ETH_STATE_ACTIVE;
                                        return 0;
@@ -323,7 +323,7 @@ void eth_halt(void)
                return;
 
        eth_get_ops(current)->stop(current);
-       priv = current->uclass_priv;
+       priv = dev_get_uclass_priv(current);
        if (priv)
                priv->state = ETH_STATE_PASSIVE;
 }
@@ -502,8 +502,8 @@ static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN])
 
 static int eth_post_probe(struct udevice *dev)
 {
-       struct eth_device_priv *priv = dev->uclass_priv;
-       struct eth_pdata *pdata = dev->plat;
+       struct eth_device_priv *priv = dev_get_uclass_priv(dev);
+       struct eth_pdata *pdata = dev_get_plat(dev);
        unsigned char env_enetaddr[ARP_HLEN];
        char *source = "DT";
 
@@ -581,7 +581,7 @@ static int eth_post_probe(struct udevice *dev)
 
 static int eth_pre_remove(struct udevice *dev)
 {
-       struct eth_pdata *pdata = dev->plat;
+       struct eth_pdata *pdata = dev_get_plat(dev);
 
        eth_get_ops(dev)->stop(dev);
 
index 5f38f9fde4165058a176a5c7f2dad53bcb0e6f8e..780526c19e3f175d2f6368b5708174635efa5631 100644 (file)
@@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux)
        ofnode ch_node;
        int err, first_err = 0;
 
-       if (!ofnode_valid(mux->node)) {
+       if (!dev_has_ofnode(mux)) {
                debug("%s: no mux node found, no child MDIO busses set up\n",
                      __func__);
                return 0;
index d062382c2a95636c2102f98d6be29bbffc518f8b..697e5f838d945c55b4afe20f10d728d3d8bd1723 100644 (file)
@@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
        const char *dt_name;
 
        /* set a custom name for the MDIO device, if present in DT */
-       if (ofnode_valid(dev->node)) {
-               dt_name = ofnode_read_string(dev->node, "device-name");
+       if (dev_has_ofnode(dev)) {
+               dt_name = dev_read_string(dev, "device-name");
                if (dt_name) {
                        debug("renaming dev %s to %s\n", dev->name, dt_name);
                        device_set_name(dev, dt_name);
@@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
        struct phy_device *phy;
        int i;
 
-       if (!ofnode_valid(ethdev->node)) {
+       if (!dev_has_ofnode(ethdev)) {
                debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
                return NULL;
        }
 
        interface = PHY_INTERFACE_MODE_NONE;
        for (i = 0; i < PHY_MODE_STR_CNT; i++) {
-               if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
+               if_str = dev_read_string(ethdev, phy_mode_str[i]);
                if (if_str) {
                        interface = phy_get_interface_by_name(if_str);
                        break;
index 9f1f7445d71123c1f78f0942cc95df959e63d416..87021e22e554274b2ab5ad6484e24b41187b5595 100644 (file)
@@ -31,10 +31,14 @@ endif
 
 ifeq ($(CONFIG_TPL_BUILD),y)
 SPL_BIN := u-boot-tpl
+SPL_NAME := tpl
 else
 SPL_BIN := u-boot-spl
+SPL_NAME := spl
 endif
 
+export SPL_NAME
+
 ifdef CONFIG_SPL_BUILD
 SPL_ := SPL_
 ifeq ($(CONFIG_TPL_BUILD),y)
@@ -116,7 +120,8 @@ 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
 
 # Linker Script
@@ -298,22 +303,23 @@ $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN)
        @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " toupper(size)}' | bc); \
        dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null;
 
-$(obj)/$(SPL_BIN).dtb: dts/dt-spl.dtb FORCE
+$(obj)/$(SPL_BIN).dtb: $(obj)/dts/dt-$(SPL_NAME).dtb FORCE
        $(call if_changed,copy)
 
 pythonpath = PYTHONPATH=scripts/dtc/pylibfdt
 
-quiet_cmd_dtocc = DTOC C  $@
-cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata
+DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \
+       -d $(obj)/$(SPL_BIN).dtb
 
-quiet_cmd_dtoch = DTOC H  $@
-cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -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)
 
@@ -321,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
@@ -457,9 +461,8 @@ endif
 PHONY += FORCE
 FORCE:
 
-PHONY += dtbs
-dtbs:
-       $(Q)$(MAKE) $(build)=dts dtbs
+$(obj)/dts/dt-$(SPL_NAME).dtb: dts/dt.dtb
+       $(Q)$(MAKE) $(build)=$(obj)/dts spl_dtbs
 
 # Declare the contents of the .PHONY variable as phony.  We keep that
 # information in a variable so we can use it in if_changed and friends.
index 60ddb1d6b1495a752c6d3a797fb7f62045cec324..e768eab6957a62414493853fc108faaaa203076d 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct dm_test_parent_plat {
-       int count;
-       int bind_flag;
-       int uclass_bind_flag;
-};
-
-enum {
-       FLAG_CHILD_PROBED       = 10,
-       FLAG_CHILD_REMOVED      = -7,
-};
-
-static struct dm_test_state *test_state;
-
-static int testbus_drv_probe(struct udevice *dev)
-{
-       return dm_scan_fdt_dev(dev);
-}
-
-static int testbus_child_post_bind(struct udevice *dev)
-{
-       struct dm_test_parent_plat *plat;
-
-       plat = dev_get_parent_plat(dev);
-       plat->bind_flag = 1;
-       plat->uclass_bind_flag = 2;
-
-       return 0;
-}
-
-static int testbus_child_pre_probe(struct udevice *dev)
-{
-       struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
-
-       parent_data->flag += FLAG_CHILD_PROBED;
-
-       return 0;
-}
-
-static int testbus_child_pre_probe_uclass(struct udevice *dev)
-{
-       struct dm_test_priv *priv = dev_get_priv(dev);
-
-       priv->uclass_flag++;
-
-       return 0;
-}
-
-static int testbus_child_post_probe_uclass(struct udevice *dev)
-{
-       struct dm_test_priv *priv = dev_get_priv(dev);
-
-       priv->uclass_postp++;
-
-       return 0;
-}
-
-static int testbus_child_post_remove(struct udevice *dev)
-{
-       struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
-       struct dm_test_state *dms = test_state;
-
-       parent_data->flag += FLAG_CHILD_REMOVED;
-       if (dms)
-               dms->removed = dev;
-
-       return 0;
-}
-
-static const struct udevice_id testbus_ids[] = {
-       {
-               .compatible = "denx,u-boot-test-bus",
-               .data = DM_TEST_TYPE_FIRST },
-       { }
-};
-
-U_BOOT_DRIVER(testbus_drv) = {
-       .name   = "testbus_drv",
-       .of_match       = testbus_ids,
-       .id     = UCLASS_TEST_BUS,
-       .probe  = testbus_drv_probe,
-       .child_post_bind = testbus_child_post_bind,
-       .priv_auto      = sizeof(struct dm_test_priv),
-       .plat_auto      = sizeof(struct dm_test_pdata),
-       .per_child_auto = sizeof(struct dm_test_parent_data),
-       .per_child_plat_auto    = sizeof(struct dm_test_parent_plat),
-       .child_pre_probe = testbus_child_pre_probe,
-       .child_post_remove = testbus_child_post_remove,
-};
-
-UCLASS_DRIVER(testbus) = {
-       .name           = "testbus",
-       .id             = UCLASS_TEST_BUS,
-       .flags          = DM_UC_FLAG_SEQ_ALIAS,
-       .child_pre_probe = testbus_child_pre_probe_uclass,
-       .child_post_probe = testbus_child_post_probe_uclass,
-};
-
 /* Test that we can probe for children */
 static int dm_test_bus_children(struct unit_test_state *uts)
 {
@@ -152,16 +55,16 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)
        ut_assertok(device_get_child(bus, 0, &dev));
        ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev));
        ut_assertok(device_get_child_by_seq(bus, 5, &dev));
-       ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+       ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
        ut_asserteq_str("c-test@5", dev->name);
 
        /* Device with sequence number 0 should be accessible */
        ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, &dev));
        ut_assertok(device_find_child_by_seq(bus, 0, &dev));
-       ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+       ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
        ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
        ut_assertok(device_get_child_by_seq(bus, 0, &dev));
-       ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+       ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
        ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
 
        /* There is no device with sequence number 2 */
@@ -193,10 +96,10 @@ static int dm_test_bus_children_of_offset(struct unit_test_state *uts)
        ut_assert(node > 0);
        ut_assertok(device_find_child_by_of_offset(bus, node, &dev));
        ut_assertnonnull(dev);
-       ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+       ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
        ut_assertok(device_get_child_by_of_offset(bus, node, &dev));
        ut_assertnonnull(dev);
-       ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+       ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
        return 0;
 }
@@ -335,11 +238,10 @@ DM_TEST(dm_test_bus_parent_data_uclass,
 static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 {
        struct dm_test_parent_data *parent_data;
-       struct dm_test_state *dms = uts->priv;
        struct udevice *bus, *dev;
        struct uclass *uc;
 
-       test_state = dms;
+       testbus_get_clear_removed();
        ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
        ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
 
@@ -351,7 +253,7 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
 
                ut_assertok(device_probe(dev));
                parent_data = dev_get_parent_priv(dev);
-               ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
+               ut_asserteq(TEST_FLAG_CHILD_PROBED, parent_data->flag);
        }
 
        uclass_foreach_dev(dev, uc) {
@@ -359,12 +261,11 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
                if (dev->parent != bus)
                        continue;
                parent_data = dev_get_parent_priv(dev);
-               ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
+               ut_asserteq(TEST_FLAG_CHILD_PROBED, parent_data->flag);
                ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
                ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
-               ut_asserteq_ptr(dms->removed, dev);
+               ut_asserteq_ptr(testbus_get_clear_removed(), dev);
        }
-       test_state = NULL;
 
        return 0;
 }
index a7c0f40b775bd06ab0b54355646e08b2a9384416..1f5ca570dc7a9f511680c466ae0055d55970188e 100644 (file)
@@ -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],
 };
@@ -116,14 +116,14 @@ static int dm_test_autobind(struct unit_test_state *uts)
         * device with no children.
         */
        ut_assert(dms->root);
-       ut_asserteq(1, list_count_items(&gd->uclass_root));
+       ut_asserteq(1, list_count_items(gd->uclass_root));
        ut_asserteq(0, list_count_items(&gd->dm_root->child_head));
        ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
 
        ut_assertok(dm_scan_plat(false));
 
        /* We should have our test class now at least, plus more children */
-       ut_assert(1 < list_count_items(&gd->uclass_root));
+       ut_assert(1 < list_count_items(gd->uclass_root));
        ut_assert(0 < list_count_items(&gd->dm_root->child_head));
 
        /* Our 3 dm_test_infox children should be bound to the test uclass */
@@ -131,7 +131,7 @@ static int dm_test_autobind(struct unit_test_state *uts)
 
        /* No devices should be probed */
        list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node)
-               ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+               ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 
        /* Our test driver should have been bound 3 times */
        ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3);
@@ -212,7 +212,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
        ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
 
        /* The root device should not be activated until needed */
-       ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
+       ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED);
 
        /*
         * We should be able to find the three test devices, and they should
@@ -222,17 +222,17 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
        for (i = 0; i < 3; i++) {
                ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
                ut_assert(dev);
-               ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
+               ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED),
                           "Driver %d/%s already activated", i, dev->name);
 
                /* This should activate it */
                ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));
                ut_assert(dev);
-               ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+               ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
                /* Activating a device should activate the root device */
                if (!i)
-                       ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
+                       ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED);
        }
 
        /*
@@ -255,7 +255,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
                ut_assert(priv);
                ut_asserteq(expected_base_add, priv->base_add);
 
-               pdata = dev->plat;
+               pdata = dev_get_plat(dev);
                expected_base_add += pdata->ping_add;
        }
 
@@ -273,7 +273,7 @@ static int dm_test_plat(struct unit_test_state *uts)
        for (i = 0; i < 3; i++) {
                ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
                ut_assert(dev);
-               pdata = dev->plat;
+               pdata = dev_get_plat(dev);
                ut_assert(pdata->ping_add == test_pdata[i].ping_add);
        }
 
@@ -297,7 +297,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts)
        ut_assert(dev);
        ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND]
                        == op_count[DM_TEST_OP_BIND] + 1);
-       ut_assert(!dev->priv);
+       ut_assert(!dev_get_priv(dev));
 
        /* Probe the device - it should fail allocating private data */
        dms->force_fail_alloc = 1;
@@ -305,14 +305,14 @@ static int dm_test_lifecycle(struct unit_test_state *uts)
        ut_assert(ret == -ENOMEM);
        ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE]
                        == op_count[DM_TEST_OP_PROBE] + 1);
-       ut_assert(!dev->priv);
+       ut_assert(!dev_get_priv(dev));
 
        /* Try again without the alloc failure */
        dms->force_fail_alloc = 0;
        ut_assertok(device_probe(dev));
        ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE]
                        == op_count[DM_TEST_OP_PROBE] + 2);
-       ut_assert(dev->priv);
+       ut_assert(dev_get_priv(dev));
 
        /* This should be device 3 in the uclass */
        ut_assertok(uclass_find_device(UCLASS_TEST, 3, &test_dev));
@@ -402,8 +402,8 @@ int dm_check_operations(struct unit_test_state *uts, struct udevice *dev,
 
        /* Getting the child device should allocate plat / priv */
        ut_assertok(testfdt_ping(dev, 10, &pingret));
-       ut_assert(dev->priv);
-       ut_assert(dev->plat);
+       ut_assert(dev_get_priv(dev));
+       ut_assert(dev_get_plat(dev));
 
        expected = 10 + base;
        ut_asserteq(expected, pingret);
@@ -414,7 +414,7 @@ int dm_check_operations(struct unit_test_state *uts, struct udevice *dev,
        ut_asserteq(expected, pingret);
 
        /* Now check the ping_total */
-       priv = dev->priv;
+       priv = dev_get_priv(dev);
        ut_asserteq(DM_TEST_START_TOTAL + 10 + 20 + base * 2,
                    priv->ping_total);
 
@@ -444,7 +444,7 @@ static int dm_test_operations(struct unit_test_state *uts)
                base = test_pdata[i].ping_add;
                debug("dev=%d, base=%d\n", i, base);
 
-               ut_assert(!dm_check_operations(uts, dev, base, dev->priv));
+               ut_assert(!dm_check_operations(uts, dev, base, dev_get_priv(dev)));
        }
 
        return 0;
@@ -460,13 +460,13 @@ static int dm_test_remove(struct unit_test_state *uts)
        for (i = 0; i < 3; i++) {
                ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
                ut_assert(dev);
-               ut_assertf(dev->flags & DM_FLAG_ACTIVATED,
+               ut_assertf(dev_get_flags(dev) & DM_FLAG_ACTIVATED,
                           "Driver %d/%s not activated", i, dev->name);
                ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
-               ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
+               ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED),
                           "Driver %d/%s should have deactivated", i,
                           dev->name);
-               ut_assert(!dev->priv);
+               ut_assert(!dev_get_priv(dev));
        }
 
        return 0;
@@ -512,7 +512,7 @@ static int dm_test_uclass(struct unit_test_state *uts)
        ut_assertok(uclass_get(UCLASS_TEST, &uc));
        ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
        ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_DESTROY]);
-       ut_assert(uc->priv);
+       ut_assert(uclass_get_priv(uc));
 
        ut_assertok(uclass_destroy(uc));
        ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
@@ -547,7 +547,7 @@ static int create_children(struct unit_test_state *uts, struct udevice *parent,
                                                &driver_info_manual, &dev));
                pdata = calloc(1, sizeof(*pdata));
                pdata->ping_add = key + i;
-               dev->plat = pdata;
+               dev_set_plat(dev, pdata);
                if (child)
                        child[i] = dev;
        }
@@ -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,
@@ -1073,12 +1073,12 @@ static int dm_test_all_have_seq(struct unit_test_state *uts)
        struct udevice *dev;
        struct uclass *uc;
 
-       list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+       list_for_each_entry(uc, gd->uclass_root, sibling_node) {
                list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-                       if (dev->sqq == -1)
+                       if (dev->seq_ == -1)
                                printf("Device '%s' has no seq (%d)\n",
-                                      dev->name, dev->sqq);
-                       ut_assert(dev->sqq != -1);
+                                      dev->name, dev->seq_);
+                       ut_assert(dev->seq_ != -1);
                }
        }
 
index 28869c1d6ffc560447a22c3839179b5b7c23ca59..ed12cafee2b9cc44b05cfb4d02b4082a56cd1bdd 100644 (file)
@@ -25,7 +25,7 @@ static int dm_test_cpu(struct unit_test_state *uts)
        for (uclass_find_first_device(UCLASS_CPU, &dev);
             dev;
             uclass_find_next_device(&dev))
-               ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+               ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
        ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev));
        ut_asserteq_ptr(cpu_get_current_dev(), dev);
index 76490befdf50d0c0a61e3a8f2ec6d16e99b13993..fa2e4a85596c61c55011b7fd65f6d83e9e315f46 100644 (file)
@@ -120,13 +120,13 @@ static int dm_test_pci_drvdata(struct unit_test_state *uts)
 
        ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap));
        ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-       ut_assertok(dev_of_valid(swap));
+       ut_assertok(dev_has_ofnode(swap));
        ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap));
        ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-       ut_assertok(dev_of_valid(swap));
+       ut_assertok(dev_has_ofnode(swap));
        ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x10, 0), &swap));
        ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-       ut_assertok(!dev_of_valid(swap));
+       ut_assertok(!dev_has_ofnode(swap));
 
        return 0;
 }
index b9f49de10a6322189db18e2040e37e1898e3e1ed..a67f5d3f982ac2ab6298549b94cb4084729a8d83 100644 (file)
@@ -12,6 +12,7 @@
 #include <log.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <dm/device-internal.h>
 #include <dm/test.h>
 #include <test/test.h>
 #include <test/ut.h>
@@ -67,7 +68,7 @@ static int test_remove(struct udevice *dev)
 static int test_unbind(struct udevice *dev)
 {
        /* Private data should not be allocated */
-       ut_assert(!dev->priv);
+       ut_assert(!dev_get_priv(dev));
 
        dm_testdrv_op_count[DM_TEST_OP_UNBIND]++;
        return 0;
@@ -119,8 +120,8 @@ static int test_manual_probe(struct udevice *dev)
 
        dm_testdrv_op_count[DM_TEST_OP_PROBE]++;
        if (!dms->force_fail_alloc)
-               dev->priv = calloc(1, sizeof(struct dm_test_priv));
-       if (!dev->priv)
+               dev_set_priv(dev, calloc(1, sizeof(struct dm_test_priv)));
+       if (!dev_get_priv(dev))
                return -ENOMEM;
 
        return 0;
index eb3c2cf161b4f4dc05b6b861020b8a99aa99512a..b53539055b60e34a5c488edf0602612f920ba485 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
-{
-       const struct dm_test_pdata *pdata = dev->plat;
-       struct dm_test_priv *priv = dev_get_priv(dev);
-
-       *pingret = pingval + pdata->ping_add;
-       priv->ping_total += *pingret;
-
-       return 0;
-}
-
-static const struct test_ops test_ops = {
-       .ping = testfdt_drv_ping,
-};
-
-static int testfdt_of_to_plat(struct udevice *dev)
-{
-       struct dm_test_pdata *pdata = dev_get_plat(dev);
-
-       pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-                                       "ping-add", -1);
-       pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
-                                     "ping-expect");
-
-       return 0;
-}
-
-static int testfdt_drv_probe(struct udevice *dev)
-{
-       struct dm_test_priv *priv = dev_get_priv(dev);
-
-       priv->ping_total += DM_TEST_START_TOTAL;
-
-       /*
-        * If this device is on a bus, the uclass_flag will be set before
-        * calling this function. In the meantime the uclass_postp is
-        * initlized to a value -1. These are used respectively by
-        * dm_test_bus_child_pre_probe_uclass() and
-        * dm_test_bus_child_post_probe_uclass().
-        */
-       priv->uclass_total += priv->uclass_flag;
-       priv->uclass_postp = -1;
-
-       return 0;
-}
-
-static const struct udevice_id testfdt_ids[] = {
-       {
-               .compatible = "denx,u-boot-fdt-test",
-               .data = DM_TEST_TYPE_FIRST },
-       {
-               .compatible = "google,another-fdt-test",
-               .data = DM_TEST_TYPE_SECOND },
-       { }
-};
-
-U_BOOT_DRIVER(testfdt_drv) = {
-       .name   = "testfdt_drv",
-       .of_match       = testfdt_ids,
-       .id     = UCLASS_TEST_FDT,
-       .of_to_plat = testfdt_of_to_plat,
-       .probe  = testfdt_drv_probe,
-       .ops    = &test_ops,
-       .priv_auto      = sizeof(struct dm_test_priv),
-       .plat_auto      = sizeof(struct dm_test_pdata),
-};
-
-static const struct udevice_id testfdt1_ids[] = {
-       {
-               .compatible = "denx,u-boot-fdt-test1",
-               .data = DM_TEST_TYPE_FIRST },
-       { }
-};
-
-U_BOOT_DRIVER(testfdt1_drv) = {
-       .name   = "testfdt1_drv",
-       .of_match       = testfdt1_ids,
-       .id     = UCLASS_TEST_FDT,
-       .of_to_plat = testfdt_of_to_plat,
-       .probe  = testfdt_drv_probe,
-       .ops    = &test_ops,
-       .priv_auto      = sizeof(struct dm_test_priv),
-       .plat_auto      = sizeof(struct dm_test_pdata),
-       .flags = DM_FLAG_PRE_RELOC,
-};
-
-/* From here is the testfdt uclass code */
-int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
-{
-       const struct test_ops *ops = device_get_ops(dev);
-
-       if (!ops->ping)
-               return -ENOSYS;
-
-       return ops->ping(dev, pingval, pingret);
-}
-
-UCLASS_DRIVER(testfdt) = {
-       .name           = "testfdt",
-       .id             = UCLASS_TEST_FDT,
-       .flags          = DM_UC_FLAG_SEQ_ALIAS,
-};
-
-static const struct udevice_id testfdtm_ids[] = {
-       { .compatible = "denx,u-boot-fdtm-test" },
-       { }
-};
-
-U_BOOT_DRIVER(testfdtm_drv) = {
-       .name   = "testfdtm_drv",
-       .of_match       = testfdtm_ids,
-       .id     = UCLASS_TEST_FDT_MANUAL,
-};
-
-UCLASS_DRIVER(testfdtm) = {
-       .name           = "testfdtm",
-       .id             = UCLASS_TEST_FDT_MANUAL,
-       .flags          = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
-};
-
 struct dm_testprobe_pdata {
        int probe_err;
 };
@@ -288,7 +168,7 @@ static int dm_test_fdt(struct unit_test_state *uts)
                ret = uclass_find_device(UCLASS_TEST_FDT, i, &dev);
                ut_assert(!ret);
                ut_assert(!dev_get_priv(dev));
-               ut_assert(dev->plat);
+               ut_assert(dev_get_plat(dev));
        }
 
        ut_assertok(dm_check_devices(uts, num_devices));
@@ -448,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@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@1", NULL, node, &dev));
        ut_asserteq(12, dev_seq(dev));
        ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 12, &dev));
@@ -468,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));
 
@@ -1151,8 +1031,8 @@ static int dm_test_child_ofdata(struct unit_test_state *uts)
        ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
        count = 0;
        device_foreach_child_of_to_plat(dev, bus) {
-               ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-               ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+               ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+               ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
                count++;
        }
        ut_asserteq(3, count);
@@ -1170,8 +1050,8 @@ static int dm_test_first_child_probe(struct unit_test_state *uts)
        ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
        count = 0;
        device_foreach_child_probe(dev, bus) {
-               ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-               ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+               ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+               ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
                count++;
        }
        ut_asserteq(3, count);
@@ -1187,19 +1067,19 @@ static int dm_test_ofdata_order(struct unit_test_state *uts)
 
        ut_assertok(uclass_find_first_device(UCLASS_I2C, &bus));
        ut_assertnonnull(bus);
-       ut_assert(!(bus->flags & DM_FLAG_PLATDATA_VALID));
+       ut_assert(!(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID));
 
        ut_assertok(device_find_first_child(bus, &dev));
        ut_assertnonnull(dev);
-       ut_assert(!(dev->flags & DM_FLAG_PLATDATA_VALID));
+       ut_assert(!(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID));
 
        /* read the child's ofdata which should cause the parent's to be read */
        ut_assertok(device_of_to_plat(dev));
-       ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-       ut_assert(bus->flags & DM_FLAG_PLATDATA_VALID);
+       ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+       ut_assert(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID);
 
-       ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
-       ut_assert(!(bus->flags & DM_FLAG_ACTIVATED));
+       ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
+       ut_assert(!(dev_get_flags(bus) & DM_FLAG_ACTIVATED));
 
        return 0;
 }
index 3ab4a23649e77baa4f06dbd246c0efdf8067888b..f1b7aaa727feb0545ed58bc47ccde8a4f61a8031 100644 (file)
@@ -82,7 +82,7 @@ static int test_post_probe(struct udevice *dev)
        if (&prev->uclass_node != &uc->dev_head) {
                struct dm_test_uclass_perdev_priv *prev_uc_priv
                                = dev_get_uclass_priv(prev);
-               struct dm_test_pdata *pdata = prev->plat;
+               struct dm_test_pdata *pdata = dev_get_plat(prev);
 
                ut_assert(pdata);
                ut_assert(prev_uc_priv);
@@ -102,7 +102,7 @@ static int test_pre_remove(struct udevice *dev)
 static int test_init(struct uclass *uc)
 {
        dm_testdrv_op_count[DM_TEST_OP_INIT]++;
-       ut_assert(uc->priv);
+       ut_assert(uclass_get_priv(uc));
 
        return 0;
 }
index 2e876c36e43f4070e048f1561939af666ccd19ed..ad355981cf41b5ed84b710c4b680c2fe391c05e8 100644 (file)
@@ -122,7 +122,7 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
        ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK));
 
        /* check the device can be successfully removed */
-       dev->flags |= DM_FLAG_ACTIVATED;
+       dev_or_flags(dev, DM_FLAG_ACTIVATED);
        ut_assertok(device_remove(bus, DM_REMOVE_ACTIVE_ALL));
 
        return 0;
index 78837a3c0081f9fd69a933f13c0a18428014ec76..d55338e37e6f2fb1440f8ee98069236118e642f7 100644 (file)
@@ -17,7 +17,6 @@ def test_spl_devicetree(u_boot_console):
     assert "u-boot,dm-spl" not in output
     assert "u-boot,dm-tpl" not in output
 
-    assert "spl-test4" in output
     assert "spl-test5" not in output
     assert "spl-test6" not in output
     assert "spl-test7" in output
index 418d7eed21d1b4583df5c41b8dc03d245aa16806..5e88b94f41561f887dbf9e58fc8e36c83881bd17 100644 (file)
@@ -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
index 82671138a9a63c73cb7244f3e49f12dbede54c01..b7abaed67acb2e302fcb51c6eca1490f542e74a4 100644 (file)
@@ -15,12 +15,15 @@ See doc/driver-model/of-plat.rst for more informaiton
 
 import collections
 import copy
+from enum import IntEnum
 import os
 import re
 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
@@ -49,6 +52,17 @@ 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-plat.c'
+# hdr_comment: Comment explaining the purpose of the file
+OutputFile = collections.namedtuple('OutputFile',
+                                    ['ftype', 'fname', 'method', 'hdr_comment'])
+
 # This holds information about a property which includes phandles.
 #
 # max_args: integer: Maximum number or arguments that any phandle uses (int).
@@ -64,23 +78,6 @@ PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args'])
 PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_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.
 
@@ -112,34 +109,22 @@ def get_value(ftype, value):
         str: String representation of the value
     """
     if ftype == fdt.Type.INT:
-        return '%#x' % fdt_util.fdt32_to_cpu(value)
+        val = '%#x' % fdt_util.fdt32_to_cpu(value)
     elif ftype == fdt.Type.BYTE:
         char = value[0]
-        return '%#x' % (ord(char) if isinstance(char, str) else char)
+        val = '%#x' % (ord(char) if isinstance(char, str) else char)
     elif ftype == fdt.Type.STRING:
         # Handle evil ACPI backslashes by adding another backslash before them.
         # So "\\_SB.GPO0" in the device tree effectively stays like that in C
-        return '"%s"' % value.replace('\\', '\\\\')
+        val = '"%s"' % value.replace('\\', '\\\\')
     elif ftype == fdt.Type.BOOL:
-        return 'true'
+        val = 'true'
     else:  # ftype == fdt.Type.INT64:
-        return '%#x' % value
-
-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 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]
+        val = '%#x' % value
+    return val
 
 
-class DtbPlatdata(object):
+class DtbPlatdata():
     """Provide a means to convert device tree binary data to platform data
 
     The output of this process is C structures which can be used in space-
@@ -147,83 +132,97 @@ class DtbPlatdata(object):
     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: List of valid driver names found in drivers/
-        _driver_aliases: Dict that holds aliases for driver names
-            key: Driver alias declared with
-                U_BOOT_DRIVER_ALIAS(driver_alias, driver_name)
-            value: Driver name declared with U_BOOT_DRIVER(driver_name)
-        _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
+        _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
+    def setup_output_dirs(self, output_dirs):
+        """Set up the output directories
 
-        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.
+        This should be done before setup_output() is called
 
         Args:
-            node: Node object to check
-        Return:
-            Tuple:
-                Driver name associated with the first compatible string
-                List of C identifiers for all the other compatible strings
-                    (possibly empty)
-                In case of no match found, the return will be the same as
-                get_compat_name()
+            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
         """
-        compat_list_c = get_compat_name(node)
-
-        for compat_c in compat_list_c:
-            if not compat_c in self._drivers:
-                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(self, fname):
+        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 '-' 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 = sys.stdout
+        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 = open(fname, 'w')
+            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
@@ -251,15 +250,20 @@ class DtbPlatdata(object):
         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
@@ -312,63 +316,6 @@ class DtbPlatdata(object):
             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('U_BOOT_DRIVER\((.*)\)', buff)
-
-            for driver in drivers:
-                self._drivers.append(driver)
-
-            # The following re will search for driver aliases declared as
-            # U_BOOT_DRIVER_ALIAS(alias, driver_name)
-            driver_aliases = re.findall(
-                'U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
-                buff)
-
-            for alias in driver_aliases: # pragma: no cover
-                if len(alias) != 2:
-                    continue
-                self._driver_aliases[alias[1]] = alias[0]
-
-    def scan_drivers(self):
-        """Scan the driver folders to build a list of driver names and aliases
-
-        This procedure will populate self._drivers and self._driver_aliases
-
-        """
-        basedir = sys.argv[0].replace('tools/dtoc/dtoc', '')
-        if basedir == '':
-            basedir = './'
-        for (dirpath, _, 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
 
@@ -383,8 +330,8 @@ class DtbPlatdata(object):
         This adds each node to self._valid_nodes.
 
         Args:
-            root: Root node for scan
-            valid_nodes: List of Node objects to add to
+            root (Node): Root node for scan
+            valid_nodes (list of Node): List of Node objects to add to
         """
         for node in root.subnodes:
             if 'compatible' in node.props:
@@ -483,16 +430,11 @@ class DtbPlatdata(object):
         Once the widest property is determined, all other properties are
         updated to match that width.
 
-        Returns:
-            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)
+            node_name, _ = self._scan.get_normalized_compat_name(node)
             fields = {}
 
             # Get a list of all the valid properties in this node.
@@ -515,14 +457,12 @@ class DtbPlatdata(object):
                 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] != '#':
                     prop.Widen(struct[name])
 
-        return structs
-
     def scan_phandles(self):
         """Figure out what phandles each node uses
 
@@ -551,22 +491,14 @@ class DtbPlatdata(object):
                         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 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
-
         """
-        self.out_header()
+        structs = self._struct_data
         self.out('#include <stdbool.h>\n')
         self.out('#include <linux/libfdt.h>\n')
 
@@ -591,158 +523,198 @@ class DtbPlatdata(object):
                 self.out(';\n')
             self.out('};\n')
 
-    def output_node(self, node):
-        """Output the C code for a node
+    def _output_list(self, node, prop):
+        """Output the C code for a devicetree property that holds a list
 
         Args:
-            node (fdt.Node): node to output
+            node (fdt.Node): Node to output
+            prop (fdt.Prop): Prop to output
         """
-        def _output_list(node, prop):
-            """Output the C code for a devicetree property that holds a list
-
-            Args:
-                node (fdt.Node): Node to output
-                prop (fdt.Prop): Prop to output
-            """
-            self.buf('{')
-            vals = []
-            # For phandles, output a reference to the platform data
-            # of the target node.
-            info = self.get_phandle_argc(prop, node.name)
-            if info:
-                # Process the list as pairs of (phandle, id)
-                pos = 0
-                for args in info.args:
-                    phandle_cell = prop.value[pos]
-                    phandle = fdt_util.fdt32_to_cpu(phandle_cell)
-                    target_node = self._fdt.phandle_to_node[phandle]
-                    arg_values = []
-                    for i in range(args):
-                        arg_values.append(
-                            str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i])))
-                    pos += 1 + args
-                    vals.append('\t{%d, {%s}}' % (target_node.idx,
-                                                  ', '.join(arg_values)))
-                for val in vals:
-                    self.buf('\n\t\t%s,' % val)
-            else:
-                for val in prop.value:
-                    vals.append(get_value(prop.type, val))
+        self.buf('{')
+        vals = []
+        # For phandles, output a reference to the platform data
+        # of the target node.
+        info = self.get_phandle_argc(prop, node.name)
+        if info:
+            # Process the list as pairs of (phandle, id)
+            pos = 0
+            for args in info.args:
+                phandle_cell = prop.value[pos]
+                phandle = fdt_util.fdt32_to_cpu(phandle_cell)
+                target_node = self._fdt.phandle_to_node[phandle]
+                arg_values = []
+                for i in range(args):
+                    arg_values.append(
+                        str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i])))
+                pos += 1 + args
+                vals.append('\t{%d, {%s}}' % (target_node.idx,
+                                              ', '.join(arg_values)))
+            for val in vals:
+                self.buf('\n\t\t%s,' % val)
+        else:
+            for val in prop.value:
+                vals.append(get_value(prop.type, val))
 
-                # Put 8 values per line to avoid very long lines.
-                for i in range(0, len(vals), 8):
-                    if i:
-                        self.buf(',\n\t\t')
-                    self.buf(', '.join(vals[i:i + 8]))
-            self.buf('}')
+            # Put 8 values per line to avoid very long lines.
+            for i in range(0, len(vals), 8):
+                if i:
+                    self.buf(',\n\t\t')
+                self.buf(', '.join(vals[i:i + 8]))
+        self.buf('}')
 
-        struct_name, _ = self.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.buf('static struct %s%s %s%s = {\n' %
-                 (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
-        for pname in sorted(node.props):
-            prop = node.props[pname]
-            if pname in PROP_IGNORE_LIST or pname[0] == '#':
-                continue
-            member_name = conv_name_to_c(prop.name)
-            self.buf('\t%s= ' % tab_to(3, '.' + member_name))
+    def _declare_device(self, var_name, struct_name, node_parent):
+        """Add a device declaration to the output
 
-            # Special handling for lists
-            if isinstance(prop.value, list):
-                _output_list(node, prop)
-            else:
-                self.buf(get_value(prop.type, prop.value))
-            self.buf(',\n')
-        self.buf('};\n')
+        This declares a U_BOOT_DRVINFO() for the device being processed
 
-        # Add a device declaration
-        self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name)
+        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_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))
         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')
 
+    def _output_prop(self, node, prop):
+        """Output a line containing the value of a struct member
+
+        Args:
+            node (Node): Node being output
+            prop (Prop): Prop object to output
+        """
+        if prop.name in PROP_IGNORE_LIST or prop.name[0] == '#':
+            return
+        member_name = conv_name_to_c(prop.name)
+        self.buf('\t%s= ' % tab_to(3, '.' + member_name))
+
+        # Special handling for lists
+        if isinstance(prop.value, list):
+            self._output_list(node, prop)
+        else:
+            self.buf(get_value(prop.type, prop.value))
+        self.buf(',\n')
+
+    def _output_values(self, var_name, struct_name, 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
+        """
+        self.buf('static struct %s%s %s%s = {\n' %
+                 (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
+        for pname in sorted(node.props):
+            self._output_prop(node, node.props[pname])
+        self.buf('};\n')
+
+    def output_node(self, node):
+        """Output the C code for a node
+
+        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.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
-        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('#define DT_PLATDATA_C\n')
+        self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n')
+        self.out('#define DT_PLAT_C\n')
         self.out('\n')
         self.out('#include <common.h>\n')
         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)
-            self.output_node(node)
-            nodes_to_output.remove(node)
 
-        # Define dm_populate_phandle_data() which will add the linking between
-        # nodes using DM_GET_DEVICE
-        # dtv_dmc_at_xxx.clocks[0].node = DM_GET_DEVICE(clock_controller_at_xxx)
-        self.buf('void dm_populate_phandle_data(void) {\n')
-        self.buf('}\n')
+        for node in self._valid_nodes:
+            self.output_node(node)
 
         self.out(''.join(self.get_buf()))
 
-def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False,
-              drivers_additional=None):
+
+# 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',
+                   DtbPlatdata.generate_structs,
+                   'Defines the structs used to hold devicetree data'),
+    'platdata':
+        OutputFile(Ftype.SOURCE, 'dt-plat.c', DtbPlatdata.generate_plat,
+                   'Declares the U_BOOT_DRIVER() records and platform data'),
+    }
+
+
+def run_steps(args, dtb_file, include_disabled, output, output_dirs,
+              warning_disabled=False, drivers_additional=None, basedir=None):
     """Run all the steps of the dtoc tool
 
     Args:
         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)
+        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
+        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
     """
     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)
-    plat.scan_drivers()
+    scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional)
+    plat = DtbPlatdata(scan, dtb_file, include_disabled)
+    scan.scan_drivers()
     plat.scan_dtb()
     plat.scan_tree()
     plat.scan_reg_sizes()
-    plat.setup_output(output)
-    structs = plat.scan_structs()
+    plat.setup_output_dirs(output_dirs)
+    plat.scan_structs()
     plat.scan_phandles()
 
-    for cmd in args[0].split(','):
-        if cmd == 'struct':
-            plat.generate_structs(structs)
-        elif cmd == 'platdata':
-            plat.generate_tables()
-        else:
-            raise ValueError("Unknown command '%s': (use: struct, platdata)" %
-                             cmd)
+    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(sorted(OUTPUT_FILES.keys()))))
+        plat.setup_output(outfile.ftype,
+                          outfile.fname if output_dirs else output)
+        plat.out_header(outfile)
+        outfile.method(plat)
+    plat.finish_output()
index 557c692ba2c12fab03991b799df6ba6b6ca1e697..f448767670eeca47be5d62b86ad46f23f4a096fd 100644 (file)
@@ -1 +1 @@
-U_BOOT_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)
+DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)
index fd168cb593175b3aa0e187c00704867344f6a976..1c87b891929f8b0ed403fdd824552190e054b58d 100644 (file)
                longbytearray = [09 0a 0b 0c 0d 0e 0f 10];
        };
 
-       spl-test4 {
-               u-boot,dm-pre-reloc;
-               compatible = "sandbox,spl-test.2";
-       };
-
        i2c@0 {
                compatible = "sandbox,i2c-test";
                u-boot,dm-pre-reloc;
index b94d9c301f492ae203abe3d0f929e4fc201964ed..b0ad0f3952aa3c995620039c7a18b2e32faf36a8 100755 (executable)
@@ -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
@@ -42,37 +38,27 @@ 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)
     """
-    import test_dtoc
+    from dtoc import test_src_scan
+    from dtoc import test_dtoc
 
     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,test_src_scan.TestSrcScan])
+
+    return test_util.ReportResult('binman', test_name, result)
 
 def RunTestCoverage():
     """Run the tests and check that we get 100% coverage"""
@@ -87,11 +73,15 @@ 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',
                   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')
@@ -103,7 +93,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:
@@ -111,4 +101,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])
diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py
new file mode 100644 (file)
index 0000000..f63c9fc
--- /dev/null
@@ -0,0 +1,185 @@
+#!/usr/bin/python
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2017 Google, Inc
+# Written by Simon Glass <[email protected]>
+#
+
+"""Scanning of U-Boot source for drivers and structs
+
+This scans the source tree to find out things about all instances of
+U_BOOT_DRIVER(), UCLASS_DRIVER and all struct declarations in header files.
+
+See doc/driver-model/of-plat.rst for more informaiton
+"""
+
+import os
+import re
+import sys
+
+
+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 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 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
+
+
+class Scanner:
+    """Scanning of the U-Boot source tree
+
+    Properties:
+        _basedir (str): Base directory of U-Boot source code. Defaults to the
+            grandparent of this file's directory
+        _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)
+        _warning_disabled: true to disable warnings about driver names not found
+        _drivers_additional (list or str): List of additional drivers to use
+            during scanning
+    """
+    def __init__(self, basedir, warning_disabled, drivers_additional):
+        """Set up a new Scanner
+        """
+        if not basedir:
+            basedir = sys.argv[0].replace('tools/dtoc/dtoc', '')
+            if basedir == '':
+                basedir = './'
+        self._basedir = basedir
+        self._drivers = {}
+        self._driver_aliases = {}
+        self._drivers_additional = drivers_additional or []
+        self._warning_disabled = warning_disabled
+
+    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 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):
+        """Scan the driver folders to build a list of driver names and aliases
+
+        This procedure will populate self._drivers and self._driver_aliases
+        """
+        for (dirpath, _, filenames) in os.walk(self._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(self._basedir + '/' + fname)
index 4913d95021801406b1d51c46d8934efbff214ce8..d961d67b8fcb0f00bf2e345121c4daf1c2db2080 100755 (executable)
@@ -10,29 +10,29 @@ tool.
 """
 
 import collections
+import glob
 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 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
 
-our_path = os.path.dirname(os.path.realpath(__file__))
+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,33 +41,33 @@ 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_DEVICE() in this file */
-#define DT_PLATDATA_C
+/* Allow use of U_BOOT_DRVINFO() in this file */
+#define DT_PLAT_C
 
 #include <common.h>
 #include <dm.h>
 #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
 
 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 +80,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,18 +102,25 @@ 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):
-        dtb_platdata.run_steps(args, dtb_file, False, output, True)
+        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):
         """Test conversion of device tree names to C identifiers"""
@@ -160,7 +168,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):
@@ -175,17 +183,9 @@ 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)
 
-    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._CheckStrings(HEADER + '''
+    struct_text = HEADER + '''
 struct dtd_sandbox_i2c_test {
 };
 struct dtd_sandbox_pmic_test {
@@ -204,18 +204,13 @@ struct dtd_sandbox_spl_test {
 \tconst char *\tstringarray[3];
 \tconst char *\tstringval;
 };
-struct dtd_sandbox_spl_test_2 {
-};
-''', data)
+'''
 
-        self.run_test(['platdata'], dtb_file, output)
-        with open(output) as infile:
-            data = infile.read()
-        self._CheckStrings(C_HEADER + '''
+    platdata_text = C_HEADER + '''
 /* Node /i2c@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),
@@ -227,7 +222,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),
@@ -247,7 +242,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),
@@ -266,7 +261,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),
@@ -279,24 +274,35 @@ 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),
 \t.parent_idx\t= -1,
 };
 
-/* Node /spl-test4 index 5 */
-static struct dtd_sandbox_spl_test_2 dtv_spl_test4 = {
-};
-U_BOOT_DEVICE(spl_test4) = {
-\t.name\t\t= "sandbox_spl_test_2",
-\t.plat\t= &dtv_spl_test4,
-\t.plat_size\t= sizeof(dtv_spl_test4),
-\t.parent_idx\t= -1,
-};
+'''
 
-''' + C_EMPTY_POPULATE_PHANDLE_DATA, 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)
+
+        # 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"""
@@ -305,7 +311,7 @@ U_BOOT_DEVICE(spl_test4) = {
         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;
@@ -316,54 +322,50 @@ 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@0 index 0 */
 static struct dtd_sandbox_gpio dtv_gpios_at_0 = {
 \t.gpio_bank_name\t\t= "a",
 \t.gpio_controller\t= true,
 \t.sandbox_gpio_count\t= 0x14,
 };
-U_BOOT_DEVICE(gpios_at_0) = {
+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),
 \t.parent_idx\t= -1,
 };
 
-void dm_populate_phandle_data(void) {
-}
 ''', data)
 
     def test_invalid_driver(self):
         """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):
-            dtb_platdata.run_steps(['struct'], dtb_file, False, output)
+        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):
-            dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        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 = {
 };
-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),
 \t.parent_idx\t= -1,
 };
 
-void dm_populate_phandle_data(void) {
-}
 ''', data)
 
     def test_phandle(self):
@@ -373,7 +375,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];
 };
@@ -385,12 +387,12 @@ 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,
 };
-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),
@@ -401,24 +403,13 @@ 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),
 \t.parent_idx\t= -1,
 };
 
-/* Node /phandle-target index 4 */
-static struct dtd_target dtv_phandle_target = {
-\t.intval\t\t\t= 0x0,
-};
-U_BOOT_DEVICE(phandle_target) = {
-\t.name\t\t= "target",
-\t.plat\t= &dtv_phandle_target,
-\t.plat_size\t= sizeof(dtv_phandle_target),
-\t.parent_idx\t= -1,
-};
-
 /* Node /phandle-source index 2 */
 static struct dtd_source dtv_phandle_source = {
 \t.clocks\t\t\t= {
@@ -427,7 +418,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),
@@ -439,15 +430,24 @@ 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),
 \t.parent_idx\t= -1,
 };
 
-void dm_populate_phandle_data(void) {
-}
+/* Node /phandle-target index 4 */
+static struct dtd_target dtv_phandle_target = {
+\t.intval\t\t\t= 0x0,
+};
+U_BOOT_DRVINFO(phandle_target) = {
+\t.name\t\t= "target",
+\t.plat\t= &dtv_phandle_target,
+\t.plat_size\t= sizeof(dtv_phandle_target),
+\t.parent_idx\t= -1,
+};
+
 ''', data)
 
     def test_phandle_single(self):
@@ -457,7 +457,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];
 };
@@ -473,46 +473,44 @@ struct dtd_target {
         self.run_test(['platdata'], dtb_file, output)
         with open(output) as infile:
             data = infile.read()
-        self._CheckStrings(C_HEADER + '''
-/* Node /phandle-target index 1 */
-static struct dtd_target dtv_phandle_target = {
-};
-U_BOOT_DEVICE(phandle_target) = {
-\t.name\t\t= "target",
-\t.plat\t= &dtv_phandle_target,
-\t.plat_size\t= sizeof(dtv_phandle_target),
-\t.parent_idx\t= -1,
-};
-
+        self._check_strings(C_HEADER + '''
 /* Node /phandle-source2 index 0 */
 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),
 \t.parent_idx\t= -1,
 };
 
-void dm_populate_phandle_data(void) {
-}
+/* Node /phandle-target index 1 */
+static struct dtd_target dtv_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),
+\t.parent_idx\t= -1,
+};
+
 ''', data)
 
     def test_phandle_cd_gpio(self):
         """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._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,
 };
-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),
@@ -523,24 +521,13 @@ 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),
 \t.parent_idx\t= -1,
 };
 
-/* Node /phandle-target index 4 */
-static struct dtd_target dtv_phandle_target = {
-\t.intval\t\t\t= 0x0,
-};
-U_BOOT_DEVICE(phandle_target) = {
-\t.name\t\t= "target",
-\t.plat\t= &dtv_phandle_target,
-\t.plat_size\t= sizeof(dtv_phandle_target),
-\t.parent_idx\t= -1,
-};
-
 /* Node /phandle-source index 2 */
 static struct dtd_source dtv_phandle_source = {
 \t.cd_gpios\t\t= {
@@ -549,7 +536,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),
@@ -561,15 +548,24 @@ 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),
 \t.parent_idx\t= -1,
 };
 
-void dm_populate_phandle_data(void) {
-}
+/* Node /phandle-target index 4 */
+static struct dtd_target dtv_phandle_target = {
+\t.intval\t\t\t= 0x0,
+};
+U_BOOT_DRVINFO(phandle_target) = {
+\t.name\t\t= "target",
+\t.plat\t= &dtv_phandle_target,
+\t.plat_size\t= sizeof(dtv_phandle_target),
+\t.parent_idx\t= -1,
+};
+
 ''', data)
 
     def test_phandle_bad(self):
@@ -577,20 +573,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"""
@@ -599,7 +595,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];
 };
@@ -614,12 +610,12 @@ 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},
 };
-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),
@@ -630,7 +626,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),
@@ -641,14 +637,14 @@ 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),
 \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"""
@@ -657,7 +653,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];
 };
@@ -669,12 +665,12 @@ 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},
 };
-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),
@@ -685,14 +681,14 @@ 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),
 \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"""
@@ -701,7 +697,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];
 };
@@ -716,12 +712,12 @@ 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},
 };
-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),
@@ -732,7 +728,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),
@@ -743,14 +739,14 @@ 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),
 \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"""
@@ -759,7 +755,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];
 };
@@ -774,12 +770,12 @@ 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},
 };
-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),
@@ -790,7 +786,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),
@@ -801,34 +797,35 @@ 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),
 \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"""
         # 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"""
@@ -837,7 +834,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;
@@ -847,12 +844,12 @@ 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,
 };
-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),
@@ -863,58 +860,70 @@ 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),
 \t.parent_idx\t= -1,
 };
 
-''' + C_EMPTY_POPULATE_PHANDLE_DATA, 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):
-            self.run_test(['struct'], dtb_file, '-')
+        with test_util.capture_sys_output() as (stdout, _):
+            self.run_test(['struct'], dtb_file, None)
+        self._check_strings(self.struct_text, stdout.getvalue())
 
-    def testNoCommand(self):
+    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(['all'], dtb_file, output)
+        data = tools.ReadFile(output, binary=False)
+        self._check_strings(self.platdata_text + self.struct_text, data)
+
+    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))
-
-    def testScanDrivers(self):
-        """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'])
-
-    def testUnicodeError(self):
-        """Test running dtoc with an invalid unicode file
+        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'], 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)
 
-        To be able to perform this test without adding a weird text file which
-        would produce issues when using checkpatch.pl or patman, generate the
-        file at runtime and then process it.
-        """
+        # This should create the .dts and .dtb in the output directory
         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 test_util.capture_sys_output() as (stdout, stderr):
-            dtb_platdata.run_steps(['struct'], dtb_file, False, output, True,
-                               [driver_fn])
+        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-plat.c', 'source.dtb'},
+            leafs)
diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py
new file mode 100644 (file)
index 0000000..7d68653
--- /dev/null
@@ -0,0 +1,107 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2020 Google LLC
+#
+
+"""Tests for the src_scan module
+
+This includes unit tests for scanning of the source code
+"""
+
+import os
+import shutil
+import tempfile
+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
+# testing
+# pylint: disable=W0212
+
+class TestSrcScan(unittest.TestCase):
+    """Tests for src_scan"""
+    @classmethod
+    def setUpClass(cls):
+        tools.PrepareOutputDir(None)
+
+    @classmethod
+    def tearDownClass(cls):
+        tools.FinaliseOutputDir()
+
+    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'])
+
+    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
+        would produce issues when using checkpatch.pl or patman, generate the
+        file at runtime and then process it.
+        """
+        driver_fn = '/tmp/' + next(tempfile._get_candidate_names())
+        with open(driver_fn, 'wb+') as fout:
+            fout.write(b'\x81')
+
+        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"""
+        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)
+        self.assertNotEqual(drv2, drv3)
+
+    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:
+            indir = tempfile.mkdtemp(prefix='dtoc.')
+
+            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(src_scan.Scanner, "scan_driver")  as mocked:
+                scan = src_scan.Scanner(indir, True, None)
+                scan.scan_drivers()
+            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)
index fca3d9e604752e90bebd459d4ba27760e7c41461..d8e01a3e60ec4252a5fe36ce76774c70c7882e6f 100644 (file)
@@ -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
This page took 0.762998 seconds and 4 git commands to generate.