max14577.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * max14577.h - Driver for the Maxim 14577/77836
  3. *
  4. * Copyright (C) 2014 Samsung Electrnoics
  5. * Chanwoo Choi <cw00.choi@samsung.com>
  6. * Krzysztof Kozlowski <k.kozlowski@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * This driver is based on max8997.h
  19. *
  20. * MAX14577 has MUIC, Charger devices.
  21. * The devices share the same I2C bus and interrupt line
  22. * included in this mfd driver.
  23. *
  24. * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave
  25. * addresses.
  26. */
  27. #ifndef __MAX14577_H__
  28. #define __MAX14577_H__
  29. #include <linux/regulator/consumer.h>
  30. /* MAX14577 regulator IDs */
  31. enum max14577_regulators {
  32. MAX14577_SAFEOUT = 0,
  33. MAX14577_CHARGER,
  34. MAX14577_REGULATOR_NUM,
  35. };
  36. /* MAX77836 regulator IDs */
  37. enum max77836_regulators {
  38. MAX77836_SAFEOUT = 0,
  39. MAX77836_CHARGER,
  40. MAX77836_LDO1,
  41. MAX77836_LDO2,
  42. MAX77836_REGULATOR_NUM,
  43. };
  44. struct max14577_regulator_platform_data {
  45. int id;
  46. struct regulator_init_data *initdata;
  47. struct device_node *of_node;
  48. };
  49. struct max14577_charger_platform_data {
  50. u32 constant_uvolt;
  51. u32 fast_charge_uamp;
  52. u32 eoc_uamp;
  53. u32 ovp_uvolt;
  54. };
  55. /*
  56. * MAX14577 MFD platform data
  57. */
  58. struct max14577_platform_data {
  59. /* IRQ */
  60. int irq_base;
  61. /* current control GPIOs */
  62. int gpio_pogo_vbatt_en;
  63. int gpio_pogo_vbus_en;
  64. /* current control GPIO control function */
  65. int (*set_gpio_pogo_vbatt_en) (int gpio_val);
  66. int (*set_gpio_pogo_vbus_en) (int gpio_val);
  67. int (*set_gpio_pogo_cb) (int new_dev);
  68. struct max14577_regulator_platform_data *regulators;
  69. };
  70. /*
  71. * Valid limits of current for max14577 and max77836 chargers.
  72. * They must correspond to MBCICHWRCL and MBCICHWRCH fields in CHGCTRL4
  73. * register for given chipset.
  74. */
  75. struct maxim_charger_current {
  76. /* Minimal current, set in CHGCTRL4/MBCICHWRCL, uA */
  77. unsigned int min;
  78. /*
  79. * Minimal current when high setting is active,
  80. * set in CHGCTRL4/MBCICHWRCH, uA
  81. */
  82. unsigned int high_start;
  83. /* Value of one step in high setting, uA */
  84. unsigned int high_step;
  85. /* Maximum current of high setting, uA */
  86. unsigned int max;
  87. };
  88. extern const struct maxim_charger_current maxim_charger_currents[];
  89. extern int maxim_charger_calc_reg_current(const struct maxim_charger_current *limits,
  90. unsigned int min_ua, unsigned int max_ua, u8 *dst);
  91. #endif /* __MAX14577_H__ */