Skip to content

Commit e2c6737

Browse files
kolacinskikarolanguy11
authored andcommitted
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>
1 parent 39f5426 commit e2c6737

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
@@ -5764,6 +5764,96 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
57645764
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
57655765
}
57665766

5767+
/**
5768+
* ice_get_pca9575_handle - find and return the PCA9575 controller
5769+
* @hw: pointer to the hw struct
5770+
* @pca9575_handle: GPIO controller's handle
5771+
*
5772+
* Find and return the GPIO controller's handle in the netlist.
5773+
* When found - the value will be cached in the hw structure and following calls
5774+
* will return cached value.
5775+
*
5776+
* Return: 0 on success, -ENXIO when there's no PCA9575 present.
5777+
*/
5778+
int ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle)
5779+
{
5780+
struct ice_aqc_get_link_topo *cmd;
5781+
struct ice_aq_desc desc;
5782+
int err;
5783+
u8 idx;
5784+
5785+
/* If handle was read previously return cached value */
5786+
if (hw->io_expander_handle) {
5787+
*pca9575_handle = hw->io_expander_handle;
5788+
return 0;
5789+
}
5790+
5791+
#define SW_PCA9575_SFP_TOPO_IDX 2
5792+
#define SW_PCA9575_QSFP_TOPO_IDX 1
5793+
5794+
/* Check if the SW IO expander controlling SMA exists in the netlist. */
5795+
if (hw->device_id == ICE_DEV_ID_E810C_SFP)
5796+
idx = SW_PCA9575_SFP_TOPO_IDX;
5797+
else if (hw->device_id == ICE_DEV_ID_E810C_QSFP)
5798+
idx = SW_PCA9575_QSFP_TOPO_IDX;
5799+
else
5800+
return -ENXIO;
5801+
5802+
/* If handle was not detected read it from the netlist */
5803+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_link_topo);
5804+
cmd = &desc.params.get_link_topo;
5805+
cmd->addr.topo_params.node_type_ctx =
5806+
ICE_AQC_LINK_TOPO_NODE_TYPE_GPIO_CTRL;
5807+
cmd->addr.topo_params.index = idx;
5808+
5809+
err = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
5810+
if (err)
5811+
return -ENXIO;
5812+
5813+
/* Verify if we found the right IO expander type */
5814+
if (desc.params.get_link_topo.node_part_num !=
5815+
ICE_AQC_GET_LINK_TOPO_NODE_NR_PCA9575)
5816+
return -ENXIO;
5817+
5818+
/* If present save the handle and return it */
5819+
hw->io_expander_handle =
5820+
le16_to_cpu(desc.params.get_link_topo.addr.handle);
5821+
*pca9575_handle = hw->io_expander_handle;
5822+
5823+
return 0;
5824+
}
5825+
5826+
/**
5827+
* ice_read_pca9575_reg - read the register from the PCA9575 controller
5828+
* @hw: pointer to the hw struct
5829+
* @offset: GPIO controller register offset
5830+
* @data: pointer to data to be read from the GPIO controller
5831+
*
5832+
* Return: 0 on success, negative error code otherwise.
5833+
*/
5834+
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data)
5835+
{
5836+
struct ice_aqc_link_topo_addr link_topo;
5837+
__le16 addr;
5838+
u16 handle;
5839+
int err;
5840+
5841+
memset(&link_topo, 0, sizeof(link_topo));
5842+
5843+
err = ice_get_pca9575_handle(hw, &handle);
5844+
if (err)
5845+
return err;
5846+
5847+
link_topo.handle = cpu_to_le16(handle);
5848+
link_topo.topo_params.node_type_ctx =
5849+
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_CTX_M,
5850+
ICE_AQC_LINK_TOPO_NODE_CTX_PROVIDED);
5851+
5852+
addr = cpu_to_le16((u16)offset);
5853+
5854+
return ice_aq_read_i2c(hw, link_topo, 0, addr, 1, data, NULL);
5855+
}
5856+
57675857
/**
57685858
* ice_aq_set_gpio
57695859
* @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
@@ -306,5 +306,7 @@ int
306306
ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
307307
u16 bus_addr, __le16 addr, u8 params, const u8 *data,
308308
struct ice_sq_cd *cd);
309+
int ice_get_pca9575_handle(struct ice_hw *hw, u16 *pca9575_handle);
310+
int ice_read_pca9575_reg(struct ice_hw *hw, u8 offset, u8 *data);
309311
bool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw);
310312
#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
@@ -3893,7 +3893,7 @@ void ice_init_feature_support(struct ice_pf *pf)
38933893
ice_set_feature_support(pf, ICE_F_CGU);
38943894
if (ice_is_clock_mux_in_netlist(&pf->hw))
38953895
ice_set_feature_support(pf, ICE_F_SMA_CTRL);
3896-
if (ice_gnss_is_gps_present(&pf->hw))
3896+
if (ice_gnss_is_module_present(&pf->hw))
38973897
ice_set_feature_support(pf, ICE_F_GNSS);
38983898
break;
38993899
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)