Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
0002 /*
0003  * DSA driver for:
0004  * Hirschmann Hellcreek TSN switch.
0005  *
0006  * Copyright (C) 2019,2020 Hochschule Offenburg
0007  * Copyright (C) 2019,2020 Linutronix GmbH
0008  * Authors: Kurt Kanzenbach <kurt@linutronix.de>
0009  *      Kamil Alkhouri <kamil.alkhouri@hs-offenburg.de>
0010  */
0011 
0012 #ifndef _HELLCREEK_HWTSTAMP_H_
0013 #define _HELLCREEK_HWTSTAMP_H_
0014 
0015 #include <net/dsa.h>
0016 #include "hellcreek.h"
0017 
0018 /* Timestamp Register */
0019 #define PR_TS_RX_P1_STATUS_C    (0x1d * 2)
0020 #define PR_TS_RX_P1_DATA_C  (0x1e * 2)
0021 #define PR_TS_TX_P1_STATUS_C    (0x1f * 2)
0022 #define PR_TS_TX_P1_DATA_C  (0x20 * 2)
0023 #define PR_TS_RX_P2_STATUS_C    (0x25 * 2)
0024 #define PR_TS_RX_P2_DATA_C  (0x26 * 2)
0025 #define PR_TS_TX_P2_STATUS_C    (0x27 * 2)
0026 #define PR_TS_TX_P2_DATA_C  (0x28 * 2)
0027 
0028 #define PR_TS_STATUS_TS_AVAIL   BIT(2)
0029 #define PR_TS_STATUS_TS_LOST    BIT(3)
0030 
0031 #define SKB_PTP_TYPE(__skb) (*(unsigned int *)((__skb)->cb))
0032 
0033 /* TX_TSTAMP_TIMEOUT: This limits the time spent polling for a TX
0034  * timestamp. When working properly, hardware will produce a timestamp
0035  * within 1ms. Software may enounter delays, so the timeout is set
0036  * accordingly.
0037  */
0038 #define TX_TSTAMP_TIMEOUT   msecs_to_jiffies(40)
0039 
0040 int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port,
0041                 struct ifreq *ifr);
0042 int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port,
0043                 struct ifreq *ifr);
0044 
0045 bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port,
0046                  struct sk_buff *clone, unsigned int type);
0047 void hellcreek_port_txtstamp(struct dsa_switch *ds, int port,
0048                  struct sk_buff *skb);
0049 
0050 int hellcreek_get_ts_info(struct dsa_switch *ds, int port,
0051               struct ethtool_ts_info *info);
0052 
0053 long hellcreek_hwtstamp_work(struct ptp_clock_info *ptp);
0054 
0055 int hellcreek_hwtstamp_setup(struct hellcreek *chip);
0056 void hellcreek_hwtstamp_free(struct hellcreek *chip);
0057 
0058 #endif /* _HELLCREEK_HWTSTAMP_H_ */