blob: 5a19b9a1457ca3829070faae3d29786fdc0a7067 [file] [log] [blame]
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +10001/*
2 * Board setup routines for the Motorola PrPMC2800
3 *
4 * Author: Dale Farnsworth <dale@farnsworth.org>
5 *
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/delay.h>
15#include <linux/interrupt.h>
16#include <linux/seq_file.h>
17
18#include <asm/machdep.h>
19#include <asm/prom.h>
20#include <asm/system.h>
21#include <asm/time.h>
22#include <asm/kexec.h>
23
24#include <mm/mmu_decl.h>
25
26#include <sysdev/mv64x60.h>
27
28#define MV64x60_MPP_CNTL_0 0x0000
29#define MV64x60_MPP_CNTL_2 0x0008
30
31#define MV64x60_GPP_IO_CNTL 0x0000
32#define MV64x60_GPP_LEVEL_CNTL 0x0010
33#define MV64x60_GPP_VALUE_SET 0x0018
34
35#define PLATFORM_NAME_MAX 32
36
37static char prpmc2800_platform_name[PLATFORM_NAME_MAX];
38
39static void __iomem *mv64x60_mpp_reg_base;
40static void __iomem *mv64x60_gpp_reg_base;
41
42static void __init prpmc2800_setup_arch(void)
43{
44 struct device_node *np;
45 phys_addr_t paddr;
46 const unsigned int *reg;
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100047
48 /*
49 * ioremap mpp and gpp registers in case they are later
50 * needed by prpmc2800_reset_board().
51 */
Mark A. Greera1810b42008-04-08 08:09:03 +100052 np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-mpp");
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100053 reg = of_get_property(np, "reg", NULL);
54 paddr = of_translate_address(np, reg);
55 of_node_put(np);
56 mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
57
Mark A. Greera1810b42008-04-08 08:09:03 +100058 np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-gpp");
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100059 reg = of_get_property(np, "reg", NULL);
60 paddr = of_translate_address(np, reg);
61 of_node_put(np);
62 mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
63
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100064#ifdef CONFIG_PCI
65 mv64x60_pci_init();
66#endif
67
68 printk("Motorola %s\n", prpmc2800_platform_name);
69}
70
71static void prpmc2800_reset_board(void)
72{
73 u32 temp;
74
75 local_irq_disable();
76
77 temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
78 temp &= 0xFFFF0FFF;
79 out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
80
81 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
82 temp |= 0x00000004;
83 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
84
85 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
86 temp |= 0x00000004;
87 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
88
89 temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
90 temp &= 0xFFFF0FFF;
91 out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
92
93 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
94 temp |= 0x00080000;
95 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
96
97 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
98 temp |= 0x00080000;
99 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
100
101 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
102}
103
104static void prpmc2800_restart(char *cmd)
105{
106 volatile ulong i = 10000000;
107
108 prpmc2800_reset_board();
109
110 while (i-- > 0);
111 panic("restart failed\n");
112}
113
114#ifdef CONFIG_NOT_COHERENT_CACHE
115#define PPRPM2800_COHERENCY_SETTING "off"
116#else
117#define PPRPM2800_COHERENCY_SETTING "on"
118#endif
119
120void prpmc2800_show_cpuinfo(struct seq_file *m)
121{
122 uint memsize = total_memory;
123
124 seq_printf(m, "Vendor\t\t: Motorola\n");
125 seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
126 seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
127}
128
129/*
130 * Called very early, device-tree isn't unflattened
131 */
132static int __init prpmc2800_probe(void)
133{
134 unsigned long root = of_get_flat_dt_root();
135 unsigned long len = PLATFORM_NAME_MAX;
136 void *m;
137
138 if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800"))
139 return 0;
140
141 /* Update ppc_md.name with name from dt */
142 m = of_get_flat_dt_prop(root, "model", &len);
143 if (m)
144 strncpy(prpmc2800_platform_name, m,
145 min((int)len, PLATFORM_NAME_MAX - 1));
146
Mark A. Greer0961dbf2007-11-15 06:04:02 +1100147 _set_L2CR(_get_L2CR() | L2CR_L2E);
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000148 return 1;
149}
150
151define_machine(prpmc2800){
152 .name = prpmc2800_platform_name,
153 .probe = prpmc2800_probe,
154 .setup_arch = prpmc2800_setup_arch,
Dale Farnsworth9b41fcb02007-05-15 05:52:22 +1000155 .init_early = mv64x60_init_early,
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000156 .show_cpuinfo = prpmc2800_show_cpuinfo,
157 .init_IRQ = mv64x60_init_irq,
158 .get_irq = mv64x60_get_irq,
159 .restart = prpmc2800_restart,
160 .calibrate_decr = generic_calibrate_decr,
161#ifdef CONFIG_KEXEC
162 .machine_kexec = default_machine_kexec,
163 .machine_kexec_prepare = default_machine_kexec_prepare,
164 .machine_crash_shutdown = default_machine_crash_shutdown,
165#endif
166};