Commit 4de3b992 authored by Grant Likely's avatar Grant Likely

[POWERPC] MPC5200: Don't make firmware fixups into common code

The Lite5200 u-boot image doesn't entirely configure the processor
correctly and so Linux needs to fixup the cpu setup in setup_arch.  Fixing
the CPU setup is good, but making it into common code is not a good idea.

New board ports should be encouraged not to take the lead of the lite5200
and instead get their firmware to setup the CPU the right way.
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarSylvain Munaut <tnt@246tnt.com>
parent 9fe2e796
...@@ -30,19 +30,56 @@ ...@@ -30,19 +30,56 @@
* *
*/ */
/*
* Fix clock configuration.
*
* Firmware is supposed to be responsible for this. If you are creating a
* new board port, do *NOT* duplicate this code. Fix your boot firmware
* to set it correctly in the first place
*/
static void __init
lite5200_fix_clock_config(void)
{
struct mpc52xx_cdm __iomem *cdm;
/* Map zones */
cdm = mpc52xx_find_and_map("mpc5200-cdm");
if (!cdm) {
printk(KERN_ERR "%s() failed; expect abnormal behaviour\n",
__FUNCTION__);
return;
}
/* Use internal 48 Mhz */
out_8(&cdm->ext_48mhz_en, 0x00);
out_8(&cdm->fd_enable, 0x01);
if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */
out_be16(&cdm->fd_counters, 0x0001);
else
out_be16(&cdm->fd_counters, 0x5555);
/* Unmap the regs */
iounmap(cdm);
}
/*
* Fix setting of port_config register.
*
* Firmware is supposed to be responsible for this. If you are creating a
* new board port, do *NOT* duplicate this code. Fix your boot firmware
* to set it correctly in the first place
*/
static void __init static void __init
lite5200_setup_cpu(void) lite5200_fix_port_config(void)
{ {
struct mpc52xx_gpio __iomem *gpio; struct mpc52xx_gpio __iomem *gpio;
u32 port_config; u32 port_config;
/* Map zones */
gpio = mpc52xx_find_and_map("mpc5200-gpio"); gpio = mpc52xx_find_and_map("mpc5200-gpio");
if (!gpio) { if (!gpio) {
printk(KERN_ERR __FILE__ ": " printk(KERN_ERR "%s() failed. expect abnormal behavior\n",
"Error while mapping GPIO register for port config. " __FUNCTION__);
"Expect some abnormal behavior\n"); return;
goto error;
} }
/* Set port config */ /* Set port config */
...@@ -61,7 +98,6 @@ lite5200_setup_cpu(void) ...@@ -61,7 +98,6 @@ lite5200_setup_cpu(void)
out_be32(&gpio->port_config, port_config); out_be32(&gpio->port_config, port_config);
/* Unmap zone */ /* Unmap zone */
error:
iounmap(gpio); iounmap(gpio);
} }
...@@ -100,9 +136,12 @@ static void __init lite5200_setup_arch(void) ...@@ -100,9 +136,12 @@ static void __init lite5200_setup_arch(void)
if (ppc_md.progress) if (ppc_md.progress)
ppc_md.progress("lite5200_setup_arch()", 0); ppc_md.progress("lite5200_setup_arch()", 0);
/* CPU & Port mux setup */ /* Fix things that firmware should have done. */
mpc52xx_setup_cpu(); /* Generic */ lite5200_fix_clock_config();
lite5200_setup_cpu(); /* Platorm specific */ lite5200_fix_port_config();
/* Some mpc5200 & mpc5200b related configuration */
mpc5200_setup_xlb_arbiter();
#ifdef CONFIG_PM #ifdef CONFIG_PM
mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare; mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
......
...@@ -75,44 +75,33 @@ mpc52xx_find_ipb_freq(struct device_node *node) ...@@ -75,44 +75,33 @@ mpc52xx_find_ipb_freq(struct device_node *node)
EXPORT_SYMBOL(mpc52xx_find_ipb_freq); EXPORT_SYMBOL(mpc52xx_find_ipb_freq);
/*
* Configure the XLB arbiter settings to match what Linux expects.
*/
void __init void __init
mpc52xx_setup_cpu(void) mpc5200_setup_xlb_arbiter(void)
{ {
struct mpc52xx_cdm __iomem *cdm;
struct mpc52xx_xlb __iomem *xlb; struct mpc52xx_xlb __iomem *xlb;
/* Map zones */
cdm = mpc52xx_find_and_map("mpc5200-cdm");
xlb = mpc52xx_find_and_map("mpc5200-xlb"); xlb = mpc52xx_find_and_map("mpc5200-xlb");
if (!xlb) {
if (!cdm || !xlb) {
printk(KERN_ERR __FILE__ ": " printk(KERN_ERR __FILE__ ": "
"Error while mapping CDM/XLB during mpc52xx_setup_cpu. " "Error mapping XLB in mpc52xx_setup_cpu(). "
"Expect some abnormal behavior\n"); "Expect some abnormal behavior\n");
goto unmap_regs; return;
} }
/* Use internal 48 Mhz */
out_8(&cdm->ext_48mhz_en, 0x00);
out_8(&cdm->fd_enable, 0x01);
if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */
out_be16(&cdm->fd_counters, 0x0001);
else
out_be16(&cdm->fd_counters, 0x5555);
/* Configure the XLB Arbiter priorities */ /* Configure the XLB Arbiter priorities */
out_be32(&xlb->master_pri_enable, 0xff); out_be32(&xlb->master_pri_enable, 0xff);
out_be32(&xlb->master_priority, 0x11111111); out_be32(&xlb->master_priority, 0x11111111);
/* Disable XLB pipelining */ /* Disable XLB pipelining
/* (cfr errate 292. We could do this only just before ATA PIO * (cfr errate 292. We could do this only just before ATA PIO
transaction and re-enable it afterwards ...) */ * transaction and re-enable it afterwards ...)
*/
out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS); out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS);
/* Unmap zones */ iounmap(xlb);
unmap_regs:
if (cdm) iounmap(cdm);
if (xlb) iounmap(xlb);
} }
void __init void __init
......
...@@ -243,7 +243,7 @@ struct mpc52xx_cdm { ...@@ -243,7 +243,7 @@ struct mpc52xx_cdm {
extern void __iomem * mpc52xx_find_and_map(const char *); extern void __iomem * mpc52xx_find_and_map(const char *);
extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node); extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node);
extern void mpc52xx_setup_cpu(void); extern void mpc5200_setup_xlb_arbiter(void);
extern void mpc52xx_declare_of_platform_devices(void); extern void mpc52xx_declare_of_platform_devices(void);
extern void mpc52xx_init_irq(void); extern void mpc52xx_init_irq(void);
......
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