Unverified Commit e6beda56 authored by Mark Brown's avatar Mark Brown
Browse files

mfd/pinctrl/regulator: Add RK806 Support

Merge series from Sebastian Reichel <sebastian.reichel@collabora.com>:

All existing boards using RK3588/RK3588s use RK806 PMICs. This series is now
the main blocker for full upstream support of those boards and it would be good
to have it merged for 6.5 :) The patches have been tested on multiple different
platforms and are mainly missing an Ack from Mark or Liam for the rk808-regulator
changes.

Merging must happen through a single tree, since the pinctrl and regulator
drivers rely on the register definitions from the include file added by the MFD
patch. My suggested merge strategy is that Lee creates an immutable branch for
the regulator/pinctrl tree once all Acks have been collected.
parents 15a1cd24 f991a220
Loading
Loading
Loading
Loading
+406 −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/mfd/rockchip,rk806.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: RK806 Power Management Integrated Circuit

maintainers:
  - Sebastian Reichel <sebastian.reichel@collabora.com>

description:
  Rockchip RK806 series PMIC. This device consists of an spi or
  i2c controlled MFD that includes multiple switchable regulators.

properties:
  compatible:
    enum:
      - rockchip,rk806

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  gpio-controller: true

  '#gpio-cells':
    const: 2

  vcc1-supply:
    description:
      The input supply for dcdc-reg1.

  vcc2-supply:
    description:
      The input supply for dcdc-reg2.

  vcc3-supply:
    description:
      The input supply for dcdc-reg3.

  vcc4-supply:
    description:
      The input supply for dcdc-reg4.

  vcc5-supply:
    description:
      The input supply for dcdc-reg5.

  vcc6-supply:
    description:
      The input supply for dcdc-reg6.

  vcc7-supply:
    description:
      The input supply for dcdc-reg7.

  vcc8-supply:
    description:
      The input supply for dcdc-reg8.

  vcc9-supply:
    description:
      The input supply for dcdc-reg9.

  vcc10-supply:
    description:
      The input supply for dcdc-reg10.

  vcc11-supply:
    description:
      The input supply for pldo-reg1, pldo-reg2 and pldo-reg3.

  vcc12-supply:
    description:
      The input supply for pldo-reg4 and pldo-reg5.

  vcc13-supply:
    description:
      The input supply for nldo-reg1, nldo-reg2 and nldo-reg3.

  vcc14-supply:
    description:
      The input supply for nldo-reg4 and nldo-reg5.

  vcca-supply:
    description:
      The input supply for pldo-reg6.

  regulators:
    type: object
    additionalProperties: false
    patternProperties:
      "^(dcdc-reg([1-9]|10)|pldo-reg[1-6]|nldo-reg[1-5])$":
        type: object
        $ref: /schemas/regulator/regulator.yaml#
        unevaluatedProperties: false

patternProperties:
  '-pins$':
    type: object
    additionalProperties: false
    $ref: /schemas/pinctrl/pinmux-node.yaml

    properties:
      function:
        enum: [pin_fun0, pin_fun1, pin_fun2, pin_fun3, pin_fun4, pin_fun5]

      pins:
        $ref: /schemas/types.yaml#/definitions/string
        enum: [gpio_pwrctrl1, gpio_pwrctrl2, gpio_pwrctrl3]

allOf:
  - $ref: /schemas/spi/spi-peripheral-props.yaml

required:
  - compatible
  - reg
  - interrupts

unevaluatedProperties: false

