| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * twl-regulator.c -- support regulators in twl4030/twl6030 family chips |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2008 David Brownell |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 363 | 359 | 2500, 2750, |
|---|
| 364 | 360 | }; |
|---|
| 365 | 361 | |
|---|
| 362 | +/* 600mV to 1450mV in 12.5 mV steps */ |
|---|
| 363 | +static const struct linear_range VDD1_ranges[] = { |
|---|
| 364 | + REGULATOR_LINEAR_RANGE(600000, 0, 68, 12500) |
|---|
| 365 | +}; |
|---|
| 366 | + |
|---|
| 367 | +/* 600mV to 1450mV in 12.5 mV steps, everything above = 1500mV */ |
|---|
| 368 | +static const struct linear_range VDD2_ranges[] = { |
|---|
| 369 | + REGULATOR_LINEAR_RANGE(600000, 0, 68, 12500), |
|---|
| 370 | + REGULATOR_LINEAR_RANGE(1500000, 69, 69, 12500) |
|---|
| 371 | +}; |
|---|
| 372 | + |
|---|
| 366 | 373 | static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) |
|---|
| 367 | 374 | { |
|---|
| 368 | 375 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
|---|
| .. | .. |
|---|
| 392 | 399 | return vsel; |
|---|
| 393 | 400 | } |
|---|
| 394 | 401 | |
|---|
| 395 | | -static struct regulator_ops twl4030ldo_ops = { |
|---|
| 402 | +static const struct regulator_ops twl4030ldo_ops = { |
|---|
| 396 | 403 | .list_voltage = twl4030ldo_list_voltage, |
|---|
| 397 | 404 | |
|---|
| 398 | 405 | .set_voltage_sel = twl4030ldo_set_voltage_sel, |
|---|
| .. | .. |
|---|
| 430 | 437 | return vsel * 12500 + 600000; |
|---|
| 431 | 438 | } |
|---|
| 432 | 439 | |
|---|
| 433 | | -static struct regulator_ops twl4030smps_ops = { |
|---|
| 440 | +static const struct regulator_ops twl4030smps_ops = { |
|---|
| 441 | + .list_voltage = regulator_list_voltage_linear_range, |
|---|
| 442 | + |
|---|
| 434 | 443 | .set_voltage = twl4030smps_set_voltage, |
|---|
| 435 | 444 | .get_voltage = twl4030smps_get_voltage, |
|---|
| 436 | 445 | }; |
|---|
| 437 | 446 | |
|---|
| 438 | 447 | /*----------------------------------------------------------------------*/ |
|---|
| 439 | 448 | |
|---|
| 440 | | -static struct regulator_ops twl4030fixed_ops = { |
|---|
| 449 | +static const struct regulator_ops twl4030fixed_ops = { |
|---|
| 441 | 450 | .list_voltage = regulator_list_voltage_linear, |
|---|
| 442 | 451 | |
|---|
| 443 | 452 | .enable = twl4030reg_enable, |
|---|
| .. | .. |
|---|
| 470 | 479 | }, \ |
|---|
| 471 | 480 | } |
|---|
| 472 | 481 | |
|---|
| 473 | | -#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \ |
|---|
| 482 | +#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf, \ |
|---|
| 483 | + n_volt) \ |
|---|
| 474 | 484 | static const struct twlreg_info TWL4030_INFO_##label = { \ |
|---|
| 475 | 485 | .base = offset, \ |
|---|
| 476 | 486 | .id = num, \ |
|---|
| .. | .. |
|---|
| 483 | 493 | .owner = THIS_MODULE, \ |
|---|
| 484 | 494 | .enable_time = turnon_delay, \ |
|---|
| 485 | 495 | .of_map_mode = twl4030reg_map_mode, \ |
|---|
| 496 | + .n_voltages = n_volt, \ |
|---|
| 497 | + .n_linear_ranges = ARRAY_SIZE(label ## _ranges), \ |
|---|
| 498 | + .linear_ranges = label ## _ranges, \ |
|---|
| 486 | 499 | }, \ |
|---|
| 487 | 500 | } |
|---|
| 488 | 501 | |
|---|
| .. | .. |
|---|
| 522 | 535 | TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08); |
|---|
| 523 | 536 | TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08); |
|---|
| 524 | 537 | TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08); |
|---|
| 525 | | -TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08); |
|---|
| 526 | | -TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08); |
|---|
| 538 | +TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08, 68); |
|---|
| 539 | +TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08, 69); |
|---|
| 527 | 540 | /* VUSBCP is managed *only* by the USB subchip */ |
|---|
| 528 | 541 | TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08); |
|---|
| 529 | 542 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08); |
|---|
| .. | .. |
|---|
| 576 | 589 | struct regulator_init_data *initdata; |
|---|
| 577 | 590 | struct regulation_constraints *c; |
|---|
| 578 | 591 | struct regulator_dev *rdev; |
|---|
| 579 | | - const struct of_device_id *match; |
|---|
| 580 | 592 | struct regulator_config config = { }; |
|---|
| 581 | 593 | |
|---|
| 582 | | - match = of_match_device(twl_of_match, &pdev->dev); |
|---|
| 583 | | - if (!match) |
|---|
| 584 | | - return -ENODEV; |
|---|
| 585 | | - |
|---|
| 586 | | - template = match->data; |
|---|
| 594 | + template = of_device_get_match_data(&pdev->dev); |
|---|
| 587 | 595 | if (!template) |
|---|
| 588 | 596 | return -ENODEV; |
|---|
| 589 | 597 | |
|---|