Commit 2e0bd7c3 authored by Tom Rini's avatar Tom Rini

ppc32: Introduce a have_residual_data macro and switch to it.

This is mainly to avoid my additions adding loads of ugly
#ifdef CONFIG_RESIDUAL_DATA sections.
Signed-off-by: default avatarLeigh Brown <leigh@solinno.co.uk>
Signed-off-by: default avatarTom Rini <trini@kernel.crashing.org>
parent 12f0142f
...@@ -836,52 +836,52 @@ struct mot_info { ...@@ -836,52 +836,52 @@ struct mot_info {
void __init void __init
ibm_prep_init(void) ibm_prep_init(void)
{ {
#ifdef CONFIG_PREP_RESIDUAL if (have_residual_data) {
u32 addr, real_addr, len; u32 addr, real_addr, len;
PPC_DEVICE *mpic; PPC_DEVICE *mpic;
PnP_TAG_PACKET *pkt; PnP_TAG_PACKET *pkt;
/* Use the PReP residual data to determine if an OpenPIC is /* Use the PReP residual data to determine if an OpenPIC is
* present. If so, get the large vendor packet which will * present. If so, get the large vendor packet which will
* tell us the base address and length in memory. * tell us the base address and length in memory.
* If we are successful, ioremap the memory area and set * If we are successful, ioremap the memory area and set
* OpenPIC_Addr (this indicates that the OpenPIC was found). * OpenPIC_Addr (this indicates that the OpenPIC was found).
*/ */
mpic = residual_find_device(-1, NULL, SystemPeripheral, mpic = residual_find_device(-1, NULL, SystemPeripheral,
ProgrammableInterruptController, MPIC, 0); ProgrammableInterruptController, MPIC, 0);
if (!mpic) if (!mpic)
return; return;
pkt = PnP_find_large_vendor_packet(res->DevicePnPHeap + pkt = PnP_find_large_vendor_packet(res->DevicePnPHeap +
mpic->AllocatedOffset, 9, 0); mpic->AllocatedOffset, 9, 0);
if (!pkt) if (!pkt)
return; return;
#define p pkt->L4_Pack.L4_Data.L4_PPCPack #define p pkt->L4_Pack.L4_Data.L4_PPCPack
if (!((p.PPCData[0] == 2) && (p.PPCData[1] == 32))) if (!((p.PPCData[0] == 2) && (p.PPCData[1] == 32)))
return; /* not a 32-bit memory address */ return; /* not a 32-bit memory address */
real_addr = ld_le32((unsigned int *) (p.PPCData + 4)); real_addr = ld_le32((unsigned int *) (p.PPCData + 4));
if (real_addr == 0xffffffff) if (real_addr == 0xffffffff)
return; return;
/* Adjust address to be as seen by CPU */ /* Adjust address to be as seen by CPU */
addr = real_addr + PREP_ISA_MEM_BASE; addr = real_addr + PREP_ISA_MEM_BASE;
len = ld_le32((unsigned int *) (p.PPCData + 12)); len = ld_le32((unsigned int *) (p.PPCData + 12));
if (!len) if (!len)
return; return;
#undef p #undef p
OpenPIC_Addr = ioremap(addr, len); OpenPIC_Addr = ioremap(addr, len);
ppc_md.get_irq = openpic_get_irq; ppc_md.get_irq = openpic_get_irq;
OpenPIC_InitSenses = prep_openpic_initsenses; OpenPIC_InitSenses = prep_openpic_initsenses;
OpenPIC_NumInitSenses = sizeof(prep_openpic_initsenses); OpenPIC_NumInitSenses = sizeof(prep_openpic_initsenses);
printk(KERN_INFO "MPIC at 0x%08x (0x%08x), length 0x%08x " printk(KERN_INFO "MPIC at 0x%08x (0x%08x), length 0x%08x "
"mapped to 0x%p\n", addr, real_addr, len, OpenPIC_Addr); "mapped to 0x%p\n", addr, real_addr, len, OpenPIC_Addr);
#endif }
} }
static void __init static void __init
...@@ -1262,8 +1262,8 @@ prep_find_bridges(void) ...@@ -1262,8 +1262,8 @@ prep_find_bridges(void)
PREP_ISA_IO_BASE + 0xcfc); PREP_ISA_IO_BASE + 0xcfc);
printk("PReP architecture\n"); printk("PReP architecture\n");
#ifdef CONFIG_PREP_RESIDUAL
{ if (have_residual_data) {
PPC_DEVICE *hostbridge; PPC_DEVICE *hostbridge;
hostbridge = residual_find_device(PROCESSORDEVICE, NULL, hostbridge = residual_find_device(PROCESSORDEVICE, NULL,
...@@ -1284,7 +1284,6 @@ prep_find_bridges(void) ...@@ -1284,7 +1284,6 @@ prep_find_bridges(void)
setup_indirect_pci(hose, 0x80000cf8, 0x80000cfc); setup_indirect_pci(hose, 0x80000cf8, 0x80000cfc);
} }
} }
#endif /* CONFIG_PREP_RESIDUAL */
ppc_md.pcibios_fixup = prep_pcibios_fixup; ppc_md.pcibios_fixup = prep_pcibios_fixup;
ppc_md.pcibios_after_init = prep_pcibios_after_init; ppc_md.pcibios_after_init = prep_pcibios_after_init;
......
...@@ -193,9 +193,8 @@ prep_ibm_cpuinfo(struct seq_file *m) ...@@ -193,9 +193,8 @@ prep_ibm_cpuinfo(struct seq_file *m)
seq_printf(m, "bad"); seq_printf(m, "bad");
seq_printf(m, "\n"); seq_printf(m, "\n");
#ifdef CONFIG_PREP_RESIDUAL
/* print info about SIMMs */ /* print info about SIMMs */
if (res->ResidualLength != 0) { if (have_residual_data) {
int i; int i;
seq_printf(m, "simms\t\t: "); seq_printf(m, "simms\t\t: ");
for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) { for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
...@@ -207,7 +206,6 @@ prep_ibm_cpuinfo(struct seq_file *m) ...@@ -207,7 +206,6 @@ prep_ibm_cpuinfo(struct seq_file *m)
} }
seq_printf(m, "\n"); seq_printf(m, "\n");
} }
#endif
} }
static int __prep static int __prep
...@@ -431,9 +429,8 @@ prep_mot_cpuinfo(struct seq_file *m) ...@@ -431,9 +429,8 @@ prep_mot_cpuinfo(struct seq_file *m)
} }
no_l2: no_l2:
#ifdef CONFIG_PREP_RESIDUAL
/* print info about SIMMs */ /* print info about SIMMs */
if (res->ResidualLength != 0) { if (have_residual_data) {
int i; int i;
seq_printf(m, "simms\t\t: "); seq_printf(m, "simms\t\t: ");
for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) { for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
...@@ -445,7 +442,6 @@ prep_mot_cpuinfo(struct seq_file *m) ...@@ -445,7 +442,6 @@ prep_mot_cpuinfo(struct seq_file *m)
} }
seq_printf(m, "\n"); seq_printf(m, "\n");
} }
#endif
return 0; return 0;
} }
...@@ -561,14 +557,12 @@ prep_show_percpuinfo(struct seq_file *m, int i) ...@@ -561,14 +557,12 @@ prep_show_percpuinfo(struct seq_file *m, int i)
{ {
/* PREP's without residual data will give incorrect values here */ /* PREP's without residual data will give incorrect values here */
seq_printf(m, "clock\t\t: "); seq_printf(m, "clock\t\t: ");
#ifdef CONFIG_PREP_RESIDUAL if (have_residual_data)
if (res->ResidualLength)
seq_printf(m, "%ldMHz\n", seq_printf(m, "%ldMHz\n",
(res->VitalProductData.ProcessorHz > 1024) ? (res->VitalProductData.ProcessorHz > 1024) ?
res->VitalProductData.ProcessorHz / 1000000 : res->VitalProductData.ProcessorHz / 1000000 :
res->VitalProductData.ProcessorHz); res->VitalProductData.ProcessorHz);
else else
#endif /* CONFIG_PREP_RESIDUAL */
seq_printf(m, "???\n"); seq_printf(m, "???\n");
return 0; return 0;
...@@ -598,9 +592,10 @@ static void __init prep_init_sound(void) ...@@ -598,9 +592,10 @@ static void __init prep_init_sound(void)
* Get the needed resource informations from residual data. * Get the needed resource informations from residual data.
* *
*/ */
#ifdef CONFIG_PREP_RESIDUAL if (have_residual_data)
audiodevice = residual_find_device(~0, NULL, MultimediaController, audiodevice = residual_find_device(~0, NULL,
AudioController, -1, 0); MultimediaController, AudioController, -1, 0);
if (audiodevice != NULL) { if (audiodevice != NULL) {
PnP_TAG_PACKET *pkt; PnP_TAG_PACKET *pkt;
...@@ -613,7 +608,6 @@ static void __init prep_init_sound(void) ...@@ -613,7 +608,6 @@ static void __init prep_init_sound(void)
if (pkt != NULL) if (pkt != NULL)
ppc_cs4232_dma2 = masktoint(pkt->S5_Pack.DMAMask); ppc_cs4232_dma2 = masktoint(pkt->S5_Pack.DMAMask);
} }
#endif
/* /*
* These are the PReP specs' defaults for the cs4231. We use these * These are the PReP specs' defaults for the cs4231. We use these
...@@ -649,13 +643,14 @@ static void __init prep_init_sound(void) ...@@ -649,13 +643,14 @@ static void __init prep_init_sound(void)
static void __init static void __init
prep_init_vesa(void) prep_init_vesa(void)
{ {
#if defined(CONFIG_PREP_RESIDUAL) && \ #if (defined(CONFIG_FB_VGA16) || defined(CONFIG_FB_VGA_16_MODULE) || \
(defined(CONFIG_FB_VGA16) || defined(CONFIG_FB_VGA_16_MODULE) || \
defined(CONFIG_FB_VESA)) defined(CONFIG_FB_VESA))
PPC_DEVICE *vgadev; PPC_DEVICE *vgadev = NULL;
if (have_residual_data)
vgadev = residual_find_device(~0, NULL, DisplayController,
SVGAController, -1, 0);
vgadev = residual_find_device(~0, NULL, DisplayController, SVGAController,
-1, 0);
if (vgadev != NULL) { if (vgadev != NULL) {
PnP_TAG_PACKET *pkt; PnP_TAG_PACKET *pkt;
...@@ -680,7 +675,7 @@ prep_init_vesa(void) ...@@ -680,7 +675,7 @@ prep_init_vesa(void)
} }
} }
} }
#endif /* CONFIG_PREP_RESIDUAL */ #endif
} }
static void __init static void __init
...@@ -819,18 +814,19 @@ prep_setup_arch(void) ...@@ -819,18 +814,19 @@ prep_setup_arch(void)
static void __init static void __init
prep_calibrate_decr(void) prep_calibrate_decr(void)
{ {
#ifdef CONFIG_PREP_RESIDUAL if (have_residual_data) {
unsigned long freq, divisor = 4; unsigned long freq, divisor = 4;
if ( res->VitalProductData.ProcessorBusHz ) { if ( res->VitalProductData.ProcessorBusHz ) {
freq = res->VitalProductData.ProcessorBusHz; freq = res->VitalProductData.ProcessorBusHz;
printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
(freq/divisor)/1000000, (freq/divisor)/1000000,
(freq/divisor)%1000000); (freq/divisor)%1000000);
tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000); tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
tb_ticks_per_jiffy = freq / HZ / divisor; tb_ticks_per_jiffy = freq / HZ / divisor;
} else }
#endif }
else
todc_calibrate_decr(); todc_calibrate_decr();
} }
...@@ -998,15 +994,14 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -998,15 +994,14 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5,
DMA_MODE_WRITE = 0x48; DMA_MODE_WRITE = 0x48;
/* figure out what kind of prep workstation we are */ /* figure out what kind of prep workstation we are */
#ifdef CONFIG_PREP_RESIDUAL if (have_residual_data) {
if ( res->ResidualLength != 0 ) {
if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) ) if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) )
_prep_type = _PREP_IBM; _prep_type = _PREP_IBM;
else else
_prep_type = _PREP_Motorola; _prep_type = _PREP_Motorola;
} else /* assume motorola if no residual (netboot?) */ }
#endif else {
{ /* assume motorola if no residual (netboot?) */
_prep_type = _PREP_Motorola; _prep_type = _PREP_Motorola;
} }
......
...@@ -504,7 +504,7 @@ void __init print_residual_device_info(void) ...@@ -504,7 +504,7 @@ void __init print_residual_device_info(void)
#define did dev->DeviceId #define did dev->DeviceId
/* make sure we have residual data first */ /* make sure we have residual data first */
if ( res->ResidualLength == 0 ) if (!have_residual_data)
return; return;
printk("Residual: %ld devices\n", res->ActualNumDevices); printk("Residual: %ld devices\n", res->ActualNumDevices);
...@@ -639,7 +639,7 @@ void print_residual_device_info(void) ...@@ -639,7 +639,7 @@ void print_residual_device_info(void)
#define did dev->DeviceId #define did dev->DeviceId
/* make sure we have residual data first */ /* make sure we have residual data first */
if ( res->ResidualLength == 0 ) if (!have_residual_data)
return; return;
printk("Residual: %ld devices\n", res->ActualNumDevices); printk("Residual: %ld devices\n", res->ActualNumDevices);
for ( i = 0; for ( i = 0;
...@@ -790,7 +790,7 @@ PPC_DEVICE __init *residual_find_device(unsigned long BusMask, ...@@ -790,7 +790,7 @@ PPC_DEVICE __init *residual_find_device(unsigned long BusMask,
int n) int n)
{ {
int i; int i;
if ( !res->ResidualLength ) return NULL; if (!have_residual_data) return NULL;
for (i=0; i<res->ActualNumDevices; i++) { for (i=0; i<res->ActualNumDevices; i++) {
#define Dev res->Devices[i].DeviceId #define Dev res->Devices[i].DeviceId
if ( (Dev.BusId&BusMask) && if ( (Dev.BusId&BusMask) &&
...@@ -813,7 +813,7 @@ PPC_DEVICE __init *residual_find_device_id(unsigned long BusMask, ...@@ -813,7 +813,7 @@ PPC_DEVICE __init *residual_find_device_id(unsigned long BusMask,
int n) int n)
{ {
int i; int i;
if ( !res->ResidualLength ) return NULL; if (!have_residual_data) return NULL;
for (i=0; i<res->ActualNumDevices; i++) { for (i=0; i<res->ActualNumDevices; i++) {
#define Dev res->Devices[i].DeviceId #define Dev res->Devices[i].DeviceId
if ( (Dev.BusId&BusMask) && if ( (Dev.BusId&BusMask) &&
...@@ -901,7 +901,7 @@ static int proc_prep_residual_read(char * buf, char ** start, off_t off, ...@@ -901,7 +901,7 @@ static int proc_prep_residual_read(char * buf, char ** start, off_t off,
int __init int __init
proc_prep_residual_init(void) proc_prep_residual_init(void)
{ {
if (res->ResidualLength) if (have_residual_data)
create_proc_read_entry("residual", S_IRUGO, NULL, create_proc_read_entry("residual", S_IRUGO, NULL,
proc_prep_residual_read, NULL); proc_prep_residual_read, NULL);
return 0; return 0;
......
...@@ -328,6 +328,13 @@ extern PnP_TAG_PACKET *PnP_find_small_vendor_packet(unsigned char *p, ...@@ -328,6 +328,13 @@ extern PnP_TAG_PACKET *PnP_find_small_vendor_packet(unsigned char *p,
extern PnP_TAG_PACKET *PnP_find_large_vendor_packet(unsigned char *p, extern PnP_TAG_PACKET *PnP_find_large_vendor_packet(unsigned char *p,
unsigned packet_type, unsigned packet_type,
int n); int n);
#ifdef CONFIG_PREP_RESIDUAL
#define have_residual_data (res && res->ResidualLength)
#else
#define have_residual_data 0
#endif
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* ndef _RESIDUAL_ */ #endif /* ndef _RESIDUAL_ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment