Unverified Commit 083986c2 authored by Mark Brown's avatar Mark Brown
Browse files

Merge series "Add pca9450 driver" from Robin Gong <yibin.gong@nxp.com>:

Add pca9450 driver for i.mx8mn-evk board. PCA9450A/B/C supported now.
Please refer to below link for PCA9450 datasheet:
https://www.nxp.com/docs/en/data-sheet/PCA9450DS.pdf

v2:
  1. rebase with the latest code to use linear_ranges helper instead.
  2. address Frieder's comments, such as dulipcated buck4 description,
     debug info added etc.

Robin Gong (4):
  regulator: pca9450: add pca9450 pmic driver
  dt-bindings: regulator: add pca9450 regulator yaml
  arm64: dts: imx8mn-evk: add pca9450 for i.mx8mn-evk board
  arm64: configs: add pca9450 pmic driver

 .../bindings/regulator/nxp,pca9450-regulator.yaml  | 190 +++++
 arch/arm64/boot/dts/freescale/imx8mn-evk.dts       |  96 +++
 arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi      |   6 +
 arch/arm64/configs/defconfig                       |   1 +
 drivers/regulator/Kconfig                          |   8 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/pca9450-regulator.c              | 859 +++++++++++++++++++++
 include/linux/regulator/pca9450.h                  | 219 ++++++
 8 files changed, 1380 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
 create mode 100644 drivers/regulator/pca9450-regulator.c
 create mode 100644 include/linux/regulator/pca9450.h

--
2.7.4

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
parents 6c814b67 7ae9e3a6
Loading
Loading
Loading
Loading
+190 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/regulator/nxp,pca9450-regulator.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: NXP PCA9450A/B/C Power Management Integrated Circuit regulators

maintainers:
  - Robin Gong <yibin.gong@nxp.com>

description: |
  Regulator nodes should be named to BUCK_<number> and LDO_<number>. 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.nxp.com/docs/en/data-sheet/PCA9450DS.pdf

#The valid names for PCA9450 regulator nodes are:
#BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6,
#LDO1, LDO2, LDO3, LDO4, LDO5
#Note: Buck3 removed on PCA9450B and connect with Buck1 on PCA9450C.

properties:
  compatible:
    enum:
      - nxp,pca9450a
      - nxp,pca9450b
      - nxp,pca9450c

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  regulators:
    type: object
    description: |
      list of regulators provided by this controller

    patternProperties:
      "^LDO[1-5]$":
        type: object
        $ref: regulator.yaml#
        description:
          Properties for single LDO regulator.

        properties:
          regulator-name:
            pattern: "^LDO[1-5]$"
            description:
              should be "LDO1", ..., "LDO5"

        unevaluatedProperties: false

      "^BUCK[1-6]$":
        type: object
        $ref: regulator.yaml#
        description:
          Properties for single BUCK regulator.

        properties:
          regulator-name:
            pattern: "^BUCK[1-6]$"
            description:
              should be "BUCK1", ..., "BUCK6"

          nxp,dvs-run-voltage:
            $ref: "/schemas/types.yaml#/definitions/uint32"
            minimum: 600000
            maximum: 2187500
            description:
              PMIC default "RUN" state voltage in uV. Only Buck1~3 have such
              dvs(dynamic voltage scaling) property.

          nxp,dvs-standby-voltage:
            $ref: "/schemas/types.yaml#/definitions/uint32"
            minimum: 600000
            maximum: 2187500
            description:
              PMIC default "STANDBY" state voltage in uV. Only Buck1~3 have such
              dvs(dynamic voltage scaling) property.

        unevaluatedProperties: false

    additionalProperties: false

