ARM: s3c64xx: bring back notes from removed debug-macro.S
[linux-2.6-microblaze.git] / arch / arm / mach-s3c24xx / mach-qt2410.c
1 // SPDX-License-Identifier: GPL-2.0+
2 //
3 // Copyright (C) 2006 by OpenMoko, Inc.
4 // Author: Harald Welte <laforge@openmoko.org>
5 // All rights reserved.
6
7 #include <linux/kernel.h>
8 #include <linux/types.h>
9 #include <linux/interrupt.h>
10 #include <linux/list.h>
11 #include <linux/timer.h>
12 #include <linux/init.h>
13 #include <linux/gpio.h>
14 #include <linux/gpio/machine.h>
15 #include <linux/device.h>
16 #include <linux/platform_device.h>
17 #include <linux/serial_core.h>
18 #include <linux/serial_s3c.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/spi_gpio.h>
21 #include <linux/io.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/rawnand.h>
24 #include <linux/mtd/nand_ecc.h>
25 #include <linux/mtd/partitions.h>
26
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
30
31 #include <mach/hardware.h>
32 #include <asm/irq.h>
33 #include <asm/mach-types.h>
34
35 #include <linux/platform_data/leds-s3c24xx.h>
36 #include <mach/regs-lcd.h>
37 #include <mach/fb.h>
38 #include <linux/platform_data/mtd-nand-s3c2410.h>
39 #include <linux/platform_data/usb-s3c2410_udc.h>
40 #include <linux/platform_data/i2c-s3c2410.h>
41 #include <mach/gpio-samsung.h>
42
43 #include <plat/gpio-cfg.h>
44 #include <plat/devs.h>
45 #include <plat/cpu.h>
46 #include <plat/pm.h>
47 #include <plat/samsung-time.h>
48
49 #include "common.h"
50 #include "common-smdk.h"
51
52 static struct map_desc qt2410_iodesc[] __initdata = {
53         { 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE }
54 };
55
56 #define UCON S3C2410_UCON_DEFAULT
57 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
58 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
59
60 static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
61         [0] = {
62                 .hwport      = 0,
63                 .flags       = 0,
64                 .ucon        = UCON,
65                 .ulcon       = ULCON,
66                 .ufcon       = UFCON,
67         },
68         [1] = {
69                 .hwport      = 1,
70                 .flags       = 0,
71                 .ucon        = UCON,
72                 .ulcon       = ULCON,
73                 .ufcon       = UFCON,
74         },
75         [2] = {
76                 .hwport      = 2,
77                 .flags       = 0,
78                 .ucon        = UCON,
79                 .ulcon       = ULCON,
80                 .ufcon       = UFCON,
81         }
82 };
83
84 /* LCD driver info */
85
86 static struct s3c2410fb_display qt2410_lcd_cfg[] __initdata = {
87         {
88                 /* Configuration for 640x480 SHARP LQ080V3DG01 */
89                 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
90                            S3C2410_LCDCON5_INVVLINE |
91                            S3C2410_LCDCON5_INVVFRAME |
92                            S3C2410_LCDCON5_PWREN |
93                            S3C2410_LCDCON5_HWSWP,
94
95                 .type           = S3C2410_LCDCON1_TFT,
96                 .width          = 640,
97                 .height         = 480,
98
99                 .pixclock       = 40000, /* HCLK/4 */
100                 .xres           = 640,
101                 .yres           = 480,
102                 .bpp            = 16,
103                 .left_margin    = 44,
104                 .right_margin   = 116,
105                 .hsync_len      = 96,
106                 .upper_margin   = 19,
107                 .lower_margin   = 11,
108                 .vsync_len      = 15,
109         },
110         {
111                 /* Configuration for 480x640 toppoly TD028TTEC1 */
112                 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
113                            S3C2410_LCDCON5_INVVLINE |
114                            S3C2410_LCDCON5_INVVFRAME |
115                            S3C2410_LCDCON5_PWREN |
116                            S3C2410_LCDCON5_HWSWP,
117
118                 .type           = S3C2410_LCDCON1_TFT,
119                 .width          = 480,
120                 .height         = 640,
121                 .pixclock       = 40000, /* HCLK/4 */
122                 .xres           = 480,
123                 .yres           = 640,
124                 .bpp            = 16,
125                 .left_margin    = 8,
126                 .right_margin   = 24,
127                 .hsync_len      = 8,
128                 .upper_margin   = 2,
129                 .lower_margin   = 4,
130                 .vsync_len      = 2,
131         },
132         {
133                 /* Config for 240x320 LCD */
134                 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
135                            S3C2410_LCDCON5_INVVLINE |
136                            S3C2410_LCDCON5_INVVFRAME |
137                            S3C2410_LCDCON5_PWREN |
138                            S3C2410_LCDCON5_HWSWP,
139
140                 .type           = S3C2410_LCDCON1_TFT,
141                 .width          = 240,
142                 .height         = 320,
143                 .pixclock       = 100000, /* HCLK/10 */
144                 .xres           = 240,
145                 .yres           = 320,
146                 .bpp            = 16,
147                 .left_margin    = 13,
148                 .right_margin   = 8,
149                 .hsync_len      = 4,
150                 .upper_margin   = 2,
151                 .lower_margin   = 7,
152                 .vsync_len      = 4,
153         },
154 };
155
156
157 static struct s3c2410fb_mach_info qt2410_fb_info __initdata = {
158         .displays       = qt2410_lcd_cfg,
159         .num_displays   = ARRAY_SIZE(qt2410_lcd_cfg),
160         .default_display = 0,
161
162         .lpcsel         = ((0xCE6) & ~7) | 1<<4,
163 };
164
165 /* CS8900 */
166
167 static struct resource qt2410_cs89x0_resources[] = {
168         [0] = DEFINE_RES_MEM(0x19000000, 17),
169         [1] = DEFINE_RES_IRQ(IRQ_EINT9),
170 };
171
172 static struct platform_device qt2410_cs89x0 = {
173         .name           = "cirrus-cs89x0",
174         .num_resources  = ARRAY_SIZE(qt2410_cs89x0_resources),
175         .resource       = qt2410_cs89x0_resources,
176 };
177
178 /* LED */
179
180 static struct gpiod_lookup_table qt2410_led_gpio_table = {
181         .dev_id = "s3c24xx_led.0",
182         .table = {
183                 GPIO_LOOKUP("GPB", 0, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
184                 { },
185         },
186 };
187
188 static struct s3c24xx_led_platdata qt2410_pdata_led = {
189         .name           = "led",
190         .def_trigger    = "timer",
191 };
192
193 static struct platform_device qt2410_led = {
194         .name           = "s3c24xx_led",
195         .id             = 0,
196         .dev            = {
197                 .platform_data = &qt2410_pdata_led,
198         },
199 };
200
201 /* SPI */
202
203 static struct spi_gpio_platform_data spi_gpio_cfg = {
204         .num_chipselect = 1,
205 };
206
207 static struct platform_device qt2410_spi = {
208         .name           = "spi_gpio",
209         .id             = 1,
210         .dev.platform_data = &spi_gpio_cfg,
211 };
212
213 static struct gpiod_lookup_table qt2410_spi_gpiod_table = {
214         .dev_id         = "spi_gpio",
215         .table          = {
216                 GPIO_LOOKUP("GPIOG", 7,
217                             "sck", GPIO_ACTIVE_HIGH),
218                 GPIO_LOOKUP("GPIOG", 6,
219                             "mosi", GPIO_ACTIVE_HIGH),
220                 GPIO_LOOKUP("GPIOG", 5,
221                             "miso", GPIO_ACTIVE_HIGH),
222                 GPIO_LOOKUP("GPIOB", 5,
223                             "cs", GPIO_ACTIVE_HIGH),
224                 { },
225         },
226 };
227
228 /* Board devices */
229
230 static struct platform_device *qt2410_devices[] __initdata = {
231         &s3c_device_ohci,
232         &s3c_device_lcd,
233         &s3c_device_wdt,
234         &s3c_device_i2c0,
235         &s3c_device_iis,
236         &s3c_device_sdi,
237         &s3c_device_usbgadget,
238         &qt2410_spi,
239         &qt2410_cs89x0,
240         &qt2410_led,
241 };
242
243 static struct mtd_partition __initdata qt2410_nand_part[] = {
244         [0] = {
245                 .name   = "U-Boot",
246                 .size   = 0x30000,
247                 .offset = 0,
248         },
249         [1] = {
250                 .name   = "U-Boot environment",
251                 .offset = 0x30000,
252                 .size   = 0x4000,
253         },
254         [2] = {
255                 .name   = "kernel",
256                 .offset = 0x34000,
257                 .size   = SZ_2M,
258         },
259         [3] = {
260                 .name   = "initrd",
261                 .offset = 0x234000,
262                 .size   = SZ_4M,
263         },
264         [4] = {
265                 .name   = "jffs2",
266                 .offset = 0x634000,
267                 .size   = 0x39cc000,
268         },
269 };
270
271 static struct s3c2410_nand_set __initdata qt2410_nand_sets[] = {
272         [0] = {
273                 .name           = "NAND",
274                 .nr_chips       = 1,
275                 .nr_partitions  = ARRAY_SIZE(qt2410_nand_part),
276                 .partitions     = qt2410_nand_part,
277         },
278 };
279
280 /* choose a set of timings which should suit most 512Mbit
281  * chips and beyond.
282  */
283
284 static struct s3c2410_platform_nand __initdata qt2410_nand_info = {
285         .tacls          = 20,
286         .twrph0         = 60,
287         .twrph1         = 20,
288         .nr_sets        = ARRAY_SIZE(qt2410_nand_sets),
289         .sets           = qt2410_nand_sets,
290         .ecc_mode       = NAND_ECC_SOFT,
291 };
292
293 /* UDC */
294
295 static struct s3c2410_udc_mach_info qt2410_udc_cfg = {
296 };
297
298 static char tft_type = 's';
299
300 static int __init qt2410_tft_setup(char *str)
301 {
302         tft_type = str[0];
303         return 1;
304 }
305
306 __setup("tft=", qt2410_tft_setup);
307
308 static void __init qt2410_map_io(void)
309 {
310         s3c24xx_init_io(qt2410_iodesc, ARRAY_SIZE(qt2410_iodesc));
311         s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
312         samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
313 }
314
315 static void __init qt2410_init_time(void)
316 {
317         s3c2410_init_clocks(12000000);
318         samsung_timer_init();
319 }
320
321 static void __init qt2410_machine_init(void)
322 {
323         s3c_nand_set_platdata(&qt2410_nand_info);
324
325         switch (tft_type) {
326         case 'p': /* production */
327                 qt2410_fb_info.default_display = 1;
328                 break;
329         case 'b': /* big */
330                 qt2410_fb_info.default_display = 0;
331                 break;
332         case 's': /* small */
333         default:
334                 qt2410_fb_info.default_display = 2;
335                 break;
336         }
337         s3c24xx_fb_set_platdata(&qt2410_fb_info);
338
339         /* set initial state of the LED GPIO */
340         WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH, NULL));
341         gpio_free(S3C2410_GPB(0));
342
343         s3c24xx_udc_set_platdata(&qt2410_udc_cfg);
344         s3c_i2c0_set_platdata(NULL);
345
346         gpiod_add_lookup_table(&qt2410_spi_gpiod_table);
347         s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
348         gpiod_add_lookup_table(&qt2410_led_gpio_table);
349         platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
350         s3c_pm_init();
351 }
352
353 MACHINE_START(QT2410, "QT2410")
354         .atag_offset    = 0x100,
355         .map_io         = qt2410_map_io,
356         .init_irq       = s3c2410_init_irq,
357         .init_machine   = qt2410_machine_init,
358         .init_time      = qt2410_init_time,
359 MACHINE_END