blob: 9efdcc03df3b5477bc51ccb8196f0f7fcccabd97 [file] [log] [blame]
Kukjin Kim6f315cb2010-09-01 13:03:39 +09001/* linux/arch/arm/mach-s5p64x0/mach-smdk6440.c
Kukjin Kimd25168e2010-01-14 08:22:00 +09002 *
Kukjin Kim6f315cb2010-09-01 13:03:39 +09003 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
Kukjin Kimd25168e2010-01-14 08:22:00 +09005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/interrupt.h>
14#include <linux/list.h>
15#include <linux/timer.h>
16#include <linux/delay.h>
17#include <linux/init.h>
Naveen Krishna Ch2c978862010-08-06 19:32:43 +090018#include <linux/i2c.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090019#include <linux/serial_core.h>
20#include <linux/platform_device.h>
21#include <linux/io.h>
22#include <linux/module.h>
23#include <linux/clk.h>
Kukjin Kim6f315cb2010-09-01 13:03:39 +090024#include <linux/gpio.h>
Banajit Goswamifec524a2011-02-28 20:31:27 +053025#include <linux/pwm_backlight.h>
Ajay Kumar1030e5c2011-09-27 07:51:22 +090026#include <linux/fb.h>
Rajeshwari Shinde66407902011-12-26 16:33:00 +090027#include <linux/mmc/host.h>
Ajay Kumar1030e5c2011-09-27 07:51:22 +090028
29#include <video/platform_lcd.h>
Leela Krishna Amudala5a213a52012-08-08 09:44:49 +090030#include <video/samsung_fimd.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090031
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090034#include <asm/irq.h>
35#include <asm/mach-types.h>
36
Kukjin Kim6f315cb2010-09-01 13:03:39 +090037#include <mach/hardware.h>
38#include <mach/map.h>
39#include <mach/regs-clock.h>
Banajit Goswamifec524a2011-02-28 20:31:27 +053040#include <mach/regs-gpio.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090041
Kukjin Kim6f315cb2010-09-01 13:03:39 +090042#include <plat/regs-serial.h>
43#include <plat/gpio-cfg.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090044#include <plat/clock.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090045#include <plat/devs.h>
46#include <plat/cpu.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020047#include <linux/platform_data/i2c-s3c2410.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090048#include <plat/pll.h>
Naveen Krishna Ch09cae8f2010-05-20 11:39:53 +090049#include <plat/adc.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020050#include <linux/platform_data/touchscreen-s3c2410.h>
Romain Naourc1fcd402013-01-09 18:47:03 -080051#include <plat/samsung-time.h>
Banajit Goswami499d2962011-07-20 23:45:22 +090052#include <plat/backlight.h>
Ajay Kumar1030e5c2011-09-27 07:51:22 +090053#include <plat/fb.h>
Rajeshwari Shinde66407902011-12-26 16:33:00 +090054#include <plat/sdhci.h>
Kukjin Kimd25168e2010-01-14 08:22:00 +090055
Kukjin Kim95af2142011-12-22 23:28:28 +010056#include "common.h"
Kukjin Kim102c3062013-01-01 18:24:57 -080057#include "i2c.h"
Kukjin Kim95af2142011-12-22 23:28:28 +010058
Kukjin Kimc8def082010-07-21 09:19:51 +090059#define SMDK6440_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
Kukjin Kimd25168e2010-01-14 08:22:00 +090060 S3C2410_UCON_RXILEVEL | \
61 S3C2410_UCON_TXIRQMODE | \
62 S3C2410_UCON_RXIRQMODE | \
63 S3C2410_UCON_RXFIFO_TOI | \
64 S3C2443_UCON_RXERR_IRQEN)
65
Kukjin Kimc8def082010-07-21 09:19:51 +090066#define SMDK6440_ULCON_DEFAULT S3C2410_LCON_CS8
Kukjin Kimd25168e2010-01-14 08:22:00 +090067
Kukjin Kimc8def082010-07-21 09:19:51 +090068#define SMDK6440_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
Kukjin Kimd25168e2010-01-14 08:22:00 +090069 S3C2440_UFCON_TXTRIG16 | \
70 S3C2410_UFCON_RXTRIG8)
71
72static struct s3c2410_uartcfg smdk6440_uartcfgs[] __initdata = {
73 [0] = {
Kukjin Kim6f315cb2010-09-01 13:03:39 +090074 .hwport = 0,
75 .flags = 0,
76 .ucon = SMDK6440_UCON_DEFAULT,
77 .ulcon = SMDK6440_ULCON_DEFAULT,
78 .ufcon = SMDK6440_UFCON_DEFAULT,
Kukjin Kimd25168e2010-01-14 08:22:00 +090079 },
80 [1] = {
Kukjin Kim6f315cb2010-09-01 13:03:39 +090081 .hwport = 1,
82 .flags = 0,
83 .ucon = SMDK6440_UCON_DEFAULT,
84 .ulcon = SMDK6440_ULCON_DEFAULT,
85 .ufcon = SMDK6440_UFCON_DEFAULT,
Kukjin Kimd25168e2010-01-14 08:22:00 +090086 },
87 [2] = {
Kukjin Kim6f315cb2010-09-01 13:03:39 +090088 .hwport = 2,
89 .flags = 0,
90 .ucon = SMDK6440_UCON_DEFAULT,
91 .ulcon = SMDK6440_ULCON_DEFAULT,
92 .ufcon = SMDK6440_UFCON_DEFAULT,
Kukjin Kimd25168e2010-01-14 08:22:00 +090093 },
94 [3] = {
Kukjin Kim6f315cb2010-09-01 13:03:39 +090095 .hwport = 3,
96 .flags = 0,
97 .ucon = SMDK6440_UCON_DEFAULT,
98 .ulcon = SMDK6440_ULCON_DEFAULT,
99 .ufcon = SMDK6440_UFCON_DEFAULT,
Kukjin Kimd25168e2010-01-14 08:22:00 +0900100 },
101};
102
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900103/* Frame Buffer */
104static struct s3c_fb_pd_win smdk6440_fb_win0 = {
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900105 .max_bpp = 32,
106 .default_bpp = 24,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530107 .xres = 800,
108 .yres = 480,
109};
110
111static struct fb_videomode smdk6440_lcd_timing = {
112 .left_margin = 8,
113 .right_margin = 13,
114 .upper_margin = 7,
115 .lower_margin = 5,
116 .hsync_len = 3,
117 .vsync_len = 1,
118 .xres = 800,
119 .yres = 480,
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900120};
121
122static struct s3c_fb_platdata smdk6440_lcd_pdata __initdata = {
123 .win[0] = &smdk6440_fb_win0,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530124 .vtiming = &smdk6440_lcd_timing,
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900125 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
126 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
127 .setup_gpio = s5p64x0_fb_gpio_setup_24bpp,
128};
129
130/* LCD power controller */
131static void smdk6440_lte480_reset_power(struct plat_lcd_data *pd,
132 unsigned int power)
133{
134 int err;
135
136 if (power) {
137 err = gpio_request(S5P6440_GPN(5), "GPN");
138 if (err) {
139 printk(KERN_ERR "failed to request GPN for lcd reset\n");
140 return;
141 }
142
143 gpio_direction_output(S5P6440_GPN(5), 1);
144 gpio_set_value(S5P6440_GPN(5), 0);
145 gpio_set_value(S5P6440_GPN(5), 1);
146 gpio_free(S5P6440_GPN(5));
147 }
148}
149
150static struct plat_lcd_data smdk6440_lcd_power_data = {
151 .set_power = smdk6440_lte480_reset_power,
152};
153
154static struct platform_device smdk6440_lcd_lte480wv = {
155 .name = "platform-lcd",
156 .dev.parent = &s3c_device_fb.dev,
157 .dev.platform_data = &smdk6440_lcd_power_data,
158};
159
Kukjin Kimd25168e2010-01-14 08:22:00 +0900160static struct platform_device *smdk6440_devices[] __initdata = {
Naveen Krishna Ch09cae8f2010-05-20 11:39:53 +0900161 &s3c_device_adc,
Atul Dahiyaff7124a2010-07-21 17:32:56 +0900162 &s3c_device_rtc,
Naveen Krishna Ch2c978862010-08-06 19:32:43 +0900163 &s3c_device_i2c0,
164 &s3c_device_i2c1,
Tomasz Figa7fa33bd2013-03-09 15:37:53 +0100165 &samsung_device_pwm,
Naveen Krishna Ch09cae8f2010-05-20 11:39:53 +0900166 &s3c_device_ts,
Banajit Goswamia0cce4552010-05-20 16:21:31 +0900167 &s3c_device_wdt,
Kukjin Kim6f315cb2010-09-01 13:03:39 +0900168 &s5p6440_device_iis,
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900169 &s3c_device_fb,
170 &smdk6440_lcd_lte480wv,
Rajeshwari Shinde66407902011-12-26 16:33:00 +0900171 &s3c_device_hsmmc0,
172 &s3c_device_hsmmc1,
173 &s3c_device_hsmmc2,
174};
175
176static struct s3c_sdhci_platdata smdk6440_hsmmc0_pdata __initdata = {
177 .cd_type = S3C_SDHCI_CD_NONE,
178};
179
180static struct s3c_sdhci_platdata smdk6440_hsmmc1_pdata __initdata = {
181 .cd_type = S3C_SDHCI_CD_INTERNAL,
182#if defined(CONFIG_S5P64X0_SD_CH1_8BIT)
183 .max_width = 8,
184 .host_caps = MMC_CAP_8_BIT_DATA,
185#endif
186};
187
188static struct s3c_sdhci_platdata smdk6440_hsmmc2_pdata __initdata = {
189 .cd_type = S3C_SDHCI_CD_NONE,
Kukjin Kim6f315cb2010-09-01 13:03:39 +0900190};
191
192static struct s3c2410_platform_i2c s5p6440_i2c0_data __initdata = {
193 .flags = 0,
194 .slave_addr = 0x10,
195 .frequency = 100*1000,
196 .sda_delay = 100,
197 .cfg_gpio = s5p6440_i2c0_cfg_gpio,
198};
199
200static struct s3c2410_platform_i2c s5p6440_i2c1_data __initdata = {
201 .flags = 0,
202 .bus_num = 1,
203 .slave_addr = 0x10,
204 .frequency = 100*1000,
205 .sda_delay = 100,
206 .cfg_gpio = s5p6440_i2c1_cfg_gpio,
Naveen Krishna Ch09cae8f2010-05-20 11:39:53 +0900207};
208
Naveen Krishna Ch2c978862010-08-06 19:32:43 +0900209static struct i2c_board_info smdk6440_i2c_devs0[] __initdata = {
210 { I2C_BOARD_INFO("24c08", 0x50), },
Jassi Brar149bb5b2010-12-21 09:46:29 +0900211 { I2C_BOARD_INFO("wm8580", 0x1b), },
Naveen Krishna Ch2c978862010-08-06 19:32:43 +0900212};
213
214static struct i2c_board_info smdk6440_i2c_devs1[] __initdata = {
215 /* To be populated */
216};
217
Banajit Goswami499d2962011-07-20 23:45:22 +0900218/* LCD Backlight data */
219static struct samsung_bl_gpio_info smdk6440_bl_gpio_info = {
220 .no = S5P6440_GPF(15),
221 .func = S3C_GPIO_SFN(2),
222};
223
224static struct platform_pwm_backlight_data smdk6440_bl_data = {
225 .pwm_id = 1,
Thierry Redinga63652f2013-08-30 12:19:52 +0200226 .enable_gpio = -1,
Banajit Goswami499d2962011-07-20 23:45:22 +0900227};
228
Kukjin Kimd25168e2010-01-14 08:22:00 +0900229static void __init smdk6440_map_io(void)
230{
Kukjin Kim95af2142011-12-22 23:28:28 +0100231 s5p64x0_init_io(NULL, 0);
Kukjin Kimd25168e2010-01-14 08:22:00 +0900232 s3c24xx_init_clocks(12000000);
233 s3c24xx_init_uarts(smdk6440_uartcfgs, ARRAY_SIZE(smdk6440_uartcfgs));
Romain Naourc1fcd402013-01-09 18:47:03 -0800234 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
Kukjin Kimd25168e2010-01-14 08:22:00 +0900235}
236
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900237static void s5p6440_set_lcd_interface(void)
238{
239 unsigned int cfg;
240
241 /* select TFT LCD type (RGB I/F) */
242 cfg = __raw_readl(S5P64X0_SPCON0);
243 cfg &= ~S5P64X0_SPCON0_LCD_SEL_MASK;
244 cfg |= S5P64X0_SPCON0_LCD_SEL_RGB;
245 __raw_writel(cfg, S5P64X0_SPCON0);
246}
247
Kukjin Kimd25168e2010-01-14 08:22:00 +0900248static void __init smdk6440_machine_init(void)
249{
Naveen Krishna Chatradhi08047652011-08-19 21:56:10 +0900250 s3c24xx_ts_set_platdata(NULL);
Naveen Krishna Ch09cae8f2010-05-20 11:39:53 +0900251
Kukjin Kim6f315cb2010-09-01 13:03:39 +0900252 s3c_i2c0_set_platdata(&s5p6440_i2c0_data);
253 s3c_i2c1_set_platdata(&s5p6440_i2c1_data);
Naveen Krishna Ch2c978862010-08-06 19:32:43 +0900254 i2c_register_board_info(0, smdk6440_i2c_devs0,
255 ARRAY_SIZE(smdk6440_i2c_devs0));
256 i2c_register_board_info(1, smdk6440_i2c_devs1,
257 ARRAY_SIZE(smdk6440_i2c_devs1));
258
Ajay Kumar1030e5c2011-09-27 07:51:22 +0900259 s5p6440_set_lcd_interface();
260 s3c_fb_set_platdata(&smdk6440_lcd_pdata);
261
Rajeshwari Shinde66407902011-12-26 16:33:00 +0900262 s3c_sdhci0_set_platdata(&smdk6440_hsmmc0_pdata);
263 s3c_sdhci1_set_platdata(&smdk6440_hsmmc1_pdata);
264 s3c_sdhci2_set_platdata(&smdk6440_hsmmc2_pdata);
265
Kukjin Kimd25168e2010-01-14 08:22:00 +0900266 platform_add_devices(smdk6440_devices, ARRAY_SIZE(smdk6440_devices));
Tomasz Figa7fa33bd2013-03-09 15:37:53 +0100267
268 samsung_bl_set(&smdk6440_bl_gpio_info, &smdk6440_bl_data);
Kukjin Kimd25168e2010-01-14 08:22:00 +0900269}
270
271MACHINE_START(SMDK6440, "SMDK6440")
272 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
Nicolas Pitre32bc8202011-07-05 22:38:17 -0400273 .atag_offset = 0x100,
Kukjin Kimd25168e2010-01-14 08:22:00 +0900274
275 .init_irq = s5p6440_init_irq,
276 .map_io = smdk6440_map_io,
277 .init_machine = smdk6440_machine_init,
Romain Naourc1fcd402013-01-09 18:47:03 -0800278 .init_time = samsung_timer_init,
Kukjin Kim73aed8b2011-12-22 23:34:25 +0100279 .restart = s5p64x0_restart,
Kukjin Kimd25168e2010-01-14 08:22:00 +0900280MACHINE_END