Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
leds-bd2802.c File Reference
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/leds.h>
#include <linux/leds-bd2802.h>
#include <linux/slab.h>
#include <linux/pm.h>

Go to the source code of this file.

Data Structures

struct  led_state
 
struct  bd2802_led
 

Macros

#define LED_CTL(rgb2en, rgb1en)   ((rgb2en) << 4 | ((rgb1en) << 0))
 
#define BD2802_LED_OFFSET   0xa
 
#define BD2802_COLOR_OFFSET   0x3
 
#define BD2802_REG_CLKSETUP   0x00
 
#define BD2802_REG_CONTROL   0x01
 
#define BD2802_REG_HOURSETUP   0x02
 
#define BD2802_REG_CURRENT1SETUP   0x03
 
#define BD2802_REG_CURRENT2SETUP   0x04
 
#define BD2802_REG_WAVEPATTERN   0x05
 
#define BD2802_CURRENT_032   0x10 /* 3.2mA */
 
#define BD2802_CURRENT_000   0x00 /* 0.0mA */
 
#define BD2802_PATTERN_FULL   0x07
 
#define BD2802_PATTERN_HALF   0x03
 
#define BD2802_SET_REGISTER(reg_addr, reg_name)
 
#define BD2802_CONTROL_ATTR(attr_name, name_str)
 
#define BD2802_CONTROL_RGBS(name, id, clr)
 
#define BD2802_PM   NULL
 

Enumerations

enum  led_ids { LED1, LED2, LED_NUM }
 
enum  led_colors { RED, GREEN, BLUE }
 
enum  led_bits { BD2802_OFF, BD2802_BLINK, BD2802_ON }
 

Functions

 BD2802_SET_REGISTER (0x00,"0x00")
 
 BD2802_SET_REGISTER (0x01,"0x01")
 
 BD2802_SET_REGISTER (0x02,"0x02")
 
 BD2802_SET_REGISTER (0x03,"0x03")
 
 BD2802_SET_REGISTER (0x04,"0x04")
 
 BD2802_SET_REGISTER (0x05,"0x05")
 
 BD2802_SET_REGISTER (0x06,"0x06")
 
 BD2802_SET_REGISTER (0x07,"0x07")
 
 BD2802_SET_REGISTER (0x08,"0x08")
 
 BD2802_SET_REGISTER (0x09,"0x09")
 
 BD2802_SET_REGISTER (0x0a,"0x0a")
 
 BD2802_SET_REGISTER (0x0b,"0x0b")
 
 BD2802_SET_REGISTER (0x0c,"0x0c")
 
 BD2802_SET_REGISTER (0x0d,"0x0d")
 
 BD2802_SET_REGISTER (0x0e,"0x0e")
 
 BD2802_SET_REGISTER (0x0f,"0x0f")
 
 BD2802_SET_REGISTER (0x10,"0x10")
 
 BD2802_SET_REGISTER (0x11,"0x11")
 
 BD2802_SET_REGISTER (0x12,"0x12")
 
 BD2802_SET_REGISTER (0x13,"0x13")
 
 BD2802_SET_REGISTER (0x14,"0x14")
 
 BD2802_SET_REGISTER (0x15,"0x15")
 
 BD2802_CONTROL_ATTR (wave_pattern,"wave_pattern")
 
 BD2802_CONTROL_ATTR (rgb_current,"rgb_current")
 
 BD2802_CONTROL_RGBS (led1r, LED1, RED)
 
 BD2802_CONTROL_RGBS (led1g, LED1, GREEN)
 
 BD2802_CONTROL_RGBS (led1b, LED1, BLUE)
 
 BD2802_CONTROL_RGBS (led2r, LED2, RED)
 
 BD2802_CONTROL_RGBS (led2g, LED2, GREEN)
 
 BD2802_CONTROL_RGBS (led2b, LED2, BLUE)
 
 MODULE_DEVICE_TABLE (i2c, bd2802_id)
 
 module_i2c_driver (bd2802_i2c_driver)
 
 MODULE_AUTHOR ("Kim Kyuwon <[email protected]>")
 
 MODULE_DESCRIPTION ("BD2802 LED driver")
 
 MODULE_LICENSE ("GPL v2")
 

Macro Definition Documentation

#define BD2802_COLOR_OFFSET   0x3

Definition at line 27 of file leds-bd2802.c.

#define BD2802_CONTROL_ATTR (   attr_name,
  name_str 
)

Definition at line 476 of file leds-bd2802.c.

