Kishore Y | a649033 | 2010-11-15 07:09:03 +0100 | [diff] [blame] | 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> |
| 17 | #include <plat/mcspi.h> |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame^] | 18 | #include <video/omapdss.h> |
Kishore Y | a649033 | 2010-11-15 07:09:03 +0100 | [diff] [blame] | 19 | |
| 20 | #define LCD_PANEL_RESET_GPIO_PROD 96 |
| 21 | #define LCD_PANEL_RESET_GPIO_PILOT 55 |
| 22 | #define LCD_PANEL_QVGA_GPIO 56 |
| 23 | |
| 24 | static void zoom_lcd_panel_init(void) |
| 25 | { |
| 26 | int ret; |
| 27 | unsigned char lcd_panel_reset_gpio; |
| 28 | |
| 29 | lcd_panel_reset_gpio = (omap_rev() > OMAP3430_REV_ES3_0) ? |
| 30 | LCD_PANEL_RESET_GPIO_PROD : |
| 31 | LCD_PANEL_RESET_GPIO_PILOT; |
| 32 | |
| 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; |
| 38 | } |
| 39 | gpio_direction_output(lcd_panel_reset_gpio, 1); |
| 40 | |
| 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; |
| 46 | } |
| 47 | gpio_direction_output(LCD_PANEL_QVGA_GPIO, 1); |
| 48 | |
| 49 | return; |
| 50 | err0: |
| 51 | gpio_free(lcd_panel_reset_gpio); |
| 52 | } |
| 53 | |
| 54 | static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev) |
| 55 | { |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | * PWMA/B register offsets (TWL4030_MODULE_PWMA) |
| 65 | */ |
| 66 | #define TWL_INTBR_PMBR1 0xD |
| 67 | #define TWL_INTBR_GPBR1 0xC |
| 68 | #define TWL_LED_PWMON 0x0 |
| 69 | #define TWL_LED_PWMOFF 0x1 |
| 70 | |
| 71 | static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level) |
| 72 | { |
| 73 | unsigned char c; |
| 74 | u8 mux_pwm, enb_pwm; |
| 75 | |
| 76 | if (level > 100) |
| 77 | return -1; |
| 78 | |
| 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); |
| 81 | |
| 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; |
| 92 | } |
| 93 | |
| 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); |
| 103 | } |
| 104 | |
| 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); |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 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, |
| 121 | }; |
| 122 | |
| 123 | static struct omap_dss_device *zoom_dss_devices[] = { |
| 124 | &zoom_lcd_device, |
| 125 | }; |
| 126 | |
| 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, |
| 131 | }; |
| 132 | |
Kishore Y | a649033 | 2010-11-15 07:09:03 +0100 | [diff] [blame] | 133 | static struct omap2_mcspi_device_config dss_lcd_mcspi_config = { |
| 134 | .turbo_mode = 1, |
| 135 | .single_channel = 1, /* 0: slave, 1: master */ |
| 136 | }; |
| 137 | |
| 138 | static struct spi_board_info nec_8048_spi_board_info[] __initdata = { |
| 139 | [0] = { |
| 140 | .modalias = "nec_8048_spi", |
| 141 | .bus_num = 1, |
| 142 | .chip_select = 2, |
| 143 | .max_speed_hz = 375000, |
| 144 | .controller_data = &dss_lcd_mcspi_config, |
| 145 | }, |
| 146 | }; |
| 147 | |
Kishore Y | a649033 | 2010-11-15 07:09:03 +0100 | [diff] [blame] | 148 | void __init zoom_display_init(void) |
| 149 | { |
Senthilvadivu Guruswamy | d5e1322 | 2011-02-22 11:24:50 +0200 | [diff] [blame] | 150 | omap_display_init(&zoom_dss_data); |
Kishore Y | a649033 | 2010-11-15 07:09:03 +0100 | [diff] [blame] | 151 | spi_register_board_info(nec_8048_spi_board_info, |
| 152 | ARRAY_SIZE(nec_8048_spi_board_info)); |
| 153 | zoom_lcd_panel_init(); |
| 154 | } |
| 155 | |