1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (C) 2021-2022, Intel Corporation. */ 3 4 #ifndef _ICE_GNSS_H_ 5 #define _ICE_GNSS_H_ 6 7 #define ICE_E810T_GNSS_I2C_BUS 0x2 8 #define ICE_GNSS_TIMER_DELAY_TIME (HZ / 10) /* 0.1 second per message */ 9 #define ICE_GNSS_TTY_WRITE_BUF 250 10 #define ICE_MAX_I2C_DATA_SIZE FIELD_MAX(ICE_AQC_I2C_DATA_SIZE_M) 11 #define ICE_MAX_I2C_WRITE_BYTES 4 12 13 /* u-blox ZED-F9T specific definitions */ 14 #define ICE_GNSS_UBX_I2C_BUS_ADDR 0x42 15 /* Data length register is big endian */ 16 #define ICE_GNSS_UBX_DATA_LEN_H 0xFD 17 #define ICE_GNSS_UBX_DATA_LEN_WIDTH 2 18 #define ICE_GNSS_UBX_EMPTY_DATA 0xFF 19 /* For u-blox writes are performed without address so the first byte to write is 20 * passed as I2C addr parameter. 21 */ 22 #define ICE_GNSS_UBX_WRITE_BYTES (ICE_MAX_I2C_WRITE_BYTES + 1) 23 #define ICE_MAX_UBX_READ_TRIES 255 24 #define ICE_MAX_UBX_ACK_READ_TRIES 4095 25 26 struct gnss_write_buf { 27 struct list_head queue; 28 unsigned int size; 29 unsigned char *buf; 30 }; 31 32 /** 33 * struct gnss_serial - data used to initialize GNSS TTY port 34 * @back: back pointer to PF 35 * @kworker: kwork thread for handling periodic work 36 * @read_work: read_work function for handling GNSS reads 37 * @write_work: write_work function for handling GNSS writes 38 * @queue: write buffers queue 39 */ 40 struct gnss_serial { 41 struct ice_pf *back; 42 struct kthread_worker *kworker; 43 struct kthread_delayed_work read_work; 44 struct kthread_work write_work; 45 struct list_head queue; 46 }; 47 48 #if IS_ENABLED(CONFIG_GNSS) 49 void ice_gnss_init(struct ice_pf *pf); 50 void ice_gnss_exit(struct ice_pf *pf); 51 bool ice_gnss_is_gps_present(struct ice_hw *hw); 52 #else 53 static inline void ice_gnss_init(struct ice_pf *pf) { } 54 static inline void ice_gnss_exit(struct ice_pf *pf) { } 55 static inline bool ice_gnss_is_gps_present(struct ice_hw *hw) 56 { 57 return false; 58 } 59 #endif /* IS_ENABLED(CONFIG_GNSS) */ 60 #endif /* _ICE_GNSS_H_ */ 61