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 {
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 */
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;
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;
/* 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;
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_find_bridges(void)
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 @@ prep_find_bridges(void)
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;
......
......@@ -193,9 +193,8 @@ prep_ibm_cpuinfo(struct seq_file *m)
seq_printf(m, "bad");
seq_printf(m, "\n");
#ifdef CONFIG_PREP_RESIDUAL
/* print info about SIMMs */
if (res->ResidualLength != 0) {
if (have_residual_data) {
int i;
seq_printf(m, "simms\t\t: ");
for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
......@@ -207,7 +206,6 @@ prep_ibm_cpuinfo(struct seq_file *m)
}
seq_printf(m, "\n");
}
#endif
}
static int __prep
......@@ -431,9 +429,8 @@ prep_mot_cpuinfo(struct seq_file *m)
}
no_l2:
#ifdef CONFIG_PREP_RESIDUAL
/* print info about SIMMs */
if (res->ResidualLength != 0) {
if (have_residual_data) {
int i;
seq_printf(m, "simms\t\t: ");
for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
......@@ -445,7 +442,6 @@ prep_mot_cpuinfo(struct seq_file *m)
}
seq_printf(m, "\n");
}
#endif
return 0;
}
......@@ -561,14 +557,12 @@ prep_show_percpuinfo(struct seq_file *m, int i)
{
/* PREP's without residual data will give incorrect values here */
seq_printf(m, "clock\t\t: ");
#ifdef CONFIG_PREP_RESIDUAL
if (res->ResidualLength)
if (have_residual_data)
seq_printf(m, "%ldMHz\n",
(res->VitalProductData.ProcessorHz > 1024) ?
res->VitalProductData.ProcessorHz / 1000000 :
res->VitalProductData.ProcessorHz);
else
#endif /* CONFIG_PREP_RESIDUAL */
seq_printf(m, "???\n");
return 0;
......@@ -598,9 +592,10 @@ static void __init prep_init_sound(void)
* Get the needed resource informations from residual data.
*
*/
#ifdef CONFIG_PREP_RESIDUAL
audiodevice = residual_find_device(~0, NULL, MultimediaController,
AudioController, -1, 0);
if (have_residual_data)
audiodevice = residual_find_device(~0, NULL,
MultimediaController, AudioController, -1, 0);
if (audiodevice != NULL) {
PnP_TAG_PACKET *pkt;
......@@ -613,7 +608,6 @@ static void __init prep_init_sound(void)
if (pkt != NULL)
ppc_cs4232_dma2 = masktoint(pkt->S5_Pack.DMAMask);
}
#endif
/*
* These are the PReP specs' defaults for the cs4231. We use these
......@@ -649,13 +643,14 @@ static void __init prep_init_sound(void)
static void __init
prep_init_vesa(void)
{
#if defined(CONFIG_PREP_RESIDUAL) && \
(defined(CONFIG_FB_VGA16) || defined(CONFIG_FB_VGA_16_MODULE) || \
#if (defined(CONFIG_FB_VGA16) || defined(CONFIG_FB_VGA_16_MODULE) || \
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) {
PnP_TAG_PACKET *pkt;
......@@ -680,7 +675,7 @@ prep_init_vesa(void)
}
}
}
#endif /* CONFIG_PREP_RESIDUAL */
#endif
}
static void __init
......@@ -819,18 +814,19 @@ prep_setup_arch(void)
static void __init
prep_calibrate_decr(void)
{
#ifdef CONFIG_PREP_RESIDUAL
unsigned long freq, divisor = 4;
if ( res->VitalProductData.ProcessorBusHz ) {
freq = res->VitalProductData.ProcessorBusHz;
printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
(freq/divisor)/1000000,
(freq/divisor)%1000000);
tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
tb_ticks_per_jiffy = freq / HZ / divisor;
} else
#endif
if (have_residual_data) {
unsigned long freq, divisor = 4;
if ( res->VitalProductData.ProcessorBusHz ) {
freq = res->VitalProductData.ProcessorBusHz;
printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
(freq/divisor)/1000000,
(freq/divisor)%1000000);
tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
tb_ticks_per_jiffy = freq / HZ / divisor;
}
}
else
todc_calibrate_decr();
}
......@@ -998,15 +994,14 @@ prep_init(unsigned long r3, unsigned long r4, unsigned long r5,
DMA_MODE_WRITE = 0x48;
/* figure out what kind of prep workstation we are */
#ifdef CONFIG_PREP_RESIDUAL
if ( res->ResidualLength != 0 ) {
if (have_residual_data) {
if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) )
_prep_type = _PREP_IBM;
else
_prep_type = _PREP_Motorola;
} else /* assume motorola if no residual (netboot?) */
#endif
{
}
else {
/* assume motorola if no residual (netboot?) */
_prep_type = _PREP_Motorola;
}
......
......@@ -504,7 +504,7 @@ void __init print_residual_device_info(void)
#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 @@ void print_residual_device_info(void)
#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 @@ PPC_DEVICE __init *residual_find_device(unsigned long BusMask,
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 @@ PPC_DEVICE __init *residual_find_device_id(unsigned long BusMask,
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 @@ static int proc_prep_residual_read(char * buf, char ** start, off_t off,
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;
......
......@@ -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,
unsigned packet_type,
int n);
#ifdef CONFIG_PREP_RESIDUAL
#define have_residual_data (res && res->ResidualLength)
#else
#define have_residual_data 0
#endif
#endif /* __ASSEMBLY__ */
#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