162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * DSA driver for: 462306a36Sopenharmony_ci * Hirschmann Hellcreek TSN switch. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 2019,2020 Hochschule Offenburg 762306a36Sopenharmony_ci * Copyright (C) 2019,2020 Linutronix GmbH 862306a36Sopenharmony_ci * Authors: Kurt Kanzenbach <kurt@linutronix.de> 962306a36Sopenharmony_ci * Kamil Alkhouri <kamil.alkhouri@hs-offenburg.de> 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef _HELLCREEK_HWTSTAMP_H_ 1362306a36Sopenharmony_ci#define _HELLCREEK_HWTSTAMP_H_ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include <net/dsa.h> 1662306a36Sopenharmony_ci#include "hellcreek.h" 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* Timestamp Register */ 1962306a36Sopenharmony_ci#define PR_TS_RX_P1_STATUS_C (0x1d * 2) 2062306a36Sopenharmony_ci#define PR_TS_RX_P1_DATA_C (0x1e * 2) 2162306a36Sopenharmony_ci#define PR_TS_TX_P1_STATUS_C (0x1f * 2) 2262306a36Sopenharmony_ci#define PR_TS_TX_P1_DATA_C (0x20 * 2) 2362306a36Sopenharmony_ci#define PR_TS_RX_P2_STATUS_C (0x25 * 2) 2462306a36Sopenharmony_ci#define PR_TS_RX_P2_DATA_C (0x26 * 2) 2562306a36Sopenharmony_ci#define PR_TS_TX_P2_STATUS_C (0x27 * 2) 2662306a36Sopenharmony_ci#define PR_TS_TX_P2_DATA_C (0x28 * 2) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define PR_TS_STATUS_TS_AVAIL BIT(2) 2962306a36Sopenharmony_ci#define PR_TS_STATUS_TS_LOST BIT(3) 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define SKB_PTP_TYPE(__skb) (*(unsigned int *)((__skb)->cb)) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* TX_TSTAMP_TIMEOUT: This limits the time spent polling for a TX 3462306a36Sopenharmony_ci * timestamp. When working properly, hardware will produce a timestamp 3562306a36Sopenharmony_ci * within 1ms. Software may enounter delays, so the timeout is set 3662306a36Sopenharmony_ci * accordingly. 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_ci#define TX_TSTAMP_TIMEOUT msecs_to_jiffies(40) 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ciint hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port, 4162306a36Sopenharmony_ci struct ifreq *ifr); 4262306a36Sopenharmony_ciint hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port, 4362306a36Sopenharmony_ci struct ifreq *ifr); 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cibool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port, 4662306a36Sopenharmony_ci struct sk_buff *clone, unsigned int type); 4762306a36Sopenharmony_civoid hellcreek_port_txtstamp(struct dsa_switch *ds, int port, 4862306a36Sopenharmony_ci struct sk_buff *skb); 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ciint hellcreek_get_ts_info(struct dsa_switch *ds, int port, 5162306a36Sopenharmony_ci struct ethtool_ts_info *info); 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cilong hellcreek_hwtstamp_work(struct ptp_clock_info *ptp); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ciint hellcreek_hwtstamp_setup(struct hellcreek *chip); 5662306a36Sopenharmony_civoid hellcreek_hwtstamp_free(struct hellcreek *chip); 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#endif /* _HELLCREEK_HWTSTAMP_H_ */ 59