Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+42 -22
+21
arch/arm/mach-ixp4xx/common.c
··· 150 150 }, 151 151 }; 152 152 153 + static struct resource ixp4xx_npe_resources[] = { 154 + { 155 + .start = IXP4XX_NPEA_BASE_PHYS, 156 + .end = IXP4XX_NPEA_BASE_PHYS + 0xfff, 157 + .flags = IORESOURCE_MEM, 158 + }, 159 + { 160 + .start = IXP4XX_NPEB_BASE_PHYS, 161 + .end = IXP4XX_NPEB_BASE_PHYS + 0xfff, 162 + .flags = IORESOURCE_MEM, 163 + }, 164 + { 165 + .start = IXP4XX_NPEC_BASE_PHYS, 166 + .end = IXP4XX_NPEC_BASE_PHYS + 0xfff, 167 + .flags = IORESOURCE_MEM, 168 + }, 169 + 170 + }; 171 + 153 172 static struct platform_device ixp4xx_npe_device = { 154 173 .name = "ixp4xx-npe", 155 174 .id = -1, 175 + .num_resources = ARRAY_SIZE(ixp4xx_npe_resources), 176 + .resource = ixp4xx_npe_resources, 156 177 }; 157 178 158 179 static struct platform_device ixp4xx_qmgr_device = {
-3
arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
··· 132 132 #define IXP4XX_INTC_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x3000) 133 133 #define IXP4XX_GPIO_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x4000) 134 134 #define IXP4XX_TIMER_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x5000) 135 - #define IXP4XX_NPEA_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x6000) 136 - #define IXP4XX_NPEB_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x7000) 137 - #define IXP4XX_NPEC_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x8000) 138 135 #define IXP4XX_EthB_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0x9000) 139 136 #define IXP4XX_EthC_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0xA000) 140 137 #define IXP4XX_USB_BASE_VIRT (IXP4XX_PERIPHERAL_BASE_VIRT + 0xB000)
+21 -17
drivers/soc/ixp4xx/ixp4xx-npe.c
··· 155 155 static struct npe npe_tab[NPE_COUNT] = { 156 156 { 157 157 .id = 0, 158 - .regs = (struct npe_regs __iomem *)IXP4XX_NPEA_BASE_VIRT, 159 - .regs_phys = IXP4XX_NPEA_BASE_PHYS, 160 158 }, { 161 159 .id = 1, 162 - .regs = (struct npe_regs __iomem *)IXP4XX_NPEB_BASE_VIRT, 163 - .regs_phys = IXP4XX_NPEB_BASE_PHYS, 164 160 }, { 165 161 .id = 2, 166 - .regs = (struct npe_regs __iomem *)IXP4XX_NPEC_BASE_VIRT, 167 - .regs_phys = IXP4XX_NPEC_BASE_PHYS, 168 162 } 169 163 }; 170 164 ··· 681 687 static int ixp4xx_npe_probe(struct platform_device *pdev) 682 688 { 683 689 int i, found = 0; 690 + struct device *dev = &pdev->dev; 691 + struct resource *res; 684 692 685 693 for (i = 0; i < NPE_COUNT; i++) { 686 694 struct npe *npe = &npe_tab[i]; 695 + 696 + res = platform_get_resource(pdev, IORESOURCE_MEM, i); 697 + if (!res) 698 + return -ENODEV; 699 + 687 700 if (!(ixp4xx_read_feature_bits() & 688 - (IXP4XX_FEATURE_RESET_NPEA << i))) 701 + (IXP4XX_FEATURE_RESET_NPEA << i))) { 702 + dev_info(dev, "NPE%d at 0x%08x-0x%08x not available\n", 703 + i, res->start, res->end); 689 704 continue; /* NPE already disabled or not present */ 690 - if (!(npe->mem_res = request_mem_region(npe->regs_phys, 691 - REGS_SIZE, 692 - npe_name(npe)))) { 693 - print_npe(KERN_ERR, npe, 694 - "failed to request memory region\n"); 705 + } 706 + npe->regs = devm_ioremap_resource(dev, res); 707 + if (!npe->regs) 708 + return -ENOMEM; 709 + 710 + if (npe_reset(npe)) { 711 + dev_info(dev, "NPE%d at 0x%08x-0x%08x does not reset\n", 712 + i, res->start, res->end); 695 713 continue; 696 714 } 697 - 698 - if (npe_reset(npe)) 699 - continue; 700 715 npe->valid = 1; 716 + dev_info(dev, "NPE%d at 0x%08x-0x%08x registered\n", 717 + i, res->start, res->end); 701 718 found++; 702 719 } 703 720 ··· 722 717 int i; 723 718 724 719 for (i = 0; i < NPE_COUNT; i++) 725 - if (npe_tab[i].mem_res) { 720 + if (npe_tab[i].regs) { 726 721 npe_reset(&npe_tab[i]); 727 - release_resource(npe_tab[i].mem_res); 728 722 } 729 723 730 724 return 0;
-2
include/linux/soc/ixp4xx/npe.h
··· 16 16 }; 17 17 18 18 struct npe { 19 - struct resource *mem_res; 20 19 struct npe_regs __iomem *regs; 21 - u32 regs_phys; 22 20 int id; 23 21 int valid; 24 22 };