mbc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * mbc.h -- Driver for NXP PCF50633 Main Battery Charger
  3. *
  4. * (C) 2006-2008 by Openmoko, Inc.
  5. * All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #ifndef __LINUX_MFD_PCF50633_MBC_H
  13. #define __LINUX_MFD_PCF50633_MBC_H
  14. #include <linux/mfd/pcf50633/core.h>
  15. #include <linux/platform_device.h>
  16. #define PCF50633_REG_MBCC1 0x43
  17. #define PCF50633_REG_MBCC2 0x44
  18. #define PCF50633_REG_MBCC3 0x45
  19. #define PCF50633_REG_MBCC4 0x46
  20. #define PCF50633_REG_MBCC5 0x47
  21. #define PCF50633_REG_MBCC6 0x48
  22. #define PCF50633_REG_MBCC7 0x49
  23. #define PCF50633_REG_MBCC8 0x4a
  24. #define PCF50633_REG_MBCS1 0x4b
  25. #define PCF50633_REG_MBCS2 0x4c
  26. #define PCF50633_REG_MBCS3 0x4d
  27. enum pcf50633_reg_mbcc1 {
  28. PCF50633_MBCC1_CHGENA = 0x01, /* Charger enable */
  29. PCF50633_MBCC1_AUTOSTOP = 0x02,
  30. PCF50633_MBCC1_AUTORES = 0x04, /* automatic resume */
  31. PCF50633_MBCC1_RESUME = 0x08, /* explicit resume cmd */
  32. PCF50633_MBCC1_RESTART = 0x10, /* restart charging */
  33. PCF50633_MBCC1_PREWDTIME_60M = 0x20, /* max. precharging time */
  34. PCF50633_MBCC1_WDTIME_1H = 0x00,
  35. PCF50633_MBCC1_WDTIME_2H = 0x40,
  36. PCF50633_MBCC1_WDTIME_4H = 0x80,
  37. PCF50633_MBCC1_WDTIME_6H = 0xc0,
  38. };
  39. #define PCF50633_MBCC1_WDTIME_MASK 0xc0
  40. enum pcf50633_reg_mbcc2 {
  41. PCF50633_MBCC2_VBATCOND_2V7 = 0x00,
  42. PCF50633_MBCC2_VBATCOND_2V85 = 0x01,
  43. PCF50633_MBCC2_VBATCOND_3V0 = 0x02,
  44. PCF50633_MBCC2_VBATCOND_3V15 = 0x03,
  45. PCF50633_MBCC2_VMAX_4V = 0x00,
  46. PCF50633_MBCC2_VMAX_4V20 = 0x28,
  47. PCF50633_MBCC2_VRESDEBTIME_64S = 0x80, /* debounce time (32/64sec) */
  48. };
  49. enum pcf50633_reg_mbcc7 {
  50. PCF50633_MBCC7_USB_100mA = 0x00,
  51. PCF50633_MBCC7_USB_500mA = 0x01,
  52. PCF50633_MBCC7_USB_1000mA = 0x02,
  53. PCF50633_MBCC7_USB_SUSPEND = 0x03,
  54. PCF50633_MBCC7_BATTEMP_EN = 0x04,
  55. PCF50633_MBCC7_BATSYSIMAX_1A6 = 0x00,
  56. PCF50633_MBCC7_BATSYSIMAX_1A8 = 0x40,
  57. PCF50633_MBCC7_BATSYSIMAX_2A0 = 0x80,
  58. PCF50633_MBCC7_BATSYSIMAX_2A2 = 0xc0,
  59. };
  60. #define PCF50633_MBCC7_USB_MASK 0x03
  61. enum pcf50633_reg_mbcc8 {
  62. PCF50633_MBCC8_USBENASUS = 0x10,
  63. };
  64. enum pcf50633_reg_mbcs1 {
  65. PCF50633_MBCS1_USBPRES = 0x01,
  66. PCF50633_MBCS1_USBOK = 0x02,
  67. PCF50633_MBCS1_ADAPTPRES = 0x04,
  68. PCF50633_MBCS1_ADAPTOK = 0x08,
  69. PCF50633_MBCS1_TBAT_OK = 0x00,
  70. PCF50633_MBCS1_TBAT_ABOVE = 0x10,
  71. PCF50633_MBCS1_TBAT_BELOW = 0x20,
  72. PCF50633_MBCS1_TBAT_UNDEF = 0x30,
  73. PCF50633_MBCS1_PREWDTEXP = 0x40,
  74. PCF50633_MBCS1_WDTEXP = 0x80,
  75. };
  76. enum pcf50633_reg_mbcs2_mbcmod {
  77. PCF50633_MBCS2_MBC_PLAY = 0x00,
  78. PCF50633_MBCS2_MBC_USB_PRE = 0x01,
  79. PCF50633_MBCS2_MBC_USB_PRE_WAIT = 0x02,
  80. PCF50633_MBCS2_MBC_USB_FAST = 0x03,
  81. PCF50633_MBCS2_MBC_USB_FAST_WAIT = 0x04,
  82. PCF50633_MBCS2_MBC_USB_SUSPEND = 0x05,
  83. PCF50633_MBCS2_MBC_ADP_PRE = 0x06,
  84. PCF50633_MBCS2_MBC_ADP_PRE_WAIT = 0x07,
  85. PCF50633_MBCS2_MBC_ADP_FAST = 0x08,
  86. PCF50633_MBCS2_MBC_ADP_FAST_WAIT = 0x09,
  87. PCF50633_MBCS2_MBC_BAT_FULL = 0x0a,
  88. PCF50633_MBCS2_MBC_HALT = 0x0b,
  89. };
  90. #define PCF50633_MBCS2_MBC_MASK 0x0f
  91. enum pcf50633_reg_mbcs2_chgstat {
  92. PCF50633_MBCS2_CHGS_NONE = 0x00,
  93. PCF50633_MBCS2_CHGS_ADAPTER = 0x10,
  94. PCF50633_MBCS2_CHGS_USB = 0x20,
  95. PCF50633_MBCS2_CHGS_BOTH = 0x30,
  96. };
  97. #define PCF50633_MBCS2_RESSTAT_AUTO 0x40
  98. enum pcf50633_reg_mbcs3 {
  99. PCF50633_MBCS3_USBLIM_PLAY = 0x01,
  100. PCF50633_MBCS3_USBLIM_CGH = 0x02,
  101. PCF50633_MBCS3_TLIM_PLAY = 0x04,
  102. PCF50633_MBCS3_TLIM_CHG = 0x08,
  103. PCF50633_MBCS3_ILIM = 0x10, /* 1: Ibat > Icutoff */
  104. PCF50633_MBCS3_VLIM = 0x20, /* 1: Vbat == Vmax */
  105. PCF50633_MBCS3_VBATSTAT = 0x40, /* 1: Vbat > Vbatcond */
  106. PCF50633_MBCS3_VRES = 0x80, /* 1: Vbat > Vth(RES) */
  107. };
  108. #define PCF50633_MBCC2_VBATCOND_MASK 0x03
  109. #define PCF50633_MBCC2_VMAX_MASK 0x3c
  110. /* Charger status */
  111. #define PCF50633_MBC_USB_ONLINE 0x01
  112. #define PCF50633_MBC_USB_ACTIVE 0x02
  113. #define PCF50633_MBC_ADAPTER_ONLINE 0x04
  114. #define PCF50633_MBC_ADAPTER_ACTIVE 0x08
  115. int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma);
  116. int pcf50633_mbc_get_status(struct pcf50633 *);
  117. int pcf50633_mbc_get_usb_online_status(struct pcf50633 *);
  118. #endif