On Oct 7, 2007, at 6:32 AM, Marian Balakowicz wrote: > > Add common MPC5200 helper routines: mpc52xx_restart(), mpc52xx_halt(), > mpc52xx_power_off(). > > This patch relies on Sascha Hauer's patch published in: > http://patchwork.ozlabs.org/linuxppc/patch?id=8910. > > Signed-off-by: Marian Balakowicz <[EMAIL PROTECTED]> > Signed-off-by: Sascha Hauer <[EMAIL PROTECTED]> > --- > > arch/powerpc/platforms/52xx/mpc52xx_common.c | 45 +++++++++++++++ > ++++++++++++ > include/asm-powerpc/mpc52xx.h | 7 ++++ > 2 files changed, 52 insertions(+) > > diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/ > powerpc/platforms/52xx/mpc52xx_common.c > index b1cd7b0..e7087d7 100644 > --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c > +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c > @@ -88,6 +88,14 @@ mpc52xx_find_ipb_freq(struct device_node *node) > } > EXPORT_SYMBOL(mpc52xx_find_ipb_freq); > > +/* > + * This variable is mapped in mpc52xx_setup_cpu() by a call to > + * mpc52xx_find_and_map(), and used in mpc52xx_restart(). This is > because > + * mpc52xx_restart() can be called from interrupt context (e.g., > watchdog > + * interrupt handler), and mpc52xx_find_and_map() (ioremap() to be > exact) > + * can't be called from interrupt context. > + */ > +volatile struct mpc52xx_gpt *mpc52xx_gpt0 = NULL; > > void __init > mpc52xx_setup_cpu(void) > @@ -95,6 +103,9 @@ mpc52xx_setup_cpu(void) > struct mpc52xx_cdm __iomem *cdm; > struct mpc52xx_xlb __iomem *xlb; > > + /* mpc52xx_gpt0 is mapped here and used in mpc52xx_restart */ > + mpc52xx_gpt0 = mpc52xx_find_and_map("mpc5200-gpt"); > + > /* Map zones */ > cdm = mpc52xx_find_and_map("mpc5200-cdm"); > xlb = mpc52xx_find_and_map("mpc5200-xlb"); > @@ -138,3 +149,37 @@ mpc52xx_declare_of_platform_devices(void) > "Error while probing of_platform bus\n"); > } > > +void > +mpc52xx_restart(char *cmd) > +{ > + local_irq_disable(); > + > + /* Turn on the watchdog and wait for it to expire. It effectively > + does a reset */ > + if (mpc52xx_gpt0) { > + out_be32(&mpc52xx_gpt0->mode, 0x00000000); > + out_be32(&mpc52xx_gpt0->count, 0x000000ff); > + out_be32(&mpc52xx_gpt0->mode, 0x00009004); > + } else > + printk("mpc52xx_restart: Can't access gpt. " > + "Restart impossible, system halted\n"); > + > + while (1); > +} > + > +void > +mpc52xx_halt(void) > +{ > + local_irq_disable(); > + > + while (1); > +} > + > +void > +mpc52xx_power_off(void) > +{ > + /* By default we don't have any way of shut down. > + If a specific board wants to, it can set the power down > + code to any hardware implementation dependent code */ > + mpc52xx_halt(); > +}
If you are just going to spin don't bother implementing these. The generic routines will do the same. - k _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev