soc: ixp4xx: npe: Pass addresses as resources
Instead of using hardcoded base addresses implicitly obtained through <linux/io.h>, pass the physical base for the three NPE blocks as memory resources and remap these in the driver. Drop the memory request region business, this will anyways be done by devm_* remapping functions. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
@@ -155,16 +155,10 @@ static struct {
|
||||
static struct npe npe_tab[NPE_COUNT] = {
|
||||
{
|
||||
.id = 0,
|
||||
.regs = (struct npe_regs __iomem *)IXP4XX_NPEA_BASE_VIRT,
|
||||
.regs_phys = IXP4XX_NPEA_BASE_PHYS,
|
||||
}, {
|
||||
.id = 1,
|
||||
.regs = (struct npe_regs __iomem *)IXP4XX_NPEB_BASE_VIRT,
|
||||
.regs_phys = IXP4XX_NPEB_BASE_PHYS,
|
||||
}, {
|
||||
.id = 2,
|
||||
.regs = (struct npe_regs __iomem *)IXP4XX_NPEC_BASE_VIRT,
|
||||
.regs_phys = IXP4XX_NPEC_BASE_PHYS,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -687,23 +681,34 @@ void npe_release(struct npe *npe)
|
||||
static int ixp4xx_npe_probe(struct platform_device *pdev)
|
||||
{
|
||||
int i, found = 0;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct resource *res;
|
||||
|
||||
for (i = 0; i < NPE_COUNT; i++) {
|
||||
struct npe *npe = &npe_tab[i];
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, i);
|
||||
if (!res)
|
||||
return -ENODEV;
|
||||
|
||||
if (!(ixp4xx_read_feature_bits() &
|
||||
(IXP4XX_FEATURE_RESET_NPEA << i)))
|
||||
(IXP4XX_FEATURE_RESET_NPEA << i))) {
|
||||
dev_info(dev, "NPE%d at 0x%08x-0x%08x not available\n",
|
||||
i, res->start, res->end);
|
||||
continue; /* NPE already disabled or not present */
|
||||
if (!(npe->mem_res = request_mem_region(npe->regs_phys,
|
||||
REGS_SIZE,
|
||||
npe_name(npe)))) {
|
||||
print_npe(KERN_ERR, npe,
|
||||
"failed to request memory region\n");
|
||||
}
|
||||
npe->regs = devm_ioremap_resource(dev, res);
|
||||
if (!npe->regs)
|
||||
return -ENOMEM;
|
||||
|
||||
if (npe_reset(npe)) {
|
||||
dev_info(dev, "NPE%d at 0x%08x-0x%08x does not reset\n",
|
||||
i, res->start, res->end);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (npe_reset(npe))
|
||||
continue;
|
||||
npe->valid = 1;
|
||||
dev_info(dev, "NPE%d at 0x%08x-0x%08x registered\n",
|
||||
i, res->start, res->end);
|
||||
found++;
|
||||
}
|
||||
|
||||
@@ -717,9 +722,8 @@ static int ixp4xx_npe_remove(struct platform_device *pdev)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NPE_COUNT; i++)
|
||||
if (npe_tab[i].mem_res) {
|
||||
if (npe_tab[i].regs) {
|
||||
npe_reset(&npe_tab[i]);
|
||||
release_resource(npe_tab[i].mem_res);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user