1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
66
67 cpu_reset();
68
69}
70
71void __init platform_setup(char** cmdline)
72{
73 led_print (0, "LINUX ");
74}
75
76
77
78void __init platform_init(bp_tag_t *first)
79{
80}
81
82
83
84void platform_heartbeat(void)
85{
86 static int i=0, t = 0;
87
88 if (--t < 0)
89 {
90 t = 59;
91 led_print(7, i ? ".": " ");
92 i ^= 1;
93 }
94}
95
96
97
98#define _SERIAL_PORT(_base,_irq) \
99{ \
100 .mapbase = (_base), \
101 .membase = (void*)(_base), \
102 .irq = (_irq), \
103 .uartclk = DUART16552_XTAL_FREQ, \
104 .iotype = UPIO_MEM, \
105 .flags = UPF_BOOT_AUTOCONF, \
106 .regshift = 2, \
107}
108
109static struct plat_serial8250_port xt2000_serial_data[] = {
110#if XCHAL_HAVE_BE
111 _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
112 _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
113#else
114 _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
115 _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
116#endif
117 { }
118};
119
120static struct platform_device xt2000_serial8250_device = {
121 .name = "serial8250",
122 .id = PLAT8250_DEV_PLATFORM,
123 .dev = {
124 .platform_data = xt2000_serial_data,
125 },
126};
127
128static struct resource xt2000_sonic_res[] = {
129 {
130 .start = SONIC83934_ADDR,
131 .end = SONIC83934_ADDR + 0xff,
132 .flags = IORESOURCE_MEM,
133 },
134 {
135 .start = SONIC83934_INTNUM,
136 .end = SONIC83934_INTNUM,
137 .flags = IORESOURCE_IRQ,
138 },
139};
140
141static struct platform_device xt2000_sonic_device = {
142 .name = "xtsonic",
143 .num_resources = ARRAY_SIZE(xt2000_sonic_res),
144 .resource = xt2000_sonic_res,
145};
146
147static int __init xt2000_setup_devinit(void)
148{
149 platform_device_register(&xt2000_serial8250_device);
150 platform_device_register(&xt2000_sonic_device);
151
152 return 0;
153}
154
155device_initcall(xt2000_setup_devinit);
156