GNU Linux-libre 5.13.14-gnu1
[releases.git] / arch / xtensa / platforms / xt2000 / setup.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * arch/xtensa/platforms/xt2000/setup.c
4  *
5  * Platform specific functions for the XT2000 board.
6  *
7  * Authors:     Chris Zankel <chris@zankel.net>
8  *              Joe Taylor <joe@tensilica.com>
9  *
10  * Copyright 2001 - 2004 Tensilica Inc.
11  */
12 #include <linux/stddef.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/errno.h>
16 #include <linux/reboot.h>
17 #include <linux/kdev_t.h>
18 #include <linux/types.h>
19 #include <linux/major.h>
20 #include <linux/console.h>
21 #include <linux/delay.h>
22 #include <linux/stringify.h>
23 #include <linux/platform_device.h>
24 #include <linux/serial.h>
25 #include <linux/serial_8250.h>
26
27 #include <asm/processor.h>
28 #include <asm/platform.h>
29 #include <asm/bootparam.h>
30 #include <platform/hardware.h>
31 #include <platform/serial.h>
32
33 /* Assumes s points to an 8-chr string.  No checking for NULL. */
34
35 static void led_print (int f, char *s)
36 {
37         unsigned long* led_addr = (unsigned long*) (XT2000_LED_ADDR + 0xE0) + f;
38         int i;
39         for (i = f; i < 8; i++)
40                 if ((*led_addr++ = *s++) == 0)
41                     break;
42 }
43
44 void platform_halt(void)
45 {
46         led_print (0, "  HALT  ");
47         local_irq_disable();
48         while (1);
49 }
50
51 void platform_power_off(void)
52 {
53         led_print (0, "POWEROFF");
54         local_irq_disable();
55         while (1);
56 }
57
58 void platform_restart(void)
59 {
60         /* Flush and reset the mmu, simulate a processor reset, and
61          * jump to the reset vector. */
62         cpu_reset();
63         /* control never gets here */
64 }
65
66 void __init platform_setup(char** cmdline)
67 {
68         led_print (0, "LINUX   ");
69 }
70
71 /* early initialization */
72
73 void __init platform_init(bp_tag_t *first)
74 {
75 }
76
77 /* Heartbeat. Let the LED blink. */
78
79 void platform_heartbeat(void)
80 {
81         static int i=0, t = 0;
82
83         if (--t < 0)
84         {
85                 t = 59;
86                 led_print(7, i ? ".": " ");
87                 i ^= 1;
88         }
89 }
90
91 //#define RS_TABLE_SIZE 2
92
93 #define _SERIAL_PORT(_base,_irq)                                        \
94 {                                                                       \
95         .mapbase        = (_base),                                      \
96         .membase        = (void*)(_base),                               \
97         .irq            = (_irq),                                       \
98         .uartclk        = DUART16552_XTAL_FREQ,                         \
99         .iotype         = UPIO_MEM,                                     \
100         .flags          = UPF_BOOT_AUTOCONF,                            \
101         .regshift       = 2,                                            \
102 }
103
104 static struct plat_serial8250_port xt2000_serial_data[] = {
105 #if XCHAL_HAVE_BE
106         _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
107         _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
108 #else
109         _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
110         _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
111 #endif
112         { }
113 };
114
115 static struct platform_device xt2000_serial8250_device = {
116         .name           = "serial8250",
117         .id             = PLAT8250_DEV_PLATFORM,
118         .dev            = {
119             .platform_data = xt2000_serial_data,
120         },
121 };
122
123 static struct resource xt2000_sonic_res[] = {
124         {
125                 .start = SONIC83934_ADDR,
126                 .end   = SONIC83934_ADDR + 0xff,
127                 .flags = IORESOURCE_MEM,
128         },
129         {
130                 .start = SONIC83934_INTNUM,
131                 .end = SONIC83934_INTNUM,
132                 .flags = IORESOURCE_IRQ,
133         },
134 };
135
136 static struct platform_device xt2000_sonic_device = {
137         .name           = "xtsonic",
138         .num_resources  = ARRAY_SIZE(xt2000_sonic_res),
139         .resource               = xt2000_sonic_res,
140 };
141
142 static int __init xt2000_setup_devinit(void)
143 {
144         platform_device_register(&xt2000_serial8250_device);
145         platform_device_register(&xt2000_sonic_device);
146
147         return 0;
148 }
149
150 device_initcall(xt2000_setup_devinit);