diff options
-rw-r--r-- | arch/powerpc/kernel/rtas_pci.c | 6 | ||||
-rw-r--r-- | include/asm-powerpc/rtas.h | 16 |
2 files changed, 18 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c index 5a798ac6aecf..b4a0de79c060 100644 --- a/arch/powerpc/kernel/rtas_pci.c +++ b/arch/powerpc/kernel/rtas_pci.c | |||
@@ -81,8 +81,7 @@ int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val) | |||
81 | if (!config_access_valid(pdn, where)) | 81 | if (!config_access_valid(pdn, where)) |
82 | return PCIBIOS_BAD_REGISTER_NUMBER; | 82 | return PCIBIOS_BAD_REGISTER_NUMBER; |
83 | 83 | ||
84 | addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | | 84 | addr = rtas_config_addr(pdn->busno, pdn->devfn, where); |
85 | (pdn->devfn << 8) | (where & 0xff); | ||
86 | buid = pdn->phb->buid; | 85 | buid = pdn->phb->buid; |
87 | if (buid) { | 86 | if (buid) { |
88 | ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, | 87 | ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, |
@@ -134,8 +133,7 @@ int rtas_write_config(struct pci_dn *pdn, int where, int size, u32 val) | |||
134 | if (!config_access_valid(pdn, where)) | 133 | if (!config_access_valid(pdn, where)) |
135 | return PCIBIOS_BAD_REGISTER_NUMBER; | 134 | return PCIBIOS_BAD_REGISTER_NUMBER; |
136 | 135 | ||
137 | addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | | 136 | addr = rtas_config_addr(pdn->busno, pdn->devfn, where); |
138 | (pdn->devfn << 8) | (where & 0xff); | ||
139 | buid = pdn->phb->buid; | 137 | buid = pdn->phb->buid; |
140 | if (buid) { | 138 | if (buid) { |
141 | ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, | 139 | ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, |
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h index 82a27e9a041f..d34f9e1f242c 100644 --- a/include/asm-powerpc/rtas.h +++ b/include/asm-powerpc/rtas.h | |||
@@ -230,5 +230,21 @@ extern unsigned long rtas_rmo_buf; | |||
230 | 230 | ||
231 | #define GLOBAL_INTERRUPT_QUEUE 9005 | 231 | #define GLOBAL_INTERRUPT_QUEUE 9005 |
232 | 232 | ||
233 | /** | ||
234 | * rtas_config_addr - Format a busno, devfn and reg for RTAS. | ||
235 | * @busno: The bus number. | ||
236 | * @devfn: The device and function number as encoded by PCI_DEVFN(). | ||
237 | * @reg: The register number. | ||
238 | * | ||
239 | * This function encodes the given busno, devfn and register number as | ||
240 | * required for RTAS calls that take a "config_addr" parameter. | ||
241 | * See PAPR requirement 7.3.4-1 for more info. | ||
242 | */ | ||
243 | static inline u32 rtas_config_addr(int busno, int devfn, int reg) | ||
244 | { | ||
245 | return ((reg & 0xf00) << 20) | ((busno & 0xff) << 16) | | ||
246 | (devfn << 8) | (reg & 0xff); | ||
247 | } | ||
248 | |||
233 | #endif /* __KERNEL__ */ | 249 | #endif /* __KERNEL__ */ |
234 | #endif /* _POWERPC_RTAS_H */ | 250 | #endif /* _POWERPC_RTAS_H */ |