]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
soc: ixp4xx: npe: Pass addresses as resources
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 10 Feb 2019 18:35:08 +0000 (19:35 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 23 Apr 2019 14:02:15 +0000 (16:02 +0200)
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>
arch/arm/mach-ixp4xx/common.c
arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
drivers/soc/ixp4xx/ixp4xx-npe.c
include/linux/soc/ixp4xx/npe.h

index cdcd6d6b6d3db64ee88f80ec158ee6ae2897da59..07c3cb312a9291f2b29bc4bbf167cef7d287bfa7 100644 (file)
@@ -150,9 +150,30 @@ static struct platform_device ixp4xx_udc_device = {
        },
 };
 
+static struct resource ixp4xx_npe_resources[] = {
+       {
+               .start = IXP4XX_NPEA_BASE_PHYS,
+               .end = IXP4XX_NPEA_BASE_PHYS + 0xfff,
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .start = IXP4XX_NPEB_BASE_PHYS,
+               .end = IXP4XX_NPEB_BASE_PHYS + 0xfff,
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .start = IXP4XX_NPEC_BASE_PHYS,
+               .end = IXP4XX_NPEC_BASE_PHYS + 0xfff,
+               .flags = IORESOURCE_MEM,
+       },
+
+};
+
 static struct platform_device ixp4xx_npe_device = {
        .name           = "ixp4xx-npe",
        .id             = -1,
+       .num_resources  = ARRAY_SIZE(ixp4xx_npe_resources),
+       .resource       = ixp4xx_npe_resources,
 };
 
 static struct platform_device ixp4xx_qmgr_device = {
index 459abe2eb4b5fb3c3f768a198798ae2cd1cd04d5..f5d5b258c3f7592230653770f0e429d07e7842db 100644 (file)
 #define IXP4XX_INTC_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0x3000)
 #define IXP4XX_GPIO_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0x4000)
 #define IXP4XX_TIMER_BASE_VIRT         (IXP4XX_PERIPHERAL_BASE_VIRT + 0x5000)
-#define IXP4XX_NPEA_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0x6000)
-#define IXP4XX_NPEB_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0x7000)
-#define IXP4XX_NPEC_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0x8000)
 #define IXP4XX_EthB_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0x9000)
 #define IXP4XX_EthC_BASE_VIRT          (IXP4XX_PERIPHERAL_BASE_VIRT + 0xA000)
 #define IXP4XX_USB_BASE_VIRT           (IXP4XX_PERIPHERAL_BASE_VIRT + 0xB000)
index e3294457b5defb5bf15c4231e1ce93e3c93fa587..d2dd916816d46c79ec782a46880b6643f6005e2e 100644 (file)
@@ -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");
-                       continue;
                }
+               npe->regs = devm_ioremap_resource(dev, res);
+               if (!npe->regs)
+                       return -ENOMEM;
 
-               if (npe_reset(npe))
+               if (npe_reset(npe)) {
+                       dev_info(dev, "NPE%d at 0x%08x-0x%08x does not reset\n",
+                                i, res->start, res->end);
                        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;
index 3a980845e5571aea09c8752237a0f1c283d37469..2a91f465d4568bdfc595e722a9c9788128920ecf 100644 (file)
@@ -16,9 +16,7 @@ struct npe_regs {
 };
 
 struct npe {
-       struct resource *mem_res;
        struct npe_regs __iomem *regs;
-       u32 regs_phys;
        int id;
        int valid;
 };