Commit 6097d55e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regulator-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
 "A quiet regulator API release, a few new drivers and some fixes but
  nothing too notable.  There will also be some updates for the PWM
  regulator coming through the PWM tree which provide much smoother
  operation when taking over an already running PWM regulator after boot
  using some new PWM APIs.

  Summary:

   - Support for configuration of the initial suspend state from DT.

   - New drivers for Mediatek MT6323, Ricoh RN5T567 and X-Powers AXP809"

* tag 'regulator-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (38 commits)
  regulator: da9053/52: Fix incorrectly stated minimum and maximum voltage limits
  regulator: mt6323: Constify struct regulator_ops
  regulator: mt6323: Fix module description
  regulator: mt6323: Add support for MT6323 regulator
  regulator: Add document for MT6323 regulator
  regulator: da9210: addition of device tree support
  regulator: act8865: Fix missing of_node_put() in act8865_pdata_from_dt()
  regulator: qcom_smd: Avoid overlapping linear voltage ranges
  regulator: s2mps11: Fix the voltage linear range for s2mps15
  regulator: pwm: Fix regulator ramp delay for continuous mode
  regulator: da9211: add descriptions for da9212/da9214
  mfd: rn5t618: Register restart handler
  mfd: rn5t618: Register power off callback optionally
  regulator: rn5t618: Add RN5T567 PMIC support
  mfd: rn5t618: Add Ricoh RN5T567 PMIC support
  ARM: dts: meson: minix-neo-x8: define PMIC as power controller
  regulator: tps65218: force set power-up/down strobe to 3 for dcdc3
  regulator: tps65218: Enable suspend configuration
  regulator: tps65217: Enable suspend configuration
  regulator: qcom_spmi: Add support for get_mode/set_mode on switches
  ...
