Skip to contentSkip to conversation

Add Support for MediaTek PMIC MT6397 MFD Core and Regulator

PATCH Superseded Flora Fu 4 participants 22 messages Nov 28, 2014 – Dec 3, 2014

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Flora Fu

author
#0 lore raw

v2 cover Add Support for MediaTek PMIC MT6397 MFD Core and Regulator

The patch sets add support for MediaTek PMIC MT6397 MFD core and its regulator driver. This is hardware layout for access PMIC MT6397 from AP SoC MT8135.
Between PMIC MT6397 and MT8135, the physical signal channel is SPI bus.
A specific hardware called PMIC Wrapper or PWRAP to handle access protocols in both PMIC and AP side.

+-----------------+           +---------------+
|                 |           |               |
| Mediatek AP SoC |           |               |
| (ex. MT8135)    |           |    MT6397     |
|                 |           |               |
|      +--------+ | (SPI bus) | +--------+    |
|      |        | |-----------| |        |    |
|      |  PMIC  | |-----------| |  PMIC  |    |
|      | Wrapper| |-----------| | Wrapper|    |
|      |        | |-----------| |        |    |
|      +--------+ |           | +--------+    |
|                 |           |               |
+-----------------+           +---------------+

Changes since v1
================
(1) Patch 1/8: Add MT8135 PMIC wrapper driver for SoC's proprietary hardware.
(2) Patch 2/8: Update patch of MT6397 MFD driver to contain only MFD related codes and fix defeat of coding styles.
(3) Patch 3/8: Update MT6397 regulator driver
- use helpers and standard ways for specifying data in regulator description.
- add more comments to explaining why the driver implement its own regulator_ops for ".is_enabled", ".set_voltage_sel" and ".get_voltage_sel".
- update driver implement for coding styles.
(4) Patch 4/8: Add document for MT8135 PMIC wrapper.
(5) Patch 5/8: Update document for MT6397 MFD.
(6) Patch 6/8: Update document for MT6397 regulators.
(7) Patch 7/8: Add device tree for MT6397 MFD in mt8135.dtsi.
(8) Patch 8/8: Update device tree for MT6397 regulators in mt8135.dtsi.

Initial version (v1):
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/302984.html

This driver is based on 3.18-rc1.

Flora Fu (8):
soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC
mfd: MT6397: Add support for PMIC MT6397 MFD
regulator: MT6397: Add support for MT6397 regulator dt-bindings:: Add document for MT8135 PMIC Wrapper
dt-bindings: Add document for MT6397 MFD
dt-bindings: Add document for MT6397 regulator
ARM: dts: mt8135: Add support for PMIC MT6397 MFD
ARM: dts: mt8135: Add support for MT6397 regulator

 Documentation/devicetree/bindings/mfd/mt6397.txt   |  73 ++
 .../bindings/regulator/mt6397-regulator.txt        |  32 +
 .../soc/mediatek/mediatek,mt8135-pwrap.txt         |  79 ++
 arch/arm/boot/dts/mt8135.dtsi                      | 211 ++++++
 drivers/mfd/Kconfig                                |  10 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/mt6397-core.c                          |  84 ++
 drivers/regulator/Kconfig                          |   9 +
 drivers/regulator/Makefile                         |   2 +-
 drivers/regulator/mt6397-regulator.c               | 369 +++++++++
 drivers/soc/Kconfig                                |   1 +
 drivers/soc/Makefile                               |   1 +
 drivers/soc/mediatek/Kconfig                       |  11 +
 drivers/soc/mediatek/Makefile                      |   1 +
 drivers/soc/mediatek/mt8135-pmic-wrap.c            | 844 +++++++++++++++++++++
 drivers/soc/mediatek/mt8135-pmic-wrap.h            | 138 ++++
 include/linux/mfd/mt6397/core.h                    |  23 +
 include/linux/mfd/mt6397/registers.h               | 362 +++++++++
 include/linux/regulator/mt6397-regulator.h         |  49 ++
 include/linux/soc/mediatek/mtk-pmic-wrap.h         |  25 +
 20 files changed, 2324 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/mt6397.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt
 create mode 100644 drivers/mfd/mt6397-core.c
 create mode 100644 drivers/regulator/mt6397-regulator.c
 create mode 100644 drivers/soc/mediatek/Kconfig
 create mode 100644 drivers/soc/mediatek/Makefile
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.c
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.h
 create mode 100644 include/linux/mfd/mt6397/core.h
 create mode 100644 include/linux/mfd/mt6397/registers.h
 create mode 100644 include/linux/regulator/mt6397-regulator.h
 create mode 100644 include/linux/soc/mediatek/mtk-pmic-wrap.h

--
1.8.1.1.dirty

author
#1 lore raw

PATCH v2 1/8 soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC

Add PMIC wrapper of MT8135 to access MFD MT6397 MFD.

---
 drivers/soc/Kconfig                        |   1 +
 drivers/soc/Makefile                       |   1 +
 drivers/soc/mediatek/Kconfig               |  11 +
 drivers/soc/mediatek/Makefile              |   1 +
 drivers/soc/mediatek/mt8135-pmic-wrap.c    | 844 +++++++++++++++++++++++++++++
 drivers/soc/mediatek/mt8135-pmic-wrap.h    | 138 +++++
 include/linux/soc/mediatek/mtk-pmic-wrap.h |  25 +
 7 files changed, 1021 insertions(+)
 create mode 100644 drivers/soc/mediatek/Kconfig
 create mode 100644 drivers/soc/mediatek/Makefile
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.c
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.h
 create mode 100644 include/linux/soc/mediatek/mtk-pmic-wrap.h
drivers/soc/Kconfig +1 -0
index 76d6bd4..d8bde82 100644
@@ -1,5 +1,6 @@
 menu "SOC (System On Chip) specific Drivers"
 
+source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/ti/Kconfig"
 source "drivers/soc/versatile/Kconfig"
drivers/soc/Makefile +1 -0
index 063113d..70042b2 100644
@@ -2,6 +2,7 @@
 # Makefile for the Linux Kernel SOC specific device drivers.
 #
 
