Commit 2dda5700 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull regulator updates from Mark Brown:
 "This has been a quiet release for the regulator API, a few new drivers
  and the usual fixes and cleanup traffic but not much else going on:

   - Optimisations for the handling of voltage enumeration, especially
     with sparse selector sets, from Claudiu Beznea.

   - Support for several ARM SCMI regulators, Dialog DA9121, NXP PF8x00,
     Qualcomm PMX55, PM8350 and PM8350c

  The addition of the SCMI regulator driver (which controls regulators
  via system firmware) means that we've pulled in the support for the
  underlying firmware operations from the firmware tree"

* tag 'regulator-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (53 commits)
  regulator: mc13892-regulator: convert comma to semicolon
  regulator: pfuze100: Convert the driver to DT-only
  regulator: max14577: Add proper module aliases strings
  regulator: da9121: Potential Oops in da9121_assign_chip_model()
  regulator: da9121: Fix index used for DT property
  regulator: da9121: Remove uninitialised string variable
  regulator: axp20x: Fix DLDO2 voltage control register mask for AXP22x
  regulator: qcom-rpmh: Add support for PM8350/PM8350c
  regulator: dt-bindings: Add PM8350x compatibles
  regulator: da9121: include linux/gpio/consumer.h
  regulator: da9121: Mark some symbols with static keyword
  regulator: da9121: Request IRQ directly and free in release function to avoid masking race
  regulator: da9121: add interrupt support
  regulator: da9121: add mode support
  regulator: da9121: add current support
  regulator: da9121: Update registration to support multiple buck variants
  regulator: da9121: Add support for device variants via devicetree
  regulator: da9121: Add device variant descriptors
  regulator: da9121: Add device variant regmaps
  regulator: da9121: Add device variants
  ...
