Skip to contentSkip to conversation

Support for QPNP PMIC's

RFC PATCH Superseded Stanimir Varbanov 3 participants 14 messages Jun 20, 2014 – Jun 26, 2014

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Support for QPNP PMIC's

Hello to all,

The goal of this WIP set is to provide support for sub-functional hw blocks inside Qualcomm QPNP PMIC chips by creating a new qpnp bus (device-driver modeled). On SPMI interface we attach a so called Slaves. For example one PMIC chip like pm8941 has two slave id's. On every slaveid the PMIC chip has various peripherials. Every peripheral driver should expose qpnp_driver structure and implement the .probe and .remove callbacks. Every peripheral driver will reside on the proper place in /drivers directory.

The fisrt patch describes the devicetree binding of the slave devices attached to the SPMI interface. The second patch adds implemetation of the qpnp-bus and a layer connection with the SPMI interface. The third patch adds spmi arbiter and underlying slaveid devicetree nodes for msm8974 SoC. The other patches are example of rtc-qpnp driver and binding documentation.

Since this set is a WIP, it will be used as a starting point for future duscussions about implementing QPNP PMIC sub-function hw blocks.

Regards,
Stan

Ivan T. Ivanov (2):
dt: qpnp: add binding description of Qualcomm QPNP PMICs
dt: qcom: msm8974: add qpnp-spmi device nodes

Stanimir Varbanov (4):
qpnp: add support for Qualcomm QPNP PMICs
rtc: add qpnp rtc driver
dt: msm8974: add qpnp rtc device node
dt: rtc: add binding document for rtc-qpnp

 .../devicetree/bindings/qpnp/qcom,qpnp-spmi.txt    |   42 ++
 .../devicetree/bindings/rtc/qcom,rtc-qpnp.txt      |   21 +
 arch/arm/boot/dts/qcom-msm8974.dtsi                |   52 ++
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    1 +
 drivers/qpnp/Kconfig                               |   12 +
 drivers/qpnp/Makefile                              |    1 +
 drivers/qpnp/qpnp-bus.c                            |  475 +++++++++++++++++++
 drivers/qpnp/qpnp-spmi.c                           |   63 +++
 drivers/rtc/Kconfig                                |    8 +
 drivers/rtc/Makefile                               |    1 +
 drivers/rtc/rtc-qpnp.c                             |  489 ++++++++++++++++++++
 include/linux/qpnp.h                               |   83 ++++
 13 files changed, 1250 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/qpnp/qcom,qpnp-spmi.txt
 create mode 100644 Documentation/devicetree/bindings/rtc/qcom,rtc-qpnp.txt
 create mode 100644 drivers/qpnp/Kconfig
 create mode 100644 drivers/qpnp/Makefile
 create mode 100644 drivers/qpnp/qpnp-bus.c
 create mode 100644 drivers/qpnp/qpnp-spmi.c
 create mode 100644 drivers/rtc/rtc-qpnp.c
 create mode 100644 include/linux/qpnp.h
#1 lore raw

RFC PATCH 1/6 dt: qpnp: add binding description of Qualcomm QPNP PMICs

From: Ivan T. Ivanov <[email protected]>

Document the bindings used to describe the Qualcomm QPNP PMICs.

---
 .../devicetree/bindings/qpnp/qcom,qpnp-spmi.txt    |   42 ++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/qpnp/qcom,qpnp-spmi.txt
