Path: blob/master/arch/arm/mach-omap2/board-zoom-display.c
10817 views
/*1* Copyright (C) 2010 Texas Instruments Inc.2*3* Modified from mach-omap2/board-zoom-peripherals.c4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/910#include <linux/kernel.h>11#include <linux/init.h>12#include <linux/platform_device.h>13#include <linux/gpio.h>14#include <linux/i2c/twl.h>15#include <linux/spi/spi.h>16#include <plat/mcspi.h>17#include <video/omapdss.h>1819#define LCD_PANEL_RESET_GPIO_PROD 9620#define LCD_PANEL_RESET_GPIO_PILOT 5521#define LCD_PANEL_QVGA_GPIO 562223static struct gpio zoom_lcd_gpios[] __initdata = {24{ -EINVAL, GPIOF_OUT_INIT_HIGH, "lcd reset" },25{ LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "lcd qvga" },26};2728static void __init zoom_lcd_panel_init(void)29{30zoom_lcd_gpios[0].gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?31LCD_PANEL_RESET_GPIO_PROD :32LCD_PANEL_RESET_GPIO_PILOT;3334if (gpio_request_array(zoom_lcd_gpios, ARRAY_SIZE(zoom_lcd_gpios)))35pr_err("%s: Failed to get LCD GPIOs.\n", __func__);36}3738static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)39{40return 0;41}4243static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)44{45}4647/*48* PWMA/B register offsets (TWL4030_MODULE_PWMA)49*/50#define TWL_INTBR_PMBR1 0xD51#define TWL_INTBR_GPBR1 0xC52#define TWL_LED_PWMON 0x053#define TWL_LED_PWMOFF 0x15455static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)56{57unsigned char c;58u8 mux_pwm, enb_pwm;5960if (level > 100)61return -1;6263twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);64twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);6566if (level == 0) {67/* disable pwm1 output and clock */68enb_pwm = enb_pwm & 0xF5;69/* change pwm1 pin to gpio pin */70mux_pwm = mux_pwm & 0xCF;71twl_i2c_write_u8(TWL4030_MODULE_INTBR,72enb_pwm, TWL_INTBR_GPBR1);73twl_i2c_write_u8(TWL4030_MODULE_INTBR,74mux_pwm, TWL_INTBR_PMBR1);75return 0;76}7778if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {79/* change gpio pin to pwm1 pin */80mux_pwm = mux_pwm | 0x30;81/* enable pwm1 output and clock*/82enb_pwm = enb_pwm | 0x0A;83twl_i2c_write_u8(TWL4030_MODULE_INTBR,84mux_pwm, TWL_INTBR_PMBR1);85twl_i2c_write_u8(TWL4030_MODULE_INTBR,86enb_pwm, TWL_INTBR_GPBR1);87}8889c = ((50 * (100 - level)) / 100) + 1;90twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);91twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);9293return 0;94}9596static struct omap_dss_device zoom_lcd_device = {97.name = "lcd",98.driver_name = "NEC_8048_panel",99.type = OMAP_DISPLAY_TYPE_DPI,100.phy.dpi.data_lines = 24,101.platform_enable = zoom_panel_enable_lcd,102.platform_disable = zoom_panel_disable_lcd,103.max_backlight_level = 100,104.set_backlight = zoom_set_bl_intensity,105};106107static struct omap_dss_device *zoom_dss_devices[] = {108&zoom_lcd_device,109};110111static struct omap_dss_board_info zoom_dss_data = {112.num_devices = ARRAY_SIZE(zoom_dss_devices),113.devices = zoom_dss_devices,114.default_device = &zoom_lcd_device,115};116117static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {118.turbo_mode = 1,119.single_channel = 1, /* 0: slave, 1: master */120};121122static struct spi_board_info nec_8048_spi_board_info[] __initdata = {123[0] = {124.modalias = "nec_8048_spi",125.bus_num = 1,126.chip_select = 2,127.max_speed_hz = 375000,128.controller_data = &dss_lcd_mcspi_config,129},130};131132void __init zoom_display_init(void)133{134omap_display_init(&zoom_dss_data);135spi_register_board_info(nec_8048_spi_board_info,136ARRAY_SIZE(nec_8048_spi_board_info));137zoom_lcd_panel_init();138}139140141142