parents ae979997 a485f5fc
...@@ -22,6 +22,11 @@ Optional properties: ...@@ -22,6 +22,11 @@ Optional properties:
AXP152/20X: range: 750-1875, Default: 1.5 MHz AXP152/20X: range: 750-1875, Default: 1.5 MHz
AXP22X/80X: range: 1800-4050, Default: 3 MHz AXP22X/80X: range: 1800-4050, Default: 3 MHz
- x-powers,drive-vbus-en: axp221 / axp223 only boolean, set this when the
N_VBUSEN pin is used as an output pin to control an external
regulator to drive the OTG VBus, rather then as an input pin
which signals whether the board is driving OTG VBus or not.
- <input>-supply: a phandle to the regulator supply node. May be omitted if - <input>-supply: a phandle to the regulator supply node. May be omitted if
inputs are unregulated, such as using the IPSOUT output inputs are unregulated, such as using the IPSOUT output
from the PMIC. from the PMIC.
...@@ -79,6 +84,7 @@ ELDO3 : LDO : eldoin-supply : shared supply ...@@ -79,6 +84,7 @@ ELDO3 : LDO : eldoin-supply : shared supply
LDO_IO0 : LDO : ips-supply : GPIO 0 LDO_IO0 : LDO : ips-supply : GPIO 0
LDO_IO1 : LDO : ips-supply : GPIO 1 LDO_IO1 : LDO : ips-supply : GPIO 1
RTC_LDO : LDO : ips-supply : always on RTC_LDO : LDO : ips-supply : always on
DRIVEVBUS : Enable output : drivevbus-supply : external regulator
AXP809 regulators, type, and corresponding input supply names: AXP809 regulators, type, and corresponding input supply names:
......
* Ricoh RN5T618 PMIC * Ricoh RN5T567/RN5T618 PMIC
Ricoh RN5T618 is a power management IC which integrates 3 step-down Ricoh RN5T567/RN5T618 is a power management IC family which integrates
DCDC converters, 7 low-dropout regulators, a Li-ion battery charger, 3 to 4 step-down DCDC converters, 7 low-dropout regulators, GPIOs and
fuel gauge, ADC, GPIOs and a watchdog timer. It can be controlled a watchdog timer. The RN5T618 provides additionally a Li-ion battery
through a I2C interface. charger, fuel gauge and an ADC. It can be controlled through an I2C
interface.
Required properties: Required properties:
- compatible: should be "ricoh,rn5t618" - compatible: must be one of
"ricoh,rn5t567"
"ricoh,rn5t618"
- reg: the I2C slave address of the device - reg: the I2C slave address of the device
Sub-nodes: Sub-nodes:
- regulators: the node is required if the regulator functionality is - regulators: the node is required if the regulator functionality is
needed. The valid regulator names are: DCDC1, DCDC2, DCDC3, LDO1, needed. The valid regulator names are: DCDC1, DCDC2, DCDC3, DCDC4
LDO2, LDO3, LDO4, LDO5, LDORTC1 and LDORTC2. (RN5T567), LDO1, LDO2, LDO3, LDO4, LDO5, LDORTC1 and LDORTC2.
The common bindings for each individual regulator can be found in: The common bindings for each individual regulator can be found in:
Documentation/devicetree/bindings/regulator/regulator.txt Documentation/devicetree/bindings/regulator/regulator.txt
......
* Dialog Semiconductor DA9210 Voltage Regulator * Dialog Semiconductor DA9210 Multi-phase 12A DCDC BUCK Converter
Required properties: Required properties:
...@@ -18,8 +18,12 @@ Example: ...@@ -18,8 +18,12 @@ Example:
compatible = "dlg,da9210"; compatible = "dlg,da9210";
reg = <0x68>; reg = <0x68>;
regulator-min-microvolt = <900000>; interrupt-parent = <...>;
regulator-max-microvolt = <1000000>; interrupts = <...>;
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <1600000>;
regulator-max-microamp = <4600000>;
regulator-boot-on; regulator-boot-on;
regulator-always-on;
}; };
* Dialog Semiconductor DA9211/DA9213/DA9215 Voltage Regulator * Dialog Semiconductor DA9211/DA9212/DA9213/DA9214/DA9215 Voltage Regulator
Required properties: Required properties:
- compatible: "dlg,da9211" or "dlg,da9213" or "dlg,da9215" - compatible: "dlg,da9211" or "dlg,da9212" or "dlg,da9213"
or "dlg,da9214" or "dlg,da9215"
- reg: I2C slave address, usually 0x68. - reg: I2C slave address, usually 0x68.
- interrupts: the interrupt outputs of the controller - interrupts: the interrupt outputs of the controller
- regulators: A node that houses a sub-node for each regulator within the - regulators: A node that houses a sub-node for each regulator within the
...@@ -21,6 +22,25 @@ Example 1) DA9211 ...@@ -21,6 +22,25 @@ Example 1) DA9211
reg = <0x68>; reg = <0x68>;
interrupts = <3 27>; interrupts = <3 27>;
regulators {
BUCKA {
regulator-name = "VBUCKA";
regulator-min-microvolt = < 300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <2000000>;
regulator-max-microamp = <5000000>;
enable-gpios = <&gpio 27 0>;
};
};
};
Example 2) DA9212
pmic: da9212@68 {
compatible = "dlg,da9212";
reg = <0x68>;
interrupts = <3 27>;
regulators { regulators {
BUCKA { BUCKA {
regulator-name = "VBUCKA"; regulator-name = "VBUCKA";
...@@ -41,12 +61,30 @@ Example 1) DA9211 ...@@ -41,12 +61,30 @@ Example 1) DA9211
}; };
}; };
Example 2) DA9213 Example 3) DA9213
pmic: da9213@68 { pmic: da9213@68 {
compatible = "dlg,da9213"; compatible = "dlg,da9213";
reg = <0x68>; reg = <0x68>;
interrupts = <3 27>; interrupts = <3 27>;
regulators {
BUCKA {
regulator-name = "VBUCKA";
regulator-min-microvolt = < 300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <3000000>;
regulator-max-microamp = <6000000>;
enable-gpios = <&gpio 27 0>;
};
};
};
Example 4) DA9214
pmic: da9214@68 {
compatible = "dlg,da9214";
reg = <0x68>;
interrupts = <3 27>;
regulators { regulators {
BUCKA { BUCKA {
regulator-name = "VBUCKA"; regulator-name = "VBUCKA";
...@@ -67,8 +105,7 @@ Example 2) DA9213 ...@@ -67,8 +105,7 @@ Example 2) DA9213
}; };
}; };
Example 5) DA9215
Example 3) DA9215
pmic: da9215@68 { pmic: da9215@68 {
compatible = "dlg,da9215"; compatible = "dlg,da9215";
reg = <0x68>; reg = <0x68>;
......
Mediatek MT6323 Regulator Driver
All voltage regulators are defined as subnodes of the regulators node. A list
of regulators provided by this controller are defined as subnodes of the
PMIC's node. Each regulator is named according to its regulator type,
buck_<name> and ldo_<name>. The definition for each of these nodes is defined
using the standard binding for regulators at
Documentation/devicetree/bindings/regulator/regulator.txt.
The valid names for regulators are::
BUCK:
buck_vproc, buck_vsys, buck_vpa
LDO:
ldo_vtcxo, ldo_vcn28, ldo_vcn33_bt, ldo_vcn33_wifi, ldo_va, ldo_vcama,
ldo_vio28, ldo_vusb, ldo_vmc, ldo_vmch, ldo_vemc3v3, ldo_vgp1, ldo_vgp2,
ldo_vgp3, ldo_vcn18, ldo_vsim1, ldo_vsim2, ldo_vrtc, ldo_vcamaf, ldo_vibr,
ldo_vrf18, ldo_vm, ldo_vio18, ldo_vcamd, ldo_vcamio
Example:
pmic: mt6323 {
mt6323regulator: regulators {
mt6323_vproc_reg: buck_vproc{
regulator-name = "vproc";
regulator-min-microvolt = < 700000>;
regulator-max-microvolt = <1350000>;
regulator-ramp-delay = <12500>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vsys_reg: buck_vsys{
regulator-name = "vsys";
regulator-min-microvolt = <1400000>;
regulator-max-microvolt = <2987500>;
regulator-ramp-delay = <25000>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vpa_reg: buck_vpa{
regulator-name = "vpa";
regulator-min-microvolt = < 500000>;
regulator-max-microvolt = <3650000>;
};
mt6323_vtcxo_reg: ldo_vtcxo{
regulator-name = "vtcxo";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-enable-ramp-delay = <90>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vcn28_reg: ldo_vcn28{
regulator-name = "vcn28";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-enable-ramp-delay = <185>;
};
mt6323_vcn33_bt_reg: ldo_vcn33_bt{
regulator-name = "vcn33_bt";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3600000>;
regulator-enable-ramp-delay = <185>;
};
mt6323_vcn33_wifi_reg: ldo_vcn33_wifi{
regulator-name = "vcn33_wifi";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3600000>;
regulator-enable-ramp-delay = <185>;
};
mt6323_va_reg: ldo_va{
regulator-name = "va";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-enable-ramp-delay = <216>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vcama_reg: ldo_vcama{
regulator-name = "vcama";
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <2800000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vio28_reg: ldo_vio28{
regulator-name = "vio28";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-enable-ramp-delay = <216>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vusb_reg: ldo_vusb{
regulator-name = "vusb";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <216>;
regulator-boot-on;
};
mt6323_vmc_reg: ldo_vmc{
regulator-name = "vmc";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <36>;
regulator-boot-on;
};
mt6323_vmch_reg: ldo_vmch{
regulator-name = "vmch";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <36>;
regulator-boot-on;
};
mt6323_vemc3v3_reg: ldo_vemc3v3{
regulator-name = "vemc3v3";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <36>;
regulator-boot-on;
};
mt6323_vgp1_reg: ldo_vgp1{
regulator-name = "vgp1";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vgp2_reg: ldo_vgp2{
regulator-name = "vgp2";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3000000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vgp3_reg: ldo_vgp3{
regulator-name = "vgp3";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1800000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vcn18_reg: ldo_vcn18{
regulator-name = "vcn18";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vsim1_reg: ldo_vsim1{
regulator-name = "vsim1";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3000000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vsim2_reg: ldo_vsim2{
regulator-name = "vsim2";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3000000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vrtc_reg: ldo_vrtc{
regulator-name = "vrtc";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vcamaf_reg: ldo_vcamaf{
regulator-name = "vcamaf";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vibr_reg: ldo_vibr{
regulator-name = "vibr";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3300000>;
regulator-enable-ramp-delay = <36>;
};
mt6323_vrf18_reg: ldo_vrf18{
regulator-name = "vrf18";
regulator-min-microvolt = <1825000>;
regulator-max-microvolt = <1825000>;
regulator-enable-ramp-delay = <187>;
};
mt6323_vm_reg: ldo_vm{
regulator-name = "vm";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1800000>;
regulator-enable-ramp-delay = <216>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vio18_reg: ldo_vio18{
regulator-name = "vio18";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-enable-ramp-delay = <216>;
regulator-always-on;
regulator-boot-on;
};
mt6323_vcamd_reg: ldo_vcamd{
regulator-name = "vcamd";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1800000>;
regulator-enable-ramp-delay = <216>;
};
mt6323_vcamio_reg: ldo_vcamio{
regulator-name = "vcamio";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-enable-ramp-delay = <216>;
};
};
};
...@@ -38,13 +38,18 @@ NB: To be clear, if voltage-table is provided, then the device will be used ...@@ -38,13 +38,18 @@ NB: To be clear, if voltage-table is provided, then the device will be used
in Voltage Table Mode. If no voltage-table is provided, then the device will in Voltage Table Mode. If no voltage-table is provided, then the device will
be used in Continuous Voltage Mode. be used in Continuous Voltage Mode.
Optional properties:
--------------------
- enable-gpios: GPIO to use to enable/disable the regulator
Any property defined as part of the core regulator binding can also be used. Any property defined as part of the core regulator binding can also be used.
(See: ../regulator/regulator.txt) (See: ../regulator/regulator.txt)
Continuous Voltage Example: Continuous Voltage With Enable GPIO Example:
pwm_regulator { pwm_regulator {
compatible = "pwm-regulator; compatible = "pwm-regulator;
pwms = <&pwm1 0 8448 0>; pwms = <&pwm1 0 8448 0>;
enable-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
regulator-min-microvolt = <1016000>; regulator-min-microvolt = <1016000>;
regulator-max-microvolt = <1114000>; regulator-max-microvolt = <1114000>;
regulator-name = "vdd_logic"; regulator-name = "vdd_logic";
......
...@@ -113,9 +113,9 @@ pm8916: ...@@ -113,9 +113,9 @@ pm8916:
l14, l15, l16, l17, l18 l14, l15, l16, l17, l18
pm8941: pm8941:
s1, s2, s3, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, s1, s2, s3, s4, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13,
l15, l16, l17, l18, l19, l20, l21, l22, l23, l24, lvs1, lvs2, lvs3, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24, lvs1, lvs2, lvs3,
mvs1, mvs2 5vs1, 5vs2
pm8994: pm8994:
s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3, l4, l5, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3, l4, l5,
......
...@@ -80,6 +80,7 @@ &i2c_AO { ...@@ -80,6 +80,7 @@ &i2c_AO {
pmic@32 { pmic@32 {
compatible = "ricoh,rn5t618"; compatible = "ricoh,rn5t618";
reg = <0x32>; reg = <0x32>;
system-power-controller;
regulators { regulators {
}; };
......
...@@ -852,13 +852,14 @@ config MFD_RK808 ...@@ -852,13 +852,14 @@ config MFD_RK808
including interrupts, RTC, LDO & DCDC regulators, and onkey. including interrupts, RTC, LDO & DCDC regulators, and onkey.
config MFD_RN5T618 config MFD_RN5T618
tristate "Ricoh RN5T5618 PMIC" tristate "Ricoh RN5T567/618 PMIC"
depends on I2C depends on I2C
depends on OF
select MFD_CORE select MFD_CORE
select REGMAP_I2C select REGMAP_I2C
help help
Say yes here to add support for the Ricoh RN5T618 PMIC. This Say yes here to add support for the Ricoh RN5T567 or R5T618 PMIC.
driver provides common support for accessing the device, This driver provides common support for accessing the device,
additional drivers must be enabled in order to use the additional drivers must be enabled in order to use the
functionality of the device. functionality of the device.
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* MFD core driver for Ricoh RN5T618 PMIC * MFD core driver for Ricoh RN5T618 PMIC
* *
* Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
* Copyright (C) 2016 Toradex AG
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -11,10 +12,13 @@ ...@@ -11,10 +12,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/mfd/rn5t618.h> #include <linux/mfd/rn5t618.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h>
#include <linux/reboot.h>
#include <linux/regmap.h> #include <linux/regmap.h>
static const struct mfd_cell rn5t618_cells[] = { static const struct mfd_cell rn5t618_cells[] = {
...@@ -48,28 +52,64 @@ static const struct regmap_config rn5t618_regmap_config = { ...@@ -48,28 +52,64 @@ static const struct regmap_config rn5t618_regmap_config = {
}; };
static struct rn5t618 *rn5t618_pm_power_off; static struct rn5t618 *rn5t618_pm_power_off;
static struct notifier_block rn5t618_restart_handler;
static void rn5t618_power_off(void) static void rn5t618_trigger_poweroff_sequence(bool repower)
{ {
/* disable automatic repower-on */ /* disable automatic repower-on */
regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_REPCNT, regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_REPCNT,
RN5T618_REPCNT_REPWRON, 0); RN5T618_REPCNT_REPWRON,
repower ? RN5T618_REPCNT_REPWRON : 0);
/* start power-off sequence */ /* start power-off sequence */
regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_SLPCNT, regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_SLPCNT,
RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF); RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF);
} }
static void rn5t618_power_off(void)
{
rn5t618_trigger_poweroff_sequence(false);
}
static int rn5t618_restart(struct notifier_block *this,
unsigned long mode, void *cmd)
{
rn5t618_trigger_poweroff_sequence(true);
/*
* Re-power factor detection on PMIC side is not instant. 1ms
* proved to be enough time until reset takes effect.
*/
mdelay(1);
return NOTIFY_DONE;
}
static const struct of_device_id rn5t618_of_match[] = {
{ .compatible = "ricoh,rn5t567", .data = (void *)RN5T567 },
{ .compatible = "ricoh,rn5t618", .data = (void *)RN5T618 },
{ }
};
MODULE_DEVICE_TABLE(of, rn5t618_of_match);
static int rn5t618_i2c_probe(struct i2c_client *i2c, static int rn5t618_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
const struct of_device_id *of_id;
struct rn5t618 *priv; struct rn5t618 *priv;
int ret; int ret;
of_id = of_match_device(rn5t618_of_match, &i2c->dev);
if (!of_id) {
dev_err(&i2c->dev, "Failed to find matching DT ID\n");
return -EINVAL;
}
priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
i2c_set_clientdata(i2c, priv); i2c_set_clientdata(i2c, priv);
priv->variant = (long)of_id->data;
priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config); priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config);
if (IS_ERR(priv->regmap)) { if (IS_ERR(priv->regmap)) {
...@@ -85,9 +125,21 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c, ...@@ -85,9 +125,21 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
if (!pm_power_off) {
rn5t618_pm_power_off = priv; rn5t618_pm_power_off = priv;
if (of_device_is_system_power_controller(i2c->dev.of_node)) {
if (!pm_power_off)
pm_power_off = rn5t618_power_off; pm_power_off = rn5t618_power_off;
else
dev_warn(&i2c->dev, "Poweroff callback already assigned\n");
}
rn5t618_restart_handler.notifier_call = rn5t618_restart;
rn5t618_restart_handler.priority = 192;
ret = register_restart_handler(&rn5t618_restart_handler);
if (ret) {
dev_err(&i2c->dev, "cannot register restart handler, %d\n", ret);
return ret;
} }
return 0; return 0;
...@@ -105,12 +157,6 @@ static int rn5t618_i2c_remove(struct i2c_client *i2c) ...@@ -105,12 +157,6 @@ static int rn5t618_i2c_remove(struct i2c_client *i2c)
return 0; return 0;
} }
static const struct of_device_id rn5t618_of_match[] = {
{ .compatible = "ricoh,rn5t618" },
{ }
};
MODULE_DEVICE_TABLE(of, rn5t618_of_match);
static const struct i2c_device_id rn5t618_i2c_id[] = { static const struct i2c_device_id rn5t618_i2c_id[] = {
{ } { }
}; };
...@@ -129,5 +175,5 @@ static struct i2c_driver rn5t618_i2c_driver = { ...@@ -129,5 +175,5 @@ static struct i2c_driver rn5t618_i2c_driver = {
module_i2c_driver(rn5t618_i2c_driver); module_i2c_driver(rn5t618_i2c_driver);
MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>"); MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>");
MODULE_DESCRIPTION("Ricoh RN5T618 MFD driver"); MODULE_DESCRIPTION("Ricoh RN5T567/618 MFD driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -498,6 +498,15 @@ config REGULATOR_MT6311 ...@@ -498,6 +498,15 @@ config REGULATOR_MT6311
This driver supports the control of different power rails of device This driver supports the control of different power rails of device
through regulator interface. through regulator interface.
config REGULATOR_MT6323
tristate "MediaTek MT6323 PMIC"
depends on MFD_MT6397
help
Say y here to select this option to enable the power regulator of
MediaTek MT6323 PMIC.
This driver supports the control of different power rails of device
through regulator interface.
config REGULATOR_MT6397 config REGULATOR_MT6397
tristate "MediaTek MT6397 PMIC" tristate "MediaTek MT6397 PMIC"
depends on MFD_MT6397 depends on MFD_MT6397
...@@ -543,12 +552,12 @@ config REGULATOR_PCF50633 ...@@ -543,12 +552,12 @@ config REGULATOR_PCF50633
on PCF50633 on PCF50633
config REGULATOR_PFUZE100 config REGULATOR_PFUZE100
tristate "Freescale PFUZE100/PFUZE200 regulator driver" tristate "Freescale PFUZE100/200/3000 regulator driver"
depends on I2C depends on I2C
select REGMAP_I2C select REGMAP_I2C
help help
Say y here to support the regulators found on the Freescale Say y here to support the regulators found on the Freescale
PFUZE100/PFUZE200 PMIC. PFUZE100/200/3000 PMIC.
config REGULATOR_PV88060 config REGULATOR_PV88060
tristate "Powerventure Semiconductor PV88060 regulator" tristate "Powerventure Semiconductor PV88060 regulator"
...@@ -636,10 +645,11 @@ config REGULATOR_RK808 ...@@ -636,10 +645,11 @@ config REGULATOR_RK808
outputs which can be controlled by i2c communication. outputs which can be controlled by i2c communication.
config REGULATOR_RN5T618 config REGULATOR_RN5T618
tristate "Ricoh RN5T618 voltage regulators" tristate "Ricoh RN5T567/618 voltage regulators"
depends on MFD_RN5T618 depends on MFD_RN5T618
help help
Say y here to support the regulators found on Ricoh RN5T618 PMIC. Say y here to support the regulators found on Ricoh RN5T567 or
RN5T618 PMIC.
config REGULATOR_RT5033 config REGULATOR_RT5033
tristate "Richtek RT5033 Regulators" tristate "Richtek RT5033 Regulators"
......
...@@ -65,6 +65,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o ...@@ -65,6 +65,7 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o
obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o
obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o
obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o
......
...@@ -395,12 +395,6 @@ static int act8865_pdata_from_dt(struct device *dev, ...@@ -395,12 +395,6 @@ static int act8865_pdata_from_dt(struct device *dev,
struct act8865_regulator_data *regulator; struct act8865_regulator_data *regulator;
struct of_regulator_match *matches; struct of_regulator_match *matches;
np = of_get_child_by_name(dev->of_node, "regulators");
if (!np) {
dev_err(dev, "missing 'regulators' subnode in DT\n");
return -EINVAL;
}
switch (type) { switch (type) {
case ACT8600: case ACT8600:
matches = act8600_matches; matches = act8600_matches;
...@@ -419,6 +413,12 @@ static int act8865_pdata_from_dt(struct device *dev, ...@@ -419,6 +413,12 @@ static int act8865_pdata_from_dt(struct device *dev,
return -EINVAL; return -EINVAL;
} }
np = of_get_child_by_name(dev->of_node, "regulators");
if (!np) {
dev_err(dev, "missing 'regulators' subnode in DT\n");
return -EINVAL;
}
matched = of_regulator_match(dev, np, matches, num_matches); matched = of_regulator_match(dev, np, matches, num_matches);
of_node_put(np); of_node_put(np);
if (matched <= 0) if (matched <= 0)
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#define AXP20X_FREQ_DCDC_MASK 0x0f #define AXP20X_FREQ_DCDC_MASK 0x0f
#define AXP22X_MISC_N_VBUSEN_FUNC BIT(4)
#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg, \ #define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _enable_val, _disable_val) \ _vmask, _ereg, _emask, _enable_val, _disable_val) \
[_family##_##_id] = { \ [_family##_##_id] = { \
...@@ -230,6 +232,73 @@ static const struct regulator_desc axp22x_regulators[] = { ...@@ -230,6 +232,73 @@ static const struct regulator_desc axp22x_regulators[] = {
AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000), AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
}; };
static const struct regulator_desc axp22x_drivevbus_regulator = {
.name = "drivevbus",
.supply_name = "drivevbus",
.of_match = of_match_ptr("drivevbus"),
.regulators_node = of_match_ptr("regulators"),
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.enable_reg = AXP20X_VBUS_IPSOUT_MGMT,
.enable_mask = BIT(2),
.ops = &axp20x_ops_sw,
};
static const struct regulator_linear_range axp809_dcdc4_ranges[] = {
REGULATOR_LINEAR_RANGE(600000, 0x0, 0x2f, 20000),
REGULATOR_LINEAR_RANGE(1800000, 0x30, 0x38, 100000),
};
static const struct regulator_linear_range axp809_dldo1_ranges[] = {
REGULATOR_LINEAR_RANGE(700000, 0x0, 0x1a, 100000),
REGULATOR_LINEAR_RANGE(3400000, 0x1b, 0x1f, 200000),
};
static const struct regulator_desc axp809_regulators[] = {
AXP_DESC(AXP809, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
AXP_DESC(AXP809, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
AXP_DESC(AXP809, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
AXP_DESC_RANGES(AXP809, DCDC4, "dcdc4", "vin4", axp809_dcdc4_ranges,
57, AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1,
BIT(4)),
AXP_DESC(AXP809, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(5)),
/* secondary switchable output of DCDC1 */
AXP_DESC_SW(AXP809, DC1SW, "dc1sw", NULL, AXP22X_PWR_OUT_CTRL2,
BIT(7)),
/* LDO regulator internally chained to DCDC5 */
AXP_DESC(AXP809, DC5LDO, "dc5ldo", NULL, 700, 1400, 100,
AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
AXP_DESC(AXP809, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
AXP_DESC(AXP809, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
AXP_DESC(AXP809, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
AXP_DESC_RANGES(AXP809, DLDO1, "dldo1", "dldoin", axp809_dldo1_ranges,
32, AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2,
BIT(3)),
AXP_DESC(AXP809, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
AXP_DESC(AXP809, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
AXP_DESC(AXP809, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
AXP_DESC(AXP809, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
AXP_DESC_IO(AXP809, LDO_IO0, "ldo_io0", "ips", 700, 3300, 100,
AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
AXP_DESC_IO(AXP809, LDO_IO1, "ldo_io1", "ips", 700, 3300, 100,
AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
AXP_DESC_FIXED(AXP809, RTC_LDO, "rtc_ldo", "ips", 1800),
AXP_DESC_SW(AXP809, SW, "sw", "swin", AXP22X_PWR_OUT_CTRL2, BIT(6)),
};
static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
{ {
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
...@@ -245,6 +314,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) ...@@ -245,6 +314,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
break; break;
case AXP221_ID: case AXP221_ID:
case AXP223_ID: case AXP223_ID:
case AXP809_ID:
min = 1800; min = 1800;
max = 4050; max = 4050;
def = 3000; def = 3000;
...@@ -324,6 +394,7 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work ...@@ -324,6 +394,7 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
case AXP221_ID: case AXP221_ID:
case AXP223_ID: case AXP223_ID:
case AXP809_ID:
if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5) if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
return -EINVAL; return -EINVAL;
...@@ -352,8 +423,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -352,8 +423,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
}; };
int ret, i, nregulators; int ret, i, nregulators;
u32 workmode; u32 workmode;
const char *axp22x_dc1_name = axp22x_regulators[AXP22X_DCDC1].name; const char *dcdc1_name = axp22x_regulators[AXP22X_DCDC1].name;
const char *axp22x_dc5_name = axp22x_regulators[AXP22X_DCDC5].name; const char *dcdc5_name = axp22x_regulators[AXP22X_DCDC5].name;
bool drivevbus = false;
switch (axp20x->variant) { switch (axp20x->variant) {
case AXP202_ID: case AXP202_ID:
...@@ -365,6 +437,12 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -365,6 +437,12 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
case AXP223_ID: case AXP223_ID:
regulators = axp22x_regulators; regulators = axp22x_regulators;
nregulators = AXP22X_REG_ID_MAX; nregulators = AXP22X_REG_ID_MAX;
drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
"x-powers,drive-vbus-en");
break;
case AXP809_ID:
regulators = axp809_regulators;
nregulators = AXP809_REG_ID_MAX;
break; break;
default: default:
dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
...@@ -388,23 +466,23 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -388,23 +466,23 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
* part of this loop to see where we save the DT defined * part of this loop to see where we save the DT defined
* name. * name.
*/ */
if (regulators == axp22x_regulators) { if ((regulators == axp22x_regulators && i == AXP22X_DC1SW) ||
if (i == AXP22X_DC1SW) { (regulators == axp809_regulators && i == AXP809_DC1SW)) {
new_desc = devm_kzalloc(&pdev->dev, new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
sizeof(*desc),
GFP_KERNEL); GFP_KERNEL);
*new_desc = regulators[i]; *new_desc = regulators[i];
new_desc->supply_name = axp22x_dc1_name; new_desc->supply_name = dcdc1_name;
desc = new_desc; desc = new_desc;
} else if (i == AXP22X_DC5LDO) { }
new_desc = devm_kzalloc(&pdev->dev,
sizeof(*desc), if ((regulators == axp22x_regulators && i == AXP22X_DC5LDO) ||
(regulators == axp809_regulators && i == AXP809_DC5LDO)) {
new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
GFP_KERNEL); GFP_KERNEL);
*new_desc = regulators[i]; *new_desc = regulators[i];
new_desc->supply_name = axp22x_dc5_name; new_desc->supply_name = dcdc5_name;
desc = new_desc; desc = new_desc;
} }
}
rdev = devm_regulator_register(&pdev->dev, desc, &config); rdev = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
...@@ -426,16 +504,29 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -426,16 +504,29 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
/* /*
* Save AXP22X DCDC1 / DCDC5 regulator names for later. * Save AXP22X DCDC1 / DCDC5 regulator names for later.
*/ */
if (regulators == axp22x_regulators) { if ((regulators == axp22x_regulators && i == AXP22X_DCDC1) ||
/* Can we use rdev->constraints->name instead? */ (regulators == axp809_regulators && i == AXP809_DCDC1))
if (i == AXP22X_DCDC1)
of_property_read_string(rdev->dev.of_node, of_property_read_string(rdev->dev.of_node,
"regulator-name", "regulator-name",
&axp22x_dc1_name); &dcdc1_name);
else if (i == AXP22X_DCDC5)
if ((regulators == axp22x_regulators && i == AXP22X_DCDC5) ||
(regulators == axp809_regulators && i == AXP809_DCDC5))
of_property_read_string(rdev->dev.of_node, of_property_read_string(rdev->dev.of_node,
"regulator-name", "regulator-name",
&axp22x_dc5_name); &dcdc5_name);
}
if (drivevbus) {
/* Change N_VBUSEN sense pin to DRIVEVBUS output pin */
regmap_update_bits(axp20x->regmap, AXP20X_OVER_TMP,
AXP22X_MISC_N_VBUSEN_FUNC, 0);
rdev = devm_regulator_register(&pdev->dev,
&axp22x_drivevbus_regulator,
&config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "Failed to register drivevbus\n");
return PTR_ERR(rdev);
} }
} }
......
...@@ -2508,33 +2508,6 @@ int regulator_is_enabled(struct regulator *regulator) ...@@ -2508,33 +2508,6 @@ int regulator_is_enabled(struct regulator *regulator)
} }
EXPORT_SYMBOL_GPL(regulator_is_enabled); EXPORT_SYMBOL_GPL(regulator_is_enabled);
/**
* regulator_can_change_voltage - check if regulator can change voltage
* @regulator: regulator source
*
* Returns positive if the regulator driver backing the source/client
* can change its voltage, false otherwise. Useful for detecting fixed
* or dummy regulators and disabling voltage change logic in the client
* driver.
*/
int regulator_can_change_voltage(struct regulator *regulator)
{
struct regulator_dev *rdev = regulator->rdev;
if (regulator_ops_is_valid(rdev, REGULATOR_CHANGE_VOLTAGE)) {
if (rdev->desc->n_voltages - rdev->desc->linear_min_sel > 1)
return 1;
if (rdev->desc->continuous_voltage_range &&
rdev->constraints->min_uV && rdev->constraints->max_uV &&
rdev->constraints->min_uV != rdev->constraints->max_uV)
return 1;
}
return 0;
}
EXPORT_SYMBOL_GPL(regulator_can_change_voltage);
/** /**
* regulator_count_voltages - count regulator_list_voltage() selectors * regulator_count_voltages - count regulator_list_voltage() selectors
* @regulator: regulator source * @regulator: regulator source
......
...@@ -333,7 +333,7 @@ static const struct regulator_ops da9052_ldo_ops = { ...@@ -333,7 +333,7 @@ static const struct regulator_ops da9052_ldo_ops = {
static struct da9052_regulator_info da9052_regulator_info[] = { static struct da9052_regulator_info da9052_regulator_info[] = {
DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO), DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO), DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
DA9052_DCDC(BUCK3, 25, 925, 2500, 6, 6, DA9052_SUPPLY_VBMEMGO), DA9052_DCDC(BUCK3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
DA9052_DCDC(BUCK4, 50, 1800, 3600, 5, 6, 0), DA9052_DCDC(BUCK4, 50, 1800, 3600, 5, 6, 0),
DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0), DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0),
DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO), DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
...@@ -350,8 +350,8 @@ static struct da9052_regulator_info da9052_regulator_info[] = { ...@@ -350,8 +350,8 @@ static struct da9052_regulator_info da9052_regulator_info[] = {
static struct da9052_regulator_info da9053_regulator_info[] = { static struct da9052_regulator_info da9053_regulator_info[] = {
DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO), DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO), DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
DA9052_DCDC(BUCK3, 25, 925, 2500, 6, 6, DA9052_SUPPLY_VBMEMGO), DA9052_DCDC(BUCK3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
DA9052_DCDC(BUCK4, 25, 925, 2500, 6, 6, 0), DA9052_DCDC(BUCK4, 25, 950, 2525, 6, 6, 0),
DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0), DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0),
DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO), DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
DA9052_LDO(LDO3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO), DA9052_LDO(LDO3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
......
...@@ -21,12 +21,11 @@ ...@@ -21,12 +21,11 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/slab.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/regmap.h> #include <linux/regmap.h>
...@@ -179,6 +178,13 @@ static irqreturn_t da9210_irq_handler(int irq, void *data) ...@@ -179,6 +178,13 @@ static irqreturn_t da9210_irq_handler(int irq, void *data)
/* /*
* I2C driver interface functions * I2C driver interface functions
*/ */
static const struct of_device_id da9210_dt_ids[] = {
{ .compatible = "dlg,da9210", },
{ }
};
MODULE_DEVICE_TABLE(of, da9210_dt_ids);
static int da9210_i2c_probe(struct i2c_client *i2c, static int da9210_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -188,6 +194,16 @@ static int da9210_i2c_probe(struct i2c_client *i2c, ...@@ -188,6 +194,16 @@ static int da9210_i2c_probe(struct i2c_client *i2c,
struct regulator_dev *rdev = NULL; struct regulator_dev *rdev = NULL;
struct regulator_config config = { }; struct regulator_config config = { };
int error; int error;
const struct of_device_id *match;
if (i2c->dev.of_node && !pdata) {
match = of_match_device(of_match_ptr(da9210_dt_ids),
&i2c->dev);
if (!match) {
dev_err(&i2c->dev, "Error: No device match found\n");
return -ENODEV;
}
}
chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL); chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL);
if (!chip) if (!chip)
...@@ -264,6 +280,7 @@ MODULE_DEVICE_TABLE(i2c, da9210_i2c_id); ...@@ -264,6 +280,7 @@ MODULE_DEVICE_TABLE(i2c, da9210_i2c_id);
static struct i2c_driver da9210_regulator_driver = { static struct i2c_driver da9210_regulator_driver = {
.driver = { .driver = {
.name = "da9210", .name = "da9210",
.of_match_table = of_match_ptr(da9210_dt_ids),
}, },
.probe = da9210_i2c_probe, .probe = da9210_i2c_probe,
.id_table = da9210_i2c_id, .id_table = da9210_i2c_id,
......
/* /*
* da9211-regulator.c - Regulator device driver for DA9211/DA9213/DA9215 * da9211-regulator.c - Regulator device driver for DA9211/DA9212
* /DA9213/DA9214/DA9215
* Copyright (C) 2015 Dialog Semiconductor Ltd. * Copyright (C) 2015 Dialog Semiconductor Ltd.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -493,7 +494,9 @@ static int da9211_i2c_probe(struct i2c_client *i2c, ...@@ -493,7 +494,9 @@ static int da9211_i2c_probe(struct i2c_client *i2c,
static const struct i2c_device_id da9211_i2c_id[] = { static const struct i2c_device_id da9211_i2c_id[] = {
{"da9211", DA9211}, {"da9211", DA9211},
{"da9212", DA9212},
{"da9213", DA9213}, {"da9213", DA9213},
{"da9214", DA9214},
{"da9215", DA9215}, {"da9215", DA9215},
{}, {},
}; };
...@@ -502,8 +505,10 @@ MODULE_DEVICE_TABLE(i2c, da9211_i2c_id); ...@@ -502,8 +505,10 @@ MODULE_DEVICE_TABLE(i2c, da9211_i2c_id);
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id da9211_dt_ids[] = { static const struct of_device_id da9211_dt_ids[] = {
{ .compatible = "dlg,da9211", .data = &da9211_i2c_id[0] }, { .compatible = "dlg,da9211", .data = &da9211_i2c_id[0] },
{ .compatible = "dlg,da9213", .data = &da9211_i2c_id[1] }, { .compatible = "dlg,da9212", .data = &da9211_i2c_id[1] },
{ .compatible = "dlg,da9215", .data = &da9211_i2c_id[2] }, { .compatible = "dlg,da9213", .data = &da9211_i2c_id[2] },
{ .compatible = "dlg,da9214", .data = &da9211_i2c_id[3] },
{ .compatible = "dlg,da9215", .data = &da9211_i2c_id[4] },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, da9211_dt_ids); MODULE_DEVICE_TABLE(of, da9211_dt_ids);
...@@ -521,5 +526,5 @@ static struct i2c_driver da9211_regulator_driver = { ...@@ -521,5 +526,5 @@ static struct i2c_driver da9211_regulator_driver = {
module_i2c_driver(da9211_regulator_driver); module_i2c_driver(da9211_regulator_driver);
MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>"); MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>");
MODULE_DESCRIPTION("Regulator device driver for Dialog DA9211/DA9213/DA9215"); MODULE_DESCRIPTION("DA9211/DA9212/DA9213/DA9214/DA9215 regulator driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* /*
* da9211-regulator.h - Regulator definitions for DA9211/DA9213/DA9215 * da9211-regulator.h - Regulator definitions for DA9211/DA9212
* /DA9213/DA9214/DA9215
* Copyright (C) 2015 Dialog Semiconductor Ltd. * Copyright (C) 2015 Dialog Semiconductor Ltd.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
......
...@@ -79,18 +79,8 @@ of_get_fixed_voltage_config(struct device *dev, ...@@ -79,18 +79,8 @@ of_get_fixed_voltage_config(struct device *dev,
config->enabled_at_boot = true; config->enabled_at_boot = true;
config->gpio = of_get_named_gpio(np, "gpio", 0); config->gpio = of_get_named_gpio(np, "gpio", 0);
/* if ((config->gpio < 0) && (config->gpio != -ENOENT))
* of_get_named_gpio() currently returns ENODEV rather than return ERR_PTR(config->gpio);
* EPROBE_DEFER. This code attempts to be compatible with both
* for now; the ENODEV check can be removed once the API is fixed.
* of_get_named_gpio() doesn't differentiate between a missing
* property (which would be fine here, since the GPIO is optional)
* and some other error. Patches have been posted for both issues.
* Once they are check in, we should replace this with:
* if (config->gpio < 0 && config->gpio != -ENOENT)
*/
if ((config->gpio == -ENODEV) || (config->gpio == -EPROBE_DEFER))
return ERR_PTR(-EPROBE_DEFER);
of_property_read_u32(np, "startup-delay-us", &config->startup_delay); of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/mfd/lp873x.h> #include <linux/mfd/lp873x.h>
#define LP873X_REGULATOR(_name, _id, _of, _ops, _n, _vr, _vm, _er, _em, \ #define LP873X_REGULATOR(_name, _id, _of, _ops, _n, _vr, _vm, _er, _em, \
_delay, _lr, _nlr, _cr) \ _delay, _lr, _cr) \
[_id] = { \ [_id] = { \
.desc = { \ .desc = { \
.name = _name, \ .name = _name, \
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
.enable_mask = _em, \ .enable_mask = _em, \
.ramp_delay = _delay, \ .ramp_delay = _delay, \
.linear_ranges = _lr, \ .linear_ranges = _lr, \
.n_linear_ranges = _nlr, \ .n_linear_ranges = ARRAY_SIZE(_lr), \
}, \ }, \
.ctrl2_reg = _cr, \ .ctrl2_reg = _cr, \
} }
...@@ -175,22 +175,20 @@ static const struct lp873x_regulator regulators[] = { ...@@ -175,22 +175,20 @@ static const struct lp873x_regulator regulators[] = {
256, LP873X_REG_BUCK0_VOUT, 256, LP873X_REG_BUCK0_VOUT,
LP873X_BUCK0_VOUT_BUCK0_VSET, LP873X_REG_BUCK0_CTRL_1, LP873X_BUCK0_VOUT_BUCK0_VSET, LP873X_REG_BUCK0_CTRL_1,
LP873X_BUCK0_CTRL_1_BUCK0_EN, 10000, LP873X_BUCK0_CTRL_1_BUCK0_EN, 10000,
buck0_buck1_ranges, 4, LP873X_REG_BUCK0_CTRL_2), buck0_buck1_ranges, LP873X_REG_BUCK0_CTRL_2),
LP873X_REGULATOR("BUCK1", LP873X_BUCK_1, "buck1", lp873x_buck01_ops, LP873X_REGULATOR("BUCK1", LP873X_BUCK_1, "buck1", lp873x_buck01_ops,
256, LP873X_REG_BUCK1_VOUT, 256, LP873X_REG_BUCK1_VOUT,
LP873X_BUCK1_VOUT_BUCK1_VSET, LP873X_REG_BUCK1_CTRL_1, LP873X_BUCK1_VOUT_BUCK1_VSET, LP873X_REG_BUCK1_CTRL_1,
LP873X_BUCK1_CTRL_1_BUCK1_EN, 10000, LP873X_BUCK1_CTRL_1_BUCK1_EN, 10000,
buck0_buck1_ranges, 4, LP873X_REG_BUCK1_CTRL_2), buck0_buck1_ranges, LP873X_REG_BUCK1_CTRL_2),
LP873X_REGULATOR("LDO0", LP873X_LDO_0, "ldo0", lp873x_ldo01_ops, 26, LP873X_REGULATOR("LDO0", LP873X_LDO_0, "ldo0", lp873x_ldo01_ops, 26,
LP873X_REG_LDO0_VOUT, LP873X_LDO0_VOUT_LDO0_VSET, LP873X_REG_LDO0_VOUT, LP873X_LDO0_VOUT_LDO0_VSET,
LP873X_REG_LDO0_CTRL, LP873X_REG_LDO0_CTRL,
LP873X_LDO0_CTRL_LDO0_EN, 0, ldo0_ldo1_ranges, 1, LP873X_LDO0_CTRL_LDO0_EN, 0, ldo0_ldo1_ranges, 0xFF),
0xFF),
LP873X_REGULATOR("LDO1", LP873X_LDO_1, "ldo1", lp873x_ldo01_ops, 26, LP873X_REGULATOR("LDO1", LP873X_LDO_1, "ldo1", lp873x_ldo01_ops, 26,
LP873X_REG_LDO1_VOUT, LP873X_LDO1_VOUT_LDO1_VSET, LP873X_REG_LDO1_VOUT, LP873X_LDO1_VOUT_LDO1_VSET,
LP873X_REG_LDO1_CTRL, LP873X_REG_LDO1_CTRL,
LP873X_LDO1_CTRL_LDO1_EN, 0, ldo0_ldo1_ranges, 1, LP873X_LDO1_CTRL_LDO1_EN, 0, ldo0_ldo1_ranges, 0xFF),
0xFF),
}; };
static int lp873x_regulator_probe(struct platform_device *pdev) static int lp873x_regulator_probe(struct platform_device *pdev)
......
...@@ -271,22 +271,18 @@ static int max8973_set_ramp_delay(struct regulator_dev *rdev, ...@@ -271,22 +271,18 @@ static int max8973_set_ramp_delay(struct regulator_dev *rdev,
struct max8973_chip *max = rdev_get_drvdata(rdev); struct max8973_chip *max = rdev_get_drvdata(rdev);
unsigned int control; unsigned int control;
int ret; int ret;
int ret_val;
/* Set ramp delay */ /* Set ramp delay */
if (ramp_delay < 25000) { if (ramp_delay <= 12000)
control = MAX8973_RAMP_12mV_PER_US; control = MAX8973_RAMP_12mV_PER_US;
ret_val = 12000; else if (ramp_delay <= 25000)
} else if (ramp_delay < 50000) {
control = MAX8973_RAMP_25mV_PER_US; control = MAX8973_RAMP_25mV_PER_US;
ret_val = 25000; else if (ramp_delay <= 50000)
} else if (ramp_delay < 200000) {
control = MAX8973_RAMP_50mV_PER_US; control = MAX8973_RAMP_50mV_PER_US;
ret_val = 50000; else if (ramp_delay <= 200000)
} else {
control = MAX8973_RAMP_200mV_PER_US; control = MAX8973_RAMP_200mV_PER_US;
ret_val = 200000; else
} return -EINVAL;
ret = regmap_update_bits(max->regmap, MAX8973_CONTROL1, ret = regmap_update_bits(max->regmap, MAX8973_CONTROL1,
MAX8973_RAMP_MASK, control); MAX8973_RAMP_MASK, control);
......
/*
* Copyright (c) 2016 MediaTek Inc.
* Author: Chen Zhong <chen.zhong@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/mfd/mt6397/core.h>
#include <linux/mfd/mt6323/registers.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/mt6323-regulator.h>
#include <linux/regulator/of_regulator.h>
#define MT6323_LDO_MODE_NORMAL 0
#define MT6323_LDO_MODE_LP 1
/*
* MT6323 regulators' information
*
* @desc: standard fields of regulator description.
* @qi: Mask for query enable signal status of regulators
* @vselon_reg: Register sections for hardware control mode of bucks
* @vselctrl_reg: Register for controlling the buck control mode.
* @vselctrl_mask: Mask for query buck's voltage control mode.
*/
struct mt6323_regulator_info {
struct regulator_desc desc;
u32 qi;
u32 vselon_reg;
u32 vselctrl_reg;
u32 vselctrl_mask;
u32 modeset_reg;
u32 modeset_mask;
};
#define MT6323_BUCK(match, vreg, min, max, step, volt_ranges, enreg, \
vosel, vosel_mask, voselon, vosel_ctrl) \
[MT6323_ID_##vreg] = { \
.desc = { \
.name = #vreg, \
.of_match = of_match_ptr(match), \
.ops = &mt6323_volt_range_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MT6323_ID_##vreg, \
.owner = THIS_MODULE, \
.n_voltages = (max - min)/step + 1, \
.linear_ranges = volt_ranges, \
.n_linear_ranges = ARRAY_SIZE(volt_ranges), \
.vsel_reg = vosel, \
.vsel_mask = vosel_mask, \
.enable_reg = enreg, \
.enable_mask = BIT(0), \
}, \
.qi = BIT(13), \
.vselon_reg = voselon, \
.vselctrl_reg = vosel_ctrl, \
.vselctrl_mask = BIT(1), \
}
#define MT6323_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel, \
vosel_mask, _modeset_reg, _modeset_mask) \
[MT6323_ID_##vreg] = { \
.desc = { \
.name = #vreg, \
.of_match = of_match_ptr(match), \
.ops = &mt6323_volt_table_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MT6323_ID_##vreg, \
.owner = THIS_MODULE, \
.n_voltages = ARRAY_SIZE(ldo_volt_table), \
.volt_table = ldo_volt_table, \
.vsel_reg = vosel, \
.vsel_mask = vosel_mask, \
.enable_reg = enreg, \
.enable_mask = BIT(enbit), \
}, \
.qi = BIT(15), \
.modeset_reg = _modeset_reg, \
.modeset_mask = _modeset_mask, \
}
#define MT6323_REG_FIXED(match, vreg, enreg, enbit, volt, \
_modeset_reg, _modeset_mask) \
[MT6323_ID_##vreg] = { \
.desc = { \
.name = #vreg, \
.of_match = of_match_ptr(match), \
.ops = &mt6323_volt_fixed_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MT6323_ID_##vreg, \
.owner = THIS_MODULE, \
.n_voltages = 1, \
.enable_reg = enreg, \
.enable_mask = BIT(enbit), \
.min_uV = volt, \
}, \
.qi = BIT(15), \
.modeset_reg = _modeset_reg, \
.modeset_mask = _modeset_mask, \
}
static const struct regulator_linear_range buck_volt_range1[] = {
REGULATOR_LINEAR_RANGE(700000, 0, 0x7f, 6250),
};
static const struct regulator_linear_range buck_volt_range2[] = {
REGULATOR_LINEAR_RANGE(1400000, 0, 0x7f, 12500),
};
static const struct regulator_linear_range buck_volt_range3[] = {
REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000),
};
static const u32 ldo_volt_table1[] = {
3300000, 3400000, 3500000, 3600000,
};
static const u32 ldo_volt_table2[] = {
1500000, 1800000, 2500000, 2800000,
};
static const u32 ldo_volt_table3[] = {
1800000, 3300000,
};
static const u32 ldo_volt_table4[] = {
3000000, 3300000,
};
static const u32 ldo_volt_table5[] = {
1200000, 1300000, 1500000, 1800000, 2000000, 2800000, 3000000, 3300000,
};
static const u32 ldo_volt_table6[] = {
1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 2000000,
};
static const u32 ldo_volt_table7[] = {
1200000, 1300000, 1500000, 1800000,
};
static const u32 ldo_volt_table8[] = {
1800000, 3000000,
};
static const u32 ldo_volt_table9[] = {
1200000, 1350000, 1500000, 1800000,
};
static const u32 ldo_volt_table10[] = {
1200000, 1300000, 1500000, 1800000,
};
static int mt6323_get_status(struct regulator_dev *rdev)
{
int ret;
u32 regval;
struct mt6323_regulator_info *info = rdev_get_drvdata(rdev);
ret = regmap_read(rdev->regmap, info->desc.enable_reg, &regval);
if (ret != 0) {
dev_err(&rdev->dev, "Failed to get enable reg: %d\n", ret);
return ret;
}
return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF;
}
static int mt6323_ldo_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
int ret, val = 0;
struct mt6323_regulator_info *info = rdev_get_drvdata(rdev);
if (!info->modeset_mask) {
dev_err(&rdev->dev, "regulator %s doesn't support set_mode\n",
info->desc.name);
return -EINVAL;
}
switch (mode) {
case REGULATOR_MODE_STANDBY:
val = MT6323_LDO_MODE_LP;
break;
case REGULATOR_MODE_NORMAL:
val = MT6323_LDO_MODE_NORMAL;
break;
default:
return -EINVAL;
}
val <<= ffs(info->modeset_mask) - 1;
ret = regmap_update_bits(rdev->regmap, info->modeset_reg,
info->modeset_mask, val);
return ret;
}
static unsigned int mt6323_ldo_get_mode(struct regulator_dev *rdev)
{
unsigned int val;
unsigned int mode;
int ret;
struct mt6323_regulator_info *info = rdev_get_drvdata(rdev);
if (!info->modeset_mask) {
dev_err(&rdev->dev, "regulator %s doesn't support get_mode\n",
info->desc.name);
return -EINVAL;
}
ret = regmap_read(rdev->regmap, info->modeset_reg, &val);
if (ret < 0)
return ret;
val &= info->modeset_mask;
val >>= ffs(info->modeset_mask) - 1;
if (val & 0x1)
mode = REGULATOR_MODE_STANDBY;
else
mode = REGULATOR_MODE_NORMAL;
return mode;
}
static const struct regulator_ops mt6323_volt_range_ops = {
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_time_sel = regulator_set_voltage_time_sel,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = mt6323_get_status,
};
static const struct regulator_ops mt6323_volt_table_ops = {
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_iterate,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_time_sel = regulator_set_voltage_time_sel,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = mt6323_get_status,
.set_mode = mt6323_ldo_set_mode,
.get_mode = mt6323_ldo_get_mode,
};
static const struct regulator_ops mt6323_volt_fixed_ops = {
.list_voltage = regulator_list_voltage_linear,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = mt6323_get_status,
.set_mode = mt6323_ldo_set_mode,
.get_mode = mt6323_ldo_get_mode,
};
/* The array is indexed by id(MT6323_ID_XXX) */
static struct mt6323_regulator_info mt6323_regulators[] = {
MT6323_BUCK("buck_vproc", VPROC, 700000, 1493750, 6250,
buck_volt_range1, MT6323_VPROC_CON7, MT6323_VPROC_CON9, 0x7f,
MT6323_VPROC_CON10, MT6323_VPROC_CON5),
MT6323_BUCK("buck_vsys", VSYS, 1400000, 2987500, 12500,
buck_volt_range2, MT6323_VSYS_CON7, MT6323_VSYS_CON9, 0x7f,
MT6323_VSYS_CON10, MT6323_VSYS_CON5),
MT6323_BUCK("buck_vpa", VPA, 500000, 3650000, 50000,
buck_volt_range3, MT6323_VPA_CON7, MT6323_VPA_CON9,
0x3f, MT6323_VPA_CON10, MT6323_VPA_CON5),
MT6323_REG_FIXED("ldo_vtcxo", VTCXO, MT6323_ANALDO_CON1, 10, 2800000,
MT6323_ANALDO_CON1, 0x2),
MT6323_REG_FIXED("ldo_vcn28", VCN28, MT6323_ANALDO_CON19, 12, 2800000,
MT6323_ANALDO_CON20, 0x2),
MT6323_LDO("ldo_vcn33_bt", VCN33_BT, ldo_volt_table1,
MT6323_ANALDO_CON16, 7, MT6323_ANALDO_CON16, 0xC,
MT6323_ANALDO_CON21, 0x2),
MT6323_LDO("ldo_vcn33_wifi", VCN33_WIFI, ldo_volt_table1,
MT6323_ANALDO_CON17, 12, MT6323_ANALDO_CON16, 0xC,
MT6323_ANALDO_CON21, 0x2),
MT6323_REG_FIXED("ldo_va", VA, MT6323_ANALDO_CON2, 14, 2800000,
MT6323_ANALDO_CON2, 0x2),
MT6323_LDO("ldo_vcama", VCAMA, ldo_volt_table2,
MT6323_ANALDO_CON4, 15, MT6323_ANALDO_CON10, 0x60, -1, 0),
MT6323_REG_FIXED("ldo_vio28", VIO28, MT6323_DIGLDO_CON0, 14, 2800000,
MT6323_DIGLDO_CON0, 0x2),
MT6323_REG_FIXED("ldo_vusb", VUSB, MT6323_DIGLDO_CON2, 14, 3300000,
MT6323_DIGLDO_CON2, 0x2),
MT6323_LDO("ldo_vmc", VMC, ldo_volt_table3,
MT6323_DIGLDO_CON3, 12, MT6323_DIGLDO_CON24, 0x10,
MT6323_DIGLDO_CON3, 0x2),
MT6323_LDO("ldo_vmch", VMCH, ldo_volt_table4,
MT6323_DIGLDO_CON5, 14, MT6323_DIGLDO_CON26, 0x80,
MT6323_DIGLDO_CON5, 0x2),
MT6323_LDO("ldo_vemc3v3", VEMC3V3, ldo_volt_table4,
MT6323_DIGLDO_CON6, 14, MT6323_DIGLDO_CON27, 0x80,
MT6323_DIGLDO_CON6, 0x2),
MT6323_LDO("ldo_vgp1", VGP1, ldo_volt_table5,
MT6323_DIGLDO_CON7, 15, MT6323_DIGLDO_CON28, 0xE0,
MT6323_DIGLDO_CON7, 0x2),
MT6323_LDO("ldo_vgp2", VGP2, ldo_volt_table6,
MT6323_DIGLDO_CON8, 15, MT6323_DIGLDO_CON29, 0xE0,
MT6323_DIGLDO_CON8, 0x2),
MT6323_LDO("ldo_vgp3", VGP3, ldo_volt_table7,
MT6323_DIGLDO_CON9, 15, MT6323_DIGLDO_CON30, 0x60,
MT6323_DIGLDO_CON9, 0x2),
MT6323_REG_FIXED("ldo_vcn18", VCN18, MT6323_DIGLDO_CON11, 14, 1800000,
MT6323_DIGLDO_CON11, 0x2),
MT6323_LDO("ldo_vsim1", VSIM1, ldo_volt_table8,
MT6323_DIGLDO_CON13, 15, MT6323_DIGLDO_CON34, 0x20,
MT6323_DIGLDO_CON13, 0x2),
MT6323_LDO("ldo_vsim2", VSIM2, ldo_volt_table8,
MT6323_DIGLDO_CON14, 15, MT6323_DIGLDO_CON35, 0x20,
MT6323_DIGLDO_CON14, 0x2),
MT6323_REG_FIXED("ldo_vrtc", VRTC, MT6323_DIGLDO_CON15, 8, 2800000,
-1, 0),
MT6323_LDO("ldo_vcamaf", VCAMAF, ldo_volt_table5,
MT6323_DIGLDO_CON31, 15, MT6323_DIGLDO_CON32, 0xE0,
MT6323_DIGLDO_CON31, 0x2),
MT6323_LDO("ldo_vibr", VIBR, ldo_volt_table5,
MT6323_DIGLDO_CON39, 15, MT6323_DIGLDO_CON40, 0xE0,
MT6323_DIGLDO_CON39, 0x2),
MT6323_REG_FIXED("ldo_vrf18", VRF18, MT6323_DIGLDO_CON45, 15, 1825000,
MT6323_DIGLDO_CON45, 0x2),
MT6323_LDO("ldo_vm", VM, ldo_volt_table9,
MT6323_DIGLDO_CON47, 14, MT6323_DIGLDO_CON48, 0x30,
MT6323_DIGLDO_CON47, 0x2),
MT6323_REG_FIXED("ldo_vio18", VIO18, MT6323_DIGLDO_CON49, 14, 1800000,
MT6323_DIGLDO_CON49, 0x2),
MT6323_LDO("ldo_vcamd", VCAMD, ldo_volt_table10,
MT6323_DIGLDO_CON51, 14, MT6323_DIGLDO_CON52, 0x60,
MT6323_DIGLDO_CON51, 0x2),
MT6323_REG_FIXED("ldo_vcamio", VCAMIO, MT6323_DIGLDO_CON53, 14, 1800000,
MT6323_DIGLDO_CON53, 0x2),
};
static int mt6323_set_buck_vosel_reg(struct platform_device *pdev)
{
struct mt6397_chip *mt6323 = dev_get_drvdata(pdev->dev.parent);
int i;
u32 regval;
for (i = 0; i < MT6323_MAX_REGULATOR; i++) {
if (mt6323_regulators[i].vselctrl_reg) {
if (regmap_read(mt6323->regmap,
mt6323_regulators[i].vselctrl_reg,
&regval) < 0) {
dev_err(&pdev->dev,
"Failed to read buck ctrl\n");
return -EIO;
}
if (regval & mt6323_regulators[i].vselctrl_mask) {
mt6323_regulators[i].desc.vsel_reg =
mt6323_regulators[i].vselon_reg;
}
}
}
return 0;
}
static int mt6323_regulator_probe(struct platform_device *pdev)
{
struct mt6397_chip *mt6323 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = {};
struct regulator_dev *rdev;
int i;
u32 reg_value;
/* Query buck controller to select activated voltage register part */
if (mt6323_set_buck_vosel_reg(pdev))
return -EIO;
/* Read PMIC chip revision to update constraints and voltage table */
if (regmap_read(mt6323->regmap, MT6323_CID, &reg_value) < 0) {
dev_err(&pdev->dev, "Failed to read Chip ID\n");
return -EIO;
}
dev_info(&pdev->dev, "Chip ID = 0x%x\n", reg_value);
for (i = 0; i < MT6323_MAX_REGULATOR; i++) {
config.dev = &pdev->dev;
config.driver_data = &mt6323_regulators[i];
config.regmap = mt6323->regmap;
rdev = devm_regulator_register(&pdev->dev,
&mt6323_regulators[i].desc, &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register %s\n",
mt6323_regulators[i].desc.name);
return PTR_ERR(rdev);
}
}
return 0;
}
static const struct platform_device_id mt6323_platform_ids[] = {
{"mt6323-regulator", 0},
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(platform, mt6323_platform_ids);
static struct platform_driver mt6323_regulator_driver = {
.driver = {
.name = "mt6323-regulator",
},
.probe = mt6323_regulator_probe,
.id_table = mt6323_platform_ids,
};
module_platform_driver(mt6323_regulator_driver);
MODULE_AUTHOR("Chen Zhong <chen.zhong@mediatek.com>");
MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6323 PMIC");
MODULE_LICENSE("GPL v2");
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <linux/regulator/mt6397-regulator.h> #include <linux/regulator/mt6397-regulator.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#define MT6397_BUCK_MODE_AUTO 0
#define MT6397_BUCK_MODE_FORCE_PWM 1
/* /*
* MT6397 regulators' information * MT6397 regulators' information
* *
...@@ -38,10 +41,14 @@ struct mt6397_regulator_info { ...@@ -38,10 +41,14 @@ struct mt6397_regulator_info {
u32 vselon_reg; u32 vselon_reg;
u32 vselctrl_reg; u32 vselctrl_reg;
u32 vselctrl_mask; u32 vselctrl_mask;
u32 modeset_reg;
u32 modeset_mask;
u32 modeset_shift;
}; };
#define MT6397_BUCK(match, vreg, min, max, step, volt_ranges, enreg, \ #define MT6397_BUCK(match, vreg, min, max, step, volt_ranges, enreg, \
vosel, vosel_mask, voselon, vosel_ctrl) \ vosel, vosel_mask, voselon, vosel_ctrl, _modeset_reg, \
_modeset_shift) \
[MT6397_ID_##vreg] = { \ [MT6397_ID_##vreg] = { \
.desc = { \ .desc = { \
.name = #vreg, \ .name = #vreg, \
...@@ -62,6 +69,9 @@ struct mt6397_regulator_info { ...@@ -62,6 +69,9 @@ struct mt6397_regulator_info {
.vselon_reg = voselon, \ .vselon_reg = voselon, \
.vselctrl_reg = vosel_ctrl, \ .vselctrl_reg = vosel_ctrl, \
.vselctrl_mask = BIT(1), \ .vselctrl_mask = BIT(1), \
.modeset_reg = _modeset_reg, \
.modeset_mask = BIT(_modeset_shift), \
.modeset_shift = _modeset_shift \
} }
#define MT6397_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel, \ #define MT6397_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel, \
...@@ -145,6 +155,63 @@ static const u32 ldo_volt_table7[] = { ...@@ -145,6 +155,63 @@ static const u32 ldo_volt_table7[] = {
1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000, 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000,
}; };
static int mt6397_regulator_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
struct mt6397_regulator_info *info = rdev_get_drvdata(rdev);
int ret, val;
switch (mode) {
case REGULATOR_MODE_FAST:
val = MT6397_BUCK_MODE_FORCE_PWM;
break;
case REGULATOR_MODE_NORMAL:
val = MT6397_BUCK_MODE_AUTO;
break;
default:
ret = -EINVAL;
goto err_mode;
}
dev_dbg(&rdev->dev, "mt6397 buck set_mode %#x, %#x, %#x, %#x\n",
info->modeset_reg, info->modeset_mask,
info->modeset_shift, val);
val <<= info->modeset_shift;
ret = regmap_update_bits(rdev->regmap, info->modeset_reg,
info->modeset_mask, val);
err_mode:
if (ret != 0) {
dev_err(&rdev->dev,
"Failed to set mt6397 buck mode: %d\n", ret);
return ret;
}
return 0;
}
static unsigned int mt6397_regulator_get_mode(struct regulator_dev *rdev)
{
struct mt6397_regulator_info *info = rdev_get_drvdata(rdev);
int ret, regval;
ret = regmap_read(rdev->regmap, info->modeset_reg, &regval);
if (ret != 0) {
dev_err(&rdev->dev,
"Failed to get mt6397 buck mode: %d\n", ret);
return ret;
}
switch ((regval & info->modeset_mask) >> info->modeset_shift) {
case MT6397_BUCK_MODE_AUTO:
return REGULATOR_MODE_NORMAL;
case MT6397_BUCK_MODE_FORCE_PWM:
return REGULATOR_MODE_FAST;
default:
return -EINVAL;
}
}
static int mt6397_get_status(struct regulator_dev *rdev) static int mt6397_get_status(struct regulator_dev *rdev)
{ {
int ret; int ret;
...@@ -160,7 +227,7 @@ static int mt6397_get_status(struct regulator_dev *rdev) ...@@ -160,7 +227,7 @@ static int mt6397_get_status(struct regulator_dev *rdev)
return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF; return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF;
} }
static struct regulator_ops mt6397_volt_range_ops = { static const struct regulator_ops mt6397_volt_range_ops = {
.list_voltage = regulator_list_voltage_linear_range, .list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap,
...@@ -170,9 +237,11 @@ static struct regulator_ops mt6397_volt_range_ops = { ...@@ -170,9 +237,11 @@ static struct regulator_ops mt6397_volt_range_ops = {
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.get_status = mt6397_get_status, .get_status = mt6397_get_status,
.set_mode = mt6397_regulator_set_mode,
.get_mode = mt6397_regulator_get_mode,
}; };
static struct regulator_ops mt6397_volt_table_ops = { static const struct regulator_ops mt6397_volt_table_ops = {
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_iterate, .map_voltage = regulator_map_voltage_iterate,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap,
...@@ -184,7 +253,7 @@ static struct regulator_ops mt6397_volt_table_ops = { ...@@ -184,7 +253,7 @@ static struct regulator_ops mt6397_volt_table_ops = {
.get_status = mt6397_get_status, .get_status = mt6397_get_status,
}; };
static struct regulator_ops mt6397_volt_fixed_ops = { static const struct regulator_ops mt6397_volt_fixed_ops = {
.list_voltage = regulator_list_voltage_linear, .list_voltage = regulator_list_voltage_linear,
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
...@@ -196,28 +265,30 @@ static struct regulator_ops mt6397_volt_fixed_ops = { ...@@ -196,28 +265,30 @@ static struct regulator_ops mt6397_volt_fixed_ops = {
static struct mt6397_regulator_info mt6397_regulators[] = { static struct mt6397_regulator_info mt6397_regulators[] = {
MT6397_BUCK("buck_vpca15", VPCA15, 700000, 1493750, 6250, MT6397_BUCK("buck_vpca15", VPCA15, 700000, 1493750, 6250,
buck_volt_range1, MT6397_VCA15_CON7, MT6397_VCA15_CON9, 0x7f, buck_volt_range1, MT6397_VCA15_CON7, MT6397_VCA15_CON9, 0x7f,
MT6397_VCA15_CON10, MT6397_VCA15_CON5), MT6397_VCA15_CON10, MT6397_VCA15_CON5, MT6397_VCA15_CON2, 11),
MT6397_BUCK("buck_vpca7", VPCA7, 700000, 1493750, 6250, MT6397_BUCK("buck_vpca7", VPCA7, 700000, 1493750, 6250,
buck_volt_range1, MT6397_VPCA7_CON7, MT6397_VPCA7_CON9, 0x7f, buck_volt_range1, MT6397_VPCA7_CON7, MT6397_VPCA7_CON9, 0x7f,
MT6397_VPCA7_CON10, MT6397_VPCA7_CON5), MT6397_VPCA7_CON10, MT6397_VPCA7_CON5, MT6397_VPCA7_CON2, 8),
MT6397_BUCK("buck_vsramca15", VSRAMCA15, 700000, 1493750, 6250, MT6397_BUCK("buck_vsramca15", VSRAMCA15, 700000, 1493750, 6250,
buck_volt_range1, MT6397_VSRMCA15_CON7, MT6397_VSRMCA15_CON9, buck_volt_range1, MT6397_VSRMCA15_CON7, MT6397_VSRMCA15_CON9,
0x7f, MT6397_VSRMCA15_CON10, MT6397_VSRMCA15_CON5), 0x7f, MT6397_VSRMCA15_CON10, MT6397_VSRMCA15_CON5,
MT6397_VSRMCA15_CON2, 8),
MT6397_BUCK("buck_vsramca7", VSRAMCA7, 700000, 1493750, 6250, MT6397_BUCK("buck_vsramca7", VSRAMCA7, 700000, 1493750, 6250,
buck_volt_range1, MT6397_VSRMCA7_CON7, MT6397_VSRMCA7_CON9, buck_volt_range1, MT6397_VSRMCA7_CON7, MT6397_VSRMCA7_CON9,
0x7f, MT6397_VSRMCA7_CON10, MT6397_VSRMCA7_CON5), 0x7f, MT6397_VSRMCA7_CON10, MT6397_VSRMCA7_CON5,
MT6397_VSRMCA7_CON2, 8),
MT6397_BUCK("buck_vcore", VCORE, 700000, 1493750, 6250, MT6397_BUCK("buck_vcore", VCORE, 700000, 1493750, 6250,
buck_volt_range1, MT6397_VCORE_CON7, MT6397_VCORE_CON9, 0x7f, buck_volt_range1, MT6397_VCORE_CON7, MT6397_VCORE_CON9, 0x7f,
MT6397_VCORE_CON10, MT6397_VCORE_CON5), MT6397_VCORE_CON10, MT6397_VCORE_CON5, MT6397_VCORE_CON2, 8),
MT6397_BUCK("buck_vgpu", VGPU, 700000, 1493750, 6250, buck_volt_range1, MT6397_BUCK("buck_vgpu", VGPU, 700000, 1493750, 6250, buck_volt_range1,
MT6397_VGPU_CON7, MT6397_VGPU_CON9, 0x7f, MT6397_VGPU_CON7, MT6397_VGPU_CON9, 0x7f,
MT6397_VGPU_CON10, MT6397_VGPU_CON5), MT6397_VGPU_CON10, MT6397_VGPU_CON5, MT6397_VGPU_CON2, 8),
MT6397_BUCK("buck_vdrm", VDRM, 800000, 1593750, 6250, buck_volt_range2, MT6397_BUCK("buck_vdrm", VDRM, 800000, 1593750, 6250, buck_volt_range2,
MT6397_VDRM_CON7, MT6397_VDRM_CON9, 0x7f, MT6397_VDRM_CON7, MT6397_VDRM_CON9, 0x7f,
MT6397_VDRM_CON10, MT6397_VDRM_CON5), MT6397_VDRM_CON10, MT6397_VDRM_CON5, MT6397_VDRM_CON2, 8),
MT6397_BUCK("buck_vio18", VIO18, 1500000, 2120000, 20000, MT6397_BUCK("buck_vio18", VIO18, 1500000, 2120000, 20000,
buck_volt_range3, MT6397_VIO18_CON7, MT6397_VIO18_CON9, 0x1f, buck_volt_range3, MT6397_VIO18_CON7, MT6397_VIO18_CON9, 0x1f,
MT6397_VIO18_CON10, MT6397_VIO18_CON5), MT6397_VIO18_CON10, MT6397_VIO18_CON5, MT6397_VIO18_CON2, 8),
MT6397_REG_FIXED("ldo_vtcxo", VTCXO, MT6397_ANALDO_CON0, 10, 2800000), MT6397_REG_FIXED("ldo_vtcxo", VTCXO, MT6397_ANALDO_CON0, 10, 2800000),
MT6397_REG_FIXED("ldo_va28", VA28, MT6397_ANALDO_CON1, 14, 2800000), MT6397_REG_FIXED("ldo_va28", VA28, MT6397_ANALDO_CON1, 14, 2800000),
MT6397_LDO("ldo_vcama", VCAMA, ldo_volt_table1, MT6397_LDO("ldo_vcama", VCAMA, ldo_volt_table1,
......
...@@ -163,6 +163,9 @@ static void of_get_regulation_constraints(struct device_node *np, ...@@ -163,6 +163,9 @@ static void of_get_regulation_constraints(struct device_node *np,
"regulator-suspend-microvolt", &pval)) "regulator-suspend-microvolt", &pval))
suspend_state->uV = pval; suspend_state->uV = pval;
if (i == PM_SUSPEND_MEM)
constraints->initial_state = PM_SUSPEND_MEM;
of_node_put(suspend_np); of_node_put(suspend_np);
suspend_state = NULL; suspend_state = NULL;
suspend_np = NULL; suspend_np = NULL;
......
...@@ -70,6 +70,7 @@ struct pfuze_chip { ...@@ -70,6 +70,7 @@ struct pfuze_chip {
struct device *dev; struct device *dev;
struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR]; struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR];
struct pfuze_regulator *pfuze_regulators;
}; };
static const int pfuze100_swbst[] = { static const int pfuze100_swbst[] = {
...@@ -334,8 +335,6 @@ static struct pfuze_regulator pfuze3000_regulators[] = { ...@@ -334,8 +335,6 @@ static struct pfuze_regulator pfuze3000_regulators[] = {
PFUZE100_VGEN_REG(PFUZE3000, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000), PFUZE100_VGEN_REG(PFUZE3000, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
}; };
static struct pfuze_regulator *pfuze_regulators;
#ifdef CONFIG_OF #ifdef CONFIG_OF
/* PFUZE100 */ /* PFUZE100 */
static struct of_regulator_match pfuze100_matches[] = { static struct of_regulator_match pfuze100_matches[] = {
...@@ -563,21 +562,21 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ...@@ -563,21 +562,21 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
/* use the right regulators after identify the right device */ /* use the right regulators after identify the right device */
switch (pfuze_chip->chip_id) { switch (pfuze_chip->chip_id) {
case PFUZE3000: case PFUZE3000:
pfuze_regulators = pfuze3000_regulators; pfuze_chip->pfuze_regulators = pfuze3000_regulators;
regulator_num = ARRAY_SIZE(pfuze3000_regulators); regulator_num = ARRAY_SIZE(pfuze3000_regulators);
sw_check_start = PFUZE3000_SW2; sw_check_start = PFUZE3000_SW2;
sw_check_end = PFUZE3000_SW2; sw_check_end = PFUZE3000_SW2;
sw_hi = 1 << 3; sw_hi = 1 << 3;
break; break;
case PFUZE200: case PFUZE200:
pfuze_regulators = pfuze200_regulators; pfuze_chip->pfuze_regulators = pfuze200_regulators;
regulator_num = ARRAY_SIZE(pfuze200_regulators); regulator_num = ARRAY_SIZE(pfuze200_regulators);
sw_check_start = PFUZE200_SW2; sw_check_start = PFUZE200_SW2;
sw_check_end = PFUZE200_SW3B; sw_check_end = PFUZE200_SW3B;
break; break;
case PFUZE100: case PFUZE100:
default: default:
pfuze_regulators = pfuze100_regulators; pfuze_chip->pfuze_regulators = pfuze100_regulators;
regulator_num = ARRAY_SIZE(pfuze100_regulators); regulator_num = ARRAY_SIZE(pfuze100_regulators);
sw_check_start = PFUZE100_SW2; sw_check_start = PFUZE100_SW2;
sw_check_end = PFUZE100_SW4; sw_check_end = PFUZE100_SW4;
...@@ -587,7 +586,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ...@@ -587,7 +586,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
(pfuze_chip->chip_id == PFUZE100) ? "100" : (pfuze_chip->chip_id == PFUZE100) ? "100" :
((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000")); ((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000"));
memcpy(pfuze_chip->regulator_descs, pfuze_regulators, memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators,
sizeof(pfuze_chip->regulator_descs)); sizeof(pfuze_chip->regulator_descs));
ret = pfuze_parse_regulators_dt(pfuze_chip); ret = pfuze_parse_regulators_dt(pfuze_chip);
...@@ -631,7 +630,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ...@@ -631,7 +630,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
devm_regulator_register(&client->dev, desc, &config); devm_regulator_register(&client->dev, desc, &config);
if (IS_ERR(pfuze_chip->regulators[i])) { if (IS_ERR(pfuze_chip->regulators[i])) {
dev_err(&client->dev, "register regulator%s failed\n", dev_err(&client->dev, "register regulator%s failed\n",
pfuze_regulators[i].desc.name); pfuze_chip->pfuze_regulators[i].desc.name);
return PTR_ERR(pfuze_chip->regulators[i]); return PTR_ERR(pfuze_chip->regulators[i]);
} }
} }
...@@ -650,5 +649,5 @@ static struct i2c_driver pfuze_driver = { ...@@ -650,5 +649,5 @@ static struct i2c_driver pfuze_driver = {
module_i2c_driver(pfuze_driver); module_i2c_driver(pfuze_driver);
MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); MODULE_AUTHOR("Robin Gong <b38343@freescale.com>");
MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/PFUZE200 PMIC"); MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/200/3000 PMIC");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -25,8 +24,6 @@ ...@@ -25,8 +24,6 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include "pv88060-regulator.h" #include "pv88060-regulator.h"
#define PV88060_MAX_REGULATORS 14 #define PV88060_MAX_REGULATORS 14
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -25,8 +24,6 @@ ...@@ -25,8 +24,6 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include "pv88080-regulator.h" #include "pv88080-regulator.h"
#define PV88080_MAX_REGULATORS 3 #define PV88080_MAX_REGULATORS 3
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -25,8 +24,6 @@ ...@@ -25,8 +24,6 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include "pv88090-regulator.h" #include "pv88090-regulator.h"
#define PV88090_MAX_REGULATORS 5 #define PV88090_MAX_REGULATORS 5
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/pwm.h> #include <linux/pwm.h>
#include <linux/gpio/consumer.h>
struct pwm_regulator_data { struct pwm_regulator_data {
/* Shared */ /* Shared */
...@@ -38,6 +39,9 @@ struct pwm_regulator_data { ...@@ -38,6 +39,9 @@ struct pwm_regulator_data {
/* Continuous voltage */ /* Continuous voltage */
int volt_uV; int volt_uV;
/* Enable GPIO */
struct gpio_desc *enb_gpio;
}; };
struct pwm_voltages { struct pwm_voltages {
...@@ -94,6 +98,9 @@ static int pwm_regulator_enable(struct regulator_dev *dev) ...@@ -94,6 +98,9 @@ static int pwm_regulator_enable(struct regulator_dev *dev)
{ {
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
if (drvdata->enb_gpio)
gpiod_set_value_cansleep(drvdata->enb_gpio, 1);
return pwm_enable(drvdata->pwm); return pwm_enable(drvdata->pwm);
} }
...@@ -103,6 +110,9 @@ static int pwm_regulator_disable(struct regulator_dev *dev) ...@@ -103,6 +110,9 @@ static int pwm_regulator_disable(struct regulator_dev *dev)
pwm_disable(drvdata->pwm); pwm_disable(drvdata->pwm);
if (drvdata->enb_gpio)
gpiod_set_value_cansleep(drvdata->enb_gpio, 0);
return 0; return 0;
} }
...@@ -110,6 +120,9 @@ static int pwm_regulator_is_enabled(struct regulator_dev *dev) ...@@ -110,6 +120,9 @@ static int pwm_regulator_is_enabled(struct regulator_dev *dev)
{ {
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
if (drvdata->enb_gpio && !gpiod_get_value_cansleep(drvdata->enb_gpio))
return false;
return pwm_is_enabled(drvdata->pwm); return pwm_is_enabled(drvdata->pwm);
} }
...@@ -132,6 +145,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev, ...@@ -132,6 +145,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
unsigned int duty_pulse; unsigned int duty_pulse;
u64 req_period; u64 req_period;
u32 rem; u32 rem;
int old_uV = pwm_regulator_get_voltage(rdev);
int ret; int ret;
pwm_get_args(drvdata->pwm, &pargs); pwm_get_args(drvdata->pwm, &pargs);
...@@ -159,15 +173,14 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev, ...@@ -159,15 +173,14 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
return ret; return ret;
} }
ret = pwm_enable(drvdata->pwm);
if (ret) {
dev_err(&rdev->dev, "Failed to enable PWM: %d\n", ret);
return ret;
}
drvdata->volt_uV = min_uV; drvdata->volt_uV = min_uV;
/* Delay required by PWM regulator to settle to the new voltage */ if ((ramp_delay == 0) || !pwm_regulator_is_enabled(rdev))
usleep_range(ramp_delay, ramp_delay + 1000); return 0;
/* Ramp delay is in uV/uS. Adjust to uS and delay */
ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10));
return 0; return 0;
} }
...@@ -253,6 +266,7 @@ static int pwm_regulator_probe(struct platform_device *pdev) ...@@ -253,6 +266,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
struct regulator_dev *regulator; struct regulator_dev *regulator;
struct regulator_config config = { }; struct regulator_config config = { };
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
enum gpiod_flags gpio_flags;
int ret; int ret;
if (!np) { if (!np) {
...@@ -290,6 +304,18 @@ static int pwm_regulator_probe(struct platform_device *pdev) ...@@ -290,6 +304,18 @@ static int pwm_regulator_probe(struct platform_device *pdev)
return ret; return ret;
} }
if (init_data->constraints.boot_on || init_data->constraints.always_on)
gpio_flags = GPIOD_OUT_HIGH;
else
gpio_flags = GPIOD_OUT_LOW;
drvdata->enb_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
gpio_flags);
if (IS_ERR(drvdata->enb_gpio)) {
ret = PTR_ERR(drvdata->enb_gpio);
dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", ret);
return ret;
}
/* /*
* FIXME: pwm_apply_args() should be removed when switching to the * FIXME: pwm_apply_args() should be removed when switching to the
* atomic PWM API. * atomic PWM API.
......
...@@ -211,7 +211,7 @@ static const struct regulator_desc pma8084_switch = { ...@@ -211,7 +211,7 @@ static const struct regulator_desc pma8084_switch = {
static const struct regulator_desc pm8x41_hfsmps = { static const struct regulator_desc pm8x41_hfsmps = {
.linear_ranges = (struct regulator_linear_range[]) { .linear_ranges = (struct regulator_linear_range[]) {
REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500), REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500),
REGULATOR_LINEAR_RANGE(1550000, 96, 158, 25000), REGULATOR_LINEAR_RANGE(1575000, 96, 158, 25000),
}, },
.n_linear_ranges = 2, .n_linear_ranges = 2,
.n_voltages = 159, .n_voltages = 159,
......
...@@ -1085,6 +1085,8 @@ static struct regulator_ops spmi_vs_ops = { ...@@ -1085,6 +1085,8 @@ static struct regulator_ops spmi_vs_ops = {
.set_pull_down = spmi_regulator_common_set_pull_down, .set_pull_down = spmi_regulator_common_set_pull_down,
.set_soft_start = spmi_regulator_common_set_soft_start, .set_soft_start = spmi_regulator_common_set_soft_start,
.set_over_current_protection = spmi_regulator_vs_ocp, .set_over_current_protection = spmi_regulator_vs_ocp,
.set_mode = spmi_regulator_common_set_mode,
.get_mode = spmi_regulator_common_get_mode,
}; };
static struct regulator_ops spmi_boost_ops = { static struct regulator_ops spmi_boost_ops = {
...@@ -1496,6 +1498,7 @@ static const struct spmi_regulator_data pm8941_regulators[] = { ...@@ -1496,6 +1498,7 @@ static const struct spmi_regulator_data pm8941_regulators[] = {
{ "s1", 0x1400, "vdd_s1", }, { "s1", 0x1400, "vdd_s1", },
{ "s2", 0x1700, "vdd_s2", }, { "s2", 0x1700, "vdd_s2", },
{ "s3", 0x1a00, "vdd_s3", }, { "s3", 0x1a00, "vdd_s3", },
{ "s4", 0xa000, },
{ "l1", 0x4000, "vdd_l1_l3", }, { "l1", 0x4000, "vdd_l1_l3", },
{ "l2", 0x4100, "vdd_l2_lvs_1_2_3", }, { "l2", 0x4100, "vdd_l2_lvs_1_2_3", },
{ "l3", 0x4200, "vdd_l1_l3", }, { "l3", 0x4200, "vdd_l1_l3", },
...@@ -1523,8 +1526,8 @@ static const struct spmi_regulator_data pm8941_regulators[] = { ...@@ -1523,8 +1526,8 @@ static const struct spmi_regulator_data pm8941_regulators[] = {
{ "lvs1", 0x8000, "vdd_l2_lvs_1_2_3", }, { "lvs1", 0x8000, "vdd_l2_lvs_1_2_3", },
{ "lvs2", 0x8100, "vdd_l2_lvs_1_2_3", }, { "lvs2", 0x8100, "vdd_l2_lvs_1_2_3", },
{ "lvs3", 0x8200, "vdd_l2_lvs_1_2_3", }, { "lvs3", 0x8200, "vdd_l2_lvs_1_2_3", },
{ "mvs1", 0x8300, "vin_5vs", }, { "5vs1", 0x8300, "vin_5vs", "ocp-5vs1", },
{ "mvs2", 0x8400, "vin_5vs", }, { "5vs2", 0x8400, "vin_5vs", "ocp-5vs2", },
{ } { }
}; };
......
...@@ -46,6 +46,23 @@ static struct regulator_ops rn5t618_reg_ops = { ...@@ -46,6 +46,23 @@ static struct regulator_ops rn5t618_reg_ops = {
.vsel_mask = (vmask), \ .vsel_mask = (vmask), \
} }
static struct regulator_desc rn5t567_regulators[] = {
/* DCDC */
REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500),
REG(DCDC4, DC4CTL, BIT(0), DC4DAC, 0xff, 600000, 3500000, 12500),
/* LDO */
REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000),
REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000),
REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 600000, 3500000, 25000),
REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000),
REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 900000, 3500000, 25000),
/* LDO RTC */
REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1200000, 3500000, 25000),
REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
};
static struct regulator_desc rn5t618_regulators[] = { static struct regulator_desc rn5t618_regulators[] = {
/* DCDC */ /* DCDC */
REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500), REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
...@@ -67,18 +84,33 @@ static int rn5t618_regulator_probe(struct platform_device *pdev) ...@@ -67,18 +84,33 @@ static int rn5t618_regulator_probe(struct platform_device *pdev)
struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { }; struct regulator_config config = { };
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct regulator_desc *regulators;
int i; int i;
for (i = 0; i < RN5T618_REG_NUM; i++) { switch (rn5t618->variant) {
case RN5T567:
regulators = rn5t567_regulators;
break;
case RN5T618:
regulators = rn5t618_regulators;
break;
default:
return -EINVAL;
}
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.regmap = rn5t618->regmap; config.regmap = rn5t618->regmap;
for (i = 0; i < RN5T618_REG_NUM; i++) {
if (!regulators[i].name)
continue;
rdev = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev,
&rn5t618_regulators[i], &regulators[i],
&config); &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register %s regulator\n", dev_err(&pdev->dev, "failed to register %s regulator\n",
rn5t618_regulators[i].name); regulators[i].name);
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
} }
......
...@@ -750,7 +750,7 @@ static const struct regulator_linear_range s2mps15_ldo_voltage_ranges3[] = { ...@@ -750,7 +750,7 @@ static const struct regulator_linear_range s2mps15_ldo_voltage_ranges3[] = {
/* voltage range for s2mps15 LDO 7, 8, 9 and 10 */ /* voltage range for s2mps15 LDO 7, 8, 9 and 10 */
static const struct regulator_linear_range s2mps15_ldo_voltage_ranges4[] = { static const struct regulator_linear_range s2mps15_ldo_voltage_ranges4[] = {
REGULATOR_LINEAR_RANGE(700000, 0xc, 0x18, 25000), REGULATOR_LINEAR_RANGE(700000, 0x10, 0x20, 25000),
}; };
/* voltage range for s2mps15 LDO 1 */ /* voltage range for s2mps15 LDO 1 */
...@@ -760,12 +760,12 @@ static const struct regulator_linear_range s2mps15_ldo_voltage_ranges5[] = { ...@@ -760,12 +760,12 @@ static const struct regulator_linear_range s2mps15_ldo_voltage_ranges5[] = {
/* voltage range for s2mps15 BUCK 1, 2, 3, 4, 5, 6 and 7 */ /* voltage range for s2mps15 BUCK 1, 2, 3, 4, 5, 6 and 7 */
static const struct regulator_linear_range s2mps15_buck_voltage_ranges1[] = { static const struct regulator_linear_range s2mps15_buck_voltage_ranges1[] = {
REGULATOR_LINEAR_RANGE(500000, 0x20, 0xb0, 6250), REGULATOR_LINEAR_RANGE(500000, 0x20, 0xc0, 6250),
}; };
/* voltage range for s2mps15 BUCK 8, 9 and 10 */ /* voltage range for s2mps15 BUCK 8, 9 and 10 */
static const struct regulator_linear_range s2mps15_buck_voltage_ranges2[] = { static const struct regulator_linear_range s2mps15_buck_voltage_ranges2[] = {
REGULATOR_LINEAR_RANGE(1000000, 0x20, 0xc0, 12500), REGULATOR_LINEAR_RANGE(1000000, 0x20, 0x78, 12500),
}; };
static const struct regulator_desc s2mps15_regulators[] = { static const struct regulator_desc s2mps15_regulators[] = {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <linux/mfd/tps65217.h> #include <linux/mfd/tps65217.h>
#define TPS65217_REGULATOR(_name, _id, _of_match, _ops, _n, _vr, _vm, _em, \ #define TPS65217_REGULATOR(_name, _id, _of_match, _ops, _n, _vr, _vm, _em, \
_t, _lr, _nlr) \ _t, _lr, _nlr, _sr, _sm) \
{ \ { \
.name = _name, \ .name = _name, \
.id = _id, \ .id = _id, \
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
.volt_table = _t, \ .volt_table = _t, \
.linear_ranges = _lr, \ .linear_ranges = _lr, \
.n_linear_ranges = _nlr, \ .n_linear_ranges = _nlr, \
.bypass_reg = _sr, \
.bypass_mask = _sm, \
} \ } \
static const unsigned int LDO1_VSEL_table[] = { static const unsigned int LDO1_VSEL_table[] = {
...@@ -118,6 +120,35 @@ static int tps65217_pmic_set_voltage_sel(struct regulator_dev *dev, ...@@ -118,6 +120,35 @@ static int tps65217_pmic_set_voltage_sel(struct regulator_dev *dev,
return ret; return ret;
} }
static int tps65217_pmic_set_suspend_enable(struct regulator_dev *dev)
{
struct tps65217 *tps = rdev_get_drvdata(dev);
unsigned int rid = rdev_get_id(dev);
if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
return -EINVAL;
return tps65217_clear_bits(tps, dev->desc->bypass_reg,
dev->desc->bypass_mask,
TPS65217_PROTECT_L1);
}
static int tps65217_pmic_set_suspend_disable(struct regulator_dev *dev)
{
struct tps65217 *tps = rdev_get_drvdata(dev);
unsigned int rid = rdev_get_id(dev);
if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
return -EINVAL;
if (!tps->strobes[rid])
return -EINVAL;
return tps65217_set_bits(tps, dev->desc->bypass_reg,
dev->desc->bypass_mask,
tps->strobes[rid], TPS65217_PROTECT_L1);
}
/* Operations permitted on DCDCx, LDO2, LDO3 and LDO4 */ /* Operations permitted on DCDCx, LDO2, LDO3 and LDO4 */
static struct regulator_ops tps65217_pmic_ops = { static struct regulator_ops tps65217_pmic_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
...@@ -127,6 +158,8 @@ static struct regulator_ops tps65217_pmic_ops = { ...@@ -127,6 +158,8 @@ static struct regulator_ops tps65217_pmic_ops = {
.set_voltage_sel = tps65217_pmic_set_voltage_sel, .set_voltage_sel = tps65217_pmic_set_voltage_sel,
.list_voltage = regulator_list_voltage_linear_range, .list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range,
.set_suspend_enable = tps65217_pmic_set_suspend_enable,
.set_suspend_disable = tps65217_pmic_set_suspend_disable,
}; };
/* Operations permitted on LDO1 */ /* Operations permitted on LDO1 */
...@@ -138,41 +171,50 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = { ...@@ -138,41 +171,50 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = {
.set_voltage_sel = tps65217_pmic_set_voltage_sel, .set_voltage_sel = tps65217_pmic_set_voltage_sel,
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_ascend, .map_voltage = regulator_map_voltage_ascend,
.set_suspend_enable = tps65217_pmic_set_suspend_enable,
.set_suspend_disable = tps65217_pmic_set_suspend_disable,
}; };
static const struct regulator_desc regulators[] = { static const struct regulator_desc regulators[] = {
TPS65217_REGULATOR("DCDC1", TPS65217_DCDC_1, "dcdc1", TPS65217_REGULATOR("DCDC1", TPS65217_DCDC_1, "dcdc1",
tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC1, tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC1,
TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC1_EN, TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC1_EN,
NULL, tps65217_uv1_ranges, 2), NULL, tps65217_uv1_ranges, 2, TPS65217_REG_SEQ1,
TPS65217_SEQ1_DC1_SEQ_MASK),
TPS65217_REGULATOR("DCDC2", TPS65217_DCDC_2, "dcdc2", TPS65217_REGULATOR("DCDC2", TPS65217_DCDC_2, "dcdc2",
tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC2, tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC2,
TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC2_EN, TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC2_EN,
NULL, tps65217_uv1_ranges, NULL, tps65217_uv1_ranges,
ARRAY_SIZE(tps65217_uv1_ranges)), ARRAY_SIZE(tps65217_uv1_ranges), TPS65217_REG_SEQ1,
TPS65217_SEQ1_DC2_SEQ_MASK),
TPS65217_REGULATOR("DCDC3", TPS65217_DCDC_3, "dcdc3", TPS65217_REGULATOR("DCDC3", TPS65217_DCDC_3, "dcdc3",
tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC3, tps65217_pmic_ops, 64, TPS65217_REG_DEFDCDC3,
TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC3_EN, TPS65217_DEFDCDCX_DCDC_MASK, TPS65217_ENABLE_DC3_EN,
NULL, tps65217_uv1_ranges, 1), NULL, tps65217_uv1_ranges, 1, TPS65217_REG_SEQ2,
TPS65217_SEQ2_DC3_SEQ_MASK),
TPS65217_REGULATOR("LDO1", TPS65217_LDO_1, "ldo1", TPS65217_REGULATOR("LDO1", TPS65217_LDO_1, "ldo1",
tps65217_pmic_ldo1_ops, 16, TPS65217_REG_DEFLDO1, tps65217_pmic_ldo1_ops, 16, TPS65217_REG_DEFLDO1,
TPS65217_DEFLDO1_LDO1_MASK, TPS65217_ENABLE_LDO1_EN, TPS65217_DEFLDO1_LDO1_MASK, TPS65217_ENABLE_LDO1_EN,
LDO1_VSEL_table, NULL, 0), LDO1_VSEL_table, NULL, 0, TPS65217_REG_SEQ2,
TPS65217_SEQ2_LDO1_SEQ_MASK),
TPS65217_REGULATOR("LDO2", TPS65217_LDO_2, "ldo2", tps65217_pmic_ops, TPS65217_REGULATOR("LDO2", TPS65217_LDO_2, "ldo2", tps65217_pmic_ops,
64, TPS65217_REG_DEFLDO2, 64, TPS65217_REG_DEFLDO2,
TPS65217_DEFLDO2_LDO2_MASK, TPS65217_ENABLE_LDO2_EN, TPS65217_DEFLDO2_LDO2_MASK, TPS65217_ENABLE_LDO2_EN,
NULL, tps65217_uv1_ranges, NULL, tps65217_uv1_ranges,
ARRAY_SIZE(tps65217_uv1_ranges)), ARRAY_SIZE(tps65217_uv1_ranges), TPS65217_REG_SEQ3,
TPS65217_SEQ3_LDO2_SEQ_MASK),
TPS65217_REGULATOR("LDO3", TPS65217_LDO_3, "ldo3", tps65217_pmic_ops, TPS65217_REGULATOR("LDO3", TPS65217_LDO_3, "ldo3", tps65217_pmic_ops,
32, TPS65217_REG_DEFLS1, TPS65217_DEFLDO3_LDO3_MASK, 32, TPS65217_REG_DEFLS1, TPS65217_DEFLDO3_LDO3_MASK,
TPS65217_ENABLE_LS1_EN | TPS65217_DEFLDO3_LDO3_EN, TPS65217_ENABLE_LS1_EN | TPS65217_DEFLDO3_LDO3_EN,
NULL, tps65217_uv2_ranges, NULL, tps65217_uv2_ranges,
ARRAY_SIZE(tps65217_uv2_ranges)), ARRAY_SIZE(tps65217_uv2_ranges), TPS65217_REG_SEQ3,
TPS65217_SEQ3_LDO3_SEQ_MASK),
TPS65217_REGULATOR("LDO4", TPS65217_LDO_4, "ldo4", tps65217_pmic_ops, TPS65217_REGULATOR("LDO4", TPS65217_LDO_4, "ldo4", tps65217_pmic_ops,
32, TPS65217_REG_DEFLS2, TPS65217_DEFLDO4_LDO4_MASK, 32, TPS65217_REG_DEFLS2, TPS65217_DEFLDO4_LDO4_MASK,
TPS65217_ENABLE_LS2_EN | TPS65217_DEFLDO4_LDO4_EN, TPS65217_ENABLE_LS2_EN | TPS65217_DEFLDO4_LDO4_EN,
NULL, tps65217_uv2_ranges, NULL, tps65217_uv2_ranges,
ARRAY_SIZE(tps65217_uv2_ranges)), ARRAY_SIZE(tps65217_uv2_ranges), TPS65217_REG_SEQ4,
TPS65217_SEQ4_LDO4_SEQ_MASK),
}; };
static int tps65217_regulator_probe(struct platform_device *pdev) static int tps65217_regulator_probe(struct platform_device *pdev)
...@@ -181,13 +223,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev) ...@@ -181,13 +223,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
struct tps65217_board *pdata = dev_get_platdata(tps->dev); struct tps65217_board *pdata = dev_get_platdata(tps->dev);
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct regulator_config config = { }; struct regulator_config config = { };
int i; int i, ret;
unsigned int val;
if (tps65217_chip_id(tps) != TPS65217) { if (tps65217_chip_id(tps) != TPS65217) {
dev_err(&pdev->dev, "Invalid tps chip version\n"); dev_err(&pdev->dev, "Invalid tps chip version\n");
return -ENODEV; return -ENODEV;
} }
/* Allocate memory for strobes */
tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
TPS65217_NUM_REGULATOR, GFP_KERNEL);
platform_set_drvdata(pdev, tps); platform_set_drvdata(pdev, tps);
for (i = 0; i < TPS65217_NUM_REGULATOR; i++) { for (i = 0; i < TPS65217_NUM_REGULATOR; i++) {
...@@ -205,6 +252,10 @@ static int tps65217_regulator_probe(struct platform_device *pdev) ...@@ -205,6 +252,10 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
pdev->name); pdev->name);
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
/* Store default strobe info */
ret = tps65217_reg_read(tps, regulators[i].bypass_reg, &val);
tps->strobes[i] = val & regulators[i].bypass_mask;
} }
return 0; return 0;
......
...@@ -31,7 +31,7 @@ enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, ...@@ -31,7 +31,7 @@ enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4,
DCDC5, DCDC6, LDO1, LS3 }; DCDC5, DCDC6, LDO1, LS3 };
#define TPS65218_REGULATOR(_name, _id, _type, _ops, _n, _vr, _vm, _er, _em, \ #define TPS65218_REGULATOR(_name, _id, _type, _ops, _n, _vr, _vm, _er, _em, \
_cr, _cm, _lr, _nlr, _delay, _fuv) \ _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm) \
{ \ { \
.name = _name, \ .name = _name, \
.id = _id, \ .id = _id, \
...@@ -49,7 +49,9 @@ enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, ...@@ -49,7 +49,9 @@ enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4,
.linear_ranges = _lr, \ .linear_ranges = _lr, \
.n_linear_ranges = _nlr, \ .n_linear_ranges = _nlr, \
.ramp_delay = _delay, \ .ramp_delay = _delay, \
.fixed_uV = _fuv \ .fixed_uV = _fuv, \
.bypass_reg = _sr, \
.bypass_mask = _sm, \
} \ } \
#define TPS65218_INFO(_id, _nm, _min, _max) \ #define TPS65218_INFO(_id, _nm, _min, _max) \
...@@ -157,6 +159,40 @@ static int tps65218_pmic_disable(struct regulator_dev *dev) ...@@ -157,6 +159,40 @@ static int tps65218_pmic_disable(struct regulator_dev *dev)
dev->desc->enable_mask, TPS65218_PROTECT_L1); dev->desc->enable_mask, TPS65218_PROTECT_L1);
} }
static int tps65218_pmic_set_suspend_enable(struct regulator_dev *dev)
{
struct tps65218 *tps = rdev_get_drvdata(dev);
unsigned int rid = rdev_get_id(dev);
if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1)
return -EINVAL;
return tps65218_clear_bits(tps, dev->desc->bypass_reg,
dev->desc->bypass_mask,
TPS65218_PROTECT_L1);
}
static int tps65218_pmic_set_suspend_disable(struct regulator_dev *dev)
{
struct tps65218 *tps = rdev_get_drvdata(dev);
unsigned int rid = rdev_get_id(dev);
if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1)
return -EINVAL;
if (!tps->info[rid]->strobe) {
if (rid == TPS65218_DCDC_3)
tps->info[rid]->strobe = 3;
else
return -EINVAL;
}
return tps65218_set_bits(tps, dev->desc->bypass_reg,
dev->desc->bypass_mask,
tps->info[rid]->strobe,
TPS65218_PROTECT_L1);
}
/* Operations permitted on DCDC1, DCDC2 */ /* Operations permitted on DCDC1, DCDC2 */
static struct regulator_ops tps65218_dcdc12_ops = { static struct regulator_ops tps65218_dcdc12_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
...@@ -167,6 +203,8 @@ static struct regulator_ops tps65218_dcdc12_ops = { ...@@ -167,6 +203,8 @@ static struct regulator_ops tps65218_dcdc12_ops = {
.list_voltage = regulator_list_voltage_linear_range, .list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range,
.set_voltage_time_sel = regulator_set_voltage_time_sel, .set_voltage_time_sel = regulator_set_voltage_time_sel,
.set_suspend_enable = tps65218_pmic_set_suspend_enable,
.set_suspend_disable = tps65218_pmic_set_suspend_disable,
}; };
/* Operations permitted on DCDC3, DCDC4 and LDO1 */ /* Operations permitted on DCDC3, DCDC4 and LDO1 */
...@@ -178,6 +216,8 @@ static struct regulator_ops tps65218_ldo1_dcdc34_ops = { ...@@ -178,6 +216,8 @@ static struct regulator_ops tps65218_ldo1_dcdc34_ops = {
.set_voltage_sel = tps65218_pmic_set_voltage_sel, .set_voltage_sel = tps65218_pmic_set_voltage_sel,
.list_voltage = regulator_list_voltage_linear_range, .list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range,
.set_suspend_enable = tps65218_pmic_set_suspend_enable,
.set_suspend_disable = tps65218_pmic_set_suspend_disable,
}; };
static const int ls3_currents[] = { 100, 200, 500, 1000 }; static const int ls3_currents[] = { 100, 200, 500, 1000 };
...@@ -247,6 +287,8 @@ static struct regulator_ops tps65218_dcdc56_pmic_ops = { ...@@ -247,6 +287,8 @@ static struct regulator_ops tps65218_dcdc56_pmic_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.enable = tps65218_pmic_enable, .enable = tps65218_pmic_enable,
.disable = tps65218_pmic_disable, .disable = tps65218_pmic_disable,
.set_suspend_enable = tps65218_pmic_set_suspend_enable,
.set_suspend_disable = tps65218_pmic_set_suspend_disable,
}; };
static const struct regulator_desc regulators[] = { static const struct regulator_desc regulators[] = {
...@@ -254,42 +296,47 @@ static const struct regulator_desc regulators[] = { ...@@ -254,42 +296,47 @@ static const struct regulator_desc regulators[] = {
tps65218_dcdc12_ops, 64, TPS65218_REG_CONTROL_DCDC1, tps65218_dcdc12_ops, 64, TPS65218_REG_CONTROL_DCDC1,
TPS65218_CONTROL_DCDC1_MASK, TPS65218_REG_ENABLE1, TPS65218_CONTROL_DCDC1_MASK, TPS65218_REG_ENABLE1,
TPS65218_ENABLE1_DC1_EN, 0, 0, dcdc1_dcdc2_ranges, TPS65218_ENABLE1_DC1_EN, 0, 0, dcdc1_dcdc2_ranges,
2, 4000, 0), 2, 4000, 0, TPS65218_REG_SEQ3,
TPS65218_SEQ3_DC1_SEQ_MASK),
TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, REGULATOR_VOLTAGE, TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, REGULATOR_VOLTAGE,
tps65218_dcdc12_ops, 64, TPS65218_REG_CONTROL_DCDC2, tps65218_dcdc12_ops, 64, TPS65218_REG_CONTROL_DCDC2,
TPS65218_CONTROL_DCDC2_MASK, TPS65218_REG_ENABLE1, TPS65218_CONTROL_DCDC2_MASK, TPS65218_REG_ENABLE1,
TPS65218_ENABLE1_DC2_EN, 0, 0, dcdc1_dcdc2_ranges, TPS65218_ENABLE1_DC2_EN, 0, 0, dcdc1_dcdc2_ranges,
2, 4000, 0), 2, 4000, 0, TPS65218_REG_SEQ3,
TPS65218_SEQ3_DC2_SEQ_MASK),
TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, REGULATOR_VOLTAGE, TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, REGULATOR_VOLTAGE,
tps65218_ldo1_dcdc34_ops, 64, tps65218_ldo1_dcdc34_ops, 64,
TPS65218_REG_CONTROL_DCDC3, TPS65218_REG_CONTROL_DCDC3,
TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1,
TPS65218_ENABLE1_DC3_EN, 0, 0, ldo1_dcdc3_ranges, 2, TPS65218_ENABLE1_DC3_EN, 0, 0, ldo1_dcdc3_ranges, 2,
0, 0), 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK),
TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, REGULATOR_VOLTAGE, TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, REGULATOR_VOLTAGE,
tps65218_ldo1_dcdc34_ops, 53, tps65218_ldo1_dcdc34_ops, 53,
TPS65218_REG_CONTROL_DCDC4, TPS65218_REG_CONTROL_DCDC4,
TPS65218_CONTROL_DCDC4_MASK, TPS65218_REG_ENABLE1, TPS65218_CONTROL_DCDC4_MASK, TPS65218_REG_ENABLE1,
TPS65218_ENABLE1_DC4_EN, 0, 0, dcdc4_ranges, 2, TPS65218_ENABLE1_DC4_EN, 0, 0, dcdc4_ranges, 2,
0, 0), 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK),
TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, REGULATOR_VOLTAGE, TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, REGULATOR_VOLTAGE,
tps65218_dcdc56_pmic_ops, 1, -1, -1, tps65218_dcdc56_pmic_ops, 1, -1, -1,
TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC5_EN, 0, 0, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC5_EN, 0, 0,
NULL, 0, 0, 1000000), NULL, 0, 0, 1000000, TPS65218_REG_SEQ5,
TPS65218_SEQ5_DC5_SEQ_MASK),
TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, REGULATOR_VOLTAGE, TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, REGULATOR_VOLTAGE,
tps65218_dcdc56_pmic_ops, 1, -1, -1, tps65218_dcdc56_pmic_ops, 1, -1, -1,
TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC6_EN, 0, 0, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC6_EN, 0, 0,
NULL, 0, 0, 1800000), NULL, 0, 0, 1800000, TPS65218_REG_SEQ5,
TPS65218_SEQ5_DC6_SEQ_MASK),
TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, REGULATOR_VOLTAGE, TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, REGULATOR_VOLTAGE,
tps65218_ldo1_dcdc34_ops, 64, tps65218_ldo1_dcdc34_ops, 64,
TPS65218_REG_CONTROL_LDO1, TPS65218_REG_CONTROL_LDO1,
TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2,
TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges, TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges,
2, 0, 0), 2, 0, 0, TPS65218_REG_SEQ6,
TPS65218_SEQ6_LDO1_SEQ_MASK),
TPS65218_REGULATOR("LS3", TPS65218_LS_3, REGULATOR_CURRENT, TPS65218_REGULATOR("LS3", TPS65218_LS_3, REGULATOR_CURRENT,
tps65218_ls3_ops, 0, 0, 0, TPS65218_REG_ENABLE2, tps65218_ls3_ops, 0, 0, 0, TPS65218_REG_ENABLE2,
TPS65218_ENABLE2_LS3_EN, TPS65218_REG_CONFIG2, TPS65218_ENABLE2_LS3_EN, TPS65218_REG_CONFIG2,
TPS65218_CONFIG2_LS3ILIM_MASK, NULL, 0, 0, 0), TPS65218_CONFIG2_LS3ILIM_MASK, NULL, 0, 0, 0, 0, 0),
}; };
static int tps65218_regulator_probe(struct platform_device *pdev) static int tps65218_regulator_probe(struct platform_device *pdev)
...@@ -300,7 +347,8 @@ static int tps65218_regulator_probe(struct platform_device *pdev) ...@@ -300,7 +347,8 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev; struct regulator_dev *rdev;
const struct of_device_id *match; const struct of_device_id *match;
struct regulator_config config = { }; struct regulator_config config = { };
int id; int id, ret;
unsigned int val;
match = of_match_device(tps65218_of_match, &pdev->dev); match = of_match_device(tps65218_of_match, &pdev->dev);
if (!match) if (!match)
...@@ -327,6 +375,12 @@ static int tps65218_regulator_probe(struct platform_device *pdev) ...@@ -327,6 +375,12 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
ret = tps65218_reg_read(tps, regulators[id].bypass_reg, &val);
if (ret)
return ret;
tps->info[id]->strobe = val & regulators[id].bypass_mask;
return 0; return 0;
} }
......
...@@ -905,7 +905,7 @@ static struct regulator_ops twlsmps_ops = { ...@@ -905,7 +905,7 @@ static struct regulator_ops twlsmps_ops = {
twl4030reg_map_mode) twl4030reg_map_mode)
#define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \ #define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \
TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \ TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
0x0, TWL6030, twl6030fixed_ops, 0x0) 0x0, TWL6030, twl6030fixed_ops, NULL)
#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \ #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
static const struct twlreg_info TWL4030_INFO_##label = { \ static const struct twlreg_info TWL4030_INFO_##label = { \
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define RN5T618_OTPVER 0x01 #define RN5T618_OTPVER 0x01
#define RN5T618_IODAC 0x02 #define RN5T618_IODAC 0x02
#define RN5T618_VINDAC 0x03 #define RN5T618_VINDAC 0x03
#define RN5T618_OUT32KEN 0x05
#define RN5T618_CPUCNT 0x06 #define RN5T618_CPUCNT 0x06
#define RN5T618_PSWR 0x07 #define RN5T618_PSWR 0x07
#define RN5T618_PONHIS 0x09 #define RN5T618_PONHIS 0x09
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
#define RN5T618_DC1_SLOT 0x16 #define RN5T618_DC1_SLOT 0x16
#define RN5T618_DC2_SLOT 0x17 #define RN5T618_DC2_SLOT 0x17
#define RN5T618_DC3_SLOT 0x18 #define RN5T618_DC3_SLOT 0x18
#define RN5T618_DC4_SLOT 0x19
#define RN5T618_LDO1_SLOT 0x1b #define RN5T618_LDO1_SLOT 0x1b
#define RN5T618_LDO2_SLOT 0x1c #define RN5T618_LDO2_SLOT 0x1c
#define RN5T618_LDO3_SLOT 0x1d #define RN5T618_LDO3_SLOT 0x1d
...@@ -54,12 +56,16 @@ ...@@ -54,12 +56,16 @@
#define RN5T618_DC2CTL2 0x2f #define RN5T618_DC2CTL2 0x2f
#define RN5T618_DC3CTL 0x30 #define RN5T618_DC3CTL 0x30
#define RN5T618_DC3CTL2 0x31 #define RN5T618_DC3CTL2 0x31
#define RN5T618_DC4CTL 0x32
#define RN5T618_DC4CTL2 0x33
#define RN5T618_DC1DAC 0x36 #define RN5T618_DC1DAC 0x36
#define RN5T618_DC2DAC 0x37 #define RN5T618_DC2DAC 0x37
#define RN5T618_DC3DAC 0x38 #define RN5T618_DC3DAC 0x38
#define RN5T618_DC4DAC 0x39
#define RN5T618_DC1DAC_SLP 0x3b #define RN5T618_DC1DAC_SLP 0x3b
#define RN5T618_DC2DAC_SLP 0x3c #define RN5T618_DC2DAC_SLP 0x3c
#define RN5T618_DC3DAC_SLP 0x3d #define RN5T618_DC3DAC_SLP 0x3d
#define RN5T618_DC4DAC_SLP 0x3e
#define RN5T618_DCIREN 0x40 #define RN5T618_DCIREN 0x40
#define RN5T618_DCIRQ 0x41 #define RN5T618_DCIRQ 0x41
#define RN5T618_DCIRMON 0x42 #define RN5T618_DCIRMON 0x42
...@@ -211,6 +217,7 @@ enum { ...@@ -211,6 +217,7 @@ enum {
RN5T618_DCDC1, RN5T618_DCDC1,
RN5T618_DCDC2, RN5T618_DCDC2,
RN5T618_DCDC3, RN5T618_DCDC3,
RN5T618_DCDC4,
RN5T618_LDO1, RN5T618_LDO1,
RN5T618_LDO2, RN5T618_LDO2,
RN5T618_LDO3, RN5T618_LDO3,
...@@ -221,8 +228,14 @@ enum { ...@@ -221,8 +228,14 @@ enum {
RN5T618_REG_NUM, RN5T618_REG_NUM,
}; };
enum {
RN5T567 = 0,
RN5T618,
};
struct rn5t618 { struct rn5t618 {
struct regmap *regmap; struct regmap *regmap;
long variant;
}; };
#endif /* __LINUX_MFD_RN5T618_H */ #endif /* __LINUX_MFD_RN5T618_H */
...@@ -257,6 +257,7 @@ struct tps65217 { ...@@ -257,6 +257,7 @@ struct tps65217 {
unsigned long id; unsigned long id;
struct regulator_desc desc[TPS65217_NUM_REGULATOR]; struct regulator_desc desc[TPS65217_NUM_REGULATOR];
struct regmap *regmap; struct regmap *regmap;
u8 *strobes;
}; };
static inline struct tps65217 *dev_to_tps65217(struct device *dev) static inline struct tps65217 *dev_to_tps65217(struct device *dev)
......
...@@ -246,6 +246,7 @@ enum tps65218_irqs { ...@@ -246,6 +246,7 @@ enum tps65218_irqs {
* @name: Voltage regulator name * @name: Voltage regulator name
* @min_uV: minimum micro volts * @min_uV: minimum micro volts
* @max_uV: minimum micro volts * @max_uV: minimum micro volts
* @strobe: sequencing strobe value for the regulator
* *
* This data is used to check the regualtor voltage limits while setting. * This data is used to check the regualtor voltage limits while setting.
*/ */
...@@ -254,6 +255,7 @@ struct tps_info { ...@@ -254,6 +255,7 @@ struct tps_info {
const char *name; const char *name;
int min_uV; int min_uV;
int max_uV; int max_uV;
int strobe;
}; };
/** /**
......
...@@ -224,7 +224,6 @@ int regulator_bulk_force_disable(int num_consumers, ...@@ -224,7 +224,6 @@ int regulator_bulk_force_disable(int num_consumers,
void regulator_bulk_free(int num_consumers, void regulator_bulk_free(int num_consumers,
struct regulator_bulk_data *consumers); struct regulator_bulk_data *consumers);
int regulator_can_change_voltage(struct regulator *regulator);
int regulator_count_voltages(struct regulator *regulator); int regulator_count_voltages(struct regulator *regulator);
int regulator_list_voltage(struct regulator *regulator, unsigned selector); int regulator_list_voltage(struct regulator *regulator, unsigned selector);
int regulator_is_supported_voltage(struct regulator *regulator, int regulator_is_supported_voltage(struct regulator *regulator,
...@@ -436,11 +435,6 @@ static inline void regulator_bulk_free(int num_consumers, ...@@ -436,11 +435,6 @@ static inline void regulator_bulk_free(int num_consumers,
{ {
} }
static inline int regulator_can_change_voltage(struct regulator *regulator)
{
return 0;
}
static inline int regulator_set_voltage(struct regulator *regulator, static inline int regulator_set_voltage(struct regulator *regulator,
int min_uV, int max_uV) int min_uV, int max_uV)
{ {
......
/* /*
* da9211.h - Regulator device driver for DA9211/DA9213/DA9215 * da9211.h - Regulator device driver for DA9211/DA9212
* /DA9213/DA9214/DA9215
* Copyright (C) 2015 Dialog Semiconductor Ltd. * Copyright (C) 2015 Dialog Semiconductor Ltd.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -22,7 +23,9 @@ ...@@ -22,7 +23,9 @@
enum da9211_chip_id { enum da9211_chip_id {
DA9211, DA9211,
DA9212,
DA9213, DA9213,
DA9214,
DA9215, DA9215,
}; };
......
/*
* Copyright (c) 2016 MediaTek Inc.
* Author: Chen Zhong <chen.zhong@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __LINUX_REGULATOR_MT6323_H
#define __LINUX_REGULATOR_MT6323_H
enum {
MT6323_ID_VPROC = 0,
MT6323_ID_VSYS,
MT6323_ID_VPA,
MT6323_ID_VTCXO,
MT6323_ID_VCN28,
MT6323_ID_VCN33_BT,
MT6323_ID_VCN33_WIFI,
MT6323_ID_VA,
MT6323_ID_VCAMA,
MT6323_ID_VIO28 = 9,
MT6323_ID_VUSB,
MT6323_ID_VMC,
MT6323_ID_VMCH,
MT6323_ID_VEMC3V3,
MT6323_ID_VGP1,
MT6323_ID_VGP2,
MT6323_ID_VGP3,
MT6323_ID_VCN18,
MT6323_ID_VSIM1,
MT6323_ID_VSIM2,
MT6323_ID_VRTC,
MT6323_ID_VCAMAF,
MT6323_ID_VIBR,
MT6323_ID_VRF18,
MT6323_ID_VM,
MT6323_ID_VIO18,
MT6323_ID_VCAMD,
MT6323_ID_VCAMIO,
MT6323_ID_RG_MAX,
};
#define MT6323_MAX_REGULATOR MT6323_ID_RG_MAX
#endif /* __LINUX_REGULATOR_MT6323_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment