Commit 1724e02e authored by Linus Torvalds's avatar Linus Torvalds

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

Pull regulator updates from Mark Brown:
 "This is a fairly small release for the regulator API, there's quite a
  few new devices supported and some important improvements around
  coupled regulators in the core but mostly just small fixes and
  improvements otherwise.

  Summary:

   - Fixes and cleanups around the handling of coupled regulators.

   - A special driver for some Raspberry Pi panels with some unusually
     custom stuff around them.

   - Support for Qualcomm PM660/PM660L, PM8950 and PM8953, Richtek
     RT4801 and RTMV20, Rohm BD9576MUF and BD9573MUF"

* tag 'regulator-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (89 commits)
  regulator: bd9576: Fix print
  regulator: bd9576: fix regulator binfdings dt node names
  dt-bindings: regulator: document pm8950 and pm8953 smd regulators
  regulator: qcom_smd: add pm8953 regulators
  regulator: Make constraint debug processing conditional on DEBUG
  regulator: qcom: labibb: Constify static structs
  regulator: dt-bindings: Document the PM660/PM660L PMICs entries
  regulator: qcom_smd: Add PM660/PM660L regulator support
  regulator: dt-bindings: Document the PM660/660L SPMI PMIC entries
  regulator: qcom_spmi: Add PM660/PM660L regulators
  regulator: qcom_spmi: Add support for new regulator types
  regulator: core: Enlarge max OF property name length to 64 chars
  regulator: tps65910: use regmap accessors
  regulator: rtmv20: Add missing regcache cache only before marked as dirty
  regulator: rtmv20: Update DT binding document and property name parsing
  regulator: rtmv20: Add DT-binding document for Richtek RTMV20
  regulator: rtmv20: Adds support for Richtek RTMV20 load switch regulator
  regulator: resolve supply after creating regulator
  regulator: print symbolic errors in kernel messages
  regulator: print state at boot
  ...
