[POWERPC] Add a helper for calculating RTAS "config_addr" parameters

Several RTAS calls take a "config_addr" parameter, which is a particular
way of specifying a PCI busno, devfn and register number into a 32-bit word.
Currently these are open-coded, and I'll be adding another soon, replace
them with a helper that encapsulates the logic. Be more strict about masking
the busno too, just in case.

Booted on P5 LPAR.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Michael Ellerman
2006-08-16 22:04:14 +10:00
committed by Paul Mackerras
parent a0a428e300
commit 6f3d5d3cc4
2 changed files with 18 additions and 4 deletions

View File

@@ -230,5 +230,21 @@ extern unsigned long rtas_rmo_buf;
#define GLOBAL_INTERRUPT_QUEUE 9005
/**
* rtas_config_addr - Format a busno, devfn and reg for RTAS.
* @busno: The bus number.
* @devfn: The device and function number as encoded by PCI_DEVFN().
* @reg: The register number.
*
* This function encodes the given busno, devfn and register number as
* required for RTAS calls that take a "config_addr" parameter.
* See PAPR requirement 7.3.4-1 for more info.
*/
static inline u32 rtas_config_addr(int busno, int devfn, int reg)
{
return ((reg & 0xf00) << 20) | ((busno & 0xff) << 16) |
(devfn << 8) | (reg & 0xff);
}
#endif /* __KERNEL__ */
#endif /* _POWERPC_RTAS_H */