xref: /rk3399_ARM-atf/include/drivers/allwinner/axp.h (revision 0bc752c9adedbda4434fddf68d3bc18c5274360b)
1*0bc752c9SSamuel Holland /*
2*0bc752c9SSamuel Holland  * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
3*0bc752c9SSamuel Holland  *
4*0bc752c9SSamuel Holland  * SPDX-License-Identifier: BSD-3-Clause
5*0bc752c9SSamuel Holland  */
6*0bc752c9SSamuel Holland 
7*0bc752c9SSamuel Holland #ifndef AXP_H
8*0bc752c9SSamuel Holland #define AXP_H
9*0bc752c9SSamuel Holland 
10*0bc752c9SSamuel Holland #include <stdint.h>
11*0bc752c9SSamuel Holland 
12*0bc752c9SSamuel Holland #define NA 0xff
13*0bc752c9SSamuel Holland 
14*0bc752c9SSamuel Holland enum {
15*0bc752c9SSamuel Holland 	AXP803_CHIP_ID = 0x41,
16*0bc752c9SSamuel Holland };
17*0bc752c9SSamuel Holland 
18*0bc752c9SSamuel Holland struct axp_regulator {
19*0bc752c9SSamuel Holland 	const char *dt_name;
20*0bc752c9SSamuel Holland 	uint16_t min_volt;
21*0bc752c9SSamuel Holland 	uint16_t max_volt;
22*0bc752c9SSamuel Holland 	uint16_t step;
23*0bc752c9SSamuel Holland 	unsigned char split;
24*0bc752c9SSamuel Holland 	unsigned char volt_reg;
25*0bc752c9SSamuel Holland 	unsigned char switch_reg;
26*0bc752c9SSamuel Holland 	unsigned char switch_bit;
27*0bc752c9SSamuel Holland };
28*0bc752c9SSamuel Holland 
29*0bc752c9SSamuel Holland extern const uint8_t axp_chip_id;
30*0bc752c9SSamuel Holland extern const char *const axp_compatible;
31*0bc752c9SSamuel Holland extern const struct axp_regulator axp_regulators[];
32*0bc752c9SSamuel Holland 
33*0bc752c9SSamuel Holland /*
34*0bc752c9SSamuel Holland  * Since the PMIC can be connected to multiple bus types,
35*0bc752c9SSamuel Holland  * low-level read/write functions must be provided by the platform
36*0bc752c9SSamuel Holland  */
37*0bc752c9SSamuel Holland int axp_read(uint8_t reg);
38*0bc752c9SSamuel Holland int axp_write(uint8_t reg, uint8_t val);
39*0bc752c9SSamuel Holland int axp_clrsetbits(uint8_t reg, uint8_t clr_mask, uint8_t set_mask);
40*0bc752c9SSamuel Holland #define axp_clrbits(reg, clr_mask) axp_clrsetbits(reg, clr_mask, 0)
41*0bc752c9SSamuel Holland #define axp_setbits(reg, set_mask) axp_clrsetbits(reg, 0, set_mask)
42*0bc752c9SSamuel Holland 
43*0bc752c9SSamuel Holland int axp_check_id(void);
44*0bc752c9SSamuel Holland void axp_power_off(void);
45*0bc752c9SSamuel Holland void axp_setup_regulators(const void *fdt);
46*0bc752c9SSamuel Holland 
47*0bc752c9SSamuel Holland #endif /* AXP_H */
48