Skip to contentSkip to conversation

ice: add support for auxiliary input/output pins

PATCH New Jacob Keller 3 participants 5 messages Jun 9, 2021 – Jun 16, 2021

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

PATCH 1/1 ice: add support for auxiliary input/output pins

From: Maciej Machnikowski <[email protected]>

The E810 device supports programmable pins for enabling both input and output events related to the PTP hardware clock. This includes both output signals with programmable period, as well as timestamping of events on input pins.

Add support for enabling these using the CONFIG_PTP_1588_CLOCK interface.

This allows programming the software defined pins to take advantage of the hardware clock features.

---

This applies on top of the v2 PTP series that Tony just posted. It adds support for the basic GPIO pins that the device supports.

 .../net/ethernet/intel/ice/ice_hw_autogen.h   |  18 ++
 drivers/net/ethernet/intel/ice/ice_main.c     |  12 +
 drivers/net/ethernet/intel/ice/ice_ptp.c      | 292 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_ptp.h      |  43 +++
 4 files changed, 365 insertions(+)
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +18 -0
index 6989a76c42a7..76021d977b60 100644
@@ -138,6 +138,10 @@
 #define GLGEN_CLKSTAT_SRC_PSM_CLK_SRC_S		4
 #define GLGEN_CLKSTAT_SRC_PSM_CLK_SRC_M		ICE_M(0x3, 4)
 #define GLGEN_CLKSTAT_SRC			0x000B826C
+#define GLGEN_GPIO_CTL(_i)			(0x000880C8 + ((_i) * 4))
+#define GLGEN_GPIO_CTL_PIN_DIR_M		BIT(4)
+#define GLGEN_GPIO_CTL_PIN_FUNC_S		8
+#define GLGEN_GPIO_CTL_PIN_FUNC_M		ICE_M(0xF, 8)
 #define GLGEN_RSTAT				0x000B8188
 #define GLGEN_RSTAT_DEVSTATE_M			ICE_M(0x3, 0)
 #define GLGEN_RSTCTL				0x000B8180
@@ -203,6 +207,7 @@
 #define PFINT_MBX_CTL_CAUSE_ENA_M		BIT(30)
 #define PFINT_OICR				0x0016CA00
 #define PFINT_OICR_TSYN_TX_M			BIT(11)
+#define PFINT_OICR_TSYN_EVNT_M			BIT(12)
 #define PFINT_OICR_ECC_ERR_M			BIT(16)
 #define PFINT_OICR_MAL_DETECT_M			BIT(19)
 #define PFINT_OICR_GRST_M			BIT(20)
@@ -434,10 +439,18 @@
 #define GLV_UPRCL(_i)				(0x003B2000 + ((_i) * 8))
 #define GLV_UPTCL(_i)				(0x0030A000 + ((_i) * 8))
 #define PRTRPB_RDPC				0x000AC260
+#define GLTSYN_AUX_IN_0(_i)			(0x000889D8 + ((_i) * 4))
+#define GLTSYN_AUX_IN_0_INT_ENA_M		BIT(4)
+#define GLTSYN_AUX_OUT_0(_i)			(0x00088998 + ((_i) * 4))
+#define GLTSYN_AUX_OUT_0_OUT_ENA_M		BIT(0)
+#define GLTSYN_AUX_OUT_0_OUTMOD_M		ICE_M(0x3, 1)
+#define GLTSYN_CLKO_0(_i)			(0x000889B8 + ((_i) * 4))
 #define GLTSYN_CMD				0x00088810
 #define GLTSYN_CMD_SYNC				0x00088814
 #define GLTSYN_ENA(_i)				(0x00088808 + ((_i) * 4))
 #define GLTSYN_ENA_TSYN_ENA_M			BIT(0)
+#define GLTSYN_EVNT_H_0(_i)			(0x00088970 + ((_i) * 4))
+#define GLTSYN_EVNT_L_0(_i)			(0x00088968 + ((_i) * 4))
 #define GLTSYN_INCVAL_H(_i)			(0x00088920 + ((_i) * 4))
 #define GLTSYN_INCVAL_L(_i)			(0x00088918 + ((_i) * 4))
 #define GLTSYN_SHADJ_H(_i)			(0x00088910 + ((_i) * 4))
@@ -446,7 +459,12 @@
 #define GLTSYN_SHTIME_H(_i)			(0x000888F0 + ((_i) * 4))
 #define GLTSYN_SHTIME_L(_i)			(0x000888E8 + ((_i) * 4))
 #define GLTSYN_STAT(_i)				(0x000888C0 + ((_i) * 4))
