Skip to content

Commit 420945a

Browse files
committed
ice: Don't check device type when checking GNSS presence
JIRA: https://issues.redhat.com/browse/RHEL-89579 Upstream commit(s): commit e2c6737 Author: Karol Kolacinski <karol.kolacinski@intel.com> Date: Mon Sep 30 14:12:38 2024 +0200 ice: Don't check device type when checking GNSS presence Don't check if the device type is E810T as non-E810T devices can support GNSS too and PCA9575 check is enough to determine if GNSS is present or not. Rename ice_gnss_is_gps_present() to ice_gnss_is_module_present() because GNSS module supports multiple GNSS providers, not only GPS. Move functions related to PCA9575 from ice_ptp_hw.c to ice_common.c to be able to access them when PTP is disabled in the kernel, but GNSS is enabled. Remove logical AND with ICE_AQC_LINK_TOPO_NODE_TYPE_M in ice_get_pca9575_handle(), which has no effect, and reorder device type checks to check the device_id first, then set other variables. Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent 5f9cfdb commit 420945a

File tree

7 files changed

+105
-116
lines changed

7 files changed

+105
-116
lines changed

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5922,6 +5922,96 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
59225922
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
59235923
}
59245924

5925+
/**
5926+
* ice_get_pca9575_handle - find and return the PCA9575 controller
5927+
* @hw: pointer to the hw struct
5928+
* @pca9575_handle: GPIO controller's handle
5929+
*
5930+
* Find and return the GPIO controller's handle in the netlist.
5931+
* When found - the value will be cached in the hw structure and following calls
5932+
* will return cached value.
5933+
*
5934+
* Return: 0 on success, -ENXIO when there's no PCA9575 present.
5935+
*/
5936+
int ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle)
5937+
{
5938+
struct ice_aqc_get_link_topo *cmd;
5939+
struct ice_aq_desc desc;
5940+
int err;
5941+
u8 idx;
5942+
5943+
/* If handle was read previously return cached value */
5944+
if (hw->io_expander_handle) {
5945+
*pca9575_handle = hw->io_expander_handle;
5946+
return 0;
5947+
}
5948+
5949+
#define SW_PCA9575_SFP_TOPO_IDX 2
5950+
#define SW_PCA9575_QSFP_TOPO_IDX 1
5951+
5952+
/* Check if the SW IO expander controlling SMA exists in the netlist. */
5953+
if (hw->device_id == ICE_DEV_ID_E810C_SFP)
5954+
idx = SW_PCA9575_SFP_TOPO_IDX;
5955+
else if (hw->device_id == ICE_DEV_ID_E810C_QSFP)
5956+
idx = SW_PCA9575_QSFP_TOPO_IDX;
5957+
else
5958+
return -ENXIO;
5959+
5960+
/* If handle was not detected read it from the netlist */
5961+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_link_topo);
5962+
cmd = &desc.params.get_link_topo;
5963+
cmd->addr.topo_params.node_type_ctx =
5964+
ICE_AQC_LINK_TOPO_NODE_TYPE_GPIO_CTRL;
5965+
cmd->addr.topo_params.index = idx;
5966+
5967+
err = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
5968+
if (err)
5969+
return -ENXIO;
5970+
5971+
/* Verify if we found the right IO expander type */
5972+
if (desc.params.get_link_topo.node_part_num !=
5973+
ICE_AQC_GET_LINK_TOPO_NODE_NR_PCA9575)
5974+
return -ENXIO;
5975+
5976+
/* If present save the handle and return it */
5977+
hw->io_expander_handle =
5978+
le16_to_cpu(desc.params.get_link_topo.addr.handle);
5979+
*pca9575_handle = hw->io_expander_handle;
5980+
5981+
return 0;
5982+
}
5983+
5984+
/**
5985+
* ice_read_pca9575_reg - read the register from the PCA9575 controller
5986+
* @hw: pointer to the hw struct
5987+
* @offset: GPIO controller register offset
5988+
* @data: pointer to data to be read from the GPIO controller
5989+
*
5990+
* Return: 0 on success, negative error code otherwise.
5991+
*/
5992+
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data)
5993+
{
5994+
struct ice_aqc_link_topo_addr link_topo;
5995+
__le16 addr;
5996+
u16 handle;
5997+
int err;
5998+
5999+
memset(&link_topo, 0, sizeof(link_topo));
6000+
6001+
err = ice_get_pca9575_handle(hw, &handle);
6002+
if (err)
6003+
return err;
6004+
6005+
link_topo.handle = cpu_to_le16(handle);
6006+
link_topo.topo_params.node_type_ctx =
6007+
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_CTX_M,
6008+
ICE_AQC_LINK_TOPO_NODE_CTX_PROVIDED);
6009+
6010+
addr = cpu_to_le16((u16)offset);
6011+
6012+
return ice_aq_read_i2c(hw, link_topo, 0, addr, 1, data, NULL);
6013+
}
6014+
59256015
/**
59266016
* ice_aq_set_gpio
59276017
* @hw: pointer to the hw struct

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,7 @@ int
305305
ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
306306
u16 bus_addr, __le16 addr, u8 params, const u8 *data,
307307
struct ice_sq_cd *cd);
308+
int ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle);
309+
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data);
308310
bool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw);
309311
#endif /* _ICE_COMMON_H_ */