required:
  - compatible
  - reg
  - interrupts
  - regulators

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/irq.h>

    i2c {
        #address-cells = <1>;
        #size-cells = <0>;
        pmic: pmic@25 {
            compatible = "nxp,pca9450b";
            reg = <0x25>;
            pinctrl-0 = <&pinctrl_pmic>;
            interrupt-parent = <&gpio1>;
            interrupts = <3 IRQ_TYPE_LEVEL_LOW>;

            regulators {
                buck1: BUCK1 {
                    regulator-name = "BUCK1";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <2187500>;
                    regulator-boot-on;
                    regulator-always-on;
                    regulator-ramp-delay = <3125>;
                };
                buck2: BUCK2 {
                    regulator-name = "BUCK2";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <2187500>;
                    regulator-boot-on;
                    regulator-always-on;
                    regulator-ramp-delay = <3125>;
                    nxp,dvs-run-voltage = <950000>;
                    nxp,dvs-standby-voltage = <850000>;
                };
                buck4: BUCK4 {
                    regulator-name = "BUCK4";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <3400000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                buck5: BUCK5 {
                    regulator-name = "BUCK5";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <3400000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                buck6: BUCK6 {
                    regulator-name = "BUCK6";
                    regulator-min-microvolt = <600000>;
                    regulator-max-microvolt = <3400000>;
                    regulator-boot-on;
                    regulator-always-on;
                };

                ldo1: LDO1 {
                    regulator-name = "LDO1";
                    regulator-min-microvolt = <1600000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo2: LDO2 {
                    regulator-name = "LDO2";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <1150000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo3: LDO3 {
                    regulator-name = "LDO3";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo4: LDO4 {
                    regulator-name = "LDO4";
                    regulator-min-microvolt = <800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
                ldo5: LDO5 {
                    regulator-name = "LDO5";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-boot-on;
                    regulator-always-on;
                };
            };
        };
    };
+8 −0
Original line number Diff line number Diff line
@@ -750,6 +750,14 @@ config REGULATOR_PBIAS
	 This driver provides support for OMAP pbias modelled
	 regulators.

config REGULATOR_PCA9450
	tristate "NXP PCA9450A/PCA9450B/PCA9450C regulator driver"
	depends on I2C
	select REGMAP_I2C
	help
	  Say y here to support the NXP PCA9450A/PCA9450B/PCA9450C PMIC
	  regulator driver.

config REGULATOR_PCAP
	tristate "Motorola PCAP2 regulator driver"
	depends on EZX_PCAP
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o
obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o
obj-$(CONFIG_REGULATOR_QCOM_USB_VBUS) += qcom_usb_vbus-regulator.o
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
obj-$(CONFIG_REGULATOR_PCA9450) += pca9450-regulator.o
obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
obj-$(CONFIG_REGULATOR_PV88060) += pv88060-regulator.o
obj-$(CONFIG_REGULATOR_PV88080) += pv88080-regulator.o
+843 −0

File added.

Preview size limit exceeded, changes collapsed.

+219 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Copyright 2020 NXP. */

#ifndef __LINUX_REG_PCA9450_H__
#define __LINUX_REG_PCA9450_H__

#include <linux/regmap.h>

enum pca9450_chip_type {
	PCA9450_TYPE_PCA9450A = 0,
	PCA9450_TYPE_PCA9450BC,
	PCA9450_TYPE_AMOUNT,
};

enum {
	PCA9450_BUCK1 = 0,
	PCA9450_BUCK2,
	PCA9450_BUCK3,
	PCA9450_BUCK4,
	PCA9450_BUCK5,
	PCA9450_BUCK6,
	PCA9450_LDO1,
	PCA9450_LDO2,
	PCA9450_LDO3,
	PCA9450_LDO4,
	PCA9450_LDO5,
	PCA9450_REGULATOR_CNT,
};

enum {
	PCA9450_DVS_LEVEL_RUN = 0,
	PCA9450_DVS_LEVEL_STANDBY,
	PCA9450_DVS_LEVEL_MAX,
};

#define PCA9450_BUCK1_VOLTAGE_NUM	0x80
#define PCA9450_BUCK2_VOLTAGE_NUM	0x80
#define PCA9450_BUCK3_VOLTAGE_NUM	0x80
#define PCA9450_BUCK4_VOLTAGE_NUM	0x80

#define PCA9450_BUCK5_VOLTAGE_NUM	0x80
#define PCA9450_BUCK6_VOLTAGE_NUM	0x80

#define PCA9450_LDO1_VOLTAGE_NUM	0x08
#define PCA9450_LDO2_VOLTAGE_NUM	0x08
#define PCA9450_LDO3_VOLTAGE_NUM	0x20
#define PCA9450_LDO4_VOLTAGE_NUM	0x20
#define PCA9450_LDO5_VOLTAGE_NUM	0x10

enum {
	PCA9450_REG_DEV_ID	    = 0x00,
	PCA9450_REG_INT1	    = 0x01,
	PCA9450_REG_INT1_MSK	    = 0x02,
	PCA9450_REG_STATUS1	    = 0x03,
	PCA9450_REG_STATUS2	    = 0x04,
	PCA9450_REG_PWRON_STAT	    = 0x05,
	PCA9450_REG_SWRST	    = 0x06,
	PCA9450_REG_PWRCTRL         = 0x07,
	PCA9450_REG_RESET_CTRL      = 0x08,
	PCA9450_REG_CONFIG1         = 0x09,
	PCA9450_REG_CONFIG2         = 0x0A,
	PCA9450_REG_BUCK123_DVS     = 0x0C,
	PCA9450_REG_BUCK1OUT_LIMIT  = 0x0D,
	PCA9450_REG_BUCK2OUT_LIMIT  = 0x0E,
	PCA9450_REG_BUCK3OUT_LIMIT  = 0x0F,
	PCA9450_REG_BUCK1CTRL       = 0x10,
	PCA9450_REG_BUCK1OUT_DVS0   = 0x11,
	PCA9450_REG_BUCK1OUT_DVS1   = 0x12,
	PCA9450_REG_BUCK2CTRL       = 0x13,
	PCA9450_REG_BUCK2OUT_DVS0   = 0x14,
	PCA9450_REG_BUCK2OUT_DVS1   = 0x15,
	PCA9450_REG_BUCK3CTRL       = 0x16,
	PCA9450_REG_BUCK3OUT_DVS0   = 0x17,
	PCA9450_REG_BUCK3OUT_DVS1   = 0x18,
	PCA9450_REG_BUCK4CTRL       = 0x19,
	PCA9450_REG_BUCK4OUT        = 0x1A,
	PCA9450_REG_BUCK5CTRL       = 0x1B,
	PCA9450_REG_BUCK5OUT        = 0x1C,
	PCA9450_REG_BUCK6CTRL       = 0x1D,
	PCA9450_REG_BUCK6OUT        = 0x1E,
	PCA9450_REG_LDO_AD_CTRL     = 0x20,
	PCA9450_REG_LDO1CTRL        = 0x21,
	PCA9450_REG_LDO2CTRL        = 0x22,
	PCA9450_REG_LDO3CTRL        = 0x23,
	PCA9450_REG_LDO4CTRL        = 0x24,
	PCA9450_REG_LDO5CTRL_L      = 0x25,
	PCA9450_REG_LDO5CTRL_H      = 0x26,
	PCA9450_REG_LOADSW_CTRL     = 0x2A,
	PCA9450_REG_VRFLT1_STS      = 0x2B,
	PCA9450_REG_VRFLT2_STS      = 0x2C,
	PCA9450_REG_VRFLT1_MASK     = 0x2D,
	PCA9450_REG_VRFLT2_MASK     = 0x2E,
	PCA9450_MAX_REGISTER	    = 0x2F,
};

/* PCA9450 BUCK ENMODE bits */
#define BUCK_ENMODE_OFF			0x00
#define BUCK_ENMODE_ONREQ		0x01
#define BUCK_ENMODE_ONREQ_STBYREQ	0x02
#define BUCK_ENMODE_ON			0x03

/* PCA9450_REG_BUCK1_CTRL bits */
#define BUCK1_RAMP_MASK			0xC0
#define BUCK1_RAMP_25MV			0x0
#define BUCK1_RAMP_12P5MV		0x1
#define BUCK1_RAMP_6P25MV		0x2
#define BUCK1_RAMP_3P125MV		0x3
#define BUCK1_DVS_CTRL			0x10
#define BUCK1_AD			0x08
#define BUCK1_FPWM			0x04
#define BUCK1_ENMODE_MASK		0x03

/* PCA9450_REG_BUCK2_CTRL bits */
#define BUCK2_RAMP_MASK			0xC0
#define BUCK2_RAMP_25MV			0x0
#define BUCK2_RAMP_12P5MV		0x1
#define BUCK2_RAMP_6P25MV		0x2
#define BUCK2_RAMP_3P125MV		0x3
#define BUCK2_DVS_CTRL			0x10
#define BUCK2_AD			0x08
#define BUCK2_FPWM			0x04
#define BUCK2_ENMODE_MASK		0x03

/* PCA9450_REG_BUCK3_CTRL bits */
#define BUCK3_RAMP_MASK			0xC0
#define BUCK3_RAMP_25MV			0x0
#define BUCK3_RAMP_12P5MV		0x1
#define BUCK3_RAMP_6P25MV		0x2
#define BUCK3_RAMP_3P125MV		0x3
#define BUCK3_DVS_CTRL			0x10
#define BUCK3_AD			0x08
#define BUCK3_FPWM			0x04
#define BUCK3_ENMODE_MASK		0x03

/* PCA9450_REG_BUCK4_CTRL bits */
#define BUCK4_AD			0x08
#define BUCK4_FPWM			0x04
#define BUCK4_ENMODE_MASK		0x03

/* PCA9450_REG_BUCK5_CTRL bits */
#define BUCK5_AD			0x08
#define BUCK5_FPWM			0x04
#define BUCK5_ENMODE_MASK		0x03

/* PCA9450_REG_BUCK6_CTRL bits */
#define BUCK6_AD			0x08
#define BUCK6_FPWM			0x04
#define BUCK6_ENMODE_MASK		0x03

/* PCA9450_BUCK1OUT_DVS0 bits */
#define BUCK1OUT_DVS0_MASK		0x7F
#define BUCK1OUT_DVS0_DEFAULT		0x14

/* PCA9450_BUCK1OUT_DVS1 bits */
#define BUCK1OUT_DVS1_MASK		0x7F
#define BUCK1OUT_DVS1_DEFAULT		0x14

/* PCA9450_BUCK2OUT_DVS0 bits */
#define BUCK2OUT_DVS0_MASK		0x7F
#define BUCK2OUT_DVS0_DEFAULT		0x14

/* PCA9450_BUCK2OUT_DVS1 bits */
#define BUCK2OUT_DVS1_MASK		0x7F
#define BUCK2OUT_DVS1_DEFAULT		0x14

/* PCA9450_BUCK3OUT_DVS0 bits */
#define BUCK3OUT_DVS0_MASK		0x7F
#define BUCK3OUT_DVS0_DEFAULT		0x14

/* PCA9450_BUCK3OUT_DVS1 bits */
#define BUCK3OUT_DVS1_MASK		0x7F
#define BUCK3OUT_DVS1_DEFAULT		0x14

/* PCA9450_REG_BUCK4OUT bits */
#define BUCK4OUT_MASK			0x7F
#define BUCK4OUT_DEFAULT		0x6C

/* PCA9450_REG_BUCK5OUT bits */
#define BUCK5OUT_MASK			0x7F
#define BUCK5OUT_DEFAULT		0x30

/* PCA9450_REG_BUCK6OUT bits */
#define BUCK6OUT_MASK			0x7F
#define BUCK6OUT_DEFAULT		0x14

/* PCA9450_REG_LDO1_VOLT bits */
#define LDO1_EN_MASK			0xC0
#define LDO1OUT_MASK			0x07

/* PCA9450_REG_LDO2_VOLT bits */
#define LDO2_EN_MASK			0xC0
#define LDO2OUT_MASK			0x07

/* PCA9450_REG_LDO3_VOLT bits */
#define LDO3_EN_MASK			0xC0
#define LDO3OUT_MASK			0x0F

/* PCA9450_REG_LDO4_VOLT bits */
#define LDO4_EN_MASK			0xC0
#define LDO4OUT_MASK			0x0F

/* PCA9450_REG_LDO5_VOLT bits */
#define LDO5L_EN_MASK			0xC0
#define LDO5LOUT_MASK			0x0F

#define LDO5H_EN_MASK			0xC0
#define LDO5HOUT_MASK			0x0F

/* PCA9450_REG_IRQ bits */
#define IRQ_PWRON			0x80
#define IRQ_WDOGB			0x40
#define IRQ_RSVD			0x20
#define IRQ_VR_FLT1			0x10
#define IRQ_VR_FLT2			0x08
#define IRQ_LOWVSYS			0x04
#define IRQ_THERM_105			0x02
#define IRQ_THERM_125			0x01

#endif /* __LINUX_REG_PCA9450_H__ */