serial.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Generic serial GNSS receiver driver
  4. *
  5. * Copyright (C) 2018 Johan Hovold <johan@kernel.org>
  6. */
  7. #ifndef _LINUX_GNSS_SERIAL_H
  8. #define _LINUX_GNSS_SERIAL_H
  9. #include <asm/termbits.h>
  10. #include <linux/pm.h>
  11. struct gnss_serial {
  12. struct serdev_device *serdev;
  13. struct gnss_device *gdev;
  14. speed_t speed;
  15. const struct gnss_serial_ops *ops;
  16. unsigned long drvdata[0];
  17. };
  18. enum gnss_serial_pm_state {
  19. GNSS_SERIAL_OFF,
  20. GNSS_SERIAL_ACTIVE,
  21. GNSS_SERIAL_STANDBY,
  22. };
  23. struct gnss_serial_ops {
  24. int (*set_power)(struct gnss_serial *gserial,
  25. enum gnss_serial_pm_state state);
  26. };
  27. extern const struct dev_pm_ops gnss_serial_pm_ops;
  28. struct gnss_serial *gnss_serial_allocate(struct serdev_device *gserial,
  29. size_t data_size);
  30. void gnss_serial_free(struct gnss_serial *gserial);
  31. int gnss_serial_register(struct gnss_serial *gserial);
  32. void gnss_serial_deregister(struct gnss_serial *gserial);
  33. static inline void *gnss_serial_get_drvdata(struct gnss_serial *gserial)
  34. {
  35. return gserial->drvdata;
  36. }
  37. #endif /* _LINUX_GNSS_SERIAL_H */