aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini2023-10-14 10:50:20 -0400
committerTom Rini2023-10-14 10:50:20 -0400
commit3c3f1626919cd93cbe6c56e3849937de5be18dbb (patch)
tree97483e691431094e5a668fcc9ac1cc96032ef543 /drivers
parent25edd247a84a31298c22a34ec5cf2851cbf61f70 (diff)
parent74aae507bc4d5726308c191d3191d9cd624ba0d2 (diff)
Merge tag 'dm-pull-13oct23' of https://source.denx.de/u-boot/custodians/u-boot-dm
improvements with dev_read_addr_..._ptr() scan all entries in multi-device boot_targets EFI empty-capsule support
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/fdtaddr.c25
-rw-r--r--drivers/core/read.c21
-rw-r--r--drivers/dma/ti/k3-udma.c5
-rw-r--r--drivers/gpio/tegra186_gpio.c4
-rw-r--r--drivers/mailbox/k3-sec-proxy.c18
-rw-r--r--drivers/phy/allwinner/phy-sun4i-usb.c12
-rw-r--r--drivers/phy/phy-bcm-sr-pcie.c4
-rw-r--r--drivers/pinctrl/pinctrl-single.c34
-rw-r--r--drivers/ram/k3-am654-ddrss.c20
-rw-r--r--drivers/ram/k3-ddrss/k3-ddrss.c23
-rw-r--r--drivers/soc/ti/k3-navss-ringacc.c12
11 files changed, 110 insertions, 68 deletions
diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
index b79d138c419..8e774d49ce6 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
@@ -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)
{
@@ -162,7 +172,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
@@ -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/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/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 <common.h>
+#include <mapmem.h>
#include <dm.h>
#include <dm/device_compat.h>
#include <dm/devres.h>
@@ -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", &reg, 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;
}
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) *