@@ -186,128 +186,14 @@ static int ice_set_mac_type(struct ice_hw *hw)
186186 * ice_is_generic_mac - check if device's mac_type is generic
187187 * @hw: pointer to the hardware structure
188188 *
189- * Return: true if mac_type is generic (with SBQ support) , false if not
189+ * Return: true if mac_type is ICE_MAC_GENERIC* , false otherwise.
190190 */
191191bool ice_is_generic_mac (struct ice_hw * hw )
192192{
193193 return (hw -> mac_type == ICE_MAC_GENERIC ||
194194 hw -> mac_type == ICE_MAC_GENERIC_3K_E825 );
195195}
196196
197- /**
198- * ice_is_e810
199- * @hw: pointer to the hardware structure
200- *
201- * returns true if the device is E810 based, false if not.
202- */
203- bool ice_is_e810 (struct ice_hw * hw )
204- {
205- return hw -> mac_type == ICE_MAC_E810 ;
206- }
207-
208- /**
209- * ice_is_e810t
210- * @hw: pointer to the hardware structure
211- *
212- * returns true if the device is E810T based, false if not.
213- */
214- bool ice_is_e810t (struct ice_hw * hw )
215- {
216- switch (hw -> device_id ) {
217- case ICE_DEV_ID_E810C_SFP :
218- switch (hw -> subsystem_device_id ) {
219- case ICE_SUBDEV_ID_E810T :
220- case ICE_SUBDEV_ID_E810T2 :
221- case ICE_SUBDEV_ID_E810T3 :
222- case ICE_SUBDEV_ID_E810T4 :
223- case ICE_SUBDEV_ID_E810T6 :
224- case ICE_SUBDEV_ID_E810T7 :
225- return true;
226- }
227- break ;
228- case ICE_DEV_ID_E810C_QSFP :
229- switch (hw -> subsystem_device_id ) {
230- case ICE_SUBDEV_ID_E810T2 :
231- case ICE_SUBDEV_ID_E810T3 :
232- case ICE_SUBDEV_ID_E810T5 :
233- return true;
234- }
235- break ;
236- default :
237- break ;
238- }
239-
240- return false;
241- }
242-
243- /**
244- * ice_is_e822 - Check if a device is E822 family device
245- * @hw: pointer to the hardware structure
246- *
247- * Return: true if the device is E822 based, false if not.
248- */
249- bool ice_is_e822 (struct ice_hw * hw )
250- {
251- switch (hw -> device_id ) {
252- case ICE_DEV_ID_E822C_BACKPLANE :
253- case ICE_DEV_ID_E822C_QSFP :
254- case ICE_DEV_ID_E822C_SFP :
255- case ICE_DEV_ID_E822C_10G_BASE_T :
256- case ICE_DEV_ID_E822C_SGMII :
257- case ICE_DEV_ID_E822L_BACKPLANE :
258- case ICE_DEV_ID_E822L_SFP :
259- case ICE_DEV_ID_E822L_10G_BASE_T :
260- case ICE_DEV_ID_E822L_SGMII :
261- return true;
262- default :
263- return false;
264- }
265- }
266-
267- /**
268- * ice_is_e823
269- * @hw: pointer to the hardware structure
270- *
271- * returns true if the device is E823-L or E823-C based, false if not.
272- */
273- bool ice_is_e823 (struct ice_hw * hw )
274- {
275- switch (hw -> device_id ) {
276- case ICE_DEV_ID_E823L_BACKPLANE :
277- case ICE_DEV_ID_E823L_SFP :
278- case ICE_DEV_ID_E823L_10G_BASE_T :
279- case ICE_DEV_ID_E823L_1GBE :
280- case ICE_DEV_ID_E823L_QSFP :
281- case ICE_DEV_ID_E823C_BACKPLANE :
282- case ICE_DEV_ID_E823C_QSFP :
283- case ICE_DEV_ID_E823C_SFP :
284- case ICE_DEV_ID_E823C_10G_BASE_T :
285- case ICE_DEV_ID_E823C_SGMII :
286- return true;
287- default :
288- return false;
289- }
290- }
291-
292- /**
293- * ice_is_e825c - Check if a device is E825C family device
294- * @hw: pointer to the hardware structure
295- *
296- * Return: true if the device is E825-C based, false if not.
297- */
298- bool ice_is_e825c (struct ice_hw * hw )
299- {
300- switch (hw -> device_id ) {
301- case ICE_DEV_ID_E825C_BACKPLANE :
302- case ICE_DEV_ID_E825C_QSFP :
303- case ICE_DEV_ID_E825C_SFP :
304- case ICE_DEV_ID_E825C_SGMII :
305- return true;
306- default :
307- return false;
308- }
309- }
310-
311197/**
312198 * ice_is_pf_c827 - check if pf contains c827 phy
313199 * @hw: pointer to the hw struct
@@ -2408,7 +2294,7 @@ ice_parse_1588_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
24082294 info -> tmr_index_owned = ((number & ICE_TS_TMR_IDX_OWND_M ) != 0 );
24092295 info -> tmr_index_assoc = ((number & ICE_TS_TMR_IDX_ASSOC_M ) != 0 );
24102296
2411- if (! ice_is_e825c ( hw ) ) {
2297+ if (hw -> mac_type != ICE_MAC_GENERIC_3K_E825 ) {
24122298 info -> clk_freq = FIELD_GET (ICE_TS_CLK_FREQ_M , number );
24132299 info -> clk_src = ((number & ICE_TS_CLK_SRC_M ) != 0 );
24142300 } else {
@@ -5764,6 +5650,96 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
57645650 return ice_aq_send_cmd (hw , & desc , NULL , 0 , cd );
57655651}
57665652
5653+ /**
5654+ * ice_get_pca9575_handle - find and return the PCA9575 controller
5655+ * @hw: pointer to the hw struct
5656+ * @pca9575_handle: GPIO controller's handle
5657+ *
5658+ * Find and return the GPIO controller's handle in the netlist.
5659+ * When found - the value will be cached in the hw structure and following calls
5660+ * will return cached value.
5661+ *
5662+ * Return: 0 on success, -ENXIO when there's no PCA9575 present.
5663+ */
5664+ int ice_get_pca9575_handle (struct ice_hw * hw , u16 * pca9575_handle )
5665+ {
5666+ struct ice_aqc_get_link_topo * cmd ;
5667+ struct ice_aq_desc desc ;
5668+ int err ;
5669+ u8 idx ;
5670+
5671+ /* If handle was read previously return cached value */
5672+ if (hw -> io_expander_handle ) {
5673+ * pca9575_handle = hw -> io_expander_handle ;
5674+ return 0 ;
5675+ }
5676+
5677+ #define SW_PCA9575_SFP_TOPO_IDX 2
5678+ #define SW_PCA9575_QSFP_TOPO_IDX 1
5679+
5680+ /* Check if the SW IO expander controlling SMA exists in the netlist. */
5681+ if (hw -> device_id == ICE_DEV_ID_E810C_SFP )
5682+ idx = SW_PCA9575_SFP_TOPO_IDX ;
5683+ else if (hw -> device_id == ICE_DEV_ID_E810C_QSFP )
5684+ idx = SW_PCA9575_QSFP_TOPO_IDX ;
5685+ else
5686+ return - ENXIO ;
5687+
5688+ /* If handle was not detected read it from the netlist */
5689+ ice_fill_dflt_direct_cmd_desc (& desc , ice_aqc_opc_get_link_topo );
5690+ cmd = & desc .params .get_link_topo ;
5691+ cmd -> addr .topo_params .node_type_ctx =
5692+ ICE_AQC_LINK_TOPO_NODE_TYPE_GPIO_CTRL ;
5693+ cmd -> addr .topo_params .index = idx ;
5694+
5695+ err = ice_aq_send_cmd (hw , & desc , NULL , 0 , NULL );
5696+ if (err )
5697+ return - ENXIO ;
5698+
5699+ /* Verify if we found the right IO expander type */
5700+ if (desc .params .get_link_topo .node_part_num !=
5701+ ICE_AQC_GET_LINK_TOPO_NODE_NR_PCA9575 )
5702+ return - ENXIO ;
5703+
5704+ /* If present save the handle and return it */
5705+ hw -> io_expander_handle =
5706+ le16_to_cpu (desc .params .get_link_topo .addr .handle );
5707+ * pca9575_handle = hw -> io_expander_handle ;
5708+
5709+ return 0 ;
5710+ }
5711+
5712+ /**
5713+ * ice_read_pca9575_reg - read the register from the PCA9575 controller
5714+ * @hw: pointer to the hw struct
5715+ * @offset: GPIO controller register offset
5716+ * @data: pointer to data to be read from the GPIO controller
5717+ *
5718+ * Return: 0 on success, negative error code otherwise.
5719+ */
5720+ int ice_read_pca9575_reg (struct ice_hw * hw , u8 offset , u8 * data )
5721+ {
5722+ struct ice_aqc_link_topo_addr link_topo ;
5723+ __le16 addr ;
5724+ u16 handle ;
5725+ int err ;
5726+
5727+ memset (& link_topo , 0 , sizeof (link_topo ));
5728+
5729+ err = ice_get_pca9575_handle (hw , & handle );
5730+ if (err )
5731+ return err ;
5732+
5733+ link_topo .handle = cpu_to_le16 (handle );
5734+ link_topo .topo_params .node_type_ctx =
5735+ FIELD_PREP (ICE_AQC_LINK_TOPO_NODE_CTX_M ,
5736+ ICE_AQC_LINK_TOPO_NODE_CTX_PROVIDED );
5737+
5738+ addr = cpu_to_le16 ((u16 )offset );
5739+
5740+ return ice_aq_read_i2c (hw , link_topo , 0 , addr , 1 , data , NULL );
5741+ }
5742+
57675743/**
57685744 * ice_aq_set_gpio
57695745 * @hw: pointer to the hw struct
0 commit comments