1f0d4ba9eSKamil Alkhouri /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 2f0d4ba9eSKamil Alkhouri /* 3f0d4ba9eSKamil Alkhouri * DSA driver for: 4f0d4ba9eSKamil Alkhouri * Hirschmann Hellcreek TSN switch. 5f0d4ba9eSKamil Alkhouri * 6f0d4ba9eSKamil Alkhouri * Copyright (C) 2019,2020 Hochschule Offenburg 7f0d4ba9eSKamil Alkhouri * Copyright (C) 2019,2020 Linutronix GmbH 8f0d4ba9eSKamil Alkhouri * Authors: Kurt Kanzenbach <kurt@linutronix.de> 9f0d4ba9eSKamil Alkhouri * Kamil Alkhouri <kamil.alkhouri@hs-offenburg.de> 10f0d4ba9eSKamil Alkhouri */ 11f0d4ba9eSKamil Alkhouri 12f0d4ba9eSKamil Alkhouri #ifndef _HELLCREEK_HWTSTAMP_H_ 13f0d4ba9eSKamil Alkhouri #define _HELLCREEK_HWTSTAMP_H_ 14f0d4ba9eSKamil Alkhouri 15f0d4ba9eSKamil Alkhouri #include <net/dsa.h> 16f0d4ba9eSKamil Alkhouri #include "hellcreek.h" 17f0d4ba9eSKamil Alkhouri 18f0d4ba9eSKamil Alkhouri /* Timestamp Register */ 19f0d4ba9eSKamil Alkhouri #define PR_TS_RX_P1_STATUS_C (0x1d * 2) 20f0d4ba9eSKamil Alkhouri #define PR_TS_RX_P1_DATA_C (0x1e * 2) 21f0d4ba9eSKamil Alkhouri #define PR_TS_TX_P1_STATUS_C (0x1f * 2) 22f0d4ba9eSKamil Alkhouri #define PR_TS_TX_P1_DATA_C (0x20 * 2) 23f0d4ba9eSKamil Alkhouri #define PR_TS_RX_P2_STATUS_C (0x25 * 2) 24f0d4ba9eSKamil Alkhouri #define PR_TS_RX_P2_DATA_C (0x26 * 2) 25f0d4ba9eSKamil Alkhouri #define PR_TS_TX_P2_STATUS_C (0x27 * 2) 26f0d4ba9eSKamil Alkhouri #define PR_TS_TX_P2_DATA_C (0x28 * 2) 27f0d4ba9eSKamil Alkhouri 28f0d4ba9eSKamil Alkhouri #define PR_TS_STATUS_TS_AVAIL BIT(2) 29f0d4ba9eSKamil Alkhouri #define PR_TS_STATUS_TS_LOST BIT(3) 30f0d4ba9eSKamil Alkhouri 31f0d4ba9eSKamil Alkhouri #define SKB_PTP_TYPE(__skb) (*(unsigned int *)((__skb)->cb)) 32f0d4ba9eSKamil Alkhouri 33f0d4ba9eSKamil Alkhouri /* TX_TSTAMP_TIMEOUT: This limits the time spent polling for a TX 34f0d4ba9eSKamil Alkhouri * timestamp. When working properly, hardware will produce a timestamp 35f0d4ba9eSKamil Alkhouri * within 1ms. Software may enounter delays, so the timeout is set 36f0d4ba9eSKamil Alkhouri * accordingly. 37f0d4ba9eSKamil Alkhouri */ 38f0d4ba9eSKamil Alkhouri #define TX_TSTAMP_TIMEOUT msecs_to_jiffies(40) 39f0d4ba9eSKamil Alkhouri 40f0d4ba9eSKamil Alkhouri int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port, 41f0d4ba9eSKamil Alkhouri struct ifreq *ifr); 42f0d4ba9eSKamil Alkhouri int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port, 43f0d4ba9eSKamil Alkhouri struct ifreq *ifr); 44f0d4ba9eSKamil Alkhouri 45f0d4ba9eSKamil Alkhouri bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port, 46f0d4ba9eSKamil Alkhouri struct sk_buff *clone, unsigned int type); 47*5c5416f5SYangbo Lu void hellcreek_port_txtstamp(struct dsa_switch *ds, int port, 48*5c5416f5SYangbo Lu struct sk_buff *skb); 49f0d4ba9eSKamil Alkhouri 50f0d4ba9eSKamil Alkhouri int hellcreek_get_ts_info(struct dsa_switch *ds, int port, 51f0d4ba9eSKamil Alkhouri struct ethtool_ts_info *info); 52f0d4ba9eSKamil Alkhouri 53f0d4ba9eSKamil Alkhouri long hellcreek_hwtstamp_work(struct ptp_clock_info *ptp); 54f0d4ba9eSKamil Alkhouri 55f0d4ba9eSKamil Alkhouri int hellcreek_hwtstamp_setup(struct hellcreek *chip); 56f0d4ba9eSKamil Alkhouri void hellcreek_hwtstamp_free(struct hellcreek *chip); 57f0d4ba9eSKamil Alkhouri 58f0d4ba9eSKamil Alkhouri #endif /* _HELLCREEK_HWTSTAMP_H_ */ 59