4c485e984236d57ed2ae012efbe3ca55df9dad55
[deliverable/linux.git] / arch / powerpc / platforms / embedded6xx / prpmc2800.c
1 /*
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
37 static char prpmc2800_platform_name[PLATFORM_NAME_MAX];
38
39 static void __iomem *mv64x60_mpp_reg_base;
40 static void __iomem *mv64x60_gpp_reg_base;
41
42 static void __init prpmc2800_setup_arch(void)
43 {
44 struct device_node *np;
45 phys_addr_t paddr;
46 const unsigned int *reg;
47
48 /*
49 * ioremap mpp and gpp registers in case they are later
50 * needed by prpmc2800_reset_board().
51 */
52 np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-mpp");
53 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
58 np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-gpp");
59 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
64 #ifdef CONFIG_PCI
65 mv64x60_pci_init();
66 #endif
67
68 printk("Motorola %s\n", prpmc2800_platform_name);
69 }
70
71 static 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
104 static 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
120 void prpmc2800_show_cpuinfo(struct seq_file *m)
121 {
122 seq_printf(m, "Vendor\t\t: Motorola\n");
123 seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
124 }
125
126 /*
127 * Called very early, device-tree isn't unflattened
128 */
129 static int __init prpmc2800_probe(void)
130 {
131 unsigned long root = of_get_flat_dt_root();
132 unsigned long len = PLATFORM_NAME_MAX;
133 void *m;
134
135 if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800"))
136 return 0;
137
138 /* Update ppc_md.name with name from dt */
139 m = of_get_flat_dt_prop(root, "model", &len);
140 if (m)
141 strncpy(prpmc2800_platform_name, m,
142 min((int)len, PLATFORM_NAME_MAX - 1));
143
144 _set_L2CR(_get_L2CR() | L2CR_L2E);
145 return 1;
146 }
147
148 define_machine(prpmc2800){
149 .name = prpmc2800_platform_name,
150 .probe = prpmc2800_probe,
151 .setup_arch = prpmc2800_setup_arch,
152 .init_early = mv64x60_init_early,
153 .show_cpuinfo = prpmc2800_show_cpuinfo,
154 .init_IRQ = mv64x60_init_irq,
155 .get_irq = mv64x60_get_irq,
156 .restart = prpmc2800_restart,
157 .calibrate_decr = generic_calibrate_decr,
158 #ifdef CONFIG_KEXEC
159 .machine_kexec = default_machine_kexec,
160 .machine_kexec_prepare = default_machine_kexec_prepare,
161 .machine_crash_shutdown = default_machine_crash_shutdown,
162 #endif
163 };
This page took 0.041867 seconds and 4 git commands to generate.