Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
prpmc2800.c
Go to the documentation of this file.
1 /*
2  * Board setup routines for the Motorola PrPMC2800
3  *
4  * Author: Dale Farnsworth <[email protected]>
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/time.h>
21 
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 
35 static char prpmc2800_platform_name[PLATFORM_NAME_MAX];
36 
37 static void __iomem *mv64x60_mpp_reg_base;
38 static void __iomem *mv64x60_gpp_reg_base;
39 
40 static void __init prpmc2800_setup_arch(void)
41 {
42  struct device_node *np;
44  const unsigned int *reg;
45 
46  /*
47  * ioremap mpp and gpp registers in case they are later
48  * needed by prpmc2800_reset_board().
49  */
50  np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-mpp");
51  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 
56  np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-gpp");
57  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 
62 #ifdef CONFIG_PCI
64 #endif
65 
66  printk("Motorola %s\n", prpmc2800_platform_name);
67 }
68 
69 static void prpmc2800_reset_board(void)
70 {
71  u32 temp;
72 
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 
102 static 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 
119 {
120  seq_printf(m, "Vendor\t\t: Motorola\n");
121  seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
122 }
123 
124 /*
125  * Called very early, device-tree isn't unflattened
126  */
127 static 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 
142  _set_L2CR(_get_L2CR() | L2CR_L2E);
143  return 1;
144 }
145 
146 define_machine(prpmc2800){
147  .name = prpmc2800_platform_name,
148  .probe = prpmc2800_probe,
149  .setup_arch = prpmc2800_setup_arch,
150  .init_early = mv64x60_init_early,
151  .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,
156 };