drivers/net/ethernet/intel/ice/ice_gnss.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -381,32 +381,23 @@ void ice_gnss_exit(struct ice_pf *pf)
381381
}
382382

383383
/**
384-
* ice_gnss_is_gps_present - Check if GPS HW is present
384+
* ice_gnss_is_module_present - Check if GNSS HW is present
385385
* @hw: pointer to HW struct
386+
*
387+
* Return: true when GNSS is present, false otherwise.
386388
*/
387-
bool ice_gnss_is_gps_present(struct ice_hw *hw)
389+
bool ice_gnss_is_module_present(struct ice_hw *hw)
388390
{
389-
if (!hw->func_caps.ts_func_info.src_tmr_owned)
390-
return false;
391+
int err;
392+
u8 data;
391393

392-
if (!ice_is_gps_in_netlist(hw))
394+
if (!hw->func_caps.ts_func_info.src_tmr_owned ||
395+
!ice_is_gps_in_netlist(hw))
393396
return false;
394397

395-
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
396-
if (ice_is_e810t(hw)) {
397-
int err;
398-
u8 data;
399-
400-
err = ice_read_pca9575_reg(hw, ICE_PCA9575_P0_IN, &data);
401-
if (err || !!(data & ICE_P0_GNSS_PRSNT_N))
402-
return false;
403-
} else {
404-
return false;
405-
}
406-
#else
407-
if (!ice_is_e810t(hw))
398+
err = ice_read_pca9575_reg(hw, ICE_PCA9575_P0_IN, &data);
399+
if (err || !!(data & ICE_P0_GNSS_PRSNT_N))
408400
return false;
409-
#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
410401

411402
return true;
412403
}

