ARM: s3c64xx: bring back notes from removed debug-macro.S
[linux-2.6-microblaze.git] / arch / arm / mach-s3c24xx / mach-vr1000.c
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright (c) 2003-2008 Simtec Electronics
4 //   Ben Dooks <ben@simtec.co.uk>
5 //
6 // Machine support for Thorcom VR1000 board. Designed for Thorcom by
7 // Simtec Electronics, http://www.simtec.co.uk/
8
9 #include <linux/kernel.h>
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/list.h>
13 #include <linux/timer.h>
14 #include <linux/init.h>
15 #include <linux/gpio.h>
16 #include <linux/gpio/machine.h>
17 #include <linux/dm9000.h>
18 #include <linux/i2c.h>
19
20 #include <linux/serial.h>
21 #include <linux/tty.h>
22 #include <linux/serial_8250.h>
23 #include <linux/serial_reg.h>
24 #include <linux/serial_s3c.h>
25 #include <linux/io.h>
26
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
30
31 #include <asm/irq.h>
32 #include <asm/mach-types.h>
33
34 #include <linux/platform_data/leds-s3c24xx.h>
35 #include <linux/platform_data/i2c-s3c2410.h>
36 #include <linux/platform_data/asoc-s3c24xx_simtec.h>
37
38 #include <mach/hardware.h>
39 #include <mach/regs-gpio.h>
40 #include <mach/gpio-samsung.h>
41
42 #include <plat/cpu.h>
43 #include <plat/devs.h>
44 #include <plat/gpio-cfg.h>
45 #include <plat/samsung-time.h>
46
47 #include "bast.h"
48 #include "common.h"
49 #include "simtec.h"
50 #include "vr1000.h"
51
52 /* macros for virtual address mods for the io space entries */
53 #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
54 #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
55 #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
56 #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
57
58 /* macros to modify the physical addresses for io space */
59
60 #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
61 #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
62 #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
63 #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
64
65 static struct map_desc vr1000_iodesc[] __initdata = {
66   /* ISA IO areas */
67   {
68           .virtual      = (u32)S3C24XX_VA_ISA_BYTE,
69           .pfn          = PA_CS2(BAST_PA_ISAIO),
70           .length       = SZ_16M,
71           .type         = MT_DEVICE,
72   }, {
73           .virtual      = (u32)S3C24XX_VA_ISA_WORD,
74           .pfn          = PA_CS3(BAST_PA_ISAIO),
75           .length       = SZ_16M,
76           .type         = MT_DEVICE,
77   },
78
79   /*  CPLD control registers, and external interrupt controls */
80   {
81           .virtual      = (u32)VR1000_VA_CTRL1,
82           .pfn          = __phys_to_pfn(VR1000_PA_CTRL1),
83           .length       = SZ_1M,
84           .type         = MT_DEVICE,
85   }, {
86           .virtual      = (u32)VR1000_VA_CTRL2,
87           .pfn          = __phys_to_pfn(VR1000_PA_CTRL2),
88           .length       = SZ_1M,
89           .type         = MT_DEVICE,
90   }, {
91           .virtual      = (u32)VR1000_VA_CTRL3,
92           .pfn          = __phys_to_pfn(VR1000_PA_CTRL3),
93           .length       = SZ_1M,
94           .type         = MT_DEVICE,
95   }, {
96           .virtual      = (u32)VR1000_VA_CTRL4,
97           .pfn          = __phys_to_pfn(VR1000_PA_CTRL4),
98           .length       = SZ_1M,
99           .type         = MT_DEVICE,
100   },
101 };
102
103 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
104 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
105 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
106
107 static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
108         [0] = {
109                 .hwport      = 0,
110                 .flags       = 0,
111                 .ucon        = UCON,
112                 .ulcon       = ULCON,
113                 .ufcon       = UFCON,
114         },
115         [1] = {
116                 .hwport      = 1,
117                 .flags       = 0,
118                 .ucon        = UCON,
119                 .ulcon       = ULCON,
120                 .ufcon       = UFCON,
121         },
122         /* port 2 is not actually used */
123         [2] = {
124                 .hwport      = 2,
125                 .flags       = 0,
126                 .ucon        = UCON,
127                 .ulcon       = ULCON,
128                 .ufcon       = UFCON,
129         }
130 };
131
132 /* definitions for the vr1000 extra 16550 serial ports */
133
134 #define VR1000_BAUDBASE (3692307)
135
136 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
137
138 static struct plat_serial8250_port serial_platform_data[] = {
139         [0] = {
140                 .mapbase        = VR1000_SERIAL_MAPBASE(0),
141                 .irq            = VR1000_IRQ_SERIAL + 0,
142                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
143                 .iotype         = UPIO_MEM,
144                 .regshift       = 0,
145                 .uartclk        = VR1000_BAUDBASE,
146         },
147         [1] = {
148                 .mapbase        = VR1000_SERIAL_MAPBASE(1),
149                 .irq            = VR1000_IRQ_SERIAL + 1,
150                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
151                 .iotype         = UPIO_MEM,
152                 .regshift       = 0,
153                 .uartclk        = VR1000_BAUDBASE,
154         },
155         [2] = {
156                 .mapbase        = VR1000_SERIAL_MAPBASE(2),
157                 .irq            = VR1000_IRQ_SERIAL + 2,
158                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
159                 .iotype         = UPIO_MEM,
160                 .regshift       = 0,
161                 .uartclk        = VR1000_BAUDBASE,
162         },
163         [3] = {
164                 .mapbase        = VR1000_SERIAL_MAPBASE(3),
165                 .irq            = VR1000_IRQ_SERIAL + 3,
166                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
167                 .iotype         = UPIO_MEM,
168                 .regshift       = 0,
169                 .uartclk        = VR1000_BAUDBASE,
170         },
171         { },
172 };
173
174 static struct platform_device serial_device = {
175         .name                   = "serial8250",
176         .id                     = PLAT8250_DEV_PLATFORM,
177         .dev                    = {
178                 .platform_data  = serial_platform_data,
179         },
180 };
181
182 /* DM9000 ethernet devices */
183
184 static struct resource vr1000_dm9k0_resource[] = {
185         [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
186         [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
187         [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
188                                                 | IORESOURCE_IRQ_HIGHLEVEL),
189 };
190
191 static struct resource vr1000_dm9k1_resource[] = {
192         [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
193         [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
194         [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
195                                                 | IORESOURCE_IRQ_HIGHLEVEL),
196 };
197
198 /* for the moment we limit ourselves to 16bit IO until some
199  * better IO routines can be written and tested
200 */
201
202 static struct dm9000_plat_data vr1000_dm9k_platdata = {
203         .flags          = DM9000_PLATF_16BITONLY,
204 };
205
206 static struct platform_device vr1000_dm9k0 = {
207         .name           = "dm9000",
208         .id             = 0,
209         .num_resources  = ARRAY_SIZE(vr1000_dm9k0_resource),
210         .resource       = vr1000_dm9k0_resource,
211         .dev            = {
212                 .platform_data = &vr1000_dm9k_platdata,
213         }
214 };
215
216 static struct platform_device vr1000_dm9k1 = {
217         .name           = "dm9000",
218         .id             = 1,
219         .num_resources  = ARRAY_SIZE(vr1000_dm9k1_resource),
220         .resource       = vr1000_dm9k1_resource,
221         .dev            = {
222                 .platform_data = &vr1000_dm9k_platdata,
223         }
224 };
225
226 /* LEDS */
227
228 static struct gpiod_lookup_table vr1000_led1_gpio_table = {
229         .dev_id = "s3c24xx_led.1",
230         .table = {
231                 GPIO_LOOKUP("GPB", 0, NULL, GPIO_ACTIVE_HIGH),
232                 { },
233         },
234 };
235
236 static struct gpiod_lookup_table vr1000_led2_gpio_table = {
237         .dev_id = "s3c24xx_led.2",
238         .table = {
239                 GPIO_LOOKUP("GPB", 1, NULL, GPIO_ACTIVE_HIGH),
240                 { },
241         },
242 };
243
244 static struct gpiod_lookup_table vr1000_led3_gpio_table = {
245         .dev_id = "s3c24xx_led.3",
246         .table = {
247                 GPIO_LOOKUP("GPB", 2, NULL, GPIO_ACTIVE_HIGH),
248                 { },
249         },
250 };
251
252 static struct s3c24xx_led_platdata vr1000_led1_pdata = {
253         .name           = "led1",
254         .def_trigger    = "",
255 };
256
257 static struct s3c24xx_led_platdata vr1000_led2_pdata = {
258         .name           = "led2",
259         .def_trigger    = "",
260 };
261
262 static struct s3c24xx_led_platdata vr1000_led3_pdata = {
263         .name           = "led3",
264         .def_trigger    = "",
265 };
266
267 static struct platform_device vr1000_led1 = {
268         .name           = "s3c24xx_led",
269         .id             = 1,
270         .dev            = {
271                 .platform_data  = &vr1000_led1_pdata,
272         },
273 };
274
275 static struct platform_device vr1000_led2 = {
276         .name           = "s3c24xx_led",
277         .id             = 2,
278         .dev            = {
279                 .platform_data  = &vr1000_led2_pdata,
280         },
281 };
282
283 static struct platform_device vr1000_led3 = {
284         .name           = "s3c24xx_led",
285         .id             = 3,
286         .dev            = {
287                 .platform_data  = &vr1000_led3_pdata,
288         },
289 };
290
291 /* I2C devices. */
292
293 static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
294         {
295                 I2C_BOARD_INFO("tlv320aic23", 0x1a),
296         }, {
297                 I2C_BOARD_INFO("tmp101", 0x48),
298         }, {
299                 I2C_BOARD_INFO("m41st87", 0x68),
300         },
301 };
302
303 /* devices for this board */
304
305 static struct platform_device *vr1000_devices[] __initdata = {
306         &s3c2410_device_dclk,
307         &s3c_device_ohci,
308         &s3c_device_lcd,
309         &s3c_device_wdt,
310         &s3c_device_i2c0,
311         &s3c_device_adc,
312         &serial_device,
313         &vr1000_dm9k0,
314         &vr1000_dm9k1,
315         &vr1000_led1,
316         &vr1000_led2,
317         &vr1000_led3,
318 };
319
320 static void vr1000_power_off(void)
321 {
322         gpio_direction_output(S3C2410_GPB(9), 1);
323 }
324
325 static void __init vr1000_map_io(void)
326 {
327         pm_power_off = vr1000_power_off;
328
329         s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
330         s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
331         samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
332 }
333
334 static void __init vr1000_init_time(void)
335 {
336         s3c2410_init_clocks(12000000);
337         samsung_timer_init();
338 }
339
340 static void __init vr1000_init(void)
341 {
342         s3c_i2c0_set_platdata(NULL);
343
344         /* Disable pull-up on LED lines and register GPIO lookups */
345         s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
346         s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_NONE);
347         s3c_gpio_setpull(S3C2410_GPB(2), S3C_GPIO_PULL_NONE);
348         gpiod_add_lookup_table(&vr1000_led1_gpio_table);
349         gpiod_add_lookup_table(&vr1000_led2_gpio_table);
350         gpiod_add_lookup_table(&vr1000_led3_gpio_table);
351
352         platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
353
354         i2c_register_board_info(0, vr1000_i2c_devs,
355                                 ARRAY_SIZE(vr1000_i2c_devs));
356
357         nor_simtec_init();
358         simtec_audio_add(NULL, true, NULL);
359
360         WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
361 }
362
363 MACHINE_START(VR1000, "Thorcom-VR1000")
364         /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
365         .atag_offset    = 0x100,
366         .map_io         = vr1000_map_io,
367         .init_machine   = vr1000_init,
368         .init_irq       = s3c2410_init_irq,
369         .init_time      = vr1000_init_time,
370 MACHINE_END