| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * TI Common Platform Time Sync |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2012 Richard Cochran <richardcochran@gmail.com> |
|---|
| 5 | 6 | * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | 7 | */ |
|---|
| 20 | 8 | #ifndef _TI_CPTS_H_ |
|---|
| 21 | 9 | #define _TI_CPTS_H_ |
|---|
| .. | .. |
|---|
| 36 | 24 | struct cpsw_cpts { |
|---|
| 37 | 25 | u32 idver; /* Identification and version */ |
|---|
| 38 | 26 | u32 control; /* Time sync control */ |
|---|
| 39 | | - u32 res1; |
|---|
| 27 | + u32 rftclk_sel; /* Reference Clock Select Register */ |
|---|
| 40 | 28 | u32 ts_push; /* Time stamp event push */ |
|---|
| 41 | 29 | u32 ts_load_val; /* Time stamp load value */ |
|---|
| 42 | 30 | u32 ts_load_en; /* Time stamp load enable */ |
|---|
| .. | .. |
|---|
| 106 | 94 | unsigned long tmo; |
|---|
| 107 | 95 | u32 high; |
|---|
| 108 | 96 | u32 low; |
|---|
| 97 | + u64 timestamp; |
|---|
| 109 | 98 | }; |
|---|
| 110 | 99 | |
|---|
| 111 | 100 | struct cpts { |
|---|
| .. | .. |
|---|
| 115 | 104 | int rx_enable; |
|---|
| 116 | 105 | struct ptp_clock_info info; |
|---|
| 117 | 106 | struct ptp_clock *clock; |
|---|
| 118 | | - spinlock_t lock; /* protects time registers */ |
|---|
| 107 | + spinlock_t lock; /* protects fifo/events */ |
|---|
| 119 | 108 | u32 cc_mult; /* for the nominal frequency */ |
|---|
| 120 | 109 | struct cyclecounter cc; |
|---|
| 121 | 110 | struct timecounter tc; |
|---|
| .. | .. |
|---|
| 126 | 115 | struct cpts_event pool_data[CPTS_MAX_EVENTS]; |
|---|
| 127 | 116 | unsigned long ov_check_period; |
|---|
| 128 | 117 | struct sk_buff_head txq; |
|---|
| 118 | + u64 cur_timestamp; |
|---|
| 119 | + u32 mult_new; |
|---|
| 120 | + struct mutex ptp_clk_mutex; /* sync PTP interface and worker */ |
|---|
| 121 | + bool irq_poll; |
|---|
| 122 | + struct completion ts_push_complete; |
|---|
| 123 | + u32 hw_ts_enable; |
|---|
| 129 | 124 | }; |
|---|
| 130 | 125 | |
|---|
| 131 | 126 | void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb); |
|---|
| .. | .. |
|---|
| 133 | 128 | int cpts_register(struct cpts *cpts); |
|---|
| 134 | 129 | void cpts_unregister(struct cpts *cpts); |
|---|
| 135 | 130 | struct cpts *cpts_create(struct device *dev, void __iomem *regs, |
|---|
| 136 | | - struct device_node *node); |
|---|
| 131 | + struct device_node *node, u32 n_ext_ts); |
|---|
| 137 | 132 | void cpts_release(struct cpts *cpts); |
|---|
| 138 | | - |
|---|
| 139 | | -static inline void cpts_rx_enable(struct cpts *cpts, int enable) |
|---|
| 140 | | -{ |
|---|
| 141 | | - cpts->rx_enable = enable; |
|---|
| 142 | | -} |
|---|
| 143 | | - |
|---|
| 144 | | -static inline bool cpts_is_rx_enabled(struct cpts *cpts) |
|---|
| 145 | | -{ |
|---|
| 146 | | - return !!cpts->rx_enable; |
|---|
| 147 | | -} |
|---|
| 148 | | - |
|---|
| 149 | | -static inline void cpts_tx_enable(struct cpts *cpts, int enable) |
|---|
| 150 | | -{ |
|---|
| 151 | | - cpts->tx_enable = enable; |
|---|
| 152 | | -} |
|---|
| 153 | | - |
|---|
| 154 | | -static inline bool cpts_is_tx_enabled(struct cpts *cpts) |
|---|
| 155 | | -{ |
|---|
| 156 | | - return !!cpts->tx_enable; |
|---|
| 157 | | -} |
|---|
| 133 | +void cpts_misc_interrupt(struct cpts *cpts); |
|---|
| 158 | 134 | |
|---|
| 159 | 135 | static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb) |
|---|
| 160 | 136 | { |
|---|
| .. | .. |
|---|
| 164 | 140 | return false; |
|---|
| 165 | 141 | |
|---|
| 166 | 142 | return true; |
|---|
| 143 | +} |
|---|
| 144 | + |
|---|
| 145 | +static inline void cpts_set_irqpoll(struct cpts *cpts, bool en) |
|---|
| 146 | +{ |
|---|
| 147 | + cpts->irq_poll = en; |
|---|
| 167 | 148 | } |
|---|
| 168 | 149 | |
|---|
| 169 | 150 | #else |
|---|
| .. | .. |
|---|
| 178 | 159 | |
|---|
| 179 | 160 | static inline |
|---|
| 180 | 161 | struct cpts *cpts_create(struct device *dev, void __iomem *regs, |
|---|
| 181 | | - struct device_node *node) |
|---|
| 162 | + struct device_node *node, u32 n_ext_ts) |
|---|
| 182 | 163 | { |
|---|
| 183 | 164 | return NULL; |
|---|
| 184 | 165 | } |
|---|
| .. | .. |
|---|
| 197 | 178 | { |
|---|
| 198 | 179 | } |
|---|
| 199 | 180 | |
|---|
| 200 | | -static inline void cpts_rx_enable(struct cpts *cpts, int enable) |
|---|
| 201 | | -{ |
|---|
| 202 | | -} |
|---|
| 203 | | - |
|---|
| 204 | | -static inline bool cpts_is_rx_enabled(struct cpts *cpts) |
|---|
| 205 | | -{ |
|---|
| 206 | | - return false; |
|---|
| 207 | | -} |
|---|
| 208 | | - |
|---|
| 209 | | -static inline void cpts_tx_enable(struct cpts *cpts, int enable) |
|---|
| 210 | | -{ |
|---|
| 211 | | -} |
|---|
| 212 | | - |
|---|
| 213 | | -static inline bool cpts_is_tx_enabled(struct cpts *cpts) |
|---|
| 214 | | -{ |
|---|
| 215 | | - return false; |
|---|
| 216 | | -} |
|---|
| 217 | | - |
|---|
| 218 | 181 | static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb) |
|---|
| 219 | 182 | { |
|---|
| 220 | 183 | return false; |
|---|
| 221 | 184 | } |
|---|
| 185 | + |
|---|
| 186 | +static inline void cpts_misc_interrupt(struct cpts *cpts) |
|---|
| 187 | +{ |
|---|
| 188 | +} |
|---|
| 189 | + |
|---|
| 190 | +static inline void cpts_set_irqpoll(struct cpts *cpts, bool en) |
|---|
| 191 | +{ |
|---|
| 192 | +} |
|---|
| 222 | 193 | #endif |
|---|
| 223 | 194 | |
|---|
| 224 | 195 | |
|---|