rendered paste bodyFrom 58dd757c7bfc11f1f47339cf248c817b5f954386 Mon Sep 17 00:00:00 2001From: HUSSON Pierre-Hugues <phhusson@free.fr>Date: Sat, 23 Oct 2010 02:05:16 +0200Subject: [PATCH] <Wistilt2> Add auto-bl for raph+rhod--- arch/arm/mach-msm/Makefile | 2 +- arch/arm/mach-msm/board-htcraphael-panel.c | 3 + arch/arm/mach-msm/board-htcrhodium-panel.c | 117 ++++++++++++++++++++++++++++ arch/arm/mach-msm/board-htctopaz-panel.c | 12 +--- drivers/i2c/chips/microp-klt.c | 56 +++++++++++++ include/linux/microp-klt.h | 18 ++++ 6 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 arch/arm/mach-msm/board-htcrhodium-panel.cdiff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefileindex eec2bb7..ed6c584 100644--- a/arch/arm/mach-msm/Makefile+++ b/arch/arm/mach-msm/Makefile@@ -41,7 +41,7 @@ obj-$(CONFIG_MACH_HTCDIAMOND_CDMA) += board-htcdiamond.o board-htcraphael-navi.o obj-$(CONFIG_MACH_HTCBLACKSTONE) += board-htcblackstone.o board-htcblackstone-panel.o obj-$(CONFIG_MACH_HTCKOVSKY) += board-htckovsky.o board-htckovsky-panel.o obj-$(CONFIG_MACH_HTCTOPAZ) += board-htctopaz.o board-htctopaz-panel.o board-htctopaz-keypad.o-obj-$(CONFIG_MACH_HTCRHODIUM) += board-htcrhodium.o board-htctopaz-panel.o board-htcrhodium-keypad.o board-htcrhodium-audio.o+obj-$(CONFIG_MACH_HTCRHODIUM) += board-htcrhodium.o board-htcrhodium-panel.o board-htcrhodium-keypad.o board-htcrhodium-audio.o obj-$(CONFIG_MACH_HTCRHODIUM) += board-htcrhodium-proximity.o obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o board-halibut-keypad.odiff --git a/arch/arm/mach-msm/board-htcraphael-panel.c b/arch/arm/mach-msm/board-htcraphael-panel.cindex 3fbf8a6..d45a445 100644--- a/arch/arm/mach-msm/board-htcraphael-panel.c+++ b/arch/arm/mach-msm/board-htcraphael-panel.c@@ -9,6 +9,7 @@ #include <linux/leds.h> #include <linux/clk.h> #include <linux/err.h>+#include <linux/microp-klt.h> #include <asm/io.h> #include <asm/gpio.h>@@ -573,6 +574,7 @@ static int htcraphael_mddi_panel_unblank( //XXX: client_data->auto_hibernate(client_data, 1); // client_data->remote_write(client_data, GPIOSEL_VWAKEINT, GPIOSEL); // client_data->remote_write(client_data, INTMASK_VWAKEOUT, INTMASK);+ micropklt_panel_resume(); return ret; }@@ -612,6 +614,7 @@ static int htcraphael_mddi_panel_blank( // client_data->remote_write(client_data, 0, SYSCLKENA); // client_data->remote_write(client_data, 1, DPSUS);+ micropklt_panel_suspend(); return ret; } diff --git a/arch/arm/mach-msm/board-htcrhodium-panel.c b/arch/arm/mach-msm/board-htcrhodium-panel.cnew file mode 100644index 0000000..290926a--- /dev/null+++ b/arch/arm/mach-msm/board-htcrhodium-panel.c@@ -0,0 +1,117 @@+/* linux/arch/arm/mach-msm/board-htcrhod-panel.c+ * Based on board-trout-panel.c by: Brian Swetland <swetland@google.com>+ * Remodelled based on board-supersonic-panel.c by: Jay Tu <jay_tu@htc.com>+ */++#include <linux/kernel.h>+#include <linux/init.h>+#include <linux/platform_device.h>+#include <linux/delay.h>+#include <linux/leds.h>+#include <linux/clk.h>+#include <linux/err.h>+#include <linux/microp-klt.h>++#include <asm/io.h>+#include <asm/gpio.h>+#include <asm/mach-types.h>++#include <mach/msm_fb.h>+#include <mach/vreg.h>+#include <linux/microp-klt.h>++#include "board-htctopaz.h"+#include "proc_comm_wince.h"+#include "devices.h"++static int htcrhod_mddi_client_init(+ struct msm_mddi_bridge_platform_data *bridge_data,+ struct msm_mddi_client_data *client_data)+{+ int i;+ unsigned reg, val;++ return 0;+}++static int htcrhod_mddi_client_uninit(+ struct msm_mddi_bridge_platform_data *bridge_data,+ struct msm_mddi_client_data *client_data)+{+ int i;+ unsigned reg, val;++ return 0;+}++static int htcrhod_mddi_panel_blank(+ struct msm_mddi_bridge_platform_data *bridge_data,+ struct msm_mddi_client_data *client_data)+{+ micropklt_panel_suspend();+ return 0;+}++static int htcrhod_mddi_panel_unblank(+ struct msm_mddi_bridge_platform_data *bridge_data,+ struct msm_mddi_client_data *client_data)+{+ micropklt_panel_resume();+ return 0;+}++static void htcrhod_mddi_power_client(+ struct msm_mddi_client_data *client_data,+ int on)+{+}++extern struct resource resources_msm_fb[];++static struct msm_mddi_bridge_platform_data novatec_client_data = {+ .init = htcrhod_mddi_client_init,+ .uninit = htcrhod_mddi_client_uninit,+ .blank = htcrhod_mddi_panel_blank,+ .unblank = htcrhod_mddi_panel_unblank,+ .fb_data = {+ .xres = 480,+ .yres = 800,+ .output_format = 0,+ },+};++static struct msm_mddi_platform_data mddi_pdata = {+ .power_client = htcrhod_mddi_power_client,+ .fb_resource = resources_msm_fb,+ .num_clients = 1,+ .client_platform_data = {+ {+ // rhod+ .product_id = (0xb9f6 << 16 | 0x5580),+ .name = "mddi_c_b9f6_5582",+ .id = 0,+ .client_data = &novatec_client_data,+ .clk_rate = 0,+ },+ },+};++int __init htcrhod_init_panel(void)+{+ int rc;++ if(!machine_is_htcrhodium()) {+ printk(KERN_INFO "%s: panel does not apply to this device, aborted\n", __func__);+ return 0;+ }++ printk(KERN_INFO "%s: Initializing panel\n", __func__);++ rc = platform_device_register(&msm_device_mdp);+ if (rc)+ return rc;+ msm_device_mddi0.dev.platform_data = &mddi_pdata;+ return platform_device_register(&msm_device_mddi0);+}++device_initcall(htcrhod_init_panel);diff --git a/arch/arm/mach-msm/board-htctopaz-panel.c b/arch/arm/mach-msm/board-htctopaz-panel.cindex f92fbe6..e43b9b8 100644--- a/arch/arm/mach-msm/board-htctopaz-panel.c+++ b/arch/arm/mach-msm/board-htctopaz-panel.c@@ -331,17 +331,9 @@ struct msm_mddi_bridge_platform_data novatec_client_data = { struct msm_mddi_platform_data mddi_pdata = { .power_client = htctopaz_mddi_power_client, .fb_resource = resources_msm_fb,- .num_clients = 2,+ .num_clients = 1, .client_platform_data = { {- // rhod- .product_id = (0xb9f6 << 16 | 0x5580),- .name = "mddi_c_b9f6_5582",- .id = 0,- .client_data = &novatec_client_data,- .clk_rate = 0,- },- { // topa .product_id = (0xb9f6 << 16 | 0x5582), .name = "mddi_c_b9f6_5582",@@ -356,7 +348,7 @@ int __init htctopaz_init_panel(void) { int rc; - if(!machine_is_htctopaz() && !machine_is_htcrhodium()) {+ if(!machine_is_htctopaz()) { printk(KERN_INFO "%s: panel does not apply to this device, aborted\n", __func__); return 0; }diff --git a/drivers/i2c/chips/microp-klt.c b/drivers/i2c/chips/microp-klt.cindex 32a3741..b17f9e6 100644--- a/drivers/i2c/chips/microp-klt.c+++ b/drivers/i2c/chips/microp-klt.c@@ -49,6 +49,7 @@ static int micropklt_read(struct i2c_client *, uint8_t, uint8_t *, int); static int micropklt_write(struct i2c_client *, uint8_t *, int); static unsigned int color_led_address; static unsigned int auto_bl;+module_param_named(auto_bl, auto_bl, int, S_IRUGO | S_IWUSR | S_IWGRP); extern int bma150_probe(struct microp_klt*); @@ -156,6 +157,60 @@ static void micropklt_led_brightness_set(struct led_classdev *led_cdev, mutex_unlock(&data->lock); } +/* Added by WisTilt2 - called in panel blank/unblank+ * Microp Auto-bl control,brightness register,gpio lcd power */+void micropklt_panel_suspend(void)+{+ struct microp_klt *data;+ struct i2c_client *client;+ data = micropklt_t;+ client = data->client;+ uint8_t buf[3] = { 0, 0, 0 };++ if (machine_is_htcraphael()){+ buf[0]=MICROP_KLT_ID_AUTO_BL_RAPH;+ buf[1]=BL_CMD_RAPH;+ buf[2]=BL_DISABLE_RAPH;+ micropklt_write(client,buf,3);+ } else if (machine_is_htcrhodium()){+ buf[0]=MICROP_KLT_ID_AUTO_BL_RHOD;+ buf[1]=BL_DISABLE_RHOD;+ micropklt_write(client,buf,2);+ msleep(20);+ buf[0]=MICROP_KLT_ID_LCD_BRIGHTNESS2;+ buf[1]=0;+ micropklt_write(client,buf,2);+ gpio_set_value(RHOD_LCD_PWR,0);+ }+}++void micropklt_panel_resume(void)+{+ struct microp_klt *data;+ struct i2c_client *client;+ data = micropklt_t;+ client = data->client;++ uint8_t buf[3] = { 0, 0, 0 };++ if (machine_is_htcraphael()){+ buf[0]=MICROP_KLT_ID_AUTO_BL_RAPH;+ buf[1]=BL_CMD_RAPH;+ buf[2]=auto_bl ? BL_ENABLE_RAPH : BL_DISABLE_RAPH;+ micropklt_write(client,buf,3);+ } else if (machine_is_htcrhodium()){+ gpio_set_value(RHOD_LCD_PWR,1);+ buf[0]=MICROP_KLT_ID_AUTO_BL_RHOD;+ buf[1]=auto_bl ? BL_ENABLE_RHOD : BL_DISABLE_RHOD;+ micropklt_write(client,buf,2);+ msleep(20);+ buf[0]=MICROP_KLT_ID_LCD_BRIGHTNESS2;+ buf[1]=1;+ micropklt_write(client,buf,2);+ }+}++ /** * set_misc_states * function to set the micropklt misc register.@@ -644,6 +699,7 @@ static int micropklt_probe(struct i2c_client *client, const struct i2c_device_id #endif printk(KERN_INFO MODULE_NAME ": Initialized MicroP-LED chip revision v%04x\n", data->version);+ micropklt_panel_resume(); return 0; diff --git a/include/linux/microp-klt.h b/include/linux/microp-klt.hindex 76bd81b..7c30782 100644--- a/include/linux/microp-klt.h+++ b/include/linux/microp-klt.h@@ -69,6 +69,16 @@ static struct microp_klt { #define RHOD_CAPS (1<<0) #define RHOD_FN (1<<1) +// Raphael auto-bl enable/disable bitmasks+#define BL_DISABLE_RAPH 0x00+#define BL_ENABLE_RAPH 0x01+#define BL_CMD_RAPH 0x02++// Rhodium auto-bl enable/disable bitmasks+#define BL_ENABLE_RHOD 0xf3+#define BL_DISABLE_RHOD 0xf8++ /** * I2C data address IDs */@@ -83,6 +93,11 @@ TODO: rename to use same convention as Kovs below */ #define MICROP_KLT_ID_LIGHT_SENSOR 0x33 // Get light sensor's result #define MICROP_KLT_ID_SPICTRL 0x21 // SPI Controll Topaz #define MICROP_KLT_ID_SPILCMDDATA 0x70 // SPI Data Topaz++#define MICROP_KLT_ID_AUTO_BL_RAPH 0x23 // Auto backlight enable/disable+#define MICROP_KLT_ID_AUTO_BL_RHOD 0x22 // Auto backlight enable/disable+#define RHOD_LCD_PWR 0x63+ // Kovsky needs special addresses. #define MICROP_KLT_ID_VERSION_KOVS 0x07 // Chip revision #define MICROP_KLT_ID_LED_STATE_KOVS 0x20 // Set LED behavior using above bitmasks@@ -110,5 +125,8 @@ extern int micropklt_set_lcd_state(int on); extern int micropklt_set_kbd_state(int on); extern int micropklt_caps_set(char on); extern int micropklt_fn_set(char on);+extern void micropklt_panel_resume(void);+extern void micropklt_panel_suspend(void);+ #endif-- 1.7.3.1