[U-Boot] [PATCH 0/7] rockchip: convert fdt_get to dev_read

With the new dev_read functions available we can start converting drivers we use (and can test) over to the dev_read family of functions.
As my development tree's test coverage is currently focused on our Rockchip devices, this series is limited to drivers used in our devices and the Rockchip subarchitecture.
To make regression testing easier, these are individual commits (across driver subsystems) instead of a single, large change bunched together. Feel free to flatten these into a single commit as they are merged upstream.
Philipp Tomsich (7): rockchip: pinctrl: dm: convert fdt_get to dev_read rockchip: spi: dm: convert fdt_get to dev_read rockchip: xhci: dm: convert fdt_get to dev_read rockchip: mmc: dm: convert fdt_get to dev_read rockchip: net: dm: convert fdt_get to dev_read rockchip: ns16550: dm: convert fdt_get to dev_read rockchip: dm: convert fdt_get to dev_read
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 8 +++----- drivers/mmc/rockchip_dw_mmc.c | 18 +++++++----------- drivers/mmc/rockchip_sdhci.c | 3 +-- drivers/net/designware.c | 7 +++---- drivers/net/gmac_rockchip.c | 10 ++++------ drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3188.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3328.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3399.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rv1108.c | 3 +-- drivers/serial/ns16550.c | 11 ++++------- drivers/spi/rk_spi.c | 15 +++++++-------- drivers/usb/host/xhci-rockchip.c | 13 ++++--------- 16 files changed, 57 insertions(+), 86 deletions(-)

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the pinctrl drivers for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
---
drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3188.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3328.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3399.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rv1108.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3036.c b/drivers/pinctrl/rockchip/pinctrl_rk3036.c index 9215d6c..94f6d7a 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3036.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3036.c @@ -193,8 +193,7 @@ static int rk3036_pinctrl_get_periph_id(struct udevice *dev, u32 cell[3]; int ret;
- ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph), - "interrupts", cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(periph, "interrupts", cell, ARRAY_SIZE(cell)); if (ret < 0) return -EINVAL;
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3188.c b/drivers/pinctrl/rockchip/pinctrl_rk3188.c index 65c1f66..692d8e2 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3188.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3188.c @@ -370,8 +370,7 @@ static int rk3188_pinctrl_get_periph_id(struct udevice *dev, u32 cell[3]; int ret;
- ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph), - "interrupts", cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(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 cb13d30..de5e834 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3288.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3288.c @@ -479,8 +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, dev_of_offset(periph), - "interrupts", cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(periph, "interrupts", cell, ARRAY_SIZE(cell)); if (ret < 0) return -EINVAL;
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3328.c b/drivers/pinctrl/rockchip/pinctrl_rk3328.c index d0ffeb1..efa5b31 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3328.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3328.c @@ -251,8 +251,7 @@ static int rk3328_pinctrl_get_periph_id(struct udevice *dev, u32 cell[3]; int ret;
- ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph), - "interrupts", cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(periph, "interrupts", cell, ARRAY_SIZE(cell)); if (ret < 0) return -EINVAL;
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3399.c b/drivers/pinctrl/rockchip/pinctrl_rk3399.c index d93b903..cab268c 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3399.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3399.c @@ -350,8 +350,7 @@ static int rk3399_pinctrl_get_periph_id(struct udevice *dev, u32 cell[3]; int ret;
- ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph), - "interrupts", cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(periph, "interrupts", cell, ARRAY_SIZE(cell)); if (ret < 0) return -EINVAL;
diff --git a/drivers/pinctrl/rockchip/pinctrl_rv1108.c b/drivers/pinctrl/rockchip/pinctrl_rv1108.c index bdf3910..cda94f4 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rv1108.c +++ b/drivers/pinctrl/rockchip/pinctrl_rv1108.c @@ -108,8 +108,7 @@ static int rv1108_pinctrl_get_periph_id(struct udevice *dev, u32 cell[3]; int ret;
- ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph), - "interrupts", cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(periph, "interrupts", cell, ARRAY_SIZE(cell)); if (ret < 0) return -EINVAL;

On 7 June 2017 at 10:45, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the pinctrl drivers for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3188.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3328.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3399.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rv1108.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the pinctrl drivers for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3188.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3328.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3399.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rv1108.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the pinctrl drivers for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3188.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3328.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3399.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rv1108.c | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the rk_spi.c (SPI driver) used in Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
drivers/spi/rk_spi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index a8f0eb0..7921ea0 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -182,8 +182,6 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice *bus) #if !CONFIG_IS_ENABLED(OF_PLATDATA) 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 = dev_of_offset(bus); int ret;
plat->base = devfdt_get_addr(bus); @@ -195,12 +193,13 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice *bus) return ret; }
- plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", - 50000000); - plat->deactivate_delay_us = fdtdec_get_int(blob, node, - "spi-deactivate-delay", 0); - plat->activate_delay_us = fdtdec_get_int(blob, node, - "spi-activate-delay", 0); + plat->frequency = + dev_read_u32_default(bus, "spi-max-frequency", 50000000); + plat->deactivate_delay_us = + dev_read_u32_default(bus, "spi-deactivate-delay", 0); + plat->activate_delay_us = + dev_read_u32_default(bus, "spi-activate-delay", 0); + debug("%s: base=%x, max-frequency=%d, deactivate_delay=%d\n", __func__, (uint)plat->base, plat->frequency, plat->deactivate_delay_us);

