drivers: power: report battery voltage in AOSP compatible format
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-s5p64x0 / mach-smdk6440.c
CommitLineData
6f315cb5 1/* linux/arch/arm/mach-s5p64x0/mach-smdk6440.c
d25168ea 2 *
6f315cb5
KK
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
d25168ea
KK
5 *
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>
2c97886d 18#include <linux/i2c.h>
d25168ea
KK
19#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>
6f315cb5 24#include <linux/gpio.h>
fec524aa 25#include <linux/pwm_backlight.h>
1030e5c5 26#include <linux/fb.h>
6640790c 27#include <linux/mmc/host.h>
1030e5c5
AK
28
29#include <video/platform_lcd.h>
5a213a55 30#include <video/samsung_fimd.h>
d25168ea
KK
31
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
6f315cb5
KK
34#include <asm/irq.h>
35#include <asm/mach-types.h>
d25168ea
KK
36
37#include <mach/hardware.h>
38#include <mach/map.h>
6f315cb5 39#include <mach/regs-clock.h>
fec524aa 40#include <mach/regs-gpio.h>
d25168ea
KK
41
42#include <plat/regs-serial.h>
6f315cb5 43#include <plat/gpio-cfg.h>
d25168ea 44#include <plat/clock.h>
d25168ea
KK
45#include <plat/devs.h>
46#include <plat/cpu.h>
436d42c6 47#include <linux/platform_data/i2c-s3c2410.h>
d25168ea 48#include <plat/pll.h>
09cae8f1 49#include <plat/adc.h>
436d42c6 50#include <linux/platform_data/touchscreen-s3c2410.h>
c1fcd403 51#include <plat/samsung-time.h>
499d2969 52#include <plat/backlight.h>
1030e5c5 53#include <plat/fb.h>
6640790c 54#include <plat/sdhci.h>
d25168ea 55
95af214b 56#include "common.h"
102c3065 57#include "i2c.h"
95af214b 58
c8def085 59#define SMDK6440_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
d25168ea
KK
60 S3C2410_UCON_RXILEVEL | \
61 S3C2410_UCON_TXIRQMODE | \
62 S3C2410_UCON_RXIRQMODE | \
63 S3C2410_UCON_RXFIFO_TOI | \
64 S3C2443_UCON_RXERR_IRQEN)
65
c8def085 66#define SMDK6440_ULCON_DEFAULT S3C2410_LCON_CS8
d25168ea 67
c8def085 68#define SMDK6440_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
d25168ea
KK
69 S3C2440_UFCON_TXTRIG16 | \
70 S3C2410_UFCON_RXTRIG8)
71
72static struct s3c2410_uartcfg smdk6440_uartcfgs[] __initdata = {
73 [0] = {
6f315cb5
KK
74 .hwport = 0,
75 .flags = 0,
76 .ucon = SMDK6440_UCON_DEFAULT,
77 .ulcon = SMDK6440_ULCON_DEFAULT,
78 .ufcon = SMDK6440_UFCON_DEFAULT,
d25168ea
KK
79 },
80 [1] = {
6f315cb5
KK
81 .hwport = 1,
82 .flags = 0,
83 .ucon = SMDK6440_UCON_DEFAULT,
84 .ulcon = SMDK6440_ULCON_DEFAULT,
85 .ufcon = SMDK6440_UFCON_DEFAULT,
d25168ea
KK
86 },
87 [2] = {
6f315cb5
KK
88 .hwport = 2,
89 .flags = 0,
90 .ucon = SMDK6440_UCON_DEFAULT,
91 .ulcon = SMDK6440_ULCON_DEFAULT,
92 .ufcon = SMDK6440_UFCON_DEFAULT,
d25168ea
KK
93 },
94 [3] = {
6f315cb5
KK
95 .hwport = 3,
96 .flags = 0,
97 .ucon = SMDK6440_UCON_DEFAULT,
98 .ulcon = SMDK6440_ULCON_DEFAULT,
99 .ufcon = SMDK6440_UFCON_DEFAULT,
d25168ea
KK
100 },
101};
102
1030e5c5
AK
103/* Frame Buffer */
104static struct s3c_fb_pd_win smdk6440_fb_win0 = {
1030e5c5
AK
105 .max_bpp = 32,
106 .default_bpp = 24,
79d3c41a
TA
107 .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,
1030e5c5
AK
120};
121
122static struct s3c_fb_platdata smdk6440_lcd_pdata __initdata = {
123 .win[0] = &smdk6440_fb_win0,
79d3c41a 124 .vtiming = &smdk6440_lcd_timing,
1030e5c5
AK
125 .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
d25168ea 160static struct platform_device *smdk6440_devices[] __initdata = {
09cae8f1 161 &s3c_device_adc,
ff7124a3 162 &s3c_device_rtc,
2c97886d
NKC
163 &s3c_device_i2c0,
164 &s3c_device_i2c1,
09cae8f1 165 &s3c_device_ts,
a0cce455 166 &s3c_device_wdt,
6f315cb5 167 &s5p6440_device_iis,
1030e5c5
AK
168 &s3c_device_fb,
169 &smdk6440_lcd_lte480wv,
6640790c
RS
170 &s3c_device_hsmmc0,
171 &s3c_device_hsmmc1,
172 &s3c_device_hsmmc2,
173};
174
175static struct s3c_sdhci_platdata smdk6440_hsmmc0_pdata __initdata = {
176 .cd_type = S3C_SDHCI_CD_NONE,
177};
178
179static struct s3c_sdhci_platdata smdk6440_hsmmc1_pdata __initdata = {
180 .cd_type = S3C_SDHCI_CD_INTERNAL,
181#if defined(CONFIG_S5P64X0_SD_CH1_8BIT)
182 .max_width = 8,
183 .host_caps = MMC_CAP_8_BIT_DATA,
184#endif
185};
186
187static struct s3c_sdhci_platdata smdk6440_hsmmc2_pdata __initdata = {
188 .cd_type = S3C_SDHCI_CD_NONE,
6f315cb5
KK
189};
190
191static struct s3c2410_platform_i2c s5p6440_i2c0_data __initdata = {
192 .flags = 0,
193 .slave_addr = 0x10,
194 .frequency = 100*1000,
195 .sda_delay = 100,
196 .cfg_gpio = s5p6440_i2c0_cfg_gpio,
197};
198
199static struct s3c2410_platform_i2c s5p6440_i2c1_data __initdata = {
200 .flags = 0,
201 .bus_num = 1,
202 .slave_addr = 0x10,
203 .frequency = 100*1000,
204 .sda_delay = 100,
205 .cfg_gpio = s5p6440_i2c1_cfg_gpio,
09cae8f1
NKC
206};
207
2c97886d
NKC
208static struct i2c_board_info smdk6440_i2c_devs0[] __initdata = {
209 { I2C_BOARD_INFO("24c08", 0x50), },
149bb5bc 210 { I2C_BOARD_INFO("wm8580", 0x1b), },
2c97886d
NKC
211};
212
213static struct i2c_board_info smdk6440_i2c_devs1[] __initdata = {
214 /* To be populated */
215};
216
499d2969
BG
217/* LCD Backlight data */
218static struct samsung_bl_gpio_info smdk6440_bl_gpio_info = {
219 .no = S5P6440_GPF(15),
220 .func = S3C_GPIO_SFN(2),
221};
222
223static struct platform_pwm_backlight_data smdk6440_bl_data = {
224 .pwm_id = 1,
225};
226
d25168ea
KK
227static void __init smdk6440_map_io(void)
228{
95af214b 229 s5p64x0_init_io(NULL, 0);
d25168ea
KK
230 s3c24xx_init_clocks(12000000);
231 s3c24xx_init_uarts(smdk6440_uartcfgs, ARRAY_SIZE(smdk6440_uartcfgs));
c1fcd403 232 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
d25168ea
KK
233}
234
1030e5c5
AK
235static void s5p6440_set_lcd_interface(void)
236{
237 unsigned int cfg;
238
239 /* select TFT LCD type (RGB I/F) */
240 cfg = __raw_readl(S5P64X0_SPCON0);
241 cfg &= ~S5P64X0_SPCON0_LCD_SEL_MASK;
242 cfg |= S5P64X0_SPCON0_LCD_SEL_RGB;
243 __raw_writel(cfg, S5P64X0_SPCON0);
244}
245
d25168ea
KK
246static void __init smdk6440_machine_init(void)
247{
0804765a 248 s3c24xx_ts_set_platdata(NULL);
09cae8f1 249
6f315cb5
KK
250 s3c_i2c0_set_platdata(&s5p6440_i2c0_data);
251 s3c_i2c1_set_platdata(&s5p6440_i2c1_data);
2c97886d
NKC
252 i2c_register_board_info(0, smdk6440_i2c_devs0,
253 ARRAY_SIZE(smdk6440_i2c_devs0));
254 i2c_register_board_info(1, smdk6440_i2c_devs1,
255 ARRAY_SIZE(smdk6440_i2c_devs1));
256
499d2969
BG
257 samsung_bl_set(&smdk6440_bl_gpio_info, &smdk6440_bl_data);
258
1030e5c5
AK
259 s5p6440_set_lcd_interface();
260 s3c_fb_set_platdata(&smdk6440_lcd_pdata);
261
6640790c
RS
262 s3c_sdhci0_set_platdata(&smdk6440_hsmmc0_pdata);
263 s3c_sdhci1_set_platdata(&smdk6440_hsmmc1_pdata);
264 s3c_sdhci2_set_platdata(&smdk6440_hsmmc2_pdata);
265
d25168ea
KK
266 platform_add_devices(smdk6440_devices, ARRAY_SIZE(smdk6440_devices));
267}
268
269MACHINE_START(SMDK6440, "SMDK6440")
270 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
32bc8201 271 .atag_offset = 0x100,
d25168ea
KK
272
273 .init_irq = s5p6440_init_irq,
274 .map_io = smdk6440_map_io,
275 .init_machine = smdk6440_machine_init,
c1fcd403 276 .init_time = samsung_timer_init,
73aed8b9 277 .restart = s5p64x0_restart,
d25168ea 278MACHINE_END