regulator, mc13xxx: Remove pointless test for unsigned less than zero
[zen-stable.git] / arch / arm / mach-omap2 / board-zoom-display.c
blob6bcd43657aed13b11cc5f15657d52483ad88bb6c
1 /*
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.
9 */
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)
26 int ret;
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");
34 if (ret) {
35 pr_err("Failed to get LCD reset GPIO (gpio%d).\n",
36 lcd_panel_reset_gpio);
37 return;
39 gpio_direction_output(lcd_panel_reset_gpio, 1);
41 ret = gpio_request(LCD_PANEL_QVGA_GPIO, "lcd qvga");
42 if (ret) {
43 pr_err("Failed to get LCD_PANEL_QVGA_GPIO (gpio%d).\n",
44 LCD_PANEL_QVGA_GPIO);
45 goto err0;
47 gpio_direction_output(LCD_PANEL_QVGA_GPIO, 1);
49 return;
50 err0:
51 gpio_free(lcd_panel_reset_gpio);
54 static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
56 return 0;
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)
73 unsigned char c;
74 u8 mux_pwm, enb_pwm;
76 if (level > 100)
77 return -1;
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);
82 if (level == 0) {
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);
91 return 0;
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);
109 return 0;
112 static struct omap_dss_device zoom_lcd_device = {
113 .name = "lcd",
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[] = {
124 &zoom_lcd_device,
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 = {
134 .name = "omapdss",
135 .id = -1,
136 .dev = {
137 .platform_data = &zoom_dss_data,
141 static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
142 .turbo_mode = 1,
143 .single_channel = 1, /* 0: slave, 1: master */
146 static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
147 [0] = {
148 .modalias = "nec_8048_spi",
149 .bus_num = 1,
150 .chip_select = 2,
151 .max_speed_hz = 375000,
152 .controller_data = &dss_lcd_mcspi_config,
156 static struct platform_device *zoom_display_devices[] __initdata = {
157 &zoom_dss_device,
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();