On 7 June 2017 at 10:45, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the rk_spi.c (SPI driver) used in Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
drivers/spi/rk_spi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the rk_spi.c (SPI driver) used in Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/spi/rk_spi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the rk_spi.c (SPI driver) used in Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/spi/rk_spi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the USB3 (xhci) driver for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
drivers/usb/host/xhci-rockchip.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/host/xhci-rockchip.c b/drivers/usb/host/xhci-rockchip.c index c4ae55f..da21bc7 100644 --- a/drivers/usb/host/xhci-rockchip.c +++ b/drivers/usb/host/xhci-rockchip.c @@ -86,18 +86,15 @@ static void rockchip_dwc3_phy_setup(struct dwc3 *dwc3_reg, struct udevice *dev) { u32 reg; - const void *blob = gd->fdt_blob; u32 utmi_bits;
/* Set dwc3 usb2 phy config */ reg = readl(&dwc3_reg->g_usb2phycfg[0]);
- if (fdtdec_get_bool(blob, dev_of_offset(dev), - "snps,dis-enblslpm-quirk")) + if (dev_read_bool(dev, "snps,dis-enblslpm-quirk")) reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
- utmi_bits = fdtdec_get_int(blob, dev_of_offset(dev), - "snps,phyif-utmi-bits", -1); + utmi_bits = dev_read_u32_default(dev, "snps,phyif-utmi-bits", -1); if (utmi_bits == 16) { reg |= DWC3_GUSB2PHYCFG_PHYIF; reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK; @@ -108,12 +105,10 @@ static void rockchip_dwc3_phy_setup(struct dwc3 *dwc3_reg, reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT; }
- if (fdtdec_get_bool(blob, dev_of_offset(dev), - "snps,dis-u2-freeclk-exists-quirk")) + if (dev_read_bool(dev, "snps,dis-u2-freeclk-exists-quirk")) reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
- if (fdtdec_get_bool(blob, dev_of_offset(dev), - "snps,dis-u2-susphy-quirk")) + if (dev_read_bool(dev, "snps,dis-u2-susphy-quirk")) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
writel(reg, &dwc3_reg->g_usb2phycfg[0]);

On 7 June 2017 at 10:45, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the USB3 (xhci) driver for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
drivers/usb/host/xhci-rockchip.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the USB3 (xhci) driver for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/usb/host/xhci-rockchip.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This change covers the USB3 (xhci) driver for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/usb/host/xhci-rockchip.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the dw_mmc and sdhci wrapper drivers for Rockchip.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
drivers/mmc/rockchip_dw_mmc.c | 18 +++++++----------- drivers/mmc/rockchip_sdhci.c | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 25a21e2..24754b7 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -59,32 +59,28 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
host->name = dev->name; host->ioaddr = (void *)devfdt_get_addr(dev); - host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "bus-width", 4); + host->buswidth = dev_read_u32_default(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(dev), "non-removable")) + if (dev_read_bool(dev, "non-removable")) host->dev_index = 0; else host->dev_index = 1;
- priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "fifo-depth", 0); + priv->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0); + if (priv->fifo_depth < 0) return -EINVAL; - priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), - "fifo-mode"); + priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
/* * 'clock-freq-min-max' is deprecated * (see https://github.com/torvalds/linux/commit/b023030f10573de738bbe8df63d43acab64...) */ - if (fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), - "clock-freq-min-max", priv->minmax, 2)) { - int val = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "max-frequency", -EINVAL); + if (dev_read_u32_array(dev, "clock-freq-min-max", priv->minmax, 2)) { + int val = dev_read_u32_default(dev, "max-frequency", -EINVAL);
if (val < 0) return val; diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index 8985878..f31d329 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -50,8 +50,7 @@ static int arasan_sdhci_probe(struct udevice *dev) max_frequency = dtplat->max_frequency; ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, &clk); #else - max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "max-frequency", 0); + max_frequency = dev_read_u32_default(dev, "max-frequency", 0); ret = clk_get_by_index(dev, 0, &clk); #endif if (!ret) {

