Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (C) 2021-2022, Intel Corporation. */
0003 
0004 #ifndef _ICE_GNSS_H_
0005 #define _ICE_GNSS_H_
0006 
0007 #include <linux/tty.h>
0008 #include <linux/tty_flip.h>
0009 
0010 #define ICE_E810T_GNSS_I2C_BUS      0x2
0011 #define ICE_GNSS_TIMER_DELAY_TIME   (HZ / 10) /* 0.1 second per message */
0012 /* Create 2 minor devices, both using the same GNSS module. First one is RW,
0013  * second one RO.
0014  */
0015 #define ICE_GNSS_TTY_MINOR_DEVICES  2
0016 #define ICE_GNSS_TTY_WRITE_BUF      250
0017 #define ICE_MAX_I2C_DATA_SIZE       FIELD_MAX(ICE_AQC_I2C_DATA_SIZE_M)
0018 #define ICE_MAX_I2C_WRITE_BYTES     4
0019 
0020 /* u-blox ZED-F9T specific definitions */
0021 #define ICE_GNSS_UBX_I2C_BUS_ADDR   0x42
0022 /* Data length register is big endian */
0023 #define ICE_GNSS_UBX_DATA_LEN_H     0xFD
0024 #define ICE_GNSS_UBX_DATA_LEN_WIDTH 2
0025 #define ICE_GNSS_UBX_EMPTY_DATA     0xFF
0026 /* For u-blox writes are performed without address so the first byte to write is
0027  * passed as I2C addr parameter.
0028  */
0029 #define ICE_GNSS_UBX_WRITE_BYTES    (ICE_MAX_I2C_WRITE_BYTES + 1)
0030 #define ICE_MAX_UBX_READ_TRIES      255
0031 #define ICE_MAX_UBX_ACK_READ_TRIES  4095
0032 
0033 struct gnss_write_buf {
0034     struct list_head queue;
0035     unsigned int size;
0036     unsigned char *buf;
0037 };
0038 
0039 
0040 /**
0041  * struct gnss_serial - data used to initialize GNSS TTY port
0042  * @back: back pointer to PF
0043  * @tty: pointer to the tty for this device
0044  * @open_count: number of times this port has been opened
0045  * @gnss_mutex: gnss_mutex used to protect GNSS serial operations
0046  * @kworker: kwork thread for handling periodic work
0047  * @read_work: read_work function for handling GNSS reads
0048  * @write_work: write_work function for handling GNSS writes
0049  * @queue: write buffers queue
0050  */
0051 struct gnss_serial {
0052     struct ice_pf *back;
0053     struct tty_struct *tty;
0054     int open_count;
0055     struct mutex gnss_mutex; /* protects GNSS serial structure */
0056     struct kthread_worker *kworker;
0057     struct kthread_delayed_work read_work;
0058     struct kthread_work write_work;
0059     struct list_head queue;
0060 };
0061 
0062 #if IS_ENABLED(CONFIG_TTY)
0063 void ice_gnss_init(struct ice_pf *pf);
0064 void ice_gnss_exit(struct ice_pf *pf);
0065 bool ice_gnss_is_gps_present(struct ice_hw *hw);
0066 #else
0067 static inline void ice_gnss_init(struct ice_pf *pf) { }
0068 static inline void ice_gnss_exit(struct ice_pf *pf) { }
0069 static inline bool ice_gnss_is_gps_present(struct ice_hw *hw)
0070 {
0071     return false;
0072 }
0073 #endif /* IS_ENABLED(CONFIG_TTY) */
0074 #endif /* _ICE_GNSS_H_ */