Skip to contentSkip to conversation

Implement SoC bus driver for Vybrid

PATCH Superseded Sanchayan Maity 2 participants 8 messages Mar 11, 2016 – Apr 4, 2016

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Implement SoC bus driver for Vybrid

Hello,

This patchset implements SoC bus support for Freescale Vybrid platform, implementing the following
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-soc

This a reworked version of an older patchset series posted in June 2015 which was at v5 then [1]. Since the NVMEM framework was then getting introduced, we decided that first a NVMEM driver for OCOTP peripheral being in place would be better.

Compared to the older revisions, this driver now relies on NVMEM consumer API using the NVMEM based vf610_ocotp driver which has already been in mainline for a while now. Also now a new syscon abstraction "syscon_regmap_read_from_offset" is implemented and exported from syscon allowing accessing a register from a syscon reference like this

ocotp-cfg1 = <&ocotp 0x20>;

avoiding code repetition in the driver.

One point on which we were not sure here is whether we really should introduce a new Kconfig symbol as being introduced here. While we could just enable it when SOC_VF610 is selected, this however would introduce circular dependencies.

This patch series is based on top of shawn's for-next branch and tested on Colibri Vybrid VF50 and VF61 modules.

Feedback is most welcome.

[1] Older v5:
http://lkml.iu.edu/hypermail/linux/kernel/1506.0/03787.html
Even earlier versions:
Version 4 of the patchset can be found here
https://lkml.org/lkml/2015/5/26/199
Version 3 of the patchset can be found here
http://www.spinics.net/lists/arm-kernel/msg420847.html
Version 2 of the patchset can be found here
http://www.spinics.net/lists/devicetree/msg80654.html
Version 1 of the patchset can be found here
http://www.spinics.net/lists/devicetree/msg80257.html
The RFC version can be found here
https://lkml.org/lkml/2015/5/11/13

Regards,
Sanchayan.

Sanchayan Maity (4):
mfd: syscon: Introduce syscon_regmap_read_from_offset
ARM: dts: vfxxx: Add device tree node for OCOTP
ARM: dts: vfxxx: Add OCROM and phandle entries for Vybrid SoC bus driver
soc: Add SoC bus driver for Freescale Vybrid Platform

 arch/arm/boot/dts/vfxxx.dtsi |  28 +++++++-
 drivers/mfd/syscon.c         |  30 ++++++++
 drivers/soc/Kconfig          |   1 +
 drivers/soc/fsl/Kconfig      |  10 +++
 drivers/soc/fsl/Makefile     |   1 +
 drivers/soc/fsl/soc-vf610.c  | 160 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/syscon.h   |  10 +++
 7 files changed, 239 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/soc-vf610.c
Signature · 1 line
2.7.2
#1 lore raw

PATCH 1/4 mfd: syscon: Introduce syscon_regmap_read_from_offset

Currently syscon does not provide an abstraction to access a register from syscon reference like below

ocotp-cfg1 = <&ocotp 0x20>

syscon_regmap_read_from_offset provides a generic abstraction to access a register from syscon reference as above. It allows to specify the node and node name of phandle reference, reading the offset from the node entry and providing the value from the offset in the register map.

---
 drivers/mfd/syscon.c       | 30 ++++++++++++++++++++++++++++++
 include/linux/mfd/syscon.h | 10 ++++++++++
 2 files changed, 40 insertions(+)
drivers/mfd/syscon.c +30 -0
index b7aabee..349c38e 100644
@@ -129,6 +129,36 @@ struct regmap *syscon_node_to_regmap(struct device_node *np)
 }
 EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
 
