aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-01-05 22:34:43 -0500
committerTom Rini <trini@konsulko.com>2021-01-05 22:34:43 -0500
commitb11f634b1c1be6ab419758c6596c673445e5ac70 (patch)
tree2329e1ff53c6c543e01d84b7901c53621ad8b7f9
parent720620e6916ba40b9a173bb07706d2c73f3c23e7 (diff)
parent970349a96dac3ad46c33851b1a773bfe3f1d4b33 (diff)
downloadu-boot-WIP/05Jan2021-next.zip
u-boot-WIP/05Jan2021-next.tar.gz
u-boot-WIP/05Jan2021-next.tar.bz2
Merge tag 'dm-pull-5jan21' of git://git.denx.de/u-boot-dm into nextWIP/05Jan2021-next
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
-rw-r--r--arch/arc/include/asm/spl.h0
-rw-r--r--arch/arm/cpu/armv7/ls102xa/fdt.c4
-rw-r--r--arch/arm/cpu/armv8/fsl-layerscape/spl.c5
-rw-r--r--arch/arm/lib/gic-v3-its.c10
-rw-r--r--arch/arm/mach-aspeed/ast2500/clk_ast2500.c2
-rw-r--r--arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c2
-rw-r--r--arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c2
-rw-r--r--arch/arm/mach-davinci/da850_lowlevel.c4
-rw-r--r--arch/arm/mach-davinci/spl.c4
-rw-r--r--arch/arm/mach-imx/mx6/soc.c2
-rw-r--r--arch/arm/mach-imx/mx7/soc.c2
-rw-r--r--arch/arm/mach-k3/am6_init.c2
-rw-r--r--arch/arm/mach-k3/common.c2
-rw-r--r--arch/arm/mach-k3/j721e_init.c2
-rw-r--r--arch/arm/mach-keystone/init.c2
-rw-r--r--arch/arm/mach-lpc32xx/devices.c4
-rw-r--r--arch/arm/mach-mediatek/mt7629/init.c4
-rw-r--r--arch/arm/mach-mediatek/mt8516/init.c2
-rw-r--r--arch/arm/mach-omap2/am33xx/board.c10
-rw-r--r--arch/arm/mach-omap2/omap3/board.c2
-rw-r--r--arch/arm/mach-rockchip/misc.c4
-rw-r--r--arch/arm/mach-rockchip/px30/clk_px30.c2
-rw-r--r--arch/arm/mach-rockchip/rk3036/clk_rk3036.c2
-rw-r--r--arch/arm/mach-rockchip/rk3128/clk_rk3128.c2
-rw-r--r--arch/arm/mach-rockchip/rk3188/clk_rk3188.c2
-rw-r--r--arch/arm/mach-rockchip/rk322x/clk_rk322x.c2
-rw-r--r--arch/arm/mach-rockchip/rk3288/clk_rk3288.c2
-rw-r--r--arch/arm/mach-rockchip/rk3308/clk_rk3308.c2
-rw-r--r--arch/arm/mach-rockchip/rk3328/clk_rk3328.c2
-rw-r--r--arch/arm/mach-rockchip/rk3368/clk_rk3368.c2
-rw-r--r--arch/arm/mach-rockchip/rk3399/clk_rk3399.c4
-rw-r--r--arch/arm/mach-rockchip/rv1108/clk_rv1108.c2
-rw-r--r--arch/arm/mach-socfpga/clock_manager_agilex.c2
-rw-r--r--arch/arm/mach-stm32mp/bsec.c2
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32key.c2
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c6
-rw-r--r--arch/arm/mach-stm32mp/cpu.c6
-rw-r--r--arch/arm/mach-stm32mp/pwr_regulator.c5
-rw-r--r--arch/arm/mach-tegra/board.c2
-rw-r--r--arch/arm/mach-tegra/board2.c2
-rw-r--r--arch/arm/mach-uniphier/micro-support-card.c2
-rw-r--r--arch/arm/mach-zynq/clk.c4
-rw-r--r--arch/arm/mach-zynq/timer.c2
-rw-r--r--arch/m68k/include/asm/spl.h0
-rw-r--r--arch/mips/mach-mtmips/mt7628/init.c2
-rw-r--r--arch/nds32/include/asm/spl.h0
-rw-r--r--arch/nios2/include/asm/spl.h0
-rw-r--r--arch/riscv/lib/sifive_clint.c2
-rw-r--r--arch/sandbox/cpu/os.c5
-rw-r--r--arch/sandbox/cpu/start.c7
-rw-r--r--arch/sandbox/cpu/state.c4
-rw-r--r--arch/sandbox/dts/sandbox.dts4
-rw-r--r--arch/sandbox/dts/sandbox.dtsi16
-rw-r--r--arch/sandbox/include/asm/i2c.h14
-rw-r--r--arch/sandbox/include/asm/serial.h30
-rw-r--r--arch/sh/include/asm/spl.h0
-rw-r--r--arch/x86/cpu/apollolake/Kconfig1
-rw-r--r--arch/x86/cpu/apollolake/fsp_m.c5
-rw-r--r--arch/x86/cpu/apollolake/hostbridge.c34
-rw-r--r--arch/x86/cpu/apollolake/lpc.c13
-rw-r--r--arch/x86/cpu/apollolake/pch.c4
-rw-r--r--arch/x86/cpu/apollolake/pmc.c14
-rw-r--r--arch/x86/cpu/apollolake/spl.c30
-rw-r--r--arch/x86/cpu/apollolake/uart.c50
-rw-r--r--arch/x86/cpu/i386/call64.S1
-rw-r--r--arch/x86/cpu/intel_common/Makefile2
-rw-r--r--arch/x86/cpu/intel_common/itss.c23
-rw-r--r--arch/x86/cpu/intel_common/p2sb.c15
-rw-r--r--arch/x86/cpu/slimbootloader/serial.c4
-rw-r--r--arch/x86/cpu/turbo.c5
-rw-r--r--arch/x86/dts/chromebook_coral.dts22
-rw-r--r--arch/x86/dts/rtc.dtsi2
-rw-r--r--arch/x86/include/asm/arch-apollolake/gpio.h18
-rw-r--r--arch/x86/include/asm/arch-apollolake/hostbridge.h28
-rw-r--r--arch/x86/include/asm/arch-apollolake/pmc.h16
-rw-r--r--arch/x86/include/asm/arch-apollolake/uart.h19
-rw-r--r--arch/x86/include/asm/itss.h21
-rw-r--r--arch/x86/include/asm/p2sb.h18
-rw-r--r--arch/x86/include/asm/pmu.h6
-rw-r--r--arch/x86/include/asm/sysreset.h18
-rw-r--r--arch/x86/lib/tpl.c4
-rw-r--r--arch/xtensa/include/asm/spl.h0
-rw-r--r--board/Arcturus/ucp1020/spl.c2
-rw-r--r--board/Arcturus/ucp1020/spl_minimal.c6
-rw-r--r--board/Synology/ds109/ds109.c9
-rw-r--r--board/armltd/integrator/integrator.c2
-rw-r--r--board/armltd/total_compute/total_compute.c2
-rw-r--r--board/armltd/vexpress64/vexpress64.c2
-rw-r--r--board/bluewater/gurnard/gurnard.c2
-rw-r--r--board/bluewater/snapper9260/snapper9260.c2
-rw-r--r--board/cadence/xtfpga/xtfpga.c4
-rw-r--r--board/cavium/thunderx/thunderx.c4
-rw-r--r--board/compulab/cm_fx6/cm_fx6.c2
-rw-r--r--board/davinci/da8xxevm/omapl138_lcdk.c4
-rw-r--r--board/dhelectronics/dh_stm32mp1/board.c6
-rw-r--r--board/freescale/ls1012afrdm/eth.c4
-rw-r--r--board/freescale/ls1012aqds/eth.c4
-rw-r--r--board/freescale/ls1012ardb/eth.c4
-rw-r--r--board/freescale/lx2160a/lx2160a.c4
-rw-r--r--board/freescale/mpc8313erdb/mpc8313erdb.c6
-rw-r--r--board/freescale/mpc8315erdb/mpc8315erdb.c6
-rw-r--r--board/freescale/p1010rdb/spl.c2
-rw-r--r--board/freescale/p1010rdb/spl_minimal.c8
-rw-r--r--board/freescale/p1_p2_rdb_pc/spl.c2
-rw-r--r--board/freescale/p1_p2_rdb_pc/spl_minimal.c8
-rw-r--r--board/freescale/t102xrdb/spl.c2
-rw-r--r--board/freescale/t104xrdb/spl.c2
-rw-r--r--board/freescale/t208xqds/spl.c2
-rw-r--r--board/freescale/t208xrdb/spl.c2
-rw-r--r--board/freescale/t4rdb/spl.c2
-rw-r--r--board/gateworks/gw_ventana/gw_ventana.c2
-rw-r--r--board/google/chromebook_coral/coral.c4
-rw-r--r--board/google/gru/gru.c2
-rw-r--r--board/hisilicon/hikey/hikey.c4
-rw-r--r--board/hisilicon/hikey960/hikey960.c2
-rw-r--r--board/hisilicon/poplar/poplar.c2
-rw-r--r--board/isee/igep00x0/igep00x0.c2
-rw-r--r--board/lg/sniper/sniper.c2
-rw-r--r--board/nokia/rx51/rx51.c2
-rw-r--r--board/nvidia/jetson-tk1/jetson-tk1.c2
-rw-r--r--board/nvidia/nyan-big/nyan-big.c2
-rw-r--r--board/renesas/ulcb/cpld.c2
-rw-r--r--board/sandbox/sandbox.c2
-rw-r--r--board/siemens/corvus/board.c2
-rw-r--r--board/sifive/fu540/fu540.c2
-rw-r--r--board/st/common/cmd_stboard.c2
-rw-r--r--board/st/common/stm32mp_dfu.c4
-rw-r--r--board/st/common/stpmic1.c4
-rw-r--r--board/st/common/stusb160x.c2
-rw-r--r--board/st/stm32mp1/stm32mp1.c12
-rw-r--r--board/st/stv0991/stv0991.c2
-rw-r--r--board/synopsys/hsdk/clk-lib.c2
-rw-r--r--board/sysam/amcore/amcore.c2
-rw-r--r--board/ti/am335x/board.c6
-rw-r--r--board/ti/j721e/evm.c4
-rw-r--r--board/timll/devkit8000/devkit8000.c2
-rw-r--r--board/toradex/apalis-tk1/apalis-tk1.c4
-rw-r--r--board/toradex/apalis_imx6/apalis_imx6.c2
-rw-r--r--board/toradex/colibri-imx6ull/colibri-imx6ull.c2
-rw-r--r--board/toradex/colibri_imx6/colibri_imx6.c2
-rw-r--r--board/toradex/colibri_pxa270/colibri_pxa270.c4
-rw-r--r--cmd/remoteproc.c2
-rw-r--r--common/spl/Kconfig9
-rw-r--r--common/spl/spl.c20
-rw-r--r--doc/driver-model/design.rst18
-rw-r--r--doc/driver-model/of-plat.rst32
-rw-r--r--doc/driver-model/remoteproc-framework.rst2
-rw-r--r--doc/driver-model/spi-howto.rst4
-rw-r--r--drivers/ata/mtk_ahci.c3
-rw-r--r--drivers/clk/clk-uclass.c2
-rw-r--r--drivers/clk/clk.c6
-rw-r--r--drivers/clk/clk_fixed_rate.c4
-rw-r--r--drivers/clk/clk_stm32mp1.c2
-rw-r--r--drivers/clk/clk_zynqmp.c2
-rw-r--r--drivers/clk/imx/clk-imx8.c2
-rw-r--r--drivers/clk/mediatek/clk-mtk.c6
-rw-r--r--drivers/clk/meson/axg.c2
-rw-r--r--drivers/clk/meson/g12a.c2
-rw-r--r--drivers/clk/meson/gxbb.c2
-rw-r--r--drivers/clk/rockchip/clk_px30.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3036.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3128.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3188.c2
-rw-r--r--drivers/clk/rockchip/clk_rk322x.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3288.c2
-rw-r--r--drivers/clk/rockchip/clk_rk3308.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3328.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3368.c3
-rw-r--r--drivers/clk/rockchip/clk_rk3399.c3
-rw-r--r--drivers/clk/rockchip/clk_rv1108.c3
-rw-r--r--drivers/clk/sifive/fu540-prci.c2
-rw-r--r--drivers/core/device-remove.c42
-rw-r--r--drivers/core/device.c214
-rw-r--r--drivers/core/devres.c4
-rw-r--r--drivers/core/dump.c10
-rw-r--r--drivers/core/lists.c6
-rw-r--r--drivers/core/root.c59
-rw-r--r--drivers/core/simple-bus.c11
-rw-r--r--drivers/core/uclass.c35
-rw-r--r--drivers/crypto/fsl/fsl_rsa.c2
-rw-r--r--drivers/crypto/rsa_mod_exp/mod_exp_sw.c2
-rw-r--r--drivers/ddr/altera/sdram_agilex.c2
-rw-r--r--drivers/ddr/altera/sdram_gen5.c4
-rw-r--r--drivers/ddr/altera/sdram_s10.c2
-rw-r--r--drivers/ddr/altera/sdram_soc64.c2
-rw-r--r--drivers/demo/demo-pdata.c10
-rw-r--r--drivers/firmware/scmi/scmi_agent-uclass.c4
-rw-r--r--drivers/gpio/dwapb_gpio.c2
-rw-r--r--drivers/gpio/gpio-uclass.c4
-rw-r--r--drivers/gpio/hi6220_gpio.c2
-rw-r--r--drivers/gpio/imx_rgpio2p.c9
-rw-r--r--drivers/gpio/intel_gpio.c4
-rw-r--r--drivers/gpio/lpc32xx_gpio.c2
-rw-r--r--drivers/gpio/mpc8xxx_gpio.c4
-rw-r--r--drivers/gpio/mt7621_gpio.c2
-rw-r--r--drivers/gpio/mxc_gpio.c4
-rw-r--r--drivers/gpio/mxs_gpio.c4
-rw-r--r--drivers/gpio/octeon_gpio.c2
-rw-r--r--drivers/gpio/omap_gpio.c3
-rw-r--r--drivers/gpio/s5p_gpio.c6
-rw-r--r--drivers/gpio/sandbox.c10
-rw-r--r--drivers/gpio/sunxi_gpio.c2
-rw-r--r--drivers/gpio/tegra186_gpio.c6
-rw-r--r--drivers/gpio/tegra_gpio.c6
-rw-r--r--drivers/i2c/designware_i2c_pci.c4
-rw-r--r--drivers/i2c/i2c-uclass.c2
-rw-r--r--drivers/i2c/rk_i2c.c2
-rw-r--r--drivers/i2c/sandbox_i2c.c5
-rw-r--r--drivers/misc/Kconfig9
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/altera_sysid.c2
-rw-r--r--drivers/misc/cros_ec_sandbox.c4
-rw-r--r--drivers/misc/fs_loader.c6
-rw-r--r--drivers/misc/i2c_eeprom.c2
-rw-r--r--drivers/misc/p2sb-uclass.c15
-rw-r--r--drivers/misc/rockchip-efuse.c2
-rw-r--r--drivers/misc/spltest_sandbox.c6
-rw-r--r--drivers/misc/stm32mp_fuse.c16
-rw-r--r--drivers/misc/swap_case.c2
-rw-r--r--drivers/misc/test_drv.c222
-rw-r--r--drivers/misc/vexpress_config.c2
-rw-r--r--drivers/mmc/arm_pl180_mmci.c6
-rw-r--r--drivers/mmc/fsl_esdhc_imx.c2
-rw-r--r--drivers/mmc/mxsmmc.c4
-rw-r--r--drivers/mmc/octeontx_hsmmc.c42
-rw-r--r--drivers/mmc/pci_mmc.c2
-rw-r--r--drivers/mmc/rockchip_dw_mmc.c4
-rw-r--r--drivers/mtd/nand/raw/arasan_nfc.c2
-rw-r--r--drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c2
-rw-r--r--drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c2
-rw-r--r--drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c2
-rw-r--r--drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c2
-rw-r--r--drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c2
-rw-r--r--drivers/mtd/nand/raw/davinci_nand.c2
-rw-r--r--drivers/mtd/nand/raw/denali_dt.c2
-rw-r--r--drivers/mtd/nand/raw/mxs_nand_dt.c2
-rw-r--r--drivers/mtd/nand/raw/octeontx_nand.c10
-rw-r--r--drivers/mtd/nand/raw/pxa3xx_nand.c2
-rw-r--r--drivers/mtd/nand/raw/stm32_fmc2_nand.c2
-rw-r--r--drivers/mtd/nand/raw/tegra_nand.c2
-rw-r--r--drivers/mtd/nand/raw/vf610_nfc.c2
-rw-r--r--drivers/mtd/nand/raw/zynq_nand.c2
-rw-r--r--drivers/mtd/nand/spi/core.c2
-rw-r--r--drivers/mtd/spi/sf-uclass.c2
-rw-r--r--drivers/mtd/spi/sf_probe.c4
-rw-r--r--drivers/mux/mmio.c3
-rw-r--r--drivers/net/eth-phy-uclass.c4
-rw-r--r--drivers/net/fm/eth.c26
-rw-r--r--drivers/net/fsl_enetc.c8
-rw-r--r--drivers/net/fsl_enetc_mdio.c2
-rw-r--r--drivers/net/fsl_mcdmafec.c10
-rw-r--r--drivers/net/mcffec.c12
-rw-r--r--drivers/net/mcfmii.c8
-rw-r--r--drivers/net/mdio-ipq4019.c4
-rw-r--r--drivers/net/mdio_mux_i2creg.c2
-rw-r--r--drivers/net/mvmdio.c4
-rw-r--r--drivers/net/octeontx/smi.c2
-rw-r--r--drivers/net/pfe_eth/pfe_eth.c2
-rw-r--r--drivers/net/sunxi_emac.c2
-rw-r--r--drivers/net/tsec.c49
-rw-r--r--drivers/net/xilinx_emaclite.c2
-rw-r--r--drivers/pci/pci-emul-uclass.c4
-rw-r--r--drivers/pci/pci-uclass.c16
-rw-r--r--drivers/phy/phy-ti-am654.c2
-rw-r--r--drivers/pinctrl/intel/pinctrl.c11
-rw-r--r--drivers/pinctrl/intel/pinctrl_apl.c18
-rw-r--r--drivers/pinctrl/nxp/pinctrl-imx6.c2
-rw-r--r--drivers/pinctrl/nxp/pinctrl-mxs.c2
-rw-r--r--drivers/pinctrl/pinctrl-at91.c2
-rw-r--r--drivers/pinctrl/pinctrl-qe-io.c4
-rw-r--r--drivers/pinctrl/pinctrl-single.c6
-rw-r--r--drivers/pinctrl/pinctrl-uclass.c6
-rw-r--r--drivers/power/acpi_pmc/acpi-pmc-uclass.c4
-rw-r--r--drivers/power/domain/meson-ee-pwrc.c4
-rw-r--r--drivers/power/domain/meson-gx-pwrc-vpu.c4
-rw-r--r--drivers/power/pmic/rk8xx.c2
-rw-r--r--drivers/power/regulator/da9063.c24
-rw-r--r--drivers/power/regulator/pbias_regulator.c6
-rw-r--r--drivers/pwm/pwm-meson.c9
-rw-r--r--drivers/remoteproc/rproc-uclass.c6
-rw-r--r--drivers/remoteproc/sandbox_testproc.c2
-rw-r--r--drivers/reset/reset-ast2500.c2
-rw-r--r--drivers/reset/reset-mediatek.c3
-rw-r--r--drivers/reset/reset-rockchip.c3
-rw-r--r--drivers/reset/reset-sifive.c3
-rw-r--r--drivers/reset/reset-socfpga.c2
-rw-r--r--drivers/reset/reset-sunxi.c3
-rw-r--r--drivers/rtc/emul_rtc.c2
-rw-r--r--drivers/serial/altera_jtag_uart.c8
-rw-r--r--drivers/serial/altera_uart.c8
-rw-r--r--drivers/serial/atmel_usart.c2
-rw-r--r--drivers/serial/ns16550.c68
-rw-r--r--drivers/serial/sandbox.c24
-rw-r--r--drivers/serial/serial-uclass.c2
-rw-r--r--drivers/serial/serial_arc.c8
-rw-r--r--drivers/serial/serial_coreboot.c2
-rw-r--r--drivers/serial/serial_intel_mid.c2
-rw-r--r--drivers/serial/serial_linflexuart.c2
-rw-r--r--drivers/serial/serial_lpuart.c10
-rw-r--r--drivers/serial/serial_mcf.c10
-rw-r--r--drivers/serial/serial_meson.c12
-rw-r--r--drivers/serial/serial_mxc.c12
-rw-r--r--drivers/serial/serial_ns16550.c26
-rw-r--r--drivers/serial/serial_omap.c8
-rw-r--r--drivers/serial/serial_pxa.c10
-rw-r--r--drivers/serial/serial_rockchip.c7
-rw-r--r--drivers/serial/serial_s5p.c12
-rw-r--r--drivers/spi/cadence_qspi.c12
-rw-r--r--drivers/spi/cf_spi.c2
-rw-r--r--drivers/spi/davinci_spi.c4
-rw-r--r--drivers/spi/designware_spi.c4
-rw-r--r--drivers/spi/exynos_spi.c4
-rw-r--r--drivers/spi/fsl_dspi.c10
-rw-r--r--drivers/spi/fsl_espi.c2
-rw-r--r--drivers/spi/fsl_qspi.c2
-rw-r--r--drivers/spi/ich.c11
-rw-r--r--drivers/spi/ich.h11
-rw-r--r--drivers/spi/mxs_spi.c4
-rw-r--r--drivers/spi/pl022_spi.c2
-rw-r--r--drivers/spi/rk_spi.c8
-rw-r--r--drivers/spi/soft_spi.c4
-rw-r--r--drivers/spi/spi-uclass.c2
-rw-r--r--drivers/spi/tegra114_spi.c4
-rw-r--r--drivers/spi/tegra20_sflash.c4
-rw-r--r--drivers/spi/tegra20_slink.c4
-rw-r--r--drivers/spi/tegra210_qspi.c4
-rw-r--r--drivers/spi/uniphier_spi.c8
-rw-r--r--drivers/spi/zynq_qspi.c4
-rw-r--r--drivers/spi/zynq_spi.c8
-rw-r--r--drivers/spi/zynqmp_gqspi.c6
-rw-r--r--drivers/sysreset/sysreset-uclass.c12
-rw-r--r--drivers/sysreset/sysreset_sandbox.c6
-rw-r--r--drivers/sysreset/sysreset_x86.c5
-rw-r--r--drivers/tee/optee/core.c2
-rw-r--r--drivers/timer/ag101p_timer.c4
-rw-r--r--drivers/timer/altera_timer.c4
-rw-r--r--drivers/timer/andes_plmt_timer.c7
-rw-r--r--drivers/timer/mpc83xx_timer.c2
-rw-r--r--drivers/timer/sandbox_timer.c2
-rw-r--r--drivers/timer/sifive_clint_timer.c7
-rw-r--r--drivers/timer/timer-uclass.c4
-rw-r--r--drivers/timer/tsc_timer.c4
-rw-r--r--drivers/usb/cdns3/core.c4
-rw-r--r--drivers/usb/dwc3/core.c2
-rw-r--r--drivers/usb/dwc3/dwc3-generic.c6
-rw-r--r--drivers/usb/dwc3/dwc3-meson-g12a.c2
-rw-r--r--drivers/usb/dwc3/dwc3-meson-gxl.c2
-rw-r--r--drivers/usb/gadget/dwc2_udc_otg.c4
-rw-r--r--drivers/usb/gadget/ether.c16
-rw-r--r--drivers/usb/host/dwc3-octeon-glue.c2
-rw-r--r--drivers/usb/host/dwc3-sti-glue.c5
-rw-r--r--drivers/usb/host/ehci-mx6.c2
-rw-r--r--drivers/usb/host/usb-uclass.c10
-rw-r--r--drivers/usb/host/xhci-dwc3.c2
-rw-r--r--drivers/usb/mtu3/mtu3_core.c2
-rw-r--r--drivers/usb/mtu3/mtu3_plat.c4
-rw-r--r--drivers/usb/musb-new/ti-musb.c2
-rw-r--r--drivers/video/lg4573.c2
-rw-r--r--drivers/video/nexell_display.c2
-rw-r--r--drivers/video/rockchip/rk_mipi.c2
-rw-r--r--drivers/video/sunxi/sunxi_de2.c2
-rw-r--r--drivers/video/sunxi/sunxi_dw_hdmi.c2
-rw-r--r--drivers/video/sunxi/sunxi_lcd.c2
-rw-r--r--drivers/video/video-uclass.c2
-rw-r--r--dts/Kconfig8
-rw-r--r--dts/Makefile14
-rw-r--r--include/asm-generic/global_data.h8
-rw-r--r--include/dm/device-internal.h85
-rw-r--r--include/dm/device.h111
-rw-r--r--include/dm/lists.h2
-rw-r--r--include/dm/platdata.h28
-rw-r--r--include/dm/platform_data/spi_pl022.h2
-rw-r--r--include/dm/read.h18
-rw-r--r--include/dm/simple_bus.h15
-rw-r--r--include/dm/test.h20
-rw-r--r--include/dm/uclass-internal.h14
-rw-r--r--include/dm/uclass.h16
-rw-r--r--include/linux/mtd/mtd.h9
-rw-r--r--include/linux/mtd/nand.h14
-rw-r--r--include/linux/mtd/spi-nor.h6
-rw-r--r--include/linux/mtd/spinand.h15
-rw-r--r--include/ns16550.h21
-rw-r--r--include/spl.h10
-rw-r--r--include/test/test.h9
-rw-r--r--include/virtio.h2
-rw-r--r--lib/efi/efi_stub.c2
-rw-r--r--lib/efi_loader/efi_device_path.c2
-rw-r--r--lib/time.c10
-rw-r--r--net/eth-uclass.c22
-rw-r--r--net/mdio-mux-uclass.c2
-rw-r--r--net/mdio-uclass.c8
-rw-r--r--scripts/Makefile.spl35
-rw-r--r--test/dm/bus.c117
-rw-r--r--test/dm/core.c58
-rw-r--r--test/dm/cpu.c2
-rw-r--r--test/dm/pci.c6
-rw-r--r--test/dm/test-driver.c7
-rw-r--r--test/dm/test-fdt.c148
-rw-r--r--test/dm/test-uclass.c4
-rw-r--r--test/dm/virtio.c2
-rw-r--r--test/py/tests/test_ofplatdata.py1
-rw-r--r--tools/concurrencytest/concurrencytest.py4
-rw-r--r--tools/dtoc/dtb_platdata.py518
-rw-r--r--tools/dtoc/dtoc_test_scan_drivers.cxx2
-rw-r--r--tools/dtoc/dtoc_test_simple.dts5
-rwxr-xr-xtools/dtoc/main.py49
-rw-r--r--tools/dtoc/src_scan.py185
-rwxr-xr-xtools/dtoc/test_dtoc.py413
-rw-r--r--tools/dtoc/test_src_scan.py107
-rw-r--r--tools/patman/tools.py8
410 files changed, 2799 insertions, 1956 deletions
diff --git a/arch/arc/include/asm/spl.h b/arch/arc/include/asm/spl.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/arch/arc/include/asm/spl.h
diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index d8cb78e..2556980 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -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;
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
index 7772433..215ed97 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
@@ -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
diff --git a/arch/arm/lib/gic-v3-its.c b/arch/arm/lib/gic-v3-its.c
index a1657e3..f5a921b 100644
--- a/arch/arm/lib/gic-v3-its.c
+++ b/arch/arm/lib/gic-v3-its.c
@@ -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;
diff --git a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c
index 3e9f5e5..02bd3f6 100644
--- a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c
+++ b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c
@@ -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)
diff --git a/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c b/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
index 9d78719..c10571f 100644
--- a/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
@@ -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] },
diff --git a/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c b/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c
index f503553..d517810 100644
--- a/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c
+++ b/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c
@@ -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] },
diff --git a/arch/arm/mach-davinci/da850_lowlevel.c b/arch/arm/mach-davinci/da850_lowlevel.c
index 07bf19b..759c937 100644
--- a/arch/arm/mach-davinci/da850_lowlevel.c
+++ b/arch/arm/mach-davinci/da850_lowlevel.c
@@ -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
diff --git a/arch/arm/mach-davinci/spl.c b/arch/arm/mach-davinci/spl.c
index 5fea935..d0d7a81 100644
--- a/arch/arm/mach-davinci/spl.c
+++ b/arch/arm/mach-davinci/spl.c
@@ -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 */
diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
index 1649f6d..bf6dddf 100644
--- a/arch/arm/mach-imx/mx6/soc.c
+++ b/arch/arm/mach-imx/mx6/soc.c
@@ -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,
};
diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 1359399..fda25ba 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -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,
};
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
index 0fed5ae..dea470c 100644
--- a/arch/arm/mach-k3/am6_init.c
+++ b/arch/arm/mach-k3/am6_init.c
@@ -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);
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 8c903f1..8b54e0c 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -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);
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 0201690..1a4f796 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -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);
diff --git a/arch/arm/mach-keystone/init.c b/arch/arm/mach-keystone/init.c
index 88e8912..4950f14 100644
--- a/arch/arm/mach-keystone/init.c
+++ b/arch/arm/mach-keystone/init.c
@@ -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
diff --git a/arch/arm/mach-lpc32xx/devices.c b/arch/arm/mach-lpc32xx/devices.c
index 04e026a..e1e2e0d 100644
--- a/arch/arm/mach-lpc32xx/devices.c
+++ b/arch/arm/mach-lpc32xx/devices.c
@@ -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"
};
diff --git a/arch/arm/mach-mediatek/mt7629/init.c b/arch/arm/mach-mediatek/mt7629/init.c
index c260413..1f102dd 100644
--- a/arch/arm/mach-mediatek/mt7629/init.c
+++ b/arch/arm/mach-mediatek/mt7629/init.c
@@ -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;
diff --git a/arch/arm/mach-mediatek/mt8516/init.c b/arch/arm/mach-mediatek/mt8516/init.c
index 13be391..2ffa559 100644
--- a/arch/arm/mach-mediatek/mt8516/init.c
+++ b/arch/arm/mach-mediatek/mt8516/init.c
@@ -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;
diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c
index b5f2b75..e17898d 100644
--- a/arch/arm/mach-omap2/am33xx/board.c
+++ b/arch/arm/mach-omap2/am33xx/board.c
@@ -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
diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c
index 6ffedd1..4da8df4 100644
--- a/arch/arm/mach-omap2/omap3/board.c
+++ b/arch/arm/mach-omap2/omap3/board.c
@@ -47,7 +47,7 @@ static const struct omap_gpio_plat omap34xx_gpio[] = {
{ 5, OMAP34XX_GPIO6_BASE },
};
-U_BOOT_DEVICES(omap34xx_gpios) = {
+U_BOOT_DRVINFOS(omap34xx_gpios) = {
{ "gpio_omap", &omap34xx_gpio[0] },
{ "gpio_omap", &omap34xx_gpio[1] },
{ "gpio_omap", &omap34xx_gpio[2] },
diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
index 28c7c72..87eebd9 100644
--- a/arch/arm/mach-rockchip/misc.c
+++ b/arch/arm/mach-rockchip/misc.c
@@ -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__);
diff --git a/arch/arm/mach-rockchip/px30/clk_px30.c b/arch/arm/mach-rockchip/px30/clk_px30.c
index 98a1bcd..7edf132 100644
--- a/arch/arm/mach-rockchip/px30/clk_px30.c
+++ b/arch/arm/mach-rockchip/px30/clk_px30.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
index 5d0def3..116dccd 100644
--- a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
+++ b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3128/clk_rk3128.c b/arch/arm/mach-rockchip/rk3128/clk_rk3128.c
index f9ce1f7..a1b038c 100644
--- a/arch/arm/mach-rockchip/rk3128/clk_rk3128.c
+++ b/arch/arm/mach-rockchip/rk3128/clk_rk3128.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3188/clk_rk3188.c b/arch/arm/mach-rockchip/rk3188/clk_rk3188.c
index a0dcac3..94d1d23 100644
--- a/arch/arm/mach-rockchip/rk3188/clk_rk3188.c
+++ b/arch/arm/mach-rockchip/rk3188/clk_rk3188.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk322x/clk_rk322x.c b/arch/arm/mach-rockchip/rk322x/clk_rk322x.c
index fc5abd7..2e57672 100644
--- a/arch/arm/mach-rockchip/rk322x/clk_rk322x.c
+++ b/arch/arm/mach-rockchip/rk322x/clk_rk322x.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
index e05bd06..fb4c089 100644
--- a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3308/clk_rk3308.c b/arch/arm/mach-rockchip/rk3308/clk_rk3308.c
index 1feb237..ccda533 100644
--- a/arch/arm/mach-rockchip/rk3308/clk_rk3308.c
+++ b/arch/arm/mach-rockchip/rk3308/clk_rk3308.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
index e537551..70c0eb6 100644
--- a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
+++ b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3368/clk_rk3368.c b/arch/arm/mach-rockchip/rk3368/clk_rk3368.c
index 9a33c67..b075319 100644
--- a/arch/arm/mach-rockchip/rk3368/clk_rk3368.c
+++ b/arch/arm/mach-rockchip/rk3368/clk_rk3368.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
index d23a5e9..9d9a837 100644
--- a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c
@@ -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)
diff --git a/arch/arm/mach-rockchip/rv1108/clk_rv1108.c b/arch/arm/mach-rockchip/rv1108/clk_rv1108.c
index b37ae1c..44b53c4 100644
--- a/arch/arm/mach-rockchip/rv1108/clk_rv1108.c
+++ b/arch/arm/mach-rockchip/rv1108/clk_rv1108.c
@@ -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)
diff --git a/arch/arm/mach-socfpga/clock_manager_agilex.c b/arch/arm/mach-socfpga/clock_manager_agilex.c
index 6188a8c..a960176 100644
--- a/arch/arm/mach-socfpga/clock_manager_agilex.c
+++ b/arch/arm/mach-socfpga/clock_manager_agilex.c
@@ -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;
diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index 85a9e6f..84e0bdd 100644
--- a/arch/arm/mach-stm32mp/bsec.c
+++ b/arch/arm/mach-stm32mp/bsec.c
@@ -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;
diff --git a/arch/arm/mach-stm32mp/cmd_stm32key.c b/arch/arm/mach-stm32mp/cmd_stm32key.c
index f191085..544bab3 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32key.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32key.c
@@ -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");
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index a777827..fc9a2af 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -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;
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index 1520c6e..29c0d92 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -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;
diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c
index 74a5df5..766ed95 100644
--- a/arch/arm/mach-stm32mp/pwr_regulator.c
+++ b/arch/arm/mach-stm32mp/pwr_regulator.c
@@ -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;
}
diff --git a/arch/arm/mach-tegra/board.c b/arch/arm/mach-tegra/board.c
index bf01aa5..9de9836 100644
--- a/arch/arm/mach-tegra/board.c
+++ b/arch/arm/mach-tegra/board.c
@@ -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
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index 48c4f32..8569ad7 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -42,7 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_SPL_BUILD
/* TODO(sjg@chromium.org): Remove once SPL supports device tree */
-U_BOOT_DEVICE(tegra_gpios) = {
+U_BOOT_DRVINFO(tegra_gpios) = {
"gpio_tegra"
};
#endif
diff --git a/arch/arm/mach-uniphier/micro-support-card.c b/arch/arm/mach-uniphier/micro-support-card.c
index dbd156f..95780f7 100644
--- a/arch/arm/mach-uniphier/micro-support-card.c
+++ b/arch/arm/mach-uniphier/micro-support-card.c
@@ -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;
diff --git a/arch/arm/mach-zynq/clk.c b/arch/arm/mach-zynq/clk.c
index 1ace117..8560476 100644
--- a/arch/arm/mach-zynq/clk.c
+++ b/arch/arm/mach-zynq/clk.c
@@ -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;
diff --git a/arch/arm/mach-zynq/timer.c b/arch/arm/mach-zynq/timer.c
index cc0e24c..3719315 100644
--- a/arch/arm/mach-zynq/timer.c
+++ b/arch/arm/mach-zynq/timer.c
@@ -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
index 0000000..e69de29
--- /dev/null
+++ b/arch/m68k/include/asm/spl.h
diff --git a/arch/mips/mach-mtmips/mt7628/init.c b/arch/mips/mach-mtmips/mt7628/init.c
index 77d1f2e..3353864 100644
--- a/arch/mips/mach-mtmips/mt7628/init.c
+++ b/arch/mips/mach-mtmips/mt7628/init.c
@@ -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
index 0000000..e69de29
--- /dev/null
+++ b/arch/nds32/include/asm/spl.h
diff --git a/arch/nios2/include/asm/spl.h b/arch/nios2/include/asm/spl.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/arch/nios2/include/asm/spl.h
diff --git a/arch/riscv/lib/sifive_clint.c b/arch/riscv/lib/sifive_clint.c
index c8079dc..cfa288a 100644
--- a/arch/riscv/lib/sifive_clint.c
+++ b/arch/riscv/lib/sifive_clint.c
@@ -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;
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index b56fa04..80996a9 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -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);
}
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index fe494ae..8322ed7a 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -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;
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 59f37fa..b2901b7 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -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);
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 8b50a40..a8938a3 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -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>;
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 81cdc55..d842f02 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -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>;
@@ -120,7 +120,7 @@
};
lcd {
- u-boot,dm-pre-reloc;
+ u-boot,dm-pre-proper;
compatible = "sandbox,lcd-sdl";
xres = <1366>;
yres = <768>;
@@ -209,7 +209,7 @@
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>;
@@ -248,11 +248,6 @@
stringarray = "one";
};
- spl-test4 {
- u-boot,dm-pre-reloc;
- compatible = "sandbox,spl-test.2";
- };
-
spl-test5 {
u-boot,dm-tpl;
compatible = "sandbox,spl-test";
@@ -283,7 +278,6 @@
};
tpm {
- u-boot,dm-pre-reloc;
compatible = "google,sandbox-tpm";
};
@@ -420,6 +414,6 @@
};
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
index 0000000..b482be4
--- /dev/null
+++ b/arch/sandbox/include/asm/i2c.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#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
index 0000000..bc82aeb
--- /dev/null
+++ b/arch/sandbox/include/asm/serial.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#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
index 0000000..e69de29
--- /dev/null
+++ b/arch/sh/include/asm/spl.h
diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
index c6c1350..f5dbd6c 100644
--- a/arch/x86/cpu/apollolake/Kconfig
+++ b/arch/x86/cpu/apollolake/Kconfig
@@ -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
diff --git a/arch/x86/cpu/apollolake/fsp_m.c b/arch/x86/cpu/apollolake/fsp_m.c
index cef9375..c6be707 100644
--- a/arch/x86/cpu/apollolake/fsp_m.c
+++ b/arch/x86/cpu/apollolake/fsp_m.c
@@ -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)
diff --git a/arch/x86/cpu/apollolake/hostbridge.c b/arch/x86/cpu/apollolake/hostbridge.c
index e4674f3..9decab7 100644
--- a/arch/x86/cpu/apollolake/hostbridge.c
+++ b/arch/x86/cpu/apollolake/hostbridge.c
@@ -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,
diff --git a/arch/x86/cpu/apollolake/lpc.c b/arch/x86/cpu/apollolake/lpc.c
index d8e05f6..e085890 100644
--- a/arch/x86/cpu/apollolake/lpc.c
+++ b/arch/x86/cpu/apollolake/lpc.c
@@ -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)
};
diff --git a/arch/x86/cpu/apollolake/pch.c b/arch/x86/cpu/apollolake/pch.c
index d9832ff..39d6ad5 100644
--- a/arch/x86/cpu/apollolake/pch.c
+++ b/arch/x86/cpu/apollolake/pch.c
@@ -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,
};
diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c
index 290b2cb..e23d38e 100644
--- a/arch/x86/cpu/apollolake/pmc.c
+++ b/arch/x86/cpu/apollolake/pmc.c
@@ -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,
diff --git a/arch/x86/cpu/apollolake/spl.c b/arch/x86/cpu/apollolake/spl.c
index 3a1588b..8991d5e 100644
--- a/arch/x86/cpu/apollolake/spl.c
+++ b/arch/x86/cpu/apollolake/spl.c
@@ -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,
};
diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c
index 26aef65..876fa59 100644
--- a/arch/x86/cpu/apollolake/uart.c
+++ b/arch/x86/cpu/apollolake/uart.c
@@ -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(sjg@chromium.org): 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,
diff --git a/arch/x86/cpu/i386/call64.S b/arch/x86/cpu/i386/call64.S
index 275063c..0ffc100 100644
--- a/arch/x86/cpu/i386/call64.S
+++ b/arch/x86/cpu/i386/call64.S
@@ -11,6 +11,7 @@
#include <asm/processor-flags.h>
.code32
+.section .text_call64
.globl cpu_call64
cpu_call64:
/*
diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile
index 4a5cf17..8b9a810 100644
--- a/arch/x86/cpu/intel_common/Makefile
+++ b/arch/x86/cpu/intel_common/Makefile
@@ -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
diff --git a/arch/x86/cpu/intel_common/itss.c b/arch/x86/cpu/intel_common/itss.c
index e71ea02..ae4de4c 100644
--- a/arch/x86/cpu/intel_common/itss.c
+++ b/arch/x86/cpu/intel_common/itss.c
@@ -19,25 +19,6 @@
#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,
diff --git a/arch/x86/cpu/intel_common/p2sb.c b/arch/x86/cpu/intel_common/p2sb.c
index e6edab0..d73ae43 100644
--- a/arch/x86/cpu/intel_common/p2sb.c
+++ b/arch/x86/cpu/intel_common/p2sb.c
@@ -13,20 +13,13 @@
#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,
diff --git a/arch/x86/cpu/slimbootloader/serial.c b/arch/x86/cpu/slimbootloader/serial.c
index 5d89632..772a94c 100644
--- a/arch/x86/cpu/slimbootloader/serial.c
+++ b/arch/x86/cpu/slimbootloader/serial.c
@@ -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,
};
diff --git a/arch/x86/cpu/turbo.c b/arch/x86/cpu/turbo.c
index f8d85d5..4a73cb2 100644
--- a/arch/x86/cpu/turbo.c
+++ b/arch/x86/cpu/turbo.c
@@ -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;
}
diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts
index d66e128..a846022 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -102,12 +102,13 @@
};
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>;
@@ -174,6 +175,9 @@
*/
fsp_s: fsp-s {
};
+ fsp_m: fsp-m {
+ u-boot,dm-spl;
+ };
nhlt {
intel,dmic-channels = <4>;
@@ -181,12 +185,14 @@
};
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";
};
@@ -321,7 +327,8 @@
};
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>;
@@ -332,7 +339,8 @@
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";
@@ -574,7 +582,7 @@
#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>;
@@ -650,7 +658,9 @@
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>;
diff --git a/arch/x86/dts/rtc.dtsi b/arch/x86/dts/rtc.dtsi
index d0bbd84..942cc93 100644
--- a/arch/x86/dts/rtc.dtsi
+++ b/arch/x86/dts/rtc.dtsi
@@ -1,7 +1,7 @@
/ {
rtc: rtc {
compatible = "motorola,mc146818";
- u-boot,dm-pre-reloc;
+ u-boot,dm-pre-proper;
reg = <0x70 2>;
};
};
diff --git a/arch/x86/include/asm/arch-apollolake/gpio.h b/arch/x86/include/asm/arch-apollolake/gpio.h
index ab5860c..762160d 100644
--- a/arch/x86/include/asm/arch-apollolake/gpio.h
+++ b/arch/x86/include/asm/arch-apollolake/gpio.h
@@ -485,4 +485,22 @@
/* 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
index 0000000..f4dce0d
--- /dev/null
+++ b/arch/x86/include/asm/arch-apollolake/hostbridge.h
@@ -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
index 0000000..23ac8fe
--- /dev/null
+++ b/arch/x86/include/asm/arch-apollolake/pmc.h
@@ -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 */
diff --git a/arch/x86/include/asm/arch-apollolake/uart.h b/arch/x86/include/asm/arch-apollolake/uart.h
index d4fffe6..38335b0 100644
--- a/arch/x86/include/asm/arch-apollolake/uart.h
+++ b/arch/x86/include/asm/arch-apollolake/uart.h
@@ -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
diff --git a/arch/x86/include/asm/itss.h b/arch/x86/include/asm/itss.h
index f7d3240..6d47932 100644
--- a/arch/x86/include/asm/itss.h
+++ b/arch/x86/include/asm/itss.h
@@ -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
@@ -42,4 +44,23 @@
/* 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
index 0000000..6f63eae
--- /dev/null
+++ b/arch/x86/include/asm/p2sb.h
@@ -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 */
diff --git a/arch/x86/include/asm/pmu.h b/arch/x86/include/asm/pmu.h
index b76bdf6..818e808 100644
--- a/arch/x86/include/asm/pmu.h
+++ b/arch/x86/include/asm/pmu.h
@@ -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
index 0000000..5e586f5
--- /dev/null
+++ b/arch/x86/include/asm/sysreset.h
@@ -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_ */
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 15b0212..04ff322 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -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
index 0000000..e69de29
--- /dev/null
+++ b/arch/xtensa/include/asm/spl.h
diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c
index 0fd9532..4ed06a8 100644
--- a/board/Arcturus/ucp1020/spl.c
+++ b/board/Arcturus/ucp1020/spl.c
@@ -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");
diff --git a/board/Arcturus/ucp1020/spl_minimal.c b/board/Arcturus/ucp1020/spl_minimal.c
index cd0022a..90abec9 100644
--- a/board/Arcturus/ucp1020/spl_minimal.c
+++ b/board/Arcturus/ucp1020/spl_minimal.c
@@ -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)
diff --git a/board/Synology/ds109/ds109.c b/board/Synology/ds109/ds109.c
index aa2987d..fe3b0eb 100644
--- a/board/Synology/ds109/ds109.c
+++ b/board/Synology/ds109/ds109.c
@@ -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 */
diff --git a/board/armltd/integrator/integrator.c b/board/armltd/integrator/integrator.c
index 21bea62..3c56fa1 100644
--- a/board/armltd/integrator/integrator.c
+++ b/board/armltd/integrator/integrator.c
@@ -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,
};
diff --git a/board/armltd/total_compute/total_compute.c b/board/armltd/total_compute/total_compute.c
index 6263d0c..da24b32 100644
--- a/board/armltd/total_compute/total_compute.c
+++ b/board/armltd/total_compute/total_compute.c
@@ -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,
};
diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
index 6df6bcd..bd66d52 100644
--- a/board/armltd/vexpress64/vexpress64.c
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -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,
};
diff --git a/board/bluewater/gurnard/gurnard.c b/board/bluewater/gurnard/gurnard.c
index a71b4eb..17ecdb6 100644
--- a/board/bluewater/gurnard/gurnard.c
+++ b/board/bluewater/gurnard/gurnard.c
@@ -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,
};
diff --git a/board/bluewater/snapper9260/snapper9260.c b/board/bluewater/snapper9260/snapper9260.c
index 9e41a42..58fab15 100644
--- a/board/bluewater/snapper9260/snapper9260.c
+++ b/board/bluewater/snapper9260/snapper9260.c
@@ -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,
};
diff --git a/board/cadence/xtfpga/xtfpga.c b/board/cadence/xtfpga/xtfpga.c
index 29db51b..c26793d 100644
--- a/board/cadence/xtfpga/xtfpga.c
+++ b/board/cadence/xtfpga/xtfpga.c
@@ -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,
};
diff --git a/board/cavium/thunderx/thunderx.c b/board/cavium/thunderx/thunderx.c
index 22c4c72..fd23472 100644
--- a/board/cavium/thunderx/thunderx.c
+++ b/board/cavium/thunderx/thunderx.c
@@ -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,
};
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index bc3ce4d..7520e96 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -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,
};
diff --git a/board/davinci/da8xxevm/omapl138_lcdk.c b/board/davinci/da8xxevm/omapl138_lcdk.c
index a8ece17..a088585 100644
--- a/board/davinci/da8xxevm/omapl138_lcdk.c
+++ b/board/davinci/da8xxevm/omapl138_lcdk.c
@@ -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,
};
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index f42d395..35669c2 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -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");
diff --git a/board/freescale/ls1012afrdm/eth.c b/board/freescale/ls1012afrdm/eth.c
index 85104ab..d2df935 100644
--- a/board/freescale/ls1012afrdm/eth.c
+++ b/board/freescale/ls1012afrdm/eth.c
@@ -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,
};
diff --git a/board/freescale/ls1012aqds/eth.c b/board/freescale/ls1012aqds/eth.c
index f6f43d2..8189f41 100644
--- a/board/freescale/ls1012aqds/eth.c
+++ b/board/freescale/ls1012aqds/eth.c
@@ -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,
};
diff --git a/board/freescale/ls1012ardb/eth.c b/board/freescale/ls1012ardb/eth.c
index 5e923e5..2241d06 100644
--- a/board/freescale/ls1012ardb/eth.c
+++ b/board/freescale/ls1012ardb/eth.c
@@ -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,
};
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index 99417aa..ea027be 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -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,
};
diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c b/board/freescale/mpc8313erdb/mpc8313erdb.c
index 65a10c3..7e1a31f 100644
--- a/board/freescale/mpc8313erdb/mpc8313erdb.c
+++ b/board/freescale/mpc8313erdb/mpc8313erdb.c
@@ -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
diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c
index f8e4599..05b983a 100644
--- a/board/freescale/mpc8315erdb/mpc8315erdb.c
+++ b/board/freescale/mpc8315erdb/mpc8315erdb.c
@@ -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 */
diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c
index fbaa6a6..35b95e0 100644
--- a/board/freescale/p1010rdb/spl.c
+++ b/board/freescale/p1010rdb/spl.c
@@ -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
diff --git a/board/freescale/p1010rdb/spl_minimal.c b/board/freescale/p1010rdb/spl_minimal.c
index 0bb2c83..989c5b1 100644
--- a/board/freescale/p1010rdb/spl_minimal.c
+++ b/board/freescale/p1010rdb/spl_minimal.c
@@ -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)
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c
index 8aceceb..b16f701 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -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");
diff --git a/board/freescale/p1_p2_rdb_pc/spl_minimal.c b/board/freescale/p1_p2_rdb_pc/spl_minimal.c
index ced5f3c..eb3f2c8 100644
--- a/board/freescale/p1_p2_rdb_pc/spl_minimal.c
+++ b/board/freescale/p1_p2_rdb_pc/spl_minimal.c
@@ -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)
diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c
index 09dd88a..66d2f3b 100644
--- a/board/freescale/t102xrdb/spl.c
+++ b/board/freescale/t102xrdb/spl.c
@@ -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)
diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c
index e792295..28ac12a 100644
--- a/board/freescale/t104xrdb/spl.c
+++ b/board/freescale/t104xrdb/spl.c
@@ -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);
diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c
index d8c2bbe..13e61f0 100644
--- a/board/freescale/t208xqds/spl.c
+++ b/board/freescale/t208xqds/spl.c
@@ -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)
diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c
index c64bd87..2bba94d 100644
--- a/board/freescale/t208xrdb/spl.c
+++ b/board/freescale/t208xrdb/spl.c
@@ -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)
diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c
index 9aa0a9b..fc624ef 100644
--- a/board/freescale/t4rdb/spl.c
+++ b/board/freescale/t4rdb/spl.c
@@ -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");
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c
index c7224d1..048f624 100644
--- a/board/gateworks/gw_ventana/gw_ventana.c
+++ b/board/gateworks/gw_ventana/gw_ventana.c
@@ -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,
};
diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c
index b8b923c..34b2c2a 100644
--- a/board/google/chromebook_coral/coral.c
+++ b/board/google/chromebook_coral/coral.c
@@ -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)
};
diff --git a/board/google/gru/gru.c b/board/google/gru/gru.c
index 441a1a3..23080c1 100644
--- a/board/google/gru/gru.c
+++ b/board/google/gru/gru.c
@@ -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;
diff --git a/board/hisilicon/hikey/hikey.c b/board/hisilicon/hikey/hikey.c
index 0ac8830..65a8179 100644
--- a/board/hisilicon/hikey/hikey.c
+++ b/board/hisilicon/hikey/hikey.c
@@ -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,
};
diff --git a/board/hisilicon/hikey960/hikey960.c b/board/hisilicon/hikey960/hikey960.c
index 04b8cde..3fe4c60 100644
--- a/board/hisilicon/hikey960/hikey960.c
+++ b/board/hisilicon/hikey960/hikey960.c
@@ -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,
};
diff --git a/board/hisilicon/poplar/poplar.c b/board/hisilicon/poplar/poplar.c
index b8be4ce..bfb2c66 100644
--- a/board/hisilicon/poplar/poplar.c
+++ b/board/hisilicon/poplar/poplar.c
@@ -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,
};
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 6a7da50..0932f62 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -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
};
diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c
index d11630b..118ab26 100644
--- a/board/lg/sniper/sniper.c
+++ b/board/lg/sniper/sniper.c
@@ -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
};
diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c
index bafb620..253ee3c 100644
--- a/board/nokia/rx51/rx51.c
+++ b/board/nokia/rx51/rx51.c
@@ -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] },
diff --git a/board/nvidia/jetson-tk1/jetson-tk1.c b/board/nvidia/jetson-tk1/jetson-tk1.c
index 9eccdc4..d349531 100644
--- a/board/nvidia/jetson-tk1/jetson-tk1.c
+++ b/board/nvidia/jetson-tk1/jetson-tk1.c
@@ -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;
diff --git a/board/nvidia/nyan-big/nyan-big.c b/board/nvidia/nyan-big/nyan-big.c
index 71c71ed..06a36f8 100644
--- a/board/nvidia/nyan-big/nyan-big.c
+++ b/board/nvidia/nyan-big/nyan-big.c
@@ -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;
diff --git a/board/renesas/ulcb/cpld.c b/board/renesas/ulcb/cpld.c
index e3fa352..ebb2d6f 100644
--- a/board/renesas/ulcb/cpld.c
+++ b/board/renesas/ulcb/cpld.c
@@ -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;
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 3235541..d152703 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -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
diff --git a/board/siemens/corvus/board.c b/board/siemens/corvus/board.c
index 1613c44..25d85a8 100644
--- a/board/siemens/corvus/board.c
+++ b/board/siemens/corvus/board.c
@@ -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,
};
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
index 54e5a4c..a4e7822 100644
--- a/board/sifive/fu540/fu540.c
+++ b/board/sifive/fu540/fu540.c
@@ -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__);
diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c
index e103861..2fba383 100644
--- a/board/st/common/cmd_stboard.c
+++ b/board/st/common/cmd_stboard.c
@@ -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),
diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
index aab7d74..9c3d115 100644
--- a/board/st/common/stm32mp_dfu.c
+++ b/board/st/common/stm32mp_dfu.c
@@ -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;
diff --git a/board/st/common/stpmic1.c b/board/st/common/stpmic1.c
index 3aa379e..a313b81 100644
--- a/board/st/common/stpmic1.c
+++ b/board/st/common/stpmic1.c
@@ -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 */
diff --git a/board/st/common/stusb160x.c b/board/st/common/stusb160x.c
index f1197f9..e0a2b76 100644
--- a/board/st/common/stusb160x.c
+++ b/board/st/common/stusb160x.c
@@ -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;
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index d3cffdd..df353cb 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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)
diff --git a/board/st/stv0991/stv0991.c b/board/st/stv0991/stv0991.c
index 3371973..95e203f 100644
--- a/board/st/stv0991/stv0991.c
+++ b/board/st/stv0991/stv0991.c
@@ -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,
};
diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
index 1c74bfb..bd43179 100644
--- a/board/synopsys/hsdk/clk-lib.c
+++ b/board/synopsys/hsdk/clk-lib.c
@@ -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) {
diff --git a/board/sysam/amcore/amcore.c b/board/sysam/amcore/amcore.c
index 42e1a80..65fc60e 100644
--- a/board/sysam/amcore/amcore.c
+++ b/board/sysam/amcore/amcore.c
@@ -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,
};
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 2aa385a..40d2e02 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -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,
};
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index d8711eb..44969e8 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -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);
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index 8753836..0731fb7 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -54,7 +54,7 @@ static const struct ns16550_plat devkit8000_serial = {
.fcr = UART_FCR_DEFVAL,
};
-U_BOOT_DEVICE(devkit8000_uart) = {
+U_BOOT_DRVINFO(devkit8000_uart) = {
"ns16550_serial",
&devkit8000_serial
};
diff --git a/board/toradex/apalis-tk1/apalis-tk1.c b/board/toradex/apalis-tk1/apalis-tk1.c
index e7a2186..b97617c 100644
--- a/board/toradex/apalis-tk1/apalis-tk1.c
+++ b/board/toradex/apalis-tk1/apalis-tk1.c
@@ -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__);
diff --git a/board/toradex/apalis_imx6/apalis_imx6.c b/board/toradex/apalis_imx6/apalis_imx6.c
index 362a750..5ae5274 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -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,
};
diff --git a/board/toradex/colibri-imx6ull/colibri-imx6ull.c b/board/toradex/colibri-imx6ull/colibri-imx6ull.c
index 056064f..6ff55ce 100644
--- a/board/toradex/colibri-imx6ull/colibri-imx6ull.c
+++ b/board/toradex/colibri-imx6ull/colibri-imx6ull.c
@@ -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,
};
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c b/board/toradex/colibri_imx6/colibri_imx6.c
index a82daad..57d3e52 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -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,
};
diff --git a/board/toradex/colibri_pxa270/colibri_pxa270.c b/board/toradex/colibri_pxa270/colibri_pxa270.c
index b9d0fb9..645751a 100644
--- a/board/toradex/colibri_pxa270/colibri_pxa270.c
+++ b/board/toradex/colibri_pxa270/colibri_pxa270.c
@@ -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,
};
diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
index 5f9ba92..b3ddceb 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -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) {
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 6d980be..6b01867 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -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
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 63c48fb..835c53d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -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
diff --git a/doc/driver-model/design.rst b/doc/driver-model/design.rst
index f26e4f1..ffed7d5 100644
--- a/doc/driver-model/design.rst
+++ b/doc/driver-model/design.rst
@@ -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
diff --git a/doc/driver-model/of-plat.rst b/doc/driver-model/of-plat.rst
index afa27c2..4ef2fe6 100644
--- a/doc/driver-model/of-plat.rst
+++ b/doc/driver-model/of-plat.rst
@@ -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.
diff --git a/doc/driver-model/remoteproc-framework.rst b/doc/driver-model/remoteproc-framework.rst
index edb09cc..566495a 100644
--- a/doc/driver-model/remoteproc-framework.rst
+++ b/doc/driver-model/remoteproc-framework.rst
@@ -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,
};
diff --git a/doc/driver-model/spi-howto.rst b/doc/driver-model/spi-howto.rst
index f1c4167..97fbf75 100644
--- a/doc/driver-model/spi-howto.rst
+++ b/doc/driver-model/spi-howto.rst
@@ -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,
};
diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index cd28e0c..46b7677 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -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;
}
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index ac954a3..5cfd00c 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -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. */
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 928ad13..1efb7fe 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -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;
diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 12d81a7..3c5a83c 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -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;
diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index 72cbcdf..5bea2b6 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -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;
diff --git a/drivers/clk/clk_zynqmp.c b/drivers/clk/clk_zynqmp.c
index a9988d8..e8acca0 100644
--- a/drivers/clk/clk_zynqmp.c
+++ b/drivers/clk/clk_zynqmp.c
@@ -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;
diff --git a/drivers/clk/imx/clk-imx8.c b/drivers/clk/imx/clk-imx8.c
index 27a652a..8484613 100644
--- a/drivers/clk/imx/clk-imx8.c
+++ b/drivers/clk/imx/clk-imx8.c
@@ -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;
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 388471b..d43b8a0 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -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:
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index 8206857..d6da59d 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -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);
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
index 01b22ab..5058db1 100644
--- a/drivers/clk/meson/g12a.c
+++ b/drivers/clk/meson/g12a.c
@@ -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);
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 2a20541..e379540 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -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);
diff --git a/drivers/clk/rockchip/clk_px30.c b/drivers/clk/rockchip/clk_px30.c
index 355362d..a2a5939 100644
--- a/drivers/clk/rockchip/clk_px30.c
+++ b/drivers/clk/rockchip/clk_px30.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3036.c b/drivers/clk/rockchip/clk_rk3036.c
index 07ef613..0268584 100644
--- a/drivers/clk/rockchip/clk_rk3036.c
+++ b/drivers/clk/rockchip/clk_rk3036.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3128.c b/drivers/clk/rockchip/clk_rk3128.c
index 9349e14..d5b2b63 100644
--- a/drivers/clk/rockchip/clk_rk3128.c
+++ b/drivers/clk/rockchip/clk_rk3128.c
@@ -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;
diff --git a/drivers/clk/rockchip/clk_rk3188.c b/drivers/clk/rockchip/clk_rk3188.c
index 48bfe09..1b62d8d 100644
--- a/drivers/clk/rockchip/clk_rk3188.c
+++ b/drivers/clk/rockchip/clk_rk3188.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk322x.c b/drivers/clk/rockchip/clk_rk322x.c
index c2f5fc0..dbef606 100644
--- a/drivers/clk/rockchip/clk_rk322x.c
+++ b/drivers/clk/rockchip/clk_rk322x.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c
index e87fdfc..6226d55 100644
--- a/drivers/clk/rockchip/clk_rk3288.c
+++ b/drivers/clk/rockchip/clk_rk3288.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3308.c b/drivers/clk/rockchip/clk_rk3308.c
index 3058951..a05efcf 100644
--- a/drivers/clk/rockchip/clk_rk3308.c
+++ b/drivers/clk/rockchip/clk_rk3308.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c
index e2df712..b825ff4 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c
index 9267cac..780b49c 100644
--- a/drivers/clk/rockchip/clk_rk3368.c
+++ b/drivers/clk/rockchip/clk_rk3368.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c
index 68d5dbb..55ebac7 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -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)
diff --git a/drivers/clk/rockchip/clk_rv1108.c b/drivers/clk/rockchip/clk_rv1108.c
index 62bcf5a..1e22db0 100644
--- a/drivers/clk/rockchip/clk_rv1108.c
+++ b/drivers/clk/rockchip/clk_rv1108.c
@@ -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)
diff --git a/drivers/clk/sifive/fu540-prci.c b/drivers/clk/sifive/fu540-prci.c
index 9a08c14..b3882d0 100644
--- a/drivers/clk/sifive/fu540-prci.c
+++ b/drivers/clk/sifive/fu540-prci.c
@@ -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);
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index 8a5f958..7e8f3af 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -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;
diff --git a/drivers/core/device.c b/drivers/core/device.c
index d1a08ce..aeab383 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -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;
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 522b07d..313ddc7 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -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;
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 2012547..f8afea3 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -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");
}
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index b23ee30..e214306 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -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)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index f2fba58..78de7cd 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -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
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index c45212a..b0c2c20 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -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,
};
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 6409457..cdb975d 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -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;
diff --git a/drivers/crypto/fsl/fsl_rsa.c b/drivers/crypto/fsl/fsl_rsa.c
index ed2a54f..897ee85 100644
--- a/drivers/crypto/fsl/fsl_rsa.c
+++ b/drivers/crypto/fsl/fsl_rsa.c
@@ -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",
};
diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c
index 4ce85b3..7bed444 100644
--- a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c
+++ b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c
@@ -35,6 +35,6 @@ U_BOOT_DRIVER(mod_exp_sw) = {
.flags = DM_FLAG_PRE_RELOC,
};
-U_BOOT_DEVICE(mod_exp_sw) = {
+U_BOOT_DRVINFO(mod_exp_sw) = {
.name = "mod_exp_sw",
};
diff --git a/drivers/ddr/altera/sdram_agilex.c b/drivers/ddr/altera/sdram_agilex.c
index 868bf14..a4ceb36 100644
--- a/drivers/ddr/altera/sdram_agilex.c
+++ b/drivers/ddr/altera/sdram_agilex.c
@@ -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;
diff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c
index 3ffe057..8d3ce49 100644
--- a/drivers/ddr/altera/sdram_gen5.c
+++ b/drivers/ddr/altera/sdram_gen5.c
@@ -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;
diff --git a/drivers/ddr/altera/sdram_s10.c b/drivers/ddr/altera/sdram_s10.c
index 984dc32..03a270f 100644
--- a/drivers/ddr/altera/sdram_s10.c
+++ b/drivers/ddr/altera/sdram_s10.c
@@ -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;
diff --git a/drivers/ddr/altera/sdram_soc64.c b/drivers/ddr/altera/sdram_soc64.c
index 7e77c7b..5aba655 100644
--- a/drivers/ddr/altera/sdram_soc64.c
+++ b/drivers/ddr/altera/sdram_soc64.c
@@ -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);
diff --git a/drivers/demo/demo-pdata.c b/drivers/demo/demo-pdata.c
index b504c31..818f775 100644
--- a/drivers/demo/demo-pdata.c
+++ b/drivers/demo/demo-pdata.c
@@ -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,
};
diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c
index b3d3f0a..516e690 100644
--- a/drivers/firmware/scmi/scmi_agent-uclass.c
+++ b/drivers/firmware/scmi/scmi_agent-uclass.c
@@ -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;
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index acd77b6..e6e9194 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -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 */
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 65b18ce..bad6b71 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -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;
}
diff --git a/drivers/gpio/hi6220_gpio.c b/drivers/gpio/hi6220_gpio.c
index f5e5fc6..04f8d90 100644
--- a/drivers/gpio/hi6220_gpio.c
+++ b/drivers/gpio/hi6220_gpio.c
@@ -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);
diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
index 17edd40..0e2874c 100644
--- a/drivers/gpio/imx_rgpio2p.c
+++ b/drivers/gpio/imx_rgpio2p.c
@@ -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] },
diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c
index 41540d8..eda9548 100644
--- a/drivers/gpio/intel_gpio.c
+++ b/drivers/gpio/intel_gpio.c
@@ -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,
diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c
index ffaec32..de66c76 100644
--- a/drivers/gpio/lpc32xx_gpio.c
+++ b/drivers/gpio/lpc32xx_gpio.c
@@ -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 */
diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c
index 2bc1a0d..a964347 100644
--- a/drivers/gpio/mpc8xxx_gpio.c
+++ b/drivers/gpio/mpc8xxx_gpio.c
@@ -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);
diff --git a/drivers/gpio/mt7621_gpio.c b/drivers/gpio/mt7621_gpio.c
index 65b4cbf..43bb4df 100644
--- a/drivers/gpio/mt7621_gpio.c
+++ b/drivers/gpio/mt7621_gpio.c
@@ -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;
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 9fc217a..06e6b22 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -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] },
diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index 5ad65e4..4b2b18f 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -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 */
diff --git a/drivers/gpio/octeon_gpio.c b/drivers/gpio/octeon_gpio.c
index 958516d..42eae79 100644
--- a/drivers/gpio/octeon_gpio.c
+++ b/drivers/gpio/octeon_gpio.c
@@ -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);
}
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 400c6ca..336ece4 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -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;
}
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 9de9541..796fe3e 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -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;
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 2708838..dc8d506 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -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) */
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 75494c7..7633422 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -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;
diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c
index cd1fb65..82dcaf9 100644
--- a/drivers/gpio/tegra186_gpio.c
+++ b/drivers/gpio/tegra186_gpio.c
@@ -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 */
diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
index c489796..5d3af8a 100644
--- a/drivers/gpio/tegra_gpio.c
+++ b/drivers/gpio/tegra_gpio.c
@@ -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;
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index 18eef62..ec0cdf6 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -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));
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 456cf3b..be56785 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -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
diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
index 704bafe..f8fac45 100644
--- a/drivers/i2c/rk_i2c.c
+++ b/drivers/i2c/rk_i2c.c
@@ -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)
diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c
index a61dfc0..c99e6de 100644
--- a/drivers/i2c/sandbox_i2c.c
+++ b/drivers/i2c/sandbox_i2c.c
@@ -10,15 +10,12 @@
#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)
{
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 29432ae..7d2a299 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -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
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 947bd3a..d737203 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -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
diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c
index 057b431..878df12 100644
--- a/drivers/misc/altera_sysid.c
+++ b/drivers/misc/altera_sysid.c
@@ -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;
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index b3bb537..9fd6cc2 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -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;
diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
index 5ed8ab6..f460b1a 100644
--- a/drivers/misc/fs_loader.c
+++ b/drivers/misc/fs_loader.c
@@ -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);
diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index 9ffd28f..5926c91 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -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);
}
diff --git a/drivers/misc/p2sb-uclass.c b/drivers/misc/p2sb-uclass.c
index 8f9ec02..ac28525 100644
--- a/drivers/misc/p2sb-uclass.c
+++ b/drivers/misc/p2sb-uclass.c
@@ -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;
diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index be25389..083ee65 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -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;
diff --git a/drivers/misc/spltest_sandbox.c b/drivers/misc/spltest_sandbox.c
index 3ae6707..6b9701a 100644
--- a/drivers/misc/spltest_sandbox.c
+++ b/drivers/misc/spltest_sandbox.c
@@ -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,
};
diff --git a/drivers/misc/stm32mp_fuse.c b/drivers/misc/stm32mp_fuse.c
index 0eed345..9fd6c36 100644
--- a/drivers/misc/stm32mp_fuse.c
+++ b/drivers/misc/stm32mp_fuse.c
@@ -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;
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
index abea0e7..3cbc8f3 100644
--- a/drivers/misc/swap_case.c
+++ b/drivers/misc/swap_case.c
@@ -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
index 0000000..7dd3de3
--- /dev/null
+++ b/drivers/misc/test_drv.c
@@ -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,
+};
diff --git a/drivers/misc/vexpress_config.c b/drivers/misc/vexpress_config.c
index 02e5b58..2baca48 100644
--- a/drivers/misc/vexpress_config.c
+++ b/drivers/misc/vexpress_config.c
@@ -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);
diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index fe406fe..b2d1b4f 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -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);
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 01a9442..f47a095 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -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
diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index 143818d..8fd4176 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -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 */
diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c
index 5552342..442ca49 100644
--- a/drivers/mmc/octeontx_hsmmc.c
+++ b/drivers/mmc/octeontx_hsmmc.c
@@ -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,
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
index fc09ad9..c71c495 100644
--- a/drivers/mmc/pci_mmc.c
+++ b/drivers/mmc/pci_mmc.c
@@ -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);
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 75db81b..1be3c17 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -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)
diff --git a/drivers/mtd/nand/raw/arasan_nfc.c b/drivers/mtd/nand/raw/arasan_nfc.c
index d4e8f8d..4621bfb 100644
--- a/drivers/mtd/nand/raw/arasan_nfc.c
+++ b/drivers/mtd/nand/raw/arasan_nfc.c
@@ -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);
}
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
index 71682cb..aa095c4 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c
index f424194..e4bf193 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c
index 47ddde4..586ea3d 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
index 6464950..85f318b 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
index 7573cd9..a5e159a 100644
--- a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
+++ b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
index 4645cc1..9ad3a57 100644
--- a/drivers/mtd/nand/raw/davinci_nand.c
+++ b/drivers/mtd/nand/raw/davinci_nand.c
@@ -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);
}
diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
index 140ef7f..cf4df01 100644
--- a/drivers/mtd/nand/raw/denali_dt.c
+++ b/drivers/mtd/nand/raw/denali_dt.c
@@ -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",
diff --git a/drivers/mtd/nand/raw/mxs_nand_dt.c b/drivers/mtd/nand/raw/mxs_nand_dt.c
index 78a423d..878796d 100644
--- a/drivers/mtd/nand/raw/mxs_nand_dt.c
+++ b/drivers/mtd/nand/raw/mxs_nand_dt.c
@@ -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",
diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
index b1ed4d9..9997135 100644
--- a/drivers/mtd/nand/raw/octeontx_nand.c
+++ b/drivers/mtd/nand/raw/octeontx_nand.c
@@ -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",
diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c b/drivers/mtd/nand/raw/pxa3xx_nand.c
index e923ce3..f623375 100644
--- a/drivers/mtd/nand/raw/pxa3xx_nand.c
+++ b/drivers/mtd/nand/raw/pxa3xx_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index 8fe7ec1..b8561b2 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -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",
diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c
index 797fc23..a530127 100644
--- a/drivers/mtd/nand/raw/tegra_nand.c
+++ b/drivers/mtd/nand/raw/tegra_nand.c
@@ -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);
diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index 422b9c5..e33953e 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -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",
diff --git a/drivers/mtd/nand/raw/zynq_nand.c b/drivers/mtd/nand/raw/zynq_nand.c
index 7cf0ccb..15d4a23 100644
--- a/drivers/mtd/nand/raw/zynq_nand.c
+++ b/drivers/mtd/nand/raw/zynq_nand.c
@@ -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);
}
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 09bfde6..68ef5d1 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -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);
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index ed629f1..3017022 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -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),
};
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index c8bcec3..6c87434 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -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 */
diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c
index b986850..00e0282 100644
--- a/drivers/mux/mmio.c
+++ b/drivers/mux/mmio.c
@@ -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);
diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c
index 65615f1..07aebd9 100644
--- a/drivers/net/eth-phy-uclass.c
+++ b/drivers/net/eth-phy-uclass.c
@@ -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
diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index 02ccf1e..0e89e66 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -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;
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index 2e684e5..f6fc780 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -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;
}
diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
index 4da97b6..3eb6ac9 100644
--- a/drivers/net/fsl_enetc_mdio.c
+++ b/drivers/net/fsl_enetc_mdio.c
@@ -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++);
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index 0196462..c36d40c 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -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;
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index 4fa7136..cb343b4 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -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;
diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c
index 3936055..ec81320 100644
--- a/drivers/net/mcfmii.c
+++ b/drivers/net/mcfmii.c
@@ -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;
diff --git a/drivers/net/mdio-ipq4019.c b/drivers/net/mdio-ipq4019.c
index 13a8856..50134b4 100644
--- a/drivers/net/mdio-ipq4019.c
+++ b/drivers/net/mdio-ipq4019.c
@@ -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;
}
diff --git a/drivers/net/mdio_mux_i2creg.c b/drivers/net/mdio_mux_i2creg.c
index f8557dd..3654230 100644
--- a/drivers/net/mdio_mux_i2creg.c
+++ b/drivers/net/mdio_mux_i2creg.c
@@ -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);
diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c
index 005f28f..96f8dc6 100644
--- a/drivers/net/mvmdio.c
+++ b/drivers/net/mvmdio.c
@@ -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;
}
diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c
index d1582b9..5843641 100644
--- a/drivers/net/octeontx/smi.c
+++ b/drivers/net/octeontx/smi.c
@@ -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);
diff --git a/drivers/net/pfe_eth/pfe_eth.c b/drivers/net/pfe_eth/pfe_eth.c
index 3d14571..0c27a66 100644
--- a/drivers/net/pfe_eth/pfe_eth.c
+++ b/drivers/net/pfe_eth/pfe_eth.c
@@ -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;
diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index 7c6ae3c..17ad88e 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -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)
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 2271eb8..ec48689 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -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);
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 5c76887..6b44753 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -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;
diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c
index 756d8ad..a0b8afb 100644
--- a/drivers/pci/pci-emul-uclass.c
+++ b/drivers/pci/pci-emul-uclass.c
@@ -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);
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 914217d..4cdd06b 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -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);
}
diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c
index 8e35ea1..82010e7 100644
--- a/drivers/phy/phy-ti-am654.c
+++ b/drivers/phy/phy-ti-am654.c
@@ -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__);
diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c
index 9f96505..987a56b 100644
--- a/drivers/pinctrl/intel/pinctrl.c
+++ b/drivers/pinctrl/intel/pinctrl.c
@@ -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;
diff --git a/drivers/pinctrl/intel/pinctrl_apl.c b/drivers/pinctrl/intel/pinctrl_apl.c
index 48b0e9a..acaa55d 100644
--- a/drivers/pinctrl/intel/pinctrl_apl.c
+++ b/drivers/pinctrl/intel/pinctrl_apl.c
@@ -17,18 +17,6 @@
#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(sjg@chromium.org): 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)
diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c
index 3cb0bf3..6994dbb 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx6.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx6.c
@@ -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)
diff --git a/drivers/pinctrl/nxp/pinctrl-mxs.c b/drivers/pinctrl/nxp/pinctrl-mxs.c
index 5ada2ac..449a0aa 100644
--- a/drivers/pinctrl/nxp/pinctrl-mxs.c
+++ b/drivers/pinctrl/nxp/pinctrl-mxs.c
@@ -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)
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 74bfd3c..ddaad55 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -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)
diff --git a/drivers/pinctrl/pinctrl-qe-io.c b/drivers/pinctrl/pinctrl-qe-io.c
index 690e5c7..e129ab2 100644
--- a/drivers/pinctrl/pinctrl-qe-io.c
+++ b/drivers/pinctrl/pinctrl-qe-io.c
@@ -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;
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 25d646a..20c3c82 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -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);
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index aba8810..7919e54 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -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",
};
diff --git a/drivers/power/acpi_pmc/acpi-pmc-uclass.c b/drivers/power/acpi_pmc/acpi-pmc-uclass.c
index 32a2836..34446a3 100644
--- a/drivers/power/acpi_pmc/acpi-pmc-uclass.c
+++ b/drivers/power/acpi_pmc/acpi-pmc-uclass.c
@@ -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);
diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c
index 2e7ab67..ef8274c 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -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;
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c
index 40947c6..eb94af2 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -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;
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 2f547a3..5f442fe 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -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)
diff --git a/drivers/power/regulator/da9063.c b/drivers/power/regulator/da9063.c
index 32be59e..8df1abc 100644
--- a/drivers/power/regulator/da9063.c
+++ b/drivers/power/regulator/da9063.c
@@ -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 */
diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c
index c3df156..5bf186e 100644
--- a/drivers/power/regulator/pbias_regulator.c
+++ b/drivers/power/regulator/pbias_regulator.c
@@ -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;
}
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 58b7469..03eeacc 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -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;
diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c
index ccc910e..c2d6a4e 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -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;
diff --git a/drivers/remoteproc/sandbox_testproc.c b/drivers/remoteproc/sandbox_testproc.c
index ee2ee73..6836eca 100644
--- a/drivers/remoteproc/sandbox_testproc.c
+++ b/drivers/remoteproc/sandbox_testproc.c
@@ -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,
};
diff --git a/drivers/reset/reset-ast2500.c b/drivers/reset/reset-ast2500.c
index a229d49..c3d650f 100644
--- a/drivers/reset/reset-ast2500.c
+++ b/drivers/reset/reset-ast2500.c
@@ -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;
diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c
index b97a21f..7427013 100644
--- a/drivers/reset/reset-mediatek.c
+++ b/drivers/reset/reset-mediatek.c
@@ -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;
}
diff --git a/drivers/reset/reset-rockchip.c b/drivers/reset/reset-rockchip.c
index e5e9918..eeb3d2e 100644
--- a/drivers/reset/reset-rockchip.c
+++ b/drivers/reset/reset-rockchip.c
@@ -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;
}
diff --git a/drivers/reset/reset-sifive.c b/drivers/reset/reset-sifive.c
index f6110d8..eec840d 100644
--- a/drivers/reset/reset-sifive.c
+++ b/drivers/reset/reset-sifive.c
@@ -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;
}
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index c64c9b5..98450db 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -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);
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index 1db321c..264337e 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -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;
}
diff --git a/drivers/rtc/emul_rtc.c b/drivers/rtc/emul_rtc.c
index 1dc80ca..8f0e1ab 100644
--- a/drivers/rtc/emul_rtc.c
+++ b/drivers/rtc/emul_rtc.c
@@ -91,6 +91,6 @@ U_BOOT_DRIVER(rtc_emul) = {
.priv_auto = sizeof(struct emul_rtc),
};
-U_BOOT_DEVICE(rtc_emul) = {
+U_BOOT_DRVINFO(rtc_emul) = {
.name = "rtc_emul",
};
diff --git a/drivers/serial/altera_jtag_uart.c b/drivers/serial/altera_jtag_uart.c
index 0d3ccd8..4435fcf 100644
--- a/drivers/serial/altera_jtag_uart.c
+++ b/drivers/serial/altera_jtag_uart.c
@@ -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 */
diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index a3efa1e..b18be6e 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
@@ -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))
diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index 7eabf76..7edec23 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -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)
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 8dd81ad..65c6db0 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -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 */
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index c7d5390..756738c 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -17,25 +17,11 @@
#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,
};
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index b645724..58a6541 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -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;
}
diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c
index 022e377..445eacc 100644
--- a/drivers/serial/serial_arc.c
+++ b/drivers/serial/serial_arc.c
@@ -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))
diff --git a/drivers/serial/serial_coreboot.c b/drivers/serial/serial_coreboot.c
index 904e1b3..88c8209 100644
--- a/drivers/serial/serial_coreboot.c
+++ b/drivers/serial/serial_coreboot.c
@@ -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,
diff --git a/drivers/serial/serial_intel_mid.c b/drivers/serial/serial_intel_mid.c
index be9bf66..bbf1905 100644
--- a/drivers/serial/serial_intel_mid.c
+++ b/drivers/serial/serial_intel_mid.c
@@ -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,
};
diff --git a/drivers/serial/serial_linflexuart.c b/drivers/serial/serial_linflexuart.c
index ced0057..c3714e1 100644
--- a/drivers/serial/serial_linflexuart.c
+++ b/drivers/serial/serial_linflexuart.c
@@ -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;
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index 5beb5f2..a35e5be 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -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;
diff --git a/drivers/serial/serial_mcf.c b/drivers/serial/serial_mcf.c
index 4ba6dc3..e6e21b2 100644
--- a/drivers/serial/serial_mcf.c
+++ b/drivers/serial/serial_mcf.c
@@ -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)
diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
index 40d9bfe..d69ec22 100644
--- a/drivers/serial/serial_meson.c
+++ b/drivers/serial/serial_meson.c
@@ -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);
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 2603fa8..e5795da 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -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);
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index ef394b7..b5beca9 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -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
diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c
index 2f38e1b..2b23ece 100644
--- a/drivers/serial/serial_omap.c
+++ b/drivers/serial/serial_omap.c
@@ -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)
diff --git a/drivers/serial/serial_pxa.c b/drivers/serial/serial_pxa.c
index d82f3b9..669841e 100644
--- a/drivers/serial/serial_pxa.c
+++ b/drivers/serial/serial_pxa.c
@@ -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)
diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c
index 4c0548e..97d4086 100644
--- a/drivers/serial/serial_rockchip.c
+++ b/drivers/serial/serial_rockchip.c
@@ -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,
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 120df83..0eac0d5 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -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);
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index b746501..6798043 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -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);
diff --git a/drivers/spi/cf_spi.c b/drivers/spi/cf_spi.c
index 8adff63..298f350 100644
--- a/drivers/spi/cf_spi.c
+++ b/drivers/spi/cf_spi.c
@@ -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;
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index ea088eb..53a791e 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -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);
diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index 88e638c..7421211 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -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;
diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
index e4d2bad..30b1a77 100644
--- a/drivers/spi/exynos_spi.c
+++ b/drivers/spi/exynos_spi.c
@@ -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;
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
index ddf4a9e..c17a552 100644
--- a/drivers/spi/fsl_dspi.c
+++ b/drivers/spi/fsl_dspi.c
@@ -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);
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c
index e9e7ffd..abc28e3 100644
--- a/drivers/spi/fsl_espi.c
+++ b/drivers/spi/fsl_espi.c
@@ -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);
diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index fc3b844..8bc7038 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -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);
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index e02850e..1cd4104 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -38,17 +38,6 @@
#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);
diff --git a/drivers/spi/ich.h b/drivers/spi/ich.h
index 23c7827..8fd150d 100644
--- a/drivers/spi/ich.h
+++ b/drivers/spi/ich.h
@@ -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_ */
diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
index 4fafe33..d41352a 100644
--- a/drivers/spi/mxs_spi.c
+++ b/drivers/spi/mxs_spi.c
@@ -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)
diff --git a/drivers/spi/pl022_spi.c b/drivers/spi/pl022_spi.c
index 179582c..133363e 100644
--- a/drivers/spi/pl022_spi.c
+++ b/drivers/spi/pl022_spi.c
@@ -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;
diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index 44ac475..40bd885 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -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)
diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index afc98bf..3425d99 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -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;
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 5d801fa..3fe351f 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -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);
diff --git a/drivers/spi/tegra114_spi.c b/drivers/spi/tegra114_spi.c
index e1fd82b..f0256d8 100644
--- a/drivers/spi/tegra114_spi.c
+++ b/drivers/spi/tegra114_spi.c
@@ -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)
diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c
index d386061..4384a48 100644
--- a/drivers/spi/tegra20_sflash.c
+++ b/drivers/spi/tegra20_sflash.c
@@ -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)
diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c
index b99ef38..3057fe1 100644
--- a/drivers/spi/tegra20_slink.c
+++ b/drivers/spi/tegra20_slink.c
@@ -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)
diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c
index a2a7f46..b464b9c 100644
--- a/drivers/spi/tegra210_qspi.c
+++ b/drivers/spi/tegra210_qspi.c
@@ -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)
diff --git a/drivers/spi/uniphier_spi.c b/drivers/spi/uniphier_spi.c
index 48b8430..e47ed5b 100644
--- a/drivers/spi/uniphier_spi.c
+++ b/drivers/spi/uniphier_spi.c
@@ -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);
diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c
index 2fc28b6..845f2d2 100644
--- a/drivers/spi/zynq_qspi.c
+++ b/drivers/spi/zynq_qspi.c
@@ -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;
diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c
index a6efa4a..2971e55 100644
--- a/drivers/spi/zynq_spi.c
+++ b/drivers/spi/zynq_spi.c
@@ -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;
diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c
index f09c507..c9e476e 100644
--- a/drivers/spi/zynqmp_gqspi.c
+++ b/drivers/spi/zynqmp_gqspi.c
@@ -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;
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 3f5414e..e69fb22 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -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();
}
diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c
index 7026a48..0868582 100644
--- a/drivers/sysreset/sysreset_sandbox.c
+++ b/drivers/sysreset/sysreset_sandbox.c
@@ -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
diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c
index 8f99703..8042f39 100644
--- a/drivers/sysreset/sysreset_x86.c
+++ b/drivers/sysreset/sysreset_x86.c
@@ -13,10 +13,7 @@
#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
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 7c38d6e..b898c32 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -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);
diff --git a/drivers/timer/ag101p_timer.c b/drivers/timer/ag101p_timer.c
index 1717434..27cf9b0 100644
--- a/drivers/timer/ag101p_timer.c
+++ b/drivers/timer/ag101p_timer.c
@@ -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);
diff --git a/drivers/timer/altera_timer.c b/drivers/timer/altera_timer.c
index 7e9abee..040dc65 100644
--- a/drivers/timer/altera_timer.c
+++ b/drivers/timer/altera_timer.c
@@ -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);
diff --git a/drivers/timer/andes_plmt_timer.c b/drivers/timer/andes_plmt_timer.c
index cec8671..db2cf86 100644
--- a/drivers/timer/andes_plmt_timer.c
+++ b/drivers/timer/andes_plmt_timer.c
@@ -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);
diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
index 9b1daaa..2f2b8be 100644
--- a/drivers/timer/mpc83xx_timer.c
+++ b/drivers/timer/mpc83xx_timer.c
@@ -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;
diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c
index 135c0f3..2075cd4 100644
--- a/drivers/timer/sandbox_timer.c
+++ b/drivers/timer/sandbox_timer.c
@@ -65,6 +65,6 @@ U_BOOT_DRIVER(sandbox_timer) = {
};
/* This is here in case we don't have a device tree */
-U_BOOT_DEVICE(sandbox_timer_non_fdt) = {
+U_BOOT_DRVINFO(sandbox_timer_non_fdt) = {
.name = "sandbox_timer",
};
diff --git a/drivers/timer/sifive_clint_timer.c b/drivers/timer/sifive_clint_timer.c
index 00ce0f0..de23b85 100644
--- a/drivers/timer/sifive_clint_timer.c
+++ b/drivers/timer/sifive_clint_timer.c
@@ -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);
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index ab53555..da1a72f 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -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);
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index e367770..706d52b 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -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,
};
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index e861c82..798a217 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -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;
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 2e00353..dfd7cf6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -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");
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index ba9f9a4..30f835e 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -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);
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 36955b5..bd8bf22 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -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)
diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c
index b63cc23..08467d6 100644
--- a/drivers/usb/dwc3/dwc3-meson-gxl.c
+++ b/drivers/usb/dwc3/dwc3-meson-gxl.c
@@ -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;
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 4771b1e..e3871e3 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -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;
}
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 7830a4a..16922ff 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -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) {
diff --git a/drivers/usb/host/dwc3-octeon-glue.c b/drivers/usb/host/dwc3-octeon-glue.c
index c3cac9c..742e156 100644
--- a/drivers/usb/host/dwc3-octeon-glue.c
+++ b/drivers/usb/host/dwc3-octeon-glue.c
@@ -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;
}
diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index 80e5434..1234399 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -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;
}
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index d2f49cf..ef3a63a 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -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:
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index a2bd743..e3b616c 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -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 */
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index 59408e4..3e0ae80 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -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;
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 28136f8..2f5cc9b 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -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);
diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index c951107..b097471 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -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;
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 81b12fa..75cf181 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -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;
diff --git a/drivers/video/lg4573.c b/drivers/video/lg4573.c
index abf40bd..dd87fc4 100644
--- a/drivers/video/lg4573.c
+++ b/drivers/video/lg4573.c
@@ -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;
diff --git a/drivers/video/nexell_display.c b/drivers/video/nexell_display.c
index 00e2c36..b47bef3 100644
--- a/drivers/video/nexell_display.c
+++ b/drivers/video/nexell_display.c
@@ -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);
diff --git a/drivers/video/rockchip/rk_mipi.c b/drivers/video/rockchip/rk_mipi.c
index d125a5b..159201a 100644
--- a/drivers/video/rockchip/rk_mipi.c
+++ b/drivers/video/rockchip/rk_mipi.c
@@ -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);
diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c
index 50657a7..a3e21aa 100644
--- a/drivers/video/sunxi/sunxi_de2.c
+++ b/drivers/video/sunxi/sunxi_de2.c
@@ -319,7 +319,7 @@ U_BOOT_DRIVER(sunxi_de2) = {
.flags = DM_FLAG_PRE_RELOC,
};
-U_BOOT_DEVICE(sunxi_de2) = {
+U_BOOT_DRVINFO(sunxi_de2) = {
.name = "sunxi_de2"
};
diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c
index 3e8d715..0b8cefc 100644
--- a/drivers/video/sunxi/sunxi_dw_hdmi.c
+++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
@@ -398,6 +398,6 @@ U_BOOT_DRIVER(sunxi_dw_hdmi) = {
.priv_auto = sizeof(struct sunxi_dw_hdmi_priv),
};
-U_BOOT_DEVICE(sunxi_dw_hdmi) = {
+U_BOOT_DRVINFO(sunxi_dw_hdmi) = {
.name = "sunxi_dw_hdmi"
};
diff --git a/drivers/video/sunxi/sunxi_lcd.c b/drivers/video/sunxi/sunxi_lcd.c
index dd2bb1f..635edf6 100644
--- a/drivers/video/sunxi/sunxi_lcd.c
+++ b/drivers/video/sunxi/sunxi_lcd.c
@@ -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
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 20f6973..8883e29 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -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;
diff --git a/dts/Kconfig b/dts/Kconfig
index aeda542..71f5055 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -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
diff --git a/dts/Makefile b/dts/Makefile
index a20930e..94967cf 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -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
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 887b5c2..31e2491 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -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;
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index af3b6b2..639bbd2 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -190,6 +190,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
*
* This handles the 'ranges' property in a simple bus. It translates the
@@ -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
diff --git a/include/dm/device.h b/include/dm/device.h
index 30fc98d..f5b4cd6 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -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
diff --git a/include/dm/lists.h b/include/dm/lists.h
index 070bc9c..1a86552 100644
--- a/include/dm/lists.h
+++ b/include/dm/lists.h
@@ -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)
diff --git a/include/dm/platdata.h b/include/dm/platdata.h
index d650fb3..3821a56 100644
--- a/include/dm/platdata.h
+++ b/include/dm/platdata.h
@@ -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(sjg@chromium.org): 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
diff --git a/include/dm/platform_data/spi_pl022.h b/include/dm/platform_data/spi_pl022.h
index c5aa321..7f74b3c 100644
--- a/include/dm/platform_data/spi_pl022.h
+++ b/include/dm/platform_data/spi_pl022.h
@@ -3,7 +3,7 @@
* (C) Copyright 2018
* Quentin Schulz, Bootlin, quentin.schulz@bootlin.com
*
- * Structure for use with U_BOOT_DEVICE for pl022 SPI devices or to use
+ * Structure for use with U_BOOT_DRVINFO for pl022 SPI devices or to use
* in of_to_plat.
*/
diff --git a/include/dm/read.h b/include/dm/read.h
index 0585eb1..fc987f7 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -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
index 0000000..4ad4cc4
--- /dev/null
+++ b/include/dm/simple_bus.h
@@ -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
diff --git a/include/dm/test.h b/include/dm/test.h
index b2adce7..6ac6672 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -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);
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index 3e052f9..c5a464b 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -12,6 +12,20 @@
#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
*
* This returns the next free sequence number. This is useful only if
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 91edbfb..b5f066d 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -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.
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 1b91517..9278549 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -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;
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 13e8dd1..7774c17 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -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
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 233fdc3..4a8e19e 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -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
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 88bacde..15bcd59 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -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,
diff --git a/include/ns16550.h b/include/ns16550.h
index bef2961..bef2071 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -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 */
diff --git a/include/spl.h b/include/spl.h
index 374a295..a764878 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -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
diff --git a/include/test/test.h b/include/test/test.h
index 03e2929..3fdaa2b 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -95,6 +95,15 @@ enum {
};
/**
+ * 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
*
* Run all the available driver model tests, or a selection
diff --git a/include/virtio.h b/include/virtio.h
index 10a9c07..a42bdad 100644
--- a/include/virtio.h
+++ b/include/virtio.h
@@ -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);
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index 7d650d5..b3393e4 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -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)
;
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 99b5078..c9315dd 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -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;
diff --git a/lib/time.c b/lib/time.c
index 88bc504..cc6944e 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -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;
}
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index e2d6731..0156324 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -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);
diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
index 5f38f9f..780526c 100644
--- a/net/mdio-mux-uclass.c
+++ b/net/mdio-mux-uclass.c
@@ -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;
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index d062382..697e5f8 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -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;
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 9f1f744..87021e2 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -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.
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 60ddb1d..e768eab 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -19,103 +19,6 @@
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;
}
diff --git a/test/dm/core.c b/test/dm/core.c
index a7c0f40..1f5ca57 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -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);
}
}
diff --git a/test/dm/cpu.c b/test/dm/cpu.c
index 28869c1..ed12caf 100644
--- a/test/dm/cpu.c
+++ b/test/dm/cpu.c
@@ -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);
diff --git a/test/dm/pci.c b/test/dm/pci.c
index 76490be..fa2e4a8 100644
--- a/test/dm/pci.c
+++ b/test/dm/pci.c
@@ -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;
}
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index b9f49de..a67f5d3 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -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;
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index eb3c2cf..b535390 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -23,126 +23,6 @@
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;
}
diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c
index 3ab4a23..f1b7aaa 100644
--- a/test/dm/test-uclass.c
+++ b/test/dm/test-uclass.c
@@ -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;
}
diff --git a/test/dm/virtio.c b/test/dm/virtio.c
index 2e876c3..ad35598 100644
--- a/test/dm/virtio.c
+++ b/test/dm/virtio.c
@@ -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;
diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py
index 78837a3..d55338e 100644
--- a/test/py/tests/test_ofplatdata.py
+++ b/test/py/tests/test_ofplatdata.py
@@ -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
diff --git a/tools/concurrencytest/concurrencytest.py b/tools/concurrencytest/concurrencytest.py
index 418d7ee..5e88b94 100644
--- a/tools/concurrencytest/concurrencytest.py
+++ b/tools/concurrencytest/concurrencytest.py
@@ -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
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 8267113..b7abaed 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -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()
diff --git a/tools/dtoc/dtoc_test_scan_drivers.cxx b/tools/dtoc/dtoc_test_scan_drivers.cxx
index 557c692..f448767 100644
--- a/tools/dtoc/dtoc_test_scan_drivers.cxx
+++ b/tools/dtoc/dtoc_test_scan_drivers.cxx
@@ -1 +1 @@
-U_BOOT_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)
+DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2)
diff --git a/tools/dtoc/dtoc_test_simple.dts b/tools/dtoc/dtoc_test_simple.dts
index fd168cb..1c87b89 100644
--- a/tools/dtoc/dtoc_test_simple.dts
+++ b/tools/dtoc/dtoc_test_simple.dts
@@ -44,11 +44,6 @@
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;
diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index b94d9c3..b0ad0f3 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -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
index 0000000..f63c9fc
--- /dev/null
+++ b/tools/dtoc/src_scan.py
@@ -0,0 +1,185 @@
+#!/usr/bin/python
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2017 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+
+"""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)
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 4913d95..d961d67 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -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
index 0000000..7d68653
--- /dev/null
+++ b/tools/dtoc/test_src_scan.py
@@ -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)
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index fca3d9e..d8e01a3 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -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