]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Access device ofnode through functions
authorSimon Glass <sjg@chromium.org>
Sat, 19 Dec 2020 17:40:14 +0000 (10:40 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 5 Jan 2021 19:24:41 +0000 (12:24 -0700)
At present ofnode is present in the device even if it is never used. With
of-platdata this field is not used, so can be removed. In preparation for
this, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
50 files changed:
arch/arm/mach-stm32mp/pwr_regulator.c
board/synopsys/hsdk/clk-lib.c
drivers/ata/mtk_ahci.c
drivers/clk/meson/axg.c
drivers/clk/meson/g12a.c
drivers/clk/meson/gxbb.c
drivers/core/device.c
drivers/core/root.c
drivers/gpio/mpc8xxx_gpio.c
drivers/gpio/octeon_gpio.c
drivers/misc/swap_case.c
drivers/mmc/octeontx_hsmmc.c
drivers/mtd/nand/raw/octeontx_nand.c
drivers/mtd/nand/spi/core.c
drivers/net/fm/eth.c
drivers/net/fsl_enetc.c
drivers/net/fsl_enetc_mdio.c
drivers/net/mdio-ipq4019.c
drivers/net/mdio_mux_i2creg.c
drivers/net/mvmdio.c
drivers/net/octeontx/smi.c
drivers/net/tsec.c
drivers/phy/phy-ti-am654.c
drivers/power/domain/meson-ee-pwrc.c
drivers/power/domain/meson-gx-pwrc-vpu.c
drivers/power/regulator/pbias_regulator.c
drivers/pwm/pwm-meson.c
drivers/reset/reset-socfpga.c
drivers/spi/fsl_dspi.c
drivers/tee/optee/core.c
drivers/usb/cdns3/core.c
drivers/usb/dwc3/core.c
drivers/usb/dwc3/dwc3-generic.c
drivers/usb/dwc3/dwc3-meson-g12a.c
drivers/usb/dwc3/dwc3-meson-gxl.c
drivers/usb/gadget/dwc2_udc_otg.c
drivers/usb/host/dwc3-octeon-glue.c
drivers/usb/host/dwc3-sti-glue.c
drivers/usb/host/ehci-mx6.c
drivers/usb/host/xhci-dwc3.c
drivers/usb/mtu3/mtu3_core.c
drivers/usb/mtu3/mtu3_plat.c
drivers/usb/musb-new/ti-musb.c
drivers/video/nexell_display.c
drivers/video/rockchip/rk_mipi.c
include/dm/device.h
include/dm/read.h
include/linux/mtd/mtd.h
net/mdio-mux-uclass.c
net/mdio-uclass.c

index af6ea4396466f9ad3dbf70e2add13332a2427d41..766ed95f1a6f853376b599552543d3974dbaf46e 100644 (file)
@@ -81,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev)
 {
        int children;
 
-       children = pmic_bind_children(dev, dev->node, pwr_children_info);
+       children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info);
        if (!children)
                dev_dbg(dev, "no child found\n");
 
index 1c74bfb93a3b6762fcd88e3b7833f797dd244fa4..bd43179fc796c29ffe382b01da5ce51be914817d 100644 (file)
@@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl)
        /* Dummy fmeas device, just to be able to use standard clk_* api */
        struct udevice fmeas = {
                .name = "clk-fmeas",
-               .node = ofnode_path("/clk-fmeas"),
        };
+       dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas"));
 
        ret = clk_get_by_name(&fmeas, name, &clk);
        if (ret) {
index cd28e0cae37de72e51a667dc7b58329b70da0321..46b7677783fe6acfe3608aa887affab358115027 100644 (file)
@@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv,
                                   SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN);
        }
 
-       ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map);
+       ofnode_read_u32(dev_ofnode(dev), "ports-implemented",
+                       &hpriv->port_map);
        return 0;
 }
 
index 82068578ffb990099de19134d22f82de95e1cccb..d6da59d269b0e09862ddf5dae45192d8ea4330f6 100644 (file)
@@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
        struct meson_clk *priv = dev_get_priv(dev);
 
-       priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->map))
                return PTR_ERR(priv->map);
 
index 01b22abc34d17e8990dd3e806e433397705bc287..5058db1a47b976cbde7a5a927fe3dbab2b7f1f09 100644 (file)
@@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
        struct meson_clk *priv = dev_get_priv(dev);
 
-       priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->map))
                return PTR_ERR(priv->map);
 
index 2a20541dcb466254ad071b5e778ca5e861a10f7f..e379540deee77bff47e29310cff6a56394c64e02 100644 (file)
@@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev)
 {
        struct meson_clk *priv = dev_get_priv(dev);
 
-       priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->map))
                return PTR_ERR(priv->map);
 
index bd4ecc9e24dab0033216b2d9380c5795346ffaf2..6a9bee093d07ed7559fca71197786e0e21d09d04 100644 (file)
@@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
        dev_set_plat(dev, plat);
        dev->driver_data = driver_data;
        dev->name = name;
-       dev->node = node;
+       dev_set_ofnode(dev, node);
        dev->parent = parent;
        dev->driver = drv;
        dev->uclass = uc;
index 9ef242979baef3ebc32cee48e6ac41a54552928a..fe7359433f6dda8b3de29ebf79b0c7e659b53293 100644 (file)
@@ -148,7 +148,7 @@ int dm_init(bool of_live)
        if (ret)
                return ret;
        if (CONFIG_IS_ENABLED(OF_CONTROL))
-               DM_ROOT_NON_CONST->node = ofnode_root();
+               dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root());
        ret = device_probe(DM_ROOT_NON_CONST);
        if (ret)
                return ret;
index 2bc1a0d57160a9a1f3d6d3d3491500833059aa9d..a964347fa32c014f33981170fcb1effcd56eeb6f 100644 (file)
@@ -191,7 +191,7 @@ static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
        u32 i;
        u32 reg[4];
 
-       if (ofnode_read_bool(dev->node, "little-endian"))
+       if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))
                data->little_endian = true;
 
        if (data->little_endian)
@@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev)
        if (!str)
                return -ENOMEM;
 
-       if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) {
+       if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
                unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
                        - sizeof(u32);
 
index 958516d8f8e3b8b62e66b192b04f9064fd8b5bad..42eae79d8c4227098150e0b4ed61433fbe18a5e9 100644 (file)
@@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev)
                        GPIO_CONST_GPIOS_MASK;
        } else {
                priv->base = dev_remap_addr(dev);
-               uc_priv->gpio_count = ofnode_read_u32_default(dev->node,
+               uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev),
                                                              "nr-gpios", 32);
        }
 
index abea0e761397d4879eda4b513d26d008819e9958..3cbc8f37ec5025758240a5d87b39335b709f58fc 100644 (file)
@@ -54,7 +54,7 @@ struct swap_case_priv {
 
 static int sandbox_swap_case_use_ea(const struct udevice *dev)
 {
-       return !!ofnode_get_property(dev->node, "use-ea", NULL);
+       return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL);
 }
 
 /* Please keep these macros in sync with ea_regs below */
index f3da6af9090be8d8aa4e5d8c4400e42e170d94c2..442ca493d76b75b982fa02b36de62fb7896141a4 100644 (file)
@@ -3439,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage)
  */
 static bool octeontx_mmc_get_valid(struct udevice *dev)
 {
-       const char *stat = ofnode_read_string(dev->node, "status");
+       const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
 
        if (!stat || !strncmp(stat, "ok", 2))
                return true;
@@ -3461,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev)
        uint low, high;
        char env_name[32];
        int err;
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
        int bus_width = 1;
        ulong new_max_freq;
 
        debug("%s(%s)", __func__, dev->name);
        slot->cfg.name = dev->name;
 
-       slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency",
+       slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
+                                                 "max-frequency",
                                                  26000000);
        snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
                 slot->bus_id);
