@@ -185,128 +185,14 @@ static int ice_set_mac_type(struct ice_hw *hw)
185185 * ice_is_generic_mac - check if device's mac_type is generic
186186 * @hw: pointer to the hardware structure
187187 *
188- * Return: true if mac_type is generic (with SBQ support) , false if not
188+ * Return: true if mac_type is ICE_MAC_GENERIC* , false otherwise.
189189 */
190190bool ice_is_generic_mac (struct ice_hw * hw )
191191{
192192 return (hw -> mac_type == ICE_MAC_GENERIC ||
193193 hw -> mac_type == ICE_MAC_GENERIC_3K_E825 );
194194}
195195
196- /**
197- * ice_is_e810
198- * @hw: pointer to the hardware structure
199- *
200- * returns true if the device is E810 based, false if not.
201- */
202- bool ice_is_e810 (struct ice_hw * hw )
203- {
204- return hw -> mac_type == ICE_MAC_E810 ;
205- }
206-
207- /**
208- * ice_is_e810t
209- * @hw: pointer to the hardware structure
210- *
211- * returns true if the device is E810T based, false if not.
212- */
213- bool ice_is_e810t (struct ice_hw * hw )
214- {
215- switch (hw -> device_id ) {
216- case ICE_DEV_ID_E810C_SFP :
217- switch (hw -> subsystem_device_id ) {
218- case ICE_SUBDEV_ID_E810T :
219- case ICE_SUBDEV_ID_E810T2 :
220- case ICE_SUBDEV_ID_E810T3 :
221- case ICE_SUBDEV_ID_E810T4 :
222- case ICE_SUBDEV_ID_E810T6 :
223- case ICE_SUBDEV_ID_E810T7 :
224- return true;
225- }
226- break ;
227- case ICE_DEV_ID_E810C_QSFP :
228- switch (hw -> subsystem_device_id ) {
229- case ICE_SUBDEV_ID_E810T2 :
230- case ICE_SUBDEV_ID_E810T3 :
231- case ICE_SUBDEV_ID_E810T5 :
232- return true;
233- }
234- break ;
235- default :
236- break ;
237- }
238-
239- return false;
240- }
241-
242- /**
243- * ice_is_e822 - Check if a device is E822 family device
244- * @hw: pointer to the hardware structure
245- *
246- * Return: true if the device is E822 based, false if not.
247- */
248- bool ice_is_e822 (struct ice_hw * hw )
249- {
250- switch (hw -> device_id ) {
251- case ICE_DEV_ID_E822C_BACKPLANE :
252- case ICE_DEV_ID_E822C_QSFP :
253- case ICE_DEV_ID_E822C_SFP :
254- case ICE_DEV_ID_E822C_10G_BASE_T :
255- case ICE_DEV_ID_E822C_SGMII :
256- case ICE_DEV_ID_E822L_BACKPLANE :
257- case ICE_DEV_ID_E822L_SFP :
258- case ICE_DEV_ID_E822L_10G_BASE_T :
259- case ICE_DEV_ID_E822L_SGMII :
260- return true;
261- default :
262- return false;
263- }
264- }
265-
266- /**
267- * ice_is_e823
268- * @hw: pointer to the hardware structure
269- *
270- * returns true if the device is E823-L or E823-C based, false if not.
271- */
272- bool ice_is_e823 (struct ice_hw * hw )
273- {
274- switch (hw -> device_id ) {
275- case ICE_DEV_ID_E823L_BACKPLANE :
276- case ICE_DEV_ID_E823L_SFP :
277- case ICE_DEV_ID_E823L_10G_BASE_T :
278- case ICE_DEV_ID_E823L_1GBE :
279- case ICE_DEV_ID_E823L_QSFP :
280- case ICE_DEV_ID_E823C_BACKPLANE :
281- case ICE_DEV_ID_E823C_QSFP :
282- case ICE_DEV_ID_E823C_SFP :
283- case ICE_DEV_ID_E823C_10G_BASE_T :
284- case ICE_DEV_ID_E823C_SGMII :
285- return true;
286- default :
287- return false;
288- }
289- }
290-
291- /**
292- * ice_is_e825c - Check if a device is E825C family device
293- * @hw: pointer to the hardware structure
294- *
295- * Return: true if the device is E825-C based, false if not.
296- */
297- bool ice_is_e825c (struct ice_hw * hw )
298- {
299- switch (hw -> device_id ) {
300- case ICE_DEV_ID_E825C_BACKPLANE :
301- case ICE_DEV_ID_E825C_QSFP :
302- case ICE_DEV_ID_E825C_SFP :
303- case ICE_DEV_ID_E825C_SGMII :
304- return true;
305- default :
306- return false;
307- }
308- }
309-
310196/**
311197 * ice_is_pf_c827 - check if pf contains c827 phy
312198 * @hw: pointer to the hw struct
@@ -2388,7 +2274,7 @@ ice_parse_1588_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
23882274 info -> tmr_index_owned = ((number & ICE_TS_TMR_IDX_OWND_M ) != 0 );
23892275 info -> tmr_index_assoc = ((number & ICE_TS_TMR_IDX_ASSOC_M ) != 0 );
23902276
2391- if (! ice_is_e825c ( hw ) ) {
2277+ if (hw -> mac_type != ICE_MAC_GENERIC_3K_E825 ) {
23922278 info -> clk_freq = FIELD_GET (ICE_TS_CLK_FREQ_M , number );
23932279 info -> clk_src = ((number & ICE_TS_CLK_SRC_M ) != 0 );
23942280 } else {
@@ -5922,6 +5808,96 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
59225808 return ice_aq_send_cmd (hw , & desc , NULL , 0 , cd );
59235809}
59245810
5811+ /**
5812+ * ice_get_pca9575_handle - find and return the PCA9575 controller
5813+ * @hw: pointer to the hw struct
5814+ * @pca9575_handle: GPIO controller's handle
5815+ *
5816+ * Find and return the GPIO controller's handle in the netlist.
5817+ * When found - the value will be cached in the hw structure and following calls
5818+ * will return cached value.
5819+ *
5820+ * Return: 0 on success, -ENXIO when there's no PCA9575 present.
5821+ */
5822+ int ice_get_pca9575_handle (struct ice_hw * hw , u16 * pca9575_handle )
5823+ {
5824+ struct ice_aqc_get_link_topo * cmd ;
5825+ struct ice_aq_desc desc ;
5826+ int err ;
5827+ u8 idx ;
5828+
5829+ /* If handle was read previously return cached value */
5830+ if (hw -> io_expander_handle ) {
5831+ * pca9575_handle = hw -> io_expander_handle ;
5832+ return 0 ;
5833+ }
5834+
5835+ #define SW_PCA9575_SFP_TOPO_IDX 2
5836+ #define SW_PCA9575_QSFP_TOPO_IDX 1
5837+
5838+ /* Check if the SW IO expander controlling SMA exists in the netlist. */
5839+ if (hw -> device_id == ICE_DEV_ID_E810C_SFP )
5840+ idx = SW_PCA9575_SFP_TOPO_IDX ;
5841+ else if (hw -> device_id == ICE_DEV_ID_E810C_QSFP )
5842+ idx = SW_PCA9575_QSFP_TOPO_IDX ;
5843+ else
5844+ return - ENXIO ;
5845+
5846+ /* If handle was not detected read it from the netlist */
5847+ ice_fill_dflt_direct_cmd_desc (& desc , ice_aqc_opc_get_link_topo );
5848+ cmd = & desc .params .get_link_topo ;
5849+ cmd -> addr .topo_params .node_type_ctx =
5850+ ICE_AQC_LINK_TOPO_NODE_TYPE_GPIO_CTRL ;
5851+ cmd -> addr .topo_params .index = idx ;
5852+
5853+ err = ice_aq_send_cmd (hw , & desc , NULL , 0 , NULL );
5854+ if (err )
5855+ return - ENXIO ;
5856+
5857+ /* Verify if we found the right IO expander type */
5858+ if (desc .params .get_link_topo .node_part_num !=
5859+ ICE_AQC_GET_LINK_TOPO_NODE_NR_PCA9575 )
5860+ return - ENXIO ;
5861+
5862+ /* If present save the handle and return it */
5863+ hw -> io_expander_handle =
5864+ le16_to_cpu (desc .params .get_link_topo .addr .handle );
5865+ * pca9575_handle = hw -> io_expander_handle ;
5866+
5867+ return 0 ;
5868+ }
5869+
5870+ /**
5871+ * ice_read_pca9575_reg - read the register from the PCA9575 controller
5872+ * @hw: pointer to the hw struct
5873+ * @offset: GPIO controller register offset
5874+ * @data: pointer to data to be read from the GPIO controller
5875+ *
5876+ * Return: 0 on success, negative error code otherwise.
5877+ */
5878+ int ice_read_pca9575_reg (struct ice_hw * hw , u8 offset , u8 * data )
5879+ {
5880+ struct ice_aqc_link_topo_addr link_topo ;
5881+ __le16 addr ;
5882+ u16 handle ;
5883+ int err ;
5884+
5885+ memset (& link_topo , 0 , sizeof (link_topo ));
5886+
5887+ err = ice_get_pca9575_handle (hw , & handle );
5888+ if (err )
5889+ return err ;
5890+
5891+ link_topo .handle = cpu_to_le16 (handle );
5892+ link_topo .topo_params .node_type_ctx =
5893+ FIELD_PREP (ICE_AQC_LINK_TOPO_NODE_CTX_M ,
5894+ ICE_AQC_LINK_TOPO_NODE_CTX_PROVIDED );
5895+
5896+ addr = cpu_to_le16 ((u16 )offset );
5897+
5898+ return ice_aq_read_i2c (hw , link_topo , 0 , addr , 1 , data , NULL );
5899+ }
5900+
59255901/**
59265902 * ice_aq_set_gpio
59275903 * @hw: pointer to the hw struct
0 commit comments