+obj-$(CONFIG_ARCH_MEDIATEK)	+= mediatek/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-$(CONFIG_SOC_TI)		+= ti/
drivers/soc/mediatek/Kconfig new file +11 -0
new file mode 100644
index 0000000..0dd1897
@@ -0,0 +1,11 @@
+#
+# MediaTek SoC drivers
+#
+config MT8135_PMIC_WRAP
+	tristate "MediaTek MT8135 PMIC Wrapper Support"
+	depends on ARCH_MEDIATEK
+	help
+	  Say yes here to add support for MediaTek MT8135 PMIC Wrapper.
+	  PMIC wrapper is a proprietary hardware in MT8135 to make
+	  communication protocols to access PMIC device.
+	  This driver implement access protocols for MT8135.
drivers/soc/mediatek/Makefile new file +1 -0
new file mode 100644
index 0000000..49b9588
@@ -0,0 +1 @@
+obj-$(CONFIG_MT8135_PMIC_WRAP)		+= mt8135-pmic-wrap.o
drivers/soc/mediatek/mt8135-pmic-wrap.c new file +844 -0

844 lines not on this page · raw message

drivers/soc/mediatek/mt8135-pmic-wrap.h new file +138 -0

138 lines not on this page · raw message

include/linux/soc/mediatek/mtk-pmic-wrap.h new file +25 -0
new file mode 100644
index 0000000..28212a1
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __MTK_PMIC_WRAP_H__
+#define __MTK_PMIC_WRAP_H__
+
+struct pmic_wrapper {
+	struct platform_device *pdev;
+	struct regmap *regmap;
+	void __iomem *pwrap_base;
+	void __iomem *pwrap_bridge_base;
+};
+
+#endif	/* __MTK_PMIC_WRAP_H__ */
Signature · 1 line
1.8.1.1.dirty
author
#3 lore raw

PATCH v2 2/8 mfd: MT6397: Add support for PMIC MT6397 MFD

In reply to Flora Fu

Add core files for MT6397 MFD driver.

---
 drivers/mfd/Kconfig                  |  10 +
 drivers/mfd/Makefile                 |   1 +
 drivers/mfd/mt6397-core.c            |  84 ++++++++
 include/linux/mfd/mt6397/core.h      |  23 +++
 include/linux/mfd/mt6397/registers.h | 362 +++++++++++++++++++++++++++++++++++
 5 files changed, 480 insertions(+)
 create mode 100644 drivers/mfd/mt6397-core.c
 create mode 100644 include/linux/mfd/mt6397/core.h
 create mode 100644 include/linux/mfd/mt6397/registers.h
drivers/mfd/Kconfig +10 -0
index 1456ea7..f0b3efc 100644
@@ -1318,6 +1318,16 @@ config MFD_STW481X
 	  in various ST Microelectronics and ST-Ericsson embedded
 	  Nomadik series.
 
+config MFD_MT6397
+	tristate "MediaTek MT6397 PMIC Support"
+	select MFD_CORE
+	select IRQ_DOMAIN
+	help
+	  Say yes here to add support for MediaTek MT6397 PMIC. This is
+	  a Power Management IC. This driver provides common support for
+	  accessing the device; additional drivers must be enabled in order
+	  to use the functionality of the device.
+
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
 
drivers/mfd/Makefile +1 -0
index 8bd54b1..7168193 100644
@@ -177,3 +177,4 @@ obj-$(CONFIG_MFD_HI6421_PMIC)	+= hi6421-pmic-core.o
 
 intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
+obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
drivers/mfd/mt6397-core.c new file +84 -0

84 lines not on this page · raw message

include/linux/mfd/mt6397/core.h new file +23 -0
new file mode 100644
index 0000000..567164e
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __MFD_MT6397_CORE_H__
+#define __MFD_MT6397_CORE_H__
+
+struct mt6397_chip {
+	struct device *dev;
+	struct regmap *regmap;
+};
+
+#endif /* __MFD_MT6397_CORE_H__ */
include/linux/mfd/mt6397/registers.h new file +362 -0

362 lines not on this page · raw message

Signature · 1 line
1.8.1.1.dirty
author
#7 lore raw

PATCH v2 3/8 regulator: MT6397: Add support for MT6397 regulator

In reply to Flora Fu

Add MT6397 regulator driver.

---
 drivers/regulator/Kconfig                  |   9 +
 drivers/regulator/Makefile                 |   2 +-
 drivers/regulator/mt6397-regulator.c       | 369 +++++++++++++++++++++++++++++
 include/linux/regulator/mt6397-regulator.h |  49 ++++
 4 files changed, 428 insertions(+), 1 deletion(-)
 create mode 100644 drivers/regulator/mt6397-regulator.c
 create mode 100644 include/linux/regulator/mt6397-regulator.h
drivers/regulator/Kconfig +9 -0
index 55d7b7b..38a8d84 100644
@@ -433,6 +433,15 @@ config REGULATOR_MC13892
 	  Say y here to support the regulators found on the Freescale MC13892
 	  PMIC.
 
+config REGULATOR_MT6397
+	tristate "MediaTek MT6397 PMIC"
+	depends on MFD_MT6397
+	help
+	  Say y here to select this option to enable the power regulator of
+	  MediaTek MT6397 PMIC.
+	  This driver supports the control of different power rails of device
+	  through regulator interface.
+
 config REGULATOR_PALMAS
 	tristate "TI Palmas PMIC Regulators"
 	depends on MFD_PALMAS
drivers/regulator/Makefile +1 -1
index 1029ed3..2f45812 100644
@@ -58,6 +58,7 @@ obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o
 obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
 obj-$(CONFIG_REGULATOR_MC13XXX_CORE) +=  mc13xxx-regulator-core.o
+obj-$(CONFIG_REGULATOR_MT6397)	+= mt6397-regulator.o
 obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
@@ -96,5 +97,4 @@ obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
 obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
 obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
 
-
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
drivers/regulator/mt6397-regulator.c new file +369 -0

369 lines not on this page · raw message

include/linux/regulator/mt6397-regulator.h new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
1.8.1.1.dirty
author
#11 lore raw

PATCH v2 4/8 dt-bindings:: Add document for MT8135 PMIC Wrapper

In reply to Flora Fu
---
 .../soc/mediatek/mediatek,mt8135-pwrap.txt         | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt new file +79 -0
