dt_for_each_device_node( dt_host, np )
{
unsigned int naddr;
- u64 addr, size;
+ paddr_t addr, size;
naddr = dt_number_of_address(np);
for ( i = 0; i < naddr; i++ )
{
- res = dt_device_get_address(np, i, &addr, &size);
+ res = dt_device_get_paddr(np, i, &addr, &size);
if ( res )
{
printk(XENLOG_ERR "Unable to retrieve address %u for %s\n",
unsigned int naddr;
unsigned int i;
int res;
- u64 addr, size;
+ paddr_t addr, size;
bool own_device = !dt_device_for_passthrough(dev);
/*
* We want to avoid mapping the MMIO in dom0 for the following cases:
/* Give permission and map MMIOs */
for ( i = 0; i < naddr; i++ )
{
- res = dt_device_get_address(dev, i, &addr, &size);
+ res = dt_device_get_paddr(dev, i, &addr, &size);
if ( res )
{
printk(XENLOG_ERR "Unable to retrieve address %u for %s\n",
if ( res )
{
printk(XENLOG_ERR "Unable to permit to dom%d access to"
- " 0x%"PRIx64" - 0x%"PRIx64"\n",
+ " 0x%"PRIpaddr" - 0x%"PRIpaddr"\n",
kinfo->d->domain_id,
mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - 1);
return res;
continue;
/* Get register frame resource from DT. */
- if ( dt_device_get_address(v2m, 0, &addr, &size) )
+ if ( dt_device_get_paddr(v2m, 0, &addr, &size) )
panic("GICv2: Cannot find a valid v2m frame address\n");
/*
paddr_t vsize;
const struct dt_device_node *node = gicv2_info.node;
- res = dt_device_get_address(node, 0, &dbase, NULL);
+ res = dt_device_get_paddr(node, 0, &dbase, NULL);
if ( res )
panic("GICv2: Cannot find a valid address for the distributor\n");
- res = dt_device_get_address(node, 1, &cbase, &csize);
+ res = dt_device_get_paddr(node, 1, &cbase, &csize);
if ( res )
panic("GICv2: Cannot find a valid address for the CPU\n");
- res = dt_device_get_address(node, 2, &hbase, NULL);
+ res = dt_device_get_paddr(node, 2, &hbase, NULL);
if ( res )
panic("GICv2: Cannot find a valid address for the hypervisor\n");
- res = dt_device_get_address(node, 3, &vbase, &vsize);
+ res = dt_device_get_paddr(node, 3, &vbase, &vsize);
if ( res )
panic("GICv2: Cannot find a valid address for the virtual CPU\n");
*/
dt_for_each_child_node(node, its)
{
- uint64_t addr, size;
+ paddr_t addr, size;
if ( !dt_device_is_compatible(its, "arm,gic-v3-its") )
continue;
- if ( dt_device_get_address(its, 0, &addr, &size) )
+ if ( dt_device_get_paddr(its, 0, &addr, &size) )
panic("GICv3: Cannot find a valid ITS frame address\n");
add_to_host_its_list(addr, size, its);
int res, i;
const struct dt_device_node *node = gicv3_info.node;
- res = dt_device_get_address(node, 0, &dbase, NULL);
+ res = dt_device_get_paddr(node, 0, &dbase, NULL);
if ( res )
panic("GICv3: Cannot find a valid distributor address\n");
for ( i = 0; i < gicv3.rdist_count; i++ )
{
- uint64_t rdist_base, rdist_size;
+ paddr_t rdist_base, rdist_size;
- res = dt_device_get_address(node, 1 + i, &rdist_base, &rdist_size);
+ res = dt_device_get_paddr(node, 1 + i, &rdist_base, &rdist_size);
if ( res )
panic("GICv3: No rdist base found for region %d\n", i);
* For GICv3 supporting GICv2, GICC and GICV base address will be
* provided.
*/
- res = dt_device_get_address(node, 1 + gicv3.rdist_count,
+ res = dt_device_get_paddr(node, 1 + gicv3.rdist_count,
&cbase, &csize);
if ( !res )
- dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
+ dt_device_get_paddr(node, 1 + gicv3.rdist_count + 2,
&vbase, &vsize);
}
cfg_reg_idx = 0;
/* Parse our PCI ecam register address */
- err = dt_device_get_address(dev, cfg_reg_idx, &addr, &size);
+ err = dt_device_get_paddr(dev, cfg_reg_idx, &addr, &size);
if ( err )
goto err_exit;
for ( i = 0; i < dt_number_of_address(dev); i++ )
{
- uint64_t addr, size;
+ paddr_t addr, size;
int err;
- err = dt_device_get_address(dev, i, &addr, &size);
+ err = dt_device_get_paddr(dev, i, &addr, &size);
if ( err )
{
printk(XENLOG_ERR
if ( !node )
return NULL;
- ret = dt_device_get_address(node, 0, &start, &len);
+ ret = dt_device_get_paddr(node, 0, &start, &len);
if ( ret )
{
printk("Cannot read watchdog register address\n");
u32 *reg_base)
{
const struct dt_device_node *node;
- u64 reg_base_64;
+ paddr_t reg_base_paddr;
int rc;
node = dt_find_compatible_node(NULL, NULL, compat_str);
return -ENOENT;
}
- rc = dt_device_get_address(node, 0, ®_base_64, NULL);
+ rc = dt_device_get_paddr(node, 0, ®_base_paddr, NULL);
if ( rc )
{
dprintk(XENLOG_ERR, "%s: missing \"reg\" prop\n", __func__);
*dn = node;
if ( reg_base )
- *reg_base = reg_base_64;
+ *reg_base = reg_base_paddr;
return 0;
}
void __iomem *mct;
int rc;
struct dt_device_node *node;
- u64 mct_base_addr;
- u64 size;
+ paddr_t mct_base_addr;
+ paddr_t size;
node = dt_find_compatible_node(NULL, NULL, "samsung,exynos4210-mct");
if ( !node )
return -ENXIO;
}
- rc = dt_device_get_address(node, 0, &mct_base_addr, &size);
+ rc = dt_device_get_paddr(node, 0, &mct_base_addr, &size);
if ( rc )
{
dprintk(XENLOG_ERR, "Error in \"samsung,exynos4210-mct\"\n");
return -ENXIO;
}
- dprintk(XENLOG_INFO, "mct_base_addr: %016llx size: %016llx\n",
+ dprintk(XENLOG_INFO, "mct_base_addr: 0x%"PRIpaddr" size: 0x%"PRIpaddr"\n",
mct_base_addr, size);
mct = ioremap_nocache(mct_base_addr, size);
struct dt_device_node *node;
void __iomem *sysram;
char *compatible;
- u64 sysram_addr;
- u64 size;
- u64 sysram_offset;
+ paddr_t sysram_addr;
+ paddr_t size;
+ paddr_t sysram_offset;
int rc;
node = dt_find_compatible_node(NULL, NULL, "samsung,secure-firmware");
return -ENXIO;
}
- rc = dt_device_get_address(node, 0, &sysram_addr, &size);
+ rc = dt_device_get_paddr(node, 0, &sysram_addr, &size);
if ( rc )
{
dprintk(XENLOG_ERR, "Error in %s\n", compatible);
return -ENXIO;
}
- dprintk(XENLOG_INFO, "sysram_addr: %016llx size: %016llx offset: %016llx\n",
+ dprintk(XENLOG_INFO,"sysram_addr: 0x%"PRIpaddr" size: 0x%"PRIpaddr"offset: 0x%"PRIpaddr"\n",
sysram_addr, size, sysram_offset);
sysram = ioremap_nocache(sysram_addr, size);
return 0;
}
-static int exynos5_get_pmu_baseandsize(u64 *power_base_addr, u64 *size)
+static int exynos5_get_pmu_baseandsize(paddr_t *power_base_addr, paddr_t *size)
{
struct dt_device_node *node;
int rc;
return -ENXIO;
}
- rc = dt_device_get_address(node, 0, power_base_addr, size);
+ rc = dt_device_get_paddr(node, 0, power_base_addr, size);
if ( rc )
{
dprintk(XENLOG_ERR, "Error in \"samsung,exynos5XXX-pmu\"\n");
return -ENXIO;
}
- dprintk(XENLOG_DEBUG, "power_base_addr: %016llx size: %016llx\n",
+ dprintk(XENLOG_DEBUG, "power_base_addr: 0x%"PRIpaddr" size: 0x%"PRIpaddr"\n",
*power_base_addr, *size);
return 0;
static int exynos5_cpu_up(int cpu)
{
- u64 power_base_addr;
- u64 size;
+ paddr_t power_base_addr;
+ paddr_t size;
void __iomem *power;
int rc;
static void exynos5_reset(void)
{
- u64 power_base_addr;
- u64 size;
+ paddr_t power_base_addr;
+ paddr_t size;
void __iomem *pmu;
int rc;
return NULL;
}
- ret = dt_device_get_address(node, 0, &wdt_start, &wdt_len);
+ ret = dt_device_get_paddr(node, 0, &wdt_start, &wdt_len);
if ( ret )
{
dprintk(XENLOG_ERR, "Cannot read watchdog register address\n");
if ( !node )
panic("%s: Can not find interrupt controller node\n", __func__);
- res = dt_device_get_address(node, 0, &dbase, NULL);
+ res = dt_device_get_paddr(node, 0, &dbase, NULL);
if ( res )
panic("%s: Cannot find a valid address for the distributor\n", __func__);
return 0;
}
+int dt_device_get_paddr(const struct dt_device_node *dev, unsigned int index,
+ paddr_t *addr, paddr_t *size)
+{
+ uint64_t dt_addr, dt_size;
+ int ret;
+
+ ret = dt_device_get_address(dev, index, &dt_addr, &dt_size);
+ if ( ret )
+ return ret;
+
+ if ( !addr )
+ return -EINVAL;
+
+ if ( dt_addr != (paddr_t)dt_addr )
+ {
+ printk("Error: Physical address 0x%"PRIx64" for node=%s is greater than max width (%zu bytes) supported\n",
+ dt_addr, dev->name, sizeof(paddr_t));
+ return -ERANGE;
+ }
+
+ *addr = dt_addr;
+
+ if ( size )
+ {
+ if ( dt_size != (paddr_t)dt_size )
+ {
+ printk("Error: Physical size 0x%"PRIx64" for node=%s is greater than max width (%zu bytes) supported\n",
+ dt_size, dev->name, sizeof(paddr_t));
+ return -ERANGE;
+ }
+
+ *size = dt_size;
+ }
+
+ return ret;
+}
int dt_for_each_range(const struct dt_device_node *dev,
int (*cb)(const struct dt_device_node *,
const char *config = data;
struct cuart *uart;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart = &cuart_com;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("cadence: Unable to retrieve the base"
const char *config = data;
struct exynos4210_uart *uart;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart->parity = PARITY_NONE;
uart->stop_bits = 1;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("exynos4210: Unable to retrieve the base"
const char *config = data;
struct imx_lpuart *uart;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart->parity = 0;
uart->stop_bits = 1;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("imx8-lpuart: Unable to retrieve the base"
const char *config = data;
struct meson_uart *uart;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart = &meson_com;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("meson: Unable to retrieve the base address of the UART\n");
const char *config = data;
struct mvebu3700_uart *uart;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart = &mvebu3700_com;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("mvebu3700: Unable to retrieve the base address of the UART\n");
struct omap_uart *uart;
u32 clkspec;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart->parity = UART_PARITY_NONE;
uart->stop_bits = 1;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("omap-uart: Unable to retrieve the base"
.vuart_info = pl011_vuart,
};
-static int __init pl011_uart_init(int irq, u64 addr, u64 size, bool sbsa)
+static int __init pl011_uart_init(int irq, paddr_t addr, paddr_t size, bool sbsa)
{
struct pl011 *uart;
{
const char *config = data;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
{
printk("WARNING: UART configuration is not supported\n");
}
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("pl011: Unable to retrieve the base"
const char *config = data;
struct scif_uart *uart;
int res;
- u64 addr, size;
+ paddr_t addr, size;
if ( strcmp(config, "") )
printk("WARNING: UART configuration is not supported\n");
uart = &scif_com;
- res = dt_device_get_address(dev, 0, &addr, &size);
+ res = dt_device_get_paddr(dev, 0, &addr, &size);
if ( res )
{
printk("scif-uart: Unable to retrieve the base"
static __init bool ipmmu_stage2_supported(void)
{
struct dt_device_node *np;
- uint64_t addr, size;
+ paddr_t addr, size;
void __iomem *base;
uint32_t product, cut;
bool stage2_supported = false;
return false;
}
- if ( dt_device_get_address(np, 0, &addr, &size) )
+ if ( dt_device_get_paddr(np, 0, &addr, &size) )
{
printk(XENLOG_ERR "ipmmu: Failed to get PRR MMIO\n");
return false;
{
const struct dt_device_match *match;
struct ipmmu_vmsa_device *mmu;
- uint64_t addr, size;
+ paddr_t addr, size;
uint32_t reg;
int irq, ret;
bitmap_zero(mmu->ctx, IPMMU_CTX_MAX);
/* Map I/O memory and request IRQ. */
- ret = dt_device_get_address(node, 0, &addr, &size);
+ ret = dt_device_get_paddr(node, 0, &addr, &size);
if ( ret )
{
dev_err(&node->dev, "Failed to get MMIO\n");
}
/* Base address */
- ret = dt_device_get_address(np, 0, &ioaddr, &iosize);
+ ret = dt_device_get_paddr(np, 0, &ioaddr, &iosize);
if (ret)
goto out_free_smmu;
/* Xen: Helpers to get device MMIO and IRQs */
struct resource
{
- u64 addr;
- u64 size;
+ paddr_t addr;
+ paddr_t size;
unsigned int type;
};
switch (type) {
case IORESOURCE_MEM:
- ret = dt_device_get_address(pdev, num, &res.addr, &res.size);
+ ret = dt_device_get_paddr(pdev, num, &res.addr, &res.size);
return ((ret) ? NULL : &res);
ptr = ioremap_nocache(res->addr, res->size);
if (!ptr) {
dev_err(dev,
- "ioremap failed (addr 0x%"PRIx64" size 0x%"PRIx64")\n",
+ "ioremap failed (addr 0x%"PRIpaddr" size 0x%"PRIpaddr")\n",
res->addr, res->size);
return ERR_PTR(-ENOMEM);
}
*/
const struct dt_device_node *dt_get_parent(const struct dt_device_node *node);
+/**
+ * dt_device_get_paddr - Resolve an address for a device
+ * @device: the device whose address is to be resolved
+ * @index: index of the address to resolve
+ * @addr: address filled by this function
+ * @size: size filled by this function
+ *
+ * This function resolves an address, walking the tree, for a given
+ * device-tree node. It returns 0 on success.
+ */
+int dt_device_get_paddr(const struct dt_device_node *dev, unsigned int index,
+ paddr_t *addr, paddr_t *size);
+
/**
* dt_device_get_address - Resolve an address for a device
* @device: the device whose address is to be resolved