static int mt65xx_led_set_cust(struct cust_mt65xx_led *cust, int level) { if (level > LED_FULL) level = LED_FULL; else if (level < 0) level = 0; switch (cust->mode) { case MT65XX_LED_MODE_PWM: if(strcmp(cust->name,"lcd-backlight") == 0) { mdelay(100); //added by chenfei //added by XIE Wei -- begin if (level) { upmu_boost_isink_hw_sel(0x1); upmu_boost_mode(3); upmu_boost_vrsel(0x07); upmu_boost_cabc_en(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_boost_en(0x1); } else { printf("[LEDS]MT65XX_LED_PMIC_LCD_BOOST:level=%d\n", level); upmu_boost_en(0x0); } //added by XIE Wei -- end return brightness_set_pwm(cust->data, level,&cust->config_data); } else { return led_set_pwm(cust->data, level); } case MT65XX_LED_MODE_GPIO: return brightness_set_gpio(cust->data, level); case MT65XX_LED_MODE_PMIC: return brightness_set_pmic(cust->data, level); case MT65XX_LED_MODE_CUST: return ((cust_brightness_set)(cust->data))(level); case MT65XX_LED_MODE_NONE: default: break; } return -1; }
static int brightness_set_pmic(enum mt65xx_led_pmic pmic_type, enum led_brightness level) { int temp_level; printf("[LEDS]LED PMIC#%d:%d\n", pmic_type, level); if (pmic_type == MT65XX_LED_PMIC_LCD_ISINK) { if(level) { //hwBacklightISINKTuning(1, PMIC_PWM_0, 0x3, 0); upmu_boost_isink_hw_sel(0x0); upmu_isinks_ch1_mode(0); upmu_isinks_ch1_step(3); upmu_isinks_ch1_cabc_en(0); //hwBacklightISINKTuning(2, PMIC_PWM_0, 0x3, 0); upmu_isinks_ch2_mode(0); upmu_isinks_ch2_step(3); upmu_isinks_ch2_cabc_en(0); //hwBacklightISINKTuning(3, PMIC_PWM_0, 0x3, 0); upmu_isinks_ch3_mode(0); upmu_isinks_ch3_step(3); upmu_isinks_ch3_cabc_en(0); //hwPWMsetting(PMIC_PWM_0, 6, 0); upmu_isinks_dim0_duty(6); upmu_isinks_dim0_fsel(0); //hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK5); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch1_en(0x1); upmu_isinks_ch2_en(0x1); upmu_isinks_ch3_en(0x1); } else { upmu_isinks_ch1_en(0x0); upmu_isinks_ch2_en(0x0); upmu_isinks_ch3_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_LCD_BOOST) { if (level) { temp_level = level/17; printf("[LEDS]MT65XX_LED_PMIC_LCD_BOOST:level=%d temp_level=%d\n", level, temp_level); //hwBacklightBoostTuning(PMIC_PWM_0, 0xA, 0); upmu_boost_isink_hw_sel(0x1); upmu_boost_mode(0); upmu_boost_vrsel(0xA); upmu_boost_cabc_en(0); //hwPWMsetting(PMIC_PWM_0, level, div); upmu_isinks_dim0_duty(temp_level); upmu_isinks_dim0_fsel(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_boost_en(0x1); } else { printf("[LEDS]MT65XX_LED_PMIC_LCD_BOOST:level=%d\n", level); //pmic_bank1_config_interface(0x3F, 0x00, 0xFF, 0x0); upmu_boost_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_NLED_ISINK4) { upmu_isinks_ch0_mode(3); //register mode upmu_isinks_ch0_step(0); //ch0_step 4ma upmu_isinks_ch0_cabc_en(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch0_en(0x1); //enable the ISINK0 if (level) { //hwBacklightISINKTuning(MT65XX_LED_PMIC_NLED_ISINK4, PMIC_PWM_1, 0x3, 0); upmu_isinks_ch4_mode(1); upmu_isinks_ch4_step(0); //change to 4ma to cut the power consumption upmu_isinks_ch4_cabc_en(0); //hwPWMsetting(PMIC_PWM_1, 31, 8); upmu_isinks_dim1_duty(15); //change duty to 50%, can customize upmu_isinks_dim1_fsel(8); //hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK4); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch4_en(0x1); } else { //hwBacklightISINKTurnOff(MT65XX_LED_PMIC_NLED_ISINK4); upmu_isinks_ch4_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_NLED_ISINK5) { upmu_isinks_ch0_mode(3); //register mode upmu_isinks_ch0_step(0); //ch0_step 4ma upmu_isinks_ch0_cabc_en(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch0_en(0x1); //enable the ISINK0 if (level) { //hwBacklightISINKTuning(MT65XX_LED_PMIC_NLED_ISINK5, PMIC_PWM_2, 0Xa, 0); upmu_isinks_ch5_mode(2); upmu_isinks_ch5_step(0); //change to 4ma to cut the power consumption upmu_isinks_ch5_cabc_en(0); //hwPWMsetting(PMIC_PWM_2, 31, 8); upmu_isinks_dim2_duty(15); //change duty to 50%, can customize upmu_isinks_dim2_fsel(8); //hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK5); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch5_en(0x1); } else { //hwBacklightISINKTurnOff(MT65XX_LED_PMIC_NLED_ISINK5); upmu_isinks_ch5_en(0x0); } return 0; } return -1; }
static int brightness_set_pmic(enum mt65xx_led_pmic pmic_type, enum led_brightness level) { int temp_level; printf("[LEDS]LED PMIC#%d:%d\n", pmic_type, level); if (pmic_type == MT65XX_LED_PMIC_LCD_ISINK) { if(level) { //hwBacklightISINKTuning(1, PMIC_PWM_0, 0x3, 0); upmu_boost_isink_hw_sel(0x0); upmu_isinks_ch1_mode(0); upmu_isinks_ch1_step(3); upmu_isinks_ch1_cabc_en(0); //hwBacklightISINKTuning(2, PMIC_PWM_0, 0x3, 0); upmu_isinks_ch2_mode(0); upmu_isinks_ch2_step(3); upmu_isinks_ch2_cabc_en(0); //hwBacklightISINKTuning(3, PMIC_PWM_0, 0x3, 0); upmu_isinks_ch3_mode(0); upmu_isinks_ch3_step(3); upmu_isinks_ch3_cabc_en(0); //hwPWMsetting(PMIC_PWM_0, 6, 0); upmu_isinks_dim0_duty(6); upmu_isinks_dim0_fsel(0); //hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK5); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch1_en(0x1); upmu_isinks_ch2_en(0x1); upmu_isinks_ch3_en(0x1); } else { upmu_isinks_ch1_en(0x0); upmu_isinks_ch2_en(0x0); upmu_isinks_ch3_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_LCD_BOOST) { if (level) { temp_level = level/17; printf("[LEDS]MT65XX_LED_PMIC_LCD_BOOST:level=%d temp_level=%d\n", level, temp_level); //hwBacklightBoostTuning(PMIC_PWM_0, 0xA, 0); upmu_boost_isink_hw_sel(0x1); upmu_boost_mode(0); upmu_boost_vrsel(0xA); upmu_boost_cabc_en(0); //hwPWMsetting(PMIC_PWM_0, level, div); upmu_isinks_dim0_duty(temp_level); upmu_isinks_dim0_fsel(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_boost_en(0x1); } else { printf("[LEDS]MT65XX_LED_PMIC_LCD_BOOST:level=%d\n", level); //pmic_bank1_config_interface(0x3F, 0x00, 0xFF, 0x0); upmu_boost_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_NLED_ISINK4) { if (level) { upmu_isinks_ch4_mode(3); //register mode upmu_isinks_ch4_step(0); //0: 4ma 1:8ma upmu_isinks_ch4_cabc_en(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch4_en(0x1); } else { upmu_isinks_ch4_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_NLED_ISINK5) { if (level) { upmu_isinks_ch5_mode(3); //register mode upmu_isinks_ch5_step(0); //0: 4ma 1:8ma upmu_isinks_ch5_cabc_en(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch5_en(0x1); } else { upmu_isinks_ch5_en(0x0); } return 0; } else if(pmic_type == MT65XX_LED_PMIC_NLED_ISINK0) { if (level) { upmu_isinks_ch0_mode(3); upmu_isinks_ch0_step(0); //0: 4ma 1:8ma upmu_isinks_ch0_cabc_en(0); upmu_top2_bst_drv_ck_pdn(0x0); upmu_isinks_ch0_en(0x1); } else { upmu_isinks_ch0_en(0x0); } return 0; } return -1; }