dm: core: Replace of_offset with accessor

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

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2017-01-17 16:52:55 -07:00
parent 8aa41363eb
commit e160f7d430
220 changed files with 445 additions and 407 deletions

View File

@ -392,7 +392,7 @@ static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev)
priv->regs = regmap_get_range(map, 0); priv->regs = regmap_get_range(map, 0);
priv->phy = regmap_get_range(map, 1); 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); "clock-frequency", 0);
if (!priv->clock_rate) { if (!priv->clock_rate) {

View File

@ -1016,7 +1016,7 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev)
#if !CONFIG_IS_ENABLED(OF_PLATDATA) #if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct rk3288_sdram_params *params = dev_get_platdata(dev); struct rk3288_sdram_params *params = dev_get_platdata(dev);
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
int ret; int ret;
/* Rk3288 supports dual-channel, set default channel num to 2 */ /* Rk3288 supports dual-channel, set default channel num to 2 */

View File

@ -103,7 +103,7 @@ static int altera_nios2_get_count(struct udevice *dev)
static int altera_nios2_probe(struct udevice *dev) static int altera_nios2_probe(struct udevice *dev)
{ {
const void *blob = gd->fdt_blob; 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, gd->cpu_clk = fdtdec_get_int(blob, node,
"clock-frequency", 0); "clock-frequency", 0);

View File

@ -256,8 +256,8 @@ static void initialize_vr_config(struct udevice *dev)
/* Set the slow ramp rate */ /* Set the slow ramp rate */
msr.hi &= ~(0x3 << (53 - 32)); msr.hi &= ~(0x3 << (53 - 32));
/* Configure the C-state exit ramp rate */ /* Configure the C-state exit ramp rate */
ramp = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,slow-ramp", ramp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-1); "intel,slow-ramp", -1);
if (ramp != -1) { if (ramp != -1) {
/* Configured slow ramp rate */ /* Configured slow ramp rate */
msr.hi |= ((ramp & 0x3) << (53 - 32)); 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 */ /* Set MIN_VID (31:24) to allow CPU to have full control */
msr.lo &= ~0xff000000; msr.lo &= ~0xff000000;
min_vid = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,min-vid", min_vid = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
0); "intel,min-vid", 0);
msr.lo |= (min_vid & 0xff) << 24; msr.lo |= (min_vid & 0xff) << 24;
msr_write(MSR_VR_MISC_CONFIG, msr); msr_write(MSR_VR_MISC_CONFIG, msr);
@ -562,7 +562,7 @@ static void configure_thermal_target(struct udevice *dev)
int tcc_offset; int tcc_offset;
msr_t msr; 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); "intel,tcc-offset", 0);
/* Set TCC activaiton offset if supported */ /* Set TCC activaiton offset if supported */

View File

@ -190,14 +190,14 @@ static int pch_power_options(struct udevice *dev)
debug("Set power %s after power failure.\n", state); debug("Set power %s after power failure.\n", state);
/* GPE setup based on device tree configuration */ /* 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)); "intel,gpe0-en", enable, ARRAY_SIZE(enable));
if (ret) if (ret)
return -EINVAL; return -EINVAL;
enable_all_gpe(enable[0], enable[1], enable[2], enable[3]); enable_all_gpe(enable[0], enable[1], enable[2], enable[3]);
/* SMI setup based on device tree configuration */ /* 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)); "intel,alt-gp-smi-enable", 0));
return 0; return 0;

View File

@ -51,7 +51,7 @@ static int broadwell_pinctrl_read_configs(struct udevice *dev,
int node; int node;
debug("%s: starting\n", __func__); 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 > 0;
node = fdt_next_subnode(blob, node)) { node = fdt_next_subnode(blob, node)) {
int phandle = fdt_get_phandle(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 count = 0;
int node; int node;
for (node = fdt_first_subnode(blob, dev->of_offset); for (node = fdt_first_subnode(blob, dev_of_offset(dev));
node > 0; node > 0;
node = fdt_next_subnode(blob, node)) { node = fdt_next_subnode(blob, node)) {
int len, i; int len, i;

View File

@ -235,7 +235,7 @@ static int broadwell_sata_ofdata_to_platdata(struct udevice *dev)
{ {
struct sata_platdata *plat = dev_get_platdata(dev); struct sata_platdata *plat = dev_get_platdata(dev);
const void *blob = gd->fdt_blob; 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->port_map = fdtdec_get_int(blob, node, "intel,sata-port-map", 0);
plat->port0_gen3_tx = fdtdec_get_int(blob, node, plat->port0_gen3_tx = fdtdec_get_int(blob, node,

View File

@ -17,7 +17,7 @@ int cpu_x86_bind(struct udevice *dev)
struct cpu_platdata *plat = dev_get_parent_platdata(dev); struct cpu_platdata *plat = dev_get_parent_platdata(dev);
struct cpuid_result res; 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); "intel,apic-id", -1);
plat->family = gd->arch.x86; plat->family = gd->arch.x86;
res = cpuid(1); res = cpuid(1);

View File

@ -50,7 +50,7 @@ int lpc_common_early_init(struct udevice *dev)
int count; int count;
int i; 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, "intel,gen-dec", (u32 *)values,
sizeof(values) / sizeof(u32)); sizeof(values) / sizeof(u32));
if (count < 0) if (count < 0)

View File

@ -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); spd_index = dm_gpio_get_values_as_int(desc, ret);
debug("spd index %d\n", spd_index); 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) if (node < 0)
return -EINVAL; return -EINVAL;
for (spd_node = fdt_first_subnode(blob, node); for (spd_node = fdt_first_subnode(blob, node);

View File

@ -96,7 +96,7 @@ static int create_pirq_routing_table(struct udevice *dev)
int i; int i;
int ret; int ret;
node = dev->of_offset; node = dev_of_offset(dev);
/* extract the bdf from fdt_pci_addr */ /* extract the bdf from fdt_pci_addr */
priv->bdf = dm_pci_get_bdf(dev->parent); priv->bdf = dm_pci_get_bdf(dev->parent);

View File