+int syscon_regmap_read_from_offset(struct device_node *np,
+				const char *s, unsigned int *val)
+{
+	struct of_phandle_args pargs;
+	struct regmap *regmap;
+	int offset;
+	int ret;
+
+	if (!np)
+		return -ENODEV;
+
+	ret = of_parse_phandle_with_fixed_args(np, s, 1, 0, &pargs);
+	if (ret)
+		return ret;
+
+	regmap = syscon_node_to_regmap(pargs.np);
+	if (IS_ERR(regmap)) {
+		of_node_put(pargs.np);
+		return PTR_ERR(regmap);
+	}
+
+	offset = pargs.args[0];
+	of_node_put(pargs.np);
+
+	ret = regmap_read(regmap, offset, val);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(syscon_regmap_read_from_offset);
+
 struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
 {
 	struct device_node *syscon_np;
include/linux/mfd/syscon.h +10 -0
index 75e543b..3c02ed9 100644
@@ -26,6 +26,9 @@ extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s);
 extern struct regmap *syscon_regmap_lookup_by_phandle(
 					struct device_node *np,
 					const char *property);
+extern int syscon_regmap_read_from_offset(struct device_node *np,
+					  const char *s,
+					  unsigned int *val);
 #else
 static inline struct regmap *syscon_node_to_regmap(struct device_node *np)
 {
@@ -48,6 +51,13 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle(
 {
 	return ERR_PTR(-ENOSYS);
 }
+
+static inline int syscon_regmap_read_from_offset(struct device_node *np,
+						 const char *s,
+						 unsigned int *val)
+{
+	return ERR_PTR(-ENOSYS);
+}
 #endif
 
 #endif /* __LINUX_MFD_SYSCON_H__ */
Signature · 1 line
2.7.2
#2 lore raw

PATCH 2/4 ARM: dts: vfxxx: Add device tree node for OCOTP

In reply to Sanchayan Maity

Add device tree node for the OCOTP peripheral on Vybrid.

---
 arch/arm/boot/dts/vfxxx.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/boot/dts/vfxxx.dtsi +16 -0
index 5e49fbd..db9157e 100644
@@ -499,6 +499,22 @@
 				status = "disabled";
 			};
 
+			ocotp at 400a5000 {
+				compatible = "fsl,vf610-ocotp";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				reg = <0x400a5000 0xCF0>;
+				clocks = <&clks VF610_CLK_OCOTP>;
+
+				ocotp_cfg0: cfg0 at 410 {
+					reg = <0x410 0x4>;
+				};
+
+				ocotp_cfg1: cfg1 at 420 {
+					reg = <0x420 0x4>;
+				};
+			};
+
 			snvs0: snvs at 400a7000 {
 			    compatible = "fsl,sec-v4.0-mon", "syscon", "simple-mfd";
 				reg = <0x400a7000 0x2000>;
Signature · 1 line
2.7.2
#3 lore raw

PATCH 3/4 ARM: dts: vfxxx: Add OCROM and phandle entries for Vybrid SoC bus driver

In reply to Sanchayan Maity

Add OCROM node and introduce phandles to OCROM, MSCM and NVMEM OCOTP for use by the Vybrid SoC bus driver.

---
 arch/arm/boot/dts/vfxxx.dtsi | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/boot/dts/vfxxx.dtsi +11 -1
index db9157e..0dd7ad5 100644
@@ -87,9 +87,19 @@
 	soc {
 		#address-cells = <1>;
 		#size-cells = <1>;
-		compatible = "simple-bus";
+		compatible = "fsl,vf610-soc-bus", "simple-bus";
 		interrupt-parent = <&mscm_ir>;
 		ranges;
+		fsl,rom-revision = <&ocrom 0x80>;
+		fsl,cpu-count = <&mscm_cpucfg 0x2C>;
+		fsl,l2-size = <&mscm_cpucfg 0x14>;
+		nvmem-cells = <&ocotp_cfg0>, <&ocotp_cfg1>;
+		nvmem-cell-names = "cfg0", "cfg1";
+
+		ocrom: ocrom at 00000000 {
+			compatible = "fsl,vf610-ocrom", "syscon";
+			reg = <0x00000000 0x18000>;
+		};
 
 		aips0: aips-bus at 40000000 {
 			compatible = "fsl,aips-bus", "simple-bus";
Signature · 1 line
2.7.2
#4 lore raw

Re: [PATCH v1 3/4] ARM: dts: vfxxx: Add OCROM and phandle entries for Vybrid SoC bus driver

Quoted 13 lines · Sanchayan Maity

Add OCROM node and introduce phandles to OCROM, MSCM and NVMEM OCOTP for use by the Vybrid SoC bus driver.

---
 arch/arm/boot/dts/vfxxx.dtsi | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/boot/dts/vfxxx.dtsi +0 -0
index db9157e..0dd7ad5 100644

arch/arm/boot/dts/vfxxx.dtsi line 95

Quoted 10 lines
arch/arm/boot/dts/vfxxx.dtsi +4 -1
@@ -87,9 +87,19 @@
 	soc {
 		#address-cells = <1>;
 		#size-cells = <1>;
-		compatible = "simple-bus";
+		compatible = "fsl,vf610-soc-bus", "simple-bus";
 		interrupt-parent = <&mscm_ir>;
 		ranges;
+		fsl,rom-revision = <&ocrom 0x80>;
+		fsl,cpu-count = <&mscm_cpucfg 0x2C>;
+		fsl,l2-size = <&mscm_cpucfg 0x14>;

We need a bindings doc for these new properties and compatible.

Shawn

Quoted 14 lines
arch/arm/boot/dts/vfxxx.dtsi +7 -0
+		nvmem-cells = <&ocotp_cfg0>, <&ocotp_cfg1>;
+		nvmem-cell-names = "cfg0", "cfg1";
+
+		ocrom: ocrom at 00000000 {
+			compatible = "fsl,vf610-ocrom", "syscon";
+			reg = <0x00000000 0x18000>;
+		};
 
 		aips0: aips-bus at 40000000 {
 			compatible = "fsl,aips-bus", "simple-bus";
Signature · 1 line
2.7.2
#5 lore raw

Re: [PATCH v1 3/4] ARM: dts: vfxxx: Add OCROM and phandle entries for Vybrid SoC bus driver

Hello,

Quoted 18 lines · Shawn Guo
Quoted 17 lines · Sanchayan Maity

Add OCROM node and introduce phandles to OCROM, MSCM and NVMEM OCOTP for use by the Vybrid SoC bus driver.

---
 arch/arm/boot/dts/vfxxx.dtsi | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm/boot/dts/vfxxx.dtsi +0 -1
index db9157e..0dd7ad5 100644
@@ -87,9 +87,19 @@
 	soc {
 		#address-cells = <1>;
 		#size-cells = <1>;
-		compatible = "simple-bus";
Quoted 8 lines

arch/arm/boot/dts/vfxxx.dtsi line 95

Quoted 6 lines
arch/arm/boot/dts/vfxxx.dtsi +4 -0
+		compatible = "fsl,vf610-soc-bus", "simple-bus";
 		interrupt-parent = <&mscm_ir>;
 		ranges;
+		fsl,rom-revision = <&ocrom 0x80>;
+		fsl,cpu-count = <&mscm_cpucfg 0x2C>;
+		fsl,l2-size = <&mscm_cpucfg 0x14>;

We need a bindings doc for these new properties and compatible.

Ok. Will add the documentation part in v2.

- Sanchayan.

Quoted 17 lines

Shawn

Quoted 14 lines
arch/arm/boot/dts/vfxxx.dtsi +7 -0
+		nvmem-cells = <&ocotp_cfg0>, <&ocotp_cfg1>;
+		nvmem-cell-names = "cfg0", "cfg1";
+
+		ocrom: ocrom at 00000000 {
+			compatible = "fsl,vf610-ocrom", "syscon";
+			reg = <0x00000000 0x18000>;
+		};
 
 		aips0: aips-bus at 40000000 {
 			compatible = "fsl,aips-bus", "simple-bus";
Signature · 1 line
2.7.2
#6 lore raw

PATCH 4/4 soc: Add SoC bus driver for Freescale Vybrid Platform

In reply to Sanchayan Maity

This adds a SoC driver to be used by Freescale Vybrid SoC's. Driver utilises syscon and nvmem consumer API's to get the various register values needed and sysfs exposes the SoC specific properties.

A sample output from Colibri Vybrid VF61 is below:

root at colibri-vf:~# cd /sys/bus/soc/devices/soc0 root at colibri-vf:/sys/bus/soc/devices/soc0# ls
family machine power revision soc_id subsystem uevent
root at colibri-vf:/sys/bus/soc/devices/soc0# cat family Freescale Vybrid VF610
root at colibri-vf:/sys/bus/soc/devices/soc0# cat machine Freescale Vybrid
root at colibri-vf:/sys/bus/soc/devices/soc0# cat revision 00000013
root at colibri-vf:/sys/bus/soc/devices/soc0# cat soc_id df6472a6130f29d4

---
 drivers/soc/Kconfig         |   1 +
 drivers/soc/fsl/Kconfig     |  10 +++
 drivers/soc/fsl/Makefile    |   1 +
 drivers/soc/fsl/soc-vf610.c | 160 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/soc-vf610.c
drivers/soc/Kconfig +1 -0
index 8826020..f84ba63 100644
@@ -2,6 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
 source "drivers/soc/brcmstb/Kconfig"
+source "drivers/soc/fsl/Kconfig"
 source "drivers/soc/fsl/qe/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
drivers/soc/fsl/Kconfig new file +10 -0
new file mode 100644
index 0000000..029ea17
@@ -0,0 +1,10 @@
+#
+# Freescale SoC drivers
+
+config SOC_BUS_VF610
+	bool "SoC bus device for the Freescale Vybrid platform"
+	depends on NVMEM && NVMEM_VF610_OCOTP
+	select SOC_BUS
+	help
+	 Include support for the SoC bus on the Freescale Vybrid platform
+	 providing sysfs information about the module variant.
drivers/soc/fsl/Makefile +1 -0
index 203307f..afaf092 100644
@@ -2,5 +2,6 @@
 # Makefile for the Linux Kernel SOC fsl specific device drivers
 #
 
+obj-$(CONFIG_SOC_VF610)			+= soc-vf610.o
 obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
drivers/soc/fsl/soc-vf610.c new file +159 -0

159 lines not on this page · raw message

Signature · 1 line
2.7.2
#7 lore raw
In reply to Sanchayan Maity

Hello,

Ping.

- Sanchayan.

Quoted 69 lines · Sanchayan Maity

Hello,

This patchset implements SoC bus support for Freescale Vybrid platform, implementing the following
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-soc

This a reworked version of an older patchset series posted in June 2015 which was at v5 then [1]. Since the NVMEM framework was then getting introduced, we decided that first a NVMEM driver for OCOTP peripheral being in place would be better.

Compared to the older revisions, this driver now relies on NVMEM consumer API using the NVMEM based vf610_ocotp driver which has already been in mainline for a while now. Also now a new syscon abstraction "syscon_regmap_read_from_offset" is implemented and exported from syscon allowing accessing a register from a syscon reference like this

ocotp-cfg1 = <&ocotp 0x20>;

avoiding code repetition in the driver.

One point on which we were not sure here is whether we really should introduce a new Kconfig symbol as being introduced here. While we could just enable it when SOC_VF610 is selected, this however would introduce circular dependencies.

This patch series is based on top of shawn's for-next branch and tested on Colibri Vybrid VF50 and VF61 modules.

Feedback is most welcome.

[1] Older v5:
http://lkml.iu.edu/hypermail/linux/kernel/1506.0/03787.html
Even earlier versions:
Version 4 of the patchset can be found here
https://lkml.org/lkml/2015/5/26/199
Version 3 of the patchset can be found here
http://www.spinics.net/lists/arm-kernel/msg420847.html
Version 2 of the patchset can be found here
http://www.spinics.net/lists/devicetree/msg80654.html
Version 1 of the patchset can be found here
http://www.spinics.net/lists/devicetree/msg80257.html
The RFC version can be found here
https://lkml.org/lkml/2015/5/11/13

Regards,
Sanchayan.

Sanchayan Maity (4):
mfd: syscon: Introduce syscon_regmap_read_from_offset
ARM: dts: vfxxx: Add device tree node for OCOTP
ARM: dts: vfxxx: Add OCROM and phandle entries for Vybrid SoC bus driver
soc: Add SoC bus driver for Freescale Vybrid Platform

 arch/arm/boot/dts/vfxxx.dtsi |  28 +++++++-
 drivers/mfd/syscon.c         |  30 ++++++++
 drivers/soc/Kconfig          |   1 +
 drivers/soc/fsl/Kconfig      |  10 +++
 drivers/soc/fsl/Makefile     |   1 +
 drivers/soc/fsl/soc-vf610.c  | 160 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/syscon.h   |  10 +++
 7 files changed, 239 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/soc-vf610.c
Signature · 1 line
2.7.2