Skip to contentSkip to conversation

Add Support for MediaTek PMIC MT6397 MFD Core and Regulator

PATCH Superseded Flora Fu 6 participants 21 messages Dec 5, 2014 – Dec 24, 2014

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Flora Fu

author
#0 lore raw

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

Hi,

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 v2
================
(1) Patch 1/8: Update kernel config of MT8135 PMIC Wrapper. It needs to select REGMAP.
(2) Patch 2/8: Update patch of MT6397 MFD driver to fix defeat of coding styles.
(3) Patch 3/8: Update MT6397 regulator driver
- use standard helpers for ops ".set_voltage_sel", ".get_voltage_sel" and ".is_enabled"
- remove regulator's DT matching codes in the driver.
- fix defeat of coding styles.
(4) Patch 4/8: Update 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: Update device tree for MT8135 PMIC wrapper in mt8135.dtsi.
(8) Patch 8/8: Add device tree for MT6397 MFD and regulators in mt8135-evbp1.dts board file. Second version (v2):
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/307069.html

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 MT8135 PMIC wrapper
ARM: dts: mt8135: Add support for MT6397 MFD and regulator

 Documentation/devicetree/bindings/mfd/mt6397.txt   |  75 ++
 .../bindings/regulator/mt6397-regulator.txt        | 217 ++++++
 .../soc/mediatek/mediatek,mt8135-pwrap.txt         |  51 ++
 arch/arm/boot/dts/mt8135-evbp1.dts                 | 193 +++++
 arch/arm/boot/dts/mt8135.dtsi                      |  14 +
 drivers/mfd/Kconfig                                |  10 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/mt6397-core.c                          |  87 +++
 drivers/regulator/Kconfig                          |   9 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/mt6397-regulator.c               | 332 ++++++++
 drivers/soc/Kconfig                                |   1 +
 drivers/soc/Makefile                               |   1 +
 drivers/soc/mediatek/Kconfig                       |  12 +
 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 +
 21 files changed, 2446 insertions(+)
 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 v3 1/8 soc: mediatek: Add PMIC wrapper for MT8135 and MT6397 SoC

Add PMIC wrapper of MT8135 to access MT6397 MFD.

---
 drivers/soc/Kconfig                        |   1 +
 drivers/soc/Makefile                       |   1 +
 drivers/soc/mediatek/Kconfig               |  12 +
 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, 1022 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 +12 -0
new file mode 100644
index 0000000..746e030
@@ -0,0 +1,12 @@
+#
+# MediaTek SoC drivers
+#
+config MT8135_PMIC_WRAP
+	tristate "MediaTek MT8135 PMIC Wrapper Support"
+	depends on ARCH_MEDIATEK
+	select REGMAP
+	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
#11 lore raw

PATCH v3 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            |  87 +++++++++
 include/linux/mfd/mt6397/core.h      |  23 +++
 include/linux/mfd/mt6397/registers.h | 362 +++++++++++++++++++++++++++++++++++
 5 files changed, 483 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 +87 -0

87 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
#13 lore raw

PATCH v3 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                 |   1 +
 drivers/regulator/mt6397-regulator.c       | 332 +++++++++++++++++++++++++++++
 include/linux/regulator/mt6397-regulator.h |  49 +++++
 4 files changed, 391 insertions(+)
 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 -0
index 1029ed3..bad280e 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
drivers/regulator/mt6397-regulator.c new file +332 -0

332 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
#15 lore raw

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

In reply to Flora Fu
---
 .../soc/mediatek/mediatek,mt8135-pwrap.txt         | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8135-pwrap.txt new file +51 -0
new file mode 100644
index 0000000..d630fa0
@@ -0,0 +1,51 @@
+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
+
+Optional properities:
+- pmic: Mediatek PMIC MFD is the child device of pwrap
+  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";
+		};
+	};
Signature · 1 line
1.8.1.1.dirty
author
#16 lore raw

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

In reply to Flora Fu
---
 Documentation/devicetree/bindings/mfd/mt6397.txt | 75 ++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mt6397.txt
