| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Regulator driver for RICOH RC5T583 power management chip. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * based on code |
|---|
| 8 | 9 | * Copyright (C) 2011 RICOH COMPANY,LTD |
|---|
| 9 | | - * |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 12 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 13 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 16 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 17 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 18 | | - * more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 22 | | - * |
|---|
| 23 | 10 | */ |
|---|
| 24 | 11 | |
|---|
| 25 | 12 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 47 | 34 | struct regulator_desc desc; |
|---|
| 48 | 35 | }; |
|---|
| 49 | 36 | |
|---|
| 50 | | -struct rc5t583_regulator { |
|---|
| 51 | | - struct rc5t583_regulator_info *reg_info; |
|---|
| 52 | | - struct regulator_dev *rdev; |
|---|
| 53 | | -}; |
|---|
| 54 | | - |
|---|
| 55 | 37 | static int rc5t583_regulator_enable_time(struct regulator_dev *rdev) |
|---|
| 56 | 38 | { |
|---|
| 57 | | - struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); |
|---|
| 39 | + struct rc5t583_regulator_info *reg_info = rdev_get_drvdata(rdev); |
|---|
| 58 | 40 | int vsel = regulator_get_voltage_sel_regmap(rdev); |
|---|
| 59 | 41 | int curr_uV = regulator_list_voltage_linear(rdev, vsel); |
|---|
| 60 | 42 | |
|---|
| 61 | | - return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us); |
|---|
| 43 | + return DIV_ROUND_UP(curr_uV, reg_info->enable_uv_per_us); |
|---|
| 62 | 44 | } |
|---|
| 63 | 45 | |
|---|
| 64 | 46 | static const struct regulator_ops rc5t583_ops = { |
|---|
| .. | .. |
|---|
| 120 | 102 | struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent); |
|---|
| 121 | 103 | struct rc5t583_platform_data *pdata = dev_get_platdata(rc5t583->dev); |
|---|
| 122 | 104 | struct regulator_config config = { }; |
|---|
| 123 | | - struct rc5t583_regulator *reg = NULL; |
|---|
| 124 | | - struct rc5t583_regulator *regs; |
|---|
| 125 | 105 | struct regulator_dev *rdev; |
|---|
| 126 | 106 | struct rc5t583_regulator_info *ri; |
|---|
| 127 | 107 | int ret; |
|---|
| .. | .. |
|---|
| 132 | 112 | return -ENODEV; |
|---|
| 133 | 113 | } |
|---|
| 134 | 114 | |
|---|
| 135 | | - regs = devm_kcalloc(&pdev->dev, |
|---|
| 136 | | - RC5T583_REGULATOR_MAX, |
|---|
| 137 | | - sizeof(struct rc5t583_regulator), |
|---|
| 138 | | - GFP_KERNEL); |
|---|
| 139 | | - if (!regs) |
|---|
| 140 | | - return -ENOMEM; |
|---|
| 141 | | - |
|---|
| 142 | | - |
|---|
| 143 | 115 | for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) { |
|---|
| 144 | | - reg = ®s[id]; |
|---|
| 145 | 116 | ri = &rc5t583_reg_info[id]; |
|---|
| 146 | | - reg->reg_info = ri; |
|---|
| 147 | 117 | |
|---|
| 148 | 118 | if (ri->deepsleep_id == RC5T583_DS_NONE) |
|---|
| 149 | 119 | goto skip_ext_pwr_config; |
|---|
| .. | .. |
|---|
| 163 | 133 | skip_ext_pwr_config: |
|---|
| 164 | 134 | config.dev = &pdev->dev; |
|---|
| 165 | 135 | config.init_data = pdata->reg_init_data[id]; |
|---|
| 166 | | - config.driver_data = reg; |
|---|
| 136 | + config.driver_data = ri; |
|---|
| 167 | 137 | config.regmap = rc5t583->regmap; |
|---|
| 168 | 138 | |
|---|
| 169 | 139 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
|---|
| .. | .. |
|---|
| 172 | 142 | ri->desc.name); |
|---|
| 173 | 143 | return PTR_ERR(rdev); |
|---|
| 174 | 144 | } |
|---|
| 175 | | - reg->rdev = rdev; |
|---|
| 176 | 145 | } |
|---|
| 177 | | - platform_set_drvdata(pdev, regs); |
|---|
| 178 | 146 | return 0; |
|---|
| 179 | 147 | } |
|---|
| 180 | 148 | |
|---|