new file mode 100644
index 0000000..46e9b2b
@@ -0,0 +1,79 @@
+MediaTek MT8135 PMIC Wrapper Driver
+
+MediaTek PMIC MFD is interfaced to host controller using SPI interface
+by a proprietary hardware called PMIC wrapper or pwrap.
+
++-----------------+           +---------------+
+|                 |           |               |
+| Mediatek AP SoC |           |               |
+| (ex. MT8135)    |           |    MT6397     |
+|                 |           |               |
+|      +--------+ | (SPI bus) | +--------+    |
+|      |        | |-----------| |        |    |
+|      |  PMIC  | |-----------| |  PMIC  |    |
+|      | Wrapper| |-----------| | Wrapper|    |
+|      |        | |-----------| |        |    |
+|      +--------+ |           | +--------+    |
+|                 |           |               |
++-----------------+           +---------------+
+
+This document describes the binding for MT8135 PMIC wrapper.
+
+Required properties in pwrap device node.
+- compatible:"mediatek,mt8135-pwrap"
+- interrupts: IRQ for pwrap in SOC
+- reg: address range for pwrap registers
+- resets: reset bit for pwrap
+- clock: clock frequency selection in SPI bus
+- pmic: Mediatek PMIC MFD is the child device of pwrap
+
+Properties for children:
+See the following for child node definitions:
+Documentation/devicetree/bindings/mfd/mt6397.txt
+
+Example:
+	pwrap: pwrap at 1000f000 {
+		compatible = "mediatek,mt8135-pwrap";
+		reg = <0 0x1000f000 0 0x1000>,
+			<0 0x11017000 0 0x1000>;
+		reg-names = "pwrap-base", "pwrap-bridge-base";
+		interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+		resets = <&infrarst MT8135_INFRA_PMIC_WRAP_RST>,
+				<&perirst MT8135_PERI_PWRAP_BRIDGE_SW_RST>;
+		reset-names = "infra-pwrap-rst",
+				"peri-pwrap-bridge-rst";
+		clocks = <&pmicspi_sel>, <&clk26m>;
+		clock-names = "pmicspi-sel", "pmicspi-parent";
+
+		pmic {
+			compatible = "mediatek,mt6397";
+
+			codec: mt6397codec {
+				compatible = "mediatek,mt6397-codec";
+			};
+
+			pinctrl at 0x0000C000 {
+				compatible = "mediatek,mt6397-pinctrl";
+				reg = <0 0x0000C000 0 0x0108>;
+				gpio-controller;
+			};
+
+			regulators {
+				mt6397_vpca15_reg: buck_vpca15 {
+					regulator-name = "vpca15";
+					regulator-min-microvolt = < 700000>;
+					regulator-max-microvolt = <1493750>;
+					regulator-always-on;
+					regulator-boot-on;
+				};
+
+				mt6397_vpca7_reg: buck_vpca7 {
+					regulator-name = "vpca7";
+					regulator-min-microvolt = < 700000>;
+					regulator-max-microvolt = <1493750>;
+					regulator-always-on;
+					regulator-boot-on;
+				};
+			}
+		}
+	}
Signature · 1 line
1.8.1.1.dirty
author
#12 lore raw

PATCH v2 5/8 dt-bindings: Add document for MT6397 MFD

In reply to Flora Fu
---
 Documentation/devicetree/bindings/mfd/mt6397.txt | 73 ++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mt6397.txt
Documentation/devicetree/bindings/mfd/mt6397.txt new file +73 -0
new file mode 100644
index 0000000..1f38c44
@@ -0,0 +1,73 @@
+MediaTek MT6397 Multifunction Device Driver
+
+MT6397 is a multifunction device with the following sub modules:
+- Regulator
+- RTC
+- Audio codec
+- GPIO
+- Clock
+
+It is interfaced to host controller using SPI interface by a proprietary hardware
+called PMIC wrapper or pwrap. MT6397 MFD is a child device of pwrap.
+See the following for pwarp node definitions:
+Documentation/devicetree/bindings/soc/mediatek,mt8135-pwrap.txt
+
+This document describes the binding for mfd device and its sub module.
+
+Required properties:
+compatible = "mediatek,mt6397";
+
+Optional properties:
+- codec: Audio codec
+- pinctrl: GPIO in mt6397
+- rtc: RTC
+- clock: clocks in mt6397
+- regulators: regulators in mt6397
+
+Example:
+	pwrap: pwrap at 1000f000 {
+		compatible = "mediatek,mt8135-pwrap";
+		reg = <0 0x1000f000 0 0x1000>,
+			<0 0x11017000 0 0x1000>;
+		reg-names = "pwrap-base", "pwrap-bridge-base";
+		interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+		resets = <&infrarst MT8135_INFRA_PMIC_WRAP_RST>,
+				<&perirst MT8135_PERI_PWRAP_BRIDGE_SW_RST>;
+		reset-names = "infra-pwrap-rst",
+				"peri-pwrap-bridge-rst";
+		clocks = <&pmicspi_sel>, <&clk26m>;
+		clock-names = "pmicspi-sel", "pmicspi-parent";
+
+		pmic {
+			compatible = "mediatek,mt6397";
+
+			codec: mt6397codec {
+				compatible = "mediatek,mt6397-codec";
+			};
+
+			pinctrl at 0x0000C000 {
+				compatible = "mediatek,mt6397-pinctrl";
+				reg = <0 0x0000C000 0 0x0108>;
+				gpio-controller;
+			};
+
+			regulators {
+				mt6397_vpca15_reg: buck_vpca15 {
+					regulator-name = "vpca15";
+					regulator-min-microvolt = < 700000>;
+					regulator-max-microvolt = <1493750>;
+					regulator-ramp-delay = <12500>;
+					regulator-enable-ramp-delay = <200>;
+					regulator-always-on;
+					regulator-boot-on;
+				};
+
+				mt6397_vgp4_reg: ldo_vgp4 {
+					regulator-name = "vgp4";
+					regulator-min-microvolt = <1200000>;
+					regulator-max-microvolt = <3300000>;
+					regulator-enable-ramp-delay = <218>;
+				};
+			}
+		}
+	}
Signature · 1 line
1.8.1.1.dirty
author
#13 lore raw

PATCH v2 6/8 dt-bindings: Add document for MT6397 regulator

In reply to Flora Fu
---
 .../bindings/regulator/mt6397-regulator.txt        | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt new file +32 -0