Documentation/devicetree/bindings/qpnp/qcom,qpnp-spmi.txt new file +42 -0
new file mode 100644
index 0000000..f657587
@@ -0,0 +1,42 @@
+Qualcomm QPNP partitioned PMIC multi-function device bindings
+
+QPNP is effectively a partitioning scheme for dividing the SPMI extended
+register space up into logical pieces, and set of fixed register
+locations/definitions within these regions, with some of these regions
+specifically used for interrupt handling.
+
+The QPNP PMICs are used with the Qualcomm Snapdragon series SoCs, and are
+interfaced to the chip via the SPMI (System Power Management Interface) bus.
+Support for multiple independent functions are implemented by splitting the
+16-bit SPMI slave address space into 256 smaller fixed-size regions, 256 bytes
+each. A function can consume one or more of these fixed-size register regions.
+
+Required properties:
+- compatible:     Should contain "qcom,qpnp-spmi"
+- reg:            Specifies the SPMI USID slave address for this device.
+                  For more info see bindings/spmi/spmi.txt
+- #address-cells: Defines address cells for peripheral nodes - should be 1
+- #size-cells:    Defines size cells for peripheral nodes - should be 0
+
+Required properties for peripheral devices:
+- compatible:     Should constain "qcom,qpnp-xxx"
+- reg:            One or more 8bits peripheral ID
+
+Each child node represents a function of the QPNP.  Each child 'reg' entry
+describes a QPNP peripheral ID (number) within the USID slave address where
+the region starts.
+
+Example:
+
+	pm8941@0 {
+		compatible = "qcom,qpnp-spmi";
+		reg = <0x0 SPMI_USID>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		rtc@60 {
+			compatible = "qcom,qpnp-rtc";
+			reg = <0x60>, <0x61>;
+		};
+	};
\ No newline at end of file
Signature · 1 line
1.7.0.4
#2 lore raw

RFC PATCH 2/6 qpnp: add support for Qualcomm QPNP PMICs

In reply to Stanimir Varbanov

The Qualcomm plug-and-play (QPNP) PMIC chips are components used with the Snapdragon series SoC family. QPNP chips make use of Qualcomm's SPMI register convention.

This driver exists largely as a glue component, it exists to be an owner of an SPMI regmap for children devices described in device tree.

---
 drivers/Kconfig          |    2 +
 drivers/Makefile         |    1 +
 drivers/qpnp/Kconfig     |   12 ++
 drivers/qpnp/Makefile    |    1 +
 drivers/qpnp/qpnp-bus.c  |  475 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/qpnp/qpnp-spmi.c |   63 ++++++
 include/linux/qpnp.h     |   83 ++++++++
 7 files changed, 637 insertions(+), 0 deletions(-)
 create mode 100644 drivers/qpnp/Kconfig
 create mode 100644 drivers/qpnp/Makefile
 create mode 100644 drivers/qpnp/qpnp-bus.c
 create mode 100644 drivers/qpnp/qpnp-spmi.c
 create mode 100644 include/linux/qpnp.h
drivers/Kconfig +2 -0
index 0e87a34..412e6ae 100644
@@ -176,4 +176,6 @@ source "drivers/powercap/Kconfig"
 
 source "drivers/mcb/Kconfig"
 
+source "drivers/qpnp/Kconfig"
+
 endmenu
drivers/Makefile +1 -0
index f98b50d..bf2f3f3 100644
@@ -158,3 +158,4 @@ obj-$(CONFIG_NTB)		+= ntb/
 obj-$(CONFIG_FMC)		+= fmc/
 obj-$(CONFIG_POWERCAP)		+= powercap/
 obj-$(CONFIG_MCB)		+= mcb/
+obj-y				+= qpnp/
drivers/qpnp/Kconfig new file +12 -0
new file mode 100644
index 0000000..c86ab52
@@ -0,0 +1,12 @@
+config QPNP_SPMI
+	tristate "Qualcomm PMIC QPNP driver"
+	depends on ARCH_QCOM
+	select REGMAP_SPMI
+	help
+	  This enables basic support for the Qualcomm QPNP PMICs.
+	  These PMICs are currently used with the Snapdragon 800 series of
+	  SoCs.  Note, that this will only be useful paired with descriptions
+	  of the independent functions as children nodes in the device tree.
+
+	  Say M here if you want to include support for the PM8x41 series as a
+	  module.  The module will be called "qpnp-spmi".
drivers/qpnp/Makefile new file +1 -0
new file mode 100644
index 0000000..753bef8
@@ -0,0 +1 @@
+obj-$(CONFIG_QPNP_SPMI)	+= qpnp-bus.o qpnp-spmi.o
drivers/qpnp/qpnp-bus.c new file +475 -0

