All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree
@ 2017-05-01 15:18 Simon Glass
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used Simon Glass
                   ` (8 more replies)
  0 siblings, 9 replies; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot


The original livetree series [1] proved out the concept of a live device
tree in U-Boot. This involved converting the existing flat tree into a
node-based data structure immediately after relocation, and adjusting
some existing drivers to continue to work.

Several points came out of that work:

1. We need to avoid increasing code size for boards which continue to use
the flat device tree

2. Code-size increase for the live tree should be minimal, ideally only a
small one-off cost rather than a per-driver increment

3. Drivers should be written to support either type of tree, and both

4. We need a new API to read from the device tree from drivers (ie. using
dev_read...(struct udevice *) instead of fdtdec_get_...(blob, offset, ...)
so that they don't need to worry about which type of tree is used.

This series defines a new means of referring to a device tree node, and
updates U-Boot to use it. It does not include any support for live tree.

Following on from this will come conversion of sandbox to support live
tree, including getting all tests to pass

After that will be conversion of a representative board to support live
tree, as a way of evaluating code-size impact.

Ideally I would like to get all of the above sent out for review and
applied for the next release, but this depends on timing and feedback.

Finally, some documentation will be added and all existing drivers
converted to the new dev_read...() API, assuming this is practical.

[1] http://u-boot.10912.n7.nabble.com/PATCH-00-22-dm-Add-support-for-a-live-device-tree-td279035.html

Changes in v2:
- Cut the series down to only prepare the way for live tree
- Drop all live tree changes
- Adjust storage to avoid a code size increase

Simon Glass (9):
  dm: Use dm.h header when driver mode is used
  dm: core: Move dev_get_addr() etc. into a separate file
  dm: Rename dev_addr..() functions
  atmel: Fix up use of  dm_scan_fdt_node()
  Fix up inclusion of common.h
  dm: core: Dont export dm_scan_fdt_node()
  dm: core: Replace of_offset with accessor (part 2)
  dm: core: Add ofnode to represent device tree nodes
  dm: core: Adjust device_bind_common() to take an ofnode

 arch/arm/lib/bootm.c                               |   2 +-
 arch/arm/mach-mvebu/sata.c                         |   2 +-
 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c       |   2 +-
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c         |   2 +-
 arch/arm/mach-rockchip/rk3399/sdram_rk3399.c       |   2 +-
 arch/arm/mach-snapdragon/clock-apq8016.c           |   2 +-
 arch/arm/mach-uniphier/pinctrl-glue.c              |   4 +-
 arch/sandbox/cpu/cpu.c                             |   1 +
 board/amlogic/odroid-c2/odroid-c2.c                |   2 +-
 board/armltd/integrator/integrator.c               |   2 +-
 board/armltd/vexpress64/vexpress64.c               |   2 +-
 board/beckhoff/mx53cx9020/mx53cx9020.c             |   2 +-
 board/cadence/xtfpga/xtfpga.c                      |   2 +-
 board/cavium/thunderx/thunderx.c                   |   2 +-
 board/freescale/common/fsl_chain_of_trust.c        |   1 +
 board/freescale/common/fsl_validate.c              |   2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c |   2 +-
 board/st/stm32f746-disco/stm32f746-disco.c         |   2 +-
 board/st/stv0991/stv0991.c                         |   2 +-
 board/toradex/apalis_imx6/apalis_imx6.c            |   1 +
 board/toradex/colibri_imx6/colibri_imx6.c          |   1 +
 board/toradex/colibri_pxa270/colibri_pxa270.c      |   1 +
 cmd/bootefi.c                                      |   2 +-
 common/env_sf.c                                    |   1 +
 configs/mx7ulp_evk_defconfig                       |   1 +
 drivers/adc/exynos-adc.c                           |   2 +-
 drivers/block/dwc_ahci.c                           |  10 +-
 drivers/block/sata_ceva.c                          |   2 +-
 drivers/clk/aspeed/clk_ast2500.c                   |   2 +-
 drivers/clk/at91/clk-generated.c                   |   2 +-
 drivers/clk/at91/clk-h32mx.c                       |   2 +-
 drivers/clk/at91/clk-main.c                        |   2 +-
 drivers/clk/at91/clk-master.c                      |   2 +-
 drivers/clk/at91/clk-peripheral.c                  |   2 +-
 drivers/clk/at91/clk-plla.c                        |   2 +-
 drivers/clk/at91/clk-slow.c                        |   2 +-
 drivers/clk/at91/clk-system.c                      |   2 +-
 drivers/clk/at91/clk-utmi.c                        |   2 +-
 drivers/clk/at91/pmc.c                             |   7 +-
 drivers/clk/at91/sckc.c                            |   3 +-
 drivers/clk/clk_fixed_rate.c                       |   2 +-
 drivers/clk/clk_zynq.c                             |   2 +-
 drivers/clk/clk_zynqmp.c                           |   2 +-
 drivers/clk/exynos/clk-exynos7420.c                |   4 +-
 drivers/clk/rockchip/clk_rk3036.c                  |   2 +-
 drivers/clk/rockchip/clk_rk3188.c                  |   2 +-
 drivers/clk/rockchip/clk_rk3288.c                  |   2 +-
 drivers/clk/rockchip/clk_rk3328.c                  |   2 +-
 drivers/clk/rockchip/clk_rk3399.c                  |   4 +-
 drivers/clk/uniphier/clk-uniphier-core.c           |   4 +-
 drivers/core/Makefile                              |   2 +-
 drivers/core/device.c                              | 143 ++-------------------
 drivers/core/fdtaddr.c                             | 143 +++++++++++++++++++++
 drivers/core/regmap.c                              |   5 +-
 drivers/core/root.c                                |  19 ++-
 drivers/dma/ti-edma3.c                             |   4 +-
 drivers/firmware/firmware-uclass.c                 |   3 +-
 drivers/firmware/psci.c                            |   6 +-
 drivers/gpio/altera_pio.c                          |   2 +-
 drivers/gpio/at91_gpio.c                           |   2 +-
 drivers/gpio/atmel_pio4.c                          |   5 +-
 drivers/gpio/bcm2835_gpio.c                        |   2 +-
 drivers/gpio/gpio-uniphier.c                       |   4 +-
 drivers/gpio/imx_rgpio2p.c                         |   2 +-
 drivers/gpio/lpc32xx_gpio.c                        |   1 +
 drivers/gpio/msm_gpio.c                            |   2 +-
 drivers/gpio/mvebu_gpio.c                          |   2 +-
 drivers/gpio/mxc_gpio.c                            |   2 +-
 drivers/gpio/omap_gpio.c                           |   2 +-
 drivers/gpio/pm8916_gpio.c                         |   4 +-
 drivers/gpio/rk_gpio.c                             |   2 +-
 drivers/gpio/s5p_gpio.c                            |   4 +-
 drivers/gpio/sunxi_gpio.c                          |   2 +-
 drivers/gpio/tegra186_gpio.c                       |   2 +-
 drivers/gpio/tegra_gpio.c                          |   2 +-
 drivers/gpio/vybrid_gpio.c                         |   2 +-
 drivers/gpio/zynq_gpio.c                           |   2 +-
 drivers/i2c/Kconfig                                |   1 -
 drivers/i2c/at91_i2c.c                             |   2 +-
 drivers/i2c/designware_i2c.c                       |   2 +-
 drivers/i2c/exynos_hs_i2c.c                        |   2 +-
 drivers/i2c/i2c-cdns.c                             |   4 +-
 drivers/i2c/i2c-uniphier-f.c                       |   4 +-
 drivers/i2c/i2c-uniphier.c                         |   4 +-
 drivers/i2c/imx_lpi2c.c                            |  80 ++++++------
 drivers/i2c/mv_i2c.c                               |   2 +-
 drivers/i2c/mvtwsi.c                               |   2 +-
 drivers/i2c/mxc_i2c.c                              |   2 +-
 drivers/i2c/omap24xx_i2c.c                         |   2 +-
 drivers/i2c/rk_i2c.c                               |   2 +-
 drivers/i2c/s3c24x0_i2c.c                          |   2 +-
 drivers/i2c/tegra_i2c.c                            |   2 +-
 drivers/input/tegra-kbc.c                          |   2 +-
 drivers/mailbox/tegra-hsp.c                        |   2 +-
 drivers/misc/altera_sysid.c                        |   2 +-
 drivers/mmc/atmel_sdhci.c                          |   2 +-
 drivers/mmc/fsl_esdhc.c                            |   2 +-
 drivers/mmc/gen_atmel_mci.c                        |   4 +-
 drivers/mmc/meson_gx_mmc.c                         |   4 +-
 drivers/mmc/mmc-uclass.c                           |   2 +-
 drivers/mmc/msm_sdhci.c                            |   2 +-
 drivers/mmc/omap_hsmmc.c                           |   4 +-
 drivers/mmc/pic32_sdhci.c                          |   2 +-
 drivers/mmc/rockchip_dw_mmc.c                      |   2 +-
 drivers/mmc/rockchip_sdhci.c                       |   2 +-
 drivers/mmc/sdhci-cadence.c                        |   4 +-
 drivers/mmc/socfpga_dw_mmc.c                       |   2 +-
 drivers/mmc/sti_sdhci.c                            |   2 +-
 drivers/mmc/tangier_sdhci.c                        |   2 +-
 drivers/mmc/tegra_mmc.c                            |   4 +-
 drivers/mmc/uniphier-sd.c                          |   4 +-
 drivers/mmc/xenon_sdhci.c                          |   4 +-
 drivers/mmc/zynq_sdhci.c                           |   4 +-
 drivers/net/ag7xxx.c                               |   2 +-
 drivers/net/cpsw.c                                 |   2 +-
 drivers/net/designware.c                           |   2 +-
 drivers/net/dwc_eth_qos.c                          |   4 +-
 drivers/net/ethoc.c                                |   6 +-
 drivers/net/fec_mxc.c                              |   2 +-
 drivers/net/keystone_net.c                         |   2 +-
 drivers/net/macb.c                                 |   2 +-
 drivers/net/mvneta.c                               |   2 +-
 drivers/net/mvpp2.c                                |   8 +-
 drivers/net/phy/phy.c                              |   2 +-
 drivers/net/phy/ti.c                               |   2 +-
 drivers/net/sandbox-raw.c                          |   2 +-
 drivers/net/sandbox.c                              |   2 +-
 drivers/net/sun8i_emac.c                           |   8 +-
 drivers/net/sunxi_emac.c                           |   2 +-
 drivers/net/tsec.c                                 |   2 +-
 drivers/net/xilinx_axi_emac.c                      |   2 +-
 drivers/net/xilinx_emaclite.c                      |   2 +-
 drivers/net/zynq_gem.c                             |   2 +-
 drivers/pci/pcie_dw_mvebu.c                        |   4 +-
 drivers/phy/marvell/comphy_core.c                  |   4 +-
 drivers/phy/ti-pipe3-phy.c                         |   4 +-
 drivers/pinctrl/ath79/pinctrl_ar933x.c             |   2 +-
 drivers/pinctrl/ath79/pinctrl_qca953x.c            |   2 +-
 drivers/pinctrl/exynos/pinctrl-exynos.c            |   2 +-
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c         |   3 +-
 drivers/pinctrl/meson/pinctrl-meson.c              |   2 +-
 drivers/pinctrl/mvebu/pinctrl-mvebu.c              |   2 +-
 drivers/pinctrl/nxp/pinctrl-imx.c                  |   2 +-
 drivers/pinctrl/nxp/pinctrl-imx5.c                 |   3 +-
 drivers/pinctrl/nxp/pinctrl-imx6.c                 |   3 +-
 drivers/pinctrl/nxp/pinctrl-imx7.c                 |   3 +-
 drivers/pinctrl/nxp/pinctrl-imx7ulp.c              |   3 +-
 drivers/pinctrl/pinctrl-at91-pio4.c                |   4 +-
 drivers/pinctrl/pinctrl-at91.c                     |   6 +-
 drivers/pinctrl/pinctrl-generic.c                  |   2 +-
 drivers/pinctrl/pinctrl-sandbox.c                  |   2 +-
 drivers/pinctrl/pinctrl-single.c                   |  13 +-
 drivers/pinctrl/pinctrl-uclass.c                   |   3 +-
 drivers/pinctrl/pinctrl_stm32.c                    |   2 +-
 drivers/pinctrl/rockchip/pinctrl_rk3188.c          |   4 +-
 drivers/pinctrl/rockchip/pinctrl_rk3328.c          |   2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-core.c   |   4 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c    |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c   |   3 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c   |   3 +-
 drivers/power/pmic/pm8916.c                        |   2 +-
 drivers/pwm/exynos_pwm.c                           |   2 +-
 drivers/pwm/rk_pwm.c                               |   2 +-
 drivers/pwm/tegra_pwm.c                            |   2 +-
 drivers/reset/reset-uniphier.c                     |   4 +-
 drivers/serial/altera_jtag_uart.c                  |   2 +-
 drivers/serial/altera_uart.c                       |   2 +-
 drivers/serial/atmel_usart.c                       |   2 +-
 drivers/serial/ns16550.c                           |   2 +-
 drivers/serial/serial_ar933x.c                     |   2 +-
 drivers/serial/serial_arc.c                        |   2 +-
 drivers/serial/serial_bcm283x_mu.c                 |   2 +-
 drivers/serial/serial_lpuart.c                     |   4 +-
 drivers/serial/serial_meson.c                      |   2 +-
 drivers/serial/serial_msm.c                        |   2 +-
 drivers/serial/serial_mvebu_a3700.c                |   2 +-
 drivers/serial/serial_mxc.c                        |   2 +-
 drivers/serial/serial_pl01x.c                      |   2 +-
 drivers/serial/serial_s5p.c                        |   2 +-
 drivers/serial/serial_sti_asc.c                    |   2 +-
 drivers/serial/serial_stm32x7.c                    |   2 +-
 drivers/serial/serial_uniphier.c                   |   5 +-
 drivers/serial/serial_xuartlite.c                  |   2 +-
 drivers/serial/serial_zynq.c                       |   2 +-
 drivers/spi/altera_spi.c                           |   2 +-
 drivers/spi/ath79_spi.c                            |   2 +-
 drivers/spi/atmel_spi.c                            |   2 +-
 drivers/spi/davinci_spi.c                          |   2 +-
 drivers/spi/designware_spi.c                       |   2 +-
 drivers/spi/exynos_spi.c                           |   2 +-
 drivers/spi/fsl_dspi.c                             |   4 +-
 drivers/spi/kirkwood_spi.c                         |   2 +-
 drivers/spi/mvebu_a3700_spi.c                      |   2 +-
 drivers/spi/omap3_spi.c                            |   2 +-
 drivers/spi/rk_spi.c                               |   2 +-
 drivers/spi/tegra114_spi.c                         |   2 +-
 drivers/spi/tegra20_sflash.c                       |   2 +-
 drivers/spi/tegra20_slink.c                        |   2 +-
 drivers/spi/tegra210_qspi.c                        |   2 +-
 drivers/spi/ti_qspi.c                              |  12 +-
 drivers/spi/zynq_spi.c                             |   2 +-
 drivers/spmi/spmi-msm.c                            |   2 +-
 drivers/sysreset/sysreset_psci.c                   |   3 +-
 drivers/sysreset/sysreset_snapdragon.c             |   2 +-
 drivers/timer/altera_timer.c                       |   2 +-
 drivers/timer/arc_timer.c                          |   2 +-
 drivers/timer/ast_timer.c                          |   2 +-
 drivers/timer/omap-timer.c                         |   2 +-
 drivers/tpm/tpm_tis_lpc.c                          |   2 +-
 drivers/usb/host/dwc2.c                            |   2 +-
 drivers/usb/host/ehci-atmel.c                      |   2 +-
 drivers/usb/host/ehci-exynos.c                     |   2 +-
 drivers/usb/host/ehci-fsl.c                        |   2 +-
 drivers/usb/host/ehci-generic.c                    |   2 +-
 drivers/usb/host/ehci-marvell.c                    |   2 +-
 drivers/usb/host/ehci-msm.c                        |   2 +-
 drivers/usb/host/ehci-mx6.c                        |   4 +-
 drivers/usb/host/ehci-sunxi.c                      |   2 +-
 drivers/usb/host/ehci-tegra.c                      |   2 +-
 drivers/usb/host/ehci-vf.c                         |   2 +-
 drivers/usb/host/ehci-zynq.c                       |   2 +-
 drivers/usb/host/ohci-generic.c                    |   2 +-
 drivers/usb/host/ohci-sunxi.c                      |   2 +-
 drivers/usb/host/xhci-exynos5.c                    |   2 +-
 drivers/usb/host/xhci-fsl.c                        |   2 +-
 drivers/usb/host/xhci-mvebu.c                      |   2 +-
 drivers/usb/host/xhci-rockchip.c                   |   4 +-
 drivers/usb/musb-new/sunxi.c                       |   1 +
 drivers/usb/musb-new/ti-musb.c                     |   2 +-
 drivers/video/atmel_hlcdfb.c                       |   6 +-
 drivers/video/exynos/exynos_dp.c                   |   4 +-
 drivers/video/exynos/exynos_fb.c                   |   2 +-
 drivers/video/rockchip/rk_edp.c                    |   2 +-
 drivers/video/rockchip/rk_hdmi.c                   |   2 +-
 drivers/video/rockchip/rk_lvds.c                   |   2 +-
 drivers/video/rockchip/rk_vop.c                    |   2 +-
 drivers/video/tegra.c                              |   2 +-
 drivers/video/tegra124/dp.c                        |   2 +-
 include/dm.h                                       |   2 +
 include/dm/device.h                                | 106 ++-------------
 include/dm/fdtaddr.h                               | 110 ++++++++++++++++
 include/dm/ofnode.h                                | 100 ++++++++++++++
 include/dm/root.h                                  |  16 ---
 250 files changed, 757 insertions(+), 588 deletions(-)
 create mode 100644 drivers/core/fdtaddr.c
 create mode 100644 include/dm/fdtaddr.h
 create mode 100644 include/dm/ofnode.h

-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file Simon Glass
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

This header includes things that are needed to make driver build. Adjust
existing users to include that always, even if other dm/ includes are
present

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 arch/arm/lib/bootm.c                               | 2 +-
 arch/arm/mach-uniphier/pinctrl-glue.c              | 3 +--
 arch/sandbox/cpu/cpu.c                             | 1 +
 board/amlogic/odroid-c2/odroid-c2.c                | 2 +-
 board/armltd/integrator/integrator.c               | 2 +-
 board/armltd/vexpress64/vexpress64.c               | 2 +-
 board/beckhoff/mx53cx9020/mx53cx9020.c             | 2 +-
 board/cadence/xtfpga/xtfpga.c                      | 2 +-
 board/cavium/thunderx/thunderx.c                   | 2 +-
 board/freescale/common/fsl_chain_of_trust.c        | 1 +
 board/freescale/common/fsl_validate.c              | 2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c | 2 +-
 board/st/stm32f746-disco/stm32f746-disco.c         | 2 +-
 board/st/stv0991/stv0991.c                         | 2 +-
 board/toradex/apalis_imx6/apalis_imx6.c            | 1 +
 board/toradex/colibri_imx6/colibri_imx6.c          | 1 +
 board/toradex/colibri_pxa270/colibri_pxa270.c      | 1 +
 cmd/bootefi.c                                      | 2 +-
 common/env_sf.c                                    | 1 +
 drivers/clk/at91/clk-generated.c                   | 2 +-
 drivers/clk/at91/clk-h32mx.c                       | 2 +-
 drivers/clk/at91/clk-main.c                        | 2 +-
 drivers/clk/at91/clk-master.c                      | 2 +-
 drivers/clk/at91/clk-peripheral.c                  | 2 +-
 drivers/clk/at91/clk-plla.c                        | 2 +-
 drivers/clk/at91/clk-slow.c                        | 2 +-
 drivers/clk/at91/clk-system.c                      | 2 +-
 drivers/clk/at91/clk-utmi.c                        | 2 +-
 drivers/clk/at91/pmc.c                             | 3 +--
 drivers/clk/at91/sckc.c                            | 3 +--
 drivers/clk/clk_fixed_rate.c                       | 2 +-
 drivers/clk/clk_zynqmp.c                           | 2 +-
 drivers/clk/uniphier/clk-uniphier-core.c           | 2 +-
 drivers/dma/ti-edma3.c                             | 2 +-
 drivers/firmware/firmware-uclass.c                 | 2 +-
 drivers/firmware/psci.c                            | 2 +-
 drivers/gpio/gpio-uniphier.c                       | 2 +-
 drivers/i2c/i2c-cdns.c                             | 2 +-
 drivers/i2c/i2c-uniphier-f.c                       | 2 +-
 drivers/i2c/i2c-uniphier.c                         | 2 +-
 drivers/mmc/gen_atmel_mci.c                        | 2 +-
 drivers/mmc/meson_gx_mmc.c                         | 2 +-
 drivers/mmc/sdhci-cadence.c                        | 2 +-
 drivers/mmc/tegra_mmc.c                            | 2 +-
 drivers/mmc/uniphier-sd.c                          | 2 +-
 drivers/net/ethoc.c                                | 2 +-
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c         | 2 +-
 drivers/pinctrl/meson/pinctrl-meson.c              | 2 +-
 drivers/pinctrl/nxp/pinctrl-imx.c                  | 2 +-
 drivers/pinctrl/nxp/pinctrl-imx5.c                 | 2 +-
 drivers/pinctrl/nxp/pinctrl-imx6.c                 | 2 +-
 drivers/pinctrl/nxp/pinctrl-imx7.c                 | 2 +-
 drivers/pinctrl/nxp/pinctrl-imx7ulp.c              | 2 +-
 drivers/pinctrl/pinctrl-at91-pio4.c                | 2 +-
 drivers/pinctrl/pinctrl-at91.c                     | 2 +-
 drivers/pinctrl/pinctrl-generic.c                  | 2 +-
 drivers/pinctrl/pinctrl-sandbox.c                  | 2 +-
 drivers/pinctrl/pinctrl-single.c                   | 2 +-
 drivers/pinctrl/pinctrl-uclass.c                   | 3 +--
 drivers/pinctrl/uniphier/pinctrl-uniphier-core.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c    | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c   | 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c   | 2 +-
 drivers/reset/reset-uniphier.c                     | 2 +-
 drivers/serial/serial_uniphier.c                   | 2 +-
 drivers/sysreset/sysreset_psci.c                   | 2 +-
 drivers/usb/musb-new/sunxi.c                       | 1 +
 74 files changed, 74 insertions(+), 71 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 4dbe6a5303..eb242223b4 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -14,7 +14,7 @@
 
 #include <common.h>
 #include <command.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/root.h>
 #include <image.h>
 #include <u-boot/zlib.h>
diff --git a/arch/arm/mach-uniphier/pinctrl-glue.c b/arch/arm/mach-uniphier/pinctrl-glue.c
index c52c6a6f6c..725569f90c 100644
--- a/arch/arm/mach-uniphier/pinctrl-glue.c
+++ b/arch/arm/mach-uniphier/pinctrl-glue.c
@@ -6,9 +6,8 @@
  */
 
 #include <linux/errno.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
-#include <dm/uclass.h>
 
 #include "init.h"
 
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 2def72212d..3fe99b853d 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -4,6 +4,7 @@
  */
 #define DEBUG
 #include <common.h>
+#include <dm.h>
 #include <errno.h>
 #include <libfdt.h>
 #include <os.h>
diff --git a/board/amlogic/odroid-c2/odroid-c2.c b/board/amlogic/odroid-c2/odroid-c2.c
index b61daaa4a7..9306b56a6a 100644
--- a/board/amlogic/odroid-c2/odroid-c2.c
+++ b/board/amlogic/odroid-c2/odroid-c2.c
@@ -5,10 +5,10 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/io.h>
 #include <asm/arch/gxbb.h>
 #include <asm/arch/sm.h>
-#include <dm/platdata.h>
 #include <phy.h>
 
 #define EFUSE_SN_OFFSET		20
diff --git a/board/armltd/integrator/integrator.c b/board/armltd/integrator/integrator.c
index cbe706170d..fabb8b1c57 100644
--- a/board/armltd/integrator/integrator.c
+++ b/board/armltd/integrator/integrator.c
@@ -18,9 +18,9 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <netdev.h>
 #include <asm/io.h>
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_pl01x.h>
 #include "arm-ebi.h"
 #include "integrator-sc.h"
diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
index 0a224178df..26e22c4c25 100644
--- a/board/armltd/vexpress64/vexpress64.c
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -6,12 +6,12 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
 #include <malloc.h>
 #include <errno.h>
 #include <netdev.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_pl01x.h>
 #include "pcie.h"
 #include <asm/armv8/mmu.h>
diff --git a/board/beckhoff/mx53cx9020/mx53cx9020.c b/board/beckhoff/mx53cx9020/mx53cx9020.c
index c5d55dc68f..e903bc1807 100644
--- a/board/beckhoff/mx53cx9020/mx53cx9020.c
+++ b/board/beckhoff/mx53cx9020/mx53cx9020.c
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
@@ -26,7 +27,6 @@
 #include <linux/fb.h>
 #include <ipu_pixfmt.h>
 #include <fs.h>
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_mxc.h>
 
 enum LED_GPIOS {
diff --git a/board/cadence/xtfpga/xtfpga.c b/board/cadence/xtfpga/xtfpga.c
index 39b9b12567..0265e9bb36 100644
--- a/board/cadence/xtfpga/xtfpga.c
+++ b/board/cadence/xtfpga/xtfpga.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <command.h>
-#include <dm/platdata.h>
+#include <dm.h>
 #include <dm/platform_data/net_ethoc.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
diff --git a/board/cavium/thunderx/thunderx.c b/board/cavium/thunderx/thunderx.c
index 960ca53b02..02253af5d9 100644
--- a/board/cavium/thunderx/thunderx.c
+++ b/board/cavium/thunderx/thunderx.c
@@ -5,6 +5,7 @@
 **/
 
 #include <common.h>
+#include <dm.h>
 #include <malloc.h>
 #include <errno.h>
 #include <linux/compiler.h>
@@ -13,7 +14,6 @@
 #include <asm/armv8/mmu.h>
 
 #if !CONFIG_IS_ENABLED(OF_CONTROL)
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_pl01x.h>
 
 static const struct pl01x_serial_platdata serial0 = {
diff --git a/board/freescale/common/fsl_chain_of_trust.c b/board/freescale/common/fsl_chain_of_trust.c
index aad1b93d14..2cd4fba13f 100644
--- a/board/freescale/common/fsl_chain_of_trust.c
+++ b/board/freescale/common/fsl_chain_of_trust.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <fsl_validate.h>
 #include <fsl_secboot_err.h>
 #include <fsl_sfp.h>
diff --git a/board/freescale/common/fsl_validate.c b/board/freescale/common/fsl_validate.c
index ed48c5c8bd..ef93407646 100644
--- a/board/freescale/common/fsl_validate.c
+++ b/board/freescale/common/fsl_validate.c
@@ -5,13 +5,13 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <fsl_validate.h>
 #include <fsl_secboot_err.h>
 #include <fsl_sfp.h>
 #include <fsl_sec.h>
 #include <command.h>
 #include <malloc.h>
-#include <dm/uclass.h>
 #include <u-boot/rsa-mod-exp.h>
 #include <hash.h>
 #include <fsl_secboot_err.h>
diff --git a/board/st/stm32f429-discovery/stm32f429-discovery.c b/board/st/stm32f429-discovery/stm32f429-discovery.c
index d16d73fc97..8c8abf6a06 100644
--- a/board/st/stm32f429-discovery/stm32f429-discovery.c
+++ b/board/st/stm32f429-discovery/stm32f429-discovery.c
@@ -12,12 +12,12 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/io.h>
 #include <asm/armv7m.h>
 #include <asm/arch/stm32.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/fmc.h>
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_stm32.h>
 #include <asm/arch/stm32_periph.h>
 #include <asm/arch/stm32_defs.h>
diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c
index fdad8d13a7..8736124ecb 100644
--- a/board/st/stm32f746-disco/stm32f746-disco.c
+++ b/board/st/stm32f746-disco/stm32f746-disco.c
@@ -6,12 +6,12 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/io.h>
 #include <asm/armv7m.h>
 #include <asm/arch/stm32.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/fmc.h>
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_stm32x7.h>
 #include <asm/arch/stm32_periph.h>
 #include <asm/arch/stm32_defs.h>
diff --git a/board/st/stv0991/stv0991.c b/board/st/stv0991/stv0991.c
index 6a19730069..85ac66ec3a 100644
--- a/board/st/stv0991/stv0991.c
+++ b/board/st/stv0991/stv0991.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <miiphy.h>
 #include <asm/arch/stv0991_periph.h>
 #include <asm/arch/stv0991_defs.h>
@@ -13,7 +14,6 @@
 #include <asm/arch/gpio.h>
 #include <netdev.h>
 #include <asm/io.h>
-#include <dm/platdata.h>
 #include <dm/platform_data/serial_pl01x.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/board/toradex/apalis_imx6/apalis_imx6.c b/board/toradex/apalis_imx6/apalis_imx6.c
index 09bebeb71b..d79f79cbb9 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/mxc_hdmi.h>
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c b/board/toradex/colibri_imx6/colibri_imx6.c
index d070677054..69467ca895 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/imx-regs.h>
diff --git a/board/toradex/colibri_pxa270/colibri_pxa270.c b/board/toradex/colibri_pxa270/colibri_pxa270.c
index 8e948545e3..5d62e66495 100644
--- a/board/toradex/colibri_pxa270/colibri_pxa270.c
+++ b/board/toradex/colibri_pxa270/colibri_pxa270.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/pxa.h>
 #include <asm/arch/regs-mmc.h>
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 3b777058f4..a0a5434967 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -8,7 +8,7 @@
 
 #include <common.h>
 #include <command.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <efi_loader.h>
 #include <errno.h>
 #include <libfdt.h>
diff --git a/common/env_sf.c b/common/env_sf.c
index 27b4d1226a..d427471e96 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -10,6 +10,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
 #include <environment.h>
 #include <malloc.h>
 #include <spi.h>
diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c
index ac27d3e675..8c9a3cb053 100644
--- a/drivers/clk/at91/clk-generated.c
+++ b/drivers/clk/at91/clk-generated.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c
index 1a304bab21..dcc64fbd6d 100644
--- a/drivers/clk/at91/clk-h32mx.c
+++ b/drivers/clk/at91/clk-h32mx.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/util.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index 252d076bd5..a234ce8b7e 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index 72d0a739f1..6bc78bad0d 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c
index 62fabe304d..212a30bd5e 100644
--- a/drivers/clk/at91/clk-peripheral.c
+++ b/drivers/clk/at91/clk-peripheral.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/clk-plla.c b/drivers/clk/at91/clk-plla.c
index 2a71399741..f5b2ca1673 100644
--- a/drivers/clk/at91/clk-plla.c
+++ b/drivers/clk/at91/clk-plla.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index f7666b4041..f18f002bea 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 
 static int at91_slow_clk_enable(struct clk *clk)
 {
diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c
index 5b59a0c852..24b271aa18 100644
--- a/drivers/clk/at91/clk-system.c
+++ b/drivers/clk/at91/clk-system.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c
index 369a6870d8..af5362da42 100644
--- a/drivers/clk/at91/clk-utmi.c
+++ b/drivers/clk/at91/clk-utmi.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <mach/at91_pmc.h>
 #include "pmc.h"
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 72d52c5818..29067fa7bd 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -7,9 +7,8 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/lists.h>
-#include <dm/root.h>
 #include <dm/util.h>
 #include "pmc.h"
 
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index 6035e20959..0c0881237c 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -6,8 +6,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
-#include <dm/root.h>
+#include <dm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 3911bf61a0..1cac4bbb85 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -6,7 +6,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/clk/clk_zynqmp.c b/drivers/clk/clk_zynqmp.c
index 694274d991..50eaf31613 100644
--- a/drivers/clk/clk_zynqmp.c
+++ b/drivers/clk/clk_zynqmp.c
@@ -9,8 +9,8 @@
 #include <common.h>
 #include <linux/bitops.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
 #include <clk.h>
+#include <dm.h>
 
 #define ZYNQMP_GEM0_REF_CTRL		0xFF5E0050
 #define ZYNQMP_IOPLL_CTRL		0xFF5E0020
diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c
index bcb2d2edb7..c53dd911f1 100644
--- a/drivers/clk/uniphier/clk-uniphier-core.c
+++ b/drivers/clk/uniphier/clk-uniphier-core.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <clk-uclass.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/dma/ti-edma3.c b/drivers/dma/ti-edma3.c
index 247843891e..645aa2c4ae 100644
--- a/drivers/dma/ti-edma3.c
+++ b/drivers/dma/ti-edma3.c
@@ -11,8 +11,8 @@
 
 #include <asm/io.h>
 #include <common.h>
+#include <dm.h>
 #include <dma.h>
-#include <dm/device.h>
 #include <asm/omap_common.h>
 #include <asm/ti-common/ti-edma3.h>
 
diff --git a/drivers/firmware/firmware-uclass.c b/drivers/firmware/firmware-uclass.c
index 01b6a44b9d..6c96656dd0 100644
--- a/drivers/firmware/firmware-uclass.c
+++ b/drivers/firmware/firmware-uclass.c
@@ -2,7 +2,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/uclass.h>
+#include <dm.h>
 
 /* Firmware access is platform-dependent.  No generic code in uclass */
 UCLASS_DRIVER(firmware) = {
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 40fba6432c..3ae627ce5d 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -8,7 +8,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/lists.h>
 #include <libfdt.h>
 #include <linux/arm-smccc.h>
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index ad1176420d..a10116c215 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -6,7 +6,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index dec18200ce..db37444108 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -9,10 +9,10 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <linux/types.h>
 #include <linux/io.h>
 #include <linux/errno.h>
-#include <dm/device.h>
 #include <dm/root.h>
 #include <i2c.h>
 #include <fdtdec.h>
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
index 9f0df599a0..be9fc8afc9 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -7,12 +7,12 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <linux/types.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/sizes.h>
 #include <linux/errno.h>
-#include <dm/device.h>
 #include <i2c.h>
 #include <fdtdec.h>
 
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
index 73575e9895..75d1c4cad8 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -7,11 +7,11 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <linux/types.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
 #include <linux/errno.h>
-#include <dm/device.h>
 #include <i2c.h>
 #include <fdtdec.h>
 
diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
index c25d9ed96e..d883da30a1 100644
--- a/drivers/mmc/gen_atmel_mci.c
+++ b/drivers/mmc/gen_atmel_mci.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <clk.h>
+#include <dm.h>
 #include <mmc.h>
 #include <part.h>
 #include <malloc.h>
@@ -19,7 +20,6 @@
 #include <asm/byteorder.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/hardware.h>
-#include <dm/device.h>
 #include "atmel_mci.h"
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index 8e28ab70f5..12da42d003 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -5,12 +5,12 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <fdtdec.h>
 #include <malloc.h>
 #include <mmc.h>
 #include <asm/io.h>
 #include <asm/arch/sd_emmc.h>
-#include <dm/device.h>
 #include <linux/log2.h>
 
 static inline void *get_regbase(const struct mmc *mmc)
diff --git a/drivers/mmc/sdhci-cadence.c b/drivers/mmc/sdhci-cadence.c
index 2253bbc518..6f3de3b6c3 100644
--- a/drivers/mmc/sdhci-cadence.c
+++ b/drivers/mmc/sdhci-cadence.c
@@ -6,9 +6,9 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
-#include <dm/device.h>
 #include <mmc.h>
 #include <sdhci.h>
 
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index 6c6affb925..9037ffb381 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -9,7 +9,7 @@
 
 #include <bouncebuf.h>
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <errno.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 7f20ef124d..195419ecda 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -9,7 +9,7 @@
 #include <clk.h>
 #include <fdtdec.h>
 #include <mmc.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <linux/compat.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index ad8c462a60..2f4cad6791 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -11,7 +11,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/platform_data/net_ethoc.h>
 #include <linux/io.h>
 #include <malloc.h>
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
index a0a7de5f0f..0dc2438ebe 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
@@ -7,7 +7,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 #include <dt-bindings/gpio/meson-gxbb-gpio.h>
 
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index b5486b8fe4..6281f529ea 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -5,7 +5,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 #include <fdt_support.h>
 #include <linux/err.h>
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c b/drivers/pinctrl/nxp/pinctrl-imx.c
index f0321c4057..49e7abf038 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx.c
@@ -8,7 +8,7 @@
 #include <mapmem.h>
 #include <linux/io.h>
 #include <linux/err.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-imx.h"
diff --git a/drivers/pinctrl/nxp/pinctrl-imx5.c b/drivers/pinctrl/nxp/pinctrl-imx5.c
index 6942f39670..5f3f94e750 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx5.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx5.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-imx.h"
diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c
index 4488b16011..3842205420 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx6.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx6.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-imx.h"
diff --git a/drivers/pinctrl/nxp/pinctrl-imx7.c b/drivers/pinctrl/nxp/pinctrl-imx7.c
index eeb79426df..439c04e0cc 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx7.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx7.c
@@ -4,7 +4,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-imx.h"
diff --git a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c
index 5f011757d8..1f81a66df4 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-imx.h"
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index 5c6bff568a..d6f8a9ba1d 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -8,7 +8,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 #include <linux/io.h>
 #include <linux/err.h>
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 904e1bdc68..3147b59d19 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -8,7 +8,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 #include <linux/io.h>
 #include <linux/err.h>
diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c
index 0272496b51..49e36480df 100644
--- a/drivers/pinctrl/pinctrl-generic.c
+++ b/drivers/pinctrl/pinctrl-generic.c
@@ -5,8 +5,8 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <linux/compat.h>
-#include <dm/device.h>
 #include <dm/pinctrl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/pinctrl/pinctrl-sandbox.c b/drivers/pinctrl/pinctrl-sandbox.c
index ab03d8bad4..e77b49c168 100644
--- a/drivers/pinctrl/pinctrl-sandbox.c
+++ b/drivers/pinctrl/pinctrl-sandbox.c
@@ -7,7 +7,7 @@
 /* #define DEBUG */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 static const char * const sandbox_pins[] = {
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index d2dcec0d13..6c952cc591 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -5,7 +5,7 @@
  */
 
 #include <common.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 #include <libfdt.h>
 #include <asm/io.h>
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 9efad0623a..0633b69bbe 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -8,10 +8,9 @@
 #include <libfdt.h>
 #include <linux/err.h>
 #include <linux/list.h>
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
-#include <dm/uclass.h>
 #include <dm/util.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
index d8e9948ee7..4f369c9049 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
@@ -6,10 +6,10 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/sizes.h>
-#include <dm/device.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
index 53c37cda7a..cc76fef0a1 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
index 5a7d142865..83d960f5e9 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c
index 9b3db9d812..84ee10387d 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c
index b25c7ea16e..15fab6a1b0 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
index f1624dab3f..cf1fc5aa32 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c
index 70c90bae54..788cfab47a 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c
index 60777c3045..8869fe4ed9 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c
index 65b56dac3f..5bff86b31a 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c
index d3a507edc1..6127fd2111 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c
index 471fb673f7..5ed49f0070 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <dm/pinctrl.h>
 
 #include "pinctrl-uniphier.h"
diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 29c4d4db97..5d17734090 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -6,8 +6,8 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <reset-uclass.h>
-#include <dm/device.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 0e25cba6ac..7c6a049692 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -6,11 +6,11 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <dm.h>
 #include <linux/io.h>
 #include <linux/serial_reg.h>
 #include <linux/sizes.h>
 #include <linux/errno.h>
-#include <dm/device.h>
 #include <serial.h>
 #include <fdtdec.h>
 
diff --git a/drivers/sysreset/sysreset_psci.c b/drivers/sysreset/sysreset_psci.c
index a4911b7d8f..b39051c220 100644
--- a/drivers/sysreset/sysreset_psci.c
+++ b/drivers/sysreset/sysreset_psci.c
@@ -4,7 +4,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm/device.h>
+#include <dm.h>
 #include <sysreset.h>
 #include <linux/errno.h>
 #include <linux/psci.h>
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 469377fe4e..5c1a902e42 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -17,6 +17,7 @@
  * SPDX-License-Identifier:	GPL-2.0
  */
 #include <common.h>
+#include <dm.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-16 10:04   ` Masahiro Yamada
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 3/9] dm: Rename dev_addr..() functions Simon Glass
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

