da9062-regulator.c (c3bdd5e65185f46150b3bac103b3854040487857) | da9062-regulator.c (fd2f02f9724c416221b42af95e1a7a57fa42d681) |
---|---|
1/* 2 * Regulator device driver for DA9061 and DA9062. 3 * Copyright (C) 2015-2017 Dialog Semiconductor 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 */ | 1// SPDX-License-Identifier: GPL-2.0+ 2// 3// Regulator device driver for DA9061 and DA9062. 4// Copyright (C) 2015-2017 Dialog Semiconductor 5 |
15#include <linux/kernel.h> 16#include <linux/module.h> 17#include <linux/init.h> 18#include <linux/err.h> 19#include <linux/slab.h> 20#include <linux/of.h> 21#include <linux/platform_device.h> 22#include <linux/regmap.h> --- 25 unchanged lines hidden (view full) --- 48 DA9062_ID_LDO3, 49 DA9062_ID_LDO4, 50 DA9062_MAX_REGULATORS, 51}; 52 53/* Regulator capabilities and registers description */ 54struct da9062_regulator_info { 55 struct regulator_desc desc; | 6#include <linux/kernel.h> 7#include <linux/module.h> 8#include <linux/init.h> 9#include <linux/err.h> 10#include <linux/slab.h> 11#include <linux/of.h> 12#include <linux/platform_device.h> 13#include <linux/regmap.h> --- 25 unchanged lines hidden (view full) --- 39 DA9062_ID_LDO3, 40 DA9062_ID_LDO4, 41 DA9062_MAX_REGULATORS, 42}; 43 44/* Regulator capabilities and registers description */ 45struct da9062_regulator_info { 46 struct regulator_desc desc; |
56 /* Current limiting */ 57 unsigned int n_current_limits; 58 const int *current_limits; | |
59 /* Main register fields */ 60 struct reg_field mode; 61 struct reg_field suspend; 62 struct reg_field sleep; 63 struct reg_field suspend_sleep; 64 unsigned int suspend_vsel_reg; | 47 /* Main register fields */ 48 struct reg_field mode; 49 struct reg_field suspend; 50 struct reg_field sleep; 51 struct reg_field suspend_sleep; 52 unsigned int suspend_vsel_reg; |
65 struct reg_field ilimit; | |
66 /* Event detection bit */ 67 struct reg_field oc_event; 68}; 69 70/* Single regulator settings */ 71struct da9062_regulator { 72 struct regulator_desc desc; 73 struct regulator_dev *rdev; 74 struct da9062 *hw; 75 const struct da9062_regulator_info *info; 76 77 struct regmap_field *mode; 78 struct regmap_field *suspend; 79 struct regmap_field *sleep; 80 struct regmap_field *suspend_sleep; | 53 /* Event detection bit */ 54 struct reg_field oc_event; 55}; 56 57/* Single regulator settings */ 58struct da9062_regulator { 59 struct regulator_desc desc; 60 struct regulator_dev *rdev; 61 struct da9062 *hw; 62 const struct da9062_regulator_info *info; 63 64 struct regmap_field *mode; 65 struct regmap_field *suspend; 66 struct regmap_field *sleep; 67 struct regmap_field *suspend_sleep; |
81 struct regmap_field *ilimit; | |
82}; 83 84/* Encapsulates all information for the regulators driver */ 85struct da9062_regulators { 86 int irq_ldo_lim; 87 unsigned n_regulators; 88 /* Array size to be defined during init. Keep at end. */ 89 struct da9062_regulator regulator[0]; --- 9 unchanged lines hidden (view full) --- 99 100/* Regulator operations */ 101 102/* Current limits array (in uA) 103 * - DA9061_ID_[BUCK1|BUCK3] 104 * - DA9062_ID_[BUCK1|BUCK2|BUCK4] 105 * Entry indexes corresponds to register values. 106 */ | 68}; 69 70/* Encapsulates all information for the regulators driver */ 71struct da9062_regulators { 72 int irq_ldo_lim; 73 unsigned n_regulators; 74 /* Array size to be defined during init. Keep at end. */ 75 struct da9062_regulator regulator[0]; --- 9 unchanged lines hidden (view full) --- 85 86/* Regulator operations */ 87 88/* Current limits array (in uA) 89 * - DA9061_ID_[BUCK1|BUCK3] 90 * - DA9062_ID_[BUCK1|BUCK2|BUCK4] 91 * Entry indexes corresponds to register values. 92 */ |
107static const int da9062_buck_a_limits[] = { | 93static const unsigned int da9062_buck_a_limits[] = { |
108 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 109 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 110}; 111 112/* Current limits array (in uA) 113 * - DA9061_ID_BUCK2 114 * - DA9062_ID_BUCK3 115 * Entry indexes corresponds to register values. 116 */ | 94 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 95 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 96}; 97 98/* Current limits array (in uA) 99 * - DA9061_ID_BUCK2 100 * - DA9062_ID_BUCK3 101 * Entry indexes corresponds to register values. 102 */ |
117static const int da9062_buck_b_limits[] = { | 103static const unsigned int da9062_buck_b_limits[] = { |
118 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, 119 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 120}; 121 | 104 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, 105 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 106}; 107 |
122static int da9062_set_current_limit(struct regulator_dev *rdev, 123 int min_ua, int max_ua) 124{ 125 struct da9062_regulator *regl = rdev_get_drvdata(rdev); 126 const struct da9062_regulator_info *rinfo = regl->info; 127 int n, tval; 128 129 for (n = rinfo->n_current_limits - 1; n >= 0; n--) { 130 tval = rinfo->current_limits[n]; 131 if (tval >= min_ua && tval <= max_ua) 132 return regmap_field_write(regl->ilimit, n); 133 } 134 135 return -EINVAL; 136} 137 138static int da9062_get_current_limit(struct regulator_dev *rdev) 139{ 140 struct da9062_regulator *regl = rdev_get_drvdata(rdev); 141 const struct da9062_regulator_info *rinfo = regl->info; 142 unsigned int sel; 143 int ret; 144 145 ret = regmap_field_read(regl->ilimit, &sel); 146 if (ret < 0) 147 return ret; 148 149 if (sel >= rinfo->n_current_limits) 150 sel = rinfo->n_current_limits - 1; 151 152 return rinfo->current_limits[sel]; 153} 154 | |
155static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode) 156{ 157 struct da9062_regulator *regl = rdev_get_drvdata(rdev); 158 unsigned val; 159 160 switch (mode) { 161 case REGULATOR_MODE_FAST: 162 val = BUCK_MODE_SYNC; --- 227 unchanged lines hidden (view full) --- 390 391static const struct regulator_ops da9062_buck_ops = { 392 .enable = regulator_enable_regmap, 393 .disable = regulator_disable_regmap, 394 .is_enabled = regulator_is_enabled_regmap, 395 .get_voltage_sel = regulator_get_voltage_sel_regmap, 396 .set_voltage_sel = regulator_set_voltage_sel_regmap, 397 .list_voltage = regulator_list_voltage_linear, | 108static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode) 109{ 110 struct da9062_regulator *regl = rdev_get_drvdata(rdev); 111 unsigned val; 112 113 switch (mode) { 114 case REGULATOR_MODE_FAST: 115 val = BUCK_MODE_SYNC; --- 227 unchanged lines hidden (view full) --- 343 344static const struct regulator_ops da9062_buck_ops = { 345 .enable = regulator_enable_regmap, 346 .disable = regulator_disable_regmap, 347 .is_enabled = regulator_is_enabled_regmap, 348 .get_voltage_sel = regulator_get_voltage_sel_regmap, 349 .set_voltage_sel = regulator_set_voltage_sel_regmap, 350 .list_voltage = regulator_list_voltage_linear, |
398 .set_current_limit = da9062_set_current_limit, 399 .get_current_limit = da9062_get_current_limit, | 351 .set_current_limit = regulator_set_current_limit_regmap, 352 .get_current_limit = regulator_get_current_limit_regmap, |
400 .set_mode = da9062_buck_set_mode, 401 .get_mode = da9062_buck_get_mode, 402 .get_status = da9062_buck_get_status, 403 .set_suspend_voltage = da9062_set_suspend_voltage, 404 .set_suspend_enable = da9062_suspend_enable, 405 .set_suspend_disable = da9062_suspend_disable, 406 .set_suspend_mode = da9062_buck_set_suspend_mode, 407}; --- 20 unchanged lines hidden (view full) --- 428 .desc.id = DA9061_ID_BUCK1, 429 .desc.name = "DA9061 BUCK1", 430 .desc.of_match = of_match_ptr("buck1"), 431 .desc.regulators_node = of_match_ptr("regulators"), 432 .desc.ops = &da9062_buck_ops, 433 .desc.min_uV = (300) * 1000, 434 .desc.uV_step = (10) * 1000, 435 .desc.n_voltages = ((1570) - (300))/(10) + 1, | 353 .set_mode = da9062_buck_set_mode, 354 .get_mode = da9062_buck_get_mode, 355 .get_status = da9062_buck_get_status, 356 .set_suspend_voltage = da9062_set_suspend_voltage, 357 .set_suspend_enable = da9062_suspend_enable, 358 .set_suspend_disable = da9062_suspend_disable, 359 .set_suspend_mode = da9062_buck_set_suspend_mode, 360}; --- 20 unchanged lines hidden (view full) --- 381 .desc.id = DA9061_ID_BUCK1, 382 .desc.name = "DA9061 BUCK1", 383 .desc.of_match = of_match_ptr("buck1"), 384 .desc.regulators_node = of_match_ptr("regulators"), 385 .desc.ops = &da9062_buck_ops, 386 .desc.min_uV = (300) * 1000, 387 .desc.uV_step = (10) * 1000, 388 .desc.n_voltages = ((1570) - (300))/(10) + 1, |
436 .current_limits = da9062_buck_a_limits, 437 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | 389 .desc.curr_table = da9062_buck_a_limits, 390 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), 391 .desc.csel_reg = DA9062AA_BUCK_ILIM_C, 392 .desc.csel_mask = DA9062AA_BUCK1_ILIM_MASK, |
438 .desc.enable_reg = DA9062AA_BUCK1_CONT, 439 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK, 440 .desc.vsel_reg = DA9062AA_VBUCK1_A, 441 .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, 442 .desc.linear_min_sel = 0, 443 .sleep = REG_FIELD(DA9062AA_VBUCK1_A, 444 __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, 445 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 452 .mode = REG_FIELD(DA9062AA_BUCK1_CFG, 453 __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1, 454 sizeof(unsigned int) * 8 - 455 __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1), 456 .suspend = REG_FIELD(DA9062AA_DVC_1, 457 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1, 458 sizeof(unsigned int) * 8 - 459 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1), | 393 .desc.enable_reg = DA9062AA_BUCK1_CONT, 394 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK, 395 .desc.vsel_reg = DA9062AA_VBUCK1_A, 396 .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, 397 .desc.linear_min_sel = 0, 398 .sleep = REG_FIELD(DA9062AA_VBUCK1_A, 399 __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, 400 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 407 .mode = REG_FIELD(DA9062AA_BUCK1_CFG, 408 __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1, 409 sizeof(unsigned int) * 8 - 410 __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1), 411 .suspend = REG_FIELD(DA9062AA_DVC_1, 412 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1, 413 sizeof(unsigned int) * 8 - 414 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1), |
460 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C, 461 __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1, 462 sizeof(unsigned int) * 8 - 463 __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1), | |
464 }, 465 { 466 .desc.id = DA9061_ID_BUCK2, 467 .desc.name = "DA9061 BUCK2", 468 .desc.of_match = of_match_ptr("buck2"), 469 .desc.regulators_node = of_match_ptr("regulators"), 470 .desc.ops = &da9062_buck_ops, 471 .desc.min_uV = (800) * 1000, 472 .desc.uV_step = (20) * 1000, 473 .desc.n_voltages = ((3340) - (800))/(20) + 1, | 415 }, 416 { 417 .desc.id = DA9061_ID_BUCK2, 418 .desc.name = "DA9061 BUCK2", 419 .desc.of_match = of_match_ptr("buck2"), 420 .desc.regulators_node = of_match_ptr("regulators"), 421 .desc.ops = &da9062_buck_ops, 422 .desc.min_uV = (800) * 1000, 423 .desc.uV_step = (20) * 1000, 424 .desc.n_voltages = ((3340) - (800))/(20) + 1, |
474 .current_limits = da9062_buck_b_limits, 475 .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), | 425 .desc.curr_table = da9062_buck_b_limits, 426 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), 427 .desc.csel_reg = DA9062AA_BUCK_ILIM_A, 428 .desc.csel_mask = DA9062AA_BUCK3_ILIM_MASK, |
476 .desc.enable_reg = DA9062AA_BUCK3_CONT, 477 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK, 478 .desc.vsel_reg = DA9062AA_VBUCK3_A, 479 .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, 480 .desc.linear_min_sel = 0, 481 .sleep = REG_FIELD(DA9062AA_VBUCK3_A, 482 __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, 483 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 490 .mode = REG_FIELD(DA9062AA_BUCK3_CFG, 491 __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1, 492 sizeof(unsigned int) * 8 - 493 __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1), 494 .suspend = REG_FIELD(DA9062AA_DVC_1, 495 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1, 496 sizeof(unsigned int) * 8 - 497 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1), | 429 .desc.enable_reg = DA9062AA_BUCK3_CONT, 430 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK, 431 .desc.vsel_reg = DA9062AA_VBUCK3_A, 432 .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, 433 .desc.linear_min_sel = 0, 434 .sleep = REG_FIELD(DA9062AA_VBUCK3_A, 435 __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, 436 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 443 .mode = REG_FIELD(DA9062AA_BUCK3_CFG, 444 __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1, 445 sizeof(unsigned int) * 8 - 446 __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1), 447 .suspend = REG_FIELD(DA9062AA_DVC_1, 448 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1, 449 sizeof(unsigned int) * 8 - 450 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1), |
498 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A, 499 __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1, 500 sizeof(unsigned int) * 8 - 501 __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1), | |
502 }, 503 { 504 .desc.id = DA9061_ID_BUCK3, 505 .desc.name = "DA9061 BUCK3", 506 .desc.of_match = of_match_ptr("buck3"), 507 .desc.regulators_node = of_match_ptr("regulators"), 508 .desc.ops = &da9062_buck_ops, 509 .desc.min_uV = (530) * 1000, 510 .desc.uV_step = (10) * 1000, 511 .desc.n_voltages = ((1800) - (530))/(10) + 1, | 451 }, 452 { 453 .desc.id = DA9061_ID_BUCK3, 454 .desc.name = "DA9061 BUCK3", 455 .desc.of_match = of_match_ptr("buck3"), 456 .desc.regulators_node = of_match_ptr("regulators"), 457 .desc.ops = &da9062_buck_ops, 458 .desc.min_uV = (530) * 1000, 459 .desc.uV_step = (10) * 1000, 460 .desc.n_voltages = ((1800) - (530))/(10) + 1, |
512 .current_limits = da9062_buck_a_limits, 513 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | 461 .desc.curr_table = da9062_buck_a_limits, 462 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), 463 .desc.csel_reg = DA9062AA_BUCK_ILIM_B, 464 .desc.csel_mask = DA9062AA_BUCK4_ILIM_MASK, |
514 .desc.enable_reg = DA9062AA_BUCK4_CONT, 515 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK, 516 .desc.vsel_reg = DA9062AA_VBUCK4_A, 517 .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, 518 .desc.linear_min_sel = 0, 519 .sleep = REG_FIELD(DA9062AA_VBUCK4_A, 520 __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, 521 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 528 .mode = REG_FIELD(DA9062AA_BUCK4_CFG, 529 __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1, 530 sizeof(unsigned int) * 8 - 531 __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1), 532 .suspend = REG_FIELD(DA9062AA_DVC_1, 533 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1, 534 sizeof(unsigned int) * 8 - 535 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1), | 465 .desc.enable_reg = DA9062AA_BUCK4_CONT, 466 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK, 467 .desc.vsel_reg = DA9062AA_VBUCK4_A, 468 .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, 469 .desc.linear_min_sel = 0, 470 .sleep = REG_FIELD(DA9062AA_VBUCK4_A, 471 __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, 472 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 479 .mode = REG_FIELD(DA9062AA_BUCK4_CFG, 480 __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1, 481 sizeof(unsigned int) * 8 - 482 __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1), 483 .suspend = REG_FIELD(DA9062AA_DVC_1, 484 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1, 485 sizeof(unsigned int) * 8 - 486 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1), |
536 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B, 537 __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1, 538 sizeof(unsigned int) * 8 - 539 __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1), | |
540 }, 541 { 542 .desc.id = DA9061_ID_LDO1, 543 .desc.name = "DA9061 LDO1", 544 .desc.of_match = of_match_ptr("ldo1"), 545 .desc.regulators_node = of_match_ptr("regulators"), 546 .desc.ops = &da9062_ldo_ops, 547 .desc.min_uV = (900) * 1000, --- 126 unchanged lines hidden (view full) --- 674 .desc.id = DA9062_ID_BUCK1, 675 .desc.name = "DA9062 BUCK1", 676 .desc.of_match = of_match_ptr("buck1"), 677 .desc.regulators_node = of_match_ptr("regulators"), 678 .desc.ops = &da9062_buck_ops, 679 .desc.min_uV = (300) * 1000, 680 .desc.uV_step = (10) * 1000, 681 .desc.n_voltages = ((1570) - (300))/(10) + 1, | 487 }, 488 { 489 .desc.id = DA9061_ID_LDO1, 490 .desc.name = "DA9061 LDO1", 491 .desc.of_match = of_match_ptr("ldo1"), 492 .desc.regulators_node = of_match_ptr("regulators"), 493 .desc.ops = &da9062_ldo_ops, 494 .desc.min_uV = (900) * 1000, --- 126 unchanged lines hidden (view full) --- 621 .desc.id = DA9062_ID_BUCK1, 622 .desc.name = "DA9062 BUCK1", 623 .desc.of_match = of_match_ptr("buck1"), 624 .desc.regulators_node = of_match_ptr("regulators"), 625 .desc.ops = &da9062_buck_ops, 626 .desc.min_uV = (300) * 1000, 627 .desc.uV_step = (10) * 1000, 628 .desc.n_voltages = ((1570) - (300))/(10) + 1, |
682 .current_limits = da9062_buck_a_limits, 683 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | 629 .desc.curr_table = da9062_buck_a_limits, 630 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), 631 .desc.csel_reg = DA9062AA_BUCK_ILIM_C, 632 .desc.csel_mask = DA9062AA_BUCK1_ILIM_MASK, |
684 .desc.enable_reg = DA9062AA_BUCK1_CONT, 685 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK, 686 .desc.vsel_reg = DA9062AA_VBUCK1_A, 687 .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, 688 .desc.linear_min_sel = 0, 689 .sleep = REG_FIELD(DA9062AA_VBUCK1_A, 690 __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, 691 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 698 .mode = REG_FIELD(DA9062AA_BUCK1_CFG, 699 __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1, 700 sizeof(unsigned int) * 8 - 701 __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1), 702 .suspend = REG_FIELD(DA9062AA_DVC_1, 703 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1, 704 sizeof(unsigned int) * 8 - 705 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1), | 633 .desc.enable_reg = DA9062AA_BUCK1_CONT, 634 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK, 635 .desc.vsel_reg = DA9062AA_VBUCK1_A, 636 .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, 637 .desc.linear_min_sel = 0, 638 .sleep = REG_FIELD(DA9062AA_VBUCK1_A, 639 __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, 640 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 647 .mode = REG_FIELD(DA9062AA_BUCK1_CFG, 648 __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1, 649 sizeof(unsigned int) * 8 - 650 __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1), 651 .suspend = REG_FIELD(DA9062AA_DVC_1, 652 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1, 653 sizeof(unsigned int) * 8 - 654 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1), |
706 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C, 707 __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1, 708 sizeof(unsigned int) * 8 - 709 __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1), | |
710 }, 711 { 712 .desc.id = DA9062_ID_BUCK2, 713 .desc.name = "DA9062 BUCK2", 714 .desc.of_match = of_match_ptr("buck2"), 715 .desc.regulators_node = of_match_ptr("regulators"), 716 .desc.ops = &da9062_buck_ops, 717 .desc.min_uV = (300) * 1000, 718 .desc.uV_step = (10) * 1000, 719 .desc.n_voltages = ((1570) - (300))/(10) + 1, | 655 }, 656 { 657 .desc.id = DA9062_ID_BUCK2, 658 .desc.name = "DA9062 BUCK2", 659 .desc.of_match = of_match_ptr("buck2"), 660 .desc.regulators_node = of_match_ptr("regulators"), 661 .desc.ops = &da9062_buck_ops, 662 .desc.min_uV = (300) * 1000, 663 .desc.uV_step = (10) * 1000, 664 .desc.n_voltages = ((1570) - (300))/(10) + 1, |
720 .current_limits = da9062_buck_a_limits, 721 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | 665 .desc.curr_table = da9062_buck_a_limits, 666 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), 667 .desc.csel_reg = DA9062AA_BUCK_ILIM_C, 668 .desc.csel_mask = DA9062AA_BUCK2_ILIM_MASK, |
722 .desc.enable_reg = DA9062AA_BUCK2_CONT, 723 .desc.enable_mask = DA9062AA_BUCK2_EN_MASK, 724 .desc.vsel_reg = DA9062AA_VBUCK2_A, 725 .desc.vsel_mask = DA9062AA_VBUCK2_A_MASK, 726 .desc.linear_min_sel = 0, 727 .sleep = REG_FIELD(DA9062AA_VBUCK2_A, 728 __builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1, 729 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 736 .mode = REG_FIELD(DA9062AA_BUCK2_CFG, 737 __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1, 738 sizeof(unsigned int) * 8 - 739 __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1), 740 .suspend = REG_FIELD(DA9062AA_DVC_1, 741 __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1, 742 sizeof(unsigned int) * 8 - 743 __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1), | 669 .desc.enable_reg = DA9062AA_BUCK2_CONT, 670 .desc.enable_mask = DA9062AA_BUCK2_EN_MASK, 671 .desc.vsel_reg = DA9062AA_VBUCK2_A, 672 .desc.vsel_mask = DA9062AA_VBUCK2_A_MASK, 673 .desc.linear_min_sel = 0, 674 .sleep = REG_FIELD(DA9062AA_VBUCK2_A, 675 __builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1, 676 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 683 .mode = REG_FIELD(DA9062AA_BUCK2_CFG, 684 __builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1, 685 sizeof(unsigned int) * 8 - 686 __builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1), 687 .suspend = REG_FIELD(DA9062AA_DVC_1, 688 __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1, 689 sizeof(unsigned int) * 8 - 690 __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1), |
744 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C, 745 __builtin_ffs((int)DA9062AA_BUCK2_ILIM_MASK) - 1, 746 sizeof(unsigned int) * 8 - 747 __builtin_clz((DA9062AA_BUCK2_ILIM_MASK)) - 1), | |
748 }, 749 { 750 .desc.id = DA9062_ID_BUCK3, 751 .desc.name = "DA9062 BUCK3", 752 .desc.of_match = of_match_ptr("buck3"), 753 .desc.regulators_node = of_match_ptr("regulators"), 754 .desc.ops = &da9062_buck_ops, 755 .desc.min_uV = (800) * 1000, 756 .desc.uV_step = (20) * 1000, 757 .desc.n_voltages = ((3340) - (800))/(20) + 1, | 691 }, 692 { 693 .desc.id = DA9062_ID_BUCK3, 694 .desc.name = "DA9062 BUCK3", 695 .desc.of_match = of_match_ptr("buck3"), 696 .desc.regulators_node = of_match_ptr("regulators"), 697 .desc.ops = &da9062_buck_ops, 698 .desc.min_uV = (800) * 1000, 699 .desc.uV_step = (20) * 1000, 700 .desc.n_voltages = ((3340) - (800))/(20) + 1, |
758 .current_limits = da9062_buck_b_limits, 759 .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), | 701 .desc.curr_table = da9062_buck_b_limits, 702 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_b_limits), 703 .desc.csel_reg = DA9062AA_BUCK_ILIM_A, 704 .desc.csel_mask = DA9062AA_BUCK3_ILIM_MASK, |
760 .desc.enable_reg = DA9062AA_BUCK3_CONT, 761 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK, 762 .desc.vsel_reg = DA9062AA_VBUCK3_A, 763 .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, 764 .desc.linear_min_sel = 0, 765 .sleep = REG_FIELD(DA9062AA_VBUCK3_A, 766 __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, 767 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 774 .mode = REG_FIELD(DA9062AA_BUCK3_CFG, 775 __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1, 776 sizeof(unsigned int) * 8 - 777 __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1), 778 .suspend = REG_FIELD(DA9062AA_DVC_1, 779 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1, 780 sizeof(unsigned int) * 8 - 781 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1), | 705 .desc.enable_reg = DA9062AA_BUCK3_CONT, 706 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK, 707 .desc.vsel_reg = DA9062AA_VBUCK3_A, 708 .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, 709 .desc.linear_min_sel = 0, 710 .sleep = REG_FIELD(DA9062AA_VBUCK3_A, 711 __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, 712 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 719 .mode = REG_FIELD(DA9062AA_BUCK3_CFG, 720 __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1, 721 sizeof(unsigned int) * 8 - 722 __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1), 723 .suspend = REG_FIELD(DA9062AA_DVC_1, 724 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1, 725 sizeof(unsigned int) * 8 - 726 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1), |
782 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A, 783 __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1, 784 sizeof(unsigned int) * 8 - 785 __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1), | |
786 }, 787 { 788 .desc.id = DA9062_ID_BUCK4, 789 .desc.name = "DA9062 BUCK4", 790 .desc.of_match = of_match_ptr("buck4"), 791 .desc.regulators_node = of_match_ptr("regulators"), 792 .desc.ops = &da9062_buck_ops, 793 .desc.min_uV = (530) * 1000, 794 .desc.uV_step = (10) * 1000, 795 .desc.n_voltages = ((1800) - (530))/(10) + 1, | 727 }, 728 { 729 .desc.id = DA9062_ID_BUCK4, 730 .desc.name = "DA9062 BUCK4", 731 .desc.of_match = of_match_ptr("buck4"), 732 .desc.regulators_node = of_match_ptr("regulators"), 733 .desc.ops = &da9062_buck_ops, 734 .desc.min_uV = (530) * 1000, 735 .desc.uV_step = (10) * 1000, 736 .desc.n_voltages = ((1800) - (530))/(10) + 1, |
796 .current_limits = da9062_buck_a_limits, 797 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), | 737 .desc.curr_table = da9062_buck_a_limits, 738 .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits), 739 .desc.csel_reg = DA9062AA_BUCK_ILIM_B, 740 .desc.csel_mask = DA9062AA_BUCK4_ILIM_MASK, |
798 .desc.enable_reg = DA9062AA_BUCK4_CONT, 799 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK, 800 .desc.vsel_reg = DA9062AA_VBUCK4_A, 801 .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, 802 .desc.linear_min_sel = 0, 803 .sleep = REG_FIELD(DA9062AA_VBUCK4_A, 804 __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, 805 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 812 .mode = REG_FIELD(DA9062AA_BUCK4_CFG, 813 __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1, 814 sizeof(unsigned int) * 8 - 815 __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1), 816 .suspend = REG_FIELD(DA9062AA_DVC_1, 817 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1, 818 sizeof(unsigned int) * 8 - 819 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1), | 741 .desc.enable_reg = DA9062AA_BUCK4_CONT, 742 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK, 743 .desc.vsel_reg = DA9062AA_VBUCK4_A, 744 .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, 745 .desc.linear_min_sel = 0, 746 .sleep = REG_FIELD(DA9062AA_VBUCK4_A, 747 __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, 748 sizeof(unsigned int) * 8 - --- 6 unchanged lines hidden (view full) --- 755 .mode = REG_FIELD(DA9062AA_BUCK4_CFG, 756 __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1, 757 sizeof(unsigned int) * 8 - 758 __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1), 759 .suspend = REG_FIELD(DA9062AA_DVC_1, 760 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1, 761 sizeof(unsigned int) * 8 - 762 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1), |
820 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B, 821 __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1, 822 sizeof(unsigned int) * 8 - 823 __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1), | |
824 }, 825 { 826 .desc.id = DA9062_ID_LDO1, 827 .desc.name = "DA9062 LDO1", 828 .desc.of_match = of_match_ptr("ldo1"), 829 .desc.regulators_node = of_match_ptr("regulators"), 830 .desc.ops = &da9062_ldo_ops, 831 .desc.min_uV = (900) * 1000, --- 137 unchanged lines hidden (view full) --- 969 } 970 971 for (i = regulators->n_regulators - 1; i >= 0; i--) { 972 regl = ®ulators->regulator[i]; 973 if (regl->info->oc_event.reg != DA9062AA_STATUS_D) 974 continue; 975 976 if (BIT(regl->info->oc_event.lsb) & bits) { | 763 }, 764 { 765 .desc.id = DA9062_ID_LDO1, 766 .desc.name = "DA9062 LDO1", 767 .desc.of_match = of_match_ptr("ldo1"), 768 .desc.regulators_node = of_match_ptr("regulators"), 769 .desc.ops = &da9062_ldo_ops, 770 .desc.min_uV = (900) * 1000, --- 137 unchanged lines hidden (view full) --- 908 } 909 910 for (i = regulators->n_regulators - 1; i >= 0; i--) { 911 regl = ®ulators->regulator[i]; 912 if (regl->info->oc_event.reg != DA9062AA_STATUS_D) 913 continue; 914 915 if (BIT(regl->info->oc_event.lsb) & bits) { |
916 regulator_lock(regl->rdev); |
|
977 regulator_notifier_call_chain(regl->rdev, 978 REGULATOR_EVENT_OVER_CURRENT, NULL); | 917 regulator_notifier_call_chain(regl->rdev, 918 REGULATOR_EVENT_OVER_CURRENT, NULL); |
919 regulator_unlock(regl->rdev); |
|
979 handled = IRQ_HANDLED; 980 } 981 } 982 983ldo_lim_error: 984 return handled; 985} 986 --- 71 unchanged lines hidden (view full) --- 1058 regl->suspend_sleep = devm_regmap_field_alloc( 1059 &pdev->dev, 1060 chip->regmap, 1061 regl->info->suspend_sleep); 1062 if (IS_ERR(regl->suspend_sleep)) 1063 return PTR_ERR(regl->suspend_sleep); 1064 } 1065 | 920 handled = IRQ_HANDLED; 921 } 922 } 923 924ldo_lim_error: 925 return handled; 926} 927 --- 71 unchanged lines hidden (view full) --- 999 regl->suspend_sleep = devm_regmap_field_alloc( 1000 &pdev->dev, 1001 chip->regmap, 1002 regl->info->suspend_sleep); 1003 if (IS_ERR(regl->suspend_sleep)) 1004 return PTR_ERR(regl->suspend_sleep); 1005 } 1006 |
1066 if (regl->info->ilimit.reg) { 1067 regl->ilimit = devm_regmap_field_alloc( 1068 &pdev->dev, 1069 chip->regmap, 1070 regl->info->ilimit); 1071 if (IS_ERR(regl->ilimit)) 1072 return PTR_ERR(regl->ilimit); 1073 } 1074 | |
1075 /* Register regulator */ 1076 memset(&config, 0, sizeof(config)); 1077 config.dev = chip->dev; 1078 config.driver_data = regl; 1079 config.regmap = chip->regmap; 1080 1081 regl->rdev = devm_regulator_register(&pdev->dev, ®l->desc, 1082 &config); --- 55 unchanged lines hidden --- | 1007 /* Register regulator */ 1008 memset(&config, 0, sizeof(config)); 1009 config.dev = chip->dev; 1010 config.driver_data = regl; 1011 config.regmap = chip->regmap; 1012 1013 regl->rdev = devm_regulator_register(&pdev->dev, ®l->desc, 1014 &config); --- 55 unchanged lines hidden --- |