/* input: intensity in percentage 0% - 100% */
static int bcm_keypad_led_update_status(struct backlight_device *bd)
{
    struct keypad_led_data *keyled= dev_get_drvdata(&bd->dev);
    int user_intensity = bd->props.brightness;

    KLDBG("[KEYLED] bcm_keypad_led_update_status : %d\n", user_intensity);
    
    writel(readl(ADDR_SYSCFG_IOCR0) |SYSCFG_IOCR0_DIGMIC_GPIO6362_MUX , ADDR_SYSCFG_IOCR0);

    gpio_request(keyled->ctrl_pin, "KEYLED_EN");
    
    if(user_intensity==0)
    {
        gpio_direction_output(keyled->ctrl_pin, KEYLED_OFF);        
        keyled_status = KEYLED_ON;           

        KLDBG("[KEYLED] OFF: SET[%d], GET[%d]\n", 0, gpio_get_value(keyled->ctrl_pin));        
    }
    else
    {
        gpio_direction_output(keyled->ctrl_pin, KEYLED_ON);
        keyled_status = KEYLED_OFF;            
        
        KLDBG("[KEYLED] ON: SET[%d], GET[%d]\n", 1, gpio_get_value(keyled->ctrl_pin));              

    }
    
    return 0;
}
Beispiel #2
0
void keyled_power_ctrl(unsigned char on_off)
{
	int rc;
	
	if(on_off==KEYLED_ON)
	{
		KLDBG("[KEYLED] %s, %d Keyled On\n", __func__, __LINE__ );

            rc = gpio_request(KEY_LED_EN,"Touchkey_led");
		if (rc < 0)
		{
			printk("[TSP] touch_power_control unable to request GPIO pin");
			//printk(KERN_ERR "unable to request GPIO pin %d\n", TSP_INT_GPIO_PIN);
			return rc;
		}
		gpio_direction_output(KEY_LED_EN,1);
		gpio_set_value(KEY_LED_EN,1);
		gpio_free(KEY_LED_EN);

	}
	else
	{
		KLDBG("[KEYLED] %s, %d Keyled Off\n", __func__, __LINE__ );

            gpio_request(KEY_LED_EN,"Touchkey_led");
		gpio_direction_output(KEY_LED_EN,0);
		gpio_set_value(KEY_LED_EN,0);
		gpio_free(KEY_LED_EN);
		
	}

}
static int bcm_keypad_led_probe(struct platform_device *pdev)
{
	struct platform_keypad_led_data *data = pdev->dev.platform_data;
	struct backlight_device *bl;
	struct keypad_led_data *keyled;
    	struct backlight_properties props;
	int ret;

        KLDBG("[KEYLED] bcm_keypad_led_probe, 0x%x\n", readl(HW_SYSCFG_BASE));
        
	if (!data) {
		dev_err(&pdev->dev, "failed to find platform data\n");
		return -EINVAL;
	}

	keyled = kzalloc(sizeof(*keyled), GFP_KERNEL);
	if (!keyled) {
		dev_err(&pdev->dev, "no memory for state\n");
		ret = -ENOMEM;
		goto err_alloc;
	}

	keyled->ctrl_pin = data->ctrl_pin;
    
	memset(&props, 0, sizeof(struct backlight_properties));
	props.max_brightness = data->max_brightness;

	bl = backlight_device_register(pdev->name, &pdev->dev,
			keyled, &bcm_keypad_led_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		ret = PTR_ERR(bl);
		goto err_bl;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	keyled->pdev = pdev;
	keyled->early_suspend_desc.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN-1;
	keyled->early_suspend_desc.suspend = bcm_keypad_led_earlysuspend;
	keyled->early_suspend_desc.resume = bcm_keypad_led_earlyresume;
	register_early_suspend(&keyled->early_suspend_desc);
#endif

	bl->props.max_brightness = data->max_brightness;
	bl->props.brightness = data->default_brightness;

        platform_set_drvdata(pdev, bl);

        bcm_keypad_led_update_status(bl);
        
        bcm_gpio_pull_up(keyled_pin, false);
        bcm_gpio_pull_up_down_enable(keyled_pin, true);  
        
	return 0;

err_bl:
	kfree(keyled);
err_alloc:
	return ret;
}
static int touchkeyled_shutdown(struct platform_device *pdev)
{
	KLDBG("[KEYLED] touchkeyled_shutdown\n");
       touchkeyled_power_ctrl(TOUCHKEYLED_OFF);

	return 0;
}
Beispiel #5
0
/* input: intensity in percentage 0% - 100% */
int keyled_set_intensity(struct backlight_device *bd)
{
	int user_intensity = bd->props.brightness;
	int plat_intensity = 0;
	u8 wled2b = 0;

     //  #if KEYPAD_BL_DEBUG
	KLDBG("[KEYLED] keyled_set_intensity = %d current_intensity = %d\n", user_intensity, current_intensity);
    //  #endif

	if (bd->props.power != FB_BLANK_UNBLANK)
		user_intensity = 0;
	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
		user_intensity = 0;
		
	if (keyled_suspended)
		user_intensity = 0;

	if(user_intensity >= 100)
		plat_intensity = 0xFF;
	else
		plat_intensity = (user_intensity*256/100); // convert precentage to WLED_DUTY


	if (user_intensity && current_intensity == 0) {
	    keyled_power_ctrl(KEYLED_ON);
	} else if (user_intensity == 0 && current_intensity != 0) {
		keyled_power_ctrl(KEYLED_OFF);
	}

	current_intensity = user_intensity;

	return 0;
}
static int touchkeyled_resume(struct platform_device *pdev)
{

	KLDBG("[KEYLED] %s, %d\n", __func__, __LINE__ );

    return 0;
}
static int touchkeyled_suspend(struct platform_device *pdev,
					pm_message_t state)
{

	KLDBG("[KEYLED] %s, %d\n", __func__, __LINE__ );

    return 0;
}
Beispiel #8
0
static int bcm_keyled_set_brightness(struct backlight_device *bd)
{

	KLDBG("[KEYLED] %s, brightness=%d \n", __func__, bd->props.brightness);	

    keyled_set_intensity(bd);

    return 0;
}
static void bcm_keypad_led_earlysuspend(struct early_suspend *desc)
{
    struct  keypad_led_data *keyled = container_of(desc, struct keypad_led_data, early_suspend_desc);    
    struct backlight_device *bl = platform_get_drvdata(keyled->pdev);
    
    KLDBG("[KEYLED] bcm_keypad_led_earlysuspend\n");

    bcm_gpio_pull_up(keyled_pin, false);
    bcm_gpio_pull_up_down_enable(keyled_pin, true);        
}
Beispiel #10
0
static int bcm_keypad_led_resume(struct platform_device *pdev)
{
	struct backlight_device *bl = platform_get_drvdata(pdev);

	KLDBG("[KEYLED] %s, %d\n", __func__, __LINE__ );

//	keyled_power_ctrl(KEYLED_ON);
	keyled_suspended = 0;
	keyled_set_intensity(bl);
    return 0;
}
void Keypad_Led_control_On(void)
{
    writel(readl(ADDR_SYSCFG_IOCR0) |SYSCFG_IOCR0_DIGMIC_GPIO6362_MUX , ADDR_SYSCFG_IOCR0);

    gpio_request(keyled_pin, "KEYLED_EN");
    gpio_direction_output(keyled_pin, 1);       

    keyled_status = KEYLED_ON;                
    KLDBG("[KEYLED] ON: SET[%d], GET[%d]\n", 1, gpio_get_value(keyled_pin));    

}
static int bcm_keypad_led_resume(struct platform_device *pdev)
{
    struct backlight_device *bl = platform_get_drvdata(pdev);
    struct keypad_led_data *keyled = dev_get_drvdata(&bl->dev);

    KLDBG("[KEYLED] bcm_keypad_led_resume\n");

    gpio_direction_output(keyled->ctrl_pin, KEYLED_ON);      
    bcm_keypad_led_update_status(bl);

    return 0;
}
static int touchkeyled_probe(struct platform_device *pdev)
{
	struct backlight_device *bl;
	struct touchkeypad_led_data *touchkeyled;
    	struct backlight_properties props;
    int ret=0;

	printk("[KEYLED] %s, %d\n", __func__, __LINE__ );


	touchkeyled = kzalloc(sizeof(*touchkeyled), GFP_KERNEL);
	if (!touchkeyled) {
		dev_err(&pdev->dev, "no memory for state\n");
		ret = -ENOMEM;
		goto err_bl;
	}

	memset(&props, 0, sizeof(struct backlight_properties));

      props.brightness = TOUCHKEY_LED_MAX;
      props.max_brightness = TOUCHKEY_LED_MAX;
	props.type = BACKLIGHT_PLATFORM;

	bl = backlight_device_register(pdev->name, &pdev->dev,
			NULL, &bcm_touchkey_led_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		goto err_bl;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	touchkeyled->pdev = pdev;
	touchkeyled->early_suspend_desc.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
	touchkeyled->early_suspend_desc.suspend = touchkeyled_suspend;
	touchkeyled->early_suspend_desc.resume = touchkeyled_resume;
	register_early_suspend(&touchkeyled->early_suspend_desc);
#endif

	    //touchkeyled_power_ctrl(TOUCHKEYLED_ON);
	platform_set_drvdata(pdev, bl);

	bl->props.power = FB_BLANK_UNBLANK;
	bl->props.brightness = TOUCHKEY_LED_MAX;
	bl->props.max_brightness = TOUCHKEY_LED_MAX;

	KLDBG("[KEYLED] Probe done!");
 	return 0;
err_bl:
	kfree(touchkeyled);
	return ret;

}
void touchkeyled_power_ctrl(unsigned char on_off)
{
	int ret;
	if(touchkeyled_regulator == NULL)
	{
		KLDBG(" %s, %d \n", __func__, __LINE__ );
		touchkeyled_regulator = regulator_get(NULL, "gpldo3_uc");

		if(IS_ERR(touchkeyled_regulator)){
			printk("[KEYLED] can not get VKEYLED_3.3V\n");
		}
	}
	if(on_off==TOUCHKEYLED_ON)
	{
	    KLDBG("[KEYLED] %s, %d Keyled On\n", __func__, __LINE__ );

	    ret = regulator_set_voltage(touchkeyled_regulator,3300000,3300000);
	   if(ret<0)
	   	printk("[KEYLED] regulator_set_voltage : %d\n", ret);

	    //ret = regulator_enable(touchkeyled_regulator);
	    ret = regulator_enable(touchkeyled_regulator);
	   if(ret<0)
	      printk("[KEYLED] regulator_enable : %d\n", ret);
	}
	else
	{
	    KLDBG("[KEYLED] %s, %d Keyled Off\n", __func__, __LINE__ );

	    ret = regulator_disable(touchkeyled_regulator);
	   //ret = regulator_force_disable(touchkeyled_regulator);
	   if(ret<0)
	     printk("[KEYLED] regulator_disable : %d\n", ret);
	}

}
/* input: intensity in percentage 0% - 100% */
int touchkeyled_set_intensity(struct backlight_device *bd)
{
	int user_intensity = bd->props.brightness;

	KLDBG("[KEYLED] keyled_set_intensity = %d current_intensity = %d\n", user_intensity, current_intensity);

	if (user_intensity !=0 && current_intensity == 0) {
	    touchkeyled_power_ctrl(TOUCHKEYLED_ON);
	} else if (user_intensity == 0 && current_intensity != 0) {
	    touchkeyled_power_ctrl(TOUCHKEYLED_OFF);
	}

	current_intensity = user_intensity;

	return 0;
}
static int bcm_keypad_led_get_brightness(struct backlight_device *bl)
{
        KLDBG("[KEYLED] bcm_keypad_led_get_brightness\n");
    
	return 0;
}
Beispiel #17
0
static int __init bcm_keypad_led_init(void)
{
    KLDBG("[KEYLED] bcm_keypad_led_init\n");

    return platform_driver_register(&keypad_led_driver);
}
Beispiel #18
0
static int bcm_keypad_led_probe(struct platform_device *pdev)
{
	struct backlight_device *bl;
	/*struct keypad_led_data *keyled;*/
    	struct backlight_properties props;
    int ret=0;

	KLDBG("[KEYLED] %s, %d\n", __func__, __LINE__ );

/*
	keyled = kzalloc(sizeof(*keyled), GFP_KERNEL);
	if (!keyled) {
		dev_err(&pdev->dev, "no memory for state\n");
		ret = -ENOMEM;
		goto err_alloc;
	}
*/
	memset(&props, 0, sizeof(struct backlight_properties));

      props.brightness = KEYPAD_LED_MAX;
      props.max_brightness = KEYPAD_LED_MAX;


	bl = backlight_device_register(pdev->name, &pdev->dev,
			NULL, &bcm_keypad_led_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		return PTR_ERR(bl);
	}

	platform_set_drvdata(pdev, bl);

#if 0
    keyled_regulator = regulator_get(NULL, "hv10");

	if(IS_ERR(keyled_regulator)){
		KLDBG("[KEYLED] can not get VKEYLED_3.3V\n");
	}	

    ret = regulator_is_enabled(keyled_regulator);
    KLDBG("[KEYLED] regulator_is_enabled : %d\n", ret);

    ret = regulator_set_voltage(keyled_regulator,3300000,3300000);	
    KLDBG("[KEYLED] regulator_set_voltage : %d\n", ret);

    ret = regulator_enable(keyled_regulator);
    KLDBG("[KEYLED] regulator_enable : %d\n", ret);
#endif

	bl->props.power = FB_BLANK_UNBLANK;
	bl->props.brightness = KEYPAD_LED_MAX;
	bl->props.max_brightness = KEYPAD_LED_MAX;

    //keyled_power_ctrl(KEYLED_ON);//test

	KLDBG("[KEYLED] Probe done!");

       
	return ret;


}
Beispiel #19
0
static int bcm_keyled_get_brightness(struct backlight_device *bl)
{
	KLDBG("[KEYLED] %s\n", __func__);	
    
	return current_intensity;
}
static int __init touchkeyled_init(void)
{
    KLDBG("[KEYLED] touchkeyled_init\n");

    return platform_driver_register(&touchkeyled_driver);
}