475 lines not on this page · raw message

drivers/qpnp/qpnp-spmi.c new file +63 -0

63 lines not on this page · raw message

include/linux/qpnp.h new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#3 lore raw

RFC PATCH 3/6 dt: qcom: msm8974: add qpnp-spmi device nodes

In reply to Stanimir Varbanov

From: Ivan T. Ivanov <[email protected]>

The qpnp-spmi device node are childrens of spmi pmic arbiter. msm8974 SoC using two pmic chips pm8941 and pm8841. Every chip has two spmi-qpnp bus id's.

---
 arch/arm/boot/dts/qcom-msm8974.dtsi |   45 +++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
arch/arm/boot/dts/qcom-msm8974.dtsi +45 -0
index 69dca2a..8149397 100644
@@ -3,6 +3,7 @@
 #include "skeleton.dtsi"
 
 #include <dt-bindings/clock/qcom,gcc-msm8974.h>
+#include <dt-bindings/spmi/spmi.h>
 
 / {
 	model = "Qualcomm MSM8974";
@@ -236,5 +237,49 @@
 			#interrupt-cells = <2>;
 			interrupts = <0 208 0>;
 		};
+
+		spmi@fc4cf000 {
+			compatible = "qcom,spmi-pmic-arb";
+			reg-names = "core", "intr", "cnfg";
+			reg = <0xfc4cf000 0x1000>,
+			      <0xfc4cb000 0x1000>,
+			      <0xfc4ca000 0x1000>;
+			interrupt-names = "periph_irq";
+			interrupts = <0 190 0>;
+			qcom,ee = <0>;
+			qcom,channel = <0>;
+			#address-cells = <2>;
+			#size-cells = <0>;
+			interrupt-controller;
+			#interrupt-cells = <4>;
+
+			usid_bus0: pm8941@0 {
+				compatible = "qcom,qpnp-spmi";
+				reg = <0x0 SPMI_USID>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			usid_bus1: pm8941@1 {
+				compatible = "qcom,qpnp-spmi";
+				reg = <0x1 SPMI_USID>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			usid_bus4: pm8841@4 {
+				compatible = "qcom,qpnp-spmi";
+				reg = <0x4 SPMI_USID>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+
+			usid_bus5: pm8841@5 {
+				compatible = "qcom,qpnp-spmi";
+				reg = <0x5 SPMI_USID>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
+		};
 	};
 };
Signature · 1 line
1.7.0.4
#4 lore raw

RFC PATCH 4/6 rtc: add qpnp rtc driver

In reply to Stanimir Varbanov

A 32bits RTC is housed inside PMIC. The RTC driver uses QPNP SPMI interface to communicate with the PMIC RTC module.

The RTC device is divided into two sub-peripherals:
- RTC read-write peripheral having basic RTC registers
- alarm peripheral for controlling alarm

These two RTC peripherals are childrens of QPNP SPMI bus. They use regmap to read/write to its registers into PMIC.

---
 drivers/rtc/Kconfig    |    8 +
 drivers/rtc/Makefile   |    1 +
 drivers/rtc/rtc-qpnp.c |  489 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 498 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-qpnp.c
drivers/rtc/Kconfig +8 -0
index 0754f5c..b0a5f20 100644
@@ -1365,6 +1365,14 @@ config RTC_DRV_XGENE
 	  This driver can also be built as a module, if so, the module
 	  will be called "rtc-xgene".
 
+config RTC_DRV_QPNP
+	tristate "Qualcomm QPNP PMIC RTC"
+	depends on QPNP_SPMI
+	help
+	  Say Y here if you want to support the Qualcomm QPNP PMIC RTC.
+	  To compile this driver as a module, choose M here: the
+	  module will be called rtc-qpnp.
+
 comment "HID Sensor RTC drivers"
 
 config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
index 70347d0..52488b5 100644
@@ -141,3 +141,4 @@ obj-$(CONFIG_RTC_DRV_X1205)	+= rtc-x1205.o
 obj-$(CONFIG_RTC_DRV_XGENE)	+= rtc-xgene.o
 obj-$(CONFIG_RTC_DRV_SIRFSOC)	+= rtc-sirfsoc.o
 obj-$(CONFIG_RTC_DRV_MOXART)	+= rtc-moxart.o
+obj-$(CONFIG_RTC_DRV_QPNP)	+= rtc-qpnp.o
drivers/rtc/rtc-qpnp.c new file +489 -0

489 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#5 lore raw

RFC PATCH 5/6 dt: msm8974: add qpnp rtc device node

In reply to Stanimir Varbanov

Add QPNP RTC device tree node. The RTC device resides into pm8941 and is attached on busid0.

---
 arch/arm/boot/dts/qcom-msm8974.dtsi |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/boot/dts/qcom-msm8974.dtsi +7 -0
index 8149397..a7cd1f4 100644
@@ -3,6 +3,7 @@
 #include "skeleton.dtsi"
 
 #include <dt-bindings/clock/qcom,gcc-msm8974.h>
+#include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/spmi/spmi.h>
 
 / {
@@ -258,6 +259,12 @@
 				reg = <0x0 SPMI_USID>;
 				#address-cells = <1>;
 				#size-cells = <0>;
+
+				pm8941_rtc {
+					compatible = "qcom,rtc-qpnp";
+					reg = <0x60>, <0x61>;
+					interrupts = <0x0 0x61 0x1 IRQ_TYPE_EDGE_RISING>;
+				};
 			};
 
 			usid_bus1: pm8941@1 {
Signature · 1 line
1.7.0.4
#6 lore raw

RFC PATCH 6/6 dt: rtc: add binding document for rtc-qpnp

In reply to Stanimir Varbanov

Add devicetree binding document which describes the rtc-qpnp.

---
 .../devicetree/bindings/rtc/qcom,rtc-qpnp.txt      |   21 ++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/qcom,rtc-qpnp.txt
Documentation/devicetree/bindings/rtc/qcom,rtc-qpnp.txt new file +21 -0
new file mode 100644
index 0000000..609603f
@@ -0,0 +1,21 @@
+Qualcomm RTC QPNP
+
+The RTC device supports 32bit RTC module housed inside QPNP PMIC's.
+The driver utilizes SPMI interface to communicate with the RTC module.
+RTC device is divided into two sub-peripherals one which controls
+basic RTC and other for controlling alarm.
+
+Required properties :
+ - compatible:  Should be "qcom,rtc-qpnp".
+ - reg:         Specify the peripheral id for device. Currently there
+                are two sub-peripherals - rtc base and alarm base.
+ - interrupts:  Specifies alarm interrupt, only for alarm sub-peripheral.
+                For more info about interrupt cells see
+                Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.txt
+
+Example:
+	rtc@60 {
+		compatible = "qcom,rtc-qpnp";
+		reg = <0x60>, <0x61>;
+		interrupts = <0x0 0x61 0x1 IRQ_TYPE_EDGE_RISING>;
+	};
\ No newline at end of file
Signature · 1 line
1.7.0.4
#7 lore raw
In reply to Stanimir Varbanov
Quoted 18 lines · Stanimir Varbanov

Hello to all,

The goal of this WIP set is to provide support for sub-functional hw blocks inside Qualcomm QPNP PMIC chips by creating a new qpnp bus (device-driver modeled). On SPMI interface we attach a so called Slaves. For example one PMIC chip like pm8941 has two slave id's. On every slaveid the PMIC chip has various peripherials. Every peripheral driver should expose qpnp_driver structure and implement the .probe and .remove callbacks. Every peripheral driver will reside on the proper place in /drivers directory.

The fisrt patch describes the devicetree binding of the slave devices attached to the SPMI interface. The second patch adds implemetation of the qpnp-bus and a layer connection with the SPMI interface. The third patch adds spmi arbiter and underlying slaveid devicetree nodes for msm8974 SoC. The other patches are example of rtc-qpnp driver and binding documentation.

Quoted 2 lines

Since this set is a WIP, it will be used as a starting point for future duscussions about implementing QPNP PMIC sub-function hw blocks.

Ok. I have a few critical problems with this approach to implementing support for the PMICs:
- It's *way* more code than needed if done with of_platform_populate()
- AFAICT, the only direct relation between this and 'QPNP' is the 256 byte block size, which I would argue can be clearly expressed in DT instead with #size-cells == 1, and #address-cells == 1
- The resource code from drivers/{base,of}/platform.c is reimplemented here, without any added benefit

What am I missing?

-Courtney

#8 lore raw

Hi Courtney,

Thanks for the comments.

Quoted 19 lines · Courtney Cavin
Quoted 18 lines · Stanimir Varbanov

Hello to all,

The goal of this WIP set is to provide support for sub-functional hw blocks inside Qualcomm QPNP PMIC chips by creating a new qpnp bus (device-driver modeled). On SPMI interface we attach a so called Slaves. For example one PMIC chip like pm8941 has two slave id's. On every slaveid the PMIC chip has various peripherials. Every peripheral driver should expose qpnp_driver structure and implement the .probe and .remove callbacks. Every peripheral driver will reside on the proper place in /drivers directory.

The fisrt patch describes the devicetree binding of the slave devices attached to the SPMI interface. The second patch adds implemetation of the qpnp-bus and a layer connection with the SPMI interface. The third patch adds spmi arbiter and underlying slaveid devicetree nodes for msm8974 SoC. The other patches are example of rtc-qpnp driver and binding documentation.

Quoted 6 lines
Quoted 2 lines

Since this set is a WIP, it will be used as a starting point for future duscussions about implementing QPNP PMIC sub-function hw blocks.

Ok. I have a few critical problems with this approach to implementing support for the PMICs:
- It's *way* more code than needed if done with of_platform_populate()

Agreed, but this will be the price we must pay to keep architectural correctness. The PMIC peripherals are not directly accessible by the CPU bus and thus they shouldn't be treated as platform devices. That fact gives as an opportunity to create a qpnp bus on which we will attach the whole bunch of PMIC peripherals and using DT we can describe register regions (256B each) belonging to it.

Quoted 3 lines

- AFAICT, the only direct relation between this and 'QPNP' is the 256 byte block size, which I would argue can be clearly expressed in DT instead with #size-cells == 1, and #address-cells == 1

The QPNP schema is a private case of Qualcomm PMIC's, so generalising will over-engineering IMO.

Quoted 2 lines

- The resource code from drivers/{base,of}/platform.c is reimplemented here, without any added benefit

The resource code could be simplified to satisfy our needs.

Signature · 2 lines
regards,
Stan
#9 lore raw
Quoted 31 lines · Stanimir Varbanov

Hi Courtney,

Thanks for the comments.

Quoted 19 lines · Courtney Cavin
Quoted 18 lines · Stanimir Varbanov

Hello to all,

The goal of this WIP set is to provide support for sub-functional hw blocks inside Qualcomm QPNP PMIC chips by creating a new qpnp bus (device-driver modeled). On SPMI interface we attach a so called Slaves. For example one PMIC chip like pm8941 has two slave id's. On every slaveid the PMIC chip has various peripherials. Every peripheral driver should expose qpnp_driver structure and implement the .probe and .remove callbacks. Every peripheral driver will reside on the proper place in /drivers directory.

The fisrt patch describes the devicetree binding of the slave devices attached to the SPMI interface. The second patch adds implemetation of the qpnp-bus and a layer connection with the SPMI interface. The third patch adds spmi arbiter and underlying slaveid devicetree nodes for msm8974 SoC. The other patches are example of rtc-qpnp driver and binding documentation.

Quoted 6 lines
Quoted 2 lines

Since this set is a WIP, it will be used as a starting point for future duscussions about implementing QPNP PMIC sub-function hw blocks.

Ok. I have a few critical problems with this approach to implementing support for the PMICs:
- It's *way* more code than needed if done with of_platform_populate()

Quoted 7 lines

Agreed, but this will be the price we must pay to keep architectural correctness. The PMIC peripherals are not directly accessible by the CPU bus and thus they shouldn't be treated as platform devices. That fact gives as an opportunity to create a qpnp bus on which we will attach the whole bunch of PMIC peripherals and using DT we can describe register regions (256B each) belonging to it.

So the price we must pay for *your* vision of architectural correctness is to duplicate code without any actual benefit?

According to Documentation/driver-model/platform.txt your view is correct:

Platform devices are devices that typically appear as autonomous entities in the system. This includes legacy port-based devices and host bridges to peripheral buses, and most controllers integrated into system-on-chip platforms. What they usually have in common is direct addressing from a CPU bus. Rarely, a platform_device will be connected through a segment of some other kind of bus; but its registers will still be directly addressable.

However, it is clear that with recent changes to the platform code, this view is getting distorted somewhere. I haven't specifically heard any decisions on what to do here though.

Greg, Grant, Rob? What's the law?

Quoted 7 lines
Quoted 3 lines

- AFAICT, the only direct relation between this and 'QPNP' is the 256 byte block size, which I would argue can be clearly expressed in DT instead with #size-cells == 1, and #address-cells == 1

The QPNP schema is a private case of Qualcomm PMIC's, so generalising will over-engineering IMO.

I made a similar attempt to write something like this, but did it entirely based on regmap "partitions", abstracting out the need for knowing anything in the client drivers but regmap.... It was about the same amount of code/complexity as this, but I tossed it out for the same reasons I mentioned here. Over/under-engineering has little to do with it.

Using 'QPNP' as an excuse to have a bus in the kernel that Qualcomm can define may not be your goal, but it does appear that way. From what I know of QPNP (which is only what Josh has described on the list) the entirety of what matters regarding the QPNP spec is already implemented in drivers/spmi/spmi-pmic-arb.c

Quoted 4 lines
Quoted 2 lines

- The resource code from drivers/{base,of}/platform.c is reimplemented here, without any added benefit

The resource code could be simplified to satisfy our needs.

Because we would then have our own playground on which to play?

On a related note, it would probably be a good idea to move much of the platform resource stuff out of the platform code... so we don't re-implement it over-and-over again.

-Courtney

maintainer
#10 lore raw
Quoted 54 lines · Courtney Cavin
Quoted 31 lines · Stanimir Varbanov

Hi Courtney,

Thanks for the comments.

Quoted 19 lines · Courtney Cavin
Quoted 18 lines · Stanimir Varbanov

Hello to all,

The goal of this WIP set is to provide support for sub-functional hw blocks inside Qualcomm QPNP PMIC chips by creating a new qpnp bus (device-driver modeled). On SPMI interface we attach a so called Slaves. For example one PMIC chip like pm8941 has two slave id's. On every slaveid the PMIC chip has various peripherials. Every peripheral driver should expose qpnp_driver structure and implement the .probe and .remove callbacks. Every peripheral driver will reside on the proper place in /drivers directory.

The fisrt patch describes the devicetree binding of the slave devices attached to the SPMI interface. The second patch adds implemetation of the qpnp-bus and a layer connection with the SPMI interface. The third patch adds spmi arbiter and underlying slaveid devicetree nodes for msm8974 SoC. The other patches are example of rtc-qpnp driver and binding documentation.

Quoted 6 lines
Quoted 2 lines

Since this set is a WIP, it will be used as a starting point for future duscussions about implementing QPNP PMIC sub-function hw blocks.

Ok. I have a few critical problems with this approach to implementing support for the PMICs:
- It's *way* more code than needed if done with of_platform_populate()

Quoted 7 lines

Agreed, but this will be the price we must pay to keep architectural correctness. The PMIC peripherals are not directly accessible by the CPU bus and thus they shouldn't be treated as platform devices. That fact gives as an opportunity to create a qpnp bus on which we will attach the whole bunch of PMIC peripherals and using DT we can describe register regions (256B each) belonging to it.

So the price we must pay for *your* vision of architectural correctness is to duplicate code without any actual benefit?

According to Documentation/driver-model/platform.txt your view is correct:

Platform devices are devices that typically appear as autonomous entities in the system. This includes legacy port-based devices and host bridges to peripheral buses, and most controllers integrated into system-on-chip platforms. What they usually have in common is direct addressing from a CPU bus. Rarely, a platform_device will be connected through a segment of some other kind of bus; but its registers will still be directly addressable.

Quoted 5 lines

However, it is clear that with recent changes to the platform code, this view is getting distorted somewhere. I haven't specifically heard any decisions on what to do here though.

Greg, Grant, Rob? What's the law?

Generally sub-blocks of a device are handled as platform devices. If there is a good enough reason then creating a new device type may be okay, but we certainly wouldn't want every PMIC or MFD driver to go off and define their own bus. Probably not each vendor doing a bus either.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

- AFAICT, the only direct relation between this and 'QPNP' is the 256 byte block size, which I would argue can be clearly expressed in DT instead with #size-cells == 1, and #address-cells == 1

I agree that I don't see anything unique here.

Quoted 2 lines
Quoted 2 lines

The QPNP schema is a private case of Qualcomm PMIC's, so generalising will over-engineering IMO.

But it is already generalized for you with platform devices.

Quoted 16 lines

I made a similar attempt to write something like this, but did it entirely based on regmap "partitions", abstracting out the need for knowing anything in the client drivers but regmap.... It was about the same amount of code/complexity as this, but I tossed it out for the same reasons I mentioned here. Over/under-engineering has little to do with it.

Using 'QPNP' as an excuse to have a bus in the kernel that Qualcomm can define may not be your goal, but it does appear that way. From what I know of QPNP (which is only what Josh has described on the list) the entirety of what matters regarding the QPNP spec is already implemented in drivers/spmi/spmi-pmic-arb.c

Quoted 3 lines
Quoted 2 lines

- The resource code from drivers/{base,of}/platform.c is reimplemented here, without any added benefit

Quoted 7 lines
Quoted 1 line

The resource code could be simplified to satisfy our needs.

Because we would then have our own playground on which to play?

On a related note, it would probably be a good idea to move much of the platform resource stuff out of the platform code... so we don't re-implement it over-and-over again.

Which part is implemented over-and-over?

Rob

#11 lore raw
Quoted 11 lines · Rob Herring
Quoted 3 lines · Courtney Cavin
Quoted 1 line · Stanimir Varbanov

On 06/25/2014 01:36 AM, Courtney Cavin wrote:

Greg, Grant, Rob? What's the law?

Generally sub-blocks of a device are handled as platform devices. If there is a good enough reason then creating a new device type may be okay, but we certainly wouldn't want every PMIC or MFD driver to go off and define their own bus. Probably not each vendor doing a bus either.

Thanks for the clarification!

Quoted 5 lines
Quoted 3 lines

On a related note, it would probably be a good idea to move much of the platform resource stuff out of the platform code... so we don't re-implement it over-and-over again.

Which part is implemented over-and-over?

These two, and all the convenient wrapper/population functions:
struct resource *resource;
u32 num_resources;

-Courtney

#12 lore raw
Quoted 7 lines · Courtney Cavin
Quoted 6 lines · Rob Herring
Quoted 3 lines · Courtney Cavin
Quoted 1 line · Stanimir Varbanov

On 06/25/2014 01:36 AM, Courtney Cavin wrote:

Greg, Grant, Rob? What's the law?

Quoted 7 lines
Quoted 5 lines

Generally sub-blocks of a device are handled as platform devices. If there is a good enough reason then creating a new device type may be okay, but we certainly wouldn't want every PMIC or MFD driver to go off and define their own bus. Probably not each vendor doing a bus either.

Thanks for the clarification!

OK, I tend to agree that creating a new bus only to define new device type is pointless. But using platform devices for sub-blocks attached to spmi-bus seems wrong too.

Courtney, the other option could be to extend spmi.c::of_spmi_register_devices to create spmi_device for each sub-function per each slave. Currently the function creates devices only for every spmi slave.

Thus every sub-function driver will be spmi_driver (something like i2c_driver for example). Sub-function resources could be embedded in spmi_device structure.

I'm not sure how much code/efforts will be needed but it seems it is worth to do.

Any thoughts?

Signature · 2 lines
regards,
Stan
#13 lore raw
In reply to Courtney Cavin
Quoted 54 lines · Courtney Cavin
Quoted 31 lines · Stanimir Varbanov

Hi Courtney,

Thanks for the comments.

Quoted 19 lines · Courtney Cavin
Quoted 18 lines · Stanimir Varbanov

Hello to all,

The goal of this WIP set is to provide support for sub-functional hw blocks inside Qualcomm QPNP PMIC chips by creating a new qpnp bus (device-driver modeled). On SPMI interface we attach a so called Slaves. For example one PMIC chip like pm8941 has two slave id's. On every slaveid the PMIC chip has various peripherials. Every peripheral driver should expose qpnp_driver structure and implement the .probe and .remove callbacks. Every peripheral driver will reside on the proper place in /drivers directory.

The fisrt patch describes the devicetree binding of the slave devices attached to the SPMI interface. The second patch adds implemetation of the qpnp-bus and a layer connection with the SPMI interface. The third patch adds spmi arbiter and underlying slaveid devicetree nodes for msm8974 SoC. The other patches are example of rtc-qpnp driver and binding documentation.

Quoted 6 lines
Quoted 2 lines

Since this set is a WIP, it will be used as a starting point for future duscussions about implementing QPNP PMIC sub-function hw blocks.

Ok. I have a few critical problems with this approach to implementing support for the PMICs:
- It's *way* more code than needed if done with of_platform_populate()

Quoted 7 lines

Agreed, but this will be the price we must pay to keep architectural correctness. The PMIC peripherals are not directly accessible by the CPU bus and thus they shouldn't be treated as platform devices. That fact gives as an opportunity to create a qpnp bus on which we will attach the whole bunch of PMIC peripherals and using DT we can describe register regions (256B each) belonging to it.

So the price we must pay for *your* vision of architectural correctness is to duplicate code without any actual benefit?

According to Documentation/driver-model/platform.txt your view is correct:

Platform devices are devices that typically appear as autonomous entities in the system. This includes legacy port-based devices and host bridges to peripheral buses, and most controllers integrated into system-on-chip platforms. What they usually have in common is direct addressing from a CPU bus. Rarely, a platform_device will be connected through a segment of some other kind of bus; but its registers will still be directly addressable.

Quoted 4 lines

However, it is clear that with recent changes to the platform code, this view is getting distorted somewhere. I haven't specifically heard any decisions on what to do here though.

Could you point me to the discussion?

Quoted 10 lines

Greg, Grant, Rob? What's the law?

Quoted 7 lines
Quoted 3 lines

- AFAICT, the only direct relation between this and 'QPNP' is the 256 byte block size, which I would argue can be clearly expressed in DT instead with #size-cells == 1, and #address-cells == 1

The QPNP schema is a private case of Qualcomm PMIC's, so generalising will over-engineering IMO.

Quoted 6 lines

I made a similar attempt to write something like this, but did it entirely based on regmap "partitions", abstracting out the need for knowing anything in the client drivers but regmap.... It was about the same amount of code/complexity as this, but I tossed it out for the same reasons I mentioned here. Over/under-engineering has little to do with it.

Hm, I missed it.

Signature · 2 lines
regards,
Stan