Documentation/devicetree/bindings/mfd/mt6397.txt new file +75 -0
new file mode 100644
index 0000000..64ef408
@@ -0,0 +1,75 @@
+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;
+			};
+
+			mt6397regulator: mt6397regulator {
+				compatible = "mediatek,mt6397-regulator";
+
+				mt6397_vpca15_reg: buck_vpca15 {
+					regulator-compatible = "buck_vpca15";
+					regulator-name = "vpca15";
+					regulator-min-microvolt = < 850000>;
+					regulator-max-microvolt = <1400000>;
+					regulator-ramp-delay = <12500>;
+					regulator-always-on;
+				};
+
+				mt6397_vgp4_reg: ldo_vgp4 {
+					regulator-compatible = "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
#17 lore raw

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

In reply to Flora Fu
---
 .../bindings/regulator/mt6397-regulator.txt        | 217 +++++++++++++++++++++
 1 file changed, 217 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt new file +217 -0
new file mode 100644
index 0000000..a42b1d6
@@ -0,0 +1,217 @@
+Mediatek MT6397 Regulator Driver
+
+Required properties:
+- compatible: "mediatek,mt6397-regulator"
+- mt6397regulator: List of regulators provided by this controller. It is named
+  according to its regulator type, buck_<name> and ldo_<name>.
+  The definition for each of these nodes is defined using the standard binding
+  for regulators at Documentation/devicetree/bindings/regulator/regulator.txt.
+
+The valid names for regulators are::
+BUCK:
+  buck_vpca15, buck_vpca7, buck_vsramca15, buck_vsramca7, buck_vcore, buck_vgpu,
+  buck_vdrm, buck_vio18
+LDO:
+  ldo_vtcxo, ldo_va28, ldo_vcama, ldo_vio28, ldo_vusb, ldo_vmc, ldo_vmch,
+  ldo_vemc3v3, ldo_vgp1, ldo_vgp2, ldo_vgp3, ldo_vgp4, ldo_vgp5, ldo_vgp6,
+  ldo_vibr
+
+Example:
+	pmic {
+		compatible = "mediatek,mt6397";
+
+		mt6397regulator: mt6397regulator {
+			compatible = "mediatek,mt6397-regulator";
+
+			mt6397_vpca15_reg: buck_vpca15 {
+				regulator-compatible = "buck_vpca15";
+				regulator-name = "vpca15";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <200>;
+			};
+
+			mt6397_vpca7_reg: buck_vpca7 {
+				regulator-compatible = "buck_vpca7";
+				regulator-name = "vpca7";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <115>;
+			};
+
+			mt6397_vsramca15_reg: buck_vsramca15 {
+				regulator-compatible = "buck_vsramca15";
+				regulator-name = "vsramca15";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <115>;
+
+			};
+
+			mt6397_vsramca7_reg: buck_vsramca7 {
+				regulator-compatible = "buck_vsramca7";
+				regulator-name = "vsramca7";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <115>;
+
+			};
+
+			mt6397_vcore_reg: buck_vcore {
+				regulator-compatible = "buck_vcore";
+				regulator-name = "vcore";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <115>;
+			};
+
+			mt6397_vgpu_reg: buck_vgpu {
+				regulator-compatible = "buck_vgpu";
+				regulator-name = "vgpu";
+				regulator-min-microvolt = < 700000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <115>;
+			};
+
+			mt6397_vdrm_reg: buck_vdrm {
+				regulator-compatible = "buck_vdrm";
+				regulator-name = "vdrm";
+				regulator-min-microvolt = < 800000>;
+				regulator-max-microvolt = <1400000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <500>;
+			};
+
+			mt6397_vio18_reg: buck_vio18 {
+				regulator-compatible = "buck_vio18";
+				regulator-name = "vio18";
+				regulator-min-microvolt = <1500000>;
+				regulator-max-microvolt = <2120000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <500>;
+			};
+
+			mt6397_vtcxo_reg: ldo_vtcxo {
+				regulator-compatible = "ldo_vtcxo";
+				regulator-name = "vtcxo";
+				regulator-min-microvolt = <2800000>;
+				regulator-max-microvolt = <2800000>;
+				regulator-enable-ramp-delay = <90>;
+			};
+
+			mt6397_va28_reg: ldo_va28 {
+				regulator-compatible = "ldo_va28";
+				regulator-name = "va28";
+				/* fixed output 2.8 V */
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vcama_reg: ldo_vcama {
+				regulator-compatible = "ldo_vcama";
+				regulator-name = "vcama";
+				regulator-min-microvolt = <1500000>;
+				regulator-max-microvolt = <2800000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vio28_reg: ldo_vio28 {
+				regulator-compatible = "ldo_vio28";
+				regulator-name = "vio28";
+				/* fixed output 2.8 V */
+				regulator-enable-ramp-delay = <240>;
+			};
+
+			mt6397_usb_reg: ldo_vusb {
+				regulator-compatible = "ldo_vusb";
+				regulator-name = "vusb";
+				/* fixed output 3.3 V */
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vmc_reg: ldo_vmc {
+				regulator-compatible = "ldo_vmc";
+				regulator-name = "vmc";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vmch_reg: ldo_vmch {
+				regulator-compatible = "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-compatible = "ldo_vemc3v3";
+				regulator-name = "vemc_3v3";
+				regulator-min-microvolt = <3000000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp1_reg: ldo_vgp1 {
+				regulator-compatible = "ldo_vgp1";
+				regulator-name = "vcamd";
+				regulator-min-microvolt = <1220000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <240>;
+			};
+
+			mt6397_vgp2_reg: ldo_vgp2 {
+				egulator-compatible = "ldo_vgp2";
+				regulator-name = "vcamio";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp3_reg: ldo_vgp3 {
+				regulator-compatible = "ldo_vgp3";
+				regulator-name = "vcamaf";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp4_reg: ldo_vgp4 {
+				regulator-compatible = "ldo_vgp4";
+				regulator-name = "vgp4";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp5_reg: ldo_vgp5 {
+				regulator-compatible = "ldo_vgp5";
+				regulator-name = "vgp5";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3000000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp6_reg: ldo_vgp6 {
+				regulator-compatible = "ldo_vgp6";
+				regulator-name = "vgp6";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vibr_reg: ldo_vibr {
+				regulator-compatible = "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
author
#19 lore raw

PATCH v3 7/8 ARM: dts: mt8135: Add support for MT8135 PMIC wrapper

In reply to Flora Fu

Add device tree for MT8135 PMIC wrapper in mt8135.dtsi.

---
 arch/arm/boot/dts/mt8135.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/boot/dts/mt8135.dtsi +14 -0
index 90a56ad..86b1326 100644
@@ -102,6 +102,20 @@
 			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";
+		};
+
 		gic: interrupt-controller at 10211000 {
 			compatible = "arm,cortex-a15-gic";
 			interrupt-controller;
Signature · 1 line
1.8.1.1.dirty
author
#20 lore raw

PATCH v3 8/8 ARM: dts: mt8135: Add support for MT6397 MFD and regulator

In reply to Flora Fu

Add device tree for MT6397 MFD and regulator in mt8135-evbp1.dts board file

---
 arch/arm/boot/dts/mt8135-evbp1.dts | 193 +++++++++++++++++++++++++++++++++++++
 1 file changed, 193 insertions(+)
arch/arm/boot/dts/mt8135-evbp1.dts +193 -0
index cba80b8..627cc47 100644
@@ -22,3 +22,196 @@
 		reg = <0 0x80000000 0 0x40000000>;
 	};
 };
+
+&pwrap {
+	pmic {
+		compatible = "mediatek,mt6397";
+
+		mt6397regulator: mt6397regulator {
+			compatible = "mediatek,mt6397-regulator";
+
+			mt6397_vpca15_reg: buck_vpca15 {
+				regulator-compatible = "buck_vpca15";
+				regulator-name = "vpca15";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vpca7_reg: buck_vpca7 {
+				regulator-compatible = "buck_vpca7";
+				regulator-name = "vpca7";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vsramca15_reg: buck_vsramca15 {
+				regulator-compatible = "buck_vsramca15";
+				regulator-name = "vsramca15";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vsramca7_reg: buck_vsramca7 {
+				regulator-compatible = "buck_vsramca7";
+				regulator-name = "vsramca7";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vcore_reg: buck_vcore {
+				regulator-compatible = "buck_vcore";
+				regulator-name = "vcore";
+				regulator-min-microvolt = < 850000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vgpu_reg: buck_vgpu {
+				regulator-compatible = "buck_vgpu";
+				regulator-name = "vgpu";
+				regulator-min-microvolt = < 700000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <12500>;
+				regulator-enable-ramp-delay = <115>;
+			};
+
+			mt6397_vdrm_reg: buck_vdrm {
+				regulator-compatible = "buck_vdrm";
+				regulator-name = "vdrm";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <1400000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vio18_reg: buck_vio18 {
+				regulator-compatible = "buck_vio18";
+				regulator-name = "vio18";
+				regulator-min-microvolt = <1620000>;
+				regulator-max-microvolt = <1980000>;
+				regulator-ramp-delay = <12500>;
+				regulator-always-on;
+			};
+
+			mt6397_vtcxo_reg: ldo_vtcxo {
+				regulator-compatible = "ldo_vtcxo";
+				regulator-name = "vtcxo";
+				regulator-always-on;
+			};
+
+			mt6397_va28_reg: ldo_va28 {
+				regulator-compatible = "ldo_va28";
+				regulator-name = "va28";
+				regulator-always-on;
+			};
+
+			mt6397_vcama_reg: ldo_vcama {
+				regulator-compatible = "ldo_vcama";
+				regulator-name = "vcama";
+				regulator-min-microvolt = <1500000>;
+				regulator-max-microvolt = <2800000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vio28_reg: ldo_vio28 {
+				regulator-compatible = "ldo_vio28";
+				regulator-name = "vio28";
+				regulator-always-on;
+			};
+
+			mt6397_vusb_reg: ldo_vusb {
+				regulator-compatible = "ldo_vusb";
+				regulator-name = "vusb";
+			};
+
+			mt6397_vmc_reg: ldo_vmc {
+				regulator-compatible = "ldo_vmc";
+				regulator-name = "vmc";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vmch_reg: ldo_vmch {
+				regulator-compatible = "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-compatible = "ldo_vemc3v3";
+				regulator-name = "vemc_3v3";
+				regulator-min-microvolt = <3000000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp1_reg: ldo_vgp1 {
+				regulator-compatible = "ldo_vgp1";
+				regulator-name = "vcamd";
+				regulator-min-microvolt = <1220000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <240>;
+			};
+
+			mt6397_vgp2_reg: ldo_vgp2 {
+				regulator-compatible = "ldo_vgp2";
+				regulator-name = "vcamio";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp3_reg: ldo_vgp3 {
+				regulator-compatible = "ldo_vgp3";
+				regulator-name = "vcamaf";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp4_reg: ldo_vgp4 {
+				regulator-compatible = "ldo_vgp4";
+				regulator-name = "vgp4";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp5_reg: ldo_vgp5 {
+				regulator-compatible = "ldo_vgp5";
+				regulator-name = "vgp5";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3000000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vgp6_reg: ldo_vgp6 {
+				regulator-compatible = "ldo_vgp6";
+				regulator-name = "vgp6";
+				regulator-min-microvolt = <1200000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+
+			mt6397_vibr_reg: ldo_vibr {
+				regulator-compatible = "ldo_vibr";
+				regulator-name = "vibr";
+				regulator-min-microvolt = <1300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-enable-ramp-delay = <218>;
+			};
+		};
+	};
+};
Signature · 1 line
1.8.1.1.dirty
#2 lore raw

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

In reply to Flora Fu
Quoted 4 lines · On Friday 05 December 2014 12:07:52 Flora Fu wrote:

Add PMIC wrapper of MT8135 to access MT6397 MFD.

Please explain what a PMIC wrapper is and why you need one for MT8135. I don't understand the purpose of this code at all. Is this just another way of accessing the MT6397 when not using i2c or spi like other PMIC drivers do?

Arnd

#12 lore raw

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

In reply to Flora Fu
Quoted 13 lines · Flora Fu

Add core files for MT6397 MFD driver.

---
 drivers/mfd/Kconfig                  |  10 +
 drivers/mfd/Makefile                 |   1 +
 drivers/mfd/mt6397-core.c            |  87 +++++++++
 include/linux/mfd/mt6397/core.h      |  23 +++
 include/linux/mfd/mt6397/registers.h | 362 +++++++++++++++++++++++++++++++++++
 5 files changed, 483 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

[...]

Quoted 35 lines

+++ b/drivers/mfd/mt6397-core.c

drivers/mfd/mt6397-core.c new file +33 -0
@@ -0,0 +1,87 @@
+/*
+ * 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",
+		.of_compatible = "mediatek,mt6397-regulator",
+	},
+	{
+		.name = "mt6397-codec",
+		.of_compatible = "mediatek,mt6397-codec",
+	},
+};
+
+static int mt6397_probe(struct platform_device *pdev)

drivers/mfd/mt6397-core.c line 43

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

You're _still_ not checking the return value prior to dereferencing.

drivers/mfd/mt6397-core.c line 52

Quoted 10 lines
drivers/mfd/mt6397-core.c new file +9 -0
+	mt6397 = devm_kzalloc(&pdev->dev, sizeof(*mt6397), GFP_KERNEL);
+	if (!mt6397)
+		return -ENOMEM;
+
+	mt6397->dev = &pdev->dev;
+	mt6397->regmap = wrp->regmap;
 
+	platform_set_drvdata(pdev, mt6397);
+
+	ret = mfd_add_devices(&pdev->dev, -1, &mt6397_devs[0],

Just mt6397_devs here.

drivers/mfd/mt6397-core.c line 55

Quoted 3 lines
drivers/mfd/mt6397-core.c new file +3 -0
+			ARRAY_SIZE(mt6397_devs), NULL, 0, NULL);
+	if (ret)
+		dev_err(&pdev->dev, "failed to add child devices: %d\n", ret);

There is no point in printing ret. The kernel will do that for you.

[...]

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

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

In reply to Arnd Bergmann

Hi, Arnd,

Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · On Friday 05 December 2014 12:07:52 Flora Fu wrote:

Add PMIC wrapper of MT8135 to access MT6397 MFD.

Please explain what a PMIC wrapper is and why you need one for MT8135. I don't understand the purpose of this code at all. Is this just another way of accessing the MT6397 when not using i2c or spi like other PMIC drivers do?

Yes, MT8135 uses a proprietary hardware to communicate with MT6397. The hardware is called PMIC Wrapper or PWRAP.
Since it is not standard i2c or spi protocols, a soc related software driver is implemented to handle access protocols in AP side.

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

Thanks,
Flora

#4 lore raw

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

Quoted 20 lines · On Tuesday 09 December 2014 10:15:37 Flora Fu wrote:

Hi, Arnd,

Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · On Friday 05 December 2014 12:07:52 Flora Fu wrote:

Add PMIC wrapper of MT8135 to access MT6397 MFD.

Please explain what a PMIC wrapper is and why you need one for MT8135. I don't understand the purpose of this code at all. Is this just another way of accessing the MT6397 when not using i2c or spi like other PMIC drivers do?

Yes, MT8135 uses a proprietary hardware to communicate with MT6397. The hardware is called PMIC Wrapper or PWRAP.
Since it is not standard i2c or spi protocols, a soc related software driver is implemented to handle access protocols in AP side.

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

I think we have had a similar case recently where a controller wasn't actually using I2C, but the sofware protocol was close enough so we decided to make it appear as i2c in Linux.

Would that work for you, i.e. register the pmic wrapper as a fake spi master driver in drivers/spi/ and register the rtc/regulator/codec as SPI clients from DT?

Arnd

#5 lore raw

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

Quoted 36 lines · Arnd Bergmann
Quoted 20 lines · On Tuesday 09 December 2014 10:15:37 Flora Fu wrote:

Hi, Arnd,

Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · On Friday 05 December 2014 12:07:52 Flora Fu wrote:

Add PMIC wrapper of MT8135 to access MT6397 MFD.

Please explain what a PMIC wrapper is and why you need one for MT8135. I don't understand the purpose of this code at all. Is this just another way of accessing the MT6397 when not using i2c or spi like other PMIC drivers do?

Yes, MT8135 uses a proprietary hardware to communicate with MT6397. The hardware is called PMIC Wrapper or PWRAP.
Since it is not standard i2c or spi protocols, a soc related software driver is implemented to handle access protocols in AP side.

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

I think we have had a similar case recently where a controller wasn't actually using I2C, but the sofware protocol was close enough so we decided to make it appear as i2c in Linux.

Would that work for you, i.e. register the pmic wrapper as a fake spi master driver in drivers/spi/ and register the rtc/regulator/codec as SPI clients from DT?

I don't think that's appropriate. I mean technically that could even work, but in software you really don't see anything from the underlying SPI bus. The SoC and the PMIC are really tightly coupled via the PMIC wrapper. This goes to the point where pins of the SoCs internal I2C and keypad controllers are routed over the SPI bus out of the PMIC. In software you do this by setting a bit in the I2C controller. If it's set, the signals are routed out of the PMIC instead of the main die. As said, technically we probably could create a fake SPI master, but that wouldn't really fit to this situation.

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 |
maintainer
#6 lore raw

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

2014-12-09 11:13 GMT+01:00 Sascha Hauer <[email protected]>:

Quoted 45 lines · Arnd Bergmann
Quoted 36 lines · On Tuesday 09 December 2014 10:15:37 Flora Fu wrote:
Quoted 20 lines

Hi, Arnd,

Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · On Friday 05 December 2014 12:07:52 Flora Fu wrote:

Add PMIC wrapper of MT8135 to access MT6397 MFD.

Please explain what a PMIC wrapper is and why you need one for MT8135. I don't understand the purpose of this code at all. Is this just another way of accessing the MT6397 when not using i2c or spi like other PMIC drivers do?

Yes, MT8135 uses a proprietary hardware to communicate with MT6397. The hardware is called PMIC Wrapper or PWRAP.
Since it is not standard i2c or spi protocols, a soc related software driver is implemented to handle access protocols in AP side.

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

I think we have had a similar case recently where a controller wasn't actually using I2C, but the sofware protocol was close enough so we decided to make it appear as i2c in Linux.

Would that work for you, i.e. register the pmic wrapper as a fake spi master driver in drivers/spi/ and register the rtc/regulator/codec as SPI clients from DT?

Quoted 9 lines

I don't think that's appropriate. I mean technically that could even work, but in software you really don't see anything from the underlying SPI bus. The SoC and the PMIC are really tightly coupled via the PMIC wrapper. This goes to the point where pins of the SoCs internal I2C and keypad controllers are routed over the SPI bus out of the PMIC. In software you do this by setting a bit in the I2C controller. If it's set, the signals are routed out of the PMIC instead of the main die. As said, technically we probably could create a fake SPI master, but that wouldn't really fit to this situation.

I agree with Sascha. Although from the hardware point of view, the communication between the PMIC and the SOC is done through SPI from the point of view of the software everything looks like I2C commands which will be "transalted" into SPI messages by the PMIC wrapper.

Cheers,
Matthias

Quoted 8 lines

Sascha

--

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 |
Signature · 1 line
motzblog.wordpress.com
#7 lore raw

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

Quoted 20 lines · On Tuesday 09 December 2014 11:30:15 Matthias Brugger wrote:

2014-12-09 11:13 GMT+01:00 Sascha Hauer <[email protected]>:

Quoted 19 lines · Arnd Bergmann
Quoted 8 lines

I think we have had a similar case recently where a controller wasn't actually using I2C, but the sofware protocol was close enough so we decided to make it appear as i2c in Linux.

Would that work for you, i.e. register the pmic wrapper as a fake spi master driver in drivers/spi/ and register the rtc/regulator/codec as SPI clients from DT?

I don't think that's appropriate. I mean technically that could even work, but in software you really don't see anything from the underlying SPI bus. The SoC and the PMIC are really tightly coupled via the PMIC wrapper. This goes to the point where pins of the SoCs internal I2C and keypad controllers are routed over the SPI bus out of the PMIC. In software you do this by setting a bit in the I2C controller. If it's set, the signals are routed out of the PMIC instead of the main die. As said, technically we probably could create a fake SPI master, but that wouldn't really fit to this situation.

Ok, I see.

Quoted 4 lines

I agree with Sascha. Although from the hardware point of view, the communication between the PMIC and the SOC is done through SPI from the point of view of the software everything looks like I2C commands which will be "transalted" into SPI messages by the PMIC wrapper.

If it looks like i2c messages, would it be more appropriate to make it appear as an i2c controller then?

Arnd

author
#8 lore raw

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

Hi,

Quoted 24 lines · Arnd Bergmann
Quoted 20 lines · On Tuesday 09 December 2014 11:30:15 Matthias Brugger wrote:

2014-12-09 11:13 GMT+01:00 Sascha Hauer <[email protected]>:

Quoted 19 lines · Arnd Bergmann
Quoted 8 lines

I think we have had a similar case recently where a controller wasn't actually using I2C, but the sofware protocol was close enough so we decided to make it appear as i2c in Linux.

Would that work for you, i.e. register the pmic wrapper as a fake spi master driver in drivers/spi/ and register the rtc/regulator/codec as SPI clients from DT?

I don't think that's appropriate. I mean technically that could even work, but in software you really don't see anything from the underlying SPI bus. The SoC and the PMIC are really tightly coupled via the PMIC wrapper. This goes to the point where pins of the SoCs internal I2C and keypad controllers are routed over the SPI bus out of the PMIC. In software you do this by setting a bit in the I2C controller. If it's set, the signals are routed out of the PMIC instead of the main die. As said, technically we probably could create a fake SPI master, but that wouldn't really fit to this situation.

Ok, I see.

Quoted 7 lines
Quoted 4 lines

I agree with Sascha. Although from the hardware point of view, the communication between the PMIC and the SOC is done through SPI from the point of view of the software everything looks like I2C commands which will be "transalted" into SPI messages by the PMIC wrapper.

If it looks like i2c messages, would it be more appropriate to make it appear as an i2c controller then?

Although the message looks like I2C command, it is not I2C. Form source code, the software does not touch any I2C i/o or protocols. It depends SoC and has specific initial flow, read and write transfer state. It is not able to an i2c controller.
That's why we consider its a proprietary hardware with specific protocols. How about let it appear in driver/soc?

Thanks,
Flora

#9 lore raw

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

Quoted 34 lines · On Thursday 11 December 2014 18:04:15 Flora Fu wrote:
Quoted 24 lines · Arnd Bergmann
Quoted 20 lines · On Tuesday 09 December 2014 11:30:15 Matthias Brugger wrote:

2014-12-09 11:13 GMT+01:00 Sascha Hauer <[email protected]>:

Quoted 19 lines · Arnd Bergmann
Quoted 8 lines

I think we have had a similar case recently where a controller wasn't actually using I2C, but the sofware protocol was close enough so we decided to make it appear as i2c in Linux.

Would that work for you, i.e. register the pmic wrapper as a fake spi master driver in drivers/spi/ and register the rtc/regulator/codec as SPI clients from DT?

I don't think that's appropriate. I mean technically that could even work, but in software you really don't see anything from the underlying SPI bus. The SoC and the PMIC are really tightly coupled via the PMIC wrapper. This goes to the point where pins of the SoCs internal I2C and keypad controllers are routed over the SPI bus out of the PMIC. In software you do this by setting a bit in the I2C controller. If it's set, the signals are routed out of the PMIC instead of the main die. As said, technically we probably could create a fake SPI master, but that wouldn't really fit to this situation.

Ok, I see.

Quoted 7 lines
Quoted 4 lines

I agree with Sascha. Although from the hardware point of view, the communication between the PMIC and the SOC is done through SPI from the point of view of the software everything looks like I2C commands which will be "transalted" into SPI messages by the PMIC wrapper.

If it looks like i2c messages, would it be more appropriate to make it appear as an i2c controller then?

Quoted 6 lines

Although the message looks like I2C command, it is not I2C. Form source code, the software does not touch any I2C i/o or protocols. It depends SoC and has specific initial flow, read and write transfer state. It is not able to an i2c controller.
That's why we consider its a proprietary hardware with specific protocols. How about let it appear in driver/soc?

Ok, I've looked a lot more at other drivers now, and I see that one of my main objections which was about the way that the drivers look into dev->parent->drvdata is in fact common practice for pmic drivers, and using i2c wouldn't change anything here. Based on this, using drivers/soc is probably best as you say.

I still think the relation between the mt8135 pmic wrapper and the mt6397 mfd driver could be improved. I don't like the way that include/linux/soc/mediatek/mtk-pmic-wrap.h exposes an internal data structure of the pmic-wrap driver to the mfd driver, which really only needs the regmap pointer from it, and I think it would be better to pass that pointer using platform_data here in one way or another. The easiest way to do that is probably using an auxdata table in of_platform_populate, while another method might be to restructure the relationship between the wrapper driver and the mfd driver in some form to take out the extra device node and make the mfd cells children of the wrapper itself.

Arnd

maintainer
#10 lore raw

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

In reply to Flora Fu
Quoted 9 lines · Flora Fu
Quoted 2 lines · Arnd Bergmann

If it looks like i2c messages, would it be more appropriate to make it appear as an i2c controller then?

Although the message looks like I2C command, it is not I2C. Form source code, the software does not touch any I2C i/o or protocols. It depends SoC and has specific initial flow, read and write transfer state. It is not able to an i2c controller.

What Arnd is suggesting is that if the flow for using it is similar enough to I2C you can push it through the I2C framework anyway even though it'll never be possible to use it with generic devices.

Quoted 2 lines

That's why we consider its a proprietary hardware with specific protocols. How about let it appear in driver/soc?

That's another option, though I'm not sure that's what the arm-soc
people are looking for.
-------------- 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/20141215/864455a9/attachment-0001.sig>