@ -86,7 +86,7 @@ static int pch_pirq_init(struct udevice *pch)
{ {
uint8_t route[8], *ptr; 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))) "intel,pirq-routing", route, sizeof(route)))
return -EINVAL; return -EINVAL;
ptr = route; ptr = route;
@ -113,7 +113,7 @@ static int pch_gpi_routing(struct udevice *pch)
u32 reg; u32 reg;
int gpi; 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))) "intel,gpi-routing", route, sizeof(route)))
return -EINVAL; return -EINVAL;
@ -128,7 +128,7 @@ static int pch_gpi_routing(struct udevice *pch)
static int pch_power_options(struct udevice *pch) static int pch_power_options(struct udevice *pch)
{ {
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = pch->of_offset; int node = dev_of_offset(pch);
u8 reg8; u8 reg8;
u16 reg16, pmbase; u16 reg16, pmbase;
u32 reg32; u32 reg32;

View File

@ -288,8 +288,8 @@ static int configure_thermal_target(struct udevice *dev)
int tcc_offset; int tcc_offset;
msr_t msr; msr_t msr;
tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "tcc-offset", tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
0); "tcc-offset", 0);
/* Set TCC activaiton offset if supported */ /* Set TCC activaiton offset if supported */
msr = msr_read(MSR_PLATFORM_INFO); msr = msr_read(MSR_PLATFORM_INFO);

View File

@ -39,7 +39,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
{ {
unsigned int port_map, speed_support, port_tx; unsigned int port_map, speed_support, port_tx;
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
const char *mode; const char *mode;
u32 reg32; u32 reg32;
u16 reg16; 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) static void bd82x6x_sata_enable(struct udevice *dev)
{ {
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
unsigned port_map; unsigned port_map;
const char *mode; const char *mode;
u16 map = 0; u16 map = 0;

View File

@ -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 * 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. * 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->ucode_version = microcode_read_rev();
plat->device_id = gd->arch.x86_device; plat->device_id = gd->arch.x86_device;

View File

@ -304,7 +304,8 @@ static int mptable_add_intsrc(struct mp_config_table *mc,
} }
/* Get I/O interrupt information from device tree */ /* 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) if (!cell)
return -ENOENT; return -ENOENT;

View File

@ -187,7 +187,7 @@ static int ich6_pinctrl_probe(struct udevice *dev)
return -EINVAL; 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 > 0;
pin_node = fdt_next_subnode(gd->fdt_blob, pin_node)) { pin_node = fdt_next_subnode(gd->fdt_blob, pin_node)) {
/* Configure the pin */ /* Configure the pin */

View File

@ -44,7 +44,8 @@ int board_prepare_usb(enum usb_init_type type)
/* Try to request gpios needed to start usb host on dragonboard */ /* Try to request gpios needed to start usb host on dragonboard */
if (!dm_gpio_is_valid(&hub_reset)) { 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"); "usb_hub_reset_pm");
if (node < 0) { if (node < 0) {
printf("Failed to find usb_hub_reset_pm dt node.\n"); 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)) { 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"); "usb_sw_sel_pm");
if (node < 0) { if (node < 0) {
printf("Failed to find usb_sw_sel_pm dt node.\n"); printf("Failed to find usb_sw_sel_pm dt node.\n");
@ -110,7 +112,8 @@ int misc_init_r(void)
return 0; 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) { if (node < 0) {
printf("Failed to find key_vol_down node. Check device tree\n"); printf("Failed to find key_vol_down node. Check device tree\n");
return 0; return 0;

View File

@ -684,7 +684,7 @@ steps (see device_probe()):
g. If the driver provides an ofdata_to_platdata() method, then this is 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 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. 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 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, using a device tree node or U_BOOT_DEVICE() structure. In either case,

View File

@ -205,7 +205,7 @@ For example:
/* Decode the device tree data */ /* Decode the device tree data */
struct mmc_platdata *plat = dev_get_platdata(dev); struct mmc_platdata *plat = dev_get_platdata(dev);
const void *blob = gd->fdt_blob; 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); plat->fifo_depth = fdtdec_get_int(blob, node, "fifo-depth", 0);
#endif #endif

View File

@ -223,7 +223,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
{ {
struct exynos_spi_platdata *plat = bus->platdata; struct exynos_spi_platdata *plat = bus->platdata;
const void *blob = gd->fdt_blob; 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->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg");
plat->periph_id = pinmux_decode_periph_id(blob, node); plat->periph_id = pinmux_decode_periph_id(blob, node);

View File

@ -345,7 +345,7 @@ nodev:
static int adc_vdd_platdata_set(struct udevice *dev) static int adc_vdd_platdata_set(struct udevice *dev)
{ {
struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(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; const void *fdt = gd->fdt_blob;
char *prop; char *prop;
@ -366,7 +366,7 @@ static int adc_vdd_platdata_set(struct udevice *dev)
static int adc_vss_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); 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; const void *fdt = gd->fdt_blob;
char *prop; char *prop;

View File

@ -154,9 +154,8 @@ static int generic_clk_ofdata_to_platdata(struct udevice *dev)
u32 num_parents; u32 num_parents;
num_parents = fdtdec_get_int_array_count(gd->fdt_blob, num_parents = fdtdec_get_int_array_count(gd->fdt_blob,
dev_get_parent(dev)->of_offset, dev_of_offset(dev_get_parent(dev)), "clocks", cells,
"clocks", cells, GENERATED_SOURCE_MAX);
GENERATED_SOURCE_MAX);
if (!num_parents) if (!num_parents)
return -1; return -1;

View File

@ -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) int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)
{ {
const void *fdt = gd->fdt_blob; 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); bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
const char *name; const char *name;
int ret; int ret;
@ -90,7 +90,8 @@ int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args)
return -EINVAL; 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) if (periph < 0)
return -EINVAL; return -EINVAL;

View File

@ -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); debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
assert(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, "clocks", "#clock-cells", 0, index,
&args); &args);
if (ret) { 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); 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); "clock-names", name);
if (index < 0) { if (index < 0) {
debug("fdt_stringlist_search() failed: %d\n", index); debug("fdt_stringlist_search() failed: %d\n", index);

View File

@ -32,7 +32,7 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
{ {
#if !CONFIG_IS_ENABLED(OF_PLATDATA) #if !CONFIG_IS_ENABLED(OF_PLATDATA)
to_clk_fixed_rate(dev)->fixed_rate = 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); "clock-frequency", 0);
#endif #endif

View File

@ -330,7 +330,7 @@ static void pic32_clk_init(struct udevice *dev)
for (i = REF1CLK; i <= REF5CLK; i++) { for (i = REF1CLK; i <= REF5CLK; i++) {
snprintf(propname, sizeof(propname), snprintf(propname, sizeof(propname),
"microchip,refo%d-frequency", i - REF1CLK + 1); "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) if (rate)
pic32_set_refclk(priv, i, pll_hz, rate, ROCLK_SRC_SPLL); 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_addr_t addr;
fdt_size_t size; 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) if (addr == FDT_ADDR_T_NONE)
return -EINVAL; return -EINVAL;

View File

@ -355,7 +355,7 @@ int device_probe(struct udevice *dev)
goto fail; 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); ret = drv->ofdata_to_platdata(dev);
if (ret) if (ret)
goto fail; goto fail;
@ -524,7 +524,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
*devp = NULL; *devp = NULL;
list_for_each_entry(dev, &parent->child_head, sibling_node) { 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; *devp = dev;
return 0; return 0;
} }
@ -549,7 +549,7 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
{ {
struct udevice *dev, *found; struct udevice *dev, *found;
if (parent->of_offset == of_offset) if (dev_of_offset(parent) == of_offset)
return parent; return parent;
list_for_each_entry(dev, &parent->child_head, sibling_node) { 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 len = 0;
int na, ns; 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) { if (na < 1) {
debug("bad #address-cells\n"); debug("bad #address-cells\n");
return FDT_ADDR_T_NONE; 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) { if (ns < 0) {
debug("bad #size-cells\n"); debug("bad #size-cells\n");
return FDT_ADDR_T_NONE; 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)))) { if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
debug("Req index out of range\n"); debug("Req index out of range\n");
return FDT_ADDR_T_NONE; return FDT_ADDR_T_NONE;
@ -662,16 +664,15 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
* bus setups. * bus setups.
*/ */
addr = fdt_translate_address((void *)gd->fdt_blob, addr = fdt_translate_address((void *)gd->fdt_blob,
dev->of_offset, reg); dev_of_offset(dev), reg);
} else { } else {
/* /*
* Use the "simple" translate function for less complex * Use the "simple" translate function for less complex
* bus setups. * bus setups.
*/ */
addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
dev->parent->of_offset, dev_of_offset(dev->parent), dev_of_offset(dev),
dev->of_offset, "reg", "reg", index, NULL, false);
index, NULL, false);
if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) { if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
if (device_get_uclass_id(dev->parent) == if (device_get_uclass_id(dev->parent) ==
UCLASS_SIMPLE_BUS) 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 * next call to the exisiting dev_get_xxx function which handles
* all config options. * 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); "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) #if CONFIG_IS_ENABLED(OF_CONTROL)
int index; 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); "reg-names", name);
if (index < 0) if (index < 0)
return index; return index;
@ -799,7 +800,7 @@ bool of_device_is_compatible(struct udevice *dev, const char *compat)
{ {
const void *fdt = gd->fdt_blob; 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) bool of_machine_is_compatible(const char *compat)

View File

@ -71,12 +71,12 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
int parent; int parent;
int len; int len;
parent = dev->parent->of_offset; parent = dev_of_offset(dev->parent);
addr_len = fdt_address_cells(blob, parent); addr_len = fdt_address_cells(blob, parent);
size_len = fdt_size_cells(blob, parent); size_len = fdt_size_cells(blob, parent);
both_len = addr_len + size_len; 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); len /= sizeof(*cell);
count = len / both_len; count = len / both_len;
if (!cell || !count) if (!cell || !count)

View File

@ -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) int dm_scan_fdt_dev(struct udevice *dev)
{ {
if (dev->of_offset == -1) if (dev_of_offset(dev) == -1)
return 0; 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); gd->flags & GD_FLG_RELOC ? false : true);
} }