+#define GLTSYN_STAT_EVENT0_M			BIT(0)
+#define GLTSYN_STAT_EVENT1_M			BIT(1)
+#define GLTSYN_STAT_EVENT2_M			BIT(2)
 #define GLTSYN_SYNC_DLAY			0x00088818
+#define GLTSYN_TGT_H_0(_i)			(0x00088930 + ((_i) * 4))
+#define GLTSYN_TGT_L_0(_i)			(0x00088928 + ((_i) * 4))
 #define GLTSYN_TIME_H(_i)			(0x000888D8 + ((_i) * 4))
 #define GLTSYN_TIME_L(_i)			(0x000888D0 + ((_i) * 4))
 #define PFTSYN_SEM				0x00088880
drivers/net/ethernet/intel/ice/ice_main.c +12 -0
index d0eb158e3e2d..ff057bdc96e2 100644
@@ -2832,6 +2832,18 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
 		ice_ptp_process_ts(pf);
 	}
 
+	if (oicr & PFINT_OICR_TSYN_EVNT_M) {
+		u8 tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned;
+		u32 gltsyn_stat = rd32(hw, GLTSYN_STAT(tmr_idx));
+
+		/* Save EVENTs from GTSYN register */
+		pf->ptp.ext_ts_irq |= gltsyn_stat & (GLTSYN_STAT_EVENT0_M |
+						     GLTSYN_STAT_EVENT1_M |
+						     GLTSYN_STAT_EVENT2_M);
+		ena_mask &= ~PFINT_OICR_TSYN_EVNT_M;
+		kthread_queue_work(pf->ptp.kworker, &pf->ptp.extts_work);
+	}
+
 #define ICE_AUX_CRIT_ERR (PFINT_OICR_PE_CRITERR_M | PFINT_OICR_HMC_ERR_M | PFINT_OICR_PE_PUSH_M)
 	if (oicr & ICE_AUX_CRIT_ERR) {
 		struct iidc_event *event;
drivers/net/ethernet/intel/ice/ice_ptp.c +292 -0

328 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_ptp.h +43 -0

75 lines not on this page · raw message

base-commit: afcc4ad3acede542d2b26689f3652b7b43db47f6

Signature · 1 line
2.31.1.331.gb0c09ab8796f
#1 lore raw

PATCH 1/1 ice: add support for auxiliary input/output pins

Quoted 11 lines · Jacob Keller

From: Maciej Machnikowski <[email protected]>

The E810 device supports programmable pins for enabling both input and
output events related to the PTP hardware clock. This includes both output signals with programmable period, as well as timestamping of events on input pins.

Add support for enabling these using the CONFIG_PTP_1588_CLOCK interface.

Quoted 7 lines

This allows programming the software defined pins to take advantage of
the hardware clock features.

---

I'm seeing this for a 32bit build:

Quoted 2 lines

make[2]: *** Deleting file 'modules-only.symvers'
ERROR: modpost: "__udivdi3" [drivers/net/ethernet/intel/ice/ice.ko]

undefined!

Quoted 1 line

ERROR: modpost: "__umoddi3" [drivers/net/ethernet/intel/ice/ice.ko]

undefined!

Quoted 1 line

make[2]: *** [../scripts/Makefile.modpost:150: modules-only.symvers]

Error 1

Quoted 2 lines

make[1]: *** [/next-queue/Makefile:1754: modules] Error 2
make: *** [Makefile:215: __sub-make] Error 2

#2 lore raw

PATCH 1/1 ice: add support for auxiliary input/output pins

Quoted 22 lines · Anthony L
Quoted 11 lines · Jacob Keller

From: Maciej Machnikowski <[email protected]>

The E810 device supports programmable pins for enabling both input and
output events related to the PTP hardware clock. This includes both output signals with programmable period, as well as timestamping of events on input pins.

Add support for enabling these using the CONFIG_PTP_1588_CLOCK interface.

Quoted 7 lines

This allows programming the software defined pins to take advantage of
the hardware clock features.

---

I'm seeing this for a 32bit build:

Quoted 10 lines
Quoted 2 lines

make[2]: *** Deleting file 'modules-only.symvers'
ERROR: modpost: "__udivdi3" [drivers/net/ethernet/intel/ice/ice.ko]

undefined!

Quoted 1 line

ERROR: modpost: "__umoddi3" [drivers/net/ethernet/intel/ice/ice.ko]

undefined!

Quoted 1 line

make[2]: *** [../scripts/Makefile.modpost:150: modules-only.symvers]

Error 1

Quoted 2 lines

make[1]: *** [/next-queue/Makefile:1754: modules] Error 2
make: *** [Makefile:215: __sub-make] Error 2

I'm not certain which divisions are causing problems, but I suspect it is the roundup() macro and/or some of the % modulo operations.

#3 lore raw

PATCH 1/1 ice: add support for auxiliary input/output pins

Quoted 40 lines

-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Monday, June 14, 2021 7:26 PM
To: Nguyen, Anthony L <[email protected]>; intel-wired- lan at lists.osuosl.org
Cc: Machnikowski, Maciej <[email protected]>
Subject: Re: [PATCH] ice: add support for auxiliary input/output pins

Quoted 27 lines · Anthony L
Quoted 11 lines · Jacob Keller

From: Maciej Machnikowski <[email protected]>

The E810 device supports programmable pins for enabling both input and
output events related to the PTP hardware clock. This includes both output signals with programmable period, as well as timestamping of events on input pins.

Add support for enabling these using the CONFIG_PTP_1588_CLOCK interface.

Quoted 7 lines

This allows programming the software defined pins to take advantage of
the hardware clock features.

---

I'm seeing this for a 32bit build:

Quoted 2 lines

make[2]: *** Deleting file 'modules-only.symvers'
ERROR: modpost: "__udivdi3" [drivers/net/ethernet/intel/ice/ice.ko]

undefined!

Quoted 1 line

ERROR: modpost: "__umoddi3" [drivers/net/ethernet/intel/ice/ice.ko]

undefined!

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

make[2]: *** [../scripts/Makefile.modpost:150: modules-only.symvers]

Error 1

Quoted 2 lines

make[1]: *** [/next-queue/Makefile:1754: modules] Error 2
make: *** [Makefile:215: __sub-make] Error 2

I'm not certain which divisions are causing problems, but I suspect it is the roundup() macro and/or some of the % modulo operations.

This patch should fix that issue. It removes all of the built-in operations done on u64. Let me know if it works.

Regards
Maciek
Intel Technology Poland sp. z o.o.
ul. Sowackiego 173 | 80-298 Gdask | Sd Rejonowy Gdask Pnoc | VII Wydzia Gospodarczy Krajowego Rejestru Sdowego - KRS 101882 | NIP 957-07-52-316 | Kapita zakadowy 200.000 PLN.
Ta wiadomo wraz z zacznikami jest przeznaczona dla okrelonego adresata i moe zawiera informacje poufne. W razie przypadkowego otrzymania tej wiadomoci, prosimy o powiadomienie nadawcy oraz trwae jej usunicie; jakiekolwiek przegldanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited. -------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ice-Fix-phase-calculation-in-ice_ptp_cfg_clkout.patch
Type: application/octet-stream
Size: 2132 bytes
Desc: 0001-ice-Fix-phase-calculation-in-ice_ptp_cfg_clkout.patch
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20210615/e9ebd089/attachment-0001.obj>

#4 lore raw
In reply to Jacob Keller
Thank you for the patch! Yet something to improve:

Hi Jacob,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on afcc4ad3acede542d2b26689f3652b7b43db47f6]

url:    https://github.com/0day-ci/linux/commits/Jacob-Keller/ice-add-support-for-auxiliary-input-output-pins/20210616-120551
base:   afcc4ad3acede542d2b26689f3652b7b43db47f6
config: arm-allyesconfig (attached as .config)
compiler: arm-linux-gnueabi-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/5bbbbb21797a206fd7f6a44845ad6c527ea12598
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jacob-Keller/ice-add-support-for-auxiliary-input-output-pins/20210616-120551 git checkout 5bbbbb21797a206fd7f6a44845ad6c527ea12598
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm

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

All errors (new ones prefixed by >>):

arm-linux-gnueabi-ld: drivers/net/ethernet/intel/ice/ice_ptp.o: in function `ice_ptp_gpio_enable_e810':

>> ice_ptp.c:(.text+0x1634): undefined reference to `__aeabi_uldivmod'
>> arm-linux-gnueabi-ld: ice_ptp.c:(.text+0x1660): undefined reference to `__aeabi_uldivmod'

arm-linux-gnueabi-ld: ice_ptp.c:(.text+0x178c): undefined reference to `__aeabi_uldivmod'

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