Skip to contentSkip to conversation

mfd: rsmu: Resolve naming conflict between idt8a340_reg.h and idt82p33_reg.h

PATCH Superseded [email protected] 3 participants 13 messages Sep 15, 2021 – Sep 16, 2021

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

PATCH v2 1/2 mfd: rsmu: Resolve naming conflict between idt8a340_reg.h and idt82p33_reg.h

From: Min Li <[email protected]>

---
Change log
-resolve name conflicts so that rsmu misc driver can be in one c file suggested by Greg

 include/linux/mfd/idt82p33_reg.h | 148 ++++++++++++++++++++-------------------
 1 file changed, 75 insertions(+), 73 deletions(-)
include/linux/mfd/idt82p33_reg.h +75 -73
index 129a6c0..ded0ab8 100644
@@ -7,106 +7,108 @@
 #ifndef HAVE_IDT82P33_REG
 #define HAVE_IDT82P33_REG
 
+#define SABRE_REG_ADDR(page, offset) (((page) << 0x7) | ((offset) & 0x7f))
+
 /* Register address */
-#define DPLL1_TOD_CNFG 0x134
-#define DPLL2_TOD_CNFG 0x1B4
+#define SABRE_DPLL1_TOD_CNFG 0x134
+#define SABRE_DPLL2_TOD_CNFG 0x1B4
 
-#define DPLL1_TOD_STS 0x10B
-#define DPLL2_TOD_STS 0x18B
+#define SABRE_DPLL1_TOD_STS 0x10B
+#define SABRE_DPLL2_TOD_STS 0x18B
 
-#define DPLL1_TOD_TRIGGER 0x115
-#define DPLL2_TOD_TRIGGER 0x195
+#define SABRE_DPLL1_TOD_TRIGGER 0x115
+#define SABRE_DPLL2_TOD_TRIGGER 0x195
 
-#define DPLL1_OPERATING_MODE_CNFG 0x120
-#define DPLL2_OPERATING_MODE_CNFG 0x1A0
+#define SABRE_DPLL1_OPERATING_MODE_CNFG 0x120
+#define SABRE_DPLL2_OPERATING_MODE_CNFG 0x1A0
 
-#define DPLL1_HOLDOVER_FREQ_CNFG 0x12C
-#define DPLL2_HOLDOVER_FREQ_CNFG 0x1AC
+#define SABRE_DPLL1_HOLDOVER_FREQ_CNFG 0x12C
+#define SABRE_DPLL2_HOLDOVER_FREQ_CNFG 0x1AC
 
-#define DPLL1_PHASE_OFFSET_CNFG 0x143
-#define DPLL2_PHASE_OFFSET_CNFG 0x1C3
+#define SABRE_DPLL1_PHASE_OFFSET_CNFG 0x143
+#define SABRE_DPLL2_PHASE_OFFSET_CNFG 0x1C3
 
-#define DPLL1_SYNC_EDGE_CNFG 0x140
-#define DPLL2_SYNC_EDGE_CNFG 0x1C0
+#define SABRE_DPLL1_SYNC_EDGE_CNFG 0x140
+#define SABRE_DPLL2_SYNC_EDGE_CNFG 0x1C0
 
-#define DPLL1_INPUT_MODE_CNFG 0x116
-#define DPLL2_INPUT_MODE_CNFG 0x196
+#define SABRE_DPLL1_INPUT_MODE_CNFG 0x116
+#define SABRE_DPLL2_INPUT_MODE_CNFG 0x196
 
-#define DPLL1_OPERATING_STS 0x102
-#define DPLL2_OPERATING_STS 0x182
+#define SABRE_DPLL1_OPERATING_STS 0x102
+#define SABRE_DPLL2_OPERATING_STS 0x182
 
-#define DPLL1_CURRENT_FREQ_STS 0x103
-#define DPLL2_CURRENT_FREQ_STS 0x183
+#define SABRE_DPLL1_CURRENT_FREQ_STS 0x103
+#define SABRE_DPLL2_CURRENT_FREQ_STS 0x183
 
-#define REG_SOFT_RESET 0X381
+#define SABRE_REG_SOFT_RESET 0X381
 
-#define OUT_MUX_CNFG(outn) REG_ADDR(0x6, (0xC * (outn)))
+#define SABRE_OUT_MUX_CNFG(outn) REG_ADDR(0x6, (0xC * (outn)))
 
 /* Register bit definitions */
-#define SYNC_TOD BIT(1)
-#define PH_OFFSET_EN BIT(7)
-#define SQUELCH_ENABLE BIT(5)
+#define SABRE_SYNC_TOD BIT(1)
+#define SABRE_PH_OFFSET_EN BIT(7)
+#define SABRE_SQUELCH_ENABLE BIT(5)
 
 /* Bit definitions for the DPLL_MODE register */
-#define PLL_MODE_SHIFT		(0)
-#define PLL_MODE_MASK		(0x1F)
-#define COMBO_MODE_EN		BIT(5)
-#define COMBO_MODE_SHIFT	(6)
-#define COMBO_MODE_MASK		(0x3)
+#define SABRE_PLL_MODE_SHIFT		(0)
+#define SABRE_PLL_MODE_MASK		(0x1F)
+#define SABRE_COMBO_MODE_EN		BIT(5)
+#define SABRE_COMBO_MODE_SHIFT	(6)
+#define SABRE_COMBO_MODE_MASK		(0x3)
 
 /* Bit definitions for DPLL_OPERATING_STS register */
-#define OPERATING_STS_MASK	(0x7)
-#define OPERATING_STS_SHIFT	(0x0)
+#define SABRE_OPERATING_STS_MASK	(0x7)
+#define SABRE_OPERATING_STS_SHIFT	(0x0)
 
 /* Bit definitions for DPLL_TOD_TRIGGER register */
-#define READ_TRIGGER_MASK	(0xF)
-#define READ_TRIGGER_SHIFT	(0x0)
-#define WRITE_TRIGGER_MASK	(0xF0)
-#define WRITE_TRIGGER_SHIFT	(0x4)
+#define SABRE_READ_TRIGGER_MASK	(0xF)
+#define SABRE_READ_TRIGGER_SHIFT	(0x0)
+#define SABRE_WRITE_TRIGGER_MASK	(0xF0)
+#define SABRE_WRITE_TRIGGER_SHIFT	(0x4)
 
 /* Bit definitions for REG_SOFT_RESET register */
