• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev,
4 // Copyright (c) 2007-2010 Vasily Khoruzhick
5 //
6 // based on smdk2440 written by Ben Dooks
7 
8 #include <linux/kernel.h>
9 #include <linux/types.h>
10 #include <linux/interrupt.h>
11 #include <linux/list.h>
12 #include <linux/memblock.h>
13 #include <linux/delay.h>
14 #include <linux/timer.h>
15 #include <linux/init.h>
16 #include <linux/gpio.h>
17 #include <linux/gpio/machine.h>
18 #include <linux/platform_device.h>
19 #include <linux/serial_core.h>
20 #include <linux/serial_s3c.h>
21 #include <linux/input.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/device.h>
24 #include <linux/pda_power.h>
25 #include <linux/pwm_backlight.h>
26 #include <linux/pwm.h>
27 #include <linux/s3c_adc_battery.h>
28 #include <linux/leds.h>
29 #include <linux/i2c.h>
30 
31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/partitions.h>
33 
34 #include <linux/mmc/host.h>
35 
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
39 
40 #include <linux/platform_data/i2c-s3c2410.h>
41 #include <linux/platform_data/mmc-s3cmci.h>
42 #include <linux/platform_data/mtd-nand-s3c2410.h>
43 #include <linux/platform_data/touchscreen-s3c2410.h>
44 #include <linux/platform_data/usb-s3c2410_udc.h>
45 #include <linux/platform_data/fb-s3c2410.h>
46 
47 #include <sound/uda1380.h>
48 
49 #include "hardware-s3c24xx.h"
50 #include "regs-gpio.h"
51 #include "gpio-samsung.h"
52 
53 #include "cpu.h"
54 #include "devs.h"
55 #include "pm.h"
56 #include "gpio-cfg.h"
57 
58 #include "s3c24xx.h"
59 #include "h1940.h"
60 
61 #define LCD_PWM_PERIOD 192960
62 #define LCD_PWM_DUTY 127353
63 
64 static struct map_desc rx1950_iodesc[] __initdata = {
65 };
66 
67 static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
68 	[0] = {
69 	       .hwport = 0,
70 	       .flags = 0,
71 	       .ucon = 0x3c5,
72 	       .ulcon = 0x03,
73 	       .ufcon = 0x51,
74 		.clk_sel = S3C2410_UCON_CLKSEL3,
75 	},
76 	[1] = {
77 	       .hwport = 1,
78 	       .flags = 0,
79 	       .ucon = 0x3c5,
80 	       .ulcon = 0x03,
81 	       .ufcon = 0x51,
82 		.clk_sel = S3C2410_UCON_CLKSEL3,
83 	},
84 	/* IR port */
85 	[2] = {
86 	       .hwport = 2,
87 	       .flags = 0,
88 	       .ucon = 0x3c5,
89 	       .ulcon = 0x43,
90 	       .ufcon = 0xf1,
91 		.clk_sel = S3C2410_UCON_CLKSEL3,
92 	},
93 };
94 
95 static struct s3c2410fb_display rx1950_display = {
96 	.type = S3C2410_LCDCON1_TFT,
97 	.width = 240,
98 	.height = 320,
99 	.xres = 240,
100 	.yres = 320,
101 	.bpp = 16,
102 
103 	.pixclock = 260000,
104 	.left_margin = 10,
105 	.right_margin = 20,
106 	.hsync_len = 10,
107 	.upper_margin = 2,
108 	.lower_margin = 2,
109 	.vsync_len = 2,
110 
111 	.lcdcon5 = S3C2410_LCDCON5_FRM565 |
112 			   S3C2410_LCDCON5_INVVCLK |
113 			   S3C2410_LCDCON5_INVVLINE |
114 			   S3C2410_LCDCON5_INVVFRAME |
115 			   S3C2410_LCDCON5_HWSWP |
116 			   (0x02 << 13) |
117 			   (0x02 << 15),
118 
119 };
120 
power_supply_init(struct device * dev)121 static int power_supply_init(struct device *dev)
122 {
123 	return gpio_request(S3C2410_GPF(2), "cable plugged");
124 }
125 
rx1950_is_ac_online(void)126 static int rx1950_is_ac_online(void)
127 {
128 	return !gpio_get_value(S3C2410_GPF(2));
129 }
130 
power_supply_exit(struct device * dev)131 static void power_supply_exit(struct device *dev)
132 {
133 	gpio_free(S3C2410_GPF(2));
134 }
135 
136 static char *rx1950_supplicants[] = {
137 	"main-battery"
138 };
139 
140 static struct pda_power_pdata power_supply_info = {
141 	.init			= power_supply_init,
142 	.is_ac_online		= rx1950_is_ac_online,
143 	.exit			= power_supply_exit,
144 	.supplied_to		= rx1950_supplicants,
145 	.num_supplicants	= ARRAY_SIZE(rx1950_supplicants),
146 };
147 
148 static struct resource power_supply_resources[] = {
149 	[0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
150 			| IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
151 };
152 
153 static struct platform_device power_supply = {
154 	.name			= "pda-power",
155 	.id			= -1,
156 	.dev			= {
157 					.platform_data =
158 						&power_supply_info,
159 	},
160 	.resource		= power_supply_resources,
161 	.num_resources		= ARRAY_SIZE(power_supply_resources),
162 };
163 
164 static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
165 	{ .volt = 4100, .cur = 156, .level = 100},
166 	{ .volt = 4050, .cur = 156, .level = 95},
167 	{ .volt = 4025, .cur = 141, .level = 90},
168 	{ .volt = 3995, .cur = 144, .level = 85},
169 	{ .volt = 3957, .cur = 162, .level = 80},
170 	{ .volt = 3931, .cur = 147, .level = 75},
171 	{ .volt = 3902, .cur = 147, .level = 70},
172 	{ .volt = 3863, .cur = 153, .level = 65},
173 	{ .volt = 3838, .cur = 150, .level = 60},
174 	{ .volt = 3800, .cur = 153, .level = 55},
175 	{ .volt = 3765, .cur = 153, .level = 50},
176 	{ .volt = 3748, .cur = 172, .level = 45},
177 	{ .volt = 3740, .cur = 153, .level = 40},
178 	{ .volt = 3714, .cur = 175, .level = 35},
179 	{ .volt = 3710, .cur = 156, .level = 30},
180 	{ .volt = 3963, .cur = 156, .level = 25},
181 	{ .volt = 3672, .cur = 178, .level = 20},
182 	{ .volt = 3651, .cur = 178, .level = 15},
183 	{ .volt = 3629, .cur = 178, .level = 10},
184 	{ .volt = 3612, .cur = 162, .level = 5},
185 	{ .volt = 3605, .cur = 162, .level = 0},
186 };
187 
188 static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
189 	{ .volt = 4200, .cur = 0, .level = 100},
190 	{ .volt = 4190, .cur = 0, .level = 99},
191 	{ .volt = 4178, .cur = 0, .level = 95},
192 	{ .volt = 4110, .cur = 0, .level = 70},
193 	{ .volt = 4076, .cur = 0, .level = 65},
194 	{ .volt = 4046, .cur = 0, .level = 60},
195 	{ .volt = 4021, .cur = 0, .level = 55},
196 	{ .volt = 3999, .cur = 0, .level = 50},
197 	{ .volt = 3982, .cur = 0, .level = 45},
198 	{ .volt = 3965, .cur = 0, .level = 40},
199 	{ .volt = 3957, .cur = 0, .level = 35},
200 	{ .volt = 3948, .cur = 0, .level = 30},
201 	{ .volt = 3936, .cur = 0, .level = 25},
202 	{ .volt = 3927, .cur = 0, .level = 20},
203 	{ .volt = 3906, .cur = 0, .level = 15},
204 	{ .volt = 3880, .cur = 0, .level = 10},
205 	{ .volt = 3829, .cur = 0, .level = 5},
206 	{ .volt = 3820, .cur = 0, .level = 0},
207 };
208 
rx1950_bat_init(void)209 static int rx1950_bat_init(void)
210 {
211 	int ret;
212 
213 	ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
214 	if (ret)
215 		goto err_gpio1;
216 	ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
217 	if (ret)
218 		goto err_gpio2;
219 
220 	return 0;
221 
222 err_gpio2:
223 	gpio_free(S3C2410_GPJ(2));
224 err_gpio1:
225 	return ret;
226 }
227 
rx1950_bat_exit(void)228 static void rx1950_bat_exit(void)
229 {
230 	gpio_free(S3C2410_GPJ(2));
231 	gpio_free(S3C2410_GPJ(3));
232 }
233 
rx1950_enable_charger(void)234 static void rx1950_enable_charger(void)
235 {
236 	gpio_direction_output(S3C2410_GPJ(2), 1);
237 	gpio_direction_output(S3C2410_GPJ(3), 1);
238 }
239 
rx1950_disable_charger(void)240 static void rx1950_disable_charger(void)
241 {
242 	gpio_direction_output(S3C2410_GPJ(2), 0);
243 	gpio_direction_output(S3C2410_GPJ(3), 0);
244 }
245 
246 static DEFINE_SPINLOCK(rx1950_blink_spin);
247 
rx1950_led_blink_set(struct gpio_desc * desc,int state,unsigned long * delay_on,unsigned long * delay_off)248 static int rx1950_led_blink_set(struct gpio_desc *desc, int state,
249 	unsigned long *delay_on, unsigned long *delay_off)
250 {
251 	int gpio = desc_to_gpio(desc);
252 	int blink_gpio, check_gpio;
253 
254 	switch (gpio) {
255 	case S3C2410_GPA(6):
256 		blink_gpio = S3C2410_GPA(4);
257 		check_gpio = S3C2410_GPA(3);
258 		break;
259 	case S3C2410_GPA(7):
260 		blink_gpio = S3C2410_GPA(3);
261 		check_gpio = S3C2410_GPA(4);
262 		break;
263 	default:
264 		return -EINVAL;
265 		break;
266 	}
267 
268 	if (delay_on && delay_off && !*delay_on && !*delay_off)
269 		*delay_on = *delay_off = 500;
270 
271 	spin_lock(&rx1950_blink_spin);
272 
273 	switch (state) {
274 	case GPIO_LED_NO_BLINK_LOW:
275 	case GPIO_LED_NO_BLINK_HIGH:
276 		if (!gpio_get_value(check_gpio))
277 			gpio_set_value(S3C2410_GPJ(6), 0);
278 		gpio_set_value(blink_gpio, 0);
279 		gpio_set_value(gpio, state);
280 		break;
281 	case GPIO_LED_BLINK:
282 		gpio_set_value(gpio, 0);
283 		gpio_set_value(S3C2410_GPJ(6), 1);
284 		gpio_set_value(blink_gpio, 1);
285 		break;
286 	}
287 
288 	spin_unlock(&rx1950_blink_spin);
289 
290 	return 0;
291 }
292 
293 static struct gpio_led rx1950_leds_desc[] = {
294 	{
295 		.name			= "Green",
296 		.default_trigger	= "main-battery-full",
297 		.gpio			= S3C2410_GPA(6),
298 		.retain_state_suspended	= 1,
299 	},
300 	{
301 		.name			= "Red",
302 		.default_trigger
303 			= "main-battery-charging-blink-full-solid",
304 		.gpio			= S3C2410_GPA(7),
305 		.retain_state_suspended	= 1,
306 	},
307 	{
308 		.name			= "Blue",
309 		.default_trigger	= "rx1950-acx-mem",
310 		.gpio			= S3C2410_GPA(11),
311 		.retain_state_suspended	= 1,
312 	},
313 };
314 
315 static struct gpio_led_platform_data rx1950_leds_pdata = {
316 	.num_leds	= ARRAY_SIZE(rx1950_leds_desc),
317 	.leds		= rx1950_leds_desc,
318 	.gpio_blink_set	= rx1950_led_blink_set,
319 };
320 
321 static struct platform_device rx1950_leds = {
322 	.name	= "leds-gpio",
323 	.id		= -1,
324 	.dev	= {
325 				.platform_data = &rx1950_leds_pdata,
326 	},
327 };
328 
329 static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
330 	.init = rx1950_bat_init,
331 	.exit = rx1950_bat_exit,
332 	.enable_charger = rx1950_enable_charger,
333 	.disable_charger = rx1950_disable_charger,
334 	.gpio_charge_finished = S3C2410_GPF(3),
335 	.lut_noac = bat_lut_noac,
336 	.lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
337 	.lut_acin = bat_lut_acin,
338 	.lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
339 	.volt_channel = 0,
340 	.current_channel = 1,
341 	.volt_mult = 4235,
342 	.current_mult = 2900,
343 	.internal_impedance = 200,
344 };
345 
346 static struct platform_device rx1950_battery = {
347 	.name             = "s3c-adc-battery",
348 	.id               = -1,
349 	.dev = {
350 		.parent = &s3c_device_adc.dev,
351 		.platform_data = &rx1950_bat_cfg,
352 	},
353 };
354 
355 static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
356 	.displays = &rx1950_display,
357 	.num_displays = 1,
358 	.default_display = 0,
359 
360 	.lpcsel = 0x02,
361 	.gpccon = 0xaa9556a9,
362 	.gpccon_mask = 0xffc003fc,
363 	.gpccon_reg = S3C2410_GPCCON,
364 	.gpcup = 0x0000ffff,
365 	.gpcup_mask = 0xffffffff,
366 	.gpcup_reg = S3C2410_GPCUP,
367 
368 	.gpdcon = 0xaa90aaa1,
369 	.gpdcon_mask = 0xffc0fff0,
370 	.gpdcon_reg = S3C2410_GPDCON,
371 	.gpdup = 0x0000fcfd,
372 	.gpdup_mask = 0xffffffff,
373 	.gpdup_reg = S3C2410_GPDUP,
374 };
375 
376 static struct pwm_lookup rx1950_pwm_lookup[] = {
377 	PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight.0", NULL, 48000,
378 		   PWM_POLARITY_NORMAL),
379 };
380 
381 static struct pwm_device *lcd_pwm;
382 static struct pwm_state lcd_pwm_state;
383 
rx1950_lcd_power(int enable)384 static void rx1950_lcd_power(int enable)
385 {
386 	int i;
387 	static int enabled;
388 	if (enabled == enable)
389 		return;
390 	if (!enable) {
391 
392 		/* GPC11-GPC15->OUTPUT */
393 		for (i = 11; i < 16; i++)
394 			gpio_direction_output(S3C2410_GPC(i), 1);
395 
396 		/* Wait a bit here... */
397 		mdelay(100);
398 
399 		/* GPD2-GPD7->OUTPUT */
400 		/* GPD11-GPD15->OUTPUT */
401 		/* GPD2-GPD7->1, GPD11-GPD15->1 */
402 		for (i = 2; i < 8; i++)
403 			gpio_direction_output(S3C2410_GPD(i), 1);
404 		for (i = 11; i < 16; i++)
405 			gpio_direction_output(S3C2410_GPD(i), 1);
406 
407 		/* Wait a bit here...*/
408 		mdelay(100);
409 
410 		/* GPB0->OUTPUT, GPB0->0 */
411 		gpio_direction_output(S3C2410_GPB(0), 0);
412 
413 		/* GPC1-GPC4->OUTPUT, GPC1-4->0 */
414 		for (i = 1; i < 5; i++)
415 			gpio_direction_output(S3C2410_GPC(i), 0);
416 
417 		/* GPC15-GPC11->0 */
418 		for (i = 11; i < 16; i++)
419 			gpio_direction_output(S3C2410_GPC(i), 0);
420 
421 		/* GPD15-GPD11->0, GPD2->GPD7->0 */
422 		for (i = 11; i < 16; i++)
423 			gpio_direction_output(S3C2410_GPD(i), 0);
424 
425 		for (i = 2; i < 8; i++)
426 			gpio_direction_output(S3C2410_GPD(i), 0);
427 
428 		/* GPC6->0, GPC7->0, GPC5->0 */
429 		gpio_direction_output(S3C2410_GPC(6), 0);
430 		gpio_direction_output(S3C2410_GPC(7), 0);
431 		gpio_direction_output(S3C2410_GPC(5), 0);
432 
433 		/* GPB1->OUTPUT, GPB1->0 */
434 		gpio_direction_output(S3C2410_GPB(1), 0);
435 
436 		lcd_pwm_state.enabled = false;
437 		pwm_apply_state(lcd_pwm, &lcd_pwm_state);
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 		lcd_pwm_state.enabled = true;
444 		pwm_apply_state(lcd_pwm, &lcd_pwm_state);
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 
rx1950_bl_power(int enable)470 static 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 
rx1950_backlight_init(struct device * dev)490 static 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 	/*
500 	 * This is only required to initialize .polarity; all other values are
501 	 * fixed in this driver.
502 	 */
503 	pwm_init_state(lcd_pwm, &lcd_pwm_state);
504 
505 	lcd_pwm_state.period = LCD_PWM_PERIOD;
506 	lcd_pwm_state.duty_cycle = LCD_PWM_DUTY;
507 
508 	rx1950_lcd_power(1);
509 	rx1950_bl_power(1);
510 
511 	return 0;
512 }
513 
rx1950_backlight_exit(struct device * dev)514 static void rx1950_backlight_exit(struct device *dev)
515 {
516 	rx1950_bl_power(0);
517 	rx1950_lcd_power(0);
518 
519 	pwm_free(lcd_pwm);
520 	gpio_free(S3C2410_GPB(0));
521 }
522 
523 
rx1950_backlight_notify(struct device * dev,int brightness)524 static int rx1950_backlight_notify(struct device *dev, int brightness)
525 {
526 	if (!brightness) {
527 		rx1950_bl_power(0);
528 		rx1950_lcd_power(0);
529 	} else {
530 		rx1950_lcd_power(1);
531 		rx1950_bl_power(1);
532 	}
533 	return brightness;
534 }
535 
536 static struct platform_pwm_backlight_data rx1950_backlight_data = {
537 	.max_brightness = 24,
538 	.dft_brightness = 4,
539 	.init = rx1950_backlight_init,
540 	.notify = rx1950_backlight_notify,
541 	.exit = rx1950_backlight_exit,
542 };
543 
544 static struct platform_device rx1950_backlight = {
545 	.name = "pwm-backlight",
546 	.dev = {
547 		.parent = &samsung_device_pwm.dev,
548 		.platform_data = &rx1950_backlight_data,
549 	},
550 };
551 
rx1950_set_mmc_power(unsigned char power_mode,unsigned short vdd)552 static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
553 {
554 	s3c24xx_mci_def_set_power(power_mode, vdd);
555 
556 	switch (power_mode) {
557 	case MMC_POWER_OFF:
558 		gpio_direction_output(S3C2410_GPJ(1), 0);
559 		break;
560 	case MMC_POWER_UP:
561 	case MMC_POWER_ON:
562 		gpio_direction_output(S3C2410_GPJ(1), 1);
563 		break;
564 	default:
565 		break;
566 	}
567 }
568 
569 static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
570 	.set_power = rx1950_set_mmc_power,
571 	.ocr_avail = MMC_VDD_32_33,
572 };
573 
574 static struct gpiod_lookup_table rx1950_mmc_gpio_table = {
575 	.dev_id = "s3c2410-sdi",
576 	.table = {
577 		/* Card detect S3C2410_GPF(5) */
578 		GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
579 		/* Write protect S3C2410_GPH(8) */
580 		GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
581 		/* bus pins */
582 		GPIO_LOOKUP_IDX("GPIOE",  5, "bus", 0, GPIO_ACTIVE_HIGH),
583 		GPIO_LOOKUP_IDX("GPIOE",  6, "bus", 1, GPIO_ACTIVE_HIGH),
584 		GPIO_LOOKUP_IDX("GPIOE",  7, "bus", 2, GPIO_ACTIVE_HIGH),
585 		GPIO_LOOKUP_IDX("GPIOE",  8, "bus", 3, GPIO_ACTIVE_HIGH),
586 		GPIO_LOOKUP_IDX("GPIOE",  9, "bus", 4, GPIO_ACTIVE_HIGH),
587 		GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
588 		{ },
589 	},
590 };
591 
592 static struct mtd_partition rx1950_nand_part[] = {
593 	[0] = {
594 			.name = "Boot0",
595 			.offset = 0,
596 			.size = 0x4000,
597 			.mask_flags = MTD_WRITEABLE,
598 	},
599 	[1] = {
600 			.name = "Boot1",
601 			.offset = MTDPART_OFS_APPEND,
602 			.size = 0x40000,
603 			.mask_flags = MTD_WRITEABLE,
604 	},
605 	[2] = {
606 			.name = "Kernel",
607 			.offset = MTDPART_OFS_APPEND,
608 			.size = 0x300000,
609 			.mask_flags = 0,
610 	},
611 	[3] = {
612 			.name = "Filesystem",
613 			.offset = MTDPART_OFS_APPEND,
614 			.size = MTDPART_SIZ_FULL,
615 			.mask_flags = 0,
616 	},
617 };
618 
619 static struct s3c2410_nand_set rx1950_nand_sets[] = {
620 	[0] = {
621 			.name = "Internal",
622 			.nr_chips = 1,
623 			.nr_partitions = ARRAY_SIZE(rx1950_nand_part),
624 			.partitions = rx1950_nand_part,
625 	},
626 };
627 
628 static struct s3c2410_platform_nand rx1950_nand_info = {
629 	.tacls = 25,
630 	.twrph0 = 50,
631 	.twrph1 = 15,
632 	.nr_sets = ARRAY_SIZE(rx1950_nand_sets),
633 	.sets = rx1950_nand_sets,
634 	.engine_type = NAND_ECC_ENGINE_TYPE_SOFT,
635 };
636 
637 static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
638 	.vbus_pin = S3C2410_GPG(5),
639 	.vbus_pin_inverted = 1,
640 	.pullup_pin = S3C2410_GPJ(5),
641 };
642 
643 static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
644 	.delay = 10000,
645 	.presc = 49,
646 	.oversampling_shift = 3,
647 };
648 
649 static struct gpio_keys_button rx1950_gpio_keys_table[] = {
650 	{
651 		.code		= KEY_POWER,
652 		.gpio		= S3C2410_GPF(0),
653 		.active_low	= 1,
654 		.desc		= "Power button",
655 		.wakeup		= 1,
656 	},
657 	{
658 		.code		= KEY_F5,
659 		.gpio		= S3C2410_GPF(7),
660 		.active_low	= 1,
661 		.desc		= "Record button",
662 	},
663 	{
664 		.code		= KEY_F1,
665 		.gpio		= S3C2410_GPG(0),
666 		.active_low	= 1,
667 		.desc		= "Calendar button",
668 	},
669 	{
670 		.code		= KEY_F2,
671 		.gpio		= S3C2410_GPG(2),
672 		.active_low	= 1,
673 		.desc		= "Contacts button",
674 	},
675 	{
676 		.code		= KEY_F3,
677 		.gpio		= S3C2410_GPG(3),
678 		.active_low	= 1,
679 		.desc		= "Mail button",
680 	},
681 	{
682 		.code		= KEY_F4,
683 		.gpio		= S3C2410_GPG(7),
684 		.active_low	= 1,
685 		.desc		= "WLAN button",
686 	},
687 	{
688 		.code		= KEY_LEFT,
689 		.gpio		= S3C2410_GPG(10),
690 		.active_low	= 1,
691 		.desc		= "Left button",
692 	},
693 	{
694 		.code		= KEY_RIGHT,
695 		.gpio		= S3C2410_GPG(11),
696 		.active_low	= 1,
697 		.desc		= "Right button",
698 	},
699 	{
700 		.code		= KEY_UP,
701 		.gpio		= S3C2410_GPG(4),
702 		.active_low	= 1,
703 		.desc		= "Up button",
704 	},
705 	{
706 		.code		= KEY_DOWN,
707 		.gpio		= S3C2410_GPG(6),
708 		.active_low	= 1,
709 		.desc		= "Down button",
710 	},
711 	{
712 		.code		= KEY_ENTER,
713 		.gpio		= S3C2410_GPG(9),
714 		.active_low	= 1,
715 		.desc		= "Ok button"
716 	},
717 };
718 
719 static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
720 	.buttons = rx1950_gpio_keys_table,
721 	.nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
722 };
723 
724 static struct platform_device rx1950_device_gpiokeys = {
725 	.name = "gpio-keys",
726 	.dev.platform_data = &rx1950_gpio_keys_data,
727 };
728 
729 static struct uda1380_platform_data uda1380_info = {
730 	.gpio_power	= S3C2410_GPJ(0),
731 	.gpio_reset	= S3C2410_GPD(0),
732 	.dac_clk	= UDA1380_DAC_CLK_SYSCLK,
733 };
734 
735 static struct i2c_board_info rx1950_i2c_devices[] = {
736 	{
737 		I2C_BOARD_INFO("uda1380", 0x1a),
738 		.platform_data = &uda1380_info,
739 	},
740 };
741 
742 static struct gpiod_lookup_table rx1950_audio_gpio_table = {
743 	.dev_id = "rx1950-audio",
744 	.table = {
745 		GPIO_LOOKUP("GPIOG", 12, "hp-gpio", GPIO_ACTIVE_HIGH),
746 		GPIO_LOOKUP("GPIOA", 1, "speaker-power", GPIO_ACTIVE_HIGH),
747 		{ },
748 	},
749 };
750 
751 static struct platform_device rx1950_audio = {
752 	.name = "rx1950-audio",
753 	.id = -1,
754 };
755 
756 static struct platform_device *rx1950_devices[] __initdata = {
757 	&s3c2410_device_dclk,
758 	&s3c_device_lcd,
759 	&s3c_device_wdt,
760 	&s3c_device_i2c0,
761 	&s3c_device_iis,
762 	&s3c_device_usbgadget,
763 	&s3c_device_rtc,
764 	&s3c_device_nand,
765 	&s3c_device_sdi,
766 	&s3c_device_adc,
767 	&s3c_device_ts,
768 	&samsung_device_pwm,
769 	&rx1950_backlight,
770 	&rx1950_device_gpiokeys,
771 	&power_supply,
772 	&rx1950_battery,
773 	&rx1950_leds,
774 	&rx1950_audio,
775 };
776 
rx1950_map_io(void)777 static void __init rx1950_map_io(void)
778 {
779 	s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
780 	s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
781 	s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
782 
783 	/* setup PM */
784 
785 #ifdef CONFIG_PM_H1940
786 	memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
787 #endif
788 
789 	s3c_pm_init();
790 }
791 
rx1950_init_time(void)792 static void __init rx1950_init_time(void)
793 {
794 	s3c2442_init_clocks(16934000);
795 	s3c24xx_timer_init();
796 }
797 
rx1950_init_machine(void)798 static void __init rx1950_init_machine(void)
799 {
800 	int i;
801 
802 	s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
803 	s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
804 	s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
805 	gpiod_add_lookup_table(&rx1950_mmc_gpio_table);
806 	s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
807 	s3c_i2c0_set_platdata(NULL);
808 	s3c_nand_set_platdata(&rx1950_nand_info);
809 
810 	/* Turn off suspend on both USB ports, and switch the
811 	 * selectable USB port to USB device mode. */
812 	s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
813 						S3C2410_MISCCR_USBSUSPND0 |
814 						S3C2410_MISCCR_USBSUSPND1, 0x0);
815 
816 	/* mmc power is disabled by default */
817 	WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
818 	gpio_direction_output(S3C2410_GPJ(1), 0);
819 
820 	for (i = 0; i < 8; i++)
821 		WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
822 
823 	for (i = 10; i < 16; i++)
824 		WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
825 
826 	for (i = 2; i < 8; i++)
827 		WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
828 
829 	for (i = 11; i < 16; i++)
830 		WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
831 
832 	WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
833 
834 	WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink"));
835 	WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink"));
836 	WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink"));
837 	gpio_direction_output(S3C2410_GPA(3), 0);
838 	gpio_direction_output(S3C2410_GPA(4), 0);
839 	gpio_direction_output(S3C2410_GPJ(6), 0);
840 
841 	pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup));
842 	gpiod_add_lookup_table(&rx1950_audio_gpio_table);
843 	/* Configure the I2S pins (GPE0...GPE4) in correct mode */
844 	s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
845 			      S3C_GPIO_PULL_NONE);
846 	platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
847 
848 	i2c_register_board_info(0, rx1950_i2c_devices,
849 		ARRAY_SIZE(rx1950_i2c_devices));
850 }
851 
852 /* H1940 and RX3715 need to reserve this for suspend */
rx1950_reserve(void)853 static void __init rx1950_reserve(void)
854 {
855 	memblock_reserve(0x30003000, 0x1000);
856 	memblock_reserve(0x30081000, 0x1000);
857 }
858 
859 MACHINE_START(RX1950, "HP iPAQ RX1950")
860     /* Maintainers: Vasily Khoruzhick */
861 	.atag_offset = 0x100,
862 	.map_io = rx1950_map_io,
863 	.reserve	= rx1950_reserve,
864 	.init_irq	= s3c2442_init_irq,
865 	.init_machine = rx1950_init_machine,
866 	.init_time	= rx1950_init_time,
867 MACHINE_END
868