Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/power/max7762x.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2019-2020 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _MAX7762X_H_
19
#define _MAX7762X_H_
20
21
#include <utils/types.h>
22
23
/*
24
* SDx actual min is 625 mV. Multipliers 0/1 reserved.
25
* SD0 max is 1400 mV
26
* SD1 max is 1550 mV
27
* SD2 max is 3787.5 mV
28
* SD3 max is 3787.5 mV
29
*/
30
31
/*
32
* Switch Power domains (max77620):
33
* Name | Usage | uV step | uV min | uV default | uV max | Init
34
*-------+---------------+---------+--------+------------+---------+------------------
35
* sd0 | SoC | 12500 | 600000 | 625000 | 1400000 | 1.125V (pkg1.1)
36
* sd1 | SDRAM | 12500 | 600000 | 1125000 | 1125000 | 1.1V (pkg1.1)
37
* sd2 | ldo{0-1, 7-8} | 12500 | 600000 | 1325000 | 1350000 | 1.325V (pcv)
38
* sd3 | 1.8V general | 12500 | 600000 | 1800000 | 1800000 |
39
* ldo0 | Display Panel | 25000 | 800000 | 1200000 | 1200000 | 1.2V (pkg1.1)
40
* ldo1 | XUSB, PCIE | 25000 | 800000 | 1050000 | 1050000 | 1.05V (pcv)
41
* ldo2 | SDMMC1 | 50000 | 800000 | 1800000 | 3300000 |
42
* ldo3 | GC ASIC | 50000 | 800000 | 3100000 | 3100000 | 3.1V (pcv)
43
* ldo4 | RTC | 12500 | 800000 | 850000 | 850000 | 0.85V (AO, pcv)
44
* ldo5 | GC Card | 50000 | 800000 | 1800000 | 1800000 | 1.8V (pcv)
45
* ldo6 | Touch, ALS | 50000 | 800000 | 2900000 | 2900000 | 2.9V (pcv)
46
* ldo7 | XUSB | 50000 | 800000 | 1050000 | 1050000 | 1.05V (pcv)
47
* ldo8 | XUSB, DP, MCU | 50000 | 800000 | 1050000 | 2800000 | 1.05V/2.8V (pcv)
48
*/
49
50
51
// GPIOs T210: 3: 3.3V, 5: CPU PMIC, 6: GPU PMIC, 7: DSI/VI 1.2V powered by ldo0.
52
53
/*
54
* OTP: T210 - T210B01:
55
* SD0: 1.0V 1.05V - SoC. EN Based on FPSSRC.
56
* SD1: 1.15V 1.1V - DRAM for T210. EN Based on FPSSRC.
57
* SD2: 1.35V 1.35V
58
* SD3: 1.8V 1.8V
59
* All powered off?
60
* LDO0: -- -- - Display
61
* LDO1: 1.05V 1.05V
62
* LDO2: -- -- - SD
63
* LDO3: 3.1V 3.1V - GC ASIC
64
* LDO4: 1.0V 0.8V - Needed for RTC domain on T210.
65
* LDO5: 3.1V 3.1V
66
* LDO6: 2.8V 2.9V - Touch.
67
* LDO7: 1.05V 1.0V
68
* LDO8: 1.05V 1.0V
69
*/
70
71
/*
72
* MAX77620_AME_GPIO: control GPIO modes (bits 0 - 7 correspond to GPIO0 - GPIO7); 0 -> GPIO, 1 -> alt-mode
73
* MAX77620_REG_GPIOx: 0x9 sets output and enable
74
*/
75
76
/*! MAX77620 partitions. */
77
#define REGULATOR_SD0 0
78
#define REGULATOR_SD1 1
79
#define REGULATOR_SD2 2
80
#define REGULATOR_SD3 3
81
#define REGULATOR_LDO0 4
82
#define REGULATOR_LDO1 5
83
#define REGULATOR_LDO2 6
84
#define REGULATOR_LDO3 7
85
#define REGULATOR_LDO4 8
86
#define REGULATOR_LDO5 9
87
#define REGULATOR_LDO6 10
88
#define REGULATOR_LDO7 11
89
#define REGULATOR_LDO8 12
90
#define REGULATOR_CPU0 13 // T210 CPU.
91
#define REGULATOR_GPU0 14 // T210 CPU.
92
#define REGULATOR_CPU1 15 // T210B01 CPU.
93
#define REGULATOR_RAM0 16 // T210B01 RAM for PHASE211.
94
//#define REGULATOR_GPU1 17 // T210B01 CPU.
95
#define REGULATOR_MAX REGULATOR_RAM0
96
97
#define MAX77621_CPU_I2C_ADDR 0x1B
98
#define MAX77621_GPU_I2C_ADDR 0x1C
99
100
#define MAX77621_REG_VOUT 0x00
101
#define MAX77621_REG_VOUT_DVS 0x01
102
#define MAX77621_REG_CONTROL1 0x02
103
#define MAX77621_REG_CONTROL2 0x03
104
#define MAX77621_REG_CHIPID1 0x04
105
#define MAX77621_REG_CHIPID2 0x05
106
107
/* MAX77621_VOUT_DVC_DVS */
108
#define MAX77621_DVC_DVS_VOLT_MASK 0x7F
109
#define MAX77621_DVC_DVS_ENABLE_SHIFT 7
110
#define MAX77621_DVC_DVS_ENABLE_MASK (1 << MAX77621_DVC_DVS_ENABLE_SHIFT)
111
112
/* MAX77621_VOUT */
113
#define MAX77621_VOUT_DISABLE 0
114
#define MAX77621_VOUT_ENABLE 1
115
#define MAX77621_VOUT_ENABLE_MASK (MAX77621_VOUT_ENABLE << MAX77621_DVC_DVS_ENABLE_SHIFT)
116
117
/* MAX77621_CONTROL1 */
118
#define MAX77621_RAMP_12mV_PER_US 0x0
119
#define MAX77621_RAMP_25mV_PER_US 0x1
120
#define MAX77621_RAMP_50mV_PER_US 0x2
121
#define MAX77621_RAMP_200mV_PER_US 0x3
122
#define MAX77621_RAMP_MASK 0x3
123
124
#define MAX77621_FREQSHIFT_9PER BIT(2)
125
#define MAX77621_BIAS_ENABLE BIT(3)
126
#define MAX77621_AD_ENABLE BIT(4)
127
#define MAX77621_NFSR_ENABLE BIT(5)
128
#define MAX77621_FPWM_EN_M BIT(6)
129
#define MAX77621_SNS_ENABLE BIT(7)
130
131
/* MAX77621_CONTROL2 */
132
#define MAX77621_INDUCTOR_MIN_30_PER 0
133
#define MAX77621_INDUCTOR_NOMINAL 1
134
#define MAX77621_INDUCTOR_PLUS_30_PER 2
135
#define MAX77621_INDUCTOR_PLUS_60_PER 3
136
#define MAX77621_INDUCTOR_MASK 3
137
138
#define MAX77621_CKKADV_TRIP_75mV_PER_US (0 << 2)
139
#define MAX77621_CKKADV_TRIP_150mV_PER_US (1u << 2)
140
#define MAX77621_CKKADV_TRIP_DISABLE (3u << 2)
141
#define MAX77621_CKKADV_TRIP_MASK (3u << 2)
142
143
#define MAX77621_FT_ENABLE BIT(4)
144
#define MAX77621_DISCH_ENABLE BIT(5)
145
#define MAX77621_WDTMR_ENABLE BIT(6)
146
#define MAX77621_T_JUNCTION_120 BIT(7)
147
148
#define MAX77621_CPU_CTRL1_POR_DEFAULT (MAX77621_RAMP_50mV_PER_US)
149
#define MAX77621_CPU_CTRL1_HOS_DEFAULT (MAX77621_AD_ENABLE | \
150
MAX77621_NFSR_ENABLE | \
151
MAX77621_SNS_ENABLE | \
152
MAX77621_RAMP_12mV_PER_US)
153
#define MAX77621_CPU_CTRL2_POR_DEFAULT (MAX77621_T_JUNCTION_120 | \
154
MAX77621_FT_ENABLE | \
155
MAX77621_CKKADV_TRIP_DISABLE | \
156
MAX77621_INDUCTOR_NOMINAL)
157
#define MAX77621_CPU_CTRL2_HOS_DEFAULT (MAX77621_T_JUNCTION_120 | \
158
MAX77621_WDTMR_ENABLE | \
159
MAX77621_CKKADV_TRIP_75mV_PER_US | \
160
MAX77621_INDUCTOR_NOMINAL)
161
162
#define MAX77621_CTRL_HOS_CFG 0
163
#define MAX77621_CTRL_POR_CFG 1
164
165
int max77620_regulator_get_status(u32 id);
166
int max77620_regulator_config_fps(u32 id);
167
int max7762x_regulator_set_voltage(u32 id, u32 uv);
168
int max7762x_regulator_enable(u32 id, bool enable);
169
void max77620_config_gpio(u32 id, bool enable);
170
void max77620_config_default();
171
void max77620_low_battery_monitor_config(bool enable);
172
173
void max77621_config_default(u32 id, bool por);
174
175
#endif
176
177