drivers/net/ethernet/intel/ice/ice_gnss.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ struct gnss_serial {
3737
#if IS_ENABLED(CONFIG_GNSS)
3838
void ice_gnss_init(struct ice_pf *pf);
3939
void ice_gnss_exit(struct ice_pf *pf);
40-
bool ice_gnss_is_gps_present(struct ice_hw *hw);
40+
bool ice_gnss_is_module_present(struct ice_hw *hw);
4141
#else
4242
static inline void ice_gnss_init(struct ice_pf *pf) { }
4343
static inline void ice_gnss_exit(struct ice_pf *pf) { }
44-
static inline bool ice_gnss_is_gps_present(struct ice_hw *hw)
44+
static inline bool ice_gnss_is_module_present(struct ice_hw *hw)
4545
{
4646
return false;
4747
}

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ void ice_init_feature_support(struct ice_pf *pf)
38853885
ice_set_feature_support(pf, ICE_F_CGU);
38863886
if (ice_is_clock_mux_in_netlist(&pf->hw))
38873887
ice_set_feature_support(pf, ICE_F_SMA_CTRL);
3888-
if (ice_gnss_is_gps_present(&pf->hw))
3888+
if (ice_gnss_is_module_present(&pf->hw))
38893889
ice_set_feature_support(pf, ICE_F_GNSS);
38903890
break;
38913891
default:

drivers/net/ethernet/intel/ice/ice_ptp_hw.c

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5315,68 +5315,6 @@ ice_get_phy_tx_tstamp_ready_e810(struct ice_hw *hw, u8 port, u64 *tstamp_ready)
53155315
* to access the extended GPIOs available.
53165316
*/
53175317

5318-
/**
5319-
* ice_get_pca9575_handle
5320-
* @hw: pointer to the hw struct
5321-
* @pca9575_handle: GPIO controller's handle
5322-
*
5323-
* Find and return the GPIO controller's handle in the netlist.
5324-
* When found - the value will be cached in the hw structure and following calls
5325-
* will return cached value
5326-
*/
5327-
static int
5328-
ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle)
5329-
{
5330-
struct ice_aqc_get_link_topo *cmd;
5331-
struct ice_aq_desc desc;
5332-
int status;
5333-
u8 idx;
5334-
5335-
/* If handle was read previously return cached value */
5336-
if (hw->io_expander_handle) {
5337-
*pca9575_handle = hw->io_expander_handle;
5338-
return 0;
5339-
}
5340-
5341-
/* If handle was not detected read it from the netlist */
5342-
cmd = &desc.params.get_link_topo;
5343-
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_link_topo);
5344-
5345-
/* Set node type to GPIO controller */
5346-
cmd->addr.topo_params.node_type_ctx =
5347-
(ICE_AQC_LINK_TOPO_NODE_TYPE_M &
5348-
ICE_AQC_LINK_TOPO_NODE_TYPE_GPIO_CTRL);
5349-
5350-
#define SW_PCA9575_SFP_TOPO_IDX 2
5351-
#define SW_PCA9575_QSFP_TOPO_IDX 1
5352-
5353-
/* Check if the SW IO expander controlling SMA exists in the netlist. */
5354-
if (hw->device_id == ICE_DEV_ID_E810C_SFP)
5355-
idx = SW_PCA9575_SFP_TOPO_IDX;
5356-
else if (hw->device_id == ICE_DEV_ID_E810C_QSFP)
5357-
idx = SW_PCA9575_QSFP_TOPO_IDX;
5358-
else
5359-
return -EOPNOTSUPP;
5360-
5361-
cmd->addr.topo_params.index = idx;
5362-
5363-
status = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
5364-
if (status)
5365-
return -EOPNOTSUPP;
5366-
5367-
/* Verify if we found the right IO expander type */
5368-
if (desc.params.get_link_topo.node_part_num !=
5369-
ICE_AQC_GET_LINK_TOPO_NODE_NR_PCA9575)
5370-
return -EOPNOTSUPP;
5371-
5372-
/* If present save the handle and return it */
5373-
hw->io_expander_handle =
5374-
le16_to_cpu(desc.params.get_link_topo.addr.handle);
5375-
*pca9575_handle = hw->io_expander_handle;
5376-
5377-
return 0;
5378-
}
5379-
53805318
/**
53815319
* ice_read_sma_ctrl
53825320
* @hw: pointer to the hw struct
@@ -5441,37 +5379,6 @@ int ice_write_sma_ctrl(struct ice_hw *hw, u8 data)
54415379
return status;
54425380
}
54435381

5444-
/**
5445-
* ice_read_pca9575_reg
5446-
* @hw: pointer to the hw struct
5447-
* @offset: GPIO controller register offset
5448-
* @data: pointer to data to be read from the GPIO controller
5449-
*
5450-
* Read the register from the GPIO controller
5451-
*/
5452-
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data)
5453-
{
5454-
struct ice_aqc_link_topo_addr link_topo;
5455-
__le16 addr;
5456-
u16 handle;
5457-
int err;
5458-
5459-
memset(&link_topo, 0, sizeof(link_topo));
5460-
5461-
err = ice_get_pca9575_handle(hw, &handle);
5462-
if (err)
5463-
return err;
5464-
5465-
link_topo.handle = cpu_to_le16(handle);
5466-
link_topo.topo_params.node_type_ctx =
5467-
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_CTX_M,
5468-
ICE_AQC_LINK_TOPO_NODE_CTX_PROVIDED);
5469-
5470-
addr = cpu_to_le16((u16)offset);
5471-
5472-
return ice_aq_read_i2c(hw, link_topo, 0, addr, 1, data, NULL);
5473-
}
5474-
54755382
/**
54765383
* ice_ptp_read_sdp_ac - read SDP available connections section from NVM
54775384
* @hw: pointer to the HW struct

drivers/net/ethernet/intel/ice/ice_ptp_hw.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ int ice_phy_cfg_intr_e82x(struct ice_hw *hw, u8 quad, bool ena, u8 threshold);
395395
/* E810 family functions */
396396
int ice_read_sma_ctrl(struct ice_hw *hw, u8 *data);
397397
int ice_write_sma_ctrl(struct ice_hw *hw, u8 data);
398-
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data);
399398
int ice_ptp_read_sdp_ac(struct ice_hw *hw, __le16 *entries, uint *num_entries);
400399
int ice_cgu_get_num_pins(struct ice_hw *hw, bool input);
401400
enum dpll_pin_type ice_cgu_get_pin_type(struct ice_hw *hw, u8 pin, bool input);

0 commit comments

Comments
 (0)