max77823-private.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * stbcfg01-private.h - Voltage regulator driver for the STBCFG01 driver
  3. *
  4. * Copyright (C) 2009-2010 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. #ifndef __LINUX_MFD_STBCFG01_PRIV_H
  21. #define __LINUX_MFD_STBCFG01_PRIV_H
  22. #include "max77823.h"
  23. #include <linux/i2c.h>
  24. #define I2C_ADDR_FUELGAUGE 0x36
  25. #define I2C_ADDR_CHARGER 0x69
  26. #define I2C_ADDR_SAFEOUT (0xCC >> 1)
  27. #define MAX77823_IRQSRC_CHG (1 << 0)
  28. #define MAX77823_IRQSRC_FG (1 << 1)
  29. #define MAX77823_IRQSRC_SYS (1 << 2)
  30. #define MAX77823_REG_INVALID (0xff)
  31. /* Slave addr = 0xCC : PMIC */
  32. enum max77823_pmic_reg {
  33. MAX77823_PMIC_ID = 0x20,
  34. MAX77823_PMIC_Ver = 0x21,
  35. MAX77823_PMIC_INT = 0x22,
  36. MAX77823_PMIC_INT_MASK = 0x23,
  37. MAX77823_PMIC_SYS_INT = 0x24,
  38. MAX77823_PMIC_SYS_INT_MASK = 0x26,
  39. MAX77823_PMIC_SAFEOUT_LDO_Control = 0xC6,
  40. MAX77823_PMIC_END,
  41. };
  42. /* Slave addr = 0xD2 : Charger */
  43. enum max77823_charger_reg {
  44. MAX77823_CHG_INT = 0xB0,
  45. MAX77823_CHG_INT_MASK = 0xB1,
  46. MAX77823_CHG_INT_OK = 0xB2,
  47. MAX77823_CHG_DETAILS_00 = 0xB3,
  48. MAX77823_CHG_DETAILS_01 = 0xB4,
  49. MAX77823_CHG_DETAILS_02 = 0xB5,
  50. MAX77823_CHG_CNFG_00 = 0xB7,
  51. MAX77823_CHG_CNFG_01 = 0xB8,
  52. MAX77823_CHG_CNFG_02 = 0xB9,
  53. MAX77823_CHG_CNFG_03 = 0xBA,
  54. MAX77823_CHG_CNFG_04 = 0xBB,
  55. MAX77823_CHG_CNFG_06 = 0xBD,
  56. MAX77823_CHG_CNFG_07 = 0xBE,
  57. MAX77823_CHG_CNFG_09 = 0xC0,
  58. MAX77823_CHG_CNFG_10 = 0xC1,
  59. MAX77823_CHG_CNFG_11 = 0xC2,
  60. MAX77823_CHG_CNFG_12 = 0xC3,
  61. MAX77823_CHG_END,
  62. };
  63. /* Slave addr = 0x6C : Fuelgauge */
  64. enum max77823_fuelgauge_reg {
  65. MAX77823_FUEL_INT = 0xB0,
  66. MAX77823_FUEL_INT_MASK = 0xB1,
  67. };
  68. enum max77823_irq_source {
  69. CHG_IRQ = 0,
  70. FUEL_IRQ,
  71. SYS_IRQ,
  72. MAX77823_IRQ_GROUP_NR,
  73. };
  74. enum max77823_irq {
  75. /* Charger */
  76. MAX77823_CHG_IRQ_BYP_I,
  77. MAX77823_CHG_IRQ_BATP_I,
  78. MAX77823_CHG_IRQ_BAT_I,
  79. MAX77823_CHG_IRQ_CHG_I,
  80. MAX77823_CHG_IRQ_WCIN_I,
  81. MAX77823_CHG_IRQ_CHGIN_I,
  82. /* Fuelgauge */
  83. MAX77823_FG_IRQ_ALERT,
  84. MAX77823_IRQ_NR,
  85. };
  86. struct max77823_dev {
  87. struct device *dev;
  88. struct i2c_client *i2c;
  89. struct i2c_client *charger;
  90. struct i2c_client *fuelgauge;
  91. struct max77823_platform_data *pdata;
  92. struct mutex i2c_lock;
  93. int irq;
  94. int irq_base;
  95. int irq_gpio;
  96. bool wakeup;
  97. struct mutex irqlock;
  98. int irq_masks_cur[MAX77823_IRQ_GROUP_NR];
  99. int irq_masks_cache[MAX77823_IRQ_GROUP_NR];
  100. };
  101. /* MAX77823 shared i2c API function */
  102. extern int max77823_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
  103. extern int max77823_bulk_read(struct i2c_client *i2c, u8 reg, int count,
  104. u8 *buf);
  105. extern int max77823_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
  106. extern int max77823_bulk_write(struct i2c_client *i2c, u8 reg, int count,
  107. u8 *buf);
  108. extern int max77823_write_word(struct i2c_client *i2c, u8 reg, u16 value);
  109. extern int max77823_read_word(struct i2c_client *i2c, u8 reg);
  110. extern int max77823_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
  111. #endif /* __LINUX_MFD_STBCFG01_PRIV_H */