2 * linux/arch/arm/mach-omap2/board-n800.c
4 * Copyright (C) 2005-2007 Nokia Corporation
5 * Author: Juha Yrjola <juha.yrjola@nokia.com>
7 * Modified from mach-omap2/board-generic.c
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/clk.h>
17 #include <linux/device.h>
18 #include <linux/platform_device.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/tsc2301.h>
21 #include <linux/spi/tsc2005.h>
22 #include <linux/input.h>
23 #include <linux/delay.h>
24 #include <linux/interrupt.h>
25 #include <linux/irq.h>
26 #include <linux/i2c.h>
27 #include <linux/i2c/lm8323.h>
28 #include <linux/i2c/menelaus.h>
29 #include <linux/i2c/lp5521.h>
30 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <mach/gpio.h>
36 #include <mach/board.h>
37 #include <mach/common.h>
38 #include <mach/mcspi.h>
39 #include <mach/lcd_mipid.h>
40 #include <mach/clock.h>
41 #include <mach/gpio-switch.h>
42 #include <mach/omapfb.h>
43 #include <mach/blizzard.h>
45 #include <../drivers/cbus/tahvo.h>
46 #include <../drivers/media/video/tcm825x.h>
48 #define N800_BLIZZARD_POWERDOWN_GPIO 15
49 #define N800_STI_GPIO 62
50 #define N800_KEYB_IRQ_GPIO 109
51 #define N800_DAV_IRQ_GPIO 103
52 #define N800_TSC2301_RESET_GPIO 118
54 #ifdef CONFIG_MACH_NOKIA_N810
55 static s16 rx44_keymap[LM8323_KEYMAP_SIZE] = {
60 [0x05] = KEY_BACKSPACE,
72 [0x14] = KEY_APOSTROPHE,
79 [0x1c] = KEY_LEFTSHIFT, /* Actually, this is both shift keys */
83 [0x22] = KEY_SEMICOLON,
91 [0x32] = KEY_RIGHTCTRL,
111 [0x75] = KEY_KPENTER,
114 static struct lm8323_platform_data lm8323_pdata = {
115 .repeat = 0, /* Repeat is handled in userspace for now. */
116 .keymap = rx44_keymap,
118 .name = "Internal keyboard",
119 .pwm1_name = "keyboard",
120 .pwm2_name = "cover",
124 void __init nokia_n800_init_irq(void)
126 omap2_init_common_hw(NULL);
130 #ifdef CONFIG_OMAP_STI
131 if (gpio_request(N800_STI_GPIO, "STI") < 0) {
132 printk(KERN_ERR "Failed to request GPIO %d for STI\n",
137 gpio_direction_output(N800_STI_GPIO, 0);
141 #if defined(CONFIG_MENELAUS) && defined(CONFIG_SENSORS_TMP105)
143 static int n800_tmp105_set_power(int enable)
145 return menelaus_set_vaux(enable ? 2800 : 0);
150 #define n800_tmp105_set_power NULL
154 static struct omap_uart_config n800_uart_config __initdata = {
155 .enabled_uarts = (1 << 0) | (1 << 2),
158 #include "../../../drivers/cbus/retu.h"
160 static struct omap_fbmem_config n800_fbmem0_config __initdata = {
164 static struct omap_fbmem_config n800_fbmem1_config __initdata = {
168 static struct omap_fbmem_config n800_fbmem2_config __initdata = {
172 static struct omap_tmp105_config n800_tmp105_config __initdata = {
173 .tmp105_irq_pin = 125,
174 .set_power = n800_tmp105_set_power,
177 static void mipid_shutdown(struct mipid_platform_data *pdata)
179 if (pdata->nreset_gpio != -1) {
180 pr_info("shutdown LCD\n");
181 gpio_set_value(pdata->nreset_gpio, 0);
186 static struct mipid_platform_data n800_mipid_platform_data = {
187 .shutdown = mipid_shutdown,
190 static void __init mipid_dev_init(void)
192 const struct omap_lcd_config *conf;
194 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
196 n800_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
197 n800_mipid_platform_data.data_lines = conf->data_lines;
205 static int blizzard_get_clocks(void)
207 blizzard.sys_ck = clk_get(0, "osc_ck");
208 if (IS_ERR(blizzard.sys_ck)) {
209 printk(KERN_ERR "can't get Blizzard clock\n");
210 return PTR_ERR(blizzard.sys_ck);
215 static unsigned long blizzard_get_clock_rate(struct device *dev)
217 return clk_get_rate(blizzard.sys_ck);
220 static void blizzard_enable_clocks(int enable)
223 clk_enable(blizzard.sys_ck);
225 clk_disable(blizzard.sys_ck);
228 static void blizzard_power_up(struct device *dev)
230 /* Vcore to 1.475V */
231 tahvo_set_clear_reg_bits(0x07, 0, 0xf);
234 blizzard_enable_clocks(1);
235 gpio_set_value(N800_BLIZZARD_POWERDOWN_GPIO, 1);
238 static void blizzard_power_down(struct device *dev)
240 gpio_set_value(N800_BLIZZARD_POWERDOWN_GPIO, 0);
241 blizzard_enable_clocks(0);
243 /* Vcore to 1.005V */
244 tahvo_set_clear_reg_bits(0x07, 0xf, 0);
247 static struct blizzard_platform_data n800_blizzard_data = {
248 .power_up = blizzard_power_up,
249 .power_down = blizzard_power_down,
250 .get_clock_rate = blizzard_get_clock_rate,
254 static void __init blizzard_dev_init(void)
258 r = gpio_request(N800_BLIZZARD_POWERDOWN_GPIO, "Blizzard pd");
261 gpio_direction_output(N800_BLIZZARD_POWERDOWN_GPIO, 1);
263 blizzard_get_clocks();
264 omapfb_set_ctrl_platform_data(&n800_blizzard_data);
267 static struct omap_board_config_kernel n800_config[] __initdata = {
268 { OMAP_TAG_UART, &n800_uart_config },
269 { OMAP_TAG_FBMEM, &n800_fbmem0_config },
270 { OMAP_TAG_FBMEM, &n800_fbmem1_config },
271 { OMAP_TAG_FBMEM, &n800_fbmem2_config },
272 { OMAP_TAG_TMP105, &n800_tmp105_config },
275 static struct tsc2301_platform_data tsc2301_config = {
276 .reset_gpio = N800_TSC2301_RESET_GPIO,
278 -1, /* Event for bit 0 */
279 KEY_UP, /* Event for bit 1 (up) */
280 KEY_F5, /* Event for bit 2 (home) */
281 -1, /* Event for bit 3 */
282 KEY_LEFT, /* Event for bit 4 (left) */
283 KEY_ENTER, /* Event for bit 5 (enter) */
284 KEY_RIGHT, /* Event for bit 6 (right) */
285 -1, /* Event for bit 7 */
286 KEY_ESC, /* Event for bit 8 (cycle) */
287 KEY_DOWN, /* Event for bit 9 (down) */
288 KEY_F4, /* Event for bit 10 (menu) */
289 -1, /* Event for bit 11 */
290 KEY_F8, /* Event for bit 12 (Zoom-) */
291 KEY_F6, /* Event for bit 13 (FS) */
292 KEY_F7, /* Event for bit 14 (Zoom+) */
293 -1, /* Event for bit 15 */
296 .keyb_name = "Internal keypad",
299 static void tsc2301_dev_init(void)
302 int gpio = N800_KEYB_IRQ_GPIO;
304 r = gpio_request(gpio, "tsc2301 KBD IRQ");
306 gpio_direction_input(gpio);
307 tsc2301_config.keyb_int = gpio_to_irq(gpio);
309 printk(KERN_ERR "unable to get KBD GPIO");
312 gpio = N800_DAV_IRQ_GPIO;
313 r = gpio_request(gpio, "tsc2301 DAV IRQ");
315 gpio_direction_input(gpio);
316 tsc2301_config.dav_int = gpio_to_irq(gpio);
318 printk(KERN_ERR "unable to get DAV GPIO");
322 static int __init tea5761_dev_init(void)
324 const struct omap_tea5761_config *info;
327 info = omap_get_config(OMAP_TAG_TEA5761, struct omap_tea5761_config);
329 enable_gpio = info->enable_gpio;
332 pr_debug("Enabling tea5761 at GPIO %d\n",
335 if (gpio_request(enable_gpio, "TEA5761 enable") < 0) {
336 printk(KERN_ERR "Can't request GPIO %d\n",
341 gpio_direction_output(enable_gpio, 0);
343 gpio_set_value(enable_gpio, 1);
349 static struct omap2_mcspi_device_config tsc2301_mcspi_config = {
354 static struct omap2_mcspi_device_config mipid_mcspi_config = {
359 static struct omap2_mcspi_device_config cx3110x_mcspi_config = {
364 #ifdef CONFIG_TOUCHSCREEN_TSC2005
365 static struct tsc2005_platform_data tsc2005_config = {
370 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
376 static struct spi_board_info n800_spi_board_info[] __initdata = {
378 .modalias = "lcd_mipid",
381 .max_speed_hz = 4000000,
382 .controller_data= &mipid_mcspi_config,
383 .platform_data = &n800_mipid_platform_data,
385 .modalias = "cx3110x",
388 .max_speed_hz = 48000000,
389 .controller_data= &cx3110x_mcspi_config,
392 .modalias = "tsc2301",
395 .max_speed_hz = 6000000,
396 .controller_data= &tsc2301_mcspi_config,
397 .platform_data = &tsc2301_config,
401 static struct spi_board_info n810_spi_board_info[] __initdata = {
403 .modalias = "lcd_mipid",
406 .max_speed_hz = 4000000,
407 .controller_data = &mipid_mcspi_config,
408 .platform_data = &n800_mipid_platform_data,
411 .modalias = "cx3110x",
414 .max_speed_hz = 48000000,
415 .controller_data = &cx3110x_mcspi_config,
418 .modalias = "tsc2005",
421 .max_speed_hz = 6000000,
422 .controller_data = &tsc2005_mcspi_config,
423 .platform_data = &tsc2005_config,
427 static void __init tsc2005_set_config(void)
429 const struct omap_lcd_config *conf;
431 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
433 #ifdef CONFIG_TOUCHSCREEN_TSC2005
434 if (strcmp(conf->panel_name, "lph8923") == 0) {
435 tsc2005_config.ts_x_plate_ohm = 180;
436 tsc2005_config.ts_hw_avg = 0;
437 tsc2005_config.ts_ignore_last = 0;
438 tsc2005_config.ts_touch_pressure = 1500;
439 tsc2005_config.ts_stab_time = 100;
440 tsc2005_config.ts_pressure_max = 2048;
441 tsc2005_config.ts_pressure_fudge = 2;
442 tsc2005_config.ts_x_max = 4096;
443 tsc2005_config.ts_x_fudge = 4;
444 tsc2005_config.ts_y_max = 4096;
445 tsc2005_config.ts_y_fudge = 7;
446 } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
447 tsc2005_config.ts_x_plate_ohm = 280;
448 tsc2005_config.ts_hw_avg = 0;
449 tsc2005_config.ts_ignore_last = 0;
450 tsc2005_config.ts_touch_pressure = 1500;
451 tsc2005_config.ts_stab_time = 1000;
452 tsc2005_config.ts_pressure_max = 2048;
453 tsc2005_config.ts_pressure_fudge = 2;
454 tsc2005_config.ts_x_max = 4096;
455 tsc2005_config.ts_x_fudge = 4;
456 tsc2005_config.ts_y_max = 4096;
457 tsc2005_config.ts_y_fudge = 7;
459 printk(KERN_ERR "Unknown panel type, set default "
460 "touchscreen configuration\n");
461 tsc2005_config.ts_x_plate_ohm = 200;
462 tsc2005_config.ts_stab_time = 100;
468 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_LEDS_OMAP_PWM)
470 void retu_keypad_led_set_power(struct omap_pwm_led_platform_data *self,
474 retu_write_reg(RETU_REG_CTRL_SET, 1 << 6);
476 retu_write_reg(RETU_REG_CTRL_SET, 1 << 3);
478 retu_write_reg(RETU_REG_CTRL_CLR, (1 << 6) | (1 << 3));
482 static struct omap_pwm_led_platform_data n800_keypad_led_data = {
484 .intensity_timer = 10,
486 .set_power = retu_keypad_led_set_power,
489 static struct platform_device n800_keypad_led_device = {
490 .name = "omap_pwm_led",
493 .platform_data = &n800_keypad_led_data,
498 #if defined(CONFIG_TOUCHSCREEN_TSC2301)
499 static void __init n800_ts_set_config(void)
501 const struct omap_lcd_config *conf;
503 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
505 if (strcmp(conf->panel_name, "lph8923") == 0) {
506 tsc2301_config.ts_x_plate_ohm = 180;
507 tsc2301_config.ts_hw_avg = 8;
508 tsc2301_config.ts_max_pressure = 2048;
509 tsc2301_config.ts_touch_pressure = 400;
510 tsc2301_config.ts_stab_time = 100;
511 tsc2301_config.ts_pressure_fudge = 2;
512 tsc2301_config.ts_x_max = 4096;
513 tsc2301_config.ts_x_fudge = 4;
514 tsc2301_config.ts_y_max = 4096;
515 tsc2301_config.ts_y_fudge = 7;
516 } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
517 tsc2301_config.ts_x_plate_ohm = 280;
518 tsc2301_config.ts_hw_avg = 8;
519 tsc2301_config.ts_touch_pressure = 400;
520 tsc2301_config.ts_max_pressure = 2048;
521 tsc2301_config.ts_stab_time = 1000;
522 tsc2301_config.ts_pressure_fudge = 2;
523 tsc2301_config.ts_x_max = 4096;
524 tsc2301_config.ts_x_fudge = 4;
525 tsc2301_config.ts_y_max = 4096;
526 tsc2301_config.ts_y_fudge = 7;
528 printk(KERN_ERR "Unknown panel type, set default "
529 "touchscreen configuration\n");
530 tsc2301_config.ts_x_plate_ohm = 200;
531 tsc2301_config.ts_stab_time = 100;
536 static inline void n800_ts_set_config(void)
541 static struct omap_gpio_switch n800_gpio_switches[] __initdata = {
545 .debounce_rising = 100,
546 .debounce_falling = 0,
547 .notify = n800_mmc_slot1_cover_handler,
552 .debounce_rising = 200,
553 .debounce_falling = 200,
557 .debounce_rising = 200,
558 .debounce_falling = 200,
562 .debounce_rising = 100,
563 .debounce_falling = 100,
567 static struct platform_device *n800_devices[] __initdata = {
568 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_LEDS_OMAP_PWM)
569 &n800_keypad_led_device,
573 #ifdef CONFIG_MENELAUS
574 static int n800_auto_sleep_regulators(void)
579 val = EN_VPLL_SLEEP | EN_VMMC_SLEEP \
580 | EN_VAUX_SLEEP | EN_VIO_SLEEP \
581 | EN_VMEM_SLEEP | EN_DC3_SLEEP \
582 | EN_VC_SLEEP | EN_DC2_SLEEP;
584 ret = menelaus_set_regulator_sleep(1, val);
586 printk(KERN_ERR "Could not set regulators to sleep on "
587 "menelaus: %u\n", ret);
593 static int n800_auto_voltage_scale(void)
597 ret = menelaus_set_vcore_hw(1400, 1050);
599 printk(KERN_ERR "Could not set VCORE voltage on "
600 "menelaus: %u\n", ret);
606 static int n800_menelaus_init(struct device *dev)
610 ret = n800_auto_voltage_scale();
613 ret = n800_auto_sleep_regulators();
619 static struct menelaus_platform_data n800_menelaus_platform_data = {
620 .late_init = n800_menelaus_init,
624 static struct i2c_board_info __initdata n800_i2c_board_info_1[] = {
626 I2C_BOARD_INFO("menelaus", 0x72),
627 .irq = INT_24XX_SYS_NIRQ,
628 .platform_data = &n800_menelaus_platform_data,
632 static struct lp5521_platform_data n810_lp5521_platform_data = {
633 .mode = LP5521_MODE_DIRECT_CONTROL,
636 .green_present = true,
637 .blue_present = true,
640 extern struct tcm825x_platform_data n800_tcm825x_platform_data;
642 static struct i2c_board_info __initdata_or_module n8x0_i2c_board_info_2[] = {
644 I2C_BOARD_INFO(TCM825X_NAME, TCM825X_I2C_ADDR),
645 #if defined (CONFIG_VIDEO_TCM825X) || defined (CONFIG_VIDEO_TCM825X_MODULE)
646 .platform_data = &n800_tcm825x_platform_data,
652 static struct i2c_board_info __initdata_or_module n800_i2c_board_info_2[] = {
654 I2C_BOARD_INFO("tea5761", 0x10),
658 static struct i2c_board_info __initdata_or_module n810_i2c_board_info_2[] = {
660 I2C_BOARD_INFO("lm8323", 0x45),
661 .irq = OMAP_GPIO_IRQ(109),
662 .platform_data = &lm8323_pdata,
665 I2C_BOARD_INFO("tsl2563", 0x29),
668 I2C_BOARD_INFO("lp5521", 0x32),
669 .platform_data = &n810_lp5521_platform_data,
673 void __init nokia_n800_common_init(void)
675 platform_add_devices(n800_devices, ARRAY_SIZE(n800_devices));
683 if (machine_is_nokia_n800())
684 spi_register_board_info(n800_spi_board_info,
685 ARRAY_SIZE(n800_spi_board_info));
686 if (machine_is_nokia_n810()) {
687 tsc2005_set_config();
688 spi_register_board_info(n810_spi_board_info,
689 ARRAY_SIZE(n810_spi_board_info));
692 omap_register_i2c_bus(1, 400, n800_i2c_board_info_1,
693 ARRAY_SIZE(n800_i2c_board_info_1));
694 omap_register_i2c_bus(2, 400, n8x0_i2c_board_info_2,
695 ARRAY_SIZE(n8x0_i2c_board_info_2));
696 if (machine_is_nokia_n800())
697 i2c_register_board_info(2, n800_i2c_board_info_2,
698 ARRAY_SIZE(n800_i2c_board_info_2));
699 if (machine_is_nokia_n810())
700 i2c_register_board_info(2, n810_i2c_board_info_2,
701 ARRAY_SIZE(n810_i2c_board_info_2));
707 static void __init nokia_n800_init(void)
709 nokia_n800_common_init();
711 n800_audio_init(&tsc2301_config);
712 n800_ts_set_config();
715 omap_register_gpio_switches(n800_gpio_switches,
716 ARRAY_SIZE(n800_gpio_switches));
719 void __init nokia_n800_map_io(void)
721 omap_board_config = n800_config;
722 omap_board_config_size = ARRAY_SIZE(n800_config);
724 omap2_set_globals_242x();
725 omap2_map_common_io();
728 MACHINE_START(NOKIA_N800, "Nokia N800")
729 .phys_io = 0x48000000,
730 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
731 .boot_params = 0x80000100,
732 .map_io = nokia_n800_map_io,
733 .init_irq = nokia_n800_init_irq,
734 .init_machine = nokia_n800_init,
735 .timer = &omap_timer,