summaryrefslogtreecommitdiff
path: root/bsp/allwinner/libraries/sunxi-hal/hal/source/regulator/axp2101.c
blob: 644ef2e610a7f18b7dd02f4b9a663a1afd0e3c75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Copyright (C) 2020 allwinnertech Ltd.
 */

#include <sunxi_hal_regulator.h>
#include <sunxi_hal_regulator_private.h>
#include <type.h>

#define AXP2101_DCDC_CFG0       (0x80)
#define AXP2101_DCDC1_CFG       (0x82)
#define AXP2101_DCDC2_CFG       (0x83)
#define AXP2101_DCDC3_CFG       (0x84)
#define AXP2101_DCDC4_CFG       (0x85)
#define AXP2101_DCDC5_CFG       (0x86)
#define AXP2101_LDO_EN_CFG0     (0x90)
#define AXP2101_LDO_EN_CFG1     (0x91)
#define AXP2101_ALDO1_CFG       (0x92)
#define AXP2101_ALDO2_CFG       (0x93)
#define AXP2101_ALDO3_CFG       (0x94)
#define AXP2101_ALDO4_CFG       (0x95)
#define AXP2101_BLDO1_CFG       (0x96)
#define AXP2101_BLDO2_CFG       (0x97)
#define AXP2101_CPUSLD_CFG      (0x98)
#define AXP2101_DLDO1_CFG       (0x99)
#define AXP2101_DLDO2_CFG       (0x9A)

static const struct regulator_linear_range axp2101_dcdc2_ranges[] = {
    REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
    REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x57, 20000),
};

static const struct regulator_linear_range axp2101_dcdc3_ranges[] = {
    REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
    REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x57, 20000),
    REGULATOR_LINEAR_RANGE(1600000, 0x58, 0x6a, 100000),
};

static const struct regulator_linear_range axp2101_dcdc4_ranges[] = {
    REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
    REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x66, 20000),
};

static const struct regulator_linear_range axp2101_dcdc5_ranges[] = {
    REGULATOR_LINEAR_RANGE(1400000, 0x0, 0x17, 100000),
    REGULATOR_LINEAR_RANGE(1200000, 0x19, 0x19, 0),
};

const struct regulator_desc axp2101_regulators[] = {
    AXP_DESC(1500, 3400, 100, AXP2101_DCDC1_CFG, 0x1f,
         AXP2101_DCDC_CFG0, BIT(0)),
    AXP_DESC_RANGES(axp2101_dcdc2_ranges, AXP2101_DCDC2_CFG, 0x7f,
            AXP2101_DCDC_CFG0, BIT(1)),
    AXP_DESC_RANGES(axp2101_dcdc3_ranges, AXP2101_DCDC3_CFG, 0x7f,
            AXP2101_DCDC_CFG0, BIT(2)),
    AXP_DESC_RANGES(axp2101_dcdc4_ranges, AXP2101_DCDC4_CFG, 0x7f,
            AXP2101_DCDC_CFG0, BIT(3)),
    AXP_DESC_RANGES(axp2101_dcdc5_ranges, AXP2101_DCDC5_CFG, 0x1f,
            AXP2101_DCDC_CFG0, BIT(4)),
    AXP_DESC(500, 3500, 100, AXP2101_ALDO1_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(0)),
    AXP_DESC(500, 3500, 100, AXP2101_ALDO2_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(1)),
    AXP_DESC(500, 3500, 100, AXP2101_ALDO3_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(2)),
    AXP_DESC(500, 3500, 100, AXP2101_ALDO4_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(3)),
    AXP_DESC(500, 3500, 100, AXP2101_BLDO1_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(4)),
    AXP_DESC(500, 3500, 100, AXP2101_BLDO2_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(5)),
    AXP_DESC(500, 3500, 100, AXP2101_DLDO1_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(7)),
    AXP_DESC(500, 1400, 50, AXP2101_DLDO2_CFG, 0x1f, AXP2101_LDO_EN_CFG1,
         BIT(0)),
    AXP_DESC(500, 1400, 50, AXP2101_CPUSLD_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
         BIT(6)),
};