1 From d0e8e774fdc82320822246fae3167302730bd7e8 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 | 408 +++++++++++++++++++++-------
8 1 files changed, 313 insertions(+), 95 deletions(-)
10 diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
11 index fc3e03c..ec7830e 100644
12 --- a/arch/arm/mach-omap2/board-omap3touchbook.c
13 +++ b/arch/arm/mach-omap2/board-omap3touchbook.c
16 * linux/arch/arm/mach-omap2/board-omap3touchbook.c
18 - * Copyright (C) 2009 Always Innovating
19 + * Copyright (C) 2009-2010 Always Innovating
21 * Modified from mach-omap2/board-omap3beagleboard.c
24 #include <linux/spi/spi.h>
26 #include <linux/spi/ads7846.h>
27 +#include <linux/mma7455l.h>
29 #include <linux/regulator/machine.h>
30 #include <linux/i2c/twl.h>
33 #include <plat/board.h>
34 #include <plat/common.h>
35 +#include <plat/display.h>
36 #include <plat/gpmc.h>
37 #include <plat/nand.h>
41 #include <asm/setup.h>
43 +#include <plat/dmtimer.h>
44 +#include <linux/backlight.h>
46 #define GPMC_CS0_BASE 0x60
47 #define GPMC_CS_SIZE 0x30
49 #define NAND_BLOCK_SIZE SZ_128K
51 +#define OMAP3_HJ_GPIO 56
52 #define OMAP3_AC_GPIO 136
53 +#define OMAP3_TS2_GPIO 154
54 #define OMAP3_TS_GPIO 162
55 #define TB_BL_PWM_TIMER 9
56 #define TB_KILL_POWER_GPIO 168
58 -unsigned long touchbook_revision;
59 +unsigned long ai_revision = 2;
61 static struct mtd_partition omap3touchbook_nand_partitions[] = {
62 /* All the partition sizes are listed in terms of NAND block size */
63 @@ -126,6 +132,103 @@ static struct platform_device omap3touchbook_nand_device = {
64 .resource = &omap3touchbook_nand_resource,
67 +static int touchbook_enable_dvi(struct omap_dss_device *dssdev)
69 + if (dssdev->reset_gpio != -1)
70 + gpio_set_value(dssdev->reset_gpio, 1);
75 +static void touchbook_disable_dvi(struct omap_dss_device *dssdev)
77 + if (dssdev->reset_gpio != -1)
78 + gpio_set_value(dssdev->reset_gpio, 0);
81 +static struct omap_dss_device touchbook_dvi_device = {
82 + .type = OMAP_DISPLAY_TYPE_DPI,
84 + .driver_name = "generic_panel",
85 + .phy.dpi.data_lines = 24,
87 + .platform_enable = touchbook_enable_dvi,
88 + .platform_disable = touchbook_disable_dvi,
91 +static int touchbook_panel_enable_tv(struct omap_dss_device *dssdev)
93 +#define ENABLE_VDAC_DEDICATED 0x03
94 +#define ENABLE_VDAC_DEV_GRP 0x20
96 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
97 + ENABLE_VDAC_DEDICATED,
98 + TWL4030_VDAC_DEDICATED);
99 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
100 + ENABLE_VDAC_DEV_GRP, TWL4030_VDAC_DEV_GRP);
105 +static void touchbook_panel_disable_tv(struct omap_dss_device *dssdev)
107 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
108 + TWL4030_VDAC_DEDICATED);
109 + twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
110 + TWL4030_VDAC_DEV_GRP);
113 +static struct omap_dss_device touchbook_tv_device = {
115 + .driver_name = "venc",
116 + .type = OMAP_DISPLAY_TYPE_VENC,
117 + .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
118 + .platform_enable = touchbook_panel_enable_tv,
119 + .platform_disable = touchbook_panel_disable_tv,
122 +static struct omap_dss_device *touchbook_dss_devices[] = {
123 + &touchbook_dvi_device,
124 + &touchbook_tv_device,
127 +static struct omap_dss_board_info touchbook_dss_data = {
128 + .num_devices = ARRAY_SIZE(touchbook_dss_devices),
129 + .devices = touchbook_dss_devices,
130 + .default_device = &touchbook_dvi_device,
133 +static struct platform_device touchbook_dss_device = {
137 + .platform_data = &touchbook_dss_data,
141 +static struct regulator_consumer_supply touchbook_vdac_supply = {
142 + .supply = "vdda_dac",
143 + .dev = &touchbook_dss_device.dev,
146 +static struct regulator_consumer_supply touchbook_vdvi_supply = {
147 + .supply = "vdds_dsi",
148 + .dev = &touchbook_dss_device.dev,
151 +static void __init touchbook_display_init(void)
155 + r = gpio_request(touchbook_dvi_device.reset_gpio, "DVI reset");
157 + printk(KERN_ERR "Unable to get DVI reset GPIO\n");
161 + gpio_direction_output(touchbook_dvi_device.reset_gpio, 0);
164 #include "sdram-micron-mt46h32m32lf-6.h"
166 static struct twl4030_hsmmc_info mmc[] = {
167 @@ -137,15 +240,6 @@ static struct twl4030_hsmmc_info mmc[] = {
171 -static struct platform_device omap3_touchbook_lcd_device = {
172 - .name = "omap3touchbook_lcd",
176 -static struct omap_lcd_config omap3_touchbook_lcd_config __initdata = {
177 - .ctrl_name = "internal",
180 static struct regulator_consumer_supply touchbook_vmmc1_supply = {
183 @@ -177,6 +271,7 @@ static int touchbook_twl_gpio_setup(struct device *dev,
184 * power switch and overcurrent detect
188 gpio_request(gpio + 1, "EHCI_nOC");
189 gpio_direction_input(gpio + 1);
191 @@ -187,6 +282,7 @@ static int touchbook_twl_gpio_setup(struct device *dev,
192 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
193 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
199 @@ -201,16 +297,6 @@ static struct twl4030_gpio_platform_data touchbook_gpio_data = {
200 .setup = touchbook_twl_gpio_setup,
203 -static struct regulator_consumer_supply touchbook_vdac_supply = {
205 - .dev = &omap3_touchbook_lcd_device.dev,
208 -static struct regulator_consumer_supply touchbook_vdvi_supply = {
210 - .dev = &omap3_touchbook_lcd_device.dev,
213 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
214 static struct regulator_init_data touchbook_vmmc1 = {
216 @@ -283,6 +369,10 @@ static struct twl4030_codec_data touchbook_codec_data = {
217 .audio = &touchbook_audio_data,
220 +static struct twl4030_madc_platform_data touchbook_madc_data = {
224 static struct twl4030_platform_data touchbook_twldata = {
225 .irq_base = TWL4030_IRQ_BASE,
226 .irq_end = TWL4030_IRQ_END,
227 @@ -291,6 +381,7 @@ static struct twl4030_platform_data touchbook_twldata = {
228 .usb = &touchbook_usb_data,
229 .gpio = &touchbook_gpio_data,
230 .codec = &touchbook_codec_data,
231 + .madc = &touchbook_madc_data,
232 .vmmc1 = &touchbook_vmmc1,
233 .vsim = &touchbook_vsim,
234 .vdac = &touchbook_vdac,
235 @@ -310,10 +401,18 @@ static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = {
237 I2C_BOARD_INFO("bq27200", 0x55),
240 + I2C_BOARD_INFO("chacha", 0x40),
241 + .irq = OMAP_GPIO_IRQ(OMAP3_TS2_GPIO),
244 + I2C_BOARD_INFO("ds1307", 0x68),
248 static int __init omap3_touchbook_i2c_init(void)
251 /* Standard TouchBook bus */
252 omap_register_i2c_bus(1, 2600, touchbook_i2c_boardinfo,
253 ARRAY_SIZE(touchbook_i2c_boardinfo));
254 @@ -322,53 +421,16 @@ static int __init omap3_touchbook_i2c_init(void)
255 omap_register_i2c_bus(3, 100, touchBook_i2c_boardinfo,
256 ARRAY_SIZE(touchBook_i2c_boardinfo));
261 -static void __init omap3_ads7846_init(void)
263 - if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
264 - printk(KERN_ERR "Failed to request GPIO %d for "
265 - "ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
267 + ret = gpio_request(OMAP3_TS2_GPIO, "chacha");
269 + printk(KERN_ERR "Failed to request GPIO %d for chacha IRQ\n", OMAP3_TS2_GPIO);
272 + gpio_direction_input(OMAP3_TS2_GPIO);
274 - gpio_direction_input(OMAP3_TS_GPIO);
275 - omap_set_gpio_debounce(OMAP3_TS_GPIO, 1);
276 - omap_set_gpio_debounce_time(OMAP3_TS_GPIO, 0xa);
280 -static struct ads7846_platform_data ads7846_config = {
285 - .x_plate_ohms = 40,
286 - .pressure_max = 255,
287 - .debounce_max = 10,
290 - .gpio_pendown = OMAP3_TS_GPIO,
294 -static struct omap2_mcspi_device_config ads7846_mcspi_config = {
296 - .single_channel = 1, /* 0: slave, 1: master */
299 -static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = {
301 - .modalias = "ads7846",
304 - .max_speed_hz = 1500000,
305 - .controller_data = &ads7846_mcspi_config,
306 - .irq = OMAP_GPIO_IRQ(OMAP3_TS_GPIO),
307 - .platform_data = &ads7846_config,
311 static struct gpio_led gpio_leds[] = {
313 .name = "touchbook::usr0",
314 @@ -412,6 +474,7 @@ static struct gpio_keys_button gpio_buttons[] = {
322 @@ -428,23 +491,8 @@ static struct platform_device keys_gpio = {
326 -static struct omap_board_config_kernel omap3_touchbook_config[] __initdata = {
327 - { OMAP_TAG_LCD, &omap3_touchbook_lcd_config },
330 -#ifdef CONFIG_OMAP_MUX
331 -static struct omap_board_mux board_mux[] __initdata = {
332 - { .reg_offset = OMAP_MUX_TERMINATOR },
335 -#define board_mux NULL
338 static void __init omap3_touchbook_init_irq(void)
340 - omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
341 - omap_board_config = omap3_touchbook_config;
342 - omap_board_config_size = ARRAY_SIZE(omap3_touchbook_config);
343 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
344 mt46h32m32lf6_sdrc_params, omap35x_mpu_rate_table,
345 omap35x_dsp_rate_table, omap35x_l3_rate_table);
346 @@ -456,9 +504,9 @@ static void __init omap3_touchbook_init_irq(void)
349 static struct platform_device *omap3_touchbook_devices[] __initdata = {
350 - &omap3_touchbook_lcd_device,
353 + &touchbook_dss_device,
356 static void __init omap3touchbook_flash_init(void)
357 @@ -500,7 +548,7 @@ static void __init omap3touchbook_flash_init(void)
361 -static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
362 +static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
364 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
365 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
366 @@ -512,6 +560,170 @@ static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
367 .reset_gpio_port[2] = -EINVAL
370 +#ifdef CONFIG_OMAP_MUX
371 +static struct omap_board_mux board_mux[] __initdata = {
372 + { .reg_offset = OMAP_MUX_TERMINATOR },
375 +#define board_mux NULL
378 +static struct ads7846_platform_data ads7846_config = {
383 + .x_plate_ohms = 40,
384 + .pressure_max = 255,
385 + .debounce_max = 10,
388 + .gpio_pendown = OMAP3_TS_GPIO,
392 +static struct omap2_mcspi_device_config ads7846_mcspi_config = {
394 + .single_channel = 1, /* 0: slave, 1: master */
397 +static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = {
399 + .modalias = "ads7846",
402 + .max_speed_hz = 1500000,
403 + .controller_data = &ads7846_mcspi_config,
404 + .irq = OMAP_GPIO_IRQ(OMAP3_TS_GPIO),
405 + .platform_data = &ads7846_config,
409 +static void __init omap3_ads7846_init(void)
411 + if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
412 + printk(KERN_ERR "Failed to request GPIO %d for "
413 + "ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
417 + gpio_direction_input(OMAP3_TS_GPIO);
418 + omap_set_gpio_debounce(OMAP3_TS_GPIO, 1);
419 + omap_set_gpio_debounce_time(OMAP3_TS_GPIO, 0xa);
422 +static struct mma7455l_platform_data mma7455l_config = {
423 + .calibration_x = -4,
424 + .calibration_y = 28,
425 + .calibration_z = -28,
428 +static struct omap2_mcspi_device_config mma7455l_mcspi_config = {
430 + .single_channel = 1, /* 0: slave, 1: master */
433 +static struct spi_board_info omap3_mma7455l_spi_board_info[] __initdata = {
435 + .modalias = "mma7455l",
438 + .max_speed_hz = 200000,
439 + .irq = OMAP_GPIO_IRQ(OMAP3_AC_GPIO),
440 + .controller_data = &mma7455l_mcspi_config, //(void *) 135,
441 + .platform_data = &mma7455l_config,
445 +static void __init omap3_mma7455l_init(void)
449 + ret = gpio_request(OMAP3_AC_GPIO, "mma7455l");
451 + printk(KERN_ERR "Failed to request GPIO %d for mma7455l IRQ\n", OMAP3_AC_GPIO);
455 + gpio_direction_input(OMAP3_AC_GPIO);
458 +static int touchbook_backlight_brightness = 50;
459 +static struct omap_dm_timer *touchbook_backlight_pwm;
461 +static int touchbook_backlight_read(struct backlight_device *bd)
463 + return touchbook_backlight_brightness;
466 +static int touchbook_backlight_update(struct backlight_device *bd)
468 + int value = bd->props.brightness;
469 + touchbook_backlight_brightness = value;
471 + /* Frequency calculation:
472 + - For 200Hz PWM, you want to load -164 (=> -32768Hz / 200Hz).
473 + - Minimum duty cycle for the backlight is 15%.
474 + - You have (164*0.85) => ~140 levels of brightness.
477 + /* Halve input brightness */
478 + if (!bd->props.boost)
481 + /* For maximum brightness, just stop the timer... */
482 + if(value != bd->props.max_brightness)
484 + /* Load the appropriate value for 200Hz PWM */
485 + u32 period = clk_get_rate(omap_dm_timer_get_fclk(touchbook_backlight_pwm)) / bd->props.pwm_fq;
487 + /* Minimum duty cycle is 15% */
488 + u32 minimum = (period * bd->props.min_duty) / 100;
489 + u32 maximum = (period * 17) / 20;
491 + /* Work out match value */
492 + u32 match = (maximum * value) / 100;
495 + omap_dm_timer_set_load(touchbook_backlight_pwm, 1, 0xFFFFFFFF - period - 1);
496 + omap_dm_timer_set_match(touchbook_backlight_pwm, 1, 0xFFFFFFFF - minimum - match);
497 + omap_dm_timer_write_counter(touchbook_backlight_pwm, -1);
498 + omap_dm_timer_start(touchbook_backlight_pwm);
501 + omap_dm_timer_stop(touchbook_backlight_pwm);
507 +static struct backlight_ops touchbook_backlight_properties = {
508 + .get_brightness = touchbook_backlight_read,
509 + .update_status = touchbook_backlight_update,
512 +static void __init omap3_touchbook_backlight_init(void)
514 + static struct backlight_device *bd;
515 + bd = backlight_device_register("touchbook", NULL, NULL, &touchbook_backlight_properties);
519 + touchbook_backlight_pwm = omap_dm_timer_request_specific(TB_BL_PWM_TIMER);
520 + omap_dm_timer_enable(touchbook_backlight_pwm);
521 + omap_dm_timer_set_source(touchbook_backlight_pwm, OMAP_TIMER_SRC_SYS_CLK);
522 + omap_dm_timer_set_pwm(touchbook_backlight_pwm, 1, 1, OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);
524 + bd->props.max_brightness = 100;
525 + bd->props.brightness = touchbook_backlight_brightness;
526 + bd->props.boost = 0;
527 + bd->props.min_duty = 15;
528 + bd->props.pwm_fq = 200;
531 + touchbook_backlight_update(bd);
534 static void omap3_touchbook_poweroff(void)
537 @@ -525,33 +737,26 @@ static void omap3_touchbook_poweroff(void)
538 gpio_direction_output(TB_KILL_POWER_GPIO, 0);
541 -static void __init early_touchbook_revision(char **p)
542 +static int __init ai_revision_instance(char *str)
549 + ai_revision = simple_strtoul(str, NULL, 10);
551 - strict_strtoul(*p, 10, &touchbook_revision);
554 -__early_param("tbr=", early_touchbook_revision);
556 static void __init omap3_touchbook_init(void)
558 pm_power_off = omap3_touchbook_poweroff;
560 + omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
561 omap3_touchbook_i2c_init();
562 platform_add_devices(omap3_touchbook_devices,
563 ARRAY_SIZE(omap3_touchbook_devices));
566 - omap_mux_init_gpio(170, OMAP_PIN_INPUT);
567 - gpio_request(176, "DVI_nPD");
568 - /* REVISIT leave DVI powered down until it's needed ... */
569 - gpio_direction_output(176, true);
571 - /* Touchscreen and accelerometer */
572 - spi_register_board_info(omap3_ads7846_spi_board_info,
573 - ARRAY_SIZE(omap3_ads7846_spi_board_info));
574 - omap3_ads7846_init();
576 usb_ehci_init(&ehci_pdata);
577 omap3touchbook_flash_init();
578 @@ -559,6 +764,17 @@ static void __init omap3_touchbook_init(void)
579 /* Ensure SDRC pins are mux'd for self-refresh */
580 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
581 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
583 + touchbook_display_init();
584 + omap3_touchbook_backlight_init();
586 + /* Touchscreen and accelerometer */
587 + spi_register_board_info(omap3_ads7846_spi_board_info,
588 + ARRAY_SIZE(omap3_ads7846_spi_board_info));
589 + spi_register_board_info(omap3_mma7455l_spi_board_info,
590 + ARRAY_SIZE(omap3_mma7455l_spi_board_info));
591 + omap3_ads7846_init();
592 + omap3_mma7455l_init();
595 static void __init omap3_touchbook_map_io(void)
596 @@ -567,6 +783,8 @@ static void __init omap3_touchbook_map_io(void)
597 omap2_map_common_io();
600 +early_param("air", ai_revision_instance);
602 MACHINE_START(TOUCHBOOK, "OMAP3 touchbook Board")
603 /* Maintainer: Gregoire Gentil - http://www.alwaysinnovating.com */
604 .phys_io = 0x48000000,