Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / arch / arm / mach-omap2 / board-zoom-display.c
CommitLineData
a6490335
K
1/*
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>
2203747c 17#include <linux/platform_data/spi-omap2-mcspi.h>
a0b38cc4 18#include <video/omapdss.h>
8599e7c5 19#include "board-zoom.h"
a6490335 20
e4c060db 21#include "soc.h"
dbc04161 22#include "common.h"
4b25408f 23
a6490335
K
24#define LCD_PANEL_RESET_GPIO_PROD 96
25#define LCD_PANEL_RESET_GPIO_PILOT 55
26#define LCD_PANEL_QVGA_GPIO 56
27
bc593f5d
IG
28static struct gpio zoom_lcd_gpios[] __initdata = {
29 { -EINVAL, GPIOF_OUT_INIT_HIGH, "lcd reset" },
30 { LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "lcd qvga" },
31};
32
89c4705e 33static void __init zoom_lcd_panel_init(void)
a6490335 34{
bc593f5d 35 zoom_lcd_gpios[0].gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?
a6490335
K
36 LCD_PANEL_RESET_GPIO_PROD :
37 LCD_PANEL_RESET_GPIO_PILOT;
38
bc593f5d
IG
39 if (gpio_request_array(zoom_lcd_gpios, ARRAY_SIZE(zoom_lcd_gpios)))
40 pr_err("%s: Failed to get LCD GPIOs.\n", __func__);
a6490335
K
41}
42
43static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
44{
45 return 0;
46}
47
48static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
49{
50}
51
c6dc9646 52/* Register offsets in TWL4030_MODULE_INTBR */
a6490335
K
53#define TWL_INTBR_PMBR1 0xD
54#define TWL_INTBR_GPBR1 0xC
c6dc9646
PU
55
56/* Register offsets in TWL_MODULE_PWM */
57#define TWL_LED_PWMON 0x3
58#define TWL_LED_PWMOFF 0x4
a6490335
K
59
60static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
61{
38232f7b 62#ifdef CONFIG_TWL4030_CORE
a6490335
K
63 unsigned char c;
64 u8 mux_pwm, enb_pwm;
65
66 if (level > 100)
67 return -1;
68
69 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
70 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
71
72 if (level == 0) {
73 /* disable pwm1 output and clock */
74 enb_pwm = enb_pwm & 0xF5;
75 /* change pwm1 pin to gpio pin */
76 mux_pwm = mux_pwm & 0xCF;
77 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
78 enb_pwm, TWL_INTBR_GPBR1);
79 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
80 mux_pwm, TWL_INTBR_PMBR1);
81 return 0;
82 }
83
84 if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
85 /* change gpio pin to pwm1 pin */
86 mux_pwm = mux_pwm | 0x30;
87 /* enable pwm1 output and clock*/
88 enb_pwm = enb_pwm | 0x0A;
89 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
90 mux_pwm, TWL_INTBR_PMBR1);
91 twl_i2c_write_u8(TWL4030_MODULE_INTBR,
92 enb_pwm, TWL_INTBR_GPBR1);
93 }
94
95 c = ((50 * (100 - level)) / 100) + 1;
c6dc9646
PU
96 twl_i2c_write_u8(TWL_MODULE_PWM, 0x7F, TWL_LED_PWMOFF);
97 twl_i2c_write_u8(TWL_MODULE_PWM, c, TWL_LED_PWMON);
38232f7b
TL
98#else
99 pr_warn("Backlight not enabled\n");
100#endif
a6490335
K
101
102 return 0;
103}
104
105static struct omap_dss_device zoom_lcd_device = {
106 .name = "lcd",
107 .driver_name = "NEC_8048_panel",
108 .type = OMAP_DISPLAY_TYPE_DPI,
109 .phy.dpi.data_lines = 24,
110 .platform_enable = zoom_panel_enable_lcd,
111 .platform_disable = zoom_panel_disable_lcd,
112 .max_backlight_level = 100,
113 .set_backlight = zoom_set_bl_intensity,
114};
115
116static struct omap_dss_device *zoom_dss_devices[] = {
117 &zoom_lcd_device,
118};
119
120static struct omap_dss_board_info zoom_dss_data = {
121 .num_devices = ARRAY_SIZE(zoom_dss_devices),
122 .devices = zoom_dss_devices,
123 .default_device = &zoom_lcd_device,
124};
125
a6490335
K
126static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
127 .turbo_mode = 1,
a6490335
K
128};
129
130static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
131 [0] = {
132 .modalias = "nec_8048_spi",
133 .bus_num = 1,
134 .chip_select = 2,
135 .max_speed_hz = 375000,
136 .controller_data = &dss_lcd_mcspi_config,
137 },
138};
139
a6490335
K
140void __init zoom_display_init(void)
141{
d5e13227 142 omap_display_init(&zoom_dss_data);
a6490335
K
143 spi_register_board_info(nec_8048_spi_board_info,
144 ARRAY_SIZE(nec_8048_spi_board_info));
145 zoom_lcd_panel_init();
146}
147
This page took 0.130112 seconds and 5 git commands to generate.