pps_kernel.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include <linux/pps.h>
  21. #include <linux/cdev.h>
  22. #include <linux/device.h>
  23. #include <linux/time.h>
  24. /*
  25. * Global defines
  26. */
  27. /* The specific PPS source info */
  28. struct pps_source_info {
  29. char name[PPS_MAX_NAME_LEN]; /* simbolic name */
  30. char path[PPS_MAX_NAME_LEN]; /* path of connected device */
  31. int mode; /* PPS's allowed mode */
  32. void (*echo)(int source, int event, void *data); /* PPS echo function */
  33. struct module *owner;
  34. struct device *dev;
  35. };
  36. /* The main struct */
  37. struct pps_device {
  38. struct pps_source_info info; /* PSS source info */
  39. struct pps_kparams params; /* PPS's current params */
  40. __u32 assert_sequence; /* PPS' assert event seq # */
  41. __u32 clear_sequence; /* PPS' clear event seq # */
  42. struct pps_ktime assert_tu;
  43. struct pps_ktime clear_tu;
  44. int current_mode; /* PPS mode at event time */
  45. int go; /* PPS event is arrived? */
  46. wait_queue_head_t queue; /* PPS event queue */
  47. unsigned int id; /* PPS source unique ID */
  48. struct cdev cdev;
  49. struct device *dev;
  50. int devno;
  51. struct fasync_struct *async_queue; /* fasync method */
  52. spinlock_t lock;
  53. atomic_t usage; /* usage count */
  54. };
  55. /*
  56. * Global variables
  57. */
  58. extern spinlock_t pps_idr_lock;
  59. extern struct idr pps_idr;
  60. extern struct timespec pps_irq_ts[];
  61. extern struct device_attribute pps_attrs[];
  62. /*
  63. * Exported functions
  64. */
  65. struct pps_device *pps_get_source(int source);
  66. extern void pps_put_source(struct pps_device *pps);
  67. extern int pps_register_source(struct pps_source_info *info,
  68. int default_params);
  69. extern void pps_unregister_source(int source);
  70. extern int pps_register_cdev(struct pps_device *pps);
  71. extern void pps_unregister_cdev(struct pps_device *pps);
  72. extern void pps_event(int source, struct pps_ktime *ts, int event, void *data);