Root/target/linux/ar71xx/patches-3.3/100-MIPS-ath79-separate-common-PCI-code.patch

1From 9d9c0d49315520754660c8df3f42d93ecf7dba7a Mon Sep 17 00:00:00 2001
2From: Gabor Juhos <juhosg@openwrt.org>
3Date: Wed, 14 Mar 2012 10:29:21 +0100
4Subject: [PATCH 05/47] MIPS: ath79: separate common PCI code
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9The 'pcibios_map_irq' and 'pcibios_plat_dev_init'
10are common functions and only instance one of them
11can be present in a single kernel.
12
13Currently these functions can be built only if the
14CONFIG_SOC_AR724X option is selected. However the
15ath79 platform contain support for the AR71XX SoCs,.
16The AR71XX SoCs have a differnet PCI controller,
17and those will require a different code.
18
19Move the common PCI code into a separeate file in
20order to be able to use that with other SoCs as
21well.
22
23Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
24Acked-by: René Bolldorf <xsecute@googlemail.com>
25Cc: linux-mips@linux-mips.org
26Patchwork: https://patchwork.linux-mips.org/patch/3485/
27Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
28---
29 arch/mips/ath79/Makefile | 1 +
30 arch/mips/ath79/pci.c | 46 +++++++++++++++++++++++++++++++++++++++++++
31 arch/mips/pci/pci-ath724x.c | 34 -------------------------------
32 3 files changed, 47 insertions(+), 34 deletions(-)
33 create mode 100644 arch/mips/ath79/pci.c
34
35--- a/arch/mips/ath79/Makefile
36+++ b/arch/mips/ath79/Makefile
37@@ -11,6 +11,7 @@
38 obj-y := prom.o setup.o irq.o common.o clock.o gpio.o
39 
40 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
41+obj-$(CONFIG_PCI) += pci.o
42 
43 #
44 # Devices
45--- /dev/null
46+++ b/arch/mips/ath79/pci.c
47@@ -0,0 +1,46 @@
48+/*
49+ * Atheros AR71XX/AR724X specific PCI setup code
50+ *
51+ * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
52+ *
53+ * This program is free software; you can redistribute it and/or modify it
54+ * under the terms of the GNU General Public License version 2 as published
55+ * by the Free Software Foundation.
56+ */
57+
58+#include <linux/pci.h>
59+#include <asm/mach-ath79/pci-ath724x.h>
60+
61+static struct ath724x_pci_data *pci_data;
62+static int pci_data_size;
63+
64+void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
65+{
66+ pci_data = data;
67+ pci_data_size = size;
68+}
69+
70+int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
71+{
72+ unsigned int devfn = dev->devfn;
73+ int irq = -1;
74+
75+ if (devfn > pci_data_size - 1)
76+ return irq;
77+
78+ irq = pci_data[devfn].irq;
79+
80+ return irq;
81+}
82+
83+int pcibios_plat_dev_init(struct pci_dev *dev)
84+{
85+ unsigned int devfn = dev->devfn;
86+
87+ if (devfn > pci_data_size - 1)
88+ return PCIBIOS_DEVICE_NOT_FOUND;
89+
90+ dev->dev.platform_data = pci_data[devfn].pdata;
91+
92+ return PCIBIOS_SUCCESSFUL;
93+}
94--- a/arch/mips/pci/pci-ath724x.c
95+++ b/arch/mips/pci/pci-ath724x.c
96@@ -9,7 +9,6 @@
97  */
98 
99 #include <linux/pci.h>
100-#include <asm/mach-ath79/pci-ath724x.h>
101 
102 #define reg_read(_phys) (*(unsigned int *) KSEG1ADDR(_phys))
103 #define reg_write(_phys, _val) ((*(unsigned int *) KSEG1ADDR(_phys)) = (_val))
104@@ -19,8 +18,6 @@
105 #define ATH724X_PCI_MEM_SIZE 0x08000000
106 
107 static DEFINE_SPINLOCK(ath724x_pci_lock);
108-static struct ath724x_pci_data *pci_data;
109-static int pci_data_size;
110 
111 static int ath724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
112                 int size, uint32_t *value)
113@@ -133,37 +130,6 @@ static struct pci_controller ath724x_pci
114     .mem_resource = &ath724x_mem_resource,
115 };
116 
117-void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
118-{
119- pci_data = data;
120- pci_data_size = size;
121-}
122-
123-int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
124-{
125- unsigned int devfn = dev->devfn;
126- int irq = -1;
127-
128- if (devfn > pci_data_size - 1)
129- return irq;
130-
131- irq = pci_data[devfn].irq;
132-
133- return irq;
134-}
135-
136-int pcibios_plat_dev_init(struct pci_dev *dev)
137-{
138- unsigned int devfn = dev->devfn;
139-
140- if (devfn > pci_data_size - 1)
141- return PCIBIOS_DEVICE_NOT_FOUND;
142-
143- dev->dev.platform_data = pci_data[devfn].pdata;
144-
145- return PCIBIOS_SUCCESSFUL;
146-}
147-
148 static int __init ath724x_pcibios_init(void)
149 {
150     register_pci_controller(&ath724x_pci_controller);
151

Archive Download this file



interactive