CONFIG_ICE_GNSS was added by commit c7ef8221ca7d ("ice: use GNSS subsystem instead of TTY") as a way to allow the ice driver to optionally support GNSS features without forcing a dependency on CONFIG_GNSS. The original implementation of that commit at [1] used IS_REACHABLE. This was rejected by Olek at [2] with the suggested implementation of CONFIG_ICE_GNSS. Eventually after merging, Linus reported a .config which had CONFIG_ICE_GNSS = y when both GNSS = n and ICE = n. This confused him and he felt that the config option was not useful, and commented about it at [3]. CONFIG_ICE_GNSS is defined to y whenever GNSS = ICE. This results in it being set in cases where both options are not enabled. The goal of CONFIG_ICE_GNSS is to ensure that the GNSS support in the ice driver is enabled when GNSS is enabled. The complaint from Olek about the original IS_REACHABLE was due to the required IS_REACHABLE checks throughout the ice driver code and the fact that ice_gnss.c was compiled regardless of GNSS support. This can be fixed in the Makefile by using ice-$(CONFIG_GNSS) += ice_gnss.o In this case, if GNSS = m and ICE = y, we can result in some confusing behavior where GNSS support is not enabled because its not built in. See [4]. To disallow this, have CONFIG_ICE depend on GNSS || GNSS = n. This ensures that we cannot enable CONFIG_ICE as builtin while GNSS is a module. Drop CONFIG_ICE_GNSS, and replace the IS_ENABLED checks for it with checks for GNSS. Update the Makefile to add the ice_gnss.o object based on CONFIG_GNSS. This works to ensure that GNSS support can optionally be enabled, doesn't have an unnnecessary extra config option, and has Kbuild enforce the dependency such that you can't accidentally enable GNSS as a module and ICE as a builtin. [1] https://lore.kernel.org/intel-wired-lan/20221019095603.44825-1-arkadiusz.kubalewski@intel.com/ [2] https://lore.kernel.org/intel-wired-lan/20221028165706.96849-1-alexandr.lobakin@intel.com/ [3] https://lore.kernel.org/all/CAHk-=wi_410KZqHwF-WL5U7QYxnpHHHNP-3xL=g_y89XnKc-uw@mail.gmail.com/ [4] https://lore.kernel.org/netdev/20230223161309.0e439c5f@kernel.org/ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Fixes: c7ef8221ca7d ("ice: use GNSS subsystem instead of TTY") Cc: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com> Cc: Alexander Lobakin <alexandr.lobakin@intel.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Anthony Nguyen <anthony.l.nguyen@intel.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
61 lines
1.8 KiB
C
61 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (C) 2021-2022, Intel Corporation. */
|
|
|
|
#ifndef _ICE_GNSS_H_
|
|
#define _ICE_GNSS_H_
|
|
|
|
#define ICE_E810T_GNSS_I2C_BUS 0x2
|
|
#define ICE_GNSS_TIMER_DELAY_TIME (HZ / 10) /* 0.1 second per message */
|
|
#define ICE_GNSS_TTY_WRITE_BUF 250
|
|
#define ICE_MAX_I2C_DATA_SIZE FIELD_MAX(ICE_AQC_I2C_DATA_SIZE_M)
|
|
#define ICE_MAX_I2C_WRITE_BYTES 4
|
|
|
|
/* u-blox ZED-F9T specific definitions */
|
|
#define ICE_GNSS_UBX_I2C_BUS_ADDR 0x42
|
|
/* Data length register is big endian */
|
|
#define ICE_GNSS_UBX_DATA_LEN_H 0xFD
|
|
#define ICE_GNSS_UBX_DATA_LEN_WIDTH 2
|
|
#define ICE_GNSS_UBX_EMPTY_DATA 0xFF
|
|
/* For u-blox writes are performed without address so the first byte to write is
|
|
* passed as I2C addr parameter.
|
|
*/
|
|
#define ICE_GNSS_UBX_WRITE_BYTES (ICE_MAX_I2C_WRITE_BYTES + 1)
|
|
#define ICE_MAX_UBX_READ_TRIES 255
|
|
#define ICE_MAX_UBX_ACK_READ_TRIES 4095
|
|
|
|
struct gnss_write_buf {
|
|
struct list_head queue;
|
|
unsigned int size;
|
|
unsigned char *buf;
|
|
};
|
|
|
|
/**
|
|
* struct gnss_serial - data used to initialize GNSS TTY port
|
|
* @back: back pointer to PF
|
|
* @kworker: kwork thread for handling periodic work
|
|
* @read_work: read_work function for handling GNSS reads
|
|
* @write_work: write_work function for handling GNSS writes
|
|
* @queue: write buffers queue
|
|
*/
|
|
struct gnss_serial {
|
|
struct ice_pf *back;
|
|
struct kthread_worker *kworker;
|
|
struct kthread_delayed_work read_work;
|
|
struct kthread_work write_work;
|
|
struct list_head queue;
|
|
};
|
|
|
|
#if IS_ENABLED(CONFIG_GNSS)
|
|
void ice_gnss_init(struct ice_pf *pf);
|
|
void ice_gnss_exit(struct ice_pf *pf);
|
|
bool ice_gnss_is_gps_present(struct ice_hw *hw);
|
|
#else
|
|
static inline void ice_gnss_init(struct ice_pf *pf) { }
|
|
static inline void ice_gnss_exit(struct ice_pf *pf) { }
|
|
static inline bool ice_gnss_is_gps_present(struct ice_hw *hw)
|
|
{
|
|
return false;
|
|
}
|
|
#endif /* IS_ENABLED(CONFIG_GNSS) */
|
|
#endif /* _ICE_GNSS_H_ */
|