blob: 4f5ebaadcb50dd340bb3520738df04cc54ecaadb [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
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/bootinfo.h>
39#include <asm/irq.h>
40#include <asm/prom.h>
41#include <asm/udbg.h>
42#include <sysdev/fsl_soc.h>
Grant Likely6b642532006-11-27 14:16:28 -070043#include <asm/of_platform.h>
44
45#include <asm/mpc52xx.h>
46
47/* ************************************************************************
48 *
49 * Setup the architecture
50 *
51 */
52
53static void __init
Grant Likelye3aba812007-02-12 13:36:55 -070054lite5200_setup_cpu(void)
Grant Likely6b642532006-11-27 14:16:28 -070055{
56 struct mpc52xx_gpio __iomem *gpio;
57 u32 port_config;
58
59 /* Map zones */
Grant Likelye3aba812007-02-12 13:36:55 -070060 gpio = mpc52xx_find_and_map("mpc5200-gpio");
Grant Likely6b642532006-11-27 14:16:28 -070061 if (!gpio) {
62 printk(KERN_ERR __FILE__ ": "
63 "Error while mapping GPIO register for port config. "
64 "Expect some abnormal behavior\n");
65 goto error;
66 }
67
68 /* Set port config */
69 port_config = in_be32(&gpio->port_config);
70
71 port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */
72
73 port_config &= ~0x00007000; /* USB port : Differential mode */
74 port_config |= 0x00001000; /* USB 1 only */
75
76 port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */
77 port_config |= 0x01000000;
78
79 pr_debug("port_config: old:%x new:%x\n",
80 in_be32(&gpio->port_config), port_config);
81 out_be32(&gpio->port_config, port_config);
82
83 /* Unmap zone */
84error:
85 iounmap(gpio);
86}
87
Grant Likelye3aba812007-02-12 13:36:55 -070088static void __init lite5200_setup_arch(void)
Grant Likely6b642532006-11-27 14:16:28 -070089{
90 struct device_node *np;
91
92 if (ppc_md.progress)
Grant Likelye3aba812007-02-12 13:36:55 -070093 ppc_md.progress("lite5200_setup_arch()", 0);
Grant Likely6b642532006-11-27 14:16:28 -070094
95 np = of_find_node_by_type(NULL, "cpu");
96 if (np) {
Stephen Rothwelle2eb6392007-04-03 22:26:41 +100097 const unsigned int *fp =
98 of_get_property(np, "clock-frequency", NULL);
Grant Likely6b642532006-11-27 14:16:28 -070099 if (fp != 0)
100 loops_per_jiffy = *fp / HZ;
101 else
102 loops_per_jiffy = 50000000 / HZ;
103 of_node_put(np);
104 }
105
106 /* CPU & Port mux setup */
107 mpc52xx_setup_cpu(); /* Generic */
Grant Likelye3aba812007-02-12 13:36:55 -0700108 lite5200_setup_cpu(); /* Platorm specific */
Grant Likely6b642532006-11-27 14:16:28 -0700109
Grant Likelyf42963f2006-12-12 15:13:19 -0700110#ifdef CONFIG_PCI
111 np = of_find_node_by_type(np, "pci");
112 if (np)
113 mpc52xx_add_bridge(np);
114#endif
115
Grant Likely6b642532006-11-27 14:16:28 -0700116#ifdef CONFIG_BLK_DEV_INITRD
117 if (initrd_start)
118 ROOT_DEV = Root_RAM0;
119 else
120#endif
121#ifdef CONFIG_ROOT_NFS
122 ROOT_DEV = Root_NFS;
123#else
124 ROOT_DEV = Root_HDA1;
125#endif
126
127}
128
Grant Likelye3aba812007-02-12 13:36:55 -0700129void lite5200_show_cpuinfo(struct seq_file *m)
Grant Likely6b642532006-11-27 14:16:28 -0700130{
131 struct device_node* np = of_find_all_nodes(NULL);
132 const char *model = NULL;
133
134 if (np)
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000135 model = of_get_property(np, "model", NULL);
Grant Likely6b642532006-11-27 14:16:28 -0700136
137 seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
138 seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
139
140 of_node_put(np);
141}
142
143/*
144 * Called very early, MMU is off, device-tree isn't unflattened
145 */
Grant Likelye3aba812007-02-12 13:36:55 -0700146static int __init lite5200_probe(void)
Grant Likely6b642532006-11-27 14:16:28 -0700147{
148 unsigned long node = of_get_flat_dt_root();
149 const char *model = of_get_flat_dt_prop(node, "model", NULL);
150
Grant Likelye3aba812007-02-12 13:36:55 -0700151 if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
152 !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
Grant Likely6b642532006-11-27 14:16:28 -0700153 return 0;
Grant Likelye3aba812007-02-12 13:36:55 -0700154 pr_debug("%s board found\n", model ? model : "unknown");
Grant Likely6b642532006-11-27 14:16:28 -0700155
156 return 1;
157}
158
Grant Likelye3aba812007-02-12 13:36:55 -0700159define_machine(lite5200) {
160 .name = "lite5200",
161 .probe = lite5200_probe,
162 .setup_arch = lite5200_setup_arch,
Sylvain Munaut5c334ee2007-01-02 23:29:53 +0100163 .init = mpc52xx_declare_of_platform_devices,
Grant Likely6b642532006-11-27 14:16:28 -0700164 .init_IRQ = mpc52xx_init_irq,
165 .get_irq = mpc52xx_get_irq,
Grant Likelye3aba812007-02-12 13:36:55 -0700166 .show_cpuinfo = lite5200_show_cpuinfo,
Grant Likely6b642532006-11-27 14:16:28 -0700167 .calibrate_decr = generic_calibrate_decr,
168};