1 /* linux/arch/arm/mach-s3c64xx/mach-smdk6410.c
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/list.h>
18 #include <linux/timer.h>
19 #include <linux/init.h>
20 #include <linux/input.h>
21 #include <linux/serial_core.h>
22 #include <linux/platform_device.h>
24 #include <linux/i2c.h>
25 #include <linux/leds.h>
27 #include <linux/gpio.h>
28 #include <linux/delay.h>
29 #include <linux/smsc911x.h>
30 #include <linux/regulator/fixed.h>
31 #include <linux/regulator/machine.h>
32 #include <linux/pwm_backlight.h>
33 #include <linux/platform_data/s3c-hsotg.h>
35 #ifdef CONFIG_SMDK6410_WM1190_EV1
36 #include <linux/mfd/wm8350/core.h>
37 #include <linux/mfd/wm8350/pmic.h>
40 #ifdef CONFIG_SMDK6410_WM1192_EV1
41 #include <linux/mfd/wm831x/core.h>
42 #include <linux/mfd/wm831x/pdata.h>
45 #include <video/platform_lcd.h>
46 #include <video/samsung_fimd.h>
48 #include <asm/mach/arch.h>
49 #include <asm/mach/map.h>
50 #include <asm/mach/irq.h>
52 #include <mach/hardware.h>
56 #include <asm/mach-types.h>
58 #include <plat/regs-serial.h>
59 #include <mach/regs-gpio.h>
60 #include <mach/gpio-samsung.h>
61 #include <linux/platform_data/ata-samsung_cf.h>
62 #include <linux/platform_data/i2c-s3c2410.h>
64 #include <plat/gpio-cfg.h>
66 #include <plat/clock.h>
67 #include <plat/devs.h>
70 #include <linux/platform_data/touchscreen-s3c2410.h>
71 #include <plat/keypad.h>
72 #include <plat/backlight.h>
73 #include <plat/samsung-time.h>
76 #include "regs-modem.h"
77 #include "regs-srom.h"
80 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
81 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
82 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
84 static struct s3c2410_uartcfg smdk6410_uartcfgs
[] __initdata
= {
115 /* framebuffer and LCD setup. */
117 /* GPF15 = LCD backlight control
118 * GPF13 => Panel power
119 * GPN5 = LCD nRESET signal
120 * PWM_TOUT1 => backlight brightness
123 static void smdk6410_lcd_power_set(struct plat_lcd_data
*pd
,
127 gpio_direction_output(S3C64XX_GPF(13), 1);
129 /* fire nRESET on power up */
130 gpio_direction_output(S3C64XX_GPN(5), 0);
132 gpio_direction_output(S3C64XX_GPN(5), 1);
135 gpio_direction_output(S3C64XX_GPF(13), 0);
139 static struct plat_lcd_data smdk6410_lcd_power_data
= {
140 .set_power
= smdk6410_lcd_power_set
,
143 static struct platform_device smdk6410_lcd_powerdev
= {
144 .name
= "platform-lcd",
145 .dev
.parent
= &s3c_device_fb
.dev
,
146 .dev
.platform_data
= &smdk6410_lcd_power_data
,
149 static struct s3c_fb_pd_win smdk6410_fb_win0
= {
154 .virtual_y
= 480 * 2,
158 static struct fb_videomode smdk6410_lcd_timing
= {
169 /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
170 static struct s3c_fb_platdata smdk6410_lcd_pdata __initdata
= {
171 .setup_gpio
= s3c64xx_fb_gpio_setup_24bpp
,
172 .vtiming
= &smdk6410_lcd_timing
,
173 .win
[0] = &smdk6410_fb_win0
,
174 .vidcon0
= VIDCON0_VIDOUT_RGB
| VIDCON0_PNRMODE_RGB
,
175 .vidcon1
= VIDCON1_INV_HSYNC
| VIDCON1_INV_VSYNC
,
179 * Configuring Ethernet on SMDK6410
181 * Both CS8900A and LAN9115 chips share one chip select mediated by CFG6.
182 * The constant address below corresponds to nCS1
184 * 1) Set CFGB2 p3 ON others off, no other CFGB selects "ethernet"
185 * 2) CFG6 needs to be switched to "LAN9115" side
188 static struct resource smdk6410_smsc911x_resources
[] = {
189 [0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN1
, SZ_64K
),
190 [1] = DEFINE_RES_NAMED(S3C_EINT(10), 1, NULL
, IORESOURCE_IRQ \
191 | IRQ_TYPE_LEVEL_LOW
),
194 static struct smsc911x_platform_config smdk6410_smsc911x_pdata
= {
195 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
196 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
197 .flags
= SMSC911X_USE_32BIT
| SMSC911X_FORCE_INTERNAL_PHY
,
198 .phy_interface
= PHY_INTERFACE_MODE_MII
,
202 static struct platform_device smdk6410_smsc911x
= {
205 .num_resources
= ARRAY_SIZE(smdk6410_smsc911x_resources
),
206 .resource
= &smdk6410_smsc911x_resources
[0],
208 .platform_data
= &smdk6410_smsc911x_pdata
,
212 #ifdef CONFIG_REGULATOR
213 static struct regulator_consumer_supply smdk6410_b_pwr_5v_consumers
[] __initdata
= {
214 REGULATOR_SUPPLY("PVDD", "0-001b"),
215 REGULATOR_SUPPLY("AVDD", "0-001b"),
218 static struct regulator_init_data smdk6410_b_pwr_5v_data
= {
222 .num_consumer_supplies
= ARRAY_SIZE(smdk6410_b_pwr_5v_consumers
),
223 .consumer_supplies
= smdk6410_b_pwr_5v_consumers
,
226 static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata
= {
227 .supply_name
= "B_PWR_5V",
228 .microvolts
= 5000000,
229 .init_data
= &smdk6410_b_pwr_5v_data
,
233 static struct platform_device smdk6410_b_pwr_5v
= {
234 .name
= "reg-fixed-voltage",
237 .platform_data
= &smdk6410_b_pwr_5v_pdata
,
242 static struct s3c_ide_platdata smdk6410_ide_pdata __initdata
= {
243 .setup_gpio
= s3c64xx_ide_setup_gpio
,
246 static uint32_t smdk6410_keymap
[] __initdata
= {
247 /* KEY(row, col, keycode) */
248 KEY(0, 3, KEY_1
), KEY(0, 4, KEY_2
), KEY(0, 5, KEY_3
),
249 KEY(0, 6, KEY_4
), KEY(0, 7, KEY_5
),
250 KEY(1, 3, KEY_A
), KEY(1, 4, KEY_B
), KEY(1, 5, KEY_C
),
251 KEY(1, 6, KEY_D
), KEY(1, 7, KEY_E
)
254 static struct matrix_keymap_data smdk6410_keymap_data __initdata
= {
255 .keymap
= smdk6410_keymap
,
256 .keymap_size
= ARRAY_SIZE(smdk6410_keymap
),
259 static struct samsung_keypad_platdata smdk6410_keypad_data __initdata
= {
260 .keymap_data
= &smdk6410_keymap_data
,
265 static struct map_desc smdk6410_iodesc
[] = {};
267 static struct platform_device
*smdk6410_devices
[] __initdata
= {
268 #ifdef CONFIG_SMDK6410_SD_CH0
271 #ifdef CONFIG_SMDK6410_SD_CH1
279 &s3c_device_usb_hsotg
,
280 &s3c64xx_device_iisv4
,
281 &samsung_device_keypad
,
283 #ifdef CONFIG_REGULATOR
286 &smdk6410_lcd_powerdev
,
296 #ifdef CONFIG_REGULATOR
298 static struct regulator_consumer_supply smdk6410_vddarm_consumers
[] = {
299 REGULATOR_SUPPLY("vddarm", NULL
),
302 /* VDDARM, BUCK1 on J5 */
303 static struct regulator_init_data smdk6410_vddarm
= {
309 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
311 .num_consumer_supplies
= ARRAY_SIZE(smdk6410_vddarm_consumers
),
312 .consumer_supplies
= smdk6410_vddarm_consumers
,
315 /* VDD_INT, BUCK2 on J5 */
316 static struct regulator_init_data smdk6410_vddint
= {
322 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
326 /* VDD_HI, LDO3 on J5 */
327 static struct regulator_init_data smdk6410_vddhi
= {
334 /* VDD_PLL, LDO2 on J5 */
335 static struct regulator_init_data smdk6410_vddpll
= {
342 /* VDD_UH_MMC, LDO5 on J5 */
343 static struct regulator_init_data smdk6410_vdduh_mmc
= {
345 .name
= "PVDD_UH+PVDD_MMC",
350 /* VCCM3BT, LDO8 on J5 */
351 static struct regulator_init_data smdk6410_vccmc3bt
= {
358 /* VCCM2MTV, LDO11 on J5 */
359 static struct regulator_init_data smdk6410_vccm2mtv
= {
366 /* VDD_LCD, LDO12 on J5 */
367 static struct regulator_init_data smdk6410_vddlcd
= {
374 /* VDD_OTGI, LDO9 on J5 */
375 static struct regulator_init_data smdk6410_vddotgi
= {
382 /* VDD_OTG, LDO14 on J5 */
383 static struct regulator_init_data smdk6410_vddotg
= {
390 /* VDD_ALIVE, LDO15 on J5 */
391 static struct regulator_init_data smdk6410_vddalive
= {
393 .name
= "PVDD_ALIVE",
398 /* VDD_AUDIO, VLDO_AUDIO on J5 */
399 static struct regulator_init_data smdk6410_vddaudio
= {
401 .name
= "PVDD_AUDIO",
407 #ifdef CONFIG_SMDK6410_WM1190_EV1
408 /* S3C64xx internal logic & PLL */
409 static struct regulator_init_data wm8350_dcdc1_data
= {
411 .name
= "PVDD_INT+PVDD_PLL",
420 static struct regulator_init_data wm8350_dcdc3_data
= {
428 .mode
= REGULATOR_MODE_NORMAL
,
431 .initial_state
= PM_SUSPEND_MEM
,
435 /* USB, EXT, PCM, ADC/DAC, USB, MMC */
436 static struct regulator_consumer_supply wm8350_dcdc4_consumers
[] = {
437 REGULATOR_SUPPLY("DVDD", "0-001b"),
440 static struct regulator_init_data wm8350_dcdc4_data
= {
442 .name
= "PVDD_HI+PVDD_EXT+PVDD_SYS+PVCCM2MTV",
447 .num_consumer_supplies
= ARRAY_SIZE(wm8350_dcdc4_consumers
),
448 .consumer_supplies
= wm8350_dcdc4_consumers
,
451 /* OTGi/1190-EV1 HPVDD & AVDD */
452 static struct regulator_init_data wm8350_ldo4_data
= {
454 .name
= "PVDD_OTGI+HPVDD+AVDD",
464 struct regulator_init_data
*initdata
;
465 } wm1190_regulators
[] = {
466 { WM8350_DCDC_1
, &wm8350_dcdc1_data
},
467 { WM8350_DCDC_3
, &wm8350_dcdc3_data
},
468 { WM8350_DCDC_4
, &wm8350_dcdc4_data
},
469 { WM8350_DCDC_6
, &smdk6410_vddarm
},
470 { WM8350_LDO_1
, &smdk6410_vddalive
},
471 { WM8350_LDO_2
, &smdk6410_vddotg
},
472 { WM8350_LDO_3
, &smdk6410_vddlcd
},
473 { WM8350_LDO_4
, &wm8350_ldo4_data
},
476 static int __init
smdk6410_wm8350_init(struct wm8350
*wm8350
)
480 /* Configure the IRQ line */
481 s3c_gpio_setpull(S3C64XX_GPN(12), S3C_GPIO_PULL_UP
);
483 /* Instantiate the regulators */
484 for (i
= 0; i
< ARRAY_SIZE(wm1190_regulators
); i
++)
485 wm8350_register_regulator(wm8350
,
486 wm1190_regulators
[i
].regulator
,
487 wm1190_regulators
[i
].initdata
);
492 static struct wm8350_platform_data __initdata smdk6410_wm8350_pdata
= {
493 .init
= smdk6410_wm8350_init
,
495 .irq_base
= IRQ_BOARD_START
,
499 #ifdef CONFIG_SMDK6410_WM1192_EV1
500 static struct gpio_led wm1192_pmic_leds
[] = {
502 .name
= "PMIC:red:power",
503 .gpio
= GPIO_BOARD_START
+ 3,
504 .default_state
= LEDS_GPIO_DEFSTATE_ON
,
508 static struct gpio_led_platform_data wm1192_pmic_led
= {
509 .num_leds
= ARRAY_SIZE(wm1192_pmic_leds
),
510 .leds
= wm1192_pmic_leds
,
513 static struct platform_device wm1192_pmic_led_dev
= {
517 .platform_data
= &wm1192_pmic_led
,
521 static int wm1192_pre_init(struct wm831x
*wm831x
)
525 /* Configure the IRQ line */
526 s3c_gpio_setpull(S3C64XX_GPN(12), S3C_GPIO_PULL_UP
);
528 ret
= platform_device_register(&wm1192_pmic_led_dev
);
530 dev_err(wm831x
->dev
, "Failed to add PMIC LED: %d\n", ret
);
535 static struct wm831x_backlight_pdata wm1192_backlight_pdata
= {
540 static struct regulator_init_data wm1192_dcdc3
= {
542 .name
= "PVDD_MEM+PVDD_GPS",
547 static struct regulator_consumer_supply wm1192_ldo1_consumers
[] = {
548 REGULATOR_SUPPLY("DVDD", "0-001b"), /* WM8580 */
551 static struct regulator_init_data wm1192_ldo1
= {
553 .name
= "PVDD_LCD+PVDD_EXT",
556 .consumer_supplies
= wm1192_ldo1_consumers
,
557 .num_consumer_supplies
= ARRAY_SIZE(wm1192_ldo1_consumers
),
560 static struct wm831x_status_pdata wm1192_led7_pdata
= {
561 .name
= "LED7:green:",
564 static struct wm831x_status_pdata wm1192_led8_pdata
= {
565 .name
= "LED8:green:",
568 static struct wm831x_pdata smdk6410_wm1192_pdata
= {
569 .pre_init
= wm1192_pre_init
,
571 .backlight
= &wm1192_backlight_pdata
,
573 &smdk6410_vddarm
, /* DCDC1 */
574 &smdk6410_vddint
, /* DCDC2 */
577 .gpio_base
= GPIO_BOARD_START
,
579 &wm1192_ldo1
, /* LDO1 */
580 &smdk6410_vdduh_mmc
, /* LDO2 */
582 &smdk6410_vddotgi
, /* LDO4 */
583 &smdk6410_vddotg
, /* LDO5 */
584 &smdk6410_vddhi
, /* LDO6 */
585 &smdk6410_vddaudio
, /* LDO7 */
586 &smdk6410_vccm2mtv
, /* LDO8 */
587 &smdk6410_vddpll
, /* LDO9 */
588 &smdk6410_vccmc3bt
, /* LDO10 */
589 &smdk6410_vddalive
, /* LDO11 */
598 static struct i2c_board_info i2c_devs0
[] __initdata
= {
599 { I2C_BOARD_INFO("24c08", 0x50), },
600 { I2C_BOARD_INFO("wm8580", 0x1b), },
602 #ifdef CONFIG_SMDK6410_WM1192_EV1
603 { I2C_BOARD_INFO("wm8312", 0x34),
604 .platform_data
= &smdk6410_wm1192_pdata
,
609 #ifdef CONFIG_SMDK6410_WM1190_EV1
610 { I2C_BOARD_INFO("wm8350", 0x1a),
611 .platform_data
= &smdk6410_wm8350_pdata
,
617 static struct i2c_board_info i2c_devs1
[] __initdata
= {
618 { I2C_BOARD_INFO("24c128", 0x57), }, /* Samsung S524AD0XD1 */
621 /* LCD Backlight data */
622 static struct samsung_bl_gpio_info smdk6410_bl_gpio_info
= {
623 .no
= S3C64XX_GPF(15),
624 .func
= S3C_GPIO_SFN(2),
627 static struct platform_pwm_backlight_data smdk6410_bl_data
= {
632 static struct s3c_hsotg_plat smdk6410_hsotg_pdata
;
634 static void __init
smdk6410_map_io(void)
638 s3c64xx_init_io(smdk6410_iodesc
, ARRAY_SIZE(smdk6410_iodesc
));
639 s3c64xx_set_xtal_freq(12000000);
640 s3c24xx_init_uarts(smdk6410_uartcfgs
, ARRAY_SIZE(smdk6410_uartcfgs
));
641 samsung_set_timer_source(SAMSUNG_PWM3
, SAMSUNG_PWM4
);
643 /* set the LCD type */
645 tmp
= __raw_readl(S3C64XX_SPCON
);
646 tmp
&= ~S3C64XX_SPCON_LCD_SEL_MASK
;
647 tmp
|= S3C64XX_SPCON_LCD_SEL_RGB
;
648 __raw_writel(tmp
, S3C64XX_SPCON
);
650 /* remove the lcd bypass */
651 tmp
= __raw_readl(S3C64XX_MODEM_MIFPCON
);
652 tmp
&= ~MIFPCON_LCD_BYPASS
;
653 __raw_writel(tmp
, S3C64XX_MODEM_MIFPCON
);
656 static void __init
smdk6410_machine_init(void)
660 s3c_i2c0_set_platdata(NULL
);
661 s3c_i2c1_set_platdata(NULL
);
662 s3c_fb_set_platdata(&smdk6410_lcd_pdata
);
663 s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata
);
665 samsung_keypad_set_platdata(&smdk6410_keypad_data
);
667 s3c24xx_ts_set_platdata(NULL
);
669 /* configure nCS1 width to 16 bits */
671 cs1
= __raw_readl(S3C64XX_SROM_BW
) &
672 ~(S3C64XX_SROM_BW__CS_MASK
<< S3C64XX_SROM_BW__NCS1__SHIFT
);
673 cs1
|= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT
) |
674 (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT
) |
675 (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT
)) <<
676 S3C64XX_SROM_BW__NCS1__SHIFT
;
677 __raw_writel(cs1
, S3C64XX_SROM_BW
);
679 /* set timing for nCS1 suitable for ethernet chip */
681 __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT
) |
682 (6 << S3C64XX_SROM_BCX__TACP__SHIFT
) |
683 (4 << S3C64XX_SROM_BCX__TCAH__SHIFT
) |
684 (1 << S3C64XX_SROM_BCX__TCOH__SHIFT
) |
685 (0xe << S3C64XX_SROM_BCX__TACC__SHIFT
) |
686 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT
) |
687 (0 << S3C64XX_SROM_BCX__TACS__SHIFT
), S3C64XX_SROM_BC1
);
689 gpio_request(S3C64XX_GPN(5), "LCD power");
690 gpio_request(S3C64XX_GPF(13), "LCD power");
692 i2c_register_board_info(0, i2c_devs0
, ARRAY_SIZE(i2c_devs0
));
693 i2c_register_board_info(1, i2c_devs1
, ARRAY_SIZE(i2c_devs1
));
695 s3c_ide_set_platdata(&smdk6410_ide_pdata
);
697 platform_add_devices(smdk6410_devices
, ARRAY_SIZE(smdk6410_devices
));
699 samsung_bl_set(&smdk6410_bl_gpio_info
, &smdk6410_bl_data
);
702 MACHINE_START(SMDK6410
, "SMDK6410")
703 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
704 .atag_offset
= 0x100,
706 .init_irq
= s3c6410_init_irq
,
707 .map_io
= smdk6410_map_io
,
708 .init_machine
= smdk6410_machine_init
,
709 .init_late
= s3c64xx_init_late
,
710 .init_time
= samsung_timer_init
,
711 .restart
= s3c64xx_restart
,