^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) // Copyright (C) 2018 ROHM Semiconductors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) // bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/mfd/rohm-bd718x7.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/regulator/of_regulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* Typical regulator startup times as per data sheet in uS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define BD71847_BUCK1_STARTUP_TIME 144
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define BD71847_BUCK2_STARTUP_TIME 162
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define BD71847_BUCK3_STARTUP_TIME 162
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define BD71847_BUCK4_STARTUP_TIME 240
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define BD71847_BUCK5_STARTUP_TIME 270
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define BD71847_BUCK6_STARTUP_TIME 200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define BD71847_LDO1_STARTUP_TIME 440
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define BD71847_LDO2_STARTUP_TIME 370
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define BD71847_LDO3_STARTUP_TIME 310
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define BD71847_LDO4_STARTUP_TIME 400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define BD71847_LDO5_STARTUP_TIME 530
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define BD71847_LDO6_STARTUP_TIME 400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define BD71837_BUCK1_STARTUP_TIME 160
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define BD71837_BUCK2_STARTUP_TIME 180
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define BD71837_BUCK3_STARTUP_TIME 180
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define BD71837_BUCK4_STARTUP_TIME 180
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define BD71837_BUCK5_STARTUP_TIME 160
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define BD71837_BUCK6_STARTUP_TIME 240
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define BD71837_BUCK7_STARTUP_TIME 220
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define BD71837_BUCK8_STARTUP_TIME 200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define BD71837_LDO1_STARTUP_TIME 440
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define BD71837_LDO2_STARTUP_TIME 370
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define BD71837_LDO3_STARTUP_TIME 310
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define BD71837_LDO4_STARTUP_TIME 400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define BD71837_LDO5_STARTUP_TIME 310
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define BD71837_LDO6_STARTUP_TIME 400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define BD71837_LDO7_STARTUP_TIME 530
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * BD718(37/47/50) have two "enable control modes". ON/OFF can either be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * controlled by software - or by PMIC internal HW state machine. Whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * regulator should be under SW or HW control can be defined from device-tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * Let's provide separate ops for regulators to use depending on the "enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * control mode".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define BD718XX_HWOPNAME(swopname) swopname##_hwcontrol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define BD718XX_OPS(name, _list_voltage, _map_voltage, _set_voltage_sel, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) _get_voltage_sel, _set_voltage_time_sel, _set_ramp_delay) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static const struct regulator_ops name = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .enable = regulator_enable_regmap, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .disable = regulator_disable_regmap, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .is_enabled = regulator_is_enabled_regmap, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .list_voltage = (_list_voltage), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) .map_voltage = (_map_voltage), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .set_voltage_sel = (_set_voltage_sel), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .get_voltage_sel = (_get_voltage_sel), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .set_voltage_time_sel = (_set_voltage_time_sel), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .set_ramp_delay = (_set_ramp_delay), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static const struct regulator_ops BD718XX_HWOPNAME(name) = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .is_enabled = always_enabled_by_hwstate, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .list_voltage = (_list_voltage), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .map_voltage = (_map_voltage), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .set_voltage_sel = (_set_voltage_sel), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .get_voltage_sel = (_get_voltage_sel), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .set_voltage_time_sel = (_set_voltage_time_sel), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .set_ramp_delay = (_set_ramp_delay), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * BUCK1/2/3/4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * 00: 10.00mV/usec 10mV 1uS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * 01: 5.00mV/usec 10mV 2uS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * 10: 2.50mV/usec 10mV 4uS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * 11: 1.25mV/usec 10mV 8uS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int ramp_delay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int id = rdev_get_id(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned int ramp_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ramp_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) switch (ramp_delay) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) case 1 ... 1250:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) ramp_value = BUCK_RAMPRATE_1P25MV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) case 1251 ... 2500:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) ramp_value = BUCK_RAMPRATE_2P50MV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) case 2501 ... 5000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ramp_value = BUCK_RAMPRATE_5P00MV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) case 5001 ... 10000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ramp_value = BUCK_RAMPRATE_10P00MV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ramp_value = BUCK_RAMPRATE_10P00MV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) dev_err(&rdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) "%s: ramp_delay: %d not supported, setting 10000mV//us\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) rdev->desc->name, ramp_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return regmap_update_bits(rdev->regmap, BD718XX_REG_BUCK1_CTRL + id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) BUCK_RAMPRATE_MASK, ramp_value << 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* These functions are used when regulators are under HW state machine control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * We assume PMIC is in RUN state because SW running and able to query the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * status. Most of the regulators have fixed ON or OFF state at RUN/IDLE so for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * them we just return a constant. BD71837 BUCK3 and BUCK4 are exceptions as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * they support configuring the ON/OFF state for RUN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * Note for next hacker - these PMICs have a register where the HW state can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * read. If assuming RUN appears to be false in your use-case - you can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * implement state reading (although that is not going to be atomic) before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * returning the enable state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static int always_enabled_by_hwstate(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static int never_enabled_by_hwstate(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static int bd71837_get_buck34_enable_hwctrl(struct regulator_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) unsigned int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return !!(BD718XX_BUCK_RUN_ON & val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * On BD71837 (not on BD71847, BD71850, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * is changed. Hence we return -EBUSY for these if voltage is changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * when BUCK/LDO is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * On BD71847, BD71850, ... The LDO voltage can be changed when LDO is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * enabled. But if voltage is increased the LDO power-good monitoring
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * must be disabled for the duration of changing + 1mS to ensure voltage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * has reached the higher level before HW does next under voltage detection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * cycle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static int bd71837_set_voltage_sel_restricted(struct regulator_dev *rdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) unsigned int sel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (rdev->desc->ops->is_enabled(rdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return regulator_set_voltage_sel_regmap(rdev, sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static void voltage_change_done(struct regulator_dev *rdev, unsigned int sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) unsigned int *mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (*mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * Let's allow scheduling as we use I2C anyways. We just need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * guarantee minimum of 1ms sleep - it shouldn't matter if we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * exceed it due to the scheduling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) msleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * Note for next hacker. The PWRGOOD should not be masked on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * BD71847 so we will just unconditionally enable detection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * when voltage is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * If someone want's to disable PWRGOOD he must implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * caching and restoring the old value here. I am not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * aware of such use-cases so for the sake of the simplicity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * we just always enable PWRGOOD here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ret = regmap_update_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) *mask, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) dev_err(&rdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) "Failed to re-enable voltage monitoring (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static int voltage_change_prepare(struct regulator_dev *rdev, unsigned int sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) unsigned int *mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) *mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) if (rdev->desc->ops->is_enabled(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) int now, new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) now = rdev->desc->ops->get_voltage_sel(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (now < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) now = rdev->desc->ops->list_voltage(rdev, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (now < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) new = rdev->desc->ops->list_voltage(rdev, sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (new < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * If we increase LDO voltage when LDO is enabled we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * disable the power-good detection until voltage has reached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * the new level. According to HW colleagues the maximum time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * it takes is 1000us. I assume that on systems with light load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * this might be less - and we could probably use DT to give
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * system specific delay value if performance matters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * Well, knowing we use I2C here and can add scheduling delays
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * I don't think it is worth the hassle and I just add fixed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * 1ms sleep here (and allow scheduling). If this turns out to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * be a problem we can change it to delay and make the delay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * time configurable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (new > now) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int ldo_offset = rdev->desc->id - BD718XX_LDO1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) *mask = BD718XX_LDO1_VRMON80 << ldo_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) ret = regmap_update_bits(rdev->regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) BD718XX_REG_MVRFLTMASK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *mask, *mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) dev_err(&rdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) "Failed to stop voltage monitoring\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static int bd718xx_set_voltage_sel_restricted(struct regulator_dev *rdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) unsigned int sel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) ret = voltage_change_prepare(rdev, sel, &mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) ret = regulator_set_voltage_sel_regmap(rdev, sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) voltage_change_done(rdev, sel, &mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static int bd718xx_set_voltage_sel_pickable_restricted(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct regulator_dev *rdev, unsigned int sel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) int mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) ret = voltage_change_prepare(rdev, sel, &mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) ret = regulator_set_voltage_sel_pickable_regmap(rdev, sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) voltage_change_done(rdev, sel, &mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static int bd71837_set_voltage_sel_pickable_restricted(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct regulator_dev *rdev, unsigned int sel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) if (rdev->desc->ops->is_enabled(rdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) return regulator_set_voltage_sel_pickable_regmap(rdev, sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * OPS common for BD71847 and BD71850
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) BD718XX_OPS(bd718xx_pickable_range_ldo_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) regulator_list_voltage_pickable_linear_range, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) bd718xx_set_voltage_sel_pickable_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) regulator_get_voltage_sel_pickable_regmap, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /* BD71847 and BD71850 LDO 5 is by default OFF at RUN state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static const struct regulator_ops bd718xx_ldo5_ops_hwstate = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) .is_enabled = never_enabled_by_hwstate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) .list_voltage = regulator_list_voltage_pickable_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) .set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) BD718XX_OPS(bd718xx_pickable_range_buck_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) regulator_list_voltage_pickable_linear_range, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) regulator_set_voltage_sel_pickable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) regulator_get_voltage_sel_pickable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) regulator_set_voltage_time_sel, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) BD718XX_OPS(bd718xx_ldo_regulator_ops, regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) NULL, bd718xx_set_voltage_sel_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) regulator_get_voltage_sel_regmap, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) BD718XX_OPS(bd718xx_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) NULL, bd718xx_set_voltage_sel_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) regulator_get_voltage_sel_regmap, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) BD718XX_OPS(bd718xx_buck_regulator_ops, regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) NULL, regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) BD718XX_OPS(bd718xx_buck_regulator_nolinear_ops, regulator_list_voltage_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) regulator_map_voltage_ascend, regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * OPS for BD71837
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) BD718XX_OPS(bd71837_pickable_range_ldo_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) regulator_list_voltage_pickable_linear_range, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) bd71837_set_voltage_sel_pickable_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) regulator_get_voltage_sel_pickable_regmap, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) BD718XX_OPS(bd71837_pickable_range_buck_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) regulator_list_voltage_pickable_linear_range, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) bd71837_set_voltage_sel_pickable_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) regulator_get_voltage_sel_pickable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) regulator_set_voltage_time_sel, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) BD718XX_OPS(bd71837_ldo_regulator_ops, regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) NULL, bd71837_set_voltage_sel_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) regulator_get_voltage_sel_regmap, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) BD718XX_OPS(bd71837_ldo_regulator_nolinear_ops, regulator_list_voltage_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) NULL, bd71837_set_voltage_sel_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) regulator_get_voltage_sel_regmap, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) NULL, bd71837_set_voltage_sel_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) regulator_map_voltage_ascend, bd71837_set_voltage_sel_restricted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * BD71837 bucks 3 and 4 support defining their enable/disable state also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * when buck enable state is under HW state machine control. In that case the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * bit [2] in CTRL register is used to indicate if regulator should be ON.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static const struct regulator_ops bd71837_buck34_ops_hwctrl = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) .is_enabled = bd71837_get_buck34_enable_hwctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) .list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) .set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) .get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) .set_voltage_time_sel = regulator_set_voltage_time_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) .set_ramp_delay = bd718xx_buck1234_set_ramp_delay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * OPS for all of the ICs - BD718(37/47/50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) BD718XX_OPS(bd718xx_dvs_buck_regulator_ops, regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) NULL, regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) bd718xx_buck1234_set_ramp_delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * BD71837 BUCK1/2/3/4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * BD71847 BUCK1/2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * 0.70 to 1.30V (10mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) static const struct linear_range bd718xx_dvs_buck_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * BD71837 BUCK5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) * 0.7V to 1.35V (range 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * 0.675 to 1.325 (range 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) static const struct linear_range bd71837_buck5_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /* Ranges when VOLT_SEL bit is 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) /* Ranges when VOLT_SEL bit is 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * Range selector for first 3 linear ranges is 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * and 0x1 for last 3 ranges.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) static const unsigned int bd71837_buck5_volt_range_sel[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 0x0, 0x0, 0x0, 0x80, 0x80, 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * BD71847 BUCK3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) static const struct linear_range bd71847_buck3_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /* Ranges when VOLT_SEL bits are 00 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) /* Ranges when VOLT_SEL bits are 01 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) REGULATOR_LINEAR_RANGE(550000, 0x0, 0x7, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) /* Ranges when VOLT_SEL bits are 11 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static const unsigned int bd71847_buck3_volt_range_sel[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 0x0, 0x0, 0x0, 0x40, 0x80, 0x80, 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) static const struct linear_range bd71847_buck4_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) REGULATOR_LINEAR_RANGE(2600000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) static const unsigned int bd71847_buck4_volt_range_sel[] = { 0x0, 0x40 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * BUCK6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * 3.0V to 3.3V (step 100mV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static const struct linear_range bd71837_buck6_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * BD71837 BUCK7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * BD71847 BUCK5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) * 000 = 1.605V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) * 001 = 1.695V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) * 010 = 1.755V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * 011 = 1.8V (Initial)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * 100 = 1.845V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * 101 = 1.905V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) * 110 = 1.95V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * 111 = 1.995V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static const unsigned int bd718xx_3rd_nodvs_buck_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * BUCK8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * 0.8V to 1.40V (step 10mV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) static const struct linear_range bd718xx_4th_nodvs_buck_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * LDO1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * 3.0 to 3.3V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static const struct linear_range bd718xx_ldo1_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) REGULATOR_LINEAR_RANGE(1600000, 0x00, 0x03, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) static const unsigned int bd718xx_ldo1_volt_range_sel[] = { 0x0, 0x20 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * LDO2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * 0.8 or 0.9V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) static const unsigned int ldo_2_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 900000, 800000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * LDO3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * 1.8 to 3.3V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static const struct linear_range bd718xx_ldo3_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * LDO4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) * 0.9 to 1.8V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) static const struct linear_range bd718xx_ldo4_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * LDO5 for BD71837
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * 1.8 to 3.3V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) static const struct linear_range bd71837_ldo5_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * LDO5 for BD71837
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * 1.8 to 3.3V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) static const struct linear_range bd71847_ldo5_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) REGULATOR_LINEAR_RANGE(800000, 0x00, 0x0F, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) static const unsigned int bd71847_ldo5_volt_range_sel[] = { 0x0, 0x20 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * LDO6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * 0.9 to 1.8V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) static const struct linear_range bd718xx_ldo6_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * LDO7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * 1.8 to 3.3V (100mV step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) static const struct linear_range bd71837_ldo7_volts[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) struct reg_init {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) unsigned int reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) unsigned int mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) unsigned int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) struct bd718xx_regulator_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) struct regulator_desc desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) const struct rohm_dvs_config dvs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) const struct reg_init init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) const struct reg_init *additional_inits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) int additional_init_amnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) * There is a HW quirk in BD71837. The shutdown sequence timings for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) * bucks/LDOs which are controlled via register interface are changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) * beginning of shut-down sequence. As bucks 6 and 7 are parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) * monitoring to errorneously detect under voltage and force PMIC to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) * emergency state instead of poweroff. In order to avoid this we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * disable voltage monitoring for LDO5 and LDO6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) static const struct reg_init bd71837_ldo5_inits[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) .reg = BD718XX_REG_MVRFLTMASK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) .mask = BD718XX_LDO5_VRMON80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) .val = BD718XX_LDO5_VRMON80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) static const struct reg_init bd71837_ldo6_inits[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) .reg = BD718XX_REG_MVRFLTMASK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) .mask = BD718XX_LDO6_VRMON80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) .val = BD718XX_LDO6_VRMON80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) static int buck_set_hw_dvs_levels(struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) const struct regulator_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) struct regulator_config *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) struct bd718xx_regulator_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) data = container_of(desc, struct bd718xx_regulator_data, desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) static const struct regulator_ops *bd71847_swcontrol_ops[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) &bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) &bd718xx_pickable_range_buck_ops, &bd718xx_pickable_range_buck_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) &bd718xx_buck_regulator_nolinear_ops, &bd718xx_buck_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) &bd718xx_pickable_range_ldo_ops, &bd718xx_ldo_regulator_nolinear_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) &bd718xx_ldo_regulator_ops, &bd718xx_ldo_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) &bd718xx_pickable_range_ldo_ops, &bd718xx_ldo_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) static const struct regulator_ops *bd71847_hwcontrol_ops[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) &BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) &BD718XX_HWOPNAME(bd718xx_pickable_range_buck_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) &BD718XX_HWOPNAME(bd718xx_buck_regulator_nolinear_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) &BD718XX_HWOPNAME(bd718xx_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) &BD718XX_HWOPNAME(bd718xx_pickable_range_ldo_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) &BD718XX_HWOPNAME(bd718xx_ldo_regulator_nolinear_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) &bd718xx_ldo5_ops_hwstate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) &BD718XX_HWOPNAME(bd718xx_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static struct bd718xx_regulator_data bd71847_regulators[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) .name = "buck1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) .of_match = of_match_ptr("BUCK1"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) .id = BD718XX_BUCK1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) .linear_ranges = bd718xx_dvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) ARRAY_SIZE(bd718xx_dvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) .vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) .vsel_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) .enable_reg = BD718XX_REG_BUCK1_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) .enable_time = BD71847_BUCK1_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) .of_parse_cb = buck_set_hw_dvs_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) .dvs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) ROHM_DVS_LEVEL_SUSPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) .run_reg = BD718XX_REG_BUCK1_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) .run_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) .idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) .idle_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) .suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) .suspend_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) .reg = BD718XX_REG_BUCK1_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) .name = "buck2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) .of_match = of_match_ptr("BUCK2"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) .id = BD718XX_BUCK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) .linear_ranges = bd718xx_dvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) .vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) .vsel_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) .enable_reg = BD718XX_REG_BUCK2_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) .enable_time = BD71847_BUCK2_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) .of_parse_cb = buck_set_hw_dvs_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) .dvs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) .run_reg = BD718XX_REG_BUCK2_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) .run_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) .idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) .idle_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) .reg = BD718XX_REG_BUCK2_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) .name = "buck3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) .of_match = of_match_ptr("BUCK3"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) .id = BD718XX_BUCK3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) .n_voltages = BD71847_BUCK3_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) .linear_ranges = bd71847_buck3_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) ARRAY_SIZE(bd71847_buck3_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) .vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) .vsel_mask = BD718XX_1ST_NODVS_BUCK_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) .vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) .vsel_range_mask = BD71847_BUCK3_RANGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) .linear_range_selectors = bd71847_buck3_volt_range_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) .enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) .enable_time = BD71847_BUCK3_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) .reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) .name = "buck4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) .of_match = of_match_ptr("BUCK4"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) .id = BD718XX_BUCK4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) .n_voltages = BD71847_BUCK4_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) .linear_ranges = bd71847_buck4_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) ARRAY_SIZE(bd71847_buck4_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) .enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) .vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) .vsel_mask = BD71847_BUCK4_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) .vsel_range_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) .vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) .linear_range_selectors = bd71847_buck4_volt_range_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) .enable_time = BD71847_BUCK4_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) .reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) .name = "buck5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) .of_match = of_match_ptr("BUCK5"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) .id = BD718XX_BUCK5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) .volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) .n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) .vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) .vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) .enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) .enable_time = BD71847_BUCK5_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) .reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) .name = "buck6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) .of_match = of_match_ptr("BUCK6"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) .id = BD718XX_BUCK6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) .n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) .linear_ranges = bd718xx_4th_nodvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) .vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) .vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) .enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) .enable_time = BD71847_BUCK6_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) .reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) .name = "ldo1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) .of_match = of_match_ptr("LDO1"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) .id = BD718XX_LDO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) .n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) .linear_ranges = bd718xx_ldo1_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) .vsel_reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) .vsel_mask = BD718XX_LDO1_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) .vsel_range_reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) .vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) .linear_range_selectors = bd718xx_ldo1_volt_range_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) .enable_reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) .enable_time = BD71847_LDO1_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) .reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) .name = "ldo2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) .of_match = of_match_ptr("LDO2"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) .id = BD718XX_LDO2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) .volt_table = &ldo_2_volts[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) .vsel_reg = BD718XX_REG_LDO2_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) .vsel_mask = BD718XX_LDO2_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) .n_voltages = ARRAY_SIZE(ldo_2_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) .enable_reg = BD718XX_REG_LDO2_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) .enable_time = BD71847_LDO2_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) .reg = BD718XX_REG_LDO2_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) .name = "ldo3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) .of_match = of_match_ptr("LDO3"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) .id = BD718XX_LDO3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) .n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) .linear_ranges = bd718xx_ldo3_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) .vsel_reg = BD718XX_REG_LDO3_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) .vsel_mask = BD718XX_LDO3_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) .enable_reg = BD718XX_REG_LDO3_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) .enable_time = BD71847_LDO3_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) .reg = BD718XX_REG_LDO3_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) .name = "ldo4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) .of_match = of_match_ptr("LDO4"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) .id = BD718XX_LDO4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) .n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) .linear_ranges = bd718xx_ldo4_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) .vsel_reg = BD718XX_REG_LDO4_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) .vsel_mask = BD718XX_LDO4_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) .enable_reg = BD718XX_REG_LDO4_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) .enable_time = BD71847_LDO4_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) .reg = BD718XX_REG_LDO4_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) .name = "ldo5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) .of_match = of_match_ptr("LDO5"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) .id = BD718XX_LDO5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) .n_voltages = BD71847_LDO5_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) .linear_ranges = bd71847_ldo5_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) .n_linear_ranges = ARRAY_SIZE(bd71847_ldo5_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) .vsel_reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) .vsel_mask = BD71847_LDO5_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) .vsel_range_reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) .vsel_range_mask = BD71847_LDO5_RANGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) .linear_range_selectors = bd71847_ldo5_volt_range_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) .enable_reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) .enable_time = BD71847_LDO5_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) .reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) .name = "ldo6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) .of_match = of_match_ptr("LDO6"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) .id = BD718XX_LDO6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) .n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) .linear_ranges = bd718xx_ldo6_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) /* LDO6 is supplied by buck5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) .supply_name = "buck5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) .vsel_reg = BD718XX_REG_LDO6_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) .vsel_mask = BD718XX_LDO6_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) .enable_reg = BD718XX_REG_LDO6_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) .enable_time = BD71847_LDO6_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) .reg = BD718XX_REG_LDO6_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) static const struct regulator_ops *bd71837_swcontrol_ops[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) &bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) &bd718xx_dvs_buck_regulator_ops, &bd718xx_dvs_buck_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) &bd71837_pickable_range_buck_ops, &bd71837_buck_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) &bd71837_buck_regulator_nolinear_ops, &bd71837_buck_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) &bd71837_pickable_range_ldo_ops, &bd71837_ldo_regulator_nolinear_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) &bd71837_ldo_regulator_ops, &bd71837_ldo_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) &bd71837_ldo_regulator_ops, &bd71837_ldo_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) &bd71837_ldo_regulator_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) static const struct regulator_ops *bd71837_hwcontrol_ops[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) &BD718XX_HWOPNAME(bd718xx_dvs_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) &bd71837_buck34_ops_hwctrl, &bd71837_buck34_ops_hwctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) &BD718XX_HWOPNAME(bd71837_pickable_range_buck_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) &BD718XX_HWOPNAME(bd71837_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) &BD718XX_HWOPNAME(bd71837_buck_regulator_nolinear_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) &BD718XX_HWOPNAME(bd71837_buck_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) &BD718XX_HWOPNAME(bd71837_pickable_range_ldo_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) &BD718XX_HWOPNAME(bd71837_ldo_regulator_nolinear_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) &BD718XX_HWOPNAME(bd71837_ldo_regulator_ops),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) static struct bd718xx_regulator_data bd71837_regulators[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) .name = "buck1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) .of_match = of_match_ptr("BUCK1"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) .id = BD718XX_BUCK1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) .linear_ranges = bd718xx_dvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) .vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) .vsel_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) .enable_reg = BD718XX_REG_BUCK1_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) .enable_time = BD71837_BUCK1_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) .of_parse_cb = buck_set_hw_dvs_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) .dvs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) ROHM_DVS_LEVEL_SUSPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) .run_reg = BD718XX_REG_BUCK1_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) .run_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) .idle_reg = BD718XX_REG_BUCK1_VOLT_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) .idle_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) .suspend_reg = BD718XX_REG_BUCK1_VOLT_SUSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) .suspend_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) .reg = BD718XX_REG_BUCK1_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) .name = "buck2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) .of_match = of_match_ptr("BUCK2"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) .id = BD718XX_BUCK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) .linear_ranges = bd718xx_dvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) .vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) .vsel_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) .enable_reg = BD718XX_REG_BUCK2_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) .enable_time = BD71837_BUCK2_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) .of_parse_cb = buck_set_hw_dvs_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) .dvs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) .level_map = ROHM_DVS_LEVEL_RUN | ROHM_DVS_LEVEL_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) .run_reg = BD718XX_REG_BUCK2_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) .run_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) .idle_reg = BD718XX_REG_BUCK2_VOLT_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) .idle_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) .reg = BD718XX_REG_BUCK2_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) .name = "buck3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) .of_match = of_match_ptr("BUCK3"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) .id = BD718XX_BUCK3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) .linear_ranges = bd718xx_dvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) .vsel_reg = BD71837_REG_BUCK3_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) .vsel_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) .enable_reg = BD71837_REG_BUCK3_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) .enable_time = BD71837_BUCK3_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) .of_parse_cb = buck_set_hw_dvs_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) .dvs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) .level_map = ROHM_DVS_LEVEL_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) .run_reg = BD71837_REG_BUCK3_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) .run_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) .reg = BD71837_REG_BUCK3_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) .name = "buck4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) .of_match = of_match_ptr("BUCK4"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) .id = BD718XX_BUCK4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) .linear_ranges = bd718xx_dvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) .vsel_reg = BD71837_REG_BUCK4_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) .vsel_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) .enable_reg = BD71837_REG_BUCK4_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) .enable_time = BD71837_BUCK4_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) .of_parse_cb = buck_set_hw_dvs_levels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) .dvs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) .level_map = ROHM_DVS_LEVEL_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) .run_reg = BD71837_REG_BUCK4_VOLT_RUN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) .run_mask = DVS_BUCK_RUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) .reg = BD71837_REG_BUCK4_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) .name = "buck5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) .of_match = of_match_ptr("BUCK5"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) .id = BD718XX_BUCK5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) .n_voltages = BD71837_BUCK5_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) .linear_ranges = bd71837_buck5_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) ARRAY_SIZE(bd71837_buck5_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) .vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) .vsel_mask = BD71837_BUCK5_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) .vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) .vsel_range_mask = BD71837_BUCK5_RANGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) .linear_range_selectors = bd71837_buck5_volt_range_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) .enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) .enable_time = BD71837_BUCK5_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) .reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) .name = "buck6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) .of_match = of_match_ptr("BUCK6"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) .id = BD718XX_BUCK6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) .n_voltages = BD71837_BUCK6_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) .linear_ranges = bd71837_buck6_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) ARRAY_SIZE(bd71837_buck6_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) .vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) .vsel_mask = BD71837_BUCK6_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) .enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) .enable_time = BD71837_BUCK6_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) .reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) .name = "buck7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) .of_match = of_match_ptr("BUCK7"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) .id = BD718XX_BUCK7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) .volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) .n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) .vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) .vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) .enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) .enable_time = BD71837_BUCK7_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) .reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) .name = "buck8",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) .of_match = of_match_ptr("BUCK8"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) .id = BD718XX_BUCK8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) .n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) .linear_ranges = bd718xx_4th_nodvs_buck_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) .n_linear_ranges =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) .vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) .vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) .enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) .enable_mask = BD718XX_BUCK_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) .enable_time = BD71837_BUCK8_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) .reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) .mask = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) .val = BD718XX_BUCK_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) .name = "ldo1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) .of_match = of_match_ptr("LDO1"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) .id = BD718XX_LDO1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) .n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) .linear_ranges = bd718xx_ldo1_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) .vsel_reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) .vsel_mask = BD718XX_LDO1_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) .vsel_range_reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) .vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) .linear_range_selectors = bd718xx_ldo1_volt_range_sel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) .enable_reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) .enable_time = BD71837_LDO1_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) .reg = BD718XX_REG_LDO1_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) .name = "ldo2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) .of_match = of_match_ptr("LDO2"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) .id = BD718XX_LDO2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) .volt_table = &ldo_2_volts[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) .vsel_reg = BD718XX_REG_LDO2_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) .vsel_mask = BD718XX_LDO2_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) .n_voltages = ARRAY_SIZE(ldo_2_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) .enable_reg = BD718XX_REG_LDO2_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) .enable_time = BD71837_LDO2_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) .reg = BD718XX_REG_LDO2_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) .name = "ldo3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) .of_match = of_match_ptr("LDO3"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) .id = BD718XX_LDO3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) .n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) .linear_ranges = bd718xx_ldo3_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) .vsel_reg = BD718XX_REG_LDO3_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) .vsel_mask = BD718XX_LDO3_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) .enable_reg = BD718XX_REG_LDO3_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) .enable_time = BD71837_LDO3_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) .reg = BD718XX_REG_LDO3_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) .name = "ldo4",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) .of_match = of_match_ptr("LDO4"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) .id = BD718XX_LDO4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) .n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) .linear_ranges = bd718xx_ldo4_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) .vsel_reg = BD718XX_REG_LDO4_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) .vsel_mask = BD718XX_LDO4_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) .enable_reg = BD718XX_REG_LDO4_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) .enable_time = BD71837_LDO4_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) .reg = BD718XX_REG_LDO4_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) .name = "ldo5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) .of_match = of_match_ptr("LDO5"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) .id = BD718XX_LDO5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) .n_voltages = BD71837_LDO5_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) .linear_ranges = bd71837_ldo5_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) .n_linear_ranges = ARRAY_SIZE(bd71837_ldo5_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) /* LDO5 is supplied by buck6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) .supply_name = "buck6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) .vsel_reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) .vsel_mask = BD71837_LDO5_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) .enable_reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) .enable_time = BD71837_LDO5_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) .reg = BD718XX_REG_LDO5_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) .additional_inits = bd71837_ldo5_inits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) .additional_init_amnt = ARRAY_SIZE(bd71837_ldo5_inits),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) .name = "ldo6",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) .of_match = of_match_ptr("LDO6"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) .id = BD718XX_LDO6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) .n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) .linear_ranges = bd718xx_ldo6_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) /* LDO6 is supplied by buck7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) .supply_name = "buck7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) .vsel_reg = BD718XX_REG_LDO6_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) .vsel_mask = BD718XX_LDO6_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) .enable_reg = BD718XX_REG_LDO6_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) .enable_time = BD71837_LDO6_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) .reg = BD718XX_REG_LDO6_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) .additional_inits = bd71837_ldo6_inits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) .additional_init_amnt = ARRAY_SIZE(bd71837_ldo6_inits),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) .desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) .name = "ldo7",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) .of_match = of_match_ptr("LDO7"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) .regulators_node = of_match_ptr("regulators"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) .id = BD718XX_LDO7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) .type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) .n_voltages = BD71837_LDO7_VOLTAGE_NUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) .linear_ranges = bd71837_ldo7_volts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) .n_linear_ranges = ARRAY_SIZE(bd71837_ldo7_volts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) .vsel_reg = BD71837_REG_LDO7_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) .vsel_mask = BD71837_LDO7_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) .enable_reg = BD71837_REG_LDO7_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) .enable_mask = BD718XX_LDO_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) .enable_time = BD71837_LDO7_STARTUP_TIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) .init = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) .reg = BD71837_REG_LDO7_VOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) .mask = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) .val = BD718XX_LDO_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) static void mark_hw_controlled(struct device *dev, struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) struct bd718xx_regulator_data *reg_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) unsigned int num_reg_data, int *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) for (i = 1; i <= num_reg_data; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) if (!of_node_name_eq(np, reg_data[i-1].desc.of_match))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) *info |= 1 << (i - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) dev_dbg(dev, "regulator %d runlevel controlled\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) dev_warn(dev, "Bad regulator node\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) static int get_hw_controlled_regulators(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) struct bd718xx_regulator_data *reg_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) unsigned int num_reg_data, int *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) struct device_node *nproot = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) const char *prop = "rohm,no-regulator-enable-control";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) *info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) nproot = of_get_child_by_name(nproot, "regulators");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) if (!nproot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) dev_err(dev, "failed to find regulators node\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) for_each_child_of_node(nproot, np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) if (of_property_read_bool(np, prop))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) mark_hw_controlled(dev, np, reg_data, num_reg_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) of_node_put(nproot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) static int bd718xx_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) struct bd718xx *mfd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) struct regulator_config config = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) int i, j, err, omit_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) bool use_snvs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) struct bd718xx_regulator_data *reg_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) unsigned int num_reg_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) const struct regulator_ops **swops, **hwops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) mfd = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) if (!mfd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) dev_err(&pdev->dev, "No MFD driver data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) switch (chip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) case ROHM_CHIP_TYPE_BD71837:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) reg_data = bd71837_regulators;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) num_reg_data = ARRAY_SIZE(bd71837_regulators);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) swops = &bd71837_swcontrol_ops[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) hwops = &bd71837_hwcontrol_ops[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) case ROHM_CHIP_TYPE_BD71847:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) reg_data = bd71847_regulators;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) num_reg_data = ARRAY_SIZE(bd71847_regulators);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) swops = &bd71847_swcontrol_ops[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) hwops = &bd71847_hwcontrol_ops[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) dev_err(&pdev->dev, "Unsupported chip type\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) /* Register LOCK release */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) err = regmap_update_bits(mfd->chip.regmap, BD718XX_REG_REGLOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) (REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) BD718XX_REG_REGLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) use_snvs = of_property_read_bool(pdev->dev.parent->of_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) "rohm,reset-snvs-powered");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) * Change the next stage from poweroff to be READY instead of SNVS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * for all reset types because OTP loading at READY will clear SEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * bit allowing HW defaults for power rails to be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) if (!use_snvs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) err = regmap_update_bits(mfd->chip.regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) BD718XX_REG_TRANS_COND1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) BD718XX_ON_REQ_POWEROFF_MASK |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) BD718XX_SWRESET_POWEROFF_MASK |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) BD718XX_WDOG_POWEROFF_MASK |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) BD718XX_KEY_L_POWEROFF_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) BD718XX_POWOFF_TO_RDY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) dev_err(&pdev->dev, "Failed to change reset target\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) dev_dbg(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) "Changed all resets from SVNS to READY\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) config.dev = pdev->dev.parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) config.regmap = mfd->chip.regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) * There are cases when we want to leave the enable-control for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) * the HW state machine and use this driver only for voltage control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) * One special case is when we use PMIC_STBY_REQ line from SoC to PMIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) * in order to set the system to SUSPEND state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) * If regulator is taken under SW control the regulator state will not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) * be affected by PMIC state machine - Eg. regulator is likely to stay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) * on even in SUSPEND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) get_hw_controlled_regulators(pdev->dev.parent, reg_data, num_reg_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) &omit_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) for (i = 0; i < num_reg_data; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) struct regulator_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) struct bd718xx_regulator_data *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) int no_enable_control = omit_enable & (1 << i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) r = ®_data[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) desc = &r->desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) if (no_enable_control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) desc->ops = hwops[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) desc->ops = swops[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) rdev = devm_regulator_register(&pdev->dev, desc, &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) "failed to register %s regulator\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) desc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) err = PTR_ERR(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) * Regulator register gets the regulator constraints and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) * applies them (set_machine_constraints). This should have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) * turned the control register(s) to correct values and we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) * can now switch the control from PMIC state machine to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) * register interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) * At poweroff transition PMIC HW disables EN bit for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) * regulators but leaves SEL bit untouched. So if state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) * transition from POWEROFF is done to SNVS - then all power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) * rails controlled by SW (having SEL bit set) stay disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) * as EN is cleared. This will result boot failure if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) * crucial systems are powered by these rails. We don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) * enable SW control for crucial regulators if snvs state is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) * used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) if (!no_enable_control && (!use_snvs ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) !rdev->constraints->always_on ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) !rdev->constraints->boot_on)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) err = regmap_update_bits(mfd->chip.regmap, r->init.reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) r->init.mask, r->init.val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) "Failed to take control for (%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) desc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) for (j = 0; j < r->additional_init_amnt; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) err = regmap_update_bits(mfd->chip.regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) r->additional_inits[j].reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) r->additional_inits[j].mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) r->additional_inits[j].val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) "Buck (%s) initialization failed\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) desc->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) static const struct platform_device_id bd718x7_pmic_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) { "bd71837-pmic", ROHM_CHIP_TYPE_BD71837 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) { "bd71847-pmic", ROHM_CHIP_TYPE_BD71847 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) MODULE_DEVICE_TABLE(platform, bd718x7_pmic_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) static struct platform_driver bd718xx_regulator = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) .name = "bd718xx-pmic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) .probe = bd718xx_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) .id_table = bd718x7_pmic_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) module_platform_driver(bd718xx_regulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) MODULE_ALIAS("platform:bd718xx-pmic");