Ejemplo n.º 1
0
static int led_blink_pmic(enum mt65xx_led_pmic pmic_type, struct nled_setting* led) 
{
	int time_index = 0;
	int duty = 0;
	
	if((pmic_type != MT65XX_LED_PMIC_NLED_ISINK0 && pmic_type != MT65XX_LED_PMIC_NLED_ISINK4 && pmic_type!= MT65XX_LED_PMIC_NLED_ISINK5) || (led->nled_mode != NLED_BLINK)) 
	{
		return -1;
	}

	time_index = find_time_index_pmic(led->blink_on_time + led->blink_off_time);
	
	duty=32*led->blink_on_time/(led->blink_on_time + led->blink_off_time);
	
	switch(pmic_type){
	       case MT65XX_LED_PMIC_NLED_ISINK0:
			upmu_isinks_ch0_mode(1); //---Rachel PMIC_PWM_1
			upmu_isinks_ch0_step(0);  //0:4mA  1:8mA
			upmu_isinks_ch0_cabc_en(0);
			upmu_isinks_dim1_duty(duty);
			upmu_isinks_dim1_fsel(pmic_freqsel_array[time_index]);
			pmic_bank1_config_interface(0x2e, pmic_clksel_array[time_index], 0x3, 0x6);
			upmu_top2_bst_drv_ck_pdn(0x0);
			//hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK4);
			upmu_isinks_ch0_en(0x1);
		       break;
		       
		case MT65XX_LED_PMIC_NLED_ISINK4:
			upmu_isinks_ch4_mode(1); //---Rachel PMIC_PWM_1
			upmu_isinks_ch4_step(0);   //0:4mA  1:8mA
			upmu_isinks_ch4_cabc_en(0);
			upmu_isinks_dim1_duty(duty);
			upmu_isinks_dim1_fsel(pmic_freqsel_array[time_index]);
			pmic_bank1_config_interface(0x2e, pmic_clksel_array[time_index], 0x3, 0x6);
			upmu_top2_bst_drv_ck_pdn(0x0);
			//hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK4);
			upmu_isinks_ch4_en(0x1);
		       break;
		
		case MT65XX_LED_PMIC_NLED_ISINK5:
			upmu_isinks_ch5_mode(2); //--Rachel PMIC_PWM_2
			upmu_isinks_ch5_step(0);   //0:4mA  1:8mA
			upmu_isinks_ch5_cabc_en(0);
			upmu_isinks_dim2_duty(duty);
			upmu_isinks_dim2_fsel(pmic_freqsel_array[time_index]);
			pmic_bank1_config_interface(0x30, pmic_clksel_array[time_index], 0x3, 0x6);
			upmu_top2_bst_drv_ck_pdn(0x0);
			//hwBacklightISINKTurnOn(MT65XX_LED_PMIC_NLED_ISINK5);
			upmu_isinks_ch5_en(0x1);
		       break;
		
		default:
		       break;
	}
			
	return 0;
}
Ejemplo n.º 2
0
void isink0_init(void)
{
	printf("[LEDS]uboot: isink0_init: turn on PMIC6329 isink0 \n\r");
	upmu_isinks_ch0_mode(3);   //register mode
	upmu_isinks_ch0_step(0);  //step 4ma,can customize
	upmu_isinks_ch0_cabc_en(0);	

	upmu_top2_bst_drv_ck_pdn(0x0);
	upmu_isinks_ch0_en(0x1);  //enable the ISINK0	
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}