@@ -166,6 +166,7 @@ static const enum gpiod_flags gpio_flags[] = {
166166 * on board (for a copper SFP) time to initialise.
167167 */
168168#define T_WAIT msecs_to_jiffies(50)
169+ #define T_WAIT_ROLLBALL msecs_to_jiffies(25000)
169170#define T_START_UP msecs_to_jiffies(300)
170171#define T_START_UP_BAD_GPON msecs_to_jiffies(60000)
171172
@@ -205,8 +206,11 @@ static const enum gpiod_flags gpio_flags[] = {
205206
206207/* SFP modules appear to always have their PHY configured for bus address
207208 * 0x56 (which with mdio-i2c, translates to a PHY address of 22).
209+ * RollBall SFPs access phy via SFP Enhanced Digital Diagnostic Interface
210+ * via address 0x51 (mdio-i2c will use RollBall protocol on this address).
208211 */
209- #define SFP_PHY_ADDR 22
212+ #define SFP_PHY_ADDR 22
213+ #define SFP_PHY_ADDR_ROLLBALL 17
210214
211215struct sff_data {
212216 unsigned int gpios ;
@@ -252,6 +256,7 @@ struct sfp {
252256 struct sfp_eeprom_id id ;
253257 unsigned int module_power_mW ;
254258 unsigned int module_t_start_up ;
259+ unsigned int module_t_wait ;
255260 bool tx_fault_ignore ;
256261
257262 const struct sfp_quirk * quirk ;
@@ -331,6 +336,22 @@ static void sfp_fixup_halny_gsfp(struct sfp *sfp)
331336 sfp -> state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS );
332337}
333338
339+ static void sfp_fixup_rollball (struct sfp * sfp )
340+ {
341+ sfp -> mdio_protocol = MDIO_I2C_ROLLBALL ;
342+ sfp -> module_t_wait = T_WAIT_ROLLBALL ;
343+ }
344+
345+ static void sfp_fixup_rollball_cc (struct sfp * sfp )
346+ {
347+ sfp_fixup_rollball (sfp );
348+
349+ /* Some RollBall SFPs may have wrong (zero) extended compliance code
350+ * burned in EEPROM. For PHY probing we need the correct one.
351+ */
352+ sfp -> id .base .extended_cc = SFF8024_ECC_10GBASE_T_SFI ;
353+ }
354+
334355static void sfp_quirk_2500basex (const struct sfp_eeprom_id * id ,
335356 unsigned long * modes ,
336357 unsigned long * interfaces )
@@ -378,6 +399,12 @@ static const struct sfp_quirk sfp_quirks[] = {
378399 SFP_QUIRK_M ("Lantech" , "8330-262D-E" , sfp_quirk_2500basex ),
379400
380401 SFP_QUIRK_M ("UBNT" , "UF-INSTANT" , sfp_quirk_ubnt_uf_instant ),
402+
403+ SFP_QUIRK_F ("OEM" , "SFP-10G-T" , sfp_fixup_rollball_cc ),
404+ SFP_QUIRK_F ("OEM" , "RTSFP-10" , sfp_fixup_rollball_cc ),
405+ SFP_QUIRK_F ("OEM" , "RTSFP-10G" , sfp_fixup_rollball_cc ),
406+ SFP_QUIRK_F ("Turris" , "RTSFP-10" , sfp_fixup_rollball ),
407+ SFP_QUIRK_F ("Turris" , "RTSFP-10G" , sfp_fixup_rollball ),
381408};
382409
383410static size_t sfp_strlen (const char * str , size_t maxlen )
@@ -1585,12 +1612,12 @@ static void sfp_sm_phy_detach(struct sfp *sfp)
15851612 sfp -> mod_phy = NULL ;
15861613}
15871614
1588- static int sfp_sm_probe_phy (struct sfp * sfp , bool is_c45 )
1615+ static int sfp_sm_probe_phy (struct sfp * sfp , int addr , bool is_c45 )
15891616{
15901617 struct phy_device * phy ;
15911618 int err ;
15921619
1593- phy = get_phy_device (sfp -> i2c_mii , SFP_PHY_ADDR , is_c45 );
1620+ phy = get_phy_device (sfp -> i2c_mii , addr , is_c45 );
15941621 if (phy == ERR_PTR (- ENODEV ))
15951622 return PTR_ERR (phy );
15961623 if (IS_ERR (phy )) {
@@ -1714,15 +1741,15 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
17141741 break ;
17151742
17161743 case MDIO_I2C_MARVELL_C22 :
1717- err = sfp_sm_probe_phy (sfp , false);
1744+ err = sfp_sm_probe_phy (sfp , SFP_PHY_ADDR , false);
17181745 break ;
17191746
17201747 case MDIO_I2C_C45 :
1721- err = sfp_sm_probe_phy (sfp , true);
1748+ err = sfp_sm_probe_phy (sfp , SFP_PHY_ADDR , true);
17221749 break ;
17231750
17241751 case MDIO_I2C_ROLLBALL :
1725- err = - EOPNOTSUPP ;
1752+ err = sfp_sm_probe_phy ( sfp , SFP_PHY_ADDR_ROLLBALL , true) ;
17261753 break ;
17271754 }
17281755
@@ -2049,6 +2076,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
20492076 sfp -> state_hw_mask |= SFP_F_LOS ;
20502077
20512078 sfp -> module_t_start_up = T_START_UP ;
2079+ sfp -> module_t_wait = T_WAIT ;
20522080
20532081 sfp -> tx_fault_ignore = false;
20542082
@@ -2263,9 +2291,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
22632291
22642292 /* We need to check the TX_FAULT state, which is not defined
22652293 * while TX_DISABLE is asserted. The earliest we want to do
2266- * anything (such as probe for a PHY) is 50ms.
2294+ * anything (such as probe for a PHY) is 50ms (or more on
2295+ * specific modules).
22672296 */
2268- sfp_sm_next (sfp , SFP_S_WAIT , T_WAIT );
2297+ sfp_sm_next (sfp , SFP_S_WAIT , sfp -> module_t_wait );
22692298 break ;
22702299
22712300 case SFP_S_WAIT :
@@ -2279,8 +2308,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
22792308 * deasserting.
22802309 */
22812310 timeout = sfp -> module_t_start_up ;
2282- if (timeout > T_WAIT )
2283- timeout -= T_WAIT ;
2311+ if (timeout > sfp -> module_t_wait )
2312+ timeout -= sfp -> module_t_wait ;
22842313 else
22852314 timeout = 1 ;
22862315
0 commit comments