1 From bd54c9c7527199156f6cd16bf3e02ebf9d663feb Mon Sep 17 00:00:00 2001
2 From: Gregoire Gentil <gregoire@gentil.com>
3 Date: Fri, 12 Mar 2010 11:49:16 +0100
4 Subject: [PATCH 16/16] ARM: OMAP: omap3-touchbook: update boardfile
7 arch/arm/mach-omap2/board-omap3touchbook.c | 394 +++++++++++++++++++++-------
8 1 files changed, 305 insertions(+), 89 deletions(-)
10 diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
11 index fc3e03c..3628362 100644
12 --- a/arch/arm/mach-omap2/board-omap3touchbook.c
13 +++ b/arch/arm/mach-omap2/board-omap3touchbook.c
15 #include <linux/spi/spi.h>
17 #include <linux/spi/ads7846.h>
18 +#include <linux/mma7455l.h>
20 #include <linux/regulator/machine.h>
21 #include <linux/i2c/twl.h>
24 #include <plat/board.h>
25 #include <plat/common.h>
26 +#include <plat/display.h>
27 #include <plat/gpmc.h>
28 #include <plat/nand.h>
32 #include <asm/setup.h>
34 +#include <plat/dmtimer.h>
35 +#include <linux/backlight.h>
37 #define GPMC_CS0_BASE 0x60
38 #define GPMC_CS_SIZE 0x30
41 #define OMAP3_AC_GPIO 136
42 #define OMAP3_TS_GPIO 162
43 +#define OMAP3_CHACHA_GPIO 154
44 #define TB_BL_PWM_TIMER 9
45 #define TB_KILL_POWER_GPIO 168
47 -unsigned long touchbook_revision;
48 +unsigned long ai_revision = 2;
50 static struct mtd_partition omap3touchbook_nand_partitions[] = {
51 /* All the partition sizes are listed in terms of NAND block size */
52 @@ -126,6 +131,103 @@ static struct platform_device omap3touchbook_nand_device = {
53 .resource = &omap3touchbook_nand_resource,
56 +static int touchbook_enable_dvi(struct omap_dss_device *dssdev)
58 + if (dssdev->reset_gpio != -1)
59 + gpio_set_value(dssdev->reset_gpio, 1);
64 +static void touchbook_disable_dvi(struct omap_dss_device *dssdev)
66 + if (dssdev->reset_gpio != -1)
67 + gpio_set_value(dssdev->reset_gpio, 0);
70 +static struct omap_dss_device touchbook_dvi_device = {
71 + .type = OMAP_DISPLAY_TYPE_DPI,
73 + .driver_name = "generic_panel",
74 + .phy.dpi.data_lines = 24,
76 + .platform_enable = touchbook_enable_dvi,
77 + .platform_disable = touchbook_disable_dvi,
80 +static int touchbook_panel_enable_tv(struct omap_dss_device *dssdev)
82 +#define ENABLE_VDAC_DEDICATED 0x03
83 +#define ENABLE_VDAC_DEV_GRP 0x20
85 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
86 + ENABLE_VDAC_DEDICATED,
87 + TWL4030_VDAC_DEDICATED);
88 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
89 + ENABLE_VDAC_DEV_GRP, TWL4030_VDAC_DEV_GRP);
94 +static void touchbook_panel_disable_tv(struct omap_dss_device *dssdev)
96 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
97 + TWL4030_VDAC_DEDICATED);
98 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
99 + TWL4030_VDAC_DEV_GRP);
102 +static struct omap_dss_device touchbook_tv_device = {
104 + .driver_name = "venc",
105 + .type = OMAP_DISPLAY_TYPE_VENC,
106 + .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
107 + .platform_enable = touchbook_panel_enable_tv,
108 + .platform_disable = touchbook_panel_disable_tv,
111 +static struct omap_dss_device *touchbook_dss_devices[] = {
112 + &touchbook_dvi_device,
113 + &touchbook_tv_device,
116 +static struct omap_dss_board_info touchbook_dss_data = {
117 + .num_devices = ARRAY_SIZE(touchbook_dss_devices),
118 + .devices = touchbook_dss_devices,
119 + .default_device = &touchbook_dvi_device,
122 +static struct platform_device touchbook_dss_device = {
126 + .platform_data = &touchbook_dss_data,
130 +static struct regulator_consumer_supply touchbook_vdac_supply = {
131 + .supply = "vdda_dac",
132 + .dev = &touchbook_dss_device.dev,
135 +static struct regulator_consumer_supply touchbook_vdvi_supply = {
136 + .supply = "vdds_dsi",
137 + .dev = &touchbook_dss_device.dev,
140 +static void __init touchbook_display_init(void)
144 + r = gpio_request(touchbook_dvi_device.reset_gpio, "DVI reset");
146 + printk(KERN_ERR "Unable to get DVI reset GPIO\n");
150 + gpio_direction_output(touchbook_dvi_device.reset_gpio, 0);
153 #include "sdram-micron-mt46h32m32lf-6.h"
155 static struct twl4030_hsmmc_info mmc[] = {
156 @@ -137,15 +239,6 @@ static struct twl4030_hsmmc_info mmc[] = {
160 -static struct platform_device omap3_touchbook_lcd_device = {
161 - .name = "omap3touchbook_lcd",
165 -static struct omap_lcd_config omap3_touchbook_lcd_config __initdata = {
166 - .ctrl_name = "internal",
169 static struct regulator_consumer_supply touchbook_vmmc1_supply = {
172 @@ -177,6 +270,7 @@ static int touchbook_twl_gpio_setup(struct device *dev,
173 * power switch and overcurrent detect
177 gpio_request(gpio + 1, "EHCI_nOC");
178 gpio_direction_input(gpio + 1);
180 @@ -187,6 +281,7 @@ static int touchbook_twl_gpio_setup(struct device *dev,
181 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
182 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
188 @@ -201,16 +296,6 @@ static struct twl4030_gpio_platform_data touchbook_gpio_data = {
189 .setup = touchbook_twl_gpio_setup,
192 -static struct regulator_consumer_supply touchbook_vdac_supply = {
194 - .dev = &omap3_touchbook_lcd_device.dev,
197 -static struct regulator_consumer_supply touchbook_vdvi_supply = {
199 - .dev = &omap3_touchbook_lcd_device.dev,
202 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
203 static struct regulator_init_data touchbook_vmmc1 = {
205 @@ -283,6 +368,10 @@ static struct twl4030_codec_data touchbook_codec_data = {
206 .audio = &touchbook_audio_data,
209 +static struct twl4030_madc_platform_data touchbook_madc_data = {
213 static struct twl4030_platform_data touchbook_twldata = {
214 .irq_base = TWL4030_IRQ_BASE,
215 .irq_end = TWL4030_IRQ_END,
216 @@ -291,6 +380,7 @@ static struct twl4030_platform_data touchbook_twldata = {
217 .usb = &touchbook_usb_data,
218 .gpio = &touchbook_gpio_data,
219 .codec = &touchbook_codec_data,
220 + .madc = &touchbook_madc_data,
221 .vmmc1 = &touchbook_vmmc1,
222 .vsim = &touchbook_vsim,
223 .vdac = &touchbook_vdac,
224 @@ -310,10 +400,18 @@ static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = {
226 I2C_BOARD_INFO("bq27200", 0x55),
229 + I2C_BOARD_INFO("chacha", 0x40),
230 + .irq = OMAP_GPIO_IRQ(OMAP3_CHACHA_GPIO),
233 + I2C_BOARD_INFO("ds1307", 0x68),
237 static int __init omap3_touchbook_i2c_init(void)
240 /* Standard TouchBook bus */
241 omap_register_i2c_bus(1, 2600, touchbook_i2c_boardinfo,
242 ARRAY_SIZE(touchbook_i2c_boardinfo));
243 @@ -322,53 +420,16 @@ static int __init omap3_touchbook_i2c_init(void)
244 omap_register_i2c_bus(3, 100, touchBook_i2c_boardinfo,
245 ARRAY_SIZE(touchBook_i2c_boardinfo));
250 -static void __init omap3_ads7846_init(void)
252 - if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
253 - printk(KERN_ERR "Failed to request GPIO %d for "
254 - "ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
256 + ret = gpio_request(OMAP3_CHACHA_GPIO, "chacha");
258 + printk(KERN_ERR "Failed to request GPIO %d for chacha IRQ\n", OMAP3_CHACHA_GPIO);
261 + gpio_direction_input(OMAP3_CHACHA_GPIO);
263 - gpio_direction_input(OMAP3_TS_GPIO);
264 - omap_set_gpio_debounce(OMAP3_TS_GPIO, 1);
265 - omap_set_gpio_debounce_time(OMAP3_TS_GPIO, 0xa);
269 -static struct ads7846_platform_data ads7846_config = {
274 - .x_plate_ohms = 40,
275 - .pressure_max = 255,
276 - .debounce_max = 10,
279 - .gpio_pendown = OMAP3_TS_GPIO,
283 -static struct omap2_mcspi_device_config ads7846_mcspi_config = {
285 - .single_channel = 1, /* 0: slave, 1: master */
288 -static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = {
290 - .modalias = "ads7846",
293 - .max_speed_hz = 1500000,
294 - .controller_data = &ads7846_mcspi_config,
295 - .irq = OMAP_GPIO_IRQ(OMAP3_TS_GPIO),
296 - .platform_data = &ads7846_config,
300 static struct gpio_led gpio_leds[] = {
302 .name = "touchbook::usr0",
303 @@ -412,6 +473,7 @@ static struct gpio_keys_button gpio_buttons[] = {
311 @@ -428,23 +490,8 @@ static struct platform_device keys_gpio = {
315 -static struct omap_board_config_kernel omap3_touchbook_config[] __initdata = {
316 - { OMAP_TAG_LCD, &omap3_touchbook_lcd_config },
319 -#ifdef CONFIG_OMAP_MUX
320 -static struct omap_board_mux board_mux[] __initdata = {
321 - { .reg_offset = OMAP_MUX_TERMINATOR },
324 -#define board_mux NULL
327 static void __init omap3_touchbook_init_irq(void)
329 - omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
330 - omap_board_config = omap3_touchbook_config;
331 - omap_board_config_size = ARRAY_SIZE(omap3_touchbook_config);
332 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
333 mt46h32m32lf6_sdrc_params, omap35x_mpu_rate_table,
334 omap35x_dsp_rate_table, omap35x_l3_rate_table);
335 @@ -456,9 +503,9 @@ static void __init omap3_touchbook_init_irq(void)
338 static struct platform_device *omap3_touchbook_devices[] __initdata = {
339 - &omap3_touchbook_lcd_device,
342 + &touchbook_dss_device,
345 static void __init omap3touchbook_flash_init(void)
346 @@ -512,6 +559,170 @@ static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
347 .reset_gpio_port[2] = -EINVAL
350 +#ifdef CONFIG_OMAP_MUX
351 +static struct omap_board_mux board_mux[] __initdata = {
352 + { .reg_offset = OMAP_MUX_TERMINATOR },
355 +#define board_mux NULL
358 +static struct ads7846_platform_data ads7846_config = {
363 + .x_plate_ohms = 40,
364 + .pressure_max = 255,
365 + .debounce_max = 10,
368 + .gpio_pendown = OMAP3_TS_GPIO,
372 +static struct omap2_mcspi_device_config ads7846_mcspi_config = {
374 + .single_channel = 1, /* 0: slave, 1: master */
377 +static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = {
379 + .modalias = "ads7846",
382 + .max_speed_hz = 1500000,
383 + .controller_data = &ads7846_mcspi_config,
384 + .irq = OMAP_GPIO_IRQ(OMAP3_TS_GPIO),
385 + .platform_data = &ads7846_config,
389 +static void __init omap3_ads7846_init(void)
391 + if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
392 + printk(KERN_ERR "Failed to request GPIO %d for "
393 + "ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
397 + gpio_direction_input(OMAP3_TS_GPIO);
398 + omap_set_gpio_debounce(OMAP3_TS_GPIO, 1);
399 + omap_set_gpio_debounce_time(OMAP3_TS_GPIO, 0xa);
402 +static struct mma7455l_platform_data mma7455l_config = {
403 + .calibration_x = -4,
404 + .calibration_y = 28,
405 + .calibration_z = -28,
408 +static struct omap2_mcspi_device_config mma7455l_mcspi_config = {
410 + .single_channel = 1, /* 0: slave, 1: master */
413 +static struct spi_board_info omap3_mma7455l_spi_board_info[] __initdata = {
415 + .modalias = "mma7455l",
418 + .max_speed_hz = 200000,
419 + .irq = OMAP_GPIO_IRQ(OMAP3_AC_GPIO),
420 + .controller_data = &mma7455l_mcspi_config, //(void *) 135,
421 + .platform_data = &mma7455l_config,
425 +static void __init omap3_mma7455l_init(void)
429 + ret = gpio_request(OMAP3_AC_GPIO, "mma7455l");
431 + printk(KERN_ERR "Failed to request GPIO %d for mma7455l IRQ\n", OMAP3_AC_GPIO);
435 + gpio_direction_input(OMAP3_AC_GPIO);
438 +static int touchbook_backlight_brightness = 50;
439 +static struct omap_dm_timer *touchbook_backlight_pwm;
441 +static int touchbook_backlight_read(struct backlight_device *bd)
443 + return touchbook_backlight_brightness;
446 +static int touchbook_backlight_update(struct backlight_device *bd)
448 + int value = bd->props.brightness;
449 + touchbook_backlight_brightness = value;
451 + /* Frequency calculation:
452 + - For 200Hz PWM, you want to load -164 (=> -32768Hz / 200Hz).
453 + - Minimum duty cycle for the backlight is 15%.
454 + - You have (164*0.85) => ~140 levels of brightness.
457 + /* Halve input brightness */
458 + if (!bd->props.boost)
461 + /* For maximum brightness, just stop the timer... */
462 + if(value != bd->props.max_brightness)
464 + /* Load the appropriate value for 200Hz PWM */
465 + u32 period = clk_get_rate(omap_dm_timer_get_fclk(touchbook_backlight_pwm)) / bd->props.pwm_fq;
467 + /* Minimum duty cycle is 15% */
468 + u32 minimum = (period * bd->props.min_duty) / 100;
469 + u32 maximum = (period * 17) / 20;
471 + /* Work out match value */
472 + u32 match = (maximum * value) / 100;
475 + omap_dm_timer_set_load(touchbook_backlight_pwm, 1, 0xFFFFFFFF - period - 1);
476 + omap_dm_timer_set_match(touchbook_backlight_pwm, 1, 0xFFFFFFFF - minimum - match);
477 + omap_dm_timer_write_counter(touchbook_backlight_pwm, -1);
478 + omap_dm_timer_start(touchbook_backlight_pwm);
481 + omap_dm_timer_stop(touchbook_backlight_pwm);
487 +static struct backlight_ops touchbook_backlight_properties = {
488 + .get_brightness = touchbook_backlight_read,
489 + .update_status = touchbook_backlight_update,
492 +static void __init omap3_touchbook_backlight_init(void)
494 + static struct backlight_device *bd;
495 + bd = backlight_device_register("touchbook", NULL, NULL, &touchbook_backlight_properties);
499 + touchbook_backlight_pwm = omap_dm_timer_request_specific(TB_BL_PWM_TIMER);
500 + omap_dm_timer_enable(touchbook_backlight_pwm);
501 + omap_dm_timer_set_source(touchbook_backlight_pwm, OMAP_TIMER_SRC_SYS_CLK);
502 + omap_dm_timer_set_pwm(touchbook_backlight_pwm, 1, 1, OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);
504 + bd->props.max_brightness = 100;
505 + bd->props.brightness = touchbook_backlight_brightness;
506 + bd->props.boost = 0;
507 + bd->props.min_duty = 15;
508 + bd->props.pwm_fq = 200;
511 + touchbook_backlight_update(bd);
514 static void omap3_touchbook_poweroff(void)
517 @@ -525,33 +736,27 @@ static void omap3_touchbook_poweroff(void)
518 gpio_direction_output(TB_KILL_POWER_GPIO, 0);
521 -static void __init early_touchbook_revision(char **p)
522 +static void __init early_ai_revision(char **p)
527 - strict_strtoul(*p, 10, &touchbook_revision);
528 + strict_strtoul(*p, 10, &ai_revision);
530 -__early_param("tbr=", early_touchbook_revision);
531 +__early_param("air=", early_ai_revision);
533 static void __init omap3_touchbook_init(void)
535 pm_power_off = omap3_touchbook_poweroff;
537 + omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
538 omap3_touchbook_i2c_init();
539 platform_add_devices(omap3_touchbook_devices,
540 ARRAY_SIZE(omap3_touchbook_devices));
543 - omap_mux_init_gpio(170, OMAP_PIN_INPUT);
544 gpio_request(176, "DVI_nPD");
545 - /* REVISIT leave DVI powered down until it's needed ... */
546 - gpio_direction_output(176, true);
548 - /* Touchscreen and accelerometer */
549 - spi_register_board_info(omap3_ads7846_spi_board_info,
550 - ARRAY_SIZE(omap3_ads7846_spi_board_info));
551 - omap3_ads7846_init();
553 usb_ehci_init(&ehci_pdata);
554 omap3touchbook_flash_init();
555 @@ -559,6 +764,17 @@ static void __init omap3_touchbook_init(void)
556 /* Ensure SDRC pins are mux'd for self-refresh */
557 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
558 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
560 + touchbook_display_init();
561 + omap3_touchbook_backlight_init();
563 + /* Touchscreen and accelerometer */
564 + spi_register_board_info(omap3_ads7846_spi_board_info,
565 + ARRAY_SIZE(omap3_ads7846_spi_board_info));
566 + spi_register_board_info(omap3_mma7455l_spi_board_info,
567 + ARRAY_SIZE(omap3_mma7455l_spi_board_info));
568 + omap3_ads7846_init();
569 + omap3_mma7455l_init();
572 static void __init omap3_touchbook_map_io(void)