Esempio n. 1
0
static void bd2802_configure(struct bd2802_led *led)
{
    struct bd2802_led_platform_data *pdata = led->pdata;
    u8 reg;

    reg = bd2802_get_reg_addr(LED1, RED, BD2802_REG_HOURSETUP);
    bd2802_write_byte(led->client, reg, pdata->rgb_time);

    reg = bd2802_get_reg_addr(LED2, RED, BD2802_REG_HOURSETUP);
    bd2802_write_byte(led->client, reg, pdata->rgb_time);
}
Esempio n. 2
0
static void bd2802_configure(struct bd2802_led *led)
{
	u8 reg;

	reg = bd2802_get_reg_addr(LED1, RED, BD2802_REG_HOURSETUP);
	bd2802_write_byte(led->client, reg, BD2802_TIME_SETUP);
	reg = bd2802_get_reg_addr(LED2, RED, BD2802_REG_HOURSETUP);
	bd2802_write_byte(led->client, reg, BD2802_TIME_SETUP);

	printk("############## system_rev = %d\n", system_rev);
	bd2802_write_byte(led->client, BD2812_DCDCDRIVER, 0x00);
	bd2802_write_byte(led->client, BD2812_PIN_FUNC_SETUP, 0x0F);
}
Esempio n. 3
0
static void bd2802_turn_off(struct bd2802_led *led, enum led_ids id,
                            enum led_colors color)
{
    u8 reg;

    if (bd2802_is_rgb_off(led, id, color))
        return;

    reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP);
    bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
    reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP);
    bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);

    bd2802_update_state(led, id, color, BD2802_OFF);
}
Esempio n. 4
0
static int bd2802_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct bd2802_led *led;
	struct bd2802_led_platform_data *pdata;
	int ret, i;

	led = devm_kzalloc(&client->dev, sizeof(struct bd2802_led), GFP_KERNEL);
	if (!led)
		return -ENOMEM;

	led->client = client;
	pdata = led->pdata = dev_get_platdata(&client->dev);
	i2c_set_clientdata(client, led);

	/* Configure RESET GPIO (L: RESET, H: RESET cancel) */
	gpio_request_one(pdata->reset_gpio, GPIOF_OUT_INIT_HIGH, "RGB_RESETB");

	/* Tacss = min 0.1ms */
	udelay(100);

	/* Detect BD2802GU */
	ret = bd2802_write_byte(client, BD2802_REG_CLKSETUP, 0x00);
	if (ret < 0) {
		dev_err(&client->dev, "failed to detect device\n");
		return ret;
	} else
		dev_info(&client->dev, "return 0x%02x\n", ret);

	/* To save the power, reset BD2802 after detecting */
	gpio_set_value(led->pdata->reset_gpio, 0);

	/* Default attributes */
	led->wave_pattern = BD2802_PATTERN_HALF;
	led->rgb_current = BD2802_CURRENT_032;

	init_rwsem(&led->rwsem);

	for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++) {
		ret = device_create_file(&led->client->dev,
						bd2802_attributes[i]);
		if (ret) {
			dev_err(&led->client->dev, "failed: sysfs file %s\n",
					bd2802_attributes[i]->attr.name);
			goto failed_unregister_dev_file;
		}
	}

	ret = bd2802_register_led_classdev(led);
	if (ret < 0)
		goto failed_unregister_dev_file;

	return 0;

failed_unregister_dev_file:
	for (i--; i >= 0; i--)
		device_remove_file(&led->client->dev, bd2802_attributes[i]);
	return ret;
}
static int __devinit bd2802_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct bd2802_led *led;
	struct bd2802_led_platform_data *pdata;
	int ret;

	led = kzalloc(sizeof(struct bd2802_led), GFP_KERNEL);
	if (!led) {
		dev_err(&client->dev, "failed to allocate driver data\n");
		return -ENOMEM;
	}

	led->client = client;
	pdata = led->pdata = client->dev.platform_data;
	i2c_set_clientdata(client, led);

	/* Configure RESET GPIO (L: RESET, H: RESET cancel) */
	gpio_request(pdata->reset_gpio, "RGB_RESETB");
	gpio_direction_output(pdata->reset_gpio, 1);

	/* Tacss = min 0.1ms */
	udelay(100);

	/* Detect BD2802GU */
	ret = bd2802_write_byte(client, BD2802_REG_CLKSETUP, 0x00);
	if (ret < 0) {
		dev_err(&client->dev, "failed to detect device\n");
		goto failed_free;
	} else
		dev_info(&client->dev, "return 0x%02x\n", ret);

	/* To save the power, reset BD2802 after detecting */
	gpio_set_value(led->pdata->reset_gpio, 0);

	init_rwsem(&led->rwsem);

	ret = device_create_file(&client->dev, &bd2802_adv_conf_attr);
	if (ret) {
		dev_err(&client->dev, "failed to create sysfs file %s\n",
					bd2802_adv_conf_attr.attr.name);
		goto failed_free;
	}

	ret = bd2802_register_led_classdev(led);
	if (ret < 0)
		goto failed_unregister_dev_file;

	return 0;

failed_unregister_dev_file:
	device_remove_file(&client->dev, &bd2802_adv_conf_attr);