Move this group of address-related functions into a new file. These use
the flat device tree. Future work will provide new versions of these which
can support the live tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 drivers/core/Makefile  |   2 +-
 drivers/core/device.c  | 125 ------------------------------------------
 drivers/core/fdtaddr.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/dm.h           |   1 +
 include/dm/device.h    |  92 -------------------------------
 include/dm/fdtaddr.h   | 110 +++++++++++++++++++++++++++++++++++++
 6 files changed, 255 insertions(+), 218 deletions(-)
 create mode 100644 drivers/core/fdtaddr.c
 create mode 100644 include/dm/fdtaddr.h

diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 07adb61c28..8261f14f45 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	+= device.o lists.o root.o uclass.o util.o
+obj-y	+= device.o fdtaddr.o lists.o root.o uclass.o util.o
 obj-$(CONFIG_DEVRES) += devres.o
 obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE)	+= device-remove.o
 obj-$(CONFIG_$(SPL_)SIMPLE_BUS)	+= simple-bus.o
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 09a115f753..483f8368f7 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -655,131 +655,6 @@ const char *dev_get_uclass_name(struct udevice *dev)
 	return dev->uclass->uc_drv->name;
 }
 
-fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
-{
-#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
-	fdt_addr_t addr;
-
-	if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
-		const fdt32_t *reg;
-		int len = 0;
-		int na, ns;
-
-		na = fdt_address_cells(gd->fdt_blob,
-				       dev_of_offset(dev->parent));
-		if (na < 1) {
-			debug("bad #address-cells\n");
-			return FDT_ADDR_T_NONE;
-		}
-
-		ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
-		if (ns < 0) {
-			debug("bad #size-cells\n");
-			return FDT_ADDR_T_NONE;
-		}
-
-		reg = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "reg",
-				  &len);
-		if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
-			debug("Req index out of range\n");
-			return FDT_ADDR_T_NONE;
-		}
-
-		reg += index * (na + ns);
-
-		/*
-		 * Use the full-fledged translate function for complex
-		 * bus setups.
-		 */
-		addr = fdt_translate_address((void *)gd->fdt_blob,
-					     dev_of_offset(dev), reg);
-	} else {
-		/*
-		 * Use the "simple" translate function for less complex
-		 * bus setups.
-		 */
-		addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-				dev_of_offset(dev->parent), dev_of_offset(dev),
-				"reg", index, NULL, false);
-		if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
-			if (device_get_uclass_id(dev->parent) ==
-			    UCLASS_SIMPLE_BUS)
-				addr = simple_bus_translate(dev->parent, addr);
-		}
-	}
-
-	/*
-	 * Some platforms need a special address translation. Those
-	 * platforms (e.g. mvebu in SPL) can configure a translation
-	 * offset in the DM by calling dm_set_translation_offset() that
-	 * will get added to all addresses returned by dev_get_addr().
-	 */
-	addr += dm_get_translation_offset();
-
-	return addr;
-#else
-	return FDT_ADDR_T_NONE;
-#endif
-}
-
-fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
-				   fdt_size_t *size)
-{
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-	/*
-	 * Only get the size in this first call. We'll get the addr in the
-	 * next call to the exisiting dev_get_xxx function which handles
-	 * all config options.
-	 */
-	fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev),
-					   "reg", index, size, false);
-
-	/*
-	 * Get the base address via the existing function which handles
-	 * all Kconfig cases
-	 */
-	return dev_get_addr_index(dev, index);
-#else
-	return FDT_ADDR_T_NONE;
-#endif
-}
-
-fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
-{
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-	int index;
-
-	index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
-				      "reg-names", name);
-	if (index < 0)
-		return index;
-
-	return dev_get_addr_index(dev, index);
-#else
-	return FDT_ADDR_T_NONE;
-#endif
-}
-
-fdt_addr_t dev_get_addr(struct udevice *dev)
-{
-	return dev_get_addr_index(dev, 0);
-}
-
-void *dev_get_addr_ptr(struct udevice *dev)
-{
-	return (void *)(uintptr_t)dev_get_addr_index(dev, 0);
-}
-
-void *dev_map_physmem(struct udevice *dev, unsigned long size)
-{
-	fdt_addr_t addr = dev_get_addr(dev);
-
-	if (addr == FDT_ADDR_T_NONE)
-		return NULL;
-
-	return map_physmem(addr, size, MAP_NOCACHE);
-}
-
 bool device_has_children(struct udevice *dev)
 {
 	return !list_empty(&dev->child_head);
diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
new file mode 100644
index 0000000000..a0578feb1b
--- /dev/null
+++ b/drivers/core/fdtaddr.c
@@ -0,0 +1,143 @@
+/*
+ * Device addresses
+ *
+ * Copyright (c) 2017 Google, Inc
+ *
+ * (C) Copyright 2012
+ * Pavel Herrmann <morpheus.ibis@gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <fdt_support.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
+{
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+	fdt_addr_t addr;
+
+	if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
+		const fdt32_t *reg;
+		int len = 0;
+		int na, ns;
+
+		na = fdt_address_cells(gd->fdt_blob,
+				       dev_of_offset(dev->parent));
+		if (na < 1) {
+			debug("bad #address-cells\n");
+			return FDT_ADDR_T_NONE;
+		}
+
+		ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
+		if (ns < 0) {
+			debug("bad #size-cells\n");
+			return FDT_ADDR_T_NONE;
+		}
+
+		reg = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "reg",
+				  &len);
+		if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
+			debug("Req index out of range\n");
+			return FDT_ADDR_T_NONE;
+		}
+
+		reg += index * (na + ns);
+
+		/*
+		 * Use the full-fledged translate function for complex
+		 * bus setups.
+		 */
+		addr = fdt_translate_address((void *)gd->fdt_blob,
+					     dev_of_offset(dev), reg);
+	} else {
+		/*
+		 * Use the "simple" translate function for less complex
+		 * bus setups.
+		 */
+		addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+				dev_of_offset(dev->parent), dev_of_offset(dev),
+				"reg", index, NULL, false);
+		if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
+			if (device_get_uclass_id(dev->parent) ==
+			    UCLASS_SIMPLE_BUS)
+				addr = simple_bus_translate(dev->parent, addr);
+		}
+	}
+
+	/*
+	 * Some platforms need a special address translation. Those
+	 * platforms (e.g. mvebu in SPL) can configure a translation
+	 * offset in the DM by calling dm_set_translation_offset() that
+	 * will get added to all addresses returned by dev_get_addr().
+	 */
+	addr += dm_get_translation_offset();
+
+	return addr;
+#else
+	return FDT_ADDR_T_NONE;
+#endif
+}
+
+fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
+				   fdt_size_t *size)
+{
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	/*
+	 * Only get the size in this first call. We'll get the addr in the
+	 * next call to the exisiting dev_get_xxx function which handles
+	 * all config options.
+	 */
+	fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev),
+					   "reg", index, size, false);
+
+	/*
+	 * Get the base address via the existing function which handles
+	 * all Kconfig cases
+	 */
+	return dev_get_addr_index(dev, index);
+#else
+	return FDT_ADDR_T_NONE;
+#endif
+}
+
+fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
+{
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	int index;
+
+	index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
+				      "reg-names", name);
+	if (index < 0)
+		return index;
+
+	return dev_get_addr_index(dev, index);
+#else
+	return FDT_ADDR_T_NONE;
+#endif
+}
+
+fdt_addr_t dev_get_addr(struct udevice *dev)
+{
+	return dev_get_addr_index(dev, 0);
+}
+
+void *dev_get_addr_ptr(struct udevice *dev)
+{
+	return (void *)(uintptr_t)dev_get_addr_index(dev, 0);
+}
+
+void *dev_map_physmem(struct udevice *dev, unsigned long size)
+{
+	fdt_addr_t addr = dev_get_addr(dev);
+
+	if (addr == FDT_ADDR_T_NONE)
+		return NULL;
+
+	return map_physmem(addr, size, MAP_NOCACHE);
+}
diff --git a/include/dm.h b/include/dm.h
index a179c8a6e3..84f789d807 100644
--- a/include/dm.h
+++ b/include/dm.h
@@ -8,6 +8,7 @@
 #define _DM_H_
 
 #include <dm/device.h>
+#include <dm/fdtaddr.h>
 #include <dm/platdata.h>
 #include <dm/uclass.h>
 
diff --git a/include/dm/device.h b/include/dm/device.h
index 079ec57003..6c4aab6c96 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -490,77 +490,6 @@ int device_find_first_child(struct udevice *parent, struct udevice **devp);
 int device_find_next_child(struct udevice **devp);
 
 /**
- * dev_get_addr() - Get the reg property of a device
- *
- * @dev: Pointer to a device
- *
- * @return addr
- */
-fdt_addr_t dev_get_addr(struct udevice *dev);
-
-/**
- * dev_get_addr_ptr() - Return pointer to the address of the reg property
- *                      of a device
- *
- * @dev: Pointer to a device
- *
- * @return Pointer to addr, or NULL if there is no such property
- */
-void *dev_get_addr_ptr(struct udevice *dev);
-
-/**
- * dev_map_physmem() - Read device address from reg property of the
- *                     device node and map the address into CPU address
- *                     space.
- *
- * @dev: Pointer to device
- * @size: size of the memory to map
- *
- * @return  mapped address, or NULL if the device does not have reg
- *          property.
- */
-void *dev_map_physmem(struct udevice *dev, unsigned long size);
-
-/**
- * dev_get_addr_index() - Get the indexed reg property of a device
- *
- * @dev: Pointer to a device
- * @index: the 'reg' property can hold a list of <addr, size> pairs
- *	   and @index is used to select which one is required
- *
- * @return addr
- */
-fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
-
-/**
- * dev_get_addr_size_index() - Get the indexed reg property of a device
- *
- * Returns the address and size specified in the 'reg' property of a device.
- *
- * @dev: Pointer to a device
- * @index: the 'reg' property can hold a list of <addr, size> pairs
- *	   and @index is used to select which one is required
- * @size: Pointer to size varible - this function returns the size
- *        specified in the 'reg' property here
- *
- * @return addr
- */
-fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
-				   fdt_size_t *size);
-
-/**
- * dev_get_addr_name() - Get the reg property of a device, indexed by name
- *
- * @dev: Pointer to a device
- * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
- *	  'reg-names' property providing named-based identification. @index
- *	  indicates the value to search for in 'reg-names'.
- *
- * @return addr
- */
-fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name);
-
-/**
  * device_has_children() - check if a device has any children
  *
  * @dev:	Device to check
@@ -935,25 +864,4 @@ static inline void devm_kfree(struct udevice *dev, void *ptr)
 
 #endif /* ! CONFIG_DEVRES */
 
-/**
- * dm_set_translation_offset() - Set translation offset
- * @offs: Translation offset
- *
- * Some platforms need a special address translation. Those
- * platforms (e.g. mvebu in SPL) can configure a translation
- * offset in the DM by calling this function. It will be
- * added to all addresses returned in dev_get_addr().
- */
-void dm_set_translation_offset(fdt_addr_t offs);
-
-/**
- * dm_get_translation_offset() - Get translation offset
- *
- * This function returns the translation offset that can
- * be configured by calling dm_set_translation_offset().
- *
- * @return translation offset for the device address (0 as default).
- */
-fdt_addr_t dm_get_translation_offset(void);
-
 #endif
diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h
new file mode 100644
index 0000000000..fd05b6fe95
--- /dev/null
+++ b/include/dm/fdtaddr.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2017 Google, Inc
+ *
+ * (C) Copyright 2012
+ * Pavel Herrmann <morpheus.ibis@gmail.com>
+ * Marek Vasut <marex@denx.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _DM_ADDR_H
+#define _DM_ADDR_H
+
+#include <fdtdec.h>
+
+struct udevice;
+
+/**
+ * dev_get_addr() - Get the reg property of a device
+ *
+ * @dev: Pointer to a device
+ *
+ * @return addr
+ */
+fdt_addr_t dev_get_addr(struct udevice *dev);
+
+/**
+ * dev_get_addr_ptr() - Return pointer to the address of the reg property
+ *                      of a device
+ *
+ * @dev: Pointer to a device
+ *
+ * @return Pointer to addr, or NULL if there is no such property
+ */
+void *dev_get_addr_ptr(struct udevice *dev);
+
+/**
+ * dev_map_physmem() - Read device address from reg property of the
+ *                     device node and map the address into CPU address
+ *                     space.
+ *
+ * @dev: Pointer to device
+ * @size: size of the memory to map
+ *
+ * @return  mapped address, or NULL if the device does not have reg
+ *          property.
+ */
+void *dev_map_physmem(struct udevice *dev, unsigned long size);
+
+/**
+ * dev_get_addr_index() - Get the indexed reg property of a device
+ *
+ * @dev: Pointer to a device
+ * @index: the 'reg' property can hold a list of <addr, size> pairs
+ *	   and @index is used to select which one is required
+ *
+ * @return addr
+ */
+fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
+
+/**
+ * dev_get_addr_size_index() - Get the indexed reg property of a device
+ *
+ * Returns the address and size specified in the 'reg' property of a device.
+ *
+ * @dev: Pointer to a device
+ * @index: the 'reg' property can hold a list of <addr, size> pairs
+ *	   and @index is used to select which one is required
+ * @size: Pointer to size varible - this function returns the size
+ *        specified in the 'reg' property here
+ *
+ * @return addr
+ */
+fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
+				   fdt_size_t *size);
+
+/**
+ * dev_get_addr_name() - Get the reg property of a device, indexed by name
+ *
+ * @dev: Pointer to a device
+ * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
+ *	  'reg-names' property providing named-based identification. @index
+ *	  indicates the value to search for in 'reg-names'.
+ *
+ * @return addr
+ */
+fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name);
+
+/**
+ * dm_set_translation_offset() - Set translation offset
+ * @offs: Translation offset
+ *
+ * Some platforms need a special address translation. Those
+ * platforms (e.g. mvebu in SPL) can configure a translation
+ * offset in the DM by calling this function. It will be
+ * added to all addresses returned in dev_get_addr().
+ */
+void dm_set_translation_offset(fdt_addr_t offs);
+
+/**
+ * dm_get_translation_offset() - Get translation offset
+ *
+ * This function returns the translation offset that can
+ * be configured by calling dm_set_translation_offset().
+ *
+ * @return translation offset for the device address (0 as default).
+ */
+fdt_addr_t dm_get_translation_offset(void);
+
+#endif
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 3/9] dm: Rename dev_addr..() functions
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used Simon Glass
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 4/9] atmel: Fix up use of dm_scan_fdt_node() Simon Glass
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

These support the flat device tree. We want to use the dev_read_..()
prefix for functions that support both flat tree and live tree. So rename
the existing functions to avoid confusion.

In the end we will have:

   1. dev_read_addr...()    - works on devices, supports flat/live tree
   2. devfdt_get_addr...()  - current functions, flat tree only
   3. of_get_address() etc. - new functions, live tree only

All drivers will be written to use 1. That function will in turn call
either 2 or 3 depending on whether the flat or live tree is in use.

