blob: 9c0035f96bd7b04995387ef4571da2a6727ae3ca [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
12#define NA 0xff
13
14enum {
15 AXP803_CHIP_ID = 0x41,
Samuel Hollande62c5dd2019-10-20 22:23:33 -050016 AXP805_CHIP_ID = 0x40,
Samuel Holland56147892019-10-20 20:50:57 -050017};
18
19struct axp_regulator {
20 const char *dt_name;
21 uint16_t min_volt;
22 uint16_t max_volt;
23 uint16_t step;
24 unsigned char split;
25 unsigned char volt_reg;
26 unsigned char switch_reg;
27 unsigned char switch_bit;
28};
29
30extern const uint8_t axp_chip_id;
31extern const char *const axp_compatible;
32extern const struct axp_regulator axp_regulators[];
33
34/*
35 * Since the PMIC can be connected to multiple bus types,
36 * low-level read/write functions must be provided by the platform
37 */
38int axp_read(uint8_t reg);
39int axp_write(uint8_t reg, uint8_t val);
40int axp_clrsetbits(uint8_t reg, uint8_t clr_mask, uint8_t set_mask);
41#define axp_clrbits(reg, clr_mask) axp_clrsetbits(reg, clr_mask, 0)
42#define axp_setbits(reg, set_mask) axp_clrsetbits(reg, 0, set_mask)
43
44int axp_check_id(void);
45void axp_power_off(void);
46void axp_setup_regulators(const void *fdt);
47
48#endif /* AXP_H */