blob: b90555cb80890135fee12f7cc3ec361127106836 [file] [log] [blame]
Chris Zankel8fa57232008-11-06 10:17:46 -08001/*
2 * arch/xtensa/platforms/xt2000/setup.c
3 *
4 * Platform specific functions for the XT2000 board.
5 *
6 * Authors: Chris Zankel <chris@zankel.net>
7 * Joe Taylor <joe@tensilica.com>
8 *
9 * Copyright 2001 - 2004 Tensilica Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17#include <linux/stddef.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/errno.h>
21#include <linux/reboot.h>
22#include <linux/kdev_t.h>
23#include <linux/types.h>
24#include <linux/major.h>
25#include <linux/console.h>
26#include <linux/delay.h>
27#include <linux/stringify.h>
28#include <linux/platform_device.h>
29#include <linux/serial.h>
30#include <linux/serial_8250.h>
31
32#include <asm/processor.h>
33#include <asm/platform.h>
34#include <asm/bootparam.h>
35#include <platform/hardware.h>
36#include <platform/serial.h>
37
38/* Assumes s points to an 8-chr string. No checking for NULL. */
39
40static void led_print (int f, char *s)
41{
42 unsigned long* led_addr = (unsigned long*) (XT2000_LED_ADDR + 0xE0) + f;
43 int i;
44 for (i = f; i < 8; i++)
45 if ((*led_addr++ = *s++) == 0)
46 break;
47}
48
49void platform_halt(void)
50{
51 led_print (0, " HALT ");
52 local_irq_disable();
53 while (1);
54}
55
56void platform_power_off(void)
57{
58 led_print (0, "POWEROFF");
59 local_irq_disable();
60 while (1);
61}
62
63void platform_restart(void)
64{
65 /* Flush and reset the mmu, simulate a processor reset, and
66 * jump to the reset vector. */
67
68 __asm__ __volatile__ ("movi a2, 15\n\t"
Max Filippovbc5378f2012-10-15 03:55:38 +040069 "wsr a2, icountlevel\n\t"
Chris Zankel8fa57232008-11-06 10:17:46 -080070 "movi a2, 0\n\t"
Max Filippovbc5378f2012-10-15 03:55:38 +040071 "wsr a2, icount\n\t"
Max Filippovd83ff0b2013-03-04 03:40:42 +040072#if XCHAL_NUM_IBREAK > 0
Max Filippovbc5378f2012-10-15 03:55:38 +040073 "wsr a2, ibreakenable\n\t"
Max Filippovd83ff0b2013-03-04 03:40:42 +040074#endif
Max Filippovbc5378f2012-10-15 03:55:38 +040075 "wsr a2, lcount\n\t"
Chris Zankel8fa57232008-11-06 10:17:46 -080076 "movi a2, 0x1f\n\t"
Max Filippovbc5378f2012-10-15 03:55:38 +040077 "wsr a2, ps\n\t"
Chris Zankel8fa57232008-11-06 10:17:46 -080078 "isync\n\t"
79 "jx %0\n\t"
80 :
81 : "a" (XCHAL_RESET_VECTOR_VADDR)
82 : "a2"
83 );
84
85 /* control never gets here */
86}
87
88void __init platform_setup(char** cmdline)
89{
90 led_print (0, "LINUX ");
91}
92
93/* early initialization */
94
Max Filippovcfe82552014-04-10 02:40:00 +040095void __init platform_init(bp_tag_t *first)
Chris Zankel8fa57232008-11-06 10:17:46 -080096{
Chris Zankel8fa57232008-11-06 10:17:46 -080097}
98
99/* Heartbeat. Let the LED blink. */
100
101void platform_heartbeat(void)
102{
103 static int i=0, t = 0;
104
105 if (--t < 0)
106 {
107 t = 59;
108 led_print(7, i ? ".": " ");
109 i ^= 1;
110 }
111}
112
113//#define RS_TABLE_SIZE 2
114//#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
115
116#define _SERIAL_PORT(_base,_irq) \
117{ \
118 .mapbase = (_base), \
119 .membase = (void*)(_base), \
120 .irq = (_irq), \
121 .uartclk = DUART16552_XTAL_FREQ, \
122 .iotype = UPIO_MEM, \
123 .flags = UPF_BOOT_AUTOCONF, \
124 .regshift = 2, \
125}
126
127static struct plat_serial8250_port xt2000_serial_data[] = {
128#if XCHAL_HAVE_BE
129 _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
130 _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
131#else
132 _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
133 _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
134#endif
135 { }
136};
137
138static struct platform_device xt2000_serial8250_device = {
139 .name = "serial8250",
140 .id = PLAT8250_DEV_PLATFORM,
141 .dev = {
142 .platform_data = xt2000_serial_data,
143 },
144};
145
146static struct resource xt2000_sonic_res[] = {
147 {
148 .start = SONIC83934_ADDR,
149 .end = SONIC83934_ADDR + 0xff,
150 .flags = IORESOURCE_MEM,
151 },
152 {
153 .start = SONIC83934_INTNUM,
154 .end = SONIC83934_INTNUM,
155 .flags = IORESOURCE_IRQ,
156 },
157};
158
159static struct platform_device xt2000_sonic_device = {
160 .name = "xtsonic",
161 .num_resources = ARRAY_SIZE(xt2000_sonic_res),
162 .resource = xt2000_sonic_res,
163};
164
165static int __init xt2000_setup_devinit(void)
166{
167 platform_device_register(&xt2000_serial8250_device);
168 platform_device_register(&xt2000_sonic_device);
169
170 return 0;
171}
172
173device_initcall(xt2000_setup_devinit);