-#define SOFT_RESET_EN		BIT(7)
-
-enum pll_mode {
-	PLL_MODE_MIN = 0,
-	PLL_MODE_AUTOMATIC = PLL_MODE_MIN,
-	PLL_MODE_FORCE_FREERUN = 1,
-	PLL_MODE_FORCE_HOLDOVER = 2,
-	PLL_MODE_FORCE_LOCKED = 4,
-	PLL_MODE_FORCE_PRE_LOCKED2 = 5,
-	PLL_MODE_FORCE_PRE_LOCKED = 6,
-	PLL_MODE_FORCE_LOST_PHASE = 7,
-	PLL_MODE_DCO = 10,
-	PLL_MODE_WPH = 18,
-	PLL_MODE_MAX = PLL_MODE_WPH,
+#define SABRE_SOFT_RESET_EN		BIT(7)
+
+enum sabre_pll_mode {
+	SABRE_PLL_MODE_MIN = 0,
+	SABRE_PLL_MODE_AUTOMATIC = SABRE_PLL_MODE_MIN,
+	SABRE_PLL_MODE_FORCE_FREERUN = 1,
+	SABRE_PLL_MODE_FORCE_HOLDOVER = 2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EL_IN13 = 3,
+	SABRE_HW_TOD_TRIG_SEL_IN14 = 4,
+	SABRE_HW_TOD_TRIG_SEL_TOD_PPS = 5,
+	SABRE_HW_TOD_TRIG_SEL_TIMER_INTERVAL = 6,
+	SABRE_HW_TOD_TRIG_SEL_MSB_PHASE_OFFSET_CNFG = 7,
+	SABRE_HW_TOD_TRIG_SEL_MSB_HOLDOVER_FREQ_CNFG = 8,
+	SABRE_HW_TOD_WR_TRIG_SEL_MSB_TOD_CNFG = 9,
+	SABRE_HW_TOD_RD_TRIG_SEL_LSB_TOD_STS = SABRE_HW_TOD_WR_TRIG_SEL_MSB_TOD_CNFG,
+	SABRE_WR_TRIG_SEL_MAX = SABRE_HW_TOD_WR_TRIG_SEL_MSB_TOD_CNFG,
 };
 
 /** @brief Enumerated type listing DPLL operational modes */
-enum dpll_state {
-	DPLL_STATE_FREERUN = 1,
-	DPLL_STATE_HOLDOVER = 2,
-	DPLL_STATE_LOCKED = 4,
-	DPLL_STATE_PRELOCKED2 = 5,
-	DPLL_STATE_PRELOCKED = 6,
-	DPLL_STATE_LOSTPHASE = 7,
-	DPLL_STATE_MAX
+enum sabre_dpll_state {
+	SABRE_DPLL_STATE_FREERUN = 1,
+	SABRE_DPLL_STATE_HOLDOVER = 2,
+	SABRE_DPLL_STATE_LOCKED = 4,
+	SABRE_DPLL_STATE_PRELOCKED2 = 5,
+	SABRE_DPLL_STATE_PRELOCKED = 6,
+	SABRE_DPLL_STATE_LOSTPHASE = 7,
+	SABRE_DPLL_STATE_MAX
 };
 
 #endif
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 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
-simply design by using only one c file suggested by Greg

 drivers/misc/Kconfig      |   8 +
 drivers/misc/Makefile     |   1 +
 drivers/misc/rsmu.c       | 536 ++++++++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/rsmu.h |  66 ++++++
 4 files changed, 611 insertions(+)
 create mode 100644 drivers/misc/rsmu.c
 create mode 100644 include/uapi/linux/rsmu.h
drivers/misc/Kconfig +8 -0
index 85ba901..6dc36f9 100644
@@ -469,6 +469,14 @@ 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 RSMU (Renesas Synchronization
+	  Management Unit) driver. 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 +1 -0
index a086197..a66e3b7 100644
@@ -59,3 +59,4 @@ obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
 obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
 obj-$(CONFIG_HI6421V600_IRQ)	+= hi6421v600-irq.o
+obj-$(CONFIG_RSMU)		+= rsmu.o
drivers/misc/rsmu.c new file +536 -0

536 lines not on this page · raw message

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

66 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 6 lines · On Wed, Sep 15, 2021 at 02:47:09PM -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.

Where is that software?

Why is this new api not a standard one?

What is the standard here?

What do other devices do and why is this a new api?

Review

Quoted 4 lines

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

Why do all of these have to be in the kernel at all?

thanks,

greg k-h

author
#3 lore raw

RE: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 14 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: September 16, 2021 1:26 AM
To: Min Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 2 lines · On Wed, Sep 15, 2021 at 02:47:09PM -0400, [email protected] wrote:

From: Min Li <[email protected]>

Quoted 7 lines
Quoted 4 lines

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.

Where is that software?

https://www.renesas.com/us/en/software-tool/ptp-clock-manager-linux

Quoted 3 lines

Why is this new api not a standard one?

There is no actual standard for the GNSS assisted partial timing support (APTS) In terms of Linux kernel API

Quoted 4 lines

What is the standard here?

What do other devices do and why is this a new api?

There is really no standard for APTS and different company has its own hw/sw solutions

Quoted 7 lines
Quoted 4 lines

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

Why do all of these have to be in the kernel at all?

Because all these API's need spi/i2c accesses to the RSMU card and spi/i2c accesses have been abstracted to the MFD driver in kernel

Quoted 3 lines

thanks,

greg k-h

maintainer
#4 lore raw

Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 18 lines · Min Li
Quoted 18 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: September 16, 2021 1:26 AM
To: Min Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 6 lines · On Wed, Sep 15, 2021 at 02:47:09PM -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

Quoted 5 lines
Quoted 3 lines

networking timing functions.

Where is that software?

https://www.renesas.com/us/en/software-tool/ptp-clock-manager-linux

Please put that link in the changelog comment and in the .c code as well so that people know where to find it.

Quoted 6 lines
Quoted 3 lines

Why is this new api not a standard one?

There is no actual standard for the GNSS assisted partial timing support (APTS) In terms of Linux kernel API

Then make one! :)

Quoted 6 lines
Quoted 4 lines

What is the standard here?

What do other devices do and why is this a new api?

There is really no standard for APTS and different company has its own hw/sw solutions

But userspace has to all deal with this in a standard way somehow, right? What libraries and apis do they interact with there?

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

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

Why do all of these have to be in the kernel at all?

Because all these API's need spi/i2c accesses to the RSMU card and spi/i2c accesses have been abstracted to the MFD driver in kernel

Why not just do this all from userspace then? You can have spi/i2c userspace code, right? Why does this have to be a kernel driver?

thanks,

greg k-h

author
#5 lore raw

RE: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 5 lines

Please put that link in the changelog comment and in the .c code as well so that people know where to find it.

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Why is this new api not a standard one?

There is no actual standard for the GNSS assisted partial timing support (APTS) In terms of Linux kernel API

Then make one! :)