Note this involves changing some dead code - the imx_lpi2c.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 arch/arm/mach-mvebu/sata.c                       |  2 +-
 arch/arm/mach-rockchip/rk3328/clk_rk3328.c       |  2 +-
 arch/arm/mach-snapdragon/clock-apq8016.c         |  2 +-
 configs/mx7ulp_evk_defconfig                     |  1 +
 drivers/adc/exynos-adc.c                         |  2 +-
 drivers/block/dwc_ahci.c                         |  4 +-
 drivers/block/sata_ceva.c                        |  2 +-
 drivers/clk/aspeed/clk_ast2500.c                 |  2 +-
 drivers/clk/at91/pmc.c                           |  4 +-
 drivers/clk/exynos/clk-exynos7420.c              |  4 +-
 drivers/clk/rockchip/clk_rk3036.c                |  2 +-
 drivers/clk/rockchip/clk_rk3188.c                |  2 +-
 drivers/clk/rockchip/clk_rk3288.c                |  2 +-
 drivers/clk/rockchip/clk_rk3328.c                |  2 +-
 drivers/clk/rockchip/clk_rk3399.c                |  4 +-
 drivers/clk/uniphier/clk-uniphier-core.c         |  2 +-
 drivers/core/fdtaddr.c                           | 24 +++----
 drivers/dma/ti-edma3.c                           |  2 +-
 drivers/gpio/altera_pio.c                        |  2 +-
 drivers/gpio/at91_gpio.c                         |  2 +-
 drivers/gpio/atmel_pio4.c                        |  2 +-
 drivers/gpio/bcm2835_gpio.c                      |  2 +-
 drivers/gpio/gpio-uniphier.c                     |  2 +-
 drivers/gpio/imx_rgpio2p.c                       |  2 +-
 drivers/gpio/msm_gpio.c                          |  2 +-
 drivers/gpio/mvebu_gpio.c                        |  2 +-
 drivers/gpio/mxc_gpio.c                          |  2 +-
 drivers/gpio/omap_gpio.c                         |  2 +-
 drivers/gpio/pm8916_gpio.c                       |  4 +-
 drivers/gpio/rk_gpio.c                           |  2 +-
 drivers/gpio/s5p_gpio.c                          |  4 +-
 drivers/gpio/sunxi_gpio.c                        |  2 +-
 drivers/gpio/tegra186_gpio.c                     |  2 +-
 drivers/gpio/tegra_gpio.c                        |  2 +-
 drivers/gpio/vybrid_gpio.c                       |  2 +-
 drivers/gpio/zynq_gpio.c                         |  2 +-
 drivers/i2c/Kconfig                              |  1 -
 drivers/i2c/at91_i2c.c                           |  2 +-
 drivers/i2c/designware_i2c.c                     |  2 +-
 drivers/i2c/exynos_hs_i2c.c                      |  2 +-
 drivers/i2c/i2c-cdns.c                           |  2 +-
 drivers/i2c/i2c-uniphier-f.c                     |  2 +-
 drivers/i2c/i2c-uniphier.c                       |  2 +-
 drivers/i2c/imx_lpi2c.c                          | 80 ++++++++++++------------
 drivers/i2c/mv_i2c.c                             |  2 +-
 drivers/i2c/mvtwsi.c                             |  2 +-
 drivers/i2c/mxc_i2c.c                            |  2 +-
 drivers/i2c/omap24xx_i2c.c                       |  2 +-
 drivers/i2c/rk_i2c.c                             |  2 +-
 drivers/i2c/s3c24x0_i2c.c                        |  2 +-
 drivers/i2c/tegra_i2c.c                          |  2 +-
 drivers/input/tegra-kbc.c                        |  2 +-
 drivers/mailbox/tegra-hsp.c                      |  2 +-
 drivers/misc/altera_sysid.c                      |  2 +-
 drivers/mmc/atmel_sdhci.c                        |  2 +-
 drivers/mmc/fsl_esdhc.c                          |  2 +-
 drivers/mmc/gen_atmel_mci.c                      |  2 +-
 drivers/mmc/meson_gx_mmc.c                       |  2 +-
 drivers/mmc/msm_sdhci.c                          |  2 +-
 drivers/mmc/omap_hsmmc.c                         |  4 +-
 drivers/mmc/rockchip_dw_mmc.c                    |  2 +-
 drivers/mmc/rockchip_sdhci.c                     |  2 +-
 drivers/mmc/sdhci-cadence.c                      |  2 +-
 drivers/mmc/socfpga_dw_mmc.c                     |  2 +-
 drivers/mmc/sti_sdhci.c                          |  2 +-
 drivers/mmc/tangier_sdhci.c                      |  2 +-
 drivers/mmc/tegra_mmc.c                          |  2 +-
 drivers/mmc/uniphier-sd.c                        |  2 +-
 drivers/mmc/xenon_sdhci.c                        |  4 +-
 drivers/mmc/zynq_sdhci.c                         |  2 +-
 drivers/net/ag7xxx.c                             |  2 +-
 drivers/net/cpsw.c                               |  2 +-
 drivers/net/designware.c                         |  2 +-
 drivers/net/dwc_eth_qos.c                        |  4 +-
 drivers/net/ethoc.c                              |  4 +-
 drivers/net/fec_mxc.c                            |  2 +-
 drivers/net/keystone_net.c                       |  2 +-
 drivers/net/macb.c                               |  2 +-
 drivers/net/mvneta.c                             |  2 +-
 drivers/net/mvpp2.c                              |  8 +--
 drivers/net/sandbox-raw.c                        |  2 +-
 drivers/net/sandbox.c                            |  2 +-
 drivers/net/sun8i_emac.c                         |  4 +-
 drivers/net/sunxi_emac.c                         |  2 +-
 drivers/net/tsec.c                               |  2 +-
 drivers/net/xilinx_axi_emac.c                    |  2 +-
 drivers/net/xilinx_emaclite.c                    |  2 +-
 drivers/net/zynq_gem.c                           |  2 +-
 drivers/pci/pcie_dw_mvebu.c                      |  4 +-
 drivers/phy/marvell/comphy_core.c                |  4 +-
 drivers/phy/ti-pipe3-phy.c                       |  2 +-
 drivers/pinctrl/ath79/pinctrl_ar933x.c           |  2 +-
 drivers/pinctrl/ath79/pinctrl_qca953x.c          |  2 +-
 drivers/pinctrl/exynos/pinctrl-exynos.c          |  2 +-
 drivers/pinctrl/mvebu/pinctrl-mvebu.c            |  2 +-
 drivers/pinctrl/pinctrl-at91-pio4.c              |  2 +-
 drivers/pinctrl/pinctrl-at91.c                   |  2 +-
 drivers/pinctrl/pinctrl-single.c                 |  2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-core.c |  2 +-
 drivers/power/pmic/pm8916.c                      |  2 +-
 drivers/pwm/exynos_pwm.c                         |  2 +-
 drivers/pwm/rk_pwm.c                             |  2 +-
 drivers/pwm/tegra_pwm.c                          |  2 +-
 drivers/reset/reset-uniphier.c                   |  2 +-
 drivers/serial/altera_jtag_uart.c                |  2 +-
 drivers/serial/altera_uart.c                     |  2 +-
 drivers/serial/atmel_usart.c                     |  2 +-
 drivers/serial/ns16550.c                         |  2 +-
 drivers/serial/serial_ar933x.c                   |  2 +-
 drivers/serial/serial_arc.c                      |  2 +-
 drivers/serial/serial_bcm283x_mu.c               |  2 +-
 drivers/serial/serial_lpuart.c                   |  2 +-
 drivers/serial/serial_meson.c                    |  2 +-
 drivers/serial/serial_msm.c                      |  2 +-
 drivers/serial/serial_mvebu_a3700.c              |  2 +-
 drivers/serial/serial_mxc.c                      |  2 +-
 drivers/serial/serial_pl01x.c                    |  2 +-
 drivers/serial/serial_s5p.c                      |  2 +-
 drivers/serial/serial_sti_asc.c                  |  2 +-
 drivers/serial/serial_stm32x7.c                  |  2 +-
 drivers/serial/serial_uniphier.c                 |  2 +-
 drivers/serial/serial_xuartlite.c                |  2 +-
 drivers/serial/serial_zynq.c                     |  2 +-
 drivers/spi/altera_spi.c                         |  2 +-
 drivers/spi/ath79_spi.c                          |  2 +-
 drivers/spi/atmel_spi.c                          |  2 +-
 drivers/spi/davinci_spi.c                        |  2 +-
 drivers/spi/designware_spi.c                     |  2 +-
 drivers/spi/exynos_spi.c                         |  2 +-
 drivers/spi/fsl_dspi.c                           |  2 +-
 drivers/spi/kirkwood_spi.c                       |  2 +-
 drivers/spi/mvebu_a3700_spi.c                    |  2 +-
 drivers/spi/omap3_spi.c                          |  2 +-
 drivers/spi/rk_spi.c                             |  2 +-
 drivers/spi/tegra114_spi.c                       |  2 +-
 drivers/spi/tegra20_sflash.c                     |  2 +-
 drivers/spi/tegra20_slink.c                      |  2 +-
 drivers/spi/tegra210_qspi.c                      |  2 +-
 drivers/spi/ti_qspi.c                            |  8 +--
 drivers/spi/zynq_spi.c                           |  2 +-
 drivers/spmi/spmi-msm.c                          |  2 +-
 drivers/sysreset/sysreset_snapdragon.c           |  2 +-
 drivers/timer/altera_timer.c                     |  2 +-
 drivers/timer/ast_timer.c                        |  2 +-
 drivers/timer/omap-timer.c                       |  2 +-
 drivers/tpm/tpm_tis_lpc.c                        |  2 +-
 drivers/usb/host/dwc2.c                          |  2 +-
 drivers/usb/host/ehci-atmel.c                    |  2 +-
 drivers/usb/host/ehci-exynos.c                   |  2 +-
 drivers/usb/host/ehci-fsl.c                      |  2 +-
 drivers/usb/host/ehci-generic.c                  |  2 +-
 drivers/usb/host/ehci-marvell.c                  |  2 +-
 drivers/usb/host/ehci-msm.c                      |  2 +-
 drivers/usb/host/ehci-mx6.c                      |  4 +-
 drivers/usb/host/ehci-sunxi.c                    |  2 +-
 drivers/usb/host/ehci-tegra.c                    |  2 +-
 drivers/usb/host/ehci-vf.c                       |  2 +-
 drivers/usb/host/ehci-zynq.c                     |  2 +-
 drivers/usb/host/ohci-generic.c                  |  2 +-
 drivers/usb/host/ohci-sunxi.c                    |  2 +-
 drivers/usb/host/xhci-exynos5.c                  |  2 +-
 drivers/usb/host/xhci-fsl.c                      |  2 +-
 drivers/usb/host/xhci-mvebu.c                    |  2 +-
 drivers/usb/host/xhci-rockchip.c                 |  4 +-
 drivers/usb/musb-new/ti-musb.c                   |  2 +-
 drivers/video/atmel_hlcdfb.c                     |  2 +-
 drivers/video/exynos/exynos_dp.c                 |  2 +-
 drivers/video/exynos/exynos_fb.c                 |  2 +-
 drivers/video/rockchip/rk_edp.c                  |  2 +-
 drivers/video/rockchip/rk_hdmi.c                 |  2 +-
 drivers/video/rockchip/rk_lvds.c                 |  2 +-
 drivers/video/rockchip/rk_vop.c                  |  2 +-
 drivers/video/tegra.c                            |  2 +-
 drivers/video/tegra124/dp.c                      |  2 +-
 include/dm/fdtaddr.h                             | 26 ++++----
 175 files changed, 257 insertions(+), 257 deletions(-)

diff --git a/arch/arm/mach-mvebu/sata.c b/arch/arm/mach-mvebu/sata.c
index 140a2952c3..5d8032bd89 100644
--- a/arch/arm/mach-mvebu/sata.c
+++ b/arch/arm/mach-mvebu/sata.c
@@ -35,7 +35,7 @@ static int mvebu_ahci_probe(struct udevice *dev)
 	 */
 	board_ahci_enable();
 
-	ahci_init(dev_get_addr_ptr(dev));
+	ahci_init(devfdt_get_addr_ptr(dev));
 
 	return 0;
 }
diff --git a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
index 1205516227..4dcac27cc7 100644
--- a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
+++ b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c
@@ -25,7 +25,7 @@ void *rockchip_get_cru(void)
 	if (ret)
 		return ERR_PTR(ret);
 
-	priv = dev_get_addr_ptr(dev);
+	priv = devfdt_get_addr_ptr(dev);
 
 	return priv->cru;
 }
diff --git a/arch/arm/mach-snapdragon/clock-apq8016.c b/arch/arm/mach-snapdragon/clock-apq8016.c
index c2cf92494a..da05015c32 100644
--- a/arch/arm/mach-snapdragon/clock-apq8016.c
+++ b/arch/arm/mach-snapdragon/clock-apq8016.c
@@ -235,7 +235,7 @@ static int msm_clk_probe(struct udevice *dev)
 {
 	struct msm_clk_priv *priv = dev_get_priv(dev);
 
-	priv->base = dev_get_addr(dev);
+	priv->base = devfdt_get_addr(dev);
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/configs/mx7ulp_evk_defconfig b/configs/mx7ulp_evk_defconfig
index ea2a0cf2a5..6bd855b21b 100644
--- a/configs/mx7ulp_evk_defconfig
+++ b/configs/mx7ulp_evk_defconfig
@@ -23,3 +23,4 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_CMD_GPIO=y
+CONFIG_SYS_I2C_IMX_LPI2C=y
diff --git a/drivers/adc/exynos-adc.c b/drivers/adc/exynos-adc.c
index 534e68db8b..324d72f3a9 100644
--- a/drivers/adc/exynos-adc.c
+++ b/drivers/adc/exynos-adc.c
@@ -107,7 +107,7 @@ int exynos_adc_ofdata_to_platdata(struct udevice *dev)
 	struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
 	struct exynos_adc_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct exynos_adc_v2 *)dev_get_addr(dev);
+	priv->regs = (struct exynos_adc_v2 *)devfdt_get_addr(dev);
 	if (priv->regs == (struct exynos_adc_v2 *)FDT_ADDR_T_NONE) {
 		error("Dev: %s - can't get address!", dev->name);
 		return -ENODATA;
diff --git a/drivers/block/dwc_ahci.c b/drivers/block/dwc_ahci.c
index d5bb0b887a..b2e715023d 100644
--- a/drivers/block/dwc_ahci.c
+++ b/drivers/block/dwc_ahci.c
@@ -36,10 +36,10 @@ static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
 	plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
 					"max-lun", CONFIG_SYS_SCSI_MAX_LUN);
 
-	priv->base = map_physmem(dev_get_addr(dev), sizeof(void *),
+	priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
 				 MAP_NOCACHE);
 
-	addr = dev_get_addr_index(dev, 1);
+	addr = devfdt_get_addr_index(dev, 1);
 	if (addr != FDT_ADDR_T_NONE) {
 		priv->wrapper_base = map_physmem(addr, sizeof(void *),
 						 MAP_NOCACHE);
diff --git a/drivers/block/sata_ceva.c b/drivers/block/sata_ceva.c
index 9b5466483a..65a4bb2099 100644
--- a/drivers/block/sata_ceva.c
+++ b/drivers/block/sata_ceva.c
@@ -129,7 +129,7 @@ static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
 	struct scsi_platdata *plat = dev_get_platdata(dev);
 
-	plat->base = dev_get_addr(dev);
+	plat->base = devfdt_get_addr(dev);
 	if (plat->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c
index 26a5e58221..7c314bf335 100644
--- a/drivers/clk/aspeed/clk_ast2500.c
+++ b/drivers/clk/aspeed/clk_ast2500.c
@@ -230,7 +230,7 @@ static int ast2500_clk_probe(struct udevice *dev)
 {
 	struct ast2500_clk_priv *priv = dev_get_priv(dev);
 
-	priv->scu = dev_get_addr_ptr(dev);
+	priv->scu = devfdt_get_addr_ptr(dev);
 	if (IS_ERR(priv->scu))
 		return PTR_ERR(priv->scu);
 
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 29067fa7bd..c552c75562 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -39,7 +39,7 @@ int at91_pmc_core_probe(struct udevice *dev)
 
 	dev = dev_get_parent(dev);
 
-	plat->reg_base = (struct at91_pmc *)dev_get_addr_ptr(dev);
+	plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev);
 
 	return 0;
 }
@@ -114,7 +114,7 @@ int at91_clk_probe(struct udevice *dev)
 	dev_periph_container = dev_get_parent(dev);
 	dev_pmc = dev_get_parent(dev_periph_container);
 
-	plat->reg_base = (struct at91_pmc *)dev_get_addr_ptr(dev_pmc);
+	plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev_pmc);
 
 	return 0;
 }
diff --git a/drivers/clk/exynos/clk-exynos7420.c b/drivers/clk/exynos/clk-exynos7420.c
index 1f017a307f..e34945dbbc 100644
--- a/drivers/clk/exynos/clk-exynos7420.c
+++ b/drivers/clk/exynos/clk-exynos7420.c
@@ -98,7 +98,7 @@ static int exynos7420_clk_topc_probe(struct udevice *dev)
 	fdt_addr_t base;
 	int ret;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
@@ -152,7 +152,7 @@ static int exynos7420_clk_top0_probe(struct udevice *dev)
 	if (!priv)
 		return -EINVAL;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/clk/rockchip/clk_rk3036.c b/drivers/clk/rockchip/clk_rk3036.c
index 7e3bf96944..e7625a1251 100644
--- a/drivers/clk/rockchip/clk_rk3036.c
+++ b/drivers/clk/rockchip/clk_rk3036.c
@@ -326,7 +326,7 @@ static int rk3036_clk_probe(struct udevice *dev)
 {
 	struct rk3036_clk_priv *priv = dev_get_priv(dev);
 
-	priv->cru = (struct rk3036_cru *)dev_get_addr(dev);
+	priv->cru = (struct rk3036_cru *)devfdt_get_addr(dev);
 	rkclk_init(priv->cru);
 
 	return 0;
diff --git a/drivers/clk/rockchip/clk_rk3188.c b/drivers/clk/rockchip/clk_rk3188.c
index d36cf8f3f2..d2e8aea6b7 100644
--- a/drivers/clk/rockchip/clk_rk3188.c
+++ b/drivers/clk/rockchip/clk_rk3188.c
@@ -530,7 +530,7 @@ static int rk3188_clk_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3188_clk_priv *priv = dev_get_priv(dev);
 
-	priv->cru = (struct rk3188_cru *)dev_get_addr(dev);
+	priv->cru = (struct rk3188_cru *)devfdt_get_addr(dev);
 #endif
 
 	return 0;
diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c
index 78356766a7..c5dc14e9a6 100644
--- a/drivers/clk/rockchip/clk_rk3288.c
+++ b/drivers/clk/rockchip/clk_rk3288.c
@@ -782,7 +782,7 @@ static int rk3288_clk_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3288_clk_priv *priv = dev_get_priv(dev);
 
-	priv->cru = (struct rk3288_cru *)dev_get_addr(dev);
+	priv->cru = (struct rk3288_cru *)devfdt_get_addr(dev);
 #endif
 
 	return 0;
diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c
index 0ff1e30bb5..699e0b6c7a 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -547,7 +547,7 @@ static int rk3328_clk_ofdata_to_platdata(struct udevice *dev)
 {
 	struct rk3328_clk_priv *priv = dev_get_priv(dev);
 
-	priv->cru = (struct rk3328_cru *)dev_get_addr(dev);
+	priv->cru = (struct rk3328_cru *)devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c
index ff3cc37af3..f20b61add3 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -853,7 +853,7 @@ static int rk3399_clk_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3399_clk_priv *priv = dev_get_priv(dev);
 
-	priv->cru = (struct rk3399_cru *)dev_get_addr(dev);
+	priv->cru = (struct rk3399_cru *)devfdt_get_addr(dev);
 #endif
 	return 0;
 }
@@ -1037,7 +1037,7 @@ static int rk3399_pmuclk_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3399_pmuclk_priv *priv = dev_get_priv(dev);
 
-	priv->pmucru = (struct rk3399_pmucru *)dev_get_addr(dev);
+	priv->pmucru = (struct rk3399_pmucru *)devfdt_get_addr(dev);
 #endif
 	return 0;
 }
diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c
index c53dd911f1..d88bd62812 100644
--- a/drivers/clk/uniphier/clk-uniphier-core.c
+++ b/drivers/clk/uniphier/clk-uniphier-core.c
@@ -132,7 +132,7 @@ static int uniphier_clk_probe(struct udevice *dev)
 	struct uniphier_clk_priv *priv = dev_get_priv(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev->parent);
+	addr = devfdt_get_addr(dev->parent);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
index a0578feb1b..3847dd836e 100644
--- a/drivers/core/fdtaddr.c
+++ b/drivers/core/fdtaddr.c
@@ -17,7 +17,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
+fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	fdt_addr_t addr;
@@ -74,7 +74,7 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
 	 * Some platforms need a special address translation. Those
 	 * platforms (e.g. mvebu in SPL) can configure a translation
 	 * offset in the DM by calling dm_set_translation_offset() that
-	 * will get added to all addresses returned by dev_get_addr().
+	 * will get added to all addresses returned by devfdt_get_addr().
 	 */
 	addr += dm_get_translation_offset();
 
@@ -84,7 +84,7 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
 #endif
 }
 
-fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
+fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
 				   fdt_size_t *size)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
@@ -100,13 +100,13 @@ fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
 	 * Get the base address via the existing function which handles
 	 * all Kconfig cases
 	 */
-	return dev_get_addr_index(dev, index);
+	return devfdt_get_addr_index(dev, index);
 #else
 	return FDT_ADDR_T_NONE;
 #endif
 }
 
-fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
+fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 	int index;
@@ -116,25 +116,25 @@ fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
 	if (index < 0)
 		return index;
 
-	return dev_get_addr_index(dev, index);
+	return devfdt_get_addr_index(dev, index);
 #else
 	return FDT_ADDR_T_NONE;
 #endif
 }
 
-fdt_addr_t dev_get_addr(struct udevice *dev)
+fdt_addr_t devfdt_get_addr(struct udevice *dev)
 {
-	return dev_get_addr_index(dev, 0);
+	return devfdt_get_addr_index(dev, 0);
 }
 
-void *dev_get_addr_ptr(struct udevice *dev)
+void *devfdt_get_addr_ptr(struct udevice *dev)
 {
-	return (void *)(uintptr_t)dev_get_addr_index(dev, 0);
+	return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0);
 }
 
