diff options
| author | Carlo Caione <carlo@caione.org> | 2014-04-11 05:38:10 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2014-04-14 12:00:34 -0400 |
| commit | dfe7a1b058bbb29fa524ca7cf05aa13ff52983f4 (patch) | |
| tree | faf786b045f9b066927ad6ef17ae69181095d7ad | |
| parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff) | |
regulator: AXP20x: Add support for regulators subsystem
AXP202 and AXP209 come with two synchronous step-down DC-DCs and five
LDOs. This patch introduces basic support for those regulators.
Signed-off-by: Carlo Caione <carlo@caione.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
| -rw-r--r-- | drivers/regulator/Kconfig | 7 | ||||
| -rw-r--r-- | drivers/regulator/Makefile | 1 | ||||
| -rw-r--r-- | drivers/regulator/axp20x-regulator.c | 285 |
3 files changed, 293 insertions, 0 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 903eb37f047a..65e5d7d1b35a 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
| @@ -139,6 +139,13 @@ config REGULATOR_AS3722 | |||
| 139 | AS3722 PMIC. This will enable support for all the software | 139 | AS3722 PMIC. This will enable support for all the software |
| 140 | controllable DCDC/LDO regulators. | 140 | controllable DCDC/LDO regulators. |
| 141 | 141 | ||
| 142 | config REGULATOR_AXP20X | ||
| 143 | tristate "X-POWERS AXP20X PMIC Regulators" | ||
| 144 | depends on MFD_AXP20X | ||
| 145 | help | ||
| 146 | This driver provides support for the voltage regulators on the | ||
| 147 | AXP20X PMIC. | ||
| 148 | |||
| 142 | config REGULATOR_BCM590XX | 149 | config REGULATOR_BCM590XX |
| 143 | tristate "Broadcom BCM590xx PMU Regulators" | 150 | tristate "Broadcom BCM590xx PMU Regulators" |
| 144 | depends on MFD_BCM590XX | 151 | depends on MFD_BCM590XX |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 12ef277a48b4..c14696b290c0 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
| @@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o | |||
| 20 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o | 20 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o |
| 21 | obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o | 21 | obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o |
| 22 | obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o | 22 | obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o |
| 23 | obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o | ||
| 23 | obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o | 24 | obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o |
| 24 | obj-$(CONFIG_REGULATOR_DA903X) += da903x.o | 25 | obj-$(CONFIG_REGULATOR_DA903X) += da903x.o |
| 25 | obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o | 26 | obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o |
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c new file mode 100644 index 000000000000..78a29e60f53a --- /dev/null +++ b/drivers/regulator/axp20x-regulator.c | |||
| @@ -0,0 +1,285 @@ | |||
| 1 | /* | ||
| 2 | * AXP20x regulators driver. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Carlo Caione <carlo@caione.org> | ||
| 5 | * | ||
| 6 | * This file is subject to the terms and conditions of the GNU General | ||
| 7 | * Public License. See the file "COPYING" in the main directory of this | ||
| 8 | * archive for more details. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <linux/err.h> | ||
| 17 | #include <linux/init.h> | ||
| 18 | #include <linux/module.h> | ||
| 19 | #include <linux/of.h> | ||
| 20 | #include <linux/of_device.h> | ||
| 21 | #include <linux/platform_device.h> | ||
| 22 | #include <linux/regmap.h> | ||
| 23 | #include <linux/mfd/axp20x.h> | ||
| 24 | #include <linux/regulator/driver.h> | ||
| 25 | #include <linux/regulator/of_regulator.h> | ||
| 26 | |||
| 27 | #define AXP20X_IO_ENABLED 0x03 | ||
| 28 | #define AXP20X_IO_DISABLED 0x07 | ||
| 29 | |||
| 30 | #define AXP20X_WORKMODE_DCDC2_MASK BIT(2) | ||
| 31 | #define AXP20X_WORKMODE_DCDC3_MASK BIT(1) | ||
| 32 | |||
| 33 | #define AXP20X_FREQ_DCDC_MASK 0x0f | ||
| 34 | |||
| 35 | #define AXP20X_DESC_IO(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ | ||
| 36 | _emask, _enable_val, _disable_val) \ | ||
| 37 | [AXP20X_##_id] = { \ | ||
| 38 | .name = #_id, \ | ||
| 39 | .supply_name = (_supply), \ | ||
| 40 | .type = REGULATOR_VOLTAGE, \ | ||
| 41 | .id = AXP20X_##_id, \ | ||
| 42 | .n_voltages = (((_max) - (_min)) / (_step) + 1), \ | ||
| 43 | .owner = THIS_MODULE, \ | ||
| 44 | .min_uV = (_min) * 1000, \ | ||
| 45 | .uV_step = (_step) * 1000, \ | ||
| 46 | .vsel_reg = (_vreg), \ | ||
| 47 | .vsel_mask = (_vmask), \ | ||
| 48 | .enable_reg = (_ereg), \ | ||
| 49 | .enable_mask = (_emask), \ | ||
| 50 | .enable_val = (_enable_val), \ | ||
| 51 | .disable_val = (_disable_val), \ | ||
| 52 | .ops = &axp20x_ops, \ | ||
| 53 | } | ||
| 54 | |||
| 55 | #define AXP20X_DESC(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ | ||
| 56 | _emask) \ | ||
| 57 | [AXP20X_##_id] = { \ | ||
| 58 | .name = #_id, \ | ||
| 59 | .supply_name = (_supply), \ | ||
| 60 | .type = REGULATOR_VOLTAGE, \ | ||
| 61 | .id = AXP20X_##_id, \ | ||
| 62 | .n_voltages = (((_max) - (_min)) / (_step) + 1), \ | ||
| 63 | .owner = THIS_MODULE, \ | ||
| 64 | .min_uV = (_min) * 1000, \ | ||
| 65 | .uV_step = (_step) * 1000, \ | ||
| 66 | .vsel_reg = (_vreg), \ | ||
| 67 | .vsel_mask = (_vmask), \ | ||
| 68 | .enable_reg = (_ereg), \ | ||
| 69 | .enable_mask = (_emask), \ | ||
| 70 | .ops = &axp20x_ops, \ | ||
| 71 | } | ||
| 72 | |||
| 73 | #define AXP20X_DESC_FIXED(_id, _supply, _volt) \ | ||
| 74 | [AXP20X_##_id] = { \ | ||
| 75 | .name = #_id, \ | ||
| 76 | .supply_name = (_supply), \ | ||
| 77 | .type = REGULATOR_VOLTAGE, \ | ||
| 78 | .id = AXP20X_##_id, \ | ||
| 79 | .n_voltages = 1, \ | ||
| 80 | .owner = THIS_MODULE, \ | ||
| 81 | .min_uV = (_volt) * 1000, \ | ||
| 82 | .ops = &axp20x_ops_fixed \ | ||
| 83 | } | ||
| 84 | |||
| 85 | #define AXP20X_DESC_TABLE(_id, _supply, _table, _vreg, _vmask, _ereg, _emask) \ | ||
| 86 | [AXP20X_##_id] = { \ | ||
| 87 | .name = #_id, \ | ||
| 88 | .supply_name = (_supply), \ | ||
| 89 | .type = REGULATOR_VOLTAGE, \ | ||
| 90 | .id = AXP20X_##_id, \ | ||
| 91 | .n_voltages = ARRAY_SIZE(_table), \ | ||
| 92 | .owner = THIS_MODULE, \ | ||
| 93 | .vsel_reg = (_vreg), \ | ||
| 94 | .vsel_mask = (_vmask), \ | ||
| 95 | .enable_reg = (_ereg), \ | ||
| 96 | .enable_mask = (_emask), \ | ||
| 97 | .volt_table = (_table), \ | ||
| 98 | .ops = &axp20x_ops_table, \ | ||
| 99 | } | ||
| 100 | |||
| 101 | static const int axp20x_ldo4_data[] = { 1250000, 1300000, 1400000, 1500000, 1600000, | ||
| 102 | 1700000, 1800000, 1900000, 2000000, 2500000, | ||
| 103 | 2700000, 2800000, 3000000, 3100000, 3200000, | ||
| 104 | 3300000 }; | ||
| 105 | |||
| 106 | static struct regulator_ops axp20x_ops_fixed = { | ||
| 107 | .list_voltage = regulator_list_voltage_linear, | ||
| 108 | }; | ||
| 109 | |||
| 110 | static struct regulator_ops axp20x_ops_table = { | ||
| 111 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
| 112 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
| 113 | .list_voltage = regulator_list_voltage_table, | ||
| 114 | .enable = regulator_enable_regmap, | ||
| 115 | .disable = regulator_disable_regmap, | ||
| 116 | .is_enabled = regulator_is_enabled_regmap, | ||
| 117 | }; | ||
| 118 | |||
| 119 | static struct regulator_ops axp20x_ops = { | ||
| 120 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
| 121 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
| 122 | .list_voltage = regulator_list_voltage_linear, | ||
| 123 | .enable = regulator_enable_regmap, | ||
| 124 | .disable = regulator_disable_regmap, | ||
| 125 | .is_enabled = regulator_is_enabled_regmap, | ||
| 126 | }; | ||
| 127 | |||
| 128 | static const struct regulator_desc axp20x_regulators[] = { | ||
| 129 | AXP20X_DESC(DCDC2, "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT, 0x3f, | ||
| 130 | AXP20X_PWR_OUT_CTRL, 0x10), | ||
| 131 | AXP20X_DESC(DCDC3, "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT, 0x7f, | ||
| 132 | AXP20X_PWR_OUT_CTRL, 0x02), | ||
| 133 | AXP20X_DESC_FIXED(LDO1, "acin", 1300), | ||
| 134 | AXP20X_DESC(LDO2, "ldo24in", 1800, 3300, 100, AXP20X_LDO24_V_OUT, 0xf0, | ||
| 135 | AXP20X_PWR_OUT_CTRL, 0x04), | ||
| 136 | AXP20X_DESC(LDO3, "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT, 0x7f, | ||
| 137 | AXP20X_PWR_OUT_CTRL, 0x40), | ||
| 138 | AXP20X_DESC_TABLE(LDO4, "ldo24in", axp20x_ldo4_data, AXP20X_LDO24_V_OUT, 0x0f, | ||
| 139 | AXP20X_PWR_OUT_CTRL, 0x08), | ||
| 140 | AXP20X_DESC_IO(LDO5, "ldo5in", 1800, 3300, 100, AXP20X_LDO5_V_OUT, 0xf0, | ||
| 141 | AXP20X_GPIO0_CTRL, 0x07, AXP20X_IO_ENABLED, | ||
| 142 | AXP20X_IO_DISABLED), | ||
| 143 | }; | ||
| 144 | |||