View File

@ -30,7 +30,7 @@ static int simple_bus_post_bind(struct udevice *dev)
u32 cell[3]; u32 cell[3];
int ret; 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)); cell, ARRAY_SIZE(cell));
if (!ret) { if (!ret) {
struct simple_bus_plat *plat = dev_get_uclass_platdata(dev); struct simple_bus_plat *plat = dev_get_uclass_platdata(dev);

View File

@ -278,7 +278,7 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node,
return ret; return ret;
list_for_each_entry(dev, &uc->dev_head, uclass_node) { list_for_each_entry(dev, &uc->dev_head, uclass_node) {
if (dev->of_offset == node) { if (dev_of_offset(dev) == node) {
*devp = dev; *devp = dev;
return 0; return 0;
} }
@ -299,7 +299,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
int ret; int ret;
*devp = NULL; *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); -1);
if (find_phandle <= 0) if (find_phandle <= 0)
return -ENOENT; return -ENOENT;
@ -308,7 +308,9 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
return ret; return ret;
list_for_each_entry(dev, &uc->dev_head, uclass_node) { 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) { if (phandle == find_phandle) {
*devp = dev; *devp = dev;

View File

@ -151,7 +151,7 @@ static int shape_ofdata_to_platdata(struct udevice *dev)
return ret; return ret;
/* Parse the data that only we need */ /* 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", '@'); "character", '@');
return 0; return 0;

View File

@ -66,7 +66,7 @@ int demo_set_light(struct udevice *dev, int light)
int demo_parse_dt(struct udevice *dev) int demo_parse_dt(struct udevice *dev)
{ {
struct dm_demo_pdata *pdata = dev_get_platdata(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->sides = fdtdec_get_int(gd->fdt_blob, dn, "sides", 0);
pdata->colour = fdt_getprop(gd->fdt_blob, dn, "colour", NULL); pdata->colour = fdt_getprop(gd->fdt_blob, dn, "colour", NULL);

View File

@ -130,7 +130,7 @@ static int gen_74x164_probe(struct udevice *dev)
char *str, name[32]; char *str, name[32];
int ret; int ret;
const void *fdt = gd->fdt_blob; const void *fdt = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
snprintf(name, sizeof(name), "%s_", dev->name); snprintf(name, sizeof(name), "%s_", dev->name);
str = strdup(name); str = strdup(name);

View File

@ -92,9 +92,9 @@ static int altera_pio_ofdata_to_platdata(struct udevice *dev)
plat->regs = map_physmem(dev_get_addr(dev), plat->regs = map_physmem(dev_get_addr(dev),
sizeof(struct altera_pio_regs), sizeof(struct altera_pio_regs),
MAP_NOCACHE); 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); "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); "gpio-bank-name", NULL);
return 0; return 0;

View File

@ -276,7 +276,7 @@ static const struct dm_gpio_ops atmel_pio4_ops = {
static int atmel_pio4_bind(struct udevice *dev) 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) 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); pioctrl_data = (struct atmel_pioctrl_data *)dev_get_driver_data(dev);
nbanks = pioctrl_data->nbanks; 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; uc_priv->gpio_count = nbanks * ATMEL_PIO_NPINS_PER_BANK;
return 0; return 0;

View File

@ -112,13 +112,13 @@ static int gpio_dwapb_bind(struct udevice *dev)
if (plat) if (plat)
return 0; 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) { if (base == FDT_ADDR_T_NONE) {
debug("Can't get the GPIO register base address\n"); debug("Can't get the GPIO register base address\n");
return -ENXIO; return -ENXIO;
} }
for (node = fdt_first_subnode(blob, dev->of_offset); for (node = fdt_first_subnode(blob, dev_of_offset(dev));
node > 0; node > 0;
node = fdt_next_subnode(blob, node)) { node = fdt_next_subnode(blob, node)) {
if (!fdtdec_get_bool(blob, node, "gpio-controller")) if (!fdtdec_get_bool(blob, node, "gpio-controller"))
@ -142,7 +142,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
if (ret) if (ret)
goto err; goto err;
subdev->of_offset = node; dev_set_of_offset(subdev, node);
bank++; bank++;
} }

View File

@ -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 * calls in gpio_request_by_name(), but we can do this until
* gpio_request_by_name_nodev() can be dropped. * 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); 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 * calls in gpio_request_by_name(), but we can do this until
* gpio_request_list_by_name_nodev() can be dropped. * 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, list_name, desc, max_count,
flags); flags);
} }
@ -755,7 +755,7 @@ int gpio_get_list_count(struct udevice *dev, const char *list_name)
{ {
int ret; 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, list_name, "#gpio-cells", 0, -1,
NULL); NULL);
if (ret) { if (ret) {

View File

@ -149,14 +149,14 @@ static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev)
if (ret) if (ret)
return 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) { if (bank == -1) {
debug("%s: Invalid bank number %d\n", __func__, bank); debug("%s: Invalid bank number %d\n", __func__, bank);
return -EINVAL; return -EINVAL;
} }
plat->bank = bank; plat->bank = bank;
plat->base_addr = gpiobase; 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); "bank-name", NULL);
return 0; return 0;

View File

@ -94,14 +94,14 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)
if (ret) if (ret)
return 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) { if (offset == -1) {
debug("%s: Invalid register offset %d\n", __func__, offset); debug("%s: Invalid register offset %d\n", __func__, offset);
return -EINVAL; return -EINVAL;
} }
plat->offset = offset; plat->offset = offset;
plat->base_addr = gpiobase + 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); "bank-name", NULL);
return 0; return 0;

View File

@ -297,7 +297,7 @@ static int lpc32xx_gpio_probe(struct udevice *dev)
struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev); struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev);
struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_dev_priv *uc_priv = dev->uclass_priv;
if (dev->of_offset == -1) { if (dev_of_offset(dev) == -1) {
/* Tell the uclass how many GPIOs we have */ /* Tell the uclass how many GPIOs we have */
uc_priv->gpio_count = LPC32XX_GPIOS; uc_priv->gpio_count = LPC32XX_GPIOS;
} }

View File

@ -169,13 +169,13 @@ static int mpc85xx_gpio_ofdata_to_platdata(struct udevice *dev) {
fdt_addr_t addr; fdt_addr_t addr;
fdt_size_t size; fdt_size_t size;
addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset, addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob,
"reg", 0, &size, false); dev_of_offset(dev), "reg", 0, &size, false);
plat->addr = addr; plat->addr = addr;
plat->size = size; plat->size = size;
plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev->of_offset, plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"ngpios", 32); "ngpios", 32);
return 0; return 0;
} }

View File

@ -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); 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); "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); "gpio-bank-name", NULL);
if (uc_priv->bank_name == NULL) if (uc_priv->bank_name == NULL)
uc_priv->bank_name = "soc"; uc_priv->bank_name = "soc";

View File

@ -320,7 +320,7 @@ static int omap_gpio_bind(struct udevice *dev)
return -ENOMEM; return -ENOMEM;
plat->base = base_addr; 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; dev->platdata = plat;
return 0; return 0;

View File

@ -265,7 +265,7 @@ static int pca953x_probe(struct udevice *dev)
return -ENODEV; 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) if (addr == 0)
return -ENODEV; return -ENODEV;

View File

@ -131,15 +131,15 @@ static int pcf8575_ofdata_platdata(struct udevice *dev)
int n_latch; 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); "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); "gpio-bank-name", NULL);
if (!uc_priv->bank_name) if (!uc_priv->bank_name)
uc_priv->bank_name = fdt_get_name(gd->fdt_blob, 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); "lines-initial-states", 0);
plat->out = ~n_latch; plat->out = ~n_latch;

View File

@ -133,7 +133,8 @@ static int pic32_gpio_probe(struct udevice *dev)
char *end; char *end;
int bank; 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) if (addr == FDT_ADDR_T_NONE)
return -EINVAL; return -EINVAL;

View File

@ -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); 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); "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); "gpio-bank-name", NULL);
if (uc_priv->bank_name == NULL) if (uc_priv->bank_name == NULL)
uc_priv->bank_name = "pm8916"; uc_priv->bank_name = "pm8916";

View File

@ -317,7 +317,7 @@ static int gpio_exynos_bind(struct udevice *parent)
return 0; return 0;
base = (struct s5p_gpio_bank *)dev_get_addr(parent); 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 > 0;
node = fdt_next_subnode(blob, node), bank++) { node = fdt_next_subnode(blob, node), bank++) {
struct exynos_gpio_platdata *plat; struct exynos_gpio_platdata *plat;
@ -337,7 +337,7 @@ static int gpio_exynos_bind(struct udevice *parent)
if (ret) if (ret)
return ret; return ret;
dev->of_offset = node; dev_set_of_offset(dev, node);
reg = dev_get_addr(dev); reg = dev_get_addr(dev);
if (reg != FDT_ADDR_T_NONE) if (reg != FDT_ADDR_T_NONE)

View File

@ -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); 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); "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); "gpio-bank-name", NULL);
return 0; 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); 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 */ /* Tell the uclass how many GPIOs we have */
uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT; uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
} }

View File

@ -312,7 +312,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
plat->bank_name, plat, -1, &dev); plat->bank_name, plat, -1, &dev);
if (ret) if (ret)
return ret; return ret;
dev->of_offset = parent->of_offset; dev_set_of_offset(dev, dev_of_offset(parent));
} }
return 0; return 0;

