pps_kernel.h 2.6 KB

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