Yes it is on our roadmap to do that for next release

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

What is the standard here?

What do other devices do and why is this a new api?

There is really no standard for APTS and different company has its own hw/sw solutions

But userspace has to all deal with this in a standard way somehow, right? What libraries and apis do they interact with there?

So far there is none. Some companies just use userspace driver and don't bother kernel

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

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

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Why do all of these have to be in the kernel at all?

Because all these API's need spi/i2c accesses to the RSMU card and spi/i2c accesses have been abstracted to the MFD driver in kernel

Why not just do this all from userspace then? You can have spi/i2c userspace code, right? Why does this have to be a kernel driver?

We used to do everything in userspace. But since PHC (ptp hardware clock) came along, we decided
to move the driver part to kernel. Please take a look at drivers/ptp/ptp_clockmatrix.c for reference. Recently, we have some functions like APTS that doesn't belong to PTP or anything else so we have to split those functions to RSMU misc driver and i2c/spi bus accesses to RSMU MFD driver.

maintainer
#6 lore raw

Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 8 lines · Min Li
Quoted 8 lines

Please put that link in the changelog comment and in the .c code as well so that people know where to find it.

Quoted 4 lines
Quoted 3 lines

Why is this new api not a standard one?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

There is no actual standard for the GNSS assisted partial timing support (APTS) In terms of Linux kernel API

Then make one! :)

Yes it is on our roadmap to do that for next release

Please do it for this kernel api, otherwise you have to support this for the next 20+ years as-is :(

Quoted 7 lines
Quoted 3 lines

Why not just do this all from userspace then? You can have spi/i2c userspace code, right? Why does this have to be a kernel driver?

We used to do everything in userspace. But since PHC (ptp hardware clock) came along, we decided
to move the driver part to kernel. Please take a look at drivers/ptp/ptp_clockmatrix.c for reference. Recently, we have some functions like APTS that doesn't belong to PTP or anything else so we have to split those functions to RSMU misc driver and i2c/spi bus accesses to RSMU MFD driver.

I still do not understand why this has to be a kernel driver, sorry. What exactly forces it to be that way?

thanks,

greg k-h

author
#7 lore raw

RE: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 23 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: September 16, 2021 12:05 PM
To: Min Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 11 lines · Min Li
Quoted 11 lines

Please put that link in the changelog comment and in the .c code as well so that people know where to find it.

Quoted 6 lines
Quoted 3 lines

Why is this new api not a standard one?

There is no actual standard for the GNSS assisted partial timing support (APTS) In terms of Linux kernel API

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Then make one! :)

Yes it is on our roadmap to do that for next release

Please do it for this kernel api, otherwise you have to support this for the next 20+ years as-is :(

In that case, I would have to get back to you in a few months. If you are rejecting this change due to this reason. Please tell me explicitly so that I can copy paste to my manager and that would be it. Thanks

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

Why not just do this all from userspace then? You can have spi/i2c userspace code, right? Why does this have to be a kernel driver?

We used to do everything in userspace. But since PHC (ptp hardware clock) came along, we decided to move the driver part to kernel. Please

Quoted 8 lines

take a look at drivers/ptp/ptp_clockmatrix.c for reference.

Quoted 2 lines

Recently, we have some functions like APTS that doesn't belong to PTP or anything else so we have to split those functions to RSMU misc driver

and i2c/spi bus accesses to RSMU MFD driver.

I still do not understand why this has to be a kernel driver, sorry. What exactly forces it to be that way?

That is our management decision since everyone is trying to move their driver to Linux kernel to contribute so that we don't have to release the driver to each customer separately. The customer can just grab the driver from linux

maintainer
#8 lore raw

Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 27 lines · Min Li
Quoted 27 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: September 16, 2021 12:05 PM
To: Min Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

Quoted 14 lines · Min Li
Quoted 5 lines

Please put that link in the changelog comment and in the .c code as well so that people know where to find it.

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Why is this new api not a standard one?

There is no actual standard for the GNSS assisted partial timing support (APTS) In terms of Linux kernel API

Then make one! :)

Yes it is on our roadmap to do that for next release

Quoted 7 lines
Quoted 3 lines