parents 57218d7f c6e70a6f
Monolithic Power Systems MP8867/MP8869 voltage regulator
Required properties:
- compatible: Must be one of the following.
"mps,mp8867"
"mps,mp8869"
- reg: I2C slave address.
- enable-gpios: enable gpios.
- mps,fb-voltage-divider: An array of two integers containing the resistor
values R1 and R2 of the feedback voltage divider in kilo ohms.
Any property defined as part of the core regulator binding, defined in
./regulator.txt, can also be used.
Example:
vcpu: regulator@62 {
compatible = "mps,mp8869";
regulator-name = "vcpu";
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <850000>;
regulator-always-on;
regulator-boot-on;
enable-gpios = <&porta 1 GPIO_ACTIVE_LOW>;
mps,fb-voltage-divider = <80 240>;
reg = <0x62>;
};
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/mps,mp886x.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Monolithic Power Systems MP8867/MP8869 voltage regulator
maintainers:
- Jisheng Zhang <jszhang@kernel.org>
allOf:
- $ref: regulator.yaml#
properties:
compatible:
enum:
- mps,mp8867
- mps,mp8869
reg:
maxItems: 1
enable-gpios:
description: GPIO to enable/disable the regulator.
maxItems: 1
mps,fb-voltage-divider:
description: An array of two integers containing the resistor
values R1 and R2 of the feedback voltage divider in kilo ohms.
$ref: "/schemas/types.yaml#/definitions/uint32-array"
maxItems: 2
mps,switch-frequency-hz:
description: The valid switch frequency in Hertz.
enum: [500000, 750000, 1000000, 1250000, 1500000]
required:
- compatible
- reg
- enable-gpios
- mps,fb-voltage-divider
examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
regulator@62 {
compatible = "mps,mp8869";
regulator-name = "vcpu";
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1150000>;
enable-gpios = <&porta 1 GPIO_ACTIVE_LOW>;
mps,fb-voltage-divider = <80 240>;
reg = <0x62>;
};
};
...
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/mt6360-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: MT6360 Regulator from MediaTek Integrated
maintainers:
- Gene Chen <gene_chen@richtek.com>
description: |
list of regulators provided by this controller, must be named
after their hardware counterparts buck1/2 or ldo1/2/3/5/6/7
properties:
compatible:
const: mediatek,mt6360-regulator
LDO_VIN1-supply:
description: Input supply phandle(s) for LDO1/2/3
LDO_VIN2-supply:
description: Input supply phandle(s) for LDO5
LDO_VIN3-supply:
description: Input supply phandle(s) for LDO6/7
patternProperties:
"^buck[12]$":
$ref: "regulator.yaml#"
"^ldo[123567]$":
$ref: "regulator.yaml#"
required:
- compatible
additionalProperties: false
examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
regulator {
compatible = "mediatek,mt6360-regulator";
LDO_VIN3-supply = <&BUCK2>;
buck1 {
regulator-compatible = "BUCK1";
regulator-name = "mt6360,buck1";
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1300000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP
MT6360_OPMODE_ULP>;
};
BUCK2: buck2 {
regulator-compatible = "BUCK2";
regulator-name = "mt6360,buck2";
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1300000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP
MT6360_OPMODE_ULP>;
};
ldo6 {
regulator-compatible = "LDO6";
regulator-name = "mt6360,ldo6";
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <2100000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP>;
};
ldo7 {
regulator-compatible = "LDO7";
regulator-name = "mt6360,ldo7";
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <2100000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP>;
};
ldo1 {
regulator-compatible = "LDO1";
regulator-name = "mt6360,ldo1";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3600000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP>;
};
ldo2 {
regulator-compatible = "LDO2";
regulator-name = "mt6360,ldo2";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3600000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP>;
};
ldo3 {
regulator-compatible = "LDO3";
regulator-name = "mt6360,ldo3";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <3600000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP>;
};
ldo5 {
regulator-compatible = "LDO5";
regulator-name = "mt6360,ldo5";
regulator-min-microvolt = <2700000>;
regulator-max-microvolt = <3600000>;
regulator-allowed-modes = <MT6360_OPMODE_NORMAL
MT6360_OPMODE_LP>;
};
};
...
PFUZE100 family of regulators
Required properties:
- compatible: "fsl,pfuze100", "fsl,pfuze200", "fsl,pfuze3000", "fsl,pfuze3001"
- reg: I2C slave address
Optional properties:
- fsl,pfuze-support-disable-sw: Boolean, if present disable all unused switch
regulators to save power consumption. Attention, ensure that all important
regulators (e.g. DDR ref, DDR supply) has set the "regulator-always-on"
property. If not present, the switched regulators are always on and can't be
disabled. This binding is a workaround to keep backward compatibility with
old dtb's which rely on the fact that the switched regulators are always on
and don't mark them explicit as "regulator-always-on".
- fsl,pmic-stby-poweroff: if present, configure the PMIC to shutdown all
power rails when PMIC_STBY_REQ line is asserted during the power off sequence.
Use this option if the SoC should be powered off by external power
management IC (PMIC) on PMIC_STBY_REQ signal.
As opposite to PMIC_STBY_REQ boards can implement PMIC_ON_REQ signal.
Required child node:
- regulators: This is the list of child nodes that specify the regulator
initialization data for defined regulators. Please refer to below doc
Documentation/devicetree/bindings/regulator/regulator.txt.
The valid names for regulators are:
--PFUZE100
sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6
--PFUZE200
sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6,coin
--PFUZE3000
sw1a,sw1b,sw2,sw3,swbst,vsnvs,vrefddr,vldo1,vldo2,vccsd,v33,vldo3,vldo4
--PFUZE3001
sw1,sw2,sw3,vsnvs,vldo1,vldo2,vccsd,v33,vldo3,vldo4
Each regulator is defined using the standard binding for regulators.
Example 1: PFUZE100
pfuze100: pmic@8 {
compatible = "fsl,pfuze100";
reg = <0x08>;
regulators {
sw1a_reg: sw1ab {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
sw1c_reg: sw1c {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
};
sw2_reg: sw2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw3a_reg: sw3a {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw3b_reg: sw3b {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw4_reg: sw4 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
};
swbst_reg: swbst {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5150000>;
};
snvs_reg: vsnvs {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vref_reg: vrefddr {
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vgen1 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen2_reg: vgen2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen3_reg: vgen3 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
vgen4_reg: vgen4 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen5_reg: vgen5 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen6_reg: vgen6 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
};
};
Example 2: PFUZE200
pfuze200: pmic@8 {
compatible = "fsl,pfuze200";
reg = <0x08>;
regulators {
sw1a_reg: sw1ab {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
sw2_reg: sw2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw3a_reg: sw3a {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw3b_reg: sw3b {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
swbst_reg: swbst {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5150000>;
};
snvs_reg: vsnvs {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vref_reg: vrefddr {
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vgen1 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen2_reg: vgen2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen3_reg: vgen3 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
vgen4_reg: vgen4 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen5_reg: vgen5 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen6_reg: vgen6 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
coin_reg: coin {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
};
};
Example 3: PFUZE3000
pfuze3000: pmic@8 {
compatible = "fsl,pfuze3000";
reg = <0x08>;
regulators {
sw1a_reg: sw1a {
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1475000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
/* use sw1c_reg to align with pfuze100/pfuze200 */
sw1c_reg: sw1b {
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1475000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
sw2_reg: sw2 {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw3a_reg: sw3 {
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1650000>;
regulator-boot-on;
regulator-always-on;
};
swbst_reg: swbst {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5150000>;
};
snvs_reg: vsnvs {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vref_reg: vrefddr {
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vldo1 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen2_reg: vldo2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen3_reg: vccsd {
regulator-min-microvolt = <2850000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen4_reg: v33 {
regulator-min-microvolt = <2850000>;
regulator-max-microvolt = <3300000>;
};
vgen5_reg: vldo3 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen6_reg: vldo4 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
};
};
Example 4: PFUZE 3001
pfuze3001: pmic@8 {
compatible = "fsl,pfuze3001";
reg = <0x08>;
regulators {
sw1_reg: sw1 {
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw2_reg: sw2 {
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw3_reg: sw3 {
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1650000>;
regulator-boot-on;
regulator-always-on;
};
snvs_reg: vsnvs {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vldo1 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen2_reg: vldo2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
regulator-always-on;
};
vgen3_reg: vccsd {
regulator-min-microvolt = <2850000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen4_reg: v33 {
regulator-min-microvolt = <2850000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen5_reg: vldo3 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen6_reg: vldo4 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
};
};
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/pfuze100.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: PFUZE100 family of regulators
maintainers:
- Robin Gong <yibin.gong@nxp.com>
description: |
The valid names for regulators are:
--PFUZE100
sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6
--PFUZE200
sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6,coin
--PFUZE3000
sw1a,sw1b,sw2,sw3,swbst,vsnvs,vrefddr,vldo1,vldo2,vccsd,v33,vldo3,vldo4
--PFUZE3001
sw1,sw2,sw3,vsnvs,vldo1,vldo2,vccsd,v33,vldo3,vldo4
Each regulator is defined using the standard binding for regulators.
properties:
$nodename:
pattern: "^pmic@[0-9]$"
compatible:
enum:
- fsl,pfuze100
- fsl,pfuze200
- fsl,pfuze3000
- fsl,pfuze3001
reg:
maxItems: 1
fsl,pfuze-support-disable-sw:
$ref: /schemas/types.yaml#/definitions/flag
description: |
Boolean, if present disable all unused switch regulators to save power
consumption. Attention, ensure that all important regulators
(e.g. DDR ref, DDR supply) has set the "regulator-always-on" property.
If not present, the switched regulators are always on and can't be
disabled. This binding is a workaround to keep backward compatibility
with old dtb's which rely on the fact that the switched regulators are
always on and don't mark them explicit as "regulator-always-on".
fsl,pmic-stby-poweroff:
$ref: /schemas/types.yaml#/definitions/flag
description: |
if present, configure the PMIC to shutdown all
power rails when PMIC_STBY_REQ line is asserted during the power off sequence.
Use this option if the SoC should be powered off by external power management
IC (PMIC) on PMIC_STBY_REQ signal.
As opposite to PMIC_STBY_REQ boards can implement PMIC_ON_REQ signal.
regulators:
type: object
description: |
list of regulators provided by this controller.
patternProperties:
"^sw([1-4]|[1-4][a-c]|[1-4][a-c][a-c])$":
$ref: "regulator.yaml#"
type: object
"^vgen[1-6]$":
$ref: "regulator.yaml#"
type: object
"^(vsnvs|vref|vrefddr|swbst|coin)$":
$ref: "regulator.yaml#"
type: object
additionalProperties: false
required:
- compatible
- reg
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
pmic@8 {
compatible = "fsl,pfuze100";
reg = <0x08>;
regulators {
sw1a_reg: sw1ab {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
sw1c_reg: sw1c {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
};
sw2_reg: sw2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw3a_reg: sw3a {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw3b_reg: sw3b {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw4_reg: sw4 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
};
swbst_reg: swbst {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5150000>;
};
snvs_reg: vsnvs {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vref_reg: vrefddr {
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vgen1 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen2_reg: vgen2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen3_reg: vgen3 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
vgen4_reg: vgen4 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen5_reg: vgen5 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen6_reg: vgen6 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
};
};
};
......@@ -33,6 +33,10 @@ description:
l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24, lvs1, lvs2,
lvs3, 5vs1, 5vs2
For pm8950 and pm8953, s1, s2, s3, s4, s5, s6, s7, l1, l2, l3, l4, l5, l6,
l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22,
l23
For pm8994, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3,
l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19,
l20, l21, l22, l23, l24, l25, l26, l27, l28, l29, l30, l31, l32, lvs1, lvs2
......@@ -41,6 +45,11 @@ description:
l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19,
l20, l21, l22, l23, l24, l25, l26, l27, l28, lvs1, lvs2
For pm660, s1, s2, s3, s4, s5, s6, l1, l2, l3, l5, l6, l7, l8, l9, l10, l22,
l12, l13, l14, l15, l16, l17, l18, l19
For pm660l s1, s2, s3, s5, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, bob
For pma8084, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3,
l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19,
l20, l21, l22, l23, l24, l25, l26, l27, lvs1, lvs2, lvs3, lvs4, 5vs1
......@@ -63,8 +72,11 @@ properties:
- qcom,rpm-pm8916-regulators
- qcom,rpm-pm8941-regulators
- qcom,rpm-pm8950-regulators
- qcom,rpm-pm8953-regulators
- qcom,rpm-pm8994-regulators
- qcom,rpm-pm8998-regulators
- qcom,rpm-pm660-regulators
- qcom,rpm-pm660l-regulators
- qcom,rpm-pma8084-regulators
- qcom,rpm-pmi8994-regulators
- qcom,rpm-pmi8998-regulators
......
......@@ -12,6 +12,8 @@ Qualcomm SPMI Regulators
"qcom,pm8950-regulators"
"qcom,pm8994-regulators"
"qcom,pmi8994-regulators"
"qcom,pm660-regulators"
"qcom,pm660l-regulators"
"qcom,pms405-regulators"
- interrupts:
......@@ -134,6 +136,35 @@ Qualcomm SPMI Regulators
Definition: Reference to regulator supplying the input pin, as
described in the data sheet.
- vdd_l1_l6_l7-supply:
- vdd_l2_l3-supply:
- vdd_l5-supply:
- vdd_l8_l9_l10_l11_l12_l13_l14-supply:
- vdd_l15_l16_l17_l18_l19-supply:
- vdd_s1-supply:
- vdd_s2-supply:
- vdd_s3-supply:
- vdd_s5-supply:
- vdd_s6-supply:
Usage: optional (pm660 only)
Value type: <phandle>
Definition: Reference to regulator supplying the input pin, as
described in the data sheet.
- vdd_l1_l9_l10-supply:
- vdd_l2-supply:
- vdd_l3_l5_l7_l8-supply:
- vdd_l4_l6-supply:
- vdd_s1-supply:
- vdd_s2-supply:
- vdd_s3-supply:
- vdd_s4-supply:
- vdd_s5-supply:
Usage: optional (pm660l only)
Value type: <phandle>
Definition: Reference to regulator supplying the input pin, as
described in the data sheet.
- vdd_l1_l2-supply:
- vdd_l3_l8-supply:
- vdd_l4-supply:
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/raspberrypi,7inch-touchscreen-panel-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: RaspberryPi 7" display ATTINY88-based regulator/backlight controller
maintainers:
- Marek Vasut <marex@denx.de>
description: |
The RaspberryPi 7" display has an ATTINY88-based regulator/backlight
controller on the PCB, which is used to turn the display unit on/off
and control the backlight.
allOf:
- $ref: "regulator.yaml#"
properties:
compatible:
const: raspberrypi,7inch-touchscreen-panel-regulator
reg:
maxItems: 1
additionalProperties: false
required:
- compatible
- reg
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
regulator@45 {
compatible = "raspberrypi,7inch-touchscreen-panel-regulator";
reg = <0x45>;
};
};
...
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/richtek,rt4801-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Richtek RT4801 Display Bias regulators
maintainers:
- ChiYuan Huang <cy_huang@richtek.com>
description: |
Regulator nodes should be named to DSVP and DSVN. The
definition for each of these nodes is defined using the standard
binding for regulators at
Documentation/devicetree/bindings/regulator/regulator.txt.
Datasheet is available at
https://www.richtek.com/assets/product_file/RT4801H/DS4801H-00.pdf
#The valid names for RT4801 regulator nodes are:
#DSVP, DSVN
properties:
compatible:
enum:
- richtek,rt4801
reg:
maxItems: 1
enable-gpios:
description: GPIOs to use to enable DSVP/DSVN regulator.
The first one is ENP to enable DSVP, and second one is ENM to enable DSVN.
Number of GPIO in the array list could be 1 or 2.
If only one gpio is specified, only one gpio used to control ENP/ENM.
Else both are spefied, DSVP/DSVN could be controlled individually.
Othersie, this property not specified. treat both as always-on regulator.
minItems: 1
maxItems: 2
patternProperties:
"^DSV(P|N)$":
type: object
$ref: regulator.yaml#
description:
Properties for single display bias regulator.
required:
- compatible
- reg
additionalProperties: false
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
rt4801@73 {
compatible = "richtek,rt4801";
reg = <0x73>;
enable-gpios = <&gpio26 2 0>, <&gpio26 3 0>;
dsvp: DSVP {
regulator-name = "rt4801,dsvp";
regulator-min-microvolt = <4000000>;
regulator-max-microvolt = <6000000>;
regulator-boot-on;
};
dsvn: DSVN {
regulator-name = "rt4801,dsvn";
regulator-min-microvolt = <4000000>;
regulator-max-microvolt = <6000000>;
regulator-boot-on;
};
};
};
# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/richtek,rtmv20-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Richtek RTMV20 laser diode regulator
maintainers:
- ChiYuan Huang <cy_huang@richtek.com>
description: |
Richtek RTMV20 is a load switch current regulator that can supply up to 6A.
It is used to drive laser diode. There're two signals for chip controls
(Enable/Fail), Enable pin to turn chip on, and Fail pin as fault indication.
There're still four pins for camera control, two inputs (strobe and vsync),
the others for outputs (fsin1 and fsin2). Strobe input to start the current
supply, vsync input from IR camera, and fsin1/fsin2 output for the optional.
properties:
compatible:
const: richtek,rtmv20
reg:
maxItems: 1
wakeup-source: true
interrupts:
maxItems: 1
enable-gpios:
description: A connection of the 'enable' gpio line.
maxItems: 1
richtek,ld-pulse-delay-us:
description: |
load current pulse delay in microsecond after strobe pin pulse high.
minimum: 0
maximum: 100000
default: 0
richtek,ld-pulse-width-us:
description: |
Load current pulse width in microsecond after strobe pin pulse high.
minimum: 0
maximum: 10000
default: 1200
richtek,fsin1-delay-us:
description: |
Fsin1 pulse high delay in microsecond after vsync signal pulse high.
minimum: 0
maximum: 100000
default: 23000
richtek,fsin1-width-us:
description: |
Fsin1 pulse high width in microsecond after vsync signal pulse high.
minimum: 40
maximum: 10000
default: 160
richtek,fsin2-delay-us:
description: |
Fsin2 pulse high delay in microsecond after vsync signal pulse high.
minimum: 0
maximum: 100000
default: 23000
richtek,fsin2-width-us:
description: |
Fsin2 pulse high width in microsecond after vsync signal pulse high.
minimum: 40
maximum: 10000
default: 160
richtek,es-pulse-width-us:
description: Eye safety function pulse width limit in microsecond.
minimum: 0
maximum: 10000
default: 1200
richtek,es-ld-current-microamp:
description: Eye safety function load current limit in microamp.
minimum: 0
maximum: 6000000
default: 3000000
richtek,lbp-level-microvolt:
description: Low battery protection level in microvolt.
minimum: 2400000
maximum: 3700000
default: 2700000
richtek,lbp-enable:
description: Low battery protection function enable control.
type: boolean
richtek,strobe-polarity-high:
description: Strobe pin active polarity control.
type: boolean
richtek,vsync-polarity-high:
description: Vsync pin active polarity control.
type: boolean
richtek,fsin-enable:
description: Fsin function enable control.
type: boolean
richtek,fsin-output:
description: Fsin function output control.
type: boolean
richtek,es-enable:
description: Eye safety function enable control.
type: boolean
lsw:
description: load switch current regulator description.
type: object
$ref: "regulator.yaml#"
required:
- compatible
- reg
- wakeup-source
- interrupts
- enable-gpios
- lsw
additionalProperties: false
examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
rtmv20@34 {
compatible = "richtek,rtmv20";
reg = <0x34>;
wakeup-source;
interrupts-extended = <&gpio26 2 IRQ_TYPE_LEVEL_LOW>;
enable-gpios = <&gpio26 3 0>;
richtek,strobe-polarity-high;
richtek,vsync-polarity-high;
lsw {
regulator-name = "rtmv20,lsw";
regulator-min-microamp = <0>;
regulator-max-microamp = <6000000>;
};
};
};
...
......@@ -93,6 +93,17 @@ patternProperties:
# ----------------------------------------------------------------
# rest | not supported | not supported | not supported
# BD71837 power outputs can either be controlled by the PMIC internal
# hardware state machine or by software. If you need regulators to be
# turned ON/OFF for example based on PMIC_STBY_REQ line (which toggles
# PMIC HW state machine) - then you should set this property.
# Tradeoff is that then SW can't control the ON/OFF state for this
# regulator (other than invoking a PMIC state change).
rohm,no-regulator-enable-control:
description: |
Enable/Disable control of this regulator must be left to the
PMIC hardware state machine.
type: boolean
required:
- regulator-name
......
......@@ -88,6 +88,17 @@ patternProperties:
# ----------------------------------------------------------------
# rest | not supported | not supported | not supported
# BD718(47/50) power outputs can either be controlled by the PMIC internal
# hardware state machine or by software. If you need regulators to be
# turned ON/OFF for example based on PMIC_STBY_REQ line (which toggles
# PMIC HW state machine) - then you should set this property.
# Tradeoff is that then SW can't control the ON/OFF state for this
# regulator (other than invoking a PMIC state change).
rohm,no-regulator-enable-control:
description: |
Enable/Disable control of this regulator must be left to the
PMIC hardware state machine.
type: boolean
required:
- regulator-name
......
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/rohm,bd9576-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: ROHM BD9576 and BD9573 Power Management Integrated Circuit regulators
maintainers:
- Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
description: |
This module is part of the ROHM BD9576 MFD device. For more details
see Documentation/devicetree/bindings/mfd/rohm,bd9576-pmic.yaml.
The regulator controller is represented as a sub-node of the PMIC node
on the device tree.
The valid names for BD9576 regulator nodes are
regulator-vd50, regulator-vd18, regulator-vdddr, regulator-vd10,
regulator-voutl1, regulator-vouts1
patternProperties:
"regulator-.+":
type: object
description:
Properties for single regulator.
$ref: "regulator.yaml#"
required:
- regulator-name
unevaluatedProperties: false
additionalProperties: false
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/silergy,sy8824x.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: silergy sy8824c,sy8824e,sy20276 and sy20278 PMIC
maintainers:
- Jisheng Zhang <jszhang@kernel.org>
allOf:
- $ref: regulator.yaml#
properties:
compatible:
enum:
- silergy,sy8824c
- silergy,sy8824e
- silergy,sy20276
- silergy,sy20278
reg:
maxItems: 1
required:
- compatible
- reg
unevaluatedProperties: false
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
regulator@60 {
compatible = "silergy,sy8824c";
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1150000>;
reg = <0x60>;
};
};
...
SY8824C/SY8824E/SY20276 Voltage regulator
Required properties:
- compatible: Must be one of the following.
"silergy,sy8824c"
"silergy,sy8824e"
"silergy,sy20276"
"silergy,sy20278"
- reg: I2C slave address
Any property defined as part of the core regulator binding, defined in
./regulator.txt, can also be used.
Example:
vcore: regulator@00 {
compatible = "silergy,sy8824c";
reg = <0x66>;
regulator-name = "vcore";
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1150000>;
regulator-boot-on;
regulator-always-on;
};
......@@ -84,7 +84,7 @@ static int pg86x_i2c_probe(struct i2c_client *i2c)
return 0;
}
static const struct of_device_id pg86x_dt_ids [] = {
static const struct of_device_id __maybe_unused pg86x_dt_ids[] = {
{ .compatible = "marvell,88pg867" },
{ .compatible = "marvell,88pg868" },
{ }
......
......@@ -231,6 +231,16 @@ config REGULATOR_BD9571MWV
This driver can also be built as a module. If so, the module
will be called bd9571mwv-regulator.
config REGULATOR_BD957XMUF
tristate "ROHM BD9576MUF and BD9573MUF Regulators"
depends on MFD_ROHM_BD957XMUF
help
This driver supports voltage regulators on ROHM BD9576MUF and
BD9573MUF PMICs.
This driver can also be built as a module. If so, the module
will be called bd9576-regulator.
config REGULATOR_CPCAP
tristate "Motorola CPCAP regulator"
depends on MFD_CPCAP
......@@ -500,7 +510,7 @@ config REGULATOR_MAX1586
config REGULATOR_MAX77620
tristate "Maxim 77620/MAX20024 voltage regulator"
depends on MFD_MAX77620
depends on MFD_MAX77620 || COMPILE_TEST
help
This driver controls Maxim MAX77620 voltage output regulator
via I2C bus. The provided regulator is suitable for Tegra
......@@ -509,7 +519,7 @@ config REGULATOR_MAX77620
config REGULATOR_MAX77650
tristate "Maxim MAX77650/77651 regulator support"
depends on MFD_MAX77650
depends on MFD_MAX77650 || COMPILE_TEST
help
Regulator driver for MAX77650/77651 PMIC from Maxim
Semiconductor. This device has a SIMO with three independent
......@@ -532,7 +542,7 @@ config REGULATOR_MAX8660
config REGULATOR_MAX8907
tristate "Maxim 8907 voltage regulator"
depends on MFD_MAX8907
depends on MFD_MAX8907 || COMPILE_TEST
help
This driver controls a Maxim 8907 voltage output regulator
via I2C bus. The provided regulator is suitable for Tegra
......@@ -582,7 +592,7 @@ config REGULATOR_MAX8998
config REGULATOR_MAX77686
tristate "Maxim 77686 regulator"
depends on MFD_MAX77686
depends on MFD_MAX77686 || COMPILE_TEST
help
This driver controls a Maxim 77686 regulator
via I2C bus. The provided regulator is suitable for
......@@ -590,7 +600,7 @@ config REGULATOR_MAX77686
config REGULATOR_MAX77693
tristate "Maxim 77693/77843 regulator"
depends on (MFD_MAX77693 || MFD_MAX77843)
depends on MFD_MAX77693 || MFD_MAX77843 || COMPILE_TEST
help
This driver controls a Maxim 77693/77843 regulators via I2C bus.
The regulators include two LDOs, 'SAFEOUT1', 'SAFEOUT2'
......@@ -599,7 +609,7 @@ config REGULATOR_MAX77693
config REGULATOR_MAX77802
tristate "Maxim 77802 regulator"
depends on MFD_MAX77686
depends on MFD_MAX77686 || COMPILE_TEST
help
This driver controls a Maxim 77802 regulator
via I2C bus. The provided regulator is suitable for
......@@ -711,6 +721,15 @@ config REGULATOR_MT6358
This driver supports the control of different power rails of device
through regulator interface.
config REGULATOR_MT6360
tristate "MT6360 SubPMIC Regulator"
depends on MFD_MT6360
help
Say Y here to enable MT6360 regulator support.
This is support MT6360 PMIC/LDO part include
2-channel buck with Thermal Shutdown and Overload Protection
6-channel High PSRR and Low Dropout LDO.
config REGULATOR_MT6380
tristate "MediaTek MT6380 PMIC"
depends on MTK_PMIC_WRAP
......@@ -864,6 +883,16 @@ config REGULATOR_QCOM_USB_VBUS
Say M here if you want to include support for enabling the VBUS output
as a module. The module will be named "qcom_usb_vbus_regulator".
config REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY
tristate "Raspberry Pi 7-inch touchscreen panel ATTINY regulator"
depends on BACKLIGHT_CLASS_DEVICE
depends on I2C
select REGMAP_I2C
help
This driver supports ATTINY regulator on the Raspberry Pi 7-inch
touchscreen unit. The regulator is used to enable power to the
TC358762, display and to control backlight.
config REGULATOR_RC5T583
tristate "RICOH RC5T583 Power regulators"
depends on MFD_RC5T583
......@@ -894,6 +923,14 @@ config REGULATOR_RN5T618
config REGULATOR_ROHM
tristate
config REGULATOR_RT4801
tristate "Richtek RT4801 Regulators"
depends on I2C
select REGMAP_I2C
help
This adds support for voltage regulators in Richtek RT4801 Display Bias IC.
The device supports two regulators (DSVP/DSVN).
config REGULATOR_RT5033
tristate "Richtek RT5033 Regulators"
depends on MFD_RT5033
......@@ -902,16 +939,25 @@ config REGULATOR_RT5033
RT5033 PMIC. The device supports multiple regulators like
current source, LDO and Buck.
config REGULATOR_RTMV20
tristate "RTMV20 Laser Diode Regulator"
depends on I2C
select REGMAP_I2C
help
This driver adds support for the load switch current regulator on
the Richtek RTMV20. It can support the load current up to 6A and
integrate strobe/vsync/fsin signal to synchronize the IR camera.
config REGULATOR_S2MPA01
tristate "Samsung S2MPA01 voltage regulator"
depends on MFD_SEC_CORE
depends on MFD_SEC_CORE || COMPILE_TEST
help
This driver controls Samsung S2MPA01 voltage output regulator
via I2C bus. S2MPA01 has 10 Bucks and 26 LDO outputs.
config REGULATOR_S2MPS11
tristate "Samsung S2MPS11/13/14/15/S2MPU02 voltage regulator"
depends on MFD_SEC_CORE
depends on MFD_SEC_CORE || COMPILE_TEST
help
This driver supports a Samsung S2MPS11/13/14/15/S2MPU02 voltage
output regulator via I2C bus. The chip is comprised of high efficient
......@@ -920,7 +966,7 @@ config REGULATOR_S2MPS11
config REGULATOR_S5M8767
tristate "Samsung S5M8767A voltage regulator"
depends on MFD_SEC_CORE
depends on MFD_SEC_CORE || COMPILE_TEST
help
This driver supports a Samsung S5M8767A voltage output regulator
via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
......
......@@ -32,6 +32,7 @@ obj-$(CONFIG_REGULATOR_BD70528) += bd70528-regulator.o
obj-$(CONFIG_REGULATOR_BD71828) += bd71828-regulator.o
obj-$(CONFIG_REGULATOR_BD718XX) += bd718x7-regulator.o
obj-$(CONFIG_REGULATOR_BD9571MWV) += bd9571mwv-regulator.o
obj-$(CONFIG_REGULATOR_BD957XMUF) += bd9576-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x-regulator.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
......@@ -88,6 +89,7 @@ obj-$(CONFIG_REGULATOR_MPQ7920) += mpq7920.o
obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o
obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o
obj-$(CONFIG_REGULATOR_MT6358) += mt6358-regulator.o
obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o
obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o
obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o
obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o
......@@ -107,11 +109,14 @@ obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY) += rpi-panel-attiny-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o
obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
obj-$(CONFIG_REGULATOR_ROHM) += rohm-regulator.o
obj-$(CONFIG_REGULATOR_RT4801) += rt4801-regulator.o
obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
obj-$(CONFIG_REGULATOR_RTMV20) += rtmv20-regulator.o
obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2020 ROHM Semiconductors
// ROHM BD9576MUF/BD9573MUF regulator driver
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/mfd/rohm-bd957x.h>
#include <linux/mfd/rohm-generic.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/slab.h>
#define BD957X_VOUTS1_VOLT 3300000
#define BD957X_VOUTS4_BASE_VOLT 1030000
#define BD957X_VOUTS34_NUM_VOLT 32
static int vout1_volt_table[] = {5000000, 4900000, 4800000, 4700000, 4600000,
4500000, 4500000, 4500000, 5000000, 5100000,
5200000, 5300000, 5400000, 5500000, 5500000,
5500000};
static int vout2_volt_table[] = {1800000, 1780000, 1760000, 1740000, 1720000,
1700000, 1680000, 1660000, 1800000, 1820000,
1840000, 1860000, 1880000, 1900000, 1920000,
1940000};
static int voutl1_volt_table[] = {2500000, 2540000, 2580000, 2620000, 2660000,
2700000, 2740000, 2780000, 2500000, 2460000,
2420000, 2380000, 2340000, 2300000, 2260000,
2220000};
struct bd957x_regulator_data {
struct regulator_desc desc;
int base_voltage;
};
static int bd957x_vout34_list_voltage(struct regulator_dev *rdev,
unsigned int selector)
{
const struct regulator_desc *desc = rdev->desc;
int multiplier = selector & desc->vsel_mask & 0x7f;
int tune;
/* VOUT3 and 4 has 10mV step */
tune = multiplier * 10000;
if (!(selector & 0x80))
return desc->fixed_uV - tune;
return desc->fixed_uV + tune;
}
static int bd957x_list_voltage(struct regulator_dev *rdev,
unsigned int selector)
{
const struct regulator_desc *desc = rdev->desc;
int index = selector & desc->vsel_mask & 0x7f;
if (!(selector & 0x80))
index += desc->n_voltages/2;
if (index >= desc->n_voltages)
return -EINVAL;
return desc->volt_table[index];
}
static const struct regulator_ops bd957x_vout34_ops = {
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = bd957x_vout34_list_voltage,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
};
static const struct regulator_ops bd957X_vouts1_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
};
static const struct regulator_ops bd957x_ops = {
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = bd957x_list_voltage,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
};
static struct bd957x_regulator_data bd9576_regulators[] = {
{
.desc = {
.name = "VD50",
.of_match = of_match_ptr("regulator-vd50"),
.regulators_node = of_match_ptr("regulators"),
.id = BD957X_VD50,
.type = REGULATOR_VOLTAGE,
.ops = &bd957x_ops,
.volt_table = &vout1_volt_table[0],
.n_voltages = ARRAY_SIZE(vout1_volt_table),
.vsel_reg = BD957X_REG_VOUT1_TUNE,
.vsel_mask = BD957X_MASK_VOUT1_TUNE,
.enable_reg = BD957X_REG_POW_TRIGGER1,
.enable_mask = BD957X_REGULATOR_EN_MASK,
.enable_val = BD957X_REGULATOR_DIS_VAL,
.enable_is_inverted = true,
.owner = THIS_MODULE,
},
},
{
.desc = {
.name = "VD18",
.of_match = of_match_ptr("regulator-vd18"),
.regulators_node = of_match_ptr("regulators"),
.id = BD957X_VD18,
.type = REGULATOR_VOLTAGE,
.ops = &bd957x_ops,
.volt_table = &vout2_volt_table[0],
.n_voltages = ARRAY_SIZE(vout2_volt_table),
.vsel_reg = BD957X_REG_VOUT2_TUNE,
.vsel_mask = BD957X_MASK_VOUT2_TUNE,
.enable_reg = BD957X_REG_POW_TRIGGER2,
.enable_mask = BD957X_REGULATOR_EN_MASK,
.enable_val = BD957X_REGULATOR_DIS_VAL,
.enable_is_inverted = true,
.owner = THIS_MODULE,
},
},
{
.desc = {
.name = "VDDDR",
.of_match = of_match_ptr("regulator-vdddr"),
.regulators_node = of_match_ptr("regulators"),
.id = BD957X_VDDDR,
.ops = &bd957x_vout34_ops,
.type = REGULATOR_VOLTAGE,
.n_voltages = BD957X_VOUTS34_NUM_VOLT,
.vsel_reg = BD957X_REG_VOUT3_TUNE,
.vsel_mask = BD957X_MASK_VOUT3_TUNE,
.enable_reg = BD957X_REG_POW_TRIGGER3,
.enable_mask = BD957X_REGULATOR_EN_MASK,
.enable_val = BD957X_REGULATOR_DIS_VAL,
.enable_is_inverted = true,
.owner = THIS_MODULE,
},
},
{
.desc = {
.name = "VD10",
.of_match = of_match_ptr("regulator-vd10"),
.regulators_node = of_match_ptr("regulators"),
.id = BD957X_VD10,
.ops = &bd957x_vout34_ops,
.type = REGULATOR_VOLTAGE,
.fixed_uV = BD957X_VOUTS4_BASE_VOLT,
.n_voltages = BD957X_VOUTS34_NUM_VOLT,
.vsel_reg = BD957X_REG_VOUT4_TUNE,
.vsel_mask = BD957X_MASK_VOUT4_TUNE,
.enable_reg = BD957X_REG_POW_TRIGGER4,
.enable_mask = BD957X_REGULATOR_EN_MASK,
.enable_val = BD957X_REGULATOR_DIS_VAL,
.enable_is_inverted = true,
.owner = THIS_MODULE,
},
},
{
.desc = {
.name = "VOUTL1",
.of_match = of_match_ptr("regulator-voutl1"),
.regulators_node = of_match_ptr("regulators"),
.id = BD957X_VOUTL1,
.ops = &bd957x_ops,
.type = REGULATOR_VOLTAGE,
.volt_table = &voutl1_volt_table[0],
.n_voltages = ARRAY_SIZE(voutl1_volt_table),
.vsel_reg = BD957X_REG_VOUTL1_TUNE,
.vsel_mask = BD957X_MASK_VOUTL1_TUNE,
.enable_reg = BD957X_REG_POW_TRIGGERL1,
.enable_mask = BD957X_REGULATOR_EN_MASK,
.enable_val = BD957X_REGULATOR_DIS_VAL,
.enable_is_inverted = true,
.owner = THIS_MODULE,
},
},
{
.desc = {
.name = "VOUTS1",
.of_match = of_match_ptr("regulator-vouts1"),
.regulators_node = of_match_ptr("regulators"),
.id = BD957X_VOUTS1,
.ops = &bd957X_vouts1_regulator_ops,
.type = REGULATOR_VOLTAGE,
.n_voltages = 1,
.fixed_uV = BD957X_VOUTS1_VOLT,
.enable_reg = BD957X_REG_POW_TRIGGERS1,
.enable_mask = BD957X_REGULATOR_EN_MASK,
.enable_val = BD957X_REGULATOR_DIS_VAL,
.enable_is_inverted = true,
.owner = THIS_MODULE,
},
},
};
static int bd957x_probe(struct platform_device *pdev)
{
struct regmap *regmap;
struct regulator_config config = { 0 };
int i, err;
bool vout_mode, ddr_sel;
const struct bd957x_regulator_data *reg_data = &bd9576_regulators[0];
unsigned int num_reg_data = ARRAY_SIZE(bd9576_regulators);
enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!regmap) {
dev_err(&pdev->dev, "No regmap\n");
return -EINVAL;
}
vout_mode = of_property_read_bool(pdev->dev.parent->of_node,
"rohm,vout1-en-low");
if (vout_mode) {
struct gpio_desc *en;
dev_dbg(&pdev->dev, "GPIO controlled mode\n");
/* VOUT1 enable state judged by VOUT1_EN pin */
/* See if we have GPIO defined */
en = devm_gpiod_get_from_of_node(&pdev->dev,
pdev->dev.parent->of_node,
"rohm,vout1-en-gpios", 0,
GPIOD_OUT_LOW, "vout1-en");
if (!IS_ERR(en)) {
/* VOUT1_OPS gpio ctrl */
/*
* Regulator core prioritizes the ena_gpio over
* enable/disable/is_enabled callbacks so no need to
* clear them. We can still use same ops
*/
config.ena_gpiod = en;
} else {
/*
* In theory it is possible someone wants to set
* vout1-en LOW during OTP loading and set VOUT1 to be
* controlled by GPIO - but control the GPIO from some
* where else than this driver. For that to work we
* should unset the is_enabled callback here.
*
* I believe such case where rohm,vout1-en-low is set
* and vout1-en-gpios is not is likely to be a
* misconfiguration. So let's just err out for now.
*/
dev_err(&pdev->dev,
"Failed to get VOUT1 control GPIO\n");
return PTR_ERR(en);
}
}
/*
* If more than one PMIC needs to be controlled by same processor then
* allocate the regulator data array here and use bd9576_regulators as
* template. At the moment I see no such use-case so I spare some
* bytes and use bd9576_regulators directly for non-constant configs
* like DDR voltage selection.
*/
ddr_sel = of_property_read_bool(pdev->dev.parent->of_node,
"rohm,ddr-sel-low");
if (ddr_sel)
bd9576_regulators[2].desc.fixed_uV = 1350000;
else
bd9576_regulators[2].desc.fixed_uV = 1500000;
switch (chip) {
case ROHM_CHIP_TYPE_BD9576:
dev_dbg(&pdev->dev, "Found BD9576MUF\n");
break;
case ROHM_CHIP_TYPE_BD9573:
dev_dbg(&pdev->dev, "Found BD9573MUF\n");
break;
default:
dev_err(&pdev->dev, "Unsupported chip type\n");
err = -EINVAL;
goto err;
}
config.dev = pdev->dev.parent;
config.regmap = regmap;
for (i = 0; i < num_reg_data; i++) {
const struct regulator_desc *desc;
struct regulator_dev *rdev;
const struct bd957x_regulator_data *r;
r = &reg_data[i];
desc = &r->desc;
rdev = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev,
"failed to register %s regulator\n",
desc->name);
err = PTR_ERR(rdev);
goto err;
}
/*
* Clear the VOUT1 GPIO setting - rest of the regulators do not
* support GPIO control
*/
config.ena_gpiod = NULL;
}
err:
return err;
}
static const struct platform_device_id bd957x_pmic_id[] = {
{ "bd9573-pmic", ROHM_CHIP_TYPE_BD9573 },
{ "bd9576-pmic", ROHM_CHIP_TYPE_BD9576 },
{ },
};
MODULE_DEVICE_TABLE(platform, bd957x_pmic_id);
static struct platform_driver bd957x_regulator = {
.driver = {
.name = "bd957x-pmic",
},
.probe = bd957x_probe,
.id_table = bd957x_pmic_id,
};
module_platform_driver(bd957x_regulator);
MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
MODULE_DESCRIPTION("ROHM BD9576/BD9573 voltage regulator driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:bd957x-pmic");
This diff is collapsed.
......@@ -485,10 +485,8 @@ static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data)
{
struct da9055_regulator *regulator = data;
regulator_lock(regulator->rdev);
regulator_notifier_call_chain(regulator->rdev,
REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(regulator->rdev);
return IRQ_HANDLED;
}
......
......@@ -907,10 +907,8 @@ static irqreturn_t da9062_ldo_lim_event(int irq, void *data)
continue;
if (BIT(regl->info->oc_event.lsb) & bits) {
regulator_lock(regl->rdev);
regulator_notifier_call_chain(regl->rdev,
REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(regl->rdev);
handled = IRQ_HANDLED;
}
}
......
......@@ -574,10 +574,8 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data)
continue;
if (BIT(regl->info->oc_event.lsb) & bits) {
regulator_lock(regl->rdev);
regulator_notifier_call_chain(regl->rdev,
REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(regl->rdev);
}
}
......
......@@ -77,8 +77,6 @@ static irqreturn_t da9210_irq_handler(int irq, void *data)
if (error < 0)
goto error_i2c;
regulator_lock(chip->rdev);
if (val & DA9210_E_OVCURR) {
regulator_notifier_call_chain(chip->rdev,
REGULATOR_EVENT_OVER_CURRENT,
......@@ -103,8 +101,6 @@ static irqreturn_t da9210_irq_handler(int irq, void *data)
handled |= DA9210_E_VMAX;
}
regulator_unlock(chip->rdev);
if (handled) {
/* Clear handled events */
error = regmap_write(chip->regmap, DA9210_REG_EVENT_B, handled);
......@@ -125,7 +121,7 @@ static irqreturn_t da9210_irq_handler(int irq, void *data)
* I2C driver interface functions
*/
static const struct of_device_id da9210_dt_ids[] = {
static const struct of_device_id __maybe_unused da9210_dt_ids[] = {
{ .compatible = "dlg,da9210", },
{ }
};
......
......@@ -51,10 +51,24 @@ static const struct regmap_range_cfg da9211_regmap_range[] = {
},
};
static bool da9211_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case DA9211_REG_STATUS_A:
case DA9211_REG_STATUS_B:
case DA9211_REG_EVENT_A:
case DA9211_REG_EVENT_B:
return true;
}
return false;
}
static const struct regmap_config da9211_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 5 * 128,
.volatile_reg = da9211_volatile_reg,
.cache_type = REGCACHE_RBTREE,
.ranges = da9211_regmap_range,
.num_ranges = ARRAY_SIZE(da9211_regmap_range),
};
......@@ -332,10 +346,8 @@ static irqreturn_t da9211_irq_handler(int irq, void *data)
goto error_i2c;
if (reg_val & DA9211_E_OV_CURR_A) {
regulator_lock(chip->rdev[0]);
regulator_notifier_call_chain(chip->rdev[0],
REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(chip->rdev[0]);
err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
DA9211_E_OV_CURR_A);
......@@ -346,10 +358,8 @@ static irqreturn_t da9211_irq_handler(int irq, void *data)
}
if (reg_val & DA9211_E_OV_CURR_B) {
regulator_lock(chip->rdev[1]);
regulator_notifier_call_chain(chip->rdev[1],
REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(chip->rdev[1]);
err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
DA9211_E_OV_CURR_B);
......
......@@ -67,8 +67,6 @@ static int power_state_active_get(void)
static struct ux500_regulator_debug {
struct dentry *dir;
struct dentry *status_file;
struct dentry *power_state_cnt_file;
struct dbx500_regulator_info *regulator_array;
int num_regulators;
u8 *state_before_suspend;
......@@ -117,22 +115,14 @@ ux500_regulator_debug_init(struct platform_device *pdev,
{
/* create directory */
rdebug.dir = debugfs_create_dir("ux500-regulator", NULL);
if (!rdebug.dir)
goto exit_no_debugfs;
/* create "status" file */
rdebug.status_file = debugfs_create_file("status",
S_IRUGO, rdebug.dir, &pdev->dev,
&ux500_regulator_status_fops);
if (!rdebug.status_file)
goto exit_destroy_dir;
debugfs_create_file("status", S_IRUGO, rdebug.dir, &pdev->dev,
&ux500_regulator_status_fops);
/* create "power-state-count" file */
rdebug.power_state_cnt_file = debugfs_create_file("power-state-count",
S_IRUGO, rdebug.dir, &pdev->dev,
&ux500_regulator_power_state_cnt_fops);
if (!rdebug.power_state_cnt_file)
goto exit_destroy_status;
debugfs_create_file("power-state-count", S_IRUGO, rdebug.dir,
&pdev->dev, &ux500_regulator_power_state_cnt_fops);
rdebug.regulator_array = regulator_info;
rdebug.num_regulators = num_regulators;
......@@ -150,13 +140,7 @@ ux500_regulator_debug_init(struct platform_device *pdev,
exit_free:
kfree(rdebug.state_before_suspend);
exit_destroy_power_state:
debugfs_remove(rdebug.power_state_cnt_file);
exit_destroy_status:
debugfs_remove(rdebug.status_file);
exit_destroy_dir:
debugfs_remove(rdebug.dir);
exit_no_debugfs:
dev_err(&pdev->dev, "failed to create debugfs entries.\n");
debugfs_remove_recursive(rdebug.dir);
return -ENOMEM;
}
......
......@@ -21,13 +21,13 @@
struct regulator_dev *dummy_regulator_rdev;
static struct regulator_init_data dummy_initdata = {
static const struct regulator_init_data dummy_initdata = {
.constraints = {
.always_on = 1,
},
};
static struct regulator_ops dummy_ops;
static const struct regulator_ops dummy_ops;
static const struct regulator_desc dummy_desc = {
.name = "regulator-dummy",
......
......@@ -436,7 +436,7 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
return pdata;
}
static const struct of_device_id fan53555_dt_ids[] = {
static const struct of_device_id __maybe_unused fan53555_dt_ids[] = {
{
.compatible = "fcs,fan53526",
.data = (void *)FAN53526_VENDOR_FAIRCHILD,
......
......@@ -41,14 +41,6 @@ struct fixed_dev_type {
bool has_enable_clock;
};
static const struct fixed_dev_type fixed_voltage_data = {
.has_enable_clock = false,
};
static const struct fixed_dev_type fixed_clkenable_data = {
.has_enable_clock = true,
};
static int reg_clock_enable(struct regulator_dev *rdev)
{
struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
......@@ -131,10 +123,10 @@ of_get_fixed_voltage_config(struct device *dev,
return config;
}
static struct regulator_ops fixed_voltage_ops = {
static const struct regulator_ops fixed_voltage_ops = {
};
static struct regulator_ops fixed_voltage_clkenabled_ops = {
static const struct regulator_ops fixed_voltage_clkenabled_ops = {
.enable = reg_clock_enable,
.disable = reg_clock_disable,
.is_enabled = reg_clock_is_enabled,
......@@ -260,6 +252,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
}
#if defined(CONFIG_OF)
static const struct fixed_dev_type fixed_voltage_data = {
.has_enable_clock = false,
};
static const struct fixed_dev_type fixed_clkenable_data = {
.has_enable_clock = true,
};
static const struct of_device_id fixed_of_match[] = {
{
.compatible = "regulator-fixed",
......
......@@ -98,6 +98,7 @@ static const struct regulator_ops lochnagar_vddcore_ops = {
};
static const struct linear_range lochnagar_vddcore_ranges[] = {
REGULATOR_LINEAR_RANGE(600000, 0, 0x7, 0),
REGULATOR_LINEAR_RANGE(600000, 0x8, 0x41, 12500),
};
......
......@@ -49,53 +49,15 @@ struct lp8755_chip {
struct regulator_dev *rdev[LP8755_BUCK_MAX];
};
/**
*lp8755_read : read a single register value from lp8755.
*@pchip : device to read from
*@reg : register to read from
*@val : pointer to store read value
*/
static int lp8755_read(struct lp8755_chip *pchip, unsigned int reg,
unsigned int *val)
{
return regmap_read(pchip->regmap, reg, val);
}
/**
*lp8755_write : write a single register value to lp8755.
*@pchip : device to write to
*@reg : register to write to
*@val : value to be written
*/
static int lp8755_write(struct lp8755_chip *pchip, unsigned int reg,
unsigned int val)
{
return regmap_write(pchip->regmap, reg, val);
}
/**
*lp8755_update_bits : set the values of bit fields in lp8755 register.
*@pchip : device to read from
*@reg : register to update
*@mask : bitmask to be changed
*@val : value for bitmask
*/
static int lp8755_update_bits(struct lp8755_chip *pchip, unsigned int reg,
unsigned int mask, unsigned int val)
{
return regmap_update_bits(pchip->regmap, reg, mask, val);
}
static int lp8755_buck_enable_time(struct regulator_dev *rdev)
{
int ret;
unsigned int regval;
enum lp8755_bucks id = rdev_get_id(rdev);
struct lp8755_chip *pchip = rdev_get_drvdata(rdev);
ret = lp8755_read(pchip, 0x12 + id, &regval);
ret = regmap_read(rdev->regmap, 0x12 + id, &regval);
if (ret < 0) {
dev_err(pchip->dev, "i2c access error %s\n", __func__);
dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return ret;
}
return (regval & 0xff) * 100;
......@@ -115,17 +77,17 @@ static int lp8755_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
break;
case REGULATOR_MODE_NORMAL:
/* enable automatic pwm/pfm mode */
ret = lp8755_update_bits(pchip, 0x08 + id, 0x20, 0x00);
ret = regmap_update_bits(rdev->regmap, 0x08 + id, 0x20, 0x00);
if (ret < 0)
goto err_i2c;
break;
case REGULATOR_MODE_IDLE:
/* enable automatic pwm/pfm/lppfm mode */
ret = lp8755_update_bits(pchip, 0x08 + id, 0x20, 0x20);
ret = regmap_update_bits(rdev->regmap, 0x08 + id, 0x20, 0x20);
if (ret < 0)
goto err_i2c;
ret = lp8755_update_bits(pchip, 0x10, 0x01, 0x01);
ret = regmap_update_bits(rdev->regmap, 0x10, 0x01, 0x01);
if (ret < 0)
goto err_i2c;
break;
......@@ -135,12 +97,12 @@ static int lp8755_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
regbval = (0x01 << id);
}
ret = lp8755_update_bits(pchip, 0x06, 0x01 << id, regbval);
ret = regmap_update_bits(rdev->regmap, 0x06, 0x01 << id, regbval);
if (ret < 0)
goto err_i2c;
return ret;
err_i2c:
dev_err(pchip->dev, "i2c access error %s\n", __func__);
dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return ret;
}
......@@ -149,9 +111,8 @@ static unsigned int lp8755_buck_get_mode(struct regulator_dev *rdev)
int ret;
unsigned int regval;
enum lp8755_bucks id = rdev_get_id(rdev);
struct lp8755_chip *pchip = rdev_get_drvdata(rdev);
ret = lp8755_read(pchip, 0x06, &regval);
ret = regmap_read(rdev->regmap, 0x06, &regval);
if (ret < 0)
goto err_i2c;
......@@ -159,7 +120,7 @@ static unsigned int lp8755_buck_get_mode(struct regulator_dev *rdev)
if (regval & (0x01 << id))
return REGULATOR_MODE_FAST;
ret = lp8755_read(pchip, 0x08 + id, &regval);
ret = regmap_read(rdev->regmap, 0x08 + id, &regval);
if (ret < 0)
goto err_i2c;
......@@ -171,7 +132,7 @@ static unsigned int lp8755_buck_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
err_i2c:
dev_err(pchip->dev, "i2c access error %s\n", __func__);
dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return 0;
}
......@@ -180,7 +141,6 @@ static int lp8755_buck_set_ramp(struct regulator_dev *rdev, int ramp)
int ret;
unsigned int regval = 0x00;
enum lp8755_bucks id = rdev_get_id(rdev);
struct lp8755_chip *pchip = rdev_get_drvdata(rdev);
/* uV/us */
switch (ramp) {
......@@ -209,17 +169,17 @@ static int lp8755_buck_set_ramp(struct regulator_dev *rdev, int ramp)
regval = 0x00;
break;
default:
dev_err(pchip->dev,
dev_err(&rdev->dev,
"Not supported ramp value %d %s\n", ramp, __func__);
return -EINVAL;
}
ret = lp8755_update_bits(pchip, 0x07 + id, 0x07, regval);
ret = regmap_update_bits(rdev->regmap, 0x07 + id, 0x07, regval);
if (ret < 0)
goto err_i2c;
return ret;
err_i2c:
dev_err(pchip->dev, "i2c access error %s\n", __func__);
dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return ret;
}
......@@ -278,7 +238,7 @@ static int lp8755_init_data(struct lp8755_chip *pchip)
struct lp8755_platform_data *pdata = pchip->pdata;
/* read back muti-phase configuration */
ret = lp8755_read(pchip, 0x3D, &regval);
ret = regmap_read(pchip->regmap, 0x3D, &regval);
if (ret < 0)
goto out_i2c_error;
pchip->mphase = regval & 0x0F;
......@@ -356,11 +316,11 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
struct lp8755_chip *pchip = data;
/* read flag0 register */
ret = lp8755_read(pchip, 0x0D, &flag0);
ret = regmap_read(pchip->regmap, 0x0D, &flag0);
if (ret < 0)
goto err_i2c;
/* clear flag register to pull up int. pin */
ret = lp8755_write(pchip, 0x0D, 0x00);
ret = regmap_write(pchip->regmap, 0x0D, 0x00);
if (ret < 0)
goto err_i2c;
......@@ -369,19 +329,17 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
if ((flag0 & (0x4 << icnt))
&& (pchip->irqmask & (0x04 << icnt))
&& (pchip->rdev[icnt] != NULL)) {
regulator_lock(pchip->rdev[icnt]);
regulator_notifier_call_chain(pchip->rdev[icnt],
LP8755_EVENT_PWR_FAULT,
NULL);
regulator_unlock(pchip->rdev[icnt]);
}
/* read flag1 register */
ret = lp8755_read(pchip, 0x0E, &flag1);
ret = regmap_read(pchip->regmap, 0x0E, &flag1);
if (ret < 0)
goto err_i2c;
/* clear flag register to pull up int. pin */
ret = lp8755_write(pchip, 0x0E, 0x00);
ret = regmap_write(pchip->regmap, 0x0E, 0x00);
if (ret < 0)
goto err_i2c;
......@@ -389,22 +347,18 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
if ((flag1 & 0x01) && (pchip->irqmask & 0x01))
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
if (pchip->rdev[icnt] != NULL) {
regulator_lock(pchip->rdev[icnt]);
regulator_notifier_call_chain(pchip->rdev[icnt],
LP8755_EVENT_OCP,
NULL);
regulator_unlock(pchip->rdev[icnt]);
}
/* send OVP event to all regulator devices */
if ((flag1 & 0x02) && (pchip->irqmask & 0x02))
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
if (pchip->rdev[icnt] != NULL) {
regulator_lock(pchip->rdev[icnt]);
regulator_notifier_call_chain(pchip->rdev[icnt],
LP8755_EVENT_OVP,
NULL);
regulator_unlock(pchip->rdev[icnt]);
}
return IRQ_HANDLED;
......@@ -423,7 +377,7 @@ static int lp8755_int_config(struct lp8755_chip *pchip)
return 0;
}
ret = lp8755_read(pchip, 0x0F, &regval);
ret = regmap_read(pchip->regmap, 0x0F, &regval);
if (ret < 0) {
dev_err(pchip->dev, "i2c access error %s\n", __func__);
return ret;
......@@ -502,7 +456,7 @@ static int lp8755_probe(struct i2c_client *client,
err:
/* output disable */
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
lp8755_write(pchip, icnt, 0x00);
regmap_write(pchip->regmap, icnt, 0x00);
return ret;
}
......@@ -513,7 +467,7 @@ static int lp8755_remove(struct i2c_client *client)
struct lp8755_chip *pchip = i2c_get_clientdata(client);
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
lp8755_write(pchip, icnt, 0x00);
regmap_write(pchip->regmap, icnt, 0x00);
return 0;
}
......
......@@ -357,22 +357,16 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id)
if (irqstat & LTC3589_IRQSTAT_THERMAL_WARN) {
event = REGULATOR_EVENT_OVER_TEMP;
for (i = 0; i < LTC3589_NUM_REGULATORS; i++) {
regulator_lock(ltc3589->regulators[i]);
for (i = 0; i < LTC3589_NUM_REGULATORS; i++)
regulator_notifier_call_chain(ltc3589->regulators[i],
event, NULL);
regulator_unlock(ltc3589->regulators[i]);
}
}
if (irqstat & LTC3589_IRQSTAT_UNDERVOLT_WARN) {
event = REGULATOR_EVENT_UNDER_VOLTAGE;
for (i = 0; i < LTC3589_NUM_REGULATORS; i++) {
regulator_lock(ltc3589->regulators[i]);
for (i = 0; i < LTC3589_NUM_REGULATORS; i++)
regulator_notifier_call_chain(ltc3589->regulators[i],
event, NULL);
regulator_unlock(ltc3589->regulators[i]);
}
}
/* Clear warning condition */
......@@ -457,7 +451,7 @@ static const struct i2c_device_id ltc3589_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, ltc3589_i2c_id);
static const struct of_device_id ltc3589_of_match[] = {
static const struct of_device_id __maybe_unused ltc3589_of_match[] = {
{
.compatible = "lltc,ltc3589",
.data = (void *)LTC3589,
......
......@@ -276,23 +276,17 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id)
if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) {
dev_warn(dev, "Over-temperature Warning\n");
event = REGULATOR_EVENT_OVER_TEMP;
for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
regulator_lock(ltc3676->regulators[i]);
for (i = 0; i < LTC3676_NUM_REGULATORS; i++)
regulator_notifier_call_chain(ltc3676->regulators[i],
event, NULL);
regulator_unlock(ltc3676->regulators[i]);
}
}
if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) {
dev_info(dev, "Undervoltage Warning\n");
event = REGULATOR_EVENT_UNDER_VOLTAGE;
for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
regulator_lock(ltc3676->regulators[i]);
for (i = 0; i < LTC3676_NUM_REGULATORS; i++)
regulator_notifier_call_chain(ltc3676->regulators[i],
event, NULL);
regulator_unlock(ltc3676->regulators[i]);
}
}
/* Clear warning condition */
......@@ -368,7 +362,7 @@ static const struct i2c_device_id ltc3676_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, ltc3676_i2c_id);
static const struct of_device_id ltc3676_of_match[] = {
static const struct of_device_id __maybe_unused ltc3676_of_match[] = {
{ .compatible = "lltc,ltc3676" },
{ },
};
......
......@@ -201,7 +201,7 @@ static int of_get_max1586_platform_data(struct device *dev,
return 0;
}
static const struct of_device_id max1586_of_match[] = {
static const struct of_device_id __maybe_unused max1586_of_match[] = {
{ .compatible = "maxim,max1586", },
{},
};
......
......@@ -274,7 +274,7 @@ static int max77826_i2c_probe(struct i2c_client *client)
return max77826_read_device_id(regmap, dev);
}
static const struct of_device_id max77826_of_match[] = {
static const struct of_device_id __maybe_unused max77826_of_match[] = {
{ .compatible = "maxim,max77826" },
{ /* sentinel */ }
};
......
......@@ -18,18 +18,70 @@
#define MP886X_V_BOOT (1 << 7)
#define MP886X_SYSCNTLREG1 0x01
#define MP886X_MODE (1 << 0)
#define MP886X_SLEW_SHIFT 3
#define MP886X_SLEW_MASK (0x7 << MP886X_SLEW_SHIFT)
#define MP886X_GO (1 << 6)
#define MP886X_EN (1 << 7)
#define MP8869_SYSCNTLREG2 0x02
struct mp886x_cfg_info {
const struct regulator_ops *rops;
const int slew_rates[8];
const int switch_freq[4];
const u8 fs_reg;
const u8 fs_shift;
};
struct mp886x_device_info {
struct device *dev;
struct regulator_desc desc;
struct regulator_init_data *regulator;
struct gpio_desc *en_gpio;
const struct mp886x_cfg_info *ci;
u32 r[2];
unsigned int sel;
};
static int mp886x_set_ramp(struct regulator_dev *rdev, int ramp)
{
struct mp886x_device_info *di = rdev_get_drvdata(rdev);
const struct mp886x_cfg_info *ci = di->ci;
int reg = -1, i;
for (i = 0; i < ARRAY_SIZE(ci->slew_rates); i++) {
if (ramp <= ci->slew_rates[i])
reg = i;
else
break;
}
if (reg < 0) {
dev_err(di->dev, "unsupported ramp value %d\n", ramp);
return -EINVAL;
}
return regmap_update_bits(rdev->regmap, MP886X_SYSCNTLREG1,
MP886X_SLEW_MASK, reg << MP886X_SLEW_SHIFT);
}
static void mp886x_set_switch_freq(struct mp886x_device_info *di,
struct regmap *regmap,
u32 freq)
{
const struct mp886x_cfg_info *ci = di->ci;
int i;
for (i = 0; i < ARRAY_SIZE(ci->switch_freq); i++) {
if (freq == ci->switch_freq[i]) {
regmap_update_bits(regmap, ci->fs_reg,
0x3 << ci->fs_shift, i << ci->fs_shift);
return;
}
}
dev_err(di->dev, "invalid frequency %d\n", freq);
}
static int mp886x_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
switch (mode) {
......@@ -117,6 +169,29 @@ static const struct regulator_ops mp8869_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
.set_mode = mp886x_set_mode,
.get_mode = mp886x_get_mode,
.set_ramp_delay = mp886x_set_ramp,
};
static const struct mp886x_cfg_info mp8869_ci = {
.rops = &mp8869_regulator_ops,
.slew_rates = {
40000,
30000,
20000,
10000,
5000,
2500,
1250,
625,
},
.switch_freq = {
500000,
750000,
1000000,
1250000,
},
.fs_reg = MP8869_SYSCNTLREG2,
.fs_shift = 4,
};
static int mp8867_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
......@@ -173,6 +248,29 @@ static const struct regulator_ops mp8867_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
.set_mode = mp886x_set_mode,
.get_mode = mp886x_get_mode,
.set_ramp_delay = mp886x_set_ramp,
};
static const struct mp886x_cfg_info mp8867_ci = {
.rops = &mp8867_regulator_ops,
.slew_rates = {
64000,
32000,
16000,
8000,
4000,
2000,
1000,
500,
},
.switch_freq = {
500000,
750000,
1000000,
1500000,
},
.fs_reg = MP886X_SYSCNTLREG1,
.fs_shift = 1,
};
static int mp886x_regulator_register(struct mp886x_device_info *di,
......@@ -183,7 +281,7 @@ static int mp886x_regulator_register(struct mp886x_device_info *di,
rdesc->name = "mp886x-reg";
rdesc->supply_name = "vin";
rdesc->ops = of_device_get_match_data(di->dev);
rdesc->ops = di->ci->rops;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->n_voltages = 128;
rdesc->enable_reg = MP886X_SYSCNTLREG1;
......@@ -213,6 +311,7 @@ static int mp886x_i2c_probe(struct i2c_client *client)
struct mp886x_device_info *di;
struct regulator_config config = { };
struct regmap *regmap;
u32 freq;
int ret;
di = devm_kzalloc(dev, sizeof(struct mp886x_device_info), GFP_KERNEL);
......@@ -234,6 +333,7 @@ static int mp886x_i2c_probe(struct i2c_client *client)
if (IS_ERR(di->en_gpio))
return PTR_ERR(di->en_gpio);
di->ci = of_device_get_match_data(dev);
di->dev = dev;
regmap = devm_regmap_init_i2c(client, &mp886x_regmap_config);
......@@ -249,6 +349,9 @@ static int mp886x_i2c_probe(struct i2c_client *client)
config.driver_data = di;
config.of_node = np;
if (!of_property_read_u32(np, "mps,switch-frequency-hz", &freq))
mp886x_set_switch_freq(di, regmap, freq);
ret = mp886x_regulator_register(di, &config);
if (ret < 0)
dev_err(dev, "Failed to register regulator!\n");
......@@ -258,11 +361,11 @@ static int mp886x_i2c_probe(struct i2c_client *client)
static const struct of_device_id mp886x_dt_ids[] = {
{
.compatible = "mps,mp8867",
.data = &mp8867_regulator_ops
.data = &mp8867_ci
},
{
.compatible = "mps,mp8869",
.data = &mp8869_regulator_ops
.data = &mp8869_ci
},
{ }
};
......
This diff is collapsed.
......@@ -90,7 +90,7 @@ static int pca9450_dvs_set_ramp_delay(struct regulator_dev *rdev,
BUCK1_RAMP_MASK, ramp_value << 6);
}
static struct regulator_ops pca9450_dvs_buck_regulator_ops = {
static const struct regulator_ops pca9450_dvs_buck_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
......@@ -101,7 +101,7 @@ static struct regulator_ops pca9450_dvs_buck_regulator_ops = {
.set_ramp_delay = pca9450_dvs_set_ramp_delay,
};
static struct regulator_ops pca9450_buck_regulator_ops = {
static const struct regulator_ops pca9450_buck_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
......@@ -111,7 +111,7 @@ static struct regulator_ops pca9450_buck_regulator_ops = {
.set_voltage_time_sel = regulator_set_voltage_time_sel,
};
static struct regulator_ops pca9450_ldo_regulator_ops = {
static const struct regulator_ops pca9450_ldo_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
......
......@@ -233,13 +233,10 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data)
if (reg_val & PV88060_E_VDD_FLT) {
for (i = 0; i < PV88060_MAX_REGULATORS; i++) {
if (chip->rdev[i] != NULL) {
regulator_lock(chip->rdev[i]);
if (chip->rdev[i] != NULL)
regulator_notifier_call_chain(chip->rdev[i],
REGULATOR_EVENT_UNDER_VOLTAGE,
NULL);
regulator_unlock(chip->rdev[i]);
}
}
err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
......@@ -252,13 +249,10 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data)
if (reg_val & PV88060_E_OVER_TEMP) {
for (i = 0; i < PV88060_MAX_REGULATORS; i++) {
if (chip->rdev[i] != NULL) {
regulator_lock(chip->rdev[i]);
if (chip->rdev[i] != NULL)
regulator_notifier_call_chain(chip->rdev[i],
REGULATOR_EVENT_OVER_TEMP,
NULL);
regulator_unlock(chip->rdev[i]);
}
}
err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
......
......@@ -334,13 +334,10 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data)
if (reg_val & PV88080_E_VDD_FLT) {
for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
if (chip->rdev[i] != NULL) {
regulator_lock(chip->rdev[i]);
if (chip->rdev[i] != NULL)
regulator_notifier_call_chain(chip->rdev[i],
REGULATOR_EVENT_UNDER_VOLTAGE,
NULL);
regulator_unlock(chip->rdev[i]);
}
}
err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
......@@ -353,13 +350,10 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data)
if (reg_val & PV88080_E_OVER_TEMP) {
for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
if (chip->rdev[i] != NULL) {
regulator_lock(chip->rdev[i]);
if (chip->rdev[i] != NULL)
regulator_notifier_call_chain(chip->rdev[i],
REGULATOR_EVENT_OVER_TEMP,
NULL);
regulator_unlock(chip->rdev[i]);
}
}
err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
......
......@@ -226,13 +226,10 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data)
if (reg_val & PV88090_E_VDD_FLT) {
for (i = 0; i < PV88090_MAX_REGULATORS; i++) {
if (chip->rdev[i] != NULL) {
regulator_lock(chip->rdev[i]);
if (chip->rdev[i] != NULL)
regulator_notifier_call_chain(chip->rdev[i],
REGULATOR_EVENT_UNDER_VOLTAGE,
NULL);
regulator_unlock(chip->rdev[i]);
}
}
err = regmap_write(chip->regmap, PV88090_REG_EVENT_A,
......@@ -245,13 +242,10 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data)
if (reg_val & PV88090_E_OVER_TEMP) {
for (i = 0; i < PV88090_MAX_REGULATORS; i++) {
if (chip->rdev[i] != NULL) {
regulator_lock(chip->rdev[i]);
if (chip->rdev[i] != NULL)
regulator_notifier_call_chain(chip->rdev[i],
REGULATOR_EVENT_OVER_TEMP,
NULL);
regulator_unlock(chip->rdev[i]);
}
}
err = regmap_write(chip->regmap, PV88090_REG_EVENT_A,
......
......@@ -390,7 +390,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
return 0;
}
static const struct of_device_id pwm_of_match[] = {
static const struct of_device_id __maybe_unused pwm_of_match[] = {
{ .compatible = "pwm-regulator" },
{ },
};
......
......@@ -44,16 +44,16 @@ struct labibb_regulator_data {
const char *name;
u8 type;
u16 base;
struct regulator_desc *desc;
const struct regulator_desc *desc;
};
static struct regulator_ops qcom_labibb_ops = {
static const struct regulator_ops qcom_labibb_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
};
static struct regulator_desc pmi8998_lab_desc = {
static const struct regulator_desc pmi8998_lab_desc = {
.enable_mask = LAB_ENABLE_CTL_MASK,
.enable_reg = (PMI8998_LAB_REG_BASE + REG_LABIBB_ENABLE_CTL),
.enable_val = LABIBB_CONTROL_ENABLE,
......@@ -65,7 +65,7 @@ static struct regulator_desc pmi8998_lab_desc = {
.ops = &qcom_labibb_ops,
};
static struct regulator_desc pmi8998_ibb_desc = {
static const struct regulator_desc pmi8998_ibb_desc = {
.enable_mask = IBB_ENABLE_CTL_MASK,
.enable_reg = (PMI8998_IBB_REG_BASE + REG_LABIBB_ENABLE_CTL),
.enable_val = LABIBB_CONTROL_ENABLE,
......
......@@ -967,7 +967,7 @@ static int rpmh_regulator_probe(struct platform_device *pdev)
return 0;
}
static const struct of_device_id rpmh_regulator_match_table[] = {
static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = {
{
.compatible = "qcom,pm8005-rpmh-regulators",
.data = pm8005_vreg_data,
......
......@@ -403,6 +403,24 @@ static const struct regulator_desc pm8950_pldo = {
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm8953_lnldo = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(1380000, 8, 15, 120000),
REGULATOR_LINEAR_RANGE(690000, 0, 7, 60000),
},
.n_linear_ranges = 2,
.n_voltages = 16,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm8953_ult_nldo = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(375000, 0, 93, 12500),
},
.n_linear_ranges = 1,
.n_voltages = 94,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm8994_hfsmps = {
.linear_ranges = (struct linear_range[]) {
......@@ -541,6 +559,69 @@ static const struct regulator_desc pmi8998_bob = {
.ops = &rpm_bob_ops,
};
static const struct regulator_desc pm660_ftsmps = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(355000, 0, 199, 5000),
},
.n_linear_ranges = 1,
.n_voltages = 200,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm660_hfsmps = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(320000, 0, 216, 8000),
},
.n_linear_ranges = 1,
.n_voltages = 217,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm660_ht_nldo = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(312000, 0, 124, 8000),
},
.n_linear_ranges = 1,
.n_voltages = 125,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm660_ht_lvpldo = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(1504000, 0, 62, 8000),
},
.n_linear_ranges = 1,
.n_voltages = 63,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm660_nldo660 = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(320000, 0, 123, 8000),
},
.n_linear_ranges = 1,
.n_voltages = 124,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm660_pldo660 = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(1504000, 0, 255, 8000),
},
.n_linear_ranges = 1,
.n_voltages = 256,
.ops = &rpm_smps_ldo_ops,
};
static const struct regulator_desc pm660l_bob = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(1800000, 0, 84, 32000),
},
.n_linear_ranges = 1,
.n_voltages = 85,
.ops = &rpm_bob_ops,
};
static const struct regulator_desc pms405_hfsmps3 = {
.linear_ranges = (struct linear_range[]) {
REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000),
......@@ -791,6 +872,41 @@ static const struct rpm_regulator_data rpm_pm8950_regulators[] = {
{}
};
static const struct rpm_regulator_data rpm_pm8953_regulators[] = {
{ "s1", QCOM_SMD_RPM_SMPA, 1, &pm8998_hfsmps, "vdd_s1" },
{ "s2", QCOM_SMD_RPM_SMPA, 2, &pm8998_hfsmps, "vdd_s2" },
{ "s3", QCOM_SMD_RPM_SMPA, 3, &pm8998_hfsmps, "vdd_s3" },
{ "s4", QCOM_SMD_RPM_SMPA, 4, &pm8998_hfsmps, "vdd_s4" },
{ "s5", QCOM_SMD_RPM_SMPA, 5, &pm8950_ftsmps2p5, "vdd_s5" },
{ "s6", QCOM_SMD_RPM_SMPA, 6, &pm8950_ftsmps2p5, "vdd_s6" },
{ "s7", QCOM_SMD_RPM_SMPA, 7, &pm8998_hfsmps, "vdd_s7" },
{ "l1", QCOM_SMD_RPM_LDOA, 1, &pm8953_ult_nldo, "vdd_l1" },
{ "l2", QCOM_SMD_RPM_LDOA, 2, &pm8953_ult_nldo, "vdd_l2_l3" },
{ "l3", QCOM_SMD_RPM_LDOA, 3, &pm8953_ult_nldo, "vdd_l2_l3" },
{ "l4", QCOM_SMD_RPM_LDOA, 4, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16_l19" },
{ "l5", QCOM_SMD_RPM_LDOA, 5, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16_l19" },
{ "l6", QCOM_SMD_RPM_LDOA, 6, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16_l19" },
{ "l7", QCOM_SMD_RPM_LDOA, 7, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16_l19" },
{ "l8", QCOM_SMD_RPM_LDOA, 8, &pm8950_ult_pldo, "vdd_l8_l11_l12_l13_l14_l15" },
{ "l9", QCOM_SMD_RPM_LDOA, 9, &pm8950_ult_pldo, "vdd_l9_l10_l17_l18_l22" },
{ "l10", QCOM_SMD_RPM_LDOA, 10, &pm8950_ult_pldo, "vdd_l9_l10_l17_l18_l22" },
{ "l11", QCOM_SMD_RPM_LDOA, 11, &pm8950_ult_pldo, "vdd_l8_l11_l12_l13_l14_l15" },
{ "l12", QCOM_SMD_RPM_LDOA, 12, &pm8950_ult_pldo, "vdd_l8_l11_l12_l13_l14_l15" },
{ "l13", QCOM_SMD_RPM_LDOA, 13, &pm8950_ult_pldo, "vdd_l8_l11_l12_l13_l14_l15" },
{ "l14", QCOM_SMD_RPM_LDOA, 14, &pm8950_ult_pldo, "vdd_l8_l11_l12_l13_l14_l15" },
{ "l15", QCOM_SMD_RPM_LDOA, 15, &pm8950_ult_pldo, "vdd_l8_l11_l12_l13_l14_l15" },
{ "l16", QCOM_SMD_RPM_LDOA, 16, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16_l19" },
{ "l17", QCOM_SMD_RPM_LDOA, 17, &pm8950_ult_pldo, "vdd_l9_l10_l17_l18_l22" },
{ "l18", QCOM_SMD_RPM_LDOA, 18, &pm8950_ult_pldo, "vdd_l9_l10_l17_l18_l22" },
{ "l19", QCOM_SMD_RPM_LDOA, 19, &pm8953_ult_nldo, "vdd_l4_l5_l6_l7_l16_l19" },
{ "l20", QCOM_SMD_RPM_LDOA, 20, &pm8953_lnldo, "vdd_l20" },
{ "l21", QCOM_SMD_RPM_LDOA, 21, &pm8953_lnldo, "vdd_l21" },
{ "l22", QCOM_SMD_RPM_LDOA, 22, &pm8950_ult_pldo, "vdd_l9_l10_l17_l18_l22" },
{ "l23", QCOM_SMD_RPM_LDOA, 23, &pm8953_ult_nldo, "vdd_l23" },
{}
};
static const struct rpm_regulator_data rpm_pm8994_regulators[] = {
{ "s1", QCOM_SMD_RPM_SMPA, 1, &pm8994_ftsmps, "vdd_s1" },
{ "s2", QCOM_SMD_RPM_SMPA, 2, &pm8994_ftsmps, "vdd_s2" },
......@@ -902,6 +1018,54 @@ static const struct rpm_regulator_data rpm_pmi8998_regulators[] = {
{}
};
static const struct rpm_regulator_data rpm_pm660_regulators[] = {
{ "s1", QCOM_SMD_RPM_SMPA, 1, &pm660_ftsmps, "vdd_s1" },
{ "s2", QCOM_SMD_RPM_SMPA, 2, &pm660_ftsmps, "vdd_s2" },
{ "s3", QCOM_SMD_RPM_SMPA, 3, &pm660_ftsmps, "vdd_s3" },
{ "s4", QCOM_SMD_RPM_SMPA, 4, &pm660_hfsmps, "vdd_s4" },
{ "s5", QCOM_SMD_RPM_SMPA, 5, &pm660_hfsmps, "vdd_s5" },
{ "s6", QCOM_SMD_RPM_SMPA, 6, &pm660_hfsmps, "vdd_s6" },
{ "l1", QCOM_SMD_RPM_LDOA, 1, &pm660_nldo660, "vdd_l1_l6_l7" },
{ "l2", QCOM_SMD_RPM_LDOA, 2, &pm660_ht_nldo, "vdd_l2_l3" },
{ "l3", QCOM_SMD_RPM_LDOA, 3, &pm660_nldo660, "vdd_l2_l3" },
/* l4 is unaccessible on PM660 */
{ "l5", QCOM_SMD_RPM_LDOA, 5, &pm660_ht_nldo, "vdd_l5" },
{ "l6", QCOM_SMD_RPM_LDOA, 6, &pm660_ht_nldo, "vdd_l1_l6_l7" },
{ "l7", QCOM_SMD_RPM_LDOA, 7, &pm660_ht_nldo, "vdd_l1_l6_l7" },
{ "l8", QCOM_SMD_RPM_LDOA, 8, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l9", QCOM_SMD_RPM_LDOA, 9, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l10", QCOM_SMD_RPM_LDOA, 10, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l11", QCOM_SMD_RPM_LDOA, 11, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l12", QCOM_SMD_RPM_LDOA, 12, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l13", QCOM_SMD_RPM_LDOA, 13, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l14", QCOM_SMD_RPM_LDOA, 14, &pm660_ht_lvpldo, "vdd_l8_l9_l10_l11_l12_l13_l14" },
{ "l15", QCOM_SMD_RPM_LDOA, 15, &pm660_pldo660, "vdd_l15_l16_l17_l18_l19" },
{ "l16", QCOM_SMD_RPM_LDOA, 16, &pm660_pldo660, "vdd_l15_l16_l17_l18_l19" },
{ "l17", QCOM_SMD_RPM_LDOA, 17, &pm660_pldo660, "vdd_l15_l16_l17_l18_l19" },
{ "l18", QCOM_SMD_RPM_LDOA, 18, &pm660_pldo660, "vdd_l15_l16_l17_l18_l19" },
{ "l19", QCOM_SMD_RPM_LDOA, 19, &pm660_pldo660, "vdd_l15_l16_l17_l18_l19" },
{ }
};
static const struct rpm_regulator_data rpm_pm660l_regulators[] = {
{ "s1", QCOM_SMD_RPM_SMPB, 1, &pm660_ftsmps, "vdd_s1" },
{ "s2", QCOM_SMD_RPM_SMPB, 2, &pm660_ftsmps, "vdd_s2" },
{ "s3", QCOM_SMD_RPM_RWCX, 0, &pm660_ftsmps, "vdd_s3_s4" },
{ "s5", QCOM_SMD_RPM_RWMX, 0, &pm660_ftsmps, "vdd_s5" },
{ "l1", QCOM_SMD_RPM_LDOB, 1, &pm660_nldo660, "vdd_l1_l9_l10" },
{ "l2", QCOM_SMD_RPM_LDOB, 2, &pm660_pldo660, "vdd_l2" },
{ "l3", QCOM_SMD_RPM_LDOB, 3, &pm660_pldo660, "vdd_l3_l5_l7_l8" },
{ "l4", QCOM_SMD_RPM_LDOB, 4, &pm660_pldo660, "vdd_l4_l6" },
{ "l5", QCOM_SMD_RPM_LDOB, 5, &pm660_pldo660, "vdd_l3_l5_l7_l8" },
{ "l6", QCOM_SMD_RPM_LDOB, 6, &pm660_pldo660, "vdd_l4_l6" },
{ "l7", QCOM_SMD_RPM_LDOB, 7, &pm660_pldo660, "vdd_l3_l5_l7_l8" },
{ "l8", QCOM_SMD_RPM_LDOB, 8, &pm660_pldo660, "vdd_l3_l5_l7_l8" },
{ "l9", QCOM_SMD_RPM_RWLC, 0, &pm660_ht_nldo, "vdd_l1_l9_l10" },
{ "l10", QCOM_SMD_RPM_RWLM, 0, &pm660_ht_nldo, "vdd_l1_l9_l10" },
{ "bob", QCOM_SMD_RPM_BOBB, 1, &pm660l_bob, "vdd_bob", },
{ }
};
static const struct rpm_regulator_data rpm_pms405_regulators[] = {
{ "s1", QCOM_SMD_RPM_SMPA, 1, &pms405_hfsmps3, "vdd_s1" },
{ "s2", QCOM_SMD_RPM_SMPA, 2, &pms405_hfsmps3, "vdd_s2" },
......@@ -930,8 +1094,11 @@ static const struct of_device_id rpm_of_match[] = {
{ .compatible = "qcom,rpm-pm8916-regulators", .data = &rpm_pm8916_regulators },
{ .compatible = "qcom,rpm-pm8941-regulators", .data = &rpm_pm8941_regulators },
{ .compatible = "qcom,rpm-pm8950-regulators", .data = &rpm_pm8950_regulators },
{ .compatible = "qcom,rpm-pm8953-regulators", .data = &rpm_pm8953_regulators },
{ .compatible = "qcom,rpm-pm8994-regulators", .data = &rpm_pm8994_regulators },
{ .compatible = "qcom,rpm-pm8998-regulators", .data = &rpm_pm8998_regulators },
{ .compatible = "qcom,rpm-pm660-regulators", .data = &rpm_pm660_regulators },
{ .compatible = "qcom,rpm-pm660l-regulators", .data = &rpm_pm660l_regulators },
{ .compatible = "qcom,rpm-pma8084-regulators", .data = &rpm_pma8084_regulators },
{ .compatible = "qcom,rpm-pmi8994-regulators", .data = &rpm_pmi8994_regulators },
{ .compatible = "qcom,rpm-pmi8998-regulators", .data = &rpm_pmi8998_regulators },
......
......@@ -135,6 +135,18 @@ enum spmi_regulator_subtype {
SPMI_REGULATOR_SUBTYPE_LV_P600 = 0x2b,
SPMI_REGULATOR_SUBTYPE_LV_P1200 = 0x2c,
SPMI_REGULATOR_SUBTYPE_LV_P450 = 0x2d,
SPMI_REGULATOR_SUBTYPE_HT_N300_ST = 0x30,
SPMI_REGULATOR_SUBTYPE_HT_N600_ST = 0x31,
SPMI_REGULATOR_SUBTYPE_HT_N1200_ST = 0x32,
SPMI_REGULATOR_SUBTYPE_HT_LVP150 = 0x3b,
SPMI_REGULATOR_SUBTYPE_HT_LVP300 = 0x3c,
SPMI_REGULATOR_SUBTYPE_L660_N300_ST = 0x42,
SPMI_REGULATOR_SUBTYPE_L660_N600_ST = 0x43,
SPMI_REGULATOR_SUBTYPE_L660_P50 = 0x46,
SPMI_REGULATOR_SUBTYPE_L660_P150 = 0x47,
SPMI_REGULATOR_SUBTYPE_L660_P600 = 0x49,
SPMI_REGULATOR_SUBTYPE_L660_LVP150 = 0x4d,
SPMI_REGULATOR_SUBTYPE_L660_LVP600 = 0x4f,
SPMI_REGULATOR_SUBTYPE_LV100 = 0x01,
SPMI_REGULATOR_SUBTYPE_LV300 = 0x02,
SPMI_REGULATOR_SUBTYPE_MV300 = 0x08,
......@@ -511,6 +523,22 @@ static struct spmi_voltage_range ult_pldo_ranges[] = {
SPMI_VOLTAGE_RANGE(0, 1750000, 1750000, 3337500, 3337500, 12500),
};
static struct spmi_voltage_range pldo660_ranges[] = {
SPMI_VOLTAGE_RANGE(0, 1504000, 1504000, 3544000, 3544000, 8000),
};
static struct spmi_voltage_range nldo660_ranges[] = {
SPMI_VOLTAGE_RANGE(0, 320000, 320000, 1304000, 1304000, 8000),
};
static struct spmi_voltage_range ht_lvpldo_ranges[] = {
SPMI_VOLTAGE_RANGE(0, 1504000, 1504000, 2000000, 2000000, 8000),
};
static struct spmi_voltage_range ht_nldo_ranges[] = {
SPMI_VOLTAGE_RANGE(0, 312000, 312000, 1304000, 1304000, 8000),
};
static struct spmi_voltage_range hfs430_ranges[] = {
SPMI_VOLTAGE_RANGE(0, 320000, 320000, 2040000, 2040000, 8000),
};
......@@ -530,6 +558,10 @@ static DEFINE_SPMI_SET_POINTS(ult_lo_smps);
static DEFINE_SPMI_SET_POINTS(ult_ho_smps);
static DEFINE_SPMI_SET_POINTS(ult_nldo);
static DEFINE_SPMI_SET_POINTS(ult_pldo);
static DEFINE_SPMI_SET_POINTS(pldo660);
static DEFINE_SPMI_SET_POINTS(nldo660);
static DEFINE_SPMI_SET_POINTS(ht_lvpldo);
static DEFINE_SPMI_SET_POINTS(ht_nldo);
static DEFINE_SPMI_SET_POINTS(hfs430);
static inline int spmi_vreg_read(struct spmi_regulator *vreg, u16 addr, u8 *buf,
......@@ -1443,6 +1475,30 @@ static const struct spmi_regulator_mapping supported_regulators[] = {
SPMI_VREG(LDO, LV_P300, 0, INF, LDO, ldo, pldo, 10000),
SPMI_VREG(LDO, LV_P600, 0, INF, LDO, ldo, pldo, 10000),
SPMI_VREG(LDO, LV_P1200, 0, INF, LDO, ldo, pldo, 10000),
SPMI_VREG(LDO, HT_N300_ST, 0, INF, FTSMPS426, ftsmps426,
ht_nldo, 30000),
SPMI_VREG(LDO, HT_N600_ST, 0, INF, FTSMPS426, ftsmps426,
ht_nldo, 30000),
SPMI_VREG(LDO, HT_N1200_ST, 0, INF, FTSMPS426, ftsmps426,
ht_nldo, 30000),
SPMI_VREG(LDO, HT_LVP150, 0, INF, FTSMPS426, ftsmps426,
ht_lvpldo, 10000),
SPMI_VREG(LDO, HT_LVP300, 0, INF, FTSMPS426, ftsmps426,
ht_lvpldo, 10000),
SPMI_VREG(LDO, L660_N300_ST, 0, INF, FTSMPS426, ftsmps426,
nldo660, 10000),
SPMI_VREG(LDO, L660_N600_ST, 0, INF, FTSMPS426, ftsmps426,
nldo660, 10000),
SPMI_VREG(LDO, L660_P50, 0, INF, FTSMPS426, ftsmps426,
pldo660, 10000),
SPMI_VREG(LDO, L660_P150, 0, INF, FTSMPS426, ftsmps426,
pldo660, 10000),
SPMI_VREG(LDO, L660_P600, 0, INF, FTSMPS426, ftsmps426,
pldo660, 10000),
SPMI_VREG(LDO, L660_LVP150, 0, INF, FTSMPS426, ftsmps426,
ht_lvpldo, 10000),
SPMI_VREG(LDO, L660_LVP600, 0, INF, FTSMPS426, ftsmps426,
ht_lvpldo, 10000),
SPMI_VREG_VS(LV100, 0, INF),
SPMI_VREG_VS(LV300, 0, INF),
SPMI_VREG_VS(MV300, 0, INF),
......@@ -1633,45 +1689,43 @@ static int spmi_regulator_init_registers(struct spmi_regulator *vreg,
return ret;
/* Set up enable pin control. */
if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS
|| type == SPMI_REGULATOR_LOGICAL_TYPE_LDO
|| type == SPMI_REGULATOR_LOGICAL_TYPE_VS)
&& !(data->pin_ctrl_enable
& SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) {
ctrl_reg[SPMI_COMMON_IDX_ENABLE] &=
~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
ctrl_reg[SPMI_COMMON_IDX_ENABLE] |=
data->pin_ctrl_enable & SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
if (!(data->pin_ctrl_enable & SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) {
switch (type) {
case SPMI_REGULATOR_LOGICAL_TYPE_SMPS:
case SPMI_REGULATOR_LOGICAL_TYPE_LDO:
case SPMI_REGULATOR_LOGICAL_TYPE_VS:
ctrl_reg[SPMI_COMMON_IDX_ENABLE] &=
~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
ctrl_reg[SPMI_COMMON_IDX_ENABLE] |=
data->pin_ctrl_enable & SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
break;
default:
break;
}
}
/* Set up mode pin control. */
if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS
|| type == SPMI_REGULATOR_LOGICAL_TYPE_LDO)
&& !(data->pin_ctrl_hpm
& SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
ctrl_reg[SPMI_COMMON_IDX_MODE] &=
~SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
ctrl_reg[SPMI_COMMON_IDX_MODE] |=
data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
}
if (type == SPMI_REGULATOR_LOGICAL_TYPE_VS
&& !(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
ctrl_reg[SPMI_COMMON_IDX_MODE] &=
~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
ctrl_reg[SPMI_COMMON_IDX_MODE] |=
data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
}
if ((type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS
|| type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS
|| type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO)
&& !(data->pin_ctrl_hpm
& SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
ctrl_reg[SPMI_COMMON_IDX_MODE] &=
~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
ctrl_reg[SPMI_COMMON_IDX_MODE] |=
data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
if (!(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
switch (type) {
case SPMI_REGULATOR_LOGICAL_TYPE_SMPS:
case SPMI_REGULATOR_LOGICAL_TYPE_LDO:
ctrl_reg[SPMI_COMMON_IDX_MODE] &=
~SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
ctrl_reg[SPMI_COMMON_IDX_MODE] |=
data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
break;
case SPMI_REGULATOR_LOGICAL_TYPE_VS:
case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS:
case SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS:
case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO:
ctrl_reg[SPMI_COMMON_IDX_MODE] &=
~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
ctrl_reg[SPMI_COMMON_IDX_MODE] |=
data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
break;
default:
break;
}
}
/* Write back any control register values that were modified. */
......@@ -1960,6 +2014,55 @@ static const struct spmi_regulator_data pmi8994_regulators[] = {
{ }
};
static const struct spmi_regulator_data pm660_regulators[] = {
{ "s1", 0x1400, "vdd_s1", },
{ "s2", 0x1700, "vdd_s2", },
{ "s3", 0x1a00, "vdd_s3", },
{ "s4", 0x1d00, "vdd_s3", },
{ "s5", 0x2000, "vdd_s5", },
{ "s6", 0x2300, "vdd_s6", },
{ "l1", 0x4000, "vdd_l1_l6_l7", },
{ "l2", 0x4100, "vdd_l2_l3", },
{ "l3", 0x4200, "vdd_l2_l3", },
/* l4 is unaccessible on PM660 */
{ "l5", 0x4400, "vdd_l5", },
{ "l6", 0x4500, "vdd_l1_l6_l7", },
{ "l7", 0x4600, "vdd_l1_l6_l7", },
{ "l8", 0x4700, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l9", 0x4800, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l10", 0x4900, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l11", 0x4a00, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l12", 0x4b00, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l13", 0x4c00, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l14", 0x4d00, "vdd_l8_l9_l10_l11_l12_l13_l14", },
{ "l15", 0x4e00, "vdd_l15_l16_l17_l18_l19", },
{ "l16", 0x4f00, "vdd_l15_l16_l17_l18_l19", },
{ "l17", 0x5000, "vdd_l15_l16_l17_l18_l19", },
{ "l18", 0x5100, "vdd_l15_l16_l17_l18_l19", },
{ "l19", 0x5200, "vdd_l15_l16_l17_l18_l19", },
{ }
};
static const struct spmi_regulator_data pm660l_regulators[] = {
{ "s1", 0x1400, "vdd_s1", },
{ "s2", 0x1700, "vdd_s2", },
{ "s3", 0x1a00, "vdd_s3", },
{ "s4", 0x1d00, "vdd_s4", },
{ "s5", 0x2000, "vdd_s5", },
{ "l1", 0x4000, "vdd_l1_l9_l10", },
{ "l2", 0x4100, "vdd_l2", },
{ "l3", 0x4200, "vdd_l3_l5_l7_l8", },
{ "l4", 0x4300, "vdd_l4_l6", },
{ "l5", 0x4400, "vdd_l3_l5_l7_l8", },
{ "l6", 0x4500, "vdd_l4_l6", },
{ "l7", 0x4600, "vdd_l3_l5_l7_l8", },
{ "l8", 0x4700, "vdd_l3_l5_l7_l8", },
{ "l9", 0x4800, "vdd_l1_l9_l10", },
{ "l10", 0x4900, "vdd_l1_l9_l10", },
{ }
};
static const struct spmi_regulator_data pm8004_regulators[] = {
{ "s2", 0x1700, "vdd_s2", },
{ "s5", 0x2000, "vdd_s5", },
......@@ -1988,6 +2091,8 @@ static const struct of_device_id qcom_spmi_regulator_match[] = {
{ .compatible = "qcom,pm8950-regulators", .data = &pm8950_regulators },
{ .compatible = "qcom,pm8994-regulators", .data = &pm8994_regulators },
{ .compatible = "qcom,pmi8994-regulators", .data = &pmi8994_regulators },
{ .compatible = "qcom,pm660-regulators", .data = &pm660_regulators },
{ .compatible = "qcom,pm660l-regulators", .data = &pm660l_regulators },
{ .compatible = "qcom,pms405-regulators", .data = &pms405_regulators },
{ }
};
......
......@@ -63,6 +63,7 @@ static int qcom_usb_vbus_regulator_probe(struct platform_device *pdev)
qcom_usb_vbus_rdesc.enable_mask = OTG_EN;
config.dev = dev;
config.init_data = init_data;
config.of_node = dev->of_node;
config.regmap = regmap;
rdev = devm_regulator_register(dev, &qcom_usb_vbus_rdesc, &config);
......
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 Marek Vasut <marex@denx.de>
*
* Based on rpi_touchscreen.c by Eric Anholt <eric@anholt.net>
*/
#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/slab.h>
/* I2C registers of the Atmel microcontroller. */
#define REG_ID 0x80
#define REG_PORTA 0x81
#define REG_PORTA_HF BIT(2)
#define REG_PORTA_VF BIT(3)
#define REG_PORTB 0x82
#define REG_POWERON 0x85
#define REG_PWM 0x86
static const struct regmap_config attiny_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = REG_PWM,
.cache_type = REGCACHE_NONE,
};
static int attiny_lcd_power_enable(struct regulator_dev *rdev)
{
unsigned int data;
regmap_write(rdev->regmap, REG_POWERON, 1);
/* Wait for nPWRDWN to go low to indicate poweron is done. */
regmap_read_poll_timeout(rdev->regmap, REG_PORTB, data,
data & BIT(0), 10, 1000000);
/* Default to the same orientation as the closed source
* firmware used for the panel. Runtime rotation
* configuration will be supported using VC4's plane
* orientation bits.
*/
regmap_write(rdev->regmap, REG_PORTA, BIT(2));
return 0;
}
static int attiny_lcd_power_disable(struct regulator_dev *rdev)
{
regmap_write(rdev->regmap, REG_PWM, 0);
regmap_write(rdev->regmap, REG_POWERON, 0);
udelay(1);
return 0;
}
static int attiny_lcd_power_is_enabled(struct regulator_dev *rdev)
{
unsigned int data;
int ret;
ret = regmap_read(rdev->regmap, REG_POWERON, &data);
if (ret < 0)
return ret;
if (!(data & BIT(0)))
return 0;
ret = regmap_read(rdev->regmap, REG_PORTB, &data);
if (ret < 0)
return ret;
return data & BIT(0);
}
static const struct regulator_init_data attiny_regulator_default = {
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
},
};
static const struct regulator_ops attiny_regulator_ops = {
.enable = attiny_lcd_power_enable,
.disable = attiny_lcd_power_disable,
.is_enabled = attiny_lcd_power_is_enabled,
};
static const struct regulator_desc attiny_regulator = {
.name = "tc358762-power",
.ops = &attiny_regulator_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
};
static int attiny_update_status(struct backlight_device *bl)
{
struct regmap *regmap = bl_get_data(bl);
int brightness = bl->props.brightness;
if (bl->props.power != FB_BLANK_UNBLANK ||
bl->props.fb_blank != FB_BLANK_UNBLANK)
brightness = 0;
return regmap_write(regmap, REG_PWM, brightness);
}
static int attiny_get_brightness(struct backlight_device *bl)
{
struct regmap *regmap = bl_get_data(bl);
int ret, brightness;
ret = regmap_read(regmap, REG_PWM, &brightness);
if (ret)
return ret;
return brightness;
}
static const struct backlight_ops attiny_bl = {
.update_status = attiny_update_status,
.get_brightness = attiny_get_brightness,
};
/*
* I2C driver interface functions
*/
static int attiny_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct backlight_properties props = { };
struct regulator_config config = { };
struct backlight_device *bl;
struct regulator_dev *rdev;
struct regmap *regmap;
unsigned int data;
int ret;
regmap = devm_regmap_init_i2c(i2c, &attiny_regmap_config);
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
ret);
return ret;
}
ret = regmap_read(regmap, REG_ID, &data);
if (ret < 0) {
dev_err(&i2c->dev, "Failed to read REG_ID reg: %d\n", ret);
return ret;
}
switch (data) {
case 0xde: /* ver 1 */
case 0xc3: /* ver 2 */
break;
default:
dev_err(&i2c->dev, "Unknown Atmel firmware revision: 0x%02x\n", data);
return -ENODEV;
}
regmap_write(regmap, REG_POWERON, 0);
mdelay(1);
config.dev = &i2c->dev;
config.regmap = regmap;
config.of_node = i2c->dev.of_node;
config.init_data = &attiny_regulator_default;
rdev = devm_regulator_register(&i2c->dev, &attiny_regulator, &config);
if (IS_ERR(rdev)) {
dev_err(&i2c->dev, "Failed to register ATTINY regulator\n");
return PTR_ERR(rdev);
}
props.type = BACKLIGHT_RAW;
props.max_brightness = 0xff;
bl = devm_backlight_device_register(&i2c->dev,
"7inch-touchscreen-panel-bl",
&i2c->dev, regmap, &attiny_bl,
&props);
if (IS_ERR(bl))
return PTR_ERR(bl);
bl->props.brightness = 0xff;
return 0;
}
static const struct of_device_id attiny_dt_ids[] = {
{ .compatible = "raspberrypi,7inch-touchscreen-panel-regulator" },
{},
};
MODULE_DEVICE_TABLE(of, attiny_dt_ids);
static struct i2c_driver attiny_regulator_driver = {
.driver = {
.name = "rpi_touchscreen_attiny",
.of_match_table = of_match_ptr(attiny_dt_ids),
},
.probe = attiny_i2c_probe,
};
module_i2c_driver(attiny_regulator_driver);
MODULE_AUTHOR("Marek Vasut <marex@denx.de>");
MODULE_DESCRIPTION("Regulator device driver for Raspberry Pi 7-inch touchscreen");
MODULE_LICENSE("GPL v2");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -101,7 +101,7 @@ static int stm32_booster_probe(struct platform_device *pdev)
return 0;
}
static const struct of_device_id stm32_booster_of_match[] = {
static const struct of_device_id __maybe_unused stm32_booster_of_match[] = {
{
.compatible = "st,stm32h7-booster",
.data = (void *)&stm32h7_booster_desc
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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