linux/drivers/video/omap/lcd_omap2evm.c
<<
>>
Prefs
   1/*
   2 * LCD panel support for the MISTRAL OMAP2EVM board
   3 *
   4 * Author: Arun C <arunedarath@mistralsolutions.com>
   5 *
   6 * Derived from drivers/video/omap/lcd_omap3evm.c
   7 * Derived from drivers/video/omap/lcd-apollon.c
   8 *
   9 * This program is free software; you can redistribute it and/or modify it
  10 * under the terms of the GNU General Public License as published by the
  11 * Free Software Foundation; either version 2 of the License, or (at your
  12 * option) any later version.
  13 *
  14 * This program is distributed in the hope that it will be useful, but
  15 * WITHOUT ANY WARRANTY; without even the implied warranty of
  16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17 * General Public License for more details.
  18 *
  19 * You should have received a copy of the GNU General Public License along
  20 * with this program; if not, write to the Free Software Foundation, Inc.,
  21 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22 */
  23
  24#include <linux/module.h>
  25#include <linux/platform_device.h>
  26#include <linux/gpio.h>
  27#include <linux/i2c/twl4030.h>
  28
  29#include <mach/mux.h>
  30#include <mach/omapfb.h>
  31#include <asm/mach-types.h>
  32
  33#define LCD_PANEL_ENABLE_GPIO   154
  34#define LCD_PANEL_LR            128
  35#define LCD_PANEL_UD            129
  36#define LCD_PANEL_INI           152
  37#define LCD_PANEL_QVGA          148
  38#define LCD_PANEL_RESB          153
  39
  40#define TWL_LED_LEDEN           0x00
  41#define TWL_PWMA_PWMAON         0x00
  42#define TWL_PWMA_PWMAOFF        0x01
  43
  44static unsigned int bklight_level;
  45
  46static int omap2evm_panel_init(struct lcd_panel *panel,
  47                                struct omapfb_device *fbdev)
  48{
  49        gpio_request(LCD_PANEL_ENABLE_GPIO, "LCD enable");
  50        gpio_request(LCD_PANEL_LR, "LCD lr");
  51        gpio_request(LCD_PANEL_UD, "LCD ud");
  52        gpio_request(LCD_PANEL_INI, "LCD ini");
  53        gpio_request(LCD_PANEL_QVGA, "LCD qvga");
  54        gpio_request(LCD_PANEL_RESB, "LCD resb");
  55
  56        gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 1);
  57        gpio_direction_output(LCD_PANEL_RESB, 1);
  58        gpio_direction_output(LCD_PANEL_INI, 1);
  59        gpio_direction_output(LCD_PANEL_QVGA, 0);
  60        gpio_direction_output(LCD_PANEL_LR, 1);
  61        gpio_direction_output(LCD_PANEL_UD, 1);
  62
  63        twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
  64        twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
  65        twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
  66        bklight_level = 100;
  67
  68        return 0;
  69}
  70
  71static void omap2evm_panel_cleanup(struct lcd_panel *panel)
  72{
  73        gpio_free(LCD_PANEL_RESB);
  74        gpio_free(LCD_PANEL_QVGA);
  75        gpio_free(LCD_PANEL_INI);
  76        gpio_free(LCD_PANEL_UD);
  77        gpio_free(LCD_PANEL_LR);
  78        gpio_free(LCD_PANEL_ENABLE_GPIO);
  79}
  80
  81static int omap2evm_panel_enable(struct lcd_panel *panel)
  82{
  83        gpio_set_value(LCD_PANEL_ENABLE_GPIO, 0);
  84        return 0;
  85}
  86
  87static void omap2evm_panel_disable(struct lcd_panel *panel)
  88{
  89        gpio_set_value(LCD_PANEL_ENABLE_GPIO, 1);
  90}
  91
  92static unsigned long omap2evm_panel_get_caps(struct lcd_panel *panel)
  93{
  94        return 0;
  95}
  96
  97static int omap2evm_bklight_setlevel(struct lcd_panel *panel,
  98                                                unsigned int level)
  99{
 100        u8 c;
 101        if ((level >= 0) && (level <= 100)) {
 102                c = (125 * (100 - level)) / 100 + 2;
 103                twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
 104                bklight_level = level;
 105        }
 106        return 0;
 107}
 108
 109static unsigned int omap2evm_bklight_getlevel(struct lcd_panel *panel)
 110{
 111        return bklight_level;
 112}
 113
 114static unsigned int omap2evm_bklight_getmaxlevel(struct lcd_panel *panel)
 115{
 116        return 100;
 117}
 118
 119struct lcd_panel omap2evm_panel = {
 120        .name           = "omap2evm",
 121        .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
 122                          OMAP_LCDC_INV_HSYNC,
 123
 124        .bpp            = 16,
 125        .data_lines     = 18,
 126        .x_res          = 480,
 127        .y_res          = 640,
 128        .hsw            = 3,
 129        .hfp            = 0,
 130        .hbp            = 28,
 131        .vsw            = 2,
 132        .vfp            = 1,
 133        .vbp            = 0,
 134
 135        .pixel_clock    = 20000,
 136
 137        .init           = omap2evm_panel_init,
 138        .cleanup        = omap2evm_panel_cleanup,
 139        .enable         = omap2evm_panel_enable,
 140        .disable        = omap2evm_panel_disable,
 141        .get_caps       = omap2evm_panel_get_caps,
 142        .set_bklight_level      = omap2evm_bklight_setlevel,
 143        .get_bklight_level      = omap2evm_bklight_getlevel,
 144        .get_bklight_max        = omap2evm_bklight_getmaxlevel,
 145};
 146
 147static int omap2evm_panel_probe(struct platform_device *pdev)
 148{
 149        omapfb_register_panel(&omap2evm_panel);
 150        return 0;
 151}
 152
 153static int omap2evm_panel_remove(struct platform_device *pdev)
 154{
 155        return 0;
 156}
 157
 158static int omap2evm_panel_suspend(struct platform_device *pdev,
 159                                   pm_message_t mesg)
 160{
 161        return 0;
 162}
 163
 164static int omap2evm_panel_resume(struct platform_device *pdev)
 165{
 166        return 0;
 167}
 168
 169struct platform_driver omap2evm_panel_driver = {
 170        .probe          = omap2evm_panel_probe,
 171        .remove         = omap2evm_panel_remove,
 172        .suspend        = omap2evm_panel_suspend,
 173        .resume         = omap2evm_panel_resume,
 174        .driver         = {
 175                .name   = "omap2evm_lcd",
 176                .owner  = THIS_MODULE,
 177        },
 178};
 179
 180static int __init omap2evm_panel_drv_init(void)
 181{
 182        return platform_driver_register(&omap2evm_panel_driver);
 183}
 184
 185static void __exit omap2evm_panel_drv_exit(void)
 186{
 187        platform_driver_unregister(&omap2evm_panel_driver);
 188}
 189
 190module_init(omap2evm_panel_drv_init);
 191module_exit(omap2evm_panel_drv_exit);
 192