]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/powerpc/platforms/52xx/lite5200.c
e11d27f9c4f000963e247c366181239fc287e096
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / 52xx / lite5200.c
1 /*
2  * Freescale Lite5200 board support
3  *
4  * Written by: Grant Likely <grant.likely@secretlab.ca>
5  *
6  * Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved.
7  * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
8  *
9  * Description:
10  * This program is free software; you can redistribute  it and/or modify it
11  * under  the terms of  the GNU General  Public License as published by the
12  * Free Software Foundation;  either version 2 of the  License, or (at your
13  * option) any later version.
14  */
15
16 #undef DEBUG
17
18 #include <linux/stddef.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/errno.h>
22 #include <linux/reboot.h>
23 #include <linux/pci.h>
24 #include <linux/kdev_t.h>
25 #include <linux/major.h>
26 #include <linux/console.h>
27 #include <linux/delay.h>
28 #include <linux/seq_file.h>
29 #include <linux/root_dev.h>
30 #include <linux/initrd.h>
31
32 #include <asm/system.h>
33 #include <asm/atomic.h>
34 #include <asm/time.h>
35 #include <asm/io.h>
36 #include <asm/machdep.h>
37 #include <asm/ipic.h>
38 #include <asm/irq.h>
39 #include <asm/prom.h>
40 #include <asm/udbg.h>
41 #include <sysdev/fsl_soc.h>
42 #include <asm/of_platform.h>
43
44 #include <asm/mpc52xx.h>
45
46 /* ************************************************************************
47  *
48  * Setup the architecture
49  *
50  */
51
52 static void __init
53 lite5200_setup_cpu(void)
54 {
55         struct mpc52xx_gpio __iomem *gpio;
56         u32 port_config;
57
58         /* Map zones */
59         gpio = mpc52xx_find_and_map("mpc5200-gpio");
60         if (!gpio) {
61                 printk(KERN_ERR __FILE__ ": "
62                         "Error while mapping GPIO register for port config. "
63                         "Expect some abnormal behavior\n");
64                 goto error;
65         }
66
67         /* Set port config */
68         port_config = in_be32(&gpio->port_config);
69
70         port_config &= ~0x00800000;     /* 48Mhz internal, pin is GPIO  */
71
72         port_config &= ~0x00007000;     /* USB port : Differential mode */
73         port_config |=  0x00001000;     /*            USB 1 only        */
74
75         port_config &= ~0x03000000;     /* ATA CS is on csb_4/5         */
76         port_config |=  0x01000000;
77
78         pr_debug("port_config: old:%x new:%x\n",
79                  in_be32(&gpio->port_config), port_config);
80         out_be32(&gpio->port_config, port_config);
81
82         /* Unmap zone */
83 error:
84         iounmap(gpio);
85 }
86
87 #ifdef CONFIG_PM
88 static void lite5200_suspend_prepare(void __iomem *mbar)
89 {
90         u8 pin = 1;     /* GPIO_WKUP_1 (GPIO_PSC2_4) */
91         u8 level = 0;   /* wakeup on low level */
92         mpc52xx_set_wakeup_gpio(pin, level);
93
94         /*
95          * power down usb port
96          * this needs to be called before of-ohci suspend code
97          */
98
99         /* set ports to "power switched" and "powered at the same time"
100          * USB Rh descriptor A: NPS = 0, PSM = 0 */
101         out_be32(mbar + 0x1048, in_be32(mbar + 0x1048) & ~0x300);
102         /* USB Rh status: LPS = 1 - turn off power */
103         out_be32(mbar + 0x1050, 0x00000001);
104 }
105
106 static void lite5200_resume_finish(void __iomem *mbar)
107 {
108         /* USB Rh status: LPSC = 1 - turn on power */
109         out_be32(mbar + 0x1050, 0x00010000);
110 }
111 #endif
112
113 static void __init lite5200_setup_arch(void)
114 {
115 #ifdef CONFIG_PCI
116         struct device_node *np;
117 #endif
118
119         if (ppc_md.progress)
120                 ppc_md.progress("lite5200_setup_arch()", 0);
121
122         /* CPU & Port mux setup */
123         mpc52xx_setup_cpu();    /* Generic */
124         lite5200_setup_cpu();   /* Platorm specific */
125
126 #ifdef CONFIG_PM
127         mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
128         mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
129         lite5200_pm_init();
130 #endif
131
132 #ifdef CONFIG_PCI
133         np = of_find_node_by_type(NULL, "pci");
134         if (np) {
135                 mpc52xx_add_bridge(np);
136                 of_node_put(np);
137         }
138 #endif
139
140 #ifdef CONFIG_BLK_DEV_INITRD
141         if (initrd_start)
142                 ROOT_DEV = Root_RAM0;
143         else
144 #endif
145 #ifdef  CONFIG_ROOT_NFS
146                 ROOT_DEV = Root_NFS;
147 #else
148                 ROOT_DEV = Root_HDA1;
149 #endif
150
151 }
152
153 static void lite5200_show_cpuinfo(struct seq_file *m)
154 {
155         struct device_node* np = of_find_all_nodes(NULL);
156         const char *model = NULL;
157
158         if (np)
159                 model = of_get_property(np, "model", NULL);
160
161         seq_printf(m, "vendor\t\t:      Freescale Semiconductor\n");
162         seq_printf(m, "machine\t\t:     %s\n", model ? model : "unknown");
163
164         of_node_put(np);
165 }
166
167 /*
168  * Called very early, MMU is off, device-tree isn't unflattened
169  */
170 static int __init lite5200_probe(void)
171 {
172         unsigned long node = of_get_flat_dt_root();
173         const char *model = of_get_flat_dt_prop(node, "model", NULL);
174
175         if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
176             !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
177                 return 0;
178         pr_debug("%s board found\n", model ? model : "unknown");
179
180         return 1;
181 }
182
183 define_machine(lite5200) {
184         .name           = "lite5200",
185         .probe          = lite5200_probe,
186         .setup_arch     = lite5200_setup_arch,
187         .init           = mpc52xx_declare_of_platform_devices,
188         .init_IRQ       = mpc52xx_init_irq,
189         .get_irq        = mpc52xx_get_irq,
190         .show_cpuinfo   = lite5200_show_cpuinfo,
191         .calibrate_decr = generic_calibrate_decr,
192 };