Skip to contentSkip to conversation

misc: Add Renesas Synchronization Management Unit (SMU) support

PATCH In review [email protected] 3 participants 7 messages Mar 26, 2021 – Apr 3, 2021 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 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

 drivers/misc/Kconfig      |   9 ++
 drivers/misc/Makefile     |   2 +
 drivers/misc/rsmu_cdev.c  | 321 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/rsmu_cdev.h  |  72 +++++++++++
 drivers/misc/rsmu_cm.c    | 166 ++++++++++++++++++++++++
 drivers/misc/rsmu_sabre.c | 128 ++++++++++++++++++
 include/uapi/linux/rsmu.h |  64 +++++++++
 7 files changed, 762 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 +321 -0

321 lines not on this page · raw message

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

72 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 +128 -0

128 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
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210326]

url:    https://github.com/0day-ci/linux/commits/min-li-xe-renesas-com/mfd-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210327-150316
base:    931294922e65a23e1aad6398b9ae02df74044679
config: x86_64-randconfig-r036-20210327 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/0719d3e2c97f4073f3b495311f260c6c3e0dda28
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review min-li-xe-renesas-com/mfd-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210327-150316
        git checkout 0719d3e2c97f4073f3b495311f260c6c3e0dda28
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

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

All errors (new ones prefixed by >>):

ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_get_dpll_ffo':

>> drivers/misc/rsmu_cm.c:148: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_get_dpll_state':
   drivers/misc/rsmu_cm.c:80: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_set_combomode':
   drivers/misc/rsmu_cm.c:56: undefined reference to `rsmu_read'
>> ld: drivers/misc/rsmu_cm.c:67: undefined reference to `rsmu_write'
   ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_get_dpll_ffo':
>> drivers/misc/rsmu_sabre.c:110: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_get_dpll_state':
   drivers/misc/rsmu_sabre.c:65: undefined reference to `rsmu_read'
   ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_set_combomode':
   drivers/misc/rsmu_sabre.c:38: undefined reference to `rsmu_read'
>> ld: drivers/misc/rsmu_sabre.c:45: undefined reference to `rsmu_write'

vim +148 drivers/misc/rsmu_cm.c

    17	
    18	static int rsmu_cm_set_combomode(struct rsmu_cdev *rsmu, u8 dpll, u8 mode)
    19	{
    20		u16 dpll_ctrl_n;
    21		u8 cfg;
    22		int err;
    23	
    24		switch (dpll) {
    25		case 0:
    26			dpll_ctrl_n = DPLL_CTRL_0;
    27			break;
    28		case 1:
    29			dpll_ctrl_n = DPLL_CTRL_1;
    30			break;
    31		case 2:
    32			dpll_ctrl_n = DPLL_CTRL_2;
    33			break;
    34		case 3:
    35			dpll_ctrl_n = DPLL_CTRL_3;
    36			break;
    37		case 4:
    38			dpll_ctrl_n = DPLL_CTRL_4;
    39			break;
    40		case 5:
    41			dpll_ctrl_n = DPLL_CTRL_5;
    42			break;
    43		case 6:
    44			dpll_ctrl_n = DPLL_CTRL_6;
    45			break;
    46		case 7:
    47			dpll_ctrl_n = DPLL_CTRL_7;
    48			break;
    49		default:
    50			return -EINVAL;
    51		}
    52	
    53		if (mode >= E_COMBOMODE_MAX)
    54			return -EINVAL;
    55	
    56		err = rsmu_read(rsmu->mfd, dpll_ctrl_n + DPLL_CTRL_COMBO_MASTER_CFG,
    57				&cfg, sizeof(cfg));
    58		if (err)
    59			return err;
    60	
    61		/* Only need to enable/disable COMBO_MODE_HOLD. */
    62		if (mode)
    63			cfg |= COMBO_MASTER_HOLD;
    64		else
    65			cfg &= ~COMBO_MASTER_HOLD;
    66	
  > 67		return rsmu_write(rsmu->mfd, dpll_ctrl_n + DPLL_CTRL_COMBO_MASTER_CFG,
    68				  &cfg, sizeof(cfg));
    69	}
    70	
    71	static int rsmu_cm_get_dpll_state(struct rsmu_cdev *rsmu, u8 dpll, u8 *state)
    72	{
    73		u8 cfg;
    74		int err;
    75	
    76		/* 8 is sys dpll */
    77		if (dpll > 8)
    78			return -EINVAL;
    79	
    80		err = rsmu_read(rsmu->mfd,
    81				  STATUS + DPLL0_STATUS + dpll,
    82				  &cfg, sizeof(cfg));
    83		if (err)
    84			return err;
    85	
    86		switch (cfg & DPLL_STATE_MASK) {
    87		case DPLL_STATE_FREERUN:
    88			*state = E_SRVLOUNQUALIFIEDSTATE;
    89			break;
    90		case DPLL_STATE_LOCKACQ:
    91		case DPLL_STATE_LOCKREC:
    92			*state = E_SRVLOLOCKACQSTATE;
    93			break;
    94		case DPLL_STATE_LOCKED:
    95			*state = E_SRVLOTIMELOCKEDSTATE;
    96			break;
    97		case DPLL_STATE_HOLDOVER:
    98			*state = E_SRVLOHOLDOVERINSPECSTATE;
    99			break;
   100		default:
   101			*state = E_SRVLOSTATEINVALID;
   102			break;
   103		}
   104	
   105		return 0;
   106	}
   107	
   108	static int rsmu_cm_get_dpll_ffo(struct rsmu_cdev *rsmu, u8 dpll,
   109					struct rsmu_get_ffo *ffo)
   110	{
   111		u8 buf[8] = {0};
   112		s64 fcw = 0;
   113		u16 dpll_filter_status;
   114		int err;
   115	
   116		switch (dpll) {
   117		case 0:
   118			dpll_filter_status = DPLL0_FILTER_STATUS;
   119			break;
   120		case 1:
   121			dpll_filter_status = DPLL1_FILTER_STATUS;
   122			break;
   123		case 2:
   124			dpll_filter_status = DPLL2_FILTER_STATUS;
   125			break;
   126		case 3:
   127			dpll_filter_status = DPLL3_FILTER_STATUS;
   128			break;
   129		case 4:
   130			dpll_filter_status = DPLL4_FILTER_STATUS;
   131			break;
   132		case 5:
   133			dpll_filter_status = DPLL5_FILTER_STATUS;
   134			break;
   135		case 6:
   136			dpll_filter_status = DPLL6_FILTER_STATUS;
   137			break;
   138		case 7:
   139			dpll_filter_status = DPLL7_FILTER_STATUS;
   140			break;
   141		case 8:
   142			dpll_filter_status = DPLLSYS_FILTER_STATUS;
   143			break;
   144		default:
   145			return -EINVAL;
   146		}
   147	
 > 148		err = rsmu_read(rsmu->mfd, STATUS + dpll_filter_status, buf, 6);

149 if (err)
150 return err;
151
152 /* Convert to frequency control word */
153 fcw = sign_extend64(get_unaligned_le64(buf), 47);
154
155 /* FCW unit is 2 ^ -53 = 1.1102230246251565404236316680908e-16 */
156 ffo->ffo = fcw * 111;
157
158 return 0;
159 }
160

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

#2 lore raw
In reply to [email protected]
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210326]

url:    https://github.com/0day-ci/linux/commits/min-li-xe-renesas-com/mfd-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210327-150316
base:    931294922e65a23e1aad6398b9ae02df74044679
config: microblaze-randconfig-r003-20210327 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.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/0719d3e2c97f4073f3b495311f260c6c3e0dda28
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review min-li-xe-renesas-com/mfd-Add-Renesas-Synchronization-Management-Unit-SMU-support/20210327-150316 git checkout 0719d3e2c97f4073f3b495311f260c6c3e0dda28
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze

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

All errors (new ones prefixed by >>):

microblaze-linux-ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_get_dpll_ffo':

>> (.text+0xb4): undefined reference to `rsmu_read'
   microblaze-linux-ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_get_dpll_state':
   (.text+0x52c): undefined reference to `rsmu_read'
   microblaze-linux-ld: drivers/misc/rsmu_cm.o: in function `rsmu_cm_set_combomode':
   (.text+0x7c0): undefined reference to `rsmu_read'
>> microblaze-linux-ld: (.text+0x87c): undefined reference to `rsmu_write'

