blob: 7fa0ec8d91cc2270f8d5304c3843fe5cd2d99842 [file] [log] [blame]
Grant Likely6b642532006-11-27 14:16:28 -07001/*
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
Grant Likely6b642532006-11-27 14:16:28 -070018#include <linux/init.h>
Grant Likely6b642532006-11-27 14:16:28 -070019#include <linux/pci.h>
Grant Likely9fe2e792007-10-10 09:52:00 -060020#include <linux/of.h>
Grant Likely6b642532006-11-27 14:16:28 -070021#include <asm/time.h>
22#include <asm/io.h>
23#include <asm/machdep.h>
Grant Likely6b642532006-11-27 14:16:28 -070024#include <asm/prom.h>
Grant Likely6b642532006-11-27 14:16:28 -070025#include <asm/mpc52xx.h>
26
27/* ************************************************************************
28 *
29 * Setup the architecture
30 *
31 */
32
33static void __init
Grant Likelye3aba812007-02-12 13:36:55 -070034lite5200_setup_cpu(void)
Grant Likely6b642532006-11-27 14:16:28 -070035{
36 struct mpc52xx_gpio __iomem *gpio;
37 u32 port_config;
38
39 /* Map zones */
Grant Likelye3aba812007-02-12 13:36:55 -070040 gpio = mpc52xx_find_and_map("mpc5200-gpio");
Grant Likely6b642532006-11-27 14:16:28 -070041 if (!gpio) {
42 printk(KERN_ERR __FILE__ ": "
43 "Error while mapping GPIO register for port config. "
44 "Expect some abnormal behavior\n");
45 goto error;
46 }
47
48 /* Set port config */
49 port_config = in_be32(&gpio->port_config);
50
51 port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */
52
53 port_config &= ~0x00007000; /* USB port : Differential mode */
54 port_config |= 0x00001000; /* USB 1 only */
55
56 port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */
57 port_config |= 0x01000000;
58
59 pr_debug("port_config: old:%x new:%x\n",
60 in_be32(&gpio->port_config), port_config);
61 out_be32(&gpio->port_config, port_config);
62
63 /* Unmap zone */
64error:
65 iounmap(gpio);
66}
67
Domen Puncer2e1ee1f2007-05-07 01:38:52 +100068#ifdef CONFIG_PM
Domen Puncer2e1ee1f2007-05-07 01:38:52 +100069static void lite5200_suspend_prepare(void __iomem *mbar)
70{
71 u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */
72 u8 level = 0; /* wakeup on low level */
73 mpc52xx_set_wakeup_gpio(pin, level);
74
75 /*
76 * power down usb port
77 * this needs to be called before of-ohci suspend code
78 */
Domen Punceree983072007-07-18 06:32:31 +100079
80 /* set ports to "power switched" and "powered at the same time"
81 * USB Rh descriptor A: NPS = 0, PSM = 0 */
82 out_be32(mbar + 0x1048, in_be32(mbar + 0x1048) & ~0x300);
83 /* USB Rh status: LPS = 1 - turn off power */
84 out_be32(mbar + 0x1050, 0x00000001);
Domen Puncer2e1ee1f2007-05-07 01:38:52 +100085}
86
87static void lite5200_resume_finish(void __iomem *mbar)
88{
Domen Punceree983072007-07-18 06:32:31 +100089 /* USB Rh status: LPSC = 1 - turn on power */
90 out_be32(mbar + 0x1050, 0x00010000);
Domen Puncer2e1ee1f2007-05-07 01:38:52 +100091}
92#endif
93
Grant Likelye3aba812007-02-12 13:36:55 -070094static void __init lite5200_setup_arch(void)
Grant Likely6b642532006-11-27 14:16:28 -070095{
Jon Loeliger7888fbf2007-07-28 04:24:52 +100096#ifdef CONFIG_PCI
Grant Likely6b642532006-11-27 14:16:28 -070097 struct device_node *np;
Jon Loeliger7888fbf2007-07-28 04:24:52 +100098#endif
Grant Likely6b642532006-11-27 14:16:28 -070099
100 if (ppc_md.progress)
Grant Likelye3aba812007-02-12 13:36:55 -0700101 ppc_md.progress("lite5200_setup_arch()", 0);
Grant Likely6b642532006-11-27 14:16:28 -0700102
Grant Likely6b642532006-11-27 14:16:28 -0700103 /* CPU & Port mux setup */
104 mpc52xx_setup_cpu(); /* Generic */
Grant Likelye3aba812007-02-12 13:36:55 -0700105 lite5200_setup_cpu(); /* Platorm specific */
Grant Likely6b642532006-11-27 14:16:28 -0700106
Domen Puncer2e1ee1f2007-05-07 01:38:52 +1000107#ifdef CONFIG_PM
108 mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
109 mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
Domen Punceree983072007-07-18 06:32:31 +1000110 lite5200_pm_init();
Domen Puncer2e1ee1f2007-05-07 01:38:52 +1000111#endif
112
Grant Likelyf42963f2006-12-12 15:13:19 -0700113#ifdef CONFIG_PCI
John Rigby6ec36702007-04-07 08:57:37 +1000114 np = of_find_node_by_type(NULL, "pci");
115 if (np) {
Grant Likelyf42963f2006-12-12 15:13:19 -0700116 mpc52xx_add_bridge(np);
John Rigby6ec36702007-04-07 08:57:37 +1000117 of_node_put(np);
118 }
Grant Likelyf42963f2006-12-12 15:13:19 -0700119#endif
120
Grant Likely6b642532006-11-27 14:16:28 -0700121#ifdef CONFIG_BLK_DEV_INITRD
122 if (initrd_start)
123 ROOT_DEV = Root_RAM0;
124 else
125#endif
126#ifdef CONFIG_ROOT_NFS
127 ROOT_DEV = Root_NFS;
128#else
129 ROOT_DEV = Root_HDA1;
130#endif
131
132}
133
Grant Likely6b642532006-11-27 14:16:28 -0700134/*
135 * Called very early, MMU is off, device-tree isn't unflattened
136 */
Grant Likelye3aba812007-02-12 13:36:55 -0700137static int __init lite5200_probe(void)
Grant Likely6b642532006-11-27 14:16:28 -0700138{
139 unsigned long node = of_get_flat_dt_root();
140 const char *model = of_get_flat_dt_prop(node, "model", NULL);
141
Grant Likelye3aba812007-02-12 13:36:55 -0700142 if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
143 !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
Grant Likely6b642532006-11-27 14:16:28 -0700144 return 0;
Grant Likelye3aba812007-02-12 13:36:55 -0700145 pr_debug("%s board found\n", model ? model : "unknown");
Grant Likely6b642532006-11-27 14:16:28 -0700146
147 return 1;
148}
149
Grant Likelye3aba812007-02-12 13:36:55 -0700150define_machine(lite5200) {
151 .name = "lite5200",
152 .probe = lite5200_probe,
153 .setup_arch = lite5200_setup_arch,
Sylvain Munaut5c334ee2007-01-02 23:29:53 +0100154 .init = mpc52xx_declare_of_platform_devices,
Grant Likely6b642532006-11-27 14:16:28 -0700155 .init_IRQ = mpc52xx_init_irq,
156 .get_irq = mpc52xx_get_irq,
Grant Likely6b642532006-11-27 14:16:28 -0700157 .calibrate_decr = generic_calibrate_decr,
158};