@@ -3486,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 
        if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
                slot->hs400_tuning_block =
-                       ofnode_read_s32_default(dev->node,
+                       ofnode_read_s32_default(dev_ofnode(dev),
                                                "marvell,hs400-tuning-block",
                                                -1);
                debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
                      dev->name, slot->hs400_tuning_block);
 
                slot->hs200_tap_adj =
-                       ofnode_read_s32_default(dev->node,
+                       ofnode_read_s32_default(dev_ofnode(dev),
                                                "marvell,hs200-tap-adjust", 0);
                debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
                      slot->hs200_tap_adj);
                slot->hs400_tap_adj =
-                       ofnode_read_s32_default(dev->node,
+                       ofnode_read_s32_default(dev_ofnode(dev),
                                                "marvell,hs400-tap-adjust", 0);
                debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
                      slot->hs400_tap_adj);
        }
 
-       err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2);
+       err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
+                                   voltages, 2);
        if (err) {
                slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
        } else {
@@ -3756,14 +3758,15 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
                pr_err("%s: No device tree information found\n", __func__);
                return -1;
        }
-       host->node = dev->node;
+       host->node = dev_ofnode(dev);
        host->last_slotid = -1;
        if (otx_is_platform(PLATFORM_ASIM))
                host->is_asim = true;
        if (otx_is_platform(PLATFORM_EMULATOR))
                host->is_emul = true;
        host->dma_wait_delay =
-               ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1);
+               ofnode_read_u32_default(dev_ofnode(dev),
+                                       "marvell,dma-wait-delay", 1);
        /* Force reset of eMMC */
        writeq(0, host->base_addr + MIO_EMM_CFG());
        debug("%s: Clearing MIO_EMM_CFG\n", __func__);
@@ -3824,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
        struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
        struct octeontx_mmc_slot *slot;
        struct mmc_uclass_priv *upriv;
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
        u32 bus_id;
        char name[16];
        int err;
index 96a5fe6592a05a618f2730cf0bc2a8ced5b48308..64433cf6ccc3bc211409feecb44a70a9ec79ebb1 100644 (file)
@@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev,
 static int octeontx_nfc_chips_init(struct octeontx_nfc *tn)
 {
        struct udevice *dev = tn->dev;
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
        ofnode nand_node;
        int nr_chips = of_get_child_count(node);
        int ret;
index ab9a24ed5b5d09aa2134add73c47f1feabf9cc15..cd12376ab82346e0551aa7868d6b65dd0e9c2577 100644 (file)
@@ -1173,7 +1173,7 @@ static int spinand_probe(struct udevice *dev)
                return -ENOMEM;
        sprintf(mtd->name, "spi-nand%d", spi_nand_idx++);
        spinand->slave = slave;
-       spinand_set_ofnode(spinand, dev->node);
+       spinand_set_ofnode(spinand, dev_ofnode(dev));
 #endif
 
        ret = spinand_init(spinand);
index a10f87eefc54510fa6ffbf0b700920579a72f202..0e89e663f716cbf977dd9707d6eb5f25c529243e 100644 (file)
@@ -957,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev)
 {
        const char *if_str;
 
-       if_str = ofnode_read_string(dev->node, "phy-connection-type");
+       if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
        debug("MAC system interface mode %s\n", if_str);
 
        return phy_get_interface_by_name(if_str);
@@ -969,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev)
        char mac_name[11];
        u32 fm, num;
 
-       if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) {
+       if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) {
                printf("FMan node property cell-index missing\n");
                return -EINVAL;
        }
index 2e684e58393ea410e7c725c52df358e8001e2263..f6fc7801b95bca2c2d4622f76a915dec8c462955 100644 (file)
@@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev)
         * and some are not, use different naming scheme - enetc-N based on
         * PCI function # and enetc#N based on interface count
         */
