leds-lp55xx: clean up init function
[deliverable/linux.git] / drivers / leds / leds-lp55xx-common.h
CommitLineData
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
18struct lp55xx_led;
19struct lp55xx_chip;
20
48068d5d
MWK
21/*
22 * 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
e3a700d8 34 * @enable : Chip specific enable command
ffbdccdb 35 * @post_init_device : Chip specific initialization code
48068d5d
MWK
36 */
37struct lp55xx_device_config {
38 const struct lp55xx_reg reset;
e3a700d8 39 const struct lp55xx_reg enable;
ffbdccdb
MWK
40
41 /* define if the device has specific initialization process */
42 int (*post_init_device) (struct lp55xx_chip *chip);
48068d5d
MWK
43};
44
c93d08fa
MWK
45/*
46 * struct lp55xx_chip
47 * @cl : I2C communication for access registers
48 * @pdata : Platform specific data
49 * @lock : Lock for user-space interface
50 * @num_leds : Number of registered LEDs
48068d5d 51 * @cfg : Device specific configuration data
c93d08fa
MWK
52 */
53struct lp55xx_chip {
54 struct i2c_client *cl;
55 struct lp55xx_platform_data *pdata;
56 struct mutex lock; /* lock for user-space interface */
57 int num_leds;
48068d5d 58 struct lp55xx_device_config *cfg;
c93d08fa
MWK
59};
60
61/*
62 * struct lp55xx_led
63 * @chan_nr : Channel number
64 * @cdev : LED class device
65 * @led_current : Current setting at each led channel
66 * @max_current : Maximun current at each led channel
67 * @brightness_work : Workqueue for brightness control
68 * @brightness : Brightness value
69 * @chip : The lp55xx chip data
70 */
71struct lp55xx_led {
72 int chan_nr;
73 struct led_classdev cdev;
74 u8 led_current;
75 u8 max_current;
76 struct work_struct brightness_work;
77 u8 brightness;
78 struct lp55xx_chip *chip;
79};
80
81/* register access */
82extern int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val);
83extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val);
84extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg,
85 u8 mask, u8 val);
86
a85908dd
MWK
87/* common device init functions */
88extern int lp55xx_init_device(struct lp55xx_chip *chip);
89
c93d08fa 90#endif /* _LEDS_LP55XX_COMMON_H */
This page took 0.033085 seconds and 5 git commands to generate.