1 From d0f1420702ed47a82572aaf39e7407055518d14e Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Sat, 23 Jun 2018 15:05:19 +0200
4 Subject: [PATCH 29/33] MIPS: ath79: drop legacy pci code
6 With the target now being fully OF based, we can drop the legacy pci
7 platform code. The only bits that we need to keep is the fixup code
8 which we move to its own code file.
10 Signed-off-by: John Crispin <john@phrozen.org>
12 arch/mips/ath79/Makefile | 1 -
13 arch/mips/ath79/pci.c | 273 --------------------------------------------
14 arch/mips/ath79/pci.h | 35 ------
15 arch/mips/pci/Makefile | 1 +
16 arch/mips/pci/fixup-ath79.c | 21 ++++
17 5 files changed, 22 insertions(+), 309 deletions(-)
18 delete mode 100644 arch/mips/ath79/pci.c
19 delete mode 100644 arch/mips/ath79/pci.h
20 create mode 100644 arch/mips/pci/fixup-ath79.c
22 --- a/arch/mips/ath79/Makefile
23 +++ b/arch/mips/ath79/Makefile
25 obj-y := prom.o setup.o common.o clock.o
27 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
28 -obj-$(CONFIG_PCI) += pci.o
32 --- a/arch/mips/ath79/pci.c
36 - * Atheros AR71XX/AR724X specific PCI setup code
38 - * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
39 - * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
40 - * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
42 - * Parts of this file are based on Atheros' 2.6.15 BSP
44 - * This program is free software; you can redistribute it and/or modify it
45 - * under the terms of the GNU General Public License version 2 as published
46 - * by the Free Software Foundation.
49 -#include <linux/init.h>
50 -#include <linux/pci.h>
51 -#include <linux/resource.h>
52 -#include <linux/platform_device.h>
53 -#include <asm/mach-ath79/ar71xx_regs.h>
54 -#include <asm/mach-ath79/ath79.h>
55 -#include <asm/mach-ath79/irq.h>
58 -static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev);
59 -static const struct ath79_pci_irq *ath79_pci_irq_map;
60 -static unsigned ath79_pci_nr_irqs;
62 -static const struct ath79_pci_irq ar71xx_pci_irq_map[] = {
66 - .irq = ATH79_PCI_IRQ(0),
70 - .irq = ATH79_PCI_IRQ(1),
74 - .irq = ATH79_PCI_IRQ(2),
78 -static const struct ath79_pci_irq ar724x_pci_irq_map[] = {
82 - .irq = ATH79_PCI_IRQ(0),
86 -static const struct ath79_pci_irq qca955x_pci_irq_map[] = {
91 - .irq = ATH79_PCI_IRQ(0),
97 - .irq = ATH79_PCI_IRQ(1),
101 -int pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
106 - if (ath79_pci_nr_irqs == 0 ||
107 - ath79_pci_irq_map == NULL) {
108 - if (soc_is_ar71xx()) {
109 - ath79_pci_irq_map = ar71xx_pci_irq_map;
110 - ath79_pci_nr_irqs = ARRAY_SIZE(ar71xx_pci_irq_map);
111 - } else if (soc_is_ar724x() ||
114 - ath79_pci_irq_map = ar724x_pci_irq_map;
115 - ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
116 - } else if (soc_is_qca955x()) {
117 - ath79_pci_irq_map = qca955x_pci_irq_map;
118 - ath79_pci_nr_irqs = ARRAY_SIZE(qca955x_pci_irq_map);
120 - pr_crit("pci %s: invalid irq map\n",
121 - pci_name((struct pci_dev *) dev));
126 - for (i = 0; i < ath79_pci_nr_irqs; i++) {
127 - const struct ath79_pci_irq *entry;
129 - entry = &ath79_pci_irq_map[i];
130 - if (entry->bus == dev->bus->number &&
131 - entry->slot == slot &&
132 - entry->pin == pin) {
139 - pr_crit("pci %s: no irq found for pin %u\n",
140 - pci_name((struct pci_dev *) dev), pin);
142 - pr_info("pci %s: using irq %d for pin %u\n",
143 - pci_name((struct pci_dev *) dev), irq, pin);
148 -int pcibios_plat_dev_init(struct pci_dev *dev)
150 - if (ath79_pci_plat_dev_init)
151 - return ath79_pci_plat_dev_init(dev);
156 -void __init ath79_pci_set_irq_map(unsigned nr_irqs,
157 - const struct ath79_pci_irq *map)
159 - ath79_pci_nr_irqs = nr_irqs;
160 - ath79_pci_irq_map = map;
163 -void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
165 - ath79_pci_plat_dev_init = func;
168 -static struct platform_device *
169 -ath79_register_pci_ar71xx(void)
171 - struct platform_device *pdev;
172 - struct resource res[4];
174 - memset(res, 0, sizeof(res));
176 - res[0].name = "cfg_base";
177 - res[0].flags = IORESOURCE_MEM;
178 - res[0].start = AR71XX_PCI_CFG_BASE;
179 - res[0].end = AR71XX_PCI_CFG_BASE + AR71XX_PCI_CFG_SIZE - 1;
181 - res[1].flags = IORESOURCE_IRQ;
182 - res[1].start = ATH79_CPU_IRQ(2);
183 - res[1].end = ATH79_CPU_IRQ(2);
185 - res[2].name = "io_base";
186 - res[2].flags = IORESOURCE_IO;
190 - res[3].name = "mem_base";
191 - res[3].flags = IORESOURCE_MEM;
192 - res[3].start = AR71XX_PCI_MEM_BASE;
193 - res[3].end = AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE - 1;
195 - pdev = platform_device_register_simple("ar71xx-pci", -1,
196 - res, ARRAY_SIZE(res));
200 -static struct platform_device *
201 -ath79_register_pci_ar724x(int id,
202 - unsigned long cfg_base,
203 - unsigned long ctrl_base,
204 - unsigned long crp_base,
205 - unsigned long mem_base,
206 - unsigned long mem_size,
207 - unsigned long io_base,
210 - struct platform_device *pdev;
211 - struct resource res[6];
213 - memset(res, 0, sizeof(res));
215 - res[0].name = "cfg_base";
216 - res[0].flags = IORESOURCE_MEM;
217 - res[0].start = cfg_base;
218 - res[0].end = cfg_base + AR724X_PCI_CFG_SIZE - 1;
220 - res[1].name = "ctrl_base";
221 - res[1].flags = IORESOURCE_MEM;
222 - res[1].start = ctrl_base;
223 - res[1].end = ctrl_base + AR724X_PCI_CTRL_SIZE - 1;
225 - res[2].flags = IORESOURCE_IRQ;
226 - res[2].start = irq;
229 - res[3].name = "mem_base";
230 - res[3].flags = IORESOURCE_MEM;
231 - res[3].start = mem_base;
232 - res[3].end = mem_base + mem_size - 1;
234 - res[4].name = "io_base";
235 - res[4].flags = IORESOURCE_IO;
236 - res[4].start = io_base;
237 - res[4].end = io_base;
239 - res[5].name = "crp_base";
240 - res[5].flags = IORESOURCE_MEM;
241 - res[5].start = crp_base;
242 - res[5].end = crp_base + AR724X_PCI_CRP_SIZE - 1;
244 - pdev = platform_device_register_simple("ar724x-pci", id,
245 - res, ARRAY_SIZE(res));
249 -int __init ath79_register_pci(void)
251 - struct platform_device *pdev = NULL;
253 - if (soc_is_ar71xx()) {
254 - pdev = ath79_register_pci_ar71xx();
255 - } else if (soc_is_ar724x()) {
256 - pdev = ath79_register_pci_ar724x(-1,
257 - AR724X_PCI_CFG_BASE,
258 - AR724X_PCI_CTRL_BASE,
259 - AR724X_PCI_CRP_BASE,
260 - AR724X_PCI_MEM_BASE,
261 - AR724X_PCI_MEM_SIZE,
264 - } else if (soc_is_ar9342() ||
268 - bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
269 - if ((bootstrap & AR934X_BOOTSTRAP_PCIE_RC) == 0)
272 - pdev = ath79_register_pci_ar724x(-1,
273 - AR724X_PCI_CFG_BASE,
274 - AR724X_PCI_CTRL_BASE,
275 - AR724X_PCI_CRP_BASE,
276 - AR724X_PCI_MEM_BASE,
277 - AR724X_PCI_MEM_SIZE,
280 - } else if (soc_is_qca9558()) {
281 - pdev = ath79_register_pci_ar724x(0,
282 - QCA955X_PCI_CFG_BASE0,
283 - QCA955X_PCI_CTRL_BASE0,
284 - QCA955X_PCI_CRP_BASE0,
285 - QCA955X_PCI_MEM_BASE0,
286 - QCA955X_PCI_MEM_SIZE,
290 - pdev = ath79_register_pci_ar724x(1,
291 - QCA955X_PCI_CFG_BASE1,
292 - QCA955X_PCI_CTRL_BASE1,
293 - QCA955X_PCI_CRP_BASE1,
294 - QCA955X_PCI_MEM_BASE1,
295 - QCA955X_PCI_MEM_SIZE,
299 - /* No PCI support */
304 - pr_err("unable to register PCI controller device\n");
306 - return pdev ? 0 : -ENODEV;
308 --- a/arch/mips/ath79/pci.h
312 - * Atheros AR71XX/AR724X PCI support
314 - * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
315 - * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
316 - * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
318 - * This program is free software; you can redistribute it and/or modify it
319 - * under the terms of the GNU General Public License version 2 as published
320 - * by the Free Software Foundation.
323 -#ifndef _ATH79_PCI_H
324 -#define _ATH79_PCI_H
326 -struct ath79_pci_irq {
334 -void ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map);
335 -void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev));
336 -int ath79_register_pci(void);
339 -ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {}
341 -ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {}
342 -static inline int ath79_register_pci(void) { return 0; }
345 -#endif /* _ATH79_PCI_H */
346 --- a/arch/mips/pci/Makefile
347 +++ b/arch/mips/pci/Makefile
348 @@ -29,6 +29,7 @@ obj-$(CONFIG_MIPS_PCI_VIRTIO) += pci-vir
350 # These are still pretty much in the old state, watch, go blind.
352 +obj-$(CONFIG_ATH79) += fixup-ath79.o
353 obj-$(CONFIG_LASAT) += pci-lasat.o
354 obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
355 obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o
357 +++ b/arch/mips/pci/fixup-ath79.c
360 + * Copyright (C) 2018 John Crispin <john@phrozen.org>
362 + * This program is free software; you can redistribute it and/or modify it
363 + * under the terms of the GNU General Public License version 2 as published
364 + * by the Free Software Foundation.
367 +#include <linux/pci.h>
368 +//#include <linux/of_irq.h>
369 +#include <linux/of_pci.h>
371 +int pcibios_plat_dev_init(struct pci_dev *dev)
373 + return PCIBIOS_SUCCESSFUL;
376 +int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
378 + return of_irq_parse_and_map_pci(dev, slot, pin);