-       if (ofnode_valid(dev->node))
+       if (ofnode_valid(dev_ofnode(dev)))
                sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
        else
                sprintf(name, "enetc#%u", eth_num_devices++);
@@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev)
                        mdio_register(&priv->imdio);
        }
 
-       if (!ofnode_valid(dev->node)) {
+       if (!ofnode_valid(dev_ofnode(dev))) {
                enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n");
                return;
        }
 
-       if_str = ofnode_read_string(dev->node, "phy-mode");
+       if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
        if (if_str)
                priv->if_type = phy_get_interface_by_name(if_str);
        else
@@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev)
 {
        struct enetc_priv *priv = dev_get_priv(dev);
 
-       if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) {
+       if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
                enetc_dbg(dev, "interface disabled\n");
                return -ENODEV;
        }
index 4da97b61d173c36f37c7762c5c6bcf58215e4bf8..3eb6ac9fc8f036c40dcad7a70d36873017a63b0e 100644 (file)
@@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev)
         * and some are not, use different naming scheme - enetc-N based on
         * PCI function # and enetc#N based on interface count
         */
-       if (ofnode_valid(dev->node))
+       if (ofnode_valid(dev_ofnode(dev)))
                sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev)));
        else
                sprintf(name, "emdio#%u", eth_num_devices++);
index 13a8856286a29decc9a48fc34841acd1e6db3ef1..50134b4d9b6a17869bd055bf1e8d1cb3f3cf6318 100644 (file)
@@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = {
 
 static int ipq4019_mdio_bind(struct udevice *dev)
 {
-       if (ofnode_valid(dev->node))
-               device_set_name(dev, ofnode_get_name(dev->node));
+       if (ofnode_valid(dev_ofnode(dev)))
+               device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
        return 0;
 }
index f8557dd2c49c11d31503104719f764bacebd0367..3654230118f12c62af40b3f3e0e1c98996d4ac3f 100644 (file)
@@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev)
        }
 
        /* parent should be an I2C chip, grandparent should be an I2C bus */
-       chip_node = ofnode_get_parent(dev->node);
+       chip_node = ofnode_get_parent(dev_ofnode(dev));
        bus_node = ofnode_get_parent(chip_node);
 
        err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus);
index 005f28f1b25400520614f10aba977ad666abce32..96f8dc62b5693a6893720a3d1f5b3ef4a783ef76 100644 (file)
@@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg,
  */
 static int mvmdio_bind(struct udevice *dev)
 {
-       if (ofnode_valid(dev->node))
-               device_set_name(dev, ofnode_get_name(dev->node));
+       if (ofnode_valid(dev_ofnode(dev)))
+               device_set_name(dev, ofnode_get_name(dev_ofnode(dev)));
 
        return 0;
 }
index d1582b968bfade3f69cfa3ace76a92bfb8b38191..58436419f1b946e1fc84c11f894047e74eb414fe 100644 (file)
@@ -313,7 +313,7 @@ read_error:
 
 int octeontx_smi_probe(struct udevice *dev)
 {
-       int ret, subnode, cnt = 0, node = dev->node.of_offset;
+       int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset;
        struct mii_dev *bus;
        struct octeontx_smi_priv *priv;
        pci_dev_t bdf = dm_pci_get_bdf(dev);
index 2d124732cf07be5350f559a9df9d048bc009012b..ec486893725753a84425641c5bfa4ac609b2909b 100644 (file)
@@ -707,7 +707,8 @@ static int init_phy(struct tsec_private *priv)
                tsec_configure_serdes(priv);
 
 #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
-       if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link")))
+       if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
+                                            "fixed-link")))
                phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
        else
                phydev = dm_eth_phy_connect(priv->dev);
