xref: /openbmc/linux/drivers/gnss/serial.h (revision 5b394b2d)
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 
8 #ifndef _LINUX_GNSS_SERIAL_H
9 #define _LINUX_GNSS_SERIAL_H
10 
11 #include <asm/termbits.h>
12 #include <linux/pm.h>
13 
14 struct gnss_serial {
15 	struct serdev_device *serdev;
16 	struct gnss_device *gdev;
17 	speed_t	speed;
18 	const struct gnss_serial_ops *ops;
19 	unsigned long drvdata[0];
20 };
21 
22 enum gnss_serial_pm_state {
23 	GNSS_SERIAL_OFF,
24 	GNSS_SERIAL_ACTIVE,
25 	GNSS_SERIAL_STANDBY,
26 };
27 
28 struct gnss_serial_ops {
29 	int (*set_power)(struct gnss_serial *gserial,
30 				enum gnss_serial_pm_state state);
31 };
32 
33 extern const struct dev_pm_ops gnss_serial_pm_ops;
34 
35 struct gnss_serial *gnss_serial_allocate(struct serdev_device *gserial,
36 						size_t data_size);
37 void gnss_serial_free(struct gnss_serial *gserial);
38 
39 int gnss_serial_register(struct gnss_serial *gserial);
40 void gnss_serial_deregister(struct gnss_serial *gserial);
41 
42 static inline void *gnss_serial_get_drvdata(struct gnss_serial *gserial)
43 {
44 	return gserial->drvdata;
45 }
46 
47 #endif /* _LINUX_GNSS_SERIAL_H */
48