Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Voltage regulation driver for active-semi ACT8945A PMIC |
| 4 | * |
| 5 | * Copyright (C) 2015 Atmel Corporation |
| 6 | * |
| 7 | * Author: Wenyou Yang <wenyou.yang@atmel.com> |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/of_device.h> |
| 12 | #include <linux/platform_device.h> |
Claudiu Beznea | 90bc8ac2 | 2018-12-11 15:56:36 +0000 | [diff] [blame] | 13 | #include <linux/regmap.h> |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 14 | #include <linux/regulator/driver.h> |
| 15 | #include <linux/regulator/machine.h> |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 16 | #include <dt-bindings/regulator/active-semi,8945a-regulator.h> |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * ACT8945A Global Register Map. |
| 20 | */ |
| 21 | #define ACT8945A_SYS_MODE 0x00 |
| 22 | #define ACT8945A_SYS_CTRL 0x01 |
Claudiu Beznea | 90bc8ac2 | 2018-12-11 15:56:36 +0000 | [diff] [blame] | 23 | #define ACT8945A_SYS_UNLK_REGS 0x0b |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 24 | #define ACT8945A_DCDC1_VSET1 0x20 |
| 25 | #define ACT8945A_DCDC1_VSET2 0x21 |
| 26 | #define ACT8945A_DCDC1_CTRL 0x22 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 27 | #define ACT8945A_DCDC1_SUS 0x24 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 28 | #define ACT8945A_DCDC2_VSET1 0x30 |
| 29 | #define ACT8945A_DCDC2_VSET2 0x31 |
| 30 | #define ACT8945A_DCDC2_CTRL 0x32 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 31 | #define ACT8945A_DCDC2_SUS 0x34 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 32 | #define ACT8945A_DCDC3_VSET1 0x40 |
| 33 | #define ACT8945A_DCDC3_VSET2 0x41 |
| 34 | #define ACT8945A_DCDC3_CTRL 0x42 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 35 | #define ACT8945A_DCDC3_SUS 0x44 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 36 | #define ACT8945A_LDO1_VSET 0x50 |
| 37 | #define ACT8945A_LDO1_CTRL 0x51 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 38 | #define ACT8945A_LDO1_SUS 0x52 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 39 | #define ACT8945A_LDO2_VSET 0x54 |
| 40 | #define ACT8945A_LDO2_CTRL 0x55 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 41 | #define ACT8945A_LDO2_SUS 0x56 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 42 | #define ACT8945A_LDO3_VSET 0x60 |
| 43 | #define ACT8945A_LDO3_CTRL 0x61 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 44 | #define ACT8945A_LDO3_SUS 0x62 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 45 | #define ACT8945A_LDO4_VSET 0x64 |
| 46 | #define ACT8945A_LDO4_CTRL 0x65 |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 47 | #define ACT8945A_LDO4_SUS 0x66 |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Field Definitions. |
| 51 | */ |
| 52 | #define ACT8945A_ENA 0x80 /* ON - [7] */ |
| 53 | #define ACT8945A_VSEL_MASK 0x3F /* VSET - [5:0] */ |
| 54 | |
| 55 | /** |
| 56 | * ACT8945A Voltage Number |
| 57 | */ |
| 58 | #define ACT8945A_VOLTAGE_NUM 64 |
| 59 | |
| 60 | enum { |
| 61 | ACT8945A_ID_DCDC1, |
| 62 | ACT8945A_ID_DCDC2, |
| 63 | ACT8945A_ID_DCDC3, |
| 64 | ACT8945A_ID_LDO1, |
| 65 | ACT8945A_ID_LDO2, |
| 66 | ACT8945A_ID_LDO3, |
| 67 | ACT8945A_ID_LDO4, |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 68 | ACT8945A_ID_MAX, |
| 69 | }; |
| 70 | |
| 71 | struct act8945a_pmic { |
| 72 | struct regmap *regmap; |
| 73 | u32 op_mode[ACT8945A_ID_MAX]; |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 74 | }; |
| 75 | |
Matti Vaittinen | 60ab7f4 | 2020-05-08 18:43:36 +0300 | [diff] [blame] | 76 | static const struct linear_range act8945a_voltage_ranges[] = { |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 77 | REGULATOR_LINEAR_RANGE(600000, 0, 23, 25000), |
| 78 | REGULATOR_LINEAR_RANGE(1200000, 24, 47, 50000), |
| 79 | REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000), |
| 80 | }; |
| 81 | |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 82 | static int act8945a_set_suspend_state(struct regulator_dev *rdev, bool enable) |
| 83 | { |
| 84 | struct regmap *regmap = rdev->regmap; |
Axel Lin | 557ce9d | 2019-01-04 22:42:36 +0800 | [diff] [blame] | 85 | int id = rdev_get_id(rdev); |
| 86 | int reg, val; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 87 | |
| 88 | switch (id) { |
| 89 | case ACT8945A_ID_DCDC1: |
| 90 | reg = ACT8945A_DCDC1_SUS; |
| 91 | val = 0xa8; |
| 92 | break; |
| 93 | case ACT8945A_ID_DCDC2: |
| 94 | reg = ACT8945A_DCDC2_SUS; |
| 95 | val = 0xa8; |
| 96 | break; |
| 97 | case ACT8945A_ID_DCDC3: |
| 98 | reg = ACT8945A_DCDC3_SUS; |
| 99 | val = 0xa8; |
| 100 | break; |
| 101 | case ACT8945A_ID_LDO1: |
| 102 | reg = ACT8945A_LDO1_SUS; |
| 103 | val = 0xe8; |
| 104 | break; |
| 105 | case ACT8945A_ID_LDO2: |
| 106 | reg = ACT8945A_LDO2_SUS; |
| 107 | val = 0xe8; |
| 108 | break; |
| 109 | case ACT8945A_ID_LDO3: |
| 110 | reg = ACT8945A_LDO3_SUS; |
| 111 | val = 0xe8; |
| 112 | break; |
| 113 | case ACT8945A_ID_LDO4: |
| 114 | reg = ACT8945A_LDO4_SUS; |
| 115 | val = 0xe8; |
| 116 | break; |
| 117 | default: |
| 118 | return -EINVAL; |
| 119 | } |
| 120 | |
| 121 | if (enable) |
| 122 | val |= BIT(4); |
| 123 | |
| 124 | /* |
| 125 | * Ask the PMIC to enable/disable this output when entering hibernate |
| 126 | * mode. |
| 127 | */ |
| 128 | return regmap_write(regmap, reg, val); |
| 129 | } |
| 130 | |
| 131 | static int act8945a_set_suspend_enable(struct regulator_dev *rdev) |
| 132 | { |
| 133 | return act8945a_set_suspend_state(rdev, true); |
| 134 | } |
| 135 | |
| 136 | static int act8945a_set_suspend_disable(struct regulator_dev *rdev) |
| 137 | { |
| 138 | return act8945a_set_suspend_state(rdev, false); |
| 139 | } |
| 140 | |
| 141 | static unsigned int act8945a_of_map_mode(unsigned int mode) |
| 142 | { |
| 143 | switch (mode) { |
| 144 | case ACT8945A_REGULATOR_MODE_FIXED: |
| 145 | case ACT8945A_REGULATOR_MODE_NORMAL: |
| 146 | return REGULATOR_MODE_NORMAL; |
| 147 | case ACT8945A_REGULATOR_MODE_LOWPOWER: |
| 148 | return REGULATOR_MODE_STANDBY; |
| 149 | default: |
| 150 | return REGULATOR_MODE_INVALID; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | static int act8945a_set_mode(struct regulator_dev *rdev, unsigned int mode) |
| 155 | { |
| 156 | struct act8945a_pmic *act8945a = rdev_get_drvdata(rdev); |
| 157 | struct regmap *regmap = rdev->regmap; |
Axel Lin | 557ce9d | 2019-01-04 22:42:36 +0800 | [diff] [blame] | 158 | int id = rdev_get_id(rdev); |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 159 | int reg, ret, val = 0; |
| 160 | |
| 161 | switch (id) { |
| 162 | case ACT8945A_ID_DCDC1: |
| 163 | reg = ACT8945A_DCDC1_CTRL; |
| 164 | break; |
| 165 | case ACT8945A_ID_DCDC2: |
| 166 | reg = ACT8945A_DCDC2_CTRL; |
| 167 | break; |
| 168 | case ACT8945A_ID_DCDC3: |
| 169 | reg = ACT8945A_DCDC3_CTRL; |
| 170 | break; |
| 171 | case ACT8945A_ID_LDO1: |
Raag Jadav | 5d2fc54 | 2019-08-13 00:09:54 +0530 | [diff] [blame] | 172 | reg = ACT8945A_LDO1_CTRL; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 173 | break; |
| 174 | case ACT8945A_ID_LDO2: |
Raag Jadav | 5d2fc54 | 2019-08-13 00:09:54 +0530 | [diff] [blame] | 175 | reg = ACT8945A_LDO2_CTRL; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 176 | break; |
| 177 | case ACT8945A_ID_LDO3: |
Raag Jadav | 5d2fc54 | 2019-08-13 00:09:54 +0530 | [diff] [blame] | 178 | reg = ACT8945A_LDO3_CTRL; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 179 | break; |
| 180 | case ACT8945A_ID_LDO4: |
Raag Jadav | 5d2fc54 | 2019-08-13 00:09:54 +0530 | [diff] [blame] | 181 | reg = ACT8945A_LDO4_CTRL; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 182 | break; |
| 183 | default: |
| 184 | return -EINVAL; |
| 185 | } |
| 186 | |
| 187 | switch (mode) { |
| 188 | case REGULATOR_MODE_STANDBY: |
Axel Lin | 557ce9d | 2019-01-04 22:42:36 +0800 | [diff] [blame] | 189 | if (id > ACT8945A_ID_DCDC3) |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 190 | val = BIT(5); |
| 191 | break; |
| 192 | case REGULATOR_MODE_NORMAL: |
Axel Lin | 557ce9d | 2019-01-04 22:42:36 +0800 | [diff] [blame] | 193 | if (id <= ACT8945A_ID_DCDC3) |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 194 | val = BIT(5); |
| 195 | break; |
| 196 | default: |
| 197 | return -EINVAL; |
| 198 | } |
| 199 | |
| 200 | ret = regmap_update_bits(regmap, reg, BIT(5), val); |
| 201 | if (ret) |
| 202 | return ret; |
| 203 | |
| 204 | act8945a->op_mode[id] = mode; |
| 205 | |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static unsigned int act8945a_get_mode(struct regulator_dev *rdev) |
| 210 | { |
| 211 | struct act8945a_pmic *act8945a = rdev_get_drvdata(rdev); |
Axel Lin | 557ce9d | 2019-01-04 22:42:36 +0800 | [diff] [blame] | 212 | int id = rdev_get_id(rdev); |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 213 | |
| 214 | if (id < ACT8945A_ID_DCDC1 || id >= ACT8945A_ID_MAX) |
| 215 | return -EINVAL; |
| 216 | |
| 217 | return act8945a->op_mode[id]; |
| 218 | } |
| 219 | |
Bhumika Goyal | 1ed1da3 | 2017-01-28 19:03:28 +0530 | [diff] [blame] | 220 | static const struct regulator_ops act8945a_ops = { |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 221 | .list_voltage = regulator_list_voltage_linear_range, |
| 222 | .map_voltage = regulator_map_voltage_linear_range, |
| 223 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 224 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 225 | .enable = regulator_enable_regmap, |
| 226 | .disable = regulator_disable_regmap, |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 227 | .set_mode = act8945a_set_mode, |
| 228 | .get_mode = act8945a_get_mode, |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 229 | .is_enabled = regulator_is_enabled_regmap, |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 230 | .set_suspend_enable = act8945a_set_suspend_enable, |
| 231 | .set_suspend_disable = act8945a_set_suspend_disable, |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | #define ACT89xx_REG(_name, _family, _id, _vsel_reg, _supply) \ |
| 235 | [_family##_ID_##_id] = { \ |
| 236 | .name = _name, \ |
| 237 | .supply_name = _supply, \ |
| 238 | .of_match = of_match_ptr("REG_"#_id), \ |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 239 | .of_map_mode = act8945a_of_map_mode, \ |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 240 | .regulators_node = of_match_ptr("regulators"), \ |
| 241 | .id = _family##_ID_##_id, \ |
| 242 | .type = REGULATOR_VOLTAGE, \ |
| 243 | .ops = &act8945a_ops, \ |
| 244 | .n_voltages = ACT8945A_VOLTAGE_NUM, \ |
| 245 | .linear_ranges = act8945a_voltage_ranges, \ |
| 246 | .n_linear_ranges = ARRAY_SIZE(act8945a_voltage_ranges), \ |
| 247 | .vsel_reg = _family##_##_id##_##_vsel_reg, \ |
| 248 | .vsel_mask = ACT8945A_VSEL_MASK, \ |
| 249 | .enable_reg = _family##_##_id##_CTRL, \ |
| 250 | .enable_mask = ACT8945A_ENA, \ |
| 251 | .owner = THIS_MODULE, \ |
| 252 | } |
| 253 | |
| 254 | static const struct regulator_desc act8945a_regulators[] = { |
| 255 | ACT89xx_REG("DCDC_REG1", ACT8945A, DCDC1, VSET1, "vp1"), |
| 256 | ACT89xx_REG("DCDC_REG2", ACT8945A, DCDC2, VSET1, "vp2"), |
| 257 | ACT89xx_REG("DCDC_REG3", ACT8945A, DCDC3, VSET1, "vp3"), |
| 258 | ACT89xx_REG("LDO_REG1", ACT8945A, LDO1, VSET, "inl45"), |
| 259 | ACT89xx_REG("LDO_REG2", ACT8945A, LDO2, VSET, "inl45"), |
| 260 | ACT89xx_REG("LDO_REG3", ACT8945A, LDO3, VSET, "inl67"), |
| 261 | ACT89xx_REG("LDO_REG4", ACT8945A, LDO4, VSET, "inl67"), |
| 262 | }; |
| 263 | |
| 264 | static const struct regulator_desc act8945a_alt_regulators[] = { |
| 265 | ACT89xx_REG("DCDC_REG1", ACT8945A, DCDC1, VSET2, "vp1"), |
| 266 | ACT89xx_REG("DCDC_REG2", ACT8945A, DCDC2, VSET2, "vp2"), |
| 267 | ACT89xx_REG("DCDC_REG3", ACT8945A, DCDC3, VSET2, "vp3"), |
| 268 | ACT89xx_REG("LDO_REG1", ACT8945A, LDO1, VSET, "inl45"), |
| 269 | ACT89xx_REG("LDO_REG2", ACT8945A, LDO2, VSET, "inl45"), |
| 270 | ACT89xx_REG("LDO_REG3", ACT8945A, LDO3, VSET, "inl67"), |
| 271 | ACT89xx_REG("LDO_REG4", ACT8945A, LDO4, VSET, "inl67"), |
| 272 | }; |
| 273 | |
| 274 | static int act8945a_pmic_probe(struct platform_device *pdev) |
| 275 | { |
| 276 | struct regulator_config config = { }; |
| 277 | const struct regulator_desc *regulators; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 278 | struct act8945a_pmic *act8945a; |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 279 | struct regulator_dev *rdev; |
| 280 | int i, num_regulators; |
| 281 | bool voltage_select; |
| 282 | |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 283 | act8945a = devm_kzalloc(&pdev->dev, sizeof(*act8945a), GFP_KERNEL); |
| 284 | if (!act8945a) |
| 285 | return -ENOMEM; |
| 286 | |
| 287 | act8945a->regmap = dev_get_regmap(pdev->dev.parent, NULL); |
| 288 | if (!act8945a->regmap) { |
Claudiu Beznea | 90bc8ac2 | 2018-12-11 15:56:36 +0000 | [diff] [blame] | 289 | dev_err(&pdev->dev, |
| 290 | "could not retrieve regmap from parent device\n"); |
| 291 | return -EINVAL; |
| 292 | } |
| 293 | |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 294 | voltage_select = of_property_read_bool(pdev->dev.parent->of_node, |
| 295 | "active-semi,vsel-high"); |
| 296 | |
| 297 | if (voltage_select) { |
| 298 | regulators = act8945a_alt_regulators; |
| 299 | num_regulators = ARRAY_SIZE(act8945a_alt_regulators); |
| 300 | } else { |
| 301 | regulators = act8945a_regulators; |
| 302 | num_regulators = ARRAY_SIZE(act8945a_regulators); |
| 303 | } |
| 304 | |
| 305 | config.dev = &pdev->dev; |
| 306 | config.dev->of_node = pdev->dev.parent->of_node; |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 307 | config.driver_data = act8945a; |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 308 | for (i = 0; i < num_regulators; i++) { |
Claudiu Beznea | 03ffbf9 | 2018-12-11 15:56:45 +0000 | [diff] [blame] | 309 | rdev = devm_regulator_register(&pdev->dev, ®ulators[i], |
| 310 | &config); |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 311 | if (IS_ERR(rdev)) { |
| 312 | dev_err(&pdev->dev, |
| 313 | "failed to register %s regulator\n", |
| 314 | regulators[i].name); |
| 315 | return PTR_ERR(rdev); |
| 316 | } |
| 317 | } |
| 318 | |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 319 | platform_set_drvdata(pdev, act8945a); |
| 320 | |
Claudiu Beznea | 90bc8ac2 | 2018-12-11 15:56:36 +0000 | [diff] [blame] | 321 | /* Unlock expert registers. */ |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 322 | return regmap_write(act8945a->regmap, ACT8945A_SYS_UNLK_REGS, 0xef); |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 323 | } |
| 324 | |
Claudiu Beznea | 22a5a4a | 2018-12-17 10:37:51 +0000 | [diff] [blame] | 325 | static int __maybe_unused act8945a_suspend(struct device *pdev) |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 326 | { |
| 327 | struct act8945a_pmic *act8945a = dev_get_drvdata(pdev); |
| 328 | |
| 329 | /* |
| 330 | * Ask the PMIC to enter the suspend mode on the next PWRHLD |
| 331 | * transition. |
| 332 | */ |
| 333 | return regmap_write(act8945a->regmap, ACT8945A_SYS_CTRL, 0x42); |
| 334 | } |
| 335 | |
Wei Yongjun | 78e6fbf | 2018-12-18 07:10:21 +0000 | [diff] [blame] | 336 | static SIMPLE_DEV_PM_OPS(act8945a_pm, act8945a_suspend, NULL); |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 337 | |
Claudiu Beznea | b5ebba4 | 2018-12-11 15:56:50 +0000 | [diff] [blame] | 338 | static void act8945a_pmic_shutdown(struct platform_device *pdev) |
| 339 | { |
| 340 | struct act8945a_pmic *act8945a = platform_get_drvdata(pdev); |
| 341 | |
| 342 | /* |
| 343 | * Ask the PMIC to shutdown everything on the next PWRHLD transition. |
| 344 | */ |
| 345 | regmap_write(act8945a->regmap, ACT8945A_SYS_CTRL, 0x0); |
| 346 | } |
| 347 | |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 348 | static struct platform_driver act8945a_pmic_driver = { |
| 349 | .driver = { |
| 350 | .name = "act8945a-regulator", |
Boris Brezillon | 7482d6ec | 2018-12-11 15:56:41 +0000 | [diff] [blame] | 351 | .pm = &act8945a_pm, |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 352 | }, |
| 353 | .probe = act8945a_pmic_probe, |
Claudiu Beznea | b5ebba4 | 2018-12-11 15:56:50 +0000 | [diff] [blame] | 354 | .shutdown = act8945a_pmic_shutdown, |
Wenyou Yang | 38c0996 | 2016-02-05 12:33:30 +0800 | [diff] [blame] | 355 | }; |
| 356 | module_platform_driver(act8945a_pmic_driver); |
| 357 | |
| 358 | MODULE_DESCRIPTION("Active-semi ACT8945A voltage regulator driver"); |
| 359 | MODULE_AUTHOR("Wenyou Yang <wenyou.yang@atmel.com>"); |
| 360 | MODULE_LICENSE("GPL"); |