Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) ST-Ericsson SA 2010 |
| 3 | * |
| 4 | * License Terms: GNU General Public License v2 |
| 5 | * |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 6 | * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson |
| 7 | * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 8 | * |
| 9 | * AB8500 peripheral regulators |
| 10 | * |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 11 | * AB8500 supports the following regulators: |
Bengt Jonsson | ea05ef3 | 2011-03-10 14:43:31 +0100 | [diff] [blame] | 12 | * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 13 | */ |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/kernel.h> |
Paul Gortmaker | 65602c3 | 2011-07-17 16:28:23 -0400 | [diff] [blame] | 16 | #include <linux/module.h> |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 17 | #include <linux/err.h> |
| 18 | #include <linux/platform_device.h> |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 19 | #include <linux/mfd/abx500.h> |
Linus Walleij | ee66e65 | 2011-12-02 14:16:33 +0100 | [diff] [blame] | 20 | #include <linux/mfd/abx500/ab8500.h> |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 21 | #include <linux/of.h> |
| 22 | #include <linux/regulator/of_regulator.h> |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 23 | #include <linux/regulator/driver.h> |
| 24 | #include <linux/regulator/machine.h> |
| 25 | #include <linux/regulator/ab8500.h> |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 26 | #include <linux/slab.h> |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * struct ab8500_regulator_info - ab8500 regulator information |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 30 | * @dev: device pointer |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 31 | * @desc: regulator description |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 32 | * @regulator_dev: regulator device |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 33 | * @update_bank: bank to control on/off |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 34 | * @update_reg: register to control on/off |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 35 | * @update_mask: mask to enable/disable regulator |
| 36 | * @update_val_enable: bits to enable the regulator in normal (high power) mode |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 37 | * @voltage_bank: bank to control regulator voltage |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 38 | * @voltage_reg: register to control regulator voltage |
| 39 | * @voltage_mask: mask to control regulator voltage |
Linus Walleij | a0a7014 | 2012-08-20 18:41:35 +0200 | [diff] [blame] | 40 | * @voltage_shift: shift to control regulator voltage |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 41 | * @delay: startup/set voltage delay in us |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 42 | */ |
| 43 | struct ab8500_regulator_info { |
| 44 | struct device *dev; |
| 45 | struct regulator_desc desc; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 46 | struct regulator_dev *regulator; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 47 | u8 update_bank; |
| 48 | u8 update_reg; |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 49 | u8 update_mask; |
| 50 | u8 update_val_enable; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 51 | u8 voltage_bank; |
| 52 | u8 voltage_reg; |
| 53 | u8 voltage_mask; |
Linus Walleij | a0a7014 | 2012-08-20 18:41:35 +0200 | [diff] [blame] | 54 | u8 voltage_shift; |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 55 | unsigned int delay; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | /* voltage tables for the vauxn/vintcore supplies */ |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 59 | static const unsigned int ldo_vauxn_voltages[] = { |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 60 | 1100000, |
| 61 | 1200000, |
| 62 | 1300000, |
| 63 | 1400000, |
| 64 | 1500000, |
| 65 | 1800000, |
| 66 | 1850000, |
| 67 | 1900000, |
| 68 | 2500000, |
| 69 | 2650000, |
| 70 | 2700000, |
| 71 | 2750000, |
| 72 | 2800000, |
| 73 | 2900000, |
| 74 | 3000000, |
| 75 | 3300000, |
| 76 | }; |
| 77 | |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 78 | static const unsigned int ldo_vaux3_voltages[] = { |
Bengt Jonsson | 2b75151 | 2010-12-10 11:08:43 +0100 | [diff] [blame] | 79 | 1200000, |
| 80 | 1500000, |
| 81 | 1800000, |
| 82 | 2100000, |
| 83 | 2500000, |
| 84 | 2750000, |
| 85 | 2790000, |
| 86 | 2910000, |
| 87 | }; |
| 88 | |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 89 | static const unsigned int ldo_vintcore_voltages[] = { |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 90 | 1200000, |
| 91 | 1225000, |
| 92 | 1250000, |
| 93 | 1275000, |
| 94 | 1300000, |
| 95 | 1325000, |
| 96 | 1350000, |
| 97 | }; |
| 98 | |
| 99 | static int ab8500_regulator_enable(struct regulator_dev *rdev) |
| 100 | { |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 101 | int ret; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 102 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
| 103 | |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 104 | if (info == NULL) { |
| 105 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 106 | return -EINVAL; |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 107 | } |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 108 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 109 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 110 | info->update_bank, info->update_reg, |
| 111 | info->update_mask, info->update_val_enable); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 112 | if (ret < 0) |
| 113 | dev_err(rdev_get_dev(rdev), |
| 114 | "couldn't set enable bits for regulator\n"); |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 115 | |
| 116 | dev_vdbg(rdev_get_dev(rdev), |
| 117 | "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", |
| 118 | info->desc.name, info->update_bank, info->update_reg, |
| 119 | info->update_mask, info->update_val_enable); |
| 120 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 121 | return ret; |
| 122 | } |
| 123 | |
| 124 | static int ab8500_regulator_disable(struct regulator_dev *rdev) |
| 125 | { |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 126 | int ret; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 127 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
| 128 | |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 129 | if (info == NULL) { |
| 130 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 131 | return -EINVAL; |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 132 | } |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 133 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 134 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 135 | info->update_bank, info->update_reg, |
| 136 | info->update_mask, 0x0); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 137 | if (ret < 0) |
| 138 | dev_err(rdev_get_dev(rdev), |
| 139 | "couldn't set disable bits for regulator\n"); |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 140 | |
| 141 | dev_vdbg(rdev_get_dev(rdev), |
| 142 | "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", |
| 143 | info->desc.name, info->update_bank, info->update_reg, |
| 144 | info->update_mask, 0x0); |
| 145 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 146 | return ret; |
| 147 | } |
| 148 | |
| 149 | static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) |
| 150 | { |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 151 | int ret; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 152 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 153 | u8 regval; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 154 | |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 155 | if (info == NULL) { |
| 156 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 157 | return -EINVAL; |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 158 | } |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 159 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 160 | ret = abx500_get_register_interruptible(info->dev, |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 161 | info->update_bank, info->update_reg, ®val); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 162 | if (ret < 0) { |
| 163 | dev_err(rdev_get_dev(rdev), |
| 164 | "couldn't read 0x%x register\n", info->update_reg); |
| 165 | return ret; |
| 166 | } |
| 167 | |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 168 | dev_vdbg(rdev_get_dev(rdev), |
| 169 | "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," |
| 170 | " 0x%x\n", |
| 171 | info->desc.name, info->update_bank, info->update_reg, |
| 172 | info->update_mask, regval); |
| 173 | |
| 174 | if (regval & info->update_mask) |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 175 | return true; |
| 176 | else |
| 177 | return false; |
| 178 | } |
| 179 | |
Axel Lin | 3bf6e90 | 2012-02-24 17:15:45 +0800 | [diff] [blame] | 180 | static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 181 | { |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 182 | int ret, val; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 183 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 184 | u8 regval; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 185 | |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 186 | if (info == NULL) { |
| 187 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 188 | return -EINVAL; |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 189 | } |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 190 | |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 191 | ret = abx500_get_register_interruptible(info->dev, |
| 192 | info->voltage_bank, info->voltage_reg, ®val); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 193 | if (ret < 0) { |
| 194 | dev_err(rdev_get_dev(rdev), |
| 195 | "couldn't read voltage reg for regulator\n"); |
| 196 | return ret; |
| 197 | } |
| 198 | |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 199 | dev_vdbg(rdev_get_dev(rdev), |
Linus Walleij | a0a7014 | 2012-08-20 18:41:35 +0200 | [diff] [blame] | 200 | "%s-get_voltage (bank, reg, mask, shift, value): " |
| 201 | "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", |
| 202 | info->desc.name, info->voltage_bank, |
| 203 | info->voltage_reg, info->voltage_mask, |
| 204 | info->voltage_shift, regval); |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 205 | |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 206 | val = regval & info->voltage_mask; |
Linus Walleij | a0a7014 | 2012-08-20 18:41:35 +0200 | [diff] [blame] | 207 | return val >> info->voltage_shift; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 208 | } |
| 209 | |
Axel Lin | ae713d3 | 2012-03-20 09:51:08 +0800 | [diff] [blame] | 210 | static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, |
| 211 | unsigned selector) |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 212 | { |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 213 | int ret; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 214 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 215 | u8 regval; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 216 | |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 217 | if (info == NULL) { |
| 218 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 219 | return -EINVAL; |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 220 | } |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 221 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 222 | /* set the registers for the request */ |
Linus Walleij | a0a7014 | 2012-08-20 18:41:35 +0200 | [diff] [blame] | 223 | regval = (u8)selector << info->voltage_shift; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 224 | ret = abx500_mask_and_set_register_interruptible(info->dev, |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 225 | info->voltage_bank, info->voltage_reg, |
| 226 | info->voltage_mask, regval); |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 227 | if (ret < 0) |
| 228 | dev_err(rdev_get_dev(rdev), |
| 229 | "couldn't set voltage reg for regulator\n"); |
| 230 | |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 231 | dev_vdbg(rdev_get_dev(rdev), |
| 232 | "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," |
| 233 | " 0x%x\n", |
| 234 | info->desc.name, info->voltage_bank, info->voltage_reg, |
| 235 | info->voltage_mask, regval); |
| 236 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 237 | return ret; |
| 238 | } |
| 239 | |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 240 | static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev, |
| 241 | unsigned int old_sel, |
| 242 | unsigned int new_sel) |
| 243 | { |
| 244 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 245 | |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 246 | return info->delay; |
| 247 | } |
| 248 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 249 | static struct regulator_ops ab8500_regulator_ops = { |
| 250 | .enable = ab8500_regulator_enable, |
| 251 | .disable = ab8500_regulator_disable, |
| 252 | .is_enabled = ab8500_regulator_is_enabled, |
Axel Lin | 3bf6e90 | 2012-02-24 17:15:45 +0800 | [diff] [blame] | 253 | .get_voltage_sel = ab8500_regulator_get_voltage_sel, |
Axel Lin | ae713d3 | 2012-03-20 09:51:08 +0800 | [diff] [blame] | 254 | .set_voltage_sel = ab8500_regulator_set_voltage_sel, |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 255 | .list_voltage = regulator_list_voltage_table, |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 256 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 257 | }; |
| 258 | |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 259 | static struct regulator_ops ab8500_regulator_fixed_ops = { |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 260 | .enable = ab8500_regulator_enable, |
| 261 | .disable = ab8500_regulator_disable, |
| 262 | .is_enabled = ab8500_regulator_is_enabled, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 263 | .list_voltage = regulator_list_voltage_linear, |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 264 | }; |
| 265 | |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 266 | static struct ab8500_regulator_info |
| 267 | ab8500_regulator_info[AB8500_NUM_REGULATORS] = { |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 268 | /* |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 269 | * Variable Voltage Regulators |
| 270 | * name, min mV, max mV, |
| 271 | * update bank, reg, mask, enable val |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 272 | * volt bank, reg, mask |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 273 | */ |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 274 | [AB8500_LDO_AUX1] = { |
| 275 | .desc = { |
| 276 | .name = "LDO-AUX1", |
| 277 | .ops = &ab8500_regulator_ops, |
| 278 | .type = REGULATOR_VOLTAGE, |
| 279 | .id = AB8500_LDO_AUX1, |
| 280 | .owner = THIS_MODULE, |
| 281 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 282 | .volt_table = ldo_vauxn_voltages, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 283 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 284 | .update_bank = 0x04, |
| 285 | .update_reg = 0x09, |
| 286 | .update_mask = 0x03, |
| 287 | .update_val_enable = 0x01, |
| 288 | .voltage_bank = 0x04, |
| 289 | .voltage_reg = 0x1f, |
| 290 | .voltage_mask = 0x0f, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 291 | }, |
| 292 | [AB8500_LDO_AUX2] = { |
| 293 | .desc = { |
| 294 | .name = "LDO-AUX2", |
| 295 | .ops = &ab8500_regulator_ops, |
| 296 | .type = REGULATOR_VOLTAGE, |
| 297 | .id = AB8500_LDO_AUX2, |
| 298 | .owner = THIS_MODULE, |
| 299 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 300 | .volt_table = ldo_vauxn_voltages, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 301 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 302 | .update_bank = 0x04, |
| 303 | .update_reg = 0x09, |
| 304 | .update_mask = 0x0c, |
| 305 | .update_val_enable = 0x04, |
| 306 | .voltage_bank = 0x04, |
| 307 | .voltage_reg = 0x20, |
| 308 | .voltage_mask = 0x0f, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 309 | }, |
| 310 | [AB8500_LDO_AUX3] = { |
| 311 | .desc = { |
| 312 | .name = "LDO-AUX3", |
| 313 | .ops = &ab8500_regulator_ops, |
| 314 | .type = REGULATOR_VOLTAGE, |
| 315 | .id = AB8500_LDO_AUX3, |
| 316 | .owner = THIS_MODULE, |
| 317 | .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 318 | .volt_table = ldo_vaux3_voltages, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 319 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 320 | .update_bank = 0x04, |
| 321 | .update_reg = 0x0a, |
| 322 | .update_mask = 0x03, |
| 323 | .update_val_enable = 0x01, |
| 324 | .voltage_bank = 0x04, |
| 325 | .voltage_reg = 0x21, |
| 326 | .voltage_mask = 0x07, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 327 | }, |
| 328 | [AB8500_LDO_INTCORE] = { |
| 329 | .desc = { |
| 330 | .name = "LDO-INTCORE", |
| 331 | .ops = &ab8500_regulator_ops, |
| 332 | .type = REGULATOR_VOLTAGE, |
| 333 | .id = AB8500_LDO_INTCORE, |
| 334 | .owner = THIS_MODULE, |
| 335 | .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 336 | .volt_table = ldo_vintcore_voltages, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 337 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 338 | .update_bank = 0x03, |
| 339 | .update_reg = 0x80, |
| 340 | .update_mask = 0x44, |
| 341 | .update_val_enable = 0x04, |
| 342 | .voltage_bank = 0x03, |
| 343 | .voltage_reg = 0x80, |
| 344 | .voltage_mask = 0x38, |
Linus Walleij | a0a7014 | 2012-08-20 18:41:35 +0200 | [diff] [blame] | 345 | .voltage_shift = 3, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 346 | }, |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 347 | |
| 348 | /* |
Bengt Jonsson | e1159e6 | 2010-12-10 11:08:44 +0100 | [diff] [blame] | 349 | * Fixed Voltage Regulators |
| 350 | * name, fixed mV, |
| 351 | * update bank, reg, mask, enable val |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 352 | */ |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 353 | [AB8500_LDO_TVOUT] = { |
| 354 | .desc = { |
| 355 | .name = "LDO-TVOUT", |
| 356 | .ops = &ab8500_regulator_fixed_ops, |
| 357 | .type = REGULATOR_VOLTAGE, |
| 358 | .id = AB8500_LDO_TVOUT, |
| 359 | .owner = THIS_MODULE, |
| 360 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 361 | .min_uV = 2000000, |
Axel Lin | 7fee2af | 2012-08-07 22:21:23 +0800 | [diff] [blame] | 362 | .enable_time = 10000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 363 | }, |
Linus Walleij | 42ab616 | 2011-03-17 13:25:02 +0100 | [diff] [blame] | 364 | .delay = 10000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 365 | .update_bank = 0x03, |
| 366 | .update_reg = 0x80, |
| 367 | .update_mask = 0x82, |
| 368 | .update_val_enable = 0x02, |
| 369 | }, |
Bengt Jonsson | ea05ef3 | 2011-03-10 14:43:31 +0100 | [diff] [blame] | 370 | [AB8500_LDO_USB] = { |
| 371 | .desc = { |
| 372 | .name = "LDO-USB", |
| 373 | .ops = &ab8500_regulator_fixed_ops, |
| 374 | .type = REGULATOR_VOLTAGE, |
| 375 | .id = AB8500_LDO_USB, |
| 376 | .owner = THIS_MODULE, |
| 377 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 378 | .min_uV = 3300000, |
Bengt Jonsson | ea05ef3 | 2011-03-10 14:43:31 +0100 | [diff] [blame] | 379 | }, |
Bengt Jonsson | ea05ef3 | 2011-03-10 14:43:31 +0100 | [diff] [blame] | 380 | .update_bank = 0x03, |
| 381 | .update_reg = 0x82, |
| 382 | .update_mask = 0x03, |
| 383 | .update_val_enable = 0x01, |
| 384 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 385 | [AB8500_LDO_AUDIO] = { |
| 386 | .desc = { |
| 387 | .name = "LDO-AUDIO", |
| 388 | .ops = &ab8500_regulator_fixed_ops, |
| 389 | .type = REGULATOR_VOLTAGE, |
| 390 | .id = AB8500_LDO_AUDIO, |
| 391 | .owner = THIS_MODULE, |
| 392 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 393 | .min_uV = 2000000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 394 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 395 | .update_bank = 0x03, |
| 396 | .update_reg = 0x83, |
| 397 | .update_mask = 0x02, |
| 398 | .update_val_enable = 0x02, |
| 399 | }, |
| 400 | [AB8500_LDO_ANAMIC1] = { |
| 401 | .desc = { |
| 402 | .name = "LDO-ANAMIC1", |
| 403 | .ops = &ab8500_regulator_fixed_ops, |
| 404 | .type = REGULATOR_VOLTAGE, |
| 405 | .id = AB8500_LDO_ANAMIC1, |
| 406 | .owner = THIS_MODULE, |
| 407 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 408 | .min_uV = 2050000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 409 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 410 | .update_bank = 0x03, |
| 411 | .update_reg = 0x83, |
| 412 | .update_mask = 0x08, |
| 413 | .update_val_enable = 0x08, |
| 414 | }, |
| 415 | [AB8500_LDO_ANAMIC2] = { |
| 416 | .desc = { |
| 417 | .name = "LDO-ANAMIC2", |
| 418 | .ops = &ab8500_regulator_fixed_ops, |
| 419 | .type = REGULATOR_VOLTAGE, |
| 420 | .id = AB8500_LDO_ANAMIC2, |
| 421 | .owner = THIS_MODULE, |
| 422 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 423 | .min_uV = 2050000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 424 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 425 | .update_bank = 0x03, |
| 426 | .update_reg = 0x83, |
| 427 | .update_mask = 0x10, |
| 428 | .update_val_enable = 0x10, |
| 429 | }, |
| 430 | [AB8500_LDO_DMIC] = { |
| 431 | .desc = { |
| 432 | .name = "LDO-DMIC", |
| 433 | .ops = &ab8500_regulator_fixed_ops, |
| 434 | .type = REGULATOR_VOLTAGE, |
| 435 | .id = AB8500_LDO_DMIC, |
| 436 | .owner = THIS_MODULE, |
| 437 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 438 | .min_uV = 1800000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 439 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 440 | .update_bank = 0x03, |
| 441 | .update_reg = 0x83, |
| 442 | .update_mask = 0x04, |
| 443 | .update_val_enable = 0x04, |
| 444 | }, |
| 445 | [AB8500_LDO_ANA] = { |
| 446 | .desc = { |
| 447 | .name = "LDO-ANA", |
| 448 | .ops = &ab8500_regulator_fixed_ops, |
| 449 | .type = REGULATOR_VOLTAGE, |
| 450 | .id = AB8500_LDO_ANA, |
| 451 | .owner = THIS_MODULE, |
| 452 | .n_voltages = 1, |
Axel Lin | 7142e21 | 2012-06-08 10:27:49 +0800 | [diff] [blame] | 453 | .min_uV = 1200000, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 454 | }, |
Bengt Jonsson | 6909b45 | 2010-12-10 11:08:47 +0100 | [diff] [blame] | 455 | .update_bank = 0x04, |
| 456 | .update_reg = 0x06, |
| 457 | .update_mask = 0x0c, |
| 458 | .update_val_enable = 0x04, |
| 459 | }, |
| 460 | |
| 461 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 462 | }; |
| 463 | |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 464 | struct ab8500_reg_init { |
| 465 | u8 bank; |
| 466 | u8 addr; |
| 467 | u8 mask; |
| 468 | }; |
| 469 | |
| 470 | #define REG_INIT(_id, _bank, _addr, _mask) \ |
| 471 | [_id] = { \ |
| 472 | .bank = _bank, \ |
| 473 | .addr = _addr, \ |
| 474 | .mask = _mask, \ |
| 475 | } |
| 476 | |
| 477 | static struct ab8500_reg_init ab8500_reg_init[] = { |
| 478 | /* |
| 479 | * 0x30, VanaRequestCtrl |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 480 | * 0x0c, VpllRequestCtrl |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 481 | * 0xc0, VextSupply1RequestCtrl |
| 482 | */ |
| 483 | REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xfc), |
| 484 | /* |
| 485 | * 0x03, VextSupply2RequestCtrl |
| 486 | * 0x0c, VextSupply3RequestCtrl |
| 487 | * 0x30, Vaux1RequestCtrl |
| 488 | * 0xc0, Vaux2RequestCtrl |
| 489 | */ |
| 490 | REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff), |
| 491 | /* |
| 492 | * 0x03, Vaux3RequestCtrl |
| 493 | * 0x04, SwHPReq |
| 494 | */ |
| 495 | REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07), |
| 496 | /* |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 497 | * 0x01, Vsmps1SysClkReq1HPValid |
| 498 | * 0x02, Vsmps2SysClkReq1HPValid |
| 499 | * 0x04, Vsmps3SysClkReq1HPValid |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 500 | * 0x08, VanaSysClkReq1HPValid |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 501 | * 0x10, VpllSysClkReq1HPValid |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 502 | * 0x20, Vaux1SysClkReq1HPValid |
| 503 | * 0x40, Vaux2SysClkReq1HPValid |
| 504 | * 0x80, Vaux3SysClkReq1HPValid |
| 505 | */ |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 506 | REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff), |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 507 | /* |
| 508 | * 0x10, VextSupply1SysClkReq1HPValid |
| 509 | * 0x20, VextSupply2SysClkReq1HPValid |
| 510 | * 0x40, VextSupply3SysClkReq1HPValid |
| 511 | */ |
| 512 | REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70), |
| 513 | /* |
| 514 | * 0x08, VanaHwHPReq1Valid |
| 515 | * 0x20, Vaux1HwHPReq1Valid |
| 516 | * 0x40, Vaux2HwHPReq1Valid |
| 517 | * 0x80, Vaux3HwHPReq1Valid |
| 518 | */ |
| 519 | REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8), |
| 520 | /* |
| 521 | * 0x01, VextSupply1HwHPReq1Valid |
| 522 | * 0x02, VextSupply2HwHPReq1Valid |
| 523 | * 0x04, VextSupply3HwHPReq1Valid |
| 524 | */ |
| 525 | REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07), |
| 526 | /* |
| 527 | * 0x08, VanaHwHPReq2Valid |
| 528 | * 0x20, Vaux1HwHPReq2Valid |
| 529 | * 0x40, Vaux2HwHPReq2Valid |
| 530 | * 0x80, Vaux3HwHPReq2Valid |
| 531 | */ |
| 532 | REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8), |
| 533 | /* |
| 534 | * 0x01, VextSupply1HwHPReq2Valid |
| 535 | * 0x02, VextSupply2HwHPReq2Valid |
| 536 | * 0x04, VextSupply3HwHPReq2Valid |
| 537 | */ |
| 538 | REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07), |
| 539 | /* |
| 540 | * 0x20, VanaSwHPReqValid |
| 541 | * 0x80, Vaux1SwHPReqValid |
| 542 | */ |
| 543 | REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0), |
| 544 | /* |
| 545 | * 0x01, Vaux2SwHPReqValid |
| 546 | * 0x02, Vaux3SwHPReqValid |
| 547 | * 0x04, VextSupply1SwHPReqValid |
| 548 | * 0x08, VextSupply2SwHPReqValid |
| 549 | * 0x10, VextSupply3SwHPReqValid |
| 550 | */ |
| 551 | REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f), |
| 552 | /* |
| 553 | * 0x02, SysClkReq2Valid1 |
| 554 | * ... |
| 555 | * 0x80, SysClkReq8Valid1 |
| 556 | */ |
| 557 | REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe), |
| 558 | /* |
| 559 | * 0x02, SysClkReq2Valid2 |
| 560 | * ... |
| 561 | * 0x80, SysClkReq8Valid2 |
| 562 | */ |
| 563 | REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe), |
| 564 | /* |
| 565 | * 0x02, VTVoutEna |
| 566 | * 0x04, Vintcore12Ena |
| 567 | * 0x38, Vintcore12Sel |
| 568 | * 0x40, Vintcore12LP |
| 569 | * 0x80, VTVoutLP |
| 570 | */ |
| 571 | REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe), |
| 572 | /* |
| 573 | * 0x02, VaudioEna |
| 574 | * 0x04, VdmicEna |
| 575 | * 0x08, Vamic1Ena |
| 576 | * 0x10, Vamic2Ena |
| 577 | */ |
| 578 | REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e), |
| 579 | /* |
| 580 | * 0x01, Vamic1_dzout |
| 581 | * 0x02, Vamic2_dzout |
| 582 | */ |
| 583 | REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03), |
| 584 | /* |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 585 | * 0x0c, VBBNRegu |
| 586 | * 0x03, VBBPRegu |
| 587 | * NOTE! PRCMU register |
| 588 | */ |
| 589 | REG_INIT(AB8500_ARMREGU2, 0x04, 0x01, 0x0f), |
| 590 | /* |
| 591 | * 0x0c, VBBPSel1 |
| 592 | * 0x03, VBBNSel1 |
| 593 | * NOTE! PRCMU register |
| 594 | */ |
| 595 | REG_INIT(AB8500_VBBSEL1, 0x04, 0x11, 0x0f), |
| 596 | /* |
| 597 | * 0x0c, VBBNSel2 |
| 598 | * 0x03, VBBPSel2 |
| 599 | * NOTE! PRCMU register |
| 600 | */ |
| 601 | REG_INIT(AB8500_VBBSEL2, 0x04, 0x12, 0x0f), |
| 602 | /* |
| 603 | * 0x03, Vsmps1Regu |
| 604 | * 0x0c, Vsmps1SelCtrl |
| 605 | */ |
| 606 | REG_INIT(AB8500_VSMPS1REGU, 0x04, 0x03, 0x0f), |
| 607 | /* |
| 608 | * 0x03, Vsmps2Regu |
| 609 | * 0x0c, Vsmps2SelCtrl |
| 610 | */ |
| 611 | REG_INIT(AB8500_VSMPS2REGU, 0x04, 0x04, 0x0f), |
| 612 | /* |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 613 | * 0x0c, VanaRegu |
| 614 | * 0x03, VpllRegu |
| 615 | */ |
| 616 | REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f), |
| 617 | /* |
| 618 | * 0x01, VrefDDREna |
| 619 | * 0x02, VrefDDRSleepMode |
| 620 | */ |
| 621 | REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03), |
| 622 | /* |
| 623 | * 0x03, VextSupply1Regu |
| 624 | * 0x0c, VextSupply2Regu |
| 625 | * 0x30, VextSupply3Regu |
| 626 | * 0x40, ExtSupply2Bypass |
| 627 | * 0x80, ExtSupply3Bypass |
| 628 | */ |
| 629 | REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff), |
| 630 | /* |
| 631 | * 0x03, Vaux1Regu |
| 632 | * 0x0c, Vaux2Regu |
| 633 | */ |
| 634 | REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f), |
| 635 | /* |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 636 | * 0x0c, Vrf1Regu |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 637 | * 0x03, Vaux3Regu |
| 638 | */ |
Lee Jones | d79df32 | 2013-03-21 15:58:58 +0000 | [diff] [blame^] | 639 | REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f), |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 640 | /* |
| 641 | * 0x3f, Vsmps1Sel1 |
| 642 | */ |
| 643 | REG_INIT(AB8500_VSMPS1SEL1, 0x04, 0x13, 0x3f), |
| 644 | /* |
| 645 | * 0x0f, Vaux1Sel |
| 646 | */ |
| 647 | REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f), |
| 648 | /* |
| 649 | * 0x0f, Vaux2Sel |
| 650 | */ |
| 651 | REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f), |
| 652 | /* |
| 653 | * 0x07, Vaux3Sel |
| 654 | */ |
| 655 | REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07), |
| 656 | /* |
| 657 | * 0x01, VextSupply12LP |
| 658 | */ |
| 659 | REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01), |
| 660 | /* |
| 661 | * 0x04, Vaux1Disch |
| 662 | * 0x08, Vaux2Disch |
| 663 | * 0x10, Vaux3Disch |
| 664 | * 0x20, Vintcore12Disch |
| 665 | * 0x40, VTVoutDisch |
| 666 | * 0x80, VaudioDisch |
| 667 | */ |
| 668 | REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc), |
| 669 | /* |
| 670 | * 0x02, VanaDisch |
| 671 | * 0x04, VdmicPullDownEna |
| 672 | * 0x10, VdmicDisch |
| 673 | */ |
| 674 | REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16), |
| 675 | }; |
| 676 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 677 | static int |
Lee Jones | a7ac1d9 | 2012-05-17 14:45:14 +0100 | [diff] [blame] | 678 | ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value) |
| 679 | { |
| 680 | int err; |
| 681 | |
| 682 | if (value & ~ab8500_reg_init[id].mask) { |
| 683 | dev_err(&pdev->dev, |
| 684 | "Configuration error: value outside mask.\n"); |
| 685 | return -EINVAL; |
| 686 | } |
| 687 | |
| 688 | err = abx500_mask_and_set_register_interruptible( |
| 689 | &pdev->dev, |
| 690 | ab8500_reg_init[id].bank, |
| 691 | ab8500_reg_init[id].addr, |
| 692 | ab8500_reg_init[id].mask, |
| 693 | value); |
| 694 | if (err < 0) { |
| 695 | dev_err(&pdev->dev, |
| 696 | "Failed to initialize 0x%02x, 0x%02x.\n", |
| 697 | ab8500_reg_init[id].bank, |
| 698 | ab8500_reg_init[id].addr); |
| 699 | return err; |
| 700 | } |
| 701 | |
| 702 | dev_vdbg(&pdev->dev, |
| 703 | "init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", |
| 704 | ab8500_reg_init[id].bank, |
| 705 | ab8500_reg_init[id].addr, |
| 706 | ab8500_reg_init[id].mask, |
| 707 | value); |
| 708 | |
| 709 | return 0; |
| 710 | } |
| 711 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 712 | static int ab8500_regulator_register(struct platform_device *pdev, |
Lee Jones | a7ac1d9 | 2012-05-17 14:45:14 +0100 | [diff] [blame] | 713 | struct regulator_init_data *init_data, |
| 714 | int id, |
| 715 | struct device_node *np) |
| 716 | { |
| 717 | struct ab8500_regulator_info *info = NULL; |
| 718 | struct regulator_config config = { }; |
| 719 | int err; |
| 720 | |
| 721 | /* assign per-regulator data */ |
| 722 | info = &ab8500_regulator_info[id]; |
| 723 | info->dev = &pdev->dev; |
| 724 | |
| 725 | config.dev = &pdev->dev; |
| 726 | config.init_data = init_data; |
| 727 | config.driver_data = info; |
| 728 | config.of_node = np; |
| 729 | |
| 730 | /* fix for hardware before ab8500v2.0 */ |
| 731 | if (abx500_get_chip_id(info->dev) < 0x20) { |
| 732 | if (info->desc.id == AB8500_LDO_AUX3) { |
| 733 | info->desc.n_voltages = |
| 734 | ARRAY_SIZE(ldo_vauxn_voltages); |
Axel Lin | ec1cc4d | 2012-05-20 10:33:35 +0800 | [diff] [blame] | 735 | info->desc.volt_table = ldo_vauxn_voltages; |
Lee Jones | a7ac1d9 | 2012-05-17 14:45:14 +0100 | [diff] [blame] | 736 | info->voltage_mask = 0xf; |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | /* register regulator with framework */ |
| 741 | info->regulator = regulator_register(&info->desc, &config); |
| 742 | if (IS_ERR(info->regulator)) { |
| 743 | err = PTR_ERR(info->regulator); |
| 744 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 745 | info->desc.name); |
| 746 | /* when we fail, un-register all earlier regulators */ |
| 747 | while (--id >= 0) { |
| 748 | info = &ab8500_regulator_info[id]; |
| 749 | regulator_unregister(info->regulator); |
| 750 | } |
| 751 | return err; |
| 752 | } |
| 753 | |
| 754 | return 0; |
| 755 | } |
| 756 | |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 757 | static struct of_regulator_match ab8500_regulator_matches[] = { |
Lee Jones | 7e715b9 | 2012-05-30 12:47:26 +0800 | [diff] [blame] | 758 | { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, }, |
| 759 | { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, }, |
| 760 | { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, }, |
| 761 | { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, }, |
| 762 | { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, }, |
| 763 | { .name = "ab8500_ldo_usb", .driver_data = (void *) AB8500_LDO_USB, }, |
| 764 | { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, }, |
| 765 | { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, }, |
| 766 | { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, }, |
| 767 | { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, }, |
| 768 | { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, }, |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 769 | }; |
| 770 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 771 | static int |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 772 | ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np) |
| 773 | { |
| 774 | int err, i; |
| 775 | |
| 776 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { |
| 777 | err = ab8500_regulator_register( |
| 778 | pdev, ab8500_regulator_matches[i].init_data, |
| 779 | i, ab8500_regulator_matches[i].of_node); |
| 780 | if (err) |
| 781 | return err; |
| 782 | } |
| 783 | |
| 784 | return 0; |
| 785 | } |
| 786 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 787 | static int ab8500_regulator_probe(struct platform_device *pdev) |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 788 | { |
| 789 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
Dan Carpenter | af54dec | 2010-08-14 11:03:16 +0200 | [diff] [blame] | 790 | struct ab8500_platform_data *pdata; |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 791 | struct device_node *np = pdev->dev.of_node; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 792 | int i, err; |
| 793 | |
Lee Jones | 3a8334b | 2012-05-17 14:45:16 +0100 | [diff] [blame] | 794 | if (np) { |
| 795 | err = of_regulator_match(&pdev->dev, np, |
| 796 | ab8500_regulator_matches, |
| 797 | ARRAY_SIZE(ab8500_regulator_matches)); |
| 798 | if (err < 0) { |
| 799 | dev_err(&pdev->dev, |
| 800 | "Error parsing regulator init data: %d\n", err); |
| 801 | return err; |
| 802 | } |
| 803 | |
| 804 | err = ab8500_regulator_of_probe(pdev, np); |
| 805 | return err; |
| 806 | } |
| 807 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 808 | if (!ab8500) { |
| 809 | dev_err(&pdev->dev, "null mfd parent\n"); |
| 810 | return -EINVAL; |
| 811 | } |
Dan Carpenter | af54dec | 2010-08-14 11:03:16 +0200 | [diff] [blame] | 812 | pdata = dev_get_platdata(ab8500->dev); |
Bengt Jonsson | fc24b42 | 2010-12-10 11:08:45 +0100 | [diff] [blame] | 813 | if (!pdata) { |
| 814 | dev_err(&pdev->dev, "null pdata\n"); |
| 815 | return -EINVAL; |
| 816 | } |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 817 | |
Bengt Jonsson | cb189b0 | 2010-12-10 11:08:40 +0100 | [diff] [blame] | 818 | /* make sure the platform data has the correct size */ |
| 819 | if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) { |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 820 | dev_err(&pdev->dev, "Configuration error: size mismatch.\n"); |
Bengt Jonsson | cb189b0 | 2010-12-10 11:08:40 +0100 | [diff] [blame] | 821 | return -EINVAL; |
| 822 | } |
| 823 | |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 824 | /* initialize registers */ |
| 825 | for (i = 0; i < pdata->num_regulator_reg_init; i++) { |
Lee Jones | a7ac1d9 | 2012-05-17 14:45:14 +0100 | [diff] [blame] | 826 | int id, value; |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 827 | |
| 828 | id = pdata->regulator_reg_init[i].id; |
| 829 | value = pdata->regulator_reg_init[i].value; |
| 830 | |
| 831 | /* check for configuration errors */ |
| 832 | if (id >= AB8500_NUM_REGULATOR_REGISTERS) { |
| 833 | dev_err(&pdev->dev, |
| 834 | "Configuration error: id outside range.\n"); |
| 835 | return -EINVAL; |
| 836 | } |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 837 | |
Lee Jones | a7ac1d9 | 2012-05-17 14:45:14 +0100 | [diff] [blame] | 838 | err = ab8500_regulator_init_registers(pdev, id, value); |
| 839 | if (err < 0) |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 840 | return err; |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 841 | } |
| 842 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 843 | /* register all regulators */ |
| 844 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { |
Lee Jones | a7ac1d9 | 2012-05-17 14:45:14 +0100 | [diff] [blame] | 845 | err = ab8500_regulator_register(pdev, &pdata->regulator[i], i, NULL); |
| 846 | if (err < 0) |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 847 | return err; |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | return 0; |
| 851 | } |
| 852 | |
Bill Pemberton | 8dc995f | 2012-11-19 13:26:10 -0500 | [diff] [blame] | 853 | static int ab8500_regulator_remove(struct platform_device *pdev) |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 854 | { |
| 855 | int i; |
| 856 | |
| 857 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { |
| 858 | struct ab8500_regulator_info *info = NULL; |
| 859 | info = &ab8500_regulator_info[i]; |
Bengt Jonsson | 09aefa1 | 2010-12-10 11:08:46 +0100 | [diff] [blame] | 860 | |
| 861 | dev_vdbg(rdev_get_dev(info->regulator), |
| 862 | "%s-remove\n", info->desc.name); |
| 863 | |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 864 | regulator_unregister(info->regulator); |
| 865 | } |
| 866 | |
| 867 | return 0; |
| 868 | } |
| 869 | |
| 870 | static struct platform_driver ab8500_regulator_driver = { |
| 871 | .probe = ab8500_regulator_probe, |
Bill Pemberton | 5eb9f2b | 2012-11-19 13:20:42 -0500 | [diff] [blame] | 872 | .remove = ab8500_regulator_remove, |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 873 | .driver = { |
| 874 | .name = "ab8500-regulator", |
| 875 | .owner = THIS_MODULE, |
Sundar R IYER | c789ca2 | 2010-07-13 21:48:56 +0530 | [diff] [blame] | 876 | }, |
| 877 | }; |
| 878 | |
| 879 | static int __init ab8500_regulator_init(void) |
| 880 | { |
| 881 | int ret; |
| 882 | |
| 883 | ret = platform_driver_register(&ab8500_regulator_driver); |
| 884 | if (ret != 0) |
| 885 | pr_err("Failed to register ab8500 regulator: %d\n", ret); |
| 886 | |
| 887 | return ret; |
| 888 | } |
| 889 | subsys_initcall(ab8500_regulator_init); |
| 890 | |
| 891 | static void __exit ab8500_regulator_exit(void) |
| 892 | { |
| 893 | platform_driver_unregister(&ab8500_regulator_driver); |
| 894 | } |
| 895 | module_exit(ab8500_regulator_exit); |
| 896 | |
| 897 | MODULE_LICENSE("GPL v2"); |
| 898 | MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>"); |
| 899 | MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC"); |
| 900 | MODULE_ALIAS("platform:ab8500-regulator"); |