View File

@ -197,7 +197,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
-1, &dev); -1, &dev);
if (ret) if (ret)
return ret; return ret;
dev->of_offset = parent->of_offset; dev_set_of_offset(dev, dev_of_offset(parent));
} }
return 0; return 0;

View File

@ -337,7 +337,8 @@ static int gpio_tegra_bind(struct udevice *parent)
* This driver does not make use of interrupts, other than to figure * This driver does not make use of interrupts, other than to figure
* out the number of GPIO banks * 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; return -EINVAL;
bank_count = len / 3 / sizeof(u32); bank_count = len / 3 / sizeof(u32);
ctlr = (struct gpio_ctlr *)dev_get_addr(parent); 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); plat->port_name, plat, -1, &dev);
if (ret) if (ret)
return ret; return ret;
dev->of_offset = parent->of_offset; dev_set_of_offset(dev, dev_of_offset(parent));
} }
} }

View File

@ -129,7 +129,7 @@ static int vybrid_gpio_bind(struct udevice *dev)
plat->base = base_addr; plat->base = base_addr;
plat->chip = dev->req_seq; 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; dev->platdata = plat;
return 0; return 0;

View File

@ -242,7 +242,7 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev)
{ {
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
struct at91_i2c_bus *bus = dev_get_priv(dev); 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->regs = (struct at91_i2c_regs *)dev_get_addr(dev);
bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev); bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev);

View File

@ -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); struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
const void *blob = gd->fdt_blob; 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", i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus",
0); 0);

View File

@ -522,7 +522,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
int node; int node;
node = dev->of_offset; node = dev_of_offset(dev);
i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev); i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev);

View File

@ -585,21 +585,21 @@ static int fsl_i2c_ofdata_to_platdata(struct udevice *bus)
struct fsl_i2c_dev *dev = dev_get_priv(bus); struct fsl_i2c_dev *dev = dev_get_priv(bus);
fdt_addr_t addr; fdt_addr_t addr;
fdt_size_t size; fdt_size_t size;
int node = dev_of_offset(bus);
addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, bus->of_offset, addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg", 0,
"reg", 0, &size, false); &size, false);
dev->base = map_sysmem(CONFIG_SYS_IMMR + addr, size); dev->base = map_sysmem(CONFIG_SYS_IMMR + addr, size);
if (!dev->base) if (!dev->base)
return -ENOMEM; return -ENOMEM;
dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset, dev->index = fdtdec_get_int(gd->fdt_blob, node, "cell-index", -1);
"cell-index", -1); dev->slaveadd = fdtdec_get_int(gd->fdt_blob, node,
dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
"u-boot,i2c-slave-addr", 0x7f); "u-boot,i2c-slave-addr", 0x7f);
dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset, dev->speed = fdtdec_get_int(gd->fdt_blob, node, "clock-frequency",
"clock-frequency", 400000); 400000);
dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk; dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk;

View File

@ -309,7 +309,7 @@ static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
{ {
struct i2c_gpio_bus *bus = dev_get_priv(dev); struct i2c_gpio_bus *bus = dev_get_priv(dev);
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
int ret; int ret;
ret = gpio_request_list_by_name(dev, "gpios", bus->gpios, ret = gpio_request_list_by_name(dev, "gpios", bus->gpios,

View File

@ -489,7 +489,7 @@ static int i2c_post_probe(struct udevice *dev)
#if CONFIG_IS_ENABLED(OF_CONTROL) #if CONFIG_IS_ENABLED(OF_CONTROL)
struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev); 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); "clock-frequency", 100000);
return dm_i2c_set_bus_speed(dev, i2c->speed_hz); 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) #if CONFIG_IS_ENABLED(OF_CONTROL)
struct dm_i2c_chip *plat = dev_get_parent_platdata(dev); struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
if (dev->of_offset == -1) if (dev_of_offset(dev) == -1)
return 0; 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 #else
return 0; return 0;
#endif #endif

View File

@ -89,7 +89,7 @@ static int i2c_arbitrator_probe(struct udevice *dev)
{ {
struct i2c_arbitrator_priv *priv = dev_get_priv(dev); struct i2c_arbitrator_priv *priv = dev_get_priv(dev);
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
int ret; int ret;
debug("%s: %s\n", __func__, dev->name); debug("%s: %s\n", __func__, dev->name);

View File

@ -40,7 +40,7 @@ static int i2c_mux_child_post_bind(struct udevice *dev)
struct i2c_mux_bus *plat = dev_get_parent_platdata(dev); struct i2c_mux_bus *plat = dev_get_parent_platdata(dev);
int channel; 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) if (channel < 0)
return -EINVAL; return -EINVAL;
plat->channel = channel; 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 * There is no compatible string in the sub-nodes, so we must manually
* bind these * bind these
*/ */
for (offset = fdt_first_subnode(blob, mux->of_offset); for (offset = fdt_first_subnode(blob, dev_of_offset(mux));
offset > 0; offset > 0;
offset = fdt_next_subnode(blob, offset)) { offset = fdt_next_subnode(blob, offset)) {
struct udevice *dev; struct udevice *dev;

View File

@ -51,7 +51,7 @@ static int pca954x_ofdata_to_platdata(struct udevice *dev)
{ {
struct pca954x_priv *priv = dev_get_priv(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) { if (!priv->addr) {
debug("MUX not found\n"); debug("MUX not found\n");
return -ENODEV; return -ENODEV;

View File

@ -775,11 +775,11 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus)
if (!dev->base) if (!dev->base)
return -ENOMEM; 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); "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); "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); "clock-frequency", 100000);
return 0; return 0;
} }

View File

@ -750,7 +750,7 @@ static int mxc_i2c_probe(struct udevice *bus)
{ {
struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus); struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
const void *fdt = gd->fdt_blob; const void *fdt = gd->fdt_blob;
int node = bus->of_offset; int node = dev_of_offset(bus);
fdt_addr_t addr; fdt_addr_t addr;
int ret, ret2; int ret, ret2;

View File

@ -312,7 +312,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
int node; int node;
node = dev->of_offset; node = dev_of_offset(dev);
i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev); i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev);

View File

@ -90,7 +90,7 @@ static int tegra186_bpmp_i2c_probe(struct udevice *dev)
{ {
struct tegra186_bpmp_i2c *priv = dev_get_priv(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); "nvidia,bpmp-bus-id", U32_MAX);
if (priv->bpmp_bus_id == U32_MAX) { if (priv->bpmp_bus_id == U32_MAX) {
debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__); debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__);

View File

@ -189,7 +189,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
struct stdio_dev *sdev = &uc_priv->sdev; struct stdio_dev *sdev = &uc_priv->sdev;
struct input_config *input = &uc_priv->input; struct input_config *input = &uc_priv->input;
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
int ret; int ret;
if (cros_ec_keyb_decode_fdt(blob, node, priv)) if (cros_ec_keyb_decode_fdt(blob, node, priv))

View File

@ -315,7 +315,7 @@ static int i8042_kbd_probe(struct udevice *dev)
struct input_config *input = &uc_priv->input; struct input_config *input = &uc_priv->input;
int ret; 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")) "intel,duplicate-por"))
priv->quirks |= QUIRK_DUP_POR; priv->quirks |= QUIRK_DUP_POR;

View File

@ -290,7 +290,7 @@ static int tegra_kbd_probe(struct udevice *dev)
struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev); struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
struct stdio_dev *sdev = &uc_priv->sdev; struct stdio_dev *sdev = &uc_priv->sdev;
struct input_config *input = &uc_priv->input; struct input_config *input = &uc_priv->input;
int node = dev->of_offset; int node = dev_of_offset(dev);
int ret; int ret;
priv->kbc = (struct kbc_tegra *)dev_get_addr(dev); priv->kbc = (struct kbc_tegra *)dev_get_addr(dev);

View File

@ -62,7 +62,7 @@ static int led_gpio_bind(struct udevice *parent)
int node; int node;
int ret; int ret;
for (node = fdt_first_subnode(blob, parent->of_offset); for (node = fdt_first_subnode(blob, dev_of_offset(parent));
node > 0; node > 0;
node = fdt_next_subnode(blob, node)) { node = fdt_next_subnode(blob, node)) {
struct led_uclass_plat *uc_plat; struct led_uclass_plat *uc_plat;

View File

@ -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); 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, "mboxes", "#mbox-cells", 0,
index, &args); index, &args);
if (ret) { 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); 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); "mbox-names", name);
if (index < 0) { if (index < 0) {
debug("fdt_stringlist_search() failed: %d\n", index); debug("fdt_stringlist_search() failed: %d\n", index);

View File

@ -998,7 +998,7 @@ int cros_ec_register(struct udevice *dev)
{ {
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
const void *blob = gd->fdt_blob; const void *blob = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
char id[MSG_BYTES]; char id[MSG_BYTES];
cdev->dev = dev; cdev->dev = dev;

View File

@ -522,7 +522,7 @@ int cros_ec_probe(struct udevice *dev)
int err; int err;
memcpy(ec, &s_state, sizeof(*ec)); 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) if (err)
return err; return err;
@ -531,7 +531,7 @@ int cros_ec_probe(struct udevice *dev)
keyb_dev; keyb_dev;
device_find_next_child(&keyb_dev)) { device_find_next_child(&keyb_dev)) {
if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) { if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) {
node = keyb_dev->of_offset; node = dev_of_offset(keyb_dev);
break; break;
} }
} }

View File

@ -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); 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); "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); "sandbox,filename", NULL);
if (!plat->filename) { if (!plat->filename) {
debug("%s: No filename for device '%s'\n", __func__, debug("%s: No filename for device '%s'\n", __func__,

View File

@ -112,19 +112,19 @@ static int tegra186_bpmp_bind(struct udevice *dev)
debug("%s(dev=%p)\n", __func__, dev); debug("%s(dev=%p)\n", __func__, dev);
ret = device_bind_driver_to_node(dev, "tegra186_clk", "tegra186_clk", ret = device_bind_driver_to_node(dev, "tegra186_clk", "tegra186_clk",
dev->of_offset, &child); dev_of_offset(dev), &child);
if (ret) if (ret)
return ret; return ret;
ret = device_bind_driver_to_node(dev, "tegra186_reset", ret = device_bind_driver_to_node(dev, "tegra186_reset",
"tegra186_reset", dev->of_offset, "tegra186_reset", dev_of_offset(dev),
&child); &child);
if (ret) if (ret)
return ret; return ret;
ret = device_bind_driver_to_node(dev, "tegra186_power_domain", ret = device_bind_driver_to_node(dev, "tegra186_power_domain",
"tegra186_power_domain", "tegra186_power_domain",
dev->of_offset, &child); dev_of_offset(dev), &child);
if (ret) if (ret)
return ret; return ret;
@ -141,7 +141,7 @@ static ulong tegra186_bpmp_get_shmem(struct udevice *dev, int index)
struct fdtdec_phandle_args args; struct fdtdec_phandle_args args;
fdt_addr_t reg; 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); "shmem", NULL, 0, index, &args);
if (ret < 0) { if (ret < 0) {
error("fdtdec_parse_phandle_with_args() failed: %d\n", ret); error("fdtdec_parse_phandle_with_args() failed: %d\n", ret);

View File

@ -22,12 +22,12 @@ static int tegra_car_bpmp_bind(struct udevice *dev)
debug("%s(dev=%p)\n", __func__, dev); debug("%s(dev=%p)\n", __func__, dev);
ret = device_bind_driver_to_node(dev, "tegra_car_clk", "tegra_car_clk", ret = device_bind_driver_to_node(dev, "tegra_car_clk", "tegra_car_clk",
dev->of_offset, &child); dev_of_offset(dev), &child);
if (ret) if (ret)
return ret; return ret;
ret = device_bind_driver_to_node(dev, "tegra_car_reset", ret = device_bind_driver_to_node(dev, "tegra_car_reset",
"tegra_car_reset", dev->of_offset, "tegra_car_reset", dev_of_offset(dev),
&child); &child);
if (ret) if (ret)
return ret; return ret;

View File

@ -75,7 +75,7 @@ static int atmel_sdhci_probe(struct udevice *dev)
host->ioaddr = (void *)dev_get_addr(dev); host->ioaddr = (void *)dev_get_addr(dev);
host->quirks = 0; 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); "bus-width", 4);
caps = sdhci_readl(host, SDHCI_CAPABILITIES); caps = sdhci_readl(host, SDHCI_CAPABILITIES);

View File

@ -264,7 +264,7 @@ static int exynos_dwmmc_probe(struct udevice *dev)
struct dwmci_host *host = &priv->host; struct dwmci_host *host = &priv->host;
int err; 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) if (err)
return err; return err;
err = do_dwmci_init(host); err = do_dwmci_init(host);

View File

@ -954,7 +954,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
struct fsl_esdhc_priv *priv = dev_get_priv(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev);
const void *fdt = gd->fdt_blob; const void *fdt = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
fdt_addr_t addr; fdt_addr_t addr;
unsigned int val; unsigned int val;
int ret; int ret;

View File

@ -50,16 +50,16 @@ DECLARE_GLOBAL_DATA_PTR;
static int msm_sdc_clk_init(struct udevice *dev) static int msm_sdc_clk_init(struct udevice *dev)
{ {
uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, int node = dev_of_offset(dev);
"clock-frequency", 400000); uint clk_rate = fdtdec_get_uint(gd->fdt_blob, node, "clock-frequency",
400000);
uint clkd[2]; /* clk_id and clk_no */ uint clkd[2]; /* clk_id and clk_no */
int clk_offset; int clk_offset;
struct udevice *clk_dev; struct udevice *clk_dev;
struct clk clk; struct clk clk;
int ret; int ret;
ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd, ret = fdtdec_get_int_array(gd->fdt_blob, node, "clock", clkd, 2);
2);
if (ret) if (ret)
return ret; return ret;
@ -168,17 +168,14 @@ static int msm_ofdata_to_platdata(struct udevice *dev)
struct udevice *parent = dev->parent; struct udevice *parent = dev->parent;
struct msm_sdhc *priv = dev_get_priv(dev); struct msm_sdhc *priv = dev_get_priv(dev);
struct sdhci_host *host = &priv->host; struct sdhci_host *host = &priv->host;
int node = dev_of_offset(dev);
host->name = strdup(dev->name); host->name = strdup(dev->name);
host->ioaddr = (void *)dev_get_addr(dev); host->ioaddr = (void *)dev_get_addr(dev);
host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, host->bus_width = fdtdec_get_int(gd->fdt_blob, node, "bus-width", 4);
"bus-width", 4); host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0);
host->index = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "index", 0);
priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob, priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
parent->of_offset, dev_of_offset(parent), node, "reg", 1, NULL, false);
dev->of_offset,
"reg", 1, NULL,
false);
if (priv->base == (void *)FDT_ADDR_T_NONE || if (priv->base == (void *)FDT_ADDR_T_NONE ||
host->ioaddr == (void *)FDT_ADDR_T_NONE) host->ioaddr == (void *)FDT_ADDR_T_NONE)
return -EINVAL; return -EINVAL;

