1 /* linux/arch/arm/mach-s3c64xx/mach-crag6410.c
3 * Copyright 2011 Wolfson Microelectronics plc
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
6 * Copyright 2011 Simtec Electronics
7 * Ben Dooks <ben@simtec.co.uk>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/list.h>
16 #include <linux/serial_core.h>
17 #include <linux/platform_device.h>
20 #include <linux/init.h>
21 #include <linux/gpio.h>
22 #include <linux/delay.h>
23 #include <linux/regulator/machine.h>
24 #include <linux/regulator/fixed.h>
25 #include <linux/pwm_backlight.h>
26 #include <linux/dm9000.h>
27 #include <linux/gpio_keys.h>
28 #include <linux/basic_mmio_gpio.h>
29 #include <linux/spi/spi.h>
31 #include <linux/i2c/pca953x.h>
33 #include <video/platform_lcd.h>
35 #include <linux/mfd/wm831x/core.h>
36 #include <linux/mfd/wm831x/pdata.h>
37 #include <linux/mfd/wm831x/irq.h>
38 #include <linux/mfd/wm831x/gpio.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach-types.h>
43 #include <mach/hardware.h>
46 #include <mach/s3c6410.h>
47 #include <mach/regs-sys.h>
48 #include <mach/regs-gpio.h>
49 #include <mach/regs-modem.h>
50 #include <mach/crag6410.h>
52 #include <mach/regs-gpio-memport.h>
54 #include <plat/regs-serial.h>
55 #include <plat/regs-fb-v4.h>
57 #include <plat/sdhci.h>
58 #include <plat/gpio-cfg.h>
59 #include <plat/s3c64xx-spi.h>
61 #include <plat/keypad.h>
62 #include <plat/clock.h>
63 #include <plat/devs.h>
69 /* serial port setup */
71 #define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK)
72 #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
73 #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
75 static struct s3c2410_uartcfg crag6410_uartcfgs
[] __initdata
= {
106 static struct platform_pwm_backlight_data crag6410_backlight_data
= {
108 .max_brightness
= 1000,
109 .dft_brightness
= 600,
110 .pwm_period_ns
= 100000, /* about 1kHz */
113 static struct platform_device crag6410_backlight_device
= {
114 .name
= "pwm-backlight",
117 .parent
= &s3c_device_timer
[0].dev
,
118 .platform_data
= &crag6410_backlight_data
,
122 static void crag6410_lcd_power_set(struct plat_lcd_data
*pd
, unsigned int power
)
124 pr_debug("%s: setting power %d\n", __func__
, power
);
127 gpio_set_value(S3C64XX_GPB(0), 1);
129 s3c_gpio_cfgpin(S3C64XX_GPF(14), S3C_GPIO_SFN(2));
131 gpio_direction_output(S3C64XX_GPF(14), 0);
132 gpio_set_value(S3C64XX_GPB(0), 0);
136 static struct platform_device crag6410_lcd_powerdev
= {
137 .name
= "platform-lcd",
139 .dev
.parent
= &s3c_device_fb
.dev
,
140 .dev
.platform_data
= &(struct plat_lcd_data
) {
141 .set_power
= crag6410_lcd_power_set
,
146 static struct s3c_fb_pd_win crag6410_fb_win0
= {
147 /* this is to ensure we use win0 */
160 .virtual_y
= 480 * 2,
164 /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
165 static struct s3c_fb_platdata crag6410_lcd_pdata __initdata
= {
166 .setup_gpio
= s3c64xx_fb_gpio_setup_24bpp
,
167 .win
[0] = &crag6410_fb_win0
,
168 .vidcon0
= VIDCON0_VIDOUT_RGB
| VIDCON0_PNRMODE_RGB
,
169 .vidcon1
= VIDCON1_INV_HSYNC
| VIDCON1_INV_VSYNC
,
174 static uint32_t crag6410_keymap
[] __initdata
= {
175 /* KEY(row, col, keycode) */
176 KEY(0, 0, KEY_VOLUMEUP
),
178 KEY(0, 2, KEY_VOLUMEDOWN
),
181 KEY(0, 5, KEY_MEDIA
),
186 KEY(1, 4, KEY_RIGHT
),
187 KEY(1, 5, KEY_CAMERA
),
190 static struct matrix_keymap_data crag6410_keymap_data __initdata
= {
191 .keymap
= crag6410_keymap
,
192 .keymap_size
= ARRAY_SIZE(crag6410_keymap
),
195 static struct samsung_keypad_platdata crag6410_keypad_data __initdata
= {
196 .keymap_data
= &crag6410_keymap_data
,
201 static struct gpio_keys_button crag6410_gpio_keys
[] = {
204 .gpio
= S3C64XX_GPL(10), /* EINT 18 */
210 .code
= SW_FRONT_PROXIMITY
,
211 .gpio
= S3C64XX_GPN(11), /* EINT 11 */
216 static struct gpio_keys_platform_data crag6410_gpio_keydata
= {
217 .buttons
= crag6410_gpio_keys
,
218 .nbuttons
= ARRAY_SIZE(crag6410_gpio_keys
),
221 static struct platform_device crag6410_gpio_keydev
= {
224 .dev
.platform_data
= &crag6410_gpio_keydata
,
227 static struct resource crag6410_dm9k_resource
[] = {
229 .start
= S3C64XX_PA_XM0CSN5
,
230 .end
= S3C64XX_PA_XM0CSN5
+ 1,
231 .flags
= IORESOURCE_MEM
,
234 .start
= S3C64XX_PA_XM0CSN5
+ (1 << 8),
235 .end
= S3C64XX_PA_XM0CSN5
+ (1 << 8) + 1,
236 .flags
= IORESOURCE_MEM
,
239 .start
= S3C_EINT(17),
241 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
245 static struct dm9000_plat_data mini6410_dm9k_pdata
= {
246 .flags
= DM9000_PLATF_16BITONLY
,
249 static struct platform_device crag6410_dm9k_device
= {
252 .num_resources
= ARRAY_SIZE(crag6410_dm9k_resource
),
253 .resource
= crag6410_dm9k_resource
,
254 .dev
.platform_data
= &mini6410_dm9k_pdata
,
257 static struct resource crag6410_mmgpio_resource
[] = {
259 .start
= S3C64XX_PA_XM0CSN4
+ 1,
260 .end
= S3C64XX_PA_XM0CSN4
+ 1,
261 .flags
= IORESOURCE_MEM
,
265 static struct platform_device crag6410_mmgpio
= {
266 .name
= "basic-mmio-gpio",
268 .resource
= crag6410_mmgpio_resource
,
269 .num_resources
= ARRAY_SIZE(crag6410_mmgpio_resource
),
270 .dev
.platform_data
= &(struct bgpio_pdata
) {
275 static struct platform_device speyside_device
= {
280 static struct platform_device speyside_wm8962_device
= {
281 .name
= "speyside-wm8962",
285 static struct regulator_consumer_supply wallvdd_consumers
[] = {
286 REGULATOR_SUPPLY("SPKVDD1", "1-001a"),
287 REGULATOR_SUPPLY("SPKVDD2", "1-001a"),
290 static struct regulator_init_data wallvdd_data
= {
294 .num_consumer_supplies
= ARRAY_SIZE(wallvdd_consumers
),
295 .consumer_supplies
= wallvdd_consumers
,
298 static struct fixed_voltage_config wallvdd_pdata
= {
299 .supply_name
= "WALLVDD",
300 .microvolts
= 5000000,
301 .init_data
= &wallvdd_data
,
305 static struct platform_device wallvdd_device
= {
306 .name
= "reg-fixed-voltage",
309 .platform_data
= &wallvdd_pdata
,
313 static struct platform_device
*crag6410_devices
[] __initdata
= {
321 &s3c_device_usb_hsotg
,
322 &s3c_device_timer
[0],
323 &s3c64xx_device_iis0
,
324 &s3c64xx_device_iis1
,
326 &samsung_device_keypad
,
327 &crag6410_gpio_keydev
,
328 &crag6410_dm9k_device
,
329 &s3c64xx_device_spi0
,
331 &crag6410_lcd_powerdev
,
332 &crag6410_backlight_device
,
334 &speyside_wm8962_device
,
338 static struct pca953x_platform_data crag6410_pca_data
= {
339 .gpio_base
= PCA935X_GPIO_BASE
,
343 /* VDDARM is controlled by DVS1 connected to GPK(0) */
344 static struct wm831x_buckv_pdata vddarm_pdata
= {
345 .dvs_control_src
= 1,
346 .dvs_gpio
= S3C64XX_GPK(0),
349 static struct regulator_consumer_supply vddarm_consumers
[] __initdata
= {
350 REGULATOR_SUPPLY("vddarm", NULL
),
353 static struct regulator_init_data vddarm __initdata
= {
359 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
361 .num_consumer_supplies
= ARRAY_SIZE(vddarm_consumers
),
362 .consumer_supplies
= vddarm_consumers
,
363 .supply_regulator
= "WALLVDD",
364 .driver_data
= &vddarm_pdata
,
367 static struct regulator_init_data vddint __initdata
= {
373 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
377 static struct regulator_init_data vddmem __initdata
= {
384 static struct regulator_init_data vddsys __initdata
= {
386 .name
= "VDDSYS,VDDEXT,VDDPCM,VDDSS",
391 static struct regulator_consumer_supply vddmmc_consumers
[] __initdata
= {
392 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
393 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.1"),
394 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
397 static struct regulator_init_data vddmmc __initdata
= {
402 .num_consumer_supplies
= ARRAY_SIZE(vddmmc_consumers
),
403 .consumer_supplies
= vddmmc_consumers
,
404 .supply_regulator
= "WALLVDD",
407 static struct regulator_init_data vddotgi __initdata
= {
412 .supply_regulator
= "WALLVDD",
415 static struct regulator_init_data vddotg __initdata
= {
420 .supply_regulator
= "WALLVDD",
423 static struct regulator_init_data vddhi __initdata
= {
428 .supply_regulator
= "WALLVDD",
431 static struct regulator_init_data vddadc __initdata
= {
433 .name
= "VDDADC,VDDDAC",
436 .supply_regulator
= "WALLVDD",
439 static struct regulator_init_data vddmem0 __initdata
= {
444 .supply_regulator
= "WALLVDD",
447 static struct regulator_init_data vddpll __initdata
= {
452 .supply_regulator
= "WALLVDD",
455 static struct regulator_init_data vddlcd __initdata
= {
460 .supply_regulator
= "WALLVDD",
463 static struct regulator_init_data vddalive __initdata
= {
468 .supply_regulator
= "WALLVDD",
471 static struct wm831x_backup_pdata banff_backup_pdata __initdata
= {
473 .vlim
= 2500, /* mV */
474 .ilim
= 200, /* uA */
477 static struct wm831x_status_pdata banff_red_led __initdata
= {
478 .name
= "banff:red:",
479 .default_src
= WM831X_STATUS_MANUAL
,
482 static struct wm831x_status_pdata banff_green_led __initdata
= {
483 .name
= "banff:green:",
484 .default_src
= WM831X_STATUS_MANUAL
,
487 static struct wm831x_touch_pdata touch_pdata __initdata
= {
488 .data_irq
= S3C_EINT(26),
489 .pd_irq
= S3C_EINT(27),
492 static struct wm831x_pdata crag_pmic_pdata __initdata
= {
494 .irq_base
= BANFF_PMIC_IRQ_BASE
,
495 .gpio_base
= GPIO_BOARD_START
+ 8,
497 .backup
= &banff_backup_pdata
,
500 /* GPIO5: DVS1_REQ - CMOS, DBVDD, active high */
501 [4] = WM831X_GPN_DIR
| WM831X_GPN_POL
| WM831X_GPN_ENA
| 0x8,
502 /* GPIO11: Touchscreen data - CMOS, DBVDD, active high*/
503 [10] = WM831X_GPN_POL
| WM831X_GPN_ENA
| 0x6,
504 /* GPIO12: Touchscreen pen down - CMOS, DBVDD, active high*/
505 [11] = WM831X_GPN_POL
| WM831X_GPN_ENA
| 0x7,
525 &vddalive
, /* LDO11 */
533 .touch
= &touch_pdata
,
536 static struct i2c_board_info i2c_devs0
[] __initdata
= {
537 { I2C_BOARD_INFO("24c08", 0x50), },
538 { I2C_BOARD_INFO("tca6408", 0x20),
539 .platform_data
= &crag6410_pca_data
,
541 { I2C_BOARD_INFO("wm8312", 0x34),
542 .platform_data
= &crag_pmic_pdata
,
547 static struct s3c2410_platform_i2c i2c0_pdata
= {
551 static struct regulator_init_data pvdd_1v2 __initdata
= {
558 static struct regulator_consumer_supply pvdd_1v8_consumers
[] __initdata
= {
559 REGULATOR_SUPPLY("PLLVDD", "1-001a"),
560 REGULATOR_SUPPLY("DBVDD", "1-001a"),
561 REGULATOR_SUPPLY("CPVDD", "1-001a"),
562 REGULATOR_SUPPLY("AVDD2", "1-001a"),
563 REGULATOR_SUPPLY("DCVDD", "1-001a"),
564 REGULATOR_SUPPLY("AVDD", "1-001a"),
567 static struct regulator_init_data pvdd_1v8 __initdata
= {
573 .consumer_supplies
= pvdd_1v8_consumers
,
574 .num_consumer_supplies
= ARRAY_SIZE(pvdd_1v8_consumers
),
577 static struct regulator_consumer_supply pvdd_3v3_consumers
[] __initdata
= {
578 REGULATOR_SUPPLY("MICVDD", "1-001a"),
579 REGULATOR_SUPPLY("AVDD1", "1-001a"),
582 static struct regulator_init_data pvdd_3v3 __initdata
= {
588 .consumer_supplies
= pvdd_3v3_consumers
,
589 .num_consumer_supplies
= ARRAY_SIZE(pvdd_3v3_consumers
),
592 static struct wm831x_pdata glenfarclas_pmic_pdata __initdata
= {
594 .irq_base
= GLENFARCLAS_PMIC_IRQ_BASE
,
595 .gpio_base
= GLENFARCLAS_PMIC_GPIO_BASE
,
598 /* GPIO1-3: IRQ inputs, rising edge triggered, CMOS */
599 [0] = WM831X_GPN_DIR
| WM831X_GPN_POL
| WM831X_GPN_ENA
,
600 [1] = WM831X_GPN_DIR
| WM831X_GPN_POL
| WM831X_GPN_ENA
,
601 [2] = WM831X_GPN_DIR
| WM831X_GPN_POL
| WM831X_GPN_ENA
,
605 &pvdd_1v2
, /* DCDC1 */
606 &pvdd_1v8
, /* DCDC2 */
607 &pvdd_3v3
, /* DCDC3 */
610 .disable_touch
= true,
613 static struct i2c_board_info i2c_devs1
[] __initdata
= {
614 { I2C_BOARD_INFO("wm8311", 0x34),
616 .platform_data
= &glenfarclas_pmic_pdata
},
618 { I2C_BOARD_INFO("wlf-gf-module", 0x24) },
619 { I2C_BOARD_INFO("wlf-gf-module", 0x25) },
620 { I2C_BOARD_INFO("wlf-gf-module", 0x26) },
622 { I2C_BOARD_INFO("wm1250-ev1", 0x27) },
625 static void __init
crag6410_map_io(void)
627 s3c64xx_init_io(NULL
, 0);
628 s3c24xx_init_clocks(12000000);
629 s3c24xx_init_uarts(crag6410_uartcfgs
, ARRAY_SIZE(crag6410_uartcfgs
));
631 /* LCD type and Bypass set by bootloader */
634 static struct s3c_sdhci_platdata crag6410_hsmmc2_pdata
= {
636 .cd_type
= S3C_SDHCI_CD_PERMANENT
,
639 static struct s3c_sdhci_platdata crag6410_hsmmc1_pdata
= {
641 .cd_type
= S3C_SDHCI_CD_GPIO
,
642 .ext_cd_gpio
= S3C64XX_GPF(11),
645 static void crag6410_cfg_sdhci0(struct platform_device
*dev
, int width
)
647 /* Set all the necessary GPG pins to special-function 2 */
648 s3c_gpio_cfgrange_nopull(S3C64XX_GPG(0), 2 + width
, S3C_GPIO_SFN(2));
650 /* force card-detected for prototype 0 */
651 s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_DOWN
);
654 static struct s3c_sdhci_platdata crag6410_hsmmc0_pdata
= {
656 .cd_type
= S3C_SDHCI_CD_INTERNAL
,
657 .cfg_gpio
= crag6410_cfg_sdhci0
,
660 static void __init
crag6410_machine_init(void)
662 /* Open drain IRQs need pullups */
663 s3c_gpio_setpull(S3C64XX_GPM(0), S3C_GPIO_PULL_UP
);
664 s3c_gpio_setpull(S3C64XX_GPN(0), S3C_GPIO_PULL_UP
);
666 gpio_request(S3C64XX_GPB(0), "LCD power");
667 gpio_direction_output(S3C64XX_GPB(0), 0);
669 gpio_request(S3C64XX_GPF(14), "LCD PWM");
670 gpio_direction_output(S3C64XX_GPF(14), 0); /* turn off */
672 gpio_request(S3C64XX_GPB(1), "SD power");
673 gpio_direction_output(S3C64XX_GPB(1), 0);
675 gpio_request(S3C64XX_GPF(10), "nRESETSEL");
676 gpio_direction_output(S3C64XX_GPF(10), 1);
678 s3c_sdhci0_set_platdata(&crag6410_hsmmc0_pdata
);
679 s3c_sdhci1_set_platdata(&crag6410_hsmmc1_pdata
);
680 s3c_sdhci2_set_platdata(&crag6410_hsmmc2_pdata
);
682 s3c_i2c0_set_platdata(&i2c0_pdata
);
683 s3c_i2c1_set_platdata(NULL
);
684 s3c_fb_set_platdata(&crag6410_lcd_pdata
);
686 i2c_register_board_info(0, i2c_devs0
, ARRAY_SIZE(i2c_devs0
));
687 i2c_register_board_info(1, i2c_devs1
, ARRAY_SIZE(i2c_devs1
));
689 samsung_keypad_set_platdata(&crag6410_keypad_data
);
691 platform_add_devices(crag6410_devices
, ARRAY_SIZE(crag6410_devices
));
693 regulator_has_full_constraints();
698 MACHINE_START(WLF_CRAGG_6410
, "Wolfson Cragganmore 6410")
699 /* Maintainer: Mark Brown <broonie@opensource.wolfsonmicro.com> */
700 .atag_offset
= 0x100,
701 .init_irq
= s3c6410_init_irq
,
702 .map_io
= crag6410_map_io
,
703 .init_machine
= crag6410_machine_init
,
704 .timer
= &s3c24xx_timer
,