diff options
author | Olof Johansson <olof@lixom.net> | 2006-09-06 15:42:08 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-09-13 04:39:53 -0400 |
commit | 1e76875e51266a5c43f601ecf08a92be5769228c (patch) | |
tree | 62867c80d57bd5fc335917dc0c2bcd26dfcc934b /arch/powerpc/platforms/pasemi/pci.c | |
parent | b3ebd1d862d6c23caa58e40d341eefc426f835e1 (diff) |
[POWERPC] powerpc: PA Semi PWRficient platform support
Base patch for PA6T and PA6T-1682M. This introduces the
arch/powerpc/platform/pasemi directory, together with basic
implementations for various setup.
Much of this was based on other platform code, i.e. Maple, etc.
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/pasemi/pci.c')
-rw-r--r-- | arch/powerpc/platforms/pasemi/pci.c | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c new file mode 100644 index 000000000000..4679c5230413 --- /dev/null +++ b/arch/powerpc/platforms/pasemi/pci.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 PA Semi, Inc | ||
3 | * | ||
4 | * Authors: Kip Walker, PA Semi | ||
5 | * Olof Johansson, PA Semi | ||
6 | * | ||
7 | * Maintained by: Olof Johansson <olof@lixom.net> | ||
8 | * | ||
9 | * Based on arch/powerpc/platforms/maple/pci.c | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/pci.h> | ||
28 | |||
29 | #include <asm/pci-bridge.h> | ||
30 | #include <asm/machdep.h> | ||
31 | |||
32 | #include <asm/ppc-pci.h> | ||
33 | |||
34 | #define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off)) | ||
35 | |||
36 | #define CONFIG_OFFSET_VALID(off) ((off) < 4096) | ||
37 | |||
38 | static unsigned long pa_pxp_cfg_addr(struct pci_controller *hose, | ||
39 | u8 bus, u8 devfn, int offset) | ||
40 | { | ||
41 | return ((unsigned long)hose->cfg_data) + PA_PXP_CFA(bus, devfn, offset); | ||
42 | } | ||
43 | |||
44 | static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn, | ||
45 | int offset, int len, u32 *val) | ||
46 | { | ||
47 | struct pci_controller *hose; | ||
48 | unsigned long addr; | ||
49 | |||
50 | hose = pci_bus_to_host(bus); | ||
51 | if (!hose) | ||
52 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
53 | |||
54 | if (!CONFIG_OFFSET_VALID(offset)) | ||
55 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
56 | |||
57 | addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset); | ||
58 | |||
59 | /* | ||
60 | * Note: the caller has already checked that offset is | ||
61 | * suitably aligned and that len is 1, 2 or 4. | ||
62 | */ | ||
63 | switch (len) { | ||
64 | case 1: | ||
65 | *val = in_8((u8 *)addr); | ||
66 | break; | ||
67 | case 2: | ||
68 | *val = in_le16((u16 *)addr); | ||
69 | break; | ||
70 | default: | ||
71 | *val = in_le32((u32 *)addr); | ||
72 | break; | ||
73 | } | ||
74 | |||
75 | return PCIBIOS_SUCCESSFUL; | ||
76 | } | ||
77 | |||
78 | static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn, | ||
79 | int offset, int len, u32 val) | ||
80 | { | ||
81 | struct pci_controller *hose; | ||
82 | unsigned long addr; | ||
83 | |||
84 | hose = pci_bus_to_host(bus); | ||
85 | if (!hose) | ||
86 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
87 | |||
88 | if (!CONFIG_OFFSET_VALID(offset)) | ||
89 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
90 | |||
91 | addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset); | ||
92 | |||
93 | /* | ||
94 | * Note: the caller has already checked that offset is | ||
95 | * suitably aligned and that len is 1, 2 or 4. | ||
96 | */ | ||
97 | switch (len) { | ||
98 | case 1: | ||
99 | out_8((u8 *)addr, val); | ||
100 | (void) in_8((u8 *)addr); | ||
101 | break; | ||
102 | case 2: | ||
103 | out_le16((u16 *)addr, val); | ||
104 | (void) in_le16((u16 *)addr); | ||
105 | break; | ||
106 | default: | ||
107 | out_le32((u32 *)addr, val); | ||
108 | (void) in_le32((u32 *)addr); | ||
109 | break; | ||
110 | } | ||
111 | return PCIBIOS_SUCCESSFUL; | ||
112 | } | ||
113 | |||
114 | static struct pci_ops pa_pxp_ops = { | ||
115 | pa_pxp_read_config, | ||
116 | pa_pxp_write_config, | ||
117 | }; | ||
118 | |||
119 | static void __init setup_pa_pxp(struct pci_controller *hose) | ||
120 | { | ||
121 | hose->ops = &pa_pxp_ops; | ||
122 | hose->cfg_data = ioremap(0xe0000000, 0x10000000); | ||
123 | } | ||
124 | |||
125 | static int __init add_bridge(struct device_node *dev) | ||
126 | { | ||
127 | struct pci_controller *hose; | ||
128 | |||
129 | pr_debug("Adding PCI host bridge %s\n", dev->full_name); | ||
130 | |||
131 | hose = pcibios_alloc_controller(dev); | ||
132 | if (!hose) | ||
133 | return -ENOMEM; | ||
134 | |||
135 | hose->first_busno = 0; | ||
136 | hose->last_busno = 0xff; | ||
137 | |||
138 | setup_pa_pxp(hose); | ||
139 | |||
140 | printk(KERN_INFO "Found PA-PXP PCI host bridge.\n"); | ||
141 | |||
142 | /* Interpret the "ranges" property */ | ||
143 | /* This also maps the I/O region and sets isa_io/mem_base */ | ||
144 | pci_process_bridge_OF_ranges(hose, dev, 1); | ||
145 | pci_setup_phb_io(hose, 1); | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | |||
151 | void __init pas_pcibios_fixup(void) | ||
152 | { | ||
153 | struct pci_dev *dev = NULL; | ||
154 | |||
155 | for_each_pci_dev(dev) | ||
156 | pci_read_irq_line(dev); | ||
157 | } | ||
158 | |||
159 | static void __init pas_fixup_phb_resources(void) | ||
160 | { | ||
161 | struct pci_controller *hose, *tmp; | ||
162 | |||
163 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | ||
164 | unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base; | ||
165 | hose->io_resource.start += offset; | ||
166 | hose->io_resource.end += offset; | ||
167 | printk(KERN_INFO "PCI Host %d, io start: %lx; io end: %lx\n", | ||
168 | hose->global_number, | ||
169 | hose->io_resource.start, hose->io_resource.end); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | |||
174 | void __init pas_pci_init(void) | ||
175 | { | ||
176 | struct device_node *np, *root; | ||
177 | |||
178 | root = of_find_node_by_path("/"); | ||
179 | if (!root) { | ||
180 | printk(KERN_CRIT "pas_pci_init: can't find root " | ||
181 | "of device tree\n"); | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) | ||
186 | if (np->name && !strcmp(np->name, "pxp") && !add_bridge(np)) | ||
187 | of_node_get(np); | ||
188 | |||
189 | of_node_put(root); | ||
190 | |||
191 | pas_fixup_phb_resources(); | ||
192 | |||
193 | /* Setup the linkage between OF nodes and PHBs */ | ||
194 | pci_devs_phb_init(); | ||
195 | |||
196 | /* Use the common resource allocation mechanism */ | ||
197 | pci_probe_only = 1; | ||
198 | } | ||