blob: d455f08bea53939e021219d3bb406cf1b18f9dc7 [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>
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100020#include <asm/time.h>
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100021
22#include <mm/mmu_decl.h>
23
24#include <sysdev/mv64x60.h>
25
26#define MV64x60_MPP_CNTL_0 0x0000
27#define MV64x60_MPP_CNTL_2 0x0008
28
29#define MV64x60_GPP_IO_CNTL 0x0000
30#define MV64x60_GPP_LEVEL_CNTL 0x0010
31#define MV64x60_GPP_VALUE_SET 0x0018
32
33#define PLATFORM_NAME_MAX 32
34
35static char prpmc2800_platform_name[PLATFORM_NAME_MAX];
36
37static void __iomem *mv64x60_mpp_reg_base;
38static void __iomem *mv64x60_gpp_reg_base;
39
40static void __init prpmc2800_setup_arch(void)
41{
42 struct device_node *np;
43 phys_addr_t paddr;
44 const unsigned int *reg;
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100045
46 /*
47 * ioremap mpp and gpp registers in case they are later
48 * needed by prpmc2800_reset_board().
49 */
Mark A. Greera1810b42008-04-08 08:09:03 +100050 np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-mpp");
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100051 reg = of_get_property(np, "reg", NULL);
52 paddr = of_translate_address(np, reg);
53 of_node_put(np);
54 mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
55
Mark A. Greera1810b42008-04-08 08:09:03 +100056 np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-gpp");
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100057 reg = of_get_property(np, "reg", NULL);
58 paddr = of_translate_address(np, reg);
59 of_node_put(np);
60 mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
61
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +100062#ifdef CONFIG_PCI
63 mv64x60_pci_init();
64#endif
65
66 printk("Motorola %s\n", prpmc2800_platform_name);
67}
68
69static void prpmc2800_reset_board(void)
70{
71 u32 temp;
72
73 local_irq_disable();
74
75 temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
76 temp &= 0xFFFF0FFF;
77 out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
78
79 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
80 temp |= 0x00000004;
81 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
82
83 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
84 temp |= 0x00000004;
85 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
86
87 temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
88 temp &= 0xFFFF0FFF;
89 out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
90
91 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
92 temp |= 0x00080000;
93 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
94
95 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
96 temp |= 0x00080000;
97 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
98
99 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
100}
101
102static void prpmc2800_restart(char *cmd)
103{
104 volatile ulong i = 10000000;
105
106 prpmc2800_reset_board();
107
108 while (i-- > 0);
109 panic("restart failed\n");
110}
111
112#ifdef CONFIG_NOT_COHERENT_CACHE
113#define PPRPM2800_COHERENCY_SETTING "off"
114#else
115#define PPRPM2800_COHERENCY_SETTING "on"
116#endif
117
118void prpmc2800_show_cpuinfo(struct seq_file *m)
119{
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000120 seq_printf(m, "Vendor\t\t: Motorola\n");
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000121 seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
122}
123
124/*
125 * Called very early, device-tree isn't unflattened
126 */
127static int __init prpmc2800_probe(void)
128{
129 unsigned long root = of_get_flat_dt_root();
130 unsigned long len = PLATFORM_NAME_MAX;
131 void *m;
132
133 if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800"))
134 return 0;
135
136 /* Update ppc_md.name with name from dt */
137 m = of_get_flat_dt_prop(root, "model", &len);
138 if (m)
139 strncpy(prpmc2800_platform_name, m,
140 min((int)len, PLATFORM_NAME_MAX - 1));
141
Mark A. Greer0961dbf2007-11-15 06:04:02 +1100142 _set_L2CR(_get_L2CR() | L2CR_L2E);
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000143 return 1;
144}
145
146define_machine(prpmc2800){
147 .name = prpmc2800_platform_name,
148 .probe = prpmc2800_probe,
149 .setup_arch = prpmc2800_setup_arch,
Dale Farnsworth9b41fcb2007-05-15 05:52:22 +1000150 .init_early = mv64x60_init_early,
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000151 .show_cpuinfo = prpmc2800_show_cpuinfo,
152 .init_IRQ = mv64x60_init_irq,
153 .get_irq = mv64x60_get_irq,
154 .restart = prpmc2800_restart,
155 .calibrate_decr = generic_calibrate_decr,
Dale Farnsworthfd4ba7e2007-05-12 10:58:43 +1000156};