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/input.h>
22 #include <linux/delay.h>
23 #include <linux/interrupt.h>
24 #include <linux/irq.h>
25 #include <linux/i2c.h>
26 #include <asm/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/usb.h>
32 #include <asm/arch/board.h>
33 #include <asm/arch/common.h>
34 #include <asm/arch/mcspi.h>
35 #include <asm/arch/menelaus.h>
36 #include <asm/arch/lcd_mipid.h>
37 #include <asm/arch/clock.h>
38 #include <asm/arch/gpio-switch.h>
39 #include <asm/arch/omapfb.h>
40 #include <asm/arch/blizzard.h>
42 #include <../drivers/cbus/tahvo.h>
43 #include <../drivers/media/video/tcm825x.h>
45 #define N800_BLIZZARD_POWERDOWN_GPIO 15
46 #define N800_STI_GPIO 62
47 #define N800_KEYB_IRQ_GPIO 109
49 void __init nokia_n800_init_irq(void)
51 omap2_init_common_hw();
55 #ifdef CONFIG_OMAP_STI
56 if (omap_request_gpio(N800_STI_GPIO) < 0) {
57 printk(KERN_ERR "Failed to request GPIO %d for STI\n",
62 omap_set_gpio_direction(N800_STI_GPIO, 0);
63 omap_set_gpio_dataout(N800_STI_GPIO, 0);
67 #if defined(CONFIG_MENELAUS) && defined(CONFIG_SENSORS_TMP105)
69 static int n800_tmp105_set_power(int enable)
71 return menelaus_set_vaux(enable ? 2800 : 0);
76 #define n800_tmp105_set_power NULL
80 static struct omap_uart_config n800_uart_config __initdata = {
81 .enabled_uarts = (1 << 0) | (1 << 2),
84 #include "../../../drivers/cbus/retu.h"
86 static struct omap_fbmem_config n800_fbmem0_config __initdata = {
90 static struct omap_fbmem_config n800_fbmem1_config __initdata = {
94 static struct omap_fbmem_config n800_fbmem2_config __initdata = {
98 static struct omap_tmp105_config n800_tmp105_config __initdata = {
99 .tmp105_irq_pin = 125,
100 .set_power = n800_tmp105_set_power,
103 static void mipid_shutdown(struct mipid_platform_data *pdata)
105 if (pdata->nreset_gpio != -1) {
106 pr_info("shutdown LCD\n");
107 omap_set_gpio_dataout(pdata->nreset_gpio, 0);
112 static struct mipid_platform_data n800_mipid_platform_data = {
113 .shutdown = mipid_shutdown,
116 static void __init mipid_dev_init(void)
118 const struct omap_lcd_config *conf;
120 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
122 n800_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
123 n800_mipid_platform_data.data_lines = conf->data_lines;
131 static int blizzard_get_clocks(void)
133 blizzard.sys_ck = clk_get(0, "osc_ck");
134 if (IS_ERR(blizzard.sys_ck)) {
135 printk(KERN_ERR "can't get Blizzard clock\n");
136 return PTR_ERR(blizzard.sys_ck);
141 static unsigned long blizzard_get_clock_rate(struct device *dev)
143 return clk_get_rate(blizzard.sys_ck);
146 static void blizzard_enable_clocks(int enable)
149 clk_enable(blizzard.sys_ck);
151 clk_disable(blizzard.sys_ck);
154 static void blizzard_power_up(struct device *dev)
156 /* Vcore to 1.475V */
157 tahvo_set_clear_reg_bits(0x07, 0, 0xf);
160 blizzard_enable_clocks(1);
161 omap_set_gpio_dataout(N800_BLIZZARD_POWERDOWN_GPIO, 1);
164 static void blizzard_power_down(struct device *dev)
166 omap_set_gpio_dataout(N800_BLIZZARD_POWERDOWN_GPIO, 0);
167 blizzard_enable_clocks(0);
169 /* Vcore to 1.005V */
170 tahvo_set_clear_reg_bits(0x07, 0xf, 0);
173 static struct blizzard_platform_data n800_blizzard_data = {
174 .power_up = blizzard_power_up,
175 .power_down = blizzard_power_down,
176 .get_clock_rate = blizzard_get_clock_rate,
180 static void __init blizzard_dev_init(void)
184 r = omap_request_gpio(N800_BLIZZARD_POWERDOWN_GPIO);
187 omap_set_gpio_direction(N800_BLIZZARD_POWERDOWN_GPIO, 0);
188 omap_set_gpio_dataout(N800_BLIZZARD_POWERDOWN_GPIO, 1);
190 blizzard_get_clocks();
191 omapfb_set_ctrl_platform_data(&n800_blizzard_data);
194 static struct omap_mmc_config n800_mmc_config __initdata = {
201 extern struct omap_mmc_platform_data n800_mmc_data;
203 static struct omap_board_config_kernel n800_config[] __initdata = {
204 { OMAP_TAG_UART, &n800_uart_config },
205 { OMAP_TAG_FBMEM, &n800_fbmem0_config },
206 { OMAP_TAG_FBMEM, &n800_fbmem1_config },
207 { OMAP_TAG_FBMEM, &n800_fbmem2_config },
208 { OMAP_TAG_TMP105, &n800_tmp105_config },
209 { OMAP_TAG_MMC, &n800_mmc_config },
213 static int n800_get_keyb_irq_state(struct device *dev)
215 return !omap_get_gpio_datain(N800_KEYB_IRQ_GPIO);
218 static struct tsc2301_platform_data tsc2301_config = {
223 -1, /* Event for bit 0 */
224 KEY_UP, /* Event for bit 1 (up) */
225 KEY_F5, /* Event for bit 2 (home) */
226 -1, /* Event for bit 3 */
227 KEY_LEFT, /* Event for bit 4 (left) */
228 KEY_ENTER, /* Event for bit 5 (enter) */
229 KEY_RIGHT, /* Event for bit 6 (right) */
230 -1, /* Event for bit 7 */
231 KEY_ESC, /* Event for bit 8 (cycle) */
232 KEY_DOWN, /* Event for bit 9 (down) */
233 KEY_F4, /* Event for bit 10 (menu) */
234 -1, /* Event for bit 11 */
235 KEY_F8, /* Event for bit 12 (Zoom-) */
236 KEY_F6, /* Event for bit 13 (FS) */
237 KEY_F7, /* Event for bit 14 (Zoom+) */
238 -1, /* Event for bit 15 */
241 .get_keyb_irq_state = n800_get_keyb_irq_state,
244 static void tsc2301_dev_init(void)
246 int gpio = N800_KEYB_IRQ_GPIO;
248 if (omap_request_gpio(gpio) < 0) {
249 printk(KERN_ERR "can't get KBIRQ GPIO\n");
252 omap_set_gpio_direction(gpio, 1);
253 tsc2301_config.keyb_int = OMAP_GPIO_IRQ(gpio);
256 static struct omap2_mcspi_device_config tsc2301_mcspi_config = {
261 static struct omap2_mcspi_device_config mipid_mcspi_config = {
266 static struct omap2_mcspi_device_config cx3110x_mcspi_config = {
271 static struct spi_board_info n800_spi_board_info[] __initdata = {
273 .modalias = "lcd_mipid",
276 .max_speed_hz = 4000000,
277 .controller_data= &mipid_mcspi_config,
278 .platform_data = &n800_mipid_platform_data,
280 .modalias = "cx3110x",
283 .max_speed_hz = 48000000,
284 .controller_data= &cx3110x_mcspi_config,
286 .modalias = "tsc2301",
289 .max_speed_hz = 6000000,
290 .controller_data= &tsc2301_mcspi_config,
291 .platform_data = &tsc2301_config,
295 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_LEDS_OMAP_PWM)
297 void retu_keypad_led_set_power(struct omap_pwm_led_platform_data *self,
301 retu_write_reg(RETU_REG_CTRL_SET, 1 << 6);
303 retu_write_reg(RETU_REG_CTRL_SET, 1 << 3);
305 retu_write_reg(RETU_REG_CTRL_CLR, (1 << 6) | (1 << 3));
309 static struct omap_pwm_led_platform_data n800_keypad_led_data = {
311 .intensity_timer = 10,
313 .set_power = retu_keypad_led_set_power,
316 static struct platform_device n800_keypad_led_device = {
317 .name = "omap_pwm_led",
320 .platform_data = &n800_keypad_led_data,
325 #if defined(CONFIG_TOUCHSCREEN_TSC2301)
326 static void __init n800_ts_set_config(void)
328 const struct omap_lcd_config *conf;
330 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
332 if (strcmp(conf->panel_name, "lph8923") == 0) {
333 tsc2301_config.ts_x_plate_ohm = 180;
334 tsc2301_config.ts_hw_avg = 4;
335 tsc2301_config.ts_ignore_last = 1;
336 tsc2301_config.ts_max_pressure = 255;
337 tsc2301_config.ts_stab_time = 100;
338 } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
339 tsc2301_config.ts_x_plate_ohm = 280;
340 tsc2301_config.ts_hw_avg = 16;
341 tsc2301_config.ts_touch_pressure= 215;
342 tsc2301_config.ts_max_pressure = 255;
343 tsc2301_config.ts_ignore_last = 1;
345 printk(KERN_ERR "Unknown panel type, set default "
346 "touchscreen configuration\n");
347 tsc2301_config.ts_x_plate_ohm = 200;
348 tsc2301_config.ts_stab_time = 100;
353 static inline void n800_ts_set_config(void)
358 static struct omap_gpio_switch n800_gpio_switches[] __initdata = {
362 .debounce_rising = 100,
363 .debounce_falling = 0,
364 .notify = n800_mmc_slot1_cover_handler,
369 .debounce_rising = 200,
370 .debounce_falling = 200,
374 .debounce_rising = 200,
375 .debounce_falling = 200,
379 .debounce_rising = 100,
380 .debounce_falling = 100,
384 static struct platform_device *n800_devices[] __initdata = {
385 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_LEDS_OMAP_PWM)
386 &n800_keypad_led_device,
390 #ifdef CONFIG_MENELAUS
391 static int n800_auto_sleep_regulators(void)
396 val = EN_VPLL_SLEEP | EN_VMMC_SLEEP \
397 | EN_VAUX_SLEEP | EN_VIO_SLEEP \
398 | EN_VMEM_SLEEP | EN_DC3_SLEEP \
399 | EN_VC_SLEEP | EN_DC2_SLEEP;
401 ret = menelaus_set_regulator_sleep(1, val);
403 printk(KERN_ERR "Could not set regulators to sleep on "
404 "menelaus: %u\n", ret);
410 static int n800_auto_voltage_scale(void)
414 ret = menelaus_set_vcore_hw(1400, 1050);
416 printk(KERN_ERR "Could not set VCORE voltage on "
417 "menelaus: %u\n", ret);
423 static int n800_menelaus_init(struct device *dev)
427 ret = n800_auto_voltage_scale();
430 ret = n800_auto_sleep_regulators();
436 static struct menelaus_platform_data n800_menelaus_platform_data = {
437 .late_init = n800_menelaus_init,
441 static struct i2c_board_info __initdata n800_i2c_board_info_1[] = {
443 I2C_BOARD_INFO("menelaus", 0x72),
444 .irq = INT_24XX_SYS_NIRQ,
445 .platform_data = &n800_menelaus_platform_data,
449 extern struct tcm825x_platform_data n800_tcm825x_platform_data;
451 static struct i2c_board_info __initdata n800_i2c_board_info_2[] = {
452 #if defined (CONFIG_VIDEO_TCM825X) || defined (CONFIG_VIDEO_TCM825X_MODULE)
454 I2C_BOARD_INFO(TCM825X_NAME, TCM825X_I2C_ADDR),
455 .platform_data = &n800_tcm825x_platform_data,
460 extern void __init n800_mmc_init(void);
462 void __init nokia_n800_common_init(void)
464 platform_add_devices(n800_devices, ARRAY_SIZE(n800_devices));
472 spi_register_board_info(n800_spi_board_info,
473 ARRAY_SIZE(n800_spi_board_info));
475 omap_register_i2c_bus(1, 400, n800_i2c_board_info_1,
476 ARRAY_SIZE(n800_i2c_board_info_1));
477 omap_register_i2c_bus(2, 400, n800_i2c_board_info_2,
478 ARRAY_SIZE(n800_i2c_board_info_2));
483 static void __init nokia_n800_init(void)
485 nokia_n800_common_init();
487 n800_audio_init(&tsc2301_config);
488 n800_ts_set_config();
490 omap_register_gpio_switches(n800_gpio_switches,
491 ARRAY_SIZE(n800_gpio_switches));
494 void __init nokia_n800_map_io(void)
496 omap_board_config = n800_config;
497 omap_board_config_size = ARRAY_SIZE(n800_config);
499 omap2_set_globals_242x();
500 omap2_map_common_io();
503 MACHINE_START(NOKIA_N800, "Nokia N800")
504 .phys_io = 0x48000000,
505 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
506 .boot_params = 0x80000100,
507 .map_io = nokia_n800_map_io,
508 .init_irq = nokia_n800_init_irq,
509 .init_machine = nokia_n800_init,
510 .timer = &omap_timer,