Milo(Woogyom) Kim | c93d08f | 2013-02-05 18:01:23 +0900 | [diff] [blame] | 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 | |
| 21 | /* |
| 22 | * struct lp55xx_chip |
| 23 | * @cl : I2C communication for access registers |
| 24 | * @pdata : Platform specific data |
| 25 | * @lock : Lock for user-space interface |
| 26 | * @num_leds : Number of registered LEDs |
| 27 | */ |
| 28 | struct lp55xx_chip { |
| 29 | struct i2c_client *cl; |
| 30 | struct lp55xx_platform_data *pdata; |
| 31 | struct mutex lock; /* lock for user-space interface */ |
| 32 | int num_leds; |
| 33 | }; |
| 34 | |
| 35 | /* |
| 36 | * struct lp55xx_led |
| 37 | * @chan_nr : Channel number |
| 38 | * @cdev : LED class device |
| 39 | * @led_current : Current setting at each led channel |
| 40 | * @max_current : Maximun current at each led channel |
| 41 | * @brightness_work : Workqueue for brightness control |
| 42 | * @brightness : Brightness value |
| 43 | * @chip : The lp55xx chip data |
| 44 | */ |
| 45 | struct lp55xx_led { |
| 46 | int chan_nr; |
| 47 | struct led_classdev cdev; |
| 48 | u8 led_current; |
| 49 | u8 max_current; |
| 50 | struct work_struct brightness_work; |
| 51 | u8 brightness; |
| 52 | struct lp55xx_chip *chip; |
| 53 | }; |
| 54 | |
| 55 | /* register access */ |
| 56 | extern int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val); |
| 57 | extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val); |
| 58 | extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, |
| 59 | u8 mask, u8 val); |
| 60 | |
Milo(Woogyom) Kim | a85908d | 2013-02-05 18:07:20 +0900 | [diff] [blame^] | 61 | /* common device init functions */ |
| 62 | extern int lp55xx_init_device(struct lp55xx_chip *chip); |
| 63 | |
Milo(Woogyom) Kim | c93d08f | 2013-02-05 18:01:23 +0900 | [diff] [blame] | 64 | #endif /* _LEDS_LP55XX_COMMON_H */ |