@@ -1653,31 +1653,29 @@ int usb4_port_margining_caps(struct tb_port *port, enum usb4_sb_target target,
16531653 * @port: USB4 port
16541654 * @target: Sideband target
16551655 * @index: Retimer index if taget is %USB4_SB_TARGET_RETIMER
1656- * @lanes: Which lanes to run (must match the port capabilities). Can be
1657- * %0, %1 or %7.
1658- * @ber_level: BER level contour value
1659- * @timing: Perform timing margining instead of voltage
1660- * @right_high: Use Right/high margin instead of left/low
1656+ * @params: Parameters for USB4 hardware margining
16611657 * @results: Array with at least two elements to hold the results
16621658 *
16631659 * Runs hardware lane margining on USB4 port and returns the result in
16641660 * @results.
16651661 */
16661662int usb4_port_hw_margin (struct tb_port * port , enum usb4_sb_target target ,
1667- u8 index , unsigned int lanes , unsigned int ber_level ,
1668- bool timing , bool right_high , u32 * results )
1663+ u8 index , const struct usb4_port_margining_params * params ,
1664+ u32 * results )
16691665{
16701666 u32 val ;
16711667 int ret ;
16721668
1673- val = lanes ;
1674- if (timing )
1669+ if (WARN_ON_ONCE (!params ))
1670+ return - EINVAL ;
1671+
1672+ val = params -> lanes ;
1673+ if (params -> time )
16751674 val |= USB4_MARGIN_HW_TIME ;
1676- if (right_high )
1675+ if (params -> right_high )
16771676 val |= USB4_MARGIN_HW_RH ;
1678- if (ber_level )
1679- val |= (ber_level << USB4_MARGIN_HW_BER_SHIFT ) &
1680- USB4_MARGIN_HW_BER_MASK ;
1677+ if (params -> ber_level )
1678+ val |= FIELD_PREP (USB4_MARGIN_HW_BER_MASK , params -> ber_level );
16811679
16821680 ret = usb4_port_sb_write (port , target , index , USB4_SB_METADATA , & val ,
16831681 sizeof (val ));
@@ -1698,31 +1696,29 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
16981696 * @port: USB4 port
16991697 * @target: Sideband target
17001698 * @index: Retimer index if taget is %USB4_SB_TARGET_RETIMER
1701- * @lanes: Which lanes to run (must match the port capabilities). Can be
1702- * %0, %1 or %7.
1703- * @timing: Perform timing margining instead of voltage
1704- * @right_high: Use Right/high margin instead of left/low
1705- * @counter: What to do with the error counter
1699+ * @params: Parameters for USB4 software margining
17061700 * @results: Data word for the operation completion data
17071701 *
17081702 * Runs software lane margining on USB4 port. Read back the error
17091703 * counters by calling usb4_port_sw_margin_errors(). Returns %0 in
17101704 * success and negative errno otherwise.
17111705 */
17121706int usb4_port_sw_margin (struct tb_port * port , enum usb4_sb_target target ,
1713- u8 index , unsigned int lanes , bool timing ,
1714- bool right_high , u32 counter , u32 * results )
1707+ u8 index , const struct usb4_port_margining_params * params ,
1708+ u32 * results )
17151709{
17161710 u32 val ;
17171711 int ret ;
17181712
1719- val = lanes ;
1720- if (timing )
1713+ if (WARN_ON_ONCE (!params ))
1714+ return - EINVAL ;
1715+
1716+ val = params -> lanes ;
1717+ if (params -> time )
17211718 val |= USB4_MARGIN_SW_TIME ;
1722- if (right_high )
1719+ if (params -> right_high )
17231720 val |= USB4_MARGIN_SW_RH ;
1724- val |= (counter << USB4_MARGIN_SW_COUNTER_SHIFT ) &
1725- USB4_MARGIN_SW_COUNTER_MASK ;
1721+ val |= FIELD_PREP (USB4_MARGIN_SW_COUNTER_MASK , params -> error_counter );
17261722
17271723 ret = usb4_port_sb_write (port , target , index , USB4_SB_METADATA , & val ,
17281724 sizeof (val ));
0 commit comments