xref: /rk3399_ARM-atf/include/drivers/allwinner/axp.h (revision f6d9c4cafa6a74f29f7b305a71ef122d470ed03c)
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,
16f6d9c4caSSamuel Holland 	AXP805_CHIP_ID = 0x40,
17*0bc752c9SSamuel Holland };
18*0bc752c9SSamuel Holland 
19*0bc752c9SSamuel Holland struct axp_regulator {
20*0bc752c9SSamuel Holland 	const char *dt_name;
21*0bc752c9SSamuel Holland 	uint16_t min_volt;
22*0bc752c9SSamuel Holland 	uint16_t max_volt;
23*0bc752c9SSamuel Holland 	uint16_t step;
24*0bc752c9SSamuel Holland 	unsigned char split;
25*0bc752c9SSamuel Holland 	unsigned char volt_reg;
26*0bc752c9SSamuel Holland 	unsigned char switch_reg;
27*0bc752c9SSamuel Holland 	unsigned char switch_bit;
28*0bc752c9SSamuel Holland };
29*0bc752c9SSamuel Holland 
30*0bc752c9SSamuel Holland extern const uint8_t axp_chip_id;
31*0bc752c9SSamuel Holland extern const char *const axp_compatible;
32*0bc752c9SSamuel Holland extern const struct axp_regulator axp_regulators[];
33*0bc752c9SSamuel Holland 
34*0bc752c9SSamuel Holland /*
35*0bc752c9SSamuel Holland  * Since the PMIC can be connected to multiple bus types,
36*0bc752c9SSamuel Holland  * low-level read/write functions must be provided by the platform
37*0bc752c9SSamuel Holland  */
38*0bc752c9SSamuel Holland int axp_read(uint8_t reg);
39*0bc752c9SSamuel Holland int axp_write(uint8_t reg, uint8_t val);
40*0bc752c9SSamuel Holland int axp_clrsetbits(uint8_t reg, uint8_t clr_mask, uint8_t set_mask);
41*0bc752c9SSamuel Holland #define axp_clrbits(reg, clr_mask) axp_clrsetbits(reg, clr_mask, 0)
42*0bc752c9SSamuel Holland #define axp_setbits(reg, set_mask) axp_clrsetbits(reg, 0, set_mask)
43*0bc752c9SSamuel Holland 
44*0bc752c9SSamuel Holland int axp_check_id(void);
45*0bc752c9SSamuel Holland void axp_power_off(void);
46*0bc752c9SSamuel Holland void axp_setup_regulators(const void *fdt);
47*0bc752c9SSamuel Holland 
48*0bc752c9SSamuel Holland #endif /* AXP_H */
49