|
@@ -272,6 +272,75 @@ static int realtek_reset ( struct realtek_nic *rtl ) {
|
272
|
272
|
return -ETIMEDOUT;
|
273
|
273
|
}
|
274
|
274
|
|
|
275
|
+/**
|
|
276
|
+ * Configure PHY for Gigabit operation
|
|
277
|
+ *
|
|
278
|
+ * @v rtl Realtek device
|
|
279
|
+ * @ret rc Return status code
|
|
280
|
+ */
|
|
281
|
+static int realtek_phy_speed ( struct realtek_nic *rtl ) {
|
|
282
|
+ int ctrl1000;
|
|
283
|
+ int rc;
|
|
284
|
+
|
|
285
|
+ /* Read CTRL1000 register */
|
|
286
|
+ ctrl1000 = mii_read ( &rtl->mii, MII_CTRL1000 );
|
|
287
|
+ if ( ctrl1000 < 0 ) {
|
|
288
|
+ rc = ctrl1000;
|
|
289
|
+ DBGC ( rtl, "REALTEK %p could not read CTRL1000: %s\n",
|
|
290
|
+ rtl, strerror ( rc ) );
|
|
291
|
+ return rc;
|
|
292
|
+ }
|
|
293
|
+
|
|
294
|
+ /* Advertise 1000Mbps speeds */
|
|
295
|
+ ctrl1000 |= ( ADVERTISE_1000FULL | ADVERTISE_1000HALF );
|
|
296
|
+ if ( ( rc = mii_write ( &rtl->mii, MII_CTRL1000, ctrl1000 ) ) != 0 ) {
|
|
297
|
+ DBGC ( rtl, "REALTEK %p could not write CTRL1000: %s\n",
|
|
298
|
+ rtl, strerror ( rc ) );
|
|
299
|
+ return rc;
|
|
300
|
+ }
|
|
301
|
+
|
|
302
|
+ return 0;
|
|
303
|
+}
|
|
304
|
+
|
|
305
|
+/**
|
|
306
|
+ * Reset PHY
|
|
307
|
+ *
|
|
308
|
+ * @v rtl Realtek device
|
|
309
|
+ * @ret rc Return status code
|
|
310
|
+ */
|
|
311
|
+static int realtek_phy_reset ( struct realtek_nic *rtl ) {
|
|
312
|
+ int rc;
|
|
313
|
+
|
|
314
|
+ /* Do nothing if we have no separate PHY register access */
|
|
315
|
+ if ( ! rtl->have_phy_regs )
|
|
316
|
+ return 0;
|
|
317
|
+
|
|
318
|
+ /* Perform MII reset */
|
|
319
|
+ if ( ( rc = mii_reset ( &rtl->mii ) ) != 0 ) {
|
|
320
|
+ DBGC ( rtl, "REALTEK %p could not reset MII: %s\n",
|
|
321
|
+ rtl, strerror ( rc ) );
|
|
322
|
+ return rc;
|
|
323
|
+ }
|
|
324
|
+
|
|
325
|
+ /* Some cards (e.g. RTL8169SC) do not advertise Gigabit by
|
|
326
|
+ * default. Try to enable advertisement of Gigabit speeds.
|
|
327
|
+ */
|
|
328
|
+ if ( ( rc = realtek_phy_speed ( rtl ) ) != 0 ) {
|
|
329
|
+ /* Ignore failures, since the register may not be
|
|
330
|
+ * present on non-Gigabit PHYs (e.g. RTL8101).
|
|
331
|
+ */
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ /* Restart autonegotiation */
|
|
335
|
+ if ( ( rc = mii_restart ( &rtl->mii ) ) != 0 ) {
|
|
336
|
+ DBGC ( rtl, "REALTEK %p could not restart MII: %s\n",
|
|
337
|
+ rtl, strerror ( rc ) );
|
|
338
|
+ return rc;
|
|
339
|
+ }
|
|
340
|
+
|
|
341
|
+ return 0;
|
|
342
|
+}
|
|
343
|
+
|
275
|
344
|
/******************************************************************************
|
276
|
345
|
*
|
277
|
346
|
* Link state
|
|
@@ -970,12 +1039,8 @@ static int realtek_probe ( struct pci_device *pci ) {
|
970
|
1039
|
|
971
|
1040
|
/* Initialise and reset MII interface */
|
972
|
1041
|
mii_init ( &rtl->mii, &realtek_mii_operations );
|
973
|
|
- if ( rtl->have_phy_regs &&
|
974
|
|
- ( ( rc = mii_reset ( &rtl->mii ) ) != 0 ) ) {
|
975
|
|
- DBGC ( rtl, "REALTEK %p could not reset MII: %s\n",
|
976
|
|
- rtl, strerror ( rc ) );
|
977
|
|
- goto err_mii_reset;
|
978
|
|
- }
|
|
1042
|
+ if ( ( rc = realtek_phy_reset ( rtl ) ) != 0 )
|
|
1043
|
+ goto err_phy_reset;
|
979
|
1044
|
|
980
|
1045
|
/* Register network device */
|
981
|
1046
|
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
|
@@ -996,7 +1061,7 @@ static int realtek_probe ( struct pci_device *pci ) {
|
996
|
1061
|
err_register_nvo:
|
997
|
1062
|
unregister_netdev ( netdev );
|
998
|
1063
|
err_register_netdev:
|
999
|
|
- err_mii_reset:
|
|
1064
|
+ err_phy_reset:
|
1000
|
1065
|
err_nvs_read:
|
1001
|
1066
|
realtek_reset ( rtl );
|
1002
|
1067
|
err_reset:
|