Stmmac: fix for hw timestamp of GMAC 3 unit

From: Mario Molitor
Date: Mon Jun 05 2017 - 18:11:50 EST


Dear stmmac maintainer group,

I have found an problem in stmmac driver of linux kernel and I hope for a fix in the mainline kernel.
At the moment I have two patch files which fix this problem for me.
The problem seems created with the commit d2042052a0aa6a54f01a0c9e14243ec040b100e2 and ba1ffd74df74a9efa5290f87632a0ed55f1aa387 has breakage the functionality of GMAC3 unit.
I assume that these commits were only tested with a GMAC4 unit.
I have got seen this problem with execution of ptp4l daemon on system with linux 4.11 Kernel.

===============================================================================
root@QuantumXsoc:~ ptp4l -f /etc/ptp.cfg -i eth0 -m
ptp4l[47.928]: selected /dev/ptp0 as PTP clock
ptp4l[47.937]: port 1: INITIALIZING to LISTENING on INITIALIZE
ptp4l[47.938]: port 0: INITIALIZING to LISTENING on INITIALIZE
ptp4l[47.938]: port 1: link up
[ 48.282709] socfpga-dwmac ff702000.ethernet eth0: get valid RX hw timestamp 0
[ 48.316316] socfpga-dwmac ff702000.ethernet eth0: get valid RX hw timestamp 0
[ 48.340260] socfpga-dwmac ff702000.ethernet eth0: get valid RX hw timestamp 0
[ 48.456738] socfpga-dwmac ff702000.ethernet eth0: get valid RX hw timestamp 0
ptp4l[48.457]: port 1: received DELAY_REQ without timestamp
[ 48.488442] socfpga-dwmac ff702000.ethernet eth0: get valid RX hw timestamp 0
[ 48.495599] socfpga-dwmac ff702000.ethernet eth0: get valid RX hw timestamp 0
ptp4l[48.489]: port 1: received SYNC without timestamp
....
================================================================================

I have found two kind of problems and for this two patches (based on the 4.11 kernel) which fix this problem.

1.) PTP_TCR_SNAPTYPSEL_1

The first problem was for my point of view the change of definition PTP_TCR_SNAPTYPSEL_1. I think according the
CYCLON V documention only the bit 16 of snaptypesel should be set. (more information see Table 17-20 (cv_5v4.pdf) : Timestamp Snapshot Dependency on Register Bits)
I believe that the GMAC4 have another necessary definition.

( patch 0001-stmmac-fix-ptp-header-for-GMAC3-hw-timestamp.patch )
================================================================================================