index 8e35ea14750ada3756a3c71c74e6b8b73a7c6c6a..82010e7c96e7061de72efbb96f73b6aca477922b 100644 (file)
@@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev)
 
        ret = device_bind_driver_to_node(dev->parent,
                                         "ti-serdes-am654-mux-clk",
-                                        dev_read_name(dev), dev->node,
+                                        dev_read_name(dev), dev_ofnode(dev),
                                         NULL);
        if (ret) {
                dev_err(dev, "%s: not able to bind clock driver\n", __func__);
index 2e7ab671286f298e98f24b6ebe4ec50dc68545a0..ef8274ce96d796f91ab20f2bab8545a9415bb6e1 100644 (file)
@@ -397,11 +397,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
        if (!priv->data)
                return -EINVAL;
 
-       priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->regmap_hhi))
                return PTR_ERR(priv->regmap_hhi);
 
-       ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl",
+       ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
                              &ao_phandle);
        if (ret)
                return ret;
index 40947c66f3113ccc58d37f0d6b31833d3f9baa12..eb94af2cf839242b8ebcc5972c0b6223632d7a0a 100644 (file)
@@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
        ofnode hhi_node;
        int ret;
 
-       priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
+       priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
        if (IS_ERR(priv->regmap_ao))
                return PTR_ERR(priv->regmap_ao);
 
-       ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
+       ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
                              &hhi_phandle);
        if (ret)
                return ret;
index 6f0d0a59ff42bd5100c46dfe7f63029d87a0fd14..5bf186e4d4c1b4739baad4b2ce5aa489f9dbb2b0 100644 (file)
@@ -103,7 +103,8 @@ static int pbias_bind(struct udevice *dev)
 {
        int children;
 
-       children = pmic_bind_children(dev, dev->node, pmic_children_info);
+       children = pmic_bind_children(dev, dev_ofnode(dev),
+                                     pmic_children_info);
        if (!children)
                debug("%s: %s - no child found\n", __func__, dev->name);
 
index 58b7469f977abc8c22a8afc5140eeb718ff72096..03eeacc286d766ff2b9a2a1e073c7d7bcdb21b8f 100644 (file)
@@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev)
                                        if (strcmp(cdev->driver->name, "fixed_rate_clock"))
                                                continue;
 
-                                       str = ofnode_read_string(cdev->node, "clock-output-names");
+                                       str = ofnode_read_string(dev_ofnode(cdev),
+                                                                "clock-output-names");
                                        if (!str)
                                                continue;
 
                                        if (!strcmp(str, "xtal")) {
                                                err = uclass_get_device_by_ofnode(UCLASS_CLK,
-                                                                                 cdev->node,
+                                                                                 dev_ofnode(cdev),
                                                                                  &cdev);
                                                if (err) {
                                                        printf("%s%d: Failed to get xtal clk\n", __func__, i);
@@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev)
                                        return -EINVAL;
                                }
 
-                               err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev);
+                               err = uclass_get_device_by_ofnode(UCLASS_CLK,
+                                                                 dev_ofnode(cdev),
+                                                                 &cdev);
                                if (err) {
                                        printf("%s%d: Failed to get clk controller\n", __func__, i);
                                        return err;
index c64c9b5917cc61619e8dff330cbb4aed76a56f01..98450db94b2020f9481eb89afe2c40a7738eb45d 100644 (file)
@@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev)
         * Bind it to the node, too, so that it can get its base address.
         */
        ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
-                                        dev->node, &sys_child);
+                                        dev_ofnode(dev), &sys_child);
        if (ret)
                debug("Warning: No sysreset driver: ret=%d\n", ret);
 
index b8c0216b39d19a666f1f104d36819ebb1583b748..c17a5522bccd06156cac4cea967472966860a03b 100644 (file)
@@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev)
                return -EINVAL;
        }
 
-       ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay);
-       ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay);
+       ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay",
+                       &cs_sck_delay);
+       ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay",
+                       &sck_cs_delay);
 
        /* Set PCS to SCK delay scale values */
        ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk);
index 7c38d6e0527231069f0c4e832952bb2b9f412ba5..b898c32edc0b61c3d2e4875d3c9061acb3781455 100644 (file)
@@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)
        const char *method;
 
        debug("optee: looking for conduit method in DT.\n");
