Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[sfrench/cifs-2.6.git] / arch / powerpc / platforms / 52xx / lite5200.c
index 5c46e898fd4526dc3a4f69681d132a26505cf1cc..0caa3d955c3b2b6948c620104c21f63fe5589ccc 100644 (file)
 
 #undef DEBUG
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
 #include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-#include <linux/initrd.h>
-
-#include <asm/system.h>
-#include <asm/atomic.h>
+#include <linux/of.h>
 #include <asm/time.h>
 #include <asm/io.h>
 #include <asm/machdep.h>
-#include <asm/ipic.h>
-#include <asm/bootinfo.h>
-#include <asm/irq.h>
 #include <asm/prom.h>
-#include <asm/udbg.h>
-#include <sysdev/fsl_soc.h>
-#include <asm/of_platform.h>
-
 #include <asm/mpc52xx.h>
 
 /* ************************************************************************
  *
  */
 
+/*
+ * 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
-lite5200_setup_cpu(void)
+lite5200_fix_port_config(void)
 {
        struct mpc52xx_gpio __iomem *gpio;
        u32 port_config;
 
-       /* Map zones */
        gpio = mpc52xx_find_and_map("mpc5200-gpio");
        if (!gpio) {
-               printk(KERN_ERR __FILE__ ": "
-                       "Error while mapping GPIO register for port config. "
-                       "Expect some abnormal behavior\n");
-               goto error;
+               printk(KERN_ERR "%s() failed. expect abnormal behavior\n",
+                      __FUNCTION__);
+               return;
        }
 
        /* Set port config */
@@ -81,12 +98,10 @@ lite5200_setup_cpu(void)
        out_be32(&gpio->port_config, port_config);
 
        /* Unmap zone */
-error:
        iounmap(gpio);
 }
 
 #ifdef CONFIG_PM
-static u32 descr_a;
 static void lite5200_suspend_prepare(void __iomem *mbar)
 {
        u8 pin = 1;     /* GPIO_WKUP_1 (GPIO_PSC2_4) */
@@ -97,42 +112,41 @@ static void lite5200_suspend_prepare(void __iomem *mbar)
         * power down usb port
         * this needs to be called before of-ohci suspend code
         */
-       descr_a = in_be32(mbar + 0x1048);
-       out_be32(mbar + 0x1048, (descr_a & ~0x200) | 0x100);
+
+       /* set ports to "power switched" and "powered at the same time"
+        * USB Rh descriptor A: NPS = 0, PSM = 0 */
+       out_be32(mbar + 0x1048, in_be32(mbar + 0x1048) & ~0x300);
+       /* USB Rh status: LPS = 1 - turn off power */
+       out_be32(mbar + 0x1050, 0x00000001);
 }
 
 static void lite5200_resume_finish(void __iomem *mbar)
 {
-       out_be32(mbar + 0x1048, descr_a);
+       /* USB Rh status: LPSC = 1 - turn on power */
+       out_be32(mbar + 0x1050, 0x00010000);
 }
 #endif
 
 static void __init lite5200_setup_arch(void)
 {
+#ifdef CONFIG_PCI
        struct device_node *np;
+#endif
 
        if (ppc_md.progress)
                ppc_md.progress("lite5200_setup_arch()", 0);
 
-       np = of_find_node_by_type(NULL, "cpu");
-       if (np) {
-               const unsigned int *fp =
-                       of_get_property(np, "clock-frequency", NULL);
-               if (fp != 0)
-                       loops_per_jiffy = *fp / HZ;
-               else
-                       loops_per_jiffy = 50000000 / HZ;
-               of_node_put(np);
-       }
+       /* Fix things that firmware should have done. */
+       lite5200_fix_clock_config();
+       lite5200_fix_port_config();
 
-       /* CPU & Port mux setup */
-       mpc52xx_setup_cpu();    /* Generic */
-       lite5200_setup_cpu();   /* Platorm specific */
+       /* Some mpc5200 & mpc5200b related configuration */
+       mpc5200_setup_xlb_arbiter();
 
 #ifdef CONFIG_PM
        mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
        mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
-       mpc52xx_pm_init();
+       lite5200_pm_init();
 #endif
 
 #ifdef CONFIG_PCI
@@ -156,20 +170,6 @@ static void __init lite5200_setup_arch(void)
 
 }
 
-static void lite5200_show_cpuinfo(struct seq_file *m)
-{
-       struct device_node* np = of_find_all_nodes(NULL);
-       const char *model = NULL;
-
-       if (np)
-               model = of_get_property(np, "model", NULL);
-
-       seq_printf(m, "vendor\t\t:      Freescale Semiconductor\n");
-       seq_printf(m, "machine\t\t:     %s\n", model ? model : "unknown");
-
-       of_node_put(np);
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -193,6 +193,5 @@ define_machine(lite5200) {
        .init           = mpc52xx_declare_of_platform_devices,
        .init_IRQ       = mpc52xx_init_irq,
        .get_irq        = mpc52xx_get_irq,
-       .show_cpuinfo   = lite5200_show_cpuinfo,
        .calibrate_decr = generic_calibrate_decr,
 };