1
0

0029-MIPS-ath79-drop-legacy-pci-code.patch 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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
  5. With the target now being fully OF based, we can drop the legacy pci
  6. platform code. The only bits that we need to keep is the fixup code
  7. which we move to its own code file.
  8. Signed-off-by: John Crispin <john@phrozen.org>
  9. ---
  10. arch/mips/ath79/Makefile | 1 -
  11. arch/mips/ath79/pci.c | 273 --------------------------------------------
  12. arch/mips/ath79/pci.h | 35 ------
  13. arch/mips/pci/Makefile | 1 +
  14. arch/mips/pci/fixup-ath79.c | 21 ++++
  15. 5 files changed, 22 insertions(+), 309 deletions(-)
  16. delete mode 100644 arch/mips/ath79/pci.c
  17. delete mode 100644 arch/mips/ath79/pci.h
  18. create mode 100644 arch/mips/pci/fixup-ath79.c
  19. --- a/arch/mips/ath79/Makefile
  20. +++ b/arch/mips/ath79/Makefile
  21. @@ -11,7 +11,6 @@
  22. obj-y := prom.o setup.o common.o clock.o
  23. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  24. -obj-$(CONFIG_PCI) += pci.o
  25. #
  26. # Devices
  27. --- a/arch/mips/ath79/pci.c
  28. +++ /dev/null
  29. @@ -1,273 +0,0 @@
  30. -/*
  31. - * Atheros AR71XX/AR724X specific PCI setup code
  32. - *
  33. - * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
  34. - * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  35. - * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  36. - *
  37. - * Parts of this file are based on Atheros' 2.6.15 BSP
  38. - *
  39. - * This program is free software; you can redistribute it and/or modify it
  40. - * under the terms of the GNU General Public License version 2 as published
  41. - * by the Free Software Foundation.
  42. - */
  43. -
  44. -#include <linux/init.h>
  45. -#include <linux/pci.h>
  46. -#include <linux/resource.h>
  47. -#include <linux/platform_device.h>
  48. -#include <asm/mach-ath79/ar71xx_regs.h>
  49. -#include <asm/mach-ath79/ath79.h>
  50. -#include <asm/mach-ath79/irq.h>
  51. -#include "pci.h"
  52. -
  53. -static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev);
  54. -static const struct ath79_pci_irq *ath79_pci_irq_map;
  55. -static unsigned ath79_pci_nr_irqs;
  56. -
  57. -static const struct ath79_pci_irq ar71xx_pci_irq_map[] = {
  58. - {
  59. - .slot = 17,
  60. - .pin = 1,
  61. - .irq = ATH79_PCI_IRQ(0),
  62. - }, {
  63. - .slot = 18,
  64. - .pin = 1,
  65. - .irq = ATH79_PCI_IRQ(1),
  66. - }, {
  67. - .slot = 19,
  68. - .pin = 1,
  69. - .irq = ATH79_PCI_IRQ(2),
  70. - }
  71. -};
  72. -
  73. -static const struct ath79_pci_irq ar724x_pci_irq_map[] = {
  74. - {
  75. - .slot = 0,
  76. - .pin = 1,
  77. - .irq = ATH79_PCI_IRQ(0),
  78. - }
  79. -};
  80. -
  81. -static const struct ath79_pci_irq qca955x_pci_irq_map[] = {
  82. - {
  83. - .bus = 0,
  84. - .slot = 0,
  85. - .pin = 1,
  86. - .irq = ATH79_PCI_IRQ(0),
  87. - },
  88. - {
  89. - .bus = 1,
  90. - .slot = 0,
  91. - .pin = 1,
  92. - .irq = ATH79_PCI_IRQ(1),
  93. - },
  94. -};
  95. -
  96. -int pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
  97. -{
  98. - int irq = -1;
  99. - int i;
  100. -
  101. - if (ath79_pci_nr_irqs == 0 ||
  102. - ath79_pci_irq_map == NULL) {
  103. - if (soc_is_ar71xx()) {
  104. - ath79_pci_irq_map = ar71xx_pci_irq_map;
  105. - ath79_pci_nr_irqs = ARRAY_SIZE(ar71xx_pci_irq_map);
  106. - } else if (soc_is_ar724x() ||
  107. - soc_is_ar9342() ||
  108. - soc_is_ar9344()) {
  109. - ath79_pci_irq_map = ar724x_pci_irq_map;
  110. - ath79_pci_nr_irqs = ARRAY_SIZE(ar724x_pci_irq_map);
  111. - } else if (soc_is_qca955x()) {
  112. - ath79_pci_irq_map = qca955x_pci_irq_map;
  113. - ath79_pci_nr_irqs = ARRAY_SIZE(qca955x_pci_irq_map);
  114. - } else {
  115. - pr_crit("pci %s: invalid irq map\n",
  116. - pci_name((struct pci_dev *) dev));
  117. - return irq;
  118. - }
  119. - }
  120. -
  121. - for (i = 0; i < ath79_pci_nr_irqs; i++) {
  122. - const struct ath79_pci_irq *entry;
  123. -
  124. - entry = &ath79_pci_irq_map[i];
  125. - if (entry->bus == dev->bus->number &&
  126. - entry->slot == slot &&
  127. - entry->pin == pin) {
  128. - irq = entry->irq;
  129. - break;
  130. - }
  131. - }
  132. -
  133. - if (irq < 0)
  134. - pr_crit("pci %s: no irq found for pin %u\n",
  135. - pci_name((struct pci_dev *) dev), pin);
  136. - else
  137. - pr_info("pci %s: using irq %d for pin %u\n",
  138. - pci_name((struct pci_dev *) dev), irq, pin);
  139. -
  140. - return irq;
  141. -}
  142. -
  143. -int pcibios_plat_dev_init(struct pci_dev *dev)
  144. -{
  145. - if (ath79_pci_plat_dev_init)
  146. - return ath79_pci_plat_dev_init(dev);
  147. -
  148. - return 0;
  149. -}
  150. -
  151. -void __init ath79_pci_set_irq_map(unsigned nr_irqs,
  152. - const struct ath79_pci_irq *map)
  153. -{
  154. - ath79_pci_nr_irqs = nr_irqs;
  155. - ath79_pci_irq_map = map;
  156. -}
  157. -
  158. -void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev))
  159. -{
  160. - ath79_pci_plat_dev_init = func;
  161. -}
  162. -
  163. -static struct platform_device *
  164. -ath79_register_pci_ar71xx(void)
  165. -{
  166. - struct platform_device *pdev;
  167. - struct resource res[4];
  168. -
  169. - memset(res, 0, sizeof(res));
  170. -
  171. - res[0].name = "cfg_base";
  172. - res[0].flags = IORESOURCE_MEM;
  173. - res[0].start = AR71XX_PCI_CFG_BASE;
  174. - res[0].end = AR71XX_PCI_CFG_BASE + AR71XX_PCI_CFG_SIZE - 1;
  175. -
  176. - res[1].flags = IORESOURCE_IRQ;
  177. - res[1].start = ATH79_CPU_IRQ(2);
  178. - res[1].end = ATH79_CPU_IRQ(2);
  179. -
  180. - res[2].name = "io_base";
  181. - res[2].flags = IORESOURCE_IO;
  182. - res[2].start = 0;
  183. - res[2].end = 0;
  184. -
  185. - res[3].name = "mem_base";
  186. - res[3].flags = IORESOURCE_MEM;
  187. - res[3].start = AR71XX_PCI_MEM_BASE;
  188. - res[3].end = AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE - 1;
  189. -
  190. - pdev = platform_device_register_simple("ar71xx-pci", -1,
  191. - res, ARRAY_SIZE(res));
  192. - return pdev;
  193. -}
  194. -
  195. -static struct platform_device *
  196. -ath79_register_pci_ar724x(int id,
  197. - unsigned long cfg_base,
  198. - unsigned long ctrl_base,
  199. - unsigned long crp_base,
  200. - unsigned long mem_base,
  201. - unsigned long mem_size,
  202. - unsigned long io_base,
  203. - int irq)
  204. -{
  205. - struct platform_device *pdev;
  206. - struct resource res[6];
  207. -
  208. - memset(res, 0, sizeof(res));
  209. -
  210. - res[0].name = "cfg_base";
  211. - res[0].flags = IORESOURCE_MEM;
  212. - res[0].start = cfg_base;
  213. - res[0].end = cfg_base + AR724X_PCI_CFG_SIZE - 1;
  214. -
  215. - res[1].name = "ctrl_base";
  216. - res[1].flags = IORESOURCE_MEM;
  217. - res[1].start = ctrl_base;
  218. - res[1].end = ctrl_base + AR724X_PCI_CTRL_SIZE - 1;
  219. -
  220. - res[2].flags = IORESOURCE_IRQ;
  221. - res[2].start = irq;
  222. - res[2].end = irq;
  223. -
  224. - res[3].name = "mem_base";
  225. - res[3].flags = IORESOURCE_MEM;
  226. - res[3].start = mem_base;
  227. - res[3].end = mem_base + mem_size - 1;
  228. -
  229. - res[4].name = "io_base";
  230. - res[4].flags = IORESOURCE_IO;
  231. - res[4].start = io_base;
  232. - res[4].end = io_base;
  233. -
  234. - res[5].name = "crp_base";
  235. - res[5].flags = IORESOURCE_MEM;
  236. - res[5].start = crp_base;
  237. - res[5].end = crp_base + AR724X_PCI_CRP_SIZE - 1;
  238. -
  239. - pdev = platform_device_register_simple("ar724x-pci", id,
  240. - res, ARRAY_SIZE(res));
  241. - return pdev;
  242. -}
  243. -
  244. -int __init ath79_register_pci(void)
  245. -{
  246. - struct platform_device *pdev = NULL;
  247. -
  248. - if (soc_is_ar71xx()) {
  249. - pdev = ath79_register_pci_ar71xx();
  250. - } else if (soc_is_ar724x()) {
  251. - pdev = ath79_register_pci_ar724x(-1,
  252. - AR724X_PCI_CFG_BASE,
  253. - AR724X_PCI_CTRL_BASE,
  254. - AR724X_PCI_CRP_BASE,
  255. - AR724X_PCI_MEM_BASE,
  256. - AR724X_PCI_MEM_SIZE,
  257. - 0,
  258. - ATH79_CPU_IRQ(2));
  259. - } else if (soc_is_ar9342() ||
  260. - soc_is_ar9344()) {
  261. - u32 bootstrap;
  262. -
  263. - bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
  264. - if ((bootstrap & AR934X_BOOTSTRAP_PCIE_RC) == 0)
  265. - return -ENODEV;
  266. -
  267. - pdev = ath79_register_pci_ar724x(-1,
  268. - AR724X_PCI_CFG_BASE,
  269. - AR724X_PCI_CTRL_BASE,
  270. - AR724X_PCI_CRP_BASE,
  271. - AR724X_PCI_MEM_BASE,
  272. - AR724X_PCI_MEM_SIZE,
  273. - 0,
  274. - ATH79_IP2_IRQ(0));
  275. - } else if (soc_is_qca9558()) {
  276. - pdev = ath79_register_pci_ar724x(0,
  277. - QCA955X_PCI_CFG_BASE0,
  278. - QCA955X_PCI_CTRL_BASE0,
  279. - QCA955X_PCI_CRP_BASE0,
  280. - QCA955X_PCI_MEM_BASE0,
  281. - QCA955X_PCI_MEM_SIZE,
  282. - 0,
  283. - ATH79_IP2_IRQ(0));
  284. -
  285. - pdev = ath79_register_pci_ar724x(1,
  286. - QCA955X_PCI_CFG_BASE1,
  287. - QCA955X_PCI_CTRL_BASE1,
  288. - QCA955X_PCI_CRP_BASE1,
  289. - QCA955X_PCI_MEM_BASE1,
  290. - QCA955X_PCI_MEM_SIZE,
  291. - 1,
  292. - ATH79_IP3_IRQ(2));
  293. - } else {
  294. - /* No PCI support */
  295. - return -ENODEV;
  296. - }
  297. -
  298. - if (!pdev)
  299. - pr_err("unable to register PCI controller device\n");
  300. -
  301. - return pdev ? 0 : -ENODEV;
  302. -}
  303. --- a/arch/mips/ath79/pci.h
  304. +++ /dev/null
  305. @@ -1,35 +0,0 @@
  306. -/*
  307. - * Atheros AR71XX/AR724X PCI support
  308. - *
  309. - * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
  310. - * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  311. - * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  312. - *
  313. - * This program is free software; you can redistribute it and/or modify it
  314. - * under the terms of the GNU General Public License version 2 as published
  315. - * by the Free Software Foundation.
  316. - */
  317. -
  318. -#ifndef _ATH79_PCI_H
  319. -#define _ATH79_PCI_H
  320. -
  321. -struct ath79_pci_irq {
  322. - int bus;
  323. - u8 slot;
  324. - u8 pin;
  325. - int irq;
  326. -};
  327. -
  328. -#ifdef CONFIG_PCI
  329. -void ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map);
  330. -void ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev));
  331. -int ath79_register_pci(void);
  332. -#else
  333. -static inline void
  334. -ath79_pci_set_irq_map(unsigned nr_irqs, const struct ath79_pci_irq *map) {}
  335. -static inline void
  336. -ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *)) {}
  337. -static inline int ath79_register_pci(void) { return 0; }
  338. -#endif
  339. -
  340. -#endif /* _ATH79_PCI_H */
  341. --- a/arch/mips/pci/Makefile
  342. +++ b/arch/mips/pci/Makefile
  343. @@ -29,6 +29,7 @@ obj-$(CONFIG_MIPS_PCI_VIRTIO) += pci-vir
  344. #
  345. # These are still pretty much in the old state, watch, go blind.
  346. #
  347. +obj-$(CONFIG_ATH79) += fixup-ath79.o
  348. obj-$(CONFIG_LASAT) += pci-lasat.o
  349. obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
  350. obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o
  351. --- /dev/null
  352. +++ b/arch/mips/pci/fixup-ath79.c
  353. @@ -0,0 +1,21 @@
  354. +/*
  355. + * Copyright (C) 2018 John Crispin <john@phrozen.org>
  356. + *
  357. + * This program is free software; you can redistribute it and/or modify it
  358. + * under the terms of the GNU General Public License version 2 as published
  359. + * by the Free Software Foundation.
  360. + */
  361. +
  362. +#include <linux/pci.h>
  363. +//#include <linux/of_irq.h>
  364. +#include <linux/of_pci.h>
  365. +
  366. +int pcibios_plat_dev_init(struct pci_dev *dev)
  367. +{
  368. + return PCIBIOS_SUCCESSFUL;
  369. +}
  370. +
  371. +int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  372. +{
  373. + return of_irq_parse_and_map_pci(dev, slot, pin);
  374. +}