lm3533.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * lm3533.h -- LM3533 interface
  3. *
  4. * Copyright (C) 2011-2012 Texas Instruments
  5. *
  6. * Author: Johan Hovold <jhovold@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #ifndef __LINUX_MFD_LM3533_H
  14. #define __LINUX_MFD_LM3533_H
  15. #define LM3533_ATTR_RO(_name) \
  16. DEVICE_ATTR(_name, S_IRUGO, show_##_name, NULL)
  17. #define LM3533_ATTR_RW(_name) \
  18. DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name)
  19. struct device;
  20. struct regmap;
  21. struct lm3533 {
  22. struct device *dev;
  23. struct regmap *regmap;
  24. int gpio_hwen;
  25. int irq;
  26. unsigned have_als:1;
  27. unsigned have_backlights:1;
  28. unsigned have_leds:1;
  29. };
  30. struct lm3533_ctrlbank {
  31. struct lm3533 *lm3533;
  32. struct device *dev;
  33. int id;
  34. };
  35. struct lm3533_als_platform_data {
  36. unsigned pwm_mode:1; /* PWM input mode (default analog) */
  37. u8 r_select; /* 1 - 127 (ignored in PWM-mode) */
  38. };
  39. struct lm3533_bl_platform_data {
  40. char *name;
  41. u16 max_current; /* 5000 - 29800 uA (800 uA step) */
  42. u8 default_brightness; /* 0 - 255 */
  43. u8 pwm; /* 0 - 0x3f */
  44. };
  45. struct lm3533_led_platform_data {
  46. char *name;
  47. const char *default_trigger;
  48. u16 max_current; /* 5000 - 29800 uA (800 uA step) */
  49. u8 pwm; /* 0 - 0x3f */
  50. };
  51. enum lm3533_boost_freq {
  52. LM3533_BOOST_FREQ_500KHZ,
  53. LM3533_BOOST_FREQ_1000KHZ,
  54. };
  55. enum lm3533_boost_ovp {
  56. LM3533_BOOST_OVP_16V,
  57. LM3533_BOOST_OVP_24V,
  58. LM3533_BOOST_OVP_32V,
  59. LM3533_BOOST_OVP_40V,
  60. };
  61. struct lm3533_platform_data {
  62. int gpio_hwen;
  63. enum lm3533_boost_ovp boost_ovp;
  64. enum lm3533_boost_freq boost_freq;
  65. struct lm3533_als_platform_data *als;
  66. struct lm3533_bl_platform_data *backlights;
  67. int num_backlights;
  68. struct lm3533_led_platform_data *leds;
  69. int num_leds;
  70. };
  71. extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb);
  72. extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb);
  73. extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val);
  74. extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val);
  75. extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb,
  76. u16 imax);
  77. extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val);
  78. extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val);
  79. extern int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val);
  80. extern int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val);
  81. extern int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask);
  82. #endif /* __LINUX_MFD_LM3533_H */