blob: cfa3ccf493bb1d36a645d582c74d12d93ca5761d [file] [log] [blame]
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +09001/*
2 * linux/arch/mips/txx9/generic/setup.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
7 * 2003-2005 (c) MontaVista Software, Inc.
8 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/types.h>
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090017#include <linux/interrupt.h>
18#include <linux/string.h>
19#include <linux/module.h>
20#include <linux/clk.h>
21#include <linux/err.h>
Atsushi Nemotoe0eb7302008-07-19 01:51:52 +090022#include <linux/gpio.h>
Atsushi Nemoto68314722008-07-24 00:25:18 +090023#include <linux/platform_device.h>
Atsushi Nemoto7779a5e2008-07-25 23:08:06 +090024#include <linux/serial_core.h>
Atsushi Nemoto51f607c2008-08-19 22:55:11 +090025#include <linux/mtd/physmap.h>
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090026#include <asm/bootinfo.h>
Atsushi Nemotoe0eb7302008-07-19 01:51:52 +090027#include <asm/time.h>
Atsushi Nemotoa49297e2008-07-24 00:25:17 +090028#include <asm/reboot.h>
Atsushi Nemotod10e0252008-08-19 22:55:09 +090029#include <asm/r4kcache.h>
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +090030#include <asm/txx9/generic.h>
Atsushi Nemoto07517522008-07-24 00:25:15 +090031#include <asm/txx9/pci.h>
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090032#ifdef CONFIG_CPU_TX49XX
33#include <asm/txx9/tx4938.h>
34#endif
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +090035
36/* EBUSC settings of TX4927, etc. */
37struct resource txx9_ce_res[8];
38static char txx9_ce_res_name[8][4]; /* "CEn" */
39
40/* pcode, internal register */
Atsushi Nemoto94a4c322008-07-19 01:51:47 +090041unsigned int txx9_pcode;
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +090042char txx9_pcode_str[8];
43static struct resource txx9_reg_res = {
44 .name = txx9_pcode_str,
45 .flags = IORESOURCE_MEM,
46};
47void __init
48txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
49{
50 int i;
51
52 for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
53 sprintf(txx9_ce_res_name[i], "CE%d", i);
54 txx9_ce_res[i].flags = IORESOURCE_MEM;
55 txx9_ce_res[i].name = txx9_ce_res_name[i];
56 }
57
Atsushi Nemoto073828d2008-08-26 21:29:58 +090058 txx9_pcode = pcode;
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +090059 sprintf(txx9_pcode_str, "TX%x", pcode);
60 if (base) {
61 txx9_reg_res.start = base & 0xfffffffffULL;
62 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
63 request_resource(&iomem_resource, &txx9_reg_res);
64 }
65}
66
67/* clocks */
68unsigned int txx9_master_clock;
69unsigned int txx9_cpu_clock;
70unsigned int txx9_gbus_clock;
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090071
Atsushi Nemotoc7b95bc2008-08-19 22:55:10 +090072#ifdef CONFIG_CPU_TX39XX
73/* don't enable by default - see errata */
74int txx9_ccfg_toeon __initdata;
75#else
Atsushi Nemoto94a4c322008-07-19 01:51:47 +090076int txx9_ccfg_toeon __initdata = 1;
Atsushi Nemotoc7b95bc2008-08-19 22:55:10 +090077#endif
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090078
79/* Minimum CLK support */
80
81struct clk *clk_get(struct device *dev, const char *id)
82{
83 if (!strcmp(id, "spi-baseclk"))
Atsushi Nemoto94a4c322008-07-19 01:51:47 +090084 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090085 if (!strcmp(id, "imbus_clk"))
Atsushi Nemoto94a4c322008-07-19 01:51:47 +090086 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +090087 return ERR_PTR(-ENOENT);
88}
89EXPORT_SYMBOL(clk_get);
90
91int clk_enable(struct clk *clk)
92{
93 return 0;
94}
95EXPORT_SYMBOL(clk_enable);
96
97void clk_disable(struct clk *clk)
98{
99}
100EXPORT_SYMBOL(clk_disable);
101
102unsigned long clk_get_rate(struct clk *clk)
103{
104 return (unsigned long)clk;
105}
106EXPORT_SYMBOL(clk_get_rate);
107
108void clk_put(struct clk *clk)
109{
110}
111EXPORT_SYMBOL(clk_put);
112
Atsushi Nemoto8d795f22008-07-18 00:43:48 +0900113/* GPIO support */
114
115#ifdef CONFIG_GENERIC_GPIO
116int gpio_to_irq(unsigned gpio)
117{
118 return -EINVAL;
119}
120EXPORT_SYMBOL(gpio_to_irq);
121
122int irq_to_gpio(unsigned irq)
123{
124 return -EINVAL;
125}
126EXPORT_SYMBOL(irq_to_gpio);
127#endif
128
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900129#define BOARD_VEC(board) extern struct txx9_board_vec board;
130#include <asm/txx9/boards.h>
131#undef BOARD_VEC
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900132
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900133struct txx9_board_vec *txx9_board_vec __initdata;
134static char txx9_system_type[32];
135
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900136static struct txx9_board_vec *board_vecs[] __initdata = {
137#define BOARD_VEC(board) &board,
138#include <asm/txx9/boards.h>
139#undef BOARD_VEC
140};
141
142static struct txx9_board_vec *__init find_board_byname(const char *name)
143{
144 int i;
145
146 /* search board_vecs table */
147 for (i = 0; i < ARRAY_SIZE(board_vecs); i++) {
148 if (strstr(board_vecs[i]->system, name))
149 return board_vecs[i];
150 }
151 return NULL;
152}
153
Atsushi Nemotoe0dfb202008-08-19 22:55:06 +0900154static void __init prom_init_cmdline(void)
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900155{
156 int argc = (int)fw_arg0;
Atsushi Nemotoe0dfb202008-08-19 22:55:06 +0900157 int *argv32 = (int *)fw_arg1;
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900158 int i; /* Always ignore the "-c" at argv[0] */
Atsushi Nemotoe0dfb202008-08-19 22:55:06 +0900159 char builtin[CL_SIZE];
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900160
161 /* ignore all built-in args if any f/w args given */
Atsushi Nemotoe0dfb202008-08-19 22:55:06 +0900162 /*
163 * But if built-in strings was started with '+', append them
164 * to command line args. If built-in was started with '-',
165 * ignore all f/w args.
166 */
167 builtin[0] = '\0';
168 if (arcs_cmdline[0] == '+')
169 strcpy(builtin, arcs_cmdline + 1);
170 else if (arcs_cmdline[0] == '-') {
171 strcpy(builtin, arcs_cmdline + 1);
172 argc = 0;
173 } else if (argc <= 1)
174 strcpy(builtin, arcs_cmdline);
175 arcs_cmdline[0] = '\0';
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900176
177 for (i = 1; i < argc; i++) {
Atsushi Nemotoe0dfb202008-08-19 22:55:06 +0900178 char *str = (char *)(long)argv32[i];
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900179 if (i != 1)
180 strcat(arcs_cmdline, " ");
Atsushi Nemotoe0dfb202008-08-19 22:55:06 +0900181 if (strchr(str, ' ')) {
182 strcat(arcs_cmdline, "\"");
183 strcat(arcs_cmdline, str);
184 strcat(arcs_cmdline, "\"");
185 } else
186 strcat(arcs_cmdline, str);
187 }
188 /* append saved builtin args */
189 if (builtin[0]) {
190 if (arcs_cmdline[0])
191 strcat(arcs_cmdline, " ");
192 strcat(arcs_cmdline, builtin);
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900193 }
194}
195
Atsushi Nemotod10e0252008-08-19 22:55:09 +0900196static int txx9_ic_disable __initdata;
197static int txx9_dc_disable __initdata;
198
199#if defined(CONFIG_CPU_TX49XX)
200/* flush all cache on very early stage (before 4k_cache_init) */
201static void __init early_flush_dcache(void)
202{
203 unsigned int conf = read_c0_config();
204 unsigned int dc_size = 1 << (12 + ((conf & CONF_DC) >> 6));
205 unsigned int linesz = 32;
206 unsigned long addr, end;
207
208 end = INDEX_BASE + dc_size / 4;
209 /* 4way, waybit=0 */
210 for (addr = INDEX_BASE; addr < end; addr += linesz) {
211 cache_op(Index_Writeback_Inv_D, addr | 0);
212 cache_op(Index_Writeback_Inv_D, addr | 1);
213 cache_op(Index_Writeback_Inv_D, addr | 2);
214 cache_op(Index_Writeback_Inv_D, addr | 3);
215 }
216}
217
218static void __init txx9_cache_fixup(void)
219{
220 unsigned int conf;
221
222 conf = read_c0_config();
223 /* flush and disable */
224 if (txx9_ic_disable) {
225 conf |= TX49_CONF_IC;
226 write_c0_config(conf);
227 }
228 if (txx9_dc_disable) {
229 early_flush_dcache();
230 conf |= TX49_CONF_DC;
231 write_c0_config(conf);
232 }
233
234 /* enable cache */
235 conf = read_c0_config();
236 if (!txx9_ic_disable)
237 conf &= ~TX49_CONF_IC;
238 if (!txx9_dc_disable)
239 conf &= ~TX49_CONF_DC;
240 write_c0_config(conf);
241
242 if (conf & TX49_CONF_IC)
243 pr_info("TX49XX I-Cache disabled.\n");
244 if (conf & TX49_CONF_DC)
245 pr_info("TX49XX D-Cache disabled.\n");
246}
247#elif defined(CONFIG_CPU_TX39XX)
248/* flush all cache on very early stage (before tx39_cache_init) */
249static void __init early_flush_dcache(void)
250{
251 unsigned int conf = read_c0_config();
252 unsigned int dc_size = 1 << (10 + ((conf & TX39_CONF_DCS_MASK) >>
253 TX39_CONF_DCS_SHIFT));
254 unsigned int linesz = 16;
255 unsigned long addr, end;
256
257 end = INDEX_BASE + dc_size / 2;
258 /* 2way, waybit=0 */
259 for (addr = INDEX_BASE; addr < end; addr += linesz) {
260 cache_op(Index_Writeback_Inv_D, addr | 0);
261 cache_op(Index_Writeback_Inv_D, addr | 1);
262 }
263}
264
265static void __init txx9_cache_fixup(void)
266{
267 unsigned int conf;
268
269 conf = read_c0_config();
270 /* flush and disable */
271 if (txx9_ic_disable) {
272 conf &= ~TX39_CONF_ICE;
273 write_c0_config(conf);
274 }
275 if (txx9_dc_disable) {
276 early_flush_dcache();
277 conf &= ~TX39_CONF_DCE;
278 write_c0_config(conf);
279 }
280
281 /* enable cache */
282 conf = read_c0_config();
283 if (!txx9_ic_disable)
284 conf |= TX39_CONF_ICE;
285 if (!txx9_dc_disable)
286 conf |= TX39_CONF_DCE;
287 write_c0_config(conf);
288
289 if (!(conf & TX39_CONF_ICE))
290 pr_info("TX39XX I-Cache disabled.\n");
291 if (!(conf & TX39_CONF_DCE))
292 pr_info("TX39XX D-Cache disabled.\n");
293}
294#else
295static inline void txx9_cache_fixup(void)
296{
297}
298#endif
299
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900300static void __init preprocess_cmdline(void)
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900301{
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900302 char cmdline[CL_SIZE];
303 char *s;
304
305 strcpy(cmdline, arcs_cmdline);
306 s = cmdline;
307 arcs_cmdline[0] = '\0';
308 while (s && *s) {
309 char *str = strsep(&s, " ");
310 if (strncmp(str, "board=", 6) == 0) {
311 txx9_board_vec = find_board_byname(str + 6);
312 continue;
313 } else if (strncmp(str, "masterclk=", 10) == 0) {
314 unsigned long val;
315 if (strict_strtoul(str + 10, 10, &val) == 0)
316 txx9_master_clock = val;
317 continue;
Atsushi Nemotod10e0252008-08-19 22:55:09 +0900318 } else if (strcmp(str, "icdisable") == 0) {
319 txx9_ic_disable = 1;
320 continue;
321 } else if (strcmp(str, "dcdisable") == 0) {
322 txx9_dc_disable = 1;
323 continue;
Atsushi Nemotoc7b95bc2008-08-19 22:55:10 +0900324 } else if (strcmp(str, "toeoff") == 0) {
325 txx9_ccfg_toeon = 0;
326 continue;
327 } else if (strcmp(str, "toeon") == 0) {
328 txx9_ccfg_toeon = 1;
329 continue;
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900330 }
331 if (arcs_cmdline[0])
332 strcat(arcs_cmdline, " ");
333 strcat(arcs_cmdline, str);
334 }
Atsushi Nemotod10e0252008-08-19 22:55:09 +0900335
336 txx9_cache_fixup();
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900337}
338
339static void __init select_board(void)
340{
341 const char *envstr;
342
343 /* first, determine by "board=" argument in preprocess_cmdline() */
344 if (txx9_board_vec)
345 return;
346 /* next, determine by "board" envvar */
347 envstr = prom_getenv("board");
348 if (envstr) {
349 txx9_board_vec = find_board_byname(envstr);
350 if (txx9_board_vec)
351 return;
352 }
353
354 /* select "default" board */
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900355#ifdef CONFIG_CPU_TX39XX
Yoichi Yuasa7a1fdf12008-07-13 19:51:55 +0900356 txx9_board_vec = &jmr3927_vec;
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900357#endif
358#ifdef CONFIG_CPU_TX49XX
359 switch (TX4938_REV_PCODE()) {
Atsushi Nemoto8d795f22008-07-18 00:43:48 +0900360#ifdef CONFIG_TOSHIBA_RBTX4927
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900361 case 0x4927:
Yoichi Yuasa7a1fdf12008-07-13 19:51:55 +0900362 txx9_board_vec = &rbtx4927_vec;
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900363 break;
364 case 0x4937:
Yoichi Yuasa7a1fdf12008-07-13 19:51:55 +0900365 txx9_board_vec = &rbtx4937_vec;
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900366 break;
Atsushi Nemoto8d795f22008-07-18 00:43:48 +0900367#endif
368#ifdef CONFIG_TOSHIBA_RBTX4938
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900369 case 0x4938:
Yoichi Yuasa7a1fdf12008-07-13 19:51:55 +0900370 txx9_board_vec = &rbtx4938_vec;
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900371 break;
Atsushi Nemoto8d795f22008-07-18 00:43:48 +0900372#endif
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900373 }
374#endif
Atsushi Nemoto860e5462008-08-19 22:55:08 +0900375}
376
377void __init prom_init(void)
378{
379 prom_init_cmdline();
380 preprocess_cmdline();
381 select_board();
Yoichi Yuasa7a1fdf12008-07-13 19:51:55 +0900382
383 strcpy(txx9_system_type, txx9_board_vec->system);
384
Atsushi Nemoto7b226092008-07-14 00:15:04 +0900385 txx9_board_vec->prom_init();
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900386}
387
388void __init prom_free_prom_memory(void)
389{
390}
391
392const char *get_system_type(void)
393{
394 return txx9_system_type;
395}
396
397char * __init prom_getcmdline(void)
398{
399 return &(arcs_cmdline[0]);
400}
401
Atsushi Nemoto265b89d2008-08-19 22:55:07 +0900402const char *__init prom_getenv(const char *name)
403{
404 const s32 *str = (const s32 *)fw_arg2;
405
406 if (!str)
407 return NULL;
408 /* YAMON style ("name", "value" pairs) */
409 while (str[0] && str[1]) {
410 if (!strcmp((const char *)(unsigned long)str[0], name))
411 return (const char *)(unsigned long)str[1];
412 str += 2;
413 }
414 return NULL;
415}
416
Atsushi Nemotoa49297e2008-07-24 00:25:17 +0900417static void __noreturn txx9_machine_halt(void)
418{
419 local_irq_disable();
420 clear_c0_status(ST0_IM);
421 while (1) {
422 if (cpu_wait) {
423 (*cpu_wait)();
424 if (cpu_has_counter) {
425 /*
426 * Clear counter interrupt while it
427 * breaks WAIT instruction even if
428 * masked.
429 */
430 write_c0_compare(0);
431 }
432 }
433 }
434}
435
Atsushi Nemoto68314722008-07-24 00:25:18 +0900436/* Watchdog support */
437void __init txx9_wdt_init(unsigned long base)
438{
439 struct resource res = {
440 .start = base,
441 .end = base + 0x100 - 1,
442 .flags = IORESOURCE_MEM,
443 };
444 platform_device_register_simple("txx9wdt", -1, &res, 1);
445}
446
Atsushi Nemotoc49f91f2008-07-24 00:25:20 +0900447/* SPI support */
448void __init txx9_spi_init(int busid, unsigned long base, int irq)
449{
450 struct resource res[] = {
451 {
452 .start = base,
453 .end = base + 0x20 - 1,
454 .flags = IORESOURCE_MEM,
455 }, {
456 .start = irq,
457 .flags = IORESOURCE_IRQ,
458 },
459 };
460 platform_device_register_simple("spi_txx9", busid,
461 res, ARRAY_SIZE(res));
462}
463
464void __init txx9_ethaddr_init(unsigned int id, unsigned char *ethaddr)
465{
466 struct platform_device *pdev =
467 platform_device_alloc("tc35815-mac", id);
468 if (!pdev ||
469 platform_device_add_data(pdev, ethaddr, 6) ||
470 platform_device_add(pdev))
471 platform_device_put(pdev);
472}
473
Atsushi Nemoto7779a5e2008-07-25 23:08:06 +0900474void __init txx9_sio_init(unsigned long baseaddr, int irq,
475 unsigned int line, unsigned int sclk, int nocts)
476{
477#ifdef CONFIG_SERIAL_TXX9
478 struct uart_port req;
479
480 memset(&req, 0, sizeof(req));
481 req.line = line;
482 req.iotype = UPIO_MEM;
483 req.membase = ioremap(baseaddr, 0x24);
484 req.mapbase = baseaddr;
485 req.irq = irq;
486 if (!nocts)
487 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
488 if (sclk) {
489 req.flags |= UPF_MAGIC_MULTIPLIER /*USE_SCLK*/;
490 req.uartclk = sclk;
491 } else
492 req.uartclk = TXX9_IMCLK;
493 early_serial_txx9_setup(&req);
494#endif /* CONFIG_SERIAL_TXX9 */
495}
496
Atsushi Nemotoe3529532008-07-29 22:10:08 +0900497#ifdef CONFIG_EARLY_PRINTK
498static void __init null_prom_putchar(char c)
499{
500}
501void (*txx9_prom_putchar)(char c) __initdata = null_prom_putchar;
502
503void __init prom_putchar(char c)
504{
505 txx9_prom_putchar(c);
506}
507
508static void __iomem *early_txx9_sio_port;
509
510static void __init early_txx9_sio_putchar(char c)
511{
512#define TXX9_SICISR 0x0c
513#define TXX9_SITFIFO 0x1c
514#define TXX9_SICISR_TXALS 0x00000002
515 while (!(__raw_readl(early_txx9_sio_port + TXX9_SICISR) &
516 TXX9_SICISR_TXALS))
517 ;
518 __raw_writel(c, early_txx9_sio_port + TXX9_SITFIFO);
519}
520
521void __init txx9_sio_putchar_init(unsigned long baseaddr)
522{
523 early_txx9_sio_port = ioremap(baseaddr, 0x24);
524 txx9_prom_putchar = early_txx9_sio_putchar;
525}
526#endif /* CONFIG_EARLY_PRINTK */
527
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900528/* wrappers */
529void __init plat_mem_setup(void)
530{
Atsushi Nemoto94a4c322008-07-19 01:51:47 +0900531 ioport_resource.start = 0;
532 ioport_resource.end = ~0UL; /* no limit */
533 iomem_resource.start = 0;
534 iomem_resource.end = ~0UL; /* no limit */
Atsushi Nemotoa49297e2008-07-24 00:25:17 +0900535
536 /* fallback restart/halt routines */
537 _machine_restart = (void (*)(char *))txx9_machine_halt;
538 _machine_halt = txx9_machine_halt;
539 pm_power_off = txx9_machine_halt;
540
Atsushi Nemoto07517522008-07-24 00:25:15 +0900541#ifdef CONFIG_PCI
542 pcibios_plat_setup = txx9_pcibios_setup;
543#endif
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900544 txx9_board_vec->mem_setup();
545}
546
547void __init arch_init_irq(void)
548{
549 txx9_board_vec->irq_setup();
550}
551
552void __init plat_time_init(void)
553{
Atsushi Nemoto1374d082008-07-31 22:29:53 +0900554#ifdef CONFIG_CPU_TX49XX
555 mips_hpt_frequency = txx9_cpu_clock / 2;
556#endif
Atsushi Nemotoedcaf1a2008-07-11 23:27:54 +0900557 txx9_board_vec->time_init();
558}
559
560static int __init _txx9_arch_init(void)
561{
562 if (txx9_board_vec->arch_init)
563 txx9_board_vec->arch_init();
564 return 0;
565}
566arch_initcall(_txx9_arch_init);
567
568static int __init _txx9_device_init(void)
569{
570 if (txx9_board_vec->device_init)
571 txx9_board_vec->device_init();
572 return 0;
573}
574device_initcall(_txx9_device_init);
575
576int (*txx9_irq_dispatch)(int pending);
577asmlinkage void plat_irq_dispatch(void)
578{
579 int pending = read_c0_status() & read_c0_cause() & ST0_IM;
580 int irq = txx9_irq_dispatch(pending);
581
582 if (likely(irq >= 0))
583 do_IRQ(irq);
584 else
585 spurious_interrupt();
586}
Atsushi Nemoto4c642f32008-07-13 23:37:56 +0900587
588/* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
589#ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
590static unsigned long __swizzle_addr_none(unsigned long port)
591{
592 return port;
593}
594unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
595EXPORT_SYMBOL(__swizzle_addr_b);
596#endif
Atsushi Nemoto51f607c2008-08-19 22:55:11 +0900597
598void __init txx9_physmap_flash_init(int no, unsigned long addr,
599 unsigned long size,
600 const struct physmap_flash_data *pdata)
601{
602#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
603 struct resource res = {
604 .start = addr,
605 .end = addr + size - 1,
606 .flags = IORESOURCE_MEM,
607 };
608 struct platform_device *pdev;
609#ifdef CONFIG_MTD_PARTITIONS
610 static struct mtd_partition parts[2];
611 struct physmap_flash_data pdata_part;
612
613 /* If this area contained boot area, make separate partition */
614 if (pdata->nr_parts == 0 && !pdata->parts &&
615 addr < 0x1fc00000 && addr + size > 0x1fc00000 &&
616 !parts[0].name) {
617 parts[0].name = "boot";
618 parts[0].offset = 0x1fc00000 - addr;
619 parts[0].size = addr + size - 0x1fc00000;
620 parts[1].name = "user";
621 parts[1].offset = 0;
622 parts[1].size = 0x1fc00000 - addr;
623 pdata_part = *pdata;
624 pdata_part.nr_parts = ARRAY_SIZE(parts);
625 pdata_part.parts = parts;
626 pdata = &pdata_part;
627 }
628#endif
629 pdev = platform_device_alloc("physmap-flash", no);
630 if (!pdev ||
631 platform_device_add_resources(pdev, &res, 1) ||
632 platform_device_add_data(pdev, pdata, sizeof(*pdata)) ||
633 platform_device_add(pdev))
634 platform_device_put(pdev);
635#endif
636}