new file mode 100644
index 0000000..3a3cc59
@@ -0,0 +1,32 @@
+Mediatek MT6397 Regulator Driver
+
+Required properties:
+- compatible: "mediatek,mt6397"
+- regulators: This is the list of child nodes that specify the regulator
+  initialization data for defined regulators. The definition for each of these
+  nodes is defined using the standard binding for regulators found at
+  Documentation/devicetree/bindings/regulator/regulator.txt.
+
+Example:
+	pmic {
+		compatible = "mediatek,mt6397";
+
+		regulators {
+			mt6397_vpca15_reg: buck_vpca15 {
+				regulator-name = "vpca15";
+				regulator-min-microvolt = < 700000>;
+				regulator-max-microvolt = <1493750>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <200>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			mt6397_vgp4_reg: ldo_vgp4 {
+				regulator-name = "vgp4";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+		};
+	};
Signature · 1 line
1.8.1.1.dirty
author
#15 lore raw

PATCH v2 7/8 ARM: dts: mt8135: Add support for PMIC MT6397 MFD

In reply to Flora Fu

Add device tree for MT6397 MFD and its PMIC wrapper in mt8135.dtsi.

---
 arch/arm/boot/dts/mt8135.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/boot/dts/mt8135.dtsi +19 -0
index 90a56ad..14a8aad 100644
@@ -102,6 +102,25 @@
 			clock-names = "system-clk", "rtc-clk";
 		};
 
+
+		pwrap: pwrap at 1000f000 {
+			compatible = "mediatek,mt8135-pwrap";
+			reg = <0 0x1000f000 0 0x1000>,
+				<0 0x11017000 0 0x1000>;
+			reg-names = "pwrap-base", "pwrap-bridge-base";
+			interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&infrarst MT8135_INFRA_PMIC_WRAP_RST>,
+					<&perirst MT8135_PERI_PWRAP_BRIDGE_SW_RST>;
+			reset-names = "infra-pwrap-rst",
+					"peri-pwrap-bridge-rst";
+			clocks = <&pmicspi_sel>, <&clk26m> ;
+			clock-names = "pmicspi-sel", "pmicspi-parent";
+
+			pmic {
+				compatible = "mediatek,mt6397";
+			};
+		};
+
 		gic: interrupt-controller at 10211000 {
 			compatible = "arm,cortex-a15-gic";
 			interrupt-controller;
Signature · 1 line
1.8.1.1.dirty
author
#16 lore raw

PATCH v2 8/8 ARM: dts: mt8135: Add support for MT6397 regulator

In reply to Flora Fu

Add device tree for MT6397 regulators in mt8135.dtsi.

---
 arch/arm/boot/dts/mt8135.dtsi | 192 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 192 insertions(+)
arch/arm/boot/dts/mt8135.dtsi +192 -0
index 14a8aad..436b72f 100644
@@ -118,6 +118,198 @@
 
 			pmic {
 				compatible = "mediatek,mt6397";
+
+				regulators {
+					mt6397_vpca15_reg: buck_vpca15 {
+						regulator-name = "vpca15";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <200>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vpca7_reg: buck_vpca7 {
+						regulator-name = "vpca7";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <115>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vsramca15_reg: buck_vsramca15 {
+						regulator-name = "vsramca15";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <115>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vsramca7_reg: buck_vsramca7 {
+						regulator-name = "vsramca7";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <115>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vcore_reg: buck_vcore {
+						regulator-name = "vcore";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <115>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vgpu_reg: buck_vgpu {
+						regulator-name = "vgpu";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <115>;
+					};
+
+					mt6397_vdrm_reg: buck_vdrm {
+						regulator-name = "vdrm";
+						regulator-min-microvolt = < 800000>;
+						regulator-max-microvolt = <1593750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <500>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vio18_reg: buck_vio18 {
+						regulator-name = "vio18";
+						regulator-min-microvolt = <1500000>;
+						regulator-max-microvolt = <2120000>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <500>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vtcxo_reg: ldo_vtcxo {
+						regulator-name = "vtcxo";
+						regulator-min-microvolt = <2800000>;
+						regulator-max-microvolt = <2800000>;
+						regulator-enable-ramp-delay = <90>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_va28_reg: ldo_va28 {
+						regulator-name = "va28";
+						regulator-min-microvolt = <2800000>;
+						regulator-max-microvolt = <2800000>;
+						regulator-enable-ramp-delay = <218>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_vcama_reg: ldo_vcama {
+						regulator-name = "vcama";
+						regulator-min-microvolt = <1500000>;
+						regulator-max-microvolt = <2800000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vio28_reg: ldo_vio28 {
+						regulator-name = "vio28";
+						regulator-min-microvolt = <2800000>;
+						regulator-max-microvolt = <2800000>;
+						regulator-enable-ramp-delay = <240>;
+						regulator-always-on;
+						regulator-boot-on;
+					};
+
+					mt6397_usb_reg: ldo_usb {
+						regulator-name = "usb";
+						regulator-min-microvolt = <3300000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vmc_reg: ldo_vmc {
+						regulator-name = "vmc";
+						regulator-min-microvolt = <1800000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vmch_reg: ldo_vmch {
+						regulator-name = "vmch";
+						regulator-min-microvolt = <3000000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vemc_3v3_reg: ldo_vemc3v3 {
+						regulator-name = "vemc_3v3";
+						regulator-min-microvolt = <3000000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+						regulator-boot-on;
+					};
+
+					mt6397_vgp1_reg: ldo_vcamd {
+						regulator-name = "vgp1";
+						regulator-min-microvolt = <1220000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <240>;
+					};
+
+					mt6397_vgp2_reg: ldo_vcamio {
+						regulator-name = "vgp2";
+						regulator-min-microvolt = <1200000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vgp3_reg: ldo_vcamaf {
+						regulator-name = "vgp3";
+						regulator-min-microvolt = <1200000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vgp4_reg: ldo_vgp4 {
+						regulator-name = "vgp4";
+						regulator-min-microvolt = <1200000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vgp5_reg: ldo_vgp5 {
+						regulator-name = "vgp5";
+						regulator-min-microvolt = <1200000>;
+						regulator-max-microvolt = <3000000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vgp6_reg: ldo_vgp6 {
+						regulator-name = "vgp6";
+						regulator-min-microvolt = <1200000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+
+					mt6397_vibr_reg: ldo_vibr {
+						regulator-name = "vibr";
+						regulator-min-microvolt = <1200000>;
+						regulator-max-microvolt = <3300000>;
+						regulator-enable-ramp-delay = <218>;
+					};
+				};
 			};
 		};
 
Signature · 1 line
1.8.1.1.dirty
maintainer
#8 lore raw

Re: [PATCH v2 3/8] regulator: MT6397: Add support for MT6397 regulator

In reply to Flora Fu

drivers/regulator/Makefile obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o · line 100

Quoted 6 lines · Flora Fu
drivers/regulator/Makefile +0 -1
@@ -96,5 +97,4 @@ obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
 obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
 obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
 
-
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG

Random whitespace change here...

drivers/regulator/mt6397-regulator.c line 151

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +5 -0
+	/* For HW design, buck voltage control register has two parts.
+	 * part 1: vsel_reg for register mode
+	 * part 2: voselon_reg or hw control mode
+	 * Both parts should be updated and sync when user set voltage.
+	 */

Why does nothing else in the driver know about this "hw control mode" - what does it actually mean, shouldn't it affect some of the other operations?

drivers/regulator/mt6397-regulator.c line 158

Quoted 7 lines
drivers/regulator/mt6397-regulator.c new file +7 -0
+	ret = regmap_update_bits(rdev->regmap, info->desc.vsel_reg,
+		info->desc.vsel_mask, sel);
+	if (ret != 0) {
+		dev_err(&rdev->dev, "Failed to update vsel: %d\n", ret);
+		return ret;
+	}
+	ret = regmap_update_bits(rdev->regmap, info->voselon_reg,

Missing blank line between these blocks.

drivers/regulator/mt6397-regulator.c line 186

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +4 -0
+static int mt6397_buck_get_voltage_sel(struct regulator_dev *rdev)
+{
 
+static int mt6397_regulator_is_enabled(struct regulator_dev *rdev)
+{

To repeat my comments on the last version: please use the generic regmap operations rather than copying them.

drivers/regulator/mt6397-regulator.c line 297

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +5 -0
+	np = of_node_get(pdev->dev.parent->of_node);
+	if (!np)
+		return -EINVAL;
+
+	regulators = of_get_child_by_name(np, "regulators");

To further repeat my previous review comments:

| Define regulators_node and of_match in the regulator desc and you can
| remove both this table and all your DT matching code in the driver, the
| core will handle it for you.

Please don't ignore review comments.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141128/71cdd44e/attachment-0001.sig>

maintainer
#17 lore raw

Re: [PATCH v2 8/8] ARM: dts: mt8135: Add support for MT6397 regulator

In reply to Flora Fu
Quoted 5 lines · Flora Fu

Add device tree for MT6397 regulators in mt8135.dtsi.

---
 arch/arm/boot/dts/mt8135.dtsi | 192 ++++++++++++++++++++++++++++++++++++++++++

This appears to be the DT fragment for a SoC but you are defining the system integration for the PMIC. That's bad, the PMIC is a separate device so should be hooked up by the board using it. If there's common elements from a reference design they should be in their own .dtsi.

arch/arm/boot/dts/mt8135.dtsi line 150

Quoted 8 lines
arch/arm/boot/dts/mt8135.dtsi +8 -0
+					mt6397_vsramca15_reg: buck_vsramca15 {
+						regulator-name = "vsramca15";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;
+						regulator-ramp-delay = <12500>;
+						regulator-enable-ramp-delay = <115>;
+						regulator-always-on;
+						regulator-boot-on;

Why do these regulators have both a board specific ramp delay specified and -always-on? If they are always on presumably they never ramp at runtime; if this is a generic parameter for the device it should be in the driver.

Similarly why is boot_on being specified - we can read the startup state for all these regulators?

arch/arm/boot/dts/mt8135.dtsi line 156

Quoted 6 lines
arch/arm/boot/dts/mt8135.dtsi +6 -0
+					};
+
+					mt6397_vsramca7_reg: buck_vsramca7 {
+						regulator-name = "vsramca7";
+						regulator-min-microvolt = < 700000>;
+						regulator-max-microvolt = <1493750>;

All these regulators seem to have exactly the same range specified which
looks awfully like it might be the maximum variability the regulator has
rather than the board specific range that's supported; the fact that
they appear to have no consumers that might vary the voltage is another
warning sign. This is probably wrong, the constraints should be
whatever is verified good for the board.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141128/d12261be/attachment.sig>

maintainer
#14 lore raw

Re: [PATCH v2 6/8] dt-bindings: Add document for MT6397 regulator

In reply to Flora Fu

Documentation/devicetree/bindings/regulator/mt6397-regulator.txt line 8

Quoted 5 lines · Flora Fu
+- compatible: "mediatek,mt6397"
+- regulators: This is the list of child nodes that specify the regulator
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt new file +3 -0
+  initialization data for defined regulators. The definition for each of these
+  nodes is defined using the standard binding for regulators found at
+  Documentation/devicetree/bindings/regulator/regulator.txt.

You need to specify which regulator names are valid and how they
correspond to the hardware as part of the binding.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141128/91b3422b/attachment-0001.sig>

maintainer
#2 lore raw

Re: [PATCH v2 1/8] soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC

In reply to Flora Fu

drivers/soc/mediatek/Kconfig

Quoted 6 lines · Flora Fu
drivers/soc/mediatek/Kconfig new file +5 -0
+config MT8135_PMIC_WRAP
+	tristate "MediaTek MT8135 PMIC Wrapper Support"
+	depends on ARCH_MEDIATEK
+	help
 
+#include <linux/regmap.h>

This uses regmap but doesn't select anything from the regmap framework
so won't build if nothing else selects regmap.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141128/ead01535/attachment.sig>

author
#9 lore raw

PATCH v2 3/8 regulator: MT6397: Add support for MT6397 regulator

In reply to Mark Brown

Hi, Mark

Quoted 11 lines · Mark Brown

drivers/regulator/Makefile obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o · line 100

Quoted 6 lines · Flora Fu
drivers/regulator/Makefile +0 -1
@@ -96,5 +97,4 @@ obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
 obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
 obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
 
-
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG

Random whitespace change here...

Quoted 9 lines

drivers/regulator/mt6397-regulator.c line 151

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +5 -0
+	/* For HW design, buck voltage control register has two parts.
+	 * part 1: vsel_reg for register mode
+	 * part 2: voselon_reg or hw control mode
+	 * Both parts should be updated and sync when user set voltage.
+	 */

Why does nothing else in the driver know about this "hw control mode" - what does it actually mean, shouldn't it affect some of the other operations?

In the regulator, we have two parts of registers to control the output in voltage selection. The mode setting is done in boot loader stage before kernel.
The hw control mode is used for external signal to control voltage selection. When the hw control mode is chosen, "voselon" register is the action register to do voltage selection if consumer make voltage selection. Without hw control mode, vsel_reg is the action register. To fit all mode selection, we update and sync two parts of registers in regulator framework.

Quoted 10 lines

drivers/regulator/mt6397-regulator.c line 186

Quoted 6 lines
drivers/regulator/mt6397-regulator.c new file +4 -0
+static int mt6397_buck_get_voltage_sel(struct regulator_dev *rdev)
+{
 
+static int mt6397_regulator_is_enabled(struct regulator_dev *rdev)
+{

To repeat my comments on the last version: please use the generic regmap operations rather than copying them.

The generic helper function does not fit usage of the regulator. In general function, it considers that the vsel_reg for selection voltage is also the register for querying voltage selection. The enable bit for enable function is the bit for querying the status.

In the hardware design, the output of voltage selection register is different from vsel_reg. Is is located in nivosel. The enable bit is locate in the other bit called "qi_mask".
Please check comment in MT6397 regulators' information.
/*
* MT6397 regulators' information
*
* @desc: standard fields of regulator description.
* @voselon_reg: Register sections for hardware control mode of bucks
* @nivosel_reg: Register for query output voltage selection of bucks
* @qi_mask: Mask for query enable signal status of regulators */

struct mt6397_regulator_info {
	struct regulator_desc desc;
	u32 voselon_reg;
	u32 nivosel_reg;
	u32 qi_mask;
};

That's whey ops ".get_voltage_sel" and ".is_enabled" is not able to use generic regamp.

Quoted 8 lines

drivers/regulator/mt6397-regulator.c line 297

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +5 -0
+	np = of_node_get(pdev->dev.parent->of_node);
+	if (!np)
+		return -EINVAL;
+
+	regulators = of_get_child_by_name(np, "regulators");

To further repeat my

Quoted 7 lines

previous review comments:

| Define regulators_node and of_match in the regulator desc and you can
| remove both this table and all your DT matching code in the driver, the
| core will handle it for you.

Please don't ignore review comments.

Sure, I think I completely misunderstood what you meant. Could you give more details about the comments?
In this version, the table for DT matching is removed and merged into regulator info in table mt6397_regulators. To register every regulator by devm_regulator_register(), the of_node is parsed from of_regulator_match() by name. Here is to retrieves the device_node "regulators" for of_regulator_match() to get all regulator_init_data and corresponding of_node.
Is any other mechanism I can use to achieve these part without of_regulstor_match()?

Thanks,
Flora

author
#18 lore raw

PATCH v2 8/8 ARM: dts: mt8135: Add support for MT6397 regulator

In reply to Mark Brown

Hi, Mark,

Quoted 4 lines · Mark Brown
Quoted 2 lines · Flora Fu

Add device tree for MT6397 regulators in mt8135.dtsi.

Quoted 9 lines
Quoted 3 lines
---
 arch/arm/boot/dts/mt8135.dtsi | 192 ++++++++++++++++++++++++++++++++++++++++++

This appears to be the DT fragment for a SoC but you are defining the system integration for the PMIC. That's bad, the PMIC is a separate device so should be hooked up by the board using it. If there's common elements from a reference design they should be in their own .dtsi.

Do you mean that we should add a mt6397.dtsi and include it from mt8135.dtsi? For board specific, update them in mt8135.dtsi?

Thanks,
Flora

#19 lore raw

Re: [PATCH v2 8/8] ARM: dts: mt8135: Add support for MT6397 regulator

Quoted 11 lines · Flora Fu

Hi, Mark,

Quoted 8 lines · Mark Brown
Quoted 5 lines · Flora Fu

Add device tree for MT6397 regulators in mt8135.dtsi.

---
 arch/arm/boot/dts/mt8135.dtsi | 192 ++++++++++++++++++++++++++++++++++++++++++
Quoted 8 lines
Quoted 5 lines

This appears to be the DT fragment for a SoC but you are defining the system integration for the PMIC. That's bad, the PMIC is a separate device so should be hooked up by the board using it. If there's common elements from a reference design they should be in their own .dtsi.

Do you mean that we should add a mt6397.dtsi and include it from mt8135.dtsi? For board specific, update them in mt8135.dtsi?

You can't include it from mt8135.dtsi since here you don't know if a mt6397.dtsi is connected. You have to include both the mt8135.dtsi and the mt6397.dtsi from the board file.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#21 lore raw
In reply to Flora Fu

Hi Flora,

Your Cc list is huge. You should limit it to the lists and to the individuals you know are interested in this series, like maintainers, people who work on Mediatek SoCs, people who commented on previous series.

Sascha

Quoted 89 lines · Flora Fu

The patch sets add support for MediaTek PMIC MT6397 MFD core and its regulator driver. This is hardware layout for access PMIC MT6397 from AP SoC MT8135.
Between PMIC MT6397 and MT8135, the physical signal channel is SPI bus.
A specific hardware called PMIC Wrapper or PWRAP to handle access protocols in both PMIC and AP side.

+-----------------+           +---------------+
|                 |           |               |
| Mediatek AP SoC |           |               |
| (ex. MT8135)    |           |    MT6397     |
|                 |           |               |
|      +--------+ | (SPI bus) | +--------+    |
|      |        | |-----------| |        |    |
|      |  PMIC  | |-----------| |  PMIC  |    |
|      | Wrapper| |-----------| | Wrapper|    |
|      |        | |-----------| |        |    |
|      +--------+ |           | +--------+    |
|                 |           |               |
+-----------------+           +---------------+

Changes since v1
================
(1) Patch 1/8: Add MT8135 PMIC wrapper driver for SoC's proprietary hardware.
(2) Patch 2/8: Update patch of MT6397 MFD driver to contain only MFD related codes and fix defeat of coding styles.
(3) Patch 3/8: Update MT6397 regulator driver
- use helpers and standard ways for specifying data in regulator description.
- add more comments to explaining why the driver implement its own regulator_ops for ".is_enabled", ".set_voltage_sel" and ".get_voltage_sel".
- update driver implement for coding styles.
(4) Patch 4/8: Add document for MT8135 PMIC wrapper.
(5) Patch 5/8: Update document for MT6397 MFD.
(6) Patch 6/8: Update document for MT6397 regulators.
(7) Patch 7/8: Add device tree for MT6397 MFD in mt8135.dtsi.
(8) Patch 8/8: Update device tree for MT6397 regulators in mt8135.dtsi.

Initial version (v1):
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/302984.html

This driver is based on 3.18-rc1.

Flora Fu (8):
soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC
mfd: MT6397: Add support for PMIC MT6397 MFD
regulator: MT6397: Add support for MT6397 regulator dt-bindings:: Add document for MT8135 PMIC Wrapper
dt-bindings: Add document for MT6397 MFD
dt-bindings: Add document for MT6397 regulator
ARM: dts: mt8135: Add support for PMIC MT6397 MFD
ARM: dts: mt8135: Add support for MT6397 regulator

 Documentation/devicetree/bindings/mfd/mt6397.txt   |  73 ++
 .../bindings/regulator/mt6397-regulator.txt        |  32 +
 .../soc/mediatek/mediatek,mt8135-pwrap.txt         |  79 ++
 arch/arm/boot/dts/mt8135.dtsi                      | 211 ++++++
 drivers/mfd/Kconfig                                |  10 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/mt6397-core.c                          |  84 ++
 drivers/regulator/Kconfig                          |   9 +
 drivers/regulator/Makefile                         |   2 +-
 drivers/regulator/mt6397-regulator.c               | 369 +++++++++
 drivers/soc/Kconfig                                |   1 +
 drivers/soc/Makefile                               |   1 +
 drivers/soc/mediatek/Kconfig                       |  11 +
 drivers/soc/mediatek/Makefile                      |   1 +
 drivers/soc/mediatek/mt8135-pmic-wrap.c            | 844 +++++++++++++++++++++
 drivers/soc/mediatek/mt8135-pmic-wrap.h            | 138 ++++
 include/linux/mfd/mt6397/core.h                    |  23 +
 include/linux/mfd/mt6397/registers.h               | 362 +++++++++
 include/linux/regulator/mt6397-regulator.h         |  49 ++
 include/linux/soc/mediatek/mtk-pmic-wrap.h         |  25 +
 20 files changed, 2324 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/mt6397.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt
 create mode 100644 drivers/mfd/mt6397-core.c
 create mode 100644 drivers/regulator/mt6397-regulator.c
 create mode 100644 drivers/soc/mediatek/Kconfig
 create mode 100644 drivers/soc/mediatek/Makefile
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.c
 create mode 100644 drivers/soc/mediatek/mt8135-pmic-wrap.h
 create mode 100644 include/linux/mfd/mt6397/core.h
 create mode 100644 include/linux/mfd/mt6397/registers.h
 create mode 100644 include/linux/regulator/mt6397-regulator.h
 create mode 100644 include/linux/soc/mediatek/mtk-pmic-wrap.h

--
1.8.1.1.dirty

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
maintainer
#20 lore raw

Re: [PATCH v2 8/8] ARM: dts: mt8135: Add support for MT6397 regulator

In reply to Flora Fu
Quoted 9 lines · Flora Fu
Quoted 4 lines · Mark Brown

This appears to be the DT fragment for a SoC but you are defining the system integration for the PMIC. That's bad, the PMIC is a separate device so should be hooked up by the board using it. If there's common elements from a reference design they should be in their own .dtsi.

Do you mean that we should add a mt6397.dtsi and include it from mt8135.dtsi? For board specific, update them in mt8135.dtsi?

More likely you should just add any integration needed in the board
file. There should be no need to specify anything generically for the
regulators on a PMIC except registering the device.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141201/7e88de18/attachment.sig>

#4 lore raw

Re: [PATCH v2 2/8] mfd: MT6397: Add support for PMIC MT6397 MFD

In reply to Flora Fu
Quoted 78 lines · Flora Fu

Add core files for MT6397 MFD driver.

---
 drivers/mfd/Kconfig                  |  10 +
 drivers/mfd/Makefile                 |   1 +
 drivers/mfd/mt6397-core.c            |  84 ++++++++
 include/linux/mfd/mt6397/core.h      |  23 +++
 include/linux/mfd/mt6397/registers.h | 362 +++++++++++++++++++++++++++++++++++
 5 files changed, 480 insertions(+)
 create mode 100644 drivers/mfd/mt6397-core.c
 create mode 100644 include/linux/mfd/mt6397/core.h
 create mode 100644 include/linux/mfd/mt6397/registers.h
drivers/mfd/Kconfig +10 -0
index 1456ea7..f0b3efc 100644
@@ -1318,6 +1318,16 @@ config MFD_STW481X
 	  in various ST Microelectronics and ST-Ericsson embedded
 	  Nomadik series.
 
+config MFD_MT6397
+	tristate "MediaTek MT6397 PMIC Support"
+	select MFD_CORE
+	select IRQ_DOMAIN
+	help
+	  Say yes here to add support for MediaTek MT6397 PMIC. This is
+	  a Power Management IC. This driver provides common support for
+	  accessing the device; additional drivers must be enabled in order
+	  to use the functionality of the device.
+
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
 
drivers/mfd/Makefile +1 -0
index 8bd54b1..7168193 100644
@@ -177,3 +177,4 @@ obj-$(CONFIG_MFD_HI6421_PMIC)	+= hi6421-pmic-core.o
 
 intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
+obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
drivers/mfd/mt6397-core.c new file +27 -0
new file mode 100644
index 0000000..d1a6913
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Flora Fu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mt6397/core.h>
+#include <linux/soc/mediatek/mtk-pmic-wrap.h>
+
+static const struct mfd_cell mt6397_devs[] = {
+	{ .name = "mt6397-rtc" },
+	{ .name = "mt6397-regulator" },
+	{
+		.name = "mt6397-codec",
+		.of_compatible = "mediatek,mt6397-codec"
+	},

drivers/mfd/mt6397-core.c line 37

Quoted 10 lines
drivers/mfd/mt6397-core.c new file +10 -0
+};
+
+static int mt6397_probe(struct platform_device *pdev)
+{
+	u32 ret;
+	struct mt6397_chip *mt6397;
+	struct pmic_wrapper *wrp;
+
+	/* mt6397 MFD is child device of soc pmic wrapper. */
+	wrp = dev_get_drvdata(pdev->dev.parent);

You might want to check this prior to dereferencing it.

drivers/mfd/mt6397-core.c line 39

Quoted 2 lines
drivers/mfd/mt6397-core.c new file +2 -0
+	mt6397 = devm_kzalloc(&pdev->dev,
+			sizeof(*mt6397), GFP_KERNEL);

Why is this wrapped?

drivers/mfd/mt6397-core.c line 43

Quoted 4 lines
drivers/mfd/mt6397-core.c new file +4 -0
+	if (!mt6397)
+		return -ENOMEM;
+
+	mt6397->dev = &pdev->dev;

Is this used else where? If not, I think you can remove it.

drivers/mfd/mt6397-core.c line 45

Quoted 2 lines
drivers/mfd/mt6397-core.c new file +2 -0
+	mt6397->regmap = wrp->regmap;
+	platform_set_drvdata(pdev, mt6397);

Then you can platform_set_drvdata(pdev, regmap);

Although I don't see this being used either. Is it used in the child devices?

drivers/mfd/mt6397-core.c line 57

Quoted 11 lines
drivers/mfd/mt6397-core.c new file +11 -0
+	ret = mfd_add_devices(mt6397->dev, -1, &mt6397_devs[0],
+			ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
+	if (ret)
+		dev_err(mt6397->dev, "failed to add child devices: %d\n", ret);
+
+	return ret;
+}
+
+static int mt6397_remove(struct platform_device *pdev)
+{
+	struct mt6397_chip *mt6397 = platform_get_drvdata(pdev);

No need for this.

drivers/mfd/mt6397-core.c line 59

Quoted 1 line
drivers/mfd/mt6397-core.c new file +1 -0
+	mfd_remove_devices(mt6397->dev);

Just use &pdev->dev, as you did when you registered.

Quoted 2 lines
drivers/mfd/mt6397-core.c new file +2 -0
+	return 0;
+}

[...]

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
maintainer
#10 lore raw

Re: [PATCH v2 3/8] regulator: MT6397: Add support for MT6397 regulator

In reply to Flora Fu
Quoted 10 lines · Flora Fu
Quoted 3 lines · Mark Brown

Why does nothing else in the driver know about this "hw control mode" - what does it actually mean, shouldn't it affect some of the other operations?

In the regulator, we have two parts of registers to control the output in voltage selection. The mode setting is done in boot loader stage before kernel.

Quoted 6 lines

The hw control mode is used for external signal to control voltage selection. When the hw control mode is chosen, "voselon" register is the action register to do voltage selection if consumer make voltage selection. Without hw control mode, vsel_reg is the action register. To fit all mode selection, we update and sync two parts of registers in regulator framework.

There must be more going on in hardware control mode than that, for example this "external signal to control voltage selection" must be able to pick between at least different voltages otherwise it wouldn't seem to make sense. I'm concerned that this implementation is making some assumption about the way in which the hardware control is being used in a particular system and will be broken in other systems, for example if something does start actively trying to vary the voltage.

Quoted 9 lines
Quoted 8 lines

drivers/regulator/mt6397-regulator.c line 186

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +4 -0
+static int mt6397_buck_get_voltage_sel(struct regulator_dev *rdev)
+{
 
+static int mt6397_regulator_is_enabled(struct regulator_dev *rdev)
+{

To repeat my comments on the last version: please use the generic regmap operations rather than copying them.

Quoted 8 lines

The generic helper function does not fit usage of the regulator. In general function, it considers that the vsel_reg for selection voltage is also the register for querying voltage selection. The enable bit for enable function is the bit for querying the status.

In the hardware design, the output of voltage selection register is different from vsel_reg. Is is located in nivosel. The enable bit is locate in the other bit called "qi_mask".

Since you've currently got a custom set voltage function there's no reason not to use this as the register that gets passed to the core and hence to use the generic operation. However I am a bit concerned about this - what is this actually reporting? Is it just something that switches between the hardware and software control voltage automatically or is it doing some kind of measurment of the output and reporting that? The general idea is that get_voltage() should report the configured voltage, monitoring of performance should be done via hwmon or similar.

Similarly for the enable state; we're looking for the state requested by software not the current state of the regulator - that should be reported via get_status() for use in error handling cases.

Quoted 16 lines
Quoted 8 lines

drivers/regulator/mt6397-regulator.c line 297

Quoted 5 lines
drivers/regulator/mt6397-regulator.c new file +4 -0
+	np = of_node_get(pdev->dev.parent->of_node);
+	if (!np)
+		return -EINVAL;
 
+	regulators = of_get_child_by_name(np, "regulators");

To further repeat my

Quoted 7 lines

previous review comments:

| Define regulators_node and of_match in the regulator desc and you can
| remove both this table and all your DT matching code in the driver, the
| core will handle it for you.

Please don't ignore review comments.

Quoted 10 lines

Sure, I think I completely misunderstood what you meant. Could you give more details about the comments?
In this version, the table for DT matching is removed and merged into regulator info in table mt6397_regulators. To register every regulator by devm_regulator_register(), the of_node is parsed from of_regulator_match() by name. Here is to retrieves the device_node "regulators" for of_regulator_match() to get all regulator_init_data and corresponding of_node.
Is any other mechanism I can use to achieve these part without of_regulstor_match()?

What I'm understanding from the above is that the code currently only
registers regulators that are listed in DT (I've not read it in detail).
This is not what should be happening, the driver should always register
all the regulators for the device regardless of if they are mentioned in
a DT somewhere. That way people can read what's currently set in the
hardware which is useful for bringup and diagnostics.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141201/839f1e0f/attachment.sig>

author
#5 lore raw

Re: [PATCH v2 2/8] mfd: MT6397: Add support for PMIC MT6397 MFD

In reply to Lee Jones
Quoted 9 lines · Lee Jones

drivers/mfd/mt6397-core.c line 43

Quoted 4 lines · Flora Fu
drivers/mfd/mt6397-core.c new file +4 -0
+	if (!mt6397)
+		return -ENOMEM;
+
+	mt6397->dev = &pdev->dev;

Is this used else where? If not, I think you can remove it.

No one is used it in this patch sets but it will be used for irq functions to get irq id or print logs for error case in the future. Can I keep it in the patch?

Quoted 9 lines

drivers/mfd/mt6397-core.c line 45

Quoted 3 lines
drivers/mfd/mt6397-core.c new file +2 -0
+	mt6397->regmap = wrp->regmap;
+	platform_set_drvdata(pdev, mt6397);

Then you can platform_set_drvdata(pdev, regmap);

Although I don't see this being used either. Is it used in the child devices?

Yes, it is used to provide regmap handle for its child device. In the patch set, regulator uses it.

Thanks,
Flora

#6 lore raw

Re: [PATCH v2 2/8] mfd: MT6397: Add support for PMIC MT6397 MFD

Quoted 11 lines · Flora Fu
Quoted 9 lines · Lee Jones

drivers/mfd/mt6397-core.c line 43

Quoted 4 lines · Flora Fu
drivers/mfd/mt6397-core.c new file +4 -0
+	if (!mt6397)
+		return -ENOMEM;
+
+	mt6397->dev = &pdev->dev;

Is this used else where? If not, I think you can remove it.

Quoted 3 lines

No one is used it in this patch sets but it will be used for irq functions to get irq id or print logs for error case in the future. Can I keep it in the patch?

It's not uncommon for devices to do this and if you're sure it's going to be used in the future you may as well keep it in.

Quoted 10 lines
Quoted 8 lines

drivers/mfd/mt6397-core.c line 45

Quoted 2 lines
drivers/mfd/mt6397-core.c new file +2 -0
+	mt6397->regmap = wrp->regmap;
+	platform_set_drvdata(pdev, mt6397);

Then you can platform_set_drvdata(pdev, regmap);

Although I don't see this being used either. Is it used in the child devices?

Yes, it is used to provide regmap handle for its child device. In the patch set, regulator uses it.

Okay.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog