summaryrefslogtreecommitdiffstats
path: root/src/soc/mediatek/mt8195/include/soc/mt6360.h
blob: 0c5edff46e3079a84f421d8c037bfb9e3db0e580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef __SOC_MEDIATEK_MT8195_MT6360_H__
#define __SOC_MEDIATEK_MT8195_MT6360_H__

#include <stdint.h>

#define MT6360_LDO_I2C_ADDR	0x64
#define MT6360_PMIC_I2C_ADDR	0x1a

#define MT6360_DATA(_enreg, _enmask, _vreg, _vmask, _table)	\
{								\
	.enable_reg = _enreg,					\
	.enable_mask = _enmask,					\
	.vsel_reg = _vreg,					\
	.vsel_mask = _vmask,					\
	.vsel_table = _table,					\
	.vsel_table_len = ARRAY_SIZE(_table),			\
}

enum {
	MT6360_INDEX_LDO = 0,
	MT6360_INDEX_PMIC,
	MT6360_INDEX_COUNT,
};

/*
 * This must match the regulator IDs defined in EC's BC1.2 MT6360 driver.
 * Please do NOT change the order.
 */
enum mt6360_regulator_id {
	MT6360_LDO3 = 0,
	MT6360_LDO5,
	MT6360_LDO6,
	MT6360_LDO7,
	MT6360_BUCK1,
	MT6360_BUCK2,
	MT6360_LDO1,
	MT6360_LDO2,
	MT6360_REGULATOR_COUNT,
};

struct mt6360_i2c_data {
	u8 bus;
	u8 addr;
};

struct mt6360_data {
	uint8_t enable_reg;
	uint8_t enable_mask;
	uint8_t vsel_reg;
	uint8_t vsel_mask;
	const uint32_t *vsel_table;
	uint32_t vsel_table_len;
};

void mt6360_init(uint8_t bus);
void mt6360_enable(enum mt6360_regulator_id id, uint8_t enable);
uint8_t mt6360_is_enabled(enum mt6360_regulator_id id);
void mt6360_set_voltage(enum mt6360_regulator_id id, u32 voltage_uv);
u32 mt6360_get_voltage(enum mt6360_regulator_id id);

#endif