-void *dev_map_physmem(struct udevice *dev, unsigned long size)
+void *devfdt_map_physmem(struct udevice *dev, unsigned long size)
 {
-	fdt_addr_t addr = dev_get_addr(dev);
+	fdt_addr_t addr = devfdt_get_addr(dev);
 
 	if (addr == FDT_ADDR_T_NONE)
 		return NULL;
diff --git a/drivers/dma/ti-edma3.c b/drivers/dma/ti-edma3.c
index 645aa2c4ae..39e9793013 100644
--- a/drivers/dma/ti-edma3.c
+++ b/drivers/dma/ti-edma3.c
@@ -505,7 +505,7 @@ static int ti_edma3_ofdata_to_platdata(struct udevice *dev)
 {
 	struct ti_edma3_priv *priv = dev_get_priv(dev);
 
-	priv->base = dev_get_addr(dev);
+	priv->base = devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c
index 92849c5295..d17245ac23 100644
--- a/drivers/gpio/altera_pio.c
+++ b/drivers/gpio/altera_pio.c
@@ -89,7 +89,7 @@ static int altera_pio_ofdata_to_platdata(struct udevice *dev)
 {
 	struct altera_pio_platdata *plat = dev_get_platdata(dev);
 
-	plat->regs = map_physmem(dev_get_addr(dev),
+	plat->regs = map_physmem(devfdt_get_addr(dev),
 				 sizeof(struct altera_pio_regs),
 				 MAP_NOCACHE);
 	plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 98dbd8210e..174d5610aa 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -587,7 +587,7 @@ static int at91_gpio_probe(struct udevice *dev)
 	uc_priv->gpio_count = GPIO_PER_BANK;
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-	plat->base_addr = (uint32_t)dev_get_addr_ptr(dev);
+	plat->base_addr = (uint32_t)devfdt_get_addr_ptr(dev);
 #endif
 	port->regs = (struct at91_port *)plat->base_addr;
 
diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index 81c3047551..73a5c54bef 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -299,7 +299,7 @@ static int atmel_pio4_probe(struct udevice *dev)
 
 	clk_free(&clk);
 
-	addr_base = dev_get_addr(dev);
+	addr_base = devfdt_get_addr(dev);
 	if (addr_base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c
index cd5480ee09..beaa21853a 100644
--- a/drivers/gpio/bcm2835_gpio.c
+++ b/drivers/gpio/bcm2835_gpio.c
@@ -130,7 +130,7 @@ static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev)
 	struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index a10116c215..c11e95355b 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -95,7 +95,7 @@ static int uniphier_gpio_probe(struct udevice *dev)
 	fdt_addr_t addr;
 	unsigned int tmp;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
index 886b16188e..5abc88ba54 100644
--- a/drivers/gpio/imx_rgpio2p.c
+++ b/drivers/gpio/imx_rgpio2p.c
@@ -166,7 +166,7 @@ static int imx_rgpio2p_bind(struct udevice *dev)
 	if (plat)
 		return 0;
 
-	addr = dev_get_addr_index(dev, 1);
+	addr = devfdt_get_addr_index(dev, 1);
 	if (addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c
index 01ce1d6fa0..ff38fc5bd3 100644
--- a/drivers/gpio/msm_gpio.c
+++ b/drivers/gpio/msm_gpio.c
@@ -97,7 +97,7 @@ static int msm_gpio_probe(struct udevice *dev)
 {
 	struct msm_gpio_bank *priv = dev_get_priv(dev);
 
-	priv->base = dev_get_addr(dev);
+	priv->base = devfdt_get_addr(dev);
 
 	return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0;
 }
diff --git a/drivers/gpio/mvebu_gpio.c b/drivers/gpio/mvebu_gpio.c
index 75dc73e586..85dea14c51 100644
--- a/drivers/gpio/mvebu_gpio.c
+++ b/drivers/gpio/mvebu_gpio.c
@@ -92,7 +92,7 @@ static int mvebu_gpio_probe(struct udevice *dev)
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 	struct mvebu_gpio_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct mvebu_gpio_regs *)dev_get_addr(dev);
+	priv->regs = (struct mvebu_gpio_regs *)devfdt_get_addr(dev);
 	uc_priv->gpio_count = MVEBU_GPIOS_PER_BANK;
 	priv->name[0] = 'A' + dev->req_seq;
 	uc_priv->bank_name = priv->name;
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 70fe5b6a4e..0eb6c600f1 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -302,7 +302,7 @@ static int mxc_gpio_bind(struct udevice *dev)
 	if (plat)
 		return 0;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 5338552179..b423e34ca4 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -305,7 +305,7 @@ static int omap_gpio_bind(struct udevice *dev)
 	if (plat)
 		return 0;
 
-	base_addr = dev_get_addr(dev);
+	base_addr = devfdt_get_addr(dev);
 	if (base_addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c
index e38cee8869..8dea69f281 100644
--- a/drivers/gpio/pm8916_gpio.c
+++ b/drivers/gpio/pm8916_gpio.c
@@ -173,7 +173,7 @@ static int pm8916_gpio_probe(struct udevice *dev)
 	struct pm8916_gpio_bank *priv = dev_get_priv(dev);
 	int reg;
 
-	priv->pid = dev_get_addr(dev);
+	priv->pid = devfdt_get_addr(dev);
 	if (priv->pid == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
@@ -259,7 +259,7 @@ static int pm8941_pwrkey_probe(struct udevice *dev)
 	struct pm8916_gpio_bank *priv = dev_get_priv(dev);
 	int reg;
 
-	priv->pid = dev_get_addr(dev);
+	priv->pid = devfdt_get_addr(dev);
 	if (priv->pid == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index 5dbd228203..6f7366acba 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -104,7 +104,7 @@ static int rockchip_gpio_probe(struct udevice *dev)
 	int ret;
 
 	/* This only supports RK3288 at present */
-	priv->regs = (struct rockchip_gpio_regs *)dev_get_addr(dev);
+	priv->regs = (struct rockchip_gpio_regs *)devfdt_get_addr(dev);
 	ret = uclass_first_device_err(UCLASS_PINCTRL, &priv->pinctrl);
 	if (ret)
 		return ret;
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 042996e559..5c894a26d7 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -316,7 +316,7 @@ static int gpio_exynos_bind(struct udevice *parent)
 	if (plat)
 		return 0;
 
-	base = (struct s5p_gpio_bank *)dev_get_addr(parent);
+	base = (struct s5p_gpio_bank *)devfdt_get_addr(parent);
 	for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base;
 	     node > 0;
 	     node = fdt_next_subnode(blob, node), bank++) {
@@ -339,7 +339,7 @@ static int gpio_exynos_bind(struct udevice *parent)
 
 		dev_set_of_offset(dev, node);
 
-		reg = dev_get_addr(dev);
+		reg = devfdt_get_addr(dev);
 		if (reg != FDT_ADDR_T_NONE)
 			bank = (struct s5p_gpio_bank *)((ulong)base + reg);
 
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 3f40e83830..f0c9ea0794 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -296,7 +296,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
 	if (plat)
 		return 0;
 
-	ctlr = (struct sunxi_gpio_reg *)dev_get_addr(parent);
+	ctlr = (struct sunxi_gpio_reg *)devfdt_get_addr(parent);
 	for (bank = 0; bank < soc_data->no_banks; bank++) {
 		struct sunxi_gpio_platdata *plat;
 		struct udevice *dev;
diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c
index b0c22e5bfe..cb2524e9bf 100644
--- a/drivers/gpio/tegra186_gpio.c
+++ b/drivers/gpio/tegra186_gpio.c
@@ -179,7 +179,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
 	if (parent_plat)
 		return 0;
 
-	regs = (uint32_t *)dev_get_addr_name(parent, "gpio");
+	regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio");
 	if (regs == (uint32_t *)FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
index b01968a304..fb79f7fa58 100644
--- a/drivers/gpio/tegra_gpio.c
+++ b/drivers/gpio/tegra_gpio.c
@@ -341,7 +341,7 @@ static int gpio_tegra_bind(struct udevice *parent)
 			 &len))
 		return -EINVAL;
 	bank_count = len / 3 / sizeof(u32);
-	ctlr = (struct gpio_ctlr *)dev_get_addr(parent);
+	ctlr = (struct gpio_ctlr *)devfdt_get_addr(parent);
 	}
 #endif
 	for (bank = 0; bank < bank_count; bank++) {
diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c
index 458104e8b0..b7a1b6a45b 100644
--- a/drivers/gpio/vybrid_gpio.c
+++ b/drivers/gpio/vybrid_gpio.c
@@ -113,7 +113,7 @@ static int vybrid_gpio_bind(struct udevice *dev)
 	if (plat)
 		return 0;
 
-	base_addr = dev_get_addr(dev);
+	base_addr = devfdt_get_addr(dev);
 	if (base_addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/gpio/zynq_gpio.c b/drivers/gpio/zynq_gpio.c
index 64579a1b6c..4cb75a8627 100644
--- a/drivers/gpio/zynq_gpio.c
+++ b/drivers/gpio/zynq_gpio.c
@@ -375,7 +375,7 @@ static int zynq_gpio_ofdata_to_platdata(struct udevice *dev)
 {
 	struct zynq_gpio_privdata *priv = dev_get_priv(dev);
 
-	priv->base = dev_get_addr(dev);
+	priv->base = devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 4e9afc120a..a8d0aa68d4 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -125,7 +125,6 @@ config SYS_I2C_INTEL
 
 config SYS_I2C_IMX_LPI2C
 	bool "NXP i.MX LPI2C driver"
-	depends on ARCH_MX7ULP
 	help
 	  Add support for the NXP i.MX LPI2C driver.
 
diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
index 5a636697a5..b7298cf774 100644
--- a/drivers/i2c/at91_i2c.c
+++ b/drivers/i2c/at91_i2c.c
@@ -244,7 +244,7 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev)
 	struct at91_i2c_bus *bus = dev_get_priv(dev);
 	int node = dev_of_offset(dev);
 
-	bus->regs = (struct at91_i2c_regs *)dev_get_addr(dev);
+	bus->regs = (struct at91_i2c_regs *)devfdt_get_addr(dev);
 	bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev);
 	bus->clock_frequency = fdtdec_get_int(blob, node,
 					      "clock-frequency", 100000);
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index c68ff6420b..d4df35a69a 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -545,7 +545,7 @@ static int designware_i2c_probe(struct udevice *bus)
 #endif
 #endif
 	} else {
-		priv->regs = (struct i2c_regs *)dev_get_addr_ptr(bus);
+		priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
 	}
 
 	__dw_i2c_init(priv->regs, 0, 0);
diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c
index 2dd75fd154..9f4ac2fc9a 100644
--- a/drivers/i2c/exynos_hs_i2c.c
+++ b/drivers/i2c/exynos_hs_i2c.c
@@ -524,7 +524,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
 
 	node = dev_of_offset(dev);
 
-	i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev);
+	i2c_bus->hsregs = (struct exynos5_hsi2c *)devfdt_get_addr(dev);
 
 	i2c_bus->id = pinmux_decode_periph_id(blob, node);
 
diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index db37444108..8265ce3210 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -419,7 +419,7 @@ static int cdns_i2c_ofdata_to_platdata(struct udevice *dev)
 	struct cdns_i2c_platform_data *pdata =
 		(struct cdns_i2c_platform_data *)dev_get_driver_data(dev);
 
-	i2c_bus->regs = (struct cdns_i2c_regs *)dev_get_addr(dev);
+	i2c_bus->regs = (struct cdns_i2c_regs *)devfdt_get_addr(dev);
 	if (!i2c_bus->regs)
 		return -ENOMEM;
 
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
index be9fc8afc9..e51537b80e 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -104,7 +104,7 @@ static int uniphier_fi2c_probe(struct udevice *dev)
 	struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
 	int ret;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
index 75d1c4cad8..3412e2a189 100644
--- a/drivers/i2c/i2c-uniphier.c
+++ b/drivers/i2c/i2c-uniphier.c
@@ -49,7 +49,7 @@ static int uniphier_i2c_probe(struct udevice *dev)
 	fdt_addr_t addr;
 	struct uniphier_i2c_dev *priv = dev_get_priv(dev);
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index f792d4432d..aa97196e23 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -25,9 +25,8 @@ int __weak init_i2c_power(unsigned i2c_num)
 	return 0;
 }
 
-static int imx_lpci2c_check_busy_bus(struct udevice *bus)
+static int imx_lpci2c_check_busy_bus(const struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 status;
 
@@ -39,9 +38,8 @@ static int imx_lpci2c_check_busy_bus(struct udevice *bus)
 	return result;
 }
 
-static int imx_lpci2c_check_clear_error(struct udevice *bus)
+static int imx_lpci2c_check_clear_error(struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 val, status;
 
@@ -71,9 +69,8 @@ static int imx_lpci2c_check_clear_error(struct udevice *bus)
 	return result;
 }
 
-static int bus_i2c_wait_for_tx_ready(struct udevice *bus)
+static int bus_i2c_wait_for_tx_ready(struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 txcount = 0;
 	ulong start_time = get_timer(0);
@@ -81,7 +78,7 @@ static int bus_i2c_wait_for_tx_ready(struct udevice *bus)
 	do {
 		txcount = LPI2C_MFSR_TXCOUNT(readl(&regs->mfsr));
 		txcount = LPI2C_FIFO_SIZE - txcount;
-		result = imx_lpci2c_check_clear_error(bus);
+		result = imx_lpci2c_check_clear_error(regs);
 		if (result) {
 			debug("i2c: wait for tx ready: result 0x%x\n", result);
 			return result;
@@ -95,9 +92,8 @@ static int bus_i2c_wait_for_tx_ready(struct udevice *bus)
 	return result;
 }
 
-static int bus_i2c_send(struct udevice *bus, u8 *txbuf, int len)
+static int bus_i2c_send(struct imx_lpi2c_reg *regs, u8 *txbuf, int len)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 
 	/* empty tx */
@@ -105,7 +101,7 @@ static int bus_i2c_send(struct udevice *bus, u8 *txbuf, int len)
 		return result;
 
 	while (len--) {
-		result = bus_i2c_wait_for_tx_ready(bus);
+		result = bus_i2c_wait_for_tx_ready(regs);
 		if (result) {
 			debug("i2c: send wait fot tx ready: %d\n", result);
 			return result;
@@ -116,9 +112,8 @@ static int bus_i2c_send(struct udevice *bus, u8 *txbuf, int len)
 	return result;
 }
 
-static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
+static int bus_i2c_receive(struct imx_lpi2c_reg *regs, u8 *rxbuf, int len)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 val;
 	ulong start_time = get_timer(0);
@@ -127,7 +122,7 @@ static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
 	if (!len)
 		return result;
 
-	result = bus_i2c_wait_for_tx_ready(bus);
+	result = bus_i2c_wait_for_tx_ready(regs);
 	if (result) {
 		debug("i2c: receive wait fot tx ready: %d\n", result);
 		return result;
@@ -141,9 +136,10 @@ static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
 
 	while (len--) {
 		do {
-			result = imx_lpci2c_check_clear_error(bus);
+			result = imx_lpci2c_check_clear_error(regs);
 			if (result) {
-				debug("i2c: receive check clear error: %d\n", result);
+				debug("i2c: receive check clear error: %d\n",
+				      result);
 				return result;
 			}
 			if (get_timer(start_time) > LPI2C_TIMEOUT_MS) {
@@ -158,13 +154,12 @@ static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len)
 	return result;
 }
 
-static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir)
+static int bus_i2c_start(struct imx_lpi2c_reg *regs, u8 addr, u8 dir)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 val;
 
-	result = imx_lpci2c_check_busy_bus(bus);
+	result = imx_lpci2c_check_busy_bus(regs);
 	if (result) {
 		debug("i2c: start check busy bus: 0x%x\n", result);
 		return result;
@@ -175,7 +170,7 @@ static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir)
 	val = readl(&regs->mcfgr1) & ~LPI2C_MCFGR1_AUTOSTOP_MASK;
 	writel(val, &regs->mcfgr1);
 	/* wait tx fifo ready */
-	result = bus_i2c_wait_for_tx_ready(bus);
+	result = bus_i2c_wait_for_tx_ready(regs);
 	if (result) {
 		debug("i2c: start wait for tx ready: 0x%x\n", result);
 		return result;
@@ -186,13 +181,13 @@ static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir)
 
 	return result;
 }
-static int bus_i2c_stop(struct udevice *bus)
+
+static int bus_i2c_stop(struct imx_lpi2c_reg *regs)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
 	lpi2c_status_t result = LPI2C_SUCESS;
 	u32 status;
 
-	result = bus_i2c_wait_for_tx_ready(bus);
+	result = bus_i2c_wait_for_tx_ready(regs);
 	if (result) {
 		debug("i2c: stop wait for tx ready: 0x%x\n", result);
 		return result;
@@ -203,7 +198,7 @@ static int bus_i2c_stop(struct udevice *bus)
 
 	while (result == LPI2C_SUCESS) {
 		status = readl(&regs->msr);
-		result = imx_lpci2c_check_clear_error(bus);
+		result = imx_lpci2c_check_clear_error(regs);
 		/* stop detect flag */
 		if (status & LPI2C_MSR_SDF_MASK) {
 			/* clear stop flag */
@@ -216,34 +211,34 @@ static int bus_i2c_stop(struct udevice *bus)
 	return result;
 }
 
-static int bus_i2c_read(struct udevice *bus, u32 chip, u8 *buf, int len)
+static int bus_i2c_read(struct imx_lpi2c_reg *regs, u32 chip, u8 *buf, int len)
 {
 	lpi2c_status_t result = LPI2C_SUCESS;
 
-	result = bus_i2c_start(bus, chip, 1);
+	result = bus_i2c_start(regs, chip, 1);
 	if (result)
 		return result;
-	result = bus_i2c_receive(bus, buf, len);
+	result = bus_i2c_receive(regs, buf, len);
 	if (result)
 		return result;
-	result = bus_i2c_stop(bus);
+	result = bus_i2c_stop(regs);
 	if (result)
 		return result;
 
 	return result;
 }
 
-static int bus_i2c_write(struct udevice *bus, u32 chip, u8 *buf, int len)
+static int bus_i2c_write(struct imx_lpi2c_reg *regs, u32 chip, u8 *buf, int len)
 {
 	lpi2c_status_t result = LPI2C_SUCESS;
 
-	result = bus_i2c_start(bus, chip, 0);
+	result = bus_i2c_start(regs, chip, 0);
 	if (result)
 		return result;
-	result = bus_i2c_send(bus, buf, len);
+	result = bus_i2c_send(regs, buf, len);
 	if (result)
 		return result;
-	result = bus_i2c_stop(bus);
+	result = bus_i2c_stop(regs);
 	if (result)
 		return result;
 
@@ -253,7 +248,7 @@ static int bus_i2c_write(struct udevice *bus, u32 chip, u8 *buf, int len)
 
 static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
+	struct imx_lpi2c_reg *regs;
 	u32 val;
 	u32 preescale = 0, best_pre = 0, clkhi = 0;
 	u32 best_clkhi = 0, abs_error = 0, rate;
@@ -262,6 +257,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
 	bool mode;
 	int i;
 
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
 	clock_rate = imx_get_i2cclk(bus->seq + 4);
 	if (!clock_rate)
 		return -EPERM;
@@ -320,10 +316,11 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
 
 static int bus_i2c_init(struct udevice *bus, int speed)
 {
-	struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)dev_get_addr(bus);
+	struct imx_lpi2c_reg *regs;
 	u32 val;
 	int ret;
 
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
 	/* reset peripheral */
 	writel(LPI2C_MCR_RST_MASK, &regs->mcr);
 	writel(0x0, &regs->mcr);
@@ -356,16 +353,18 @@ static int bus_i2c_init(struct udevice *bus, int speed)
 static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip,
 				u32 chip_flags)
 {
+	struct imx_lpi2c_reg *regs;
 	lpi2c_status_t result = LPI2C_SUCESS;
 
-	result = bus_i2c_start(bus, chip, 0);
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
+	result = bus_i2c_start(regs, chip, 0);
 	if (result) {
-		bus_i2c_stop(bus);
+		bus_i2c_stop(regs);
 		bus_i2c_init(bus, 100000);
 		return result;
 	}
 
-	result = bus_i2c_stop(bus);
+	result = bus_i2c_stop(regs);
 	if (result) {
 		bus_i2c_init(bus, 100000);
 		return -result;
@@ -376,15 +375,16 @@ static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip,
 
 static int imx_lpi2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
 {
+	struct imx_lpi2c_reg *regs;
 	int ret = 0;
 
+	regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
 	for (; nmsgs > 0; nmsgs--, msg++) {
 		debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
 		if (msg->flags & I2C_M_RD)
-			ret = bus_i2c_read(bus, msg->addr, msg->buf,
-					   msg->len);
+			ret = bus_i2c_read(regs, msg->addr, msg->buf, msg->len);
 		else {
-			ret = bus_i2c_write(bus, msg->addr, msg->buf,
+			ret = bus_i2c_write(regs, msg->addr, msg->buf,
 					    msg->len);
 			if (ret)
 				break;
@@ -410,7 +410,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
 
 	i2c_bus->driver_data = dev_get_driver_data(bus);
 
-	addr = dev_get_addr(bus);
+	addr = devfdt_get_addr(bus);
 	if (addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index c78027239f..913721b987 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -579,7 +579,7 @@ static int mv_i2c_probe(struct udevice *bus)
 {
 	struct mv_i2c_priv *priv = dev_get_priv(bus);
 
-	priv->base = (void *)dev_get_addr_ptr(bus);
+	priv->base = (void *)devfdt_get_addr_ptr(bus);
 
 	return 0;
 }
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 648a96eeb4..d17f8cc0f4 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -770,7 +770,7 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus)
 {
 	struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
 
-	dev->base = dev_get_addr_ptr(bus);
+	dev->base = devfdt_get_addr_ptr(bus);
 
 	if (!dev->base)
 		return -ENOMEM;
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 13ec0e63b1..6fc11e74aa 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -756,7 +756,7 @@ static int mxc_i2c_probe(struct udevice *bus)
 
 	i2c_bus->driver_data = dev_get_driver_data(bus);
 
-	addr = dev_get_addr(bus);
+	addr = devfdt_get_addr(bus);
 	if (addr == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index 26996e9db9..9dfce8d942 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -896,7 +896,7 @@ static int omap_i2c_ofdata_to_platdata(struct udevice *bus)
 {
 	struct omap_i2c *priv = dev_get_priv(bus);
 
-	priv->regs = map_physmem(dev_get_addr(bus), sizeof(void *),
+	priv->regs = map_physmem(devfdt_get_addr(bus), sizeof(void *),
 				 MAP_NOCACHE);
 	priv->speed = CONFIG_SYS_OMAP24_I2C_SPEED;
 
diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
index 76f41f7e85..8bc045a1a0 100644
--- a/drivers/i2c/rk_i2c.c
+++ b/drivers/i2c/rk_i2c.c
@@ -369,7 +369,7 @@ static int rockchip_i2c_probe(struct udevice *bus)
 {
 	struct rk_i2c *priv = dev_get_priv(bus);
 
-	priv->regs = (void *)dev_get_addr(bus);
+	priv->regs = (void *)devfdt_get_addr(bus);
 
 	return 0;
 }
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 3c69dbf409..06fe0a51f3 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -314,7 +314,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
 
 	node = dev_of_offset(dev);
 
-	i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev);
+	i2c_bus->regs = (struct s3c24x0_i2c *)devfdt_get_addr(dev);
 
 	i2c_bus->id = pinmux_decode_periph_id(blob, node);
 
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 898f12a946..055f48153a 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -365,7 +365,7 @@ static int tegra_i2c_probe(struct udevice *dev)
 
 	i2c_bus->id = dev->seq;
 	i2c_bus->type = dev_get_driver_data(dev);
-	i2c_bus->regs = (struct i2c_ctlr *)dev_get_addr(dev);
+	i2c_bus->regs = (struct i2c_ctlr *)devfdt_get_addr(dev);
 
 	ret = reset_get_by_name(dev, "i2c", &i2c_bus->reset_ctl);
 	if (ret) {
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index d36f1a1dfa..836aba1f1b 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -293,7 +293,7 @@ static int tegra_kbd_probe(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	int ret;
 
-	priv->kbc = (struct kbc_tegra *)dev_get_addr(dev);
+	priv->kbc = (struct kbc_tegra *)devfdt_get_addr(dev);
 	if ((fdt_addr_t)priv->kbc == FDT_ADDR_T_NONE) {
 		debug("%s: No keyboard register found\n", __func__);
 		return -EINVAL;
diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c
index 3d0362d587..b546ba2471 100644
--- a/drivers/mailbox/tegra-hsp.c
+++ b/drivers/mailbox/tegra-hsp.c
@@ -153,7 +153,7 @@ static int tegra_hsp_probe(struct udevice *dev)
 
 	debug("%s(dev=%p)\n", __func__, dev);
 
-	thsp->regs = dev_get_addr(dev);
+	thsp->regs = devfdt_get_addr(dev);
 	if (thsp->regs == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c
index ed6d462c95..87aadaf24f 100644
--- a/drivers/misc/altera_sysid.c
+++ b/drivers/misc/altera_sysid.c
@@ -74,7 +74,7 @@ static int altera_sysid_ofdata_to_platdata(struct udevice *dev)
 {
 	struct altera_sysid_platdata *plat = dev_get_platdata(dev);
 
-	plat->regs = map_physmem(dev_get_addr(dev),
+	plat->regs = map_physmem(devfdt_get_addr(dev),
 				 sizeof(struct altera_sysid_regs),
 				 MAP_NOCACHE);
 
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
index 852255782f..4302fb9518 100644
--- a/drivers/mmc/atmel_sdhci.c
+++ b/drivers/mmc/atmel_sdhci.c
@@ -72,7 +72,7 @@ static int atmel_sdhci_probe(struct udevice *dev)
 		return ret;
 
 	host->name = dev->name;
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 
 	host->quirks = 0;
 	host->bus_width	= fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index f3c63585a8..3b3110f58b 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -963,7 +963,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
 	unsigned int val;
 	int ret;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
index d883da30a1..e9f061e55d 100644
--- a/drivers/mmc/gen_atmel_mci.c
+++ b/drivers/mmc/gen_atmel_mci.c
@@ -576,7 +576,7 @@ static int atmel_mci_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	priv->mci = (struct atmel_mci *)dev_get_addr_ptr(dev);
+	priv->mci = (struct atmel_mci *)devfdt_get_addr_ptr(dev);
 
 	atmel_mci_setup_cfg(priv);
 
diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index 12da42d003..96a9fc8019 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -221,7 +221,7 @@ static int meson_mmc_ofdata_to_platdata(struct udevice *dev)
 	struct meson_mmc_platdata *pdata = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index 7a7e67f6f3..9117ab6bf9 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -171,7 +171,7 @@ static int msm_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 
 	host->name = strdup(dev->name);
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 	host->bus_width = fdtdec_get_int(gd->fdt_blob, node, "bus-width", 4);
 	host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0);
 	priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 83dda09c1f..82ed2b0240 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -782,8 +782,8 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	int val;
 
-	priv->base_addr = map_physmem(dev_get_addr(dev), sizeof(struct hsmmc *),
-				      MAP_NOCACHE);
+	priv->base_addr = map_physmem(devfdt_get_addr(dev),
+				      sizeof(struct hsmmc *), MAP_NOCACHE);
 
 	cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
 	val = fdtdec_get_int(fdt, node, "bus-width", -1);
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index c36eda05d2..4a0681ea32 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -58,7 +58,7 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
 	struct dwmci_host *host = &priv->host;
 
 	host->name = dev->name;
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 	host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"bus-width", 4);
 	host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index bdde831ffd..8985878d7e 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -83,7 +83,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
 	struct sdhci_host *host = dev_get_priv(dev);
 
 	host->name = dev->name;
-	host->ioaddr = dev_get_addr_ptr(dev);
+	host->ioaddr = devfdt_get_addr_ptr(dev);
 #endif
 
 	return 0;
diff --git a/drivers/mmc/sdhci-cadence.c b/drivers/mmc/sdhci-cadence.c
index 6f3de3b6c3..f7b40ec653 100644
--- a/drivers/mmc/sdhci-cadence.c
+++ b/drivers/mmc/sdhci-cadence.c
@@ -82,7 +82,7 @@ static int sdhci_cdns_probe(struct udevice *dev)
 	fdt_addr_t base;
 	int ret;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
index d0c3c5155a..759686ccd6 100644
--- a/drivers/mmc/socfpga_dw_mmc.c
+++ b/drivers/mmc/socfpga_dw_mmc.c
@@ -78,7 +78,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
 	}
 
 	host->name = dev->name;
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 	host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					"bus-width", 4);
 	host->clksel = socfpga_dwmci_clksel;
diff --git a/drivers/mmc/sti_sdhci.c b/drivers/mmc/sti_sdhci.c
index 2a07082036..f85f6b4db6 100644
--- a/drivers/mmc/sti_sdhci.c
+++ b/drivers/mmc/sti_sdhci.c
@@ -108,7 +108,7 @@ static int sti_sdhci_ofdata_to_platdata(struct udevice *dev)
 	struct sdhci_host *host = dev_get_priv(dev);
 
 	host->name = strdup(dev->name);
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 
 	host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 					 "bus-width", 4);
diff --git a/drivers/mmc/tangier_sdhci.c b/drivers/mmc/tangier_sdhci.c
index 77b18e75f0..bafe85bf64 100644
--- a/drivers/mmc/tangier_sdhci.c
+++ b/drivers/mmc/tangier_sdhci.c
@@ -36,7 +36,7 @@ static int sdhci_tangier_probe(struct udevice *dev)
 	fdt_addr_t base;
 	int ret;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index 9037ffb381..cc70078984 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -616,7 +616,7 @@ static int tegra_mmc_probe(struct udevice *dev)
 
 	priv->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
-	priv->reg = (void *)dev_get_addr(dev);
+	priv->reg = (void *)devfdt_get_addr(dev);
 
 	ret = reset_get_by_name(dev, "sdhci", &priv->reset_ctl);
 	if (ret) {
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 195419ecda..3c462bd583 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -673,7 +673,7 @@ static int uniphier_sd_probe(struct udevice *dev)
 	struct clk clk;
 	int ret;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c
index 2a0d8b46c6..6cd176f9f8 100644
--- a/drivers/mmc/xenon_sdhci.c
+++ b/drivers/mmc/xenon_sdhci.c
@@ -452,10 +452,10 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev)
 	const char *name;
 
 	host->name = dev->name;
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 
 	if (of_device_is_compatible(dev, "marvell,armada-3700-sdhci"))
-		priv->pad_ctrl_reg = (void *)dev_get_addr_index(dev, 1);
+		priv->pad_ctrl_reg = (void *)devfdt_get_addr_index(dev, 1);
 
 	name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type",
 			   NULL);
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 28cedf0c46..70ad5734e1 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -81,7 +81,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
 	struct sdhci_host *host = dev_get_priv(dev);
 
 	host->name = dev->name;
-	host->ioaddr = (void *)dev_get_addr(dev);
+	host->ioaddr = (void *)devfdt_get_addr(dev);
 
 	plat->f_max = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
 				"max-frequency", CONFIG_ZYNQ_SDHCI_MAX_FREQ);
diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c
index f8782bcbd0..cf60d11475 100644
--- a/drivers/net/ag7xxx.c
+++ b/drivers/net/ag7xxx.c
@@ -941,7 +941,7 @@ static int ag7xxx_eth_ofdata_to_platdata(struct udevice *dev)
 	const char *phy_mode;
 	int ret;
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 	pdata->phy_interface = -1;
 
 	/* Decoding of convoluted PHY wiring on Atheros MIPS. */
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 5fbab9e492..778d2f5739 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -1293,7 +1293,7 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
 	int num_mode_gpios;
 	int ret;
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 	priv->data.version = CPSW_CTRL_VERSION_2;
 	priv->data.bd_ram_ofs = CPSW_BD_OFFSET;
 	priv->data.ale_reg_ofs = CPSW_ALE_OFFSET;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index f9fb8e0886..e3a194c2c0 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -726,7 +726,7 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
 #endif
 	int ret = 0;
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 	pdata->phy_interface = -1;
 	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
 			       NULL);
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 81eeba2e05..5c4315ffea 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -1452,9 +1452,9 @@ static int eqos_probe(struct udevice *dev)
 	eqos->dev = dev;
 	eqos->config = (void *)dev_get_driver_data(dev);
 
-	eqos->regs = dev_get_addr(dev);
+	eqos->regs = devfdt_get_addr(dev);
 	if (eqos->regs == FDT_ADDR_T_NONE) {
-		error("dev_get_addr() failed");
+		error("devfdt_get_addr() failed");
 		return -ENODEV;
 	}
 	eqos->mac_regs = (void *)(eqos->regs + EQOS_MAC_REGS_BASE);
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 2f4cad6791..a6df950081 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -689,8 +689,8 @@ static int ethoc_ofdata_to_platdata(struct udevice *dev)
 	struct ethoc_eth_pdata *pdata = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	pdata->eth_pdata.iobase = dev_get_addr(dev);
-	addr = dev_get_addr_index(dev, 1);
+	pdata->eth_pdata.iobase = devfdt_get_addr(dev);
+	addr = devfdt_get_addr_index(dev, 1);
 	if (addr != FDT_ADDR_T_NONE)
 		pdata->packet_base = addr;
 	return 0;
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 910879ba3e..e7c159ed4a 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1272,7 +1272,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
 	struct fec_priv *priv = dev_get_priv(dev);
 	const char *phy_mode;
 
-	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
+	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
 	priv->eth = (struct ethernet_regs *)pdata->iobase;
 
 	pdata->phy_interface = -1;
diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 1b781f4d95..f9ffd6d725 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -1134,7 +1134,7 @@ static int ks2_eth_ofdata_to_platdata(struct udevice *dev)
 
 	ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata);
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 21a620c244..bbbdb74e95 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1090,7 +1090,7 @@ static int macb_eth_ofdata_to_platdata(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 	return 0;
 }
 
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 8881cc77fe..af07b281e8 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1756,7 +1756,7 @@ static int mvneta_ofdata_to_platdata(struct udevice *dev)
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	const char *phy_mode;
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 
 	/* Get phy-mode / phy_interface from DT */
 	pdata->phy_interface = -1;
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 8ffe6c84d4..624a4b0818 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -5387,18 +5387,18 @@ static int mvpp2_base_probe(struct udevice *dev)
 	memset(bd_space, 0, size);
 
 	/* Save base addresses for later use */
-	priv->base = (void *)dev_get_addr_index(dev, 0);
+	priv->base = (void *)devfdt_get_addr_index(dev, 0);
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
 	if (priv->hw_version == MVPP21) {
-		priv->lms_base = (void *)dev_get_addr_index(dev, 1);
+		priv->lms_base = (void *)devfdt_get_addr_index(dev, 1);
 		if (IS_ERR(priv->lms_base))
 			return PTR_ERR(priv->lms_base);
 
 		priv->mdio_base = priv->lms_base + MVPP21_SMI;
 	} else {
-		priv->iface_base = (void *)dev_get_addr_index(dev, 1);
+		priv->iface_base = (void *)devfdt_get_addr_index(dev, 1);
 		if (IS_ERR(priv->iface_base))
 			return PTR_ERR(priv->iface_base);
 
@@ -5456,7 +5456,7 @@ static int mvpp2_probe(struct udevice *dev)
 	if (priv->hw_version == MVPP21) {
 		int priv_common_regs_num = 2;
 
-		port->base = (void __iomem *)dev_get_addr_index(
+		port->base = (void __iomem *)devfdt_get_addr_index(
 			dev->parent, priv_common_regs_num + port->id);
 		if (IS_ERR(port->base))
 			return PTR_ERR(port->base);
diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c
index 9742c2c4f6..f5fa0e8533 100644
--- a/drivers/net/sandbox-raw.c
+++ b/drivers/net/sandbox-raw.c
@@ -145,7 +145,7 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 	return 0;
 }
 
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
index 79d0ae68bf..59c57d1c6d 100644
--- a/drivers/net/sandbox.c
+++ b/drivers/net/sandbox.c
@@ -205,7 +205,7 @@ static int sb_eth_ofdata_to_platdata(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 	return 0;
 }
 
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index a3dbe2823b..d895d09a76 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -776,8 +776,8 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 	int ret = 0;
 #endif
 
-	pdata->iobase = dev_get_addr_name(dev, "emac");
-	priv->sysctl_reg = dev_get_addr_name(dev, "syscon");
+	pdata->iobase = devfdt_get_addr_name(dev, "emac");
+	priv->sysctl_reg = devfdt_get_addr_name(dev, "syscon");
 
 	pdata->phy_interface = -1;
 	priv->phyaddr = -1;
diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index 99339db4bf..37685f30f3 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -576,7 +576,7 @@ static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 
-	pdata->iobase = dev_get_addr(dev);
+	pdata->iobase = devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index f2ce4e2a8e..18e7a83d0f 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -780,7 +780,7 @@ int tsec_probe(struct udevice *dev)
 	const char *phy_mode;
 	int ret;
 
-	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
+	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
 	priv->regs = (struct tsec *)pdata->iobase;
 
 	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index a6f24b3cbe..25c66c6098 100644
--- a/drivers/net/xilinx_axi_emac.c
+++ b/drivers/net/xilinx_axi_emac.c
@@ -686,7 +686,7 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev)
 	int offset = 0;
 	const char *phy_mode;
 
-	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
+	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
 	priv->iobase = (struct axi_regs *)pdata->iobase;
 
 	offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 7d4e14f8ef..e3e58aeb83 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -598,7 +598,7 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev)
 	struct xemaclite *emaclite = dev_get_priv(dev);
 	int offset = 0;
 
-	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
+	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
 	emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase,
 								 0x10000);
 
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index 357f8c2917..1bb7fa576f 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -683,7 +683,7 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	const char *phy_mode;
 
-	pdata->iobase = (phys_addr_t)dev_get_addr(dev);
+	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
 	priv->iobase = (struct zynq_gem_regs *)pdata->iobase;
 	/* Hardcode for now */
 	priv->phyaddr = -1;
diff --git a/drivers/pci/pcie_dw_mvebu.c b/drivers/pci/pcie_dw_mvebu.c
index d4776a9c81..7161d57c0f 100644
--- a/drivers/pci/pcie_dw_mvebu.c
+++ b/drivers/pci/pcie_dw_mvebu.c
@@ -521,12 +521,12 @@ static int pcie_dw_mvebu_ofdata_to_platdata(struct udevice *dev)
 	struct pcie_dw_mvebu *pcie = dev_get_priv(dev);
 
 	/* Get the controller base address */
-	pcie->ctrl_base = (void *)dev_get_addr_index(dev, 0);
+	pcie->ctrl_base = (void *)devfdt_get_addr_index(dev, 0);
 	if ((fdt_addr_t)pcie->ctrl_base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
 	/* Get the config space base address and size */
-	pcie->cfg_base = (void *)dev_get_addr_size_index(dev, 1,
+	pcie->cfg_base = (void *)devfdt_get_addr_size_index(dev, 1,
 							 &pcie->cfg_size);
 	if ((fdt_addr_t)pcie->cfg_base == FDT_ADDR_T_NONE)
 		return -EINVAL;
diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c
index caa1928f07..81dfbe4dda 100644
--- a/drivers/phy/marvell/comphy_core.c
+++ b/drivers/phy/marvell/comphy_core.c
@@ -115,11 +115,11 @@ static int comphy_probe(struct udevice *dev)
 	int last_idx = 0;
 
 	/* Save base addresses for later use */
-	chip_cfg->comphy_base_addr = (void *)dev_get_addr_index(dev, 0);
+	chip_cfg->comphy_base_addr = (void *)devfdt_get_addr_index(dev, 0);
 	if (IS_ERR(chip_cfg->comphy_base_addr))
 		return PTR_ERR(chip_cfg->comphy_base_addr);
 
-	chip_cfg->hpipe3_base_addr = (void *)dev_get_addr_index(dev, 1);
+	chip_cfg->hpipe3_base_addr = (void *)devfdt_get_addr_index(dev, 1);
 	if (IS_ERR(chip_cfg->hpipe3_base_addr))
 		return PTR_ERR(chip_cfg->hpipe3_base_addr);
 
diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c
index ed80f0ff0b..350dab72f8 100644
--- a/drivers/phy/ti-pipe3-phy.c
+++ b/drivers/phy/ti-pipe3-phy.c
@@ -316,7 +316,7 @@ static int pipe3_phy_probe(struct udevice *dev)
 	fdt_size_t sz;
 	struct omap_pipe3 *pipe3 = dev_get_priv(dev);
 
-	addr = dev_get_addr_size_index(dev, 2, &sz);
+	addr = devfdt_get_addr_size_index(dev, 2, &sz);
 	if (addr == FDT_ADDR_T_NONE) {
 		error("missing pll ctrl address\n");
 		return -EINVAL;
diff --git a/drivers/pinctrl/ath79/pinctrl_ar933x.c b/drivers/pinctrl/ath79/pinctrl_ar933x.c
index fccc7c4b06..83f4d5332a 100644
--- a/drivers/pinctrl/ath79/pinctrl_ar933x.c
+++ b/drivers/pinctrl/ath79/pinctrl_ar933x.c
@@ -111,7 +111,7 @@ static int ar933x_pinctrl_probe(struct udevice *dev)
 	struct ar933x_pinctrl_priv *priv = dev_get_priv(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/pinctrl/ath79/pinctrl_qca953x.c b/drivers/pinctrl/ath79/pinctrl_qca953x.c
index a7f8c7082e..abc0368593 100644
--- a/drivers/pinctrl/ath79/pinctrl_qca953x.c
+++ b/drivers/pinctrl/ath79/pinctrl_qca953x.c
@@ -131,7 +131,7 @@ static int qca953x_pinctrl_probe(struct udevice *dev)
 	struct qca953x_pinctrl_priv *priv = dev_get_priv(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c
index 5b9a592b0d..95610a7e16 100644
--- a/drivers/pinctrl/exynos/pinctrl-exynos.c
+++ b/drivers/pinctrl/exynos/pinctrl-exynos.c
@@ -128,7 +128,7 @@ int exynos_pinctrl_probe(struct udevice *dev)
 	if (!priv)
 		return -EINVAL;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index 80f0dfaf91..ec1958382a 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -137,7 +137,7 @@ int mvebu_pinctl_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	priv->base_reg = dev_get_addr_ptr(dev);
+	priv->base_reg = devfdt_get_addr_ptr(dev);
 	if (priv->base_reg == (void *)FDT_ADDR_T_NONE) {
 		debug("%s: Failed to get base address\n", __func__);
 		return -EINVAL;
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index d6f8a9ba1d..1abfc50f66 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -158,7 +158,7 @@ static int atmel_pinctrl_probe(struct udevice *dev)
 	fdt_addr_t addr_base;
 
 	dev = dev_get_parent(dev);
-	addr_base = dev_get_addr(dev);
+	addr_base = devfdt_get_addr(dev);
 	if (addr_base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 3147b59d19..023cc010d3 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -424,7 +424,7 @@ static int at91_pinctrl_probe(struct udevice *dev)
 	int index;
 
 	for (index = 0; index < MAX_GPIO_BANKS; index++) {
-		addr_base = dev_get_addr_index(dev, index);
+		addr_base = devfdt_get_addr_index(dev, index);
 		if (addr_base == FDT_ADDR_T_NONE)
 			break;
 
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 6c952cc591..25ed5abc5d 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -109,7 +109,7 @@ static int single_ofdata_to_platdata(struct udevice *dev)
 		return res;
 	pdata->offset = of_reg[1] - pdata->width / 8;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE) {
 		dev_dbg(dev, "no valid base register address\n");
 		return -EINVAL;
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
index 4f369c9049..d314482acf 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
@@ -299,7 +299,7 @@ int uniphier_pinctrl_probe(struct udevice *dev,
 	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev->parent);
+	addr = devfdt_get_addr(dev->parent);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c
index 2b65c697ec..3632ee2d1e 100644
--- a/drivers/power/pmic/pm8916.c
+++ b/drivers/power/pmic/pm8916.c
@@ -70,7 +70,7 @@ static int pm8916_probe(struct udevice *dev)
 {
 	struct pm8916_priv *priv = dev_get_priv(dev);
 
-	priv->usid = dev_get_addr(dev);
+	priv->usid = devfdt_get_addr(dev);
 
 	if (priv->usid == FDT_ADDR_T_NONE)
 		return -EINVAL;
diff --git a/drivers/pwm/exynos_pwm.c b/drivers/pwm/exynos_pwm.c
index a0edafce40..9520a14387 100644
--- a/drivers/pwm/exynos_pwm.c
+++ b/drivers/pwm/exynos_pwm.c
@@ -94,7 +94,7 @@ static int exynos_pwm_ofdata_to_platdata(struct udevice *dev)
 {
 	struct exynos_pwm_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct s5p_timer *)dev_get_addr(dev);
+	priv->regs = (struct s5p_timer *)devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/pwm/rk_pwm.c b/drivers/pwm/rk_pwm.c
index 9254f5bc39..7c39f1febe 100644
--- a/drivers/pwm/rk_pwm.c
+++ b/drivers/pwm/rk_pwm.c
@@ -61,7 +61,7 @@ static int rk_pwm_ofdata_to_platdata(struct udevice *dev)
 {
 	struct rk_pwm_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct rk3288_pwm *)dev_get_addr(dev);
+	priv->regs = (struct rk3288_pwm *)devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/pwm/tegra_pwm.c b/drivers/pwm/tegra_pwm.c
index 10e1fdc9b5..d93ac28c31 100644
--- a/drivers/pwm/tegra_pwm.c
+++ b/drivers/pwm/tegra_pwm.c
@@ -59,7 +59,7 @@ static int tegra_pwm_ofdata_to_platdata(struct udevice *dev)
 {
 	struct tegra_pwm_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct pwm_ctlr *)dev_get_addr(dev);
+	priv->regs = (struct pwm_ctlr *)devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 5d17734090..e98df43bdb 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -254,7 +254,7 @@ static int uniphier_reset_probe(struct udevice *dev)
 	struct uniphier_reset_priv *priv = dev_get_priv(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev->parent);
+	addr = devfdt_get_addr(dev->parent);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/altera_jtag_uart.c b/drivers/serial/altera_jtag_uart.c
index cb11b31326..4a6e60f87e 100644
--- a/drivers/serial/altera_jtag_uart.c
+++ b/drivers/serial/altera_jtag_uart.c
@@ -97,7 +97,7 @@ static int altera_jtaguart_ofdata_to_platdata(struct udevice *dev)
 {
 	struct altera_jtaguart_platdata *plat = dev_get_platdata(dev);
 
-	plat->regs = map_physmem(dev_get_addr(dev),
+	plat->regs = map_physmem(devfdt_get_addr(dev),
 				 sizeof(struct altera_jtaguart_regs),
 				 MAP_NOCACHE);
 
diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index 8344940282..75c035285e 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
@@ -89,7 +89,7 @@ static int altera_uart_ofdata_to_platdata(struct udevice *dev)
 {
 	struct altera_uart_platdata *plat = dev_get_platdata(dev);
 
-	plat->regs = map_physmem(dev_get_addr(dev),
+	plat->regs = map_physmem(devfdt_get_addr(dev),
 				 sizeof(struct altera_uart_regs),
 				 MAP_NOCACHE);
 	plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index 453f8eb451..bb294ff94f 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -255,7 +255,7 @@ static int atmel_serial_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 	fdt_addr_t addr_base;
 
-	addr_base = dev_get_addr(dev);
+	addr_base = devfdt_get_addr(dev);
 	if (addr_base == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 4f86780cb1..f31bf5cf01 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -374,7 +374,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
 	int err;
 
 	/* try Processor Local Bus device first */
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 #if defined(CONFIG_PCI) && defined(CONFIG_DM_PCI)
 	if (addr == FDT_ADDR_T_NONE) {
 		/* then try pci device */
diff --git a/drivers/serial/serial_ar933x.c b/drivers/serial/serial_ar933x.c
index aae66dc682..09d2efefdf 100644
--- a/drivers/serial/serial_ar933x.c
+++ b/drivers/serial/serial_ar933x.c
@@ -149,7 +149,7 @@ static int ar933x_serial_probe(struct udevice *dev)
 	fdt_addr_t addr;
 	u32 val;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c
index fc91977b4c..da4a07ab2f 100644
--- a/drivers/serial/serial_arc.c
+++ b/drivers/serial/serial_arc.c
@@ -114,7 +114,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev)
 	struct arc_serial_platdata *plat = dev_get_platdata(dev);
 	DECLARE_GLOBAL_DATA_PTR;
 
-	plat->reg = (struct arc_serial_regs *)dev_get_addr(dev);
+	plat->reg = (struct arc_serial_regs *)devfdt_get_addr(dev);
 	plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				       "clock-frequency", 0);
 
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
index e7ed8993b8..41c26b3d93 100644
--- a/drivers/serial/serial_bcm283x_mu.c
+++ b/drivers/serial/serial_bcm283x_mu.c
@@ -159,7 +159,7 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
 	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index 95e002ea4b..47dd88b32c 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -419,7 +419,7 @@ static int lpuart_serial_ofdata_to_platdata(struct udevice *dev)
 	int node = dev->of_offset;
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
index 1b494265ce..363affb8c5 100644
--- a/drivers/serial/serial_meson.c
+++ b/drivers/serial/serial_meson.c
@@ -108,7 +108,7 @@ static int meson_serial_ofdata_to_platdata(struct udevice *dev)
 	struct meson_serial_platdata *plat = dev->platdata;
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
index 63b3006c63..7bed756a71 100644
--- a/drivers/serial/serial_msm.c
+++ b/drivers/serial/serial_msm.c
@@ -201,7 +201,7 @@ static int msm_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct msm_serial_data *priv = dev_get_priv(dev);
 
-	priv->base = dev_get_addr(dev);
+	priv->base = devfdt_get_addr(dev);
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_mvebu_a3700.c b/drivers/serial/serial_mvebu_a3700.c
index 192e79a3d3..4f9de88c1b 100644
--- a/drivers/serial/serial_mvebu_a3700.c
+++ b/drivers/serial/serial_mvebu_a3700.c
@@ -105,7 +105,7 @@ static int mvebu_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct mvebu_platdata *plat = dev_get_platdata(dev);
 
-	plat->base = dev_get_addr_ptr(dev);
+	plat->base = devfdt_get_addr_ptr(dev);
 
 	return 0;
 }
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 64126e25bf..75264fb781 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -353,7 +353,7 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
 	struct mxc_serial_platdata *plat = dev->platdata;
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 941b424a4c..4ec0f29c42 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -349,7 +349,7 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 96842de8d4..a2f692bf05 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -182,7 +182,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev)
 	struct s5p_serial_platdata *plat = dev->platdata;
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_sti_asc.c b/drivers/serial/serial_sti_asc.c
index ce26c94710..8dcd4f8d25 100644
--- a/drivers/serial/serial_sti_asc.c
+++ b/drivers/serial/serial_sti_asc.c
@@ -170,7 +170,7 @@ static int sti_asc_serial_probe(struct udevice *dev)
 	unsigned long val;
 	fdt_addr_t base;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_stm32x7.c b/drivers/serial/serial_stm32x7.c
index 1907cef5b3..bdabf87e50 100644
--- a/drivers/serial/serial_stm32x7.c
+++ b/drivers/serial/serial_stm32x7.c
@@ -110,7 +110,7 @@ static int stm32_serial_ofdata_to_platdata(struct udevice *dev)
 	struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 7c6a049692..0762bd9052 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -95,7 +95,7 @@ static int uniphier_serial_probe(struct udevice *dev)
 	fdt_addr_t base;
 	u32 tmp;
 
-	base = dev_get_addr(dev);
+	base = devfdt_get_addr(dev);
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/serial/serial_xuartlite.c b/drivers/serial/serial_xuartlite.c
index a2e9303925..fedd2a9df5 100644
--- a/drivers/serial/serial_xuartlite.c
+++ b/drivers/serial/serial_xuartlite.c
@@ -87,7 +87,7 @@ static int uartlite_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct uartlite_platdata *plat = dev_get_platdata(dev);
 
-	plat->regs = (struct uartlite *)dev_get_addr(dev);
+	plat->regs = (struct uartlite *)devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c
index a2967c03c7..4e86e5c2a1 100644
--- a/drivers/serial/serial_zynq.c
+++ b/drivers/serial/serial_zynq.c
@@ -179,7 +179,7 @@ static int zynq_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct zynq_uart_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct uart_zynq *)dev_get_addr(dev);
+	priv->regs = (struct uart_zynq *)devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c
index eb1ba27acc..c8dcb82150 100644
--- a/drivers/spi/altera_spi.c
+++ b/drivers/spi/altera_spi.c
@@ -174,7 +174,7 @@ static int altera_spi_ofdata_to_platdata(struct udevice *bus)
 {
 	struct altera_spi_platdata *plat = dev_get_platdata(bus);
 
-	plat->regs = map_physmem(dev_get_addr(bus),
+	plat->regs = map_physmem(devfdt_get_addr(bus),
 				 sizeof(struct altera_spi_regs),
 				 MAP_NOCACHE);
 
diff --git a/drivers/spi/ath79_spi.c b/drivers/spi/ath79_spi.c
index b18c733b67..f4b92aae28 100644
--- a/drivers/spi/ath79_spi.c
+++ b/drivers/spi/ath79_spi.c
@@ -177,7 +177,7 @@ static int ath79_spi_probe(struct udevice *bus)
 	struct ath79_spi_priv *priv = dev_get_priv(bus);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(bus);
+	addr = devfdt_get_addr(bus);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 7649114231..d0decaca7b 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -463,7 +463,7 @@ static int atmel_spi_probe(struct udevice *bus)
 	if (ret)
 		return ret;
 
-	bus_plat->regs = (struct at91_spi *)dev_get_addr(bus);
+	bus_plat->regs = (struct at91_spi *)devfdt_get_addr(bus);
 
 	ret = gpio_request_list_by_name(bus, "cs-gpios", priv->cs_gpios,
 					ARRAY_SIZE(priv->cs_gpios), 0);
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 65d37b0b9f..291ef9576a 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -542,7 +542,7 @@ static int davinci_ofdata_to_platadata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	ds->regs = dev_map_physmem(bus, sizeof(struct davinci_spi_regs));
+	ds->regs = devfdt_map_physmem(bus, sizeof(struct davinci_spi_regs));
 	if (!ds->regs) {
 		printf("%s: could not map device address\n", __func__);
 		return -EINVAL;
diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index 9d5e29c6c3..5aa507b2d8 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -134,7 +134,7 @@ static int dw_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->regs = (struct dw_spi *)dev_get_addr(bus);
+	plat->regs = (struct dw_spi *)devfdt_get_addr(bus);
 
 	/* Use 500KHz as a suitable default */
 	plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
index aa0784c04a..89490f70d4 100644
--- a/drivers/spi/exynos_spi.c
+++ b/drivers/spi/exynos_spi.c
@@ -255,7 +255,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->regs = (struct exynos_spi *)dev_get_addr(bus);
+	plat->regs = (struct exynos_spi *)devfdt_get_addr(bus);
 	plat->periph_id = pinmux_decode_periph_id(blob, node);
 
 	if (plat->periph_id == PERIPH_ID_NONE) {
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
index e09985ef2b..38caf69eb4 100644
--- a/drivers/spi/fsl_dspi.c
+++ b/drivers/spi/fsl_dspi.c
@@ -654,7 +654,7 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)
 	plat->num_chipselect =
 		fdtdec_get_int(blob, node, "num-cs", FSL_DSPI_MAX_CHIPSELECT);
 
-	addr = dev_get_addr(bus);
+	addr = devfdt_get_addr(bus);
 	if (addr == FDT_ADDR_T_NONE) {
 		debug("DSPI: Can't get base address or size\n");
 		return -ENOMEM;
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 791f3e8099..0c6bd295cd 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -327,7 +327,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
 {
 	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
 
-	plat->spireg = (struct kwspi_registers *)dev_get_addr(bus);
+	plat->spireg = (struct kwspi_registers *)devfdt_get_addr(bus);
 
 	return 0;
 }
diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c
index ee847e4610..ec4907391c 100644
--- a/drivers/spi/mvebu_a3700_spi.c
+++ b/drivers/spi/mvebu_a3700_spi.c
@@ -251,7 +251,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
 {
 	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
 
-	plat->spireg = (struct spi_reg *)dev_get_addr(bus);
+	plat->spireg = (struct spi_reg *)devfdt_get_addr(bus);
 
 	/*
 	 * FIXME
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index 8a89450109..4935ed1198 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -632,7 +632,7 @@ static int omap3_spi_probe(struct udevice *dev)
 	struct omap2_mcspi_platform_config* data =
 		(struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
 
-	priv->regs = (struct mcspi *)(dev_get_addr(dev) + data->regs_offset);
+	priv->regs = (struct mcspi *)(devfdt_get_addr(dev) + data->regs_offset);
 	priv->pin_dir = fdtdec_get_uint(blob, node, "ti,pindir-d0-out-d1-in",
 					    MCSPI_PINDIR_D0_IN_D1_OUT);
 	priv->wordlen = SPI_DEFAULT_WORDLEN;
diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index 3e44f1795e..db7cab2607 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -167,7 +167,7 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice *bus)
 	int node = dev_of_offset(bus);
 	int ret;
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 
 	ret = clk_get_by_index(bus, 0, &priv->clk);
 	if (ret < 0) {
diff --git a/drivers/spi/tegra114_spi.c b/drivers/spi/tegra114_spi.c
index 897409ca02..802117eb49 100644
--- a/drivers/spi/tegra114_spi.c
+++ b/drivers/spi/tegra114_spi.c
@@ -103,7 +103,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
 
 	if (plat->periph_id == PERIPH_ID_NONE) {
diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c
index ecbf4c16f3..299e1b44fa 100644
--- a/drivers/spi/tegra20_sflash.c
+++ b/drivers/spi/tegra20_sflash.c
@@ -90,7 +90,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
 
 	if (plat->periph_id == PERIPH_ID_NONE) {
diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c
index 1d99a1e910..4cbde7b22f 100644
--- a/drivers/spi/tegra20_slink.c
+++ b/drivers/spi/tegra20_slink.c
@@ -96,7 +96,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
 
 	if (plat->periph_id == PERIPH_ID_NONE) {
diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c
index 1e094cbc8b..6d0b5da261 100644
--- a/drivers/spi/tegra210_qspi.c
+++ b/drivers/spi/tegra210_qspi.c
@@ -99,7 +99,7 @@ static int tegra210_qspi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 	plat->periph_id = clock_decode_periph_id(blob, node);
 
 	if (plat->periph_id == PERIPH_ID_NONE) {
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index 3c4c9dd986..0e8411b4af 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -584,7 +584,7 @@ static void *map_syscon_chipselects(struct udevice *bus)
 	return fdtdec_get_number(cell + 1, 1) + regmap_get_range(regmap, 0);
 #else
 	fdt_addr_t addr;
-	addr = dev_get_addr_index(bus, 2);
+	addr = devfdt_get_addr_index(bus, 2);
 	return (addr == FDT_ADDR_T_NONE) ? NULL :
 		map_physmem(addr, 0, MAP_NOCACHE);
 #endif
@@ -597,9 +597,9 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus)
 	int node = dev_of_offset(bus);
 
 	priv->ctrl_mod_mmap = map_syscon_chipselects(bus);
-	priv->base = map_physmem(dev_get_addr(bus), sizeof(struct ti_qspi_regs),
-				 MAP_NOCACHE);
-	priv->memory_map = map_physmem(dev_get_addr_index(bus, 1), 0,
+	priv->base = map_physmem(devfdt_get_addr(bus),
+				 sizeof(struct ti_qspi_regs), MAP_NOCACHE);
+	priv->memory_map = map_physmem(devfdt_get_addr_index(bus, 1), 0,
 				       MAP_NOCACHE);
 
 	priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1);
diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c
index 5a9b1f0f2e..e19e9e2f15 100644
--- a/drivers/spi/zynq_spi.c
+++ b/drivers/spi/zynq_spi.c
@@ -73,7 +73,7 @@ static int zynq_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 
-	plat->regs = (struct zynq_spi_regs *)dev_get_addr(bus);
+	plat->regs = (struct zynq_spi_regs *)devfdt_get_addr(bus);
 
 	/* FIXME: Use 250MHz as a suitable default */
 	plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c
index 605683fc0e..ca27ee5736 100644
--- a/drivers/spmi/spmi-msm.c
+++ b/drivers/spmi/spmi-msm.c
@@ -150,7 +150,7 @@ static int msm_spmi_probe(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	int i;
 
-	priv->arb_chnl = dev_get_addr(dev);
+	priv->arb_chnl = devfdt_get_addr(dev);
 	priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
 			dev_of_offset(parent), node, "reg", 1, NULL, false);
 	priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
diff --git a/drivers/sysreset/sysreset_snapdragon.c b/drivers/sysreset/sysreset_snapdragon.c
index a6cabfb8b0..9869813978 100644
--- a/drivers/sysreset/sysreset_snapdragon.c
+++ b/drivers/sysreset/sysreset_snapdragon.c
@@ -16,7 +16,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static int msm_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
-	phys_addr_t addr = dev_get_addr(dev);
+	phys_addr_t addr = devfdt_get_addr(dev);
 	if (!addr)
 		return -EINVAL;
 	writel(0, addr);
diff --git a/drivers/timer/altera_timer.c b/drivers/timer/altera_timer.c
index 89fe05b704..1ba85c4399 100644
--- a/drivers/timer/altera_timer.c
+++ b/drivers/timer/altera_timer.c
@@ -71,7 +71,7 @@ static int altera_timer_ofdata_to_platdata(struct udevice *dev)
 {
 	struct altera_timer_platdata *plat = dev_get_platdata(dev);
 
-	plat->regs = map_physmem(dev_get_addr(dev),
+	plat->regs = map_physmem(devfdt_get_addr(dev),
 				 sizeof(struct altera_timer_regs),
 				 MAP_NOCACHE);
 
diff --git a/drivers/timer/ast_timer.c b/drivers/timer/ast_timer.c
index d7c5460cd3..e194c50f4a 100644
--- a/drivers/timer/ast_timer.c
+++ b/drivers/timer/ast_timer.c
@@ -66,7 +66,7 @@ static int ast_timer_ofdata_to_platdata(struct udevice *dev)
 {
 	struct ast_timer_priv *priv = dev_get_priv(dev);
 
-	priv->regs = dev_get_addr_ptr(dev);
+	priv->regs = devfdt_get_addr_ptr(dev);
 	if (IS_ERR(priv->regs))
 		return PTR_ERR(priv->regs);
 
diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c
index 7422e0a653..4cc6105505 100644
--- a/drivers/timer/omap-timer.c
+++ b/drivers/timer/omap-timer.c
@@ -79,7 +79,7 @@ static int omap_timer_ofdata_to_platdata(struct udevice *dev)
 {
 	struct omap_timer_priv *priv = dev_get_priv(dev);
 
-	priv->regs = map_physmem(dev_get_addr(dev),
+	priv->regs = map_physmem(devfdt_get_addr(dev),
 				 sizeof(struct omap_gptimer_regs), MAP_NOCACHE);
 
 	return 0;
diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
index d2b3783673..c00a2d030b 100644
--- a/drivers/tpm/tpm_tis_lpc.c
+++ b/drivers/tpm/tpm_tis_lpc.c
@@ -165,7 +165,7 @@ static int tpm_tis_lpc_probe(struct udevice *dev)
 	u32 didvid;
 	ulong chip_type = dev_get_driver_data(dev);
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 	priv->regs = map_sysmem(addr, 0);
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 0e5df15a0d..bbaefd2334 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -1234,7 +1234,7 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
 	const void *prop;
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 	priv->regs = (struct dwc2_core_regs *)addr;
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index a5c6d34974..f6c6b019ca 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -96,7 +96,7 @@ static int ehci_atmel_probe(struct udevice *dev)
 	/*
 	 * Get the base address for EHCI controller from the device node
 	 */
-	hcd_base = dev_get_addr(dev);
+	hcd_base = devfdt_get_addr(dev);
 	if (hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the EHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 981543e315..30297b02d3 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -52,7 +52,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	/*
 	 * Get the base address for XHCI controller from the device node
 	 */
-	plat->hcd_base = dev_get_addr(dev);
+	plat->hcd_base = devfdt_get_addr(dev);
 	if (plat->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the XHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 7ad50fccee..b57c6cd35a 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -98,7 +98,7 @@ static int ehci_fsl_probe(struct udevice *dev)
 	/*
 	 * Get the base address for EHCI controller from the device node
 	 */
-	priv->hcd_base = dev_get_addr(dev);
+	priv->hcd_base = devfdt_get_addr(dev);
 	if (priv->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the EHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 2190adba67..fb78462893 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -50,7 +50,7 @@ static int ehci_usb_probe(struct udevice *dev)
 		reset_free(&reset);
 	}
 
-	hccr = map_physmem(dev_get_addr(dev), 0x100, MAP_NOCACHE);
+	hccr = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE);
 	hcor = (struct ehci_hcor *)((uintptr_t)hccr +
 				    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
 
diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index 464247035e..56409df26e 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -108,7 +108,7 @@ static int ehci_mvebu_probe(struct udevice *dev)
 	/*
 	 * Get the base address for EHCI controller from the device node
 	 */
-	priv->hcd_base = dev_get_addr(dev);
+	priv->hcd_base = devfdt_get_addr(dev);
 	if (priv->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the EHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 6484c1c334..2c0c63322c 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -147,7 +147,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	struct msm_ehci_priv *priv = dev_get_priv(dev);
 
 	priv->ulpi_vp.port_num = 0;
-	priv->ehci = (void *)dev_get_addr(dev);
+	priv->ehci = (void *)devfdt_get_addr(dev);
 
 	if (priv->ehci == (void *)FDT_ADDR_T_NONE)
 		return -EINVAL;
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 55ac162a3c..2367671dae 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -434,7 +434,7 @@ static const struct ehci_ops mx6_ehci_ops = {
 static int ehci_usb_phy_mode(struct udevice *dev)
 {
 	struct usb_platdata *plat = dev_get_platdata(dev);
-	void *__iomem addr = (void *__iomem)dev_get_addr(dev);
+	void *__iomem addr = (void *__iomem)devfdt_get_addr(dev);
 	void *__iomem phy_ctrl, *__iomem phy_status;
 	const void *blob = gd->fdt_blob;
 	int offset = dev_of_offset(dev), phy_off;
@@ -504,7 +504,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 static int ehci_usb_probe(struct udevice *dev)
 {
 	struct usb_platdata *plat = dev_get_platdata(dev);
-	struct usb_ehci *ehci = (struct usb_ehci *)dev_get_addr(dev);
+	struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev);
 	struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
 	enum usb_init_type type = plat->init_type;
 	struct ehci_hccr *hccr;
diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c
index 068f24f483..6ecb7c4d12 100644
--- a/drivers/usb/host/ehci-sunxi.c
+++ b/drivers/usb/host/ehci-sunxi.c
@@ -36,7 +36,7 @@ static int ehci_usb_probe(struct udevice *dev)
 	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 	struct usb_platdata *plat = dev_get_platdata(dev);
 	struct ehci_sunxi_priv *priv = dev_get_priv(dev);
-	struct ehci_hccr *hccr = (struct ehci_hccr *)dev_get_addr(dev);
+	struct ehci_hccr *hccr = (struct ehci_hccr *)devfdt_get_addr(dev);
 	struct ehci_hcor *hcor;
 	int extra_ahb_gate_mask = 0;
 
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index beb3b02796..da9e9440b7 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -699,7 +699,7 @@ static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)
 	int node = dev_of_offset(dev);
 	const char *phy, *mode;
 
-	config->reg = (struct usb_ctlr *)dev_get_addr(dev);
+	config->reg = (struct usb_ctlr *)devfdt_get_addr(dev);
 	mode = fdt_getprop(blob, node, "dr_mode", NULL);
 	if (mode) {
 		if (0 == strcmp(mode, "host"))
diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
index 84241cd173..e52cd6ad32 100644
--- a/drivers/usb/host/ehci-vf.c
+++ b/drivers/usb/host/ehci-vf.c
@@ -223,7 +223,7 @@ static int vf_usb_ofdata_to_platdata(struct udevice *dev)
 
 	priv->portnr = dev->seq;
 
-	priv->ehci = (struct usb_ehci *)dev_get_addr(dev);
+	priv->ehci = (struct usb_ehci *)devfdt_get_addr(dev);
 	mode = fdt_getprop(dt_blob, node, "dr_mode", NULL);
 	if (mode) {
 		if (0 == strcmp(mode, "host")) {
diff --git a/drivers/usb/host/ehci-zynq.c b/drivers/usb/host/ehci-zynq.c
index 1e3b8001f3..4f127d5afa 100644
--- a/drivers/usb/host/ehci-zynq.c
+++ b/drivers/usb/host/ehci-zynq.c
@@ -26,7 +26,7 @@ static int ehci_zynq_ofdata_to_platdata(struct udevice *dev)
 {
 	struct zynq_ehci_priv *priv = dev_get_priv(dev);
 
-	priv->ehci = (struct usb_ehci *)dev_get_addr_ptr(dev);
+	priv->ehci = (struct usb_ehci *)devfdt_get_addr_ptr(dev);
 	if (!priv->ehci)
 		return -EINVAL;
 
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index f3307f47a7..f85738fb05 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -18,7 +18,7 @@ struct generic_ohci {
 
 static int ohci_usb_probe(struct udevice *dev)
 {
-	struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
+	struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev);
 
 	return ohci_register(dev, regs);
 }
diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c
index 0c45eec04a..133774f6e6 100644
--- a/drivers/usb/host/ohci-sunxi.c
+++ b/drivers/usb/host/ohci-sunxi.c
@@ -37,7 +37,7 @@ static int ohci_usb_probe(struct udevice *dev)
 	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 	struct usb_bus_priv *bus_priv = dev_get_uclass_priv(dev);
 	struct ohci_sunxi_priv *priv = dev_get_priv(dev);
-	struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
+	struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev);
 	int extra_ahb_gate_mask = 0;
 
 	bus_priv->companion = true;
diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c
index b3f48b34e2..bf7286554e 100644
--- a/drivers/usb/host/xhci-exynos5.c
+++ b/drivers/usb/host/xhci-exynos5.c
@@ -61,7 +61,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 	/*
 	 * Get the base address for XHCI controller from the device node
 	 */
-	plat->hcd_base = dev_get_addr(dev);
+	plat->hcd_base = devfdt_get_addr(dev);
 	if (plat->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the XHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c
index 798c358fd9..72c4092630 100644
--- a/drivers/usb/host/xhci-fsl.c
+++ b/drivers/usb/host/xhci-fsl.c
@@ -121,7 +121,7 @@ static int xhci_fsl_probe(struct udevice *dev)
 	/*
 	 * Get the base address for XHCI controller from the device node
 	 */
-	priv->hcd_base = dev_get_addr(dev);
+	priv->hcd_base = devfdt_get_addr(dev);
 	if (priv->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the XHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index d880af1113..b9201a5a6a 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -74,7 +74,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 	/*
 	 * Get the base address for XHCI controller from the device node
 	 */
-	plat->hcd_base = dev_get_addr(dev);
+	plat->hcd_base = devfdt_get_addr(dev);
 	if (plat->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the XHCI register base address\n");
 		return -ENXIO;
diff --git a/drivers/usb/host/xhci-rockchip.c b/drivers/usb/host/xhci-rockchip.c
index f559830185..5e7130f0e1 100644
--- a/drivers/usb/host/xhci-rockchip.c
+++ b/drivers/usb/host/xhci-rockchip.c
@@ -46,7 +46,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 	/*
 	 * Get the base address for XHCI controller from the device node
 	 */
-	plat->hcd_base = dev_get_addr(dev);
+	plat->hcd_base = devfdt_get_addr(dev);
 	if (plat->hcd_base == FDT_ADDR_T_NONE) {
 		debug("Can't get the XHCI register base address\n");
 		return -ENXIO;
@@ -57,7 +57,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 	     device_find_next_child(&child)) {
 		if (!of_device_is_compatible(child, "rockchip,rk3399-usb3-phy"))
 			continue;
-		plat->phy_base = dev_get_addr(child);
+		plat->phy_base = devfdt_get_addr(child);
 		break;
 	}
 
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 852f07facc..27018c73b6 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -88,7 +88,7 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev)
 	int ctrl_mod;
 	int usb_index;
 
-	platdata->base = (void *)dev_get_addr_index(dev, 1);
+	platdata->base = (void *)devfdt_get_addr_index(dev, 1);
 
 	phys = fdtdec_lookup_phandle(fdt, node, "phys");
 	ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 59b9c45616..903653fdc4 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -499,7 +499,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev)
 	const void *blob = gd->fdt_blob;
 	int node = dev->of_offset;
 
-	priv->regs = (struct atmel_hlcd_regs *)dev_get_addr(dev);
+	priv->regs = (struct atmel_hlcd_regs *)devfdt_get_addr(dev);
 	if (!priv->regs) {
 		debug("%s: No display controller address\n", __func__);
 		return -EINVAL;
diff --git a/drivers/video/exynos/exynos_dp.c b/drivers/video/exynos/exynos_dp.c
index c5039e7b43..0ee0d0a7fb 100644
--- a/drivers/video/exynos/exynos_dp.c
+++ b/drivers/video/exynos/exynos_dp.c
@@ -883,7 +883,7 @@ static int exynos_dp_ofdata_to_platdata(struct udevice *dev)
 	unsigned int node = dev_of_offset(dev);
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE) {
 		debug("Can't get the DP base address\n");
 		return -EINVAL;
diff --git a/drivers/video/exynos/exynos_fb.c b/drivers/video/exynos/exynos_fb.c
index 46320e7f02..6ca17f2db2 100644
--- a/drivers/video/exynos/exynos_fb.c
+++ b/drivers/video/exynos/exynos_fb.c
@@ -486,7 +486,7 @@ int exynos_fb_ofdata_to_platdata(struct udevice *dev)
 	const void *blob = gd->fdt_blob;
 	fdt_addr_t addr;
 
-	addr = dev_get_addr(dev);
+	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE) {
 		debug("Can't get the FIMD base address\n");
 		return -EINVAL;
diff --git a/drivers/video/rockchip/rk_edp.c b/drivers/video/rockchip/rk_edp.c
index 7ece038c8f..4e2030e8e4 100644
--- a/drivers/video/rockchip/rk_edp.c
+++ b/drivers/video/rockchip/rk_edp.c
@@ -998,7 +998,7 @@ static int rk_edp_ofdata_to_platdata(struct udevice *dev)
 {
 	struct rk_edp_priv *priv = dev_get_priv(dev);
 
-	priv->regs = (struct rk3288_edp *)dev_get_addr(dev);
+	priv->regs = (struct rk3288_edp *)devfdt_get_addr(dev);
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
 	return 0;
diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c
index db07588302..cd695ca508 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -85,7 +85,7 @@ static int rk_hdmi_ofdata_to_platdata(struct udevice *dev)
 	struct rk_hdmi_priv *priv = dev_get_priv(dev);
 	struct dw_hdmi *hdmi = &priv->hdmi;
 
-	hdmi->ioaddr = (ulong)dev_get_addr(dev);
+	hdmi->ioaddr = (ulong)devfdt_get_addr(dev);
 	hdmi->mpll_cfg = rockchip_mpll_cfg;
 	hdmi->phy_cfg = rockchip_phy_config;
 	hdmi->i2c_clk_high = 0x7a;
diff --git a/drivers/video/rockchip/rk_lvds.c b/drivers/video/rockchip/rk_lvds.c
index ee43255753..66418ddfad 100644
--- a/drivers/video/rockchip/rk_lvds.c
+++ b/drivers/video/rockchip/rk_lvds.c
@@ -176,7 +176,7 @@ static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(dev);
 	int ret;
-	priv->regs = (void *)dev_get_addr(dev);
+	priv->regs = (void *)devfdt_get_addr(dev);
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
 	ret = fdtdec_get_int(blob, node, "rockchip,output", -1);
diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index bc02f800dc..4d8232bbc5 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -278,7 +278,7 @@ static int rk_vop_probe(struct udevice *dev)
 		return 0;
 
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
-	priv->regs = (struct rk3288_vop *)dev_get_addr(dev);
+	priv->regs = (struct rk3288_vop *)devfdt_get_addr(dev);
 
 	/* lcdc(vop) iodomain select 1.8V */
 	rk_setreg(&priv->grf->io_vsel, 1 << 0);
diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c
index 0ba3f2c2b4..ec62fc9e51 100644
--- a/drivers/video/tegra.c
+++ b/drivers/video/tegra.c
@@ -343,7 +343,7 @@ static int tegra_lcd_ofdata_to_platdata(struct udevice *dev)
 	int rgb;
 	int ret;
 
-	priv->disp = (struct disp_ctlr *)dev_get_addr(dev);
+	priv->disp = (struct disp_ctlr *)devfdt_get_addr(dev);
 	if (!priv->disp) {
 		debug("%s: No display controller address\n", __func__);
 		return -EINVAL;
diff --git a/drivers/video/tegra124/dp.c b/drivers/video/tegra124/dp.c
index 5bf8524a5e..c38b3e5335 100644
--- a/drivers/video/tegra124/dp.c
+++ b/drivers/video/tegra124/dp.c
@@ -1572,7 +1572,7 @@ static int tegra_dp_ofdata_to_platdata(struct udevice *dev)
 {
 	struct tegra_dp_plat *plat = dev_get_platdata(dev);
 
-	plat->base = dev_get_addr(dev);
+	plat->base = devfdt_get_addr(dev);
 
 	return 0;
 }
diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h
index fd05b6fe95..ef6e86379f 100644
--- a/include/dm/fdtaddr.h
+++ b/include/dm/fdtaddr.h
@@ -16,26 +16,26 @@
 struct udevice;
 
 /**
- * dev_get_addr() - Get the reg property of a device
+ * devfdt_get_addr() - Get the reg property of a device
  *
  * @dev: Pointer to a device
  *
  * @return addr
  */
-fdt_addr_t dev_get_addr(struct udevice *dev);
+fdt_addr_t devfdt_get_addr(struct udevice *dev);
 
 /**
- * dev_get_addr_ptr() - Return pointer to the address of the reg property
+ * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
  *                      of a device
  *
  * @dev: Pointer to a device
  *
  * @return Pointer to addr, or NULL if there is no such property
  */
-void *dev_get_addr_ptr(struct udevice *dev);
+void *devfdt_get_addr_ptr(struct udevice *dev);
 
 /**
- * dev_map_physmem() - Read device address from reg property of the
+ * devfdt_map_physmem() - Read device address from reg property of the
  *                     device node and map the address into CPU address
  *                     space.
  *
@@ -45,10 +45,10 @@ void *dev_get_addr_ptr(struct udevice *dev);
  * @return  mapped address, or NULL if the device does not have reg
  *          property.
  */
-void *dev_map_physmem(struct udevice *dev, unsigned long size);
+void *devfdt_map_physmem(struct udevice *dev, unsigned long size);
 
 /**
- * dev_get_addr_index() - Get the indexed reg property of a device
+ * devfdt_get_addr_index() - Get the indexed reg property of a device
  *
  * @dev: Pointer to a device
  * @index: the 'reg' property can hold a list of <addr, size> pairs
@@ -56,10 +56,10 @@ void *dev_map_physmem(struct udevice *dev, unsigned long size);
  *
  * @return addr
  */
-fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
+fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);
 
 /**
- * dev_get_addr_size_index() - Get the indexed reg property of a device
+ * devfdt_get_addr_size_index() - Get the indexed reg property of a device
  *
  * Returns the address and size specified in the 'reg' property of a device.
  *
@@ -71,11 +71,11 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
  *
  * @return addr
  */
-fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
+fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
 				   fdt_size_t *size);
 
 /**
- * dev_get_addr_name() - Get the reg property of a device, indexed by name
+ * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
  *
  * @dev: Pointer to a device
  * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
@@ -84,7 +84,7 @@ fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
  *
  * @return addr
  */
-fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name);
+fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);
 
 /**
  * dm_set_translation_offset() - Set translation offset
@@ -93,7 +93,7 @@ fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name);
  * Some platforms need a special address translation. Those
  * platforms (e.g. mvebu in SPL) can configure a translation
  * offset in the DM by calling this function. It will be
- * added to all addresses returned in dev_get_addr().
+ * added to all addresses returned in devfdt_get_addr().
  */
 void dm_set_translation_offset(fdt_addr_t offs);
 
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 4/9] atmel: Fix up use of  dm_scan_fdt_node()
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
                   ` (2 preceding siblings ...)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 3/9] dm: Rename dev_addr..() functions Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h Simon Glass
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

This function should not be used outside the core driver-model code.
Update it to use dm_scan_fdt_dev() instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 drivers/gpio/atmel_pio4.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index 73a5c54bef..f3689467f0 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -10,7 +10,6 @@
 #include <clk.h>
 #include <dm.h>
 #include <fdtdec.h>
-#include <dm/root.h>
 #include <asm/arch/hardware.h>
 #include <asm/gpio.h>
 #include <mach/gpio.h>
@@ -276,7 +275,7 @@ static const struct dm_gpio_ops atmel_pio4_ops = {
 
 static int atmel_pio4_bind(struct udevice *dev)
 {
-	return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), false);
+	return dm_scan_fdt_dev(dev);
 }
 
 static int atmel_pio4_probe(struct udevice *dev)
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
                   ` (3 preceding siblings ...)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 4/9] atmel: Fix up use of dm_scan_fdt_node() Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 6/9] dm: core: Dont export dm_scan_fdt_node() Simon Glass
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

It is good practice to include common.h as the first header. This ensures
that required features like the DECLARE_GLOBAL_DATA_PTR macro,
configuration options and common types are available.

Fix up some files which currently don't do this. This is necessary because
driver model will soon start using global data and configuration in the
dm/ofnode.h header file, included via dm.h.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 arch/arm/mach-uniphier/pinctrl-glue.c            | 1 +
 drivers/firmware/firmware-uclass.c               | 1 +
 drivers/gpio/lpc32xx_gpio.c                      | 1 +
 drivers/mmc/pic32_sdhci.c                        | 2 +-
 drivers/pinctrl/meson/pinctrl-meson-gxbb.c       | 1 +
 drivers/pinctrl/nxp/pinctrl-imx5.c               | 1 +
 drivers/pinctrl/nxp/pinctrl-imx6.c               | 1 +
 drivers/pinctrl/nxp/pinctrl-imx7.c               | 1 +
 drivers/pinctrl/nxp/pinctrl-imx7ulp.c            | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c  | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c | 1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c | 1 +
 drivers/serial/serial_uniphier.c                 | 1 +
 drivers/spi/fsl_dspi.c                           | 2 ++
 drivers/sysreset/sysreset_psci.c                 | 1 +
 drivers/video/exynos/exynos_dp.c                 | 2 +-
 23 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-uniphier/pinctrl-glue.c b/arch/arm/mach-uniphier/pinctrl-glue.c
index 725569f90c..3a9ec9c7bc 100644
--- a/arch/arm/mach-uniphier/pinctrl-glue.c
+++ b/arch/arm/mach-uniphier/pinctrl-glue.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <linux/errno.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
diff --git a/drivers/firmware/firmware-uclass.c b/drivers/firmware/firmware-uclass.c
index 6c96656dd0..af781b5b69 100644
--- a/drivers/firmware/firmware-uclass.c
+++ b/drivers/firmware/firmware-uclass.c
@@ -2,6 +2,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 
 /* Firmware access is platform-dependent.  No generic code in uclass */
diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c
index 1bf945acfc..292fc74fc3 100644
--- a/drivers/gpio/lpc32xx_gpio.c
+++ b/drivers/gpio/lpc32xx_gpio.c
@@ -7,6 +7,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <asm/io.h>
 #include <asm/arch-lpc32xx/cpu.h>
 #include <asm/arch-lpc32xx/gpio.h>
diff --git a/drivers/mmc/pic32_sdhci.c b/drivers/mmc/pic32_sdhci.c
index 9d8a392ed9..212e22ee02 100644
--- a/drivers/mmc/pic32_sdhci.c
+++ b/drivers/mmc/pic32_sdhci.c
@@ -7,8 +7,8 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <dm.h>
 #include <common.h>
+#include <dm.h>
 #include <sdhci.h>
 #include <linux/errno.h>
 #include <mach/pic32.h>
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
index 0dc2438ebe..2fa840c21a 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
@@ -7,6 +7,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 #include <dt-bindings/gpio/meson-gxbb-gpio.h>
diff --git a/drivers/pinctrl/nxp/pinctrl-imx5.c b/drivers/pinctrl/nxp/pinctrl-imx5.c
index 5f3f94e750..f1c655f4cb 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx5.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx5.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c
index 3842205420..0f767d9079 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx6.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx6.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/nxp/pinctrl-imx7.c b/drivers/pinctrl/nxp/pinctrl-imx7.c
index 439c04e0cc..1f3e4231bc 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx7.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx7.c
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c
index 1f81a66df4..4a893e5a65 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c
@@ -6,6 +6,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
index cc76fef0a1..9c2db1afc8 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
index 83d960f5e9..0b0af1c018 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c
index 84ee10387d..709b005298 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c
index 15fab6a1b0..6ade131385 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
index cf1fc5aa32..df5f2d86fa 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c
index 788cfab47a..7b14662a71 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c
index 8869fe4ed9..90d632903c 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c
index 5bff86b31a..86752d91ff 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c
index 6127fd2111..e9cc9d205d 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld3.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c
index 5ed49f0070..897ce15131 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <dm/pinctrl.h>
 
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 0762bd9052..68895bde8e 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -6,6 +6,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <linux/io.h>
 #include <linux/serial_reg.h>
diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c
index 38caf69eb4..42086197d9 100644
--- a/drivers/spi/fsl_dspi.c
+++ b/drivers/spi/fsl_dspi.c
@@ -9,6 +9,8 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
+
+#include <common.h>
 #include <dm.h>
 #include <errno.h>
 #include <common.h>
diff --git a/drivers/sysreset/sysreset_psci.c b/drivers/sysreset/sysreset_psci.c
index b39051c220..4656d273c1 100644
--- a/drivers/sysreset/sysreset_psci.c
+++ b/drivers/sysreset/sysreset_psci.c
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
 #include <dm.h>
 #include <sysreset.h>
 #include <linux/errno.h>
diff --git a/drivers/video/exynos/exynos_dp.c b/drivers/video/exynos/exynos_dp.c
index 0ee0d0a7fb..092342e7ad 100644
--- a/drivers/video/exynos/exynos_dp.c
+++ b/drivers/video/exynos/exynos_dp.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <config.h>
+#include <common.h>
 #include <dm.h>
 #include <common.h>
 #include <display.h>
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 6/9] dm: core: Dont export dm_scan_fdt_node()
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
                   ` (4 preceding siblings ...)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 7/9] dm: core: Replace of_offset with accessor (part 2) Simon Glass
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

This function is only used in one place. It is better to just declare it
internally since there is a simpler replacement for use outside the
driver-model core code.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 drivers/core/root.c | 17 +++++++++++++++--
 include/dm/root.h   | 16 ----------------
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 42679d047c..4bb71f3cac 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -207,8 +207,21 @@ int dm_scan_platdata(bool pre_reloc_only)
 }
 
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
-int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
-		     bool pre_reloc_only)
+/**
+ * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
+ *
+ * This scans the subnodes of a device tree node and and creates a driver
+ * for each one.
+ *
+ * @parent: Parent device for the devices that will be created
+ * @blob: Pointer to device tree blob
+ * @offset: Offset of node to scan
+ * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
+ * flag. If false bind all drivers.
+ * @return 0 if OK, -ve on error
+ */
+static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
+			    int offset, bool pre_reloc_only)
 {
 	int ret = 0, err;
 
diff --git a/include/dm/root.h b/include/dm/root.h
index 058eb98923..186cf8ba1c 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -56,22 +56,6 @@ int dm_scan_platdata(bool pre_reloc_only);
 int dm_scan_fdt(const void *blob, bool pre_reloc_only);
 
 /**
- * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
- *
- * This scans the subnodes of a device tree node and and creates a driver
- * for each one.
- *
- * @parent: Parent device for the devices that will be created
- * @blob: Pointer to device tree blob
- * @offset: Offset of node to scan
- * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC
- * flag. If false bind all drivers.
- * @return 0 if OK, -ve on error
- */
-int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
-		     bool pre_reloc_only);
-
-/**
  * dm_scan_other() - Scan for other devices
  *
  * Some devices may not be visible to Driver Model. This weak function can
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 7/9] dm: core: Replace of_offset with accessor (part 2)
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
                   ` (5 preceding siblings ...)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 6/9] dm: core: Dont export dm_scan_fdt_node() Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes Simon Glass
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 9/9] dm: core: Adjust device_bind_common() to take an ofnode Simon Glass
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

At present devices use a simple integer offset to record the device tree
node associated with the device. In preparation for supporting a live
device tree, which uses a node pointer instead, refactor existing code to
access this field through an inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 2 +-
 arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 2 +-
 drivers/block/dwc_ahci.c                     | 6 +++---
 drivers/clk/clk_zynq.c                       | 2 +-
 drivers/core/regmap.c                        | 5 +++--
 drivers/firmware/psci.c                      | 4 ++--
 drivers/mmc/mmc-uclass.c                     | 2 +-
 drivers/mmc/zynq_sdhci.c                     | 2 +-
 drivers/net/phy/phy.c                        | 2 +-
 drivers/net/phy/ti.c                         | 2 +-
 drivers/net/sun8i_emac.c                     | 4 ++--
 drivers/phy/ti-pipe3-phy.c                   | 2 +-
 drivers/pinctrl/pinctrl-at91.c               | 2 +-
 drivers/pinctrl/pinctrl-single.c             | 9 +++++----
 drivers/pinctrl/pinctrl_stm32.c              | 2 +-
 drivers/pinctrl/rockchip/pinctrl_rk3188.c    | 4 ++--
 drivers/pinctrl/rockchip/pinctrl_rk3328.c    | 2 +-
 drivers/serial/serial_lpuart.c               | 2 +-
 drivers/spi/ti_qspi.c                        | 4 ++--
 drivers/timer/arc_timer.c                    | 2 +-
 drivers/video/atmel_hlcdfb.c                 | 4 ++--
 21 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c b/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c
index fea8007265..946a9f1653 100644
--- a/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c
+++ b/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c
@@ -852,7 +852,7 @@ static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rk3188_sdram_params *params = dev_get_platdata(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	/* rk3188 supports only one-channel */
diff --git a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c
index 749b52c8e7..0bb156aa1f 100644
--- a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c
+++ b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c
@@ -1128,7 +1128,7 @@ static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct rockchip_dmc_plat *plat = dev_get_platdata(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	int ret;
 
 	ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params",
diff --git a/drivers/block/dwc_ahci.c b/drivers/block/dwc_ahci.c
index b2e715023d..3f839bf987 100644
--- a/drivers/block/dwc_ahci.c
+++ b/drivers/block/dwc_ahci.c
@@ -31,9 +31,9 @@ static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
 	struct scsi_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
-	plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "max-id",
-				       CONFIG_SYS_SCSI_MAX_SCSI_ID);
-	plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
+				       "max-id", CONFIG_SYS_SCSI_MAX_SCSI_ID);
+	plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 					"max-lun", CONFIG_SYS_SCSI_MAX_LUN);
 
 	priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
diff --git a/drivers/clk/clk_zynq.c b/drivers/clk/clk_zynq.c
index 6edc4dc6ca..b9975456fa 100644
--- a/drivers/clk/clk_zynq.c
+++ b/drivers/clk/clk_zynq.c
@@ -466,7 +466,7 @@ static int zynq_clk_probe(struct udevice *dev)
 	}
 #endif
 
-	priv->ps_clk_freq = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+	priv->ps_clk_freq = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
 					    "ps-clk-frequency", 33333333UL);
 
 	return 0;
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 3bec3df9b6..7f21dee7e4 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -90,8 +90,9 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
 	for (range = map->range, index = 0; count > 0;
 	     count--, cell += both_len, range++, index++) {
 		fdt_size_t sz;
-		range->start = fdtdec_get_addr_size_fixed(blob, dev->of_offset,
-				"reg", index, addr_len, size_len, &sz, true);
+		range->start = fdtdec_get_addr_size_fixed(blob,
+				dev_of_offset(dev), "reg", index, addr_len,
+				size_len, &sz, true);
 		range->size = sz;
 	}
 	map->base = map->range[0].start;
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 3ae627ce5d..7652cc27aa 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -59,8 +59,8 @@ static int psci_probe(struct udevice *dev)
 	DECLARE_GLOBAL_DATA_PTR;
 	const char *method;
 
-	method = fdt_stringlist_get(gd->fdt_blob, dev->of_offset, "method", 0,
-				    NULL);
+	method = fdt_stringlist_get(gd->fdt_blob, dev_of_offset(dev), "method",
+				    0, NULL);
 	if (!method) {
 		printf("missing \"method\" property\n");
 		return -ENXIO;
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 9c07871d3a..8d03ec67c1 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -198,7 +198,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 
 #ifndef CONFIG_SPL_BUILD
 	/* Use the fixed index with aliase node's index */
-	fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev->of_offset, &devnum);
+	fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev_of_offset(dev), &devnum);
 #endif
 
 	ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 70ad5734e1..0fddb420dc 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -83,7 +83,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
 	host->name = dev->name;
 	host->ioaddr = (void *)devfdt_get_addr(dev);
 
-	plat->f_max = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	plat->f_max = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				"max-frequency", CONFIG_ZYNQ_SDHCI_MAX_FREQ);
 
 	return 0;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 8bacd991ad..97e0bc022b 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -860,7 +860,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
 #ifdef CONFIG_PHY_FIXED
 	int sn;
 	const char *name;
-	sn = fdt_first_subnode(gd->fdt_blob, dev->of_offset);
+	sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
 	while (sn > 0) {
 		name = fdt_get_name(gd->fdt_blob, sn, NULL);
 		if (name != NULL && strcmp(name, "fixed-link") == 0) {
diff --git a/drivers/net/phy/ti.c b/drivers/net/phy/ti.c
index 1d870806a3..6ad31a0465 100644
--- a/drivers/net/phy/ti.c
+++ b/drivers/net/phy/ti.c
@@ -174,7 +174,7 @@ static int dp83867_of_init(struct phy_device *phydev)
 {
 	struct dp83867_private *dp83867 = phydev->priv;
 	struct udevice *dev = phydev->dev;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	const void *fdt = gd->fdt_blob;
 
 	if (fdtdec_get_bool(fdt, node, "ti,max-output-impedance"))
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index d895d09a76..09bbb2cdb5 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -820,7 +820,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 		parse_phy_pins(dev);
 
 #ifdef CONFIG_DM_GPIO
-	if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+	if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 			    "snps,reset-active-low"))
 		reset_flags |= GPIOD_ACTIVE_LOW;
 
@@ -828,7 +828,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 				   &priv->reset_gpio, reset_flags);
 
 	if (ret == 0) {
-		ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+		ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
 					   "snps,reset-delays-us",
 					   sun8i_pdata->reset_delays, 3);
 	} else if (ret == -ENOENT) {
diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c
index 350dab72f8..680e32f3ea 100644
--- a/drivers/phy/ti-pipe3-phy.c
+++ b/drivers/phy/ti-pipe3-phy.c
@@ -296,7 +296,7 @@ static void *get_reg(struct udevice *dev, const char *name)
 		return NULL;
 	}
 
-	cell = fdt_getprop(gd->fdt_blob, dev->of_offset, name,
+	cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), name,
 			   &len);
 	if (len < 2*sizeof(fdt32_t)) {
 		error("offset not available for %s\n", name);
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 023cc010d3..38c435e37a 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -364,7 +364,7 @@ static int at91_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
 	struct at91_pinctrl_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = config->of_offset;
+	int node = dev_of_offset(config);
 	u32 cells[MAX_PINMUX_ENTRIES];
 	const u32 *list = cells;
 	u32 bank, pin;
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 25ed5abc5d..44bac401a8 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -79,7 +79,8 @@ static int single_set_state(struct udevice *dev,
 	const struct single_fdt_pin_cfg *prop;
 	int len;
 
-	prop = fdt_getprop(fdt, config->of_offset, "pinctrl-single,pins", &len);
+	prop = fdt_getprop(fdt, dev_of_offset(config), "pinctrl-single,pins",
+			   &len);
 	if (prop) {
 		dev_dbg(dev, "configuring pins for %s\n", config->name);
 		if (len % sizeof(struct single_fdt_pin_cfg)) {
@@ -100,10 +101,10 @@ static int single_ofdata_to_platdata(struct udevice *dev)
 	int res;
 	struct single_pdata *pdata = dev->platdata;
 
-	pdata->width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	pdata->width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				      "pinctrl-single,register-width", 0);
 
-	res = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+	res = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
 				   "reg", of_reg, 2);
 	if (res)
 		return res;
@@ -116,7 +117,7 @@ static int single_ofdata_to_platdata(struct udevice *dev)
 	}
 	pdata->base = addr;
 
-	pdata->mask = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+	pdata->mask = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
 				     "pinctrl-single,function-mask",
 				     0xffffffff);
 	return 0;
diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index aa2c440b14..fd850b93c9 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -64,7 +64,7 @@ static int stm32_pinctrl_set_state_simple(struct udevice *dev,
 	int rv, len;
 
 	/* Get node pinctrl-0 */
-	rv = fdtdec_parse_phandle_with_args(gd->fdt_blob, periph->of_offset,
+	rv = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(periph),
 					   "pinctrl-0", 0, 0, 0, &args);
 	if (rv)
 		return rv;
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3188.c b/drivers/pinctrl/rockchip/pinctrl_rk3188.c
index ef94dab210..65c1f665ea 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3188.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3188.c
@@ -370,7 +370,7 @@ static int rk3188_pinctrl_get_periph_id(struct udevice *dev,
 	u32 cell[3];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
@@ -516,7 +516,7 @@ static int rk3188_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 	u32 cell[60], *ptr;
 
 	debug("%s: %s %s\n", __func__, dev->name, config->name);
-	ret = fdtdec_get_int_array_count(blob, config->of_offset,
+	ret = fdtdec_get_int_array_count(blob, dev_of_offset(config),
 					 "rockchip,pins", cell,
 					 ARRAY_SIZE(cell));
 	if (ret < 0) {
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3328.c b/drivers/pinctrl/rockchip/pinctrl_rk3328.c
index 5ca6782ccc..b6beec5ed0 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3328.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3328.c
@@ -347,7 +347,7 @@ static int rk3328_pinctrl_get_periph_id(struct udevice *dev,
 	u32 cell[3];
 	int ret;
 
-	ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
 				   "interrupts", cell, ARRAY_SIZE(cell));
 	if (ret < 0)
 		return -EINVAL;
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index 47dd88b32c..382f8ba5b5 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -416,7 +416,7 @@ static int lpuart_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct lpuart_serial_platdata *plat = dev->platdata;
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 	fdt_addr_t addr;
 
 	addr = devfdt_get_addr(dev);
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index 0e8411b4af..bea3aff943 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -574,8 +574,8 @@ static void *map_syscon_chipselects(struct udevice *bus)
 		return NULL;
 	}
 
-	cell = fdt_getprop(gd->fdt_blob, bus->of_offset, "syscon-chipselects",
-			   &len);
+	cell = fdt_getprop(gd->fdt_blob, dev_of_offset(bus),
+			   "syscon-chipselects", &len);
 	if (len < 2*sizeof(fdt32_t)) {
 		debug("%s: offset not available\n", __func__);
 		return NULL;
diff --git a/drivers/timer/arc_timer.c b/drivers/timer/arc_timer.c
index e94e4a4bca..a5f6b345c8 100644
--- a/drivers/timer/arc_timer.c
+++ b/drivers/timer/arc_timer.c
@@ -51,7 +51,7 @@ static int arc_timer_probe(struct udevice *dev)
 	struct arc_timer_priv *priv = dev_get_priv(dev);
 
 	/* Get registers offset and size */
-	id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+	id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
 	if (id < 0)
 		return -EINVAL;
 
diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c
index 903653fdc4..47078fdaae 100644
--- a/drivers/video/atmel_hlcdfb.c
+++ b/drivers/video/atmel_hlcdfb.c
@@ -497,7 +497,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev)
 {
 	struct atmel_hlcdc_priv *priv = dev_get_priv(dev);
 	const void *blob = gd->fdt_blob;
-	int node = dev->of_offset;
+	int node = dev_of_offset(dev);
 
 	priv->regs = (struct atmel_hlcd_regs *)devfdt_get_addr(dev);
 	if (!priv->regs) {
@@ -505,7 +505,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	if (fdtdec_decode_display_timing(blob, dev->of_offset,
+	if (fdtdec_decode_display_timing(blob, dev_of_offset(dev),
 					 0, &priv->timing)) {
 		debug("%s: Failed to decode display timing\n", __func__);
 		return -EINVAL;
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
                   ` (6 preceding siblings ...)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 7/9] dm: core: Replace of_offset with accessor (part 2) Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
                     ` (2 more replies)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 9/9] dm: core: Adjust device_bind_common() to take an ofnode Simon Glass
  8 siblings, 3 replies; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

With live tree we need a struct device_node * to reference a node. With
the existing flat tree, we need an int offset. We need to unify these into
a single value which can represent both.

Add an ofnode union for this and adjust existing code to move to this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 drivers/core/device.c |   2 +-
 drivers/core/root.c   |   2 +-
 include/dm.h          |   1 +
 include/dm/device.h   |  14 +++++--
 include/dm/ofnode.h   | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 113 insertions(+), 6 deletions(-)
 create mode 100644 include/dm/ofnode.h

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 483f8368f7..2738685092 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -60,7 +60,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	dev->platdata = platdata;
 	dev->driver_data = driver_data;
 	dev->name = name;
-	dev->of_offset = of_offset;
+	dev->node = offset_to_ofnode(of_offset);
 	dev->parent = parent;
 	dev->driver = drv;
 	dev->uclass = uc;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 4bb71f3cac..570b4d855f 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -167,7 +167,7 @@ int dm_init(void)
 	if (ret)
 		return ret;
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-	DM_ROOT_NON_CONST->of_offset = 0;
+	DM_ROOT_NON_CONST->node = offset_to_ofnode(0);
 #endif
 	ret = device_probe(DM_ROOT_NON_CONST);
 	if (ret)
diff --git a/include/dm.h b/include/dm.h
index 84f789d807..e634814d74 100644
--- a/include/dm.h
+++ b/include/dm.h
@@ -7,6 +7,7 @@
 #ifndef _DM_H_
 #define _DM_H_
 
+#include <dm/ofnode.h>
 #include <dm/device.h>
 #include <dm/fdtaddr.h>
 #include <dm/platdata.h>
diff --git a/include/dm/device.h b/include/dm/device.h
index 6c4aab6c96..89f9f53c43 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -11,6 +11,7 @@
 #ifndef _DM_DEVICE_H
 #define _DM_DEVICE_H
 
+#include <dm/ofnode.h>
 #include <dm/uclass-id.h>
 #include <fdtdec.h>
 #include <linker_lists.h>
@@ -94,7 +95,7 @@ enum {
  * @platdata: Configuration data for this device
  * @parent_platdata: The parent bus's configuration data for this device
  * @uclass_platdata: The uclass's configuration data for this device
- * @of_offset: Device tree node offset for this device (- for none)
+ * @node: Reference to device tree node for this device
  * @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
@@ -120,7 +121,7 @@ struct udevice {
 	void *platdata;
 	void *parent_platdata;
 	void *uclass_platdata;
-	int of_offset;
+	ofnode node;
 	ulong driver_data;
 	struct udevice *parent;
 	void *priv;
@@ -149,12 +150,17 @@ struct udevice {
 
 static inline int dev_of_offset(const struct udevice *dev)
 {
-	return dev->of_offset;
+	return ofnode_to_offset(dev->node);
 }
 
 static inline void dev_set_of_offset(struct udevice *dev, int of_offset)
 {
-	dev->of_offset = of_offset;
+	dev->node = offset_to_ofnode(of_offset);
+}
+
+static inline bool dev_has_of_node(struct udevice *dev)
+{
+	return ofnode_valid(dev->node);
 }
 
 /**
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
new file mode 100644
index 0000000000..f952c989d2
--- /dev/null
+++ b/include/dm/ofnode.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2017 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _DM_OFNODE_H
+#define _DM_OFNODE_H
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct fdtdec_phandle_args;
+
+/**
+ * ofnode - reference to a device tree node
+ *
+ * This union can hold either a straightforward pointer to a struct device_node
+ * in the live device tree, or an offset within the flat device tree. In the
+ * latter case, the pointer value is just the integer offset within the flat DT.
+ *
+ * Thus we can reference nodes in both the live tree (once available) and the
+ * flat tree (until then). Functions are available to translate between an
+ * ofnode and either an offset or a struct device_node *.
+ *
+ * The reference can also hold a null offset, in which case the pointer value
+ * here is (void *)-1. This corresponds to a struct device_node * value of
+ * NULL, or an offset of -1.
+ *
+ * There is no ambiguity as to whether ofnode holds an offset or a node
+ * pointer: when the live tree is active it holds a node pointer, otherwise it
+ * holds an offset. The value itself does not need to be unique and in theory
+ * the same value could point to a valid device node or a valid offset. We
+ * could arrange for a unique value to be used (e.g. by making the pointer
+ * point to an offset within the flat device tree in the case of an offset) but
+ * this increases code size slightly due to the subtraction. Since it offers no
+ * real benefit, the approach described here seems best.
+ *
+ * For now these points use constant types, since we don't allow writing
+ * the DT.
+ *
+ * @np: Pointer to device node, used for live tree
+ * @flat_ptr: Pointer into flat device tree, used for flat tree. Note that this
+ *	is not a really a pointer to a node: it is an offset value. See above.
+ */
+typedef union ofnode_union {
+	const struct device_node *np;	/* will be used for future live tree */
+	long of_offset;
+} ofnode;
+
+/**
+ * ofnode_to_offset() - convert an ofnode to a flat DT offset
+ *
+ * This cannot be called if the reference contains a node pointer.
+ *
+ * @node: Reference containing offset (possibly invalid)
+ * @return DT offset (can be -1)
+ */
+static inline int ofnode_to_offset(ofnode node)
+{
+	return node.of_offset;
+}
+
+/**
+ * ofnode_valid() - check if an ofnode is valid
+ *
+ * @return true if the reference contains a valid ofnode, false if it is NULL
+ */
+static inline bool ofnode_valid(ofnode node)
+{
+	return node.of_offset != -1;
+}
+
+/**
+ * offset_to_ofnode() - convert a DT offset to an ofnode
+ *
+ * @of_offset: DT offset (either valid, or -1)
+ * @return reference to the associated DT offset
+ */
+static inline ofnode offset_to_ofnode(int of_offset)
+{
+	ofnode node;
+
+	node.of_offset = of_offset;
+
+	return node;
+}
+
+/**
+ * ofnode_equal() - check if two references are equal
+ *
+ * @return true if equal, else false
+ */
+static inline bool ofnode_equal(ofnode ref1, ofnode ref2)
+{
+	/* We only need to compare the contents */
+	return ref1.of_offset == ref2.of_offset;
+}
+
+#endif
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 9/9] dm: core: Adjust device_bind_common() to take an ofnode
  2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
                   ` (7 preceding siblings ...)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes Simon Glass
@ 2017-05-01 15:18 ` Simon Glass
  2017-05-10 21:43   ` Tom Rini
  8 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-01 15:18 UTC (permalink / raw)
  To: u-boot

This core function will need to work with a live tree also. Update it to
accept an ofnode instead of an offset.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Cut the series down to only prepare the way for live tree
- Drop all live tree changes
- Adjust storage to avoid a code size increase

 drivers/core/device.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 2738685092..363c1833e9 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -29,7 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static int device_bind_common(struct udevice *parent, const struct driver *drv,
 			      const char *name, void *platdata,
-			      ulong driver_data, int of_offset,
+			      ulong driver_data, ofnode node,
 			      uint of_platdata_size, struct udevice **devp)
 {
 	struct udevice *dev;
@@ -60,7 +60,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	dev->platdata = platdata;
 	dev->driver_data = driver_data;
 	dev->name = name;
-	dev->node = offset_to_ofnode(of_offset);
+	dev->node = node;
 	dev->parent = parent;
 	dev->driver = drv;
 	dev->uclass = uc;
@@ -76,9 +76,10 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 		 * resolved (and ->seq updated) when the device is probed.
 		 */
 		if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) {
-			if (uc->uc_drv->name && of_offset != -1) {
+			if (uc->uc_drv->name && ofnode_valid(node)) {
 				fdtdec_get_alias_seq(gd->fdt_blob,
-						uc->uc_drv->name, of_offset,
+						uc->uc_drv->name,
+						ofnode_to_offset(node),
 						&dev->req_seq);
 			}
 		}
@@ -219,15 +220,15 @@ int device_bind_with_driver_data(struct udevice *parent,
 				 struct udevice **devp)
 {
 	return device_bind_common(parent, drv, name, NULL, driver_data,
-				  of_offset, 0, devp);
+				  offset_to_ofnode(of_offset), 0, devp);
 }
 
 int device_bind(struct udevice *parent, const struct driver *drv,
 		const char *name, void *platdata, int of_offset,
 		struct udevice **devp)
 {
-	return device_bind_common(parent, drv, name, platdata, 0, of_offset, 0,
-				  devp);
+	return device_bind_common(parent, drv, name, platdata, 0,
+				  offset_to_ofnode(of_offset), 0, devp);
 }
 
 int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
@@ -246,7 +247,8 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
 	platdata_size = info->platdata_size;
 #endif
 	return device_bind_common(parent, drv, info->name,
-			(void *)info->platdata, 0, -1, platdata_size, devp);
+			(void *)info->platdata, 0, offset_to_ofnode(-1),
+			platdata_size, devp);
 }
 
 static void *alloc_priv(int size, uint flags)
-- 
2.13.0.rc0.306.g87b477812d-goog

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  2017-05-11  2:12     ` Masahiro Yamada
  0 siblings, 1 reply; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:44AM -0600, Simon Glass wrote:

> This header includes things that are needed to make driver build. Adjust
> existing users to include that always, even if other dm/ includes are
> present
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/c3880ea1/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  2017-05-16 10:04   ` Masahiro Yamada
  1 sibling, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:45AM -0600, Simon Glass wrote:

> Move this group of address-related functions into a new file. These use
> the flat device tree. Future work will provide new versions of these which
> can support the live tree.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/ac04198f/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 3/9] dm: Rename dev_addr..() functions
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 3/9] dm: Rename dev_addr..() functions Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  0 siblings, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:46AM -0600, Simon Glass wrote:

> These support the flat device tree. We want to use the dev_read_..()
> prefix for functions that support both flat tree and live tree. So rename
> the existing functions to avoid confusion.
> 
> In the end we will have:
> 
>    1. dev_read_addr...()    - works on devices, supports flat/live tree
>    2. devfdt_get_addr...()  - current functions, flat tree only
>    3. of_get_address() etc. - new functions, live tree only
> 
> All drivers will be written to use 1. That function will in turn call
> either 2 or 3 depending on whether the flat or live tree is in use.
> 
> Note this involves changing some dead code - the imx_lpi2c.c file.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/5e5e9a24/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 4/9] atmel: Fix up use of dm_scan_fdt_node()
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 4/9] atmel: Fix up use of dm_scan_fdt_node() Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  0 siblings, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:47AM -0600, Simon Glass wrote:

> This function should not be used outside the core driver-model code.
> Update it to use dm_scan_fdt_dev() instead.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/0fd58340/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  2017-05-11  2:21     ` Masahiro Yamada
  0 siblings, 1 reply; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:48AM -0600, Simon Glass wrote:

> It is good practice to include common.h as the first header. This ensures
> that required features like the DECLARE_GLOBAL_DATA_PTR macro,
> configuration options and common types are available.
> 
> Fix up some files which currently don't do this. This is necessary because
> driver model will soon start using global data and configuration in the
> dm/ofnode.h header file, included via dm.h.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/e92424e5/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 6/9] dm: core: Dont export dm_scan_fdt_node()
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 6/9] dm: core: Dont export dm_scan_fdt_node() Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  0 siblings, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:49AM -0600, Simon Glass wrote:

> This function is only used in one place. It is better to just declare it
> internally since there is a simpler replacement for use outside the
> driver-model core code.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/ec8d8389/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 7/9] dm: core: Replace of_offset with accessor (part 2)
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 7/9] dm: core: Replace of_offset with accessor (part 2) Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  0 siblings, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:50AM -0600, Simon Glass wrote:

> At present devices use a simple integer offset to record the device tree
> node associated with the device. In preparation for supporting a live
> device tree, which uses a node pointer instead, refactor existing code to
> access this field through an inline function.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/6e70ceff/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  2017-05-11  2:33   ` Masahiro Yamada
  2017-05-16 10:35   ` Masahiro Yamada
  2 siblings, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:51AM -0600, Simon Glass wrote:

> With live tree we need a struct device_node * to reference a node. With
> the existing flat tree, we need an int offset. We need to unify these into
> a single value which can represent both.
> 
> Add an ofnode union for this and adjust existing code to move to this.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/e3d4fbea/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 9/9] dm: core: Adjust device_bind_common() to take an ofnode
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 9/9] dm: core: Adjust device_bind_common() to take an ofnode Simon Glass
@ 2017-05-10 21:43   ` Tom Rini
  0 siblings, 0 replies; 35+ messages in thread
From: Tom Rini @ 2017-05-10 21:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 01, 2017 at 09:18:52AM -0600, Simon Glass wrote:

> This core function will need to work with a live tree also. Update it to
> accept an ofnode instead of an offset.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170510/50b48a14/attachment.sig>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used
  2017-05-10 21:43   ` Tom Rini
@ 2017-05-11  2:12     ` Masahiro Yamada
  2017-05-13  1:11       ` Simon Glass
  0 siblings, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-11  2:12 UTC (permalink / raw)
  To: u-boot

Hi Simon,


2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
> On Mon, May 01, 2017 at 09:18:44AM -0600, Simon Glass wrote:
>
>> This header includes things that are needed to make driver build. Adjust
>> existing users to include that always, even if other dm/ includes are
>> present
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
>

I'd say this is a bad idea.
I believe .c files should include headers that are really necessary.

Mostly, drivers need only dm/device.h, but this commit
requires additional parse of dm/uclass.h and dm/platdata.h.

Rather, it is better to deprecate dm.h.

Its concept is DM common header that you force drivers to include
where some in them may not be necessary.

It is a similar idea to include/common.h,
which is one of the biggest design mistakes in U-Boot.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-10 21:43   ` Tom Rini
@ 2017-05-11  2:21     ` Masahiro Yamada
  2017-05-13  1:11       ` Simon Glass
  0 siblings, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-11  2:21 UTC (permalink / raw)
  To: u-boot

Hi Simon

2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
> On Mon, May 01, 2017 at 09:18:48AM -0600, Simon Glass wrote:
>
>> It is good practice to include common.h as the first header. This ensures
>> that required features like the DECLARE_GLOBAL_DATA_PTR macro,
>> configuration options and common types are available.
>>
>> Fix up some files which currently don't do this. This is necessary because
>> driver model will soon start using global data and configuration in the
>> dm/ofnode.h header file, included via dm.h.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Reviewed-by: Tom Rini <trini@konsulko.com>


NACK.

include/common.h is really bad idea
and this is a step backward.

If you need something in your include/dm/ofnode.h
you should include needed header(s) from it.

Why do you need to touch lots of C files?


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes Simon Glass
  2017-05-10 21:43   ` Tom Rini
@ 2017-05-11  2:33   ` Masahiro Yamada
  2017-05-13  1:11     ` Simon Glass
  2017-05-16 10:35   ` Masahiro Yamada
  2 siblings, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-11  2:33 UTC (permalink / raw)
  To: u-boot

2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:

> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> new file mode 100644
> index 0000000000..f952c989d2
> --- /dev/null
> +++ b/include/dm/ofnode.h
> @@ -0,0 +1,100 @@
> +/*
> + * Copyright (c) 2017 Google, Inc
> + * Written by Simon Glass <sjg@chromium.org>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#ifndef _DM_OFNODE_H
> +#define _DM_OFNODE_H
> +
> +DECLARE_GLOBAL_DATA_PTR;

Which line in this header references gd?



> +
> +struct fdtdec_phandle_args;
> +
> +/**
> + * ofnode - reference to a device tree node
> + *
> + * This union can hold either a straightforward pointer to a struct device_node
> + * in the live device tree, or an offset within the flat device tree. In the
> + * latter case, the pointer value is just the integer offset within the flat DT.
> + *
> + * Thus we can reference nodes in both the live tree (once available) and the
> + * flat tree (until then). Functions are available to translate between an
> + * ofnode and either an offset or a struct device_node *.
> + *
> + * The reference can also hold a null offset, in which case the pointer value
> + * here is (void *)-1. This corresponds to a struct device_node * value of
> + * NULL, or an offset of -1.
> + *
> + * There is no ambiguity as to whether ofnode holds an offset or a node
> + * pointer: when the live tree is active it holds a node pointer, otherwise it
> + * holds an offset. The value itself does not need to be unique and in theory
> + * the same value could point to a valid device node or a valid offset. We
> + * could arrange for a unique value to be used (e.g. by making the pointer
> + * point to an offset within the flat device tree in the case of an offset) but
> + * this increases code size slightly due to the subtraction. Since it offers no
> + * real benefit, the approach described here seems best.
> + *
> + * For now these points use constant types, since we don't allow writing
> + * the DT.
> + *
> + * @np: Pointer to device node, used for live tree
> + * @flat_ptr: Pointer into flat device tree, used for flat tree. Note that this
> + *     is not a really a pointer to a node: it is an offset value. See above.
> + */
> +typedef union ofnode_union {
> +       const struct device_node *np;   /* will be used for future live tree */
> +       long of_offset;
> +} ofnode;
> +
> +/**
> + * ofnode_to_offset() - convert an ofnode to a flat DT offset
> + *
> + * This cannot be called if the reference contains a node pointer.
> + *
> + * @node: Reference containing offset (possibly invalid)
> + * @return DT offset (can be -1)
> + */
> +static inline int ofnode_to_offset(ofnode node)
> +{
> +       return node.of_offset;
> +}
> +
> +/**
> + * ofnode_valid() - check if an ofnode is valid
> + *
> + * @return true if the reference contains a valid ofnode, false if it is NULL
> + */
> +static inline bool ofnode_valid(ofnode node)
> +{
> +       return node.of_offset != -1;
> +}
> +
> +/**
> + * offset_to_ofnode() - convert a DT offset to an ofnode
> + *
> + * @of_offset: DT offset (either valid, or -1)
> + * @return reference to the associated DT offset
> + */
> +static inline ofnode offset_to_ofnode(int of_offset)
> +{
> +       ofnode node;
> +
> +       node.of_offset = of_offset;
> +
> +       return node;
> +}
> +
> +/**
> + * ofnode_equal() - check if two references are equal
> + *
> + * @return true if equal, else false
> + */
> +static inline bool ofnode_equal(ofnode ref1, ofnode ref2)
> +{
> +       /* We only need to compare the contents */
> +       return ref1.of_offset == ref2.of_offset;
> +}
> +
> +#endif




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used
  2017-05-11  2:12     ` Masahiro Yamada
@ 2017-05-13  1:11       ` Simon Glass
  2017-05-16  9:56         ` Masahiro Yamada
  0 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-13  1:11 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 10 May 2017 at 20:12, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Simon,
>
>
> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>> On Mon, May 01, 2017 at 09:18:44AM -0600, Simon Glass wrote:
>>
>>> This header includes things that are needed to make driver build. Adjust
>>> existing users to include that always, even if other dm/ includes are
>>> present
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>
>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>
>
> I'd say this is a bad idea.
> I believe .c files should include headers that are really necessary.
>
> Mostly, drivers need only dm/device.h, but this commit
> requires additional parse of dm/uclass.h and dm/platdata.h.
>
> Rather, it is better to deprecate dm.h.
>
> Its concept is DM common header that you force drivers to include
> where some in them may not be necessary.

I did consider this right at the start but I think it is too painful
for users. There are only a few files that we pull in so the overhead
is not great. It avoids having to add new headers because some other
function is used.

One option might be to define all the structs in one header, since
those are the things that are really painful to figure out. We could
then make the function name prefixes fully consistent with the header
file name (mostly they are, but see lists.h and root.h). That would
make it easier.

>
> It is a similar idea to include/common.h,
> which is one of the biggest design mistakes in U-Boot.

We have been slowing pulling things out of common.h - see for example
mapmem.h and vsprint.h. We also have a lot of files in include/ which
really should be arch-specific.

But in any case I think common.h is useful just to include the
configuration and some common declarations (like global_data). The
problem is that it has too much in it.

Regards,
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-11  2:21     ` Masahiro Yamada
@ 2017-05-13  1:11       ` Simon Glass
  2017-05-16 10:32         ` Masahiro Yamada
  0 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-13  1:11 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 10 May 2017 at 20:21, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Simon
>
> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>> On Mon, May 01, 2017 at 09:18:48AM -0600, Simon Glass wrote:
>>
>>> It is good practice to include common.h as the first header. This ensures
>>> that required features like the DECLARE_GLOBAL_DATA_PTR macro,
>>> configuration options and common types are available.
>>>
>>> Fix up some files which currently don't do this. This is necessary because
>>> driver model will soon start using global data and configuration in the
>>> dm/ofnode.h header file, included via dm.h.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>
>> Reviewed-by: Tom Rini <trini@konsulko.com>
>
>
> NACK.
>
> include/common.h is really bad idea
> and this is a step backward.
>
> If you need something in your include/dm/ofnode.h
> you should include needed header(s) from it.
>
> Why do you need to touch lots of C files?

All of these files fail to build when they cannot see global_data.
Also we need access to CONFIG options in dm.h. So I think we have to
have common.h - it is (I think) a rule that all files should have
common.h and have it first, because any other header.

Regards,
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-11  2:33   ` Masahiro Yamada
@ 2017-05-13  1:11     ` Simon Glass
  0 siblings, 0 replies; 35+ messages in thread
From: Simon Glass @ 2017-05-13  1:11 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 10 May 2017 at 20:33, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> 2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:
>
>> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
>> new file mode 100644
>> index 0000000000..f952c989d2
>> --- /dev/null
>> +++ b/include/dm/ofnode.h
>> @@ -0,0 +1,100 @@
>> +/*
>> + * Copyright (c) 2017 Google, Inc
>> + * Written by Simon Glass <sjg@chromium.org>
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#ifndef _DM_OFNODE_H
>> +#define _DM_OFNODE_H
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>
> Which line in this header references gd?

It is actually needed in dev.h when that is inlined. I originally had
to access it here but can move it.

Regards,
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used
  2017-05-13  1:11       ` Simon Glass
@ 2017-05-16  9:56         ` Masahiro Yamada
  2017-05-17 10:07           ` Simon Glass
  0 siblings, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-16  9:56 UTC (permalink / raw)
  To: u-boot

Hi Simon,

2017-05-13 10:11 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 10 May 2017 at 20:12, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>> Hi Simon,
>>
>>
>> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>>> On Mon, May 01, 2017 at 09:18:44AM -0600, Simon Glass wrote:
>>>
>>>> This header includes things that are needed to make driver build. Adjust
>>>> existing users to include that always, even if other dm/ includes are
>>>> present
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>
>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>>
>>
>> I'd say this is a bad idea.
>> I believe .c files should include headers that are really necessary.
>>
>> Mostly, drivers need only dm/device.h, but this commit
>> requires additional parse of dm/uclass.h and dm/platdata.h.
>>
>> Rather, it is better to deprecate dm.h.
>>
>> Its concept is DM common header that you force drivers to include
>> where some in them may not be necessary.
>
> I did consider this right at the start but I think it is too painful
> for users. There are only a few files that we pull in so the overhead
> is not great. It avoids having to add new headers because some other
> function is used.
>
> One option might be to define all the structs in one header, since
> those are the things that are really painful to figure out. We could
> then make the function name prefixes fully consistent with the header
> file name (mostly they are, but see lists.h and root.h). That would
> make it easier.

Still I do not get your point.

include/dm.h includes 3 headers and they are used for different purposes.

Most of drivers need only <dm/device.h>.
<dm/platdata.h> is mostly used in board files.
<dm/uclass.h> is used for core frameworks,
(and when getting access to a different uclass).


Each file just includes only needed headers, and
nothing confusing.


I do not see any benefit in this patch.



>>
>> It is a similar idea to include/common.h,
>> which is one of the biggest design mistakes in U-Boot.
>
> We have been slowing pulling things out of common.h - see for example
> mapmem.h and vsprint.h. We also have a lot of files in include/ which
> really should be arch-specific.
>
> But in any case I think common.h is useful just to include the
> configuration and some common declarations (like global_data). The
> problem is that it has too much in it.

The concept of common.h itself is wrong.

If global_data is needed, <asm-generic/global_data.h> should be included.
If printf() is needed, it should be declared in include/stdio.h or somewhere.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file Simon Glass
  2017-05-10 21:43   ` Tom Rini
@ 2017-05-16 10:04   ` Masahiro Yamada
  2017-05-17 10:09     ` Simon Glass
  1 sibling, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-16 10:04 UTC (permalink / raw)
  To: u-boot

Hi Simon,


2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Move this group of address-related functions into a new file. These use
> the flat device tree. Future work will provide new versions of these which
> can support the live tree.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>




> diff --git a/include/dm.h b/include/dm.h
> index a179c8a6e3..84f789d807 100644
> --- a/include/dm.h
> +++ b/include/dm.h
> @@ -8,6 +8,7 @@
>  #define _DM_H_
>
>  #include <dm/device.h>
> +#include <dm/fdtaddr.h>
>  #include <dm/platdata.h>
>  #include <dm/uclass.h>


I guess your motivation for 1/9 is this.

If you force all drivers to include these 4 headers,
what is the point of splitting?

No, please do not do this.

Please drop 1/9 and,
add #include <dm/fdtaddr.h> where it is necessary.

I know this is painful, but onetime pain.

Perhaps you can use coccinelle for the conversion?

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-13  1:11       ` Simon Glass
@ 2017-05-16 10:32         ` Masahiro Yamada
  2017-05-17 10:09           ` Simon Glass
  0 siblings, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-16 10:32 UTC (permalink / raw)
  To: u-boot

Hi Simon,


2017-05-13 10:11 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 10 May 2017 at 20:21, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>> Hi Simon
>>
>> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>>> On Mon, May 01, 2017 at 09:18:48AM -0600, Simon Glass wrote:
>>>
>>>> It is good practice to include common.h as the first header. This ensures
>>>> that required features like the DECLARE_GLOBAL_DATA_PTR macro,
>>>> configuration options and common types are available.
>>>>
>>>> Fix up some files which currently don't do this. This is necessary because
>>>> driver model will soon start using global data and configuration in the
>>>> dm/ofnode.h header file, included via dm.h.
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>
>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>
>>
>> NACK.
>>
>> include/common.h is really bad idea
>> and this is a step backward.
>>
>> If you need something in your include/dm/ofnode.h
>> you should include needed header(s) from it.
>>
>> Why do you need to touch lots of C files?
>
> All of these files fail to build when they cannot see global_data.

Because you added DECLARE_GLOBAL_DATA_PTR in 8/9.

If you always make sure each header is self-contained,
you do not have to touch so many C files.



> Also we need access to CONFIG options in dm.h.

DM related options are new enough to exist in Kconfig.
No explicit header inclusion is required to reference options from Kconfig.

To reference legacy options that have not converted to Kconfig,
<config.h> should be included.
<common.h> also works, but it is sometimes over-inclusion.


> So I think we have to
> have common.h - it is (I think) a rule that all files should have
> common.h and have it first, because any other header.

I disagree.
The concept of <common.h> is wrong.
<common.h> always comes first in the inclusion list.  This is wrong too.

For example in Linux, includes are often sorted alphabetically.
This makes sense because headers can theoretically be included in any order.


I always make efforts to reduce the dependency on <common.h>.
<common.h> is missing from the code I wrote, and it is intentional.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-01 15:18 ` [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes Simon Glass
  2017-05-10 21:43   ` Tom Rini
  2017-05-11  2:33   ` Masahiro Yamada
@ 2017-05-16 10:35   ` Masahiro Yamada
  2017-05-20  2:29     ` Simon Glass
  2 siblings, 1 reply; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-16 10:35 UTC (permalink / raw)
  To: u-boot

Hi Simon,


2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:
> With live tree we need a struct device_node * to reference a node. With
> the existing flat tree, we need an int offset. We need to unify these into
> a single value which can represent both.
>
> Add an ofnode union for this and adjust existing code to move to this.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
>  drivers/core/device.c |   2 +-
>  drivers/core/root.c   |   2 +-
>  include/dm.h          |   1 +
>  include/dm/device.h   |  14 +++++--
>  include/dm/ofnode.h   | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 113 insertions(+), 6 deletions(-)
>  create mode 100644 include/dm/ofnode.h
>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 483f8368f7..2738685092 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -60,7 +60,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
>         dev->platdata = platdata;
>         dev->driver_data = driver_data;
>         dev->name = name;
> -       dev->of_offset = of_offset;
> +       dev->node = offset_to_ofnode(of_offset);
>         dev->parent = parent;
>         dev->driver = drv;
>         dev->uclass = uc;
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index 4bb71f3cac..570b4d855f 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -167,7 +167,7 @@ int dm_init(void)
>         if (ret)
>                 return ret;
>  #if CONFIG_IS_ENABLED(OF_CONTROL)
> -       DM_ROOT_NON_CONST->of_offset = 0;
> +       DM_ROOT_NON_CONST->node = offset_to_ofnode(0);
>  #endif
>         ret = device_probe(DM_ROOT_NON_CONST);
>         if (ret)
> diff --git a/include/dm.h b/include/dm.h
> index 84f789d807..e634814d74 100644
> --- a/include/dm.h
> +++ b/include/dm.h
> @@ -7,6 +7,7 @@
>  #ifndef _DM_H_
>  #define _DM_H_
>
> +#include <dm/ofnode.h>
>  #include <dm/device.h>
>  #include <dm/fdtaddr.h>
>  #include <dm/platdata.h>
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 6c4aab6c96..89f9f53c43 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -11,6 +11,7 @@
>  #ifndef _DM_DEVICE_H
>  #define _DM_DEVICE_H
>
> +#include <dm/ofnode.h>
>  #include <dm/uclass-id.h>
>  #include <fdtdec.h>
>  #include <linker_lists.h>
> @@ -94,7 +95,7 @@ enum {
>   * @platdata: Configuration data for this device
>   * @parent_platdata: The parent bus's configuration data for this device
>   * @uclass_platdata: The uclass's configuration data for this device
> - * @of_offset: Device tree node offset for this device (- for none)
> + * @node: Reference to device tree node for this device
>   * @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
> @@ -120,7 +121,7 @@ struct udevice {
>         void *platdata;
>         void *parent_platdata;
>         void *uclass_platdata;
> -       int of_offset;
> +       ofnode node;
>         ulong driver_data;
>         struct udevice *parent;
>         void *priv;
> @@ -149,12 +150,17 @@ struct udevice {
>
>  static inline int dev_of_offset(const struct udevice *dev)
>  {
> -       return dev->of_offset;
> +       return ofnode_to_offset(dev->node);
>  }
>
>  static inline void dev_set_of_offset(struct udevice *dev, int of_offset)
>  {
> -       dev->of_offset = of_offset;
> +       dev->node = offset_to_ofnode(of_offset);
> +}
> +
> +static inline bool dev_has_of_node(struct udevice *dev)
> +{
> +       return ofnode_valid(dev->node);
>  }
>
>  /**
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> new file mode 100644
> index 0000000000..f952c989d2
> --- /dev/null
> +++ b/include/dm/ofnode.h
> @@ -0,0 +1,100 @@
> +/*
> + * Copyright (c) 2017 Google, Inc
> + * Written by Simon Glass <sjg@chromium.org>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#ifndef _DM_OFNODE_H
> +#define _DM_OFNODE_H
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +struct fdtdec_phandle_args;
> +
> +/**
> + * ofnode - reference to a device tree node
> + *
> + * This union can hold either a straightforward pointer to a struct device_node
> + * in the live device tree, or an offset within the flat device tree. In the
> + * latter case, the pointer value is just the integer offset within the flat DT.
> + *
> + * Thus we can reference nodes in both the live tree (once available) and the
> + * flat tree (until then). Functions are available to translate between an
> + * ofnode and either an offset or a struct device_node *.
> + *
> + * The reference can also hold a null offset, in which case the pointer value
> + * here is (void *)-1. This corresponds to a struct device_node * value of
> + * NULL, or an offset of -1.
> + *
> + * There is no ambiguity as to whether ofnode holds an offset or a node
> + * pointer: when the live tree is active it holds a node pointer, otherwise it
> + * holds an offset. The value itself does not need to be unique and in theory
> + * the same value could point to a valid device node or a valid offset. We
> + * could arrange for a unique value to be used (e.g. by making the pointer
> + * point to an offset within the flat device tree in the case of an offset) but
> + * this increases code size slightly due to the subtraction. Since it offers no
> + * real benefit, the approach described here seems best.
> + *
> + * For now these points use constant types, since we don't allow writing
> + * the DT.
> + *
> + * @np: Pointer to device node, used for live tree
> + * @flat_ptr: Pointer into flat device tree, used for flat tree. Note that this
> + *     is not a really a pointer to a node: it is an offset value. See above.
> + */
> +typedef union ofnode_union {
> +       const struct device_node *np;   /* will be used for future live tree */
> +       long of_offset;
> +} ofnode;
> +
> +/**
> + * ofnode_to_offset() - convert an ofnode to a flat DT offset
> + *
> + * This cannot be called if the reference contains a node pointer.
> + *
> + * @node: Reference containing offset (possibly invalid)
> + * @return DT offset (can be -1)
> + */
> +static inline int ofnode_to_offset(ofnode node)
> +{
> +       return node.of_offset;
> +}
> +
> +/**
> + * ofnode_valid() - check if an ofnode is valid
> + *
> + * @return true if the reference contains a valid ofnode, false if it is NULL
> + */
> +static inline bool ofnode_valid(ofnode node)
> +{
> +       return node.of_offset != -1;
> +}
> +
> +/**
> + * offset_to_ofnode() - convert a DT offset to an ofnode
> + *
> + * @of_offset: DT offset (either valid, or -1)
> + * @return reference to the associated DT offset
> + */
> +static inline ofnode offset_to_ofnode(int of_offset)
> +{
> +       ofnode node;
> +
> +       node.of_offset = of_offset;
> +
> +       return node;
> +}
> +
> +/**
> + * ofnode_equal() - check if two references are equal
> + *
> + * @return true if equal, else false
> + */
> +static inline bool ofnode_equal(ofnode ref1, ofnode ref2)
> +{
> +       /* We only need to compare the contents */
> +       return ref1.of_offset == ref2.of_offset;
> +}
> +
> +#endif

When you add a new header, please make sure it is self-contained.

You use bool for offset_toofnode() and ofnode_equal().
So you need to include <stdbool.h> from this header.

(or, use "int" for the return type.)



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used
  2017-05-16  9:56         ` Masahiro Yamada
@ 2017-05-17 10:07           ` Simon Glass
  0 siblings, 0 replies; 35+ messages in thread
From: Simon Glass @ 2017-05-17 10:07 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 16 May 2017 at 03:56, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Simon,
>
> 2017-05-13 10:11 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi Masahiro,
>>
>> On 10 May 2017 at 20:12, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>>> Hi Simon,
>>>
>>>
>>> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>>>> On Mon, May 01, 2017 at 09:18:44AM -0600, Simon Glass wrote:
>>>>
>>>>> This header includes things that are needed to make driver build. Adjust
>>>>> existing users to include that always, even if other dm/ includes are
>>>>> present
>>>>>
>>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>>
>>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>>>
>>>
>>> I'd say this is a bad idea.
>>> I believe .c files should include headers that are really necessary.
>>>
>>> Mostly, drivers need only dm/device.h, but this commit
>>> requires additional parse of dm/uclass.h and dm/platdata.h.
>>>
>>> Rather, it is better to deprecate dm.h.
>>>
>>> Its concept is DM common header that you force drivers to include
>>> where some in them may not be necessary.
>>
>> I did consider this right at the start but I think it is too painful
>> for users. There are only a few files that we pull in so the overhead
>> is not great. It avoids having to add new headers because some other
>> function is used.
>>
>> One option might be to define all the structs in one header, since
>> those are the things that are really painful to figure out. We could
>> then make the function name prefixes fully consistent with the header
>> file name (mostly they are, but see lists.h and root.h). That would
>> make it easier.
>
> Still I do not get your point.
>
> include/dm.h includes 3 headers and they are used for different purposes.
>
> Most of drivers need only <dm/device.h>.
> <dm/platdata.h> is mostly used in board files.
> <dm/uclass.h> is used for core frameworks,
> (and when getting access to a different uclass).
>
>
> Each file just includes only needed headers, and
> nothing confusing.
>
>
> I do not see any benefit in this patch.

See the next patch which moves some functions from device.h to
fdtaddr.h. The intent is to make it clear that these functions do not
support livetree. The next series sets up support for dev_read_...()
which is what each driver should use. Eventually we could make
fdtaddr.h private and only include it when needed (i.e. when not using
a live tree). I certainly don't want that inclusion logic to bleed
into drivers.

The implication of what you are asking is that I need to include
dm/fdtaddr.h in those drivers that don't include dm.h. Then in a later
patch I need to change this to dm/read.h.

In fact most people don't want to worry about which header to include
to get the common DM functions. For this sort of refactoring effort it
makes the job that much more painful if every C file does things its
own way.

I regard the actual dm/... headers as internal to driver model. I
don't want to expose particular headers in general, for the very
reason that it causes these sorts of problems.

I think once livetree is complete and the header files are stable then
we could look at the benefits of requiring files to include dm/read.h
since that will become the only file most drivers want. But it does
involve higher maintenance cost.

Right now I am really feeling the pain of the maintenance cost.

So while I understand the disadvantages, I'd like to leave this patch
as is. It is 74 files. I have a second series to get through and then
a third to enable on a real board. It is a lot of work even without
this sort of problem.

If you are really upset about it I am willing to come back when they
are converted and minimise the headers on these files.

>
>
>
>>>
>>> It is a similar idea to include/common.h,
>>> which is one of the biggest design mistakes in U-Boot.
>>
>> We have been slowing pulling things out of common.h - see for example
>> mapmem.h and vsprint.h. We also have a lot of files in include/ which
>> really should be arch-specific.
>>
>> But in any case I think common.h is useful just to include the
>> configuration and some common declarations (like global_data). The
>> problem is that it has too much in it.
>
> The concept of common.h itself is wrong.
>
> If global_data is needed, <asm-generic/global_data.h> should be included.
> If printf() is needed, it should be declared in include/stdio.h or somewhere.

It's all very well to talk about this problem, but we need to change
it. I think the best way is to remove things from common.h until it
contains nothing.

I'll send a series to pare this down a bit more
(u-boot-dm/common-working). If you have time, please help!

Regards
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file
  2017-05-16 10:04   ` Masahiro Yamada
@ 2017-05-17 10:09     ` Simon Glass
  0 siblings, 0 replies; 35+ messages in thread
From: Simon Glass @ 2017-05-17 10:09 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 16 May 2017 at 04:04, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Simon,
>
>
> 2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Move this group of address-related functions into a new file. These use
>> the flat device tree. Future work will provide new versions of these which
>> can support the live tree.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
>
>
>
>> diff --git a/include/dm.h b/include/dm.h
>> index a179c8a6e3..84f789d807 100644
>> --- a/include/dm.h
>> +++ b/include/dm.h
>> @@ -8,6 +8,7 @@
>>  #define _DM_H_
>>
>>  #include <dm/device.h>
>> +#include <dm/fdtaddr.h>
>>  #include <dm/platdata.h>
>>  #include <dm/uclass.h>
>
>
> I guess your motivation for 1/9 is this.

Yes, plus the fact that later is changes again.

>
> If you force all drivers to include these 4 headers,
> what is the point of splitting?

I can change this inclusion later. The main point is to reduce the
work required to introduce livetree to something I can bear.

> No, please do not do this.
>
> Please drop 1/9 and,
> add #include <dm/fdtaddr.h> where it is necessary.
>
> I know this is painful, but onetime pain.

It is two-time pain so far as I know, and I suspect three. This is
just the wrong place to be including a header that is only needed if
you are not using live tree. These sorts of details will drive
everyone mad.

>
> Perhaps you can use coccinelle for the conversion?

I have not used that tool, but it looks interesting. Have you used it?

Perhaps we can just let this be and come back to it when everything is stable.

Regards,
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-16 10:32         ` Masahiro Yamada
@ 2017-05-17 10:09           ` Simon Glass
  2017-05-20 16:50             ` Masahiro Yamada
  0 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-17 10:09 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 16 May 2017 at 04:32, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Hi Simon,
>
>
> 2017-05-13 10:11 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi Masahiro,
>>
>> On 10 May 2017 at 20:21, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>>> Hi Simon
>>>
>>> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>>>> On Mon, May 01, 2017 at 09:18:48AM -0600, Simon Glass wrote:
>>>>
>>>>> It is good practice to include common.h as the first header. This ensures
>>>>> that required features like the DECLARE_GLOBAL_DATA_PTR macro,
>>>>> configuration options and common types are available.
>>>>>
>>>>> Fix up some files which currently don't do this. This is necessary because
>>>>> driver model will soon start using global data and configuration in the
>>>>> dm/ofnode.h header file, included via dm.h.
>>>>>
>>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>>
>>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>>
>>>
>>> NACK.
>>>
>>> include/common.h is really bad idea
>>> and this is a step backward.
>>>
>>> If you need something in your include/dm/ofnode.h
>>> you should include needed header(s) from it.
>>>
>>> Why do you need to touch lots of C files?
>>
>> All of these files fail to build when they cannot see global_data.
>
> Because you added DECLARE_GLOBAL_DATA_PTR in 8/9.

Yes that's right.

>
> If you always make sure each header is self-contained,
> you do not have to touch so many C files.

It depends what the objective is. If you are not careful you can end
up including lots of header files all the time.

It we are trying to reduce this (and I agree it is a good goal) we
should measure it, e.g. by having a buildman feature to count the
number of header files / lines including each each build.

>
>
>
>> Also we need access to CONFIG options in dm.h.
>
> DM related options are new enough to exist in Kconfig.
> No explicit header inclusion is required to reference options from Kconfig.

OK that makes sense and I certainly want to point to the future.

>
> To reference legacy options that have not converted to Kconfig,
> <config.h> should be included.
> <common.h> also works, but it is sometimes over-inclusion.

OK

>
>
>> So I think we have to
>> have common.h - it is (I think) a rule that all files should have
>> common.h and have it first, because any other header.
>
> I disagree.
> The concept of <common.h> is wrong.
> <common.h> always comes first in the inclusion list.  This is wrong too.
>
> For example in Linux, includes are often sorted alphabetically.
> This makes sense because headers can theoretically be included in any order.
>
>
> I always make efforts to reduce the dependency on <common.h>.
> <common.h> is missing from the code I wrote, and it is intentional.

I think I can include asm/global_data in the header instead, so I can
drop this patch.

Regards,
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-16 10:35   ` Masahiro Yamada
@ 2017-05-20  2:29     ` Simon Glass
  2017-05-20 16:17       ` Masahiro Yamada
  0 siblings, 1 reply; 35+ messages in thread
From: Simon Glass @ 2017-05-20  2:29 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 16 May 2017 at 04:35, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>
> Hi Simon,
>
>
> 2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:
> > With live tree we need a struct device_node * to reference a node. With
> > the existing flat tree, we need an int offset. We need to unify these into
> > a single value which can represent both.
> >
> > Add an ofnode union for this and adjust existing code to move to this.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v2: None
> >
> >  drivers/core/device.c |   2 +-
> >  drivers/core/root.c   |   2 +-
> >  include/dm.h          |   1 +
> >  include/dm/device.h   |  14 +++++--
> >  include/dm/ofnode.h   | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  5 files changed, 113 insertions(+), 6 deletions(-)
> >  create mode 100644 include/dm/ofnode.h

> When you add a new header, please make sure it is self-contained.
>
> You use bool for offset_toofnode() and ofnode_equal().
> So you need to include <stdbool.h> from this header.
>
> (or, use "int" for the return type.)

I'm wondering about this problem:

In general we want to minimise the size of headers included by U-Boot.
For something like ofnode which is used by several header files we end
up including it many times, once per header.

With dm.h we avoid this since the header is only included ones (and in
the correct order).

What is the best solution to this?

Regards,
Simon

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes
  2017-05-20  2:29     ` Simon Glass
@ 2017-05-20 16:17       ` Masahiro Yamada
  0 siblings, 0 replies; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-20 16:17 UTC (permalink / raw)
  To: u-boot

Hi Simon,


2017-05-20 11:29 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 16 May 2017 at 04:35, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>>
>> Hi Simon,
>>
>>
>> 2017-05-02 0:18 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> > With live tree we need a struct device_node * to reference a node. With
>> > the existing flat tree, we need an int offset. We need to unify these into
>> > a single value which can represent both.
>> >
>> > Add an ofnode union for this and adjust existing code to move to this.
>> >
>> > Signed-off-by: Simon Glass <sjg@chromium.org>
>> > ---
>> >
>> > Changes in v2: None
>> >
>> >  drivers/core/device.c |   2 +-
>> >  drivers/core/root.c   |   2 +-
>> >  include/dm.h          |   1 +
>> >  include/dm/device.h   |  14 +++++--
>> >  include/dm/ofnode.h   | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++
>> >  5 files changed, 113 insertions(+), 6 deletions(-)
>> >  create mode 100644 include/dm/ofnode.h
>
>> When you add a new header, please make sure it is self-contained.
>>
>> You use bool for offset_toofnode() and ofnode_equal().
>> So you need to include <stdbool.h> from this header.
>>
>> (or, use "int" for the return type.)
>
> I'm wondering about this problem:
>
> In general we want to minimise the size of headers included by U-Boot.
> For something like ofnode which is used by several header files we end
> up including it many times, once per header.

It is no problem if the header body is surrounded by an include guard.

With include guards, each header is
_parsed_ only once even if _included_ multiple times.


> With dm.h we avoid this since the header is only included ones (and in
> the correct order).

Generally, we should not rely on a specific include order.

Even if we compel drivers to include dm.h,
each of dm/{device.h, platdata.h, uclass.h} should be self-contained.


We usually sort includes alphabetically,
but technically it should work in any order.
It would be possible if each header is self-contained.



> What is the best solution to this?


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h
  2017-05-17 10:09           ` Simon Glass
@ 2017-05-20 16:50             ` Masahiro Yamada
  0 siblings, 0 replies; 35+ messages in thread
From: Masahiro Yamada @ 2017-05-20 16:50 UTC (permalink / raw)
  To: u-boot

Hi Simon

2017-05-17 19:09 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 16 May 2017 at 04:32, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>> Hi Simon,
>>
>>
>> 2017-05-13 10:11 GMT+09:00 Simon Glass <sjg@chromium.org>:
>>> Hi Masahiro,
>>>
>>> On 10 May 2017 at 20:21, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>>>> Hi Simon
>>>>
>>>> 2017-05-11 6:43 GMT+09:00 Tom Rini <trini@konsulko.com>:
>>>>> On Mon, May 01, 2017 at 09:18:48AM -0600, Simon Glass wrote:
>>>>>
>>>>>> It is good practice to include common.h as the first header. This ensures
>>>>>> that required features like the DECLARE_GLOBAL_DATA_PTR macro,
>>>>>> configuration options and common types are available.
>>>>>>
>>>>>> Fix up some files which currently don't do this. This is necessary because
>>>>>> driver model will soon start using global data and configuration in the
>>>>>> dm/ofnode.h header file, included via dm.h.
>>>>>>
>>>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>>>
>>>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>>>
>>>>
>>>> NACK.
>>>>
>>>> include/common.h is really bad idea
>>>> and this is a step backward.
>>>>
>>>> If you need something in your include/dm/ofnode.h
>>>> you should include needed header(s) from it.
>>>>
>>>> Why do you need to touch lots of C files?
>>>
>>> All of these files fail to build when they cannot see global_data.
>>
>> Because you added DECLARE_GLOBAL_DATA_PTR in 8/9.
>
> Yes that's right.
>
>>
>> If you always make sure each header is self-contained,
>> you do not have to touch so many C files.
>
> It depends what the objective is. If you are not careful you can end
> up including lots of header files all the time.

When we end up including lots of unnecessary things,
it is a sign that we need cleanups.
This would happen if we put unrelated misc things into a single header.

So, cleaning of <common.h> as you did
is really nice.



>
> I think I can include asm/global_data in the header instead, so I can
> drop this patch.

Agree.
I think #include <asm/global.h> is the right thing to do.





-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2017-05-20 16:50 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 15:18 [U-Boot] [PATCH v2 0/9] dm: Prepare for supporting a live device tree Simon Glass
2017-05-01 15:18 ` [U-Boot] [PATCH v2 1/9] dm: Use dm.h header when driver mode is used Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-11  2:12     ` Masahiro Yamada
2017-05-13  1:11       ` Simon Glass
2017-05-16  9:56         ` Masahiro Yamada
2017-05-17 10:07           ` Simon Glass
2017-05-01 15:18 ` [U-Boot] [PATCH v2 2/9] dm: core: Move dev_get_addr() etc. into a separate file Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-16 10:04   ` Masahiro Yamada
2017-05-17 10:09     ` Simon Glass
2017-05-01 15:18 ` [U-Boot] [PATCH v2 3/9] dm: Rename dev_addr..() functions Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-01 15:18 ` [U-Boot] [PATCH v2 4/9] atmel: Fix up use of dm_scan_fdt_node() Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-01 15:18 ` [U-Boot] [PATCH v2 5/9] Fix up inclusion of common.h Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-11  2:21     ` Masahiro Yamada
2017-05-13  1:11       ` Simon Glass
2017-05-16 10:32         ` Masahiro Yamada
2017-05-17 10:09           ` Simon Glass
2017-05-20 16:50             ` Masahiro Yamada
2017-05-01 15:18 ` [U-Boot] [PATCH v2 6/9] dm: core: Dont export dm_scan_fdt_node() Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-01 15:18 ` [U-Boot] [PATCH v2 7/9] dm: core: Replace of_offset with accessor (part 2) Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-01 15:18 ` [U-Boot] [PATCH v2 8/9] dm: core: Add ofnode to represent device tree nodes Simon Glass
2017-05-10 21:43   ` Tom Rini
2017-05-11  2:33   ` Masahiro Yamada
2017-05-13  1:11     ` Simon Glass
2017-05-16 10:35   ` Masahiro Yamada
2017-05-20  2:29     ` Simon Glass
2017-05-20 16:17       ` Masahiro Yamada
2017-05-01 15:18 ` [U-Boot] [PATCH v2 9/9] dm: core: Adjust device_bind_common() to take an ofnode Simon Glass
2017-05-10 21:43   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.