| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * tps80031-regulator.c -- TI TPS80031 regulator driver. |
|---|
| 3 | | - * |
|---|
| 4 | | - * Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power |
|---|
| 5 | | - * Management with Power Path and Battery Charger. |
|---|
| 6 | | - * |
|---|
| 7 | | - * Copyright (c) 2012, NVIDIA Corporation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * Author: Laxman Dewangan <ldewangan@nvidia.com> |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or |
|---|
| 12 | | - * modify it under the terms of the GNU General Public License as |
|---|
| 13 | | - * published by the Free Software Foundation version 2. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, |
|---|
| 16 | | - * whether express or implied; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 18 | | - * General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program; if not, write to the Free Software |
|---|
| 22 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|---|
| 23 | | - * 02111-1307, USA |
|---|
| 24 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +// |
|---|
| 3 | +// tps80031-regulator.c -- TI TPS80031 regulator driver. |
|---|
| 4 | +// |
|---|
| 5 | +// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power |
|---|
| 6 | +// Management with Power Path and Battery Charger. |
|---|
| 7 | +// |
|---|
| 8 | +// Copyright (c) 2012, NVIDIA Corporation. |
|---|
| 9 | +// |
|---|
| 10 | +// Author: Laxman Dewangan <ldewangan@nvidia.com> |
|---|
| 25 | 11 | |
|---|
| 26 | 12 | #include <linux/delay.h> |
|---|
| 27 | 13 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 85 | 71 | |
|---|
| 86 | 72 | struct tps80031_regulator { |
|---|
| 87 | 73 | struct device *dev; |
|---|
| 88 | | - struct regulator_dev *rdev; |
|---|
| 89 | 74 | struct tps80031_regulator_info *rinfo; |
|---|
| 90 | 75 | |
|---|
| 91 | 76 | u8 device_flags; |
|---|
| .. | .. |
|---|
| 155 | 140 | } |
|---|
| 156 | 141 | |
|---|
| 157 | 142 | /* DCDC voltages for the selector of 58 to 63 */ |
|---|
| 158 | | -static int tps80031_dcdc_voltages[4][5] = { |
|---|
| 143 | +static const int tps80031_dcdc_voltages[4][5] = { |
|---|
| 159 | 144 | { 1350, 1500, 1800, 1900, 2100}, |
|---|
| 160 | 145 | { 1350, 1500, 1800, 1900, 2100}, |
|---|
| 161 | 146 | { 2084, 2315, 2778, 2932, 3241}, |
|---|
| .. | .. |
|---|
| 286 | 271 | { |
|---|
| 287 | 272 | struct tps80031_regulator *ri = rdev_get_drvdata(rdev); |
|---|
| 288 | 273 | struct device *parent = to_tps80031_dev(rdev); |
|---|
| 289 | | - int ret = -EIO; |
|---|
| 274 | + int ret; |
|---|
| 290 | 275 | uint8_t ctrl1 = 0; |
|---|
| 291 | 276 | uint8_t ctrl3 = 0; |
|---|
| 292 | 277 | |
|---|
| .. | .. |
|---|
| 337 | 322 | { |
|---|
| 338 | 323 | struct tps80031_regulator *ri = rdev_get_drvdata(rdev); |
|---|
| 339 | 324 | struct device *parent = to_tps80031_dev(rdev); |
|---|
| 340 | | - int ret = 0; |
|---|
| 325 | + int ret; |
|---|
| 341 | 326 | |
|---|
| 342 | 327 | if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) { |
|---|
| 343 | 328 | ret = tps80031_write(parent, TPS80031_SLAVE_ID2, |
|---|
| .. | .. |
|---|
| 378 | 363 | return ret; |
|---|
| 379 | 364 | } |
|---|
| 380 | 365 | |
|---|
| 381 | | -static struct regulator_ops tps80031_dcdc_ops = { |
|---|
| 366 | +static const struct regulator_ops tps80031_dcdc_ops = { |
|---|
| 382 | 367 | .list_voltage = tps80031_dcdc_list_voltage, |
|---|
| 383 | 368 | .set_voltage_sel = tps80031_dcdc_set_voltage_sel, |
|---|
| 384 | 369 | .get_voltage_sel = tps80031_dcdc_get_voltage_sel, |
|---|
| .. | .. |
|---|
| 387 | 372 | .is_enabled = tps80031_reg_is_enabled, |
|---|
| 388 | 373 | }; |
|---|
| 389 | 374 | |
|---|
| 390 | | -static struct regulator_ops tps80031_ldo_ops = { |
|---|
| 375 | +static const struct regulator_ops tps80031_ldo_ops = { |
|---|
| 391 | 376 | .list_voltage = tps80031_ldo_list_voltage, |
|---|
| 392 | 377 | .map_voltage = tps80031_ldo_map_voltage, |
|---|
| 393 | 378 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
|---|
| .. | .. |
|---|
| 397 | 382 | .is_enabled = tps80031_reg_is_enabled, |
|---|
| 398 | 383 | }; |
|---|
| 399 | 384 | |
|---|
| 400 | | -static struct regulator_ops tps80031_vbus_sw_ops = { |
|---|
| 385 | +static const struct regulator_ops tps80031_vbus_sw_ops = { |
|---|
| 401 | 386 | .list_voltage = regulator_list_voltage_linear, |
|---|
| 402 | 387 | .enable = tps80031_vbus_enable, |
|---|
| 403 | 388 | .disable = tps80031_vbus_disable, |
|---|
| 404 | 389 | .is_enabled = tps80031_vbus_is_enabled, |
|---|
| 405 | 390 | }; |
|---|
| 406 | 391 | |
|---|
| 407 | | -static struct regulator_ops tps80031_vbus_hw_ops = { |
|---|
| 392 | +static const struct regulator_ops tps80031_vbus_hw_ops = { |
|---|
| 408 | 393 | .list_voltage = regulator_list_voltage_linear, |
|---|
| 409 | 394 | }; |
|---|
| 410 | 395 | |
|---|
| 411 | | -static struct regulator_ops tps80031_ext_reg_ops = { |
|---|
| 396 | +static const struct regulator_ops tps80031_ext_reg_ops = { |
|---|
| 412 | 397 | .list_voltage = regulator_list_voltage_linear, |
|---|
| 413 | 398 | .enable = tps80031_reg_enable, |
|---|
| 414 | 399 | .disable = tps80031_reg_disable, |
|---|
| .. | .. |
|---|
| 545 | 530 | case TPS80031_REGULATOR_LDOUSB: |
|---|
| 546 | 531 | if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS | |
|---|
| 547 | 532 | TPS80031_USBLDO_INPUT_PMID)) { |
|---|
| 548 | | - unsigned val = 0; |
|---|
| 533 | + unsigned val; |
|---|
| 534 | + |
|---|
| 549 | 535 | if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS) |
|---|
| 550 | 536 | val = MISC2_LDOUSB_IN_VSYS; |
|---|
| 551 | 537 | else |
|---|
| .. | .. |
|---|
| 736 | 722 | ri->rinfo->desc.name); |
|---|
| 737 | 723 | return PTR_ERR(rdev); |
|---|
| 738 | 724 | } |
|---|
| 739 | | - ri->rdev = rdev; |
|---|
| 740 | 725 | } |
|---|
| 741 | 726 | |
|---|
| 742 | 727 | platform_set_drvdata(pdev, pmic); |
|---|