Blame view

include/linux/gnss.h 1.56 KB
2b6a44035   Johan Hovold   gnss: add GNSS re...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  /* SPDX-License-Identifier: GPL-2.0 */
  /*
   * GNSS receiver support
   *
   * Copyright (C) 2018 Johan Hovold <johan@kernel.org>
   */
  
  #ifndef _LINUX_GNSS_H
  #define _LINUX_GNSS_H
  
  #include <linux/cdev.h>
  #include <linux/device.h>
  #include <linux/kfifo.h>
  #include <linux/mutex.h>
  #include <linux/rwsem.h>
  #include <linux/types.h>
  #include <linux/wait.h>
  
  struct gnss_device;
10f146639   Johan Hovold   gnss: add receive...
20
21
22
23
  enum gnss_type {
  	GNSS_TYPE_NMEA = 0,
  	GNSS_TYPE_SIRF,
  	GNSS_TYPE_UBX,
625239d4a   Loys Ollivier   gnss: add mtk rec...
24
  	GNSS_TYPE_MTK,
10f146639   Johan Hovold   gnss: add receive...
25
26
27
  
  	GNSS_TYPE_COUNT
  };
2b6a44035   Johan Hovold   gnss: add GNSS re...
28
29
30
31
32
33
34
35
36
37
38
  struct gnss_operations {
  	int (*open)(struct gnss_device *gdev);
  	void (*close)(struct gnss_device *gdev);
  	int (*write_raw)(struct gnss_device *gdev, const unsigned char *buf,
  				size_t count);
  };
  
  struct gnss_device {
  	struct device dev;
  	struct cdev cdev;
  	int id;
10f146639   Johan Hovold   gnss: add receive...
39
  	enum gnss_type type;
2b6a44035   Johan Hovold   gnss: add GNSS re...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  	unsigned long flags;
  
  	struct rw_semaphore rwsem;
  	const struct gnss_operations *ops;
  	unsigned int count;
  	unsigned int disconnected:1;
  
  	struct mutex read_mutex;
  	struct kfifo read_fifo;
  	wait_queue_head_t read_queue;
  
  	struct mutex write_mutex;
  	char *write_buf;
  };
  
  struct gnss_device *gnss_allocate_device(struct device *parent);
  void gnss_put_device(struct gnss_device *gdev);
  int gnss_register_device(struct gnss_device *gdev);
  void gnss_deregister_device(struct gnss_device *gdev);
  
  int gnss_insert_raw(struct gnss_device *gdev, const unsigned char *buf,
  			size_t count);
  
  static inline void gnss_set_drvdata(struct gnss_device *gdev, void *data)
  {
  	dev_set_drvdata(&gdev->dev, data);
  }
  
  static inline void *gnss_get_drvdata(struct gnss_device *gdev)
  {
  	return dev_get_drvdata(&gdev->dev);
  }
  
  #endif /* _LINUX_GNSS_H */