| 1 | From f1c3a7dadf7b77809cda7f77df4b1ba3b24fbfa3 Mon Sep 17 00:00:00 2001 |
| 2 | From: Gabor Juhos <juhosg@openwrt.org> |
| 3 | Date: Wed, 27 Jun 2012 10:12:50 +0200 |
| 4 | Subject: [PATCH 11/34] MIPS: pci-ar724x: remove static PCI resources |
| 5 | |
| 6 | Get those from the platform device instead. |
| 7 | |
| 8 | Signed-off-by: Gabor Juhos <juhosg@openwrt.org> |
| 9 | --- |
| 10 | arch/mips/ath79/pci.c | 21 ++++++++++++++++++++- |
| 11 | arch/mips/pci/pci-ar724x.c | 40 ++++++++++++++++++++++++---------------- |
| 12 | 2 files changed, 44 insertions(+), 17 deletions(-) |
| 13 | |
| 14 | --- a/arch/mips/ath79/pci.c |
| 15 | +++ b/arch/mips/ath79/pci.c |
| 16 | @@ -137,10 +137,13 @@ static struct platform_device * |
| 17 | ath79_register_pci_ar724x(int id, |
| 18 | unsigned long cfg_base, |
| 19 | unsigned long ctrl_base, |
| 20 | + unsigned long mem_base, |
| 21 | + unsigned long mem_size, |
| 22 | + unsigned long io_base, |
| 23 | int irq) |
| 24 | { |
| 25 | struct platform_device *pdev; |
| 26 | - struct resource res[3]; |
| 27 | + struct resource res[5]; |
| 28 | |
| 29 | memset(res, 0, sizeof(res)); |
| 30 | |
| 31 | @@ -158,6 +161,16 @@ ath79_register_pci_ar724x(int id, |
| 32 | res[2].start = irq; |
| 33 | res[2].end = irq; |
| 34 | |
| 35 | + res[3].name = "mem_base"; |
| 36 | + res[3].flags = IORESOURCE_MEM; |
| 37 | + res[3].start = mem_base; |
| 38 | + res[3].end = mem_base + mem_size - 1; |
| 39 | + |
| 40 | + res[4].name = "io_base"; |
| 41 | + res[4].flags = IORESOURCE_IO; |
| 42 | + res[4].start = io_base; |
| 43 | + res[4].end = io_base; |
| 44 | + |
| 45 | pdev = platform_device_register_simple("ar724x-pci", id, |
| 46 | res, ARRAY_SIZE(res)); |
| 47 | return pdev; |
| 48 | @@ -173,6 +186,9 @@ int __init ath79_register_pci(void) |
| 49 | pdev = ath79_register_pci_ar724x(-1, |
| 50 | AR724X_PCI_CFG_BASE, |
| 51 | AR724X_PCI_CTRL_BASE, |
| 52 | + AR724X_PCI_MEM_BASE, |
| 53 | + AR724X_PCI_MEM_SIZE, |
| 54 | + 0, |
| 55 | ATH79_CPU_IRQ_IP2); |
| 56 | } else if (soc_is_ar9342() || |
| 57 | soc_is_ar9344()) { |
| 58 | @@ -185,6 +201,9 @@ int __init ath79_register_pci(void) |
| 59 | pdev = ath79_register_pci_ar724x(-1, |
| 60 | AR724X_PCI_CFG_BASE, |
| 61 | AR724X_PCI_CTRL_BASE, |
| 62 | + AR724X_PCI_MEM_BASE, |
| 63 | + AR724X_PCI_MEM_SIZE, |
| 64 | + 0, |
| 65 | ATH79_IP2_IRQ(0)); |
| 66 | } else { |
| 67 | /* No PCI support */ |
| 68 | --- a/arch/mips/pci/pci-ar724x.c |
| 69 | +++ b/arch/mips/pci/pci-ar724x.c |
| 70 | @@ -42,6 +42,8 @@ struct ar724x_pci_controller { |
| 71 | spinlock_t lock; |
| 72 | |
| 73 | struct pci_controller pci_controller; |
| 74 | + struct resource io_res; |
| 75 | + struct resource mem_res; |
| 76 | }; |
| 77 | |
| 78 | static inline bool ar724x_pci_check_link(struct ar724x_pci_controller *apc) |
| 79 | @@ -190,20 +192,6 @@ static struct pci_ops ar724x_pci_ops = { |
| 80 | .write = ar724x_pci_write, |
| 81 | }; |
| 82 | |
| 83 | -static struct resource ar724x_io_resource = { |
| 84 | - .name = "PCI IO space", |
| 85 | - .start = 0, |
| 86 | - .end = 0, |
| 87 | - .flags = IORESOURCE_IO, |
| 88 | -}; |
| 89 | - |
| 90 | -static struct resource ar724x_mem_resource = { |
| 91 | - .name = "PCI memory space", |
| 92 | - .start = AR724X_PCI_MEM_BASE, |
| 93 | - .end = AR724X_PCI_MEM_BASE + AR724X_PCI_MEM_SIZE - 1, |
| 94 | - .flags = IORESOURCE_MEM, |
| 95 | -}; |
| 96 | - |
| 97 | static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 98 | { |
| 99 | struct ar724x_pci_controller *apc; |
| 100 | @@ -331,9 +319,29 @@ static int __devinit ar724x_pci_probe(st |
| 101 | |
| 102 | spin_lock_init(&apc->lock); |
| 103 | |
| 104 | + res = platform_get_resource_byname(pdev, IORESOURCE_IO, "io_base"); |
| 105 | + if (!res) |
| 106 | + return -EINVAL; |
| 107 | + |
| 108 | + apc->io_res.parent = res; |
| 109 | + apc->io_res.name = "PCI IO space"; |
| 110 | + apc->io_res.start = res->start; |
| 111 | + apc->io_res.end = res->end; |
| 112 | + apc->io_res.flags = IORESOURCE_IO; |
| 113 | + |
| 114 | + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem_base"); |
| 115 | + if (!res) |
| 116 | + return -EINVAL; |
| 117 | + |
| 118 | + apc->mem_res.parent = res; |
| 119 | + apc->mem_res.name = "PCI memory space"; |
| 120 | + apc->mem_res.start = res->start; |
| 121 | + apc->mem_res.end = res->end; |
| 122 | + apc->mem_res.flags = IORESOURCE_MEM; |
| 123 | + |
| 124 | apc->pci_controller.pci_ops = &ar724x_pci_ops; |
| 125 | - apc->pci_controller.io_resource = &ar724x_io_resource; |
| 126 | - apc->pci_controller.mem_resource = &ar724x_mem_resource; |
| 127 | + apc->pci_controller.io_resource = &apc->io_res; |
| 128 | + apc->pci_controller.mem_resource = &apc->mem_res; |
| 129 | |
| 130 | apc->link_up = ar724x_pci_check_link(apc); |
| 131 | if (!apc->link_up) |
| 132 | |