smb347-charger.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Summit Microelectronics SMB347 Battery Charger Driver
  3. *
  4. * Copyright (C) 2011, Intel Corporation
  5. *
  6. * Authors: Bruce E. Robertson <bruce.e.robertson@intel.com>
  7. * Mika Westerberg <mika.westerberg@linux.intel.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef SMB347_CHARGER_H
  14. #define SMB347_CHARGER_H
  15. #include <linux/types.h>
  16. #include <linux/power_supply.h>
  17. enum {
  18. /* use the default compensation method */
  19. SMB347_SOFT_TEMP_COMPENSATE_DEFAULT = -1,
  20. SMB347_SOFT_TEMP_COMPENSATE_NONE,
  21. SMB347_SOFT_TEMP_COMPENSATE_CURRENT,
  22. SMB347_SOFT_TEMP_COMPENSATE_VOLTAGE,
  23. };
  24. /* Use default factory programmed value for hard/soft temperature limit */
  25. #define SMB347_TEMP_USE_DEFAULT -273
  26. /*
  27. * Charging enable can be controlled by software (via i2c) by
  28. * smb347-charger driver or by EN pin (active low/high).
  29. */
  30. enum smb347_chg_enable {
  31. SMB347_CHG_ENABLE_SW,
  32. SMB347_CHG_ENABLE_PIN_ACTIVE_LOW,
  33. SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH,
  34. };
  35. /**
  36. * struct smb347_charger_platform_data - platform data for SMB347 charger
  37. * @battery_info: Information about the battery
  38. * @max_charge_current: maximum current (in uA) the battery can be charged
  39. * @max_charge_voltage: maximum voltage (in uV) the battery can be charged
  40. * @pre_charge_current: current (in uA) to use in pre-charging phase
  41. * @termination_current: current (in uA) used to determine when the
  42. * charging cycle terminates
  43. * @pre_to_fast_voltage: voltage (in uV) treshold used for transitioning to
  44. * pre-charge to fast charge mode
  45. * @mains_current_limit: maximum input current drawn from AC/DC input (in uA)
  46. * @usb_hc_current_limit: maximum input high current (in uA) drawn from USB
  47. * input
  48. * @chip_temp_threshold: die temperature where device starts limiting charge
  49. * current [%100 - %130] (in degree C)
  50. * @soft_cold_temp_limit: soft cold temperature limit [%0 - %15] (in degree C),
  51. * granularity is 5 deg C.
  52. * @soft_hot_temp_limit: soft hot temperature limit [%40 - %55] (in degree C),
  53. * granularity is 5 deg C.
  54. * @hard_cold_temp_limit: hard cold temperature limit [%-5 - %10] (in degree C),
  55. * granularity is 5 deg C.
  56. * @hard_hot_temp_limit: hard hot temperature limit [%50 - %65] (in degree C),
  57. * granularity is 5 deg C.
  58. * @suspend_on_hard_temp_limit: suspend charging when hard limit is hit
  59. * @soft_temp_limit_compensation: compensation method when soft temperature
  60. * limit is hit
  61. * @charge_current_compensation: current (in uA) for charging compensation
  62. * current when temperature hits soft limits
  63. * @use_mains: AC/DC input can be used
  64. * @use_usb: USB input can be used
  65. * @use_usb_otg: USB OTG output can be used (not implemented yet)
  66. * @irq_gpio: GPIO number used for interrupts (%-1 if not used)
  67. * @enable_control: how charging enable/disable is controlled
  68. * (driver/pin controls)
  69. *
  70. * @use_main, @use_usb, and @use_usb_otg are means to enable/disable
  71. * hardware support for these. This is useful when we want to have for
  72. * example OTG charging controlled via OTG transceiver driver and not by
  73. * the SMB347 hardware.
  74. *
  75. * Hard and soft temperature limit values are given as described in the
  76. * device data sheet and assuming NTC beta value is %3750. Even if this is
  77. * not the case, these values should be used. They can be mapped to the
  78. * corresponding NTC beta values with the help of table %2 in the data
  79. * sheet. So for example if NTC beta is %3375 and we want to program hard
  80. * hot limit to be %53 deg C, @hard_hot_temp_limit should be set to %50.
  81. *
  82. * If zero value is given in any of the current and voltage values, the
  83. * factory programmed default will be used. For soft/hard temperature
  84. * values, pass in %SMB347_TEMP_USE_DEFAULT instead.
  85. */
  86. struct smb347_charger_platform_data {
  87. struct power_supply_info battery_info;
  88. unsigned int max_charge_current;
  89. unsigned int max_charge_voltage;
  90. unsigned int pre_charge_current;
  91. unsigned int termination_current;
  92. unsigned int pre_to_fast_voltage;
  93. unsigned int mains_current_limit;
  94. unsigned int usb_hc_current_limit;
  95. unsigned int chip_temp_threshold;
  96. int soft_cold_temp_limit;
  97. int soft_hot_temp_limit;
  98. int hard_cold_temp_limit;
  99. int hard_hot_temp_limit;
  100. bool suspend_on_hard_temp_limit;
  101. unsigned int soft_temp_limit_compensation;
  102. unsigned int charge_current_compensation;
  103. bool use_mains;
  104. bool use_usb;
  105. bool use_usb_otg;
  106. int irq_gpio;
  107. enum smb347_chg_enable enable_control;
  108. };
  109. #endif /* SMB347_CHARGER_H */