aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorGabor Juhos2013-02-03 03:59:45 -0600
committerJohn Crispin2013-02-16 18:25:39 -0600
commit34b134aebda89888b6985b7a3139e9cbdf209236 (patch)
treef6dc7a06f2b74420b77bac128a237af91ce00bbb /arch/mips
parent908339ef25b1d5e80f1c6fab22b9958174708b4a (diff)
downloadam43-linux-kernel-34b134aebda89888b6985b7a3139e9cbdf209236.tar.gz
am43-linux-kernel-34b134aebda89888b6985b7a3139e9cbdf209236.tar.xz
am43-linux-kernel-34b134aebda89888b6985b7a3139e9cbdf209236.zip
MIPS: pci-ar724x: remove static PCI IO/MEM resources
Static resources become impractical when multiple PCI controllers are present. Move the resources into the platform device registration code and change the probe routine to get those from there platform device's resources. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4914/ Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/ath79/pci.c21
-rw-r--r--arch/mips/pci/pci-ar724x.c40
2 files changed, 44 insertions, 17 deletions
diff --git a/arch/mips/ath79/pci.c b/arch/mips/ath79/pci.c
index d90e0713638..45d1112de50 100644
--- a/arch/mips/ath79/pci.c
+++ b/arch/mips/ath79/pci.c
@@ -139,10 +139,13 @@ static struct platform_device *
139ath79_register_pci_ar724x(int id, 139ath79_register_pci_ar724x(int id,
140 unsigned long cfg_base, 140 unsigned long cfg_base,
141 unsigned long ctrl_base, 141 unsigned long ctrl_base,
142 unsigned long mem_base,
143 unsigned long mem_size,
144 unsigned long io_base,
142 int irq) 145 int irq)
143{ 146{
144 struct platform_device *pdev; 147 struct platform_device *pdev;
145 struct resource res[3]; 148 struct resource res[5];
146 149
147 memset(res, 0, sizeof(res)); 150 memset(res, 0, sizeof(res));
148 151
@@ -160,6 +163,16 @@ ath79_register_pci_ar724x(int id,
160 res[2].start = irq; 163 res[2].start = irq;
161 res[2].end = irq; 164 res[2].end = irq;
162 165
166 res[3].name = "mem_base";
167 res[3].flags = IORESOURCE_MEM;
168 res[3].start = mem_base;
169 res[3].end = mem_base + mem_size - 1;
170
171 res[4].name = "io_base";
172 res[4].flags = IORESOURCE_IO;
173 res[4].start = io_base;
174 res[4].end = io_base;
175
163 pdev = platform_device_register_simple("ar724x-pci", id, 176 pdev = platform_device_register_simple("ar724x-pci", id,
164 res, ARRAY_SIZE(res)); 177 res, ARRAY_SIZE(res));
165 return pdev; 178 return pdev;
@@ -175,6 +188,9 @@ int __init ath79_register_pci(void)
175 pdev = ath79_register_pci_ar724x(-1, 188 pdev = ath79_register_pci_ar724x(-1,
176 AR724X_PCI_CFG_BASE, 189 AR724X_PCI_CFG_BASE,
177 AR724X_PCI_CTRL_BASE, 190 AR724X_PCI_CTRL_BASE,
191 AR724X_PCI_MEM_BASE,
192 AR724X_PCI_MEM_SIZE,
193 0,
178 ATH79_CPU_IRQ_IP2); 194 ATH79_CPU_IRQ_IP2);
179 } else if (soc_is_ar9342() || 195 } else if (soc_is_ar9342() ||
180 soc_is_ar9344()) { 196 soc_is_ar9344()) {
@@ -187,6 +203,9 @@ int __init ath79_register_pci(void)
187 pdev = ath79_register_pci_ar724x(-1, 203 pdev = ath79_register_pci_ar724x(-1,
188 AR724X_PCI_CFG_BASE, 204 AR724X_PCI_CFG_BASE,
189 AR724X_PCI_CTRL_BASE, 205 AR724X_PCI_CTRL_BASE,
206 AR724X_PCI_MEM_BASE,
207 AR724X_PCI_MEM_SIZE,
208 0,
190 ATH79_IP2_IRQ(0)); 209 ATH79_IP2_IRQ(0));
191 } else { 210 } else {
192 /* No PCI support */ 211 /* No PCI support */
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c
index 93ab8778ce1..d0d707de6c6 100644
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -42,6 +42,8 @@ struct ar724x_pci_controller {
42 spinlock_t lock; 42 spinlock_t lock;
43 43
44 struct pci_controller pci_controller; 44 struct pci_controller pci_controller;
45 struct resource io_res;
46 struct resource mem_res;
45}; 47};
46 48
47static inline bool ar724x_pci_check_link(struct ar724x_pci_controller *apc) 49static inline bool ar724x_pci_check_link(struct ar724x_pci_controller *apc)
@@ -190,20 +192,6 @@ static struct pci_ops ar724x_pci_ops = {
190 .write = ar724x_pci_write, 192 .write = ar724x_pci_write,
191}; 193};
192 194
193static struct resource ar724x_io_resource = {
194 .name = "PCI IO space",
195 .start = 0,
196 .end = 0,
197 .flags = IORESOURCE_IO,
198};
199
200static struct resource ar724x_mem_resource = {
201 .name = "PCI memory space",
202 .start = AR724X_PCI_MEM_BASE,
203 .end = AR724X_PCI_MEM_BASE + AR724X_PCI_MEM_SIZE - 1,
204 .flags = IORESOURCE_MEM,
205};
206
207static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc) 195static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc)
208{ 196{
209 struct ar724x_pci_controller *apc; 197 struct ar724x_pci_controller *apc;
@@ -331,9 +319,29 @@ static int ar724x_pci_probe(struct platform_device *pdev)
331 319
332 spin_lock_init(&apc->lock); 320 spin_lock_init(&apc->lock);
333 321
322 res = platform_get_resource_byname(pdev, IORESOURCE_IO, "io_base");
323 if (!res)
324 return -EINVAL;
325
326 apc->io_res.parent = res;
327 apc->io_res.name = "PCI IO space";
328 apc->io_res.start = res->start;
329 apc->io_res.end = res->end;
330 apc->io_res.flags = IORESOURCE_IO;
331
332 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem_base");
333 if (!res)
334 return -EINVAL;
335
336 apc->mem_res.parent = res;
337 apc->mem_res.name = "PCI memory space";
338 apc->mem_res.start = res->start;
339 apc->mem_res.end = res->end;
340 apc->mem_res.flags = IORESOURCE_MEM;
341
334 apc->pci_controller.pci_ops = &ar724x_pci_ops; 342 apc->pci_controller.pci_ops = &ar724x_pci_ops;
335 apc->pci_controller.io_resource = &ar724x_io_resource; 343 apc->pci_controller.io_resource = &apc->io_res;
336 apc->pci_controller.mem_resource = &ar724x_mem_resource; 344 apc->pci_controller.mem_resource = &apc->mem_res;
337 345
338 apc->link_up = ar724x_pci_check_link(apc); 346 apc->link_up = ar724x_pci_check_link(apc);
339 if (!apc->link_up) 347 if (!apc->link_up)