static void bl_set_pwm_mode(int mode) { if (mode) lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x09); else lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x08); }
void lm3630_backlight_on(int level) { if (backlight_status == BL_OFF) { pr_info("%s with level %d\n", __func__, level); lm3630_hw_reset(); /* OVP(24V),OCP(1.0A) , Boost Frequency(500khz) */ lm3630_write_reg(main_lm3630_dev->client, 0x02, 0x30); if( lm3630_pwm_enable ) { /* eble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x09); } else { /* eble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x08); } /* Brightness Code Setting Max on Bank A */ /* Full-Scale Current (20.2mA) of BANK A */ /* 20.2mA : 0x13 , 23.4mA : 0x17 */ lm3630_write_reg(main_lm3630_dev->client, 0x05, 0x16); /* Enable LED A to Exponential, LED2 is connected to BANK_A */ lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x15); } mdelay(1); lm3630_set_main_current_level(main_lm3630_dev->client, level); backlight_status = BL_ON; return; }
static void lm3630_change_mode(int mode) { if (mode == 0) lm3630_write_reg(0x01,0x08);// 0x08 disable cabc else if(mode == 1) lm3630_write_reg(0x01,0x09);// 0x09 enable cabc else printk("lm3630 mode wrong\n"); }
static void lm3630_set_main_current_level(struct i2c_client *client, int level) { struct lm3630_device *dev = i2c_get_clientdata(client); int min_brightness = dev->min_brightness; int max_brightness = dev->max_brightness; if (level == -BOOT_BRIGHTNESS) level = dev->default_brightness; cur_main_lcd_level = level; dev->bl_dev->props.brightness = cur_main_lcd_level; store_level_used = 0; mutex_lock(&dev->bl_mutex); #if defined(CONFIG_MACH_LGE) && !defined(CONFIG_MACH_MSM8974_VU3_KR) && !defined(CONFIG_MACH_MSM8974_Z_KR) && !defined(CONFIG_MACH_MSM8974_Z_US) && !defined(CONFIG_OLED_SUPPORT) if (level < PWM_THRESHOLD) bl_set_pwm_mode(PWM_OFF); else bl_set_pwm_mode(PWM_ON); #endif if (level != 0) { if (level > 0 && level <= min_brightness) level = min_brightness; else if (level > max_brightness) level = max_brightness; if (dev->blmap) { if (level < dev->blmap_size) { cal_value = dev->blmap[level]; lm3630_write_reg(client, 0x03, cal_value); } else dev_warn(&client->dev, "invalid index %d:%d\n", dev->blmap_size, level); } else { cal_value = level; lm3630_write_reg(client, 0x03, cal_value); } } else lm3630_write_reg(client, 0x00, 0x00); mutex_unlock(&dev->bl_mutex); #ifdef CONFIG_MACH_MSM8974_VU3_KR pr_info("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n", __func__, level, cal_value); #else pr_debug("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n", __func__, level, cal_value); #endif }
static void lm3630_hw_init(struct lm3630_device *dev) { lm3630_hw_reset(dev); lm3630_write_reg(dev->client, BOOST_CTL_REG, dev->boost_ctrl_reg); lm3630_write_reg(dev->client, CONFIG_REG, dev->cfg_reg); if (!backlight_dimmer) lm3630_set_max_current_reg(dev, dev->max_current); lm3630_write_reg(dev->client, CONTROL_REG, dev->ctrl_reg); mdelay(1); }
static void lm3630_set_max_current_reg(struct lm3630_device *dev, int val) { if (dev->bank_sel == LED_BANK_A) { lm3630_write_reg(dev->client, CURRENT_A_REG, val); } else if (dev->bank_sel == LED_BANK_B) { lm3630_write_reg(dev->client, CURRENT_B_REG, val); } else { lm3630_write_reg(dev->client, CURRENT_A_REG, val); lm3630_write_reg(dev->client, CURRENT_B_REG, val); } }
static void lm3630_set_brightness_reg(struct lm3630_device *dev, int level) { if (dev->bank_sel == LED_BANK_A) { lm3630_write_reg(dev->client, BRIGHTNESS_A_REG, level); } else if (dev->bank_sel == LED_BANK_B) { lm3630_write_reg(dev->client, BRIGHTNESS_B_REG, level); } else { lm3630_write_reg(dev->client, BRIGHTNESS_A_REG, level); lm3630_write_reg(dev->client, BRIGHTNESS_B_REG, level); } }
static void lm3630_set_main_current_level(struct i2c_client *client, int level) { struct lm3630_device *dev = i2c_get_clientdata(client); int min_brightness = dev->min_brightness; int max_brightness = dev->max_brightness; if (level == -BOOT_BRIGHTNESS) level = dev->default_brightness; cur_main_lcd_level = level; dev->bl_dev->props.brightness = cur_main_lcd_level; store_level_used = 0; mutex_lock(&dev->bl_mutex); if (level != 0) { if (level > 0 && level <= min_brightness) level = min_brightness; else if (level > max_brightness) level = max_brightness; if (dev->blmap) { if (level < dev->blmap_size) { cal_value = dev->blmap[level]; #ifdef CONFIG_MACH_MSM8974_VU3_KR if(lge_get_boot_mode() == LGE_BOOT_MODE_FACTORY2||lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT||lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT2) cal_value = dev->blmap[130]; #endif lm3630_write_reg(client, 0x03, cal_value); } else dev_warn(&client->dev, "invalid index %d:%d\n", dev->blmap_size, level); } else { cal_value = level; lm3630_write_reg(client, 0x03, cal_value); } } else lm3630_write_reg(client, 0x00, 0x00); mutex_unlock(&dev->bl_mutex); #ifdef CONFIG_MACH_MSM8974_VU3_KR pr_info("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n", __func__, level, cal_value); #else pr_debug("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n", __func__, level, cal_value); #endif }
static void lm3630_set_main_current_level(struct i2c_client *client, int level) { struct lm3630_device *dev = i2c_get_clientdata(client); int min_brightness = dev->min_brightness; int max_brightness = dev->max_brightness; cur_main_lcd_level = level; dev->bl_dev->props.brightness = cur_main_lcd_level; store_level_used = 0; mutex_lock(&dev->bl_mutex); #if defined(CONFIG_B1_LGD_PANEL) if(factory_boot) level = min_brightness; #endif #if defined(CONFIG_G2_LGD_PANEL) || defined(CONFIG_B1_LGD_PANEL) if (level < PWM_THRESHOLD) bl_set_pwm_mode(PWM_OFF); else bl_set_pwm_mode(PWM_ON); #endif if (level != 0) { if (level > 0 && level <= min_brightness) level = min_brightness; else if (level > max_brightness) level = max_brightness; if (dev->blmap) { if (level < dev->blmap_size) { cal_value = dev->blmap[level]; lm3630_write_reg(client, 0x03, cal_value); } else dev_warn(&client->dev, "invalid index %d:%d\n", dev->blmap_size, level); } else { cal_value = level; lm3630_write_reg(client, 0x03, cal_value); } } else lm3630_write_reg(client, 0x00, 0x00); mutex_unlock(&dev->bl_mutex); pr_info("%s : backlight level=%d, cal_value=%d \n", __func__, level, cal_value); }
void lm3630_backlight_on(int level) { hw_rev_type hw_rev; hw_rev = lge_get_board_revno(); if (backlight_status == BL_OFF) { pr_info("%s with level %d\n", __func__, level); lm3630_hw_reset(); /* OVP(24V),OCP(1.0A) , Boost Frequency(500khz) */ #if !defined(CONFIG_MACH_MSM8926_B1L_VZW) && !defined(CONFIG_MACH_MSM8926_B1L_ATT) lm3630_write_reg(main_lm3630_dev->client, 0x02, 0x30); #else lm3630_write_reg(main_lm3630_dev->client, 0x02, 0x50); /*B1L Rev0,A... OVP = 32V */ #endif if( lm3630_pwm_enable ) { /* eble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x09); } else { /* eble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x08); } /* Brightness Code Setting Max on Bank A */ /* Full-Scale Current (20.2mA) of BANK A */ /* 20.2mA : 0x13 , 23.4mA : 0x17 */ lm3630_write_reg(main_lm3630_dev->client, 0x05, 0x16); /* Enable LED A to Exponential, LED2 is connected to BANK_A */ #if !defined(CONFIG_MACH_MSM8926_B1L_VZW) && !defined(CONFIG_MACH_MSM8926_B1L_ATT) lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x15); #else if(HW_REV_0 == hw_rev) { pr_info("%s HW_REV_0\n", __func__); lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x14 /*0x14*/); /* 0x15 : enable BANK A | enable LED A */ } else { pr_info("%s HW_REV_A\n", __func__); lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x15 /*0x14*/); /* 0x15 : enable BANK A | enable LED A | LED2 on BANK A */ } #endif } mdelay(1); lm3630_set_main_current_level(main_lm3630_dev->client, level); backlight_status = BL_ON; return; }
static int set_reg(void *data, u64 val) { u32 addr = (u32) data; int ret; struct i2c_client *client = lm3630_dev->client; ret = lm3630_write_reg(client, addr, (u8) val); return ret; }
static void lm3630_set_main_current_level(struct i2c_client *client, int level) { struct lm3630_device *dev = i2c_get_clientdata(client); int min_brightness = dev->min_brightness; int max_brightness = dev->max_brightness; if (level == -BOOT_BRIGHTNESS) level = dev->default_brightness; cur_main_lcd_level = level; dev->bl_dev->props.brightness = cur_main_lcd_level; store_level_used = 0; mutex_lock(&dev->bl_mutex); if (level != 0) { if (level > 0 && level <= min_brightness) level = min_brightness; else if (level > max_brightness) level = max_brightness; if (dev->blmap) { if (level < dev->blmap_size) { cal_value = dev->blmap[level]; lm3630_write_reg(client, 0x03, cal_value); } else dev_warn(&client->dev, "invalid index %d:%d\n", dev->blmap_size, level); } else { cal_value = level; lm3630_write_reg(client, 0x03, cal_value); } } else lm3630_write_reg(client, 0x00, 0x00); mutex_unlock(&dev->bl_mutex); pr_info("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n", __func__, level, cal_value); }
static void lm3630_set_main_current_level_no_mapping( struct i2c_client *client, int level) { struct lm3630_device *dev; dev = (struct lm3630_device *)i2c_get_clientdata(client); if (level > 255) level = 255; else if (level < 0) level = 0; cur_main_lcd_level = level; dev->bl_dev->props.brightness = cur_main_lcd_level; store_level_used = 1; mutex_lock(&main_lm3630_dev->bl_mutex); if (level != 0) { lm3630_write_reg(client, 0x03, level); } else { lm3630_write_reg(client, 0x00, 0x00); } mutex_unlock(&main_lm3630_dev->bl_mutex); }
static int __devinit lm3630_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = 0; static const char *backlight_ic_name; i2c_client = client; backlight_ic_name = of_get_property(client->dev.of_node, "label", NULL); if (!backlight_ic_name) { printk("Unable to read device name\n"); return -ENODEV; } printk("backlight ic name = %s\n",backlight_ic_name); mdelay(10); err = lm3630_write_reg(0x00,0x15); if (err<0) { printk( " fail to write tpd cfg %d\n", err ); return err; } if(strstr(saved_command_line, "jdi") != NULL) { lcd_vendor = 1; }else if(strstr(saved_command_line, "truly") != NULL) { lcd_vendor = 2; }else if(strstr(saved_command_line, "tianma") != NULL) { lcd_vendor = 3; } else lcd_vendor = 0; if (led_classdev_register(&client->dev, &backlight_cabc)) pr_err("led_classdev_register failed\n"); printk("lm3630 probe done\n"); return 0; }
static void lm3630_set_main_current_level(struct i2c_client *client, int level) { struct lm3630_device *dev = i2c_get_clientdata(client); mutex_lock(&backlight_mtx); dev->bl_dev->props.brightness = level; if (backlight_dimmer) { if (level == 0) { lm3630_write_reg(client, CONTROL_REG, BL_OFF); } else if (level == 1) { lm3630_set_max_current_reg(dev, 0); lm3630_set_brightness_reg(dev, 1); } else { if (level < dev->min_brightness) { level = dev->min_brightness; } else if (level > dev->max_brightness) { level = dev->max_brightness; } lm3630_set_max_current_reg(dev, dev->max_current); if (dev->blmap) { if (level < dev->blmap_size) { lm3630_set_brightness_reg(dev, dev->blmap[level]); } else { pr_err("%s: invalid index %d:%d\n", __func__, dev->blmap_size, level); } } else { lm3630_set_brightness_reg(dev, level); } } } else { if (level != 0) { if (level < dev->min_brightness) level = dev->min_brightness; else if (level > dev->max_brightness) level = dev->max_brightness; if (dev->blmap) { if (level < dev->blmap_size) lm3630_set_brightness_reg(dev, dev->blmap[level]); else pr_err("%s: invalid index %d:%d\n", __func__, dev->blmap_size, level); } else { lm3630_set_brightness_reg(dev, level); } } else { lm3630_write_reg(client, CONTROL_REG, BL_OFF); } } mutex_unlock(&backlight_mtx); pr_debug("%s: level=%d\n", __func__, level); }
void set_backlight_lm3630(unsigned int level) { u8 para; if(lcd_vendor == 1) para = (u8) ((level*17)/20); else if(lcd_vendor == 2) para = (u8) ((level*3)/4); else if(lcd_vendor == 3) para = (u8) ((level*9)/10); else { printk("%s:lcd detect error\n",__func__); return; } printk("mdss:backlight level = %d\n",para); if(para == 0) { printk("mdss:backlight level = 0\n"); if(sleep == 1) return ; lm3630_write_reg(0x03,para); sleep = 1; } else { if(sleep == 1) { printk("init the lm3630 register\n"); lm3630_write_reg(0x00,0x11); if(level > 60) { lm3630_write_reg(0x01,0x09);// 0x09 for cabc cabc_change = 1; } else { lm3630_write_reg(0x01,0x08);// 0x09 for cabc cabc_change = 0; } lm3630_write_reg(0x02,0x33);//set freq to 1M for 4.7 u lm3630_write_reg(0x05,0x14); lm3630_write_reg(0x03,para); lm3630_write_reg(0x00,0x15); sleep = 0; } else { if(level < 60) { if(1 == cabc_change) { lm3630_write_reg(0x01,0x08);// 0x09 for cabc cabc_change = 0; } }else { if(0 == cabc_change) { cabc_change = 1; lm3630_write_reg(0x01,0x09);// 0x09 for cabc } } lm3630_write_reg(0x03,para); } } }
void lm3630_backlight_on(int level) { hw_rev_type hw_rev; hw_rev = lge_get_board_revno(); if (backlight_status == BL_OFF) { pr_info("%s with level %d\n", __func__, level); lm3630_hw_reset(); #if defined(CONFIG_MACH_MSM8226_E7WIFI) || defined(CONFIG_MACH_MSM8226_E8WIFI) || defined (CONFIG_MACH_MSM8926_E8LTE_KR) || defined(CONFIG_MACH_MSM8926_E8LTE) || defined ( CONFIG_MACH_MSM8926_E7LTE_ATT_US) || defined(CONFIG_MACH_MSM8926_E7LTE_VZW_US) || defined (CONFIG_MACH_MSM8926_E7LTE_USC_US) lm3630_write_reg(main_lm3630_dev->client, 0x02, 0x50); //OVP 32V, OCP 1.0A Boost Freq. 500Khz if( lm3630_pwm_enable ) { /* Enble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x09); } else { /* Enble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x08); } lm3630_write_reg(main_lm3630_dev->client, 0x05, 0x13); //Full Scale Current 20.2mA, Brightness Code Setting Max on Bank A lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x15); //Enable Bank A | LED A | LED1,2 on Bank A #else /* OVP(24V),OCP(1.0A) , Boost Frequency(500khz) */ #if !defined(CONFIG_MACH_MSM8926_X10_VZW) && !defined(CONFIG_MACH_MSM8926_B2L_ATT) && !defined(CONFIG_MACH_MSM8926_B2LN_KR) || defined(CONFIG_MACH_MSM8926_JAGNM_ATT) || defined(CONFIG_MACH_MSM8926_JAGN_KR) || defined(CONFIG_MACH_MSM8926_JAGNM_GLOBAL_COM) || defined(CONFIG_MACH_MSM8926_JAGNM_KDDI_JP) || defined(CONFIG_MACH_MSM8926_AKA_KR) || defined(CONFIG_MACH_MSM8926_F60S_JP) lm3630_write_reg(main_lm3630_dev->client, 0x02, 0x30); #else lm3630_write_reg(main_lm3630_dev->client, 0x02, 0x50); /*B1L Rev0,A... OVP = 32V */ #endif if( lm3630_pwm_enable ) { /* eble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x09); } else { /* eble Feedback , disable PWM for BANK A,B */ lm3630_write_reg(main_lm3630_dev->client, 0x01, 0x08); } /* Brightness Code Setting Max on Bank A */ /* Full-Scale Current (20.2mA) of BANK A */ /* 20.2mA : 0x13 , 23.4mA : 0x17 */ lm3630_write_reg(main_lm3630_dev->client, 0x05, 0x16); /* Enable LED A to Exponential, LED2 is connected to BANK_A */ #if !defined(CONFIG_MACH_MSM8926_X10_VZW) && !defined(CONFIG_MACH_MSM8926_B2L_ATT) && !defined(CONFIG_MACH_MSM8926_B2LN_KR) || defined(CONFIG_MACH_MSM8926_JAGNM_ATT) || defined(CONFIG_MACH_MSM8926_JAGN_KR) || defined(CONFIG_MACH_MSM8926_JAGNM_GLOBAL_COM) || defined(CONFIG_MACH_MSM8926_JAGNM_KDDI_JP) || defined(CONFIG_MACH_MSM8926_AKA_KR) || defined(CONFIG_MACH_MSM8926_F60S_JP) lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x15); #else if(HW_REV_0 == hw_rev) { pr_info("%s HW_REV_0\n", __func__); lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x14 /*0x14*/); /* 0x15 : enable BANK A | enable LED A */ } else { pr_info("%s HW_REV_A\n", __func__); lm3630_write_reg(main_lm3630_dev->client, 0x00, 0x15 /*0x14*/); /* 0x15 : enable BANK A | enable LED A | LED2 on BANK A */ } #endif #endif//defined( CONFIG_MACH_MSM8226_E7WIFI ) || defined ( CONFIG_MACH_MSM8926_E7LTE) } mdelay(1); lm3630_set_main_current_level(main_lm3630_dev->client, level); backlight_status = BL_ON; return; }