1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_PF1550_H_
10 #define _FSL_PF1550_H_
11 
12 /*******************************************************************************
13  * Includes
14  ******************************************************************************/
15 #include <stdint.h>
16 #include <stdbool.h>
17 #include "fsl_common.h"
18 
19 /*******************************************************************************
20  * Definitions
21  ******************************************************************************/
22 
23 /*! @brief PF1550 Default I2C address. */
24 #define PF1550_DEFAULT_I2C_ADDR 0x08U
25 
26 /*! @brief Define the Register Memory Map of PF1550. */
27 /*! PMIC Register Memory Map. */
28 #define PF1550_DEVICE_ID         0x00U
29 #define PF1550_OTP_FLAVOR        0x01U
30 #define PF1550_SILICON_REV       0x02U
31 #define PF1550_INT_CATEGORY      0x06U
32 #define PF1550_SW_INT_STAT0      0x08U
33 #define PF1550_SW_INT_MASK0      0x09U
34 #define PF1550_SW_INT_SENSE0     0x0AU
35 #define PF1550_SW_INT_STAT1      0x0BU
36 #define PF1550_SW_INT_MASK1      0x0CU
37 #define PF1550_SW_INT_SENSE1     0x0DU
38 #define PF1550_SW_INT_STAT2      0x0EU
39 #define PF1550_SW_INT_MASK2      0x0FU
40 #define PF1550_SW_INT_SENSE2     0x10U
41 #define PF1550_LDO_INT_STAT0     0x18U
42 #define PF1550_LDO_INT_MASK0     0x19U
43 #define PF1550_LDO_INT_SENSE0    0x1AU
44 #define PF1550_TEMP_INT_STAT0    0x20U
45 #define PF1550_TEMP_INT_MASK0    0x21U
46 #define PF1550_TEMP_INT_SENSE0   0x22U
47 #define PF1550_ONKEY_INT_STAT0   0x24U
48 #define PF1550_ONKEY_INT_MASK0   0x25U
49 #define PF1550_ONKEY_INT_SENSE0  0x26U
50 #define PF1550_MISC_INT_STAT0    0x28U
51 #define PF1550_MISC_INT_MASK0    0x29U
52 #define PF1550_MISC_INT_SENSE0   0x2AU
53 #define PF1550_COINCELL_CONTROL  0x30U
54 #define PF1550_SW1_VOLT          0x32U
55 #define PF1550_SW1_STBY_VOLT     0x33U
56 #define PF1550_SW1_SLP_VOLT      0x34U
57 #define PF1550_SW1_CTRL          0x35U
58 #define PF1550_SW1_CTRL1         0x36U
59 #define PF1550_SW2_VOLT          0x38U
60 #define PF1550_SW2_STBY_VOLT     0x39U
61 #define PF1550_SW2_SLP_VOLT      0x3AU
62 #define PF1550_SW2_CTRL          0x3BU
63 #define PF1550_SW2_CTRL1         0x3CU
64 #define PF1550_SW3_VOLT          0x3EU
65 #define PF1550_SW3_STBY_VOLT     0x3FU
66 #define PF1550_SW3_SLP_VOLT      0x40U
67 #define PF1550_SW3_CTRL          0x41U
68 #define PF1550_SW3_CTRL1         0x42U
69 #define PF1550_VSNVS_CTRL        0x48U
70 #define PF1550_VREFDDR_CTRL      0x4AU
71 #define PF1550_LDO1_VOLT         0x4CU
72 #define PF1550_LDO1_CTRL         0x4DU
73 #define PF1550_LDO2_VOLT         0x4FU
74 #define PF1550_LDO2_CTRL         0x50U
75 #define PF1550_LDO3_VOLT         0x52U
76 #define PF1550_LDO3_CTRL         0x53U
77 #define PF1550_PWRCTRL0          0x58U
78 #define PF1550_PWRCTRL1          0x59U
79 #define PF1550_PWRCTRL2          0x5AU
80 #define PF1550_PWRCTRL3          0x5BU
81 #define PF1550_SW1_PWRDN_SEQ     0x5FU
82 #define PF1550_SW2_PWRDN_SEQ     0x60U
83 #define PF1550_SW3_PWRDN_SEQ     0x61U
84 #define PF1550_LDO1_PWRDN_SEQ    0x62U
85 #define PF1550_LDO2_PWRDN_SEQ    0x63U
86 #define PF1550_LDO3_PWRDN_SEQ    0x64U
87 #define PF1550_VREFDDR_PWRDN_SEQ 0x65U
88 #define PF1550_STATE_INFO        0x67U
89 #define PF1550_I2C_ADDR          0x68U
90 #define PF1550_IO_DRV0           0x69U
91 #define PF1550_IO_DRV1           0x6AU
92 #define PF1550_RC_16MHZ          0x6BU
93 #define PF1550_KEY1              0x6FU
94 /*! Charger Register Memory Map. */
95 #define PF1550_CHG_INT           0x80U
96 #define PF1550_CHG_INT_MASK      0x82U
97 #define PF1550_CHG_INT_OK        0x84U
98 #define PF1550_VBUS_SNS          0x86U
99 #define PF1550_CHG_SNS           0x87U
100 #define PF1550_BATT_SNS          0x88U
101 #define PF1550_CHG_OPER          0x89U
102 #define PF1550_CHG_TMR           0x8AU
103 #define PF1550_CHG_EOC_CNFG      0x8DU
104 #define PF1550_CHG_CURR_CNFG     0x8EU
105 #define PF1550_BATT_REG          0x8FU
106 #define PF1550_BATFET_CNFG       0x91U
107 #define PF1550_THM_REG_CNFG      0x92U
108 #define PF1550_VBUS_INLIM_CNFG   0x94U
109 #define PF1550_VBUS_LIN_DPM      0x95U
110 #define PF1550_USB_PHY_LDO_CNFG  0x96U
111 #define PF1550_DBNC_DELAY_TIME   0x98U
112 #define PF1550_CHG_INT_CNFG      0x99U
113 #define PF1550_THM_ADJ_SETTING   0x9AU
114 #define PF1550_VBUS2SYS_CNFG     0x9BU
115 #define PF1550_LED_PWM           0x9CU
116 #define PF1550_FAULT_BATFET_CNFG 0x9DU
117 #define PF1550_LED_CNFG          0x9EU
118 #define PF1550_CHGR_KEY2         0x9FU
119 /*! Test Register Memory Map. */
120 #define PF1550_KEY3    0xDFU
121 #define PF1550_FMRADDR 0xC4U
122 #define PF1550_FMRDATA 0xC5U
123 /*! OTP Register Memory Map. */
124 #define PF1550_OTP_SW1_SW2 0x1EU
125 #define PF1550_OTP_SW2_SW3 0x1FU
126 
127 /*! @brief PF1550 Operating Status definition. */
128 typedef enum _pf1550_operating_status
129 {
130     kPF1550_OperatingStatusCoreOff     = 0x1U, /* Indicates the state machine is in CoreOff Status. */
131     kPF1550_OperatingStatusShipMode    = 0x2U, /* Indicates the state machine is in ShipMode Status. */
132     kPF1550_OperatingStatusRegsDisable = 0x3U, /* Indicates the state machine is in RegsDisable Status. */
133     kPF1550_OperatingStatusRun         = 0x4U, /* Indicates the state machine is in Run Status. */
134     kPF1550_OperatingStatusStandby     = 0x5U, /* Indicates the state machine is in Standby Status. */
135     kPF1550_OperatingStatusSleep       = 0x6U, /* Indicates the state machine is in Sleep Status. */
136     kPF1550_OperatingStatusSystemOn    = 0x7U, /* Indicates the state machine is in any of the
137                                                   SystemOn Status including Run, Standby, Sleep
138                                                   and Low-Power. */
139     kPF1550_OperatingStatusSystemOff = 0x8U,   /* Indicates the state machine is in any of the
140                                                   SystemOff Status including RegsDisable, CoreOff
141                                                   and ShipMode. */
142 } pf1550_operating_status_t;
143 
144 /*! @brief PF1550 Sub-Module definition. */
145 typedef enum _pf1550_module
146 {
147     kPF1550_ModuleSwitch1 = 0x0U, /* Switch1 Sub-Module Identifier. */
148     kPF1550_ModuleSwitch2 = 0x1U, /* Switch2 Sub-Module Identifier. */
149     kPF1550_ModuleSwitch3 = 0x2U, /* Switch3 Sub-Module Identifier. */
150     kPF1550_ModuleLdo1    = 0x3U, /* LDO1 Sub-Module Identifier. */
151     kPF1550_ModuleLdo2    = 0x4U, /* LDO2 Sub-Module Identifier. */
152     kPF1550_ModuleLdo3    = 0x5U, /* LDO3 Sub-Module Identifier. */
153     kPF1550_ModuleVsnvs   = 0x6U, /* VSNVS Sub-Module Identifier. */
154     kPF1550_ModuleVrefDdr = 0x7U, /* Vref DDR Sub-Module Identifier. */
155 } pf1550_module_t;
156 
157 /*! @brief PF1550 Interrupt Category definition. */
158 typedef enum _pf1550_interrupt_category
159 {
160     kPF1550_IntCategoryCharger = 0x01U, /* Any of the Charger interrupt status bit is set. */
161     kPF1550_IntCategorySwitch  = 0x0EU, /* Any of the Switch interrupt status bit is set. */
162     kPF1550_IntCategoryLdo     = 0x10U, /* Any of the LDO interrupt status bit is set. */
163     kPF1550_IntCategoryOnkey   = 0x20U, /* Any of the ONKEY interrupt status bit is set. */
164     kPF1550_IntCategoryTemp    = 0x40U, /* Any of the PMIC junction temperature
165                                            interrupt status bit is set. */
166     kPF1550_IntCategoryMisc = 0x80U,    /* Any of the interrupts not covered by the above
167                                            mentioned categories status bit is set. */
168 } pf1550_interrupt_category_t;
169 
170 /*! @brief PF1550 Switch Interrupt Source definition. */
171 enum _pf1550_switch_interrupt_source
172 {
173     kPF1550_IntSrcSw1LowSideCurrentLimit  = 0x1U,        /* Switch1 Low side current limit interrupt source. */
174     kPF1550_IntSrcSw2LowSideCurrentLimit  = 0x2U,        /* Switch2 Low side current limit interrupt source. */
175     kPF1550_IntSrcSw3LowSideCurrentLimit  = 0x4U,        /* Switch3 Low side current limit interrupt source. */
176     kPF1550_IntSrcSw1HighSideCurrentLimit = 0x1U << 8U,  /* Switch1 High side current limit interrupt source. */
177     kPF1550_IntSrcSw2HighSideCurrentLimit = 0x2U << 8U,  /* Switch2 High side current limit interrupt source. */
178     kPF1550_IntSrcSw3HighSideCurrentLimit = 0x4U << 8U,  /* Switch3 High side current limit interrupt source. */
179     kPF1550_IntSrcSw1DvsDone              = 0x1U << 16U, /* Switch1 DVS Complete interrupt source. */
180     kPF1550_IntSrcSw2DvsDone              = 0x2U << 16U, /* Switch2 DVS Complete interrupt source. */
181 };
182 
183 /*! @brief PF1550 LDO Interrupt Source definition. */
184 enum _pf1550_ldo_interrupt_source
185 {
186     kPF1550_IntSrcLdo1CurrentLimit = 0x1U, /* LDO1 current limit interrupt source. */
187     kPF1550_IntSrcLdo2CurrentLimit = 0x2U, /* LDO2 current limit interrupt source. */
188     kPF1550_IntSrcLdo3CurrentLimit = 0x4U, /* LDO3 current limit interrupt source. */
189 };
190 
191 /*! @brief PF1550 Die Temperature Interrupt Source definition. */
192 enum _pf1550_temp_interrupt_source
193 {
194     kPF1550_IntSrcTemp_110C = 0x1U, /* Die temperature crosses 110C interrupt source. */
195     kPF1550_IntSrcTemp_125C = 0x4U, /* Die temperature crosses 125C interrupt source. */
196 };
197 
198 /*! @brief PF1550 ONKEY Interrupt Source definition. */
199 enum _pf1550_onkey_interrupt_source
200 {
201     kPF1550_IntSrcOnkeyPush     = 0x01U, /* A push of the ONKEY button interrupt source. */
202     kPF1550_IntSrcOnkeyPress_1s = 0x02U, /* After ONKEY pressed for >1s interrupt source. */
203     kPF1550_IntSrcOnkeyPress_2s = 0x04U, /* After ONKEY pressed for >2s interrupt source. */
204     kPF1550_IntSrcOnkeyPress_3s = 0x08U, /* After ONKEY pressed for >3s interrupt source. */
205     kPF1550_IntSrcOnkeyPress_4s = 0x10U, /* After ONKEY pressed for >4s interrupt source. */
206     kPF1550_IntSrcOnkeyPress_8s = 0x20U, /* After ONKEY pressed for >8s interrupt source. */
207 };
208 
209 /*! @brief PF1550 Misc. Interrupt Source definition. */
210 enum _pf1550_misc_interrupt_source
211 {
212     kPF1550_IntSrcMiscPowerUp = 0x01U,    /* Completion of transition from STANDBY to RUN
213                                              and from SLEEP to RUN interrupt source. */
214     kPF1550_IntSrcMiscPowerDown = 0x02U,  /* Completion of transition from RUN to STANDBY
215                                              and from RUN to SLEEP interrupt source. */
216     kPF1550_IntSrcMiscPowerOn = 0x04U,    /* Power on button event interrupt source
217                                              (keep same function as PF3000/PF0100). */
218     kPF1550_IntSrcMiscLowSysWarn = 0x08U, /* LOW_SYS_WARN threshold crossed interrupt source. */
219     kPF1550_IntSrcMiscOverLoad   = 0x10U, /* SYS_OVLO threshold crossed interrupt source. */
220 };
221 
222 /*! @brief PF1550 Undervoltage Detection Threshold definition. */
223 typedef enum _pf1550_undervoltage_detect_threshold
224 {
225     kPF1550_UnderVoltDetThres_Rising2V65Falling2V55 =
226         0x0U, /* Undervoltage Detection Threshold: Rising 2.65V; Falling 2.55V. */
227     kPF1550_UnderVoltDetThres_Rising2V8Falling2V7 =
228         0x1U, /* Undervoltage Detection Threshold: Rising 2.8V; Falling 2.7V. */
229     kPF1550_UnderVoltDetThres_Rising3V0Falling2V9 =
230         0x2U, /* Undervoltage Detection Threshold: Rising 3.0V; Falling 2.9V. */
231     kPF1550_UnderVoltDetThres_Rising3V1Falling3V0 =
232         0x3U, /* Undervoltage Detection Threshold: Rising 3.1V; Falling 3.0V. */
233 } pf1550_undervoltage_detect_threshold_t;
234 
235 /*! @brief PF1550 Low Vsys Warning Threshold definition. */
236 typedef enum _pf1550_low_vsys_warning_threshold
237 {
238     kPF1550_LowVsysWarnThres_Rising3V3Falling3V1 = 0x0U, /* Low Vsys Warning Threshold: Rising 3.3V; Falling 3.1V. */
239     kPF1550_LowVsysWarnThres_Rising3V5Falling3V3 = 0x1U, /* Low Vsys Warning Threshold: Rising 3.5V; Falling 3.3V. */
240     kPF1550_LowVsysWarnThres_Rising3V7Falling3V5 = 0x2U, /* Low Vsys Warning Threshold: Rising 3.7V; Falling 3.5V. */
241     kPF1550_LowVsysWarnThres_Rising3V9Falling3V7 = 0x3U, /* Low Vsys Warning Threshold: Rising 3.9V; Falling 3.7V. */
242 } pf1550_low_vsys_warning_threshold_t;
243 
244 /*! @brief PF1550 ONKEY Push Reset Time definition. */
245 typedef enum _pf1550_onkey_push_reset_time
246 {
247     kPF1550_OnkeyPushResetTime_4s  = 0x0U, /* Push ONKEY 4s for a global reset. */
248     kPF1550_OnkeyPushResetTime_8s  = 0x1U, /* Push ONKEY 8s for a global reset. */
249     kPF1550_OnkeyPushResetTime_12s = 0x2U, /* Push ONKEY 12s for a global reset. */
250     kPF1550_OnkeyPushResetTime_16s = 0x3U, /* Push ONKEY 16s for a global reset. */
251 } pf1550_onkey_push_reset_time_t;
252 
253 /*! @brief PF1550 ONKEY Push Debounce Time definition. */
254 typedef enum _pf1550_onkey_debounce
255 {
256     kPF1550_OnkeyDebounce_Falling31ms25Rising31ms25 =
257         0x0U, /* ONKEY Push Debounce: 31.25ms falling edge; 31.25ms rising edge. */
258     kPF1550_OnkeyDebounce_Falling125msRising31ms25 =
259         0x2U, /* ONKEY Push Debounce: 125ms falling edge; 31.25ms rising edge. */
260     kPF1550_OnkeyDebounce_Falling750msRising31ms25 =
261         0x3U, /* ONKEY Push Debounce: 750ms falling edge; 31.25ms rising edge. */
262 } pf1550_onkey_debounce_t;
263 
264 /*! @brief PF1550 Standby Delay Time definition. */
265 typedef enum _pf1550_standby_delay
266 {
267     kPF1550_StandbyDelay_None         = 0x0U, /* No additional delay. */
268     kPF1550_StandbyDelay_1x32kHzCycle = 0x1U, /* 1 x 32kHz cycle additional delay. */
269     kPF1550_StandbyDelay_2x32kHzCycle = 0x2U, /* 2 x 32kHz cycle additional delay. */
270     kPF1550_StandbyDelay_3x32kHzCycle = 0x3U, /* 3 x 32kHz cycle additional delay. */
271 } pf1550_standby_delay_t;
272 
273 /*! @brief PF1550 Standby Pad Active Polarity definition. */
274 typedef enum _pf1550_standby_polarity
275 {
276     kPF1550_StandbyPolActiveHigh = 0x0U, /* Standby pin input active high. */
277     kPF1550_StandbyPolActiveLow  = 0x1U, /* Standby pin input active low. */
278 } pf1550_standby_polarity_t;
279 
280 /*! @brief PF1550 Power Up Delay Time definition. */
281 typedef enum _pf1550_power_up_delay
282 {
283     kPF1550_PowerUpDelay_2ms    = 0x0U, /* RESETBMCU goes high 2ms after last regulator. */
284     kPF1550_PowerUpDelay_4ms    = 0x2U, /* RESETBMCU goes high 4ms after last regulator. */
285     kPF1550_PowerUpDelay_8ms    = 0x3U, /* RESETBMCU goes high 8ms after last regulator. */
286     kPF1550_PowerUpDelay_16ms   = 0x4U, /* RESETBMCU goes high 16ms after last regulator. */
287     kPF1550_PowerUpDelay_128ms  = 0x5U, /* RESETBMCU goes high 128ms after last regulator. */
288     kPF1550_PowerUpDelay_256ms  = 0x6U, /* RESETBMCU goes high 256ms after last regulator. */
289     kPF1550_PowerUpDelay_1024ms = 0x7U, /* RESETBMCU goes high 1024ms after last regulator. */
290 } pf1550_power_up_delay_t;
291 
292 /*! @brief PF1550 Power On Pad Debounce Time definition. */
293 typedef enum _pf1550_power_on_debounce
294 {
295     kPF1550_PowerOnDebounce_Fall31ms25Rise31ms25 =
296         0x0U, /* Power On Pad Debounce: 31.25ms falling edge; 31.25ms rising edge. */
297     kPF1550_PowerOnDebounce_Fall125msRise31ms25 =
298         0x2U, /* Power On Pad Debounce: 125ms falling edge; 31.25ms rising edge. */
299     kPF1550_PowerOnDebounce_Fall750msRise31ms25 =
300         0x3U, /* Power On Pad Debounce: 750ms falling edge; 31.25ms rising edge. */
301 } pf1550_power_on_debounce_t;
302 
303 /*! @brief PF1550 Regulator Power Down Sequence Attribute definition. */
304 typedef enum _pf1550_regulator_power_down_sequence
305 {
306     kPF1550_RegulatorPowerDownSeqOpt0 = 0x0U, /* Regulator Power Down Sequence Attribute: Option 0. */
307     kPF1550_RegulatorPowerDownSeqOpt1 = 0x1U, /* Regulator Power Down Sequence Attribute: Option 1. */
308     kPF1550_RegulatorPowerDownSeqOpt2 = 0x2U, /* Regulator Power Down Sequence Attribute: Option 2. */
309     kPF1550_RegulatorPowerDownSeqOpt3 = 0x3U, /* Regulator Power Down Sequence Attribute: Option 3. */
310     kPF1550_RegulatorPowerDownSeqOpt4 = 0x4U, /* Regulator Power Down Sequence Attribute: Option 4. */
311     kPF1550_RegulatorPowerDownSeqOpt5 = 0x5U, /* Regulator Power Down Sequence Attribute: Option 5. */
312     kPF1550_RegulatorPowerDownSeqOpt6 = 0x6U, /* Regulator Power Down Sequence Attribute: Option 6. */
313     kPF1550_RegulatorPowerDownSeqOpt7 = 0x7U, /* Regulator Power Down Sequence Attribute: Option 7. */
314 } pf1550_regulator_power_down_sequence_t;
315 
316 /*! @brief PF1550 Switch DVS Speed Attribute definition. */
317 typedef enum _pf1550_switch_dvs_speed
318 {
319     kPF1550_SwitchDvsSpeed_12mV5Per2us = 0x0U, /* Switch DVS rate at 12.5mV/2us. */
320     kPF1550_SwitchDvsSpeed_12mV5Per4us = 0x1U, /* Switch DVS rate at 12.5mV/4us. */
321 } pf1550_switch_dvs_speed_t;
322 
323 /*! @brief PF1550 Switch Current Limit Attribute definition. */
324 typedef enum _pf1550_switch_current_limit
325 {
326     kPF1550_SwitchCurrentLimit_1A  = 0x0U, /* Switch Current Limit: Typical current limit of 1.0A. */
327     kPF1550_SwitchCurrentLimit_1A5 = 0x1U, /* Switch Current Limit: Typical current limit of 1.5A. */
328     kPF1550_SwitchCurrentLimit_2A  = 0x2U, /* Switch Current Limit: Typical current limit of 2.0A. */
329 } pf1550_switch_current_limit_t;
330 
331 /*! @brief PF1550 Vsnvs Coin Cell Charging Voltage Attribute definition. */
332 typedef enum _pf1550_coin_cell_charging_voltage
333 {
334     kPF1550_CoinCellChargingVoltage_1V8 = 0x0U, /* Coin cell charger charging voltage 1.8V. */
335     kPF1550_CoinCellChargingVoltage_1V9 = 0x1U, /* Coin cell charger charging voltage 1.9V. */
336     kPF1550_CoinCellChargingVoltage_2V  = 0x2U, /* Coin cell charger charging voltage 2.0V. */
337     kPF1550_CoinCellChargingVoltage_2V1 = 0x3U, /* Coin cell charger charging voltage 2.1V. */
338     kPF1550_CoinCellChargingVoltage_2V2 = 0x4U, /* Coin cell charger charging voltage 2.2V. */
339     kPF1550_CoinCellChargingVoltage_2V3 = 0x5U, /* Coin cell charger charging voltage 2.3V. */
340     kPF1550_CoinCellChargingVoltage_2V4 = 0x6U, /* Coin cell charger charging voltage 2.4V. */
341     kPF1550_CoinCellChargingVoltage_2V5 = 0x7U, /* Coin cell charger charging voltage 2.5V. */
342     kPF1550_CoinCellChargingVoltage_2V6 = 0x8U, /* Coin cell charger charging voltage 2.6V. */
343     kPF1550_CoinCellChargingVoltage_2V7 = 0x9U, /* Coin cell charger charging voltage 2.7V. */
344     kPF1550_CoinCellChargingVoltage_2V8 = 0xAU, /* Coin cell charger charging voltage 2.8V. */
345     kPF1550_CoinCellChargingVoltage_2V9 = 0xBU, /* Coin cell charger charging voltage 2.9V. */
346     kPF1550_CoinCellChargingVoltage_3V  = 0xCU, /* Coin cell charger charging voltage 3.0V. */
347     kPF1550_CoinCellChargingVoltage_3V1 = 0xDU, /* Coin cell charger charging voltage 3.1V. */
348     kPF1550_CoinCellChargingVoltage_3V2 = 0xEU, /* Coin cell charger charging voltage 3.2V. */
349     kPF1550_CoinCellChargingVoltage_3V3 = 0xFU, /* Coin cell charger charging voltage 3.3V. */
350 } pf1550_coin_cell_charging_voltage_t;
351 
352 /*! @brief PF1550 Switch Attribute Structure definition. */
353 typedef struct _pf1550_switch_attribute
354 {
355     pf1550_switch_dvs_speed_t dvsSpeed;                       /* Switch DVS Speed Selection. */
356     pf1550_switch_current_limit_t currentLimit;               /* Switch Current Limit Selection. */
357     pf1550_regulator_power_down_sequence_t powerDownSequence; /* The power down sequencer performs the functional
358                                                                  opposite to the power up sequencer. */
359     bool enableLowPowerMode;      /* Lets the buck enter low power mode during Standby and Sleep. */
360     bool enableForcedPwm;         /* Forced in PWM mode irrespective of load current. */
361     bool enableForcedPwmInDvs;    /* Forces to track the DVS reference while it is falling. */
362     bool enableDischargeResistor; /* Enables discharge resistor on output when regulator disabled. */
363 } pf1550_switch_attribute_t;
364 
365 /*! @brief PF1550 LDO Attribute Structure definition. */
366 typedef struct _pf1550_ldo_attribute
367 {
368     pf1550_regulator_power_down_sequence_t powerDownSequence; /* The power down sequencer performs the functional
369                                                                  opposite to the power up sequencer. */
370     bool enableLowPowerMode; /* Lets LDO enter low power mode during Standby and Sleep. */
371     bool enableLoadSwitch;   /* Set LDO to a load switch (fully on) mode.
372                                 Changing from true to false is not allowed. */
373 } pf1550_ldo_attribute_t;
374 
375 /*! @brief PF1550 Vrefddr Attribute Structure definition. */
376 typedef struct _pf1550_vrefddr_attribute
377 {
378     pf1550_regulator_power_down_sequence_t powerDownSequence; /* The power down sequencer performs the functional
379                                                                  opposite to the power up sequencer. */
380 } pf1550_vrefddr_attribute_t;
381 
382 /*! @brief PF1550 Vsnvs Attribute Structure definition. */
383 typedef struct _pf1550_vsnvs_attribute
384 {
385     pf1550_coin_cell_charging_voltage_t coinCellChargingVoltage; /* Vsnvs Coin Cell Charging Voltage Selection. */
386     bool enableLocalBandgapInCoinCellMode;                       /* Enable bandgap in coin cell mode. */
387     bool enableCoinCellCharger;                                  /* Enable Coin Cell Charger. */
388 } pf1550_vsnvs_attribute_t;
389 
390 /*! @brief PF1550 ONKEY Pad Attribute Structure definition. */
391 typedef struct _pf1550_onkey_attribute
392 {
393     pf1550_onkey_debounce_t debounce;        /* ONKEY Push Debounce Time Selection. */
394     pf1550_onkey_push_reset_time_t pushTime; /* ONKEY Push Reset Time Selection. */
395     bool enableTurnOffSystemViaOnkey;        /* Enables turning off of system via ONKEY. */
396 } pf1550_onkey_attribute_t;
397 
398 /*! @brief PF1550 PWRON Pad Attribute Structure definition. */
399 typedef struct _pf1550_power_on_attribute
400 {
401     pf1550_power_on_debounce_t debounce;  /* Power On Pad Debounce Time Selection. */
402     bool longPressGoToRegsDisableOrSleep; /* Enables going to REGS_DISABLE or Sleep mode when
403                                              PWRON_CFG = 1. Refer to state machine for details. */
404     bool longPressRestartToRunStauts;     /* Enables restart of system when PWRON push button is
405                                              held low for 5 seconds. */
406 } pf1550_power_on_attribute_t;
407 
408 /*! @brief PF1550 STANDBY Pad Attribute Structure definition. */
409 typedef struct _pf1550_standby_attribute
410 {
411     pf1550_standby_delay_t standbyDelay;       /* Select delay of Standby pin (after synchronization). */
412     pf1550_standby_polarity_t standbyPolarity; /* Standby Pad Active Polarity Selection. */
413 } pf1550_standby_attribute_t;
414 
415 /*! @brief PF1550 Handle definition. */
416 typedef struct _pf1550_handle
417 {
418     /* Pointer to the user-defined I2C Send Data function. */
419     status_t (*I2C_SendFunc)(
420         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
421     /* Pointer to the user-defined I2C Receive Data function. */
422     status_t (*I2C_ReceiveFunc)(
423         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
424     /* The I2C Slave Address Read From OTP. */
425     uint8_t slaveAddress;
426 } pf1550_handle_t;
427 
428 /*! @brief PF1550 Configuration Structure definition. */
429 typedef struct _pf1550_config
430 {
431     /* Pointer to the user-defined I2C Send Data function. */
432     status_t (*I2C_SendFunc)(
433         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
434     /* Pointer to the user-defined I2C Receive Data function. */
435     status_t (*I2C_ReceiveFunc)(
436         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
437     /* Undervoltage Detection Threshold Selection. */
438     pf1550_undervoltage_detect_threshold_t threshold;
439     /* Power Up Delay Time Selection. */
440     pf1550_power_up_delay_t delay;
441     /* Shuts down LDO if it enters a current limit fault. Controls LDO1, LDO2 and LDO3. */
442     bool shutDownLdoInCurrentFault;
443     /* The PF1550 I2C Slave Address. */
444     uint8_t slaveAddress;
445 } pf1550_config_t;
446 
447 /*!
448  * @addtogroup pf1550
449  * @{
450  */
451 
452 /*******************************************************************************
453  * API
454  ******************************************************************************/
455 #if defined(__cplusplus)
456 extern "C" {
457 #endif
458 
459 /*!
460  * @name Initialization function
461  * @{
462  */
463 
464 /*!
465  * @brief Gets the default configuration structure.
466  *
467  * This function initializes the PF1550 configuration structure to default values. The default
468  * values are as follows.
469  *   pf1550Config->I2C_SendFunc              = NULL;
470  *   pf1550Config->I2C_ReceiveFunc           = NULL;
471  *   pf1550Config->threshold                 = kPF1550_UnderVoltDetThres_Rising3V0Falling2V9;
472  *   pf1550Config->delay                     = kPF1550_PowerUpDelay_2ms;
473  *   pf1550Config->shutDownLdoInCurrentFault = false;
474  *   pf1550Config->slaveAddress              = PF1550_DEFAULT_I2C_ADDR;
475  *
476  * @param config Pointer to the PF1550 configuration structure.
477  */
478 void PF1550_GetDefaultConfig(pf1550_config_t *config);
479 
480 /*!
481  * @brief Initializes a PF1550 instance.
482  *
483  * This function initializes the PF1550 module with user-defined settings.
484  * This example shows how to set up the pf1550_config_t parameters and how
485  * to call the PF1550_Init function by passing in these parameters.
486  * @code
487  *   pf1550_config_t pf1550Config;
488  *   pf1550Config.I2C_SendFunc              = APP_I2C_SendFunc;
489  *   pf1550Config.I2C_ReceiveFunc           = APP_I2C_ReceiveFunc;
490  *   pf1550Config.threshold                 = kPF1550_UnderVoltDetThres_Rising3V1Falling3V0;
491  *   pf1550Config.delay                     = kPF1550_PowerUpDelay_1024ms;
492  *   pf1550Config.shutDownLdoInCurrentFault = true;
493  *   pf1550Config.slaveAddress              = PF1550_DEFAULT_I2C_ADDR;
494  *   PF1550_Init(&pf1550Handle, &pf1550Config);
495  * @endcode
496  *
497  * @param handle PF1550 Handle.
498  * @param config Pointer to the user-defined configuration structure.
499  */
500 void PF1550_Init(pf1550_handle_t *handle, const pf1550_config_t *config);
501 /*! @} */
502 
503 /*!
504  * @name Basic register access functions
505  * @{
506  */
507 
508 /*!
509  * @brief Write the value to register of PF1550.
510  *
511  * @param handle Pointer to a valid PF1550 instance structure.
512  * @param reg variable store address of register.
513  * @param val variable store value which is written to PF1550.
514  * @return true if success or false if error.
515  */
516 bool PF1550_WriteReg(pf1550_handle_t *handle, uint8_t reg, uint8_t val);
517 
518 /*!
519  * @brief Read the value of register in PF1550.
520  *
521  * @param handle Pointer to a valid PF1550 instance structure.
522  * @param reg variable store address of register.
523  * @param val pointer store return value.
524  * @return true if success or false if error.
525  */
526 bool PF1550_ReadReg(pf1550_handle_t *handle, uint8_t reg, uint8_t *val);
527 
528 /*!
529  * @brief Modify some bits in the register in PF1550.
530  * @param handle Pointer to a valid PF1550 instance structure.
531  * @param reg variable store address of register.
532  * @param mask The mask code for the bits want to write. The bit you want to write should be 1.
533  * @param val Value needs to write into the register.
534  * @return true if success or false if error.
535  */
536 bool PF1550_ModifyReg(pf1550_handle_t *handle, uint8_t reg, uint8_t mask, uint8_t val);
537 
538 /*!
539  * @brief Dump the register content in PF1550.
540  * @param handle Pointer to a valid PF1550 instance structure.
541  * @param reg The address of the first register to dump.
542  * @param buffer The buffer to store the dumped content.
543  * @param size The count of registers to dump.
544  * @return true if success or false if error.
545  */
546 bool PF1550_DumpReg(pf1550_handle_t *handle, uint8_t reg, uint8_t *buffer, uint8_t size);
547 
548 /*! @} */
549 
550 /*!
551  * @name Interrupts
552  * @{
553  */
554 
555 /*!
556  * @brief Enables PF1550 interrupts according to the provided interrupt source mask.
557  *
558  * This function enables the PF1550 interrupts according to the provided interrupt category
559  * and interrupt source.
560  * The interrupt source category enumerate the available interrupt groups in category.
561  * The interrupt source mask is a logical OR of enumeration members:
562  * see @ref _pf1550_switch_interrupt_source for Switch interrupt sources;
563  *     @ref _pf1550_ldo_interrupt_source for LDO interrupt sources;
564  *     @ref _pf1550_temp_interrupt_source for Die Temperature interrupt sources;
565  *     @ref _pf1550_onkey_interrupt_source for ONKEY interrupt sources;
566  *     @ref _pf1550_misc_interrupt_source for Misc. interrupt sources.
567  *
568  * @param handle Pointer to a valid PF1550 instance structure.
569  * @param category The interrupt category to set.
570  * @param source Logic ORed interrupt sources of selected interrupt category to enable.
571  */
572 void PF1550_EnableInterrupts(pf1550_handle_t *handle, pf1550_interrupt_category_t category, uint32_t source);
573 
574 /*!
575  * @brief Disable PF1550 interrupts according to the provided interrupt source mask.
576  *
577  * This function disables the PF1550 interrupts according to the provided interrupt category
578  * and interrupt source.
579  * The interrupt source category enumerate the available interrupt groups in category.
580  * The interrupt source mask is a logical OR of enumeration members:
581  * see @ref _pf1550_switch_interrupt_source for Switch interrupt sources;
582  *     @ref _pf1550_ldo_interrupt_source for LDO interrupt sources;
583  *     @ref _pf1550_temp_interrupt_source for Die Temperature interrupt sources;
584  *     @ref _pf1550_onkey_interrupt_source for ONKEY interrupt sources;
585  *     @ref _pf1550_misc_interrupt_source for Misc. interrupt sources.
586  *
587  * @param handle Pointer to a valid PF1550 instance structure.
588  * @param category The interrupt category to set.
589  * @param source Logic ORed interrupt sources of selected interrupt category to disable.
590  */
591 void PF1550_DisableInterrupts(pf1550_handle_t *handle, pf1550_interrupt_category_t category, uint32_t source);
592 
593 /*!
594  * @brief Get Interrupt Category of PF1550.
595  * This function is used to get the ORed Interrupt Category
596  * that is asserted by hardware. Users can AND the return value with
597  * Interrupt Category defined in @ pf1550_interrupt_category_t to check
598  * which kinds of interrupt event is happened, after that user can get/clear
599  * the interrupt status bits for the specified interrupt category, other than
600  * check all the interrupt status.
601  *
602  * @param handle Pointer to a valid PF1550 instance structure.
603  * @return ORed Interrupt Category combination.
604  */
605 uint32_t PF1550_GetInterruptCategory(pf1550_handle_t *handle);
606 
607 /*!
608  * @brief Get interrupt flags of selected interrupt category.
609  *
610  * This function gets all interrupt flags of selected interrupt category.
611  * The flags are returned as the logical OR value of the corresponding interrupt source:
612  * see @ref _pf1550_switch_interrupt_source for Switch interrupt sources;
613  *     @ref _pf1550_ldo_interrupt_source for LDO interrupt sources;
614  *     @ref _pf1550_temp_interrupt_source for Die Temperature interrupt sources;
615  *     @ref _pf1550_onkey_interrupt_source for ONKEY interrupt sources;
616  *     @ref _pf1550_misc_interrupt_source for Misc. interrupt sources.
617  *
618  * @param handle Pointer to a valid PF1550 instance structure.
619  * @param category The interrupt category that to query.
620  * @return status flags which are ORed by the enumerators in the corresponding interrupt source.
621  */
622 uint32_t PF1550_GetInterruptStatus(pf1550_handle_t *handle, pf1550_interrupt_category_t category);
623 
624 /*!
625  * @brief Clear interrupt flags of selected interrupt category.
626  *
627  * This function clears all interrupt flags of selected interrupt category.
628  * The interrupt source category enumerate the available interrupt groups in category.
629  * The interrupt source mask is a logical OR of enumeration members:
630  * see @ref _pf1550_switch_interrupt_source for Switch interrupt sources;
631  *     @ref _pf1550_ldo_interrupt_source for LDO interrupt sources;
632  *     @ref _pf1550_temp_interrupt_source for Die Temperature interrupt sources;
633  *     @ref _pf1550_onkey_interrupt_source for ONKEY interrupt sources;
634  *     @ref _pf1550_misc_interrupt_source for Misc. interrupt sources.
635  *
636  * @param handle Pointer to a valid PF1550 instance structure.
637  * @param category The interrupt category that set.
638  * @param source Logic ORed interrupt sources of selected interrupt category to clear.
639  */
640 void PF1550_ClearInterruptStatus(pf1550_handle_t *handle, pf1550_interrupt_category_t category, uint32_t source);
641 /*! @} */
642 
643 /*!
644  * @name Regulator control functions
645  * @{
646  */
647 
648 /*!
649  * @brief Enable/Disable the output of selected regulator.
650  *
651  * This function is used to enable/disable the output of selected regulator
652  * enumerated in @ref pf1550_module_t under selected operating status
653  * enumerated in @ref pf1550_operating_status_t. The output state of
654  * the regulators will change automatically once the operating status
655  * changed.
656  *
657  * @param handle Pointer to a valid PF1550 instance structure.
658  * @param module Sub-modules in PF1550 device.
659  * @param status The operating status of PF1550 to set.
660  * @param enable Set true to enable regulator, set false to disable regulator.
661  */
662 void PF1550_EnableRegulator(pf1550_handle_t *handle,
663                             pf1550_module_t module,
664                             pf1550_operating_status_t status,
665                             bool enable);
666 
667 /*!
668  * @brief Query the output state of selected regulator.
669  *
670  * This function is used to query the output state of selected regulator
671  * enumerated in @ref pf1550_module_t under selected operating status
672  * enumerated in @ref pf1550_operating_status_t. The output state of
673  * the regulators will change automatically once the operating status
674  * changed.
675  *
676  * @param handle Pointer to a valid PF1550 instance structure.
677  * @param module Sub-modules in PF1550 device.
678  * @param status The operating status of PF1550 to set.
679  * @return true if regulator is enabled, false if regulator is disabled.
680  */
681 bool PF1550_IsRegulatorEnabled(pf1550_handle_t *handle, pf1550_module_t module, pf1550_operating_status_t status);
682 
683 /*!
684  * @brief Set the output voltage of selected regulator.
685  *
686  * This function is used to set the output voltage of selected regulator
687  * enumerated in @ref pf1550_module_t under selected operating status
688  * enumerated in @ref pf1550_operating_status_t. The output state of
689  * the regulators will change automatically once the operating status
690  * changed. All the available output voltages are listed in
691  * @ref pf1550_regulator_output_voltage_t.
692  *
693  * @param handle Pointer to a valid PF1550 instance structure.
694  * @param module Sub-modules in PF1550 device.
695  * @param status The operating status of PF1550 to set.
696  * @param voltage The output voltage in uV to set.
697  */
698 void PF1550_SetRegulatorOutputVoltage(pf1550_handle_t *handle,
699                                       pf1550_module_t module,
700                                       pf1550_operating_status_t status,
701                                       uint32_t voltage);
702 
703 /*!
704  * @brief Query the output voltage of selected regulator.
705  *
706  * This function is used to query the output voltage of selected regulator
707  * enumerated in @ref pf1550_module_t under selected operating status
708  * enumerated in @ref pf1550_operating_status_t. The output state of
709  * the regulators will change automatically once the operating status
710  * changed. All the available output voltages are listed in
711  * @ref pf1550_regulator_output_voltage_t.
712  *
713  * @param handle Pointer to a valid PF1550 instance structure.
714  * @param module Sub-modules in PF1550 device.
715  * @param status The operating status of PF1550 to set.
716  * @return voltage The output voltage in uV of selected regulator.
717  */
718 uint32_t PF1550_GetRegulatorOutputVoltage(pf1550_handle_t *handle,
719                                           pf1550_module_t module,
720                                           pf1550_operating_status_t status);
721 
722 /*!
723  * @brief Set the attributes of selected Buck Switch.
724  *
725  * This function is used to set the attributes of Buck Switch regulator.
726  * All the available attributes for Switch are listed in
727  * @ref pf1550_switch_attribute_t.
728  *
729  * @param handle Pointer to a valid PF1550 instance structure.
730  * @param module Sub-modules in PF1550 device.
731  * @param attribute Pointer to the Switch Attribute structure to set.
732  */
733 void PF1550_SetSwitchAttribute(pf1550_handle_t *handle,
734                                pf1550_module_t module,
735                                const pf1550_switch_attribute_t *attribute);
736 
737 /*!
738  * @brief Set the attributes of selected LDO.
739  *
740  * This function is used to set the attributes of LDO regulator.
741  * All the available attributes for Switch are listed in
742  * @ref pf1550_ldo_attribute_t.
743  *
744  * @param handle Pointer to a valid PF1550 instance structure.
745  * @param module Sub-modules in PF1550 device.
746  * @param attribute Pointer to the LDO Attribute structure to set.
747  */
748 void PF1550_SetLdoAttribute(pf1550_handle_t *handle, pf1550_module_t module, const pf1550_ldo_attribute_t *attribute);
749 
750 /*!
751  * @brief Set the attributes of Vref DDR.
752  *
753  * This function is used to set the attributes of Vref DDR regulator.
754  * All the available attributes for Vref DDR are listed in
755  * @ref pf1550_vrefddr_attribute_t.
756  *
757  * @param handle Pointer to a valid PF1550 instance structure.
758  * @param module Sub-modules in PF1550 device.
759  * @param attribute Pointer to the Vref DDR Attribute structure to set.
760  */
761 void PF1550_SetVrefDdrAttribute(pf1550_handle_t *handle, const pf1550_vrefddr_attribute_t *attribute);
762 
763 /*!
764  * @brief Set the attributes of Vsnvs.
765  *
766  * This function is used to set the attributes of Vsnvs regulator.
767  * All the available attributes for Vsnvs are listed in
768  * @ref pf1550_vsnvs_attribute_t.
769  *
770  * @param handle Pointer to a valid PF1550 instance structure.
771  * @param module Sub-modules in PF1550 device.
772  * @param attribute Pointer to the Vsnvs Attribute structure to set.
773  */
774 void PF1550_SetVsnvsAttribute(pf1550_handle_t *handle, const pf1550_vsnvs_attribute_t *attribute);
775 /*! @} */
776 
777 /*!
778  * @name I/O Pad control functions
779  * @{
780  */
781 
782 /*!
783  * @brief Set the attributes of ONKEY Pad.
784  *
785  * This function is used to set the attributes of ONKEY Pad.
786  * All the available attributes for ONKEY Pad are listed in
787  * @ref pf1550_onkey_attribute_t.
788  *
789  * @param handle Pointer to a valid PF1550 instance structure.
790  * @param module Sub-modules in PF1550 device.
791  * @param attribute Pointer to the ONKEY Pad Attribute structure to set.
792  */
793 void PF1550_SetOnKeyPadAttibute(pf1550_handle_t *handle, const pf1550_onkey_attribute_t *attribute);
794 
795 /*!
796  * @brief Set the attributes of PowerOn Pad.
797  *
798  * This function is used to set the attributes of PowerOn Pad.
799  * All the available attributes for PowerOn Pad are listed in
800  * @ref pf1550_power_on_attribute_t.
801  *
802  * @param handle Pointer to a valid PF1550 instance structure.
803  * @param module Sub-modules in PF1550 device.
804  * @param attribute Pointer to the PowerOn Pad Attribute structure to set.
805  */
806 void PF1550_SetPwrOnPadAttibute(pf1550_handle_t *handle, const pf1550_power_on_attribute_t *attribute);
807 
808 /*!
809  * @brief Set the attributes of Standby Pad.
810  *
811  * This function is used to set the attributes of Standby Pad.
812  * All the available attributes for Standby Pad are listed in
813  * @ref pf1550_standby_attribute_t.
814  *
815  * @param handle Pointer to a valid PF1550 instance structure.
816  * @param module Sub-modules in PF1550 device.
817  * @param attribute Pointer to the Standby Pad Attribute structure to set.
818  */
819 void PF1550_SetStandbyPadAttibute(pf1550_handle_t *handle, const pf1550_standby_attribute_t *attribute);
820 /*! @} */
821 
822 /*!
823  * @name Misc. functions
824  * @{
825  */
826 
827 /*!
828  * @brief Query Current Operating Status of PF1550.
829  *
830  * This function is used to query the current operating status of PF1550.
831  * All the available operating status for PF1550 are listed in
832  * @ref pf1550_operating_status_t.
833  *
834  * @param handle Pointer to a valid PF1550 instance structure.
835  * @return Current PF1550 operating status.
836  */
837 pf1550_operating_status_t PF1550_GetOperatingStatus(pf1550_handle_t *handle);
838 
839 /*!
840  * @brief Query if regulator support dynamic voltage scaling.
841  *
842  * This function is used to query if the regulator support DVS feature.
843  * User can only set the output voltage to the regulators that support
844  * DVS feature, otherwise PF1550_SetRegulatorOutputVoltage() function will
845  * return immediately.
846  *
847  * @param handle Pointer to a valid PF1550 instance structure.
848  * @param module Sub-modules in PF1550 device.
849  * @return true: regulator support DVS feature, false: regulator does not support DVS.
850  */
851 bool PF1550_IsRegulatorSupportDvs(pf1550_handle_t *handle, pf1550_module_t module);
852 /*! @} */
853 
854 #if defined(__cplusplus)
855 }
856 #endif
857 
858 /*! @} */
859 
860 #endif /* _FSL_PF1550_H_ */
861 
862 /*******************************************************************************
863  * EOF
864  ******************************************************************************/
865