/* * arch/arm/mach-omap2/board-blaze-panel.c * * Copyright (C) 2011 Texas Instruments * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include #include #include #include #include #include #include #include #include #include #include #include "board-blaze.h" #include "mux.h" #define DP_4430_GPIO_59 59 #define LED_SEC_DISP_GPIO 27 #define DSI2_GPIO_59 59 #define LED_PWM2ON 0x03 #define LED_PWM2OFF 0x04 #define LED_TOGGLE3 0x92 static void blaze_init_display_led(void) { twl_i2c_write_u8(TWL_MODULE_PWM, 0xFF, LED_PWM2ON); twl_i2c_write_u8(TWL_MODULE_PWM, 0x7F, LED_PWM2OFF); twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x30, LED_TOGGLE3); } static void blaze_set_primary_brightness(u8 brightness) { if (brightness > 1) { if (brightness == 255) brightness = 0x7f; else brightness = (~(brightness/2)) & 0x7f; twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x30, LED_TOGGLE3); twl_i2c_write_u8(TWL_MODULE_PWM, brightness, LED_PWM2ON); } else if (brightness <= 1) { twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x08, LED_TOGGLE3); twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x38, LED_TOGGLE3); } } static void blaze_set_secondary_brightness(u8 brightness) { if (brightness > 0) brightness = 1; gpio_set_value(LED_SEC_DISP_GPIO, brightness); } static struct omap4430_sdp_disp_led_platform_data blaze_disp_led_data = { .flags = LEDS_CTRL_AS_ONE_DISPLAY, .display_led_init = blaze_init_display_led, .primary_display_set = blaze_set_primary_brightness, .secondary_display_set = blaze_set_secondary_brightness, }; static void __init omap_disp_led_init(void) { /* Seconday backlight control */ gpio_request(DSI2_GPIO_59, "dsi2_bl_gpio"); gpio_direction_output(DSI2_GPIO_59, 0); if (blaze_disp_led_data.flags & LEDS_CTRL_AS_ONE_DISPLAY) { pr_info("%s: Configuring as one display LED\n", __func__); gpio_set_value(DSI2_GPIO_59, 1); } gpio_request(LED_SEC_DISP_GPIO, "dsi1_bl_gpio"); gpio_direction_output(LED_SEC_DISP_GPIO, 1); mdelay(120); gpio_set_value(LED_SEC_DISP_GPIO, 0); } static struct platform_device blaze_disp_led = { .name = "display_led", .id = -1, .dev = { .platform_data = &blaze_disp_led_data, }, }; int __init blaze_panel_init(void) { omap_disp_led_init(); platform_device_register(&blaze_disp_led); return 0; }