Source
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* h3xxx atmel micro companion support, notification LED subdevice
*
* Author : Linus Walleij <linus.walleij@linaro.org>
*/
/* LED ON/OFF 0:off, 1:on */
/* LED ON/OFF auto stop set 0:disable, 1:enable */
/* LED Interrupt Mask 0:No mask, 1:mask */
static int micro_leds_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct ipaq_micro *micro = dev_get_drvdata(led_cdev->dev->parent->parent);
/*
* In this message:
* Byte 0 = LED color: 0 = yellow, 1 = green
* yellow LED is always ~30 blinks per minute
* Byte 1 = duration (flags?) appears to be ignored
* Byte 2 = green ontime in 1/10 sec (deciseconds)
* 1 = 1/10 second
* 0 = 256/10 second
* Byte 3 = green offtime in 1/10 sec (deciseconds)
* 1 = 1/10 second
* 0 = 256/10 seconds
*/
struct ipaq_micro_msg msg = {
.id = MSG_NOTIFY_LED,
.tx_len = 4,
};
msg.tx_data[0] = LED_GREEN;
msg.tx_data[1] = 0;
if (value) {
msg.tx_data[2] = 0; /* Duty cycle 256 */
msg.tx_data[3] = 1;
} else {
msg.tx_data[2] = 1;
msg.tx_data[3] = 0; /* Duty cycle 256 */
}
return ipaq_micro_tx_msg_sync(micro, &msg);
}
/* Maximum duty cycle in ms 256/10 sec = 25600 ms */
static int micro_leds_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on,
unsigned long *delay_off)
{
struct ipaq_micro *micro = dev_get_drvdata(led_cdev->dev->parent->parent);