View File

@ -728,7 +728,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
{ {
struct omap_hsmmc_data *priv = dev_get_priv(dev); struct omap_hsmmc_data *priv = dev_get_priv(dev);
const void *fdt = gd->fdt_blob; const void *fdt = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
struct mmc_config *cfg; struct mmc_config *cfg;
int val; int val;

View File

@ -38,18 +38,18 @@ static int pic32_sdhci_probe(struct udevice *dev)
fdt_size_t size; fdt_size_t size;
int ret; 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) if (addr == FDT_ADDR_T_NONE)
return -EINVAL; return -EINVAL;
host->ioaddr = ioremap(addr, size); host->ioaddr = ioremap(addr, size);
host->name = dev->name; host->name = dev->name;
host->quirks = SDHCI_QUIRK_NO_HISPD_BIT; 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); "bus-width", 4);
host->ops = &pic32_sdhci_ops; 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); "clock-freq-min-max", f_min_max, 2);
if (ret) { if (ret) {
printf("sdhci: clock-freq-min-max not found\n"); printf("sdhci: clock-freq-min-max not found\n");

View File

@ -59,24 +59,24 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
host->name = dev->name; host->name = dev->name;
host->ioaddr = (void *)dev_get_addr(dev); 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); "bus-width", 4);
host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk; host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
host->priv = dev; host->priv = dev;
/* use non-removeable as sdcard and emmc as judgement */ /* 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; host->dev_index = 0;
else else
host->dev_index = 1; 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); "fifo-depth", 0);
if (priv->fifo_depth < 0) if (priv->fifo_depth < 0)
return -EINVAL; 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"); "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)) "clock-freq-min-max", priv->minmax, 2))
return -EINVAL; return -EINVAL;
#endif #endif

View File

@ -38,7 +38,7 @@ static int arasan_sdhci_probe(struct udevice *dev)
struct clk clk; 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); "max-frequency", 0);
ret = clk_get_by_index(dev, 0, &clk); ret = clk_get_by_index(dev, 0, &clk);
if (!ret) { if (!ret) {

View File

@ -247,7 +247,7 @@ static int s5p_sdhci_probe(struct udevice *dev)
struct sdhci_host *host = dev_get_priv(dev); struct sdhci_host *host = dev_get_priv(dev);
int ret; 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) if (ret)
return ret; return ret;

View File

@ -70,7 +70,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
return -EINVAL; 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); "fifo-depth", 0);
if (fifo_depth < 0) { if (fifo_depth < 0) {
printf("DWMMC: Can't get FIFO depth\n"); 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->name = dev->name;
host->ioaddr = (void *)dev_get_addr(dev); 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); "bus-width", 4);
host->clksel = socfpga_dwmci_clksel; host->clksel = socfpga_dwmci_clksel;
@ -92,9 +92,9 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
host->bus_hz = clk; host->bus_hz = clk;
host->fifoth_val = MSIZE(0x2) | host->fifoth_val = MSIZE(0x2) |
RX_WMARK(fifo_depth / 2 - 1) | TX_WMARK(fifo_depth / 2); 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); "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); "smplsel", 0);
host->priv = priv; host->priv = priv;

View File

@ -578,8 +578,8 @@ static int tegra_mmc_probe(struct udevice *dev)
priv->cfg.name = "Tegra SD/MMC"; priv->cfg.name = "Tegra SD/MMC";
priv->cfg.ops = &tegra_mmc_ops; priv->cfg.ops = &tegra_mmc_ops;
bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
1); "bus-width", 1);
priv->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; priv->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
priv->cfg.host_caps = 0; priv->cfg.host_caps = 0;

View File

@ -705,7 +705,8 @@ static int uniphier_sd_probe(struct udevice *dev)
plat->cfg.name = dev->name; plat->cfg.name = dev->name;
plat->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS; 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: case 8:
plat->cfg.host_caps |= MMC_MODE_8BIT; plat->cfg.host_caps |= MMC_MODE_8BIT;
break; break;
@ -719,7 +720,7 @@ static int uniphier_sd_probe(struct udevice *dev)
return -EINVAL; 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)) NULL))
priv->caps |= UNIPHIER_SD_CAP_NONREMOVABLE; priv->caps |= UNIPHIER_SD_CAP_NONREMOVABLE;

View File

@ -405,7 +405,8 @@ static int xenon_sdhci_probe(struct udevice *dev)
armada_3700_soc_pad_voltage_set(host); armada_3700_soc_pad_voltage_set(host);
host->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_DDR_52MHz; 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: case 8:
host->host_caps |= MMC_MODE_8BIT; host->host_caps |= MMC_MODE_8BIT;
break; 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")) if (of_device_is_compatible(dev, "marvell,armada-3700-sdhci"))
priv->pad_ctrl_reg = (void *)dev_get_addr_index(dev, 1); priv->pad_ctrl_reg = (void *)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); NULL);
if (name) { if (name) {
if (0 == strncmp(name, "sd", 2)) { if (0 == strncmp(name, "sd", 2)) {

View File

@ -349,7 +349,7 @@ static int altera_qspi_ofdata_to_platdata(struct udevice *dev)
{ {
struct altera_qspi_platdata *pdata = dev_get_platdata(dev); struct altera_qspi_platdata *pdata = dev_get_platdata(dev);
void *blob = (void *)gd->fdt_blob; void *blob = (void *)gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
const char *list, *end; const char *list, *end;
const fdt32_t *cell; const fdt32_t *cell;
void *base; void *base;

View File

@ -2441,7 +2441,7 @@ unsigned long flash_init (void)
static int cfi_flash_probe(struct udevice *dev) static int cfi_flash_probe(struct udevice *dev)
{ {
void *blob = (void *)gd->fdt_blob; void *blob = (void *)gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
const fdt32_t *cell; const fdt32_t *cell;
phys_addr_t addr; phys_addr_t addr;
int parent, addrc, sizec; int parent, addrc, sizec;

View File

@ -371,7 +371,7 @@ static void pic32_flash_bank_init(flash_info_t *info,
static int pic32_flash_probe(struct udevice *dev) static int pic32_flash_probe(struct udevice *dev)
{ {
void *blob = (void *)gd->fdt_blob; void *blob = (void *)gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
const char *list, *end; const char *list, *end;
const fdt32_t *cell; const fdt32_t *cell;
unsigned long addr, size; unsigned long addr, size;

View File

@ -516,7 +516,7 @@ int sandbox_sf_ofdata_to_platdata(struct udevice *dev)
{ {
struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
const void *blob = gd->fdt_blob; 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->filename = fdt_getprop(blob, node, "sandbox,filename", NULL);
pdata->device_name = fdt_getprop(blob, node, "compatible", 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: ", debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
__func__, busnum, cs); __func__, busnum, cs);
ret = sandbox_sf_bind_emul(state, busnum, cs, bus, ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
slave->of_offset, slave->name); dev_of_offset(slave), slave->name);
if (ret) { if (ret) {
debug("failed (err=%d)\n", ret); debug("failed (err=%d)\n", ret);
return ret; return ret;

View File

@ -919,7 +919,7 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
#ifdef CONFIG_DM_SPI_FLASH #ifdef CONFIG_DM_SPI_FLASH
fdt_addr_t addr; fdt_addr_t addr;
fdt_size_t size; 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); addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
if (addr == FDT_ADDR_T_NONE) { if (addr == FDT_ADDR_T_NONE) {

View File

@ -857,7 +857,7 @@ static int ag7xxx_get_phy_iface_offset(struct udevice *dev)
{ {
int offset; 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) { if (offset <= 0) {
debug("%s: PHY OF node not found (ret=%i)\n", __func__, offset); debug("%s: PHY OF node not found (ret=%i)\n", __func__, offset);
return -EINVAL; return -EINVAL;

View File

@ -576,7 +576,7 @@ static int altera_tse_probe(struct udevice *dev)
struct eth_pdata *pdata = dev_get_platdata(dev); struct eth_pdata *pdata = dev_get_platdata(dev);
struct altera_tse_priv *priv = dev_get_priv(dev); struct altera_tse_priv *priv = dev_get_priv(dev);
void *blob = (void *)gd->fdt_blob; void *blob = (void *)gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
const char *list, *end; const char *list, *end;
const fdt32_t *cell; const fdt32_t *cell;
void *base, *desc_mem = NULL; void *base, *desc_mem = NULL;
@ -676,7 +676,8 @@ static int altera_tse_ofdata_to_platdata(struct udevice *dev)
const char *phy_mode; const char *phy_mode;
pdata->phy_interface = -1; 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) if (phy_mode)
pdata->phy_interface = phy_get_interface_by_name(phy_mode); pdata->phy_interface = phy_get_interface_by_name(phy_mode);
if (pdata->phy_interface == -1) { if (pdata->phy_interface == -1) {

View File

@ -20,7 +20,7 @@ static int davinci_emac_3517_get_macid(struct udevice *dev, u16 offset,
int slave, u8 *mac_addr) int slave, u8 *mac_addr)
{ {
void *fdt = (void *)gd->fdt_blob; void *fdt = (void *)gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
u32 macid_lsb; u32 macid_lsb;
u32 macid_msb; u32 macid_msb;
fdt32_t gmii = 0; 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) u8 *mac_addr)
{ {
void *fdt = (void *)gd->fdt_blob; void *fdt = (void *)gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
u32 macid_lo; u32 macid_lo;
u32 macid_hi; u32 macid_hi;
fdt32_t gmii = 0; fdt32_t gmii = 0;

View File

@ -981,7 +981,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
#ifdef CONFIG_DM_ETH #ifdef CONFIG_DM_ETH
if (slave->data->phy_of_handle) 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 #endif
priv->phydev = phydev; priv->phydev = phydev;
@ -1286,7 +1286,7 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
const char *phy_mode; const char *phy_mode;
const char *phy_sel_compat = NULL; const char *phy_sel_compat = NULL;
const void *fdt = gd->fdt_blob; const void *fdt = gd->fdt_blob;
int node = dev->of_offset; int node = dev_of_offset(dev);
int subnode; int subnode;
int slave_index = 0; int slave_index = 0;
int active_slave; int active_slave;

Some files were not shown because too many files have changed in this diff Show More