-       method = ofnode_get_property(dev->node, "method", NULL);
+       method = ofnode_get_property(dev_ofnode(dev), "method", NULL);
        if (!method) {
                debug("optee: missing \"method\" property\n");
                return ERR_PTR(-ENXIO);
index e861c82f7e17aca3fa018ecda18a263885c772f0..798a21793f711c890abaedb9c7942ceb1e5d8a4e 100644 (file)
@@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
        enum usb_dr_mode dr_mode;
        int ret = 0;
 
-       dr_mode = usb_get_dr_mode(dev->node);
+       dr_mode = usb_get_dr_mode(dev_ofnode(dev));
        cdns->role = USB_ROLE_NONE;
 
        /*
@@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       node = ofnode_by_compatible(parent->node, "cdns,usb3");
+       node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3");
        if (!ofnode_valid(node)) {
                ret = -ENODEV;
                goto fail;
index 2e003530a15eb2ccfb182e11289ebb592f1c049e..dfd7cf683f723b3f2e0b2f86a185c55e8e74cdc7 100644 (file)
@@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc)
         */
        hird_threshold = 12;
 
-       dwc->hsphy_mode = usb_get_phy_mode(dev->node);
+       dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev));
 
        dwc->has_lpm_erratum = dev_read_bool(dev,
                                "snps,has-lpm-erratum");
index 459add80c58c2cb1067136d1efb2ec293eed5350..39e931f634d92733ca686ef2454150296f47aa01 100644 (file)
@@ -108,7 +108,7 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_of_to_plat(struct udevice *dev)
 {
        struct dwc3_generic_plat *plat = dev_get_plat(dev);
-       ofnode node = dev->node;
+       ofnode node = dev_ofnode(dev);
 
        plat->base = dev_read_addr(dev);
 
@@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       ofnode_for_each_subnode(node, parent->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(parent)) {
                const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
                struct udevice *dev;
@@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev)
        while (child) {
                enum usb_dr_mode dr_mode;
 
-               dr_mode = usb_get_dr_mode(child->node);
+               dr_mode = usb_get_dr_mode(dev_ofnode(child));
                device_find_next_child(&child);
                if (ops && ops->select_dr_mode)
                        ops->select_dr_mode(dev, index, dr_mode);
index acc7866b64a7cf29ba69470224f86a17ddd89bfd..6f99fb27f3f7521a4df2f230d34234ef6a0338b3 100644 (file)
@@ -395,7 +395,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
        }
 #endif
 
-       priv->otg_mode = usb_get_dr_mode(dev->node);
+       priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
        ret = dwc3_meson_g12a_usb_init(priv);
        if (ret)
index b63cc235f7e0b8139a08ecf7d9cfc9160e96dfc2..08467d6210b688726870ab17bdf7700d5dce567b 100644 (file)
@@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev)
        if (ret)
                return ret;
 
-       priv->otg_mode = usb_get_dr_mode(dev->node);
+       priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev));
 
        if (priv->otg_mode == USB_DR_MODE_PERIPHERAL)
                priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL;
index 4771b1e931234624228c611e150e963e59e78b91..e3871e381e1493633432162532367e7717c63199 100644 (file)
@@ -987,8 +987,8 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
        void (*set_params)(struct dwc2_plat_otg_data *data);
        int ret;
 
-       if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
-           usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
+       if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL &&
+           usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) {
                dev_dbg(dev, "Invalid mode\n");
                return -ENODEV;
        }
index c3cac9c5abdbb691bf666b33604b5aef9da2e76e..742e156cbb94cdd78b0346dc54be5a8e62794ed3 100644 (file)
@@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev)
 
        /* Find snps,dwc3 node from subnode */
        dwc3_node = ofnode_null();
-       ofnode_for_each_subnode(node, dev->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(dev)) {
                if (ofnode_device_is_compatible(node, "snps,dwc3"))
                        dwc3_node = node;
        }
