Axel Lin | 6a1beee | 2019-04-19 08:58:24 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // |
| 3 | // FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver. |
| 4 | // |
| 5 | // Supported Part Numbers: |
| 6 | // FAN53555UC00X/01X/03X/04X/05X |
| 7 | // |
| 8 | // Copyright (c) 2012 Marvell Technology Ltd. |
| 9 | // Yunfan Zhang <yfzhang@marvell.com> |
| 10 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 11 | #include <linux/module.h> |
| 12 | #include <linux/param.h> |
| 13 | #include <linux/err.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/regulator/driver.h> |
| 16 | #include <linux/regulator/machine.h> |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 17 | #include <linux/regulator/of_regulator.h> |
| 18 | #include <linux/of_device.h> |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 19 | #include <linux/i2c.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/regmap.h> |
| 22 | #include <linux/regulator/fan53555.h> |
| 23 | |
| 24 | /* Voltage setting */ |
| 25 | #define FAN53555_VSEL0 0x00 |
| 26 | #define FAN53555_VSEL1 0x01 |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 27 | |
| 28 | #define TCS4525_VSEL0 0x11 |
| 29 | #define TCS4525_VSEL1 0x10 |
| 30 | #define TCS4525_TIME 0x13 |
| 31 | #define TCS4525_COMMAND 0x14 |
| 32 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 33 | /* Control register */ |
| 34 | #define FAN53555_CONTROL 0x02 |
| 35 | /* IC Type */ |
| 36 | #define FAN53555_ID1 0x03 |
| 37 | /* IC mask version */ |
| 38 | #define FAN53555_ID2 0x04 |
| 39 | /* Monitor register */ |
| 40 | #define FAN53555_MONITOR 0x05 |
| 41 | |
| 42 | /* VSEL bit definitions */ |
| 43 | #define VSEL_BUCK_EN (1 << 7) |
| 44 | #define VSEL_MODE (1 << 6) |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 45 | /* Chip ID and Verison */ |
| 46 | #define DIE_ID 0x0F /* ID1 */ |
| 47 | #define DIE_REV 0x0F /* ID2 */ |
| 48 | /* Control bit definitions */ |
| 49 | #define CTL_OUTPUT_DISCHG (1 << 7) |
| 50 | #define CTL_SLEW_MASK (0x7 << 4) |
| 51 | #define CTL_SLEW_SHIFT 4 |
| 52 | #define CTL_RESET (1 << 2) |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 53 | #define CTL_MODE_VSEL0_MODE BIT(0) |
| 54 | #define CTL_MODE_VSEL1_MODE BIT(1) |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 55 | |
| 56 | #define FAN53555_NVOLTAGES 64 /* Numbers of voltages */ |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 57 | #define FAN53526_NVOLTAGES 128 |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 58 | |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 59 | #define TCS_VSEL0_MODE (1 << 7) |
| 60 | #define TCS_VSEL1_MODE (1 << 6) |
| 61 | |
| 62 | #define TCS_SLEW_SHIFT 3 |
| 63 | #define TCS_SLEW_MASK (0x3 < 3) |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 64 | |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 65 | enum fan53555_vendor { |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 66 | FAN53526_VENDOR_FAIRCHILD = 0, |
| 67 | FAN53555_VENDOR_FAIRCHILD, |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 68 | FAN53555_VENDOR_SILERGY, |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 69 | FAN53526_VENDOR_TCS, |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 70 | }; |
| 71 | |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 72 | enum { |
| 73 | FAN53526_CHIP_ID_01 = 1, |
| 74 | }; |
| 75 | |
| 76 | enum { |
| 77 | FAN53526_CHIP_REV_08 = 8, |
| 78 | }; |
| 79 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 80 | /* IC Type */ |
| 81 | enum { |
| 82 | FAN53555_CHIP_ID_00 = 0, |
| 83 | FAN53555_CHIP_ID_01, |
| 84 | FAN53555_CHIP_ID_02, |
| 85 | FAN53555_CHIP_ID_03, |
| 86 | FAN53555_CHIP_ID_04, |
| 87 | FAN53555_CHIP_ID_05, |
Wadim Egorov | 5e39cf4 | 2016-04-20 10:01:07 +0200 | [diff] [blame] | 88 | FAN53555_CHIP_ID_08 = 8, |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Peter Geis | f9028dc | 2021-05-11 17:13:34 -0400 | [diff] [blame] | 91 | enum { |
| 92 | TCS4525_CHIP_ID_12 = 12, |
| 93 | }; |
| 94 | |
Rudi Heitbaum | 5eee5ec | 2021-06-02 11:29:47 +0000 | [diff] [blame] | 95 | enum { |
| 96 | TCS4526_CHIP_ID_00 = 0, |
| 97 | }; |
| 98 | |
Wadim Egorov | e57cbb7 | 2016-04-20 10:01:08 +0200 | [diff] [blame] | 99 | /* IC mask revision */ |
| 100 | enum { |
| 101 | FAN53555_CHIP_REV_00 = 0x3, |
| 102 | FAN53555_CHIP_REV_13 = 0xf, |
| 103 | }; |
| 104 | |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 105 | enum { |
| 106 | SILERGY_SYR82X = 8, |
Vasily Khoruzhick | 5365e3d | 2019-11-06 08:12:11 -0800 | [diff] [blame] | 107 | SILERGY_SYR83X = 9, |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 108 | }; |
| 109 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 110 | struct fan53555_device_info { |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 111 | enum fan53555_vendor vendor; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 112 | struct device *dev; |
| 113 | struct regulator_desc desc; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 114 | struct regulator_init_data *regulator; |
| 115 | /* IC Type and Rev */ |
| 116 | int chip_id; |
| 117 | int chip_rev; |
| 118 | /* Voltage setting register */ |
| 119 | unsigned int vol_reg; |
| 120 | unsigned int sleep_reg; |
| 121 | /* Voltage range and step(linear) */ |
| 122 | unsigned int vsel_min; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 123 | unsigned int vsel_step; |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 124 | unsigned int vsel_count; |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 125 | /* Mode */ |
| 126 | unsigned int mode_reg; |
| 127 | unsigned int mode_mask; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 128 | /* Sleep voltage cache */ |
| 129 | unsigned int sleep_vol_cache; |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 130 | /* Slew rate */ |
| 131 | unsigned int slew_reg; |
| 132 | unsigned int slew_mask; |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 133 | const unsigned int *ramp_delay_table; |
| 134 | unsigned int n_ramp_values; |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 135 | unsigned int slew_rate; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | static int fan53555_set_suspend_voltage(struct regulator_dev *rdev, int uV) |
| 139 | { |
| 140 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 141 | int ret; |
| 142 | |
| 143 | if (di->sleep_vol_cache == uV) |
| 144 | return 0; |
| 145 | ret = regulator_map_voltage_linear(rdev, uV, uV); |
| 146 | if (ret < 0) |
Sachin Kamat | 145fe1e | 2014-02-18 16:11:04 +0530 | [diff] [blame] | 147 | return ret; |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 148 | ret = regmap_update_bits(rdev->regmap, di->sleep_reg, |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 149 | di->desc.vsel_mask, ret); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 150 | if (ret < 0) |
Sachin Kamat | 145fe1e | 2014-02-18 16:11:04 +0530 | [diff] [blame] | 151 | return ret; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 152 | /* Cache the sleep voltage setting. |
| 153 | * Might not be the real voltage which is rounded */ |
| 154 | di->sleep_vol_cache = uV; |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
zhangqing | ab7cad3 | 2016-01-12 03:05:56 -0800 | [diff] [blame] | 159 | static int fan53555_set_suspend_enable(struct regulator_dev *rdev) |
| 160 | { |
| 161 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 162 | |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 163 | return regmap_update_bits(rdev->regmap, di->sleep_reg, |
zhangqing | ab7cad3 | 2016-01-12 03:05:56 -0800 | [diff] [blame] | 164 | VSEL_BUCK_EN, VSEL_BUCK_EN); |
| 165 | } |
| 166 | |
| 167 | static int fan53555_set_suspend_disable(struct regulator_dev *rdev) |
| 168 | { |
| 169 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 170 | |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 171 | return regmap_update_bits(rdev->regmap, di->sleep_reg, |
zhangqing | ab7cad3 | 2016-01-12 03:05:56 -0800 | [diff] [blame] | 172 | VSEL_BUCK_EN, 0); |
| 173 | } |
| 174 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 175 | static int fan53555_set_mode(struct regulator_dev *rdev, unsigned int mode) |
| 176 | { |
| 177 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 178 | |
| 179 | switch (mode) { |
| 180 | case REGULATOR_MODE_FAST: |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 181 | regmap_update_bits(rdev->regmap, di->mode_reg, |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 182 | di->mode_mask, di->mode_mask); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 183 | break; |
| 184 | case REGULATOR_MODE_NORMAL: |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 185 | regmap_update_bits(rdev->regmap, di->vol_reg, di->mode_mask, 0); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 186 | break; |
| 187 | default: |
| 188 | return -EINVAL; |
| 189 | } |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | static unsigned int fan53555_get_mode(struct regulator_dev *rdev) |
| 194 | { |
| 195 | struct fan53555_device_info *di = rdev_get_drvdata(rdev); |
| 196 | unsigned int val; |
| 197 | int ret = 0; |
| 198 | |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 199 | ret = regmap_read(rdev->regmap, di->mode_reg, &val); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 200 | if (ret < 0) |
| 201 | return ret; |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 202 | if (val & di->mode_mask) |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 203 | return REGULATOR_MODE_FAST; |
| 204 | else |
| 205 | return REGULATOR_MODE_NORMAL; |
| 206 | } |
| 207 | |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 208 | static const unsigned int slew_rates[] = { |
Heiko Stuebner | dd7e71f | 2014-09-16 17:54:01 +0200 | [diff] [blame] | 209 | 64000, |
| 210 | 32000, |
| 211 | 16000, |
| 212 | 8000, |
| 213 | 4000, |
| 214 | 2000, |
| 215 | 1000, |
| 216 | 500, |
| 217 | }; |
| 218 | |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 219 | static const unsigned int tcs_slew_rates[] = { |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 220 | 18700, |
| 221 | 9300, |
| 222 | 4600, |
| 223 | 2300, |
| 224 | }; |
| 225 | |
Bhumika Goyal | 71880ab | 2017-01-28 19:32:05 +0530 | [diff] [blame] | 226 | static const struct regulator_ops fan53555_regulator_ops = { |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 227 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 228 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
Heiko Stuebner | fda87a4 | 2015-05-26 18:19:45 +0200 | [diff] [blame] | 229 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 230 | .map_voltage = regulator_map_voltage_linear, |
| 231 | .list_voltage = regulator_list_voltage_linear, |
| 232 | .set_suspend_voltage = fan53555_set_suspend_voltage, |
| 233 | .enable = regulator_enable_regmap, |
| 234 | .disable = regulator_disable_regmap, |
| 235 | .is_enabled = regulator_is_enabled_regmap, |
| 236 | .set_mode = fan53555_set_mode, |
| 237 | .get_mode = fan53555_get_mode, |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 238 | .set_ramp_delay = regulator_set_ramp_delay_regmap, |
zhangqing | ab7cad3 | 2016-01-12 03:05:56 -0800 | [diff] [blame] | 239 | .set_suspend_enable = fan53555_set_suspend_enable, |
| 240 | .set_suspend_disable = fan53555_set_suspend_disable, |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 241 | }; |
| 242 | |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 243 | static int fan53526_voltages_setup_fairchild(struct fan53555_device_info *di) |
| 244 | { |
| 245 | /* Init voltage range and step */ |
| 246 | switch (di->chip_id) { |
| 247 | case FAN53526_CHIP_ID_01: |
| 248 | switch (di->chip_rev) { |
| 249 | case FAN53526_CHIP_REV_08: |
| 250 | di->vsel_min = 600000; |
| 251 | di->vsel_step = 6250; |
| 252 | break; |
| 253 | default: |
| 254 | dev_err(di->dev, |
| 255 | "Chip ID %d with rev %d not supported!\n", |
| 256 | di->chip_id, di->chip_rev); |
| 257 | return -EINVAL; |
| 258 | } |
| 259 | break; |
| 260 | default: |
| 261 | dev_err(di->dev, |
| 262 | "Chip ID %d not supported!\n", di->chip_id); |
| 263 | return -EINVAL; |
| 264 | } |
| 265 | |
Axel Lin | 30b38b8 | 2021-05-25 20:40:16 +0800 | [diff] [blame] | 266 | di->slew_reg = FAN53555_CONTROL; |
| 267 | di->slew_mask = CTL_SLEW_MASK; |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 268 | di->ramp_delay_table = slew_rates; |
| 269 | di->n_ramp_values = ARRAY_SIZE(slew_rates); |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 270 | di->vsel_count = FAN53526_NVOLTAGES; |
| 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 275 | static int fan53555_voltages_setup_fairchild(struct fan53555_device_info *di) |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 276 | { |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 277 | /* Init voltage range and step */ |
| 278 | switch (di->chip_id) { |
| 279 | case FAN53555_CHIP_ID_00: |
Wadim Egorov | e57cbb7 | 2016-04-20 10:01:08 +0200 | [diff] [blame] | 280 | switch (di->chip_rev) { |
| 281 | case FAN53555_CHIP_REV_00: |
| 282 | di->vsel_min = 600000; |
| 283 | di->vsel_step = 10000; |
| 284 | break; |
| 285 | case FAN53555_CHIP_REV_13: |
| 286 | di->vsel_min = 800000; |
| 287 | di->vsel_step = 10000; |
| 288 | break; |
| 289 | default: |
| 290 | dev_err(di->dev, |
| 291 | "Chip ID %d with rev %d not supported!\n", |
| 292 | di->chip_id, di->chip_rev); |
| 293 | return -EINVAL; |
| 294 | } |
| 295 | break; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 296 | case FAN53555_CHIP_ID_01: |
| 297 | case FAN53555_CHIP_ID_03: |
| 298 | case FAN53555_CHIP_ID_05: |
Wadim Egorov | 5e39cf4 | 2016-04-20 10:01:07 +0200 | [diff] [blame] | 299 | case FAN53555_CHIP_ID_08: |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 300 | di->vsel_min = 600000; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 301 | di->vsel_step = 10000; |
| 302 | break; |
| 303 | case FAN53555_CHIP_ID_04: |
| 304 | di->vsel_min = 603000; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 305 | di->vsel_step = 12826; |
| 306 | break; |
| 307 | default: |
| 308 | dev_err(di->dev, |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 309 | "Chip ID %d not supported!\n", di->chip_id); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 310 | return -EINVAL; |
| 311 | } |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 312 | di->slew_reg = FAN53555_CONTROL; |
| 313 | di->slew_mask = CTL_SLEW_MASK; |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 314 | di->ramp_delay_table = slew_rates; |
| 315 | di->n_ramp_values = ARRAY_SIZE(slew_rates); |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 316 | di->vsel_count = FAN53555_NVOLTAGES; |
| 317 | |
Heiko Stuebner | dd7e71f | 2014-09-16 17:54:01 +0200 | [diff] [blame] | 318 | return 0; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 321 | static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di) |
| 322 | { |
| 323 | /* Init voltage range and step */ |
| 324 | switch (di->chip_id) { |
| 325 | case SILERGY_SYR82X: |
Vasily Khoruzhick | 5365e3d | 2019-11-06 08:12:11 -0800 | [diff] [blame] | 326 | case SILERGY_SYR83X: |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 327 | di->vsel_min = 712500; |
| 328 | di->vsel_step = 12500; |
| 329 | break; |
| 330 | default: |
| 331 | dev_err(di->dev, |
| 332 | "Chip ID %d not supported!\n", di->chip_id); |
| 333 | return -EINVAL; |
| 334 | } |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 335 | di->slew_reg = FAN53555_CONTROL; |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 336 | di->slew_mask = CTL_SLEW_MASK; |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 337 | di->ramp_delay_table = slew_rates; |
| 338 | di->n_ramp_values = ARRAY_SIZE(slew_rates); |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 339 | di->vsel_count = FAN53555_NVOLTAGES; |
| 340 | |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 341 | return 0; |
| 342 | } |
| 343 | |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 344 | static int fan53526_voltages_setup_tcs(struct fan53555_device_info *di) |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 345 | { |
Peter Geis | f9028dc | 2021-05-11 17:13:34 -0400 | [diff] [blame] | 346 | switch (di->chip_id) { |
| 347 | case TCS4525_CHIP_ID_12: |
Rudi Heitbaum | 5eee5ec | 2021-06-02 11:29:47 +0000 | [diff] [blame] | 348 | case TCS4526_CHIP_ID_00: |
Peter Geis | f9028dc | 2021-05-11 17:13:34 -0400 | [diff] [blame] | 349 | di->slew_reg = TCS4525_TIME; |
| 350 | di->slew_mask = TCS_SLEW_MASK; |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 351 | di->ramp_delay_table = tcs_slew_rates; |
| 352 | di->n_ramp_values = ARRAY_SIZE(tcs_slew_rates); |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 353 | |
Peter Geis | f9028dc | 2021-05-11 17:13:34 -0400 | [diff] [blame] | 354 | /* Init voltage range and step */ |
| 355 | di->vsel_min = 600000; |
| 356 | di->vsel_step = 6250; |
| 357 | di->vsel_count = FAN53526_NVOLTAGES; |
| 358 | break; |
| 359 | default: |
| 360 | dev_err(di->dev, "Chip ID %d not supported!\n", di->chip_id); |
| 361 | return -EINVAL; |
| 362 | } |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 363 | |
| 364 | return 0; |
| 365 | } |
| 366 | |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 367 | /* For 00,01,03,05 options: |
| 368 | * VOUT = 0.60V + NSELx * 10mV, from 0.60 to 1.23V. |
| 369 | * For 04 option: |
| 370 | * VOUT = 0.603V + NSELx * 12.826mV, from 0.603 to 1.411V. |
| 371 | * */ |
| 372 | static int fan53555_device_setup(struct fan53555_device_info *di, |
| 373 | struct fan53555_platform_data *pdata) |
| 374 | { |
| 375 | int ret = 0; |
| 376 | |
| 377 | /* Setup voltage control register */ |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 378 | switch (di->vendor) { |
| 379 | case FAN53526_VENDOR_FAIRCHILD: |
| 380 | case FAN53555_VENDOR_FAIRCHILD: |
| 381 | case FAN53555_VENDOR_SILERGY: |
| 382 | switch (pdata->sleep_vsel_id) { |
| 383 | case FAN53555_VSEL_ID_0: |
| 384 | di->sleep_reg = FAN53555_VSEL0; |
| 385 | di->vol_reg = FAN53555_VSEL1; |
| 386 | break; |
| 387 | case FAN53555_VSEL_ID_1: |
| 388 | di->sleep_reg = FAN53555_VSEL1; |
| 389 | di->vol_reg = FAN53555_VSEL0; |
| 390 | break; |
| 391 | default: |
| 392 | dev_err(di->dev, "Invalid VSEL ID!\n"); |
| 393 | return -EINVAL; |
| 394 | } |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 395 | break; |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 396 | case FAN53526_VENDOR_TCS: |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 397 | switch (pdata->sleep_vsel_id) { |
| 398 | case FAN53555_VSEL_ID_0: |
| 399 | di->sleep_reg = TCS4525_VSEL0; |
| 400 | di->vol_reg = TCS4525_VSEL1; |
| 401 | break; |
| 402 | case FAN53555_VSEL_ID_1: |
| 403 | di->sleep_reg = TCS4525_VSEL1; |
| 404 | di->vol_reg = TCS4525_VSEL0; |
| 405 | break; |
| 406 | default: |
| 407 | dev_err(di->dev, "Invalid VSEL ID!\n"); |
| 408 | return -EINVAL; |
| 409 | } |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 410 | break; |
| 411 | default: |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 412 | dev_err(di->dev, "vendor %d not supported!\n", di->vendor); |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 413 | return -EINVAL; |
| 414 | } |
| 415 | |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 416 | /* Setup mode control register */ |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 417 | switch (di->vendor) { |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 418 | case FAN53526_VENDOR_FAIRCHILD: |
| 419 | di->mode_reg = FAN53555_CONTROL; |
| 420 | |
| 421 | switch (pdata->sleep_vsel_id) { |
| 422 | case FAN53555_VSEL_ID_0: |
| 423 | di->mode_mask = CTL_MODE_VSEL1_MODE; |
| 424 | break; |
| 425 | case FAN53555_VSEL_ID_1: |
| 426 | di->mode_mask = CTL_MODE_VSEL0_MODE; |
| 427 | break; |
| 428 | } |
| 429 | break; |
| 430 | case FAN53555_VENDOR_FAIRCHILD: |
| 431 | case FAN53555_VENDOR_SILERGY: |
| 432 | di->mode_reg = di->vol_reg; |
| 433 | di->mode_mask = VSEL_MODE; |
| 434 | break; |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 435 | case FAN53526_VENDOR_TCS: |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 436 | di->mode_reg = TCS4525_COMMAND; |
| 437 | |
| 438 | switch (pdata->sleep_vsel_id) { |
| 439 | case FAN53555_VSEL_ID_0: |
| 440 | di->mode_mask = TCS_VSEL1_MODE; |
| 441 | break; |
| 442 | case FAN53555_VSEL_ID_1: |
| 443 | di->mode_mask = TCS_VSEL0_MODE; |
| 444 | break; |
| 445 | } |
| 446 | break; |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 447 | default: |
| 448 | dev_err(di->dev, "vendor %d not supported!\n", di->vendor); |
| 449 | return -EINVAL; |
| 450 | } |
| 451 | |
| 452 | /* Setup voltage range */ |
| 453 | switch (di->vendor) { |
| 454 | case FAN53526_VENDOR_FAIRCHILD: |
| 455 | ret = fan53526_voltages_setup_fairchild(di); |
| 456 | break; |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 457 | case FAN53555_VENDOR_FAIRCHILD: |
| 458 | ret = fan53555_voltages_setup_fairchild(di); |
| 459 | break; |
| 460 | case FAN53555_VENDOR_SILERGY: |
| 461 | ret = fan53555_voltages_setup_silergy(di); |
| 462 | break; |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 463 | case FAN53526_VENDOR_TCS: |
| 464 | ret = fan53526_voltages_setup_tcs(di); |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 465 | break; |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 466 | default: |
Axel Lin | fe23053 | 2014-09-18 21:48:48 +0800 | [diff] [blame] | 467 | dev_err(di->dev, "vendor %d not supported!\n", di->vendor); |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 468 | return -EINVAL; |
| 469 | } |
| 470 | |
| 471 | return ret; |
| 472 | } |
| 473 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 474 | static int fan53555_regulator_register(struct fan53555_device_info *di, |
| 475 | struct regulator_config *config) |
| 476 | { |
| 477 | struct regulator_desc *rdesc = &di->desc; |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 478 | struct regulator_dev *rdev; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 479 | |
| 480 | rdesc->name = "fan53555-reg"; |
Heiko Stuebner | 3415d60 | 2014-09-14 21:23:01 +0200 | [diff] [blame] | 481 | rdesc->supply_name = "vin"; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 482 | rdesc->ops = &fan53555_regulator_ops; |
| 483 | rdesc->type = REGULATOR_VOLTAGE; |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 484 | rdesc->n_voltages = di->vsel_count; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 485 | rdesc->enable_reg = di->vol_reg; |
| 486 | rdesc->enable_mask = VSEL_BUCK_EN; |
| 487 | rdesc->min_uV = di->vsel_min; |
| 488 | rdesc->uV_step = di->vsel_step; |
| 489 | rdesc->vsel_reg = di->vol_reg; |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 490 | rdesc->vsel_mask = di->vsel_count - 1; |
Axel Lin | b61ac76 | 2021-05-25 20:40:17 +0800 | [diff] [blame] | 491 | rdesc->ramp_reg = di->slew_reg; |
| 492 | rdesc->ramp_mask = di->slew_mask; |
| 493 | rdesc->ramp_delay_table = di->ramp_delay_table; |
| 494 | rdesc->n_ramp_values = di->n_ramp_values; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 495 | rdesc->owner = THIS_MODULE; |
| 496 | |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 497 | rdev = devm_regulator_register(di->dev, &di->desc, config); |
| 498 | return PTR_ERR_OR_ZERO(rdev); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 499 | } |
| 500 | |
Krzysztof Kozlowski | 121b567 | 2015-01-05 10:04:19 +0100 | [diff] [blame] | 501 | static const struct regmap_config fan53555_regmap_config = { |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 502 | .reg_bits = 8, |
| 503 | .val_bits = 8, |
| 504 | }; |
| 505 | |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 506 | static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev, |
Javier Martinez Canillas | 072e78b | 2014-11-10 14:43:53 +0100 | [diff] [blame] | 507 | struct device_node *np, |
| 508 | const struct regulator_desc *desc) |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 509 | { |
| 510 | struct fan53555_platform_data *pdata; |
| 511 | int ret; |
| 512 | u32 tmp; |
| 513 | |
| 514 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
| 515 | if (!pdata) |
| 516 | return NULL; |
| 517 | |
Javier Martinez Canillas | 072e78b | 2014-11-10 14:43:53 +0100 | [diff] [blame] | 518 | pdata->regulator = of_get_regulator_init_data(dev, np, desc); |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 519 | |
| 520 | ret = of_property_read_u32(np, "fcs,suspend-voltage-selector", |
| 521 | &tmp); |
| 522 | if (!ret) |
| 523 | pdata->sleep_vsel_id = tmp; |
| 524 | |
| 525 | return pdata; |
| 526 | } |
| 527 | |
Jisheng Zhang | 5e97d7e | 2020-08-21 11:13:24 +0800 | [diff] [blame] | 528 | static const struct of_device_id __maybe_unused fan53555_dt_ids[] = { |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 529 | { |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 530 | .compatible = "fcs,fan53526", |
| 531 | .data = (void *)FAN53526_VENDOR_FAIRCHILD, |
| 532 | }, { |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 533 | .compatible = "fcs,fan53555", |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 534 | .data = (void *)FAN53555_VENDOR_FAIRCHILD |
| 535 | }, { |
| 536 | .compatible = "silergy,syr827", |
| 537 | .data = (void *)FAN53555_VENDOR_SILERGY, |
| 538 | }, { |
| 539 | .compatible = "silergy,syr828", |
| 540 | .data = (void *)FAN53555_VENDOR_SILERGY, |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 541 | }, { |
| 542 | .compatible = "tcs,tcs4525", |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 543 | .data = (void *)FAN53526_VENDOR_TCS |
Rudi Heitbaum | 5eee5ec | 2021-06-02 11:29:47 +0000 | [diff] [blame] | 544 | }, { |
| 545 | .compatible = "tcs,tcs4526", |
| 546 | .data = (void *)FAN53526_VENDOR_TCS |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 547 | }, |
| 548 | { } |
| 549 | }; |
| 550 | MODULE_DEVICE_TABLE(of, fan53555_dt_ids); |
| 551 | |
Bill Pemberton | a502357 | 2012-11-19 13:22:22 -0500 | [diff] [blame] | 552 | static int fan53555_regulator_probe(struct i2c_client *client, |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 553 | const struct i2c_device_id *id) |
| 554 | { |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 555 | struct device_node *np = client->dev.of_node; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 556 | struct fan53555_device_info *di; |
| 557 | struct fan53555_platform_data *pdata; |
| 558 | struct regulator_config config = { }; |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 559 | struct regmap *regmap; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 560 | unsigned int val; |
| 561 | int ret; |
| 562 | |
Javier Martinez Canillas | 072e78b | 2014-11-10 14:43:53 +0100 | [diff] [blame] | 563 | di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info), |
| 564 | GFP_KERNEL); |
| 565 | if (!di) |
| 566 | return -ENOMEM; |
| 567 | |
Jingoo Han | dff91d0 | 2013-07-30 17:20:47 +0900 | [diff] [blame] | 568 | pdata = dev_get_platdata(&client->dev); |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 569 | if (!pdata) |
Javier Martinez Canillas | 072e78b | 2014-11-10 14:43:53 +0100 | [diff] [blame] | 570 | pdata = fan53555_parse_dt(&client->dev, np, &di->desc); |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 571 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 572 | if (!pdata || !pdata->regulator) { |
| 573 | dev_err(&client->dev, "Platform data not found!\n"); |
| 574 | return -ENODEV; |
| 575 | } |
| 576 | |
Axel Lin | e13426b | 2014-09-18 21:49:38 +0800 | [diff] [blame] | 577 | di->regulator = pdata->regulator; |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 578 | if (client->dev.of_node) { |
Jisheng Zhang | d110e3e | 2017-07-20 16:42:17 +0800 | [diff] [blame] | 579 | di->vendor = |
| 580 | (unsigned long)of_device_get_match_data(&client->dev); |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 581 | } else { |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 582 | /* if no ramp constraint set, get the pdata ramp_delay */ |
| 583 | if (!di->regulator->constraints.ramp_delay) { |
Axel Lin | 87919e0 | 2019-02-24 11:21:46 +0800 | [diff] [blame] | 584 | if (pdata->slew_rate >= ARRAY_SIZE(slew_rates)) { |
| 585 | dev_err(&client->dev, "Invalid slew_rate\n"); |
| 586 | return -EINVAL; |
| 587 | } |
Heiko Stuebner | dd7e71f | 2014-09-16 17:54:01 +0200 | [diff] [blame] | 588 | |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 589 | di->regulator->constraints.ramp_delay |
Axel Lin | 87919e0 | 2019-02-24 11:21:46 +0800 | [diff] [blame] | 590 | = slew_rates[pdata->slew_rate]; |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 591 | } |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 592 | |
| 593 | di->vendor = id->driver_data; |
Heiko Stuebner | dd7e71f | 2014-09-16 17:54:01 +0200 | [diff] [blame] | 594 | } |
| 595 | |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 596 | regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); |
| 597 | if (IS_ERR(regmap)) { |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 598 | dev_err(&client->dev, "Failed to allocate regmap!\n"); |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 599 | return PTR_ERR(regmap); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 600 | } |
| 601 | di->dev = &client->dev; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 602 | i2c_set_clientdata(client, di); |
| 603 | /* Get chip ID */ |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 604 | ret = regmap_read(regmap, FAN53555_ID1, &val); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 605 | if (ret < 0) { |
| 606 | dev_err(&client->dev, "Failed to get chip ID!\n"); |
Sachin Kamat | 145fe1e | 2014-02-18 16:11:04 +0530 | [diff] [blame] | 607 | return ret; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 608 | } |
| 609 | di->chip_id = val & DIE_ID; |
| 610 | /* Get chip revision */ |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 611 | ret = regmap_read(regmap, FAN53555_ID2, &val); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 612 | if (ret < 0) { |
| 613 | dev_err(&client->dev, "Failed to get chip Rev!\n"); |
Sachin Kamat | 145fe1e | 2014-02-18 16:11:04 +0530 | [diff] [blame] | 614 | return ret; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 615 | } |
| 616 | di->chip_rev = val & DIE_REV; |
| 617 | dev_info(&client->dev, "FAN53555 Option[%d] Rev[%d] Detected!\n", |
| 618 | di->chip_id, di->chip_rev); |
| 619 | /* Device init */ |
| 620 | ret = fan53555_device_setup(di, pdata); |
| 621 | if (ret < 0) { |
| 622 | dev_err(&client->dev, "Failed to setup device!\n"); |
| 623 | return ret; |
| 624 | } |
| 625 | /* Register regulator */ |
| 626 | config.dev = di->dev; |
| 627 | config.init_data = di->regulator; |
Axel Lin | a69929c | 2019-04-19 08:58:23 +0800 | [diff] [blame] | 628 | config.regmap = regmap; |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 629 | config.driver_data = di; |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 630 | config.of_node = np; |
| 631 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 632 | ret = fan53555_regulator_register(di, &config); |
| 633 | if (ret < 0) |
| 634 | dev_err(&client->dev, "Failed to register regulator!\n"); |
| 635 | return ret; |
| 636 | |
| 637 | } |
| 638 | |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 639 | static const struct i2c_device_id fan53555_id[] = { |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 640 | { |
Bjorn Andersson | f2a9eb9 | 2019-02-20 16:43:03 -0800 | [diff] [blame] | 641 | .name = "fan53526", |
| 642 | .driver_data = FAN53526_VENDOR_FAIRCHILD |
| 643 | }, { |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 644 | .name = "fan53555", |
| 645 | .driver_data = FAN53555_VENDOR_FAIRCHILD |
| 646 | }, { |
Guillaume Tucker | fc1111b | 2017-08-21 13:47:43 +0100 | [diff] [blame] | 647 | .name = "syr827", |
| 648 | .driver_data = FAN53555_VENDOR_SILERGY |
| 649 | }, { |
| 650 | .name = "syr828", |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 651 | .driver_data = FAN53555_VENDOR_SILERGY |
Joseph Chen | 914df8f | 2021-04-21 18:03:38 -0300 | [diff] [blame] | 652 | }, { |
| 653 | .name = "tcs4525", |
Peter Geis | b3cc8ec | 2021-05-11 17:13:35 -0400 | [diff] [blame] | 654 | .driver_data = FAN53526_VENDOR_TCS |
Rudi Heitbaum | 5eee5ec | 2021-06-02 11:29:47 +0000 | [diff] [blame] | 655 | }, { |
| 656 | .name = "tcs4526", |
| 657 | .driver_data = FAN53526_VENDOR_TCS |
Heiko Stuebner | ee30928 | 2014-09-16 21:22:54 +0200 | [diff] [blame] | 658 | }, |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 659 | { }, |
| 660 | }; |
Javier Martinez Canillas | e80c47b | 2015-07-30 18:18:40 +0200 | [diff] [blame] | 661 | MODULE_DEVICE_TABLE(i2c, fan53555_id); |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 662 | |
| 663 | static struct i2c_driver fan53555_regulator_driver = { |
| 664 | .driver = { |
| 665 | .name = "fan53555-regulator", |
Heiko Stuebner | 91f23d8 | 2014-09-16 21:22:53 +0200 | [diff] [blame] | 666 | .of_match_table = of_match_ptr(fan53555_dt_ids), |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 667 | }, |
| 668 | .probe = fan53555_regulator_probe, |
Yunfan Zhang | 49d8c59 | 2012-09-08 03:52:18 -0700 | [diff] [blame] | 669 | .id_table = fan53555_id, |
| 670 | }; |
| 671 | |
| 672 | module_i2c_driver(fan53555_regulator_driver); |
| 673 | |
| 674 | MODULE_AUTHOR("Yunfan Zhang <yfzhang@marvell.com>"); |
| 675 | MODULE_DESCRIPTION("FAN53555 regulator driver"); |
| 676 | MODULE_LICENSE("GPL v2"); |