diff options
Diffstat (limited to 'arch/mips/pci/pci-ar724x.c')
-rw-r--r-- | arch/mips/pci/pci-ar724x.c | 304 |
1 files changed, 217 insertions, 87 deletions
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c index 279585d6eca0..8a0700d448fe 100644 --- a/arch/mips/pci/pci-ar724x.c +++ b/arch/mips/pci/pci-ar724x.c | |||
@@ -9,19 +9,13 @@ | |||
9 | * by the Free Software Foundation. | 9 | * by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/spinlock.h> | ||
12 | #include <linux/irq.h> | 13 | #include <linux/irq.h> |
13 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
14 | #include <asm/mach-ath79/ath79.h> | 17 | #include <asm/mach-ath79/ath79.h> |
15 | #include <asm/mach-ath79/ar71xx_regs.h> | 18 | #include <asm/mach-ath79/ar71xx_regs.h> |
16 | #include <asm/mach-ath79/pci.h> | ||
17 | |||
18 | #define AR724X_PCI_CFG_BASE 0x14000000 | ||
19 | #define AR724X_PCI_CFG_SIZE 0x1000 | ||
20 | #define AR724X_PCI_CTRL_BASE (AR71XX_APB_BASE + 0x000f0000) | ||
21 | #define AR724X_PCI_CTRL_SIZE 0x100 | ||
22 | |||
23 | #define AR724X_PCI_MEM_BASE 0x10000000 | ||
24 | #define AR724X_PCI_MEM_SIZE 0x04000000 | ||
25 | 19 | ||
26 | #define AR724X_PCI_REG_RESET 0x18 | 20 | #define AR724X_PCI_REG_RESET 0x18 |
27 | #define AR724X_PCI_REG_INT_STATUS 0x4c | 21 | #define AR724X_PCI_REG_INT_STATUS 0x4c |
@@ -35,38 +29,112 @@ | |||
35 | 29 | ||
36 | #define AR7240_BAR0_WAR_VALUE 0xffff | 30 | #define AR7240_BAR0_WAR_VALUE 0xffff |
37 | 31 | ||
38 | static DEFINE_SPINLOCK(ar724x_pci_lock); | 32 | #define AR724X_PCI_CMD_INIT (PCI_COMMAND_MEMORY | \ |
39 | static void __iomem *ar724x_pci_devcfg_base; | 33 | PCI_COMMAND_MASTER | \ |
40 | static void __iomem *ar724x_pci_ctrl_base; | 34 | PCI_COMMAND_INVALIDATE | \ |
35 | PCI_COMMAND_PARITY | \ | ||
36 | PCI_COMMAND_SERR | \ | ||
37 | PCI_COMMAND_FAST_BACK) | ||
38 | |||
39 | struct ar724x_pci_controller { | ||
40 | void __iomem *devcfg_base; | ||
41 | void __iomem *ctrl_base; | ||
42 | void __iomem *crp_base; | ||
43 | |||
44 | int irq; | ||
45 | int irq_base; | ||
46 | |||
47 | bool link_up; | ||
48 | bool bar0_is_cached; | ||
49 | u32 bar0_value; | ||
41 | 50 | ||
42 | static u32 ar724x_pci_bar0_value; | 51 | spinlock_t lock; |
43 | static bool ar724x_pci_bar0_is_cached; | ||
44 | static bool ar724x_pci_link_up; | ||
45 | 52 | ||
46 | static inline bool ar724x_pci_check_link(void) | 53 | struct pci_controller pci_controller; |
54 | struct resource io_res; | ||
55 | struct resource mem_res; | ||
56 | }; | ||
57 | |||
58 | static inline bool ar724x_pci_check_link(struct ar724x_pci_controller *apc) | ||
47 | { | 59 | { |
48 | u32 reset; | 60 | u32 reset; |
49 | 61 | ||
50 | reset = __raw_readl(ar724x_pci_ctrl_base + AR724X_PCI_REG_RESET); | 62 | reset = __raw_readl(apc->ctrl_base + AR724X_PCI_REG_RESET); |
51 | return reset & AR724X_PCI_RESET_LINK_UP; | 63 | return reset & AR724X_PCI_RESET_LINK_UP; |
52 | } | 64 | } |
53 | 65 | ||
66 | static inline struct ar724x_pci_controller * | ||
67 | pci_bus_to_ar724x_controller(struct pci_bus *bus) | ||
68 | { | ||
69 | struct pci_controller *hose; | ||
70 | |||
71 | hose = (struct pci_controller *) bus->sysdata; | ||
72 | return container_of(hose, struct ar724x_pci_controller, pci_controller); | ||
73 | } | ||
74 | |||
75 | static int ar724x_pci_local_write(struct ar724x_pci_controller *apc, | ||
76 | int where, int size, u32 value) | ||
77 | { | ||
78 | unsigned long flags; | ||
79 | void __iomem *base; | ||
80 | u32 data; | ||
81 | int s; | ||
82 | |||
83 | WARN_ON(where & (size - 1)); | ||
84 | |||
85 | if (!apc->link_up) | ||
86 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
87 | |||
88 | base = apc->crp_base; | ||
89 | |||
90 | spin_lock_irqsave(&apc->lock, flags); | ||
91 | data = __raw_readl(base + (where & ~3)); | ||
92 | |||
93 | switch (size) { | ||
94 | case 1: | ||
95 | s = ((where & 3) * 8); | ||
96 | data &= ~(0xff << s); | ||
97 | data |= ((value & 0xff) << s); | ||
98 | break; | ||
99 | case 2: | ||
100 | s = ((where & 2) * 8); | ||
101 | data &= ~(0xffff << s); | ||
102 | data |= ((value & 0xffff) << s); | ||
103 | break; | ||
104 | case 4: | ||
105 | data = value; | ||
106 | break; | ||
107 | default: | ||
108 | spin_unlock_irqrestore(&apc->lock, flags); | ||
109 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
110 | } | ||
111 | |||
112 | __raw_writel(data, base + (where & ~3)); | ||
113 | /* flush write */ | ||
114 | __raw_readl(base + (where & ~3)); | ||
115 | spin_unlock_irqrestore(&apc->lock, flags); | ||
116 | |||
117 | return PCIBIOS_SUCCESSFUL; | ||
118 | } | ||
119 | |||
54 | static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, | 120 | static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, |
55 | int size, uint32_t *value) | 121 | int size, uint32_t *value) |
56 | { | 122 | { |
123 | struct ar724x_pci_controller *apc; | ||
57 | unsigned long flags; | 124 | unsigned long flags; |
58 | void __iomem *base; | 125 | void __iomem *base; |
59 | u32 data; | 126 | u32 data; |
60 | 127 | ||
61 | if (!ar724x_pci_link_up) | 128 | apc = pci_bus_to_ar724x_controller(bus); |
129 | if (!apc->link_up) | ||
62 | return PCIBIOS_DEVICE_NOT_FOUND; | 130 | return PCIBIOS_DEVICE_NOT_FOUND; |
63 | 131 | ||
64 | if (devfn) | 132 | if (devfn) |
65 | return PCIBIOS_DEVICE_NOT_FOUND; | 133 | return PCIBIOS_DEVICE_NOT_FOUND; |
66 | 134 | ||
67 | base = ar724x_pci_devcfg_base; | 135 | base = apc->devcfg_base; |
68 | 136 | ||
69 | spin_lock_irqsave(&ar724x_pci_lock, flags); | 137 | spin_lock_irqsave(&apc->lock, flags); |
70 | data = __raw_readl(base + (where & ~3)); | 138 | data = __raw_readl(base + (where & ~3)); |
71 | 139 | ||
72 | switch (size) { | 140 | switch (size) { |
@@ -85,17 +153,17 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, | |||
85 | case 4: | 153 | case 4: |
86 | break; | 154 | break; |
87 | default: | 155 | default: |
88 | spin_unlock_irqrestore(&ar724x_pci_lock, flags); | 156 | spin_unlock_irqrestore(&apc->lock, flags); |
89 | 157 | ||
90 | return PCIBIOS_BAD_REGISTER_NUMBER; | 158 | return PCIBIOS_BAD_REGISTER_NUMBER; |
91 | } | 159 | } |
92 | 160 | ||
93 | spin_unlock_irqrestore(&ar724x_pci_lock, flags); | 161 | spin_unlock_irqrestore(&apc->lock, flags); |
94 | 162 | ||
95 | if (where == PCI_BASE_ADDRESS_0 && size == 4 && | 163 | if (where == PCI_BASE_ADDRESS_0 && size == 4 && |
96 | ar724x_pci_bar0_is_cached) { | 164 | apc->bar0_is_cached) { |
97 | /* use the cached value */ | 165 | /* use the cached value */ |
98 | *value = ar724x_pci_bar0_value; | 166 | *value = apc->bar0_value; |
99 | } else { | 167 | } else { |
100 | *value = data; | 168 | *value = data; |
101 | } | 169 | } |
@@ -106,12 +174,14 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, | |||
106 | static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, | 174 | static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, |
107 | int size, uint32_t value) | 175 | int size, uint32_t value) |
108 | { | 176 | { |
177 | struct ar724x_pci_controller *apc; | ||
109 | unsigned long flags; | 178 | unsigned long flags; |
110 | void __iomem *base; | 179 | void __iomem *base; |
111 | u32 data; | 180 | u32 data; |
112 | int s; | 181 | int s; |
113 | 182 | ||
114 | if (!ar724x_pci_link_up) | 183 | apc = pci_bus_to_ar724x_controller(bus); |
184 | if (!apc->link_up) | ||
115 | return PCIBIOS_DEVICE_NOT_FOUND; | 185 | return PCIBIOS_DEVICE_NOT_FOUND; |
116 | 186 | ||
117 | if (devfn) | 187 | if (devfn) |
@@ -129,18 +199,18 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, | |||
129 | * BAR0 register in order to make the device memory | 199 | * BAR0 register in order to make the device memory |
130 | * accessible. | 200 | * accessible. |
131 | */ | 201 | */ |
132 | ar724x_pci_bar0_is_cached = true; | 202 | apc->bar0_is_cached = true; |
133 | ar724x_pci_bar0_value = value; | 203 | apc->bar0_value = value; |
134 | 204 | ||
135 | value = AR7240_BAR0_WAR_VALUE; | 205 | value = AR7240_BAR0_WAR_VALUE; |
136 | } else { | 206 | } else { |
137 | ar724x_pci_bar0_is_cached = false; | 207 | apc->bar0_is_cached = false; |
138 | } | 208 | } |
139 | } | 209 | } |
140 | 210 | ||
141 | base = ar724x_pci_devcfg_base; | 211 | base = apc->devcfg_base; |
142 | 212 | ||
143 | spin_lock_irqsave(&ar724x_pci_lock, flags); | 213 | spin_lock_irqsave(&apc->lock, flags); |
144 | data = __raw_readl(base + (where & ~3)); | 214 | data = __raw_readl(base + (where & ~3)); |
145 | 215 | ||
146 | switch (size) { | 216 | switch (size) { |
@@ -158,7 +228,7 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, | |||
158 | data = value; | 228 | data = value; |
159 | break; | 229 | break; |
160 | default: | 230 | default: |
161 | spin_unlock_irqrestore(&ar724x_pci_lock, flags); | 231 | spin_unlock_irqrestore(&apc->lock, flags); |
162 | 232 | ||
163 | return PCIBIOS_BAD_REGISTER_NUMBER; | 233 | return PCIBIOS_BAD_REGISTER_NUMBER; |
164 | } | 234 | } |
@@ -166,7 +236,7 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, | |||
166 | __raw_writel(data, base + (where & ~3)); | 236 | __raw_writel(data, base + (where & ~3)); |
167 | /* flush write */ | 237 | /* flush write */ |
168 | __raw_readl(base + (where & ~3)); | 238 | __raw_readl(base + (where & ~3)); |
169 | spin_unlock_irqrestore(&ar724x_pci_lock, flags); | 239 | spin_unlock_irqrestore(&apc->lock, flags); |
170 | 240 | ||
171 | return PCIBIOS_SUCCESSFUL; | 241 | return PCIBIOS_SUCCESSFUL; |
172 | } | 242 | } |
@@ -176,38 +246,20 @@ static struct pci_ops ar724x_pci_ops = { | |||
176 | .write = ar724x_pci_write, | 246 | .write = ar724x_pci_write, |
177 | }; | 247 | }; |
178 | 248 | ||
179 | static struct resource ar724x_io_resource = { | ||
180 | .name = "PCI IO space", | ||
181 | .start = 0, | ||
182 | .end = 0, | ||
183 | .flags = IORESOURCE_IO, | ||
184 | }; | ||
185 | |||
186 | static struct resource ar724x_mem_resource = { | ||
187 | .name = "PCI memory space", | ||
188 | .start = AR724X_PCI_MEM_BASE, | ||
189 | .end = AR724X_PCI_MEM_BASE + AR724X_PCI_MEM_SIZE - 1, | ||
190 | .flags = IORESOURCE_MEM, | ||
191 | }; | ||
192 | |||
193 | static struct pci_controller ar724x_pci_controller = { | ||
194 | .pci_ops = &ar724x_pci_ops, | ||
195 | .io_resource = &ar724x_io_resource, | ||
196 | .mem_resource = &ar724x_mem_resource, | ||
197 | }; | ||
198 | |||
199 | static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc) | 249 | static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc) |
200 | { | 250 | { |
251 | struct ar724x_pci_controller *apc; | ||
201 | void __iomem *base; | 252 | void __iomem *base; |
202 | u32 pending; | 253 | u32 pending; |
203 | 254 | ||
204 | base = ar724x_pci_ctrl_base; | 255 | apc = irq_get_handler_data(irq); |
256 | base = apc->ctrl_base; | ||
205 | 257 | ||
206 | pending = __raw_readl(base + AR724X_PCI_REG_INT_STATUS) & | 258 | pending = __raw_readl(base + AR724X_PCI_REG_INT_STATUS) & |
207 | __raw_readl(base + AR724X_PCI_REG_INT_MASK); | 259 | __raw_readl(base + AR724X_PCI_REG_INT_MASK); |
208 | 260 | ||
209 | if (pending & AR724X_PCI_INT_DEV0) | 261 | if (pending & AR724X_PCI_INT_DEV0) |
210 | generic_handle_irq(ATH79_PCI_IRQ(0)); | 262 | generic_handle_irq(apc->irq_base + 0); |
211 | 263 | ||
212 | else | 264 | else |
213 | spurious_interrupt(); | 265 | spurious_interrupt(); |
@@ -215,13 +267,17 @@ static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
215 | 267 | ||
216 | static void ar724x_pci_irq_unmask(struct irq_data *d) | 268 | static void ar724x_pci_irq_unmask(struct irq_data *d) |
217 | { | 269 | { |
270 | struct ar724x_pci_controller *apc; | ||
218 | void __iomem *base; | 271 | void __iomem *base; |
272 | int offset; | ||
219 | u32 t; | 273 | u32 t; |
220 | 274 | ||
221 | base = ar724x_pci_ctrl_base; | 275 | apc = irq_data_get_irq_chip_data(d); |
276 | base = apc->ctrl_base; | ||
277 | offset = apc->irq_base - d->irq; | ||
222 | 278 | ||
223 | switch (d->irq) { | 279 | switch (offset) { |
224 | case ATH79_PCI_IRQ(0): | 280 | case 0: |
225 | t = __raw_readl(base + AR724X_PCI_REG_INT_MASK); | 281 | t = __raw_readl(base + AR724X_PCI_REG_INT_MASK); |
226 | __raw_writel(t | AR724X_PCI_INT_DEV0, | 282 | __raw_writel(t | AR724X_PCI_INT_DEV0, |
227 | base + AR724X_PCI_REG_INT_MASK); | 283 | base + AR724X_PCI_REG_INT_MASK); |
@@ -232,13 +288,17 @@ static void ar724x_pci_irq_unmask(struct irq_data *d) | |||
232 | 288 | ||
233 | static void ar724x_pci_irq_mask(struct irq_data *d) | 289 | static void ar724x_pci_irq_mask(struct irq_data *d) |
234 | { | 290 | { |
291 | struct ar724x_pci_controller *apc; | ||
235 | void __iomem *base; | 292 | void __iomem *base; |
293 | int offset; | ||
236 | u32 t; | 294 | u32 t; |
237 | 295 | ||
238 | base = ar724x_pci_ctrl_base; | 296 | apc = irq_data_get_irq_chip_data(d); |
297 | base = apc->ctrl_base; | ||
298 | offset = apc->irq_base - d->irq; | ||
239 | 299 | ||
240 | switch (d->irq) { | 300 | switch (offset) { |
241 | case ATH79_PCI_IRQ(0): | 301 | case 0: |
242 | t = __raw_readl(base + AR724X_PCI_REG_INT_MASK); | 302 | t = __raw_readl(base + AR724X_PCI_REG_INT_MASK); |
243 | __raw_writel(t & ~AR724X_PCI_INT_DEV0, | 303 | __raw_writel(t & ~AR724X_PCI_INT_DEV0, |
244 | base + AR724X_PCI_REG_INT_MASK); | 304 | base + AR724X_PCI_REG_INT_MASK); |
@@ -262,53 +322,123 @@ static struct irq_chip ar724x_pci_irq_chip = { | |||
262 | .irq_mask_ack = ar724x_pci_irq_mask, | 322 | .irq_mask_ack = ar724x_pci_irq_mask, |
263 | }; | 323 | }; |
264 | 324 | ||
265 | static void __init ar724x_pci_irq_init(int irq) | 325 | static void ar724x_pci_irq_init(struct ar724x_pci_controller *apc, |
326 | int id) | ||
266 | { | 327 | { |
267 | void __iomem *base; | 328 | void __iomem *base; |
268 | int i; | 329 | int i; |
269 | 330 | ||
270 | base = ar724x_pci_ctrl_base; | 331 | base = apc->ctrl_base; |
271 | 332 | ||
272 | __raw_writel(0, base + AR724X_PCI_REG_INT_MASK); | 333 | __raw_writel(0, base + AR724X_PCI_REG_INT_MASK); |
273 | __raw_writel(0, base + AR724X_PCI_REG_INT_STATUS); | 334 | __raw_writel(0, base + AR724X_PCI_REG_INT_STATUS); |
274 | 335 | ||
275 | BUILD_BUG_ON(ATH79_PCI_IRQ_COUNT < AR724X_PCI_IRQ_COUNT); | 336 | apc->irq_base = ATH79_PCI_IRQ_BASE + (id * AR724X_PCI_IRQ_COUNT); |
276 | 337 | ||
277 | for (i = ATH79_PCI_IRQ_BASE; | 338 | for (i = apc->irq_base; |
278 | i < ATH79_PCI_IRQ_BASE + AR724X_PCI_IRQ_COUNT; i++) | 339 | i < apc->irq_base + AR724X_PCI_IRQ_COUNT; i++) { |
279 | irq_set_chip_and_handler(i, &ar724x_pci_irq_chip, | 340 | irq_set_chip_and_handler(i, &ar724x_pci_irq_chip, |
280 | handle_level_irq); | 341 | handle_level_irq); |
342 | irq_set_chip_data(i, apc); | ||
343 | } | ||
281 | 344 | ||
282 | irq_set_chained_handler(irq, ar724x_pci_irq_handler); | 345 | irq_set_handler_data(apc->irq, apc); |
346 | irq_set_chained_handler(apc->irq, ar724x_pci_irq_handler); | ||
283 | } | 347 | } |
284 | 348 | ||
285 | int __init ar724x_pcibios_init(int irq) | 349 | static int ar724x_pci_probe(struct platform_device *pdev) |
286 | { | 350 | { |
287 | int ret; | 351 | struct ar724x_pci_controller *apc; |
352 | struct resource *res; | ||
353 | int id; | ||
288 | 354 | ||
289 | ret = -ENOMEM; | 355 | id = pdev->id; |
356 | if (id == -1) | ||
357 | id = 0; | ||
290 | 358 | ||
291 | ar724x_pci_devcfg_base = ioremap(AR724X_PCI_CFG_BASE, | 359 | apc = devm_kzalloc(&pdev->dev, sizeof(struct ar724x_pci_controller), |
292 | AR724X_PCI_CFG_SIZE); | 360 | GFP_KERNEL); |
293 | if (ar724x_pci_devcfg_base == NULL) | 361 | if (!apc) |
294 | goto err; | 362 | return -ENOMEM; |
295 | 363 | ||
296 | ar724x_pci_ctrl_base = ioremap(AR724X_PCI_CTRL_BASE, | 364 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl_base"); |
297 | AR724X_PCI_CTRL_SIZE); | 365 | if (!res) |
298 | if (ar724x_pci_ctrl_base == NULL) | 366 | return -EINVAL; |
299 | goto err_unmap_devcfg; | ||
300 | 367 | ||
301 | ar724x_pci_link_up = ar724x_pci_check_link(); | 368 | apc->ctrl_base = devm_request_and_ioremap(&pdev->dev, res); |
302 | if (!ar724x_pci_link_up) | 369 | if (apc->ctrl_base == NULL) |
303 | pr_warn("ar724x: PCIe link is down\n"); | 370 | return -EBUSY; |
304 | 371 | ||
305 | ar724x_pci_irq_init(irq); | 372 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg_base"); |
306 | register_pci_controller(&ar724x_pci_controller); | 373 | if (!res) |
374 | return -EINVAL; | ||
307 | 375 | ||
308 | return PCIBIOS_SUCCESSFUL; | 376 | apc->devcfg_base = devm_request_and_ioremap(&pdev->dev, res); |
377 | if (!apc->devcfg_base) | ||
378 | return -EBUSY; | ||
379 | |||
380 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "crp_base"); | ||
381 | if (!res) | ||
382 | return -EINVAL; | ||
309 | 383 | ||
310 | err_unmap_devcfg: | 384 | apc->crp_base = devm_request_and_ioremap(&pdev->dev, res); |
311 | iounmap(ar724x_pci_devcfg_base); | 385 | if (apc->crp_base == NULL) |
312 | err: | 386 | return -EBUSY; |
313 | return ret; | 387 | |
388 | apc->irq = platform_get_irq(pdev, 0); | ||
389 | if (apc->irq < 0) | ||
390 | return -EINVAL; | ||
391 | |||
392 | spin_lock_init(&apc->lock); | ||
393 | |||
394 | res = platform_get_resource_byname(pdev, IORESOURCE_IO, "io_base"); | ||
395 | if (!res) | ||
396 | return -EINVAL; | ||
397 | |||
398 | apc->io_res.parent = res; | ||
399 | apc->io_res.name = "PCI IO space"; | ||
400 | apc->io_res.start = res->start; | ||
401 | apc->io_res.end = res->end; | ||
402 | apc->io_res.flags = IORESOURCE_IO; | ||
403 | |||
404 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem_base"); | ||
405 | if (!res) | ||
406 | return -EINVAL; | ||
407 | |||
408 | apc->mem_res.parent = res; | ||
409 | apc->mem_res.name = "PCI memory space"; | ||
410 | apc->mem_res.start = res->start; | ||
411 | apc->mem_res.end = res->end; | ||
412 | apc->mem_res.flags = IORESOURCE_MEM; | ||
413 | |||
414 | apc->pci_controller.pci_ops = &ar724x_pci_ops; | ||
415 | apc->pci_controller.io_resource = &apc->io_res; | ||
416 | apc->pci_controller.mem_resource = &apc->mem_res; | ||
417 | |||
418 | apc->link_up = ar724x_pci_check_link(apc); | ||
419 | if (!apc->link_up) | ||
420 | dev_warn(&pdev->dev, "PCIe link is down\n"); | ||
421 | |||
422 | ar724x_pci_irq_init(apc, id); | ||
423 | |||
424 | ar724x_pci_local_write(apc, PCI_COMMAND, 4, AR724X_PCI_CMD_INIT); | ||
425 | |||
426 | register_pci_controller(&apc->pci_controller); | ||
427 | |||
428 | return 0; | ||
314 | } | 429 | } |
430 | |||
431 | static struct platform_driver ar724x_pci_driver = { | ||
432 | .probe = ar724x_pci_probe, | ||
433 | .driver = { | ||
434 | .name = "ar724x-pci", | ||
435 | .owner = THIS_MODULE, | ||
436 | }, | ||
437 | }; | ||
438 | |||
439 | static int __init ar724x_pci_init(void) | ||
440 | { | ||
441 | return platform_driver_register(&ar724x_pci_driver); | ||
442 | } | ||
443 | |||
444 | postcore_initcall(ar724x_pci_init); | ||