1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2018-2021, Intel Corporation. */
3 
4 #ifndef _ICE_GNSS_H_
5 #define _ICE_GNSS_H_
6 
7 #include <linux/tty.h>
8 #include <linux/tty_flip.h>
9 
10 #define ICE_E810T_GNSS_I2C_BUS		0x2
11 #define ICE_GNSS_UBX_I2C_BUS_ADDR	0x42
12 /* Data length register is big endian */
13 #define ICE_GNSS_UBX_DATA_LEN_H		0xFD
14 #define ICE_GNSS_UBX_DATA_LEN_WIDTH	2
15 #define ICE_GNSS_UBX_EMPTY_DATA		0xFF
16 #define ICE_GNSS_TIMER_DELAY_TIME	(HZ / 10) /* 0.1 second per message */
17 #define ICE_MAX_I2C_DATA_SIZE		FIELD_MAX(ICE_AQC_I2C_DATA_SIZE_M)
18 #define ICE_MAX_UBX_READ_TRIES		255
19 
20 /**
21  * struct gnss_serial - data used to initialize GNSS TTY port
22  * @back: back pointer to PF
23  * @tty: pointer to the tty for this device
24  * @open_count: number of times this port has been opened
25  * @gnss_mutex: gnss_mutex used to protect GNSS serial operations
26  * @kworker: kwork thread for handling periodic work
27  * @read_work: read_work function for handling GNSS reads
28  */
29 struct gnss_serial {
30 	struct ice_pf *back;
31 	struct tty_struct *tty;
32 	int open_count;
33 	struct mutex gnss_mutex; /* protects GNSS serial structure */
34 	struct kthread_worker *kworker;
35 	struct kthread_delayed_work read_work;
36 };
37 
38 #if IS_ENABLED(CONFIG_TTY)
39 void ice_gnss_init(struct ice_pf *pf);
40 void ice_gnss_exit(struct ice_pf *pf);
41 bool ice_gnss_is_gps_present(struct ice_hw *hw);
42 #else
43 static inline void ice_gnss_init(struct ice_pf *pf) { }
44 static inline void ice_gnss_exit(struct ice_pf *pf) { }
45 static inline bool ice_gnss_is_gps_present(struct ice_hw *hw)
46 {
47 	return false;
48 }
49 #endif /* IS_ENABLED(CONFIG_TTY) */
50 #endif /* _ICE_GNSS_H_ */
51