On 7 June 2017 at 10:46, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the dw_mmc and sdhci wrapper drivers for Rockchip.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
drivers/mmc/rockchip_dw_mmc.c | 18 +++++++----------- drivers/mmc/rockchip_sdhci.c | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the dw_mmc and sdhci wrapper drivers for Rockchip.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/mmc/rockchip_dw_mmc.c | 18 +++++++----------- drivers/mmc/rockchip_sdhci.c | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the dw_mmc and sdhci wrapper drivers for Rockchip.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/mmc/rockchip_dw_mmc.c | 18 +++++++----------- drivers/mmc/rockchip_sdhci.c | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the Gigabit Ethernet MAC (i.e. common designware driver and rockchip-specific wrapper).
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
drivers/net/designware.c | 7 +++---- drivers/net/gmac_rockchip.c | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c index e8569e6..521e4dd 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -760,15 +760,14 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev) pdata->max_speed = fdt32_to_cpu(*cell);
#ifdef CONFIG_DM_GPIO - if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), - "snps,reset-active-low")) + if (dev_read_bool(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(dev), - "snps,reset-delays-us", dw_pdata->reset_delays, 3); + ret = dev_read_u32_array(dev, "snps,reset-delays-us", + dw_pdata->reset_delays, 3); } else if (ret == -ENOENT) { ret = 0; } diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c index 5e2ca76..c9f9e83 100644 --- a/drivers/net/gmac_rockchip.c +++ b/drivers/net/gmac_rockchip.c @@ -43,18 +43,16 @@ struct rk_gmac_ops { static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) { struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev);
/* Check the new naming-style first... */ - pdata->tx_delay = fdtdec_get_int(blob, node, "tx_delay", -ENOENT); - pdata->rx_delay = fdtdec_get_int(blob, node, "rx_delay", -ENOENT); + pdata->tx_delay = dev_read_u32_default(dev, "tx_delay", -ENOENT); + pdata->rx_delay = dev_read_u32_default(dev, "rx_delay", -ENOENT);
/* ... and fall back to the old naming style or default, if necessary */ if (pdata->tx_delay == -ENOENT) - pdata->tx_delay = fdtdec_get_int(blob, node, "tx-delay", 0x30); + pdata->tx_delay = dev_read_u32_default(dev, "tx-delay", 0x30); if (pdata->rx_delay == -ENOENT) - pdata->rx_delay = fdtdec_get_int(blob, node, "rx-delay", 0x10); + pdata->rx_delay = dev_read_u32_default(dev, "rx-delay", 0x10);
return designware_eth_ofdata_to_platdata(dev); }

