.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * drivers/regulator/ab3100.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2008-2009 ST-Ericsson AB |
---|
5 | | - * License terms: GNU General Public License (GPL) version 2 |
---|
6 | 6 | * Low-level control of the AB3100 IC Low Dropout (LDO) |
---|
7 | 7 | * regulators, external regulator and buck converter |
---|
8 | 8 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> |
---|
.. | .. |
---|
48 | 48 | * @regreg: regulator register number in the AB3100 |
---|
49 | 49 | */ |
---|
50 | 50 | struct ab3100_regulator { |
---|
51 | | - struct regulator_dev *rdev; |
---|
52 | 51 | struct device *dev; |
---|
53 | 52 | struct ab3100_platform_data *plfdata; |
---|
54 | 53 | u8 regreg; |
---|
.. | .. |
---|
354 | 353 | return 0; |
---|
355 | 354 | } |
---|
356 | 355 | |
---|
357 | | -static struct regulator_ops regulator_ops_fixed = { |
---|
358 | | - .list_voltage = regulator_list_voltage_linear, |
---|
| 356 | +static const struct regulator_ops regulator_ops_fixed = { |
---|
359 | 357 | .enable = ab3100_enable_regulator, |
---|
360 | 358 | .disable = ab3100_disable_regulator, |
---|
361 | 359 | .is_enabled = ab3100_is_enabled_regulator, |
---|
362 | 360 | }; |
---|
363 | 361 | |
---|
364 | | -static struct regulator_ops regulator_ops_variable = { |
---|
| 362 | +static const struct regulator_ops regulator_ops_variable = { |
---|
365 | 363 | .enable = ab3100_enable_regulator, |
---|
366 | 364 | .disable = ab3100_disable_regulator, |
---|
367 | 365 | .is_enabled = ab3100_is_enabled_regulator, |
---|
.. | .. |
---|
370 | 368 | .list_voltage = regulator_list_voltage_table, |
---|
371 | 369 | }; |
---|
372 | 370 | |
---|
373 | | -static struct regulator_ops regulator_ops_variable_sleepable = { |
---|
| 371 | +static const struct regulator_ops regulator_ops_variable_sleepable = { |
---|
374 | 372 | .enable = ab3100_enable_regulator, |
---|
375 | 373 | .disable = ab3100_disable_regulator, |
---|
376 | 374 | .is_enabled = ab3100_is_enabled_regulator, |
---|
.. | .. |
---|
386 | 384 | * is an on/off switch plain an simple. The external |
---|
387 | 385 | * voltage is defined in the board set-up if any. |
---|
388 | 386 | */ |
---|
389 | | -static struct regulator_ops regulator_ops_external = { |
---|
| 387 | +static const struct regulator_ops regulator_ops_external = { |
---|
390 | 388 | .enable = ab3100_enable_regulator, |
---|
391 | 389 | .disable = ab3100_disable_regulator, |
---|
392 | 390 | .is_enabled = ab3100_is_enabled_regulator, |
---|
393 | 391 | .get_voltage = ab3100_get_voltage_regulator_external, |
---|
394 | 392 | }; |
---|
395 | 393 | |
---|
396 | | -static struct regulator_desc |
---|
| 394 | +static const struct regulator_desc |
---|
397 | 395 | ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { |
---|
398 | 396 | { |
---|
399 | 397 | .name = "LDO_A", |
---|
.. | .. |
---|
402 | 400 | .n_voltages = 1, |
---|
403 | 401 | .type = REGULATOR_VOLTAGE, |
---|
404 | 402 | .owner = THIS_MODULE, |
---|
405 | | - .min_uV = LDO_A_VOLTAGE, |
---|
| 403 | + .fixed_uV = LDO_A_VOLTAGE, |
---|
406 | 404 | .enable_time = 200, |
---|
407 | 405 | }, |
---|
408 | 406 | { |
---|
.. | .. |
---|
412 | 410 | .n_voltages = 1, |
---|
413 | 411 | .type = REGULATOR_VOLTAGE, |
---|
414 | 412 | .owner = THIS_MODULE, |
---|
415 | | - .min_uV = LDO_C_VOLTAGE, |
---|
| 413 | + .fixed_uV = LDO_C_VOLTAGE, |
---|
416 | 414 | .enable_time = 200, |
---|
417 | 415 | }, |
---|
418 | 416 | { |
---|
.. | .. |
---|
422 | 420 | .n_voltages = 1, |
---|
423 | 421 | .type = REGULATOR_VOLTAGE, |
---|
424 | 422 | .owner = THIS_MODULE, |
---|
425 | | - .min_uV = LDO_D_VOLTAGE, |
---|
| 423 | + .fixed_uV = LDO_D_VOLTAGE, |
---|
426 | 424 | .enable_time = 200, |
---|
427 | 425 | }, |
---|
428 | 426 | { |
---|
.. | .. |
---|
500 | 498 | struct device_node *np, |
---|
501 | 499 | unsigned long id) |
---|
502 | 500 | { |
---|
503 | | - struct regulator_desc *desc; |
---|
| 501 | + const struct regulator_desc *desc; |
---|
504 | 502 | struct ab3100_regulator *reg; |
---|
505 | 503 | struct regulator_dev *rdev; |
---|
506 | 504 | struct regulator_config config = { }; |
---|
.. | .. |
---|
545 | 543 | return err; |
---|
546 | 544 | } |
---|
547 | 545 | |
---|
548 | | - /* Then set a pointer back to the registered regulator */ |
---|
549 | | - reg->rdev = rdev; |
---|
550 | 546 | return 0; |
---|
551 | 547 | } |
---|
552 | 548 | |
---|
.. | .. |
---|
609 | 605 | LDO_D_SETTING, |
---|
610 | 606 | }; |
---|
611 | 607 | |
---|
612 | | -static int ab3100_regulators_remove(struct platform_device *pdev) |
---|
613 | | -{ |
---|
614 | | - int i; |
---|
615 | | - |
---|
616 | | - for (i = 0; i < AB3100_NUM_REGULATORS; i++) { |
---|
617 | | - struct ab3100_regulator *reg = &ab3100_regulators[i]; |
---|
618 | | - |
---|
619 | | - reg->rdev = NULL; |
---|
620 | | - } |
---|
621 | | - return 0; |
---|
622 | | -} |
---|
623 | | - |
---|
624 | 608 | static int |
---|
625 | 609 | ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) |
---|
626 | 610 | { |
---|
.. | .. |
---|
647 | 631 | pdev, NULL, ab3100_regulator_matches[i].init_data, |
---|
648 | 632 | ab3100_regulator_matches[i].of_node, |
---|
649 | 633 | (unsigned long)ab3100_regulator_matches[i].driver_data); |
---|
650 | | - if (err) { |
---|
651 | | - ab3100_regulators_remove(pdev); |
---|
| 634 | + if (err) |
---|
652 | 635 | return err; |
---|
653 | | - } |
---|
654 | 636 | } |
---|
655 | 637 | |
---|
656 | 638 | return 0; |
---|
.. | .. |
---|
705 | 687 | |
---|
706 | 688 | /* Register the regulators */ |
---|
707 | 689 | for (i = 0; i < AB3100_NUM_REGULATORS; i++) { |
---|
708 | | - struct regulator_desc *desc = &ab3100_regulator_desc[i]; |
---|
| 690 | + const struct regulator_desc *desc = &ab3100_regulator_desc[i]; |
---|
709 | 691 | |
---|
710 | 692 | err = ab3100_regulator_register(pdev, plfdata, NULL, NULL, |
---|
711 | 693 | desc->id); |
---|
712 | | - if (err) { |
---|
713 | | - ab3100_regulators_remove(pdev); |
---|
| 694 | + if (err) |
---|
714 | 695 | return err; |
---|
715 | | - } |
---|
716 | 696 | } |
---|
717 | 697 | |
---|
718 | 698 | return 0; |
---|
.. | .. |
---|
723 | 703 | .name = "ab3100-regulators", |
---|
724 | 704 | }, |
---|
725 | 705 | .probe = ab3100_regulators_probe, |
---|
726 | | - .remove = ab3100_regulators_remove, |
---|
727 | 706 | }; |
---|
728 | 707 | |
---|
729 | 708 | static __init int ab3100_regulators_init(void) |
---|