2 * LP55XX Common Driver Header
4 * Copyright (C) 2012 Texas Instruments
6 * Author: Milo(Woogyom) Kim <milo.kim@ti.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * Derived from leds-lp5521.c, leds-lp5523.c
15 #ifndef _LEDS_LP55XX_COMMON_H
16 #define _LEDS_LP55XX_COMMON_H
23 * @addr : Register address
24 * @val : Register value
32 * struct lp55xx_device_config
33 * @reset : Chip specific reset command
34 * @enable : Chip specific enable command
35 * @max_channel : Maximum number of channels
36 * @post_init_device : Chip specific initialization code
37 * @brightness_work_fn : Brightness work function
38 * @set_led_current : LED current set function
40 struct lp55xx_device_config
{
41 const struct lp55xx_reg reset
;
42 const struct lp55xx_reg enable
;
43 const int max_channel
;
45 /* define if the device has specific initialization process */
46 int (*post_init_device
) (struct lp55xx_chip
*chip
);
48 /* access brightness register */
49 void (*brightness_work_fn
)(struct work_struct
*work
);
51 /* current setting function */
52 void (*set_led_current
) (struct lp55xx_led
*led
, u8 led_current
);
57 * @cl : I2C communication for access registers
58 * @pdata : Platform specific data
59 * @lock : Lock for user-space interface
60 * @num_leds : Number of registered LEDs
61 * @cfg : Device specific configuration data
64 struct i2c_client
*cl
;
65 struct lp55xx_platform_data
*pdata
;
66 struct mutex lock
; /* lock for user-space interface */
68 struct lp55xx_device_config
*cfg
;
73 * @chan_nr : Channel number
74 * @cdev : LED class device
75 * @led_current : Current setting at each led channel
76 * @max_current : Maximun current at each led channel
77 * @brightness_work : Workqueue for brightness control
78 * @brightness : Brightness value
79 * @chip : The lp55xx chip data
83 struct led_classdev cdev
;
86 struct work_struct brightness_work
;
88 struct lp55xx_chip
*chip
;
92 extern int lp55xx_write(struct lp55xx_chip
*chip
, u8 reg
, u8 val
);
93 extern int lp55xx_read(struct lp55xx_chip
*chip
, u8 reg
, u8
*val
);
94 extern int lp55xx_update_bits(struct lp55xx_chip
*chip
, u8 reg
,
97 /* common device init/deinit functions */
98 extern int lp55xx_init_device(struct lp55xx_chip
*chip
);
99 extern void lp55xx_deinit_device(struct lp55xx_chip
*chip
);
101 /* common LED class device functions */
102 extern int lp55xx_register_leds(struct lp55xx_led
*led
,
103 struct lp55xx_chip
*chip
);
104 extern void lp55xx_unregister_leds(struct lp55xx_led
*led
,
105 struct lp55xx_chip
*chip
);
107 /* common device attributes functions */
108 extern int lp55xx_register_sysfs(struct lp55xx_chip
*chip
);
110 #endif /* _LEDS_LP55XX_COMMON_H */