summaryrefslogtreecommitdiff
path: root/firmware/export/axp192.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/axp192.h')
-rw-r--r--firmware/export/axp192.h131
1 files changed, 0 insertions, 131 deletions
diff --git a/firmware/export/axp192.h b/firmware/export/axp192.h
deleted file mode 100644
index 6ed278d086..0000000000
--- a/firmware/export/axp192.h
+++ /dev/null
@@ -1,131 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __AXP192_H__
23#define __AXP192_H__
24
25#include <stdint.h>
26#include <stdbool.h>
27
28enum {
29#define DEFREG(regname, addr) AXP_REG_##regname = addr,
30#include "axp192-defs.h"
31};
32
33enum {
34#define DEFFLD(regname, fldname, msb, lsb, ...) \
35 BM_AXP_##regname##_##fldname = ((1 << ((msb) - (lsb) + 1)) - 1) << lsb, \
36 BP_AXP_##regname##_##fldname = lsb,
37#include "axp192-defs.h"
38};
39
40enum {
41 AXP_SUPPLY_EXTEN,
42 AXP_SUPPLY_DCDC1,
43 AXP_SUPPLY_DCDC2,
44 AXP_SUPPLY_DCDC3,
45 AXP_SUPPLY_LDO2,
46 AXP_SUPPLY_LDO3,
47 AXP_SUPPLY_LDOIO0,
48 AXP_NUM_SUPPLIES,
49};
50
51enum {
52 AXP_ADC_ACIN_VOLTAGE,
53 AXP_ADC_ACIN_CURRENT,
54 AXP_ADC_VBUS_VOLTAGE,
55 AXP_ADC_VBUS_CURRENT,
56 AXP_ADC_INTERNAL_TEMP,
57 AXP_ADC_TS_INPUT,
58 AXP_ADC_GPIO0,
59 AXP_ADC_GPIO1,
60 AXP_ADC_GPIO2,
61 AXP_ADC_GPIO3,
62 AXP_ADC_BATTERY_VOLTAGE,
63 AXP_ADC_CHARGE_CURRENT,
64 AXP_ADC_DISCHARGE_CURRENT,
65 AXP_ADC_APS_VOLTAGE,
66 AXP_NUM_ADCS,
67};
68
69enum {
70 AXP_GPIO_OPEN_DRAIN_OUTPUT = 0x0,
71 AXP_GPIO_INPUT = 0x1,
72 AXP_GPIO_SPECIAL = 0x2,
73 AXP_GPIO_ADC_IN = 0x4,
74 AXP_GPIO_LOW_OUTPUT = 0x5,
75 AXP_GPIO_FLOATING = 0x7,
76};
77
78enum {
79 /* Limit USB current consumption to 100 mA. */
80 AXP_VBUS_LIMIT_100mA = (1 << BP_AXP_VBUSIPSOUT_VHOLD_LIM) |
81 (1 << BP_AXP_VBUSIPSOUT_VBUS_LIM) |
82 (1 << BP_AXP_VBUSIPSOUT_LIM_100mA),
83
84 /* Limit USB current consumption to 500 mA. */
85 AXP_VBUS_LIMIT_500mA = (1 << BP_AXP_VBUSIPSOUT_VHOLD_LIM) |
86 (1 << BP_AXP_VBUSIPSOUT_VBUS_LIM) |
87 (0 << BP_AXP_VBUSIPSOUT_LIM_100mA),
88
89 /* No upper bound on USB current, but the current will still
90 * be reduced to maintain the bus voltage above V_hold. */
91 AXP_VBUS_UNLIMITED = (1 << BP_AXP_VBUSIPSOUT_VHOLD_LIM) |
92 (0 << BP_AXP_VBUSIPSOUT_VBUS_LIM) |
93 (0 << BP_AXP_VBUSIPSOUT_LIM_100mA),
94
95 /* Unlimited USB current consumption. Voltage is allowed to drop
96 * below V_hold, which may interfere with normal USB operation.
97 * This mode is really only useful with AC charging adapters. */
98 AXP_VBUS_FULLY_UNLIMITED = (0 << BP_AXP_VBUSIPSOUT_VHOLD_LIM) |
99 (0 << BP_AXP_VBUSIPSOUT_VBUS_LIM) |
100 (0 << BP_AXP_VBUSIPSOUT_LIM_100mA),
101};
102
103extern int axp_read(uint8_t reg);
104extern int axp_write(uint8_t reg, uint8_t value);
105extern int axp_modify(uint8_t reg, uint8_t clr, uint8_t set);
106
107extern void axp_enable_supply(int supply, bool enable);
108extern void axp_set_enabled_supplies(unsigned int supply_mask);
109extern void axp_set_supply_voltage(int supply, int output_mV);
110
111extern void axp_enable_adc(int adc, bool enable);
112extern void axp_set_enabled_adcs(unsigned int adc_mask);
113extern int axp_read_adc_raw(int adc);
114extern int axp_conv_adc(int adc, int value);
115extern int axp_read_adc(int adc);
116
117extern void axp_set_gpio_function(int gpio, int function);
118extern void axp_set_gpio_pulldown(int gpio, bool enable);
119extern int axp_get_gpio(int gpio);
120extern void axp_set_gpio(int gpio, bool enable);
121
122extern void axp_set_charge_current(int current_mA);
123extern int axp_get_charge_current(void);
124extern void axp_set_vbus_limit(int vbus_limit);
125extern void axp_set_vhold_level(int vhold_mV);
126extern bool axp_is_charging(void);
127extern unsigned int axp_power_input_status(void);
128
129extern void axp_power_off(void);
130
131#endif /* __AXP192_H__ */