index deb820a0f846e1af5865c384c11df6968577c2dc..e5c6a1a67d62e9799e6f1b4db50795951c0298f7 100644 (file)
@@ -108,7 +108,8 @@ static int sti_dwc3_glue_of_to_plat(struct udevice *dev)
        int ret;
        u32 reg[4];
 
-       ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
+       ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg,
+                                   ARRAY_SIZE(reg));
        if (ret) {
                pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret);
                return ret;
@@ -154,7 +155,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
        ofnode node, dwc3_node;
 
        /* Find snps,dwc3 node from subnode */
-       ofnode_for_each_subnode(node, dev->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(dev)) {
                if (ofnode_device_is_compatible(node, "snps,dwc3"))
                        dwc3_node = node;
        }
index d2f49cf4690101e58f3202c1e9816ac4c1c4917e..ef3a63afa4406f9a0418eb54aa2fe0adf656f818 100644 (file)
@@ -523,7 +523,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
        struct usb_plat *plat = dev_get_plat(dev);
        enum usb_dr_mode dr_mode;
 
-       dr_mode = usb_get_dr_mode(dev->node);
+       dr_mode = usb_get_dr_mode(dev_ofnode(dev));
 
        switch (dr_mode) {
        case USB_DR_MODE_HOST:
index 59408e4e50ec38650f9ed4e5b159d6aeb55b9691..3e0ae80cece076a40457bded275540f9d1afab4a 100644 (file)
@@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 
        writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
-       dr_mode = usb_get_dr_mode(dev->node);
+       dr_mode = usb_get_dr_mode(dev_ofnode(dev));
        if (dr_mode == USB_DR_MODE_UNKNOWN)
                /* by default set dual role mode to HOST */
                dr_mode = USB_DR_MODE_HOST;
index 28136f88f450f35d8ac2415163ba048185adc793..2f5cc9b1480385ac0c2ef09c541dd50dc93e448e 100644 (file)
@@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
        mtu->ippc_base = ssusb->ippc_base;
        mtu->mac_base = ssusb->mac_base;
        mtu->ssusb = ssusb;
-       mtu->max_speed = usb_get_maximum_speed(dev->node);
+       mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev));
        mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus");
 
        ret = mtu3_hw_init(mtu);
index c951107b20133444a44e3d236071ca881add8500..b097471f3d4e9b2f0b4a920f571a747f0a3adcde 100644 (file)
@@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb)
                return -ENODEV;
        }
 
-       ssusb->dr_mode = usb_get_dr_mode(child->node);
+       ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child));
 
        if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN ||
                ssusb->dr_mode == USB_DR_MODE_OTG)
@@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       node = ofnode_by_compatible(parent->node, "mediatek,ssusb");
+       node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb");
        if (!ofnode_valid(node))
                return -ENODEV;
 
index 81b12fadfc1c47d42d744ee54e3159e5e50265b5..75cf1811f7aa11aabfc6f8c74beb6a911ea77614 100644 (file)
@@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
        ofnode node;
        int ret;
 
-       ofnode_for_each_subnode(node, parent->node) {
+       ofnode_for_each_subnode(node, dev_ofnode(parent)) {
                struct udevice *dev;
                const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
index 00e2c36f376bc80145ba8441988681908d1d1cc7..b47bef3578f7d5dbe0d586d31209d985b4fc5636 100644 (file)
@@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void)
                      __func__);
                return NULL;
        }
