Linux 2.6.25-rc4
[linux-2.6/next.git] / arch / mips / pmc-sierra / msp71xx / msp_setup.c
blobc93675615f5d8582c3323349157c663853e6df6e
1 /*
2 * The generic setup file for PMC-Sierra MSP processors
4 * Copyright 2005-2007 PMC-Sierra, Inc,
5 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 #include <asm/bootinfo.h>
14 #include <asm/cacheflush.h>
15 #include <asm/r4kcache.h>
16 #include <asm/reboot.h>
17 #include <asm/time.h>
19 #include <msp_prom.h>
20 #include <msp_regs.h>
22 #if defined(CONFIG_PMC_MSP7120_GW)
23 #include <msp_regops.h>
24 #include <msp_gpio.h>
25 #define MSP_BOARD_RESET_GPIO 9
26 #endif
28 extern void msp_serial_setup(void);
29 extern void pmctwiled_setup(void);
31 #if defined(CONFIG_PMC_MSP7120_EVAL) || \
32 defined(CONFIG_PMC_MSP7120_GW) || \
33 defined(CONFIG_PMC_MSP7120_FPGA)
35 * Performs the reset for MSP7120-based boards
37 void msp7120_reset(void)
39 void *start, *end, *iptr;
40 register int i;
42 /* Diasble all interrupts */
43 local_irq_disable();
44 #ifdef CONFIG_SYS_SUPPORTS_MULTITHREADING
45 dvpe();
46 #endif
48 /* Cache the reset code of this function */
49 __asm__ __volatile__ (
50 " .set push \n"
51 " .set mips3 \n"
52 " la %0,startpoint \n"
53 " la %1,endpoint \n"
54 " .set pop \n"
55 : "=r" (start), "=r" (end)
59 for (iptr = (void *)((unsigned int)start & ~(L1_CACHE_BYTES - 1));
60 iptr < end; iptr += L1_CACHE_BYTES)
61 cache_op(Fill, iptr);
63 __asm__ __volatile__ (
64 "startpoint: \n"
67 /* Put the DDRC into self-refresh mode */
68 DDRC_INDIRECT_WRITE(DDRC_CTL(10), 0xb, 1 << 16);
71 * IMPORTANT!
72 * DO NOT do anything from here on out that might even
73 * think about fetching from RAM - i.e., don't call any
74 * non-inlined functions, and be VERY sure that any inline
75 * functions you do call do NOT access any sort of RAM
76 * anywhere!
79 /* Wait a bit for the DDRC to settle */
80 for (i = 0; i < 100000000; i++);
82 #if defined(CONFIG_PMC_MSP7120_GW)
84 * Set GPIO 9 HI, (tied to board reset logic)
85 * GPIO 9 is the 4th GPIO of register 3
87 * NOTE: We cannot use the higher-level msp_gpio_mode()/out()
88 * as GPIO char driver may not be enabled and it would look up
89 * data inRAM!
91 set_value_reg32(GPIO_CFG3_REG,
92 basic_mode_mask(MSP_BOARD_RESET_GPIO),
93 basic_mode(MSP_GPIO_OUTPUT, MSP_BOARD_RESET_GPIO));
94 set_reg32(GPIO_DATA3_REG,
95 basic_data_mask(MSP_BOARD_RESET_GPIO));
98 * In case GPIO9 doesn't reset the board (jumper configurable!)
99 * fallback to device reset below.
101 #endif
102 /* Set bit 1 of the MSP7120 reset register */
103 *RST_SET_REG = 0x00000001;
105 __asm__ __volatile__ (
106 "endpoint: \n"
109 #endif
111 void msp_restart(char *command)
113 printk(KERN_WARNING "Now rebooting .......\n");
115 #if defined(CONFIG_PMC_MSP7120_EVAL) || \
116 defined(CONFIG_PMC_MSP7120_GW) || \
117 defined(CONFIG_PMC_MSP7120_FPGA)
118 msp7120_reset();
119 #else
120 /* No chip-specific reset code, just jump to the ROM reset vector */
121 set_c0_status(ST0_BEV | ST0_ERL);
122 change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
123 flush_cache_all();
124 write_c0_wired(0);
126 __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
127 #endif
130 void msp_halt(void)
132 printk(KERN_WARNING "\n** You can safely turn off the power\n");
133 while (1)
134 /* If possible call official function to get CPU WARs */
135 if (cpu_wait)
136 (*cpu_wait)();
137 else
138 __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
141 void msp_power_off(void)
143 msp_halt();
146 void __init plat_mem_setup(void)
148 _machine_restart = msp_restart;
149 _machine_halt = msp_halt;
150 pm_power_off = msp_power_off;
153 void __init prom_init(void)
155 unsigned long family;
156 unsigned long revision;
158 prom_argc = fw_arg0;
159 prom_argv = (char **)fw_arg1;
160 prom_envp = (char **)fw_arg2;
163 * Someday we can use this with PMON2000 to get a
164 * platform call prom routines for output etc. without
165 * having to use grody hacks. For now it's unused.
167 * struct callvectors *cv = (struct callvectors *) fw_arg3;
169 family = identify_family();
170 revision = identify_revision();
172 switch (family) {
173 case FAMILY_FPGA:
174 if (FPGA_IS_MSP4200(revision)) {
175 /* Old-style revision ID */
176 mips_machtype = MACH_MSP4200_FPGA;
177 } else {
178 mips_machtype = MACH_MSP_OTHER;
180 break;
182 case FAMILY_MSP4200:
183 #if defined(CONFIG_PMC_MSP4200_EVAL)
184 mips_machtype = MACH_MSP4200_EVAL;
185 #elif defined(CONFIG_PMC_MSP4200_GW)
186 mips_machtype = MACH_MSP4200_GW;
187 #else
188 mips_machtype = MACH_MSP_OTHER;
189 #endif
190 break;
192 case FAMILY_MSP4200_FPGA:
193 mips_machtype = MACH_MSP4200_FPGA;
194 break;
196 case FAMILY_MSP7100:
197 #if defined(CONFIG_PMC_MSP7120_EVAL)
198 mips_machtype = MACH_MSP7120_EVAL;
199 #elif defined(CONFIG_PMC_MSP7120_GW)
200 mips_machtype = MACH_MSP7120_GW;
201 #else
202 mips_machtype = MACH_MSP_OTHER;
203 #endif
204 break;
206 case FAMILY_MSP7100_FPGA:
207 mips_machtype = MACH_MSP7120_FPGA;
208 break;
210 default:
211 /* we don't recognize the machine */
212 mips_machtype = MACH_UNKNOWN;
213 panic("***Bogosity factor five***, exiting\n");
214 break;
217 prom_init_cmdline();
219 prom_meminit();
222 * Sub-system setup follows.
223 * Setup functions can either be called here or using the
224 * subsys_initcall mechanism (i.e. see msp_pci_setup). The
225 * order in which they are called can be changed by using the
226 * link order in arch/mips/pmc-sierra/msp71xx/Makefile.
228 * NOTE: Please keep sub-system specific initialization code
229 * in separate specific files.
231 msp_serial_setup();
233 #ifdef CONFIG_PMCTWILED
235 * Setup LED states before the subsys_initcall loads other
236 * dependant drivers/modules.
238 pmctwiled_setup();
239 #endif