2
0

0022-MIPS-ath79-drop-pci.c.patch 9.4 KB

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