microblaze-linux-ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_get_dpll_state':
(.text+0xd0): undefined reference to `rsmu_read'
microblaze-linux-ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_get_dpll_ffo':
(.text+0x388): undefined reference to `rsmu_read'
microblaze-linux-ld: drivers/misc/rsmu_sabre.o: in function `rsmu_sabre_set_combomode':
(.text+0x714): undefined reference to `rsmu_read'
microblaze-linux-ld: (.text+0x7ac): undefined reference to `rsmu_write'

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

maintainer
#3 lore raw
In reply to [email protected]
Quoted 15 lines · On Fri, Mar 26, 2021 at 11:34:11AM -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

Review

Quoted 3 lines
(quoted diff) +0 -3
-rebase change to linux-next tree
-remove uncessary condition checks suggested by Greg
-fix compile error for x86_64

Where is patch 1/2 of this series?

Also, please fix up the errors that the testing bot found, and properly version your patch submission so I know which one is the "latest" one to look at.

thanks,

greg k-h

author
#4 lore raw
Quoted 6 lines

Where is patch 1/2 of this series?

Also, please fix up the errors that the testing bot found, and properly version your patch submission so I know which one is the "latest" one to look at.

Hi Greg

The first patch is mfd so I was not sure if I should send that to you guys in the first place.

Anyways, I just sent it over.

Min

maintainer
#5 lore raw
Quoted 10 lines · Min Li
Quoted 6 lines

Where is patch 1/2 of this series?

Also, please fix up the errors that the testing bot found, and properly version your patch submission so I know which one is the "latest" one to look at.

Hi Greg

The first patch is mfd so I was not sure if I should send that to you guys in the first place.

Then the patches are independant and they should be sent as such, otherwise it causes confusion and our tools get messed up when trying to grab the whole "series" of patches.

Can you please fix this up and just send two independant patches?

thanks,

greg k-h

author
#6 lore raw
Quoted 8 lines

Then the patches are independant and they should be sent as such, otherwise it causes confusion and our tools get messed up when trying to grab the whole "series" of patches.

Can you please fix this up and just send two independant patches?

Hi Greg

These 2 patches are not independent. Patch 2/2 depends on patch 1/2 to build and work successfully. They just belong to different domain, patch 1/2 belongs to MFD while patch 2/2 belongs to MISC.
That is why I wasn't sure if I should send both patches to you in the first place. Anyways, I just sent both patches again.

Thanks

Min