#define BD2802_CONTROL_RGBS (   name,
  id,
  clr 
)
Value:
static void bd2802_set_##name##_brightness(struct led_classdev *led_cdev,\
{ \
container_of(led_cdev, struct bd2802_led, cdev_##name); \
led->led_id = id; \
led->color = clr; \
if (value == LED_OFF) \
led->state = BD2802_OFF; \
else \
led->state = BD2802_ON; \
schedule_work(&led->work); \
} \
static int bd2802_set_##name##_blink(struct led_classdev *led_cdev, \
unsigned long *delay_on, unsigned long *delay_off) \
{ \
container_of(led_cdev, struct bd2802_led, cdev_##name); \
if (*delay_on == 0 || *delay_off == 0) \
return -EINVAL; \
led->led_id = id; \
led->color = clr; \
led->state = BD2802_BLINK; \
schedule_work(&led->work); \
return 0; \
}

Definition at line 531 of file leds-bd2802.c.

#define BD2802_CURRENT_000   0x00 /* 0.0mA */

Definition at line 37 of file leds-bd2802.c.

#define BD2802_CURRENT_032   0x10 /* 3.2mA */

Definition at line 36 of file leds-bd2802.c.

#define BD2802_LED_OFFSET   0xa

Definition at line 26 of file leds-bd2802.c.

#define BD2802_PATTERN_FULL   0x07

Definition at line 39 of file leds-bd2802.c.

#define BD2802_PATTERN_HALF   0x03

Definition at line 40 of file leds-bd2802.c.

#define BD2802_PM   NULL

Definition at line 792 of file leds-bd2802.c.

#define BD2802_REG_CLKSETUP   0x00

Definition at line 29 of file leds-bd2802.c.

#define BD2802_REG_CONTROL   0x01

Definition at line 30 of file leds-bd2802.c.

#define BD2802_REG_CURRENT1SETUP   0x03

Definition at line 32 of file leds-bd2802.c.

#define BD2802_REG_CURRENT2SETUP   0x04

Definition at line 33 of file leds-bd2802.c.

#define BD2802_REG_HOURSETUP   0x02

Definition at line 31 of file leds-bd2802.c.

#define BD2802_REG_WAVEPATTERN   0x05

Definition at line 34 of file leds-bd2802.c.

#define BD2802_SET_REGISTER (   reg_addr,
  reg_name 
)
Value:
static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \
struct device_attribute *attr, const char *buf, size_t count) \
{ \
struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\
unsigned long val; \
int ret; \
if (!count) \
return -EINVAL; \
ret = strict_strtoul(buf, 16, &val); \
if (ret) \
return ret; \
down_write(&led->rwsem); \
bd2802_write_byte(led->client, reg_addr, (u8) val); \
up_write(&led->rwsem); \
return count; \
} \
static struct device_attribute bd2802_reg##reg_addr##_attr = { \
.attr = {.name = reg_name, .mode = 0644}, \
.store = bd2802_store_reg##reg_addr, \
};

Definition at line 322 of file leds-bd2802.c.

#define LED_CTL (   rgb2en,
  rgb1en 
)    ((rgb2en) << 4 | ((rgb1en) << 0))

Definition at line 24 of file leds-bd2802.c.

Enumeration Type Documentation

enum led_bits
Enumerator:
BD2802_OFF 
BD2802_BLINK 
BD2802_ON 

Definition at line 54 of file leds-bd2802.c.

enum led_colors
Enumerator:
RED 
GREEN 
BLUE 

Definition at line 48 of file leds-bd2802.c.

enum led_ids
Enumerator:
LED1 
LED2 
LED_NUM 

Definition at line 42 of file leds-bd2802.c.

Function Documentation

BD2802_CONTROL_ATTR ( wave_pattern  ,
"wave_pattern"   
)
BD2802_CONTROL_ATTR ( rgb_current  ,
"rgb_current"   
)
BD2802_CONTROL_RGBS ( led1r  ,
LED1  ,
RED   
)
BD2802_CONTROL_RGBS ( led1g  ,
LED1  ,
GREEN   
)
BD2802_CONTROL_RGBS ( led1b  ,
LED1  ,
BLUE   
)
BD2802_CONTROL_RGBS ( led2r  ,
LED2  ,
RED   
)
BD2802_CONTROL_RGBS ( led2g  ,
LED2  ,
GREEN   
)
BD2802_CONTROL_RGBS ( led2b  ,
LED2  ,
BLUE   
)
BD2802_SET_REGISTER ( 0x00  ,
"0x00"   
)
BD2802_SET_REGISTER ( 0x01  ,
"0x01"   
)
BD2802_SET_REGISTER ( 0x02  ,
"0x02"   
)
BD2802_SET_REGISTER ( 0x03  ,
"0x03"   
)
BD2802_SET_REGISTER ( 0x04  ,
"0x04"   
)
BD2802_SET_REGISTER ( 0x05  ,
"0x05"   
)
BD2802_SET_REGISTER ( 0x06  ,
"0x06"   
)
BD2802_SET_REGISTER ( 0x07  ,
"0x07"   
)
BD2802_SET_REGISTER ( 0x08  ,
"0x08"   
)
BD2802_SET_REGISTER ( 0x09  ,
"0x09"   
)
BD2802_SET_REGISTER ( 0x0a  ,
"0x0a"   
)
BD2802_SET_REGISTER ( 0x0b  ,
"0x0b"   
)
BD2802_SET_REGISTER ( 0x0c  ,
"0x0c"   
)
BD2802_SET_REGISTER ( 0x0d  ,
"0x0d"   
)
BD2802_SET_REGISTER ( 0x0e  ,
"0x0e"   
)
BD2802_SET_REGISTER ( 0x0f  ,
"0x0f"   
)
BD2802_SET_REGISTER ( 0x10  ,
"0x10"   
)
BD2802_SET_REGISTER ( 0x11  ,
"0x11"   
)
BD2802_SET_REGISTER ( 0x12  ,
"0x12"   
)
BD2802_SET_REGISTER ( 0x13  ,
"0x13"   
)
BD2802_SET_REGISTER ( 0x14  ,
"0x14"   
)
BD2802_SET_REGISTER ( 0x15  ,
"0x15"   
)
MODULE_AUTHOR ( "Kim Kyuwon <[email protected]>"  )
MODULE_DESCRIPTION ( "BD2802 LED driver )
MODULE_DEVICE_TABLE ( i2c  ,
bd2802_id   
)
module_i2c_driver ( bd2802_i2c_driver  )
MODULE_LICENSE ( "GPL v2 )