-       node = dev->node.of_offset;
+       node = dev_ofnode(dev).of_offset;
 
        if (CONFIG_IS_ENABLED(OF_CONTROL)) {
                ret = nx_display_parse_dt(dev, dp, plat);
index d125a5ba737456125da77444f95378a8d18ae268..159201a59168ae3537042d0c07d686047e9b537c 100644 (file)
@@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev,
        rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
 
        /* Set dpi color coding depth 24 bit */
-       timing_node = ofnode_find_subnode(dev->node, "display-timings");
+       timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings");
        node = ofnode_first_subnode(timing_node);
 
        val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
index 4a1224bcc26bc94b0c1c608017cbca2caed803df..1b274206ea356ce6bceeb30fd2769fc147047d5f 100644 (file)
@@ -200,7 +200,11 @@ static inline void dev_bic_flags(struct udevice *dev, u32 bic)
  */
 static inline ofnode dev_ofnode(const struct udevice *dev)
 {
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
        return dev->node;
+#else
+       return ofnode_null();
+#endif
 }
 
 /* Returns non-zero if the device is active (probed and not removed) */
@@ -208,12 +212,27 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
 
 static inline int dev_of_offset(const struct udevice *dev)
 {
-       return ofnode_to_offset(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       return ofnode_to_offset(dev_ofnode(dev));
+#else
+       return -1;
+#endif
 }
 
 static inline bool dev_has_ofnode(const struct udevice *dev)
 {
-       return ofnode_valid(dev->node);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       return ofnode_valid(dev_ofnode(dev));
+#else
+       return false;
+#endif
+}
+
+static inline void dev_set_ofnode(struct udevice *dev, ofnode node)
+{
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       dev->node = node;
+#endif
 }
 
 static inline int dev_seq(const struct udevice *dev)
index d5cdd87911d73a949eaeea1fde628697a08d5a82..fc987f775986f6c61a701de479558730759cf495 100644 (file)
@@ -21,7 +21,7 @@ struct resource;
 #if CONFIG_IS_ENABLED(OF_LIVE)
 static inline const struct device_node *dev_np(const struct udevice *dev)
 {
-       return ofnode_to_np(dev->node);
+       return ofnode_to_np(dev_ofnode(dev));
 }
 #else
 static inline const struct device_node *dev_np(const struct udevice *dev)
index 54d03d024029e9695ed8e12a9e3da1f030aa0384..927854950a03ef93b26351d65039aaef8b937f14 100644 (file)
@@ -334,12 +334,12 @@ struct mtd_info {
 #if IS_ENABLED(CONFIG_DM)
 static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node)
 {
-       mtd->dev->node = node;
+       dev_set_ofnode(mtd->dev, node);
 }
 
 static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd)
 {
-       return mtd->dev->node;
+       return dev_ofnode(mtd->dev);
 }
 #else
 struct device_node;
index 5f38f9fde4165058a176a5c7f2dad53bcb0e6f8e..780526c19e3f175d2f6368b5708174635efa5631 100644 (file)
@@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux)
        ofnode ch_node;
        int err, first_err = 0;
 
-       if (!ofnode_valid(mux->node)) {
+       if (!dev_has_ofnode(mux)) {
                debug("%s: no mux node found, no child MDIO busses set up\n",
                      __func__);
                return 0;
index d062382c2a95636c2102f98d6be29bbffc518f8b..697e5f838d945c55b4afe20f10d728d3d8bd1723 100644 (file)
@@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev)
        const char *dt_name;
 
        /* set a custom name for the MDIO device, if present in DT */
-       if (ofnode_valid(dev->node)) {
-               dt_name = ofnode_read_string(dev->node, "device-name");
+       if (dev_has_ofnode(dev)) {
+               dt_name = dev_read_string(dev, "device-name");
                if (dt_name) {
                        debug("renaming dev %s to %s\n", dev->name, dt_name);
                        device_set_name(dev, dt_name);
@@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
        struct phy_device *phy;
        int i;
 
-       if (!ofnode_valid(ethdev->node)) {
+       if (!dev_has_ofnode(ethdev)) {
                debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
                return NULL;
        }
 
        interface = PHY_INTERFACE_MODE_NONE;
        for (i = 0; i < PHY_MODE_STR_CNT; i++) {
-               if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]);
+               if_str = dev_read_string(ethdev, phy_mode_str[i]);
                if (if_str) {
                        interface = phy_get_interface_by_name(if_str);
                        break;