2 * Copyright (C) 2010 Texas Instruments Inc.
4 * Modified from mach-omap2/board-zoom-peripherals.c
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/gpio.h>
15 #include <linux/i2c/twl.h>
16 #include <linux/spi/spi.h>
17 #include <plat/mcspi.h>
18 #include <plat/display.h>
20 #define LCD_PANEL_RESET_GPIO_PROD 96
21 #define LCD_PANEL_RESET_GPIO_PILOT 55
22 #define LCD_PANEL_QVGA_GPIO 56
24 static void zoom_lcd_panel_init(void)
27 unsigned char lcd_panel_reset_gpio
;
29 lcd_panel_reset_gpio
= (omap_rev() > OMAP3430_REV_ES3_0
) ?
30 LCD_PANEL_RESET_GPIO_PROD
:
31 LCD_PANEL_RESET_GPIO_PILOT
;
33 ret
= gpio_request(lcd_panel_reset_gpio
, "lcd reset");
35 pr_err("Failed to get LCD reset GPIO (gpio%d).\n",
36 lcd_panel_reset_gpio
);
39 gpio_direction_output(lcd_panel_reset_gpio
, 1);
41 ret
= gpio_request(LCD_PANEL_QVGA_GPIO
, "lcd qvga");
43 pr_err("Failed to get LCD_PANEL_QVGA_GPIO (gpio%d).\n",
47 gpio_direction_output(LCD_PANEL_QVGA_GPIO
, 1);
51 gpio_free(lcd_panel_reset_gpio
);
54 static int zoom_panel_enable_lcd(struct omap_dss_device
*dssdev
)
59 static void zoom_panel_disable_lcd(struct omap_dss_device
*dssdev
)
64 * PWMA/B register offsets (TWL4030_MODULE_PWMA)
66 #define TWL_INTBR_PMBR1 0xD
67 #define TWL_INTBR_GPBR1 0xC
68 #define TWL_LED_PWMON 0x0
69 #define TWL_LED_PWMOFF 0x1
71 static int zoom_set_bl_intensity(struct omap_dss_device
*dssdev
, int level
)
79 twl_i2c_read_u8(TWL4030_MODULE_INTBR
, &mux_pwm
, TWL_INTBR_PMBR1
);
80 twl_i2c_read_u8(TWL4030_MODULE_INTBR
, &enb_pwm
, TWL_INTBR_GPBR1
);
83 /* disable pwm1 output and clock */
84 enb_pwm
= enb_pwm
& 0xF5;
85 /* change pwm1 pin to gpio pin */
86 mux_pwm
= mux_pwm
& 0xCF;
87 twl_i2c_write_u8(TWL4030_MODULE_INTBR
,
88 enb_pwm
, TWL_INTBR_GPBR1
);
89 twl_i2c_write_u8(TWL4030_MODULE_INTBR
,
90 mux_pwm
, TWL_INTBR_PMBR1
);
94 if (!((enb_pwm
& 0xA) && (mux_pwm
& 0x30))) {
95 /* change gpio pin to pwm1 pin */
96 mux_pwm
= mux_pwm
| 0x30;
97 /* enable pwm1 output and clock*/
98 enb_pwm
= enb_pwm
| 0x0A;
99 twl_i2c_write_u8(TWL4030_MODULE_INTBR
,
100 mux_pwm
, TWL_INTBR_PMBR1
);
101 twl_i2c_write_u8(TWL4030_MODULE_INTBR
,
102 enb_pwm
, TWL_INTBR_GPBR1
);
105 c
= ((50 * (100 - level
)) / 100) + 1;
106 twl_i2c_write_u8(TWL4030_MODULE_PWM1
, 0x7F, TWL_LED_PWMOFF
);
107 twl_i2c_write_u8(TWL4030_MODULE_PWM1
, c
, TWL_LED_PWMON
);
112 static struct omap_dss_device zoom_lcd_device
= {
114 .driver_name
= "NEC_8048_panel",
115 .type
= OMAP_DISPLAY_TYPE_DPI
,
116 .phy
.dpi
.data_lines
= 24,
117 .platform_enable
= zoom_panel_enable_lcd
,
118 .platform_disable
= zoom_panel_disable_lcd
,
119 .max_backlight_level
= 100,
120 .set_backlight
= zoom_set_bl_intensity
,
123 static struct omap_dss_device
*zoom_dss_devices
[] = {
127 static struct omap_dss_board_info zoom_dss_data
= {
128 .num_devices
= ARRAY_SIZE(zoom_dss_devices
),
129 .devices
= zoom_dss_devices
,
130 .default_device
= &zoom_lcd_device
,
133 static struct platform_device zoom_dss_device
= {
137 .platform_data
= &zoom_dss_data
,
141 static struct omap2_mcspi_device_config dss_lcd_mcspi_config
= {
143 .single_channel
= 1, /* 0: slave, 1: master */
146 static struct spi_board_info nec_8048_spi_board_info
[] __initdata
= {
148 .modalias
= "nec_8048_spi",
151 .max_speed_hz
= 375000,
152 .controller_data
= &dss_lcd_mcspi_config
,
156 static struct platform_device
*zoom_display_devices
[] __initdata
= {
160 void __init
zoom_display_init(void)
162 platform_add_devices(zoom_display_devices
,
163 ARRAY_SIZE(zoom_display_devices
));
164 spi_register_board_info(nec_8048_spi_board_info
,
165 ARRAY_SIZE(nec_8048_spi_board_info
));
166 zoom_lcd_panel_init();