blob: a43a765dd0921d1d1fee5fb5d195f0dfdfd68f60 [file] [log] [blame]
Kishore Ya6490332010-11-15 07:09:03 +01001/*
2 * Copyright (C) 2010 Texas Instruments Inc.
3 *
4 * Modified from mach-omap2/board-zoom-peripherals.c
5 *
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.
9 */
10
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>
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030018#include <video/omapdss.h>
Kishore Ya6490332010-11-15 07:09:03 +010019
20#define LCD_PANEL_RESET_GPIO_PROD 96
21#define LCD_PANEL_RESET_GPIO_PILOT 55
22#define LCD_PANEL_QVGA_GPIO 56
23
Igor Grinbergbc593f52011-05-03 18:22:09 +030024static struct gpio zoom_lcd_gpios[] __initdata = {
25 { -EINVAL, GPIOF_OUT_INIT_HIGH, "lcd reset" },
26 { LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "lcd qvga" },
27};
28
Santosh Shilimkar89c47052011-05-30 00:11:45 -070029static void __init zoom_lcd_panel_init(void)
Kishore Ya6490332010-11-15 07:09:03 +010030{
Igor Grinbergbc593f52011-05-03 18:22:09 +030031 zoom_lcd_gpios[0].gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?
Kishore Ya6490332010-11-15 07:09:03 +010032 LCD_PANEL_RESET_GPIO_PROD :
33 LCD_PANEL_RESET_GPIO_PILOT;
34
Igor Grinbergbc593f52011-05-03 18:22:09 +030035 if (gpio_request_array(zoom_lcd_gpios, ARRAY_SIZE(zoom_lcd_gpios)))
36 pr_err("%s: Failed to get LCD GPIOs.\n", __func__);
Kishore Ya6490332010-11-15 07:09:03 +010037}
38
39static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
40{
41 return 0;
42}
43
44static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
45{
46}
47
48/*
49 * PWMA/B register offsets (TWL4030_MODULE_PWMA)
50 */
51#define TWL_INTBR_PMBR1 0xD
52#define TWL_INTBR_GPBR1 0xC
53#define TWL_LED_PWMON 0x0
54#define TWL_LED_PWMOFF 0x1
55
56static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
57{
Tony Lindgren38232f72012-02-23 14:29:59 -080058#ifdef CONFIG_TWL4030_CORE
Kishore Ya6490332010-11-15 07:09:03 +010059 unsigned char c;
60 u8 mux_pwm, enb_pwm;
61
62 if (level > 100)
63 return -1;
64
65 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
66 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
67
68 if (level == 0) {
69 /* disable pwm1 output and clock */
70 enb_pwm = enb_pwm & 0xF5;
71 /* change pwm1 pin to gpio pin */
72 mux_pwm = mux_pwm & 0xCF;
73 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
74 enb_pwm, TWL_INTBR_GPBR1);
75 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
76 mux_pwm, TWL_INTBR_PMBR1);
77 return 0;
78 }
79
80 if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
81 /* change gpio pin to pwm1 pin */
82 mux_pwm = mux_pwm | 0x30;
83 /* enable pwm1 output and clock*/
84 enb_pwm = enb_pwm | 0x0A;
85 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
86 mux_pwm, TWL_INTBR_PMBR1);
87 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
88 enb_pwm, TWL_INTBR_GPBR1);
89 }
90
91 c = ((50 * (100 - level)) / 100) + 1;
92 twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
93 twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
Tony Lindgren38232f72012-02-23 14:29:59 -080094#else
95 pr_warn("Backlight not enabled\n");
96#endif
Kishore Ya6490332010-11-15 07:09:03 +010097
98 return 0;
99}
100
101static struct omap_dss_device zoom_lcd_device = {
102 .name = "lcd",
103 .driver_name = "NEC_8048_panel",
104 .type = OMAP_DISPLAY_TYPE_DPI,
105 .phy.dpi.data_lines = 24,
106 .platform_enable = zoom_panel_enable_lcd,
107 .platform_disable = zoom_panel_disable_lcd,
108 .max_backlight_level = 100,
109 .set_backlight = zoom_set_bl_intensity,
110};
111
112static struct omap_dss_device *zoom_dss_devices[] = {
113 &zoom_lcd_device,
114};
115
116static struct omap_dss_board_info zoom_dss_data = {
117 .num_devices = ARRAY_SIZE(zoom_dss_devices),
118 .devices = zoom_dss_devices,
119 .default_device = &zoom_lcd_device,
120};
121
Kishore Ya6490332010-11-15 07:09:03 +0100122static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
123 .turbo_mode = 1,
Kishore Ya6490332010-11-15 07:09:03 +0100124};
125
126static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
127 [0] = {
128 .modalias = "nec_8048_spi",
129 .bus_num = 1,
130 .chip_select = 2,
131 .max_speed_hz = 375000,
132 .controller_data = &dss_lcd_mcspi_config,
133 },
134};
135
Kishore Ya6490332010-11-15 07:09:03 +0100136void __init zoom_display_init(void)
137{
Senthilvadivu Guruswamyd5e13222011-02-22 11:24:50 +0200138 omap_display_init(&zoom_dss_data);
Kishore Ya6490332010-11-15 07:09:03 +0100139 spi_register_board_info(nec_8048_spi_board_info,
140 ARRAY_SIZE(nec_8048_spi_board_info));
141 zoom_lcd_panel_init();
142}
143