supply.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * supply.h -- Power Supply Driver for Wolfson WM8350 PMIC
  4. *
  5. * Copyright 2007 Wolfson Microelectronics PLC
  6. */
  7. #ifndef __LINUX_MFD_WM8350_SUPPLY_H_
  8. #define __LINUX_MFD_WM8350_SUPPLY_H_
  9. #include <linux/mutex.h>
  10. #include <linux/power_supply.h>
  11. /*
  12. * Charger registers
  13. */
  14. #define WM8350_BATTERY_CHARGER_CONTROL_1 0xA8
  15. #define WM8350_BATTERY_CHARGER_CONTROL_2 0xA9
  16. #define WM8350_BATTERY_CHARGER_CONTROL_3 0xAA
  17. /*
  18. * R168 (0xA8) - Battery Charger Control 1
  19. */
  20. #define WM8350_CHG_ENA_R168 0x8000
  21. #define WM8350_CHG_THR 0x2000
  22. #define WM8350_CHG_EOC_SEL_MASK 0x1C00
  23. #define WM8350_CHG_TRICKLE_TEMP_CHOKE 0x0200
  24. #define WM8350_CHG_TRICKLE_USB_CHOKE 0x0100
  25. #define WM8350_CHG_RECOVER_T 0x0080
  26. #define WM8350_CHG_END_ACT 0x0040
  27. #define WM8350_CHG_FAST 0x0020
  28. #define WM8350_CHG_FAST_USB_THROTTLE 0x0010
  29. #define WM8350_CHG_NTC_MON 0x0008
  30. #define WM8350_CHG_BATT_HOT_MON 0x0004
  31. #define WM8350_CHG_BATT_COLD_MON 0x0002
  32. #define WM8350_CHG_CHIP_TEMP_MON 0x0001
  33. /*
  34. * R169 (0xA9) - Battery Charger Control 2
  35. */
  36. #define WM8350_CHG_ACTIVE 0x8000
  37. #define WM8350_CHG_PAUSE 0x4000
  38. #define WM8350_CHG_STS_MASK 0x3000
  39. #define WM8350_CHG_TIME_MASK 0x0F00
  40. #define WM8350_CHG_MASK_WALL_FB 0x0080
  41. #define WM8350_CHG_TRICKLE_SEL 0x0040
  42. #define WM8350_CHG_VSEL_MASK 0x0030
  43. #define WM8350_CHG_ISEL_MASK 0x000F
  44. #define WM8350_CHG_STS_OFF 0x0000
  45. #define WM8350_CHG_STS_TRICKLE 0x1000
  46. #define WM8350_CHG_STS_FAST 0x2000
  47. /*
  48. * R170 (0xAA) - Battery Charger Control 3
  49. */
  50. #define WM8350_CHG_THROTTLE_T_MASK 0x0060
  51. #define WM8350_CHG_SMART 0x0010
  52. #define WM8350_CHG_TIMER_ADJT_MASK 0x000F
  53. /*
  54. * Charger Interrupts
  55. */
  56. #define WM8350_IRQ_CHG_BAT_HOT 0
  57. #define WM8350_IRQ_CHG_BAT_COLD 1
  58. #define WM8350_IRQ_CHG_BAT_FAIL 2
  59. #define WM8350_IRQ_CHG_TO 3
  60. #define WM8350_IRQ_CHG_END 4
  61. #define WM8350_IRQ_CHG_START 5
  62. #define WM8350_IRQ_CHG_FAST_RDY 6
  63. #define WM8350_IRQ_CHG_VBATT_LT_3P9 10
  64. #define WM8350_IRQ_CHG_VBATT_LT_3P1 11
  65. #define WM8350_IRQ_CHG_VBATT_LT_2P85 12
  66. /*
  67. * Charger Policy
  68. */
  69. #define WM8350_CHG_TRICKLE_50mA (0 << 6)
  70. #define WM8350_CHG_TRICKLE_100mA (1 << 6)
  71. #define WM8350_CHG_4_05V (0 << 4)
  72. #define WM8350_CHG_4_10V (1 << 4)
  73. #define WM8350_CHG_4_15V (2 << 4)
  74. #define WM8350_CHG_4_20V (3 << 4)
  75. #define WM8350_CHG_FAST_LIMIT_mA(x) ((x / 50) & 0xf)
  76. #define WM8350_CHG_EOC_mA(x) (((x - 10) & 0x7) << 10)
  77. #define WM8350_CHG_TRICKLE_3_1V (0 << 13)
  78. #define WM8350_CHG_TRICKLE_3_9V (1 << 13)
  79. /*
  80. * Supply Registers.
  81. */
  82. #define WM8350_USB_VOLTAGE_READBACK 0x9C
  83. #define WM8350_LINE_VOLTAGE_READBACK 0x9D
  84. #define WM8350_BATT_VOLTAGE_READBACK 0x9E
  85. /*
  86. * Supply Interrupts.
  87. */
  88. #define WM8350_IRQ_USB_LIMIT 15
  89. #define WM8350_IRQ_EXT_USB_FB 36
  90. #define WM8350_IRQ_EXT_WALL_FB 37
  91. #define WM8350_IRQ_EXT_BAT_FB 38
  92. /*
  93. * Policy to control charger state machine.
  94. */
  95. struct wm8350_charger_policy {
  96. /* charger state machine policy - set in machine driver */
  97. int eoc_mA; /* end of charge current (mA) */
  98. int charge_mV; /* charge voltage */
  99. int fast_limit_mA; /* fast charge current limit */
  100. int fast_limit_USB_mA; /* USB fast charge current limit */
  101. int charge_timeout; /* charge timeout (mins) */
  102. int trickle_start_mV; /* trickle charge starts at mV */
  103. int trickle_charge_mA; /* trickle charge current */
  104. int trickle_charge_USB_mA; /* USB trickle charge current */
  105. };
  106. struct wm8350_power {
  107. struct platform_device *pdev;
  108. struct power_supply *battery;
  109. struct power_supply *usb;
  110. struct power_supply *ac;
  111. struct wm8350_charger_policy *policy;
  112. int rev_g_coeff;
  113. };
  114. #endif