blob: 980ffdc86c2a72c2c51f07497ebb4219146ed21d [file] [log] [blame]
Johan Hovold37768b02018-06-01 10:22:54 +02001/* 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
14struct 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
22enum gnss_serial_pm_state {
23 GNSS_SERIAL_OFF,
24 GNSS_SERIAL_ACTIVE,
25 GNSS_SERIAL_STANDBY,
26};
27
28struct gnss_serial_ops {
29 int (*set_power)(struct gnss_serial *gserial,
30 enum gnss_serial_pm_state state);
31};
32
33extern const struct dev_pm_ops gnss_serial_pm_ops;
34
35struct gnss_serial *gnss_serial_allocate(struct serdev_device *gserial,
36 size_t data_size);
37void gnss_serial_free(struct gnss_serial *gserial);
38
39int gnss_serial_register(struct gnss_serial *gserial);
40void gnss_serial_deregister(struct gnss_serial *gserial);
41
42static inline void *gnss_serial_get_drvdata(struct gnss_serial *gserial)
43{
44 return gserial->drvdata;
45}
46
47#endif /* _LINUX_GNSS_SERIAL_H */