leds-lp55xx-common.h 2.2 KB

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