blob: 621953f7821da17ee4160666706e7fbd110a9021 [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;
Gustavo A. R. Silva9b5816b2020-05-07 13:53:13 -050019 unsigned long drvdata[];
Johan Hovold37768b02018-06-01 10:22:54 +020020};
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 */