2 * linux/arch/arm/mach-omap/omap2/board-n800.c
4 * Copyright (C) 2005 Nokia Corporation
5 * Author: Juha Yrj?l? <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 <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/arch/gpio.h>
30 #include <asm/arch/usb.h>
31 #include <asm/arch/board.h>
32 #include <asm/arch/common.h>
33 #include <asm/arch/mcspi.h>
34 #include <asm/arch/menelaus.h>
35 #include <asm/arch/lcd_mipid.h>
36 #include <asm/arch/clock.h>
37 #include <asm/arch/gpio-switch.h>
38 #include <asm/arch/omapfb.h>
39 #include <asm/arch/blizzard.h>
41 #include <../drivers/cbus/tahvo.h>
43 #define N800_BLIZZARD_POWERDOWN_GPIO 15
44 #define N800_STI_GPIO 62
45 #define N800_CAM_SENSOR_RESET_GPIO 53
46 #define N800_KEYB_IRQ_GPIO 109
48 static void __init nokia_n800_init_irq(void)
50 omap2_init_common_hw();
54 #ifdef CONFIG_OMAP_STI
55 if (omap_request_gpio(N800_STI_GPIO) < 0) {
56 printk(KERN_ERR "Failed to request GPIO %d for STI\n",
61 omap_set_gpio_direction(N800_STI_GPIO, 0);
62 omap_set_gpio_dataout(N800_STI_GPIO, 0);
66 #if defined(CONFIG_MENELAUS) && defined(CONFIG_SENSORS_TMP105)
68 static int n800_tmp105_set_power(int enable)
70 return menelaus_set_vaux(enable ? 2800 : 0);
75 #define n800_tmp105_set_power NULL
79 static struct omap_uart_config n800_uart_config __initdata = {
80 .enabled_uarts = (1 << 0) | (1 << 2),
83 #include "../../../drivers/cbus/retu.h"
85 static struct omap_fbmem_config n800_fbmem0_config __initdata = {
89 static struct omap_fbmem_config n800_fbmem1_config __initdata = {
93 static struct omap_fbmem_config n800_fbmem2_config __initdata = {
97 static struct omap_tmp105_config n800_tmp105_config __initdata = {
98 .tmp105_irq_pin = 125,
99 .set_power = n800_tmp105_set_power,
102 static void mipid_shutdown(struct mipid_platform_data *pdata)
104 if (pdata->nreset_gpio != -1) {
105 pr_info("shutdown LCD\n");
106 omap_set_gpio_dataout(pdata->nreset_gpio, 0);
111 static struct mipid_platform_data n800_mipid_platform_data = {
112 .shutdown = mipid_shutdown,
115 static void __init mipid_dev_init(void)
117 const struct omap_lcd_config *conf;
119 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
121 n800_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
122 n800_mipid_platform_data.data_lines = conf->data_lines;
130 static int blizzard_get_clocks(void)
132 blizzard.sys_ck = clk_get(0, "osc_ck");
133 if (IS_ERR(blizzard.sys_ck)) {
134 printk(KERN_ERR "can't get Blizzard clock\n");
135 return PTR_ERR(blizzard.sys_ck);
140 static unsigned long blizzard_get_clock_rate(struct device *dev)
142 return clk_get_rate(blizzard.sys_ck);
145 static void blizzard_enable_clocks(int enable)
148 clk_enable(blizzard.sys_ck);
150 clk_disable(blizzard.sys_ck);
153 static void blizzard_power_up(struct device *dev)
155 /* Vcore to 1.475V */
156 tahvo_set_clear_reg_bits(0x07, 0, 0xf);
159 blizzard_enable_clocks(1);
160 omap_set_gpio_dataout(N800_BLIZZARD_POWERDOWN_GPIO, 1);
163 static void blizzard_power_down(struct device *dev)
165 omap_set_gpio_dataout(N800_BLIZZARD_POWERDOWN_GPIO, 0);
166 blizzard_enable_clocks(0);
168 /* Vcore to 1.005V */
169 tahvo_set_clear_reg_bits(0x07, 0xf, 0);
172 static struct blizzard_platform_data n800_blizzard_data = {
173 .power_up = blizzard_power_up,
174 .power_down = blizzard_power_down,
175 .get_clock_rate = blizzard_get_clock_rate,
179 static void __init blizzard_dev_init(void)
183 r = omap_request_gpio(N800_BLIZZARD_POWERDOWN_GPIO);
186 omap_set_gpio_direction(N800_BLIZZARD_POWERDOWN_GPIO, 0);
187 omap_set_gpio_dataout(N800_BLIZZARD_POWERDOWN_GPIO, 1);
189 blizzard_get_clocks();
190 omapfb_set_ctrl_platform_data(&n800_blizzard_data);
193 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_VIDEO_CAMERA_SENSOR_TCM825X) && \
194 defined(CONFIG_MENELAUS)
195 #define SUPPORT_SENSOR
198 #ifdef SUPPORT_SENSOR
200 static int sensor_okay;
203 * VSIM1 --> CAM_IOVDD --> IOVDD (1.8 V)
205 static int tcm825x_sensor_power_on(void *data)
212 /* Set VMEM to 1.5V and VIO to 2.5V */
213 ret = menelaus_set_vmem(1500);
215 /* Try once more, it seems the sensor power up causes
216 * some problems on the I2C bus. */
217 ret = menelaus_set_vmem(1500);
223 ret = menelaus_set_vio(2500);
228 retu_write_reg(RETU_REG_CTRL_SET, 0x0080);
231 omap_set_gpio_dataout(N800_CAM_SENSOR_RESET_GPIO, 1);
237 static int tcm825x_sensor_power_off(void * data)
241 omap_set_gpio_dataout(N800_CAM_SENSOR_RESET_GPIO, 0);
245 retu_write_reg(RETU_REG_CTRL_CLR, 0x0080);
248 /* Set VIO_MODE to off */
249 ret = menelaus_set_vio(0);
254 /* Set VMEM_MODE to off */
255 ret = menelaus_set_vmem(0);
263 static struct omap_camera_sensor_config n800_sensor_config = {
264 .power_on = tcm825x_sensor_power_on,
265 .power_off = tcm825x_sensor_power_off,
268 static void __init n800_cam_init(void)
272 r = omap_request_gpio(N800_CAM_SENSOR_RESET_GPIO);
276 omap_set_gpio_dataout(N800_CAM_SENSOR_RESET_GPIO, 0);
277 omap_set_gpio_direction(N800_CAM_SENSOR_RESET_GPIO, 0);
284 static inline void n800_cam_init(void) {}
288 static struct omap_board_config_kernel n800_config[] = {
289 { OMAP_TAG_UART, &n800_uart_config },
290 #ifdef SUPPORT_SENSOR
291 { OMAP_TAG_CAMERA_SENSOR, &n800_sensor_config },
293 { OMAP_TAG_FBMEM, &n800_fbmem0_config },
294 { OMAP_TAG_FBMEM, &n800_fbmem1_config },
295 { OMAP_TAG_FBMEM, &n800_fbmem2_config },
296 { OMAP_TAG_TMP105, &n800_tmp105_config },
300 static int n800_get_keyb_irq_state(struct device *dev)
302 return !omap_get_gpio_datain(N800_KEYB_IRQ_GPIO);
305 static struct tsc2301_platform_data tsc2301_config = {
310 -1, /* Event for bit 0 */
311 KEY_UP, /* Event for bit 1 (up) */
312 KEY_F5, /* Event for bit 2 (home) */
313 -1, /* Event for bit 3 */
314 KEY_LEFT, /* Event for bit 4 (left) */
315 KEY_ENTER, /* Event for bit 5 (enter) */
316 KEY_RIGHT, /* Event for bit 6 (right) */
317 -1, /* Event for bit 7 */
318 KEY_ESC, /* Event for bit 8 (cycle) */
319 KEY_DOWN, /* Event for bit 9 (down) */
320 KEY_F4, /* Event for bit 10 (menu) */
321 -1, /* Event for bit 11 */
322 KEY_F8, /* Event for bit 12 (Zoom-) */
323 KEY_F6, /* Event for bit 13 (FS) */
324 KEY_F7, /* Event for bit 14 (Zoom+) */
325 -1, /* Event for bit 15 */
328 .get_keyb_irq_state = n800_get_keyb_irq_state,
331 static void tsc2301_dev_init(void)
333 int gpio = N800_KEYB_IRQ_GPIO;
335 if (omap_request_gpio(gpio) < 0) {
336 printk("can't get KBIRQ GPIO\n");
339 omap_set_gpio_direction(gpio, 1);
340 tsc2301_config.keyb_int = OMAP_GPIO_IRQ(gpio);
343 static struct omap2_mcspi_device_config tsc2301_mcspi_config = {
348 static struct omap2_mcspi_device_config mipid_mcspi_config = {
353 static struct omap2_mcspi_device_config cx3110x_mcspi_config = {
358 static struct spi_board_info n800_spi_board_info[] __initdata = {
360 .modalias = "lcd_mipid",
363 .max_speed_hz = 4000000,
364 .controller_data= &mipid_mcspi_config,
365 .platform_data = &n800_mipid_platform_data,
367 .modalias = "cx3110x",
370 .max_speed_hz = 48000000,
371 .controller_data= &cx3110x_mcspi_config,
373 .modalias = "tsc2301",
376 .max_speed_hz = 6000000,
377 .controller_data= &tsc2301_mcspi_config,
378 .platform_data = &tsc2301_config,
382 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_LEDS_OMAP_PWM)
384 void retu_keypad_led_set_power(struct omap_pwm_led_platform_data *self,
388 retu_write_reg(RETU_REG_CTRL_SET, 1 << 6);
390 retu_write_reg(RETU_REG_CTRL_SET, 1 << 3);
392 retu_write_reg(RETU_REG_CTRL_CLR, (1 << 6) | (1 << 3));
396 static struct omap_pwm_led_platform_data n800_keypad_led_data = {
398 .intensity_timer = 10,
400 .set_power = retu_keypad_led_set_power,
403 static struct platform_device n800_keypad_led_device = {
404 .name = "omap_pwm_led",
407 .platform_data = &n800_keypad_led_data,
412 #if defined(CONFIG_SPI_TSC2301_TOUCHSCREEN)
413 static void __init n800_ts_set_config(void)
415 const struct omap_lcd_config *conf;
417 conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
419 if (strcmp(conf->panel_name, "lph8923") == 0) {
420 tsc2301_config.ts_x_plate_ohm = 180;
421 tsc2301_config.ts_hw_avg = 4;
422 tsc2301_config.ts_ignore_last = 1;
423 tsc2301_config.ts_max_pressure = 255;
424 tsc2301_config.ts_stab_time = 100;
425 } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
426 tsc2301_config.ts_x_plate_ohm = 280;
427 tsc2301_config.ts_hw_avg = 16;
428 tsc2301_config.ts_touch_pressure= 215;
429 tsc2301_config.ts_max_pressure = 255;
430 tsc2301_config.ts_ignore_last = 1;
432 printk(KERN_ERR "Unknown panel type, set default "
433 "touchscreen configuration\n");
434 tsc2301_config.ts_x_plate_ohm = 200;
435 tsc2301_config.ts_stab_time = 100;
440 static inline void n800_ts_set_config(void)
445 extern void n800_mmc_slot1_cover_handler(void *arg, int state);
447 static struct omap_gpio_switch n800_gpio_switches[] __initdata = {
451 .debounce_rising = 100,
452 .debounce_falling = 0,
453 .notify = n800_mmc_slot1_cover_handler,
458 .debounce_rising = 200,
459 .debounce_falling = 200,
463 .debounce_rising = 200,
464 .debounce_falling = 200,
468 .debounce_rising = 100,
469 .debounce_falling = 100,
473 static struct platform_device *n800_devices[] __initdata = {
474 #if defined(CONFIG_CBUS_RETU) && defined(CONFIG_LEDS_OMAP_PWM)
475 &n800_keypad_led_device,
479 extern void __init n800_flash_init(void);
480 extern void __init n800_mmc_init(void);
481 extern void __init n800_bt_init(void);
482 extern void __init n800_audio_init(struct tsc2301_platform_data *);
483 extern void __init n800_dsp_init(void);
484 extern void __init n800_usb_init(void);
485 extern void __init n800_pm_init(void);
487 static void __init nokia_n800_init(void)
489 platform_add_devices(n800_devices, ARRAY_SIZE(n800_devices));
493 n800_audio_init(&tsc2301_config);
497 n800_ts_set_config();
498 spi_register_board_info(n800_spi_board_info,
499 ARRAY_SIZE(n800_spi_board_info));
504 omap_register_gpio_switches(n800_gpio_switches,
505 ARRAY_SIZE(n800_gpio_switches));
509 static void __init nokia_n800_map_io(void)
511 omap_board_config = n800_config;
512 omap_board_config_size = ARRAY_SIZE(n800_config);
514 omap2_map_common_io();
517 MACHINE_START(NOKIA_N800, "Nokia N800")
518 .phys_io = 0x48000000,
519 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
520 .boot_params = 0x80000100,
521 .map_io = nokia_n800_map_io,
522 .init_irq = nokia_n800_init_irq,
523 .init_machine = nokia_n800_init,
524 .timer = &omap_timer,