ARM: s3c64xx: include header defining input event codes
[sfrench/cifs-2.6.git] / arch / arm / mach-s3c / mach-crag6410.c
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright 2011 Wolfson Microelectronics plc
4 //      Mark Brown <broonie@opensource.wolfsonmicro.com>
5 //
6 // Copyright 2011 Simtec Electronics
7 //      Ben Dooks <ben@simtec.co.uk>
8
9 #include <linux/kernel.h>
10 #include <linux/list.h>
11 #include <linux/serial_core.h>
12 #include <linux/serial_s3c.h>
13 #include <linux/platform_device.h>
14 #include <linux/fb.h>
15 #include <linux/io.h>
16 #include <linux/init.h>
17 #include <linux/input-event-codes.h>
18 #include <linux/gpio.h>
19 #include <linux/gpio/machine.h>
20 #include <linux/leds.h>
21 #include <linux/delay.h>
22 #include <linux/mmc/host.h>
23 #include <linux/regulator/machine.h>
24 #include <linux/regulator/fixed.h>
25 #include <linux/pwm.h>
26 #include <linux/pwm_backlight.h>
27 #include <linux/dm9000.h>
28 #include <linux/gpio_keys.h>
29 #include <linux/gpio/driver.h>
30 #include <linux/spi/spi.h>
31
32 #include <linux/platform_data/pca953x.h>
33 #include <linux/platform_data/s3c-hsotg.h>
34
35 #include <video/platform_lcd.h>
36
37 #include <linux/mfd/wm831x/core.h>
38 #include <linux/mfd/wm831x/pdata.h>
39 #include <linux/mfd/wm831x/irq.h>
40 #include <linux/mfd/wm831x/gpio.h>
41
42 #include <sound/wm1250-ev1.h>
43
44 #include <asm/mach/arch.h>
45 #include <asm/mach-types.h>
46
47 #include <video/samsung_fimd.h>
48 #include "map.h"
49 #include "regs-gpio.h"
50 #include "gpio-samsung.h"
51 #include "irqs.h"
52
53 #include "fb.h"
54 #include "sdhci.h"
55 #include "gpio-cfg.h"
56 #include <linux/platform_data/spi-s3c64xx.h>
57
58 #include "keypad.h"
59 #include "devs.h"
60 #include "cpu.h"
61 #include <linux/soc/samsung/s3c-adc.h>
62 #include <linux/platform_data/i2c-s3c2410.h>
63 #include "pm.h"
64
65 #include "s3c64xx.h"
66 #include "crag6410.h"
67 #include "regs-gpio-memport-s3c64xx.h"
68 #include "regs-modem-s3c64xx.h"
69 #include "regs-sys-s3c64xx.h"
70
71 /* serial port setup */
72
73 #define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK)
74 #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
75 #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
76
77 static struct s3c2410_uartcfg crag6410_uartcfgs[] __initdata = {
78         [0] = {
79                 .hwport         = 0,
80                 .flags          = 0,
81                 .ucon           = UCON,
82                 .ulcon          = ULCON,
83                 .ufcon          = UFCON,
84         },
85         [1] = {
86                 .hwport         = 1,
87                 .flags          = 0,
88                 .ucon           = UCON,
89                 .ulcon          = ULCON,
90                 .ufcon          = UFCON,
91         },
92         [2] = {
93                 .hwport         = 2,
94                 .flags          = 0,
95                 .ucon           = UCON,
96                 .ulcon          = ULCON,
97                 .ufcon          = UFCON,
98         },
99         [3] = {
100                 .hwport         = 3,
101                 .flags          = 0,
102                 .ucon           = UCON,
103                 .ulcon          = ULCON,
104                 .ufcon          = UFCON,
105         },
106 };
107
108 static struct pwm_lookup crag6410_pwm_lookup[] = {
109         PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 100000,
110                    PWM_POLARITY_NORMAL),
111 };
112
113 static struct platform_pwm_backlight_data crag6410_backlight_data = {
114         .max_brightness = 1000,
115         .dft_brightness = 600,
116 };
117
118 static struct platform_device crag6410_backlight_device = {
119         .name           = "pwm-backlight",
120         .id             = -1,
121         .dev            = {
122                 .parent = &samsung_device_pwm.dev,
123                 .platform_data = &crag6410_backlight_data,
124         },
125 };
126
127 static void crag6410_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
128 {
129         pr_debug("%s: setting power %d\n", __func__, power);
130
131         if (power) {
132                 gpio_set_value(S3C64XX_GPB(0), 1);
133                 msleep(1);
134                 s3c_gpio_cfgpin(S3C64XX_GPF(14), S3C_GPIO_SFN(2));
135         } else {
136                 gpio_direction_output(S3C64XX_GPF(14), 0);
137                 gpio_set_value(S3C64XX_GPB(0), 0);
138         }
139 }
140
141 static struct platform_device crag6410_lcd_powerdev = {
142         .name                   = "platform-lcd",
143         .id                     = -1,
144         .dev.parent             = &s3c_device_fb.dev,
145         .dev.platform_data      = &(struct plat_lcd_data) {
146                 .set_power      = crag6410_lcd_power_set,
147         },
148 };
149
150 /* 640x480 URT */
151 static struct s3c_fb_pd_win crag6410_fb_win0 = {
152         .max_bpp        = 32,
153         .default_bpp    = 16,
154         .xres           = 640,
155         .yres           = 480,
156         .virtual_y      = 480 * 2,
157         .virtual_x      = 640,
158 };
159
160 static struct fb_videomode crag6410_lcd_timing = {
161         .left_margin    = 150,
162         .right_margin   = 80,
163         .upper_margin   = 40,
164         .lower_margin   = 5,
165         .hsync_len      = 40,
166         .vsync_len      = 5,
167         .xres           = 640,
168         .yres           = 480,
169 };
170
171 /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
172 static struct s3c_fb_platdata crag6410_lcd_pdata = {
173         .setup_gpio     = s3c64xx_fb_gpio_setup_24bpp,
174         .vtiming        = &crag6410_lcd_timing,
175         .win[0]         = &crag6410_fb_win0,
176         .vidcon0        = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
177         .vidcon1        = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
178 };
179
180 /* 2x6 keypad */
181
182 static uint32_t crag6410_keymap[] = {
183         /* KEY(row, col, keycode) */
184         KEY(0, 0, KEY_VOLUMEUP),
185         KEY(0, 1, KEY_HOME),
186         KEY(0, 2, KEY_VOLUMEDOWN),
187         KEY(0, 3, KEY_HELP),
188         KEY(0, 4, KEY_MENU),
189         KEY(0, 5, KEY_MEDIA),
190         KEY(1, 0, 232),
191         KEY(1, 1, KEY_DOWN),
192         KEY(1, 2, KEY_LEFT),
193         KEY(1, 3, KEY_UP),
194         KEY(1, 4, KEY_RIGHT),
195         KEY(1, 5, KEY_CAMERA),
196 };
197
198 static struct matrix_keymap_data crag6410_keymap_data = {
199         .keymap         = crag6410_keymap,
200         .keymap_size    = ARRAY_SIZE(crag6410_keymap),
201 };
202
203 static struct samsung_keypad_platdata crag6410_keypad_data = {
204         .keymap_data    = &crag6410_keymap_data,
205         .rows           = 2,
206         .cols           = 6,
207 };
208
209 static struct gpio_keys_button crag6410_gpio_keys[] = {
210         [0] = {
211                 .code   = KEY_SUSPEND,
212                 .gpio   = S3C64XX_GPL(10),      /* EINT 18 */
213                 .type   = EV_KEY,
214                 .wakeup = 1,
215                 .active_low = 1,
216         },
217         [1] = {
218                 .code   = SW_FRONT_PROXIMITY,
219                 .gpio   = S3C64XX_GPN(11),      /* EINT 11 */
220                 .type   = EV_SW,
221         },
222 };
223
224 static struct gpio_keys_platform_data crag6410_gpio_keydata = {
225         .buttons        = crag6410_gpio_keys,
226         .nbuttons       = ARRAY_SIZE(crag6410_gpio_keys),
227 };
228
229 static struct platform_device crag6410_gpio_keydev = {
230         .name           = "gpio-keys",
231         .id             = 0,
232         .dev.platform_data = &crag6410_gpio_keydata,
233 };
234
235 static struct resource crag6410_dm9k_resource[] = {
236         [0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5, 2),
237         [1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5 + (1 << 8), 2),
238         [2] = DEFINE_RES_NAMED(S3C_EINT(17), 1, NULL, IORESOURCE_IRQ \
239                                 | IORESOURCE_IRQ_HIGHLEVEL),
240 };
241
242 static struct dm9000_plat_data mini6410_dm9k_pdata = {
243         .flags  = DM9000_PLATF_16BITONLY,
244 };
245
246 static struct platform_device crag6410_dm9k_device = {
247         .name           = "dm9000",
248         .id             = -1,
249         .num_resources  = ARRAY_SIZE(crag6410_dm9k_resource),
250         .resource       = crag6410_dm9k_resource,
251         .dev.platform_data = &mini6410_dm9k_pdata,
252 };
253
254 static struct resource crag6410_mmgpio_resource[] = {
255         [0] = DEFINE_RES_MEM_NAMED(S3C64XX_PA_XM0CSN4, 1, "dat"),
256 };
257
258 static struct platform_device crag6410_mmgpio = {
259         .name           = "basic-mmio-gpio",
260         .id             = -1,
261         .resource       = crag6410_mmgpio_resource,
262         .num_resources  = ARRAY_SIZE(crag6410_mmgpio_resource),
263         .dev.platform_data = &(struct bgpio_pdata) {
264                 .base   = MMGPIO_GPIO_BASE,
265         },
266 };
267
268 static struct platform_device speyside_device = {
269         .name           = "speyside",
270         .id             = -1,
271 };
272
273 static struct platform_device lowland_device = {
274         .name           = "lowland",
275         .id             = -1,
276 };
277
278 static struct platform_device tobermory_device = {
279         .name           = "tobermory",
280         .id             = -1,
281 };
282
283 static struct platform_device littlemill_device = {
284         .name           = "littlemill",
285         .id             = -1,
286 };
287
288 static struct platform_device bells_wm2200_device = {
289         .name           = "bells",
290         .id             = 0,
291 };
292
293 static struct platform_device bells_wm5102_device = {
294         .name           = "bells",
295         .id             = 1,
296 };
297
298 static struct platform_device bells_wm5110_device = {
299         .name           = "bells",
300         .id             = 2,
301 };
302
303 static struct regulator_consumer_supply wallvdd_consumers[] = {
304         REGULATOR_SUPPLY("SPKVDD", "1-001a"),
305         REGULATOR_SUPPLY("SPKVDD1", "1-001a"),
306         REGULATOR_SUPPLY("SPKVDD2", "1-001a"),
307         REGULATOR_SUPPLY("SPKVDDL", "1-001a"),
308         REGULATOR_SUPPLY("SPKVDDR", "1-001a"),
309
310         REGULATOR_SUPPLY("SPKVDDL", "spi0.1"),
311         REGULATOR_SUPPLY("SPKVDDR", "spi0.1"),
312
313         REGULATOR_SUPPLY("DC1VDD", "0-0034"),
314         REGULATOR_SUPPLY("DC2VDD", "0-0034"),
315         REGULATOR_SUPPLY("DC3VDD", "0-0034"),
316         REGULATOR_SUPPLY("LDO1VDD", "0-0034"),
317         REGULATOR_SUPPLY("LDO2VDD", "0-0034"),
318         REGULATOR_SUPPLY("LDO4VDD", "0-0034"),
319         REGULATOR_SUPPLY("LDO5VDD", "0-0034"),
320         REGULATOR_SUPPLY("LDO6VDD", "0-0034"),
321         REGULATOR_SUPPLY("LDO7VDD", "0-0034"),
322         REGULATOR_SUPPLY("LDO8VDD", "0-0034"),
323         REGULATOR_SUPPLY("LDO9VDD", "0-0034"),
324         REGULATOR_SUPPLY("LDO10VDD", "0-0034"),
325         REGULATOR_SUPPLY("LDO11VDD", "0-0034"),
326
327         REGULATOR_SUPPLY("DC1VDD", "1-0034"),
328         REGULATOR_SUPPLY("DC2VDD", "1-0034"),
329         REGULATOR_SUPPLY("DC3VDD", "1-0034"),
330         REGULATOR_SUPPLY("LDO1VDD", "1-0034"),
331         REGULATOR_SUPPLY("LDO2VDD", "1-0034"),
332         REGULATOR_SUPPLY("LDO4VDD", "1-0034"),
333         REGULATOR_SUPPLY("LDO5VDD", "1-0034"),
334         REGULATOR_SUPPLY("LDO6VDD", "1-0034"),
335         REGULATOR_SUPPLY("LDO7VDD", "1-0034"),
336         REGULATOR_SUPPLY("LDO8VDD", "1-0034"),
337         REGULATOR_SUPPLY("LDO9VDD", "1-0034"),
338         REGULATOR_SUPPLY("LDO10VDD", "1-0034"),
339         REGULATOR_SUPPLY("LDO11VDD", "1-0034"),
340 };
341
342 static struct regulator_init_data wallvdd_data = {
343         .constraints = {
344                 .always_on = 1,
345         },
346         .num_consumer_supplies = ARRAY_SIZE(wallvdd_consumers),
347         .consumer_supplies = wallvdd_consumers,
348 };
349
350 static struct fixed_voltage_config wallvdd_pdata = {
351         .supply_name = "WALLVDD",
352         .microvolts = 5000000,
353         .init_data = &wallvdd_data,
354 };
355
356 static struct platform_device wallvdd_device = {
357         .name           = "reg-fixed-voltage",
358         .id             = -1,
359         .dev = {
360                 .platform_data = &wallvdd_pdata,
361         },
362 };
363
364 static struct platform_device *crag6410_devices[] __initdata = {
365         &s3c_device_hsmmc0,
366         &s3c_device_hsmmc2,
367         &s3c_device_i2c0,
368         &s3c_device_i2c1,
369         &s3c_device_fb,
370         &s3c_device_ohci,
371         &s3c_device_usb_hsotg,
372         &samsung_device_pwm,
373         &s3c64xx_device_iis0,
374         &s3c64xx_device_iis1,
375         &samsung_device_keypad,
376         &crag6410_gpio_keydev,
377         &crag6410_dm9k_device,
378         &s3c64xx_device_spi0,
379         &crag6410_mmgpio,
380         &crag6410_lcd_powerdev,
381         &crag6410_backlight_device,
382         &speyside_device,
383         &tobermory_device,
384         &littlemill_device,
385         &lowland_device,
386         &bells_wm2200_device,
387         &bells_wm5102_device,
388         &bells_wm5110_device,
389         &wallvdd_device,
390 };
391
392 static struct pca953x_platform_data crag6410_pca_data = {
393         .gpio_base      = PCA935X_GPIO_BASE,
394         .irq_base       = -1,
395 };
396
397 /* VDDARM is controlled by DVS1 connected to GPK(0) */
398 static struct wm831x_buckv_pdata vddarm_pdata = {
399         .dvs_control_src = 1,
400 };
401
402 static struct regulator_consumer_supply vddarm_consumers[] = {
403         REGULATOR_SUPPLY("vddarm", NULL),
404 };
405
406 static struct regulator_init_data vddarm = {
407         .constraints = {
408                 .name = "VDDARM",
409                 .min_uV = 1000000,
410                 .max_uV = 1300000,
411                 .always_on = 1,
412                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
413         },
414         .num_consumer_supplies = ARRAY_SIZE(vddarm_consumers),
415         .consumer_supplies = vddarm_consumers,
416         .supply_regulator = "WALLVDD",
417         .driver_data = &vddarm_pdata,
418 };
419
420 static struct regulator_consumer_supply vddint_consumers[] = {
421         REGULATOR_SUPPLY("vddint", NULL),
422 };
423
424 static struct regulator_init_data vddint = {
425         .constraints = {
426                 .name = "VDDINT",
427                 .min_uV = 1000000,
428                 .max_uV = 1200000,
429                 .always_on = 1,
430                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
431         },
432         .num_consumer_supplies = ARRAY_SIZE(vddint_consumers),
433         .consumer_supplies = vddint_consumers,
434         .supply_regulator = "WALLVDD",
435 };
436
437 static struct regulator_init_data vddmem = {
438         .constraints = {
439                 .name = "VDDMEM",
440                 .always_on = 1,
441         },
442 };
443
444 static struct regulator_init_data vddsys = {
445         .constraints = {
446                 .name = "VDDSYS,VDDEXT,VDDPCM,VDDSS",
447                 .always_on = 1,
448         },
449 };
450
451 static struct regulator_consumer_supply vddmmc_consumers[] = {
452         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
453         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.1"),
454         REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
455 };
456
457 static struct regulator_init_data vddmmc = {
458         .constraints = {
459                 .name = "VDDMMC,UH",
460                 .always_on = 1,
461         },
462         .num_consumer_supplies = ARRAY_SIZE(vddmmc_consumers),
463         .consumer_supplies = vddmmc_consumers,
464         .supply_regulator = "WALLVDD",
465 };
466
467 static struct regulator_init_data vddotgi = {
468         .constraints = {
469                 .name = "VDDOTGi",
470                 .always_on = 1,
471         },
472         .supply_regulator = "WALLVDD",
473 };
474
475 static struct regulator_init_data vddotg = {
476         .constraints = {
477                 .name = "VDDOTG",
478                 .always_on = 1,
479         },
480         .supply_regulator = "WALLVDD",
481 };
482
483 static struct regulator_init_data vddhi = {
484         .constraints = {
485                 .name = "VDDHI",
486                 .always_on = 1,
487         },
488         .supply_regulator = "WALLVDD",
489 };
490
491 static struct regulator_init_data vddadc = {
492         .constraints = {
493                 .name = "VDDADC,VDDDAC",
494                 .always_on = 1,
495         },
496         .supply_regulator = "WALLVDD",
497 };
498
499 static struct regulator_init_data vddmem0 = {
500         .constraints = {
501                 .name = "VDDMEM0",
502                 .always_on = 1,
503         },
504         .supply_regulator = "WALLVDD",
505 };
506
507 static struct regulator_init_data vddpll = {
508         .constraints = {
509                 .name = "VDDPLL",
510                 .always_on = 1,
511         },
512         .supply_regulator = "WALLVDD",
513 };
514
515 static struct regulator_init_data vddlcd = {
516         .constraints = {
517                 .name = "VDDLCD",
518                 .always_on = 1,
519         },
520         .supply_regulator = "WALLVDD",
521 };
522
523 static struct regulator_init_data vddalive = {
524         .constraints = {
525                 .name = "VDDALIVE",
526                 .always_on = 1,
527         },
528         .supply_regulator = "WALLVDD",
529 };
530
531 static struct wm831x_backup_pdata banff_backup_pdata = {
532         .charger_enable = 1,
533         .vlim = 2500,  /* mV */
534         .ilim = 200,   /* uA */
535 };
536
537 static struct wm831x_status_pdata banff_red_led = {
538         .name = "banff:red:",
539         .default_src = WM831X_STATUS_MANUAL,
540 };
541
542 static struct wm831x_status_pdata banff_green_led = {
543         .name = "banff:green:",
544         .default_src = WM831X_STATUS_MANUAL,
545 };
546
547 static struct wm831x_touch_pdata touch_pdata = {
548         .data_irq = S3C_EINT(26),
549         .pd_irq = S3C_EINT(27),
550 };
551
552 static struct wm831x_pdata crag_pmic_pdata = {
553         .wm831x_num = 1,
554         .irq_base = BANFF_PMIC_IRQ_BASE,
555         .gpio_base = BANFF_PMIC_GPIO_BASE,
556         .soft_shutdown = true,
557
558         .backup = &banff_backup_pdata,
559
560         .gpio_defaults = {
561                 /* GPIO5: DVS1_REQ - CMOS, DBVDD, active high */
562                 [4] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA | 0x8,
563                 /* GPIO11: Touchscreen data - CMOS, DBVDD, active high*/
564                 [10] = WM831X_GPN_POL | WM831X_GPN_ENA | 0x6,
565                 /* GPIO12: Touchscreen pen down - CMOS, DBVDD, active high*/
566                 [11] = WM831X_GPN_POL | WM831X_GPN_ENA | 0x7,
567         },
568
569         .dcdc = {
570                 &vddarm,  /* DCDC1 */
571                 &vddint,  /* DCDC2 */
572                 &vddmem,  /* DCDC3 */
573         },
574
575         .ldo = {
576                 &vddsys,   /* LDO1 */
577                 &vddmmc,   /* LDO2 */
578                 NULL,      /* LDO3 */
579                 &vddotgi,  /* LDO4 */
580                 &vddotg,   /* LDO5 */
581                 &vddhi,    /* LDO6 */
582                 &vddadc,   /* LDO7 */
583                 &vddmem0,  /* LDO8 */
584                 &vddpll,   /* LDO9 */
585                 &vddlcd,   /* LDO10 */
586                 &vddalive, /* LDO11 */
587         },
588
589         .status = {
590                 &banff_green_led,
591                 &banff_red_led,
592         },
593
594         .touch = &touch_pdata,
595 };
596
597 /*
598  * VDDARM is eventually ending up as a regulator hanging on the MFD cell device
599  * "wm831x-buckv.1" spawn from drivers/mfd/wm831x-core.c.
600  *
601  * From the note on the platform data we can see that this is clearly DVS1
602  * and assigned as dcdc1 resource to the MFD core which sets .id of the cell
603  * spawning the DVS1 platform device to 1, then the cell platform device
604  * name is calculated from 10*instance + id resulting in the device name
605  * "wm831x-buckv.11"
606  */
607 static struct gpiod_lookup_table crag_pmic_gpiod_table = {
608         .dev_id = "wm831x-buckv.11",
609         .table = {
610                 GPIO_LOOKUP("GPIOK", 0, "dvs", GPIO_ACTIVE_HIGH),
611                 { },
612         },
613 };
614
615 static struct i2c_board_info i2c_devs0[] = {
616         { I2C_BOARD_INFO("24c08", 0x50), },
617         { I2C_BOARD_INFO("tca6408", 0x20),
618           .platform_data = &crag6410_pca_data,
619         },
620         { I2C_BOARD_INFO("wm8312", 0x34),
621           .platform_data = &crag_pmic_pdata,
622           .irq = S3C_EINT(23),
623         },
624 };
625
626 static struct s3c2410_platform_i2c i2c0_pdata = {
627         .frequency = 400000,
628 };
629
630 static struct regulator_consumer_supply pvdd_1v2_consumers[] = {
631         REGULATOR_SUPPLY("DCVDD", "spi0.0"),
632         REGULATOR_SUPPLY("AVDD", "spi0.0"),
633         REGULATOR_SUPPLY("AVDD", "spi0.1"),
634 };
635
636 static struct regulator_init_data pvdd_1v2 = {
637         .constraints = {
638                 .name = "PVDD_1V2",
639                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
640         },
641
642         .consumer_supplies = pvdd_1v2_consumers,
643         .num_consumer_supplies = ARRAY_SIZE(pvdd_1v2_consumers),
644 };
645
646 static struct regulator_consumer_supply pvdd_1v8_consumers[] = {
647         REGULATOR_SUPPLY("LDOVDD", "1-001a"),
648         REGULATOR_SUPPLY("PLLVDD", "1-001a"),
649         REGULATOR_SUPPLY("DBVDD", "1-001a"),
650         REGULATOR_SUPPLY("DBVDD1", "1-001a"),
651         REGULATOR_SUPPLY("DBVDD2", "1-001a"),
652         REGULATOR_SUPPLY("DBVDD3", "1-001a"),
653         REGULATOR_SUPPLY("CPVDD", "1-001a"),
654         REGULATOR_SUPPLY("AVDD2", "1-001a"),
655         REGULATOR_SUPPLY("DCVDD", "1-001a"),
656         REGULATOR_SUPPLY("AVDD", "1-001a"),
657         REGULATOR_SUPPLY("DBVDD", "spi0.0"),
658
659         REGULATOR_SUPPLY("DBVDD", "1-003a"),
660         REGULATOR_SUPPLY("LDOVDD", "1-003a"),
661         REGULATOR_SUPPLY("CPVDD", "1-003a"),
662         REGULATOR_SUPPLY("AVDD", "1-003a"),
663         REGULATOR_SUPPLY("DBVDD1", "spi0.1"),
664         REGULATOR_SUPPLY("DBVDD2", "spi0.1"),
665         REGULATOR_SUPPLY("DBVDD3", "spi0.1"),
666         REGULATOR_SUPPLY("LDOVDD", "spi0.1"),
667         REGULATOR_SUPPLY("CPVDD", "spi0.1"),
668 };
669
670 static struct regulator_init_data pvdd_1v8 = {
671         .constraints = {
672                 .name = "PVDD_1V8",
673                 .always_on = 1,
674         },
675
676         .consumer_supplies = pvdd_1v8_consumers,
677         .num_consumer_supplies = ARRAY_SIZE(pvdd_1v8_consumers),
678 };
679
680 static struct regulator_consumer_supply pvdd_3v3_consumers[] = {
681         REGULATOR_SUPPLY("MICVDD", "1-001a"),
682         REGULATOR_SUPPLY("AVDD1", "1-001a"),
683 };
684
685 static struct regulator_init_data pvdd_3v3 = {
686         .constraints = {
687                 .name = "PVDD_3V3",
688                 .always_on = 1,
689         },
690
691         .consumer_supplies = pvdd_3v3_consumers,
692         .num_consumer_supplies = ARRAY_SIZE(pvdd_3v3_consumers),
693 };
694
695 static struct wm831x_pdata glenfarclas_pmic_pdata = {
696         .wm831x_num = 2,
697         .irq_base = GLENFARCLAS_PMIC_IRQ_BASE,
698         .gpio_base = GLENFARCLAS_PMIC_GPIO_BASE,
699         .soft_shutdown = true,
700
701         .gpio_defaults = {
702                 /* GPIO1-3: IRQ inputs, rising edge triggered, CMOS */
703                 [0] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA,
704                 [1] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA,
705                 [2] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA,
706         },
707
708         .dcdc = {
709                 &pvdd_1v2,  /* DCDC1 */
710                 &pvdd_1v8,  /* DCDC2 */
711                 &pvdd_3v3,  /* DCDC3 */
712         },
713
714         .disable_touch = true,
715 };
716
717 static struct wm1250_ev1_pdata wm1250_ev1_pdata = {
718         .gpios = {
719                 [WM1250_EV1_GPIO_CLK_ENA] = S3C64XX_GPN(12),
720                 [WM1250_EV1_GPIO_CLK_SEL0] = S3C64XX_GPL(12),
721                 [WM1250_EV1_GPIO_CLK_SEL1] = S3C64XX_GPL(13),
722                 [WM1250_EV1_GPIO_OSR] = S3C64XX_GPL(14),
723                 [WM1250_EV1_GPIO_MASTER] = S3C64XX_GPL(8),
724         },
725 };
726
727 static struct i2c_board_info i2c_devs1[] = {
728         { I2C_BOARD_INFO("wm8311", 0x34),
729           .irq = S3C_EINT(0),
730           .platform_data = &glenfarclas_pmic_pdata },
731
732         { I2C_BOARD_INFO("wlf-gf-module", 0x20) },
733         { I2C_BOARD_INFO("wlf-gf-module", 0x22) },
734         { I2C_BOARD_INFO("wlf-gf-module", 0x24) },
735         { I2C_BOARD_INFO("wlf-gf-module", 0x25) },
736         { I2C_BOARD_INFO("wlf-gf-module", 0x26) },
737
738         { I2C_BOARD_INFO("wm1250-ev1", 0x27),
739           .platform_data = &wm1250_ev1_pdata },
740 };
741
742 static struct s3c2410_platform_i2c i2c1_pdata = {
743         .frequency = 400000,
744         .bus_num = 1,
745 };
746
747 static void __init crag6410_map_io(void)
748 {
749         s3c64xx_init_io(NULL, 0);
750         s3c64xx_set_xtal_freq(12000000);
751         s3c24xx_init_uarts(crag6410_uartcfgs, ARRAY_SIZE(crag6410_uartcfgs));
752         s3c64xx_set_timer_source(S3C64XX_PWM3, S3C64XX_PWM4);
753
754         /* LCD type and Bypass set by bootloader */
755 }
756
757 static struct s3c_sdhci_platdata crag6410_hsmmc2_pdata = {
758         .max_width              = 4,
759         .cd_type                = S3C_SDHCI_CD_PERMANENT,
760         .host_caps              = MMC_CAP_POWER_OFF_CARD,
761 };
762
763 static void crag6410_cfg_sdhci0(struct platform_device *dev, int width)
764 {
765         /* Set all the necessary GPG pins to special-function 2 */
766         s3c_gpio_cfgrange_nopull(S3C64XX_GPG(0), 2 + width, S3C_GPIO_SFN(2));
767
768         /* force card-detected for prototype 0 */
769         s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_DOWN);
770 }
771
772 static struct s3c_sdhci_platdata crag6410_hsmmc0_pdata = {
773         .max_width              = 4,
774         .cd_type                = S3C_SDHCI_CD_INTERNAL,
775         .cfg_gpio               = crag6410_cfg_sdhci0,
776         .host_caps              = MMC_CAP_POWER_OFF_CARD,
777 };
778
779 static const struct gpio_led gpio_leds[] = {
780         {
781                 .name = "d13:green:",
782                 .gpio = MMGPIO_GPIO_BASE + 0,
783                 .default_state = LEDS_GPIO_DEFSTATE_ON,
784         },
785         {
786                 .name = "d14:green:",
787                 .gpio = MMGPIO_GPIO_BASE + 1,
788                 .default_state = LEDS_GPIO_DEFSTATE_ON,
789         },
790         {
791                 .name = "d15:green:",
792                 .gpio = MMGPIO_GPIO_BASE + 2,
793                 .default_state = LEDS_GPIO_DEFSTATE_ON,
794         },
795         {
796                 .name = "d16:green:",
797                 .gpio = MMGPIO_GPIO_BASE + 3,
798                 .default_state = LEDS_GPIO_DEFSTATE_ON,
799         },
800         {
801                 .name = "d17:green:",
802                 .gpio = MMGPIO_GPIO_BASE + 4,
803                 .default_state = LEDS_GPIO_DEFSTATE_ON,
804         },
805         {
806                 .name = "d18:green:",
807                 .gpio = MMGPIO_GPIO_BASE + 5,
808                 .default_state = LEDS_GPIO_DEFSTATE_ON,
809         },
810         {
811                 .name = "d19:green:",
812                 .gpio = MMGPIO_GPIO_BASE + 6,
813                 .default_state = LEDS_GPIO_DEFSTATE_ON,
814         },
815         {
816                 .name = "d20:green:",
817                 .gpio = MMGPIO_GPIO_BASE + 7,
818                 .default_state = LEDS_GPIO_DEFSTATE_ON,
819         },
820 };
821
822 static const struct gpio_led_platform_data gpio_leds_pdata = {
823         .leds = gpio_leds,
824         .num_leds = ARRAY_SIZE(gpio_leds),
825 };
826
827 static struct dwc2_hsotg_plat crag6410_hsotg_pdata;
828
829 static struct gpiod_lookup_table crag_spi0_gpiod_table = {
830         .dev_id = "s3c6410-spi.0",
831         .table = {
832                 GPIO_LOOKUP_IDX("GPIOC", 3, "cs", 0, GPIO_ACTIVE_LOW),
833                 GPIO_LOOKUP_IDX("GPION", 5, "cs", 1, GPIO_ACTIVE_LOW),
834                 { },
835         },
836 };
837
838 static void __init crag6410_machine_init(void)
839 {
840         /* Open drain IRQs need pullups */
841         s3c_gpio_setpull(S3C64XX_GPM(0), S3C_GPIO_PULL_UP);
842         s3c_gpio_setpull(S3C64XX_GPN(0), S3C_GPIO_PULL_UP);
843
844         gpio_request(S3C64XX_GPB(0), "LCD power");
845         gpio_direction_output(S3C64XX_GPB(0), 0);
846
847         gpio_request(S3C64XX_GPF(14), "LCD PWM");
848         gpio_direction_output(S3C64XX_GPF(14), 0);  /* turn off */
849
850         gpio_request(S3C64XX_GPB(1), "SD power");
851         gpio_direction_output(S3C64XX_GPB(1), 0);
852
853         gpio_request(S3C64XX_GPF(10), "nRESETSEL");
854         gpio_direction_output(S3C64XX_GPF(10), 1);
855
856         s3c_sdhci0_set_platdata(&crag6410_hsmmc0_pdata);
857         s3c_sdhci2_set_platdata(&crag6410_hsmmc2_pdata);
858
859         s3c_i2c0_set_platdata(&i2c0_pdata);
860         s3c_i2c1_set_platdata(&i2c1_pdata);
861         s3c_fb_set_platdata(&crag6410_lcd_pdata);
862         dwc2_hsotg_set_platdata(&crag6410_hsotg_pdata);
863
864         gpiod_add_lookup_table(&crag_pmic_gpiod_table);
865         i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
866         i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
867
868         samsung_keypad_set_platdata(&crag6410_keypad_data);
869
870         gpiod_add_lookup_table(&crag_spi0_gpiod_table);
871         s3c64xx_spi0_set_platdata(0, 2);
872
873         pwm_add_table(crag6410_pwm_lookup, ARRAY_SIZE(crag6410_pwm_lookup));
874         platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices));
875
876         gpio_led_register_device(-1, &gpio_leds_pdata);
877
878         regulator_has_full_constraints();
879
880         s3c64xx_pm_init();
881 }
882
883 MACHINE_START(WLF_CRAGG_6410, "Wolfson Cragganmore 6410")
884         /* Maintainer: Mark Brown <broonie@opensource.wolfsonmicro.com> */
885         .atag_offset    = 0x100,
886         .nr_irqs        = S3C64XX_NR_IRQS,
887         .init_irq       = s3c6410_init_irq,
888         .map_io         = crag6410_map_io,
889         .init_machine   = crag6410_machine_init,
890         .init_time      = s3c64xx_timer_init,
891 MACHINE_END