diff options
| author | Axel Lin <axel.lin@gmail.com> | 2010-09-16 04:48:49 -0400 |
|---|---|---|
| committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-10-28 17:40:31 -0400 |
| commit | 5976f0959d5251ae5b4db848eaa2f42a19e98652 (patch) | |
| tree | ee8396999d0b037a72bc5b8b8e5c8f18e10c0d49 | |
| parent | 202f4f53e503ae09b431459131b5b3a99fa6d839 (diff) | |
Regulator: LP3972 PMIC regulator driver
This patch adds regulator drivers for National Semiconductors LP3972 PMIC.
This LP3972 PMIC controller has 3 DC/DC voltage converters and 5 low drop-out
(LDO) regulators. LP3972 PMIC controller uses I2C interface.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
| -rw-r--r-- | drivers/regulator/Kconfig | 7 | ||||
| -rw-r--r-- | drivers/regulator/Makefile | 1 | ||||
| -rw-r--r-- | drivers/regulator/lp3972.c | 649 | ||||
| -rw-r--r-- | include/linux/regulator/lp3972.h | 48 |
4 files changed, 705 insertions, 0 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 4889caabc632..dd30e883d4a7 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
| @@ -172,6 +172,13 @@ config REGULATOR_LP3971 | |||
| 172 | Say Y here to support the voltage regulators and convertors | 172 | Say Y here to support the voltage regulators and convertors |
| 173 | on National Semiconductors LP3971 PMIC | 173 | on National Semiconductors LP3971 PMIC |
| 174 | 174 | ||
| 175 | config REGULATOR_LP3972 | ||
| 176 | tristate "National Semiconductors LP3972 PMIC regulator driver" | ||
| 177 | depends on I2C | ||
| 178 | help | ||
| 179 | Say Y here to support the voltage regulators and convertors | ||
| 180 | on National Semiconductors LP3972 PMIC | ||
| 181 | |||
| 175 | config REGULATOR_PCAP | 182 | config REGULATOR_PCAP |
| 176 | tristate "PCAP2 regulator driver" | 183 | tristate "PCAP2 regulator driver" |
| 177 | depends on EZX_PCAP | 184 | depends on EZX_PCAP |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index beff6da6eff6..6cae6419b8b1 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
| @@ -12,6 +12,7 @@ obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o | |||
| 12 | obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o | 12 | obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o |
| 13 | obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o | 13 | obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o |
| 14 | obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o | 14 | obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o |
| 15 | obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o | ||
| 15 | obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o | 16 | obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o |
| 16 | obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o | 17 | obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o |
| 17 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o | 18 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o |
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c new file mode 100644 index 000000000000..0d9b47569c1b --- /dev/null +++ b/drivers/regulator/lp3972.c | |||
| @@ -0,0 +1,649 @@ | |||
| 1 | /* | ||
| 2 | * Regulator driver for National Semiconductors LP3972 PMIC chip | ||
| 3 | * | ||
| 4 | * Based on lp3971.c | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/bug.h> | ||
| 13 | #include <linux/err.h> | ||
| 14 | #include <linux/i2c.h> | ||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/regulator/driver.h> | ||
| 17 | #include <linux/regulator/lp3972.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | |||
| 20 | struct lp3972 { | ||
| 21 | struct device *dev; | ||
| 22 | struct mutex io_lock; | ||
| 23 | struct i2c_client *i2c; | ||
| 24 | int num_regulators; | ||
| 25 | struct regulator_dev **rdev; | ||
| 26 | }; | ||
| 27 | |||
| 28 | /* LP3972 Control Registers */ | ||
| 29 | #define LP3972_SCR_REG 0x07 | ||
| 30 | #define LP3972_OVER1_REG 0x10 | ||
| 31 | #define LP3972_OVSR1_REG 0x11 | ||
| 32 | #define LP3972_OVER2_REG 0x12 | ||
| 33 | #define LP3972_OVSR2_REG 0x13 | ||
| 34 | #define LP3972_VCC1_REG 0x20 | ||
| 35 | #define LP3972_ADTV1_REG 0x23 | ||
| 36 | #define LP3972_ADTV2_REG 0x24 | ||
| 37 | #define LP3972_AVRC_REG 0x25 | ||
| 38 | #define LP3972_CDTC1_REG 0x26 | ||
| 39 | #define LP3972_CDTC2_REG 0x27 | ||
| 40 | #define LP3972_SDTV1_REG 0x29 | ||
| 41 | #define LP3972_SDTV2_REG 0x2A | ||
| 42 | #define LP3972_MDTV1_REG 0x32 | ||
| 43 | #define LP3972_MDTV2_REG 0x33 | ||
| 44 | #define LP3972_L2VCR_REG 0x39 | ||
| 45 | #define LP3972_L34VCR_REG 0x3A | ||
| 46 | #define LP3972_SCR1_REG 0x80 | ||
| 47 | #define LP3972_SCR2_REG 0x81 | ||
| 48 | #define LP3972_OEN3_REG 0x82 | ||
| 49 | #define LP3972_OSR3_REG 0x83 | ||
| 50 | #define LP3972_LOER4_REG 0x84 | ||
| 51 | #define LP3972_B2TV_REG 0x85 | ||
| 52 | #define LP3972_B3TV_REG 0x86 | ||
| 53 | #define LP3972_B32RC_REG 0x87 | ||
| 54 | #define LP3972_ISRA_REG 0x88 | ||
| 55 | #define LP3972_BCCR_REG 0x89 | ||
| 56 | #define LP3972_II1RR_REG 0x8E | ||
| 57 | #define LP3972_II2RR_REG 0x8F | ||
| 58 | |||
| 59 | #define LP3972_SYS_CONTROL1_REG LP3972_SCR1_REG | ||
| 60 | /* System control register 1 initial value, | ||
| 61 | * bits 5, 6 and 7 are EPROM programmable */ | ||
| 62 | #define SYS_CONTROL1_INIT_VAL 0x02 | ||
| 63 | #define SYS_CONTROL1_INIT_MASK 0x1F | ||
| 64 | |||
| 65 | #define LP3972_VOL_CHANGE_REG LP3972_VCC1_REG | ||
| 66 | #define LP3972_VOL_CHANGE_FLAG_GO 0x01 | ||
| 67 | #define LP3972_VOL_CHANGE_FLAG_MASK 0x03 | ||
| 68 | |||
| 69 | /* LDO output enable mask */ | ||
| 70 | #define LP3972_OEN3_L1EN BIT(0) | ||
| 71 | #define LP3972_OVER2_LDO2_EN BIT(2) | ||
| 72 | #define LP3972_OVER2_LDO3_EN BIT(3) | ||
| 73 | #define LP3972_OVER2_LDO4_EN BIT(4) | ||
| 74 | #define LP3972_OVER1_S_EN BIT(2) | ||
| 75 | |||
| 76 | static const int ldo1_voltage_map[] = { | ||
| 77 | 1700, 1725, 1750, 1775, 1800, 1825, 1850, 1875, | ||
| 78 | 1900, 1925, 1950, 1975, 2000, | ||
| 79 | }; | ||
| 80 | |||
| 81 | static const int ldo23_voltage_map[] = { | ||
| 82 | 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, | ||
| 83 | 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, | ||
| 84 | }; | ||
| 85 | |||
| 86 | static const int ldo4_voltage_map[] = { | ||
| 87 | 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, | ||
| 88 | 1400, 1500, 1800, 1900, 2500, 2800, 3000, 3300, | ||
| 89 | }; | ||
| 90 | |||
| 91 | static const int ldo5_voltage_map[] = { | ||
| 92 | 0, 0, 0, 0, 0, 850, 875, 900, | ||
| 93 | 925, 950, 975, 1000, 1025, 1050, 1075, 1100, | ||
| 94 | 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300, | ||
| 95 | 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500, | ||
| 96 | }; | ||
| 97 | |||
| 98 | static const int buck1_voltage_map[] = { | ||
| 99 | 725, 750, 775, 800, 825, 850, 875, 900, | ||
| 100 | 925, 950, 975, 1000, 1025, 1050, 1075, 1100, | ||
| 101 | 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300, | ||
| 102 | 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500, | ||
| 103 | }; | ||
| 104 | |||
| 105 | static const int buck23_voltage_map[] = { | ||
| 106 | 0, 800, 850, 900, 950, 1000, 1050, 1100, | ||
| 107 | 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500, | ||
| 108 | 1550, 1600, 1650, 1700, 1800, 1900, 2500, 2800, | ||
| 109 | 3000, 3300, | ||
| 110 | }; | ||
| 111 | |||
| 112 | static const int *ldo_voltage_map[] = { | ||
| 113 | ldo1_voltage_map, | ||
| 114 | ldo23_voltage_map, | ||
| 115 | ldo23_voltage_map, | ||
| 116 | ldo4_voltage_map, | ||
| 117 | ldo5_voltage_map, | ||
| 118 | }; | ||
| 119 | |||
| 120 | static const int *buck_voltage_map[] = { | ||
| 121 | buck1_voltage_map, | ||
| 122 | buck23_voltage_map, | ||
| 123 | buck23_voltage_map, | ||
| 124 | }; | ||
| 125 | |||
| 126 | static const int ldo_output_enable_mask[] = { | ||
| 127 | LP3972_OEN3_L1EN, | ||
| 128 | LP3972_OVER2_LDO2_EN, | ||
| 129 | LP3972_OVER2_LDO3_EN, | ||
| 130 | LP3972_OVER2_LDO4_EN, | ||
| 131 | LP3972_OVER1_S_EN, | ||
| 132 | }; | ||
| 133 | |||
| 134 | static const int ldo_output_enable_addr[] = { | ||
| 135 | LP3972_OEN3_REG, | ||
| 136 | LP3972_OVER2_REG, | ||
| 137 | LP3972_OVER2_REG, | ||
| 138 | LP3972_OVER2_REG, | ||
| 139 | LP3972_OVER1_REG, | ||
| 140 | }; | ||
| 141 | |||
| 142 | static const int ldo_vol_ctl_addr[] = { | ||
| 143 | LP3972_MDTV1_REG, | ||
| 144 | LP3972_L2VCR_REG, | ||
| 145 | LP3972_L34VCR_REG, | ||
| 146 | LP3972_L34VCR_REG, | ||
| 147 | LP3972_SDTV1_REG, | ||
| 148 | }; | ||
| 149 | |||
| 150 | static const int buck_vol_enable_addr[] = { | ||
| 151 | LP3972_OVER1_REG, | ||
| 152 | LP3972_OEN3_REG, | ||
| 153 | LP3972_OEN3_REG, | ||
| 154 | }; | ||
| 155 | |||
| 156 | static const int buck_base_addr[] = { | ||
| 157 | LP3972_ADTV1_REG, | ||
| 158 | LP3972_B2TV_REG, | ||
| 159 | LP3972_B3TV_REG, | ||
| 160 | }; | ||
| 161 | |||
| 162 | |||