examples:
  - |
    #include <dt-bindings/pinctrl/rockchip.h>
    #include <dt-bindings/interrupt-controller/irq.h>
    #include <dt-bindings/gpio/gpio.h>
    spi {
        #address-cells = <1>;
        #size-cells = <0>;

        pmic@0 {
            compatible = "rockchip,rk806";
            reg = <0x0>;

            interrupts = <7 IRQ_TYPE_LEVEL_LOW>;

            vcc1-supply = <&vcc5v0_sys>;
            vcc2-supply = <&vcc5v0_sys>;
            vcc3-supply = <&vcc5v0_sys>;
            vcc4-supply = <&vcc5v0_sys>;
            vcc5-supply = <&vcc5v0_sys>;
            vcc6-supply = <&vcc5v0_sys>;
            vcc7-supply = <&vcc5v0_sys>;
            vcc8-supply = <&vcc5v0_sys>;
            vcc9-supply = <&vcc5v0_sys>;
            vcc10-supply = <&vcc5v0_sys>;
            vcc11-supply = <&vcc_2v0_pldo_s3>;
            vcc12-supply = <&vcc5v0_sys>;
            vcc13-supply = <&vcc5v0_sys>;
            vcc14-supply = <&vcc_1v1_nldo_s3>;
            vcca-supply = <&vcc5v0_sys>;

            regulators {
                vdd_gpu_s0: dcdc-reg1 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <550000>;
                    regulator-max-microvolt = <950000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_gpu_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd_npu_s0: dcdc-reg2 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <550000>;
                    regulator-max-microvolt = <950000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_npu_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd_log_s0: dcdc-reg3 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <750000>;
                    regulator-max-microvolt = <750000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_log_s0";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <750000>;
                    };
                };

                vdd_vdenc_s0: dcdc-reg4 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <550000>;
                    regulator-max-microvolt = <950000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_vdenc_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd_gpu_mem_s0: dcdc-reg5 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <675000>;
                    regulator-max-microvolt = <950000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_gpu_mem_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd_npu_mem_s0: dcdc-reg6 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <675000>;
                    regulator-max-microvolt = <950000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_npu_mem_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vcc_2v0_pldo_s3: dcdc-reg7 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <2000000>;
                    regulator-max-microvolt = <2000000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_2v0_pldo_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <2000000>;
                    };
                };

                vdd_vdenc_mem_s0: dcdc-reg8 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <675000>;
                    regulator-max-microvolt = <950000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_vdenc_mem_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd2_ddr_s3: dcdc-reg9 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-name = "vdd2_ddr_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                    };
                };

                vcc_1v1_nldo_s3: dcdc-reg10 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <1100000>;
                    regulator-max-microvolt = <1100000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vcc_1v1_nldo_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <1100000>;
                    };
                };

                avcc_1v8_s0: pldo-reg1 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "avcc_1v8_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd1_1v8_ddr_s3: pldo-reg2 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd1_1v8_ddr_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <1800000>;
                    };
                };

                vcc_1v8_s3: pldo-reg3 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vcc_1v8_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <1800000>;
                    };
                };

                vcc_3v3_s0: pldo-reg4 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <3300000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vcc_3v3_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vccio_sd_s0: pldo-reg5 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <3300000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vccio_sd_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                master_pldo6_s3: pldo-reg6 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                    regulator-name = "master_pldo6_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <1800000>;
                    };
                };

                vdd_0v75_s3: nldo-reg1 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <750000>;
                    regulator-max-microvolt = <750000>;
                    regulator-ramp-delay = <12500>;
                    regulator-name = "vdd_0v75_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <750000>;
                    };
                };

                vdd2l_0v9_ddr_s3: nldo-reg2 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <900000>;
                    regulator-max-microvolt = <900000>;
                    regulator-name = "vdd2l_0v9_ddr_s3";
                    regulator-state-mem {
                        regulator-on-in-suspend;
                        regulator-suspend-microvolt = <900000>;
                    };
                };

                master_nldo3: nldo-reg3 {
                    regulator-name = "master_nldo3";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                avdd_0v75_s0: nldo-reg4 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <750000>;
                    regulator-max-microvolt = <750000>;
                    regulator-name = "avdd_0v75_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };

                vdd_0v85_s0: nldo-reg5 {
                    regulator-always-on;
                    regulator-boot-on;
                    regulator-min-microvolt = <850000>;
                    regulator-max-microvolt = <850000>;
                    regulator-name = "vdd_0v85_s0";
                    regulator-state-mem {
                        regulator-off-in-suspend;
                    };
                };
            };
        };
    };
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ config COMMON_CLK_MAX9485

config COMMON_CLK_RK808
	tristate "Clock driver for RK805/RK808/RK809/RK817/RK818"
	depends on MFD_RK808
	depends on MFD_RK8XX
	help
	  This driver supports RK805, RK809 and RK817, RK808 and RK818 crystal oscillator clock.
	  These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each.
+16 −18
Original line number Diff line number Diff line
@@ -12,10 +12,9 @@
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/mfd/rk808.h>
#include <linux/i2c.h>

struct rk808_clkout {
	struct rk808 *rk808;
	struct regmap		*regmap;
	struct clk_hw		clkout1_hw;
	struct clk_hw		clkout2_hw;
};
@@ -31,9 +30,8 @@ static int rk808_clkout2_enable(struct clk_hw *hw, bool enable)
	struct rk808_clkout *rk808_clkout = container_of(hw,
							 struct rk808_clkout,
							 clkout2_hw);
	struct rk808 *rk808 = rk808_clkout->rk808;

	return regmap_update_bits(rk808->regmap, RK808_CLK32OUT_REG,
	return regmap_update_bits(rk808_clkout->regmap, RK808_CLK32OUT_REG,
				  CLK32KOUT2_EN, enable ? CLK32KOUT2_EN : 0);
}

@@ -52,10 +50,9 @@ static int rk808_clkout2_is_prepared(struct clk_hw *hw)
	struct rk808_clkout *rk808_clkout = container_of(hw,
							 struct rk808_clkout,
							 clkout2_hw);
	struct rk808 *rk808 = rk808_clkout->rk808;
	uint32_t val;

	int ret = regmap_read(rk808->regmap, RK808_CLK32OUT_REG, &val);
	int ret = regmap_read(rk808_clkout->regmap, RK808_CLK32OUT_REG, &val);

	if (ret < 0)
		return ret;
