dm: Use dev_get_addr() where possible
Subsystems (12)
PATCH 1/1 dm: Use dev_get_addr() where possible
This is a convenient way for a driver to get the hardware address of a device, when regmap or syscon are not being used. Change existing callers to use it as an example to others.
---
drivers/core/device.c | 2 ++ drivers/gpio/s5p_gpio.c | 3 +-- drivers/gpio/sunxi_gpio.c | 5 +---- drivers/gpio/tegra_gpio.c | 3 +-- drivers/i2c/s3c24x0_i2c.c | 6 ++---- drivers/i2c/tegra_i2c.c | 2 +- drivers/serial/ns16550.c | 2 +- drivers/serial/serial_arc.c | 3 +-- drivers/serial/serial_pl01x.c | 2 +- drivers/serial/serial_s5p.c | 2 +- drivers/serial/serial_uniphier.c | 2 +- drivers/spi/designware_spi.c | 2 +- drivers/spi/exynos_spi.c | 2 +- drivers/spi/fsl_dspi.c | 2 +- drivers/spi/tegra114_spi.c | 2 +- drivers/spi/tegra20_sflash.c | 2 +- drivers/spi/tegra20_slink.c | 2 +- drivers/spi/zynq_spi.c | 2 +- drivers/usb/host/ehci-tegra.c | 8 +++++--- drivers/usb/host/xhci-exynos5.c | 2 +- drivers/video/tegra124/dp.c | 3 +-- 21 files changed, 27 insertions(+), 32 deletions(-)
drivers/core/device.c +2 -0
@@ -566,8 +566,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev) addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );if (addr !=FDT_ADDR_T_NONE ) { +#ifndef CONFIG_SPL_BUILD if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr); +#endif }return addr;
drivers/gpio/s5p_gpio.c +1 -2
@@ -327,8 +327,7 @@ static int gpio_exynos_bind(struct udevice *parent)if (plat)return 0 ; - base = (struct s5p_gpio_bank *)fdtdec_get_addr (gd->fdt_blob, - parent->of_offset,"reg" ); + base = (struct s5p_gpio_bank *)dev_get_addr (parent);for (node =fdt_first_subnode (blob, parent->of_offset), bank = base; node >0 ; node =fdt_next_subnode (blob, node), bank++) {
drivers/gpio/sunxi_gpio.c +1 -4
@@ -20,8 +20,6 @@#include <asm/gpio.h> #include <dm/device-internal.h> -DECLARE_GLOBAL_DATA_PTR ; -#define SUNXI_GPIOS_PER_BANK SUNXI_GPIO_A_NRstruct sunxi_gpio_platdata {
@@ -273,8 +271,7 @@ static int gpio_sunxi_bind(struct udevice *parent)if (plat)return 0 ; - ctlr = (struct sunxi_gpio_reg *)fdtdec_get_addr (gd->fdt_blob, - parent->of_offset,"reg" ); + ctlr = (struct sunxi_gpio_reg *)dev_get_addr (parent);for (bank =0 ; bank <SUNXI_GPIO_BANKS ; bank++) {struct sunxi_gpio_platdata *plat;struct udevice *dev;
drivers/gpio/tegra_gpio.c +1 -2
@@ -343,8 +343,7 @@ static int gpio_tegra_bind(struct udevice *parent)if (!fdt_getprop (gd->fdt_blob, parent->of_offset,"interrupts" , &len))return -EINVAL ; bank_count = len /3 /sizeof (u32); - ctlr = (struct gpio_ctlr *)fdtdec_get_addr (gd->fdt_blob, - parent->of_offset, "reg"); + ctlr = (struct gpio_ctlr *)dev_get_addr(parent); }#endif for (bank =0 ; bank < bank_count; bank++) {
drivers/i2c/s3c24x0_i2c.c +2 -4
@@ -1397,12 +1397,10 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)if (i2c_bus->is_highspeed) { flags =PINMUX_FLAG_HS_MODE ; - i2c_bus->hsregs = (struct exynos5_hsi2c *) -fdtdec_get_addr (blob, node,"reg" ); + i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr (dev); }else { flags =0 ; - i2c_bus->regs = (struct s3c24x0_i2c *) -fdtdec_get_addr (blob, node,"reg" ); + i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr (dev); } i2c_bus->id =pinmux_decode_periph_id (blob, node);
drivers/i2c/tegra_i2c.c +1 -1
@@ -339,7 +339,7 @@ static int tegra_i2c_probe(struct udevice *dev) i2c_bus->id = dev->seq; i2c_bus->type =dev_get_driver_data (dev); - i2c_bus->regs = (struct i2c_ctlr *)fdtdec_get_addr (blob, node,"reg" ); + i2c_bus->regs = (struct i2c_ctlr *)dev_get_addr (dev);/* * We don't have a binding for pinmux yet. Leave it out for now. So
drivers/serial/ns16550.c +1 -1
@@ -364,7 +364,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)fdt_addr_t addr;/* try Processor Local Bus device first */ - addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" ); + addr =dev_get_addr (dev);#ifdef CONFIG_PCI if (addr ==FDT_ADDR_T_NONE ) {/* then try pci device */
drivers/serial/serial_arc.c +1 -2
@@ -133,8 +133,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev)struct arc_serial_platdata *plat =dev_get_platdata (dev);DECLARE_GLOBAL_DATA_PTR ; - plat->reg = (struct arc_serial_regs *)fdtdec_get_addr (gd->fdt_blob, - dev->of_offset,"reg" ); + plat->reg = (struct arc_serial_regs *)dev_get_addr (dev); plat->uartclk =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock-frequency" ,0 );
drivers/serial/serial_pl01x.c +1 -1
@@ -365,7 +365,7 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)struct pl01x_serial_platdata *plat =dev_get_platdata (dev);fdt_addr_t addr; - addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" ); + addr =dev_get_addr (dev);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;
drivers/serial/serial_s5p.c +1 -1
@@ -169,7 +169,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev)struct s5p_serial_platdata *plat = dev->platdata;fdt_addr_t addr; - addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" ); + addr =dev_get_addr (dev);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;
drivers/serial/serial_uniphier.c +1 -1
@@ -124,7 +124,7 @@ static int uniphier_serial_ofdata_to_platdata(struct udevice *dev)struct uniphier_serial_platform_data *plat =dev_get_platdata (dev);DECLARE_GLOBAL_DATA_PTR ; - plat->base =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" ); + plat->base =dev_get_addr (dev); plat->uartclk =fdtdec_get_int (gd->fdt_blob, dev->of_offset,"clock-frequency" ,0 );
drivers/spi/designware_spi.c +1 -1
@@ -134,7 +134,7 @@ static int dw_spi_ofdata_to_platdata(struct udevice *bus)const void *blob = gd->fdt_blob;int node = bus->of_offset; - plat->regs = (struct dw_spi *)fdtdec_get_addr (blob, node,"reg" ); + plat->regs = (struct dw_spi *)dev_get_addr (bus);/* Use 500KHz as a suitable default */ plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
drivers/spi/exynos_spi.c +1 -1
@@ -255,7 +255,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)const void *blob = gd->fdt_blob;int node = bus->of_offset; - plat->regs = (struct exynos_spi *)fdtdec_get_addr (blob, node,"reg" ); + plat->regs = (struct exynos_spi *)dev_get_addr (bus); plat->periph_id =pinmux_decode_periph_id (blob, node);if (plat->periph_id ==PERIPH_ID_NONE ) {
drivers/spi/fsl_dspi.c +1 -1
@@ -654,7 +654,7 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus) plat->num_chipselect =fdtdec_get_int (blob, node,"num-cs" ,FSL_DSPI_MAX_CHIPSELECT ); - addr =fdtdec_get_addr (blob, node,"reg" ); + addr =dev_get_addr (bus);if (addr ==FDT_ADDR_T_NONE ) {debug ("DSPI: Can't get base address or size\n" );return -ENOMEM ;
drivers/spi/tegra114_spi.c +1 -1
@@ -118,7 +118,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)const void *blob = gd->fdt_blob;int node = bus->of_offset; - plat->base =fdtdec_get_addr (blob, node,"reg" ); + plat->base =dev_get_addr (bus); plat->periph_id =clock_decode_periph_id (blob, node);if (plat->periph_id ==PERIPH_ID_NONE ) {
drivers/spi/tegra20_sflash.c +1 -1
@@ -90,7 +90,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)const void *blob = gd->fdt_blob;int node = bus->of_offset; - plat->base =fdtdec_get_addr (blob, node,"reg" ); + plat->base =dev_get_addr (bus); plat->periph_id =clock_decode_periph_id (blob, node);if (plat->periph_id ==PERIPH_ID_NONE ) {
drivers/spi/tegra20_slink.c +1 -1
@@ -106,7 +106,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus)const void *blob = gd->fdt_blob;int node = bus->of_offset; - plat->base =fdtdec_get_addr (blob, node,"reg" ); + plat->base =dev_get_addr (bus); plat->periph_id =clock_decode_periph_id (blob, node);if (plat->periph_id ==PERIPH_ID_NONE ) {
drivers/spi/zynq_spi.c +1 -1
@@ -72,7 +72,7 @@ static int zynq_spi_ofdata_to_platdata(struct udevice *bus)const void *blob = gd->fdt_blob;int node = bus->of_offset; - plat->regs = (struct zynq_spi_regs *)fdtdec_get_addr (blob, node,"reg" ); + plat->regs = (struct zynq_spi_regs *)dev_get_addr (bus);/* FIXME: Use 250MHz as a suitable default */ plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
drivers/usb/host/ehci-tegra.c +5 -3
@@ -684,11 +684,13 @@ static void config_clock(const u32 timing[]) timing[PARAM_CPCON], timing[PARAM_LFCON]); } -static int fdt_decode_usb (const void *blob,int node,struct fdt_usb *config) +static int fdt_decode_usb (struct udevice *dev,struct fdt_usb *config) { +const void *blob = gd->fdt_blob; +int node = dev->of_offset;const char *phy, *mode; - config->reg = (struct usb_ctlr *)fdtdec_get_addr (blob, node,"reg" ); + config->reg = (struct usb_ctlr *)dev_get_addr (dev); mode =fdt_getprop (blob, node,"dr_mode" ,NULL );if (mode) {if (0 ==strcmp (mode,"host" ))
@@ -812,7 +814,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)struct fdt_usb *priv =dev_get_priv (dev);int ret; - ret =fdt_decode_usb (gd->fdt_blob, dev->of_offset, priv); + ret =fdt_decode_usb (dev, priv);if (ret)return ret;
drivers/usb/host/xhci-exynos5.c +1 -1
@@ -61,7 +61,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)/* * Get the base address for XHCI controller from the device node */ - plat->hcd_base =fdtdec_get_addr (blob, dev->of_offset,"reg" ); + plat->hcd_base =dev_get_addr (dev);if (plat->hcd_base ==FDT_ADDR_T_NONE ) {debug ("Can't get the XHCI register base address\n" );return -ENXIO ;
drivers/video/tegra124/dp.c +1 -2
@@ -1555,9 +1555,8 @@ error_enable:static int tegra_dp_ofdata_to_platdata (struct udevice *dev) {struct tegra_dp_plat *plat =dev_get_platdata (dev); -const void *blob = gd->fdt_blob; - plat->base =fdtdec_get_addr (blob, dev->of_offset,"reg" ); + plat->base =dev_get_addr (dev);return 0 ; }
Signature · 1 line
2.5.0.rc2.392.g76e840b
PATCH 1/1 dm: Use dev_get_addr() where possible
Hi Simon,
Quoted 5 lines · Simon Glass
This is a convenient way for a driver to get the hardware address of a device, when regmap or syscon are not being used. Change existing callers to use it as an example to others.
Signed-off-by Simon Glass <[email protected]>
This looks great!
PATCH 1/1 dm: Use dev_get_addr() where possible
In reply to Simon GlassQuoted 3 lines · Simon Glass
This is a convenient way for a driver to get the hardware address of a device, when regmap or syscon are not being used. Change existing callers to use it as an example to others.
Ah good; I was a little worried about the tiny number of users of dev_get_addr().
drivers/core/device.c fdt_addr_t dev_get_addr(struct udevice *dev) · line 572
Quoted 10 lines
drivers/core/device.c +2
-0@@ -566,8 +566,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev) addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );if (addr !=FDT_ADDR_T_NONE ) { +#ifndef CONFIG_SPL_BUILD if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr); +#endif
That seems like an unrelated change; is it a fix for a pre-existing issue? Either way, it looks like that will cause SPL to get incorrect values for the address since addresses won't get translated (via the parent's ranges property??) in SPL. Isn't that a bad thing?
The rest of the patch,
PATCH 1/1 dm: Use dev_get_addr() where possible
Hi Stephen,
Quoted 15 lines · Stephen Warren
Quoted 4 lines · Simon Glass
This is a convenient way for a driver to get the hardware address of a device, when regmap or syscon are not being used. Change existing callers to use it as an example to others.
Ah good; I was a little worried about the tiny number of users of
dev_get_addr().Quoted 5 lines
drivers/core/device.c +0
-0@@ -566,8 +566,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
Quoted 9 lines
drivers/core/device.c fdt_addr_t dev_get_addr(struct udevice *dev) · line 572
Quoted 6 lines
drivers/core/device.c +2
-0addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );if (addr !=FDT_ADDR_T_NONE ) { +#ifndef CONFIG_SPL_BUILD if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr); +#endif That seems like an unrelated change; is it a fix for a pre-existing issue? Either way, it looks like that will cause SPL to get incorrect values for the address since addresses won't get translated (via the parent's ranges property??) in SPL. Isn't that a bad thing?
Masahiro has a series pending which will clean this up, and I'll revisit it after that. But for now SPL does not support simple bus. It does not affect current platforms.
Quoted 3 lines
The rest of the patch,
Acked-by Stephen Warren <[email protected]>
Regards,
Simon
PATCH 1/1 dm: Use dev_get_addr() where possible
Hi,
Quoted 28 lines · Simon Glass
Hi Stephen,
Quoted 15 lines · Stephen Warren
Quoted 4 lines · Simon Glass
This is a convenient way for a driver to get the hardware address of a device, when regmap or syscon are not being used. Change existing callers to use it as an example to others.
Ah good; I was a little worried about the tiny number of users of
dev_get_addr().Quoted 5 lines
drivers/core/device.c +0
-0@@ -566,8 +566,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev)Quoted 9 lines
drivers/core/device.c fdt_addr_t dev_get_addr(struct udevice *dev) · line 572
Quoted 6 lines
drivers/core/device.c +2
-0addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );if (addr !=FDT_ADDR_T_NONE ) { +#ifndef CONFIG_SPL_BUILD if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr); +#endif That seems like an unrelated change; is it a fix for a pre-existing issue? Either way, it looks like that will cause SPL to get incorrect values for the address since addresses won't get translated (via the parent's ranges property??) in SPL. Isn't that a bad thing?
Quoted 8 lines
Masahiro has a series pending which will clean this up, and I'll revisit it after that. But for now SPL does not support simple bus. It does not affect current platforms.
Quoted 3 lines
The rest of the patch,
Acked-by Stephen Warren <[email protected]>
Unless there are objections I plan to apply this clean-up patch to dm/master next week.
Regards,
Simon
PATCH 1/1 dm: Use dev_get_addr() where possible
Quoted 36 lines · Simon Glass
Hi,
Quoted 33 lines · Simon Glass
Hi Stephen,
Quoted 15 lines · Stephen Warren
Quoted 4 lines · Simon Glass
This is a convenient way for a driver to get the hardware address of a device, when regmap or syscon are not being used. Change existing callers to use it as an example to others.
Ah good; I was a little worried about the tiny number of users of
dev_get_addr().Quoted 5 lines
drivers/core/device.c +0
-0@@ -566,8 +566,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev)Quoted 9 lines
drivers/core/device.c fdt_addr_t dev_get_addr(struct udevice *dev) · line 572
Quoted 6 lines
drivers/core/device.c +2
-0addr =fdtdec_get_addr (gd->fdt_blob, dev->of_offset,"reg" );if (addr !=FDT_ADDR_T_NONE ) { +#ifndef CONFIG_SPL_BUILD if (device_get_uclass_id (dev->parent) ==UCLASS_SIMPLE_BUS ) addr =simple_bus_translate (dev->parent, addr); +#endif That seems like an unrelated change; is it a fix for a pre-existing issue? Either way, it looks like that will cause SPL to get incorrect values for the address since addresses won't get translated (via the parent's ranges property??) in SPL. Isn't that a bad thing?
Masahiro has a series pending which will clean this up, and I'll revisit it after that. But for now SPL does not support simple bus. It does not affect current platforms.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
The rest of the patch,
Acked-by Stephen Warren <[email protected]>Unless there are objections I plan to apply this clean-up patch to dm/master next week.
Or maybe this week.
Applied to u-boot-dm.