leds-lp55xx-common.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef _LEDS_LP55XX_COMMON_H
  15. #define _LEDS_LP55XX_COMMON_H
  16. struct lp55xx_led;
  17. struct lp55xx_chip;
  18. /*
  19. * struct lp55xx_reg
  20. * @addr : Register address
  21. * @val : Register value
  22. */
  23. struct lp55xx_reg {
  24. u8 addr;
  25. u8 val;
  26. };
  27. /*
  28. * struct lp55xx_device_config
  29. * @reset : Chip specific reset command
  30. */
  31. struct lp55xx_device_config {
  32. const struct lp55xx_reg reset;
  33. };
  34. /*
  35. * struct lp55xx_chip
  36. * @cl : I2C communication for access registers
  37. * @pdata : Platform specific data
  38. * @lock : Lock for user-space interface
  39. * @num_leds : Number of registered LEDs
  40. * @cfg : Device specific configuration data
  41. */
  42. struct lp55xx_chip {
  43. struct i2c_client *cl;
  44. struct lp55xx_platform_data *pdata;
  45. struct mutex lock; /* lock for user-space interface */
  46. int num_leds;
  47. struct lp55xx_device_config *cfg;
  48. };
  49. /*
  50. * struct lp55xx_led
  51. * @chan_nr : Channel number
  52. * @cdev : LED class device
  53. * @led_current : Current setting at each led channel
  54. * @max_current : Maximun current at each led channel
  55. * @brightness_work : Workqueue for brightness control
  56. * @brightness : Brightness value
  57. * @chip : The lp55xx chip data
  58. */
  59. struct lp55xx_led {
  60. int chan_nr;
  61. struct led_classdev cdev;
  62. u8 led_current;
  63. u8 max_current;
  64. struct work_struct brightness_work;
  65. u8 brightness;
  66. struct lp55xx_chip *chip;
  67. };
  68. /* register access */
  69. extern int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val);
  70. extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val);
  71. extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg,
  72. u8 mask, u8 val);
  73. /* common device init functions */
  74. extern int lp55xx_init_device(struct lp55xx_chip *chip);
  75. #endif /* _LEDS_LP55XX_COMMON_H */