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