parents a45f1d43 5e999f10
......@@ -62,6 +62,20 @@ Required properties:
- #power-domain-cells : Should be 1. Contains the device or the power
domain ID value used by SCMI commands.
Regulator bindings for the SCMI Regulator based on SCMI Message Protocol
------------------------------------------------------------
An SCMI Regulator is permanently bound to a well defined SCMI Voltage Domain,
and should be always positioned as a root regulator.
It does not support any current operation.
SCMI Regulators are grouped under a 'regulators' node which in turn is a child
of the SCMI Voltage protocol node inside the desired SCMI instance node.
This binding uses the common regulator binding[6].
Required properties:
- reg : shall identify an existent SCMI Voltage Domain.
Sensor bindings for the sensors based on SCMI Message Protocol
--------------------------------------------------------------
SCMI provides an API to access the various sensors on the SoC.
......@@ -105,6 +119,7 @@ Required sub-node properties:
[3] Documentation/devicetree/bindings/thermal/thermal*.yaml
[4] Documentation/devicetree/bindings/sram/sram.yaml
[5] Documentation/devicetree/bindings/reset/reset.txt
[6] Documentation/devicetree/bindings/regulator/regulator.yaml
Example:
......@@ -169,6 +184,25 @@ firmware {
reg = <0x16>;
#reset-cells = <1>;
};
scmi_voltage: protocol@17 {
reg = <0x17>;
regulators {
regulator_devX: regulator@0 {
reg = <0x0>;
regulator-max-microvolt = <3300000>;
};
regulator_devY: regulator@9 {
reg = <0x9>;
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <4200000>;
};
...
};
};
};
};
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/dlg,da9121.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Dialog Semiconductor DA9121 voltage regulator
maintainers:
- Adam Ward <Adam.Ward.opensource@diasemi.com>
description: |
Dialog Semiconductor DA9121 Single-channel 10A double-phase buck converter
Dialog Semiconductor DA9122 Double-channel 5A single-phase buck converter
Dialog Semiconductor DA9220 Double-channel 3A single-phase buck converter
Dialog Semiconductor DA9217 Single-channel 6A double-phase buck converter
Dialog Semiconductor DA9130 Single-channel 10A double-phase buck converter
Dialog Semiconductor DA9131 Double-channel 5A single-phase buck converter
Dialog Semiconductor DA9132 Double-channel 3A single-phase buck converter
Current limits
This is PER PHASE, and the current limit setting in the devices reflect
that with a maximum 10A limit. Allowing for transients at/near double
the rated current, this translates across the device range to per
channel figures as so...
| DA9121 DA9122 DA9220 DA9217 DA9140
| /DA9130 /DA9131 /DA9132
-----------------------------------------------------------------------------
Output current / channel | 10000000 5000000 3000000 6000000 40000000
Output current / phase | 5000000 5000000 3000000 3000000 9500000
-----------------------------------------------------------------------------
Min regulator-min-microvolt| 300000 300000 300000 300000 500000
Max regulator-max-microvolt| 1900000 1900000 1900000 1900000 1000000
Device hardware default | 1000000 1000000 1000000 1000000 1000000
-----------------------------------------------------------------------------
Min regulator-min-microamp | 7000000 3500000 3500000 7000000 26000000
Max regulator-max-microamp | 20000000 10000000 6000000 12000000 78000000
Device hardware default | 15000000 7500000 5500000 11000000 58000000
properties:
$nodename:
pattern: "pmic@[0-9a-f]{1,2}"
compatible:
enum:
- dlg,da9121
- dlg,da9122
- dlg,da9220
- dlg,da9217
- dlg,da9130
- dlg,da9131
- dlg,da9132
- dlg,da9140
reg:
maxItems: 1
description: Specifies the I2C slave address.
interrupts:
maxItems: 1
description: IRQ line information.
dlg,irq-polling-delay-passive-ms:
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 1000
maximum: 10000
description: |
Specify the polling period, measured in milliseconds, between interrupt status
update checks. Range 1000-10000 ms.
regulators:
type: object
$ref: regulator.yaml#
description: |
This node defines the settings for the BUCK. The content of the
sub-node is defined by the standard binding for regulators; see regulator.yaml.
The DA9121 regulator is bound using their names listed below
buck1 - BUCK1
buck2 - BUCK2 //DA9122, DA9220, DA9131, DA9132 only
patternProperties:
"^buck([1-2])$":
type: object
$ref: regulator.yaml#
properties:
regulator-mode:
maxItems: 1
description: Defined in include/dt-bindings/regulator/dlg,da9121-regulator.h
regulator-initial-mode:
maxItems: 1
description: Defined in include/dt-bindings/regulator/dlg,da9121-regulator.h
enable-gpios:
maxItems: 1
description: Specify a valid GPIO for platform control of the regulator
dlg,ripple-cancel:
$ref: "/schemas/types.yaml#/definitions/uint32"
description: |
Defined in include/dt-bindings/regulator/dlg,da9121-regulator.h
Only present on multi-channel devices (DA9122, DA9220, DA9131, DA9132)
unevaluatedProperties: false
required:
- compatible
- reg
- regulators
additionalProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/regulator/dlg,da9121-regulator.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
pmic@68 {
compatible = "dlg,da9121";
reg = <0x68>;
interrupt-parent = <&gpio6>;
interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
dlg,irq-polling-delay-passive-ms = <2000>;
regulators {
DA9121_BUCK1: buck1 {
regulator-name = "BUCK1";
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1900000>;
regulator-min-microamp = <7000000>;
regulator-max-microamp = <20000000>;
regulator-boot-on;
regulator-initial-mode = <DA9121_BUCK_MODE_AUTO>;
enable-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
};
};
};
};
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/regulator/dlg,da9121-regulator.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
pmic@68 {
compatible = "dlg,da9122";
reg = <0x68>;
interrupt-parent = <&gpio6>;
interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
dlg,irq-polling-delay-passive-ms = <2000>;
regulators {
DA9122_BUCK1: buck1 {
regulator-name = "BUCK1";
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1900000>;
regulator-min-microamp = <3500000>;
regulator-max-microamp = <10000000>;
regulator-boot-on;
regulator-initial-mode = <DA9121_BUCK_MODE_AUTO>;
enable-gpios = <&gpio6 1 GPIO_ACTIVE_HIGH>;
dlg,ripple-cancel = <DA9121_BUCK_RIPPLE_CANCEL_NONE>;
};
DA9122_BUCK2: buck2 {
regulator-name = "BUCK2";
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1900000>;
regulator-min-microamp = <3500000>;
regulator-max-microamp = <10000000>;
regulator-boot-on;
regulator-initial-mode = <DA9121_BUCK_MODE_AUTO>;
enable-gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>;
dlg,ripple-cancel = <DA9121_BUCK_RIPPLE_CANCEL_NONE>;
};
};
};
};
...
......@@ -26,12 +26,22 @@ if:
const: regulator-fixed-clock
required:
- clocks
else:
if:
properties:
compatible:
contains:
const: regulator-fixed-domain
required:
- power-domains
- required-opps
properties:
compatible:
enum:
- regulator-fixed
- regulator-fixed-clock
- regulator-fixed-domain
regulator-name: true
......@@ -46,6 +56,20 @@ properties:
is mandatory if compatible is chosen to regulator-fixed-clock.
maxItems: 1
power-domains:
description:
Power domain to use for enable control. This binding is only
available if the compatible is chosen to regulator-fixed-domain.
maxItems: 1
required-opps:
description:
Performance state to use for enable control. This binding is only
available if the compatible is chosen to regulator-fixed-domain. The
power-domain binding is mandatory if compatible is chosen to
regulator-fixed-domain.
maxItems: 1
startup-delay-us:
description: startup time in microseconds
$ref: /schemas/types.yaml#/definitions/uint32
......@@ -89,4 +113,27 @@ examples:
gpio-open-drain;
vin-supply = <&parent_reg>;
};
reg_1v8_clk: regulator-1v8-clk {
compatible = "regulator-fixed-clock";
regulator-name = "1v8";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
clocks = <&clock1>;
startup-delay-us = <70000>;
enable-active-high;
regulator-boot-on;
vin-supply = <&parent_reg>;
};
reg_1v8_domain: regulator-1v8-domain {
compatible = "regulator-fixed-domain";
regulator-name = "1v8";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
power-domains = <&domain1>;
required-opps = <&domain1_state1>;
startup-delay-us = <70000>;
enable-active-high;
regulator-boot-on;
vin-supply = <&parent_reg>;
};
...
......@@ -10,7 +10,7 @@ Required properties:
name. The content of each sub-node is defined by the
standard binding for regulators; see regulator.txt.
Regualtors of MCP16502 PMIC:
Regulators of MCP16502 PMIC:
1) VDD_IO - Buck (1.2 - 3.7 V)
2) VDD_DDR - Buck (0.6 - 1.85 V)
3) VDD_CORE - Buck (0.6 - 1.85 V)
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/nxp,pf8x00-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: NXP PF8100/PF8121A/PF8200 PMIC regulators
maintainers:
- Jagan Teki <jagan@amarulasolutions.com>
- Troy Kisky <troy.kisky@boundarydevices.com>
description: |
PF8100/PF8121A/PF8200 is a PMIC designed for highperformance consumer
applications. It features seven high efficiency buck converters, four
linear and one vsnvs regulators. It has built-in one time programmable
fuse bank for device configurations.
properties:
compatible:
enum:
- nxp,pf8x00
reg:
maxItems: 1
regulators:
type: object
description: |
list of regulators provided by this controller
patternProperties:
"^ldo[1-4]$":
type: object
$ref: regulator.yaml#
description:
Properties for single LDO regulator.
properties:
regulator-name:
pattern: "^ldo[1-4]$"
description:
should be "ldo1", ..., "ldo4"
unevaluatedProperties: false
"^buck[1-7]$":
type: object
$ref: regulator.yaml#
description:
Properties for single BUCK regulator.
properties:
regulator-name:
pattern: "^buck[1-7]$"
description:
should be "buck1", ..., "buck7"
nxp,ilim-ma:
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 2100
maximum: 4500
description:
BUCK regulators current limit in mA.
Listed current limits in mA are,
2100 (default)
2600
3000
4500
nxp,phase-shift:
$ref: "/schemas/types.yaml#/definitions/uint32"
minimum: 45
maximum: 0
description:
BUCK regulators phase shift control in degrees.
Listed phase shift control values in degrees are,
45
90
135
180
225
270
315
0 (default)
unevaluatedProperties: false
"^vsnvs$":
type: object
$ref: regulator.yaml#
description:
Properties for single VSNVS regulator.
properties:
regulator-name:
pattern: "^vsnvs$"
description:
should be "vsnvs"
unevaluatedProperties: false
additionalProperties: false
required:
- compatible
- reg
- regulators
additionalProperties: false
examples:
- |
i2c1 {
#address-cells = <1>;
#size-cells = <0>;
pmic@8 {
compatible = "nxp,pf8x00";
reg = <0x08>;
regulators {
reg_ldo1: ldo1 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <5000000>;
regulator-min-microvolt = <1500000>;
};
reg_ldo2: ldo2 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <5000000>;
regulator-min-microvolt = <1500000>;
};
reg_ldo3: ldo3 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <5000000>;
regulator-min-microvolt = <1500000>;
};
reg_ldo4: ldo4 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <5000000>;
regulator-min-microvolt = <1500000>;
};
reg_buck1: buck1 {
nxp,ilim-ma = <4500>;
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <1800000>;
regulator-min-microvolt = <400000>;
};
reg_buck2: buck2 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <1800000>;
regulator-min-microvolt = <400000>;
};
reg_buck3: buck3 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <1800000>;
regulator-min-microvolt = <400000>;
};
reg_buck4: buck4 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <1800000>;
regulator-min-microvolt = <400000>;
};
reg_buck5: buck5 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <1800000>;
regulator-min-microvolt = <400000>;
};
reg_buck6: buck6 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <1800000>;
regulator-min-microvolt = <400000>;
};
reg_buck7: buck7 {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <3300000>;
regulator-min-microvolt = <3300000>;
};
reg_vsnvs: vsnvs {
regulator-always-on;
regulator-boot-on;
regulator-max-microvolt = <3300000>;
regulator-min-microvolt = <1800000>;
};
};
};
};
......@@ -26,10 +26,13 @@ Supported regulator node names:
PM8009: smps1 - smps2, ldo1 - ldo7
PM8150: smps1 - smps10, ldo1 - ldo18
PM8150L: smps1 - smps8, ldo1 - ldo11, bob, flash, rgb
PM8350: smps1 - smps12, ldo1 - ldo10,
PM8350C: smps1 - smps10, ldo1 - ldo13, bob
PM8998: smps1 - smps13, ldo1 - ldo28, lvs1 - lvs2
PMI8998: bob
PM6150: smps1 - smps5, ldo1 - ldo19
PM6150L: smps1 - smps8, ldo1 - ldo11, bob
PMX55: smps1 - smps7, ldo1 - ldo16
========================
First Level Nodes - PMIC
......@@ -43,10 +46,13 @@ First Level Nodes - PMIC
"qcom,pm8009-rpmh-regulators"
"qcom,pm8150-rpmh-regulators"
"qcom,pm8150l-rpmh-regulators"
"qcom,pm8350-rpmh-regulators"
"qcom,pm8350c-rpmh-regulators"
"qcom,pm8998-rpmh-regulators"
"qcom,pmi8998-rpmh-regulators"
"qcom,pm6150-rpmh-regulators"
"qcom,pm6150l-rpmh-regulators"
"qcom,pmx55-rpmh-regulators"
- qcom,pmic-id
Usage: required
......
......@@ -105,6 +105,54 @@ patternProperties:
PMIC hardware state machine.
type: boolean
# Setups where regulator (especially the buck8) output voltage is scaled
# by adding external connection where some other regulator output is
# connected to feedback-pin (over suitable resistors) is getting popular
# amongst users of BD71837. (This allows for example scaling down the
# buck8 voltages to suit lover GPU voltages for projects where buck8 is
# (ab)used to supply power for GPU.
#
# So we allow describing this external connection from DT and scale the
# voltages accordingly. This is what the connection should look like:
#
# |---------------|
# | buck 8 |-------+----->Vout
# | | |
# |---------------| |
# | |
# | |
# +-------+--R2----+
# |
# R1
# |
# V FB-pull-up
#
# Here the buck output is sifted according to formula:
#
# Vout_o = Vo - (Vpu - Vo)*R2/R1
# Linear_step = step_orig*(R1+R2)/R1
#
# where:
# Vout_o is adjusted voltage output at vsel reg value 0
# Vo is original voltage output at vsel reg value 0
# Vpu is the pull-up voltage V FB-pull-up in the picture
# R1 and R2 are resistor values.
rohm,fb-pull-up-microvolt:
description:
Feedback-pin has pull-up connection to adjust voltage range. This is
the used pull-up voltage before R1.
rohm,feedback-pull-up-r1-ohms:
description:
Feedback-pin has pull-up connection to adjust voltage range. This is
the used R1 resistor.
rohm,feedback-pull-up-r2-ohms:
description:
Feedback-pin has pull-up connection to adjust voltage range. This is
the used R2 resistor.
required:
- regulator-name
......
......@@ -99,6 +99,55 @@ patternProperties:
Enable/Disable control of this regulator must be left to the
PMIC hardware state machine.
type: boolean
# Setups where regulator (especially the buck8) output voltage is scaled
# by adding external connection where some other regulator output is
# connected to feedback-pin (over suitable resistors) is getting popular
# amongst users of BD71837. (This allows for example scaling down the
# buck8 voltages to suit lover GPU voltages for projects where buck8 is
# (ab)used to supply power for GPU.
#
# So we allow describing this external connection from DT and scale the
# voltages accordingly. This is what the connection should look like:
#
# |---------------|
# | buck 8 |-------+----->Vout
# | | |
# |---------------| |
# | |
# | |
# +-------+--R2----+
# |
# R1
# |
# V FB-pull-up
#
# Here the buck output is sifted according to formula:
#
# Vout_o = Vo - (Vpu - Vo)*R2/R1
# Linear_step = step_orig*(R1+R2)/R1
#
# where:
# Vout_o is adjusted voltage output at vsel reg value 0
# Vo is original voltage output at vsel reg value 0
# Vpu is the pull-up voltage V FB-pull-up in the picture
# R1 and R2 are resistor values.
rohm,fb-pull-up-microvolt:
description:
Feedback-pin has pull-up connection to adjust voltage range. This is
the used pull-up voltage before R1.
rohm,feedback-pull-up-r1-ohms:
description:
Feedback-pin has pull-up connection to adjust voltage range. This is
the used R1 resistor.
rohm,feedback-pull-up-r2-ohms:
description:
Feedback-pin has pull-up connection to adjust voltage range. This is
the used R2 resistor.
required:
- regulator-name
......
......@@ -5138,6 +5138,7 @@ S: Supported
W: http://www.dialog-semiconductor.com/products
F: Documentation/devicetree/bindings/input/da90??-onkey.txt
F: Documentation/devicetree/bindings/mfd/da90*.txt
F: Documentation/devicetree/bindings/regulator/dlg,da9*.yaml
F: Documentation/devicetree/bindings/regulator/da92*.txt
F: Documentation/devicetree/bindings/regulator/slg51000.txt
F: Documentation/devicetree/bindings/sound/da[79]*.txt
......@@ -5162,6 +5163,7 @@ F: drivers/rtc/rtc-da90??.c
F: drivers/thermal/da90??-thermal.c
F: drivers/video/backlight/da90??_bl.c
F: drivers/watchdog/da90??_wdt.c
F: include/dt-bindings/regulator/dlg,da9*-regulator.h
F: include/linux/mfd/da903x.h
F: include/linux/mfd/da9052/
F: include/linux/mfd/da9055/
......@@ -12666,6 +12668,12 @@ S: Maintained
F: Documentation/devicetree/bindings/display/imx/nxp,imx8mq-dcss.yaml
F: drivers/gpu/drm/imx/dcss/
NXP PF8100/PF8121A/PF8200 PMIC REGULATOR DEVICE DRIVER
M: Jagan Teki <jagan@amarulasolutions.com>
S: Maintained
F: Documentation/devicetree/bindings/regulator/nxp,pf8x00-regulator.yaml
F: drivers/regulator/pf8x00-regulator.c
NXP PTN5150A CC LOGIC AND EXTCON DRIVER
M: Krzysztof Kozlowski <krzk@kernel.org>
L: linux-kernel@vger.kernel.org
......
......@@ -4,7 +4,7 @@ scmi-driver-y = driver.o notify.o
scmi-transport-y = shmem.o
scmi-transport-$(CONFIG_MAILBOX) += mailbox.o
scmi-transport-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smc.o
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o
scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \
$(scmi-transport-y)
obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o
......
......@@ -169,6 +169,7 @@ DECLARE_SCMI_REGISTER_UNREGISTER(perf);
DECLARE_SCMI_REGISTER_UNREGISTER(power);
DECLARE_SCMI_REGISTER_UNREGISTER(reset);
DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
DECLARE_SCMI_REGISTER_UNREGISTER(voltage);
DECLARE_SCMI_REGISTER_UNREGISTER(system);
#define DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(id, name) \
......
......@@ -743,6 +743,7 @@ static struct scmi_prot_devnames devnames[] = {
{ SCMI_PROTOCOL_CLOCK, { "clocks" },},
{ SCMI_PROTOCOL_SENSOR, { "hwmon" },},
{ SCMI_PROTOCOL_RESET, { "reset" },},
{ SCMI_PROTOCOL_VOLTAGE, { "regulator" },},
};
static inline void
......@@ -946,6 +947,7 @@ static int __init scmi_driver_init(void)
scmi_power_register();
scmi_reset_register();
scmi_sensors_register();
scmi_voltage_register();
scmi_system_register();
return platform_driver_register(&scmi_driver);
......@@ -961,6 +963,7 @@ static void __exit scmi_driver_exit(void)
scmi_power_unregister();
scmi_reset_unregister();
scmi_sensors_unregister();
scmi_voltage_unregister();
scmi_system_unregister();
platform_driver_unregister(&scmi_driver);
......
// SPDX-License-Identifier: GPL-2.0
/*
* System Control and Management Interface (SCMI) Voltage Protocol
*
* Copyright (C) 2020 ARM Ltd.
*/
#include <linux/scmi_protocol.h>
#include "common.h"
#define VOLTAGE_DOMS_NUM_MASK GENMASK(15, 0)
#define REMAINING_LEVELS_MASK GENMASK(31, 16)
#define RETURNED_LEVELS_MASK GENMASK(11, 0)
enum scmi_voltage_protocol_cmd {
VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
VOLTAGE_DESCRIBE_LEVELS = 0x4,
VOLTAGE_CONFIG_SET = 0x5,
VOLTAGE_CONFIG_GET = 0x6,
VOLTAGE_LEVEL_SET = 0x7,
VOLTAGE_LEVEL_GET = 0x8,
};
#define NUM_VOLTAGE_DOMAINS(x) ((u16)(FIELD_GET(VOLTAGE_DOMS_NUM_MASK, (x))))
struct scmi_msg_resp_domain_attributes {
__le32 attr;
u8 name[SCMI_MAX_STR_SIZE];
};
struct scmi_msg_cmd_describe_levels {
__le32 domain_id;
__le32 level_index;
};
struct scmi_msg_resp_describe_levels {
__le32 flags;
#define NUM_REMAINING_LEVELS(f) ((u16)(FIELD_GET(REMAINING_LEVELS_MASK, (f))))
#define NUM_RETURNED_LEVELS(f) ((u16)(FIELD_GET(RETURNED_LEVELS_MASK, (f))))
#define SUPPORTS_SEGMENTED_LEVELS(f) ((f) & BIT(12))
__le32 voltage[];
};
struct scmi_msg_cmd_config_set {
__le32 domain_id;
__le32 config;
};
struct scmi_msg_cmd_level_set {
__le32 domain_id;
__le32 flags;
__le32 voltage_level;
};
struct voltage_info {
unsigned int version;
unsigned int num_domains;
struct scmi_voltage_info *domains;
};
static int scmi_protocol_attributes_get(const struct scmi_handle *handle,
struct voltage_info *vinfo)
{
int ret;
struct scmi_xfer *t;
ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES,
SCMI_PROTOCOL_VOLTAGE, 0, sizeof(__le32), &t);
if (ret)
return ret;
ret = scmi_do_xfer(handle, t);
if (!ret)
vinfo->num_domains =
NUM_VOLTAGE_DOMAINS(get_unaligned_le32(t->rx.buf));
scmi_xfer_put(handle, t);
return ret;
}
static int scmi_init_voltage_levels(struct device *dev,
struct scmi_voltage_info *v,
u32 num_returned, u32 num_remaining,
bool segmented)
{
u32 num_levels;
num_levels = num_returned + num_remaining;
/*
* segmented levels entries are represented by a single triplet
* returned all in one go.
*/
if (!num_levels ||
(segmented && (num_remaining || num_returned != 3))) {
dev_err(dev,
"Invalid level descriptor(%d/%d/%d) for voltage dom %d\n",
num_levels, num_returned, num_remaining, v->id);
return -EINVAL;
}
v->levels_uv = devm_kcalloc(dev, num_levels, sizeof(u32), GFP_KERNEL);
if (!v->levels_uv)
return -ENOMEM;
v->num_levels = num_levels;
v->segmented = segmented;
return 0;
}
static int scmi_voltage_descriptors_get(const struct scmi_handle *handle,
struct voltage_info *vinfo)
{
int ret, dom;
struct scmi_xfer *td, *tl;
struct device *dev = handle->dev;
struct scmi_msg_resp_domain_attributes *resp_dom;
struct scmi_msg_resp_describe_levels *resp_levels;
ret = scmi_xfer_get_init(handle, VOLTAGE_DOMAIN_ATTRIBUTES,
SCMI_PROTOCOL_VOLTAGE, sizeof(__le32),
sizeof(*resp_dom), &td);
if (ret)
return ret;
resp_dom = td->rx.buf;
ret = scmi_xfer_get_init(handle, VOLTAGE_DESCRIBE_LEVELS,
SCMI_PROTOCOL_VOLTAGE, sizeof(__le64), 0, &tl);
if (ret)
goto outd;
resp_levels = tl->rx.buf;
for (dom = 0; dom < vinfo->num_domains; dom++) {
u32 desc_index = 0;
u16 num_returned = 0, num_remaining = 0;
struct scmi_msg_cmd_describe_levels *cmd;
struct scmi_voltage_info *v;
/* Retrieve domain attributes at first ... */
put_unaligned_le32(dom, td->tx.buf);
ret = scmi_do_xfer(handle, td);
/* Skip domain on comms error */
if (ret)
continue;
v = vinfo->domains + dom;
v->id = dom;
v->attributes = le32_to_cpu(resp_dom->attr);
strlcpy(v->name, resp_dom->name, SCMI_MAX_STR_SIZE);
cmd = tl->tx.buf;
/* ...then retrieve domain levels descriptions */
do {
u32 flags;
int cnt;
cmd->domain_id = cpu_to_le32(v->id);
cmd->level_index = desc_index;
ret = scmi_do_xfer(handle, tl);
if (ret)
break;
flags = le32_to_cpu(resp_levels->flags);
num_returned = NUM_RETURNED_LEVELS(flags);
num_remaining = NUM_REMAINING_LEVELS(flags);
/* Allocate space for num_levels if not already done */
if (!v->num_levels) {
ret = scmi_init_voltage_levels(dev, v,
num_returned,
num_remaining,
SUPPORTS_SEGMENTED_LEVELS(flags));
if (ret)
break;
}
if (desc_index + num_returned > v->num_levels) {
dev_err(handle->dev,
"No. of voltage levels can't exceed %d\n",
v->num_levels);
ret = -EINVAL;
break;
}
for (cnt = 0; cnt < num_returned; cnt++) {
s32 val;
val =
(s32)le32_to_cpu(resp_levels->voltage[cnt]);
v->levels_uv[desc_index + cnt] = val;
if (val < 0)
v->negative_volts_allowed = true;
}
desc_index += num_returned;
scmi_reset_rx_to_maxsz(handle, tl);
/* check both to avoid infinite loop due to buggy fw */
} while (num_returned && num_remaining);
if (ret) {
v->num_levels = 0;
devm_kfree(dev, v->levels_uv);
}
scmi_reset_rx_to_maxsz(handle, td);
}
scmi_xfer_put(handle, tl);
outd:
scmi_xfer_put(handle, td);
return ret;
}
static int __scmi_voltage_get_u32(const struct scmi_handle *handle,
u8 cmd_id, u32 domain_id, u32 *value)
{
int ret;
struct scmi_xfer *t;
struct voltage_info *vinfo = handle->voltage_priv;
if (domain_id >= vinfo->num_domains)
return -EINVAL;
ret = scmi_xfer_get_init(handle, cmd_id,
SCMI_PROTOCOL_VOLTAGE,
sizeof(__le32), 0, &t);
if (ret)
return ret;
put_unaligned_le32(domain_id, t->tx.buf);
ret = scmi_do_xfer(handle, t);
if (!ret)
*value = get_unaligned_le32(t->rx.buf);
scmi_xfer_put(handle, t);
return ret;
}
static int scmi_voltage_config_set(const struct scmi_handle *handle,
u32 domain_id, u32 config)
{
int ret;
struct scmi_xfer *t;
struct voltage_info *vinfo = handle->voltage_priv;
struct scmi_msg_cmd_config_set *cmd;
if (domain_id >= vinfo->num_domains)
return -EINVAL;
ret = scmi_xfer_get_init(handle, VOLTAGE_CONFIG_SET,
SCMI_PROTOCOL_VOLTAGE,
sizeof(*cmd), 0, &t);
if (ret)
return ret;
cmd = t->tx.buf;
cmd->domain_id = cpu_to_le32(domain_id);
cmd->config = cpu_to_le32(config & GENMASK(3, 0));
ret = scmi_do_xfer(handle, t);
scmi_xfer_put(handle, t);
return ret;
}
static int scmi_voltage_config_get(const struct scmi_handle *handle,
u32 domain_id, u32 *config)
{
return __scmi_voltage_get_u32(handle, VOLTAGE_CONFIG_GET,
domain_id, config);
}
static int scmi_voltage_level_set(const struct scmi_handle *handle,
u32 domain_id, u32 flags, s32 volt_uV)
{
int ret;
struct scmi_xfer *t;
struct voltage_info *vinfo = handle->voltage_priv;
struct scmi_msg_cmd_level_set *cmd;
if (domain_id >= vinfo->num_domains)
return -EINVAL;
ret = scmi_xfer_get_init(handle, VOLTAGE_LEVEL_SET,
SCMI_PROTOCOL_VOLTAGE,
sizeof(*cmd), 0, &t);
if (ret)
return ret;
cmd = t->tx.buf;
cmd->domain_id = cpu_to_le32(domain_id);
cmd->flags = cpu_to_le32(flags);
cmd->voltage_level = cpu_to_le32(volt_uV);
ret = scmi_do_xfer(handle, t);
scmi_xfer_put(handle, t);
return ret;
}
static int scmi_voltage_level_get(const struct scmi_handle *handle,
u32 domain_id, s32 *volt_uV)
{
return __scmi_voltage_get_u32(handle, VOLTAGE_LEVEL_GET,
domain_id, (u32 *)volt_uV);
}
static const struct scmi_voltage_info * __must_check
scmi_voltage_info_get(const struct scmi_handle *handle, u32 domain_id)
{
struct voltage_info *vinfo = handle->voltage_priv;
if (domain_id >= vinfo->num_domains ||
!vinfo->domains[domain_id].num_levels)
return NULL;
return vinfo->domains + domain_id;
}
static int scmi_voltage_domains_num_get(const struct scmi_handle *handle)
{
struct voltage_info *vinfo = handle->voltage_priv;
return vinfo->num_domains;
}
static struct scmi_voltage_ops voltage_ops = {
.num_domains_get = scmi_voltage_domains_num_get,
.info_get = scmi_voltage_info_get,
.config_set = scmi_voltage_config_set,
.config_get = scmi_voltage_config_get,
.level_set = scmi_voltage_level_set,
.level_get = scmi_voltage_level_get,
};
static int scmi_voltage_protocol_init(struct scmi_handle *handle)
{
int ret;
u32 version;
struct voltage_info *vinfo;
ret = scmi_version_get(handle, SCMI_PROTOCOL_VOLTAGE, &version);
if (ret)
return ret;
dev_dbg(handle->dev, "Voltage Version %d.%d\n",
PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version));
vinfo = devm_kzalloc(handle->dev, sizeof(*vinfo), GFP_KERNEL);
if (!vinfo)
return -ENOMEM;
vinfo->version = version;
ret = scmi_protocol_attributes_get(handle, vinfo);
if (ret)
return ret;
if (vinfo->num_domains) {
vinfo->domains = devm_kcalloc(handle->dev, vinfo->num_domains,
sizeof(*vinfo->domains),
GFP_KERNEL);
if (!vinfo->domains)
return -ENOMEM;
ret = scmi_voltage_descriptors_get(handle, vinfo);
if (ret)
return ret;
} else {
dev_warn(handle->dev, "No Voltage domains found.\n");
}
handle->voltage_ops = &voltage_ops;
handle->voltage_priv = vinfo;
return 0;
}
DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_VOLTAGE, voltage)
......@@ -155,6 +155,15 @@ config REGULATOR_ARIZONA_MICSUPP
and Wolfson Microelectronic Arizona codecs
devices.
config REGULATOR_ARM_SCMI
tristate "SCMI based regulator driver"
depends on ARM_SCMI_PROTOCOL && OF
help
This adds the regulator driver support for ARM platforms using SCMI
protocol for device voltage management.
This driver uses SCMI Message Protocol driver to interact with the
firmware providing the device Voltage functionality.
config REGULATOR_AS3711
tristate "AS3711 PMIC"
depends on MFD_AS3711
......@@ -303,6 +312,26 @@ config REGULATOR_DA9063
This driver can also be built as a module. If so, the module
will be called da9063-regulator.
config REGULATOR_DA9121
tristate "Dialog Semiconductor DA9121/DA9122/DA9220/DA9217/DA9130/DA9131/DA9132 regulator"
depends on I2C && OF
select REGMAP_I2C
help
Say y here to support for the Dialog Semiconductor DA9121. The
DA9121 is a single channel dual-phase buck converter controlled
through an I2C interface.
DA9121 Single-channel dual-phase 10A buck converter
DA9130 Single-channel dual-phase 10A buck converter (Automotive)
DA9217 Single-channel dual-phase 6A buck converter
DA9122 Dual-channel single-phase 5A buck converter
DA9131 Dual-channel single-phase 5A buck converter (Automotive)
DA9220 Dual-channel single-phase 3A buck converter
DA9132 Dual-channel single-phase 3A buck converter (Automotive)
This driver can also be built as a module. If so, the module
will be called da9121-regulator.
config REGULATOR_DA9210
tristate "Dialog Semiconductor DA9210 regulator"
depends on I2C
......@@ -791,9 +820,17 @@ config REGULATOR_PCF50633
Say Y here to support the voltage regulators and converters
on PCF50633
config REGULATOR_PF8X00
tristate "NXP PF8100/PF8121A/PF8200 regulator driver"
depends on I2C && OF
select REGMAP_I2C
help
Say y here to support the regulators found on the NXP
PF8100/PF8121A/PF8200 PMIC.
config REGULATOR_PFUZE100
tristate "Freescale PFUZE100/200/3000/3001 regulator driver"
depends on I2C
depends on I2C && OF
select REGMAP_I2C
help
Say y here to support the regulators found on the Freescale
......@@ -843,7 +880,7 @@ config REGULATOR_QCOM_RPM
config REGULATOR_QCOM_RPMH
tristate "Qualcomm Technologies, Inc. RPMh regulator driver"
depends on QCOM_RPMH || COMPILE_TEST
depends on QCOM_RPMH || (QCOM_RPMH=n && COMPILE_TEST)
help
This driver supports control of PMIC regulators via the RPMh hardware
block found on Qualcomm Technologies Inc. SoCs. RPMh regulator
......
......@@ -24,6 +24,7 @@ obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_ARIZONA_LDO1) += arizona-ldo1.o
obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o
obj-$(CONFIG_REGULATOR_ARM_SCMI) += scmi-regulator.o
obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
......@@ -38,6 +39,7 @@ obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
obj-$(CONFIG_REGULATOR_DA9062) += da9062-regulator.o
obj-$(CONFIG_REGULATOR_DA9063) += da9063-regulator.o
obj-$(CONFIG_REGULATOR_DA9121) += da9121-regulator.o
obj-$(CONFIG_REGULATOR_DA9210) += da9210-regulator.o
obj-$(CONFIG_REGULATOR_DA9211) += da9211-regulator.o
obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
......@@ -100,6 +102,7 @@ obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o
obj-$(CONFIG_REGULATOR_QCOM_USB_VBUS) += qcom_usb_vbus-regulator.o
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
obj-$(CONFIG_REGULATOR_PCA9450) += pca9450-regulator.o
obj-$(CONFIG_REGULATOR_PF8X00) += pf8x00-regulator.o
obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
obj-$(CONFIG_REGULATOR_PV88060) += pv88060-regulator.o
obj-$(CONFIG_REGULATOR_PV88080) += pv88080-regulator.o
......
......@@ -455,7 +455,8 @@ static int as3722_sd_set_mode(struct regulator_dev *rdev,
switch (mode) {
case REGULATOR_MODE_FAST:
val = as3722_reg_lookup[id].mode_mask;
case REGULATOR_MODE_NORMAL: /* fall down */
fallthrough;
case REGULATOR_MODE_NORMAL:
break;
default:
return -EINVAL;
......
......@@ -594,7 +594,7 @@ static const struct regulator_desc axp22x_regulators[] = {
AXP22X_DLDO1_V_OUT, AXP22X_DLDO1_V_OUT_MASK,
AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO1_MASK),
AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
AXP22X_DLDO2_V_OUT, AXP22X_PWR_OUT_DLDO2_MASK,
AXP22X_DLDO2_V_OUT, AXP22X_DLDO2_V_OUT_MASK,
AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DLDO2_MASK),
AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
AXP22X_DLDO3_V_OUT, AXP22X_DLDO3_V_OUT_MASK,
......
......@@ -1323,13 +1323,142 @@ static void mark_hw_controlled(struct device *dev, struct device_node *np,
dev_warn(dev, "Bad regulator node\n");
}
static int get_hw_controlled_regulators(struct device *dev,
struct bd718xx_regulator_data *reg_data,
unsigned int num_reg_data, int *info)
/*
* Setups where regulator (especially the buck8) output voltage is scaled
* by adding external connection where some other regulator output is connected
* to feedback-pin (over suitable resistors) is getting popular amongst users
* of BD71837. (This allows for example scaling down the buck8 voltages to suit
* lover GPU voltages for projects where buck8 is (ab)used to supply power
* for GPU. Additionally some setups do allow DVS for buck8 but as this do
* produce voltage spikes the HW must be evaluated to be able to survive this
* - hence I keep the DVS disabled for non DVS bucks by default. I don't want
* to help you burn your proto board)
*
* So we allow describing this external connection from DT and scale the
* voltages accordingly. This is what the connection should look like:
*
* |------------|
* | buck 8 |-------+----->Vout
* | | |
* |------------| |
* | FB pin |
* | |
* +-------+--R2---+
* |
* R1
* |
* V FB-pull-up
*
* Here the buck output is sifted according to formula:
*
* Vout_o = Vo - (Vpu - Vo)*R2/R1
* Linear_step = step_orig*(R1+R2)/R1
*
* where:
* Vout_o is adjusted voltage output at vsel reg value 0
* Vo is original voltage output at vsel reg value 0
* Vpu is the pull-up voltage V FB-pull-up in the picture
* R1 and R2 are resistor values.
*
* As a real world example for buck8 and a specific GPU:
* VLDO = 1.6V (used as FB-pull-up)
* R1 = 1000ohms
* R2 = 150ohms
* VSEL 0x0 => 0.8V – (VLDO – 0.8) * R2 / R1 = 0.68V
* Linear Step = 10mV * (R1 + R2) / R1 = 11.5mV
*/
static int setup_feedback_loop(struct device *dev, struct device_node *np,
struct bd718xx_regulator_data *reg_data,
unsigned int num_reg_data, int fb_uv)
{
int i, r1, r2, ret;
/*
* We do adjust the values in the global desc based on DT settings.
* This may not be best approach as it can cause problems if more than
* one PMIC is controlled from same processor. I don't see such use-case
* for BD718x7 now - so we spare some bits.
*
* If this will point out to be a problem - then we can allocate new
* bd718xx_regulator_data array at probe and just use the global
* array as a template where we copy initial values. Then we can
* use allocated descs for regultor registration and do IC specific
* modifications to this copy while leaving other PMICs untouched. But
* that means allocating new array for each PMIC - and currently I see
* no need for that.
*/
for (i = 0; i < num_reg_data; i++) {
struct regulator_desc *desc = &reg_data[i].desc;
int j;
if (!of_node_name_eq(np, desc->of_match))
continue;
pr_info("Looking at node '%s'\n", desc->of_match);
/* The feedback loop connection does not make sense for LDOs */
if (desc->id >= BD718XX_LDO1)
return -EINVAL;
ret = of_property_read_u32(np, "rohm,feedback-pull-up-r1-ohms",
&r1);
if (ret)
return ret;
if (!r1)
return -EINVAL;
ret = of_property_read_u32(np, "rohm,feedback-pull-up-r2-ohms",
&r2);
if (ret)
return ret;
if (desc->n_linear_ranges && desc->linear_ranges) {
struct linear_range *new;
new = devm_kzalloc(dev, desc->n_linear_ranges *
sizeof(struct linear_range),
GFP_KERNEL);
if (!new)
return -ENOMEM;
for (j = 0; j < desc->n_linear_ranges; j++) {
int min = desc->linear_ranges[j].min;
int step = desc->linear_ranges[j].step;
min -= (fb_uv - min)*r2/r1;
step = step * (r1 + r2);
step /= r1;
new[j].min = min;
new[j].step = step;
dev_dbg(dev, "%s: old range min %d, step %d\n",
desc->name, desc->linear_ranges[j].min,
desc->linear_ranges[j].step);
dev_dbg(dev, "new range min %d, step %d\n", min,
step);
}
desc->linear_ranges = new;
}
dev_dbg(dev, "regulator '%s' has FB pull-up configured\n",
desc->name);
return 0;
}
return -ENODEV;
}
static int get_special_regulators(struct device *dev,
struct bd718xx_regulator_data *reg_data,
unsigned int num_reg_data, int *info)
{
int ret;
struct device_node *np;
struct device_node *nproot = dev->of_node;
const char *prop = "rohm,no-regulator-enable-control";
int uv;
*info = 0;
......@@ -1338,13 +1467,32 @@ static int get_hw_controlled_regulators(struct device *dev,
dev_err(dev, "failed to find regulators node\n");
return -ENODEV;
}
for_each_child_of_node(nproot, np)
if (of_property_read_bool(np, prop))
for_each_child_of_node(nproot, np) {
if (of_property_read_bool(np, "rohm,no-regulator-enable-control"))
mark_hw_controlled(dev, np, reg_data, num_reg_data,
info);
ret = of_property_read_u32(np, "rohm,fb-pull-up-microvolt",
&uv);
if (ret) {
if (ret == -EINVAL)
continue;
else
goto err_out;
}
ret = setup_feedback_loop(dev, np, reg_data, num_reg_data, uv);
if (ret)
goto err_out;
}
of_node_put(nproot);
return 0;
err_out:
of_node_put(np);
of_node_put(nproot);
return ret;
}
static int bd718xx_probe(struct platform_device *pdev)
......@@ -1432,8 +1580,10 @@ static int bd718xx_probe(struct platform_device *pdev)
* be affected by PMIC state machine - Eg. regulator is likely to stay
* on even in SUSPEND
*/
get_hw_controlled_regulators(pdev->dev.parent, reg_data, num_reg_data,
err = get_special_regulators(pdev->dev.parent, reg_data, num_reg_data,
&omit_enable);
if (err)
return err;
for (i = 0; i < num_reg_data; i++) {
......
......@@ -2958,6 +2958,8 @@ static int _regulator_list_voltage(struct regulator_dev *rdev,
if (ops->list_voltage) {
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < rdev->desc->linear_min_sel)
return 0;
if (lock)
regulator_lock(rdev);
ret = ops->list_voltage(rdev, selector);
......@@ -3109,6 +3111,8 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < rdev->desc->linear_min_sel)
return 0;
if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap)
return -EOPNOTSUPP;
......@@ -4030,6 +4034,12 @@ int regulator_set_voltage_time(struct regulator *regulator,
for (i = 0; i < rdev->desc->n_voltages; i++) {
/* We only look for exact voltage matches here */
if (i < rdev->desc->linear_min_sel)
continue;
if (old_sel >= 0 && new_sel >= 0)
break;
voltage = regulator_list_voltage(regulator, i);
if (voltage < 0)
return -EINVAL;
......@@ -5305,6 +5315,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
/* FIXME: this currently triggers a chicken-and-egg problem
* when creating -SUPPLY symlink in sysfs to a regulator
* that is just being created */
rdev_dbg(rdev, "will resolve supply early: %s\n",
rdev->supply_name);
ret = regulator_resolve_supply(rdev);
if (!ret)
ret = set_machine_constraints(rdev);
......@@ -5537,7 +5549,7 @@ void regulator_set_drvdata(struct regulator *regulator, void *data)
EXPORT_SYMBOL_GPL(regulator_set_drvdata);
/**
* regulator_get_id - get regulator ID
* rdev_get_id - get regulator ID
* @rdev: regulator
*/
int rdev_get_id(struct regulator_dev *rdev)
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* DA9121 Single-channel dual-phase 10A buck converter
* DA9130 Single-channel dual-phase 10A buck converter (Automotive)
* DA9217 Single-channel dual-phase 6A buck converter
* DA9122 Dual-channel single-phase 5A buck converter
* DA9131 Dual-channel single-phase 5A buck converter (Automotive)
* DA9220 Dual-channel single-phase 3A buck converter
* DA9132 Dual-channel single-phase 3A buck converter (Automotive)
*
* Copyright (C) 2020 Dialog Semiconductor
*
* Authors: Steve Twiss, Dialog Semiconductor
* Adam Ward, Dialog Semiconductor
*/
#ifndef __DA9121_REGISTERS_H__
#define __DA9121_REGISTERS_H__
/* Values for: DA9121_REG_BUCK_BUCKx_4 registers, fields CHx_y_MODE
* DA9121_REG_BUCK_BUCKx_7 registers, fields CHx_RIPPLE_CANCEL
*/
#include <dt-bindings/regulator/dlg,da9121-regulator.h>
enum da9121_variant {
DA9121_TYPE_DA9121_DA9130,
DA9121_TYPE_DA9220_DA9132,
DA9121_TYPE_DA9122_DA9131,
DA9121_TYPE_DA9217
};
/* Minimum, maximum and default polling millisecond periods are provided
* here as an example. It is expected that any final implementation will
* include a modification of these settings to match the required
* application.
*/
#define DA9121_DEFAULT_POLLING_PERIOD_MS 3000
#define DA9121_MAX_POLLING_PERIOD_MS 10000
#define DA9121_MIN_POLLING_PERIOD_MS 1000
/* Registers */
#define DA9121_REG_SYS_STATUS_0 0x01
#define DA9121_REG_SYS_STATUS_1 0x02
#define DA9121_REG_SYS_STATUS_2 0x03
#define DA9121_REG_SYS_EVENT_0 0x04
#define DA9121_REG_SYS_EVENT_1 0x05
#define DA9121_REG_SYS_EVENT_2 0x06
#define DA9121_REG_SYS_MASK_0 0x07
#define DA9121_REG_SYS_MASK_1 0x08
#define DA9121_REG_SYS_MASK_2 0x09
#define DA9121_REG_SYS_MASK_3 0x0A
#define DA9121_REG_SYS_CONFIG_0 0x0B
#define DA9121_REG_SYS_CONFIG_1 0x0C
#define DA9121_REG_SYS_CONFIG_2 0x0D
#define DA9121_REG_SYS_CONFIG_3 0x0E
#define DA9121_REG_SYS_GPIO0_0 0x10
#define DA9121_REG_SYS_GPIO0_1 0x11
#define DA9121_REG_SYS_GPIO1_0 0x12
#define DA9121_REG_SYS_GPIO1_1 0x13
#define DA9121_REG_SYS_GPIO2_0 0x14
#define DA9121_REG_SYS_GPIO2_1 0x15
#define DA9121_REG_BUCK_BUCK1_0 0x20
#define DA9121_REG_BUCK_BUCK1_1 0x21
#define DA9121_REG_BUCK_BUCK1_2 0x22
#define DA9121_REG_BUCK_BUCK1_3 0x23
#define DA9121_REG_BUCK_BUCK1_4 0x24
#define DA9121_REG_BUCK_BUCK1_5 0x25
#define DA9121_REG_BUCK_BUCK1_6 0x26
#define DA9121_REG_BUCK_BUCK1_7 0x27
#define DA9xxx_REG_BUCK_BUCK2_0 0x28
#define DA9xxx_REG_BUCK_BUCK2_1 0x29
#define DA9xxx_REG_BUCK_BUCK2_2 0x2A
#define DA9xxx_REG_BUCK_BUCK2_3 0x2B
#define DA9xxx_REG_BUCK_BUCK2_4 0x2C
#define DA9xxx_REG_BUCK_BUCK2_5 0x2D
#define DA9xxx_REG_BUCK_BUCK2_6 0x2E
#define DA9xxx_REG_BUCK_BUCK2_7 0x2F
#define DA9121_REG_OTP_DEVICE_ID 0x48
#define DA9121_REG_OTP_VARIANT_ID 0x49
#define DA9121_REG_OTP_CUSTOMER_ID 0x4A
#define DA9121_REG_OTP_CONFIG_ID 0x4B
/* Register bits */
/* DA9121_REG_SYS_STATUS_0 */
#define DA9xxx_MASK_SYS_STATUS_0_SG BIT(2)
#define DA9121_MASK_SYS_STATUS_0_TEMP_CRIT BIT(1)
#define DA9121_MASK_SYS_STATUS_0_TEMP_WARN BIT(0)
/* DA9121_REG_SYS_STATUS_1 */
#define DA9xxx_MASK_SYS_STATUS_1_PG2 BIT(7)
#define DA9xxx_MASK_SYS_STATUS_1_OV2 BIT(6)
#define DA9xxx_MASK_SYS_STATUS_1_UV2 BIT(5)
#define DA9xxx_MASK_SYS_STATUS_1_OC2 BIT(4)
#define DA9121_MASK_SYS_STATUS_1_PG1 BIT(3)
#define DA9121_MASK_SYS_STATUS_1_OV1 BIT(2)
#define DA9121_MASK_SYS_STATUS_1_UV1 BIT(1)
#define DA9121_MASK_SYS_STATUS_1_OC1 BIT(0)
/* DA9121_REG_SYS_STATUS_2 */
#define DA9121_MASK_SYS_STATUS_2_GPIO2 BIT(2)
#define DA9121_MASK_SYS_STATUS_2_GPIO1 BIT(1)
#define DA9121_MASK_SYS_STATUS_2_GPIO0 BIT(0)
/* DA9121_REG_SYS_EVENT_0 */
#define DA9xxx_MASK_SYS_EVENT_0_E_SG BIT(2)
#define DA9121_MASK_SYS_EVENT_0_E_TEMP_CRIT BIT(1)
#define DA9121_MASK_SYS_EVENT_0_E_TEMP_WARN BIT(0)
/* DA9121_REG_SYS_EVENT_1 */
#define DA9xxx_MASK_SYS_EVENT_1_E_PG2 BIT(7)
#define DA9xxx_MASK_SYS_EVENT_1_E_OV2 BIT(6)
#define DA9xxx_MASK_SYS_EVENT_1_E_UV2 BIT(5)
#define DA9xxx_MASK_SYS_EVENT_1_E_OC2 BIT(4)
#define DA9121_MASK_SYS_EVENT_1_E_PG1 BIT(3)
#define DA9121_MASK_SYS_EVENT_1_E_OV1 BIT(2)
#define DA9121_MASK_SYS_EVENT_1_E_UV1 BIT(1)
#define DA9121_MASK_SYS_EVENT_1_E_OC1 BIT(0)
/* DA9121_REG_SYS_EVENT_2 */
#define DA9121_MASK_SYS_EVENT_2_E_GPIO2 BIT(2)
#define DA9121_MASK_SYS_EVENT_2_E_GPIO1 BIT(1)
#define DA9121_MASK_SYS_EVENT_2_E_GPIO0 BIT(0)
/* DA9121_REG_SYS_MASK_0 */
#define DA9xxx_MASK_SYS_MASK_0_M_SG BIT(2)
#define DA9121_MASK_SYS_MASK_0_M_TEMP_CRIT BIT(1)
#define DA9121_MASK_SYS_MASK_0_M_TEMP_WARN BIT(0)
/* DA9121_REG_SYS_MASK_1 */
#define DA9xxx_MASK_SYS_MASK_1_M_PG2 BIT(7)
#define DA9xxx_MASK_SYS_MASK_1_M_OV2 BIT(6)
#define DA9xxx_MASK_SYS_MASK_1_M_UV2 BIT(5)
#define DA9xxx_MASK_SYS_MASK_1_M_OC2 BIT(4)
#define DA9121_MASK_SYS_MASK_1_M_PG1 BIT(3)
#define DA9121_MASK_SYS_MASK_1_M_OV1 BIT(2)
#define DA9121_MASK_SYS_MASK_1_M_UV1 BIT(1)
#define DA9121_MASK_SYS_MASK_1_M_OC1 BIT(0)
/* DA9121_REG_SYS_MASK_2 */
#define DA9121_MASK_SYS_MASK_2_M_GPIO2 BIT(2)
#define DA9121_MASK_SYS_MASK_2_M_GPIO1 BIT(1)
#define DA9121_MASK_SYS_MASK_2_M_GPIO0 BIT(0)
/* DA9122_REG_SYS_MASK_3 */
#define DA9121_MASK_SYS_MASK_3_M_VR_HOT BIT(3)
#define DA9xxx_MASK_SYS_MASK_3_M_SG_STAT BIT(2)
#define DA9xxx_MASK_SYS_MASK_3_M_PG2_STAT BIT(1)
#define DA9121_MASK_SYS_MASK_3_M_PG1_STAT BIT(0)
/* DA9121_REG_SYS_CONFIG_0 */
#define DA9121_MASK_SYS_CONFIG_0_CH1_DIS_DLY 0xF0
#define DA9121_MASK_SYS_CONFIG_0_CH1_EN_DLY 0x0F
/* DA9xxx_REG_SYS_CONFIG_1 */
#define DA9xxx_MASK_SYS_CONFIG_1_CH2_DIS_DLY 0xF0
#define DA9xxx_MASK_SYS_CONFIG_1_CH2_EN_DLY 0x0F
/* DA9121_REG_SYS_CONFIG_2 */
#define DA9121_MASK_SYS_CONFIG_2_OC_LATCHOFF 0x60
#define DA9121_MASK_SYS_CONFIG_2_OC_DVC_MASK BIT(4)
#define DA9121_MASK_SYS_CONFIG_2_PG_DVC_MASK 0x0C
/* DA9121_REG_SYS_CONFIG_3 */
#define DA9121_MASK_SYS_CONFIG_3_OSC_TUNE 0X70
#define DA9121_MASK_SYS_CONFIG_3_I2C_TIMEOUT BIT(1)
/* DA9121_REG_SYS_GPIO0_0 */
#define DA9121_MASK_SYS_GPIO0_0_GPIO0_MODE 0X1E
#define DA9121_MASK_SYS_GPIO0_0_GPIO0_OBUF BIT(0)
/* DA9121_REG_SYS_GPIO0_1 */
#define DA9121_MASK_SYS_GPIO0_1_GPIO0_DEB_FALL BIT(7)
#define DA9121_MASK_SYS_GPIO0_1_GPIO0_DEB_RISE BIT(6)
#define DA9121_MASK_SYS_GPIO0_1_GPIO0_DEB 0x30
#define DA9121_MASK_SYS_GPIO0_1_GPIO0_PUPD BIT(3)
#define DA9121_MASK_SYS_GPIO0_1_GPIO0_POL BIT(2)
#define DA9121_MASK_SYS_GPIO0_1_GPIO0_TRIG 0x03
/* DA9121_REG_SYS_GPIO1_0 */
#define DA9121_MASK_SYS_GPIO1_0_GPIO1_MODE 0x1E
#define DA9121_MASK_SYS_GPIO1_0_GPIO1_OBUF BIT(0)
/* DA9121_REG_SYS_GPIO1_1 */
#define DA9121_MASK_SYS_GPIO1_1_GPIO1_DEB_FALL BIT(7)
#define DA9121_MASK_SYS_GPIO1_1_GPIO1_DEB_RISE BIT(6)
#define DA9121_MASK_SYS_GPIO1_1_GPIO1_DEB 0x30
#define DA9121_MASK_SYS_GPIO1_1_GPIO1_PUPD BIT(3)
#define DA9121_MASK_SYS_GPIO1_1_GPIO1_POL BIT(2)
#define DA9121_MASK_SYS_GPIO1_1_GPIO1_TRIG 0x03
/* DA9121_REG_SYS_GPIO2_0 */
#define DA9121_MASK_SYS_GPIO2_0_GPIO2_MODE 0x1E
#define DA9121_MASK_SYS_GPIO2_0_GPIO2_OBUF BIT(0)
/* DA9121_REG_SYS_GPIO2_1 */
#define DA9121_MASK_SYS_GPIO2_1_GPIO2_DEB_FALL BIT(7)
#define DA9121_MASK_SYS_GPIO2_1_GPIO2_DEB_RISE BIT(6)
#define DA9121_MASK_SYS_GPIO2_1_GPIO2_DEB 0x30
#define DA9121_MASK_SYS_GPIO2_1_GPIO2_PUPD BIT(3)
#define DA9121_MASK_SYS_GPIO2_1_GPIO2_POL BIT(2)
#define DA9121_MASK_SYS_GPIO2_1_GPIO2_TRIG 0x03
/* DA9121_REG_BUCK_BUCK1_0 / DA9xxx_REG_BUCK_BUCK2_0 */
#define DA9121_MASK_BUCK_BUCKx_0_CHx_SR_DVC_DWN 0x70
#define DA9121_MASK_BUCK_BUCKx_0_CHx_SR_DVC_UP 0x0E
#define DA9121_MASK_BUCK_BUCKx_0_CHx_EN BIT(0)
/* DA9121_REG_BUCK_BUCK1_1 / DA9xxx_REG_BUCK_BUCK2_1 */
#define DA9121_MASK_BUCK_BUCKx_1_CHx_SR_SHDN 0x70
#define DA9121_MASK_BUCK_BUCKx_1_CHx_SR_STARTUP 0x0E
#define DA9121_MASK_BUCK_BUCKx_1_CHx_PD_DIS BIT(0)
/* DA9121_REG_BUCK_BUCK1_2 / DA9xxx_REG_BUCK_BUCK2_2 */
#define DA9121_MASK_BUCK_BUCKx_2_CHx_ILIM 0x0F
/* DA9121_REG_BUCK_BUCK1_3 / DA9xxx_REG_BUCK_BUCK2_3 */
#define DA9121_MASK_BUCK_BUCKx_3_CHx_VMAX 0xFF
/* DA9121_REG_BUCK_BUCK1_4 / DA9xxx_REG_BUCK_BUCK2_4 */
#define DA9121_MASK_BUCK_BUCKx_4_CHx_VSEL BIT(4)
#define DA9121_MASK_BUCK_BUCKx_4_CHx_B_MODE 0x0C
#define DA9121_MASK_BUCK_BUCKx_4_CHx_A_MODE 0x03
/* DA9121_REG_BUCK_BUCK1_5 / DA9xxx_REG_BUCK_BUCK2_5 */
#define DA9121_MASK_BUCK_BUCKx_5_CHx_A_VOUT 0xFF
/* DA9121_REG_BUCK_BUCK1_6 / DA9xxx_REG_BUCK_BUCK2_6 */
#define DA9121_MASK_BUCK_BUCKx_6_CHx_B_VOUT 0xFF
/* DA9121_REG_BUCK_BUCK1_7 / DA9xxx_REG_BUCK_BUCK2_7 */
#define DA9xxx_MASK_BUCK_BUCKx_7_CHx_RIPPLE_CANCEL 0x03
/* DA9121_REG_OTP_DEVICE_ID */
#define DA9121_MASK_OTP_DEVICE_ID_DEV_ID 0xFF
#define DA9121_DEVICE_ID 0x05
/* DA9121_REG_OTP_VARIANT_ID */
#define DA9121_SHIFT_OTP_VARIANT_ID_MRC 4
#define DA9121_MASK_OTP_VARIANT_ID_MRC 0xF0
#define DA9121_SHIFT_OTP_VARIANT_ID_VRC 0
#define DA9121_MASK_OTP_VARIANT_ID_VRC 0x0F
#define DA9121_VARIANT_MRC_BASE 0x2
#define DA9121_VARIANT_VRC 0x1
#define DA9220_VARIANT_VRC 0x0
#define DA9122_VARIANT_VRC 0x2
#define DA9217_VARIANT_VRC 0x7
/* DA9121_REG_OTP_CUSTOMER_ID */
#define DA9121_MASK_OTP_CUSTOMER_ID_CUST_ID 0xFF
/* DA9121_REG_OTP_CONFIG_ID */
#define DA9121_MASK_OTP_CONFIG_ID_CONFIG_REV 0xFF
#endif /* __DA9121_REGISTERS_H__ */
......@@ -18,6 +18,8 @@
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_opp.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/fixed.h>
#include <linux/gpio/consumer.h>
......@@ -34,11 +36,13 @@ struct fixed_voltage_data {
struct regulator_dev *dev;
struct clk *enable_clock;
unsigned int clk_enable_counter;
unsigned int enable_counter;
int performance_state;
};
struct fixed_dev_type {
bool has_enable_clock;
bool has_performance_state;
};
static int reg_clock_enable(struct regulator_dev *rdev)
......@@ -50,7 +54,7 @@ static int reg_clock_enable(struct regulator_dev *rdev)
if (ret)
return ret;
priv->clk_enable_counter++;
priv->enable_counter++;
return ret;
}
......@@ -60,16 +64,41 @@ static int reg_clock_disable(struct regulator_dev *rdev)
struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
clk_disable_unprepare(priv->enable_clock);
priv->clk_enable_counter--;
priv->enable_counter--;
return 0;
}
static int reg_clock_is_enabled(struct regulator_dev *rdev)
static int reg_domain_enable(struct regulator_dev *rdev)
{
struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
struct device *dev = rdev->dev.parent;
int ret;
ret = dev_pm_genpd_set_performance_state(dev, priv->performance_state);
if (ret)
return ret;
return priv->clk_enable_counter > 0;
priv->enable_counter++;
return ret;
}
static int reg_domain_disable(struct regulator_dev *rdev)
{
struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
struct device *dev = rdev->dev.parent;
priv->enable_counter--;
return dev_pm_genpd_set_performance_state(dev, 0);
}
static int reg_is_enabled(struct regulator_dev *rdev)
{
struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
return priv->enable_counter > 0;
}
......@@ -129,7 +158,13 @@ static const struct regulator_ops fixed_voltage_ops = {
static const struct regulator_ops fixed_voltage_clkenabled_ops = {
.enable = reg_clock_enable,
.disable = reg_clock_disable,
.is_enabled = reg_clock_is_enabled,
.is_enabled = reg_is_enabled,
};
static const struct regulator_ops fixed_voltage_domain_ops = {
.enable = reg_domain_enable,
.disable = reg_domain_disable,
.is_enabled = reg_is_enabled,
};
static int reg_fixed_voltage_probe(struct platform_device *pdev)
......@@ -177,6 +212,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
dev_err(dev, "Can't get enable-clock from devicetree\n");
return -ENOENT;
}
} else if (drvtype && drvtype->has_performance_state) {
drvdata->desc.ops = &fixed_voltage_domain_ops;
drvdata->performance_state = of_get_required_opp_performance_state(dev->of_node, 0);
if (drvdata->performance_state < 0) {
dev_err(dev, "Can't get performance state from devicetree\n");
return drvdata->performance_state;
}
} else {
drvdata->desc.ops = &fixed_voltage_ops;
}
......@@ -260,6 +303,10 @@ static const struct fixed_dev_type fixed_clkenable_data = {
.has_enable_clock = true,
};
static const struct fixed_dev_type fixed_domain_data = {
.has_performance_state = true,
};
static const struct of_device_id fixed_of_match[] = {
{
.compatible = "regulator-fixed",
......@@ -269,6 +316,10 @@ static const struct of_device_id fixed_of_match[] = {
.compatible = "regulator-fixed-clock",
.data = &fixed_clkenable_data,
},
{
.compatible = "regulator-fixed-domain",
.data = &fixed_domain_data,
},
{
},
};
......
......@@ -649,6 +649,8 @@ int regulator_list_voltage_table(struct regulator_dev *rdev,
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < rdev->desc->linear_min_sel)
return 0;
return rdev->desc->volt_table[selector];
}
......
......@@ -892,7 +892,7 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
struct lp872x *lp;
struct lp872x_platform_data *pdata;
int ret;
const int lp872x_num_regulators[] = {
static const int lp872x_num_regulators[] = {
[LP8720] = LP8720_NUM_REGULATORS,
[LP8725] = LP8725_NUM_REGULATORS,
};
......
......@@ -269,3 +269,5 @@ module_exit(max14577_regulator_exit);
MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:max14577-regulator");
MODULE_ALIAS("platform:max77836-regulator");
......@@ -582,8 +582,8 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
/* update mc13892_vcam ops */
memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
sizeof(struct regulator_ops));
mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode;
mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode;
mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
......
......@@ -22,8 +22,9 @@
#define VDD_LOW_SEL 0x0D
#define VDD_HIGH_SEL 0x3F
#define MCP16502_FLT BIT(7)
#define MCP16502_ENS BIT(0)
#define MCP16502_FLT BIT(7)
#define MCP16502_DVSR GENMASK(3, 2)
#define MCP16502_ENS BIT(0)
/*
* The PMIC has four sets of registers corresponding to four power modes:
......@@ -54,13 +55,9 @@
* This function is useful for iterating over all regulators and accessing their
* registers in a generic way or accessing a regulator device by its id.
*/
#define MCP16502_BASE(i) (((i) + 1) << 4)
#define MCP16502_REG_BASE(i, r) ((((i) + 1) << 4) + MCP16502_REG_##r)
#define MCP16502_STAT_BASE(i) ((i) + 5)
#define MCP16502_OFFSET_MODE_A 0
#define MCP16502_OFFSET_MODE_LPM 1
#define MCP16502_OFFSET_MODE_HIB 2
#define MCP16502_OPMODE_ACTIVE REGULATOR_MODE_NORMAL
#define MCP16502_OPMODE_LPM REGULATOR_MODE_IDLE
#define MCP16502_OPMODE_HIB REGULATOR_MODE_STANDBY
......@@ -75,6 +72,29 @@
#define MCP16502_MIN_REG 0x0
#define MCP16502_MAX_REG 0x65
/**
* enum mcp16502_reg - MCP16502 regulators's registers
* @MCP16502_REG_A: active state register
* @MCP16502_REG_LPM: low power mode state register
* @MCP16502_REG_HIB: hibernate state register
* @MCP16502_REG_SEQ: startup sequence register
* @MCP16502_REG_CFG: configuration register
*/
enum mcp16502_reg {
MCP16502_REG_A,
MCP16502_REG_LPM,
MCP16502_REG_HIB,
MCP16502_REG_HPM,
MCP16502_REG_SEQ,
MCP16502_REG_CFG,
};
/* Ramp delay (uV/us) for buck1, ldo1, ldo2. */
static const int mcp16502_ramp_b1l12[] = { 6250, 3125, 2083, 1563 };
/* Ramp delay (uV/us) for buck2, buck3, buck4. */
static const int mcp16502_ramp_b234[] = { 3125, 1563, 1042, 781 };
static unsigned int mcp16502_of_map_mode(unsigned int mode)
{
if (mode == REGULATOR_MODE_NORMAL || mode == REGULATOR_MODE_IDLE)
......@@ -93,6 +113,7 @@ static unsigned int mcp16502_of_map_mode(unsigned int mode)
.owner = THIS_MODULE, \
.n_voltages = MCP16502_VSEL + 1, \
.linear_ranges = _ranges, \
.linear_min_sel = VDD_LOW_SEL, \
.n_linear_ranges = ARRAY_SIZE(_ranges), \
.of_match = of_match_ptr(_name), \
.of_map_mode = mcp16502_of_map_mode, \
......@@ -114,8 +135,6 @@ enum {
/*
* struct mcp16502 - PMIC representation
* @rdev: the regulators belonging to this chip
* @rmap: regmap to be used for I2C communication
* @lpm: LPM GPIO descriptor
*/
struct mcp16502 {
......@@ -143,22 +162,20 @@ static void mcp16502_gpio_set_mode(struct mcp16502 *mcp, int mode)
}
/*
* mcp16502_get_reg() - get the PMIC's configuration register for opmode
* mcp16502_get_reg() - get the PMIC's state configuration register for opmode
*
* @rdev: the regulator whose register we are searching
* @opmode: the PMIC's operating mode ACTIVE, Low-power, Hibernate
*/
static int mcp16502_get_reg(struct regulator_dev *rdev, int opmode)
static int mcp16502_get_state_reg(struct regulator_dev *rdev, int opmode)
{
int reg = MCP16502_BASE(rdev_get_id(rdev));
switch (opmode) {
case MCP16502_OPMODE_ACTIVE:
return reg + MCP16502_OFFSET_MODE_A;
return MCP16502_REG_BASE(rdev_get_id(rdev), A);
case MCP16502_OPMODE_LPM:
return reg + MCP16502_OFFSET_MODE_LPM;
return MCP16502_REG_BASE(rdev_get_id(rdev), LPM);
case MCP16502_OPMODE_HIB:
return reg + MCP16502_OFFSET_MODE_HIB;
return MCP16502_REG_BASE(rdev_get_id(rdev), HIB);
default:
return -EINVAL;
}
......@@ -178,7 +195,7 @@ static unsigned int mcp16502_get_mode(struct regulator_dev *rdev)
unsigned int val;
int ret, reg;
reg = mcp16502_get_reg(rdev, MCP16502_OPMODE_ACTIVE);
reg = mcp16502_get_state_reg(rdev, MCP16502_OPMODE_ACTIVE);
if (reg < 0)
return reg;
......@@ -209,7 +226,7 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode,
int val;
int reg;
reg = mcp16502_get_reg(rdev, op_mode);
reg = mcp16502_get_state_reg(rdev, op_mode);
if (reg < 0)
return reg;
......@@ -259,6 +276,80 @@ static int mcp16502_get_status(struct regulator_dev *rdev)
return REGULATOR_STATUS_UNDEFINED;
}
static int mcp16502_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int old_sel,
unsigned int new_sel)
{
static const u8 us_ramp[] = { 8, 16, 24, 32 };
int id = rdev_get_id(rdev);
unsigned int uV_delta, val;
int ret;
ret = regmap_read(rdev->regmap, MCP16502_REG_BASE(id, CFG), &val);
if (ret)
return ret;
val = (val & MCP16502_DVSR) >> 2;
uV_delta = abs(new_sel * rdev->desc->linear_ranges->step -
old_sel * rdev->desc->linear_ranges->step);
switch (id) {
case BUCK1:
case LDO1:
case LDO2:
ret = DIV_ROUND_CLOSEST(uV_delta * us_ramp[val],
mcp16502_ramp_b1l12[val]);
break;
case BUCK2:
case BUCK3:
case BUCK4:
ret = DIV_ROUND_CLOSEST(uV_delta * us_ramp[val],
mcp16502_ramp_b234[val]);
break;
default:
return -EINVAL;
}
return ret;
}
static int mcp16502_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
{
const int *ramp;
int id = rdev_get_id(rdev);
unsigned int i, size;
switch (id) {
case BUCK1:
case LDO1:
case LDO2:
ramp = mcp16502_ramp_b1l12;
size = ARRAY_SIZE(mcp16502_ramp_b1l12);
break;
case BUCK2:
case BUCK3:
case BUCK4:
ramp = mcp16502_ramp_b234;
size = ARRAY_SIZE(mcp16502_ramp_b234);
break;
default:
return -EINVAL;
}
for (i = 0; i < size; i++) {
if (ramp[i] == ramp_delay)
break;
}
if (i == size)
return -EINVAL;
return regmap_update_bits(rdev->regmap, MCP16502_REG_BASE(id, CFG),
MCP16502_DVSR, (i << 2));
}
#ifdef CONFIG_SUSPEND
/*
* mcp16502_suspend_get_target_reg() - get the reg of the target suspend PMIC
......@@ -268,10 +359,10 @@ static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev)
{
switch (pm_suspend_target_state) {
case PM_SUSPEND_STANDBY:
return mcp16502_get_reg(rdev, MCP16502_OPMODE_LPM);
return mcp16502_get_state_reg(rdev, MCP16502_OPMODE_LPM);
case PM_SUSPEND_ON:
case PM_SUSPEND_MEM:
return mcp16502_get_reg(rdev, MCP16502_OPMODE_HIB);
return mcp16502_get_state_reg(rdev, MCP16502_OPMODE_HIB);
default:
dev_err(&rdev->dev, "invalid suspend target: %d\n",
pm_suspend_target_state);
......@@ -353,6 +444,8 @@ static const struct regulator_ops mcp16502_buck_ops = {
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = mcp16502_get_status,
.set_voltage_time_sel = mcp16502_set_voltage_time_sel,
.set_ramp_delay = mcp16502_set_ramp_delay,
.set_mode = mcp16502_set_mode,
.get_mode = mcp16502_get_mode,
......@@ -377,6 +470,8 @@ static const struct regulator_ops mcp16502_ldo_ops = {
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_status = mcp16502_get_status,
.set_voltage_time_sel = mcp16502_set_voltage_time_sel,
.set_ramp_delay = mcp16502_set_ramp_delay,
#ifdef CONFIG_SUSPEND
.set_suspend_voltage = mcp16502_set_suspend_voltage,
......
......@@ -413,8 +413,12 @@ device_node *regulator_of_get_init_node(struct device *dev,
for_each_available_child_of_node(search, child) {
name = of_get_property(child, "regulator-compatible", NULL);
if (!name)
name = child->name;
if (!name) {
if (!desc->of_match_full_name)
name = child->name;
else
name = child->full_name;
}
if (!strcmp(desc->of_match, name)) {
of_node_put(search);
......
This diff is collapsed.
......@@ -105,15 +105,6 @@ static const int pfuze3000_sw2hi[] = {
2500000, 2800000, 2850000, 3000000, 3100000, 3150000, 3200000, 3300000,
};
static const struct i2c_device_id pfuze_device_id[] = {
{.name = "pfuze100", .driver_data = PFUZE100},
{.name = "pfuze200", .driver_data = PFUZE200},
{.name = "pfuze3000", .driver_data = PFUZE3000},
{.name = "pfuze3001", .driver_data = PFUZE3001},
{ }
};
MODULE_DEVICE_TABLE(i2c, pfuze_device_id);
static const struct of_device_id pfuze_dt_ids[] = {
{ .compatible = "fsl,pfuze100", .data = (void *)PFUZE100},
{ .compatible = "fsl,pfuze200", .data = (void *)PFUZE200},
......@@ -440,7 +431,6 @@ static struct pfuze_regulator pfuze3001_regulators[] = {
PFUZE100_VGEN_REG(PFUZE3001, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
};
#ifdef CONFIG_OF
/* PFUZE100 */
static struct of_regulator_match pfuze100_matches[] = {
{ .name = "sw1ab", },
......@@ -578,22 +568,6 @@ static inline struct device_node *match_of_node(int index)
{
return pfuze_matches[index].of_node;
}
#else
static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
{
return 0;
}
static inline struct regulator_init_data *match_init_data(int index)
{
return NULL;
}
static inline struct device_node *match_of_node(int index)
{
return NULL;
}
#endif
static struct pfuze_chip *syspm_pfuze_chip;
......@@ -708,8 +682,6 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct pfuze_chip *pfuze_chip;
struct pfuze_regulator_platform_data *pdata =
dev_get_platdata(&client->dev);
struct regulator_config config = { };
int i, ret;
const struct of_device_id *match;
......@@ -802,10 +774,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
desc = &pfuze_chip->regulator_descs[i].desc;
if (pdata)
init_data = pdata->init_data[i];
else
init_data = match_init_data(i);
init_data = match_init_data(i);
/* SW2~SW4 high bit check and modify the voltage value table */
if (i >= sw_check_start && i <= sw_check_end) {
......@@ -879,7 +848,6 @@ static int pfuze100_regulator_remove(struct i2c_client *client)
}
static struct i2c_driver pfuze_driver = {
.id_table = pfuze_device_id,
.driver = {
.name = "pfuze100-regulator",
.of_match_table = pfuze_dt_ids,
......
......@@ -865,6 +865,60 @@ static const struct rpmh_vreg_init_data pm8150l_vreg_data[] = {
{},
};
static const struct rpmh_vreg_init_data pm8350_vreg_data[] = {
RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"),
RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"),
RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"),
RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"),
RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"),
RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"),
RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"),
RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"),
RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"),
RPMH_VREG("smps10", "smp%s10", &pmic5_hfsmps510, "vdd-s10"),
RPMH_VREG("smps11", "smp%s11", &pmic5_hfsmps510, "vdd-s11"),
RPMH_VREG("smps12", "smp%s12", &pmic5_hfsmps510, "vdd-s12"),
RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l4"),
RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, "vdd-l2-l7"),
RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l5"),
RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l1-l4"),
RPMH_VREG("ldo5", "ldo%s5", &pmic5_nldo, "vdd-l3-l5"),
RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6-l9-l10"),
RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l2-l7"),
RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l8"),
RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l6-l9-l10"),
RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l6-l9-l10"),
{},
};
static const struct rpmh_vreg_init_data pm8350c_vreg_data[] = {
RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"),
RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"),
RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"),
RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"),
RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"),
RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"),
RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"),
RPMH_VREG("smps8", "smp%s8", &pmic5_ftsmps510, "vdd-s8"),
RPMH_VREG("smps9", "smp%s9", &pmic5_ftsmps510, "vdd-s9"),
RPMH_VREG("smps10", "smp%s10", &pmic5_ftsmps510, "vdd-s10"),
RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l12"),
RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo_lv, "vdd-l2-l8"),
RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"),
RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"),
RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"),
RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l6-l9-l11"),
RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"),
RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo_lv, "vdd-l2-l8"),
RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l6-l9-l11"),
RPMH_VREG("ldo10", "ldo%s10", &pmic5_nldo, "vdd-l10"),
RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l6-l9-l11"),
RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l1-l12"),
RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"),
RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"),
{},
};
static const struct rpmh_vreg_init_data pm8009_vreg_data[] = {
RPMH_VREG("smps1", "smp%s1", &pmic5_hfsmps510, "vdd-s1"),
RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps515, "vdd-s2"),
......@@ -930,6 +984,33 @@ static const struct rpmh_vreg_init_data pm6150l_vreg_data[] = {
{},
};
static const struct rpmh_vreg_init_data pmx55_vreg_data[] = {
RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"),
RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"),
RPMH_VREG("smps3", "smp%s3", &pmic5_hfsmps510, "vdd-s3"),
RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"),
RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"),
RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"),
RPMH_VREG("smps7", "smp%s7", &pmic5_hfsmps510, "vdd-s7"),
RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1-l2"),
RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l1-l2"),
RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3-l9"),
RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4-l12"),
RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"),
RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"),
RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l7-l8"),
RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l7-l8"),
RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l3-l9"),
RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l10-l11-l13"),
RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l10-l11-l13"),
RPMH_VREG("ldo12", "ldo%s12", &pmic5_nldo, "vdd-l4-l12"),
RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l10-l11-l13"),
RPMH_VREG("ldo14", "ldo%s14", &pmic5_nldo, "vdd-l14"),
RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, "vdd-l15"),
RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l16"),
{},
};
static int rpmh_regulator_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
......@@ -984,6 +1065,14 @@ static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = {
.compatible = "qcom,pm8150l-rpmh-regulators",
.data = pm8150l_vreg_data,
},
{
.compatible = "qcom,pm8350-rpmh-regulators",
.data = pm8350_vreg_data,
},
{
.compatible = "qcom,pm8350c-rpmh-regulators",
.data = pm8350c_vreg_data,
},
{
.compatible = "qcom,pm8998-rpmh-regulators",
.data = pm8998_vreg_data,
......@@ -1000,6 +1089,10 @@ static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = {
.compatible = "qcom,pm6150l-rpmh-regulators",
.data = pm6150l_vreg_data,
},
{
.compatible = "qcom,pmx55-rpmh-regulators",
.data = pmx55_vreg_data,
},
{}
};
MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table);
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0+ */
#ifndef _DT_BINDINGS_REGULATOR_DLG_DA9121_H
#define _DT_BINDINGS_REGULATOR_DLG_DA9121_H
/*
* These buck mode constants may be used to specify values in device tree
* properties (e.g. regulator-initial-mode).
* A description of the following modes is in the manufacturers datasheet.
*/
#define DA9121_BUCK_MODE_FORCE_PFM 0
#define DA9121_BUCK_MODE_FORCE_PWM 1
#define DA9121_BUCK_MODE_FORCE_PWM_SHEDDING 2
#define DA9121_BUCK_MODE_AUTO 3
#define DA9121_BUCK_RIPPLE_CANCEL_NONE 0
#define DA9121_BUCK_RIPPLE_CANCEL_SMALL 1
#define DA9121_BUCK_RIPPLE_CANCEL_MID 2
#define DA9121_BUCK_RIPPLE_CANCEL_LARGE 3
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* DA9121 Single-channel dual-phase 10A buck converter
* DA9130 Single-channel dual-phase 10A buck converter (Automotive)
* DA9217 Single-channel dual-phase 6A buck converter
* DA9122 Dual-channel single-phase 5A buck converter
* DA9131 Dual-channel single-phase 5A buck converter (Automotive)
* DA9220 Dual-channel single-phase 3A buck converter
* DA9132 Dual-channel single-phase 3A buck converter (Automotive)
*
* Copyright (C) 2020 Dialog Semiconductor
*
* Authors: Adam Ward, Dialog Semiconductor
*/
#ifndef __LINUX_REGULATOR_DA9121_H
#define __LINUX_REGULATOR_DA9121_H
#include <linux/regulator/machine.h>
struct gpio_desc;
enum {
DA9121_IDX_BUCK1,
DA9121_IDX_BUCK2,
DA9121_IDX_MAX
};
struct da9121_pdata {
int num_buck;
struct gpio_desc *gpiod_ren[DA9121_IDX_MAX];
struct device_node *reg_node[DA9121_IDX_MAX];
struct regulator_init_data *init_data[DA9121_IDX_MAX];
};
#endif
......@@ -223,6 +223,8 @@ enum regulator_type {
* @name: Identifying name for the regulator.
* @supply_name: Identifying the regulator supply
* @of_match: Name used to identify regulator in DT.
* @of_match_full_name: A flag to indicate that the of_match string, if
* present, should be matched against the node full_name.
* @regulators_node: Name of node containing regulator definitions in DT.
* @of_parse_cb: Optional callback called only if of_match is present.
* Will be called for each regulator parsed from DT, during
......@@ -314,6 +316,7 @@ struct regulator_desc {
const char *name;
const char *supply_name;
const char *of_match;
bool of_match_full_name;
const char *regulators_node;
int (*of_parse_cb)(struct device_node *,
const struct regulator_desc *,
......
......@@ -63,10 +63,4 @@
#define PFUZE3001_VLDO3 8
#define PFUZE3001_VLDO4 9
struct regulator_init_data;
struct pfuze_regulator_platform_data {
struct regulator_init_data *init_data[PFUZE100_MAX_REGULATOR];
};
#endif /* __LINUX_REG_PFUZE100_H */
......@@ -209,6 +209,64 @@ struct scmi_reset_ops {
int (*deassert)(const struct scmi_handle *handle, u32 domain);
};
/**
* struct scmi_voltage_info - describe one available SCMI Voltage Domain
*
* @id: the domain ID as advertised by the platform
* @segmented: defines the layout of the entries of array @levels_uv.
* - when True the entries are to be interpreted as triplets,
* each defining a segment representing a range of equally
* space voltages: <lowest_volts>, <highest_volt>, <step_uV>
* - when False the entries simply represent a single discrete
* supported voltage level
* @negative_volts_allowed: True if any of the entries of @levels_uv represent
* a negative voltage.
* @attributes: represents Voltage Domain advertised attributes
* @name: name assigned to the Voltage Domain by platform
* @num_levels: number of total entries in @levels_uv.
* @levels_uv: array of entries describing the available voltage levels for
* this domain.
*/
struct scmi_voltage_info {
unsigned int id;
bool segmented;
bool negative_volts_allowed;
unsigned int attributes;
char name[SCMI_MAX_STR_SIZE];
unsigned int num_levels;
#define SCMI_VOLTAGE_SEGMENT_LOW 0
#define SCMI_VOLTAGE_SEGMENT_HIGH 1
#define SCMI_VOLTAGE_SEGMENT_STEP 2
int *levels_uv;
};
/**
* struct scmi_voltage_ops - represents the various operations provided
* by SCMI Voltage Protocol
*
* @num_domains_get: get the count of voltage domains provided by SCMI
* @info_get: get the information of the specified domain
* @config_set: set the config for the specified domain
* @config_get: get the config of the specified domain
* @level_set: set the voltage level for the specified domain
* @level_get: get the voltage level of the specified domain
*/
struct scmi_voltage_ops {
int (*num_domains_get)(const struct scmi_handle *handle);
const struct scmi_voltage_info __must_check *(*info_get)
(const struct scmi_handle *handle, u32 domain_id);
int (*config_set)(const struct scmi_handle *handle, u32 domain_id,
u32 config);
#define SCMI_VOLTAGE_ARCH_STATE_OFF 0x0
#define SCMI_VOLTAGE_ARCH_STATE_ON 0x7
int (*config_get)(const struct scmi_handle *handle, u32 domain_id,
u32 *config);
int (*level_set)(const struct scmi_handle *handle, u32 domain_id,
u32 flags, s32 volt_uV);
int (*level_get)(const struct scmi_handle *handle, u32 domain_id,
s32 *volt_uV);
};
/**
* struct scmi_notify_ops - represents notifications' operations provided by
* SCMI core
......@@ -262,6 +320,7 @@ struct scmi_notify_ops {
* @clk_ops: pointer to set of clock protocol operations
* @sensor_ops: pointer to set of sensor protocol operations
* @reset_ops: pointer to set of reset protocol operations
* @voltage_ops: pointer to set of voltage protocol operations
* @notify_ops: pointer to set of notifications related operations
* @perf_priv: pointer to private data structure specific to performance
* protocol(for internal use only)
......@@ -273,6 +332,8 @@ struct scmi_notify_ops {
* protocol(for internal use only)
* @reset_priv: pointer to private data structure specific to reset
* protocol(for internal use only)
* @voltage_priv: pointer to private data structure specific to voltage
* protocol(for internal use only)
* @notify_priv: pointer to private data structure specific to notifications
* (for internal use only)
*/
......@@ -284,6 +345,7 @@ struct scmi_handle {
const struct scmi_power_ops *power_ops;
const struct scmi_sensor_ops *sensor_ops;
const struct scmi_reset_ops *reset_ops;
const struct scmi_voltage_ops *voltage_ops;
const struct scmi_notify_ops *notify_ops;
/* for protocol internal use */
void *perf_priv;
......@@ -291,6 +353,7 @@ struct scmi_handle {
void *power_priv;
void *sensor_priv;
void *reset_priv;
void *voltage_priv;
void *notify_priv;
void *system_priv;
};
......@@ -303,6 +366,7 @@ enum scmi_std_protocol {
SCMI_PROTOCOL_CLOCK = 0x14,
SCMI_PROTOCOL_SENSOR = 0x15,
SCMI_PROTOCOL_RESET = 0x16,
SCMI_PROTOCOL_VOLTAGE = 0x17,
};
enum scmi_system_events {
......
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