Please do it for this kernel api, otherwise you have to support this for the next 20+ years as-is :(

In that case, I would have to get back to you in a few months. If you are rejecting this change due to this reason. Please tell me explicitly so that I can copy paste to my manager and that would be it. Thanks

Please come up with a unified api that will work with all devices of this type, and not a one-off ioctl with random structures in it that are directly tied to the hardware.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Why not just do this all from userspace then? You can have spi/i2c userspace code, right? Why does this have to be a kernel driver?

We used to do everything in userspace. But since PHC (ptp hardware clock) came along, we decided to move the driver part to kernel. Please

take a look at drivers/ptp/ptp_clockmatrix.c for reference.

Quoted 2 lines

Recently, we have some functions like APTS that doesn't belong to PTP or anything else so we have to split those functions to RSMU misc driver

Quoted 8 lines
Quoted 5 lines

and i2c/spi bus accesses to RSMU MFD driver.

I still do not understand why this has to be a kernel driver, sorry. What exactly forces it to be that way?

That is our management decision since everyone is trying to move their driver to Linux kernel to contribute so that we don't have to release the driver to each customer separately. The customer can just grab the driver from linux

Don't use the kernel as your distribution method for things that should not belong in the kernel. There is no need for creating and maintain kernel modules for drivers that do not need to be drivers at all. That feels like you would be doing extra work here. Writing a simple userspace library for this that works for all kernel versions would be much easier.

thanks,

greg k-h

#9 lore raw

Re: [PATCH misc v2 2/2] misc: Add Renesas Synchronization Management Unit (SMU) support

In reply to [email protected]
Thank you for the patch! Perhaps something to improve:

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on soc/for-next linus/master v5.15-rc1 next-20210916] [cannot apply to lee-mfd/for-mfd-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/min-li-xe-renesas-com/mfd-rsmu-Resolve-naming-conflict-between-idt8a340_reg-h-and-idt82p33_reg-h/20210916-024925
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git d06246ebd7738bbfc581b887bc24a102450a323f
config: openrisc-randconfig-r034-20210916 (attached as .config)
compiler: or1k-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/dfbca4a07f1f8ca11b5993215ee233f7f28c1519
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review min-li-xe-renesas-com/mfd-rsmu-Resolve-naming-conflict-between-idt8a340_reg-h-and-idt82p33_reg-h/20210916-024925 git checkout dfbca4a07f1f8ca11b5993215ee233f7f28c1519
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=openrisc

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/misc/rsmu.c:54: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

* Enumerated type listing DPLL combination modes
drivers/misc/rsmu.c:65: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* An id used to identify the respective child class states.

vim +54 drivers/misc/rsmu.c

    52	
    53	/**
  > 54	 * Enumerated type listing DPLL combination modes
    55	 */
    56	enum rsmu_dpll_combomode {
    57		E_COMBOMODE_CURRENT = 0,
    58		E_COMBOMODE_FASTAVG,
    59		E_COMBOMODE_SLOWAVG,
    60		E_COMBOMODE_HOLDOVER,
    61		E_COMBOMODE_MAX
    62	};
    63	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#11 lore raw
In reply to [email protected]
Quoted 199 lines · On Wed, Sep 15, 2021 at 02:47:08PM -0400, [email protected] wrote:

From: Min Li <[email protected]>

---
Change log

(quoted diff) +0 -1
-resolve name conflicts so that rsmu misc driver can be in one c file suggested by Greg
 
 include/linux/mfd/idt82p33_reg.h | 148 ++++++++++++++++++++-------------------
 1 file changed, 75 insertions(+), 73 deletions(-)
include/linux/mfd/idt82p33_reg.h +75 -73
index 129a6c0..ded0ab8 100644
@@ -7,106 +7,108 @@
 #ifndef HAVE_IDT82P33_REG
 #define HAVE_IDT82P33_REG
 
+#define SABRE_REG_ADDR(page, offset) (((page) << 0x7) | ((offset) & 0x7f))
+
 /* Register address */
-#define DPLL1_TOD_CNFG 0x134
-#define DPLL2_TOD_CNFG 0x1B4
+#define SABRE_DPLL1_TOD_CNFG 0x134
+#define SABRE_DPLL2_TOD_CNFG 0x1B4
 
-#define DPLL1_TOD_STS 0x10B
-#define DPLL2_TOD_STS 0x18B
+#define SABRE_DPLL1_TOD_STS 0x10B
+#define SABRE_DPLL2_TOD_STS 0x18B
 
-#define DPLL1_TOD_TRIGGER 0x115
-#define DPLL2_TOD_TRIGGER 0x195
+#define SABRE_DPLL1_TOD_TRIGGER 0x115
+#define SABRE_DPLL2_TOD_TRIGGER 0x195
 
-#define DPLL1_OPERATING_MODE_CNFG 0x120
-#define DPLL2_OPERATING_MODE_CNFG 0x1A0
+#define SABRE_DPLL1_OPERATING_MODE_CNFG 0x120
+#define SABRE_DPLL2_OPERATING_MODE_CNFG 0x1A0
 
-#define DPLL1_HOLDOVER_FREQ_CNFG 0x12C
-#define DPLL2_HOLDOVER_FREQ_CNFG 0x1AC
+#define SABRE_DPLL1_HOLDOVER_FREQ_CNFG 0x12C
+#define SABRE_DPLL2_HOLDOVER_FREQ_CNFG 0x1AC
 
-#define DPLL1_PHASE_OFFSET_CNFG 0x143
-#define DPLL2_PHASE_OFFSET_CNFG 0x1C3
+#define SABRE_DPLL1_PHASE_OFFSET_CNFG 0x143
+#define SABRE_DPLL2_PHASE_OFFSET_CNFG 0x1C3
 
-#define DPLL1_SYNC_EDGE_CNFG 0x140
-#define DPLL2_SYNC_EDGE_CNFG 0x1C0
+#define SABRE_DPLL1_SYNC_EDGE_CNFG 0x140
+#define SABRE_DPLL2_SYNC_EDGE_CNFG 0x1C0
 
-#define DPLL1_INPUT_MODE_CNFG 0x116
-#define DPLL2_INPUT_MODE_CNFG 0x196
+#define SABRE_DPLL1_INPUT_MODE_CNFG 0x116
+#define SABRE_DPLL2_INPUT_MODE_CNFG 0x196
 
-#define DPLL1_OPERATING_STS 0x102
-#define DPLL2_OPERATING_STS 0x182
+#define SABRE_DPLL1_OPERATING_STS 0x102
+#define SABRE_DPLL2_OPERATING_STS 0x182
 
-#define DPLL1_CURRENT_FREQ_STS 0x103
-#define DPLL2_CURRENT_FREQ_STS 0x183
+#define SABRE_DPLL1_CURRENT_FREQ_STS 0x103
+#define SABRE_DPLL2_CURRENT_FREQ_STS 0x183
 
-#define REG_SOFT_RESET 0X381
+#define SABRE_REG_SOFT_RESET 0X381
 
-#define OUT_MUX_CNFG(outn) REG_ADDR(0x6, (0xC * (outn)))
+#define SABRE_OUT_MUX_CNFG(outn) REG_ADDR(0x6, (0xC * (outn)))
 
 /* Register bit definitions */
-#define SYNC_TOD BIT(1)
-#define PH_OFFSET_EN BIT(7)
-#define SQUELCH_ENABLE BIT(5)
+#define SABRE_SYNC_TOD BIT(1)
+#define SABRE_PH_OFFSET_EN BIT(7)
+#define SABRE_SQUELCH_ENABLE BIT(5)
 
 /* Bit definitions for the DPLL_MODE register */
-#define PLL_MODE_SHIFT		(0)
-#define PLL_MODE_MASK		(0x1F)
-#define COMBO_MODE_EN		BIT(5)
-#define COMBO_MODE_SHIFT	(6)
-#define COMBO_MODE_MASK		(0x3)
+#define SABRE_PLL_MODE_SHIFT		(0)
+#define SABRE_PLL_MODE_MASK		(0x1F)
+#define SABRE_COMBO_MODE_EN		BIT(5)
+#define SABRE_COMBO_MODE_SHIFT	(6)
+#define SABRE_COMBO_MODE_MASK		(0x3)
 
 /* Bit definitions for DPLL_OPERATING_STS register */
-#define OPERATING_STS_MASK	(0x7)
-#define OPERATING_STS_SHIFT	(0x0)
+#define SABRE_OPERATING_STS_MASK	(0x7)
+#define SABRE_OPERATING_STS_SHIFT	(0x0)
 
 /* Bit definitions for DPLL_TOD_TRIGGER register */
-#define READ_TRIGGER_MASK	(0xF)
-#define READ_TRIGGER_SHIFT	(0x0)
-#define WRITE_TRIGGER_MASK	(0xF0)
-#define WRITE_TRIGGER_SHIFT	(0x4)
+#define SABRE_READ_TRIGGER_MASK	(0xF)
+#define SABRE_READ_TRIGGER_SHIFT	(0x0)
+#define SABRE_WRITE_TRIGGER_MASK	(0xF0)
+#define SABRE_WRITE_TRIGGER_SHIFT	(0x4)
 
 /* Bit definitions for REG_SOFT_RESET register */
-#define SOFT_RESET_EN		BIT(7)
-
-enum pll_mode {
-	PLL_MODE_MIN = 0,
-	PLL_MODE_AUTOMATIC = PLL_MODE_MIN,
-	PLL_MODE_FORCE_FREERUN = 1,
-	PLL_MODE_FORCE_HOLDOVER = 2,
-	PLL_MODE_FORCE_LOCKED = 4,
-	PLL_MODE_FORCE_PRE_LOCKED2 = 5,
-	PLL_MODE_FORCE_PRE_LOCKED = 6,
-	PLL_MODE_FORCE_LOST_PHASE = 7,
-	PLL_MODE_DCO = 10,
-	PLL_MODE_WPH = 18,
-	PLL_MODE_MAX = PLL_MODE_WPH,
+#define SABRE_SOFT_RESET_EN		BIT(7)
+
+enum sabre_pll_mode {
+	SABRE_PLL_MODE_MIN = 0,
+	SABRE_PLL_MODE_AUTOMATIC = SABRE_PLL_MODE_MIN,
+	SABRE_PLL_MODE_FORCE_FREERUN = 1,
+	SABRE_PLL_MODE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RE_HW_TOD_TRIG_SEL_IN13 = 3,
+	SABRE_HW_TOD_TRIG_SEL_IN14 = 4,
+	SABRE_HW_TOD_TRIG_SEL_TOD_PPS = 5,
+	SABRE_HW_TOD_TRIG_SEL_TIMER_INTERVAL = 6,
+	SABRE_HW_TOD_TRIG_SEL_MSB_PHASE_OFFSET_CNFG = 7,
+	SABRE_HW_TOD_TRIG_SEL_MSB_HOLDOVER_FREQ_CNFG = 8,
+	SABRE_HW_TOD_WR_TRIG_SEL_MSB_TOD_CNFG = 9,
+	SABRE_HW_TOD_RD_TRIG_SEL_LSB_TOD_STS = SABRE_HW_TOD_WR_TRIG_SEL_MSB_TOD_CNFG,
+	SABRE_WR_TRIG_SEL_MAX = SABRE_HW_TOD_WR_TRIG_SEL_MSB_TOD_CNFG,
 };
 
 /** @brief Enumerated type listing DPLL operational modes */
-enum dpll_state {
-	DPLL_STATE_FREERUN = 1,
-	DPLL_STATE_HOLDOVER = 2,
-	DPLL_STATE_LOCKED = 4,
-	DPLL_STATE_PRELOCKED2 = 5,
-	DPLL_STATE_PRELOCKED = 6,
-	DPLL_STATE_LOSTPHASE = 7,
-	DPLL_STATE_MAX
+enum sabre_dpll_state {
+	SABRE_DPLL_STATE_FREERUN = 1,
+	SABRE_DPLL_STATE_HOLDOVER = 2,
+	SABRE_DPLL_STATE_LOCKED = 4,
+	SABRE_DPLL_STATE_PRELOCKED2 = 5,
+	SABRE_DPLL_STATE_PRELOCKED = 6,
+	SABRE_DPLL_STATE_LOSTPHASE = 7,
+	SABRE_DPLL_STATE_MAX
 };
 
 #endif
Signature · 1 line
2.7.4

Wait, how can this patch on its own not break things? Are there no in-kernel users of these symbols today? If not, why is this file in here?

confused,

greg k-h

author
#12 lore raw
Quoted 9 lines
Quoted 1 line

Wait, how can this patch on its own not break things? Are there no in-kernel users of these symbols today? If not, why is this file in here?

confused,

greg k-h

Yes, it is standalone now but it would be used by this driver and another PHC driver that I will submit later.

This file provides register definitions and belongs to the MFD change I submitted before. The MFD driver will spawn 2 devices

1) ptp hardware clock device
2) This RSMU misc device

The plan is

1) submit mfd change
2) submit misc change
3) submit phc change

Min