Rodolfo Giometti | eae9d2b | 2009-06-17 16:28:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * PPS API kernel header |
| 3 | * |
| 4 | * Copyright (C) 2009 Rodolfo Giometti <giometti@linux.it> |
| 5 | * |
| 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | */ |
| 20 | |
Alexander Gordeev | 7a21a3c | 2011-01-12 17:00:49 -0800 | [diff] [blame^] | 21 | #ifndef LINUX_PPS_KERNEL_H |
| 22 | #define LINUX_PPS_KERNEL_H |
| 23 | |
Rodolfo Giometti | eae9d2b | 2009-06-17 16:28:37 -0700 | [diff] [blame] | 24 | #include <linux/pps.h> |
| 25 | |
| 26 | #include <linux/cdev.h> |
| 27 | #include <linux/device.h> |
| 28 | #include <linux/time.h> |
| 29 | |
| 30 | /* |
| 31 | * Global defines |
| 32 | */ |
| 33 | |
| 34 | /* The specific PPS source info */ |
| 35 | struct pps_source_info { |
| 36 | char name[PPS_MAX_NAME_LEN]; /* simbolic name */ |
| 37 | char path[PPS_MAX_NAME_LEN]; /* path of connected device */ |
| 38 | int mode; /* PPS's allowed mode */ |
| 39 | |
| 40 | void (*echo)(int source, int event, void *data); /* PPS echo function */ |
| 41 | |
| 42 | struct module *owner; |
| 43 | struct device *dev; |
| 44 | }; |
| 45 | |
| 46 | /* The main struct */ |
| 47 | struct pps_device { |
| 48 | struct pps_source_info info; /* PSS source info */ |
| 49 | |
| 50 | struct pps_kparams params; /* PPS's current params */ |
| 51 | |
| 52 | __u32 assert_sequence; /* PPS' assert event seq # */ |
| 53 | __u32 clear_sequence; /* PPS' clear event seq # */ |
| 54 | struct pps_ktime assert_tu; |
| 55 | struct pps_ktime clear_tu; |
| 56 | int current_mode; /* PPS mode at event time */ |
| 57 | |
| 58 | int go; /* PPS event is arrived? */ |
| 59 | wait_queue_head_t queue; /* PPS event queue */ |
| 60 | |
| 61 | unsigned int id; /* PPS source unique ID */ |
| 62 | struct cdev cdev; |
| 63 | struct device *dev; |
| 64 | int devno; |
| 65 | struct fasync_struct *async_queue; /* fasync method */ |
| 66 | spinlock_t lock; |
| 67 | |
| 68 | atomic_t usage; /* usage count */ |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * Global variables |
| 73 | */ |
| 74 | |
| 75 | extern spinlock_t pps_idr_lock; |
| 76 | extern struct idr pps_idr; |
Rodolfo Giometti | eae9d2b | 2009-06-17 16:28:37 -0700 | [diff] [blame] | 77 | |
| 78 | extern struct device_attribute pps_attrs[]; |
| 79 | |
| 80 | /* |
| 81 | * Exported functions |
| 82 | */ |
| 83 | |
| 84 | struct pps_device *pps_get_source(int source); |
| 85 | extern void pps_put_source(struct pps_device *pps); |
| 86 | extern int pps_register_source(struct pps_source_info *info, |
| 87 | int default_params); |
| 88 | extern void pps_unregister_source(int source); |
| 89 | extern int pps_register_cdev(struct pps_device *pps); |
| 90 | extern void pps_unregister_cdev(struct pps_device *pps); |
| 91 | extern void pps_event(int source, struct pps_ktime *ts, int event, void *data); |
Alexander Gordeev | 7a21a3c | 2011-01-12 17:00:49 -0800 | [diff] [blame^] | 92 | |
| 93 | #endif /* LINUX_PPS_KERNEL_H */ |