@@ -93,9 +90,8 @@ static int rk817_clkout2_enable(struct clk_hw *hw, bool enable)
	struct rk808_clkout *rk808_clkout = container_of(hw,
							 struct rk808_clkout,
							 clkout2_hw);
	struct rk808 *rk808 = rk808_clkout->rk808;

	return regmap_update_bits(rk808->regmap, RK817_SYS_CFG(1),
	return regmap_update_bits(rk808_clkout->regmap, RK817_SYS_CFG(1),
				  RK817_CLK32KOUT2_EN,
				  enable ? RK817_CLK32KOUT2_EN : 0);
}
@@ -115,10 +111,9 @@ static int rk817_clkout2_is_prepared(struct clk_hw *hw)
	struct rk808_clkout *rk808_clkout = container_of(hw,
							 struct rk808_clkout,
							 clkout2_hw);
	struct rk808 *rk808 = rk808_clkout->rk808;
	unsigned int val;

	int ret = regmap_read(rk808->regmap, RK817_SYS_CFG(1), &val);
	int ret = regmap_read(rk808_clkout->regmap, RK817_SYS_CFG(1), &val);

	if (ret < 0)
		return 0;
@@ -153,18 +148,21 @@ static const struct clk_ops *rkpmic_get_ops(long variant)
static int rk808_clkout_probe(struct platform_device *pdev)
{
	struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
	struct i2c_client *client = rk808->i2c;
	struct device_node *node = client->dev.of_node;
	struct device *dev = &pdev->dev;
	struct clk_init_data init = {};
	struct rk808_clkout *rk808_clkout;
	int ret;

	rk808_clkout = devm_kzalloc(&client->dev,
	dev->of_node = pdev->dev.parent->of_node;

	rk808_clkout = devm_kzalloc(dev,
				    sizeof(*rk808_clkout), GFP_KERNEL);
	if (!rk808_clkout)
		return -ENOMEM;

	rk808_clkout->rk808 = rk808;
	rk808_clkout->regmap = dev_get_regmap(pdev->dev.parent, NULL);
	if (!rk808_clkout->regmap)
		return -ENODEV;

	init.parent_names = NULL;
	init.num_parents = 0;
@@ -173,10 +171,10 @@ static int rk808_clkout_probe(struct platform_device *pdev)
	rk808_clkout->clkout1_hw.init = &init;

	/* optional override of the clockname */
	of_property_read_string_index(node, "clock-output-names",
	of_property_read_string_index(dev->of_node, "clock-output-names",
				      0, &init.name);

	ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout1_hw);
	ret = devm_clk_hw_register(dev, &rk808_clkout->clkout1_hw);
	if (ret)
		return ret;

@@ -185,10 +183,10 @@ static int rk808_clkout_probe(struct platform_device *pdev)
	rk808_clkout->clkout2_hw.init = &init;

	/* optional override of the clockname */
	of_property_read_string_index(node, "clock-output-names",
	of_property_read_string_index(dev->of_node, "clock-output-names",
				      1, &init.name);

	ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout2_hw);
	ret = devm_clk_hw_register(dev, &rk808_clkout->clkout2_hw);
	if (ret)
		return ret;

+1 −1
Original line number Diff line number Diff line
@@ -609,7 +609,7 @@ config INPUT_PWM_VIBRA

config INPUT_RK805_PWRKEY
	tristate "Rockchip RK805 PMIC power key support"
	depends on MFD_RK808
	depends on MFD_RK8XX
	help
	  Select this option to enable power key driver for RK805.

+20 −1
Original line number Diff line number Diff line
@@ -1183,12 +1183,17 @@ config MFD_RC5T583
	  Additional drivers must be enabled in order to use the
	  different functionality of the device.

config MFD_RK808
config MFD_RK8XX
	bool
	select MFD_CORE

config MFD_RK8XX_I2C
	tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power Management Chip"
	depends on I2C && OF
	select MFD_CORE
	select REGMAP_I2C
	select REGMAP_IRQ
	select MFD_RK8XX
	help
	  If you say yes here you get support for the RK805, RK808, RK809,
	  RK817 and RK818 Power Management chips.
@@ -1196,6 +1201,20 @@ config MFD_RK808
	  through I2C interface. The device supports multiple sub-devices
	  including interrupts, RTC, LDO & DCDC regulators, and onkey.

config MFD_RK8XX_SPI
	tristate "Rockchip RK806 Power Management Chip"
	depends on SPI && OF
	select MFD_CORE
	select REGMAP_SPI
	select REGMAP_IRQ
	select MFD_RK8XX
	help
	  If you say yes here you get support for the RK806 Power Management
	  chip.
	  This driver provides common support for accessing the device
	  through an SPI interface. The device supports multiple sub-devices
	  including interrupts, LDO & DCDC regulators, and power on-key.

config MFD_RN5T618
	tristate "Ricoh RN5T567/618 PMIC"
	depends on I2C
Loading