Skip to contentSkip to conversation

mfd: Add Renesas Synchronization Management Unit (SMU) support

PATCH In review [email protected] 3 participants 14 messages Apr 8, 2021 – Apr 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 mfd: Add Renesas Synchronization Management Unit (SMU) support

From: Min Li <[email protected]>

Add support for ClockMatrix(TM) and 82P33xxx families of timing and synchronization devices. The access interface can be either SPI or I2C. Currently, it will create 2 types of MFD devices, which are to be used by the corresponding rsmu character device driver and the PTP hardware clock driver, respectively.

---
 drivers/mfd/Kconfig              |  28 ++
 drivers/mfd/Makefile             |   3 +
 drivers/mfd/rsmu_i2c.c           | 349 +++++++++++++++++
 drivers/mfd/rsmu_private.h       |  32 ++
 drivers/mfd/rsmu_spi.c           | 376 ++++++++++++++++++
 include/linux/mfd/idt82p33_reg.h | 116 ++++++
 include/linux/mfd/idt8a340_reg.h | 817 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rsmu.h         |  54 +++
 8 files changed, 1775 insertions(+)
 create mode 100644 drivers/mfd/rsmu_i2c.c
 create mode 100644 drivers/mfd/rsmu_private.h
 create mode 100644 drivers/mfd/rsmu_spi.c
 create mode 100644 include/linux/mfd/idt82p33_reg.h
 create mode 100644 include/linux/mfd/idt8a340_reg.h
 create mode 100644 include/linux/mfd/rsmu.h
drivers/mfd/Kconfig +28 -0
index 21a131d..63b18b3 100644
@@ -2172,5 +2172,33 @@ config MFD_INTEL_M10_BMC
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_RSMU_I2C
+	tristate "Renesas Synchronization Management Unit with I2C"
+	depends on I2C && OF
+	depends on MFD_RSMU_SPI=n
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  Support for the Renesas synchronization management unit, such as
+	  Clockmatrix and 82P33XXX series. This option supports I2C as
+	  the control interface.
+
+	  This driver provides common support for accessing the device,
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+
+config MFD_RSMU_SPI
+	tristate "Renesas Synchronization Management Unit with SPI"
+	depends on SPI && OF
+	select MFD_CORE
+	help
+	  Support for the Renesas synchronization management unit, such as
+	  Clockmatrix and 82P33XXX series. This option supports SPI as
+	  the control interface.
+
+	  This driver provides common support for accessing the device,
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+
 endmenu
 endif
drivers/mfd/Makefile +3 -0
index 4f6d2b8..4ab32ef 100644
@@ -271,3 +271,6 @@ obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
 
 obj-$(CONFIG_MFD_ATC260X)	+= atc260x-core.o
 obj-$(CONFIG_MFD_ATC260X_I2C)	+= atc260x-i2c.o
+
+obj-$(CONFIG_MFD_RSMU_I2C)	+= rsmu_i2c.o
+obj-$(CONFIG_MFD_RSMU_SPI)	+= rsmu_spi.o
drivers/mfd/rsmu_i2c.c new file +349 -0

349 lines not on this page · raw message

drivers/mfd/rsmu_private.h new file +32 -0
new file mode 100644
index 0000000..8841a24
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Multi-function driver for the IDT ClockMatrix(TM) and 82p33xxx families of
+ * timing and synchronization devices.
+ *
+ * Copyright (C) 2019 Integrated Device Technology, Inc., a Renesas Company.
+ */
+
+#ifndef __RSMU_MFD_PRIVATE_H
+#define __RSMU_MFD_PRIVATE_H
+
+#include <linux/mfd/rsmu.h>
+
+/* Maximum number of mfd devices */
+#define RSMU_MAX_MFD_DEV		4
+
+struct rsmu_dev {
+	struct device *dev;
+	void *client;
+	struct regmap *regmap;
+	struct mutex lock;
+	enum rsmu_type type;
+	u8 index;
+	u16 page;
+};
+
+enum rsmu_mfd_type {
+	RSMU_MFD_PTP		= 0,
+	RSMU_MFD_CDEV		= 1,
+	RSMU_MFD_NUM		= 2,
+};
+#endif /*  __LINUX_MFD_RSMU_H */
drivers/mfd/rsmu_spi.c new file +376 -0

376 lines not on this page · raw message

include/linux/mfd/idt82p33_reg.h new file +116 -0

116 lines not on this page · raw message

include/linux/mfd/idt8a340_reg.h new file +817 -0

817 lines not on this page · raw message

include/linux/mfd/rsmu.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 2/2 misc: Add Renesas Synchronization Management Unit (SMU) support

From: Min Li <[email protected]>

This driver is developed for the IDT ClockMatrix(TM) and 82P33xxx families of timing and synchronization devices.It will be used by Renesas PTP Clock Manager for Linux (pcm4l) software to provide support to GNSS assisted partial timing support (APTS) and other networking timing functions.

Current version provides kernel API's to support the following functions -set combomode to enable SYNCE clock support
-read dpll's state to determine if the dpll is locked to the GNSS channel -read dpll's ffo (fractional frequency offset) in ppqt

---
Change log
-rebase change to linux-next tree
-remove uncessary condition checks suggested by Greg -fix compile error for x86_64
-register device through misc_register suggested by Greg -change to use module_platform_device to register driver -remove empty open and release functions
-more informational comment for struct rsmu_cdev

 drivers/misc/Kconfig      |   9 ++
 drivers/misc/Makefile     |   2 +
 drivers/misc/rsmu_cdev.c  | 231 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/rsmu_cdev.h  |  74 +++++++++++++++
 drivers/misc/rsmu_cm.c    | 166 +++++++++++++++++++++++++++++++++
 drivers/misc/rsmu_sabre.c | 133 ++++++++++++++++++++++++++
 include/uapi/linux/rsmu.h |  64 +++++++++++++
 7 files changed, 679 insertions(+)
 create mode 100644 drivers/misc/rsmu_cdev.c
 create mode 100644 drivers/misc/rsmu_cdev.h
 create mode 100644 drivers/misc/rsmu_cm.c
 create mode 100644 drivers/misc/rsmu_sabre.c
 create mode 100644 include/uapi/linux/rsmu.h
drivers/misc/Kconfig +9 -0
index f532c59..49b523a 100644
@@ -445,6 +445,15 @@ config HISI_HIKEY_USB
 	  switching between the dual-role USB-C port and the USB-A host ports
 	  using only one USB controller.
 
+config RSMU
+	tristate "Renesas Synchronization Management Unit (SMU)"
+	help
+	  This option enables support for the IDT ClockMatrix(TM) and 82P33xxx
+	  families of timing and synchronization devices. It will be used by
+	  Renesas PTP Clock Manager for Linux (pcm4l) software to provide support
+	  for GNSS assisted partial timing support (APTS) and other networking
+	  timing functions.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +2 -0
index 99b6f15..21b8ed4 100644
@@ -56,3 +56,5 @@ obj-$(CONFIG_HABANA_AI)		+= habanalabs/
 obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
 obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
+rsmu-objs			:= rsmu_cdev.o rsmu_cm.o rsmu_sabre.o
+obj-$(CONFIG_RSMU)		+= rsmu.o
drivers/misc/rsmu_cdev.c new file +231 -0

231 lines not on this page · raw message

drivers/misc/rsmu_cdev.h new file +74 -0

74 lines not on this page · raw message

drivers/misc/rsmu_cm.c new file +166 -0

166 lines not on this page · raw message

drivers/misc/rsmu_sabre.c new file +133 -0

133 lines not on this page · raw message

include/uapi/linux/rsmu.h new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 19 lines · On Wed, Apr 07, 2021 at 09:50:50PM -0400, [email protected] wrote:

From: Min Li <[email protected]>

This driver is developed for the IDT ClockMatrix(TM) and 82P33xxx families of timing and synchronization devices.It will be used by Renesas PTP Clock Manager for Linux (pcm4l) software to provide support to GNSS assisted partial timing support (APTS) and other networking timing functions.

Current version provides kernel API's to support the following functions

(quoted diff) +0 -3
-set combomode to enable SYNCE clock support
-read dpll's state to determine if the dpll is locked to the GNSS channel
-read dpll's ffo (fractional frequency offset) in ppqt

---
Change log

(quoted diff) +0 -4
-rebase change to linux-next tree
-remove uncessary condition checks suggested by Greg
-fix compile error for x86_64
-register device through misc_register suggested by Greg

Review

Quoted 10 lines
(quoted diff) +0 -3
-change to use module_platform_device to register driver
-remove empty open and release functions
-more informational comment for struct rsmu_cdev
 
 drivers/misc/Kconfig      |   9 ++
 drivers/misc/Makefile     |   2 +
 drivers/misc/rsmu_cdev.c  | 231 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/rsmu_cdev.h  |  74 +++++++++++++++
 drivers/misc/rsmu_cm.c    | 166 +++++++++++++++++++++++++++++++++
 drivers/misc/rsmu_sabre.c | 133 ++++++++++++++++++++++++++

Again, please make this only one file.

thanks,

greg k-h

author
#3 lore raw

RE: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 3 lines

Again, please make this only one file.

Hi Greg, the 2 boards have some same named registers in idt82p33_reg.h and idt8a340_reg.h so if I put them all in the same file, there will be name conflicts.

maintainer
#4 lore raw

Re: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 5 lines · Min Li
Quoted 3 lines

Again, please make this only one file.

Hi Greg, the 2 boards have some same named registers in idt82p33_reg.h and idt8a340_reg.h so if I put them all in the same file, there will be name conflicts.

That does not make sense, this is only one kernel module, with one .h file in this patch, I do not see those other files you are talking about...

