1 From 9d9c0d49315520754660c8df3f42d93ecf7dba7a Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Wed, 14 Mar 2012 10:29:21 +0100
4 Subject: [PATCH 05/47] MIPS: ath79: separate common PCI code
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The 'pcibios_map_irq' and 'pcibios_plat_dev_init'
10 are common functions and only instance one of them
11 can be present in a single kernel.
13 Currently these functions can be built only if the
14 CONFIG_SOC_AR724X option is selected. However the
15 ath79 platform contain support for the AR71XX SoCs,.
16 The AR71XX SoCs have a differnet PCI controller,
17 and those will require a different code.
19 Move the common PCI code into a separeate file in
20 order to be able to use that with other SoCs as
23 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
24 Acked-by: René Bolldorf <xsecute@googlemail.com>
25 Cc: linux-mips@linux-mips.org
26 Patchwork: https://patchwork.linux-mips.org/patch/3485/
27 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
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
35 --- a/arch/mips/ath79/Makefile
36 +++ b/arch/mips/ath79/Makefile
38 obj-y := prom.o setup.o irq.o common.o clock.o gpio.o
40 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
41 +obj-$(CONFIG_PCI) += pci.o
46 +++ b/arch/mips/ath79/pci.c
49 + * Atheros AR71XX/AR724X specific PCI setup code
51 + * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
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.
58 +#include <linux/pci.h>
59 +#include <asm/mach-ath79/pci-ath724x.h>
61 +static struct ath724x_pci_data *pci_data;
62 +static int pci_data_size;
64 +void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
67 + pci_data_size = size;
70 +int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
72 + unsigned int devfn = dev->devfn;
75 + if (devfn > pci_data_size - 1)
78 + irq = pci_data[devfn].irq;
83 +int pcibios_plat_dev_init(struct pci_dev *dev)
85 + unsigned int devfn = dev->devfn;
87 + if (devfn > pci_data_size - 1)
88 + return PCIBIOS_DEVICE_NOT_FOUND;
90 + dev->dev.platform_data = pci_data[devfn].pdata;
92 + return PCIBIOS_SUCCESSFUL;
94 --- a/arch/mips/pci/pci-ath724x.c
95 +++ b/arch/mips/pci/pci-ath724x.c
99 #include <linux/pci.h>
100 -#include <asm/mach-ath79/pci-ath724x.h>
102 #define reg_read(_phys) (*(unsigned int *) KSEG1ADDR(_phys))
103 #define reg_write(_phys, _val) ((*(unsigned int *) KSEG1ADDR(_phys)) = (_val))
105 #define ATH724X_PCI_MEM_SIZE 0x08000000
107 static DEFINE_SPINLOCK(ath724x_pci_lock);
108 -static struct ath724x_pci_data *pci_data;
109 -static int pci_data_size;
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,
117 -void ath724x_pci_add_data(struct ath724x_pci_data *data, int size)
120 - pci_data_size = size;
123 -int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
125 - unsigned int devfn = dev->devfn;
128 - if (devfn > pci_data_size - 1)
131 - irq = pci_data[devfn].irq;
136 -int pcibios_plat_dev_init(struct pci_dev *dev)
138 - unsigned int devfn = dev->devfn;
140 - if (devfn > pci_data_size - 1)
141 - return PCIBIOS_DEVICE_NOT_FOUND;
143 - dev->dev.platform_data = pci_data[devfn].pdata;
145 - return PCIBIOS_SUCCESSFUL;
148 static int __init ath724x_pcibios_init(void)
150 register_pci_controller(&ath724x_pci_controller);