blob: 774c982a7b7ed4260a49ca01d7d9714b188f65d4 [file] [log] [blame]
Kukjin Kim232910d2013-01-02 10:18:58 -08001/*
Vasily Khoruzhickc394f172010-05-11 09:55:07 +03002 * Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev,
3 * Copyright (c) 2007-2010 Vasily Khoruzhick
4 *
5 * based on smdk2440 written by Ben Dooks
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/list.h>
Russell King8d717a52010-05-22 19:47:18 +010017#include <linux/memblock.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030018#include <linux/delay.h>
19#include <linux/timer.h>
20#include <linux/init.h>
21#include <linux/gpio.h>
22#include <linux/platform_device.h>
23#include <linux/serial_core.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090024#include <linux/serial_s3c.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030025#include <linux/input.h>
26#include <linux/gpio_keys.h>
Kay Sieversedbaa602011-12-21 16:26:03 -080027#include <linux/device.h>
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +030028#include <linux/pda_power.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030029#include <linux/pwm_backlight.h>
30#include <linux/pwm.h>
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +030031#include <linux/s3c_adc_battery.h>
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +030032#include <linux/leds.h>
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +030033#include <linux/i2c.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030034
35#include <linux/mtd/mtd.h>
36#include <linux/mtd/partitions.h>
37
38#include <linux/mmc/host.h>
39
Kukjin Kim232910d2013-01-02 10:18:58 -080040#include <asm/mach-types.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030041#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030043
Arnd Bergmann436d42c2012-08-24 15:22:12 +020044#include <linux/platform_data/i2c-s3c2410.h>
Kukjin Kim232910d2013-01-02 10:18:58 -080045#include <linux/platform_data/mmc-s3cmci.h>
46#include <linux/platform_data/mtd-nand-s3c2410.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020047#include <linux/platform_data/touchscreen-s3c2410.h>
Kukjin Kim232910d2013-01-02 10:18:58 -080048#include <linux/platform_data/usb-s3c2410_udc.h>
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030049
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +030050#include <sound/uda1380.h>
51
Kukjin Kim232910d2013-01-02 10:18:58 -080052#include <mach/fb.h>
53#include <mach/regs-gpio.h>
54#include <mach/regs-lcd.h>
Linus Walleijb0161ca2014-01-14 14:24:24 +010055#include <mach/gpio-samsung.h>
Kukjin Kim232910d2013-01-02 10:18:58 -080056
Kukjin Kim232910d2013-01-02 10:18:58 -080057#include <plat/cpu.h>
58#include <plat/devs.h>
Kukjin Kim232910d2013-01-02 10:18:58 -080059#include <plat/pm.h>
Romain Naour7f78b6e2013-01-09 18:47:04 -080060#include <plat/samsung-time.h>
Linus Walleij36437412014-01-14 15:05:22 +010061#include <plat/gpio-cfg.h>
Kukjin Kim232910d2013-01-02 10:18:58 -080062
Kukjin Kimb27b0722012-01-03 14:02:03 +010063#include "common.h"
Kukjin Kim232910d2013-01-02 10:18:58 -080064#include "h1940.h"
Kukjin Kimb27b0722012-01-03 14:02:03 +010065
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030066#define LCD_PWM_PERIOD 192960
67#define LCD_PWM_DUTY 127353
68
69static struct map_desc rx1950_iodesc[] __initdata = {
70};
71
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030072static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
73 [0] = {
74 .hwport = 0,
75 .flags = 0,
76 .ucon = 0x3c5,
77 .ulcon = 0x03,
78 .ufcon = 0x51,
Thomas Abrahamafba7f92011-10-24 11:47:51 +020079 .clk_sel = S3C2410_UCON_CLKSEL3,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030080 },
81 [1] = {
82 .hwport = 1,
83 .flags = 0,
84 .ucon = 0x3c5,
85 .ulcon = 0x03,
86 .ufcon = 0x51,
Thomas Abrahamafba7f92011-10-24 11:47:51 +020087 .clk_sel = S3C2410_UCON_CLKSEL3,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030088 },
89 /* IR port */
90 [2] = {
91 .hwport = 2,
92 .flags = 0,
93 .ucon = 0x3c5,
94 .ulcon = 0x43,
95 .ufcon = 0xf1,
Thomas Abrahamafba7f92011-10-24 11:47:51 +020096 .clk_sel = S3C2410_UCON_CLKSEL3,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +030097 },
98};
99
100static struct s3c2410fb_display rx1950_display = {
101 .type = S3C2410_LCDCON1_TFT,
102 .width = 240,
103 .height = 320,
104 .xres = 240,
105 .yres = 320,
106 .bpp = 16,
107
108 .pixclock = 260000,
109 .left_margin = 10,
110 .right_margin = 20,
111 .hsync_len = 10,
112 .upper_margin = 2,
113 .lower_margin = 2,
114 .vsync_len = 2,
115
116 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
117 S3C2410_LCDCON5_INVVCLK |
118 S3C2410_LCDCON5_INVVLINE |
119 S3C2410_LCDCON5_INVVFRAME |
120 S3C2410_LCDCON5_HWSWP |
121 (0x02 << 13) |
122 (0x02 << 15),
123
124};
125
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300126static int power_supply_init(struct device *dev)
127{
128 return gpio_request(S3C2410_GPF(2), "cable plugged");
129}
130
131static int rx1950_is_ac_online(void)
132{
133 return !gpio_get_value(S3C2410_GPF(2));
134}
135
136static void power_supply_exit(struct device *dev)
137{
138 gpio_free(S3C2410_GPF(2));
139}
140
141static char *rx1950_supplicants[] = {
142 "main-battery"
143};
144
145static struct pda_power_pdata power_supply_info = {
146 .init = power_supply_init,
147 .is_ac_online = rx1950_is_ac_online,
148 .exit = power_supply_exit,
149 .supplied_to = rx1950_supplicants,
150 .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
151};
152
153static struct resource power_supply_resources[] = {
Tushar Behera5f3b90d2012-05-12 16:12:25 +0900154 [0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
155 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300156};
157
158static struct platform_device power_supply = {
159 .name = "pda-power",
160 .id = -1,
161 .dev = {
162 .platform_data =
163 &power_supply_info,
164 },
165 .resource = power_supply_resources,
166 .num_resources = ARRAY_SIZE(power_supply_resources),
167};
168
169static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
170 { .volt = 4100, .cur = 156, .level = 100},
171 { .volt = 4050, .cur = 156, .level = 95},
172 { .volt = 4025, .cur = 141, .level = 90},
173 { .volt = 3995, .cur = 144, .level = 85},
174 { .volt = 3957, .cur = 162, .level = 80},
175 { .volt = 3931, .cur = 147, .level = 75},
176 { .volt = 3902, .cur = 147, .level = 70},
177 { .volt = 3863, .cur = 153, .level = 65},
178 { .volt = 3838, .cur = 150, .level = 60},
179 { .volt = 3800, .cur = 153, .level = 55},
180 { .volt = 3765, .cur = 153, .level = 50},
181 { .volt = 3748, .cur = 172, .level = 45},
182 { .volt = 3740, .cur = 153, .level = 40},
183 { .volt = 3714, .cur = 175, .level = 35},
184 { .volt = 3710, .cur = 156, .level = 30},
185 { .volt = 3963, .cur = 156, .level = 25},
186 { .volt = 3672, .cur = 178, .level = 20},
187 { .volt = 3651, .cur = 178, .level = 15},
188 { .volt = 3629, .cur = 178, .level = 10},
189 { .volt = 3612, .cur = 162, .level = 5},
190 { .volt = 3605, .cur = 162, .level = 0},
191};
192
193static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
194 { .volt = 4200, .cur = 0, .level = 100},
195 { .volt = 4190, .cur = 0, .level = 99},
196 { .volt = 4178, .cur = 0, .level = 95},
197 { .volt = 4110, .cur = 0, .level = 70},
198 { .volt = 4076, .cur = 0, .level = 65},
199 { .volt = 4046, .cur = 0, .level = 60},
200 { .volt = 4021, .cur = 0, .level = 55},
201 { .volt = 3999, .cur = 0, .level = 50},
202 { .volt = 3982, .cur = 0, .level = 45},
203 { .volt = 3965, .cur = 0, .level = 40},
204 { .volt = 3957, .cur = 0, .level = 35},
205 { .volt = 3948, .cur = 0, .level = 30},
206 { .volt = 3936, .cur = 0, .level = 25},
207 { .volt = 3927, .cur = 0, .level = 20},
208 { .volt = 3906, .cur = 0, .level = 15},
209 { .volt = 3880, .cur = 0, .level = 10},
210 { .volt = 3829, .cur = 0, .level = 5},
211 { .volt = 3820, .cur = 0, .level = 0},
212};
213
Kukjin Kim4cfb7b72012-01-21 11:46:41 +0900214static int rx1950_bat_init(void)
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300215{
216 int ret;
217
218 ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
219 if (ret)
220 goto err_gpio1;
221 ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
222 if (ret)
223 goto err_gpio2;
224
225 return 0;
226
227err_gpio2:
228 gpio_free(S3C2410_GPJ(2));
229err_gpio1:
230 return ret;
231}
232
Kukjin Kim4cfb7b72012-01-21 11:46:41 +0900233static void rx1950_bat_exit(void)
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300234{
235 gpio_free(S3C2410_GPJ(2));
236 gpio_free(S3C2410_GPJ(3));
237}
238
Kukjin Kim4cfb7b72012-01-21 11:46:41 +0900239static void rx1950_enable_charger(void)
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300240{
241 gpio_direction_output(S3C2410_GPJ(2), 1);
242 gpio_direction_output(S3C2410_GPJ(3), 1);
243}
244
Kukjin Kim4cfb7b72012-01-21 11:46:41 +0900245static void rx1950_disable_charger(void)
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300246{
247 gpio_direction_output(S3C2410_GPJ(2), 0);
248 gpio_direction_output(S3C2410_GPJ(3), 0);
249}
250
Kukjin Kim4cfb7b72012-01-21 11:46:41 +0900251static DEFINE_SPINLOCK(rx1950_blink_spin);
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200252
Mika Westerbergc673a2b2014-10-31 13:40:58 +0200253static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200254 unsigned long *delay_on, unsigned long *delay_off)
255{
Mika Westerbergc673a2b2014-10-31 13:40:58 +0200256 int gpio = desc_to_gpio(desc);
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200257 int blink_gpio, check_gpio;
258
259 switch (gpio) {
260 case S3C2410_GPA(6):
261 blink_gpio = S3C2410_GPA(4);
262 check_gpio = S3C2410_GPA(3);
263 break;
264 case S3C2410_GPA(7):
265 blink_gpio = S3C2410_GPA(3);
266 check_gpio = S3C2410_GPA(4);
267 break;
268 default:
269 return -EINVAL;
270 break;
271 }
272
273 if (delay_on && delay_off && !*delay_on && !*delay_off)
274 *delay_on = *delay_off = 500;
275
276 spin_lock(&rx1950_blink_spin);
277
278 switch (state) {
279 case GPIO_LED_NO_BLINK_LOW:
280 case GPIO_LED_NO_BLINK_HIGH:
281 if (!gpio_get_value(check_gpio))
282 gpio_set_value(S3C2410_GPJ(6), 0);
283 gpio_set_value(blink_gpio, 0);
284 gpio_set_value(gpio, state);
285 break;
286 case GPIO_LED_BLINK:
287 gpio_set_value(gpio, 0);
288 gpio_set_value(S3C2410_GPJ(6), 1);
289 gpio_set_value(blink_gpio, 1);
290 break;
291 }
292
293 spin_unlock(&rx1950_blink_spin);
294
295 return 0;
296}
297
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300298static struct gpio_led rx1950_leds_desc[] = {
299 {
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200300 .name = "Green",
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300301 .default_trigger = "main-battery-full",
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200302 .gpio = S3C2410_GPA(6),
303 .retain_state_suspended = 1,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300304 },
305 {
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200306 .name = "Red",
307 .default_trigger
308 = "main-battery-charging-blink-full-solid",
309 .gpio = S3C2410_GPA(7),
310 .retain_state_suspended = 1,
311 },
312 {
313 .name = "Blue",
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300314 .default_trigger = "rx1950-acx-mem",
Vasily Khoruzhick9edb2402011-03-17 20:04:57 +0200315 .gpio = S3C2410_GPA(11),
316 .retain_state_suspended = 1,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300317 },
318};
319
320static struct gpio_led_platform_data rx1950_leds_pdata = {
321 .num_leds = ARRAY_SIZE(rx1950_leds_desc),
322 .leds = rx1950_leds_desc,
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200323 .gpio_blink_set = rx1950_led_blink_set,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300324};
325
326static struct platform_device rx1950_leds = {
327 .name = "leds-gpio",
328 .id = -1,
329 .dev = {
330 .platform_data = &rx1950_leds_pdata,
331 },
332};
333
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300334static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
335 .init = rx1950_bat_init,
336 .exit = rx1950_bat_exit,
337 .enable_charger = rx1950_enable_charger,
338 .disable_charger = rx1950_disable_charger,
339 .gpio_charge_finished = S3C2410_GPF(3),
340 .lut_noac = bat_lut_noac,
341 .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
342 .lut_acin = bat_lut_acin,
343 .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
344 .volt_channel = 0,
345 .current_channel = 1,
346 .volt_mult = 4235,
347 .current_mult = 2900,
348 .internal_impedance = 200,
349};
350
351static struct platform_device rx1950_battery = {
352 .name = "s3c-adc-battery",
353 .id = -1,
354 .dev = {
355 .parent = &s3c_device_adc.dev,
356 .platform_data = &rx1950_bat_cfg,
357 },
358};
359
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300360static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
361 .displays = &rx1950_display,
362 .num_displays = 1,
363 .default_display = 0,
364
365 .lpcsel = 0x02,
366 .gpccon = 0xaa9556a9,
367 .gpccon_mask = 0xffc003fc,
368 .gpcup = 0x0000ffff,
369 .gpcup_mask = 0xffffffff,
370
371 .gpdcon = 0xaa90aaa1,
372 .gpdcon_mask = 0xffc0fff0,
373 .gpdup = 0x0000fcfd,
374 .gpdup_mask = 0xffffffff,
375
376};
377
Thierry Redingc107fe92015-10-13 05:04:22 +0900378static struct pwm_lookup rx1950_pwm_lookup[] = {
379 PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
380 PWM_POLARITY_NORMAL),
381};
382
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300383static struct pwm_device *lcd_pwm;
384
Kukjin Kim4cfb7b72012-01-21 11:46:41 +0900385static void rx1950_lcd_power(int enable)
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300386{
387 int i;
388 static int enabled;
389 if (enabled == enable)
390 return;
391 if (!enable) {
392
393 /* GPC11-GPC15->OUTPUT */
394 for (i = 11; i < 16; i++)
395 gpio_direction_output(S3C2410_GPC(i), 1);
396
397 /* Wait a bit here... */
398 mdelay(100);
399
400 /* GPD2-GPD7->OUTPUT */
401 /* GPD11-GPD15->OUTPUT */
402 /* GPD2-GPD7->1, GPD11-GPD15->1 */
403 for (i = 2; i < 8; i++)
404 gpio_direction_output(S3C2410_GPD(i), 1);
405 for (i = 11; i < 16; i++)
406 gpio_direction_output(S3C2410_GPD(i), 1);
407
408 /* Wait a bit here...*/
409 mdelay(100);
410
411 /* GPB0->OUTPUT, GPB0->0 */
412 gpio_direction_output(S3C2410_GPB(0), 0);
413
414 /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
415 for (i = 1; i < 5; i++)
416 gpio_direction_output(S3C2410_GPC(i), 0);
417
418 /* GPC15-GPC11->0 */
419 for (i = 11; i < 16; i++)
420 gpio_direction_output(S3C2410_GPC(i), 0);
421
422 /* GPD15-GPD11->0, GPD2->GPD7->0 */
423 for (i = 11; i < 16; i++)
424 gpio_direction_output(S3C2410_GPD(i), 0);
425
426 for (i = 2; i < 8; i++)
427 gpio_direction_output(S3C2410_GPD(i), 0);
428
429 /* GPC6->0, GPC7->0, GPC5->0 */
430 gpio_direction_output(S3C2410_GPC(6), 0);
431 gpio_direction_output(S3C2410_GPC(7), 0);
432 gpio_direction_output(S3C2410_GPC(5), 0);
433
434 /* GPB1->OUTPUT, GPB1->0 */
435 gpio_direction_output(S3C2410_GPB(1), 0);
436 pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
437 pwm_disable(lcd_pwm);
438
439 /* GPC0->0, GPC10->0 */
440 gpio_direction_output(S3C2410_GPC(0), 0);
441 gpio_direction_output(S3C2410_GPC(10), 0);
442 } else {
443 pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
444 pwm_enable(lcd_pwm);
445
446 gpio_direction_output(S3C2410_GPC(0), 1);
447 gpio_direction_output(S3C2410_GPC(5), 1);
448
449 s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
450 gpio_direction_output(S3C2410_GPC(7), 1);
451
452 for (i = 1; i < 5; i++)
453 s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
454
455 for (i = 11; i < 16; i++)
456 s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
457
458 for (i = 2; i < 8; i++)
459 s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
460
461 for (i = 11; i < 16; i++)
462 s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
463
464 gpio_direction_output(S3C2410_GPC(10), 1);
465 gpio_direction_output(S3C2410_GPC(6), 1);
466 }
467 enabled = enable;
468}
469
470static void rx1950_bl_power(int enable)
471{
472 static int enabled;
473 if (enabled == enable)
474 return;
475 if (!enable) {
476 gpio_direction_output(S3C2410_GPB(0), 0);
477 } else {
478 /* LED driver need a "push" to power on */
479 gpio_direction_output(S3C2410_GPB(0), 1);
480 /* Warm up backlight for one period of PWM.
481 * Without this trick its almost impossible to
482 * enable backlight with low brightness value
483 */
484 ndelay(48000);
485 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
486 }
487 enabled = enable;
488}
489
490static int rx1950_backlight_init(struct device *dev)
491{
492 WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
493 lcd_pwm = pwm_request(1, "RX1950 LCD");
494 if (IS_ERR(lcd_pwm)) {
495 dev_err(dev, "Unable to request PWM for LCD power!\n");
496 return PTR_ERR(lcd_pwm);
497 }
498
499 rx1950_lcd_power(1);
500 rx1950_bl_power(1);
501
502 return 0;
503}
504
505static void rx1950_backlight_exit(struct device *dev)
506{
507 rx1950_bl_power(0);
508 rx1950_lcd_power(0);
509
510 pwm_free(lcd_pwm);
511 gpio_free(S3C2410_GPB(0));
512}
513
514
515static int rx1950_backlight_notify(struct device *dev, int brightness)
516{
517 if (!brightness) {
518 rx1950_bl_power(0);
519 rx1950_lcd_power(0);
520 } else {
521 rx1950_lcd_power(1);
522 rx1950_bl_power(1);
523 }
524 return brightness;
525}
526
527static struct platform_pwm_backlight_data rx1950_backlight_data = {
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300528 .max_brightness = 24,
529 .dft_brightness = 4,
Thierry Redinga63652f2013-08-30 12:19:52 +0200530 .enable_gpio = -1,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300531 .init = rx1950_backlight_init,
532 .notify = rx1950_backlight_notify,
533 .exit = rx1950_backlight_exit,
534};
535
536static struct platform_device rx1950_backlight = {
537 .name = "pwm-backlight",
538 .dev = {
Tomasz Figa7fa33bd2013-03-09 15:37:53 +0100539 .parent = &samsung_device_pwm.dev,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300540 .platform_data = &rx1950_backlight_data,
541 },
542};
543
544static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
545{
546 switch (power_mode) {
547 case MMC_POWER_OFF:
548 gpio_direction_output(S3C2410_GPJ(1), 0);
549 break;
550 case MMC_POWER_UP:
551 case MMC_POWER_ON:
552 gpio_direction_output(S3C2410_GPJ(1), 1);
553 break;
554 default:
555 break;
556 }
557}
558
559static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
560 .gpio_detect = S3C2410_GPF(5),
561 .gpio_wprotect = S3C2410_GPH(8),
562 .set_power = rx1950_set_mmc_power,
563 .ocr_avail = MMC_VDD_32_33,
564};
565
566static struct mtd_partition rx1950_nand_part[] = {
567 [0] = {
568 .name = "Boot0",
569 .offset = 0,
570 .size = 0x4000,
571 .mask_flags = MTD_WRITEABLE,
572 },
573 [1] = {
574 .name = "Boot1",
575 .offset = MTDPART_OFS_APPEND,
576 .size = 0x40000,
577 .mask_flags = MTD_WRITEABLE,
578 },
579 [2] = {
580 .name = "Kernel",
581 .offset = MTDPART_OFS_APPEND,
582 .size = 0x300000,
583 .mask_flags = 0,
584 },
585 [3] = {
586 .name = "Filesystem",
587 .offset = MTDPART_OFS_APPEND,
588 .size = MTDPART_SIZ_FULL,
589 .mask_flags = 0,
590 },
591};
592
593static struct s3c2410_nand_set rx1950_nand_sets[] = {
594 [0] = {
595 .name = "Internal",
596 .nr_chips = 1,
597 .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
598 .partitions = rx1950_nand_part,
599 },
600};
601
602static struct s3c2410_platform_nand rx1950_nand_info = {
603 .tacls = 25,
604 .twrph0 = 50,
605 .twrph1 = 15,
606 .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
607 .sets = rx1950_nand_sets,
608};
609
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300610static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300611 .vbus_pin = S3C2410_GPG(5),
612 .vbus_pin_inverted = 1,
Lars-Peter Clausene27c3c52011-03-07 08:42:00 +0100613 .pullup_pin = S3C2410_GPJ(5),
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300614};
615
616static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
617 .delay = 10000,
618 .presc = 49,
619 .oversampling_shift = 3,
620};
621
622static struct gpio_keys_button rx1950_gpio_keys_table[] = {
623 {
624 .code = KEY_POWER,
625 .gpio = S3C2410_GPF(0),
626 .active_low = 1,
627 .desc = "Power button",
628 .wakeup = 1,
629 },
630 {
631 .code = KEY_F5,
632 .gpio = S3C2410_GPF(7),
633 .active_low = 1,
634 .desc = "Record button",
635 },
636 {
637 .code = KEY_F1,
638 .gpio = S3C2410_GPG(0),
639 .active_low = 1,
640 .desc = "Calendar button",
641 },
642 {
643 .code = KEY_F2,
644 .gpio = S3C2410_GPG(2),
645 .active_low = 1,
646 .desc = "Contacts button",
647 },
648 {
649 .code = KEY_F3,
650 .gpio = S3C2410_GPG(3),
651 .active_low = 1,
652 .desc = "Mail button",
653 },
654 {
655 .code = KEY_F4,
656 .gpio = S3C2410_GPG(7),
657 .active_low = 1,
658 .desc = "WLAN button",
659 },
660 {
661 .code = KEY_LEFT,
662 .gpio = S3C2410_GPG(10),
663 .active_low = 1,
664 .desc = "Left button",
665 },
666 {
667 .code = KEY_RIGHT,
668 .gpio = S3C2410_GPG(11),
669 .active_low = 1,
670 .desc = "Right button",
671 },
672 {
673 .code = KEY_UP,
674 .gpio = S3C2410_GPG(4),
675 .active_low = 1,
676 .desc = "Up button",
677 },
678 {
679 .code = KEY_DOWN,
680 .gpio = S3C2410_GPG(6),
681 .active_low = 1,
682 .desc = "Down button",
683 },
684 {
685 .code = KEY_ENTER,
686 .gpio = S3C2410_GPG(9),
687 .active_low = 1,
688 .desc = "Ok button"
689 },
690};
691
692static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
693 .buttons = rx1950_gpio_keys_table,
694 .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
695};
696
697static struct platform_device rx1950_device_gpiokeys = {
698 .name = "gpio-keys",
699 .dev.platform_data = &rx1950_gpio_keys_data,
700};
701
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +0300702static struct uda1380_platform_data uda1380_info = {
703 .gpio_power = S3C2410_GPJ(0),
704 .gpio_reset = S3C2410_GPD(0),
705 .dac_clk = UDA1380_DAC_CLK_SYSCLK,
706};
707
708static struct i2c_board_info rx1950_i2c_devices[] = {
709 {
710 I2C_BOARD_INFO("uda1380", 0x1a),
711 .platform_data = &uda1380_info,
712 },
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300713};
714
715static struct platform_device *rx1950_devices[] __initdata = {
Heiko Stuebner51cb1282014-05-09 05:48:57 +0900716 &s3c2410_device_dclk,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300717 &s3c_device_lcd,
718 &s3c_device_wdt,
719 &s3c_device_i2c0,
720 &s3c_device_iis,
721 &s3c_device_usbgadget,
722 &s3c_device_rtc,
723 &s3c_device_nand,
724 &s3c_device_sdi,
725 &s3c_device_adc,
726 &s3c_device_ts,
Tomasz Figa7fa33bd2013-03-09 15:37:53 +0100727 &samsung_device_pwm,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300728 &rx1950_backlight,
729 &rx1950_device_gpiokeys,
Vasily Khoruzhickecab01d2010-09-27 00:17:48 +0300730 &power_supply,
731 &rx1950_battery,
Vasily Khoruzhick9c1a47c2010-09-07 17:32:25 +0300732 &rx1950_leds,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300733};
734
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300735static void __init rx1950_map_io(void)
736{
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300737 s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300738 s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
Romain Naour7f78b6e2013-01-09 18:47:04 -0800739 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300740
741 /* setup PM */
742
743#ifdef CONFIG_PM_H1940
744 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
745#endif
746
747 s3c_pm_init();
748}
749
Heiko Stuebnera28d6182014-05-09 05:49:19 +0900750static void __init rx1950_init_time(void)
751{
752 s3c2442_init_clocks(16934000);
753 samsung_timer_init();
754}
755
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300756static void __init rx1950_init_machine(void)
757{
758 int i;
759
760 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
761 s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
762 s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
763 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +0300764 s3c_i2c0_set_platdata(NULL);
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300765 s3c_nand_set_platdata(&rx1950_nand_info);
766
767 /* Turn off suspend on both USB ports, and switch the
768 * selectable USB port to USB device mode. */
769 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
770 S3C2410_MISCCR_USBSUSPND0 |
771 S3C2410_MISCCR_USBSUSPND1, 0x0);
772
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300773 /* mmc power is disabled by default */
774 WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
775 gpio_direction_output(S3C2410_GPJ(1), 0);
776
777 for (i = 0; i < 8; i++)
778 WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
779
780 for (i = 10; i < 16; i++)
781 WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
782
783 for (i = 2; i < 8; i++)
784 WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
785
786 for (i = 11; i < 16; i++)
787 WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
788
789 WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
790
Vasily Khoruzhick62235dc2011-01-06 21:52:52 +0200791 WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
792 WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
793 WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
794 gpio_direction_output(S3C2410_GPA(3), 0);
795 gpio_direction_output(S3C2410_GPA(4), 0);
796 gpio_direction_output(S3C2410_GPJ(6), 0);
797
Thierry Redingc107fe92015-10-13 05:04:22 +0900798 pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup));
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300799 platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
Vasily Khoruzhick2cc857f2010-09-07 17:32:26 +0300800
801 i2c_register_board_info(0, rx1950_i2c_devices,
802 ARRAY_SIZE(rx1950_i2c_devices));
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300803}
804
Russell King98c672c2010-05-22 18:18:57 +0100805/* H1940 and RX3715 need to reserve this for suspend */
806static void __init rx1950_reserve(void)
807{
Russell King8d717a52010-05-22 19:47:18 +0100808 memblock_reserve(0x30003000, 0x1000);
809 memblock_reserve(0x30081000, 0x1000);
Russell King98c672c2010-05-22 18:18:57 +0100810}
811
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300812MACHINE_START(RX1950, "HP iPAQ RX1950")
813 /* Maintainers: Vasily Khoruzhick */
Nicolas Pitre69d50712011-07-05 22:38:17 -0400814 .atag_offset = 0x100,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300815 .map_io = rx1950_map_io,
Russell King98c672c2010-05-22 18:18:57 +0100816 .reserve = rx1950_reserve,
Heiko Stuebnerce6c1642013-02-12 09:59:20 -0800817 .init_irq = s3c2442_init_irq,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300818 .init_machine = rx1950_init_machine,
Heiko Stuebnera28d6182014-05-09 05:49:19 +0900819 .init_time = rx1950_init_time,
Vasily Khoruzhickc394f172010-05-11 09:55:07 +0300820MACHINE_END