failed_free:
	i2c_set_clientdata(client, NULL);
	kfree(led);

	return ret;
}
Esempio n. 6
0
static void bd2802_set_blink(struct bd2802_led *led, enum led_ids id,
                             enum led_colors color)
{
    u8 reg;

    if (bd2802_is_all_off(led) && !led->adf_on)
        bd2802_reset_cancel(led);

    reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP);
    bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
    reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP);
    bd2802_write_byte(led->client, reg, led->rgb_current);
    reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN);
    bd2802_write_byte(led->client, reg, led->wave_pattern);

    bd2802_enable(led, id);
    bd2802_update_state(led, id, color, BD2802_BLINK);
}
static void bd2802_set_on(struct bd2802_led *led, enum led_ids id,
							enum led_colors color)
{
	u8 reg;

	if (bd2802_is_all_off(led) && !led->adf_on)
		bd2802_reset_cancel(led);

	reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP);
	bd2802_write_byte(led->client, reg, BD2802_CURRENT_032);
	reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP);
	bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
	reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN);
	bd2802_write_byte(led->client, reg, BD2802_PATTERN_FULL);

	bd2802_enable(led, id);
	bd2802_update_state(led, id, color, BD2802_ON);
}
Esempio n. 8
0
static void bd2802_enable(struct bd2802_led *led, enum led_ids id)
{
    enum led_ids other_led = (id == LED1) ? LED2 : LED1;
    u8 value, other_led_on;

    other_led_on = !bd2802_is_led_off(led, other_led);
    if (id == LED1)
        value = LED_CTL(other_led_on, 1);
    else
        value = LED_CTL(1 , other_led_on);

    bd2802_write_byte(led->client, BD2802_REG_CONTROL, value);
}
Esempio n. 9
0
static void bd2802_update_state(struct bd2802_led *led, enum led_ids id,
                                enum led_colors color, enum led_bits led_bit)
{
    int i;
    u8 value;

    for (i = 0; i < LED_NUM; i++) {
        if (i == id) {
            switch (color) {
            case RED:
                led->led[i].r = led_bit;
                break;
            case GREEN:
                led->led[i].g = led_bit;
                break;
            case BLUE:
                led->led[i].b = led_bit;
                break;
            default:
                dev_err(&led->client->dev,
                        "%s: Invalid color\n", __func__);
                return;
            }
        }
    }

    if (led_bit == BD2802_BLINK || led_bit == BD2802_ON)
        return;

    if (!bd2802_is_led_off(led, id))
        return;

    if (bd2802_is_all_off(led) && !led->adf_on) {
        gpio_set_value(led->pdata->reset_gpio, 0);
        return;
    }

    /*
     * In this case, other led is turned on, and current led is turned
     * off. So set RGB LED Control register to stop the current RGB LED
     */
    value = (id == LED1) ? LED_CTL(1, 0) : LED_CTL(0, 1);
    bd2802_write_byte(led->client, BD2802_REG_CONTROL, value);
}
Esempio n. 10
0
static void bd2802_off(struct bd2802_led *led)
{
	bd2802_write_byte(led->client, BD2802_REG_CONTROL, 0x00);
}
Esempio n. 11
0
static void bd2802_turn_blue(struct bd2802_led *led, enum key_leds id)
{
	u8 reg;

	switch (id) {
		case MENU:
			reg = bd2802_get_reg_addr(LED1, GREEN, BD2802_REG_CURRENT1SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			reg = bd2802_get_reg_addr(LED1, GREEN, BD2802_REG_CURRENT2SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			break;
		case HOME:
			reg = bd2802_get_reg_addr(LED2, RED, BD2802_REG_CURRENT1SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			reg = bd2802_get_reg_addr(LED2, RED, BD2802_REG_CURRENT2SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			break;
		case BACK:
			reg = bd2802_get_reg_addr(LED2, GREEN, BD2802_REG_CURRENT1SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			reg = bd2802_get_reg_addr(LED2, GREEN, BD2802_REG_CURRENT2SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			break;
		case SEARCH:
			reg = bd2802_get_reg_addr(LED1, RED, BD2802_REG_CURRENT1SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			reg = bd2802_get_reg_addr(LED1, RED, BD2802_REG_CURRENT2SETUP);
			bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
			break;
		case HIDDEN1://BLUE1
			reg = bd2802_get_reg_addr(LED1, BLUE, BD2802_REG_CURRENT1SETUP);
			bd2802_write_byte(led->client, reg, led->blue_current);
			reg = bd2802_get_reg_addr(LED1, BLUE, BD2802_REG_CURRENT2SETUP);
			bd2802_write_byte(led->client, reg, led->blue_current);
			break;
		case HIDDEN2://BLUE2
			reg = bd2802_get_reg_addr(LED2, BLUE, BD2802_REG_CURRENT1SETUP);
			bd2802_write_byte(led->client, reg, led->blue_current);
			reg = bd2802_get_reg_addr(LED2, BLUE, BD2802_REG_CURRENT2SETUP);
			bd2802_write_byte(led->client, reg, led->blue_current);
			break;
		default:
			break;
	}

}
Esempio n. 12
0
static void bd2802_enable(struct bd2802_led *led)
{
	bd2802_write_byte(led->client, BD2802_REG_CONTROL, 0x11);
}
Esempio n. 13
0
static void bd2802_sw_reset(struct bd2802_led *led)
{
	bd2802_write_byte(led->client, BD2802_REG_CLKSETUP, 0x01);
}