diff options
229 files changed, 576 insertions, 440 deletions
diff --git a/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c b/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c index ace10281166..cb6e03fa342 100644 --- a/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c +++ b/arch/arm/mach-aspeed/ast2500/sdram_ast2500.c @@ -392,7 +392,7 @@ static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev) priv->regs = regmap_get_range(map, 0); priv->phy = regmap_get_range(map, 1); - priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); if (!priv->clock_rate) { diff --git a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c index be3d7132020..89fd8e6bff1 100644 --- a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c +++ b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c @@ -1016,7 +1016,7 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev) #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3288_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; /* Rk3288 supports dual-channel, set default channel num to 2 */ diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 4f0f8fc5f8b..c1caa651742 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -103,7 +103,7 @@ static int altera_nios2_get_count(struct udevice *dev) static int altera_nios2_probe(struct udevice *dev) { const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); gd->cpu_clk = fdtdec_get_int(blob, node, "clock-frequency", 0); diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index e6d336f16ab..20614646f7f 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -203,6 +203,11 @@ stringarray = "one"; }; + spl-test4 { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test.2"; + }; + square { compatible = "demo-shape"; colour = "blue"; diff --git a/arch/x86/cpu/broadwell/cpu.c b/arch/x86/cpu/broadwell/cpu.c index 6977e860321..1b71d566c95 100644 --- a/arch/x86/cpu/broadwell/cpu.c +++ b/arch/x86/cpu/broadwell/cpu.c @@ -256,8 +256,8 @@ static void initialize_vr_config(struct udevice *dev) /* Set the slow ramp rate */ msr.hi &= ~(0x3 << (53 - 32)); /* Configure the C-state exit ramp rate */ - ramp = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,slow-ramp", - -1); + ramp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), + "intel,slow-ramp", -1); if (ramp != -1) { /* Configured slow ramp rate */ msr.hi |= ((ramp & 0x3) << (53 - 32)); @@ -271,8 +271,8 @@ static void initialize_vr_config(struct udevice *dev) } /* Set MIN_VID (31:24) to allow CPU to have full control */ msr.lo &= ~0xff000000; - min_vid = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,min-vid", - 0); + min_vid = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), + "intel,min-vid", 0); msr.lo |= (min_vid & 0xff) << 24; msr_write(MSR_VR_MISC_CONFIG, msr); @@ -562,7 +562,7 @@ static void configure_thermal_target(struct udevice *dev) int tcc_offset; msr_t msr; - tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "intel,tcc-offset", 0); /* Set TCC activaiton offset if supported */ diff --git a/arch/x86/cpu/broadwell/pch.c b/arch/x86/cpu/broadwell/pch.c index 317f57d3f98..16eac3daae6 100644 --- a/arch/x86/cpu/broadwell/pch.c +++ b/arch/x86/cpu/broadwell/pch.c @@ -190,14 +190,14 @@ static int pch_power_options(struct udevice *dev) debug("Set power %s after power failure.\n", state); /* GPE setup based on device tree configuration */ - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "intel,gpe0-en", enable, ARRAY_SIZE(enable)); if (ret) return -EINVAL; enable_all_gpe(enable[0], enable[1], enable[2], enable[3]); /* SMI setup based on device tree configuration */ - enable_alt_smi(dev, fdtdec_get_int(gd->fdt_blob, dev->of_offset, + enable_alt_smi(dev, fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "intel,alt-gp-smi-enable", 0)); return 0; diff --git a/arch/x86/cpu/broadwell/pinctrl_broadwell.c b/arch/x86/cpu/broadwell/pinctrl_broadwell.c index 2a3fcedd0db..881413f4769 100644 --- a/arch/x86/cpu/broadwell/pinctrl_broadwell.c +++ b/arch/x86/cpu/broadwell/pinctrl_broadwell.c @@ -51,7 +51,7 @@ static int broadwell_pinctrl_read_configs(struct udevice *dev, int node; debug("%s: starting\n", __func__); - for (node = fdt_first_subnode(blob, dev->of_offset); + for (node = fdt_first_subnode(blob, dev_of_offset(dev)); node > 0; node = fdt_next_subnode(blob, node)) { int phandle = fdt_get_phandle(blob, node); @@ -115,7 +115,7 @@ static int broadwell_pinctrl_read_pins(struct udevice *dev, int count = 0; int node; - for (node = fdt_first_subnode(blob, dev->of_offset); + for (node = fdt_first_subnode(blob, dev_of_offset(dev)); node > 0; node = fdt_next_subnode(blob, node)) { int len, i; diff --git a/arch/x86/cpu/broadwell/sata.c b/arch/x86/cpu/broadwell/sata.c index 2e4708262c1..10461d99a8c 100644 --- a/arch/x86/cpu/broadwell/sata.c +++ b/arch/x86/cpu/broadwell/sata.c @@ -235,7 +235,7 @@ static int broadwell_sata_ofdata_to_platdata(struct udevice *dev) { struct sata_platdata *plat = dev_get_platdata(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); plat->port_map = fdtdec_get_int(blob, node, "intel,sata-port-map", 0); plat->port0_gen3_tx = fdtdec_get_int(blob, node, diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c index 157f3de6d81..8be14b59291 100644 --- a/arch/x86/cpu/cpu_x86.c +++ b/arch/x86/cpu/cpu_x86.c @@ -17,7 +17,7 @@ int cpu_x86_bind(struct udevice *dev) struct cpu_platdata *plat = dev_get_parent_platdata(dev); struct cpuid_result res; - plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "intel,apic-id", -1); plat->family = gd->arch.x86; res = cpuid(1); diff --git a/arch/x86/cpu/intel_common/lpc.c b/arch/x86/cpu/intel_common/lpc.c index 03cb45b6369..696b6304fe1 100644 --- a/arch/x86/cpu/intel_common/lpc.c +++ b/arch/x86/cpu/intel_common/lpc.c @@ -50,7 +50,7 @@ int lpc_common_early_init(struct udevice *dev) int count; int i; - count = fdtdec_get_int_array_count(gd->fdt_blob, dev->of_offset, + count = fdtdec_get_int_array_count(gd->fdt_blob, dev_of_offset(dev), "intel,gen-dec", (u32 *)values, sizeof(values) / sizeof(u32)); if (count < 0) diff --git a/arch/x86/cpu/intel_common/mrc.c b/arch/x86/cpu/intel_common/mrc.c index 01b6e866b5b..f1a249af72c 100644 --- a/arch/x86/cpu/intel_common/mrc.c +++ b/arch/x86/cpu/intel_common/mrc.c @@ -149,7 +149,7 @@ int mrc_locate_spd(struct udevice *dev, int size, const void **spd_datap) spd_index = dm_gpio_get_values_as_int(desc, ret); debug("spd index %d\n", spd_index); - node = fdt_first_subnode(blob, dev->of_offset); + node = fdt_first_subnode(blob, dev_of_offset(dev)); if (node < 0) return -EINVAL; for (spd_node = fdt_first_subnode(blob, node); diff --git a/arch/x86/cpu/irq.c b/arch/x86/cpu/irq.c index d2901de6d58..f5654eb510d 100644 --- a/arch/x86/cpu/irq.c +++ b/arch/x86/cpu/irq.c @@ -96,7 +96,7 @@ static int create_pirq_routing_table(struct udevice *dev) int i; int ret; - node = dev->of_offset; + node = dev_of_offset(dev); /* extract the bdf from fdt_pci_addr */ priv->bdf = dm_pci_get_bdf(dev->parent); diff --git a/arch/x86/cpu/ivybridge/lpc.c b/arch/x86/cpu/ivybridge/lpc.c index aef1206be41..4e254b3c571 100644 --- a/arch/x86/cpu/ivybridge/lpc.c +++ b/arch/x86/cpu/ivybridge/lpc.c @@ -86,7 +86,7 @@ static int pch_pirq_init(struct udevice *pch) { uint8_t route[8], *ptr; - if (fdtdec_get_byte_array(gd->fdt_blob, pch->of_offset, + if (fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(pch), "intel,pirq-routing", route, sizeof(route))) return -EINVAL; ptr = route; @@ -113,7 +113,7 @@ static int pch_gpi_routing(struct udevice *pch) u32 reg; int gpi; - if (fdtdec_get_byte_array(gd->fdt_blob, pch->of_offset, + if (fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(pch), "intel,gpi-routing", route, sizeof(route))) return -EINVAL; @@ -128,7 +128,7 @@ static int pch_gpi_routing(struct udevice *pch) static int pch_power_options(struct udevice *pch) { const void *blob = gd->fdt_blob; - int node = pch->of_offset; + int node = dev_of_offset(pch); u8 reg8; u16 reg16, pmbase; u32 reg32; diff --git a/arch/x86/cpu/ivybridge/model_206ax.c b/arch/x86/cpu/ivybridge/model_206ax.c index d5f32196ae3..81dedee2ec0 100644 --- a/arch/x86/cpu/ivybridge/model_206ax.c +++ b/arch/x86/cpu/ivybridge/model_206ax.c @@ -288,8 +288,8 @@ static int configure_thermal_target(struct udevice *dev) int tcc_offset; msr_t msr; - tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "tcc-offset", - 0); + tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), + "tcc-offset", 0); /* Set TCC activaiton offset if supported */ msr = msr_read(MSR_PLATFORM_INFO); diff --git a/arch/x86/cpu/ivybridge/sata.c b/arch/x86/cpu/ivybridge/sata.c index c7ffbc11fd9..0f5e1904257 100644 --- a/arch/x86/cpu/ivybridge/sata.c +++ b/arch/x86/cpu/ivybridge/sata.c @@ -39,7 +39,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch) { unsigned int port_map, speed_support, port_tx; const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const char *mode; u32 reg32; u16 reg16; @@ -190,7 +190,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch) static void bd82x6x_sata_enable(struct udevice *dev) { const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); unsigned port_map; const char *mode; u16 map = 0; diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c index 2b6b3bd04e6..988073cc795 100644 --- a/arch/x86/cpu/mp_init.c +++ b/arch/x86/cpu/mp_init.c @@ -568,7 +568,8 @@ int mp_init_cpu(struct udevice *cpu, void *unused) * seq num in the uclass_resolve_seq() during device_probe(). To avoid * this, set req_seq to the reg number in the device tree in advance. */ - cpu->req_seq = fdtdec_get_int(gd->fdt_blob, cpu->of_offset, "reg", -1); + cpu->req_seq = fdtdec_get_int(gd->fdt_blob, dev_of_offset(cpu), "reg", + -1); plat->ucode_version = microcode_read_rev(); plat->device_id = gd->arch.x86_device; diff --git a/arch/x86/lib/mpspec.c b/arch/x86/lib/mpspec.c index 17e977ce5e3..a6e493d69af 100644 --- a/arch/x86/lib/mpspec.c +++ b/arch/x86/lib/mpspec.c @@ -304,7 +304,8 @@ static int mptable_add_intsrc(struct mp_config_table *mc, } /* Get I/O interrupt information from device tree */ - cell = fdt_getprop(blob, dev->of_offset, "intel,pirq-routing", &len); + cell = fdt_getprop(blob, dev_of_offset(dev), "intel,pirq-routing", + &len); if (!cell) return -ENOENT; diff --git a/arch/x86/lib/pinctrl_ich6.c b/arch/x86/lib/pinctrl_ich6.c index fb2d2940c95..406852d324d 100644 --- a/arch/x86/lib/pinctrl_ich6.c +++ b/arch/x86/lib/pinctrl_ich6.c @@ -187,7 +187,7 @@ static int ich6_pinctrl_probe(struct udevice *dev) return -EINVAL; } - for (pin_node = fdt_first_subnode(gd->fdt_blob, dev->of_offset); + for (pin_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev)); pin_node > 0; pin_node = fdt_next_subnode(gd->fdt_blob, pin_node)) { /* Configure the pin */ diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index 1fa566436b4..818ae04dfd0 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -44,7 +44,8 @@ int board_prepare_usb(enum usb_init_type type) /* Try to request gpios needed to start usb host on dragonboard */ if (!dm_gpio_is_valid(&hub_reset)) { - node = fdt_subnode_offset(gd->fdt_blob, pmic_gpio->of_offset, + node = fdt_subnode_offset(gd->fdt_blob, + dev_of_offset(pmic_gpio), "usb_hub_reset_pm"); if (node < 0) { printf("Failed to find usb_hub_reset_pm dt node.\n"); @@ -59,7 +60,8 @@ int board_prepare_usb(enum usb_init_type type) } if (!dm_gpio_is_valid(&usb_sel)) { - node = fdt_subnode_offset(gd->fdt_blob, pmic_gpio->of_offset, + node = fdt_subnode_offset(gd->fdt_blob, + dev_of_offset(pmic_gpio), "usb_sw_sel_pm"); if (node < 0) { printf("Failed to find usb_sw_sel_pm dt node.\n"); @@ -110,7 +112,8 @@ int misc_init_r(void) return 0; } - node = fdt_subnode_offset(gd->fdt_blob, pon->of_offset, "key_vol_down"); + node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon), + "key_vol_down"); if (node < 0) { printf("Failed to find key_vol_down node. Check device tree\n"); return 0; diff --git a/common/fdt_support.c b/common/fdt_support.c index c9f7019e38e..a57a5759e4a 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -903,14 +903,9 @@ void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) { struct node_info *ni = node_info; struct mtd_device *dev; - char *parts; int i, idx; int noff; - parts = getenv("mtdparts"); - if (!parts) - return; - if (mtdparts_init() != 0) return; diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt index 1b5ccec4b2e..fea324e25ee 100644 --- a/doc/driver-model/README.txt +++ b/doc/driver-model/README.txt @@ -684,7 +684,7 @@ steps (see device_probe()): g. If the driver provides an ofdata_to_platdata() method, then this is called to convert the device tree data into platform data. This should - do various calls like fdtdec_get_int(gd->fdt_blob, dev->of_offset, ...) + do various calls like fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), ...) to access the node and store the resulting information into dev->platdata. After this point, the device works the same way whether it was bound using a device tree node or U_BOOT_DEVICE() structure. In either case, diff --git a/doc/driver-model/of-plat.txt b/doc/driver-model/of-plat.txt index 86e5e25300c..0063bfe510c 100644 --- a/doc/driver-model/of-plat.txt +++ b/doc/driver-model/of-plat.txt @@ -205,7 +205,7 @@ For example: /* Decode the device tree data */ struct mmc_platdata *plat = dev_get_platdata(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); plat->fifo_depth = fdtdec_get_int(blob, node, "fifo-depth", 0); #endif diff --git a/doc/driver-model/spi-howto.txt b/doc/driver-model/spi-howto.txt index ee4abf4a8b4..1955ffe284e 100644 --- a/doc/driver-model/spi-howto.txt +++ b/doc/driver-model/spi-howto.txt @@ -223,7 +223,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus) { struct exynos_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg"); plat->periph_id = pinmux_decode_periph_id(blob, node); diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index 9233fcdb6c1..3e28a5600bf 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -345,7 +345,7 @@ nodev: static int adc_vdd_platdata_set(struct udevice *dev) { struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); - int ret, offset = dev->of_offset; + int ret, offset = dev_of_offset(dev); const void *fdt = gd->fdt_blob; char *prop; @@ -366,7 +366,7 @@ static int adc_vdd_platdata_set(struct udevice *dev) static int adc_vss_platdata_set(struct udevice *dev) { struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); - int ret, offset = dev->of_offset; + int ret, offset = dev_of_offset(dev); const void *fdt = gd->fdt_blob; char *prop; diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index d36f64ffdf8..ac27d3e6750 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -154,9 +154,8 @@ static int generic_clk_ofdata_to_platdata(struct udevice *dev) u32 num_parents; num_parents = fdtdec_get_int_array_count(gd->fdt_blob, - dev_get_parent(dev)->of_offset, - "clocks", cells, - GENERATED_SOURCE_MAX); + dev_of_offset(dev_get_parent(dev)), "clocks", cells, + GENERATED_SOURCE_MAX); if (!num_parents) return -1; diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 76ba91af812..c73156a0df1 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -47,7 +47,7 @@ int at91_pmc_core_probe(struct udevice *dev) int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) { const void *fdt = gd->fdt_blob; - int offset = dev->of_offset; + int offset = dev_of_offset(dev); bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC); const char *name; int ret; @@ -90,7 +90,8 @@ int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args) return -EINVAL; } - periph = fdtdec_get_uint(gd->fdt_blob, clk->dev->of_offset, "reg", -1); + periph = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(clk->dev), "reg", + -1); if (periph < 0) return -EINVAL; diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 153ceba702d..6fcfd6997c8 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -65,7 +65,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk); assert(clk); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset, + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), "clocks", "#clock-cells", 0, index, &args); if (ret) { @@ -104,7 +104,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk) debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk); - index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset, + index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), "clock-names", name); if (index < 0) { debug("fdt_stringlist_search() failed: %d\n", index); diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c index 9c4d2b322f7..3911bf61a03 100644 --- a/drivers/clk/clk_fixed_rate.c +++ b/drivers/clk/clk_fixed_rate.c @@ -32,7 +32,7 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) to_clk_fixed_rate(dev)->fixed_rate = - fdtdec_get_int(gd->fdt_blob, dev->of_offset, + fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); #endif diff --git a/drivers/clk/clk_pic32.c b/drivers/clk/clk_pic32.c index 70ec3543cf9..f6eef314ec3 100644 --- a/drivers/clk/clk_pic32.c +++ b/drivers/clk/clk_pic32.c @@ -330,7 +330,7 @@ static void pic32_clk_init(struct udevice *dev) for (i = REF1CLK; i <= REF5CLK; i++) { snprintf(propname, sizeof(propname), "microchip,refo%d-frequency", i - REF1CLK + 1); - rate = fdtdec_get_int(blob, dev->of_offset, propname, 0); + rate = fdtdec_get_int(blob, dev_of_offset(dev), propname, 0); if (rate) pic32_set_refclk(priv, i, pll_hz, rate, ROCLK_SRC_SPLL); } @@ -393,7 +393,8 @@ static int pic32_clk_probe(struct udevice *dev) fdt_addr_t addr; fdt_size_t size; - addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg", + &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/core/device.c b/drivers/core/device.c index ed553d70a6b..70fcfc23e0c 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -355,7 +355,7 @@ int device_probe(struct udevice *dev) goto fail; } - if (drv->ofdata_to_platdata && dev->of_offset >= 0) { + if (drv->ofdata_to_platdata && dev_of_offset(dev) >= 0) { ret = drv->ofdata_to_platdata(dev); if (ret) goto fail; @@ -524,7 +524,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset, *devp = NULL; list_for_each_entry(dev, &parent->child_head, sibling_node) { - if (dev->of_offset == of_offset) { + if (dev_of_offset(dev) == of_offset) { *devp = dev; return 0; } @@ -549,7 +549,7 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent, { struct udevice *dev, *found; - if (parent->of_offset == of_offset) + if (dev_of_offset(parent) == of_offset) return parent; list_for_each_entry(dev, &parent->child_head, sibling_node) { @@ -637,19 +637,21 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) int len = 0; int na, ns; - na = fdt_address_cells(gd->fdt_blob, dev->parent->of_offset); + 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->parent->of_offset); + 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, "reg", &len); + 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; @@ -662,16 +664,15 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) * bus setups. */ addr = fdt_translate_address((void *)gd->fdt_blob, - dev->of_offset, reg); + 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->parent->of_offset, - dev->of_offset, "reg", - index, NULL, false); + 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) @@ -702,7 +703,7 @@ fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index, * 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, + fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev), "reg", index, size, false); /* @@ -720,7 +721,7 @@ 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, + index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), "reg-names", name); if (index < 0) return index; @@ -799,7 +800,7 @@ bool of_device_is_compatible(struct udevice *dev, const char *compat) { const void *fdt = gd->fdt_blob; - return !fdt_node_check_compatible(fdt, dev->of_offset, compat); + return !fdt_node_check_compatible(fdt, dev_of_offset(dev), compat); } bool of_machine_is_compatible(const char *compat) diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index c68bcba54f1..833cd78e848 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -71,12 +71,12 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp) int parent; int len; - parent = dev->parent->of_offset; + parent = dev_of_offset(dev->parent); addr_len = fdt_address_cells(blob, parent); size_len = fdt_size_cells(blob, parent); both_len = addr_len + size_len; - cell = fdt_getprop(blob, dev->of_offset, "reg", &len); + cell = fdt_getprop(blob, dev_of_offset(dev), "reg", &len); len /= sizeof(*cell); count = len / both_len; if (!cell || !count) diff --git a/drivers/core/root.c b/drivers/core/root.c index 9edfc1efb66..175fd3fb252 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -227,10 +227,10 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, int dm_scan_fdt_dev(struct udevice *dev) { - if (dev->of_offset == -1) + if (dev_of_offset(dev) == -1) return 0; - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, + return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), gd->flags & GD_FLG_RELOC ? false : true); } diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c index 5c955da3346..a300217d39a 100644 --- a/drivers/core/simple-bus.c +++ b/drivers/core/simple-bus.c @@ -27,10 +27,13 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr) static int simple_bus_post_bind(struct udevice *dev) { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + return 0; +#else u32 cell[3]; int ret; - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "ranges", + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "ranges", cell, ARRAY_SIZE(cell)); if (!ret) { struct simple_bus_plat *plat = dev_get_uclass_platdata(dev); @@ -41,6 +44,7 @@ static int simple_bus_post_bind(struct udevice *dev) } return dm_scan_fdt_dev(dev); +#endif } UCLASS_DRIVER(simple_bus) = { diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 60610e5a1f5..7de370644d7 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -278,7 +278,7 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node, return ret; list_for_each_entry(dev, &uc->dev_head, uclass_node) { - if (dev->of_offset == node) { + if (dev_of_offset(dev) == node) { *devp = dev; return 0; } @@ -299,7 +299,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id, int ret; *devp = NULL; - find_phandle = fdtdec_get_int(gd->fdt_blob, parent->of_offset, name, + find_phandle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(parent), name, -1); if (find_phandle <= 0) return -ENOENT; @@ -308,7 +308,9 @@ static int uclass_find_device_by_phandle(enum uclass_id id, return ret; list_for_each_entry(dev, &uc->dev_head, uclass_node) { - uint phandle = fdt_get_phandle(gd->fdt_blob, dev->of_offset); + uint phandle; + + phandle = fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev)); if (phandle == find_phandle) { *devp = dev; diff --git a/drivers/demo/demo-shape.c b/drivers/demo/demo-shape.c index d908736cffe..7e71f3bf6ae 100644 --- a/drivers/demo/demo-shape.c +++ b/drivers/demo/demo-shape.c @@ -151,7 +151,7 @@ static int shape_ofdata_to_platdata(struct udevice *dev) return ret; /* Parse the data that only we need */ - pdata->default_char = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + pdata->default_char = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "character", '@'); return 0; diff --git a/drivers/demo/demo-uclass.c b/drivers/demo/demo-uclass.c index 725f06898f3..3341572e8a6 100644 --- a/drivers/demo/demo-uclass.c +++ b/drivers/demo/demo-uclass.c @@ -66,7 +66,7 @@ int demo_set_light(struct udevice *dev, int light) int demo_parse_dt(struct udevice *dev) { struct dm_demo_pdata *pdata = dev_get_platdata(dev); - int dn = dev->of_offset; + int dn = dev_of_offset(dev); pdata->sides = fdtdec_get_int(gd->fdt_blob, dn, "sides", 0); pdata->colour = fdt_getprop(gd->fdt_blob, dn, "colour", NULL); diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c index 9ac10a745d2..750eedfffd0 100644 --- a/drivers/gpio/74x164_gpio.c +++ b/drivers/gpio/74x164_gpio.c @@ -130,7 +130,7 @@ static int gen_74x164_probe(struct udevice *dev) char *str, name[32]; int ret; const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); snprintf(name, sizeof(name), "%s_", dev->name); str = strdup(name); diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c index 6f42bf8a226..92849c5295e 100644 --- a/drivers/gpio/altera_pio.c +++ b/drivers/gpio/altera_pio.c @@ -92,9 +92,9 @@ static int altera_pio_ofdata_to_platdata(struct udevice *dev) plat->regs = map_physmem(dev_get_addr(dev), sizeof(struct altera_pio_regs), MAP_NOCACHE); - plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "altr,gpio-bank-width", 32); - plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "gpio-bank-name", NULL); return 0; diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c index cb90b0241a2..81c30475514 100644 --- a/drivers/gpio/atmel_pio4.c +++ b/drivers/gpio/atmel_pio4.c @@ -276,7 +276,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, false); + return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), false); } static int atmel_pio4_probe(struct udevice *dev) @@ -308,7 +308,8 @@ static int atmel_pio4_probe(struct udevice *dev) pioctrl_data = (struct atmel_pioctrl_data *)dev_get_driver_data(dev); nbanks = pioctrl_data->nbanks; - uc_priv->bank_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL); + uc_priv->bank_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), + NULL); uc_priv->gpio_count = nbanks * ATMEL_PIO_NPINS_PER_BANK; return 0; diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c index 85e0a8647f2..7d1904c1e1e 100644 --- a/drivers/gpio/dwapb_gpio.c +++ b/drivers/gpio/dwapb_gpio.c @@ -112,13 +112,13 @@ static int gpio_dwapb_bind(struct udevice *dev) if (plat) return 0; - base = fdtdec_get_addr(blob, dev->of_offset, "reg"); + base = fdtdec_get_addr(blob, dev_of_offset(dev), "reg"); if (base == FDT_ADDR_T_NONE) { debug("Can't get the GPIO register base address\n"); return -ENXIO; } - for (node = fdt_first_subnode(blob, dev->of_offset); + for (node = fdt_first_subnode(blob, dev_of_offset(dev)); node > 0; node = fdt_next_subnode(blob, node)) { if (!fdtdec_get_bool(blob, node, "gpio-controller")) @@ -142,7 +142,7 @@ static int gpio_dwapb_bind(struct udevice *dev) if (ret) goto err; - subdev->of_offset = node; + dev_set_of_offset(subdev, node); bank++; } diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 4559739d619..9ab9df4ce7a 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -707,7 +707,7 @@ int gpio_request_by_name(struct udevice *dev, const char *list_name, int index, * calls in gpio_request_by_name(), but we can do this until * gpio_request_by_name_nodev() can be dropped. */ - return gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset, + return gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev), list_name, index, desc, flags); } @@ -746,7 +746,7 @@ int gpio_request_list_by_name(struct udevice *dev, const char *list_name, * calls in gpio_request_by_name(), but we can do this until * gpio_request_list_by_name_nodev() can be dropped. */ - return gpio_request_list_by_name_nodev(gd->fdt_blob, dev->of_offset, + return gpio_request_list_by_name_nodev(gd->fdt_blob, dev_of_offset(dev), list_name, desc, max_count, flags); } @@ -755,7 +755,7 @@ int gpio_get_list_count(struct udevice *dev, const char *list_name) { int ret; - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset, + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), list_name, "#gpio-cells", 0, -1, NULL); if (ret) { diff --git a/drivers/gpio/intel_broadwell_gpio.c b/drivers/gpio/intel_broadwell_gpio.c index 81ce446e1a1..790577ac810 100644 --- a/drivers/gpio/intel_broadwell_gpio.c +++ b/drivers/gpio/intel_broadwell_gpio.c @@ -149,14 +149,14 @@ static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev) if (ret) return ret; - bank = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1); + bank = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1); if (bank == -1) { debug("%s: Invalid bank number %d\n", __func__, bank); return -EINVAL; } plat->bank = bank; plat->base_addr = gpiobase; - plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "bank-name", NULL); return 0; diff --git a/drivers/gpio/intel_ich6_gpio.c b/drivers/gpio/intel_ich6_gpio.c index fd6181fa5a7..8b782260bc3 100644 --- a/drivers/gpio/intel_ich6_gpio.c +++ b/drivers/gpio/intel_ich6_gpio.c @@ -94,14 +94,14 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev) if (ret) return ret; - offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1); + offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1); if (offset == -1) { debug("%s: Invalid register offset %d\n", __func__, offset); return -EINVAL; } plat->offset = offset; plat->base_addr = gpiobase + offset; - plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "bank-name", NULL); return 0; diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c index 9674ee75f03..1bf945acfc6 100644 --- a/drivers/gpio/lpc32xx_gpio.c +++ b/drivers/gpio/lpc32xx_gpio.c @@ -297,7 +297,7 @@ static int lpc32xx_gpio_probe(struct udevice *dev) struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev); struct gpio_dev_priv *uc_priv = dev->uclass_priv; - if (dev->of_offset == -1) { + if (dev_of_offset(dev) == -1) { /* Tell the uclass how many GPIOs we have */ uc_priv->gpio_count = LPC32XX_GPIOS; } diff --git a/drivers/gpio/mpc85xx_gpio.c b/drivers/gpio/mpc85xx_gpio.c index 168c696c4dc..cfeb6e76328 100644 --- a/drivers/gpio/mpc85xx_gpio.c +++ b/drivers/gpio/mpc85xx_gpio.c @@ -169,13 +169,13 @@ static int mpc85xx_gpio_ofdata_to_platdata(struct udevice *dev) { fdt_addr_t addr; fdt_size_t size; - addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset, - "reg", 0, &size, false); + addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, + dev_of_offset(dev), "reg", 0, &size, false); plat->addr = addr; plat->size = size; - plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev->of_offset, - "ngpios", 32); + plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), + "ngpios", 32); return 0; } diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c index 03029792c2a..01ce1d6fa0f 100644 --- a/drivers/gpio/msm_gpio.c +++ b/drivers/gpio/msm_gpio.c @@ -106,9 +106,9 @@ static int msm_gpio_ofdata_to_platdata(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "gpio-count", 0); - uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "gpio-bank-name", NULL); if (uc_priv->bank_name == NULL) uc_priv->bank_name = "soc"; diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index f906b97fb74..5338552179f 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -320,7 +320,7 @@ static int omap_gpio_bind(struct udevice *dev) return -ENOMEM; plat->base = base_addr; - plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL); + plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL); dev->platdata = plat; return 0; diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c index 0410add5183..b81f0fa90c2 100644 --- a/drivers/gpio/pca953x_gpio.c +++ b/drivers/gpio/pca953x_gpio.c @@ -265,7 +265,7 @@ static int pca953x_probe(struct udevice *dev) return -ENODEV; } - addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", 0); + addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0); if (addr == 0) return -ENODEV; diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c index 2bda0ff9966..2cbb9e61ea3 100644 --- a/drivers/gpio/pcf8575_gpio.c +++ b/drivers/gpio/pcf8575_gpio.c @@ -131,15 +131,15 @@ static int pcf8575_ofdata_platdata(struct udevice *dev) int n_latch; - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "gpio-count", 16); - uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "gpio-bank-name", NULL); if (!uc_priv->bank_name) uc_priv->bank_name = fdt_get_name(gd->fdt_blob, - dev->of_offset, NULL); + dev_of_offset(dev), NULL); - n_latch = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + n_latch = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "lines-initial-states", 0); plat->out = ~n_latch; diff --git a/drivers/gpio/pic32_gpio.c b/drivers/gpio/pic32_gpio.c index 7a037f3a77c..e838ad45a8c 100644 --- a/drivers/gpio/pic32_gpio.c +++ b/drivers/gpio/pic32_gpio.c @@ -133,7 +133,8 @@ static int pic32_gpio_probe(struct udevice *dev) char *end; int bank; - addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg", + &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c index 0b619758438..e38cee88693 100644 --- a/drivers/gpio/pm8916_gpio.c +++ b/drivers/gpio/pm8916_gpio.c @@ -193,9 +193,9 @@ static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "gpio-count", 0); - uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "gpio-bank-name", NULL); if (uc_priv->bank_name == NULL) uc_priv->bank_name = "pm8916"; diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index 377fed467fb..042996e559e 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -317,7 +317,7 @@ static int gpio_exynos_bind(struct udevice *parent) return 0; base = (struct s5p_gpio_bank *)dev_get_addr(parent); - for (node = fdt_first_subnode(blob, parent->of_offset), bank = base; + for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base; node > 0; node = fdt_next_subnode(blob, node), bank++) { struct exynos_gpio_platdata *plat; @@ -337,7 +337,7 @@ static int gpio_exynos_bind(struct udevice *parent) if (ret) return ret; - dev->of_offset = node; + dev_set_of_offset(dev, node); reg = dev_get_addr(dev); if (reg != FDT_ADDR_T_NONE) diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index f6435a0543b..ae6d93013f7 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -197,9 +197,9 @@ static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "num-gpios", 0); - uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, + uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "gpio-bank-name", NULL); return 0; @@ -209,7 +209,7 @@ static int gpio_sandbox_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - if (dev->of_offset == -1) { + if (dev_of_offset(dev) == -1) { /* Tell the uclass how many GPIOs we have */ uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT; } diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c index e8accaa3330..8d2bb18504a 100644 --- a/drivers/gpio/sunxi_gpio.c +++ b/drivers/gpio/sunxi_gpio.c @@ -312,7 +312,7 @@ static int gpio_sunxi_bind(struct udevice *parent) plat->bank_name, plat, -1, &dev); if (ret) return ret; - dev->of_offset = parent->of_offset; + dev_set_of_offset(dev, dev_of_offset(parent)); } return 0; diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c index 1c681514db9..b0c22e5bfe3 100644 --- a/drivers/gpio/tegra186_gpio.c +++ b/drivers/gpio/tegra186_gpio.c @@ -197,7 +197,7 @@ static int tegra186_gpio_bind(struct udevice *parent) -1, &dev); if (ret) return ret; - dev->of_offset = parent->of_offset; + dev_set_of_offset(dev, dev_of_offset(parent)); } return 0; diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c index 5a031159ca3..b01968a304d 100644 --- a/drivers/gpio/tegra_gpio.c +++ b/drivers/gpio/tegra_gpio.c @@ -337,7 +337,8 @@ static int gpio_tegra_bind(struct udevice *parent) * This driver does not make use of interrupts, other than to figure * out the number of GPIO banks */ - if (!fdt_getprop(gd->fdt_blob, parent->of_offset, "interrupts", &len)) + if (!fdt_getprop(gd->fdt_blob, dev_of_offset(parent), "interrupts", + &len)) return -EINVAL; bank_count = len / 3 / sizeof(u32); ctlr = (struct gpio_ctlr *)dev_get_addr(parent); @@ -363,7 +364,7 @@ static int gpio_tegra_bind(struct udevice *parent) plat->port_name, plat, -1, &dev); if (ret) return ret; - dev->of_offset = parent->of_offset; + dev_set_of_offset(dev, dev_of_offset(parent)); } } diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c index a30ba5d2ed6..458104e8b07 100644 --- a/drivers/gpio/vybrid_gpio.c +++ b/drivers/gpio/vybrid_gpio.c @@ -129,7 +129,7 @@ static int vybrid_gpio_bind(struct udevice *dev) plat->base = base_addr; plat->chip = dev->req_seq; - plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL); + plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL); dev->platdata = plat; return 0; diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index 4bc54eea596..5a636697a5e 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -242,7 +242,7 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev) { const void *blob = gd->fdt_blob; struct at91_i2c_bus *bus = dev_get_priv(dev); - int node = dev->of_offset; + int node = dev_of_offset(dev); bus->regs = (struct at91_i2c_regs *)dev_get_addr(dev); bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev); diff --git a/drivers/i2c/cros_ec_tunnel.c b/drivers/i2c/cros_ec_tunnel.c index 9cf8e7dec0f..86fa684ff05 100644 --- a/drivers/i2c/cros_ec_tunnel.c +++ b/drivers/i2c/cros_ec_tunnel.c @@ -34,7 +34,7 @@ static int cros_ec_i2c_ofdata_to_platdata(struct udevice *dev) { struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus", 0); diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c index 9521aeb3c30..2dd75fd154c 100644 --- a/drivers/i2c/exynos_hs_i2c.c +++ b/drivers/i2c/exynos_hs_i2c.c @@ -522,7 +522,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); int node; - node = dev->of_offset; + node = dev_of_offset(dev); i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev); diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index c3f826d68c7..e9fbf828f34 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -585,21 +585,21 @@ static int fsl_i2c_ofdata_to_platdata(struct udevice *bus) struct fsl_i2c_dev *dev = dev_get_priv(bus); fdt_addr_t addr; fdt_size_t size; + int node = dev_of_offset(bus); - addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, bus->of_offset, - "reg", 0, &size, false); + addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg", 0, + &size, false); dev->base = map_sysmem(CONFIG_SYS_IMMR + addr, size); if (!dev->base) return -ENOMEM; - dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset, - "cell-index", -1); - dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + dev->index = fdtdec_get_int(gd->fdt_blob, node, "cell-index", -1); + dev->slaveadd = fdtdec_get_int(gd->fdt_blob, node, "u-boot,i2c-slave-addr", 0x7f); - dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset, - "clock-frequency", 400000); + dev->speed = fdtdec_get_int(gd->fdt_blob, node, "clock-frequency", + 400000); dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk; diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index a8b83c51bc3..aeeb304a876 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -309,7 +309,7 @@ static int i2c_gpio_ofdata_to_platdata(struct udevice *dev) { struct i2c_gpio_bus *bus = dev_get_priv(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; ret = gpio_request_list_by_name(dev, "gpios", bus->gpios, diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index dbd3789747d..f3184c71d9e 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -489,7 +489,7 @@ static int i2c_post_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev); - i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 100000); return dm_i2c_set_bus_speed(dev, i2c->speed_hz); @@ -503,10 +503,11 @@ static int i2c_child_post_bind(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) struct dm_i2c_chip *plat = dev_get_parent_platdata(dev); - if (dev->of_offset == -1) + if (dev_of_offset(dev) == -1) return 0; - return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat); + return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev), + plat); #else return 0; #endif diff --git a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c index 3f072c78b81..66ce7ecc9c2 100644 --- a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c +++ b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c @@ -89,7 +89,7 @@ static int i2c_arbitrator_probe(struct udevice *dev) { struct i2c_arbitrator_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; debug("%s: %s\n", __func__, dev->name); diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c index db086efe612..d243b8e32d6 100644 --- a/drivers/i2c/muxes/i2c-mux-uclass.c +++ b/drivers/i2c/muxes/i2c-mux-uclass.c @@ -40,7 +40,7 @@ static int i2c_mux_child_post_bind(struct udevice *dev) struct i2c_mux_bus *plat = dev_get_parent_platdata(dev); int channel; - channel = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1); + channel = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1); if (channel < 0) return -EINVAL; plat->channel = channel; @@ -60,7 +60,7 @@ static int i2c_mux_post_bind(struct udevice *mux) * There is no compatible string in the sub-nodes, so we must manually * bind these */ - for (offset = fdt_first_subnode(blob, mux->of_offset); + for (offset = fdt_first_subnode(blob, dev_of_offset(mux)); offset > 0; offset = fdt_next_subnode(blob, offset)) { struct udevice *dev; diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c index 7e0d2da4d60..1a6761858ce 100644 --- a/drivers/i2c/muxes/pca954x.c +++ b/drivers/i2c/muxes/pca954x.c @@ -51,7 +51,7 @@ static int pca954x_ofdata_to_platdata(struct udevice *dev) { struct pca954x_priv *priv = dev_get_priv(dev); - priv->addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", 0); + priv->addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0); if (!priv->addr) { debug("MUX not found\n"); return -ENODEV; diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index cea3da0b276..648a96eeb4e 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -775,11 +775,11 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus) if (!dev->base) return -ENOMEM; - dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + dev->index = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), "cell-index", -1); - dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + dev->slaveadd = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), "u-boot,i2c-slave-addr", 0x0); - dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + dev->speed = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), "clock-frequency", 100000); return 0; } diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 94d9027d256..eb789f5bff4 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -750,7 +750,7 @@ static int mxc_i2c_probe(struct udevice *bus) { struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus); const void *fdt = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); fdt_addr_t addr; int ret, ret2; diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c index 363cd04e4e2..3c69dbf409b 100644 --- a/drivers/i2c/s3c24x0_i2c.c +++ b/drivers/i2c/s3c24x0_i2c.c @@ -312,7 +312,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); int node; - node = dev->of_offset; + node = dev_of_offset(dev); i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev); diff --git a/drivers/i2c/tegra186_bpmp_i2c.c b/drivers/i2c/tegra186_bpmp_i2c.c index 513c414ae38..931c6de508c 100644 --- a/drivers/i2c/tegra186_bpmp_i2c.c +++ b/drivers/i2c/tegra186_bpmp_i2c.c @@ -90,7 +90,7 @@ static int tegra186_bpmp_i2c_probe(struct udevice *dev) { struct tegra186_bpmp_i2c *priv = dev_get_priv(dev); - priv->bpmp_bus_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + priv->bpmp_bus_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "nvidia,bpmp-bus-id", U32_MAX); if (priv->bpmp_bus_id == U32_MAX) { debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__); diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c index 9bc4555c2eb..00381dcd720 100644 --- a/drivers/input/cros_ec_keyb.c +++ b/drivers/input/cros_ec_keyb.c @@ -189,7 +189,7 @@ static int cros_ec_kbd_probe(struct udevice *dev) struct stdio_dev *sdev = &uc_priv->sdev; struct input_config *input = &uc_priv->input; const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; if (cros_ec_keyb_decode_fdt(blob, node, priv)) diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index 03d48403857..0fd25b17ec0 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -315,7 +315,7 @@ static int i8042_kbd_probe(struct udevice *dev) struct input_config *input = &uc_priv->input; int ret; - if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, + if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "intel,duplicate-por")) priv->quirks |= QUIRK_DUP_POR; diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c index c77f6107696..d36f1a1dfa1 100644 --- a/drivers/input/tegra-kbc.c +++ b/drivers/input/tegra-kbc.c @@ -290,7 +290,7 @@ static int tegra_kbd_probe(struct udevice *dev) struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev); struct stdio_dev *sdev = &uc_priv->sdev; struct input_config *input = &uc_priv->input; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; priv->kbc = (struct kbc_tegra *)dev_get_addr(dev); diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index cb6e996931b..5b119903f55 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -62,7 +62,7 @@ static int led_gpio_bind(struct udevice *parent) int node; int ret; - for (node = fdt_first_subnode(blob, parent->of_offset); + for (node = fdt_first_subnode(blob, dev_of_offset(parent)); node > 0; node = fdt_next_subnode(blob, node)) { struct led_uclass_plat *uc_plat; diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c index a7fcde51d59..38448de9655 100644 --- a/drivers/mailbox/mailbox-uclass.c +++ b/drivers/mailbox/mailbox-uclass.c @@ -41,7 +41,7 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan) debug("%s(dev=%p, index=%d, chan=%p)\n", __func__, dev, index, chan); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset, + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), "mboxes", "#mbox-cells", 0, index, &args); if (ret) { @@ -85,7 +85,7 @@ int mbox_get_by_name(struct udevice *dev, const char *name, debug("%s(dev=%p, name=%s, chan=%p)\n", __func__, dev, name, chan); - index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset, + index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), "mbox-names", name); if (index < 0) { debug("fdt_stringlist_search() failed: %d\n", index); diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 759bb46c57b..3d449b2a552 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -998,7 +998,7 @@ int cros_ec_register(struct udevice *dev) { struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); char id[MSG_BYTES]; cdev->dev = dev; diff --git a/drivers/misc/cros_ec_i2c.c b/drivers/misc/cros_ec_i2c.c index 3de18b2d2ad..6e0934017a3 100644 --- a/drivers/misc/cros_ec_i2c.c +++ b/drivers/misc/cros_ec_i2c.c @@ -24,11 +24,96 @@ #define debug_trace(fmt, b...) #endif +/** + * Request format for protocol v3 + * byte 0 0xda (EC_COMMAND_PROTOCOL_3) + * byte 1-8 struct ec_host_request + * byte 10- response data + */ +struct ec_host_request_i2c { + /* Always 0xda to backward compatible with v2 struct */ + uint8_t command_protocol; + struct ec_host_request ec_request; +} __packed; + +/* + * Response format for protocol v3 + * byte 0 result code + * byte 1 packet_length + * byte 2-9 struct ec_host_response + * byte 10- response data + */ +struct ec_host_response_i2c { + uint8_t result; + uint8_t packet_length; + struct ec_host_response ec_response; +} __packed; + +static int cros_ec_i2c_packet(struct udevice *udev, int out_bytes, int in_bytes) +{ + struct cros_ec_dev *dev = dev_get_uclass_priv(udev); + struct dm_i2c_chip *chip = dev_get_parent_platdata(udev); + struct ec_host_request_i2c *ec_request_i2c = + (struct ec_host_request_i2c *)dev->dout; + struct ec_host_response_i2c *ec_response_i2c = + (struct ec_host_response_i2c *)dev->din; + struct i2c_msg i2c_msg[2]; + int ret; + + i2c_msg[0].addr = chip->chip_addr; + i2c_msg[0].flags = 0; + i2c_msg[1].addr = chip->chip_addr; + i2c_msg[1].flags = I2C_M_RD; + + /* one extra byte, to indicate v3 */ + i2c_msg[0].len = out_bytes + 1; + i2c_msg[0].buf = dev->dout; + + /* stitch on EC_COMMAND_PROTOCOL_3 */ + memmove(&ec_request_i2c->ec_request, dev->dout, out_bytes); + ec_request_i2c->command_protocol = EC_COMMAND_PROTOCOL_3; + + /* two extra bytes for v3 */ + i2c_msg[1].len = in_bytes + 2; + i2c_msg[1].buf = dev->din; + + ret = dm_i2c_xfer(udev, &i2c_msg[0], 2); + if (ret) { + printf("%s: Could not execute transfer: %d\n", __func__, ret); + return ret; + } + + /* When we send a v3 request to v2 ec, ec won't recognize the 0xda + * (EC_COMMAND_PROTOCOL_3) and will return with status + * EC_RES_INVALID_COMMAND with zero data length + * + * In case of invalid command for v3 protocol the data length + * will be at least sizeof(struct ec_host_response) + */ + if (ec_response_i2c->result == EC_RES_INVALID_COMMAND && + ec_response_i2c->packet_length == 0) + return -EPROTONOSUPPORT; + + if (ec_response_i2c->packet_length < sizeof(struct ec_host_response)) { + printf("%s: response of %u bytes too short; not a full hdr\n", + __func__, ec_response_i2c->packet_length); + return -EBADMSG; + } + + + /* drop result and packet_len */ + memmove(dev->din, &ec_response_i2c->ec_response, in_bytes); + + return in_bytes; +} + static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); + struct dm_i2c_chip *chip = dev_get_parent_platdata(udev); + struct i2c_msg i2c_msg[2]; /* version8, cmd8, arglen8, out8[dout_len], csum8 */ int out_bytes = dout_len + 4; /* response8, arglen8, in8[din_len], checksum8 */ @@ -53,6 +138,11 @@ static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd, assert(dout_len >= 0); assert(dinp); + i2c_msg[0].addr = chip->chip_addr; + i2c_msg[0].len = out_bytes; + i2c_msg[0].buf = dev->dout; + i2c_msg[0].flags = 0; + /* * Copy command and data into output buffer so we can do a single I2C * burst transaction. @@ -85,24 +175,21 @@ static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd, *ptr++ = (uint8_t) cros_ec_calc_checksum(dev->dout, dout_len + 3); + i2c_msg[1].addr = chip->chip_addr; + i2c_msg[1].len = in_bytes; + i2c_msg[1].buf = in_ptr; + i2c_msg[1].flags = I2C_M_RD; + /* Send output data */ cros_ec_dump_data("out", -1, dev->dout, out_bytes); - ret = dm_i2c_write(udev, 0, dev->dout, out_bytes); + + ret = dm_i2c_xfer(udev, &i2c_msg[0], 2); if (ret) { - debug("%s: Cannot complete I2C write to %s\n", __func__, + debug("%s: Could not execute transfer to %s\n", __func__, udev->name); ret = -1; } - if (!ret) { - ret = dm_i2c_read(udev, 0, in_ptr, in_bytes); - if (ret) { - debug("%s: Cannot complete I2C read from %s\n", - __func__, udev->name); - ret = -1; - } - } - if (*in_ptr != EC_RES_SUCCESS) { debug("%s: Received bad result code %d\n", __func__, *in_ptr); return -(int)*in_ptr; @@ -136,6 +223,7 @@ static int cros_ec_probe(struct udevice *dev) static struct dm_cros_ec_ops cros_ec_ops = { .command = cros_ec_i2c_command, + .packet = cros_ec_i2c_packet, }; static const struct udevice_id cros_ec_ids[] = { diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index c4fbca0d3ae..848c67bc230 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -522,7 +522,7 @@ int cros_ec_probe(struct udevice *dev) int err; memcpy(ec, &s_state, sizeof(*ec)); - err = cros_ec_decode_ec_flash(blob, dev->of_offset, &ec->ec_config); + err = cros_ec_decode_ec_flash(blob, dev_of_offset(dev), &ec->ec_config); if (err) return err; @@ -531,7 +531,7 @@ int cros_ec_probe(struct udevice *dev) keyb_dev; device_find_next_child(&keyb_dev)) { if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) { - node = keyb_dev->of_offset; + node = dev_of_offset(keyb_dev); break; } } diff --git a/drivers/misc/i2c_eeprom_emul.c b/drivers/misc/i2c_eeprom_emul.c index 4410d0357ff..02de8d7df3d 100644 --- a/drivers/misc/i2c_eeprom_emul.c +++ b/drivers/misc/i2c_eeprom_emul.c @@ -115,9 +115,9 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev) { struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); - plat->size = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->size = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "sandbox,size", 32); - plat->filename = fdt_getprop(gd->fdt_blob, dev->of_offset, + plat->filename = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "sandbox,filename", NULL); if (!plat->filename) { debug("%s: No filename for device '%s'\n", __func__, diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c index f4ddbea3760..bd8b9602e0d 100644 --- a/drivers/misc/tegra186_bpmp.c +++ b/drivers/misc/tegra186_bpmp.c @@ -112,19 +112,19 @@ static int tegra186_bpmp_bind(struct udevice *dev) debug("%s(dev=%p)\n", __func__, dev); ret = device_bind_driver_to_node(dev, "tegra186_clk", "tegra186_clk", - dev->of_offset, &child); + dev_of_offset(dev), &child); if (ret) return ret; ret = device_bind_driver_to_node(dev, "tegra186_reset", - "tegra186_reset", dev->of_offset, + "tegra186_reset", dev_of_offset(dev), &child); if (ret) return ret; ret = device_bind_driver_to_node(dev, "tegra186_power_domain", "tegra186_power_domain", - dev->of_offset, &child); + dev_of_offset(dev), &child); if (ret) return ret; @@ -141,7 +141,7 @@ static ulong tegra186_bpmp_get_shmem(struct udevice *dev, int index) struct fdtdec_phandle_args args; fdt_addr_t reg; - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset, + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), "shmem", NULL, 0, index, &args); if (ret < 0) { error("fdtdec_parse_phandle_with_args() failed: %d\n", ret); diff --git a/drivers/misc/tegra_car.c b/drivers/misc/tegra_car.c index 0eb009657c4..5db3c374ce0 100644 --- a/drivers/misc/tegra_car.c +++ b/drivers/misc/tegra_car.c @@ -22,12 +22,12 @@ static int tegra_car_bpmp_bind(struct udevice *dev) debug("%s(dev=%p)\n", __func__, dev); ret = device_bind_driver_to_node(dev, "tegra_car_clk", "tegra_car_clk", - dev->of_offset, &child); + dev_of_offset(dev), &child); if (ret) return ret; ret = device_bind_driver_to_node(dev, "tegra_car_reset", - "tegra_car_reset", dev->of_offset, + "tegra_car_reset", dev_of_offset(dev), &child); if (ret) return ret; diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c index 62cb242343c..852255782f1 100644 --- a/drivers/mmc/atmel_sdhci.c +++ b/drivers/mmc/atmel_sdhci.c @@ -75,7 +75,7 @@ static int atmel_sdhci_probe(struct udevice *dev) host->ioaddr = (void *)dev_get_addr(dev); host->quirks = 0; - host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); caps = sdhci_readl(host, SDHCI_CAPABILITIES); diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index c440399a09c..40f7892ac80 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -264,7 +264,7 @@ static int exynos_dwmmc_probe(struct udevice *dev) struct dwmci_host *host = &priv->host; int err; - err = exynos_dwmci_get_config(gd->fdt_blob, dev->of_offset, host); + err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host); if (err) return err; err = do_dwmci_init(host); diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 73473c53a37..adeb5df6da9 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -954,7 +954,7 @@ static int fsl_esdhc_probe(struct udevice *dev) struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); fdt_addr_t addr; unsigned int val; int ret; diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c index 1db683d01e6..7a7e67f6f35 100644 --- a/drivers/mmc/msm_sdhci.c +++ b/drivers/mmc/msm_sdhci.c @@ -50,16 +50,16 @@ DECLARE_GLOBAL_DATA_PTR; static int msm_sdc_clk_init(struct udevice *dev) { - uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, - "clock-frequency", 400000); + int node = dev_of_offset(dev); + uint clk_rate = fdtdec_get_uint(gd->fdt_blob, node, "clock-frequency", + 400000); uint clkd[2]; /* clk_id and clk_no */ int clk_offset; struct udevice *clk_dev; struct clk clk; int ret; - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd, - 2); + ret = fdtdec_get_int_array(gd->fdt_blob, node, "clock", clkd, 2); if (ret) return ret; @@ -168,17 +168,14 @@ static int msm_ofdata_to_platdata(struct udevice *dev) struct udevice *parent = dev->parent; struct msm_sdhc *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host; + int node = dev_of_offset(dev); host->name = strdup(dev->name); host->ioaddr = (void *)dev_get_addr(dev); - host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, - "bus-width", 4); - host->index = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "index", 0); + 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, - parent->of_offset, - dev->of_offset, - "reg", 1, NULL, - false); + dev_of_offset(parent), node, "reg", 1, NULL, false); if (priv->base == (void *)FDT_ADDR_T_NONE || host->ioaddr == (void *)FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c index b3268467dcc..5bb628d1250 100644 --- a/drivers/mmc/omap_hsmmc.c +++ b/drivers/mmc/omap_hsmmc.c @@ -728,7 +728,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev) { struct omap_hsmmc_data *priv = dev_get_priv(dev); const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); struct mmc_config *cfg; int val; diff --git a/drivers/mmc/pic32_sdhci.c b/drivers/mmc/pic32_sdhci.c index 1e14fa14d6a..9d8a392ed96 100644 --- a/drivers/mmc/pic32_sdhci.c +++ b/drivers/mmc/pic32_sdhci.c @@ -38,18 +38,18 @@ static int pic32_sdhci_probe(struct udevice *dev) fdt_size_t size; int ret; - addr = fdtdec_get_addr_size(fdt, dev->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(fdt, dev_of_offset(dev), "reg", &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; host->ioaddr = ioremap(addr, size); host->name = dev->name; host->quirks = SDHCI_QUIRK_NO_HISPD_BIT; - host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); host->ops = &pic32_sdhci_ops; - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "clock-freq-min-max", f_min_max, 2); if (ret) { printf("sdhci: clock-freq-min-max not found\n"); diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 47db6786cfc..c36eda05d20 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -59,24 +59,24 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev) host->name = dev->name; host->ioaddr = (void *)dev_get_addr(dev); - host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk; host->priv = dev; /* use non-removeable as sdcard and emmc as judgement */ - if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "non-removable")) + if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "non-removable")) host->dev_index = 0; else host->dev_index = 1; - priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "fifo-depth", 0); if (priv->fifo_depth < 0) return -EINVAL; - priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, + priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "fifo-mode"); - if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, + if (fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "clock-freq-min-max", priv->minmax, 2)) return -EINVAL; #endif diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index 13588647014..bd91f917580 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -38,7 +38,7 @@ static int arasan_sdhci_probe(struct udevice *dev) struct clk clk; - max_frequency = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "max-frequency", 0); ret = clk_get_by_index(dev, 0, &clk); if (!ret) { diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c index 28327d5f0bc..640ea0261eb 100644 --- a/drivers/mmc/s5p_sdhci.c +++ b/drivers/mmc/s5p_sdhci.c @@ -247,7 +247,7 @@ static int s5p_sdhci_probe(struct udevice *dev) struct sdhci_host *host = dev_get_priv(dev); int ret; - ret = sdhci_get_config(gd->fdt_blob, dev->of_offset, host); + ret = sdhci_get_config(gd->fdt_blob, dev_of_offset(dev), host); if (ret) return ret; diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c index 0a22e582957..d0c3c5155a0 100644 --- a/drivers/mmc/socfpga_dw_mmc.c +++ b/drivers/mmc/socfpga_dw_mmc.c @@ -70,7 +70,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev) return -EINVAL; } - fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "fifo-depth", 0); if (fifo_depth < 0) { printf("DWMMC: Can't get FIFO depth\n"); @@ -79,7 +79,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev) host->name = dev->name; host->ioaddr = (void *)dev_get_addr(dev); - host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); host->clksel = socfpga_dwmci_clksel; @@ -92,9 +92,9 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev) host->bus_hz = clk; host->fifoth_val = MSIZE(0x2) | RX_WMARK(fifo_depth / 2 - 1) | TX_WMARK(fifo_depth / 2); - priv->drvsel = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + priv->drvsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "drvsel", 3); - priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "smplsel", 0); host->priv = priv; diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c index 0211dc7b80d..0df74ef79ae 100644 --- a/drivers/mmc/tegra_mmc.c +++ b/drivers/mmc/tegra_mmc.c @@ -578,8 +578,8 @@ static int tegra_mmc_probe(struct udevice *dev) priv->cfg.name = "Tegra SD/MMC"; priv->cfg.ops = &tegra_mmc_ops; - bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", - 1); + bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), + "bus-width", 1); priv->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; priv->cfg.host_caps = 0; diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index 4af7fdb13c9..7f20ef124d6 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -705,7 +705,8 @@ static int uniphier_sd_probe(struct udevice *dev) plat->cfg.name = dev->name; plat->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS; - switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) { + switch (fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", + 1)) { case 8: plat->cfg.host_caps |= MMC_MODE_8BIT; break; @@ -719,7 +720,7 @@ static int uniphier_sd_probe(struct udevice *dev) return -EINVAL; } - if (fdt_get_property(gd->fdt_blob, dev->of_offset, "non-removable", + if (fdt_get_property(gd->fdt_blob, dev_of_offset(dev), "non-removable", NULL)) priv->caps |= UNIPHIER_SD_CAP_NONREMOVABLE; diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c index 828da111c80..f6781102398 100644 --- a/drivers/mmc/xenon_sdhci.c +++ b/drivers/mmc/xenon_sdhci.c @@ -405,7 +405,8 @@ static int xenon_sdhci_probe(struct udevice *dev) armada_3700_soc_pad_voltage_set(host); host->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_DDR_52MHz; - switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) { + switch (fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", + 1)) { case 8: host->host_caps |= MMC_MODE_8BIT; break; @@ -455,7 +456,7 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev) if (of_device_is_compatible(dev, "marvell,armada-3700-sdhci")) priv->pad_ctrl_reg = (void *)dev_get_addr_index(dev, 1); - name = fdt_getprop(gd->fdt_blob, dev->of_offset, "marvell,pad-type", + name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type", NULL); if (name) { if (0 == strncmp(name, "sd", 2)) { diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c index a9148a7fe41..e04964b558e 100644 --- a/drivers/mtd/altera_qspi.c +++ b/drivers/mtd/altera_qspi.c @@ -349,7 +349,7 @@ static int altera_qspi_ofdata_to_platdata(struct udevice *dev) { struct altera_qspi_platdata *pdata = dev_get_platdata(dev); void *blob = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const char *list, *end; const fdt32_t *cell; void *base; diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index e036b88a625..d440f5ccd96 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -2441,7 +2441,7 @@ unsigned long flash_init (void) static int cfi_flash_probe(struct udevice *dev) { void *blob = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const fdt32_t *cell; phys_addr_t addr; int parent, addrc, sizec; diff --git a/drivers/mtd/pic32_flash.c b/drivers/mtd/pic32_flash.c index 9166fcd9803..8ed7874cc9f 100644 --- a/drivers/mtd/pic32_flash.c +++ b/drivers/mtd/pic32_flash.c @@ -371,7 +371,7 @@ static void pic32_flash_bank_init(flash_info_t *info, static int pic32_flash_probe(struct udevice *dev) { void *blob = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const char *list, *end; const fdt32_t *cell; unsigned long addr, size; diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c index 4944059fa3f..36a50fe3a15 100644 --- a/drivers/mtd/spi/sandbox.c +++ b/drivers/mtd/spi/sandbox.c @@ -516,7 +516,7 @@ int sandbox_sf_ofdata_to_platdata(struct udevice *dev) { struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); pdata->filename = fdt_getprop(blob, node, "sandbox,filename", NULL); pdata->device_name = fdt_getprop(blob, node, "compatible", NULL); @@ -641,7 +641,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state, debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ", __func__, busnum, cs); ret = sandbox_sf_bind_emul(state, busnum, cs, bus, - slave->of_offset, slave->name); + dev_of_offset(slave), slave->name); if (ret) { debug("failed (err=%d)\n", ret); return ret; diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 2e378dc822a..ab7910bc145 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -919,7 +919,7 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) #ifdef CONFIG_DM_SPI_FLASH fdt_addr_t addr; fdt_size_t size; - int node = flash->dev->of_offset; + int node = dev_of_offset(flash->dev); addr = fdtdec_get_addr_size(blob, node, "memory-map", &size); if (addr == FDT_ADDR_T_NONE) { diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c index 346f138caf8..f8782bcbd03 100644 --- a/drivers/net/ag7xxx.c +++ b/drivers/net/ag7xxx.c @@ -857,7 +857,7 @@ static int ag7xxx_get_phy_iface_offset(struct udevice *dev) { int offset; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "phy"); + offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "phy"); if (offset <= 0) { debug("%s: PHY OF node not found (ret=%i)\n", __func__, offset); return -EINVAL; diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index 92a1b644958..d4d17dd2226 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -576,7 +576,7 @@ static int altera_tse_probe(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); struct altera_tse_priv *priv = dev_get_priv(dev); void *blob = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const char *list, *end; const fdt32_t *cell; void *base, *desc_mem = NULL; @@ -676,7 +676,8 @@ static int altera_tse_ofdata_to_platdata(struct udevice *dev) const char *phy_mode; pdata->phy_interface = -1; - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", + NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { diff --git a/drivers/net/cpsw-common.c b/drivers/net/cpsw-common.c index 607eb4563ce..55f56d95552 100644 --- a/drivers/net/cpsw-common.c +++ b/drivers/net/cpsw-common.c @@ -20,7 +20,7 @@ static int davinci_emac_3517_get_macid(struct udevice *dev, u16 offset, int slave, u8 *mac_addr) { void *fdt = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); u32 macid_lsb; u32 macid_msb; fdt32_t gmii = 0; @@ -60,7 +60,7 @@ static int cpsw_am33xx_cm_get_macid(struct udevice *dev, u16 offset, int slave, u8 *mac_addr) { void *fdt = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); u32 macid_lo; u32 macid_hi; fdt32_t gmii = 0; diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index cbce683eea9..5fbab9e492f 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -981,7 +981,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave) #ifdef CONFIG_DM_ETH if (slave->data->phy_of_handle) - phydev->dev->of_offset = slave->data->phy_of_handle; + dev_set_of_offset(phydev->dev, slave->data->phy_of_handle); #endif priv->phydev = phydev; @@ -1286,7 +1286,7 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) const char *phy_mode; const char *phy_sel_compat = NULL; const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int subnode; int slave_index = 0; int active_slave; diff --git a/drivers/net/designware.c b/drivers/net/designware.c index e207bc63b83..eee4e09d7ed 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -728,7 +728,8 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev) pdata->iobase = dev_get_addr(dev); pdata->phy_interface = -1; - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", + NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { @@ -737,19 +738,19 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev) } pdata->max_speed = 0; - cell = fdt_getprop(gd->fdt_blob, dev->of_offset, "max-speed", NULL); + cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL); if (cell) pdata->max_speed = fdt32_to_cpu(*cell); #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; ret = gpio_request_by_name(dev, "snps,reset-gpio", 0, &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", dw_pdata->reset_delays, 3); } else if (ret == -ENOENT) { ret = 0; diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 3304fddc696..5f34c8fe3c6 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1277,7 +1277,8 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) priv->eth = (struct ethernet_regs *)pdata->iobase; pdata->phy_interface = -1; - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", + NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c index 5f833fa711f..e9b202ab9ae 100644 --- a/drivers/net/gmac_rockchip.c +++ b/drivers/net/gmac_rockchip.c @@ -36,9 +36,9 @@ static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) { struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev); - pdata->tx_delay = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + pdata->tx_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "tx-delay", 0x30); - pdata->rx_delay = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + pdata->rx_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "rx-delay", 0x10); return designware_eth_ofdata_to_platdata(dev); diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c index a5120e01ad3..1b781f4d95a 100644 --- a/drivers/net/keystone_net.c +++ b/drivers/net/keystone_net.c @@ -1099,7 +1099,7 @@ static int ks2_sl_eth_ofdata_to_platdata(struct udevice *dev) struct ks2_eth_priv *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; - int slave = dev->of_offset; + int slave = dev_of_offset(dev); int interfaces; int gbe; int netcp_devices; @@ -1126,13 +1126,13 @@ static int ks2_eth_ofdata_to_platdata(struct udevice *dev) int netcp_devices; int gbe; - netcp_devices = fdt_subnode_offset(fdt, dev->of_offset, + netcp_devices = fdt_subnode_offset(fdt, dev_of_offset(dev), "netcp-devices"); gbe = fdt_subnode_offset(fdt, netcp_devices, "gbe"); ks2_eth_bind_slaves(dev, gbe, &gbe_0); - ks2_eth_parse_slave_interface(dev->of_offset, gbe_0, priv, pdata); + ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata); pdata->iobase = dev_get_addr(dev); diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 01527f7fc7c..452fc3e3b97 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -999,7 +999,8 @@ static int macb_eth_probe(struct udevice *dev) #ifdef CONFIG_DM_ETH const char *phy_mode; - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", + NULL); if (phy_mode) macb->phy_interface = phy_get_interface_by_name(phy_mode); if (macb->phy_interface == -1) { diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index 00f378f0826..674075f037d 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -1611,7 +1611,7 @@ static int mvneta_probe(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); struct mvneta_port *pp = dev_get_priv(dev); void *blob = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); struct mii_dev *bus; unsigned long addr; void *bd_space; @@ -1691,7 +1691,8 @@ static int mvneta_ofdata_to_platdata(struct udevice *dev) /* Get phy-mode / phy_interface from DT */ pdata->phy_interface = -1; - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", + NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c index 405776af95d..88e88b903b3 100644 --- a/drivers/net/mvpp2.c +++ b/drivers/net/mvpp2.c @@ -4047,7 +4047,7 @@ static int mvpp2_probe(struct udevice *dev) return err; } - return mvpp2_port_probe(dev, port, dev->of_offset, priv, + return mvpp2_port_probe(dev, port, dev_of_offset(dev), priv, &buffer_loc.first_rxq); } @@ -4138,7 +4138,7 @@ static int mvpp2_base_probe(struct udevice *dev) static int mvpp2_base_bind(struct udevice *parent) { const void *blob = gd->fdt_blob; - int node = parent->of_offset; + int node = dev_of_offset(parent); struct uclass_driver *drv; struct udevice *dev; struct eth_pdata *plat; @@ -4169,7 +4169,7 @@ static int mvpp2_base_bind(struct udevice *parent) /* Create child device UCLASS_ETH and bind it */ device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev); - dev->of_offset = subnode; + dev_set_of_offset(dev, subnode); } return 0; diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 7163fa257f4..0e4a4ebcc60 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -244,7 +244,7 @@ static int ksz90x1_of_config_group(struct phy_device *phydev, return -EOPNOTSUPP; for (i = 0; i < ofcfg->grpsz; i++) { - val[i] = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + val[i] = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), ofcfg->grp[i].name, -1); offset = ofcfg->grp[i].off; if (val[i] == -1) { diff --git a/drivers/net/phy/ti.c b/drivers/net/phy/ti.c index c55dd973f4c..d1ce4060ff8 100644 --- a/drivers/net/phy/ti.c +++ b/drivers/net/phy/ti.c @@ -167,13 +167,13 @@ static int dp83867_of_init(struct phy_device *phydev) struct dp83867_private *dp83867 = phydev->priv; struct udevice *dev = phydev->dev; - dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "ti,rx-internal-delay", -1); - dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "ti,tx-internal-delay", -1); - dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "ti,fifo-depth", -1); return 0; diff --git a/drivers/net/phy/xilinx_phy.c b/drivers/net/phy/xilinx_phy.c index 920bfcb380b..3f80f0495e8 100644 --- a/drivers/net/phy/xilinx_phy.c +++ b/drivers/net/phy/xilinx_phy.c @@ -104,7 +104,7 @@ static int xilinxphy_of_init(struct phy_device *phydev) u32 phytype; debug("%s\n", __func__); - phytype = fdtdec_get_int(gd->fdt_blob, phydev->dev->of_offset, + phytype = fdtdec_get_int(gd->fdt_blob, dev_of_offset(phydev->dev), "phy-type", -1); if (phytype == XAE_PHY_TYPE_1000BASE_X) phydev->flags |= XAE_PHY_TYPE_1000BASE_X; diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c index 167af8bde5b..385aad5b7e1 100644 --- a/drivers/net/pic32_eth.c +++ b/drivers/net/pic32_eth.c @@ -535,7 +535,8 @@ static int pic32_eth_probe(struct udevice *dev) int offset = 0; int phy_addr = -1; - addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg", + &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -544,7 +545,8 @@ static int pic32_eth_probe(struct udevice *dev) /* get phy mode */ pdata->phy_interface = -1; - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", + NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { @@ -553,13 +555,13 @@ static int pic32_eth_probe(struct udevice *dev) } /* get phy addr */ - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "phy-handle"); if (offset > 0) phy_addr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); /* phy reset gpio */ - gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset, + gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev), "reset-gpios", 0, &priv->rst_gpio, GPIOD_IS_OUT); diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index 591242797e2..9742c2c4f66 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -26,7 +26,7 @@ static int sb_eth_raw_start(struct udevice *dev) debug("eth_sandbox_raw: Start\n"); - interface = fdt_getprop(gd->fdt_blob, dev->of_offset, + interface = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "host-raw-interface", NULL); if (interface == NULL) return -EINVAL; diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index d538d379bbe..79d0ae68bfd 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -60,8 +60,9 @@ static int sb_eth_start(struct udevice *dev) debug("eth_sandbox: Start\n"); - fdtdec_get_byte_array(gd->fdt_blob, dev->of_offset, "fake-host-hwaddr", - priv->fake_host_hwaddr, ARP_HLEN); + fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(dev), + "fake-host-hwaddr", priv->fake_host_hwaddr, + ARP_HLEN); priv->recv_packet_buffer = net_rx_packets[0]; return 0; } diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index abd9cc8bc0b..b87210bad79 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -442,7 +442,7 @@ static int parse_phy_pins(struct udevice *dev) const char *pin_name; int drive, pull, i; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "pinctrl-0"); if (offset < 0) { printf("WARNING: emac: cannot find pinctrl-0 node\n"); @@ -716,6 +716,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); struct emac_eth_dev *priv = dev_get_priv(dev); const char *phy_mode; + int node = dev_of_offset(dev); int offset = 0; pdata->iobase = dev_get_addr_name(dev, "emac"); @@ -725,13 +726,13 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) priv->phyaddr = -1; priv->use_internal_phy = false; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy"); if (offset > 0) priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); @@ -751,7 +752,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) } if (priv->variant == H3_EMAC) { - if (fdt_getprop(gd->fdt_blob, dev->of_offset, + if (fdt_getprop(gd->fdt_blob, node, "allwinner,use-internal-phy", NULL)) priv->use_internal_phy = true; } diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index 7df4c63acfd..f2ce4e2a8ed 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -783,7 +783,7 @@ int tsec_probe(struct udevice *dev) pdata->iobase = (phys_addr_t)dev_get_addr(dev); priv->regs = (struct tsec *)pdata->iobase; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "phy-handle"); if (offset > 0) { reg = fdtdec_get_int(gd->fdt_blob, offset, "reg", 0); @@ -802,7 +802,7 @@ int tsec_probe(struct udevice *dev) return -ENOENT; } - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "tbi-handle"); if (offset > 0) { reg = fdtdec_get_int(gd->fdt_blob, offset, "reg", @@ -812,7 +812,7 @@ int tsec_probe(struct udevice *dev) priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE; } - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-connection-type", NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 51c74266637..a6f24b3cbec 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -682,13 +682,14 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); struct axidma_priv *priv = dev_get_priv(dev); + int node = dev_of_offset(dev); int offset = 0; const char *phy_mode; pdata->iobase = (phys_addr_t)dev_get_addr(dev); priv->iobase = (struct axi_regs *)pdata->iobase; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "axistream-connected"); if (offset <= 0) { printf("%s: axistream is not found\n", __func__); @@ -705,12 +706,11 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev) priv->phyaddr = -1; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, - "phy-handle"); + offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle"); if (offset > 0) priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index ea93cf906ed..7d4e14f8ef3 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -604,15 +604,15 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev) emaclite->phyaddr = -1; - offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, + offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "phy-handle"); if (offset > 0) emaclite->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); - emaclite->txpp = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + emaclite->txpp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "xlnx,tx-ping-pong", 0); - emaclite->rxpp = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + emaclite->rxpp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "xlnx,rx-ping-pong", 0); printf("EMACLITE: %lx, phyaddr %d, %d/%d\n", (ulong)emaclite->regs, diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 6dd87cf28f9..86dd03fedaf 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -345,7 +345,7 @@ static int zynq_phy_init(struct udevice *dev) priv->phydev->advertising = priv->phydev->supported; if (priv->phy_of_handle > 0) - priv->phydev->dev->of_offset = priv->phy_of_handle; + dev_set_of_offset(priv->phydev->dev, priv->phy_of_handle); return phy_config(priv->phydev); } @@ -684,6 +684,7 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); struct zynq_gem_priv *priv = dev_get_priv(dev); + int node = dev_of_offset(dev); const char *phy_mode; pdata->iobase = (phys_addr_t)dev_get_addr(dev); @@ -692,13 +693,13 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev) priv->emio = 0; priv->phyaddr = -1; - priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, - dev->of_offset, "phy-handle"); + priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, node, + "phy-handle"); if (priv->phy_of_handle > 0) priv->phyaddr = fdtdec_get_int(gd->fdt_blob, priv->phy_of_handle, "reg", -1); - phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); if (phy_mode) pdata->phy_interface = phy_get_interface_by_name(phy_mode); if (pdata->phy_interface == -1) { @@ -707,7 +708,7 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev) } priv->interface = pdata->phy_interface; - priv->emio = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "xlnx,emio"); + priv->emio = fdtdec_get_bool(gd->fdt_blob, node, "xlnx,emio"); printf("ZYNQ GEM: %lx, phyaddr %x, interface %s\n", (ulong)priv->iobase, priv->phyaddr, phy_string_for_interface(priv->interface)); diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 3b00e6a41b3..a1408f5bf1c 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -839,8 +839,9 @@ static int pci_uclass_pre_probe(struct udevice *bus) /* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus(bus)) { hose->ctlr = bus; - ret = decode_regions(hose, gd->fdt_blob, bus->parent->of_offset, - bus->of_offset); + ret = decode_regions(hose, gd->fdt_blob, + dev_of_offset(bus->parent), + dev_of_offset(bus)); if (ret) { debug("%s: Cannot decode regions\n", __func__); return ret; @@ -903,7 +904,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev) struct fdt_pci_addr addr; int ret; - if (dev->of_offset == -1) + if (dev_of_offset(dev) == -1) return 0; /* @@ -911,7 +912,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev) * just check the address. */ pplat = dev_get_parent_platdata(dev); - ret = fdtdec_get_pci_addr(gd->fdt_blob, dev->of_offset, + ret = fdtdec_get_pci_addr(gd->fdt_blob, dev_of_offset(dev), FDT_PCI_SPACE_CONFIG, "reg", &addr); if (ret) { diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c index 430270ec292..7d9c63b06f2 100644 --- a/drivers/pci/pci_tegra.c +++ b/drivers/pci/pci_tegra.c @@ -1099,7 +1099,7 @@ static int pci_tegra_ofdata_to_platdata(struct udevice *dev) INIT_LIST_HEAD(&pcie->ports); - if (tegra_pcie_parse_dt(gd->fdt_blob, dev->of_offset, id, pcie)) + if (tegra_pcie_parse_dt(gd->fdt_blob, dev_of_offset(dev), id, pcie)) return -EINVAL; return 0; diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c index 90b9fe2a17a..b6806cf67b6 100644 --- a/drivers/pci/pcie_layerscape.c +++ b/drivers/pci/pcie_layerscape.c @@ -438,7 +438,7 @@ static int ls_pcie_probe(struct udevice *dev) { struct ls_pcie *pcie = dev_get_priv(dev); const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); u8 header_type; u16 link_sta; bool ep_mode; diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c index 521600180e6..08e2e934458 100644 --- a/drivers/pci/pcie_xilinx.c +++ b/drivers/pci/pcie_xilinx.c @@ -186,7 +186,7 @@ static int pcie_xilinx_ofdata_to_platdata(struct udevice *dev) DECLARE_GLOBAL_DATA_PTR; int err; - err = fdt_get_resource(gd->fdt_blob, dev->of_offset, "reg", + err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg", 0, ®_res); if (err < 0) { error("\"reg\" resource not found\n"); diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index bc2508bb7e0..caa1928f07d 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -107,7 +107,7 @@ void comphy_print(struct chip_serdes_phy_config *chip_cfg, static int comphy_probe(struct udevice *dev) { const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); struct chip_serdes_phy_config *chip_cfg = dev_get_priv(dev); struct comphy_map comphy_map_data[MAX_LANE_OPTIONS]; int subnode; diff --git a/drivers/pinctrl/ath79/pinctrl_ar933x.c b/drivers/pinctrl/ath79/pinctrl_ar933x.c index e3f64b63553..fccc7c4b066 100644 --- a/drivers/pinctrl/ath79/pinctrl_ar933x.c +++ b/drivers/pinctrl/ath79/pinctrl_ar933x.c @@ -75,7 +75,7 @@ static int ar933x_pinctrl_get_periph_id(struct udevice *dev, u32 cell[2]; 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/pinctrl/ath79/pinctrl_qca953x.c b/drivers/pinctrl/ath79/pinctrl_qca953x.c index d02597e968a..a7f8c7082e8 100644 --- a/drivers/pinctrl/ath79/pinctrl_qca953x.c +++ b/drivers/pinctrl/ath79/pinctrl_qca953x.c @@ -95,7 +95,7 @@ static int qca953x_pinctrl_get_periph_id(struct udevice *dev, u32 cell[2]; 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/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c index dd0a16ef5fa..5b9a592b0da 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos.c @@ -70,7 +70,7 @@ static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name, int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config) { const void *fdt = gd->fdt_blob; - int node = config->of_offset; + int node = dev_of_offset(config); unsigned int count, idx, pin_num; unsigned int pinfunc, pinpud, pindrv; unsigned long reg, value; diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 30f7cfc8200..b5486b8fe4b 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -142,19 +142,19 @@ int meson_pinctrl_probe(struct udevice *dev) int node, gpio = -1, len; int na, ns; - na = fdt_address_cells(gd->fdt_blob, dev->parent->of_offset); + na = fdt_address_cells(gd->fdt_blob, dev_of_offset(dev->parent)); if (na < 1) { debug("bad #address-cells\n"); return -EINVAL; } - ns = fdt_size_cells(gd->fdt_blob, dev->parent->of_offset); + ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent)); if (ns < 1) { debug("bad #size-cells\n"); return -EINVAL; } - fdt_for_each_subnode(node, gd->fdt_blob, dev->of_offset) { + fdt_for_each_subnode(node, gd->fdt_blob, dev_of_offset(dev)) { if (fdt_getprop(gd->fdt_blob, node, "gpio-controller", &len)) { gpio = node; break; diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index b07763931fe..80f0dfaf91b 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR; int mvebu_pinctrl_set_state(struct udevice *dev, struct udevice *config) { const void *blob = gd->fdt_blob; - int node = config->of_offset; + int node = dev_of_offset(config); struct mvebu_pinctrl_priv *priv; u32 pin_arr[MVEBU_MAX_PINS_PER_BANK]; u32 function; @@ -82,7 +82,7 @@ static int mvebu_pinctrl_set_state_all(struct udevice *dev, struct udevice *config) { const void *blob = gd->fdt_blob; - int node = config->of_offset; + int node = dev_of_offset(config); struct mvebu_pinctrl_priv *priv; u32 func_arr[MVEBU_MAX_PINS_PER_BANK]; int pin, err; @@ -128,7 +128,7 @@ static int mvebu_pinctrl_set_state_all(struct udevice *dev, int mvebu_pinctl_probe(struct udevice *dev) { const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); struct mvebu_pinctrl_priv *priv; priv = dev_get_priv(dev); diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c b/drivers/pinctrl/nxp/pinctrl-imx.c index 949d0f32d8b..e130faf8764 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx.c +++ b/drivers/pinctrl/nxp/pinctrl-imx.c @@ -19,7 +19,7 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config) { struct imx_pinctrl_priv *priv = dev_get_priv(dev); struct imx_pinctrl_soc_info *info = priv->info; - int node = config->of_offset; + int node = dev_of_offset(config); const struct fdt_property *prop; u32 *pin_data; int npins, size, pin_size; @@ -176,7 +176,7 @@ int imx_pinctrl_probe(struct udevice *dev, struct imx_pinctrl_soc_info *info) { struct imx_pinctrl_priv *priv = dev_get_priv(dev); - int node = dev->of_offset, ret; + int node = dev_of_offset(dev), ret; struct fdtdec_phandle_args arg; fdt_addr_t addr; fdt_size_t size; @@ -189,7 +189,8 @@ int imx_pinctrl_probe(struct udevice *dev, priv->dev = dev; priv->info = info; - addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg", + &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 6d4aadc32c0..5c6bff568ad 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -109,7 +109,7 @@ static int atmel_pinctrl_set_state(struct udevice *dev, struct udevice *config) { struct atmel_pio4_port *bank_base; const void *blob = gd->fdt_blob; - int node = config->of_offset; + int node = dev_of_offset(config); u32 offset, func, bank, line; u32 cells[MAX_PINMUX_ENTRIES]; u32 i, conf; diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c index 3629322dbb3..0272496b51d 100644 --- a/drivers/pinctrl/pinctrl-generic.c +++ b/drivers/pinctrl/pinctrl-generic.c @@ -245,7 +245,7 @@ static int pinctrl_generic_set_state_one(struct udevice *dev, bool is_group, unsigned selector) { const void *fdt = gd->fdt_blob; - int node_offset = config->of_offset; + int node_offset = dev_of_offset(config); const char *propname; const void *value; int prop_offset, len, func_selector, param, ret; @@ -300,7 +300,7 @@ static int pinctrl_generic_set_state_subnode(struct udevice *dev, struct udevice *config) { const void *fdt = gd->fdt_blob; - int node = config->of_offset; + int node = dev_of_offset(config); const char *subnode_target_type = "pins"; bool is_group = false; const char *name; diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index 02ab9b4afde..49afe91c24e 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -64,7 +64,7 @@ static int pinctrl_config_one(struct udevice *config) static int pinctrl_select_state_full(struct udevice *dev, const char *statename) { const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); char propname[32]; /* long enough */ const fdt32_t *list; uint32_t phandle; @@ -122,7 +122,7 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename) static int pinconfig_post_bind(struct udevice *dev) { const void *fdt = gd->fdt_blob; - int offset = dev->of_offset; + int offset = dev_of_offset(dev); bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC); const char *name; int ret; diff --git a/drivers/pinctrl/pinctrl_pic32.c b/drivers/pinctrl/pinctrl_pic32.c index 9acac29133c..59466ee02e6 100644 --- a/drivers/pinctrl/pinctrl_pic32.c +++ b/drivers/pinctrl/pinctrl_pic32.c @@ -253,7 +253,7 @@ static int pic32_pinctrl_get_periph_id(struct udevice *dev, int ret; u32 cell[2]; - 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; @@ -310,7 +310,7 @@ static int pic32_pinctrl_probe(struct udevice *dev) struct pic32_pinctrl_priv *priv = dev_get_priv(dev); struct fdt_resource res; void *fdt = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; ret = fdt_get_named_resource(fdt, node, "reg", "reg-names", diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3036.c b/drivers/pinctrl/rockchip/pinctrl_rk3036.c index 6aea856aa63..8d42584b315 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3036.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3036.c @@ -205,7 +205,7 @@ static int rk3036_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/pinctrl/rockchip/pinctrl_rk3288.c b/drivers/pinctrl/rockchip/pinctrl_rk3288.c index 03222647cad..cb13d30da8e 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3288.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3288.c @@ -479,7 +479,7 @@ static int rk3288_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; @@ -644,7 +644,7 @@ static int rk3288_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_rk3399.c b/drivers/pinctrl/rockchip/pinctrl_rk3399.c index 17ea165edaf..da301544c99 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3399.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3399.c @@ -362,7 +362,7 @@ static int rk3399_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/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c index 1bb6262fa1b..3dabbe4ac0a 100644 --- a/drivers/power/domain/power-domain-uclass.c +++ b/drivers/power/domain/power-domain-uclass.c @@ -41,7 +41,7 @@ int power_domain_get(struct udevice *dev, struct power_domain *power_domain) debug("%s(dev=%p, power_domain=%p)\n", __func__, dev, power_domain); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset, + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), "power-domains", "#power-domain-cells", 0, 0, &args); diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c index e8164bfd08a..15da12edea9 100644 --- a/drivers/power/pmic/act8846.c +++ b/drivers/power/pmic/act8846.c @@ -52,7 +52,7 @@ static int act8846_bind(struct udevice *dev) int regulators_node; int children; - regulators_node = fdt_subnode_offset(blob, dev->of_offset, + regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators"); if (regulators_node <= 0) { debug("%s: %s regulators subnode not found!", __func__, diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c index aeab5c949ad..4f92e3dad82 100644 --- a/drivers/power/pmic/i2c_pmic_emul.c +++ b/drivers/power/pmic/i2c_pmic_emul.c @@ -108,9 +108,9 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul) debug("%s:%d Setting PMIC default registers\n", __func__, __LINE__); - reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob, emul->of_offset, - "reg-defaults", - SANDBOX_PMIC_REG_COUNT); + reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob, + dev_of_offset(emul), "reg-defaults", + SANDBOX_PMIC_REG_COUNT); if (!reg_defaults) { error("Property \"reg-defaults\" not found for device: %s!", diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c index 307f96bad1b..d8f30df371b 100644 --- a/drivers/power/pmic/lp873x.c +++ b/drivers/power/pmic/lp873x.c @@ -49,7 +49,7 @@ static int lp873x_bind(struct udevice *dev) int regulators_node; const void *blob = gd->fdt_blob; int children; - int node = dev->of_offset; + int node = dev_of_offset(dev); regulators_node = fdt_subnode_offset(blob, node, "regulators"); diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c index dc5a54a6a3a..8295fab3f02 100644 --- a/drivers/power/pmic/max77686.c +++ b/drivers/power/pmic/max77686.c @@ -54,7 +54,7 @@ static int max77686_bind(struct udevice *dev) const void *blob = gd->fdt_blob; int children; - regulators_node = fdt_subnode_offset(blob, dev->of_offset, + regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), "voltage-regulators"); if (regulators_node <= 0) { debug("%s: %s regulators subnode not found!", __func__, diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c index 0ab425e5dc7..f5a23073c4a 100644 --- a/drivers/power/pmic/palmas.c +++ b/drivers/power/pmic/palmas.c @@ -49,7 +49,7 @@ static int palmas_bind(struct udevice *dev) int pmic_node = -1, regulators_node; const void *blob = gd->fdt_blob; int children; - int node = dev->of_offset; + int node = dev_of_offset(dev); int subnode, len; fdt_for_each_subnode(subnode, blob, node) { diff --git a/drivers/power/pmic/pfuze100.c b/drivers/power/pmic/pfuze100.c index 3beb48eeac5..90a43f2fe52 100644 --- a/drivers/power/pmic/pfuze100.c +++ b/drivers/power/pmic/pfuze100.c @@ -56,7 +56,7 @@ static int pfuze100_bind(struct udevice *dev) int regulators_node; const void *blob = gd->fdt_blob; - regulators_node = fdt_subnode_offset(blob, dev->of_offset, + regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators"); if (regulators_node <= 0) { debug("%s: %s regulators subnode not found!", __func__, diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c index 7211026aecb..0f7fa517f99 100644 --- a/drivers/power/pmic/pmic-uclass.c +++ b/drivers/power/pmic/pmic-uclass.c @@ -33,7 +33,7 @@ int pmic_bind_children(struct udevice *pmic, int offset, int ret; debug("%s for '%s' at node offset: %d\n", __func__, pmic->name, - pmic->of_offset); + dev_of_offset(pmic)); for (node = fdt_first_subnode(blob, offset); node > 0; diff --git a/drivers/power/pmic/rk808.c b/drivers/power/pmic/rk808.c index 770f471672e..3f5f316b56f 100644 --- a/drivers/power/pmic/rk808.c +++ b/drivers/power/pmic/rk808.c @@ -61,7 +61,7 @@ static int rk808_bind(struct udevice *dev) int regulators_node; int children; - regulators_node = fdt_subnode_offset(blob, dev->of_offset, + regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators"); if (regulators_node <= 0) { debug("%s: %s regulators subnode not found!", __func__, diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c index 075fe7e2f15..25d673b9981 100644 --- a/drivers/power/pmic/s5m8767.c +++ b/drivers/power/pmic/s5m8767.c @@ -58,7 +58,7 @@ static int s5m8767_bind(struct udevice *dev) const void *blob = gd->fdt_blob; int children; - node = fdt_subnode_offset(blob, dev->of_offset, "regulators"); + node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators"); if (node <= 0) { debug("%s: %s regulators subnode not found!", __func__, dev->name); diff --git a/drivers/power/pmic/sandbox.c b/drivers/power/pmic/sandbox.c index 3e56acd5e27..b4e412eb3ef 100644 --- a/drivers/power/pmic/sandbox.c +++ b/drivers/power/pmic/sandbox.c @@ -51,7 +51,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg, static int sandbox_pmic_bind(struct udevice *dev) { - if (!pmic_bind_children(dev, dev->of_offset, pmic_children_info)) + if (!pmic_bind_children(dev, dev_of_offset(dev), pmic_children_info)) error("%s:%d PMIC: %s - no child found!", __func__, __LINE__, dev->name); diff --git a/drivers/power/pmic/tps65090.c b/drivers/power/pmic/tps65090.c index 4797f327fac..b30a7f08e95 100644 --- a/drivers/power/pmic/tps65090.c +++ b/drivers/power/pmic/tps65090.c @@ -56,7 +56,7 @@ static int tps65090_bind(struct udevice *dev) const void *blob = gd->fdt_blob; int children; - regulators_node = fdt_subnode_offset(blob, dev->of_offset, + regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators"); if (regulators_node <= 0) { debug("%s: %s regulators subnode not found!", __func__, diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index 3d2d9081c1b..cd5213766dc 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -28,7 +28,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) struct fixed_regulator_platdata *dev_pdata; struct gpio_desc *gpio; const void *blob = gd->fdt_blob; - int node = dev->of_offset, flags = GPIOD_IS_OUT; + int node = dev_of_offset(dev), flags = GPIOD_IS_OUT; int ret; dev_pdata = dev_get_platdata(dev); @@ -54,7 +54,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) /* Get optional ramp up delay */ dev_pdata->startup_delay_us = fdtdec_get_uint(gd->fdt_blob, - dev->of_offset, + dev_of_offset(dev), "startup-delay-us", 0); return 0; diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c index 0a60a9cfc6a..42391c69b43 100644 --- a/drivers/power/regulator/gpio-regulator.c +++ b/drivers/power/regulator/gpio-regulator.c @@ -30,7 +30,7 @@ static int gpio_regulator_ofdata_to_platdata(struct udevice *dev) struct gpio_regulator_platdata *dev_pdata; struct gpio_desc *gpio; const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret, count, i, j; u32 states_array[8]; diff --git a/drivers/power/regulator/pwm_regulator.c b/drivers/power/regulator/pwm_regulator.c index b0a4c5da6d8..4875238e43d 100644 --- a/drivers/power/regulator/pwm_regulator.c +++ b/drivers/power/regulator/pwm_regulator.c @@ -88,7 +88,7 @@ static int pwm_regulator_ofdata_to_platdata(struct udevice *dev) struct pwm_regulator_info *priv = dev_get_priv(dev); struct fdtdec_phandle_args args; const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; ret = fdtdec_parse_phandle_with_args(blob, node, "pwms", "#pwm-cells", diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 52a10703632..2e0b5ed307f 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -278,7 +278,7 @@ static bool regulator_name_is_unique(struct udevice *check_dev, static int regulator_post_bind(struct udevice *dev) { struct dm_regulator_uclass_platdata *uc_pdata; - int offset = dev->of_offset; + int offset = dev_of_offset(dev); const void *blob = gd->fdt_blob; const char *property = "regulator-name"; @@ -308,7 +308,7 @@ static int regulator_post_bind(struct udevice *dev) static int regulator_pre_probe(struct udevice *dev) { struct dm_regulator_uclass_platdata *uc_pdata; - int offset = dev->of_offset; + int offset = dev_of_offset(dev); uc_pdata = dev_get_uclass_platdata(dev); if (!uc_pdata) diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c index 200cf61bc94..b6e67f2bf3e 100644 --- a/drivers/remoteproc/rproc-uclass.c +++ b/drivers/remoteproc/rproc-uclass.c @@ -116,7 +116,7 @@ static int rproc_pre_probe(struct udevice *dev) if (!dev->platdata) { #if CONFIG_IS_ENABLED(OF_CONTROL) - int node = dev->of_offset; + int node = dev_of_offset(dev); const void *blob = gd->fdt_blob; bool tmp; if (!blob) { diff --git a/drivers/remoteproc/ti_power_proc.c b/drivers/remoteproc/ti_power_proc.c index 76ac3be092e..bb7a145f452 100644 --- a/drivers/remoteproc/ti_power_proc.c +++ b/drivers/remoteproc/ti_power_proc.c @@ -33,7 +33,7 @@ struct ti_powerproc_privdata { static int ti_of_to_priv(struct udevice *dev, struct ti_powerproc_privdata *priv) { - int node = dev->of_offset; + int node = dev_of_offset(dev); const void *blob = gd->fdt_blob; int tmp; diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c index d3744ef703c..e92b24fa34a 100644 --- a/drivers/reset/reset-uclass.c +++ b/drivers/reset/reset-uclass.c @@ -43,7 +43,7 @@ int reset_get_by_index(struct udevice *dev, int index, debug("%s(dev=%p, index=%d, reset_ctl=%p)\n", __func__, dev, index, reset_ctl); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset, + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), "resets", "#reset-cells", 0, index, &args); if (ret) { @@ -88,7 +88,7 @@ int reset_get_by_name(struct udevice *dev, const char *name, debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name, reset_ctl); - index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset, + index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), "reset-names", name); if (index < 0) { debug("fdt_stringlist_search() failed: %d\n", index); diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c index eff9c592d65..8344940282e 100644 --- a/drivers/serial/altera_uart.c +++ b/drivers/serial/altera_uart.c @@ -92,7 +92,7 @@ static int altera_uart_ofdata_to_platdata(struct udevice *dev) plat->regs = map_physmem(dev_get_addr(dev), sizeof(struct altera_uart_regs), MAP_NOCACHE); - plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); return 0; diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 2df4a1f04fe..1f819d487b6 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -383,13 +383,13 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev) int ret; /* we prefer to use a memory-mapped register */ - ret = fdtdec_get_pci_addr(gd->fdt_blob, dev->of_offset, + ret = fdtdec_get_pci_addr(gd->fdt_blob, dev_of_offset(dev), FDT_PCI_SPACE_MEM32, "reg", &pci_addr); if (ret) { /* try if there is any i/o-mapped register */ ret = fdtdec_get_pci_addr(gd->fdt_blob, - dev->of_offset, + dev_of_offset(dev), FDT_PCI_SPACE_IO, "reg", &pci_addr); if (ret) @@ -413,9 +413,9 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev) plat->base = (unsigned long)map_physmem(addr, 0, MAP_NOCACHE); #endif - plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg-offset", 0); - plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg-shift", 0); err = clk_get_by_index(dev, 0, &clk); @@ -429,7 +429,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev) } if (!plat->clock) - plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", CONFIG_SYS_NS16550_CLK); if (!plat->clock) { diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index bcc3465312e..858e340f593 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -152,7 +152,7 @@ static int sandbox_serial_ofdata_to_platdata(struct udevice *dev) int i; plat->colour = -1; - colour = fdt_getprop(gd->fdt_blob, dev->of_offset, + colour = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "sandbox,text-colour", NULL); if (colour) { for (i = 0; i < ARRAY_SIZE(ansi_colour); i++) { diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 326a536a26a..fc91977b4c8 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -115,7 +115,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev) DECLARE_GLOBAL_DATA_PTR; plat->reg = (struct arc_serial_regs *)dev_get_addr(dev); - plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); return 0; diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 3884f744cda..e7ed8993b84 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -164,8 +164,9 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev) return -EINVAL; plat->base = addr; - plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1); - plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, + plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock", + 1); + plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "skip-init"); plat->disabled = false; return 0; diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c index a7cab1346f2..63b3006c638 100644 --- a/drivers/serial/serial_msm.c +++ b/drivers/serial/serial_msm.c @@ -146,7 +146,7 @@ static const struct dm_serial_ops msm_serial_ops = { static int msm_uart_clk_init(struct udevice *dev) { - uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, + uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 115200); uint clkd[2]; /* clk_id and clk_no */ int clk_offset; @@ -154,8 +154,8 @@ static int msm_uart_clk_init(struct udevice *dev) struct clk clk; int ret; - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd, - 2); + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "clock", + clkd, 2); if (ret) return ret; diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 4fd2b1dd054..1cfcbf25b4f 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -359,7 +359,7 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev) plat->reg = (struct mxc_uart *)addr; - plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, + plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "fsl,dte-mode"); return 0; } diff --git a/drivers/serial/serial_pic32.c b/drivers/serial/serial_pic32.c index c2141f0a083..b0e01aa0e5c 100644 --- a/drivers/serial/serial_pic32.c +++ b/drivers/serial/serial_pic32.c @@ -141,7 +141,8 @@ static int pic32_uart_probe(struct udevice *dev) int ret; /* get address */ - addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg", + &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index a8d3d675d57..a49134a95a8 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -354,9 +354,10 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev) return -EINVAL; plat->base = addr; - plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1); + plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock", + 1); plat->type = dev_get_driver_data(dev); - plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, + plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "skip-init"); return 0; } diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 622547951e6..96842de8d47 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -187,7 +187,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev) return -EINVAL; plat->reg = (struct s5p_uart *)addr; - plat->port_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + plat->port_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "id", dev->seq); return 0; } diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index ef7cf0f26c8..51f7fbcfb79 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -216,12 +216,13 @@ static int sh_serial_ofdata_to_platdata(struct udevice *dev) struct sh_serial_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg"); + addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg"); if (addr == FDT_ADDR_T_NONE) return -EINVAL; plat->base = addr; - plat->clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1); + plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock", + 1); plat->type = dev_get_driver_data(dev); return 0; } diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c index 4ea5304b1d0..0e25cba6acc 100644 --- a/drivers/serial/serial_uniphier.c +++ b/drivers/serial/serial_uniphier.c @@ -105,7 +105,7 @@ static int uniphier_serial_probe(struct udevice *dev) priv->membase = port; - priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); tmp = readl(&port->lcr_mcr); diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c index f16f90de289..9a6e41f3307 100644 --- a/drivers/spi/cadence_qspi.c +++ b/drivers/spi/cadence_qspi.c @@ -282,7 +282,7 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) { struct cadence_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); int subnode; u32 data[4]; int ret; diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 20aa99a451d..65d37b0b9fa 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -540,7 +540,7 @@ static int davinci_ofdata_to_platadata(struct udevice *bus) { struct davinci_spi_slave *ds = dev_get_priv(bus); const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); ds->regs = dev_map_physmem(bus, sizeof(struct davinci_spi_regs)); if (!ds->regs) { diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c index 24a6e982054..9d5e29c6c3f 100644 --- a/drivers/spi/designware_spi.c +++ b/drivers/spi/designware_spi.c @@ -132,7 +132,7 @@ static int dw_spi_ofdata_to_platdata(struct udevice *bus) { struct dw_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->regs = (struct dw_spi *)dev_get_addr(bus); diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index 44948c37364..aa0784c04a5 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -253,7 +253,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus) { struct exynos_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->regs = (struct exynos_spi *)dev_get_addr(bus); plat->periph_id = pinmux_decode_periph_id(blob, node); diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c index f213587557c..e09985ef2bf 100644 --- a/drivers/spi/fsl_dspi.c +++ b/drivers/spi/fsl_dspi.c @@ -646,7 +646,7 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus) fdt_addr_t addr; struct fsl_dspi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); if (fdtdec_get_bool(blob, node, "big-endian")) plat->flags |= DSPI_FLAG_REGMAP_ENDIAN_BIG; diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 4d378c227d5..b2a058380f6 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -1078,7 +1078,7 @@ static int fsl_qspi_ofdata_to_platdata(struct udevice *bus) struct fdt_resource res_regs, res_mem; struct fsl_qspi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); int ret, flash_num = 0, subnode; if (fdtdec_get_bool(blob, node, "big-endian")) diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index caf0103dc38..893fe33b66f 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -658,14 +658,14 @@ static int ich_spi_child_pre_probe(struct udevice *dev) static int ich_spi_ofdata_to_platdata(struct udevice *dev) { struct ich_spi_platdata *plat = dev_get_platdata(dev); + int node = dev_of_offset(dev); int ret; - ret = fdt_node_check_compatible(gd->fdt_blob, dev->of_offset, - "intel,ich7-spi"); + ret = fdt_node_check_compatible(gd->fdt_blob, node, "intel,ich7-spi"); if (ret == 0) { plat->ich_version = ICHV_7; } else { - ret = fdt_node_check_compatible(gd->fdt_blob, dev->of_offset, + ret = fdt_node_check_compatible(gd->fdt_blob, node, "intel,ich9-spi"); if (ret == 0) plat->ich_version = ICHV_9; diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c index 7c58c3661fa..ee847e46105 100644 --- a/drivers/spi/mvebu_a3700_spi.c +++ b/drivers/spi/mvebu_a3700_spi.c @@ -261,9 +261,9 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) * it should be used to read the input clock and the DT property * can be removed. */ - plat->clock = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), "clock-frequency", 160000); - plat->frequency = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + plat->frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), "spi-max-frequency", 40000); return 0; diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index 60e9d6e8255..8a894501097 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -627,7 +627,7 @@ static int omap3_spi_probe(struct udevice *dev) { struct omap3_spi_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); struct omap2_mcspi_platform_config* data = (struct omap2_mcspi_platform_config*)dev_get_driver_data(dev); diff --git a/drivers/spi/pic32_spi.c b/drivers/spi/pic32_spi.c index 25ca1f3e1ba..78d78bc54ba 100644 --- a/drivers/spi/pic32_spi.c +++ b/drivers/spi/pic32_spi.c @@ -377,13 +377,14 @@ static int pic32_spi_probe(struct udevice *bus) { struct pic32_spi_priv *priv = dev_get_priv(bus); struct dm_spi_bus *dm_spi = dev_get_uclass_priv(bus); + int node = dev_of_offset(bus); struct udevice *clkdev; fdt_addr_t addr; fdt_size_t size; int ret; debug("%s: %d, bus: %i\n", __func__, __LINE__, bus->seq); - addr = fdtdec_get_addr_size(gd->fdt_blob, bus->of_offset, "reg", &size); + addr = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -391,8 +392,8 @@ static int pic32_spi_probe(struct udevice *bus) if (!priv->regs) return -EINVAL; - dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset, - "spi-max-frequency", 250000000); + dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, node, "spi-max-frequency", + 250000000); /* get clock rate */ ret = clk_get_by_index(bus, 0, &clkdev); if (ret < 0) { @@ -413,8 +414,7 @@ static int pic32_spi_probe(struct udevice *bus) * of the ongoing transfer. To avoid this sort of error we will drive * /CS manually by toggling cs-gpio pins. */ - ret = gpio_request_by_name_nodev(gd->fdt_blob, bus->of_offset, - "cs-gpios", 0, + ret = gpio_request_by_name_nodev(gd->fdt_blob, node, "cs-gpios", 0, &priv->cs_gpio, GPIOD_IS_OUT); if (ret) { printf("pic32-spi: error, cs-gpios not found\n"); diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index 15cf0bda202..3e44f1795e3 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -164,7 +164,7 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice *bus) struct rockchip_spi_platdata *plat = dev_get_platdata(bus); struct rockchip_spi_priv *priv = dev_get_priv(bus); const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); int ret; plat->base = dev_get_addr(bus); diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index d23dc81a211..1690cd76f90 100644 --- a/drivers/spi/soft_spi.c +++ b/drivers/spi/soft_spi.c @@ -202,7 +202,7 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev) { struct soft_spi_platdata *plat = dev->platdata; const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); plat->spi_delay_us = fdtdec_get_int(blob, node, "spi-delay-us", 0); diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index 1ab5b75fa1f..ac17da0777d 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -113,10 +113,11 @@ static int spi_child_post_bind(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); - if (dev->of_offset == -1) + if (dev_of_offset(dev) == -1) return 0; - return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat); + return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev), + plat); } #endif @@ -125,7 +126,7 @@ static int spi_post_probe(struct udevice *bus) #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct dm_spi_bus *spi = dev_get_uclass_priv(bus); - spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset, + spi->max_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), "spi-max-frequency", 0); #endif #if defined(CONFIG_NEEDS_MANUAL_RELOC) diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c index 123a1f368d8..05358ebf4cd 100644 --- a/drivers/spi/stm32_qspi.c +++ b/drivers/spi/stm32_qspi.c @@ -411,7 +411,7 @@ static int stm32_qspi_ofdata_to_platdata(struct udevice *bus) struct fdt_resource res_regs, res_mem; struct stm32_qspi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); int ret; ret = fdt_get_named_resource(blob, node, "reg", "reg-names", diff --git a/drivers/spi/tegra114_spi.c b/drivers/spi/tegra114_spi.c index 509afba0a29..897409ca02f 100644 --- a/drivers/spi/tegra114_spi.c +++ b/drivers/spi/tegra114_spi.c @@ -101,7 +101,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus) { struct tegra_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->base = dev_get_addr(bus); plat->periph_id = clock_decode_periph_id(blob, node); diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c index ce3a2d398cf..ecbf4c16f3b 100644 --- a/drivers/spi/tegra20_sflash.c +++ b/drivers/spi/tegra20_sflash.c @@ -88,7 +88,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus) { struct tegra_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->base = dev_get_addr(bus); plat->periph_id = clock_decode_periph_id(blob, node); diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c index e1da23b7b44..1d99a1e910e 100644 --- a/drivers/spi/tegra20_slink.c +++ b/drivers/spi/tegra20_slink.c @@ -94,7 +94,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus) { struct tegra_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->base = dev_get_addr(bus); plat->periph_id = clock_decode_periph_id(blob, node); diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c index 026cff0c152..1e094cbc8b3 100644 --- a/drivers/spi/tegra210_qspi.c +++ b/drivers/spi/tegra210_qspi.c @@ -97,7 +97,7 @@ static int tegra210_qspi_ofdata_to_platdata(struct udevice *bus) { struct tegra_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->base = dev_get_addr(bus); plat->periph_id = clock_decode_periph_id(blob, node); diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c index 6f9f983524d..79955d75979 100644 --- a/drivers/spi/ti_qspi.c +++ b/drivers/spi/ti_qspi.c @@ -553,7 +553,7 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus) { struct ti_qspi_priv *priv = dev_get_priv(bus); const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); fdt_addr_t addr; void *mmap; diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c index b98663c23b2..255e02f585d 100644 --- a/drivers/spi/zynq_qspi.c +++ b/drivers/spi/zynq_qspi.c @@ -101,7 +101,7 @@ static int zynq_qspi_ofdata_to_platdata(struct udevice *bus) { struct zynq_qspi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->regs = (struct zynq_qspi_regs *)fdtdec_get_addr(blob, node, "reg"); diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c index 15ca271ea4a..5a9b1f0f2ee 100644 --- a/drivers/spi/zynq_spi.c +++ b/drivers/spi/zynq_spi.c @@ -71,7 +71,7 @@ static int zynq_spi_ofdata_to_platdata(struct udevice *bus) { struct zynq_spi_platdata *plat = bus->platdata; const void *blob = gd->fdt_blob; - int node = bus->of_offset; + int node = dev_of_offset(bus); plat->regs = (struct zynq_spi_regs *)dev_get_addr(bus); diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 48bc1575964..605683fc0e5 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -147,18 +147,14 @@ static int msm_spmi_probe(struct udevice *dev) { struct udevice *parent = dev->parent; struct msm_spmi_priv *priv = dev_get_priv(dev); + int node = dev_of_offset(dev); int i; priv->arb_chnl = dev_get_addr(dev); priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, - parent->of_offset, - dev->of_offset, - "reg", 1, NULL, - false); + dev_of_offset(parent), node, "reg", 1, NULL, false); priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, - parent->of_offset, - dev->of_offset, "reg", - 2, NULL, false); + dev_of_offset(parent), node, "reg", 2, NULL, false); if (priv->arb_chnl == FDT_ADDR_T_NONE || priv->spmi_core == FDT_ADDR_T_NONE || priv->spmi_obs == FDT_ADDR_T_NONE) diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 7ae7f386ee0..0c4e2e1a93a 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -41,7 +41,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) * (see the U_BOOT_DEVICE() declaration below) should not do anything. * If we are that device, return an error. */ - if (state->fdt_fname && dev->of_offset == -1) + if (state->fdt_fname && dev_of_offset(dev) == -1) return -ENODEV; switch (type) { diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 5c63e6b4101..1caf3cd2887 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -55,7 +55,7 @@ static int timer_pre_probe(struct udevice *dev) uc_priv->clock_rate = ret; } else uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob, - dev->of_offset, "clock-frequency", 0); + dev_of_offset(dev), "clock-frequency", 0); return 0; } diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c index 0965ad01d3d..9abb323745a 100644 --- a/drivers/usb/emul/sandbox_flash.c +++ b/drivers/usb/emul/sandbox_flash.c @@ -373,8 +373,8 @@ static int sandbox_flash_ofdata_to_platdata(struct udevice *dev) struct sandbox_flash_plat *plat = dev_get_platdata(dev); const void *blob = gd->fdt_blob; - plat->pathname = fdt_getprop(blob, dev->of_offset, "sandbox,filepath", - NULL); + plat->pathname = fdt_getprop(blob, dev_of_offset(dev), + "sandbox,filepath", NULL); return 0; } diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c index 624fbdecf1f..c3a8e73389d 100644 --- a/drivers/usb/emul/sandbox_hub.c +++ b/drivers/usb/emul/sandbox_hub.c @@ -277,7 +277,8 @@ static int sandbox_child_post_bind(struct udevice *dev) { struct sandbox_hub_platdata *plat = dev_get_parent_platdata(dev); - plat->port = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1); + plat->port = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", + -1); return 0; } diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index d08879dc67d..d253b946f33 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -1199,8 +1199,8 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) return -EINVAL; priv->regs = (struct dwc2_core_regs *)addr; - prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "disable-over-current", - NULL); + prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), + "disable-over-current", NULL); if (prop) priv->oc_disable = true; diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 53281d78b35..981543e3150 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -59,7 +59,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) } depth = 0; - node = fdtdec_next_compatible_subnode(blob, dev->of_offset, + node = fdtdec_next_compatible_subnode(blob, dev_of_offset(dev), COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth); if (node <= 0) { debug("XHCI: Can't get device node for usb3-phy controller\n"); diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 9c329218268..7ad50fccee3 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -61,7 +61,7 @@ static int ehci_fsl_ofdata_to_platdata(struct udevice *dev) struct ehci_fsl_priv *priv = dev_get_priv(dev); const void *prop; - prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy_type", + prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy_type", NULL); if (prop) { priv->phy_type = (char *)prop; diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 7b309b7b961..55ac162a3c0 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -437,7 +437,7 @@ static int ehci_usb_phy_mode(struct udevice *dev) void *__iomem addr = (void *__iomem)dev_get_addr(dev); void *__iomem phy_ctrl, *__iomem phy_status; const void *blob = gd->fdt_blob; - int offset = dev->of_offset, phy_off; + int offset = dev_of_offset(dev), phy_off; u32 val; /* @@ -484,7 +484,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) struct usb_platdata *plat = dev_get_platdata(dev); const char *mode; - mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "dr_mode", NULL); + mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "dr_mode", NULL); if (mode) { if (strcmp(mode, "peripheral") == 0) plat->init_type = USB_INIT_DEVICE; diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index e3620da15fb..beb3b027963 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -696,7 +696,7 @@ static void config_clock(const u32 timing[]) static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config) { const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const char *phy, *mode; config->reg = (struct usb_ctlr *)dev_get_addr(dev); diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index f389bff1718..84241cd1732 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -218,7 +218,7 @@ static int vf_usb_ofdata_to_platdata(struct udevice *dev) { struct ehci_vf_priv_data *priv = dev_get_priv(dev); const void *dt_blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); const char *mode; priv->portnr = dev->seq; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index be114fc0771..5cf1e9a36cb 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -686,16 +686,17 @@ int usb_child_post_bind(struct udevice *dev) const void *blob = gd->fdt_blob; int val; - if (dev->of_offset == -1) + if (dev_of_offset(dev) == -1) return 0; /* We only support matching a few things */ - val = fdtdec_get_int(blob, dev->of_offset, "usb,device-class", -1); + val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,device-class", -1); if (val != -1) { plat->id.match_flags |= USB_DEVICE_ID_MATCH_DEV_CLASS; plat->id.bDeviceClass = val; } - val = fdtdec_get_int(blob, dev->of_offset, "usb,interface-class", -1); + val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,interface-class", + -1); if (val != -1) { plat->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS; plat->id.bInterfaceClass = val; diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c index 82fcd84ef2f..b3f48b34e22 100644 --- a/drivers/usb/host/xhci-exynos5.c +++ b/drivers/usb/host/xhci-exynos5.c @@ -68,7 +68,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev) } depth = 0; - node = fdtdec_next_compatible_subnode(blob, dev->of_offset, + node = fdtdec_next_compatible_subnode(blob, dev_of_offset(dev), COMPAT_SAMSUNG_EXYNOS5_USB3_PHY, &depth); if (node <= 0) { debug("XHCI: Can't get device node for usb3-phy controller\n"); diff --git a/drivers/usb/host/xhci-rockchip.c b/drivers/usb/host/xhci-rockchip.c index 8cbcb8f923e..f559830185d 100644 --- a/drivers/usb/host/xhci-rockchip.c +++ b/drivers/usb/host/xhci-rockchip.c @@ -90,11 +90,11 @@ static void rockchip_dwc3_phy_setup(struct dwc3 *dwc3_reg, /* Set dwc3 usb2 phy config */ reg = readl(&dwc3_reg->g_usb2phycfg[0]); - if (fdtdec_get_bool(blob, dev->of_offset, + if (fdtdec_get_bool(blob, dev_of_offset(dev), "snps,dis-enblslpm-quirk")) reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; - utmi_bits = fdtdec_get_int(blob, dev->of_offset, + utmi_bits = fdtdec_get_int(blob, dev_of_offset(dev), "snps,phyif-utmi-bits", -1); if (utmi_bits == 16) { reg |= DWC3_GUSB2PHYCFG_PHYIF; @@ -106,11 +106,11 @@ static void rockchip_dwc3_phy_setup(struct dwc3 *dwc3_reg, reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT; } - if (fdtdec_get_bool(blob, dev->of_offset, + if (fdtdec_get_bool(blob, dev_of_offset(dev), "snps,dis-u2-freeclk-exists-quirk")) reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS; - if (fdtdec_get_bool(blob, dev->of_offset, + if (fdtdec_get_bool(blob, dev_of_offset(dev), "snps,dis-u2-susphy-quirk")) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; diff --git a/drivers/usb/musb-new/pic32.c b/drivers/usb/musb-new/pic32.c index c888c645fa0..ed6da19eecd 100644 --- a/drivers/usb/musb-new/pic32.c +++ b/drivers/usb/musb-new/pic32.c @@ -219,7 +219,7 @@ static int musb_usb_probe(struct udevice *dev) struct musb_host_data *mdata = &pdata->mdata; struct fdt_resource mc, glue; void *fdt = (void *)gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); void __iomem *mregs; int ret; diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 1c15aa2a427..852f07facc3 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -83,7 +83,7 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) { struct ti_musb_platdata *platdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int phys; int ctrl_mod; int usb_index; @@ -178,7 +178,7 @@ static int ti_musb_host_ofdata_to_platdata(struct udevice *dev) { struct ti_musb_platdata *platdata = dev_get_platdata(dev); const void *fdt = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; ret = ti_musb_ofdata_to_platdata(dev); @@ -209,7 +209,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent) int node; int ret; - for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0; + for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0; node = fdt_next_subnode(fdt, node)) { struct udevice *dev; const char *name = fdt_get_name(fdt, node, NULL); diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 39cd7caff16..ed2bd306c6b 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -276,7 +276,7 @@ static int atmel_fb_ofdata_to_platdata(struct udevice *dev) struct display_timing *timing = &priv->timing; const void *blob = gd->fdt_blob; - if (fdtdec_decode_display_timing(blob, dev->of_offset, + if (fdtdec_decode_display_timing(blob, dev_of_offset(dev), plat->timing_index, timing)) { debug("%s: Failed to decode display timing\n", __func__); return -EINVAL; diff --git a/drivers/video/bridge/ps862x.c b/drivers/video/bridge/ps862x.c index 80f63e3eb55..46aacca2b7d 100644 --- a/drivers/video/bridge/ps862x.c +++ b/drivers/video/bridge/ps862x.c @@ -86,7 +86,8 @@ static int ps8622_attach(struct udevice *dev) if (ret) return ret; - params = fdt_getprop(gd->fdt_blob, dev->of_offset, "parade,regs", &len); + params = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "parade,regs", + &len); if (!params || len % 3) { debug("%s: missing/invalid params=%p, len=%x\n", __func__, params, len); diff --git a/drivers/video/broadwell_igd.c b/drivers/video/broadwell_igd.c index beef770f920..4612d0414ef 100644 --- a/drivers/video/broadwell_igd.c +++ b/drivers/video/broadwell_igd.c @@ -705,7 +705,7 @@ static int broadwell_igd_ofdata_to_platdata(struct udevice *dev) { struct broadwell_igd_plat *plat = dev_get_platdata(dev); struct broadwell_igd_priv *priv = dev_get_priv(dev); - int node = dev->of_offset; + int node = dev_of_offset(dev); const void *blob = gd->fdt_blob; if (fdtdec_get_int_array(blob, node, "intel,dp-hotplug", diff --git a/drivers/video/exynos/exynos_dp.c b/drivers/video/exynos/exynos_dp.c index fc39f2c5620..c5039e7b430 100644 --- a/drivers/video/exynos/exynos_dp.c +++ b/drivers/video/exynos/exynos_dp.c @@ -880,7 +880,7 @@ static int exynos_dp_ofdata_to_platdata(struct udevice *dev) { struct exynos_dp_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; - unsigned int node = dev->of_offset; + unsigned int node = dev_of_offset(dev); fdt_addr_t addr; addr = dev_get_addr(dev); diff --git a/drivers/video/exynos/exynos_fb.c b/drivers/video/exynos/exynos_fb.c index 5483d6613f7..46320e7f02a 100644 --- a/drivers/video/exynos/exynos_fb.c +++ b/drivers/video/exynos/exynos_fb.c @@ -383,7 +383,7 @@ void exynos_fimd_lcd_init(struct udevice *dev) unsigned int offset; unsigned int node; - node = dev->of_offset; + node = dev_of_offset(dev); if (fdtdec_get_bool(gd->fdt_blob, node, "samsung,disable-sysmmu")) exynos_fimd_disable_sysmmu(); @@ -482,7 +482,7 @@ unsigned long exynos_fimd_calc_fbsize(struct exynos_fb_priv *priv) int exynos_fb_ofdata_to_platdata(struct udevice *dev) { struct exynos_fb_priv *priv = dev_get_priv(dev); - unsigned int node = dev->of_offset; + unsigned int node = dev_of_offset(dev); const void *blob = gd->fdt_blob; fdt_addr_t addr; diff --git a/drivers/video/ivybridge_igd.c b/drivers/video/ivybridge_igd.c index f16d725f3c7..d8af2e16963 100644 --- a/drivers/video/ivybridge_igd.c +++ b/drivers/video/ivybridge_igd.c @@ -517,7 +517,7 @@ static int gma_pm_init_pre_vbios(void *gtt_bar, int rev) static int gma_pm_init_post_vbios(struct udevice *dev, int rev, void *gtt_bar) { const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); u32 reg32, cycle_delay; debug("GT Power Management Init (post VBIOS)\n"); diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c index de6277f4ffe..3697f4905c9 100644 --- a/drivers/video/pwm_backlight.c +++ b/drivers/video/pwm_backlight.c @@ -61,7 +61,7 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev) struct pwm_backlight_priv *priv = dev_get_priv(dev); struct fdtdec_phandle_args args; const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int index, ret, count, len; const u32 *cell; diff --git a/drivers/video/rockchip/rk_lvds.c b/drivers/video/rockchip/rk_lvds.c index fcbb4d63d25..ee43255753c 100644 --- a/drivers/video/rockchip/rk_lvds.c +++ b/drivers/video/rockchip/rk_lvds.c @@ -162,7 +162,7 @@ int rk_lvds_enable(struct udevice *dev, int panel_bpp, int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing) { if (fdtdec_decode_display_timing - (gd->fdt_blob, dev->of_offset, 0, timing)) { + (gd->fdt_blob, dev_of_offset(dev), 0, timing)) { debug("%s: Failed to decode display timing\n", __func__); return -EINVAL; } @@ -174,7 +174,7 @@ static int rk_lvds_ofdata_to_platdata(struct udevice *dev) { struct rk_lvds_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int ret; priv->regs = (void *)dev_get_addr(dev); priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c index eab548699f7..aeecb5815be 100644 --- a/drivers/video/rockchip/rk_vop.c +++ b/drivers/video/rockchip/rk_vop.c @@ -321,7 +321,7 @@ static int rk_vop_probe(struct udevice *dev) * clock so it is currently not possible to use more than one display * device simultaneously. */ - port = fdt_subnode_offset(blob, dev->of_offset, "port"); + port = fdt_subnode_offset(blob, dev_of_offset(dev), "port"); if (port < 0) return -EINVAL; for (node = fdt_first_subnode(blob, port); diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index dc5a220d512..18afe2f3fd3 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -46,7 +46,7 @@ static int sandbox_sdl_bind(struct udevice *dev) struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); struct sandbox_sdl_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 = 0; plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH); diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c index 92214d61b27..0ba3f2c2b4b 100644 --- a/drivers/video/tegra.c +++ b/drivers/video/tegra.c @@ -338,7 +338,7 @@ static int tegra_lcd_ofdata_to_platdata(struct udevice *dev) struct tegra_lcd_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; struct display_timing *timing; - int node = dev->of_offset; + int node = dev_of_offset(dev); int panel_node; int rgb; int ret; @@ -392,7 +392,7 @@ static int tegra_lcd_bind(struct udevice *dev) { struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); const void *blob = gd->fdt_blob; - int node = dev->of_offset; + int node = dev_of_offset(dev); int rgb; rgb = fdt_subnode_offset(blob, node, "rgb"); diff --git a/drivers/video/tegra124/display.c b/drivers/video/tegra124/display.c index 28db96c9529..bbbca13bdc4 100644 --- a/drivers/video/tegra124/display.c +++ b/drivers/video/tegra124/display.c @@ -363,9 +363,9 @@ static int display_init(struct udevice *dev, void *lcdbase, return ret; } - dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, dev->of_offset, + dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, dev_of_offset(dev), "reg"); - if (fdtdec_decode_display_timing(blob, dev->of_offset, 0, timing)) { + if (fdtdec_decode_display_timing(blob, dev_of_offset(dev), 0, timing)) { debug("%s: Failed to decode display timing\n", __func__); return -EINVAL; } diff --git a/drivers/video/tegra124/sor.c b/drivers/video/tegra124/sor.c index e5cea51d48c..5e4140ff532 100644 --- a/drivers/video/tegra124/sor.c +++ b/drivers/video/tegra124/sor.c @@ -757,7 +757,7 @@ int tegra_dc_sor_attach(struct udevice *dc_dev, struct udevice *dev, /* Use the first display controller */ debug("%s\n", __func__); - node = dc_dev->of_offset; + node = dev_of_offset(dc_dev); disp_ctrl = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg"); tegra_dc_sor_enable_dc(disp_ctrl); @@ -973,7 +973,7 @@ int tegra_dc_sor_detach(struct udevice *dc_dev, struct udevice *dev) debug("%s\n", __func__); /* Use the first display controller */ - node = dc_dev->of_offset; + node = dev_of_offset(dc_dev); disp_ctrl = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg"); /* Sleep mode */ @@ -1045,7 +1045,7 @@ static int tegra_sor_ofdata_to_platdata(struct udevice *dev) int node; int ret; - priv->base = (void *)fdtdec_get_addr(blob, dev->of_offset, "reg"); + priv->base = (void *)fdtdec_get_addr(blob, dev_of_offset(dev), "reg"); node = fdtdec_next_compatible(blob, 0, COMPAT_NVIDIA_TEGRA124_PMC); if (node < 0) { diff --git a/include/dm/device.h b/include/dm/device.h index 9948bd49fa5..4e95fb7773d 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -121,6 +121,16 @@ struct udevice { /* Returns non-zero if the device is active (probed and not removed) */ #define device_active(dev) ((dev)->flags & DM_FLAG_ACTIVATED) +static inline int dev_of_offset(const struct udevice *dev) +{ + return dev->of_offset; +} + +static inline void dev_set_of_offset(struct udevice *dev, int of_offset) +{ + dev->of_offset = of_offset; +} + /** * struct udevice_id - Lists the compatible strings supported by a driver * @compatible: Compatible string diff --git a/test/dm/spi.c b/test/dm/spi.c index 5733096066c..f52cb733c77 100644 --- a/test/dm/spi.c +++ b/test/dm/spi.c @@ -35,7 +35,7 @@ static int dm_test_spi_find(struct unit_test_state *uts) */ ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus)); ut_assertok(spi_cs_info(bus, cs, &info)); - of_offset = info.dev->of_offset; + of_offset = dev_of_offset(info.dev); device_remove(info.dev); device_unbind(info.dev); diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 49a36cb1932..3048a7b890c 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -37,9 +37,9 @@ static int testfdt_ofdata_to_platdata(struct udevice *dev) { struct dm_test_pdata *pdata = dev_get_platdata(dev); - pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "ping-add", -1); - pdata->base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, + pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "ping-expect"); return 0; @@ -121,10 +121,10 @@ int dm_check_devices(struct unit_test_state *uts, int num_devices) * want to test the code that sets that up * (testfdt_drv_probe()). */ - base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, + base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "ping-expect"); debug("dev=%d, base=%d: %s\n", i, base, - fdt_get_name(gd->fdt_blob, dev->of_offset, NULL)); + fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL)); ut_assert(!dm_check_operations(uts, dev, base, dev_get_priv(dev))); diff --git a/tools/buildman/README b/tools/buildman/README index ccea13fd2db..f66527665ad 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -141,7 +141,7 @@ means to build all arm boards except nvidia, freescale and anything ending with 'ball'. It is convenient to use the -n option to see what will be built based on -the subset given. +the subset given. Use -v as well to get an actual list of boards. Buildman does not store intermediate object files. It optionally copies the binary output into a directory when a build is successful. Size diff --git a/tools/buildman/board.py b/tools/buildman/board.py index ae0e0b8e171..f842d3a1fa1 100644 --- a/tools/buildman/board.py +++ b/tools/buildman/board.py @@ -249,15 +249,15 @@ class Boards: exclude: List of boards to exclude, regardless of 'args' Returns: - Dictionary which holds the number of boards which were selected + Dictionary which holds the list of boards which were selected due to each argument, arranged by argument. """ result = {} terms = self._BuildTerms(args) - result['all'] = 0 + result['all'] = [] for term in terms: - result[str(term)] = 0 + result[str(term)] = [] exclude_list = [] for expr in exclude: @@ -285,7 +285,7 @@ class Boards: if build_it: board.build_it = True if matching_term: - result[matching_term] += 1 - result['all'] += 1 + result[matching_term].append(board.target) + result['all'].append(board.target) return result diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 545c2cb44a1..73b1a14fb6b 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -48,9 +48,9 @@ def ShowActions(series, why_selected, boards_selected, builder, options): Args: series: Series object why_selected: Dictionary where each key is a buildman argument - provided by the user, and the value is the boards brought - in by that argument. For example, 'arm' might bring in - 400 boards, so in this case the key would be 'arm' and + provided by the user, and the value is the list of boards + brought in by that argument. For example, 'arm' might bring + in 400 boards, so in this case the key would be 'arm' and the value would be a list of board names. boards_selected: Dict of selected boards, key is target name, value is Board object @@ -75,9 +75,11 @@ def ShowActions(series, why_selected, boards_selected, builder, options): print for arg in why_selected: if arg != 'all': - print arg, ': %d boards' % why_selected[arg] + print arg, ': %d boards' % len(why_selected[arg]) + if options.verbose: + print ' %s' % ' '.join(why_selected[arg]) print ('Total boards to build for each commit: %d\n' % - why_selected['all']) + len(why_selected['all'])) def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, clean_dir=False): @@ -221,9 +223,10 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, options.git_dir, count, series=None, allow_overwrite=True) else: series = None - options.verbose = True - if not options.summary: - options.show_errors = True + if not options.dry_run: + options.verbose = True + if not options.summary: + options.show_errors = True # By default we have one thread per CPU. But if there are not enough jobs # we can have fewer threads and use a high '-j' value for make. diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py index 11050b66f71..6df7b0da13a 100755 --- a/tools/dtoc/dtoc.py +++ b/tools/dtoc/dtoc.py @@ -54,6 +54,7 @@ def Conv_name_to_c(name): str = name.replace('@', '_at_') str = str.replace('-', '_') str = str.replace(',', '_') + str = str.replace('.', '_') str = str.replace('/', '__') return str diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index be78fc510b8..2915d97950d 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -138,7 +138,7 @@ def GetWarningMsg(col, msg_type, fname, line, msg): msg_type = col.Color(col.RED, msg_type) elif msg_type == 'check': msg_type = col.Color(col.MAGENTA, msg_type) - return '%s: %s,%d: %s' % (msg_type, fname, line, msg) + return '%s:%d: %s: %s\n' % (fname, line, msg_type, msg) def CheckPatches(verbose, args): '''Run the checkpatch.pl script on each patch''' @@ -157,7 +157,8 @@ def CheckPatches(verbose, args): result.checks): print("Internal error: some problems lost") for item in result.problems: - print(GetWarningMsg(col, item.get('type', '<unknown>'), + sys.stderr.write( + GetWarningMsg(col, item.get('type', '<unknown>'), item.get('file', '<unknown>'), item.get('line', 0), item.get('msg', 'message'))) print diff --git a/tools/patman/series.py b/tools/patman/series.py index 38a452edad4..c1b86521aa4 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -235,7 +235,8 @@ class Series(dict): if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) - print(cover_fname, ', '.join(set(cover_cc + all_ccs)), file=fd) + cc_list = ', '.join([x.decode('utf-8') for x in set(cover_cc + all_ccs)]) + print(cover_fname, cc_list.encode('utf-8'), file=fd) fd.close() return fname |