And if you have named registers that are identical, and yet you only work on one device, that feels like a design flaw somewhere :)

thanks,

greg k-h

author
#5 lore raw

RE: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 7 lines

That does not make sense, this is only one kernel module, with one .h file in this patch, I do not see those other files you are talking about...

And if you have named registers that are identical, and yet you only work on one device, that feels like a design flaw somewhere :)

Hi Greg, the register files are in the 1/2 patch for the mfd part of the change. The reason they have same named register is because they are all synchronization devices and they share some similar features

maintainer
#6 lore raw

Re: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 11 lines · Min Li
Quoted 7 lines

That does not make sense, this is only one kernel module, with one .h file in this patch, I do not see those other files you are talking about...

And if you have named registers that are identical, and yet you only work on one device, that feels like a design flaw somewhere :)

Hi Greg, the register files are in the 1/2 patch for the mfd part of the change. The reason they have same named register is because they are all synchronization devices and they share some similar features

But what does that have to do with the misc device?

totally confused,

greg k-h

author
#7 lore raw

RE: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 3 lines

But what does that have to do with the misc device?

Hi Greg, MFD driver is the start of everything. Once MFD driver is loading, it will spawn 2 devices, one is for phc driver, which is under /driver/ptp and the other one is for this misc driver. Both PHC and misc drivers are operating on the same device.
They are both calling exported functions from mfd drivers to access the device through i2c/spi and the register definitions are located in include/Linux/mfd/idt8a340_reg.h or idt82p33_reg.h depending on which device was found by mfd driver through device tree node.

maintainer
#8 lore raw

Re: [PATCH net-next v3 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 10 lines · Min Li
Quoted 3 lines

But what does that have to do with the misc device?

Hi Greg, MFD driver is the start of everything. Once MFD driver is loading, it will spawn 2 devices, one is for phc driver, which is under /driver/ptp and the other one is for this misc driver. Both PHC and misc drivers are operating on the same device.
They are both calling exported functions from mfd drivers to access the device through i2c/spi and the register definitions are located in include/Linux/mfd/idt8a340_reg.h or idt82p33_reg.h depending on which device was found by mfd driver through device tree node.

I don't think it's a good idea to have the same defines with different values in different files, that's just a problem waiting to happen...

good luck!

greg k-h

#9 lore raw
In reply to [email protected]
Quoted 10 lines · On Wed, 07 Apr 2021, [email protected] wrote:

From: Min Li <[email protected]>

Add support for ClockMatrix(TM) and 82P33xxx families of timing and synchronization devices. The access interface can be either SPI or I2C. Currently, it will create 2 types of MFD devices, which are to be used by the corresponding rsmu character device driver and the PTP hardware clock driver, respectively.

---

If this is v3, there should be a changelog here.

Quoted 15 lines
 drivers/mfd/Kconfig              |  28 ++
 drivers/mfd/Makefile             |   3 +
 drivers/mfd/rsmu_i2c.c           | 349 +++++++++++++++++
 drivers/mfd/rsmu_private.h       |  32 ++
 drivers/mfd/rsmu_spi.c           | 376 ++++++++++++++++++
 include/linux/mfd/idt82p33_reg.h | 116 ++++++
 include/linux/mfd/idt8a340_reg.h | 817 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rsmu.h         |  54 +++
 8 files changed, 1775 insertions(+)
 create mode 100644 drivers/mfd/rsmu_i2c.c
 create mode 100644 drivers/mfd/rsmu_private.h
 create mode 100644 drivers/mfd/rsmu_spi.c
 create mode 100644 include/linux/mfd/idt82p33_reg.h
 create mode 100644 include/linux/mfd/idt8a340_reg.h
 create mode 100644 include/linux/mfd/rsmu.h
Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#10 lore raw
Quoted 3 lines

If this is v3, there should be a changelog here.

Hi Lee

There is no change in v3 for MFD part of code, v3 is only for misc part. But I have to format 2 patches together and that is why mfd part got v3 as well. But it is actually identical to v2

#11 lore raw
Quoted 8 lines · Min Li
Quoted 3 lines

If this is v3, there should be a changelog here.

Hi Lee

There is no change in v3 for MFD part of code, v3 is only for misc part. But I have to format 2 patches together and that is why mfd part got v3 as well. But it is actually identical to v2

Then you need to mention that in the change log.

What changed from v1 => v2?

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#12 lore raw
Quoted 5 lines

Then you need to mention that in the change log.

What changed from v1 => v2?

Please look it up by the latest patch I sent over yesterday. It is under the Signed-off-by

---
-rebase change to linux-next tree
-add log to inform driver loading success

author
#13 lore raw
In reply to Lee Jones
Quoted 5 lines

Then you need to mention that in the change log.

What changed from v1 => v2?

Please see my latest [PATCH next v2] and it has the following change log

---
-rebase change to linux-next tree
-add log to inform driver loading success