Support for old IBM PReP boxes
PATCH 1/9 Support for old IBM PReP boxes
Introduce have_residual_data() function and change existing code to use it. This is mainly to avoid my additions adding loads of ugly #ifdef CONFIG_RESIDUAL_DATA sections.
arch/ppc/platforms/prep_pci.c +40 -41
@@ -836,52 +836,52 @@void __init ibm_prep_init (void ) { -#ifdef CONFIG_PREP_RESIDUAL -u32 addr, real_addr, len; -PPC_DEVICE *mpic; -PnP_TAG_PACKET *pkt; - -/* Use the PReP residual data to determine if an OpenPIC is -* present. If so, get the large vendor packet which will -* tell us the base address and length in memory. -* If we are successful, ioremap the memory area and set -* OpenPIC_Addr (this indicates that the OpenPIC was found). -*/ - mpic =residual_find_device (-1 ,NULL , SystemPeripheral, - ProgrammableInterruptController,MPIC ,0 ); -if (!mpic) -return ; +if (have_residual_data ()) { +u32 addr, real_addr, len; +PPC_DEVICE *mpic; +PnP_TAG_PACKET *pkt; + +/* Use the PReP residual data to determine if an OpenPIC is +* present. If so, get the large vendor packet which will +* tell us the base address and length in memory. +* If we are successful, ioremap the memory area and set +* OpenPIC_Addr (this indicates that the OpenPIC was found). +*/ + mpic =residual_find_device (-1 ,NULL , SystemPeripheral, + ProgrammableInterruptController,MPIC ,0 ); +if (!mpic) +return ; - pkt =PnP_find_large_vendor_packet (res->DevicePnPHeap + - mpic->AllocatedOffset,9 ,0 ); + pkt =PnP_find_large_vendor_packet (res->DevicePnPHeap + + mpic->AllocatedOffset,9 ,0 ); -if (!pkt) -return ; +if (!pkt) +return ;#define p pkt->L4_Pack.L4_Data.L4_PPCPack -if (!((p.PPCData[0 ] ==2 ) && (p.PPCData[1 ] ==32 ))) -return ;/* not a 32-bit memory address */ - - real_addr =ld_le32 ((unsigned int *) (p.PPCData +4 )); -if (real_addr ==0xffffffff ) -return ; +if (!((p.PPCData[0 ] ==2 ) && (p.PPCData[1 ] ==32 ))) +return ;/* not a 32-bit memory address */ -/* Adjust address to be as seen by CPU */ - addr = real_addr +PREP_ISA_MEM_BASE ; - - len =ld_le32 ((unsigned int *) (p.PPCData +12 )); -if (!len) -return ; + real_addr =ld_le32 ((unsigned int *) (p.PPCData +4 )); +if (real_addr ==0xffffffff ) +return ; + +/* Adjust address to be as seen by CPU */ + addr = real_addr +PREP_ISA_MEM_BASE ; + + len =ld_le32 ((unsigned int *) (p.PPCData +12 )); +if (!len) +return ;#undef p - OpenPIC_Addr =ioremap (addr, len); - ppc_md.get_irq = openpic_get_irq; + OpenPIC_Addr =ioremap (addr, len); + ppc_md.get_irq = openpic_get_irq; - OpenPIC_InitSenses = prep_openpic_initsenses; - OpenPIC_NumInitSenses =sizeof (prep_openpic_initsenses); + OpenPIC_InitSenses = prep_openpic_initsenses; + OpenPIC_NumInitSenses =sizeof (prep_openpic_initsenses); -printk (KERN_INFO "MPIC at 0x%08x (0x%08x), length 0x%08x " -"mapped to 0x%p\n" , addr, real_addr, len, OpenPIC_Addr); -#endif +printk (KERN_INFO "MPIC at 0x%08x (0x%08x), length 0x%08x " +"mapped to 0x%p\n" , addr, real_addr, len, OpenPIC_Addr); + } } static void __init
@@ -1262,8 +1262,8 @@ PREP_ISA_IO_BASE + 0xcfc);printk ("PReP architecture\n" ); -#ifdef CONFIG_PREP_RESIDUAL - { + +if (have_residual_data ()) {PPC_DEVICE *hostbridge; hostbridge = residual_find_device(PROCESSORDEVICE, NULL,
@@ -1284,7 +1284,6 @@setup_indirect_pci (hose,0x80000cf8 ,0x80000cfc ); } } -#endif /* CONFIG_PREP_RESIDUAL */ ppc_md.pcibios_fixup = prep_pcibios_fixup; ppc_md.pcibios_after_init = prep_pcibios_after_init;
arch/ppc/platforms/prep_setup.c +30 -35
145 lines not on this page · raw message
arch/ppc/platforms/residual.c +5 -5
@@ -504,7 +504,7 @@#define did dev->DeviceId/* make sure we have residual data first */ -if ( res->ResidualLength ==0 ) +if (!have_residual_data ())return ;printk ("Residual: %ld devices\n" , res->ActualNumDevices);
@@ -639,7 +639,7 @@#define did dev->DeviceId/* make sure we have residual data first */ -if ( res->ResidualLength ==0 ) +if (!have_residual_data ())return ;printk ("Residual: %ld devices\n" , res->ActualNumDevices); for ( i = 0;
@@ -790,7 +790,7 @@ int n) {int i; -if ( !res->ResidualLength )return NULL ; +if (!have_residual_data ())return NULL ;for (i=0 ; i<res->ActualNumDevices; i++) {#define Dev res->Devices[i].DeviceId if ( (Dev.BusId&BusMask) &&
@@ -813,7 +813,7 @@ int n) {int i; -if ( !res->ResidualLength )return NULL ; +if (!have_residual_data ())return NULL ;for (i=0 ; i<res->ActualNumDevices; i++) {#define Dev res->Devices[i].DeviceId if ( (Dev.BusId&BusMask) &&
@@ -901,7 +901,7 @@int __init proc_prep_residual_init (void ) { -if (res->ResidualLength) +if (have_residual_data ())create_proc_read_entry ("residual" ,S_IRUGO ,NULL , proc_prep_residual_read,NULL );return 0 ;
include/asm-ppc/residual.h +13 -0
@@ -328,6 +328,19 @@extern PnP_TAG_PACKET *PnP_find_large_vendor_packet (unsigned char *p,unsigned packet_type,int n); + +#if defined(CONFIG_PREP_RESIDUAL ) +static inline int have_residual_data (void ) +{ +return res && res->ResidualLength; +} +#else /* !defined(CONFIG_PREP_RESIDUAL) */ +static inline int have_residual_data (void ) +{ +return 0 ; +} +#endif /* defined(CONFIG_PREP_RESIDUAL) */ +#endif /* __ASSEMBLY__ */ #endif /* ndef _RESIDUAL_ */
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/