From e367305769d091bc8a0026d69136eb77fd055784 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 27 Sep 2023 15:33:31 +0200 Subject: core: return FDT_ADDR_T_NONE from devfdt_get_addr_[size_]name() on errors Checking for the error cast to fdt_addr_t is rather awkward - IS_ERR() can be used, but it's not really made to be used on fdt_addr_t, which may not even be the same size as a native pointer. Most places in U-Boot only check for FDT_ADDR_T_NONE; let's adjust the error return to match the expectation. Signed-off-by: Matthias Schiffer Reviewed-by: Simon Glass --- drivers/core/fdtaddr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index b79d138c419..0f4eff6707d 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -145,7 +145,7 @@ fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name) index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), "reg-names", name); if (index < 0) - return index; + return FDT_ADDR_T_NONE; return devfdt_get_addr_index(dev, index); #else @@ -162,7 +162,7 @@ fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev, index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), "reg-names", name); if (index < 0) - return index; + return FDT_ADDR_T_NONE; return devfdt_get_addr_size_index(dev, index, size); #else -- cgit v1.2.3 From bc8fa1cbfd429138ebd894a170ce36b07f86b150 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 27 Sep 2023 15:33:32 +0200 Subject: core: introduce dev_read_addr_name[_size]_ptr() functions Same as dev_read_addr_name[_size](), but returns a pointer, cast through map_sysmem(). Signed-off-by: Matthias Schiffer Reviewed-by: Simon Glass --- drivers/core/fdtaddr.c | 21 +++++++++++++++++++++ drivers/core/read.c | 21 +++++++++++++++++++++ include/dm/fdtaddr.h | 31 +++++++++++++++++++++++++++++++ include/dm/read.h | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) (limited to 'drivers') diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index 0f4eff6707d..8e774d49ce6 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -153,6 +153,16 @@ fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name) #endif } +void *devfdt_get_addr_name_ptr(const struct udevice *dev, const char *name) +{ + fdt_addr_t addr = devfdt_get_addr_name(dev, name); + + if (addr == FDT_ADDR_T_NONE) + return NULL; + + return map_sysmem(addr, 0); +} + fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev, const char *name, fdt_size_t *size) { @@ -170,6 +180,17 @@ fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev, #endif } +void *devfdt_get_addr_size_name_ptr(const struct udevice *dev, + const char *name, fdt_size_t *size) +{ + fdt_addr_t addr = devfdt_get_addr_size_name(dev, name, size); + + if (addr == FDT_ADDR_T_NONE) + return NULL; + + return map_sysmem(addr, 0); +} + fdt_addr_t devfdt_get_addr(const struct udevice *dev) { return devfdt_get_addr_index(dev, 0); diff --git a/drivers/core/read.c b/drivers/core/read.c index 419013451f0..1a4a95cddea 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -181,6 +181,16 @@ fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name) return dev_read_addr_index(dev, index); } +void *dev_read_addr_name_ptr(const struct udevice *dev, const char *name) +{ + fdt_addr_t addr = dev_read_addr_name(dev, name); + + if (addr == FDT_ADDR_T_NONE) + return NULL; + + return map_sysmem(addr, 0); +} + fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name, fdt_size_t *size) { @@ -192,6 +202,17 @@ fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name, return dev_read_addr_size_index(dev, index, size); } +void *dev_read_addr_size_name_ptr(const struct udevice *dev, const char *name, + fdt_size_t *size) +{ + fdt_addr_t addr = dev_read_addr_size_name(dev, name, size); + + if (addr == FDT_ADDR_T_NONE) + return NULL; + + return map_sysmem(addr, 0); +} + void *dev_remap_addr_name(const struct udevice *dev, const char *name) { fdt_addr_t addr = dev_read_addr_name(dev, name); diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h index c577d4369ce..bf8132deb86 100644 --- a/include/dm/fdtaddr.h +++ b/include/dm/fdtaddr.h @@ -146,6 +146,19 @@ void *devfdt_get_addr_size_index_ptr(const struct udevice *dev, int index, */ fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name); +/** + * devfdt_get_addr_name_ptr() - Get the reg property of a device as a pointer, + * indexed by name + * + * @dev: Pointer to a device + * @name: the 'reg' property can hold a list of pairs, with the + * 'reg-names' property providing named-based identification. @name + * indicates the value to search for in 'reg-names'. + * + * Return: Pointer to addr, or NULL if there is no such property + */ +void *devfdt_get_addr_name_ptr(const struct udevice *dev, const char *name); + /** * devfdt_get_addr_size_name() - Get the reg property and its size for a device, * indexed by name @@ -164,6 +177,24 @@ fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name); fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev, const char *name, fdt_size_t *size); +/** + * devfdt_get_addr_size_name_ptr() - Get the reg property for a device as a + * pointer, indexed by name + * + * Returns the address and size specified in the 'reg' property of a device. + * + * @dev: Pointer to a device + * @name: the 'reg' property can hold a list of pairs, with the + * 'reg-names' property providing named-based identification. @name + * indicates the value to search for in 'reg-names'. + * @size: Pointer to size variable - this function returns the size + * specified in the 'reg' property here + * + * Return: Pointer to addr, or NULL if there is no such property + */ +void *devfdt_get_addr_size_name_ptr(const struct udevice *dev, + const char *name, fdt_size_t *size); + /** * devfdt_get_addr_pci() - Read an address and handle PCI address translation * diff --git a/include/dm/read.h b/include/dm/read.h index 517795cc206..894bc698bb4 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -284,6 +284,19 @@ void *dev_remap_addr_index(const struct udevice *dev, int index); */ fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name); +/** + * dev_read_addr_name_ptr() - Get the reg property of a device as a pointer, + * indexed by name + * + * @dev: Device to read from + * @name: the 'reg' property can hold a list of pairs, with the + * 'reg-names' property providing named-based identification. @name + * indicates the value to search for in 'reg-names'. + * + * Return: pointer or NULL if not found + */ +void *dev_read_addr_name_ptr(const struct udevice *dev, const char *name); + /** * dev_read_addr_size_name() - Get the reg property of a device, indexed by name * @@ -298,6 +311,21 @@ fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name); fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name, fdt_size_t *size); +/** + * dev_read_addr_size_name_ptr() - Get the reg property of a device as a pointer, + * indexed by name + * + * @dev: Device to read from + * @name: the 'reg' property can hold a list of pairs, with the + * 'reg-names' property providing named-based identification. @name + * indicates the value to search for in 'reg-names'. + * @size: place to put size value (on success) + * + * Return: pointer or NULL if not found + */ +void *dev_read_addr_size_name_ptr(const struct udevice *dev, const char *name, + fdt_size_t *size); + /** * dev_remap_addr_name() - Get the reg property of a device, indexed by name, * as a memory-mapped I/O pointer @@ -980,6 +1008,12 @@ static inline fdt_addr_t dev_read_addr_name(const struct udevice *dev, return devfdt_get_addr_name(dev, name); } +static inline void *dev_read_addr_name_ptr(const struct udevice *dev, + const char *name) +{ + return devfdt_get_addr_name_ptr(dev, name); +} + static inline fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name, fdt_size_t *size) @@ -987,6 +1021,13 @@ static inline fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, return devfdt_get_addr_size_name(dev, name, size); } +static inline void *dev_read_addr_size_name_ptr(const struct udevice *dev, + const char *name, + fdt_size_t *size) +{ + return devfdt_get_addr_size_name_ptr(dev, name, size); +} + static inline fdt_addr_t dev_read_addr(const struct udevice *dev) { return devfdt_get_addr(dev); -- cgit v1.2.3 From 7f18fb8a272893eb32ce88cb780d51b4390b1899 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 27 Sep 2023 15:33:33 +0200 Subject: pinctrl: single: fix compile warnings with PHYS_64BIT on 32bit pinctrl-single uses fdt_addr_t and phys_addr_t inconsistently, but both are wrong to be passed to readb() etc., which expect a pointer or pointer-sized integer. Change the driver to use dev_read_addr_size_index_ptr(), so we consistently deal with void* (except for the sandbox case and single_get_pin_muxing()). Signed-off-by: Matthias Schiffer Reviewed-by: Simon Glass Add missing mapmem.h header: Signed-off-by: Simon Glass --- drivers/pinctrl/pinctrl-single.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index d80281fd3dd..d1db377c137 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -24,7 +25,7 @@ * @bits_per_mux: true if one register controls more than one pin */ struct single_pdata { - fdt_addr_t base; + void *base; int offset; u32 mask; u32 width; @@ -97,7 +98,7 @@ struct single_fdt_bits_cfg { #if (!IS_ENABLED(CONFIG_SANDBOX)) -static unsigned int single_read(struct udevice *dev, fdt_addr_t reg) +static unsigned int single_read(struct udevice *dev, void *reg) { struct single_pdata *pdata = dev_get_plat(dev); @@ -113,7 +114,7 @@ static unsigned int single_read(struct udevice *dev, fdt_addr_t reg) return readb(reg); } -static void single_write(struct udevice *dev, unsigned int val, fdt_addr_t reg) +static void single_write(struct udevice *dev, unsigned int val, void *reg) { struct single_pdata *pdata = dev_get_plat(dev); @@ -131,18 +132,18 @@ static void single_write(struct udevice *dev, unsigned int val, fdt_addr_t reg) #else /* CONFIG_SANDBOX */ -static unsigned int single_read(struct udevice *dev, fdt_addr_t reg) +static unsigned int single_read(struct udevice *dev, void *reg) { struct single_priv *priv = dev_get_priv(dev); - return priv->sandbox_regs[reg]; + return priv->sandbox_regs[map_to_sysmem(reg)]; } -static void single_write(struct udevice *dev, unsigned int val, fdt_addr_t reg) +static void single_write(struct udevice *dev, unsigned int val, void *reg) { struct single_priv *priv = dev_get_priv(dev); - priv->sandbox_regs[reg] = val; + priv->sandbox_regs[map_to_sysmem(reg)] = val; } #endif /* CONFIG_SANDBOX */ @@ -214,7 +215,8 @@ static int single_get_pin_muxing(struct udevice *dev, unsigned int pin, { struct single_pdata *pdata = dev_get_plat(dev); struct single_priv *priv = dev_get_priv(dev); - fdt_addr_t reg; + phys_addr_t phys_reg; + void *reg; const char *fname; unsigned int val; int offset, pin_shift = 0; @@ -226,13 +228,15 @@ static int single_get_pin_muxing(struct udevice *dev, unsigned int pin, reg = pdata->base + offset; val = single_read(dev, reg); + phys_reg = map_to_sysmem(reg); + if (pdata->bits_per_mux) pin_shift = pin % (pdata->width / priv->bits_per_pin) * priv->bits_per_pin; val &= (pdata->mask << pin_shift); fname = single_get_pin_function(dev, pin); - snprintf(buf, size, "%pa 0x%08x %s", ®, val, + snprintf(buf, size, "%pa 0x%08x %s", &phys_reg, val, fname ? fname : "UNCLAIMED"); return 0; } @@ -243,7 +247,7 @@ static int single_request(struct udevice *dev, int pin, int flags) struct single_pdata *pdata = dev_get_plat(dev); struct single_gpiofunc_range *frange = NULL; struct list_head *pos, *tmp; - phys_addr_t reg; + void *reg; int mux_bytes = 0; u32 data; @@ -321,7 +325,7 @@ static int single_configure_pins(struct udevice *dev, int stride = pdata->args_count + 1; int n, pin, count = size / sizeof(u32); struct single_func *func; - phys_addr_t reg; + void *reg; u32 offset, val, mux; /* If function mask is null, needn't enable it. */ @@ -379,7 +383,7 @@ static int single_configure_bits(struct udevice *dev, int n, pin, count = size / sizeof(struct single_fdt_bits_cfg); int npins_in_reg, pin_num_from_lsb; struct single_func *func; - phys_addr_t reg; + void *reg; u32 offset, val, mask, bit_pos, val_pos, mask_pos, submask; /* If function mask is null, needn't enable it. */ @@ -570,7 +574,7 @@ static int single_probe(struct udevice *dev) static int single_of_to_plat(struct udevice *dev) { - fdt_addr_t addr; + void *addr; fdt_size_t size; struct single_pdata *pdata = dev_get_plat(dev); int ret; @@ -591,8 +595,8 @@ static int single_of_to_plat(struct udevice *dev) return -EINVAL; } - addr = dev_read_addr_size_index(dev, 0, &size); - if (addr == FDT_ADDR_T_NONE) { + addr = dev_read_addr_size_index_ptr(dev, 0, &size); + if (!addr) { dev_err(dev, "failed to get base register address\n"); return -EINVAL; } -- cgit v1.2.3 From 5fecea171de3b66e9e3a199c588bf12c6b1d3084 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 27 Sep 2023 15:33:34 +0200 Subject: treewide: use dev_read_addr_*_ptr() where appropriate A follow-up to commit 842fb5de424e ("drivers: use devfdt_get_addr_size_index_ptr when cast to pointer") and commit 320a1938b6f7 ("drivers: use devfdt_get_addr_index_ptr when cast to pointer"). In addition to using the *_ptr variants of these functions where the address is cast to a pointer, this also changes devfdt_get_addr_*() to dev_read_addr_*() in a few places. Some variable and field types are changed from fdt_addr_t or phys_addr_t to void* where the cast was happening later. This patch fixes a number of compile warnings when building a 32bit U-Boot with CONFIG_PHYS_64BIT=y. In some places, it also fixes error handling where the return value of dev_read_addr() etc. was checked for NULL instead of FDT_ADDR_T_NONE. Signed-off-by: Matthias Schiffer Reviewed-by: Simon Glass --- arch/arm/mach-k3/sysfw-loader.c | 16 ++++++++-------- drivers/dma/ti/k3-udma.c | 5 ++--- drivers/gpio/tegra186_gpio.c | 4 ++-- drivers/mailbox/k3-sec-proxy.c | 18 +++++++++--------- drivers/phy/allwinner/phy-sun4i-usb.c | 12 ++++++------ drivers/phy/phy-bcm-sr-pcie.c | 4 ++-- drivers/ram/k3-am654-ddrss.c | 20 ++++++++++---------- drivers/ram/k3-ddrss/k3-ddrss.c | 23 ++++++++++------------- drivers/soc/ti/k3-navss-ringacc.c | 12 ++++++------ 9 files changed, 55 insertions(+), 59 deletions(-) (limited to 'drivers') diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c index 9be2d9eaea2..ef245fef9c4 100644 --- a/arch/arm/mach-k3/sysfw-loader.c +++ b/arch/arm/mach-k3/sysfw-loader.c @@ -321,7 +321,7 @@ exit: static void *k3_sysfw_get_spi_addr(void) { struct udevice *dev; - fdt_addr_t addr; + void *addr; int ret; unsigned int sf_bus = spl_spi_boot_bus(); @@ -329,11 +329,11 @@ static void *k3_sysfw_get_spi_addr(void) if (ret) return NULL; - addr = dev_read_addr_index(dev, 1); - if (addr == FDT_ADDR_T_NONE) + addr = dev_read_addr_index_ptr(dev, 1); + if (!addr) return NULL; - return (void *)(addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS); + return addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS; } static void k3_sysfw_spi_copy(u32 *dst, u32 *src, size_t len) @@ -349,18 +349,18 @@ static void k3_sysfw_spi_copy(u32 *dst, u32 *src, size_t len) static void *get_sysfw_hf_addr(void) { struct udevice *dev; - fdt_addr_t addr; + void *addr; int ret; ret = uclass_find_first_device(UCLASS_MTD, &dev); if (ret) return NULL; - addr = dev_read_addr_index(dev, 1); - if (addr == FDT_ADDR_T_NONE) + addr = dev_read_addr_index_ptr(dev, 1); + if (!addr) return NULL; - return (void *)(addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS); + return addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS; } #endif diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 4f2effd39a8..9273c70e9d9 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -1287,7 +1287,7 @@ static int udma_get_mmrs(struct udevice *dev) u32 cap2, cap3, cap4; int i; - ud->mmrs[MMR_GCFG] = (uint32_t *)devfdt_get_addr_name(dev, mmr_names[MMR_GCFG]); + ud->mmrs[MMR_GCFG] = dev_read_addr_name_ptr(dev, mmr_names[MMR_GCFG]); if (!ud->mmrs[MMR_GCFG]) return -EINVAL; @@ -1325,8 +1325,7 @@ static int udma_get_mmrs(struct udevice *dev) if (i == MMR_RCHANRT && ud->rchan_cnt == 0) continue; - ud->mmrs[i] = (uint32_t *)devfdt_get_addr_name(dev, - mmr_names[i]); + ud->mmrs[i] = dev_read_addr_name_ptr(dev, mmr_names[i]); if (!ud->mmrs[i]) return -EINVAL; } diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c index 82dcaf96312..94a20d143e1 100644 --- a/drivers/gpio/tegra186_gpio.c +++ b/drivers/gpio/tegra186_gpio.c @@ -176,8 +176,8 @@ static int tegra186_gpio_bind(struct udevice *parent) if (parent_plat) return 0; - regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio"); - if (regs == (uint32_t *)FDT_ADDR_T_NONE) + regs = dev_read_addr_name_ptr(parent, "gpio"); + if (!regs) return -EINVAL; for (port = 0; port < ctlr_data->port_count; port++) { diff --git a/drivers/mailbox/k3-sec-proxy.c b/drivers/mailbox/k3-sec-proxy.c index 27072610462..e0a18d8a97d 100644 --- a/drivers/mailbox/k3-sec-proxy.c +++ b/drivers/mailbox/k3-sec-proxy.c @@ -84,9 +84,9 @@ struct k3_sec_proxy_mbox { struct mbox_chan chan; struct k3_sec_proxy_desc *desc; struct k3_sec_proxy_thread *chans; - phys_addr_t target_data; - phys_addr_t scfg; - phys_addr_t rt; + void *target_data; + void *scfg; + void *rt; }; static inline u32 sp_readl(void __iomem *addr, unsigned int offset) @@ -319,20 +319,20 @@ static int k3_sec_proxy_of_to_priv(struct udevice *dev, return -ENODEV; } - spm->target_data = devfdt_get_addr_name(dev, "target_data"); - if (spm->target_data == FDT_ADDR_T_NONE) { + spm->target_data = dev_read_addr_name_ptr(dev, "target_data"); + if (!spm->target_data) { dev_err(dev, "No reg property for target data base\n"); return -EINVAL; } - spm->scfg = devfdt_get_addr_name(dev, "scfg"); - if (spm->scfg == FDT_ADDR_T_NONE) { + spm->scfg = dev_read_addr_name_ptr(dev, "scfg"); + if (!spm->scfg) { dev_err(dev, "No reg property for Secure Cfg base\n"); return -EINVAL; } - spm->rt = devfdt_get_addr_name(dev, "rt"); - if (spm->rt == FDT_ADDR_T_NONE) { + spm->rt = dev_read_addr_name_ptr(dev, "rt"); + if (!spm->rt) { dev_err(dev, "No reg property for Real Time Cfg base\n"); return -EINVAL; } diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 77dffcad884..6624e9134f4 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -472,9 +472,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev) if (!data->cfg) return -EINVAL; - data->base = (void __iomem *)devfdt_get_addr_name(dev, "phy_ctrl"); - if (IS_ERR(data->base)) - return PTR_ERR(data->base); + data->base = (void __iomem *)dev_read_addr_name_ptr(dev, "phy_ctrl"); + if (!data->base) + return -EINVAL; device_get_supply_regulator(dev, "usb0_vbus_power-supply", &data->vbus_power_supply); @@ -555,9 +555,9 @@ static int sun4i_usb_phy_probe(struct udevice *dev) if (i || data->cfg->phy0_dual_route) { snprintf(name, sizeof(name), "pmu%d", i); - phy->pmu = (void __iomem *)devfdt_get_addr_name(dev, name); - if (IS_ERR(phy->pmu)) - return PTR_ERR(phy->pmu); + phy->pmu = (void __iomem *)dev_read_addr_name_ptr(dev, name); + if (!phy->pmu) + return -EINVAL; } phy->id = i; diff --git a/drivers/phy/phy-bcm-sr-pcie.c b/drivers/phy/phy-bcm-sr-pcie.c index f0e795333b9..cf33bab3707 100644 --- a/drivers/phy/phy-bcm-sr-pcie.c +++ b/drivers/phy/phy-bcm-sr-pcie.c @@ -143,8 +143,8 @@ static int sr_pcie_phy_probe(struct udevice *dev) core->dev = dev; - core->base = (void __iomem *)devfdt_get_addr_name(dev, "reg_base"); - core->cdru = (void __iomem *)devfdt_get_addr_name(dev, "cdru_base"); + core->base = (void __iomem *)dev_read_addr_name_ptr(dev, "reg_base"); + core->cdru = (void __iomem *)dev_read_addr_name_ptr(dev, "cdru_base"); debug("ip base %p\n", core->base); debug("cdru base %p\n", core->cdru); diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c index b8338f84a3d..4a8a6a90bfc 100644 --- a/drivers/ram/k3-am654-ddrss.c +++ b/drivers/ram/k3-am654-ddrss.c @@ -903,7 +903,7 @@ static int am654_ddrss_power_on(struct am654_ddrss_desc *ddrss) static int am654_ddrss_ofdata_to_priv(struct udevice *dev) { struct am654_ddrss_desc *ddrss = dev_get_priv(dev); - phys_addr_t reg; + void *reg; int ret; debug("%s(dev=%p)\n", __func__, dev); @@ -926,26 +926,26 @@ static int am654_ddrss_ofdata_to_priv(struct udevice *dev) return ret; } - reg = devfdt_get_addr_name(dev, "ss"); - if (reg == FDT_ADDR_T_NONE) { + reg = dev_read_addr_name_ptr(dev, "ss"); + if (!reg) { dev_err(dev, "No reg property for DDRSS wrapper logic\n"); return -EINVAL; } - ddrss->ddrss_ss_cfg = (void *)reg; + ddrss->ddrss_ss_cfg = reg; - reg = devfdt_get_addr_name(dev, "ctl"); - if (reg == FDT_ADDR_T_NONE) { + reg = dev_read_addr_name_ptr(dev, "ctl"); + if (!reg) { dev_err(dev, "No reg property for Controller region\n"); return -EINVAL; } - ddrss->ddrss_ctl_cfg = (void *)reg; + ddrss->ddrss_ctl_cfg = reg; - reg = devfdt_get_addr_name(dev, "phy"); - if (reg == FDT_ADDR_T_NONE) { + reg = dev_read_addr_name_ptr(dev, "phy"); + if (!reg) { dev_err(dev, "No reg property for PHY region\n"); return -EINVAL; } - ddrss->ddrss_phy_cfg = (void *)reg; + ddrss->ddrss_phy_cfg = reg; ret = dev_read_u32_array(dev, "ti,ss-reg", (u32 *)&ddrss->params.ss_reg, diff --git a/drivers/ram/k3-ddrss/k3-ddrss.c b/drivers/ram/k3-ddrss/k3-ddrss.c index b54557f02cc..5b6089e8526 100644 --- a/drivers/ram/k3-ddrss/k3-ddrss.c +++ b/drivers/ram/k3-ddrss/k3-ddrss.c @@ -331,32 +331,29 @@ static int k3_ddrss_ofdata_to_priv(struct udevice *dev) { struct k3_ddrss_desc *ddrss = dev_get_priv(dev); struct k3_ddrss_data *ddrss_data = (struct k3_ddrss_data *)dev_get_driver_data(dev); - phys_addr_t reg; + void *reg; int ret; debug("%s(dev=%p)\n", __func__, dev); - reg = dev_read_addr_name(dev, "cfg"); - if (reg == FDT_ADDR_T_NONE) { + reg = dev_read_addr_name_ptr(dev, "cfg"); + if (!reg) { dev_err(dev, "No reg property for DDRSS wrapper logic\n"); return -EINVAL; } - ddrss->ddrss_ctl_cfg = (void *)reg; + ddrss->ddrss_ctl_cfg = reg; - reg = dev_read_addr_name(dev, "ctrl_mmr_lp4"); - if (reg == FDT_ADDR_T_NONE) { + reg = dev_read_addr_name_ptr(dev, "ctrl_mmr_lp4"); + if (!reg) { dev_err(dev, "No reg property for CTRL MMR\n"); return -EINVAL; } - ddrss->ddrss_ctrl_mmr = (void *)reg; + ddrss->ddrss_ctrl_mmr = reg; - reg = dev_read_addr_name(dev, "ss_cfg"); - if (reg == FDT_ADDR_T_NONE) { + reg = dev_read_addr_name_ptr(dev, "ss_cfg"); + if (!reg) dev_dbg(dev, "No reg property for SS Config region, but this is optional so continuing.\n"); - ddrss->ddrss_ss_cfg = NULL; - } else { - ddrss->ddrss_ss_cfg = (void *)reg; - } + ddrss->ddrss_ss_cfg = reg; ret = power_domain_get_by_index(dev, &ddrss->ddrcfg_pwrdmn, 0); if (ret) { diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c index 9881bffc8e1..e02889649b2 100644 --- a/drivers/soc/ti/k3-navss-ringacc.c +++ b/drivers/soc/ti/k3-navss-ringacc.c @@ -987,10 +987,10 @@ static int k3_nav_ringacc_init(struct udevice *dev, struct k3_nav_ringacc *ringa if (!base_cfg) return -EINVAL; - base_rt = (uint32_t *)devfdt_get_addr_name(dev, "rt"); + base_rt = dev_read_addr_name_ptr(dev, "rt"); pr_debug("rt %p\n", base_rt); - if (IS_ERR(base_rt)) - return PTR_ERR(base_rt); + if (!base_rt) + return -EINVAL; ringacc->rings = devm_kzalloc(dev, sizeof(*ringacc->rings) * @@ -1045,9 +1045,9 @@ struct k3_nav_ringacc *k3_ringacc_dmarings_init(struct udevice *dev, ringacc->tisci = data->tisci; ringacc->tisci_dev_id = data->tisci_dev_id; - base_rt = (uint32_t *)devfdt_get_addr_name(dev, "ringrt"); - if (IS_ERR(base_rt)) - return base_rt; + base_rt = dev_read_addr_name_ptr(dev, "ringrt"); + if (!base_rt) + return ERR_PTR(-EINVAL); ringacc->rings = devm_kzalloc(dev, sizeof(*ringacc->rings) * -- cgit v1.2.3