Blame view
include/linux/ptp_clock_kernel.h
8.39 KB
d94ba80eb ptp: Added a bran... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/* * PTP 1588 clock support * * Copyright (C) 2010 OMICRON electronics GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _PTP_CLOCK_KERNEL_H_ #define _PTP_CLOCK_KERNEL_H_ |
1ef761582 ptp: link the phc... |
23 |
#include <linux/device.h> |
220a60a42 pps/ptp: Allow PH... |
24 |
#include <linux/pps_kernel.h> |
d94ba80eb ptp: Added a bran... |
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#include <linux/ptp_clock.h> struct ptp_clock_request { enum { PTP_CLK_REQ_EXTTS, PTP_CLK_REQ_PEROUT, PTP_CLK_REQ_PPS, } type; union { struct ptp_extts_request extts; struct ptp_perout_request perout; }; }; |
719f1aa4a ptp: Add PTP_SYS_... |
39 |
struct system_device_crosststamp; |
d94ba80eb ptp: Added a bran... |
40 41 42 43 |
/** * struct ptp_clock_info - decribes a PTP hardware clock * * @owner: The clock driver should set to THIS_MODULE. |
de4658467 ptp: clarify the ... |
44 45 46 |
* @name: A short "friendly name" to identify the clock and to * help distinguish PHY based devices from MAC based ones. * The string is not meant to be a unique id. |
d94ba80eb ptp: Added a bran... |
47 48 49 50 |
* @max_adj: The maximum possible frequency adjustment, in parts per billon. * @n_alarm: The number of programmable alarms. * @n_ext_ts: The number of external time stamp channels. * @n_per_out: The number of programmable periodic signals. |
6092315df ptp: introduce pr... |
51 |
* @n_pins: The number of programmable pins. |
d94ba80eb ptp: Added a bran... |
52 |
* @pps: Indicates whether the clock supports a PPS callback. |
6092315df ptp: introduce pr... |
53 54 55 |
* @pin_config: Array of length 'n_pins'. If the number of * programmable pins is nonzero, then drivers must * allocate and initialize this array. |
d94ba80eb ptp: Added a bran... |
56 57 58 |
* * clock operations * |
d8d263541 ptp: Introduce a ... |
59 60 61 62 63 |
* @adjfine: Adjusts the frequency of the hardware clock. * parameter scaled_ppm: Desired frequency offset from * nominal frequency in parts per million, but with a * 16 bit binary fractional field. * |
d94ba80eb ptp: Added a bran... |
64 |
* @adjfreq: Adjusts the frequency of the hardware clock. |
d8d263541 ptp: Introduce a ... |
65 66 |
* This method is deprecated. New drivers should implement * the @adjfine method instead. |
87f4d7c1d ptp: update adjfr... |
67 68 |
* parameter delta: Desired frequency offset from nominal frequency * in parts per billion |
d94ba80eb ptp: Added a bran... |
69 70 71 72 |
* * @adjtime: Shifts the time of the hardware clock. * parameter delta: Desired change in nanoseconds. * |
92f171940 ptp: introduce ge... |
73 74 75 |
* @gettime64: Reads the current time from the hardware clock. * parameter ts: Holds the result. * |
719f1aa4a ptp: Add PTP_SYS_... |
76 77 78 79 80 |
* @getcrosststamp: Reads the current time from the hardware clock and * system clock simultaneously. * parameter cts: Contains timestamp (device,system) pair, * where system time is realtime and monotonic. * |
92f171940 ptp: introduce ge... |
81 82 83 |
* @settime64: Set the current time on the hardware clock. * parameter ts: Time value to set. * |
d94ba80eb ptp: Added a bran... |
84 85 86 87 |
* @enable: Request driver to enable or disable an ancillary feature. * parameter request: Desired resource to enable or disable. * parameter on: Caller passes one to enable or zero to disable. * |
6092315df ptp: introduce pr... |
88 89 90 91 92 93 94 95 96 97 98 99 |
* @verify: Confirm that a pin can perform a given function. The PTP * Hardware Clock subsystem maintains the 'pin_config' * array on behalf of the drivers, but the PHC subsystem * assumes that every pin can perform every function. This * hook gives drivers a way of telling the core about * limitations on specific pins. This function must return * zero if the function can be assigned to this pin, and * nonzero otherwise. * parameter pin: index of the pin in question. * parameter func: the desired function to use. * parameter chan: the function channel index to use. * |
d9535cb7b ptp: introduce pt... |
100 101 102 103 104 |
* @do_work: Request driver to perform auxiliary (periodic) operations * Driver should return delay of the next auxiliary work scheduling * time (>=0) or negative value in case further scheduling * is not required. * |
d94ba80eb ptp: Added a bran... |
105 106 107 108 109 110 111 112 113 114 115 116 117 |
* Drivers should embed their ptp_clock_info within a private * structure, obtaining a reference to it using container_of(). * * The callbacks must all return zero on success, non-zero otherwise. */ struct ptp_clock_info { struct module *owner; char name[16]; s32 max_adj; int n_alarm; int n_ext_ts; int n_per_out; |
6092315df ptp: introduce pr... |
118 |
int n_pins; |
d94ba80eb ptp: Added a bran... |
119 |
int pps; |
6092315df ptp: introduce pr... |
120 |
struct ptp_pin_desc *pin_config; |
d8d263541 ptp: Introduce a ... |
121 |
int (*adjfine)(struct ptp_clock_info *ptp, long scaled_ppm); |
d94ba80eb ptp: Added a bran... |
122 123 |
int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta); int (*adjtime)(struct ptp_clock_info *ptp, s64 delta); |
92f171940 ptp: introduce ge... |
124 |
int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *ts); |
719f1aa4a ptp: Add PTP_SYS_... |
125 126 |
int (*getcrosststamp)(struct ptp_clock_info *ptp, struct system_device_crosststamp *cts); |
92f171940 ptp: introduce ge... |
127 |
int (*settime64)(struct ptp_clock_info *p, const struct timespec64 *ts); |
d94ba80eb ptp: Added a bran... |
128 129 |
int (*enable)(struct ptp_clock_info *ptp, struct ptp_clock_request *request, int on); |
6092315df ptp: introduce pr... |
130 131 |
int (*verify)(struct ptp_clock_info *ptp, unsigned int pin, enum ptp_pin_function func, unsigned int chan); |
d9535cb7b ptp: introduce pt... |
132 |
long (*do_aux_work)(struct ptp_clock_info *ptp); |
d94ba80eb ptp: Added a bran... |
133 134 135 |
}; struct ptp_clock; |
d94ba80eb ptp: Added a bran... |
136 137 138 139 |
enum ptp_clock_events { PTP_CLOCK_ALARM, PTP_CLOCK_EXTTS, PTP_CLOCK_PPS, |
220a60a42 pps/ptp: Allow PH... |
140 |
PTP_CLOCK_PPSUSR, |
d94ba80eb ptp: Added a bran... |
141 142 143 144 145 146 147 |
}; /** * struct ptp_clock_event - decribes a PTP hardware clock event * * @type: One of the ptp_clock_events enumeration values. * @index: Identifies the source of the event. |
220a60a42 pps/ptp: Allow PH... |
148 149 |
* @timestamp: When the event occurred (%PTP_CLOCK_EXTTS only). * @pps_times: When the event occurred (%PTP_CLOCK_PPSUSR only). |
d94ba80eb ptp: Added a bran... |
150 151 152 153 154 |
*/ struct ptp_clock_event { int type; int index; |
220a60a42 pps/ptp: Allow PH... |
155 156 157 158 |
union { u64 timestamp; struct pps_event_time pps_times; }; |
d94ba80eb ptp: Added a bran... |
159 |
}; |
d1cbfd771 ptp_clock: Allow ... |
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) /** * ptp_clock_register() - register a PTP hardware clock driver * * @info: Structure describing the new clock. * @parent: Pointer to the parent device of the new clock. * * Returns a valid pointer on success or PTR_ERR on failure. If PHC * support is missing at the configuration level, this function * returns NULL, and drivers are expected to gracefully handle that * case separately. */ extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, struct device *parent); /** * ptp_clock_unregister() - unregister a PTP hardware clock driver * * @ptp: The clock to remove from service. */ extern int ptp_clock_unregister(struct ptp_clock *ptp); |
d94ba80eb ptp: Added a bran... |
184 185 186 187 188 189 190 191 192 |
/** * ptp_clock_event() - notify the PTP layer about an event * * @ptp: The clock obtained from ptp_clock_register(). * @event: Message structure describing the event. */ extern void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event); |
995a9090b ptp: Add a method... |
193 194 195 196 197 198 199 |
/** * ptp_clock_index() - obtain the device index of a PTP clock * * @ptp: The clock obtained from ptp_clock_register(). */ extern int ptp_clock_index(struct ptp_clock *ptp); |
6092315df ptp: introduce pr... |
200 201 202 203 204 205 206 207 208 209 210 211 |
/** * ptp_find_pin() - obtain the pin index of a given auxiliary function * * @ptp: The clock obtained from ptp_clock_register(). * @func: One of the ptp_pin_function enumerated values. * @chan: The particular functional channel to find. * Return: Pin index in the range of zero to ptp_clock_caps.n_pins - 1, * or -1 if the auxiliary function cannot be found. */ int ptp_find_pin(struct ptp_clock *ptp, enum ptp_pin_function func, unsigned int chan); |
d9535cb7b ptp: introduce pt... |
212 213 214 215 216 217 218 219 220 |
/** * ptp_schedule_worker() - schedule ptp auxiliary work * * @ptp: The clock obtained from ptp_clock_register(). * @delay: number of jiffies to wait before queuing * See kthread_queue_delayed_work() for more info. */ int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay); |
d1cbfd771 ptp_clock: Allow ... |
221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
#else static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, struct device *parent) { return NULL; } static inline int ptp_clock_unregister(struct ptp_clock *ptp) { return 0; } static inline void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event) { } static inline int ptp_clock_index(struct ptp_clock *ptp) { return -1; } static inline int ptp_find_pin(struct ptp_clock *ptp, enum ptp_pin_function func, unsigned int chan) { return -1; } |
d9535cb7b ptp: introduce pt... |
235 236 237 |
static inline int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) { return -EOPNOTSUPP; } |
d1cbfd771 ptp_clock: Allow ... |
238 |
#endif |
d94ba80eb ptp: Added a bran... |
239 |
#endif |