Commit | Line | Data |
---|---|---|
c93d08fa MWK |
1 | /* |
2 | * LP55XX Common Driver Header | |
3 | * | |
4 | * Copyright (C) 2012 Texas Instruments | |
5 | * | |
6 | * Author: Milo(Woogyom) Kim <milo.kim@ti.com> | |
7 | * | |
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. | |
11 | * | |
12 | * Derived from leds-lp5521.c, leds-lp5523.c | |
13 | */ | |
14 | ||
15 | #ifndef _LEDS_LP55XX_COMMON_H | |
16 | #define _LEDS_LP55XX_COMMON_H | |
17 | ||
18 | struct lp55xx_led; | |
19 | struct lp55xx_chip; | |
20 | ||
48068d5d MWK |
21 | /* |
22 | * struct lp55xx_reg | |
23 | * @addr : Register address | |
24 | * @val : Register value | |
25 | */ | |
26 | struct lp55xx_reg { | |
27 | u8 addr; | |
28 | u8 val; | |
29 | }; | |
30 | ||
31 | /* | |
32 | * struct lp55xx_device_config | |
33 | * @reset : Chip specific reset command | |
e3a700d8 | 34 | * @enable : Chip specific enable command |
48068d5d MWK |
35 | */ |
36 | struct lp55xx_device_config { | |
37 | const struct lp55xx_reg reset; | |
e3a700d8 | 38 | const struct lp55xx_reg enable; |
48068d5d MWK |
39 | }; |
40 | ||
c93d08fa MWK |
41 | /* |
42 | * struct lp55xx_chip | |
43 | * @cl : I2C communication for access registers | |
44 | * @pdata : Platform specific data | |
45 | * @lock : Lock for user-space interface | |
46 | * @num_leds : Number of registered LEDs | |
48068d5d | 47 | * @cfg : Device specific configuration data |
c93d08fa MWK |
48 | */ |
49 | struct lp55xx_chip { | |
50 | struct i2c_client *cl; | |
51 | struct lp55xx_platform_data *pdata; | |
52 | struct mutex lock; /* lock for user-space interface */ | |
53 | int num_leds; | |
48068d5d | 54 | struct lp55xx_device_config *cfg; |
c93d08fa MWK |
55 | }; |
56 | ||
57 | /* | |
58 | * struct lp55xx_led | |
59 | * @chan_nr : Channel number | |
60 | * @cdev : LED class device | |
61 | * @led_current : Current setting at each led channel | |
62 | * @max_current : Maximun current at each led channel | |
63 | * @brightness_work : Workqueue for brightness control | |
64 | * @brightness : Brightness value | |
65 | * @chip : The lp55xx chip data | |
66 | */ | |
67 | struct lp55xx_led { | |
68 | int chan_nr; | |
69 | struct led_classdev cdev; | |
70 | u8 led_current; | |
71 | u8 max_current; | |
72 | struct work_struct brightness_work; | |
73 | u8 brightness; | |
74 | struct lp55xx_chip *chip; | |
75 | }; | |
76 | ||
77 | /* register access */ | |
78 | extern int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val); | |
79 | extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val); | |
80 | extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, | |
81 | u8 mask, u8 val); | |
82 | ||
a85908dd MWK |
83 | /* common device init functions */ |
84 | extern int lp55xx_init_device(struct lp55xx_chip *chip); | |
85 | ||
c93d08fa | 86 | #endif /* _LEDS_LP55XX_COMMON_H */ |