blob: 8b90c7f0c224cacf8823fdd30d4f68d44ebed270 [file] [log] [blame]
Samuel Holland56147892019-10-20 20:50:57 -05001/*
2 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef AXP_H
8#define AXP_H
9
10#include <stdint.h>
11
Samuel Holland2d47ab22020-12-13 22:43:15 -060012#define AXP20X_MODE_REG 0x3e
13#define AXP20X_MODE_I2C 0x00
14#define AXP20X_MODE_RSB 0x7c
15
Samuel Holland56147892019-10-20 20:50:57 -050016#define NA 0xff
17
18enum {
19 AXP803_CHIP_ID = 0x41,
Samuel Hollande62c5dd2019-10-20 22:23:33 -050020 AXP805_CHIP_ID = 0x40,
Samuel Holland56147892019-10-20 20:50:57 -050021};
22
23struct axp_regulator {
24 const char *dt_name;
25 uint16_t min_volt;
26 uint16_t max_volt;
27 uint16_t step;
28 unsigned char split;
29 unsigned char volt_reg;
30 unsigned char switch_reg;
31 unsigned char switch_bit;
32};
33
34extern const uint8_t axp_chip_id;
35extern const char *const axp_compatible;
36extern const struct axp_regulator axp_regulators[];
37
38/*
39 * Since the PMIC can be connected to multiple bus types,
40 * low-level read/write functions must be provided by the platform
41 */
42int axp_read(uint8_t reg);
43int axp_write(uint8_t reg, uint8_t val);
44int axp_clrsetbits(uint8_t reg, uint8_t clr_mask, uint8_t set_mask);
45#define axp_clrbits(reg, clr_mask) axp_clrsetbits(reg, clr_mask, 0)
46#define axp_setbits(reg, set_mask) axp_clrsetbits(reg, 0, set_mask)
47
48int axp_check_id(void);
49void axp_power_off(void);
Andre Przywara71b5a1d2021-11-01 00:17:37 +000050
51#if SUNXI_SETUP_REGULATORS == 1
Samuel Holland56147892019-10-20 20:50:57 -050052void axp_setup_regulators(const void *fdt);
Andre Przywara71b5a1d2021-11-01 00:17:37 +000053#else
54static inline void axp_setup_regulators(const void *fdt)
55{
56}
57#endif
Samuel Holland56147892019-10-20 20:50:57 -050058
59#endif /* AXP_H */