cps4038_charger.h 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340
  1. /*
  2. * cps4038_charger.h
  3. * Samsung CPS4038 Charger Header
  4. *
  5. * Copyright (C) 2022 Samsung Electronics, Inc.
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  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. */
  17. #ifndef __WIRELESS_CHARGER_CPS4038_H
  18. #define __WIRELESS_CHARGER_CPS4038_H __FILE__
  19. #include <linux/mfd/core.h>
  20. #include <linux/regulator/machine.h>
  21. #include <linux/i2c.h>
  22. #include <linux/alarmtimer.h>
  23. #include <linux/pm_wakeup.h>
  24. #include <linux/battery/sb_wireless.h>
  25. #include "../common/sec_charging_common.h"
  26. #include "cps4038_fod.h"
  27. #include "cps4038_cmfet.h"
  28. /* REGISTER MAPS */
  29. #define MFC_CHIP_ID_L_REG 0x00
  30. #define MFC_CHIP_ID_H_REG 0x01
  31. #define MFC_CHIP_REVISION_REG 0x02
  32. #define MFC_CUSTOMER_ID_REG 0x03
  33. #define MFC_FW_MAJOR_REV_L_REG 0x04
  34. #define MFC_FW_MAJOR_REV_H_REG 0x05
  35. #define MFC_FW_MINOR_REV_L_REG 0x06
  36. #define MFC_FW_MINOR_REV_H_REG 0x07
  37. #define MFC_PRMC_ID_L_REG 0x0A
  38. #define MFC_PRMC_ID_H_REG 0x0B
  39. /* RXID BIT[0:47] */
  40. #define MFC_WPC_RXID_0_REG 0x10
  41. #define MFC_WPC_RXID_1_REG 0x11
  42. #define MFC_WPC_RXID_2_REG 0x12
  43. #define MFC_WPC_RXID_3_REGs 0x13
  44. #define MFC_WPC_RXID_4_REG 0x14
  45. #define MFC_WPC_RXID_5_REG 0x15
  46. #define MFC_STATUS_L_REG 0x20
  47. #define MFC_STATUS_H_REG 0x21
  48. #define MFC_STATUS1_L_REG 0x22
  49. #define MFC_STATUS1_H_REG 0x23
  50. #define MFC_INT_A_L_REG 0x24
  51. #define MFC_INT_A_H_REG 0x25
  52. #define MFC_INT_B_L_REG 0x26
  53. #define MFC_INT_B_H_REG 0x27
  54. #define MFC_INT_A_ENABLE_L_REG 0x28
  55. #define MFC_INT_A_ENABLE_H_REG 0x29
  56. #define MFC_INT_B_ENABLE_L_REG 0x2A
  57. #define MFC_INT_B_ENABLE_H_REG 0x2B
  58. #define MFC_INT_A_CLEAR_L_REG 0x2C
  59. #define MFC_INT_A_CLEAR_H_REG 0x2D
  60. #define MFC_INT_B_CLEAR_L_REG 0x2E
  61. #define MFC_INT_B_CLEAR_H_REG 0x2F
  62. //#define MFC_CTRL_STS_REG 0x28
  63. #define MFC_SYS_OP_MODE_REG 0x30
  64. #define MFC_BATTERY_CHG_STATUS_REG 0x3A
  65. #define MFC_EPT_REG 0x3B /* EPT(End of Power Transfer) cases. PMA has only EOC case */
  66. #define MFC_ADC_VOUT_L_REG 0x3C
  67. #define MFC_ADC_VOUT_H_REG 0x3D
  68. #define MFC_VOUT_SET_L_REG 0x3E
  69. #define MFC_VOUT_SET_H_REG 0x3F
  70. #define MFC_VRECT_ADJ_REG 0x39
  71. #define MFC_ADC_VRECT_L_REG 0x40
  72. #define MFC_ADC_VRECT_H_REG 0x41
  73. #define MFC_ADC_IRECT_L_REG 0x42
  74. #define MFC_ADC_IRECT_H_REG 0x43
  75. #define MFC_TX_IUNO_LIMIT_L_REG 0x34
  76. #define MFC_TX_IUNO_LIMIT_H_REG 0x35
  77. #define MFC_ADC_IOUT_L_REG 0x44
  78. #define MFC_ADC_IOUT_H_REG 0x45
  79. #define MFC_ADC_DIE_TEMP_L_REG 0x46 /* 8 LSB field is used, Celsius */
  80. #define MFC_ADC_DIE_TEMP_H_REG 0x47 /* only 4 MSB[3:0] field is used, Celsius */
  81. #define MFC_TRX_OP_FREQ_L_REG 0x48 /* kHZ */
  82. #define MFC_TRX_OP_FREQ_H_REG 0x49 /* kHZ */
  83. #define MFC_RX_PING_FREQ_L_REG 0x4A /* kHZ */
  84. #define MFC_RX_PING_FREQ_H_REG 0x4B /* kHZ */
  85. #define MFC_ILIM_SET_REG 0x4C /* ILim = value * 0.05(A) */
  86. #define MFC_ILIM_ADJ_REG 0x4D /* AdjVal = ILIM_ADJ * 50 */
  87. #define MFC_AP2MFC_CMD_L_REG 0x4E
  88. #define MFC_AP2MFC_CMD_H_REG 0x4F
  89. /********************************************************************************/
  90. /* Below register are functionally depends on the operation mode(TX or RX mode) */
  91. /* RX mode */
  92. #define MFC_WPC_PCKT_HEADER_REG 0x50
  93. #define MFC_WPC_RX_DATA_COM_REG 0x51 /* WPC Rx to Tx COMMAND */
  94. #define MFC_WPC_RX_DATA_VALUE0_REG 0x52
  95. #define MFC_WPC_RX_DATA_VALUE1_REG 0x53
  96. #define MFC_WPC_RX_DATA_VALUE2_REG 0x54
  97. #define MFC_WPC_RX_DATA_VALUE3_REG 0x55
  98. #define MFC_WPC_RX_DATA_VALUE4_REG 0x56
  99. #define MFC_WPC_RX_DATA_VALUE5_REG 0x57
  100. #define MFC_WPC_RX_DATA_VALUE6_REG 0x58
  101. #define MFC_WPC_RX_DATA_VALUE7_REG 0x59
  102. /* TX mode */
  103. #define MFC_WPC_TX_DATA_COM_REG 0x50 /* WPC Tx to Rx COMMAND */
  104. #define MFC_WPC_TX_DATA_VALUE0_REG 0x51
  105. #define MFC_WPC_TX_DATA_VALUE1_REG 0x52
  106. #define MFC_WPC_TX_DATA_VALUE2_REG 0x53
  107. #define MFC_WPC_TX_DATA_VALUE3_REG 0x54
  108. #define MFC_WPC_TX_DATA_VALUE4_REG 0x55
  109. #define MFC_WPC_TX_DATA_VALUE5_REG 0x56
  110. #define MFC_WPC_TX_DATA_VALUE6_REG 0x57
  111. #define MFC_WPC_TX_DATA_VALUE7_REG 0x58
  112. #define MFC_WPC_TX_DATA_VALUE8_REG 0x59
  113. /* Common */
  114. #define MFC_WPC_TRX_DATA2_COM_REG 0x5A
  115. #define MFC_WPC_TRX_DATA2_VALUE0_REG 0x5B
  116. #define MFC_WPC_TRX_DATA2_VALUE1_REG 0x5C
  117. #define MFC_WPC_TRX_DATA2_VALUE2_REG 0x5D
  118. #define MFC_WPC_TRX_DATA2_VALUE3_REG 0x5E
  119. #define MFC_WPC_TRX_DATA2_VALUE4_REG 0x5F
  120. #define MFC_WPC_TRX_DATA2_VALUE5_REG 0x60
  121. #define MFC_WPC_TRX_DATA2_VALUE6_REG 0x61
  122. #define MFC_WPC_TRX_DATA2_VALUE7_REG 0x62
  123. #define MFC_WPC_TRX_DATA2_VALUE8_REG 0x63
  124. /********************************************************************************/
  125. #define MFC_ADT_TIMEOUT_PKT_REG 0x16B
  126. #define MFC_ADT_TIMEOUT_STR_REG 0x16C
  127. #define MFC_TX_IUNO_HYS_REG 0x36
  128. #define MFC_TX_IUNO_OFFSET_L_REG 0x37
  129. #define MFC_TX_IUNO_OFFSET_H_REG 0x38
  130. #define MFC_TX_OC_FOD1_LIMIT_L_REG 0x94
  131. #define MFC_TX_OC_FOD1_LIMIT_H_REG 0x95
  132. #define MFC_TX_OC_FOD2_LIMIT_L_REG 0x96
  133. #define MFC_TX_OC_FOD2_LIMIT_H_REG 0x97
  134. #define MFC_STARTUP_EPT_COUNTER 0x6D
  135. #define MFC_TX_DUTY_CYCLE 0xE6
  136. /* TX Digital Ping duty, default is 45% (0x2D=45) */
  137. #define MFC_TX_PING_DUTY_CYCLE 0x16D /* default 0x2D */
  138. /* TX Max Operating Frequency, default is 145kHz (0x5AA/10=145KHz) */
  139. #define MFC_TX_MAX_OP_FREQ_L_REG 0x16E /* default 0xAA */
  140. #define MFC_TX_MAX_OP_FREQ_H_REG 0x16F /* default 0x05 */
  141. /* TX Min Operating Frequency, default is 111kHz (0x456/10=111KHz) */
  142. #define MFC_TX_MIN_OP_FREQ_L_REG 0x170 /* default 0x56 */
  143. #define MFC_TX_MIN_OP_FREQ_H_REG 0x171 /* default 0x4 */
  144. /* TX Digital Ping Frequency, default is 145kHz (0x5AA/10=145KHz) */
  145. #define MFC_TX_PING_FREQ_L_REG 0x64 /* default 0xAA */
  146. #define MFC_TX_PING_FREQ_H_REG 0x65 /* default 0x05 */
  147. /* TX Mode Minimum Duty Setting Register, Min_Duty, default is 20% (0x14=20) */
  148. #define MFC_TX_MIN_DUTY_SETTING_REG 0x66 /* default 0x14 */
  149. #define TX_MIN_OP_FREQ_DEFAULT 1110 /* default 111kHz */
  150. #define MFC_INVERTER_CTRL_REG 0x67
  151. #define MFC_CMFET_CTRL_REG 0x68
  152. /* RX Mode Communication Modulation FET Ctrl */
  153. #define MFC_MST_MODE_SEL_REG 0x69
  154. #define MFC_RX_OV_CLAMP_REG 0x6A
  155. //#define MFC_RX_COMM_MOD_AFC_FET_REG 0x37
  156. #define MFC_RX_COMM_MOD_FET_REG 0x6B
  157. #define MFC_RECTMODE_REG 0x6C
  158. #define MFC_START_EPT_COUNTER_REG 0x6D
  159. #define MFC_CTRL_MODE_REG 0x6E
  160. #define MFC_RC_PHM_PING_PERIOD_REG 0x6F
  161. #define MFC_IEC_QFOD_ENABLE_REG 0x114
  162. #define MFC_IEC_QVALUE_REG 0x115
  163. #define MFC_IEC_FRES_L_REG 0x116
  164. #define MFC_IEC_FRES_R_REG 0x117
  165. #define MFC_IEC_Q_THRESH1_REG 0x118
  166. #define MFC_IEC_Q_THRESH2_REG 0x119
  167. #define MFC_IEC_FRES_THRESH1_REG 0x11A
  168. #define MFC_IEC_FRES_THRESH2_REG 0x11B
  169. #define MFC_IEC_POWER_LIMIT_THRESH_L_REG 0x11C
  170. #define MFC_IEC_POWER_LIMIT_THRESH_H_REG 0x11D
  171. #define MFC_IEC_PLOSS_THRESH1_L_REG 0x11E
  172. #define MFC_IEC_PLOSS_THRESH1_H_REG 0x11F
  173. #define MFC_IEC_PLOSS_THRESH2_L_REG 0x120
  174. #define MFC_IEC_PLOSS_THRESH2_H_REG 0x121
  175. #define MFC_IEC_PLOSS_FREQ_THRESH1_REG 0x122
  176. #define MFC_IEC_PLOSS_FREQ_THRESH2_REG 0x123
  177. #define MFC_IEC_TA_POWER_LIMIT_THRESH_L_REG 0x124
  178. #define MFC_IEC_TA_POWER_LIMIT_THRESH_H_REG 0x125
  179. #define MFC_IEC_TA_PLOSS_THRESH1_L_REG 0x126
  180. #define MFC_IEC_TA_PLOSS_THRESH1_H_REG 0x127
  181. #define MFC_IEC_TA_PLOSS_THRESH2_L_REG 0x128
  182. #define MFC_IEC_TA_PLOSS_THRESH2_H_REG 0x129
  183. #define MFC_IEC_TA_PLOSS_FREQ_THRESH1_REG 0x12A
  184. #define MFC_IEC_TA_PLOSS_FREQ_THRESH2_REG 0x12B
  185. #define MFC_IEC_PLOSS_FOD_ENABLE_REG 0x12C
  186. #define MIN_DUTY_SETTING_20_DATA 20
  187. #define MIN_DUTY_SETTING_30_DATA 30
  188. #define MIN_DUTY_SETTING_50_DATA 50
  189. #define MFC_WPC_FOD_0A_REG 0x70
  190. #define MFC_WPC_FOD_0B_REG 0x71
  191. #define MFC_WPC_FOD_1A_REG 0x72
  192. #define MFC_WPC_FOD_1B_REG 0x73
  193. #define MFC_WPC_FOD_2A_REG 0x74
  194. #define MFC_WPC_FOD_2B_REG 0x75
  195. #define MFC_WPC_FOD_3A_REG 0x76
  196. #define MFC_WPC_FOD_3B_REG 0x77
  197. #define MFC_WPC_FOD_4A_REG 0x78
  198. #define MFC_WPC_FOD_4B_REG 0x79
  199. #define MFC_WPC_FOD_5A_REG 0x7A
  200. #define MFC_WPC_FOD_5B_REG 0x7B
  201. #define MFC_WPC_FOD_6A_REG 0x7C
  202. #define MFC_WPC_FOD_6B_REG 0x7D
  203. #define MFC_WPC_FOD_7A_REG 0x7E
  204. #define MFC_WPC_FOD_7B_REG 0x7F
  205. #define MFC_WPC_FOD_8A_REG 0x80
  206. #define MFC_WPC_FOD_8B_REG 0x81
  207. #define MFC_WPC_FOD_9A_REG 0x82
  208. #define MFC_WPC_FOD_9B_REG 0x83
  209. #define MFC_WPC_PARA_MODE_REG 0x8C
  210. #define MFC_WPC_FWC_FOD_0A_REG 0x100
  211. #define MFC_WPC_FWC_FOD_0B_REG 0x101
  212. #define MFC_WPC_FWC_FOD_1A_REG 0x102
  213. #define MFC_WPC_FWC_FOD_1B_REG 0x103
  214. #define MFC_WPC_FWC_FOD_2A_REG 0x104
  215. #define MFC_WPC_FWC_FOD_2B_REG 0x105
  216. #define MFC_WPC_FWC_FOD_3A_REG 0x106
  217. #define MFC_WPC_FWC_FOD_3B_REG 0x107
  218. #define MFC_WPC_FWC_FOD_4A_REG 0x108
  219. #define MFC_WPC_FWC_FOD_4B_REG 0x109
  220. #define MFC_WPC_FWC_FOD_5A_REG 0x10A
  221. #define MFC_WPC_FWC_FOD_5B_REG 0x10B
  222. #define MFC_WPC_FWC_FOD_6A_REG 0x10C
  223. #define MFC_WPC_FWC_FOD_6B_REG 0x10D
  224. #define MFC_WPC_FWC_FOD_7A_REG 0x10E
  225. #define MFC_WPC_FWC_FOD_7B_REG 0x10F
  226. #define MFC_WPC_FWC_FOD_8A_REG 0x100
  227. #define MFC_WPC_FWC_FOD_8B_REG 0x101
  228. #define MFC_WPC_FWC_FOD_9A_REG 0x102
  229. #define MFC_WPC_FWC_FOD_9B_REG 0x103
  230. #define MFC_WPC_EPP_FOD_0A_REG 0x1A2
  231. #define MFC_WPC_EPP_FOD_0B_REG 0x1A3
  232. #define MFC_WPC_EPP_FOD_1A_REG 0x1A4
  233. #define MFC_WPC_EPP_FOD_1B_REG 0x1A5
  234. #define MFC_WPC_EPP_FOD_2A_REG 0x1A6
  235. #define MFC_WPC_EPP_FOD_2B_REG 0x1A7
  236. #define MFC_WPC_EPP_FOD_3A_REG 0x1A8
  237. #define MFC_WPC_EPP_FOD_3B_REG 0x1A9
  238. #define MFC_WPC_EPP_FOD_4A_REG 0x1AA
  239. #define MFC_WPC_EPP_FOD_4B_REG 0x1AB
  240. #define MFC_WPC_EPP_FOD_5A_REG 0x1AC
  241. #define MFC_WPC_EPP_FOD_5B_REG 0x1AD
  242. #define MFC_WPC_EPP_FOD_6A_REG 0x1AE
  243. #define MFC_WPC_EPP_FOD_6B_REG 0x1AF
  244. #define MFC_WPC_EPP_FOD_7A_REG 0x1B0
  245. #define MFC_WPC_EPP_FOD_7B_REG 0x1B1
  246. #define MFC_WPC_EPP_FOD_8A_REG 0x1B2
  247. #define MFC_WPC_EPP_FOD_8B_REG 0x1B3
  248. #define MFC_WPC_EPP_FOD_9A_REG 0x1B4
  249. #define MFC_WPC_EPP_FOD_9B_REG 0x1B5
  250. #define MFC_PMA_FOD_0A_REG 0x84
  251. #define MFC_PMA_FOD_0B_REG 0x85
  252. #define MFC_PMA_FOD_1A_REG 0x86
  253. #define MFC_PMA_FOD_1B_REG 0x87
  254. #define MFC_PMA_FOD_2A_REG 0x88
  255. #define MFC_PMA_FOD_2B_REG 0x89
  256. #define MFC_PMA_FOD_3A_REG 0x8A
  257. #define MFC_PMA_FOD_3B_REG 0x8B
  258. #define MFC_ADT_ERROR_CODE_REG 0x8D
  259. #define MFC_TX_FOD_GAIN_REG 0x8F
  260. #define MFC_TX_FOD_OFFSET_L_REG 0x90
  261. #define MFC_TX_FOD_OFFSET_H_REG 0x91
  262. #define MFC_TX_FOD_THRESH1_L_REG 0x92
  263. #define MFC_TX_FOD_THRESH1_H_REG 0x93
  264. #define MFC_TX_FOD_TA_THRESH_L_REG 0x98
  265. #define MFC_TX_FOD_TA_THRESH_H_REG 0x99
  266. #define MFX_TX_ID_VALUE_L_REG 0x9C
  267. #define MFX_TX_ID_VALUE_H_REG 0x9D
  268. #define MFC_DEMOD1_REG 0x9E
  269. #define MFC_DEMOD2_REG 0x9F
  270. #define MFC_TX_CONFLICT_CURRENT_REG 0xA0
  271. #define MFC_RECT_MODE_AP_CTRL 0xA2
  272. #define MFC_FW_DATA_CODE_0 0xB0
  273. #define MFC_FW_DATA_CODE_1 0xB1
  274. #define MFC_FW_DATA_CODE_2 0xB2
  275. #define MFC_FW_DATA_CODE_3 0xB3
  276. #define MFC_FW_DATA_CODE_4 0xB4
  277. #define MFC_FW_DATA_CODE_5 0xB5
  278. #define MFC_FW_DATA_CODE_6 0xB6
  279. #define MFC_FW_DATA_CODE_7 0xB7
  280. #define MFC_FW_DATA_CODE_8 0xB8
  281. #define MFC_FW_DATA_CODE_9 0xB9
  282. #define MFC_FW_DATA_CODE_A 0xBA
  283. #define MFC_RX_PWR_L_REG 0xBC
  284. #define MFC_RX_PWR_H_REG 0xBD
  285. /* Timer code contains ASCII value. (ex. 31 means '1', 3A means ':') */
  286. #define MFC_FW_TIMER_CODE_0 0xC0
  287. #define MFC_FW_TIMER_CODE_1 0xC1
  288. #define MFC_FW_TIMER_CODE_2 0xC2
  289. #define MFC_FW_TIMER_CODE_3 0xC3
  290. #define MFC_FW_TIMER_CODE_4 0xC4
  291. #define MFC_FW_TIMER_CODE_5 0xC5
  292. #define MFC_FW_TIMER_CODE_6 0xC6
  293. #define MFC_FW_TIMER_CODE_7 0xC7
  294. #define MFC_PWR_HOLD_INTERVAL_REG 0xCF
  295. //#define MFC_TX_FOD_THRESH2_REG 0xE3
  296. //#define MFC_TX_DUTY_CYCLE_REG 0xE6
  297. //#define MFC_TX_PWR_L_REG 0xEC
  298. //#define MFC_TX_PWR_H_REG 0xED
  299. #define MFC_RPP_SCALE_COEF_REG 0xF0
  300. //#define MFC_ACTIVE_LOAD_CONTROL_REG 0xF1
  301. /* Parameter 1: Major and Minor Version */
  302. #define MFC_TX_RXID1_READ_REG 0xF2
  303. /* Parameter 2~3: Manufacturer Code */
  304. #define MFC_TX_RXID2_READ_REG 0xF3
  305. #define MFC_TX_RXID3_READ_REG 0xF4
  306. /* Parameter 4~10: Basic Device Identifier */
  307. //#define MFC_TX_RXID4_READ_REG 0xF5
  308. //#define MFC_TX_RXID5_READ_REG 0xF6
  309. //#define MFC_TX_RXID6_READ_REG 0xF7
  310. //#define MFC_TX_RXID7_READ_REG 0xF8
  311. //#define MFC_TX_RXID8_READ_REG 0xF9
  312. //#define MFC_TX_RXID9_READ_REG 0xFA
  313. //#define MFC_TX_RXID10_READ_REG 0xFB
  314. /* Target Vrect is ReadOnly register, and updated by every 10ms
  315. * Its default value is 0x1A90(6800mV).
  316. * Target_Vrect (Iout,Vout) = {Vout + 0.05} + { Vrect(Iout,5V)-Vrect(1A,5V) } * 5/9
  317. */
  318. #define MFC_TARGET_VRECT_L_REG 0x0164 /* default 0x90 */
  319. #define MFC_TARGET_VRECT_H_REG 0x0165 /* default 0x1A */
  320. #define MFC_MPP_CLOAK_REASON_REG 0x180
  321. #define MFC_MPP_FULL_MODE_TRANS_TYPE_REG 0x181
  322. #define MFC_MPP_POWER_LEVEL_SETTING_REG 0x182
  323. #define MFC_MPP_GP_STATE_REG 0x183
  324. #define MFC_MPP_EPP_NEGO_DONE_POWER_L_REG 0x184
  325. #define MFC_MPP_EPP_NEGO_DONE_POWER_H_REG 0x185
  326. #define MFC_MPP_EPP_POTENTIAL_LOAD_POWER_L_REG 0x186
  327. #define MFC_MPP_EPP_POTENTIAL_LOAD_POWER_H_REG 0x187
  328. #define MFC_MPP_EPP_NEGOTIABLE_LOAD_POWER_L_REG 0x188
  329. #define MFC_MPP_EPP_NEGOTIABLE_LOAD_POWER_H_REG 0x189
  330. #define MFC_MPP_PTX_EXTENDED_ID0_REG 0x18A
  331. #define MFC_MPP_PTX_EXTENDED_ID1_REG 0x18B
  332. #define MFC_MPP_PTX_EXTENDED_ID2_REG 0x18C
  333. #define MFC_MPP_DC_CURRENT_MOD_BASE_LIGHT_REG 0x18D
  334. #define MFC_MPP_DC_CURRENT_MOD_BASE_HEAVY_REG 0x18E
  335. #define MFC_MPP_DC_CURRENT_MOD_DEPTH_REG 0x18F
  336. #define MFC_MPP_EXIT_CLOAK_REASON_REG 0x190
  337. #define MFC_MPP_FOD_QF_REG 0x191
  338. #define MFC_MPP_FOD_RF_REG 0x192
  339. #define MFC_MPP_ALPHA0_RX_REG 0x193
  340. #define MFC_MPP_ALPHA1_RX_REG 0x194
  341. #define MFC_MPP_ALPHA_KTH_RX_REG 0x195
  342. #define MFC_MPP_RX_COIL_RAC_L_REG 0x196
  343. #define MFC_MPP_RX_COIL_RAC_H_REG 0x197
  344. #define MFC_MPP_RX_CAP_ESR_L_REG 0x198
  345. #define MFC_MPP_RX_CAP_ESR_H_REG 0x199
  346. #define MFC_MPP_M_COIL_L_REG 0x19A
  347. #define MFC_MPP_M_COIL_H_REG 0x19B
  348. #define MFC_MPP_ALPHA_FM_L_REG 0x19C
  349. #define MFC_MPP_ALPHA_FM_H_REG 0x19D
  350. #define MFC_MPP_ALPHA_FM_DC_L_REG 0x19E
  351. #define MFC_MPP_ALPHA_FM_DC_H_REG 0x19F
  352. #define MFC_MPP_G_COIL_Tx_L_REG 0x1A0
  353. #define MFC_MPP_G_COIL_Tx_H_REG 0x1A1
  354. #define MFC_MPP_THERMAL_CTRL_REG 0x1B6
  355. #define MFC_TX_WPC_AUTH_SUPPORT_REG 0x1B7
  356. #define MFC_CEP_TIME_OUT_REG 0x1B8
  357. #define SS_ID 0x42
  358. #define SS_CODE 0x64
  359. /* Cloak reason Register, CLOAK_REASON (0x180) */
  360. #define MFC_TRX_MPP_CLOAK_GENERIC 0x0
  361. #define MFC_TRX_MPP_CLOAK_FORCED 0x1
  362. #define MFC_TRX_MPP_CLOAK_THERMALLY_CONSTRAINED 0x2
  363. #define MFC_TRX_MPP_CLOAK_INSUFFICIENT_POWER 0x3
  364. #define MFC_TRX_MPP_CLOAK_COEX_MITIGATION 0x4
  365. #define MFC_TRX_MPP_CLOAK_END_OF_CHARGE 0x5
  366. #define MFC_TRX_MPP_CLOAK_PTX_INITIATED 0x6
  367. /* Cloak exit reason Register, EXIT_CLOAK_REASON (0x190) */
  368. #define MFC_TRX_MPP_EXIT_CLOAK_NORMAL 0x0
  369. #define MFC_TRX_MPP_EXIT_CLOAK_FSK_FAIL 0x1
  370. #define MFC_TRX_MPP_EXIT_CLOAK_DET_PING_TIMEOUT 0x2
  371. #define MFC_TRX_MPP_EXIT_CLOAK_PING_TIMEOUT 0x3
  372. #define MFC_TRX_MPP_EXIT_CLOAK_PTX_ID_FAIL 0x4
  373. /* full mode transfer type Register, FULL_MODE_TRANS_TYPE (0x181) */
  374. #define MFC_RX_MPP_FULL_MODE_TRAN_NO_POWER_RESET 0x00
  375. #define MFC_RX_MPP_FULL_MODE_TRAN_POWER_RESET 0x01
  376. /* nego power level Register, POWER_LEVEL_SETTING (0x182) */
  377. #define MFC_RX_MPP_NEGO_POWER_10W 10
  378. #define MFC_RX_MPP_NEGO_POWER_15W 15
  379. /* ADT type Register, ADT_TYPE (0x800[7:3]) */
  380. #define MFC_ADT_FWC_EPP_END 0x0
  381. #define MFC_ADT_FWC_EPP_GENERAL 0x1
  382. #define MFC_ADT_FWC_EPP_AUTHENTICATION 0x2
  383. #define MFC_ADT_FWC_EPP_RESET 0x12
  384. #define MFC_ADT_MPP_RESET_ALL 0x0
  385. #define MFC_ADT_MPP_RESET_SINGLE 0x1
  386. #define MFC_ADT_MPP_ABORT 0x2
  387. #define MFC_ADT_MPP_COMPLETE 0x3
  388. #define MFC_ADT_MPP_OPEN 0x4
  389. #define MFC_RX_CEP_PACKET_COUNTER0 0x029C
  390. #define MFC_RX_CEP_PACKET_COUNTER1 0x029D
  391. #define MFC_RX_CEP_PACKET_COUNTER2 0x029E
  392. #define MFC_RX_CEP_PACKET_COUNTER3 0x029F
  393. #define MFC_RX_RPP_PACKET_COUNTER0 0x02A0
  394. #define MFC_RX_RPP_PACKET_COUNTER1 0x02A1
  395. #define MFC_RX_RPP_PACKET_COUNTER2 0x02A2
  396. #define MFC_RX_RPP_PACKET_COUNTER3 0x02A3
  397. #define MFC_RX_CSP_PACKET_COUNTER0 0x02A4
  398. #define MFC_RX_CSP_PACKET_COUNTER1 0x02A5
  399. #define MFC_RX_CSP_PACKET_COUNTER2 0x02A6
  400. #define MFC_RX_CSP_PACKET_COUNTER3 0x02A7
  401. #define MFC_RX_PPP_PACKET_COUNTER0 0x02A8
  402. #define MFC_RX_PPP_PACKET_COUNTER1 0x02A9
  403. #define MFC_RX_PPP_PACKET_COUNTER2 0x02AA
  404. #define MFC_RX_PPP_PACKET_COUNTER3 0x02AB
  405. /* ADT Buffer Registers, (0x0800 ~ 0x0FFF) */
  406. #define MFC_ADT_BUFFER_ADT_TYPE_REG 0x0800
  407. #define MFC_ADT_BUFFER_ADT_MSG_SIZE_REG 0x0801
  408. #define MFC_ADT_BUFFER_ADT_PARAM_REG 0x0804
  409. #define MFC_ADT_BUFFER_ADT_PARAM_MAX_REG 0x0FFF
  410. /* System Operating Mode Register, Sys_Op_Mode (0x2B) */
  411. #define PAD_MODE_MISSING 0
  412. #define PAD_MODE_WPC_BASIC 1
  413. #define PAD_MODE_WPC_ADV 2
  414. #define PAD_MODE_PMA_SR1 3
  415. #define PAD_MODE_PMA_SR1E 4
  416. #define PAD_MODE_UNKNOWN 5
  417. /* MFC_RX_DATA_COM_REG (0x51) : RX Data Command VALUE of 0x19 PPP Heaader */
  418. #define WPC_COM_CLEAR_PACKET_COUNTING 0x01
  419. #define WPC_COM_START_PACKET_COUNTING 0x02
  420. #define WPC_COM_DISABLE_PACKET_COUNTING 0x03
  421. /* RX Data Value1 Register (Data Sending), RX_Data_VALUE1_Out (0x51) : Function and Description */
  422. #define WPC_COM_UNKNOWN 0x00
  423. #define WPC_COM_TX_ID 0x01
  424. #define WPC_COM_CHG_STATUS 0x05
  425. #define WPC_COM_AFC_SET 0x06
  426. #define WPC_COM_AFC_DEBOUNCE 0x07 /* Data Values [ 0~1000mV : 0x0000~0x03E8 ], 2 bytes*/
  427. #define WPC_COM_SID_TAG 0x08
  428. #define WPC_COM_SID_TOKEN 0x09
  429. #define WPC_COM_TX_STANDBY 0x0A
  430. #define WPC_COM_LED_CONTROL 0x0B /* Data Value LED Enable(0x00), LED Disable(0xFF) */
  431. #define WPC_COM_REQ_AFC_TX 0x0C /* Data Value (0x00) */
  432. #define WPC_COM_COOLING_CTRL 0x0D /* Data Value ON(0x00), OFF(0xFF) */
  433. #define WPC_COM_RX_ID 0x0E /* Received RX ID */
  434. #define WPC_COM_CHG_LEVEL 0x0F /* Battery level */
  435. #define WPC_COM_ENTER_PHM 0x18 /* GEAR entered PHM */
  436. #define WPC_COM_DISABLE_TX 0x19 /* Turn off UNO of TX, OFF(0xFF) */
  437. #define WPC_COM_PAD_LED 0x20 /* PAD LED */
  438. #define WPC_COM_REQ_PWR_BUDG 0x21
  439. #define WPC_COM_OP_FREQ_SET 0xD1
  440. #define WPC_COM_WDT_ERR 0xE7 /* Data Value WDT Error */
  441. /* RX Data Value 2~5 Register (Data Sending), RX_Data_Value2_5_Out : Function and Description */
  442. #define RX_DATA_VAL2_5V 0x05
  443. #define RX_DATA_VAL2_10V 0x2C
  444. #define RX_DATA_VAL2_12V 0x4B
  445. #define RX_DATA_VAL2_12_5V 0x69
  446. #define RX_DATA_VAL2_20V 0x9B
  447. #define RX_DATA_VAL2_TA_CONNECT_DURING_WC 0x55
  448. #define RX_DATA_VAL2_MISALIGN 0xFF
  449. #define RX_DATA_VAL2_ENABLE 0x01
  450. #define RX_DATA_VAL2_RXID_ACC_BUDS 0x70
  451. #define RX_DATA_VAL2_RXID_ACC_BUDS_MAX 0x8F
  452. /* MFC_TX_DATA_COM_REG (0x58) : TX Command */
  453. #define WPC_TX_COM_UNKNOWN 0x00
  454. #define WPC_TX_COM_TX_ID 0x01
  455. #define WPC_TX_COM_AFC_SET 0x02
  456. #define WPC_TX_COM_ACK 0x03
  457. #define WPC_TX_COM_NAK 0x04
  458. #define WPC_TX_COM_CHG_ERR 0x05
  459. #define WPC_TX_COM_WPS 0x07
  460. #define WPC_TX_COM_RX_POWER 0x0A
  461. #define WPC_TX_COM_TX_PWR_BUDG 0x0C
  462. /* value of WPC_TX_COM_AFC_SET(0x02) */
  463. #define TX_AFC_SET_5V 0x00
  464. #define TX_AFC_SET_10V 0x01
  465. #define TX_AFC_SET_12V 0x02
  466. #define TX_AFC_SET_18V 0x03
  467. #define TX_AFC_SET_19V 0x04
  468. #define TX_AFC_SET_20V 0x05
  469. #define TX_AFC_SET_24V 0x06
  470. /* value of WPC_TX_COM_TX_ID(0x01) */
  471. #define TX_ID_UNKNOWN 0x00
  472. #define TX_ID_SNGL_PORT_START 0x01
  473. #define TX_ID_VEHICLE_PAD 0x11
  474. #define TX_ID_PG950_D_PAD 0x14
  475. #define TX_ID_P1100_PAD 0x16
  476. #define TX_ID_P1300_PAD 0x17
  477. #define TX_ID_P2400_PAD_NOAUTH 0x18
  478. #define TX_ID_SNGL_PORT_END 0x1F
  479. #define TX_ID_MULTI_PORT_START 0x20
  480. #define TX_ID_P4300_PAD 0x25
  481. #define TX_ID_P5400_PAD_NOAUTH 0x27
  482. #define TX_ID_MULTI_PORT_END 0x2F
  483. #define TX_ID_STAND_TYPE_START 0x30
  484. #define TX_ID_PG950_S_PAD 0x31
  485. #define TX_ID_N3300_V_PAD 0x35
  486. #define TX_ID_N3300_H_PAD 0xF2
  487. #define TX_ID_STAND_TYPE_END 0x3F
  488. #define TX_ID_BATT_PACK_TA 0x41 /* 0x40 ~ 0x41 is N/C*/
  489. #define TX_ID_BATT_PACK_U1200 0x42
  490. #define TX_ID_BATT_PACK_U3300 0x43
  491. #define TX_ID_BATT_PACK_END 0x4F /* reserved 0x40 ~ 0x4F for wireless battery pack */
  492. #define TX_ID_UNO_TX 0x72
  493. #define TX_ID_UNO_TX_B0 0x80
  494. #define TX_ID_UNO_TX_B1 0x81
  495. #define TX_ID_UNO_TX_B2 0x82
  496. #define TX_ID_UNO_TX_MAX 0x9F
  497. #define TX_ID_AUTH_PAD 0xA0
  498. #define TX_ID_P5200_PAD 0xA0
  499. #define TX_ID_N5200_V_PAD 0xA1
  500. #define TX_ID_N5200_H_PAD 0xA2
  501. #define TX_ID_P2400_PAD 0xA3
  502. #define TX_ID_P5400_PAD 0xA4
  503. #define TX_ID_AUTH_PAD_ACLASS_END 0xAF
  504. #define TX_ID_AUTH_PAD_END 0xBF /* reserved 0xA1 ~ 0xBF for auth pad */
  505. #define TX_ID_JIG_PAD 0xED /* for factory */
  506. #define TX_ID_FG_PAD 0xEF /* Galaxy Friends */
  507. #define TX_ID_NON_AUTH_PAD 0xF0
  508. #define TX_ID_NON_AUTH_PAD_END 0xFF
  509. /* value of WPC_TX_COM_CHG_ERR(0x05) */
  510. #define TX_CHG_ERR_OTP 0x12
  511. #define TX_CHG_ERR_OCP 0x13
  512. #define TX_CHG_ERR_DARKZONE 0x14
  513. #define TX_CHG_ERR_FOD (0x20 ... 0x27)
  514. /* value of WPC_TX_COM_WPS 0x07) */
  515. #define WPS_AICL_RESET 0x01
  516. /* value of WPC_TX_COM_RX_POWER(0x0A) */
  517. #define TX_RX_POWER_0W 0x0
  518. #define TX_RX_POWER_3W 0x1E
  519. #define TX_RX_POWER_5W 0x32
  520. #define TX_RX_POWER_6W 0x3C
  521. #define TX_RX_POWER_6_5W 0x41
  522. #define TX_RX_POWER_7_5W 0x4B
  523. #define TX_RX_POWER_8W 0x50
  524. #define TX_RX_POWER_10W 0x64
  525. #define TX_RX_POWER_12W 0x78
  526. #define TX_RX_POWER_15W 0x96
  527. #define TX_RX_POWER_17_5W 0xAF
  528. #define TX_RX_POWER_20W 0xC8
  529. #define MFC_NUM_FOD_REG 20
  530. /* BIT DEFINE of Command Register, COM_L(0x4E) */
  531. #define MFC_CMD_TOGGLE_PHM_SHIFT 7
  532. #define MFC_CMD_RESERVED6_SHIFT 6
  533. #define MFC_CMD_CLEAR_INT_SHIFT 5
  534. #define MFC_CMD_SEND_CHG_STS_SHIFT 4
  535. #define MFC_CMD_SEND_EOP_SHIFT 3
  536. #define MFC_CMD_MCU_RESET_SHIFT 2
  537. #define MFC_CMD_TOGGLE_LDO_SHIFT 1
  538. #define MFC_CMD_SEND_TRX_DATA_SHIFT 0
  539. #define MFC_CMD_TOGGLE_PHM_MASK (1 << MFC_CMD_TOGGLE_PHM_SHIFT)
  540. #define MFC_CMD_RESERVED6_MASK (1 << MFC_CMD_RESERVED6_SHIFT)
  541. #define MFC_CMD_CLEAR_INT_MASK (1 << MFC_CMD_CLEAR_INT_SHIFT)
  542. #define MFC_CMD_SEND_CHG_STS_MASK (1 << MFC_CMD_SEND_CHG_STS_SHIFT) /* MFC MCU sends ChgStatus packet to TX */
  543. #define MFC_CMD_SEND_EOP_MASK (1 << MFC_CMD_SEND_EOP_SHIFT)
  544. #define MFC_CMD_MCU_RESET_MASK (1 << MFC_CMD_MCU_RESET_SHIFT)
  545. #define MFC_CMD_TOGGLE_LDO_MASK (1 << MFC_CMD_TOGGLE_LDO_SHIFT)
  546. #define MFC_CMD_SEND_TRX_DATA_MASK (1 << MFC_CMD_SEND_TRX_DATA_SHIFT)
  547. /* Command Register, COM_H(0x4F) */
  548. #define MFC_CMD2_MPP_EXIT_CLOAK_SHIFT 4
  549. #define MFC_CMD2_MPP_ENTER_CLOAK_SHIFT 3
  550. #define MFC_CMD2_MPP_FULL_MODE_SHIFT 2
  551. #define MFC_CMD2_ADT_SENT_SHIFT 1
  552. #define MFC_CMD2_WP_ON_SHIFT 0
  553. #define MFC_CMD2_MPP_EXIT_CLOAK_MASK (1 << MFC_CMD2_MPP_EXIT_CLOAK_SHIFT)
  554. #define MFC_CMD2_MPP_ENTER_CLOAK_MASK (1 << MFC_CMD2_MPP_ENTER_CLOAK_SHIFT)
  555. #define MFC_CMD2_MPP_FULL_MODE_MASK (1 << MFC_CMD2_MPP_FULL_MODE_SHIFT)
  556. #define MFC_CMD2_ADT_SENT_MASK (1 << MFC_CMD2_ADT_SENT_SHIFT)
  557. #define MFC_CMD2_WP_ON_MASK (1 << MFC_CMD2_WP_ON_SHIFT)
  558. /* Chip Revision and Font Register, Chip_Rev (0x02) */
  559. #define MFC_CHIP_REVISION_MASK 0xf0
  560. #define MFC_CHIP_FONT_MASK 0x0f
  561. /* BIT DEFINE of Status Registers, Status_L (0x20), Status_H (0x21), Status1_L (0x22), Status1_H (0x23) */
  562. #define MFC_STAT_L_STAT_VOUT_SHIFT 7
  563. #define MFC_STAT_L_STAT_VRECT_SHIFT 6
  564. #define MFC_STAT_L_OP_MODE_SHIFT 5
  565. #define MFC_STAT_L_OVER_VOL_SHIFT 4
  566. #define MFC_STAT_L_OVER_CURR_SHIFT 3
  567. #define MFC_STAT_L_OVER_TEMP_SHIFT 2
  568. #define MFC_STAT_L_TXCONFLICT_SHIFT 1
  569. #define MFC_STAT_L_ADT_ERROR_SHIFT 0
  570. #define MFC_STAT_L_STAT_VOUT_MASK (1 << MFC_STAT_L_STAT_VOUT_SHIFT)
  571. #define MFC_STAT_L_STAT_VRECT_MASK (1 << MFC_STAT_L_STAT_VRECT_SHIFT)
  572. #define MFC_STAT_L_OP_MODE_MASK (1 << MFC_STAT_L_OP_MODE_SHIFT)
  573. #define MFC_STAT_L_OVER_VOL_MASK (1 << MFC_STAT_L_OVER_VOL_SHIFT)
  574. #define MFC_STAT_L_OVER_CURR_MASK (1 << MFC_STAT_L_OVER_CURR_SHIFT)
  575. #define MFC_STAT_L_OVER_TEMP_MASK (1 << MFC_STAT_L_OVER_TEMP_SHIFT)
  576. #define MFC_STAT_L_TXCONFLICT_MASK (1 << MFC_STAT_L_TXCONFLICT_SHIFT)
  577. #define MFC_STAT_L_ADT_ERROR_MASK (1 << MFC_STAT_L_ADT_ERROR_SHIFT)
  578. #define MFC_STAT_H_TRX_DATA_RECEIVED_SHIFT 7
  579. #define MFC_STAT_H_TX_OCP_SHIFT 6
  580. #define MFC_STAT_H_TX_MODE_RX_NOT_DET_SHIFT 5
  581. #define MFC_STAT_H_TX_FOD_SHIFT 4
  582. #define MFC_STAT_H_TX_CON_DISCON_SHIFT 3
  583. #define MFC_STAT_H_AC_MISSING_DET_SHIFT 2
  584. #define MFC_STAT_H_ADT_RECEIVED_SHIFT 1
  585. #define MFC_STAT_H_ADT_SENT_SHIFT 0
  586. #define MFC_STAT_H_TRX_DATA_RECEIVED_MASK (1 << MFC_STAT_H_TRX_DATA_RECEIVED_SHIFT)
  587. #define MFC_STAT_H_TX_OCP_MASK (1 << MFC_STAT_H_TX_OCP_SHIFT)
  588. #define MFC_STAT_H_TX_MODE_RX_NOT_DET_MASK (1 << MFC_STAT_H_TX_MODE_RX_NOT_DET_SHIFT)
  589. #define MFC_STAT_H_TX_FOD_MASK (1 << MFC_STAT_H_TX_FOD_SHIFT)
  590. #define MFC_STAT_H_TX_CON_DISCON_MASK (1 << MFC_STAT_H_TX_CON_DISCON_SHIFT)
  591. #define MFC_STAT_H_AC_MISSING_DET_MASK (1 << MFC_STAT_H_AC_MISSING_DET_SHIFT)
  592. #define MFC_STAT_H_ADT_RECEIVED_MASK (1 << MFC_STAT_H_ADT_RECEIVED_SHIFT)
  593. #define MFC_STAT_H_ADT_SENT_MASK (1 << MFC_STAT_H_ADT_SENT_SHIFT)
  594. #define MFC_STAT1_L_EPP_NEGO_FAIL_SHIFT 7
  595. #define MFC_STAT1_L_EPP_NEGO_PASS_SHIFT 6
  596. #define MFC_STAT1_L_EXIT_CLOAK_SHIFT 5
  597. #define MFC_STAT1_L_DECREASE_POWER_SHIFT 4
  598. #define MFC_STAT1_L_INCREASE_POWER_SHIFT 3
  599. #define MFC_STAT1_L_360K_NEGO_PASS_SHIFT 2
  600. #define MFC_STAT1_L_EPP_SUPPROT_SHIFT 1
  601. #define MFC_STAT1_L_MPP_SUPPROT_SHIFT 0
  602. #define MFC_STAT1_L_EPP_NEGO_FAIL_MASK (1 << MFC_STAT1_L_EPP_NEGO_FAIL_SHIFT)
  603. #define MFC_STAT1_L_EPP_NEGO_PASS_MASK (1 << MFC_STAT1_L_EPP_NEGO_PASS_SHIFT)
  604. #define MFC_STAT1_L_EXIT_CLOAK_MASK (1 << MFC_STAT1_L_EXIT_CLOAK_SHIFT)
  605. #define MFC_STAT1_L_DECREASE_POWER_MASK (1 << MFC_STAT1_L_DECREASE_POWER_SHIFT)
  606. #define MFC_STAT1_L_INCREASE_POWER_MASK (1 << MFC_STAT1_L_INCREASE_POWER_SHIFT)
  607. #define MFC_STAT1_L_360K_NEGO_PASS_MASK (1 << MFC_STAT1_L_360K_NEGO_PASS_SHIFT)
  608. #define MFC_STAT1_L_EPP_SUPPROT_MASK (1 << MFC_STAT1_L_EPP_SUPPROT_SHIFT)
  609. #define MFC_STAT1_L_MPP_SUPPROT_MASK (1 << MFC_STAT1_L_MPP_SUPPROT_SHIFT)
  610. /* BIT DEFINE of Interrupt_A Registers, INTA_L (0x24), INTA_H (0x25), INTB_L (0x26), INTB_H (0x27) */
  611. #define MFC_INTA_L_STAT_VOUT_SHIFT 7
  612. #define MFC_INTA_L_STAT_VRECT_SHIFT 6
  613. #define MFC_INTA_L_OP_MODE_SHIFT 5
  614. #define MFC_INTA_L_OVER_VOL_SHIFT 4
  615. #define MFC_INTA_L_OVER_CURR_SHIFT 3
  616. #define MFC_INTA_L_OVER_TEMP_SHIFT 2
  617. #define MFC_INTA_L_TXCONFLICT_SHIFT 1
  618. #define MFC_INTA_L_ADT_ERROR_SHIFT 0
  619. #define MFC_INTA_L_STAT_VOUT_MASK (1 << MFC_INTA_L_STAT_VOUT_SHIFT)
  620. #define MFC_INTA_L_STAT_VRECT_MASK (1 << MFC_INTA_L_STAT_VRECT_SHIFT)
  621. #define MFC_INTA_L_OP_MODE_MASK (1 << MFC_INTA_L_OP_MODE_SHIFT)
  622. #define MFC_INTA_L_OVER_VOL_MASK (1 << MFC_INTA_L_OVER_VOL_SHIFT)
  623. #define MFC_INTA_L_OVER_CURR_MASK (1 << MFC_STAT_L_OVER_CURR_SHIFT)
  624. #define MFC_INTA_L_OVER_TEMP_MASK (1 << MFC_STAT_L_OVER_TEMP_SHIFT)
  625. #define MFC_INTA_L_TXCONFLICT_MASK (1 << MFC_STAT_L_TXCONFLICT_SHIFT)
  626. #define MFC_INTA_L_ADT_ERROR_MASK (1 << MFC_INTA_L_ADT_ERROR_SHIFT)
  627. #define MFC_INTA_H_TRX_DATA_RECEIVED_SHIFT 7
  628. #define MFC_INTA_H_TX_OCP_SHIFT 6
  629. #define MFC_INTA_H_TX_MODE_RX_NOT_DET 5
  630. #define MFC_INTA_H_TX_FOD_SHIFT 4
  631. #define MFC_INTA_H_TX_CON_DISCON_SHIFT 3
  632. #define MFC_INTA_H_AC_MISSING_DET_SHIFT 2
  633. #define MFC_INTA_H_ADT_RECEIVED_SHIFT 1
  634. #define MFC_INTA_H_ADT_SENT_SHIFT 0
  635. #define MFC_INTA_H_TRX_DATA_RECEIVED_MASK (1 << MFC_INTA_H_TRX_DATA_RECEIVED_SHIFT)
  636. #define MFC_INTA_H_TX_OCP_MASK (1 << MFC_INTA_H_TX_OCP_SHIFT)
  637. #define MFC_INTA_H_TX_MODE_RX_NOT_DET_MASK (1 << MFC_INTA_H_TX_MODE_RX_NOT_DET)
  638. #define MFC_INTA_H_TX_FOD_MASK (1 << MFC_INTA_H_TX_FOD_SHIFT)
  639. #define MFC_INTA_H_TX_CON_DISCON_MASK (1 << MFC_INTA_H_TX_CON_DISCON_SHIFT)
  640. #define MFC_INTA_H_AC_MISSING_DET_MASK (1 << MFC_INTA_H_AC_MISSING_DET_SHIFT)
  641. #define MFC_INTA_H_ADT_RECEIVED_MASK (1 << MFC_INTA_H_ADT_RECEIVED_SHIFT)
  642. #define MFC_INTA_H_ADT_SENT_MASK (1 << MFC_INTA_H_ADT_SENT_SHIFT)
  643. #define MFC_INTB_L_EPP_NEGO_FAIL_SHIFT 7
  644. #define MFC_INTB_L_EPP_NEGO_PASS_SHIFT 6
  645. #define MFC_INTB_L_EXIT_CLOAK_SHIFT 5
  646. #define MFC_INTB_L_DECREASE_POWER_SHIFT 4
  647. #define MFC_INTB_L_INCREASE_POWER_SHIFT 3
  648. #define MFC_INTB_L_360K_NEGO_PASS_SHIFT 2
  649. #define MFC_INTB_L_EPP_SUPPROT_SHIFT 1
  650. #define MFC_INTB_L_MPP_SUPPROT_SHIFT 0
  651. #define MFC_INTB_L_EPP_NEGO_FAIL_MASK (1 << MFC_INTB_L_EPP_NEGO_FAIL_SHIFT)
  652. #define MFC_INTB_L_EPP_NEGO_PASS_MASK (1 << MFC_INTB_L_EPP_NEGO_PASS_SHIFT)
  653. #define MFC_INTB_L_EXIT_CLOAK_MASK (1 << MFC_INTB_L_EXIT_CLOAK_SHIFT)
  654. #define MFC_INTB_L_DECREASE_POWER_MASK (1 << MFC_INTB_L_DECREASE_POWER_SHIFT)
  655. #define MFC_INTB_L_INCREASE_POWER_MASK (1 << MFC_INTB_L_INCREASE_POWER_SHIFT)
  656. #define MFC_INTB_L_360K_NEGO_PASS_MASK (1 << MFC_INTB_L_360K_NEGO_PASS_SHIFT)
  657. #define MFC_INTB_L_EPP_SUPPROT_MASK (1 << MFC_INTB_L_EPP_SUPPROT_SHIFT)
  658. #define MFC_INTB_L_MPP_SUPPROT_MASK (1 << MFC_INTB_L_MPP_SUPPROT_SHIFT)
  659. /* System Operating Mode Register, Sys_op_mode(0x2B) */
  660. /* RX MODE[7:5] */
  661. #define MFC_RX_MODE_AC_MISSING 0x0
  662. #define MFC_RX_MODE_WPC_BASIC 0x1
  663. #define MFC_RX_MODE_WPC_ADV 0x2
  664. #define MFC_RX_MODE_PMA_SR1 0x3
  665. #define MFC_RX_MODE_PMA_SR1E 0x4
  666. #define MFC_RX_MODE_RESERVED1 0x5
  667. #define MFC_RX_MODE_RESERVED2 0x6
  668. #define MFC_RX_MODE_UNKNOWN 0x7
  669. #define MFC_RX_MODE_WPC_BPP 0x1
  670. #define MFC_RX_MODE_WPC_EPP 0x2
  671. #define MFC_RX_MODE_WPC_MPP_RESTRICT 0x3
  672. #define MFC_RX_MODE_WPC_MPP_FULL 0x4
  673. #define MFC_RX_MODE_WPC_MPP_CLOAK 0x5
  674. #define MFC_RX_MODE_WPC_MPP_NEGO 0x6
  675. #define MFC_RX_MODE_WPC_EPP_NEGO 0x7
  676. //#if defined(CONFIG_WIRELESS_CHARGER_cps4038)
  677. /* TX MODE[3:0] */
  678. #define MFC_TX_MODE_RX_MODE 0x0
  679. #define MFC_TX_MODE_MST_MODE1 0x1
  680. #define MFC_TX_MODE_MST_MODE2 0x2
  681. #define MFC_TX_MODE_TX_MODE 0x3
  682. #define MFC_TX_MODE_MST_PCR_MODE1 0x7
  683. #define MFC_TX_MODE_MST_PCR_MODE2 0xF
  684. //#endif
  685. /* TX MODE[3:0] */
  686. #define MFC_TX_MODE_BACK_PWR_MISSING 0x0
  687. #define MFC_TX_MODE_MST_ON 0x4
  688. #define MFC_TX_MODE_TX_MODE_ON 0x8
  689. #define MFC_TX_MODE_TX_ERROR 0x9 /* TX FOD, TX conflict */
  690. #define MFC_TX_MODE_TX_PWR_HOLD 0xA
  691. /* End of Power Transfer Register, EPT (0x3B) (RX only) */
  692. #define MFC_WPC_EPT_UNKNOWN 0
  693. #define MFC_WPC_EPT_END_OF_CHG 1
  694. #define MFC_WPC_EPT_INT_FAULT 2
  695. #define MFC_WPC_EPT_OVER_TEMP 3
  696. #define MFC_WPC_EPT_OVER_VOL 4
  697. #define MFC_WPC_EPT_OVER_CURR 5
  698. #define MFC_WPC_EPT_BATT_FAIL 6
  699. #define MFC_WPC_EPT_RECONFIG 7
  700. #define MFC_WPC_EPT_NO_RESPONSE 8
  701. /* Proprietary Packet Header Register, PPP_Header VALUE(0x50) */
  702. #define MFC_HEADER_END_SIG_STRENGTH 0x01 /* Message Size 1 */
  703. #define MFC_HEADER_END_POWER_TRANSFER 0x02 /* Message Size 1 */
  704. #define MFC_HEADER_END_CTR_ERROR 0x03 /* Message Size 1 */
  705. #define MFC_HEADER_END_RECEIVED_POWER 0x04 /* Message Size 1 */
  706. #define MFC_HEADER_END_CHARGE_STATUS 0x05 /* Message Size 1 */
  707. #define MFC_HEADER_POWER_CTR_HOLD_OFF 0x06 /* Message Size 1 */
  708. #define MFC_HEADER_PROPRIETARY_1_BYTE 0x18 /* Message Size 1 */
  709. #define MFC_HEADER_PACKET_COUNTING 0x19 /* Message Size 1 */
  710. #define MFC_HEADER_CLOAK 0x1E
  711. #define MFC_HEADER_AFC_CONF 0x28 /* Message Size 2 */
  712. #define MFC_HEADER_CONFIGURATION 0x51 /* Message Size 5 */
  713. #define MFC_HEADER_IDENTIFICATION 0x71 /* Message Size 7 */
  714. #define MFC_HEADER_EXTENDED_IDENT 0x81 /* Message Size 8 */
  715. /* END CHARGE STATUS CODES IN WPC */
  716. #define MFC_ECS_CS100 0x64 /* CS 100 */
  717. /* TX Data Command Register, TX Data_COM VALUE(0x50) */
  718. #define MFC_TX_DATA_COM_TX_ID 0x01
  719. /* END POWER TRANSFER CODES IN WPC */
  720. #define MFC_EPT_CODE_UNKNOWN 0x00
  721. #define MFC_EPT_CODE_CHARGE_COMPLETE 0x01
  722. #define MFC_EPT_CODE_INTERNAL_FAULT 0x02
  723. #define MFC_EPT_CODE_OVER_TEMPERATURE 0x03
  724. #define MFC_EPT_CODE_OVER_VOLTAGE 0x04
  725. #define MFC_EPT_CODE_OVER_CURRENT 0x05
  726. #define MFC_EPT_CODE_BATTERY_FAILURE 0x06
  727. #define MFC_EPT_CODE_RECONFIGURE 0x07
  728. #define MFC_EPT_CODE_NO_RESPONSE 0x08
  729. #define MFC_POWER_MODE_MASK (0x1 << 0)
  730. #define MFC_SEND_USER_PKT_DONE_MASK (0x1 << 7)
  731. #define MFC_SEND_USER_PKT_ERR_MASK (0x3 << 5)
  732. #define MFC_SEND_ALIGN_MASK (0x1 << 3)
  733. #define MFC_SEND_EPT_CC_MASK (0x1 << 0)
  734. #define MFC_SEND_EOC_MASK (0x1 << 0)
  735. #define MFC_PTK_ERR_NO_ERR 0x00
  736. #define MFC_PTK_ERR_ERR 0x01
  737. #define MFC_PTK_ERR_ILLEGAL_HD 0x02
  738. #define MFC_PTK_ERR_NO_DEF 0x03
  739. #define MFC_FW_RESULT_DOWNLOADING 2
  740. #define MFC_FW_RESULT_PASS 1
  741. #define MFC_FW_RESULT_FAIL 0
  742. #define REQ_AFC_DLY 300
  743. #define MFC_FW_MSG "@MFC_FW "
  744. /* value of TX POWER BUDGET */
  745. #define MFC_TX_PWR_BUDG_NONE 0x00
  746. #define MFC_TX_PWR_BUDG_2W 0x14
  747. #define MFC_TX_PWR_BUDG_5W 0x32
  748. #define MFC_TX_PWR_BUDG_7_5W 0x4B
  749. #define MFC_TX_PWR_BUDG_10W 0x64
  750. #define MFC_TX_PWR_BUDG_12W 0x78
  751. #define MFC_TX_PWR_BUDG_15W 0x96
  752. /* CPS F/W Update & Verification Define */
  753. #define ADDR_BUFFER0 0x20000800
  754. #define ADDR_BUFFER1 0x20001000
  755. #define ADDR_CMD 0x20001800
  756. #define ADDR_FLAG 0x20001804
  757. #define ADDR_BUF_SIZE 0x20001808
  758. #define ADDR_FW_VER 0x2000180C
  759. #define PGM_BUFFER0 0x10
  760. #define PGM_BUFFER1 0x20
  761. #define PGM_BUFFER2 0x30
  762. #define PGM_BUFFER3 0x40
  763. #define PGM_BUFFER0_1 0x50
  764. #define PGM_ERASER_0 0x60
  765. #define PGM_ERASER_1 0x70
  766. #define PGM_WR_FLAG 0x80
  767. #define CACL_CRC_APP 0x90
  768. #define CACL_CRC_TEST 0xB0
  769. #define PGM_ADDR_SET 0xC0
  770. #define RUNNING 0x66
  771. #define PASS 0x55
  772. #define FAIL 0xAA
  773. #define ILLEGAL 0x40
  774. #if defined(CONFIG_MST_V2)
  775. #define MST_MODE_ON 1 // ON Message to MFC ic
  776. #define MST_MODE_OFF 0 // OFF Message to MFC ic
  777. #define DELAY_FOR_MST 100 // S.LSI : 100 ms
  778. #define MFC_MST_LDO_CONFIG_1 0x7400
  779. #define MFC_MST_LDO_CONFIG_2 0x7409
  780. #define MFC_MST_LDO_CONFIG_3 0x7418
  781. #define MFC_MST_LDO_CONFIG_4 0x3014
  782. #define MFC_MST_LDO_CONFIG_5 0x3405
  783. #define MFC_MST_LDO_CONFIG_6 0x3010
  784. #define MFC_MST_LDO_TURN_ON 0x301c
  785. #define MFC_MST_LDO_CONFIG_8 0x343c
  786. #define MFC_MST_OVER_TEMP_INT 0x0024
  787. #define MFC_ISET_PCR 0x0169
  788. #define MFC_RES_PCR 0x016A
  789. #define PCR_FIX_MODE 0x0168
  790. #endif
  791. /* F/W Update & Verification ERROR CODES */
  792. enum {
  793. MFC_FWUP_ERR_COMMON_FAIL = 0,
  794. MFC_FWUP_ERR_SUCCEEDED,
  795. MFC_FWUP_ERR_RUNNING,
  796. MFC_FWUP_ERR_REQUEST_FW_BIN,
  797. /* F/W update error */
  798. MFC_FWUP_ERR_WRITE_KEY_ERR,
  799. MFC_FWUP_ERR_CLK_TIMING_ERR1, /* 5 */
  800. MFC_FWUP_ERR_CLK_TIMING_ERR2,
  801. MFC_FWUP_ERR_CLK_TIMING_ERR3,
  802. MFC_FWUP_ERR_CLK_TIMING_ERR4,
  803. MFC_FWUP_ERR_INFO_PAGE_EMPTY,
  804. MFC_FWUP_ERR_HALT_M0_ERR, /* 10 */
  805. MFC_FWUP_ERR_FAIL,
  806. MFC_FWUP_ERR_ADDR_READ_FAIL,
  807. MFC_FWUP_ERR_DATA_NOT_MATCH,
  808. MFC_FWUP_ERR_OTP_LOADER_IN_RAM_ERR,
  809. MFC_FWUP_ERR_CLR_MTP_STATUS_BYTE, /* 15 */
  810. MFC_FWUP_ERR_MAP_RAM_TO_OTP_ERR,
  811. MFC_FWUP_ERR_WRITING_TO_OTP_BUFFER,
  812. MFC_FWUP_ERR_OTF_BUFFER_VALIDATION,
  813. MFC_FWUP_ERR_READING_OTP_BUFFER_STATUS,
  814. MFC_FWUP_ERR_TIMEOUT_ON_BUFFER_TO_OTP, /* 20 */
  815. MFC_FWUP_ERR_MTP_WRITE_ERR,
  816. MFC_FWUP_ERR_PKT_CHECKSUM_ERR,
  817. MFC_FWUP_ERR_UNKNOWN_ERR,
  818. MFC_FWUP_ERR_BUFFER_WRITE_IN_SECTOR,
  819. MFC_FWUP_ERR_WRITING_FW_VERION, /* 25 */
  820. /* F/W verification error */
  821. MFC_VERIFY_ERR_WRITE_KEY_ERR,
  822. MFC_VERIFY_ERR_HALT_M0_ERR,
  823. MFC_VERIFY_ERR_KZALLOC_ERR,
  824. MFC_VERIFY_ERR_FAIL,
  825. MFC_VERIFY_ERR_ADDR_READ_FAIL, /* 30 */
  826. MFC_VERIFY_ERR_DATA_NOT_MATCH,
  827. MFC_VERIFY_ERR_MTP_VERIFIER_IN_RAM_ERR,
  828. MFC_VERIFY_ERR_CLR_MTP_STATUS_BYTE,
  829. MFC_VERIFY_ERR_MAP_RAM_TO_OTP_ERR,
  830. MFC_VERIFY_ERR_UNLOCK_SYS_REG_ERR, /* 35 */
  831. MFC_VERIFY_ERR_LDO_CLK_2MHZ_ERR,
  832. MFC_VERIFY_ERR_LDO_OUTPUT_5_5V_ERR,
  833. MFC_VERIFY_ERR_ENABLE_LDO_ERR,
  834. MFC_VERIFY_ERR_WRITING_TO_MTP_VERIFY_BUFFER,
  835. MFC_VERIFY_ERR_START_MTP_VERIFY_ERR, /* 40 */
  836. MFC_VERIFY_ERR_READING_MTP_VERIFY_STATUS,
  837. MFC_VERIFY_ERR_CRC_BUSY,
  838. MFC_VERIFY_ERR_READING_MTP_VERIFY_PASS_FAIL,
  839. MFC_VERIFY_ERR_CRC_ERROR,
  840. MFC_VERIFY_ERR_UNKNOWN_ERR, /* 45 */
  841. MFC_VERIFY_ERR_BUFFER_WRITE_IN_SECTOR,
  842. MFC_REPAIR_ERR_HALT_M0_ERR,
  843. MFC_REPAIR_ERR_MTP_REPAIR_IN_RAM,
  844. MFC_REPAIR_ERR_CLR_MTP_STATUS_BYTE,
  845. MFC_REPAIR_ERR_START_MTP_REPAIR_ERR, /* 50 */
  846. MFC_REPAIR_ERR_READING_MTP_REPAIR_STATUS,
  847. MFC_REPAIR_ERR_READING_MTP_REPAIR_PASS_FAIL,
  848. MFC_REPAIR_ERR_BUFFER_WRITE_IN_SECTOR,
  849. };
  850. /* PAD Vout */
  851. enum {
  852. PAD_VOUT_5V = 0,
  853. PAD_VOUT_9V,
  854. PAD_VOUT_10V,
  855. PAD_VOUT_12V,
  856. PAD_VOUT_18V,
  857. PAD_VOUT_19V,
  858. PAD_VOUT_20V,
  859. PAD_VOUT_24V,
  860. };
  861. enum {
  862. MFC_ADC_VOUT = 0,
  863. MFC_ADC_VRECT,
  864. MFC_ADC_RX_IOUT,
  865. MFC_ADC_DIE_TEMP,
  866. MFC_ADC_OP_FRQ,
  867. MFC_ADC_TX_MAX_OP_FRQ,
  868. MFC_ADC_TX_MIN_OP_FRQ,
  869. MFC_ADC_PING_FRQ,
  870. MFC_ADC_TX_IOUT,
  871. MFC_ADC_TX_VOUT,
  872. };
  873. enum {
  874. MFC_ADDR = 0,
  875. MFC_SIZE,
  876. MFC_DATA,
  877. MFC_PACKET,
  878. };
  879. ssize_t cps4038_show_attrs(struct device *dev,
  880. struct device_attribute *attr, char *buf);
  881. ssize_t cps4038_store_attrs(struct device *dev,
  882. struct device_attribute *attr,
  883. const char *buf, size_t count);
  884. #define CPS4038_ATTR(_name) \
  885. { \
  886. .attr = {.name = #_name, .mode = 0660}, \
  887. .show = cps4038_show_attrs, \
  888. .store = cps4038_store_attrs, \
  889. }
  890. enum mfc_irq {
  891. MFC_IRQ_STAT_VOUT = 0,
  892. MFC_IRQ_STAT_VRECT,
  893. MFC_IRQ_MODE_CHANGE,
  894. MFC_IRQ_TX_DATA_RECEIVED,
  895. MFC_IRQ_OVER_VOLT,
  896. MFC_IRQ_OVER_CURR,
  897. MFC_IRQ_OVER_TEMP,
  898. MFC_IRQ_TX_OVER_CURR,
  899. MFC_IRQ_TX_OVER_TEMP,
  900. MFC_IRQ_TX_FOD,
  901. MFC_IRQ_TX_CONNECT,
  902. MFC_IRQ_NR,
  903. };
  904. enum mfc_firmware_mode {
  905. MFC_RX_FIRMWARE = 0,
  906. MFC_TX_FIRMWARE,
  907. };
  908. enum mfc_ic_revision {
  909. MFC_IC_REVISION = 0,
  910. MFC_IC_FONT,
  911. };
  912. enum mfc_chip_id {
  913. MFC_CHIP_IDT = 1,
  914. MFC_CHIP_LSI,
  915. MFC_CHIP_CPS,
  916. };
  917. enum mfc_headroom {
  918. MFC_HEADROOM_0 = 0,
  919. MFC_HEADROOM_1, /* 0.277V */
  920. MFC_HEADROOM_2, /* 0.497V */
  921. MFC_HEADROOM_3, /* 0.650V */
  922. MFC_HEADROOM_4, /* 0.030V */
  923. MFC_HEADROOM_5, /* 0.082V */
  924. MFC_HEADROOM_6, /* 0.097V */
  925. MFC_HEADROOM_7, /* -0.600V */
  926. };
  927. #if defined(CONFIG_WIRELESS_IC_PARAM)
  928. extern unsigned int wireless_fw_ver_param;
  929. extern unsigned int wireless_chip_id_param;
  930. extern unsigned int wireless_fw_mode_param;
  931. #endif
  932. struct mfc_charger_platform_data {
  933. int pad_mode;
  934. int wpc_det;
  935. int irq_wpc_det;
  936. int wpc_int;
  937. int mst_pwr_en;
  938. int wpc_en;
  939. int mag_det;
  940. int mpp_sw;
  941. int coil_sw_en;
  942. int wpc_pdrc;
  943. int irq_wpc_pdrc;
  944. int ping_nen;
  945. int irq_wpc_int;
  946. int wpc_pdet_b;
  947. int irq_wpc_pdet_b;
  948. int cs100_status;
  949. int vout_status;
  950. int siop_level;
  951. int cable_type;
  952. bool default_voreg;
  953. int is_charging;
  954. u32 *wireless20_vout_list;
  955. u32 *wireless20_vrect_list;
  956. u32 *wireless20_max_power_list;
  957. u8 len_wc20_list;
  958. bool ic_on_mode;
  959. int hw_rev_changed; /* this is only for noble/zero2 */
  960. int otp_firmware_result;
  961. int tx_firmware_result;
  962. int wc_ic_grade;
  963. int wc_ic_rev;
  964. int otp_firmware_ver;
  965. int tx_firmware_ver;
  966. int vout;
  967. int vrect;
  968. u8 trx_data_cmd;
  969. u8 trx_data_val;
  970. char *wireless_charger_name;
  971. char *wired_charger_name;
  972. char *fuelgauge_name;
  973. int opfq_cnt;
  974. int mst_switch_delay;
  975. int wc_cover_rpp;
  976. int wc_hv_rpp;
  977. u32 tx_fod_gain;
  978. u32 tx_fod_offset;
  979. u32 phone_fod_thresh1;
  980. u32 phone_fod_ta_thresh;
  981. u32 buds_fod_thresh1;
  982. u32 buds_fod_ta_thresh;
  983. u32 tx_max_op_freq;
  984. u32 tx_min_op_freq;
  985. u32 gear_op_freq;
  986. u32 gear_min_op_freq;
  987. u32 gear_min_op_freq_delay;
  988. u32 cep_timeout;
  989. int no_hv;
  990. bool keep_tx_vout;
  991. u32 wpc_vout_ctrl_full;
  992. bool wpc_headroom_ctrl_full;
  993. bool mis_align_guide;
  994. bool unknown_cmb_ctrl;
  995. bool default_clamp_volt;
  996. u32 mis_align_target_vout;
  997. u32 mis_align_offset;
  998. int tx_conflict_curr;
  999. u32 iec_qfod_enable;
  1000. u32 iec_q_thresh_1;
  1001. u32 iec_q_thresh_2;
  1002. u32 iec_fres_thresh_1;
  1003. u32 iec_fres_thresh_2;
  1004. u32 iec_power_limit_thresh;
  1005. u32 iec_ploss_thresh_1;
  1006. u32 iec_ploss_thresh_2;
  1007. u32 iec_ploss_freq_thresh_1;
  1008. u32 iec_ploss_freq_thresh_2;
  1009. u32 iec_ta_power_limit_thresh;
  1010. u32 iec_ta_ploss_thresh_1;
  1011. u32 iec_ta_ploss_thresh_2;
  1012. u32 iec_ta_ploss_freq_thresh_1;
  1013. u32 iec_ta_ploss_freq_thresh_2;
  1014. u32 iec_ploss_fod_enable;
  1015. #if defined(CONFIG_MST_PCR)
  1016. u32 mst_iset_pcr;
  1017. #endif
  1018. u32 mpp_epp_vout;
  1019. u32 mpp_epp_def_power;
  1020. u32 mpp_epp_max_count;
  1021. };
  1022. #define mfc_charger_platform_data_t \
  1023. struct mfc_charger_platform_data
  1024. #define MST_MODE_0 0
  1025. #define MST_MODE_2 1
  1026. #define MFC_BAT_DUMP_SIZE 256
  1027. struct mfc_charger_data {
  1028. struct i2c_client *client;
  1029. struct device *dev;
  1030. mfc_charger_platform_data_t *pdata;
  1031. struct mutex io_lock;
  1032. struct mutex wpc_en_lock;
  1033. struct mutex fw_lock;
  1034. const struct firmware *firm_data_bin;
  1035. u8 det_state; /* ACTIVE HIGH */
  1036. u8 pdrc_state; /* ACTIVE LOW */
  1037. struct power_supply *psy_chg;
  1038. struct wakeup_source *wpc_ws;
  1039. struct wakeup_source *wpc_det_ws;
  1040. struct wakeup_source *wpc_tx_ws;
  1041. struct wakeup_source *wpc_rx_ws;
  1042. struct wakeup_source *wpc_update_ws;
  1043. struct wakeup_source *wpc_tx_duty_min_ws;
  1044. struct wakeup_source *wpc_tx_min_opfq_ws;
  1045. struct wakeup_source *wpc_afc_vout_ws;
  1046. struct wakeup_source *wpc_vout_mode_ws;
  1047. struct wakeup_source *wpc_rx_det_ws;
  1048. struct wakeup_source *wpc_tx_phm_ws;
  1049. struct wakeup_source *wpc_tx_id_ws;
  1050. struct wakeup_source *wpc_tx_pwr_budg_ws;
  1051. struct wakeup_source *wpc_pdrc_ws;
  1052. struct wakeup_source *align_check_ws;
  1053. struct wakeup_source *mode_change_ws;
  1054. struct wakeup_source *wpc_cs100_ws;
  1055. struct wakeup_source *wpc_check_rx_power_ws;
  1056. struct wakeup_source *wpc_pdet_b_ws;
  1057. struct wakeup_source *wpc_rx_phm_ws;
  1058. struct wakeup_source *wpc_phm_exit_ws;
  1059. struct wakeup_source *epp_clear_ws;
  1060. struct wakeup_source *epp_count_ws;
  1061. struct workqueue_struct *wqueue;
  1062. struct work_struct wcin_work;
  1063. struct delayed_work wpc_det_work;
  1064. struct delayed_work wpc_pdrc_work;
  1065. struct delayed_work wpc_isr_work;
  1066. struct delayed_work wpc_tx_isr_work;
  1067. struct delayed_work wpc_tx_id_work;
  1068. struct delayed_work wpc_tx_pwr_budg_work;
  1069. struct delayed_work mst_off_work;
  1070. struct delayed_work wpc_int_req_work;
  1071. struct delayed_work wpc_fw_update_work;
  1072. struct delayed_work wpc_afc_vout_work;
  1073. struct delayed_work wpc_fw_booting_work;
  1074. struct delayed_work wpc_vout_mode_work;
  1075. struct delayed_work wpc_i2c_error_work;
  1076. struct delayed_work wpc_rx_type_det_work;
  1077. struct delayed_work wpc_rx_connection_work;
  1078. struct delayed_work wpc_tx_op_freq_work;
  1079. struct delayed_work wpc_tx_duty_min_work;
  1080. struct delayed_work wpc_tx_min_op_freq_work;
  1081. struct delayed_work wpc_tx_phm_work;
  1082. struct delayed_work wpc_vrect_check_work;
  1083. struct delayed_work wpc_rx_power_work;
  1084. struct delayed_work wpc_cs100_work;
  1085. struct delayed_work wpc_init_work;
  1086. struct delayed_work align_check_work;
  1087. struct delayed_work mode_change_work;
  1088. struct delayed_work wpc_check_rx_power_work;
  1089. struct delayed_work wpc_rx_phm_work;
  1090. struct delayed_work wpc_deactivate_work;
  1091. struct delayed_work wpc_phm_exit_work;
  1092. struct delayed_work epp_clear_timer_work;
  1093. struct delayed_work epp_count_work;
  1094. struct alarm phm_alarm;
  1095. struct mfc_fod *fod;
  1096. struct mfc_cmfet *cmfet;
  1097. u16 addr;
  1098. int size;
  1099. int is_afc;
  1100. int pad_vout;
  1101. int is_mst_on; /* mst */
  1102. int chip_id;
  1103. u8 rx_op_mode;
  1104. int fw_cmd;
  1105. int vout_mode;
  1106. u32 vout_by_txid;
  1107. u32 vrect_by_txid;
  1108. u32 max_power_by_txid;
  1109. int is_full_status;
  1110. int mst_off_lock;
  1111. bool is_otg_on;
  1112. int led_cover;
  1113. bool is_probed;
  1114. bool is_afc_tx;
  1115. bool pad_ctrl_by_lcd;
  1116. bool tx_id_done;
  1117. bool is_suspend;
  1118. int tx_id;
  1119. int tx_id_cnt;
  1120. bool rx_phm_status;
  1121. int rx_phm_state;
  1122. int flicker_delay;
  1123. int flicker_vout_threshold;
  1124. /* wireless tx */
  1125. int tx_status;
  1126. bool initial_wc_check;
  1127. bool wc_tx_enable;
  1128. int wc_rx_type;
  1129. bool wc_rx_connected;
  1130. bool wc_rx_fod;
  1131. bool wc_ldo_status;
  1132. int non_sleep_mode_cnt;
  1133. u8 adt_transfer_status;
  1134. unsigned int current_rx_power;
  1135. u8 tx_pwr_budg;
  1136. u8 device_event;
  1137. int i2c_error_count;
  1138. int gpio_irq_missing_wa_cnt;
  1139. int input_current;
  1140. int duty_min;
  1141. int wpc_en_flag;
  1142. bool tx_device_phm;
  1143. bool req_tx_id;
  1144. bool afc_tx_done;
  1145. int req_afc_delay;
  1146. bool sleep_mode;
  1147. bool wc_checking_align;
  1148. struct timespec64 wc_align_check_start;
  1149. int vout_strength;
  1150. u32 mis_align_tx_try_cnt;
  1151. bool skip_phm_work_in_sleep;
  1152. bool reg_access_lock;
  1153. bool check_rx_power;
  1154. int mfc_adc_tx_vout;
  1155. int mfc_adc_tx_iout;
  1156. int mfc_adc_ping_frq;
  1157. int mfc_adc_tx_min_op_frq;
  1158. int mfc_adc_tx_max_op_frq;
  1159. int mfc_adc_vout;
  1160. int mfc_adc_vrect;
  1161. int mfc_adc_rx_iout;
  1162. int mfc_adc_op_frq;
  1163. union mfc_fod_state now_fod_state;
  1164. union mfc_cmfet_state now_cmfet_state;
  1165. int mpp_epp_tx_id;
  1166. int mpp_epp_nego_done_power;
  1167. int mpp_epp_tx_potential_load_power;
  1168. int mpp_epp_tx_negotiable_load_power;
  1169. int mpp_cloak;
  1170. #if defined(CONFIG_WIRELESS_IC_PARAM)
  1171. unsigned int wireless_param_info;
  1172. unsigned int wireless_fw_ver_param;
  1173. unsigned int wireless_chip_id_param;
  1174. unsigned int wireless_fw_mode_param;
  1175. #endif
  1176. int epp_time;
  1177. int epp_count;
  1178. char d_buf[MFC_BAT_DUMP_SIZE];
  1179. };
  1180. #define fan_ctrl_pad(pad_id) (\
  1181. (pad_id >= 0x14 && pad_id <= 0x1f) || \
  1182. (pad_id >= 0x25 && pad_id <= 0x2f) || \
  1183. (pad_id >= 0x30 && pad_id <= 0x3f) || \
  1184. (pad_id >= 0x46 && pad_id <= 0x4f) || \
  1185. (pad_id >= 0xa1 && pad_id <= 0xcf) || \
  1186. (pad_id >= 0xd0 && pad_id <= 0xff))
  1187. #define opfreq_ctrl_pad(pad_id) (\
  1188. ((pad_id >= TX_ID_NON_AUTH_PAD) && (pad_id <= TX_ID_NON_AUTH_PAD_END)) || \
  1189. ((pad_id >= TX_ID_N5200_V_PAD) && (pad_id <= TX_ID_AUTH_PAD_ACLASS_END)) || \
  1190. (pad_id == TX_ID_P1300_PAD) || \
  1191. (pad_id == TX_ID_N3300_V_PAD) || \
  1192. (pad_id == TX_ID_N3300_H_PAD) || \
  1193. (pad_id == TX_ID_P4300_PAD))
  1194. #define volt_ctrl_pad(pad_id) (\
  1195. (pad_id != TX_ID_PG950_S_PAD) && \
  1196. (pad_id != TX_ID_PG950_D_PAD))
  1197. #define bpp_mode(op_mode) (\
  1198. (op_mode == MFC_RX_MODE_WPC_BPP))
  1199. #define mpp_mode(op_mode) (\
  1200. (op_mode == MFC_RX_MODE_WPC_MPP_RESTRICT) || \
  1201. (op_mode == MFC_RX_MODE_WPC_MPP_FULL) || \
  1202. (op_mode == MFC_RX_MODE_WPC_MPP_CLOAK) || \
  1203. (op_mode == MFC_RX_MODE_WPC_MPP_NEGO))
  1204. #define epp_mode(op_mode) (\
  1205. (op_mode == MFC_RX_MODE_WPC_EPP) || \
  1206. (op_mode == MFC_RX_MODE_WPC_EPP_NEGO))
  1207. #endif /* __WIRELESS_CHARGER_CPS4038_H */