blob: a73ee0b9a0bdeea8ab997584535f4dee2318150e [file] [log] [blame]
Milo(Woogyom) Kimc93d08f2013-02-05 18:01:23 +09001/*
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
18struct lp55xx_led;
19struct lp55xx_chip;
20
21/*
Milo(Woogyom) Kim48068d52013-02-05 18:08:49 +090022 * struct lp55xx_reg
23 * @addr : Register address
24 * @val : Register value
25 */
26struct lp55xx_reg {
27 u8 addr;
28 u8 val;
29};
30
31/*
32 * struct lp55xx_device_config
33 * @reset : Chip specific reset command
34 */
35struct lp55xx_device_config {
36 const struct lp55xx_reg reset;
37};
38
39/*
Milo(Woogyom) Kimc93d08f2013-02-05 18:01:23 +090040 * struct lp55xx_chip
41 * @cl : I2C communication for access registers
42 * @pdata : Platform specific data
43 * @lock : Lock for user-space interface
44 * @num_leds : Number of registered LEDs
Milo(Woogyom) Kim48068d52013-02-05 18:08:49 +090045 * @cfg : Device specific configuration data
Milo(Woogyom) Kimc93d08f2013-02-05 18:01:23 +090046 */
47struct lp55xx_chip {
48 struct i2c_client *cl;
49 struct lp55xx_platform_data *pdata;
50 struct mutex lock; /* lock for user-space interface */
51 int num_leds;
Milo(Woogyom) Kim48068d52013-02-05 18:08:49 +090052 struct lp55xx_device_config *cfg;
Milo(Woogyom) Kimc93d08f2013-02-05 18:01:23 +090053};
54
55/*
56 * struct lp55xx_led
57 * @chan_nr : Channel number
58 * @cdev : LED class device
59 * @led_current : Current setting at each led channel
60 * @max_current : Maximun current at each led channel
61 * @brightness_work : Workqueue for brightness control
62 * @brightness : Brightness value
63 * @chip : The lp55xx chip data
64 */
65struct lp55xx_led {
66 int chan_nr;
67 struct led_classdev cdev;
68 u8 led_current;
69 u8 max_current;
70 struct work_struct brightness_work;
71 u8 brightness;
72 struct lp55xx_chip *chip;
73};
74
75/* register access */
76extern int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val);
77extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val);
78extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg,
79 u8 mask, u8 val);
80
Milo(Woogyom) Kima85908d2013-02-05 18:07:20 +090081/* common device init functions */
82extern int lp55xx_init_device(struct lp55xx_chip *chip);
83
Milo(Woogyom) Kimc93d08f2013-02-05 18:01:23 +090084#endif /* _LEDS_LP55XX_COMMON_H */