aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorlinas <linas@austin.ibm.com>2005-11-03 19:42:26 -0500
committerPaul Mackerras <paulus@samba.org>2005-11-09 19:30:25 -0500
commitae65a391caf1830aea9e4cadd69bb1aa69aad492 (patch)
tree7174b40718cbf42e4b1bddaa5dbe4bcdcf456da0 /arch
parent77ac166fba909d520b9a21dcc28cb49081e31033 (diff)
[PATCH] ppc64: uniform usage of bus unit id interfaces
01-pci-dn-uniformization.patch This patch changes the rtas_pci interface to use the new struct pci_dn structure for two routines that work with pci device nodes. This patch also does some minor janitorial work: it uses some handy macros and cleans up some trailing whitespace in the affected file. Signed-off-by: Linas Vepstas <linas@austin.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/ppc64/kernel/eeh.c4
-rw-r--r--arch/ppc64/kernel/rtas_pci.c47
2 files changed, 24 insertions, 27 deletions
diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c
index 035d1b14a207..eedf21d5f3b7 100644
--- a/arch/ppc64/kernel/eeh.c
+++ b/arch/ppc64/kernel/eeh.c
@@ -71,10 +71,6 @@
71 * and sent out for processing. 71 * and sent out for processing.
72 */ 72 */
73 73
74/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
75#define BUID_HI(buid) ((buid) >> 32)
76#define BUID_LO(buid) ((buid) & 0xffffffff)
77
78/* EEH event workqueue setup. */ 74/* EEH event workqueue setup. */
79static DEFINE_SPINLOCK(eeh_eventlist_lock); 75static DEFINE_SPINLOCK(eeh_eventlist_lock);
80LIST_HEAD(eeh_eventlist); 76LIST_HEAD(eeh_eventlist);
diff --git a/arch/ppc64/kernel/rtas_pci.c b/arch/ppc64/kernel/rtas_pci.c
index 3c3f19192fcc..0e5a8e116653 100644
--- a/arch/ppc64/kernel/rtas_pci.c
+++ b/arch/ppc64/kernel/rtas_pci.c
@@ -5,19 +5,19 @@
5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM 5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
6 * 6 *
7 * RTAS specific routines for PCI. 7 * RTAS specific routines for PCI.
8 * 8 *
9 * Based on code from pci.c, chrp_pci.c and pSeries_pci.c 9 * Based on code from pci.c, chrp_pci.c and pSeries_pci.c
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. 14 * (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -47,7 +47,7 @@ static int write_pci_config;
47static int ibm_read_pci_config; 47static int ibm_read_pci_config;
48static int ibm_write_pci_config; 48static int ibm_write_pci_config;
49 49
50static int config_access_valid(struct pci_dn *dn, int where) 50static inline int config_access_valid(struct pci_dn *dn, int where)
51{ 51{
52 if (where < 256) 52 if (where < 256)
53 return 1; 53 return 1;
@@ -72,16 +72,14 @@ static int of_device_available(struct device_node * dn)
72 return 0; 72 return 0;
73} 73}
74 74
75static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val) 75static int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
76{ 76{
77 int returnval = -1; 77 int returnval = -1;
78 unsigned long buid, addr; 78 unsigned long buid, addr;
79 int ret; 79 int ret;
80 struct pci_dn *pdn;
81 80
82 if (!dn || !dn->data) 81 if (!pdn)
83 return PCIBIOS_DEVICE_NOT_FOUND; 82 return PCIBIOS_DEVICE_NOT_FOUND;
84 pdn = dn->data;
85 if (!config_access_valid(pdn, where)) 83 if (!config_access_valid(pdn, where))
86 return PCIBIOS_BAD_REGISTER_NUMBER; 84 return PCIBIOS_BAD_REGISTER_NUMBER;
87 85
@@ -90,7 +88,7 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va
90 buid = pdn->phb->buid; 88 buid = pdn->phb->buid;
91 if (buid) { 89 if (buid) {
92 ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, 90 ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval,
93 addr, buid >> 32, buid & 0xffffffff, size); 91 addr, BUID_HI(buid), BUID_LO(buid), size);
94 } else { 92 } else {
95 ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, size); 93 ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, size);
96 } 94 }
@@ -100,7 +98,7 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va
100 return PCIBIOS_DEVICE_NOT_FOUND; 98 return PCIBIOS_DEVICE_NOT_FOUND;
101 99
102 if (returnval == EEH_IO_ERROR_VALUE(size) && 100 if (returnval == EEH_IO_ERROR_VALUE(size) &&
103 eeh_dn_check_failure (dn, NULL)) 101 eeh_dn_check_failure (pdn->node, NULL))
104 return PCIBIOS_DEVICE_NOT_FOUND; 102 return PCIBIOS_DEVICE_NOT_FOUND;
105 103
106 return PCIBIOS_SUCCESSFUL; 104 return PCIBIOS_SUCCESSFUL;
@@ -118,23 +116,23 @@ static int rtas_pci_read_config(struct pci_bus *bus,
118 busdn = bus->sysdata; /* must be a phb */ 116 busdn = bus->sysdata; /* must be a phb */
119 117
120 /* Search only direct children of the bus */ 118 /* Search only direct children of the bus */
121 for (dn = busdn->child; dn; dn = dn->sibling) 119 for (dn = busdn->child; dn; dn = dn->sibling) {
122 if (dn->data && PCI_DN(dn)->devfn == devfn 120 struct pci_dn *pdn = PCI_DN(dn);
121 if (pdn && pdn->devfn == devfn
123 && of_device_available(dn)) 122 && of_device_available(dn))
124 return rtas_read_config(dn, where, size, val); 123 return rtas_read_config(pdn, where, size, val);
124 }
125 125
126 return PCIBIOS_DEVICE_NOT_FOUND; 126 return PCIBIOS_DEVICE_NOT_FOUND;
127} 127}
128 128
129int rtas_write_config(struct device_node *dn, int where, int size, u32 val) 129int rtas_write_config(struct pci_dn *pdn, int where, int size, u32 val)
130{ 130{
131 unsigned long buid, addr; 131 unsigned long buid, addr;
132 int ret; 132 int ret;
133 struct pci_dn *pdn;
134 133
135 if (!dn || !dn->data) 134 if (!pdn)
136 return PCIBIOS_DEVICE_NOT_FOUND; 135 return PCIBIOS_DEVICE_NOT_FOUND;
137 pdn = dn->data;
138 if (!config_access_valid(pdn, where)) 136 if (!config_access_valid(pdn, where))
139 return PCIBIOS_BAD_REGISTER_NUMBER; 137 return PCIBIOS_BAD_REGISTER_NUMBER;
140 138
@@ -142,7 +140,8 @@ int rtas_write_config(struct device_node *dn, int where, int size, u32 val)
142 (pdn->devfn << 8) | (where & 0xff); 140 (pdn->devfn << 8) | (where & 0xff);
143 buid = pdn->phb->buid; 141 buid = pdn->phb->buid;
144 if (buid) { 142 if (buid) {
145 ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, size, (ulong) val); 143 ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr,
144 BUID_HI(buid), BUID_LO(buid), size, (ulong) val);
146 } else { 145 } else {
147 ret = rtas_call(write_pci_config, 3, 1, NULL, addr, size, (ulong)val); 146 ret = rtas_call(write_pci_config, 3, 1, NULL, addr, size, (ulong)val);
148 } 147 }
@@ -165,10 +164,12 @@ static int rtas_pci_write_config(struct pci_bus *bus,
165 busdn = bus->sysdata; /* must be a phb */ 164 busdn = bus->sysdata; /* must be a phb */
166 165
167 /* Search only direct children of the bus */ 166 /* Search only direct children of the bus */
168 for (dn = busdn->child; dn; dn = dn->sibling) 167 for (dn = busdn->child; dn; dn = dn->sibling) {
169 if (dn->data && PCI_DN(dn)->devfn == devfn 168 struct pci_dn *pdn = PCI_DN(dn);
169 if (pdn && pdn->devfn == devfn
170 && of_device_available(dn)) 170 && of_device_available(dn))
171 return rtas_write_config(dn, where, size, val); 171 return rtas_write_config(pdn, where, size, val);
172 }
172 return PCIBIOS_DEVICE_NOT_FOUND; 173 return PCIBIOS_DEVICE_NOT_FOUND;
173} 174}
174 175
@@ -221,7 +222,7 @@ static void python_countermeasures(struct device_node *dev,
221 /* Python's register file is 1 MB in size. */ 222 /* Python's register file is 1 MB in size. */
222 chip_regs = ioremap(reg_struct.address & ~(0xfffffUL), 0x100000); 223 chip_regs = ioremap(reg_struct.address & ~(0xfffffUL), 0x100000);
223 224
224 /* 225 /*
225 * Firmware doesn't always clear this bit which is critical 226 * Firmware doesn't always clear this bit which is critical
226 * for good performance - Anton 227 * for good performance - Anton
227 */ 228 */
@@ -292,7 +293,7 @@ static int phb_set_bus_ranges(struct device_node *dev,
292 if (bus_range == NULL || len < 2 * sizeof(int)) { 293 if (bus_range == NULL || len < 2 * sizeof(int)) {
293 return 1; 294 return 1;
294 } 295 }
295 296
296 phb->first_busno = bus_range[0]; 297 phb->first_busno = bus_range[0];
297 phb->last_busno = bus_range[1]; 298 phb->last_busno = bus_range[1];
298 299