On 7 June 2017 at 10:46, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the Gigabit Ethernet MAC (i.e. common designware driver and rockchip-specific wrapper).
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
drivers/net/designware.c | 7 +++---- drivers/net/gmac_rockchip.c | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
This is fine, but if we want to we could add a dev_read_u32() function:
int dev_read_u32(struct udevice *dev, const char *propname, u32 *resultp)
which returns an error code.

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the Gigabit Ethernet MAC (i.e. common designware driver and rockchip-specific wrapper).
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/net/designware.c | 7 +++---- drivers/net/gmac_rockchip.c | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the Gigabit Ethernet MAC (i.e. common designware driver and rockchip-specific wrapper).
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/net/designware.c | 7 +++---- drivers/net/gmac_rockchip.c | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the serial driver (ns16550 and compatible) used for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
drivers/serial/ns16550.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 52c52c1..e0e7024 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -434,10 +434,8 @@ 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(dev), - "reg-offset", 0); - plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "reg-shift", 0); + plat->reg_offset = dev_read_u32_default(dev, "reg-offset", 0); + plat->reg_shift = dev_read_u32_default(dev, "reg-shift", 0);
err = clk_get_by_index(dev, 0, &clk); if (!err) { @@ -450,9 +448,8 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev) }
if (!plat->clock) - plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "clock-frequency", - CONFIG_SYS_NS16550_CLK); + plat->clock = dev_read_u32_default(dev, "clock-frequency", + CONFIG_SYS_NS16550_CLK); if (!plat->clock) { debug("ns16550 clock not defined\n"); return -EINVAL;

On 7 June 2017 at 10:46, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the serial driver (ns16550 and compatible) used for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
drivers/serial/ns16550.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the serial driver (ns16550 and compatible) used for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/serial/ns16550.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the serial driver (ns16550 and compatible) used for the Rockchip devices.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
drivers/serial/ns16550.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the DRAM controller initialisation for the RK3188, RK3288 and RK3399... all of these read some of the tuning/setup/timing parameters from the device-tree.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 8 +++----- 3 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c b/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c index 946a9f1..981d1d6 100644 --- a/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c +++ b/arch/arm/mach-rockchip/rk3188/sdram_rk3188.c @@ -851,29 +851,27 @@ static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3188_sdram_params *params = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev); int ret;
/* rk3188 supports only one-channel */ params->num_channels = 1; - ret = fdtdec_get_int_array(blob, node, "rockchip,pctl-timing", - (u32 *)¶ms->pctl_timing, - sizeof(params->pctl_timing) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,pctl-timing", + (u32 *)¶ms->pctl_timing, + sizeof(params->pctl_timing) / sizeof(u32)); if (ret) { printf("%s: Cannot read rockchip,pctl-timing\n", __func__); return -EINVAL; } - ret = fdtdec_get_int_array(blob, node, "rockchip,phy-timing", - (u32 *)¶ms->phy_timing, - sizeof(params->phy_timing) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,phy-timing", + (u32 *)¶ms->phy_timing, + sizeof(params->phy_timing) / sizeof(u32)); if (ret) { printf("%s: Cannot read rockchip,phy-timing\n", __func__); return -EINVAL; } - ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params", - (u32 *)¶ms->base, - sizeof(params->base) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,sdram-params", + (u32 *)¶ms->base, + sizeof(params->base) / sizeof(u32)); if (ret) { printf("%s: Cannot read rockchip,sdram-params\n", __func__); return -EINVAL; diff --git a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c index 2feda61..b3ed3f2 100644 --- a/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c +++ b/arch/arm/mach-rockchip/rk3288/sdram_rk3288.c @@ -1018,29 +1018,27 @@ 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(dev); int ret;
/* Rk3288 supports dual-channel, set default channel num to 2 */ params->num_channels = 2; - ret = fdtdec_get_int_array(blob, node, "rockchip,pctl-timing", - (u32 *)¶ms->pctl_timing, - sizeof(params->pctl_timing) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,pctl-timing", + (u32 *)¶ms->pctl_timing, + sizeof(params->pctl_timing) / sizeof(u32)); if (ret) { debug("%s: Cannot read rockchip,pctl-timing\n", __func__); return -EINVAL; } - ret = fdtdec_get_int_array(blob, node, "rockchip,phy-timing", - (u32 *)¶ms->phy_timing, - sizeof(params->phy_timing) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,phy-timing", + (u32 *)¶ms->phy_timing, + sizeof(params->phy_timing) / sizeof(u32)); if (ret) { debug("%s: Cannot read rockchip,phy-timing\n", __func__); return -EINVAL; } - ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params", - (u32 *)¶ms->base, - sizeof(params->base) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,sdram-params", + (u32 *)¶ms->base, + sizeof(params->base) / sizeof(u32)); if (ret) { debug("%s: Cannot read rockchip,sdram-params\n", __func__); return -EINVAL; diff --git a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c index db75eb1..683fa40 100644 --- a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c @@ -1140,13 +1140,11 @@ static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rockchip_dmc_plat *plat = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev); int ret;
- ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params", - (u32 *)&plat->sdram_params, - sizeof(plat->sdram_params) / sizeof(u32)); + ret = dev_read_u32_array(dev, "rockchip,sdram-params", + (u32 *)&plat->sdram_params, + sizeof(plat->sdram_params) / sizeof(u32)); if (ret) { printf("%s: Cannot read rockchip,sdram-params %d\n", __func__, ret);

On 7 June 2017 at 10:46, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the DRAM controller initialisation for the RK3188, RK3288 and RK3399... all of these read some of the tuning/setup/timing parameters from the device-tree.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 8 +++----- 3 files changed, 21 insertions(+), 27 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the DRAM controller initialisation for the RK3188, RK3288 and RK3399... all of these read some of the tuning/setup/timing parameters from the device-tree.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 8 +++----- 3 files changed, 21 insertions(+), 27 deletions(-)
Applied to u-boot-rockchip/next, thanks!

With the new dev_read functions available, we can convert the rockchip architecture-specific drivers and common drivers used by these devices over to the dev_read family of calls.
This covers the DRAM controller initialisation for the RK3188, RK3288 and RK3399... all of these read some of the tuning/setup/timing parameters from the device-tree.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 20 +++++++++----------- arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 8 +++----- 3 files changed, 21 insertions(+), 27 deletions(-)
Applied to u-boot-rockchip/next, thanks!
participants (2)
-
Philipp Tomsich
-
Simon Glass