blob: 2bfe2091fb30660727f6c01df0544ccb5daf4020 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * (C) Copyright 2016, ZIXC Corporation.
3 *
4 */
5
6#ifndef __ZX234290_H__
7#define __ZX234290_H__
8#include <drvs_gpio.h>
9//#define PS_HOLD_PIN GPIO51
10
11#define ZX234290_I2C_SLAVE_ADDR 0x12
12#define ZX234296_REG_PWRKEY_CTRL2 0x43
13#define ZX234290_REG_ADDR_STSA 0x04
14
15#define INTR_A 0x0
16#define INTR_B 0x1
17
18#define INTR_MASK_A 0x2
19#define INTR_EOADC (0x1 << 2)
20#define INTR_PWR_ON_SHORT_PRESS (0x1 << 3)
21#define INTR_PWR_ON_LONG_PRESS (0x1 << 4)
22#define INTR_PWR_ON (0x1 << 5)
23
24#define INTR_MASK_B 0x3
25
26#define STATUS_A 0x4
27#define STATUS_EOADC (0x1 << 2)
28#define STATUS_PWR_ON (0x1 << 5)
29#define STATUS_B 0x5
30#define STATUS_RTC_ALARM (0x1 << 0)
31
32#define START_UP_STATUS 0x6
33#define PWR_ON_START_UP (0x1 << 0)
34#define RTC_ALARM_START_UP (0x1 << 1)
35#define PS_HOLD_START_UP (0x1 << 2)
36#define LLP_RESTART_UP (0x1 << 3)
37
38#define SYS_CONTROL 0x7
39//#define SINK1_ENABLE (0x1 << 0)
40//#define SINK2_ENABLE (0x1 << 1)
41#define ADC1_ENABLE (0x1 << 3)
42#define ADC2_ENABLE (0x1 << 4)
43
44#define BUCK_MODE_CONTROL0 0xe
45#define BUCK_MODE_CONTROL1 0xf
46#define MMC_CTRL 0x15
47#define ZX234290_REG_ADDR_LDO78_VOL 0x15
48#define ZX234290_REG_ADDR_LDO78_SLPVOL 0x1B
49
50#define ZX234290_LDO8_VSEL_LSH (4)
51#define ZX234290_LDO8_SLP_VSEL_LSH (4)
52
53#define ZX234290_REG_LDO_EN1 0x21 /* LDO8-1 */
54#define ZX234290_REG_ADC_ADC2MSB 0x27 /* CHANNEL 2 */
55#define ZX234290_REG_ADC_ADC2LSB 0x28
56#define ZX234290_REG_ADC_ADC1MSB 0x25 /* CHANNEL 2 */
57#define ZX234290_REG_ADC_ADC1LSB 0x26
58#define ZX234290_REG_ADC_VBATMSB 0x23 /* CHANNEL 2 */
59#define ZX234290_REG_ADC_VBATLSB 0x24
xf.lie31de8b2023-12-26 23:38:58 -080060#define ZX234297_REG_ADDR_SINK_CONTROL 0X29
lh9ed821d2023-04-07 01:36:19 -070061
62#define ZX234290_REG_RTC_CONTROL2 0x31
xf.li7ccf8372024-03-07 00:08:02 -080063
64/*RTC ALARM Enable*/
65#define ZX234290_REG_ADDR_ALARM_MINUTE 0x39
66#define ZX234290_REG_ADDR_ALARM_HOUR 0x3A
67#define ZX234290_REG_ADDR_ALARM_DAY 0x3B
68#define ZX234290_REG_ADDR_ALARM_WEEK 0x3C
69#define ZX234290_REG_ADDR_ALARM_SECOND 0x3D
70#define ZX234290_RTC_AlARM_ACTIVATED_LSH (7)
71
lh9ed821d2023-04-07 01:36:19 -070072#define RTC_CONTROL2_TIE (1 << 0)
73#define RTC_CONTROL2_AIE (1 << 1)
74#define RTC_CONTROL2_TF (1 << 2)
75#define RTC_CONTROL2_AF (1 << 3)
76
77#define ZX234290_REG_USER 0x50
78
79/*define reset flag*/
80#define ZX234290_USER_RST_FLAG (0x0<<4)/*0x00*/
81#define ZX234290_WDT_RST_FLAG (0x1<<4)/*0x10*/
82#define ZX234290_USER_RST_UNDEFINE (0x0<<0)/*0x0*/
83#define ZX234290_USER_RST_TO_NORMAL (0x1<<0)/*0x1*/
84#define ZX234290_USER_RST_TO_CHARGER (0x2<<0)/*0x2*/
85#define ZX234290_USER_RST_TO_ALARM (0x3<<0)/*0x3*/
86#define ZX234290_USER_RST_TO_EXCEPT (0x4<<0)/*0x4*/
87
88
89#define ZX234290_REG_INTA 0x00 /* INTERRUPT */
90#define ZX234290_REG_INTB 0x01
91
92
93#define ZX234290_REG_SYS_CTRL 0x07
94/* sink control */
95#define ZX234297_REG_ADDR_SINK_CONTROL 0x29
96#define ZX234290_REG_ADDR_LDO_EN2 0x22 /* [xx xx]BUCK4-1, [0xx0]LDO10-9*/
xf.lif2330622024-05-15 18:17:18 -070097#define ZX234290_REG_ADDR_TYPE 0xb0 /*used for pmu type*/
lh9ed821d2023-04-07 01:36:19 -070098
99/* 0x22 */
100#define ZX234297_SINK1_ON_LSH (2)
101#define ZX234297_SINK2_ON_LSH (3)
102#define ZX234297_SINK_ON_WID (1)
103/* 0x29 */
104#define ZX234297_SINK1_CURRENT_LSH (0)
105#define ZX234297_SINK2_CURRENT_LSH (4)
106#define ZX234297_SINK_CURRENT_WID (4)
107
xf.lif2330622024-05-15 18:17:18 -0700108#define PMU_TYPE_296 1
109#define PMU_TYPE_296G 2
110#define PMU_TYPE_297 3
111#define PMU_TYPE_296H 4
112#define PMU_TYPE_MAX 0xf
113
lh9ed821d2023-04-07 01:36:19 -0700114typedef enum _T_ZX234290_SINK
115{
116 SINK_1 = 0,
117 SINK_2 = 1,
118 SINK_MAX
119}T_ZX234290_SINK;
120
121typedef enum _T_ZX234290_SINK_CURRENT
122{
123 SINK_CURRENT_5MA,
124 SINK_CURRENT_10MA,
125 SINK_CURRENT_15MA,
126 SINK_CURRENT_20MA,
127 SINK_CURRENT_30MA,
128 SINK_CURRENT_40MA,
129 SINK_CURRENT_50MA,
130 SINK_CURRENT_60MA,
131 SINK_CURRENT_70MA,
132 SINK_CURRENT_80MA,
133 SINK_CURRENT_90MA,
134 SINK_CURRENT_100MA,
135 SINK_CURRENT_110MA,
136 SINK_CURRENT_120MA,
137
138 SINK_CURRENT_MAX
139}T_ZX234297_SINK_CURRENT;
140
141typedef enum _T_ZDrvZx234290_VldoD
142{
143 VLDOD_1_400 = 0,
144 VLDOD_1_500 = 1,
145 VLDOD_1_600 = 2,
146 VLDOD_1_800 = 3,
147 VLDOD_1_850 = 4,
148 VLDOD_2_000 = 5,
149 VLDOD_2_050 = 6,
150 VLDOD_2_500 = 7,
151 VLDOD_2_550 = 8,
152 VLDOD_2_700 = 9,
153 VLDOD_2_750 = 10,
154 VLDOD_2_800 = 11,
155 VLDOD_2_850 = 12,
156 VLDOD_2_900 = 13,
157 VLDOD_2_950 = 14,
158 VLDOD_3_000 = 15,
159
160 VLDOD_MAX
161
162}T_ZDrvZx234290_VldoD;
163
164
165/* pwr_on long pressed time */
166#define ZX234290_REG_ADDR_PWRON 0x42
167
168int zx234290_reset_flag(void);
169int zx234290_write_flag(UINT8 val);
170int pmu_pull_off_ps_hold(void);
171int pmu_pull_on_ps_hold(void);
172
173/*get the poweron key state 1: poweron press 0:poweron up*/
174int zx234290_get_poweron_state(void);
175int zx234290_get_rtc_state(void);
176int zx234290_get_adc1_voltage(void);
177int zx234290_get_adc2_voltage(void);
178int zx234290_get_vbat_voltage(void);
179int zx234290_set_softon(int on);
180int zx234290_ldo8_enable(int enable);
181int zx234290_set_sink(T_ZX234290_SINK sink_num, int is_on, T_ZX234297_SINK_CURRENT sink_current);
182
183
184#endif /* __ZX234290_H__ */