s2mpb02.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * s2mpb02.h - Driver for the Samsung s2mpb02
  3. *
  4. * Copyright (C) 2014 Samsung Electrnoics
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. *
  21. * S2MPB02 has Flash LED devices.
  22. * The devices share the same I2C bus and included in
  23. * this mfd driver.
  24. */
  25. #ifndef __S2MPB02_H__
  26. #define __S2MPB02_H__
  27. #include <linux/i2c.h>
  28. #define MFD_DEV_NAME "s2mpb02"
  29. #define S2MPB02_I2C_ADDR (0xB2 >> 1)
  30. #define S2MPB02_REG_INVALID (0xff)
  31. #define S2MPB02_PMIC_REV(iodev) (iodev)->rev_num
  32. enum s2mpb02_types {
  33. TYPE_S2MPB02,
  34. };
  35. enum s2mpb02_reg_types {
  36. TYPE_S2MPB02_REG_MAIN = 0,
  37. TYPE_S2MPB02_REG_SUB,
  38. TYPE_S2MPB02_REG_MAX
  39. };
  40. enum s2mpb02_irq_source {
  41. LED_INT = 0,
  42. S2MPB02_IRQ_GROUP_NR,
  43. };
  44. enum s2mpb02_irq {
  45. /* FLASH */
  46. S2MPB02_LED_IRQ_IRLED_END,
  47. S2MPB02_IRQ_NR,
  48. };
  49. struct s2mpb02_dev {
  50. struct device *dev;
  51. struct i2c_client *i2c; /* 0xB2; PMIC, Flash LED */
  52. struct mutex i2c_lock;
  53. int type;
  54. u8 rev_num; /* pmic Rev */
  55. int irq;
  56. int irq_base;
  57. int irq_gpio;
  58. bool wakeup;
  59. struct mutex irqlock;
  60. int irq_masks_cur[S2MPB02_IRQ_GROUP_NR];
  61. int irq_masks_cache[S2MPB02_IRQ_GROUP_NR];
  62. struct s2mpb02_platform_data *pdata;
  63. };
  64. #ifdef CONFIG_LEDS_S2MPB02
  65. struct s2mpb02_led_platform_data;
  66. #endif
  67. struct s2mpb02_regulator_data {
  68. int id;
  69. struct regulator_init_data *initdata;
  70. struct device_node *reg_node;
  71. };
  72. struct s2mpb02_platform_data {
  73. /* IRQ */
  74. int irq_base;
  75. int irq_gpio;
  76. bool wakeup;
  77. bool need_recovery;;
  78. int num_regulators;
  79. int num_rdata;
  80. struct s2mpb02_regulator_data *regulators;
  81. #ifdef CONFIG_LEDS_S2MPB02
  82. /* led (flash/torch) data */
  83. struct s2mpb02_led_platform_data *led_data;
  84. #endif
  85. int devs_num;
  86. struct mfd_cell *devs;
  87. };
  88. extern int s2mpb02_irq_init(struct s2mpb02_dev *s2mpb02);
  89. extern void s2mpb02_irq_exit(struct s2mpb02_dev *s2mpb02);
  90. extern int s2mpb02_irq_resume(struct s2mpb02_dev *s2mpb02);
  91. /* S2MPB02 shared i2c API function */
  92. extern int s2mpb02_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
  93. extern int s2mpb02_bulk_read(struct i2c_client *i2c, u8 reg, int count,
  94. u8 *buf);
  95. extern int s2mpb02_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
  96. extern int s2mpb02_bulk_write(struct i2c_client *i2c, u8 reg, int count,
  97. u8 *buf);
  98. extern int s2mpb02_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
  99. #endif /* __S2MPB02_H__ */