History

r8169: improve RTL8411b phy-down fixup

Mirsad proposed a patch to reduce the number of spinlock lock/unlock operations and the function code size. This can be further improved because the function sets a consecutive register block.

Heiner Kallweit committed 3 years ago

Commit 055dd751 parent ce30df21 file · +28 −111Browse files

Unified · Split

drivers/net/ethernet/realtek/r8169_main.c+28−111
@@ -3102,6 +3102,33 @@ static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) · 3101 unmodified lines
31023102 rtl_ephy_init(tp, e_info_8168g_2);
31033103 }
31043104
3105+static void rtl8411b_fix_phy_down(struct rtl8169_private *tp)
3106+{
3107+ static const u16 fix_data[] = {
3108+/* 0xf800 */ 0xe008, 0xe00a, 0xe00c, 0xe00e, 0xe027, 0xe04f, 0xe05e, 0xe065,
3109+/* 0xf810 */ 0xc602, 0xbe00, 0x0000, 0xc502, 0xbd00, 0x074c, 0xc302, 0xbb00,
3110+/* 0xf820 */ 0x080a, 0x6420, 0x48c2, 0x8c20, 0xc516, 0x64a4, 0x49c0, 0xf009,
3111+/* 0xf830 */ 0x74a2, 0x8ca5, 0x74a0, 0xc50e, 0x9ca2, 0x1c11, 0x9ca0, 0xe006,
3112+/* 0xf840 */ 0x74f8, 0x48c4, 0x8cf8, 0xc404, 0xbc00, 0xc403, 0xbc00, 0x0bf2,
3113+/* 0xf850 */ 0x0c0a, 0xe434, 0xd3c0, 0x49d9, 0xf01f, 0xc526, 0x64a5, 0x1400,
3114+/* 0xf860 */ 0xf007, 0x0c01, 0x8ca5, 0x1c15, 0xc51b, 0x9ca0, 0xe013, 0xc519,
3115+/* 0xf870 */ 0x74a0, 0x48c4, 0x8ca0, 0xc516, 0x74a4, 0x48c8, 0x48ca, 0x9ca4,
3116+/* 0xf880 */ 0xc512, 0x1b00, 0x9ba0, 0x1b1c, 0x483f, 0x9ba2, 0x1b04, 0xc508,
3117+/* 0xf890 */ 0x9ba0, 0xc505, 0xbd00, 0xc502, 0xbd00, 0x0300, 0x051e, 0xe434,
3118+/* 0xf8a0 */ 0xe018, 0xe092, 0xde20, 0xd3c0, 0xc50f, 0x76a4, 0x49e3, 0xf007,
3119+/* 0xf8b0 */ 0x49c0, 0xf103, 0xc607, 0xbe00, 0xc606, 0xbe00, 0xc602, 0xbe00,
3120+/* 0xf8c0 */ 0x0c4c, 0x0c28, 0x0c2c, 0xdc00, 0xc707, 0x1d00, 0x8de2, 0x48c1,
3121+/* 0xf8d0 */ 0xc502, 0xbd00, 0x00aa, 0xe0c0, 0xc502, 0xbd00, 0x0132
3122+ };
3123+ unsigned long flags;
3124+ int i;
3125+
3126+ raw_spin_lock_irqsave(&tp->mac_ocp_lock, flags);
3127+ for (i = 0; i < ARRAY_SIZE(fix_data); i++)
3128+ __r8168_mac_ocp_write(tp, 0xf800 + 2 * i, fix_data[i]);
3129+ raw_spin_unlock_irqrestore(&tp->mac_ocp_lock, flags);
3130+}
3131+
31053132 static void rtl_hw_start_8411_2(struct rtl8169_private *tp)
31063133 {
31073134 static const struct ephy_info e_info_8411_2[] = {
@@ -3135,117 +3162,7 @@ static void rtl_hw_start_8411_2(struct rtl8169_private *tp) · 27 unmodified lines
31353162 mdelay(3);
31363163 r8168_mac_ocp_write(tp, 0xFC26, 0x0000);
31373164
3138− r8168_mac_ocp_write(tp, 0xF800, 0xE008);
3139− r8168_mac_ocp_write(tp, 0xF802, 0xE00A);
3140− r8168_mac_ocp_write(tp, 0xF804, 0xE00C);
3141− r8168_mac_ocp_write(tp, 0xF806, 0xE00E);
3142− r8168_mac_ocp_write(tp, 0xF808, 0xE027);
3143− r8168_mac_ocp_write(tp, 0xF80A, 0xE04F);
3144− r8168_mac_ocp_write(tp, 0xF80C, 0xE05E);
3145− r8168_mac_ocp_write(tp, 0xF80E, 0xE065);
3146− r8168_mac_ocp_write(tp, 0xF810, 0xC602);
3147− r8168_mac_ocp_write(tp, 0xF812, 0xBE00);
3148− r8168_mac_ocp_write(tp, 0xF814, 0x0000);
3149− r8168_mac_ocp_write(tp, 0xF816, 0xC502);
3150− r8168_mac_ocp_write(tp, 0xF818, 0xBD00);
3151− r8168_mac_ocp_write(tp, 0xF81A, 0x074C);
3152− r8168_mac_ocp_write(tp, 0xF81C, 0xC302);
3153− r8168_mac_ocp_write(tp, 0xF81E, 0xBB00);
3154− r8168_mac_ocp_write(tp, 0xF820, 0x080A);
3155− r8168_mac_ocp_write(tp, 0xF822, 0x6420);
3156− r8168_mac_ocp_write(tp, 0xF824, 0x48C2);
3157− r8168_mac_ocp_write(tp, 0xF826, 0x8C20);
3158− r8168_mac_ocp_write(tp, 0xF828, 0xC516);
3159− r8168_mac_ocp_write(tp, 0xF82A, 0x64A4);
3160− r8168_mac_ocp_write(tp, 0xF82C, 0x49C0);
3161− r8168_mac_ocp_write(tp, 0xF82E, 0xF009);
3162− r8168_mac_ocp_write(tp, 0xF830, 0x74A2);
3163− r8168_mac_ocp_write(tp, 0xF832, 0x8CA5);
3164− r8168_mac_ocp_write(tp, 0xF834, 0x74A0);
3165− r8168_mac_ocp_write(tp, 0xF836, 0xC50E);
3166− r8168_mac_ocp_write(tp, 0xF838, 0x9CA2);
3167− r8168_mac_ocp_write(tp, 0xF83A, 0x1C11);
3168− r8168_mac_ocp_write(tp, 0xF83C, 0x9CA0);
3169− r8168_mac_ocp_write(tp, 0xF83E, 0xE006);
3170− r8168_mac_ocp_write(tp, 0xF840, 0x74F8);
3171− r8168_mac_ocp_write(tp, 0xF842, 0x48C4);
3172− r8168_mac_ocp_write(tp, 0xF844, 0x8CF8);
3173− r8168_mac_ocp_write(tp, 0xF846, 0xC404);
3174− r8168_mac_ocp_write(tp, 0xF848, 0xBC00);
3175− r8168_mac_ocp_write(tp, 0xF84A, 0xC403);
3176− r8168_mac_ocp_write(tp, 0xF84C, 0xBC00);
3177− r8168_mac_ocp_write(tp, 0xF84E, 0x0BF2);
3178− r8168_mac_ocp_write(tp, 0xF850, 0x0C0A);
3179− r8168_mac_ocp_write(tp, 0xF852, 0xE434);
3180− r8168_mac_ocp_write(tp, 0xF854, 0xD3C0);
3181− r8168_mac_ocp_write(tp, 0xF856, 0x49D9);
3182− r8168_mac_ocp_write(tp, 0xF858, 0xF01F);
3183− r8168_mac_ocp_write(tp, 0xF85A, 0xC526);
3184− r8168_mac_ocp_write(tp, 0xF85C, 0x64A5);
3185− r8168_mac_ocp_write(tp, 0xF85E, 0x1400);
3186− r8168_mac_ocp_write(tp, 0xF860, 0xF007);
3187− r8168_mac_ocp_write(tp, 0xF862, 0x0C01);
3188− r8168_mac_ocp_write(tp, 0xF864, 0x8CA5);
3189− r8168_mac_ocp_write(tp, 0xF866, 0x1C15);
3190− r8168_mac_ocp_write(tp, 0xF868, 0xC51B);
3191− r8168_mac_ocp_write(tp, 0xF86A, 0x9CA0);
3192− r8168_mac_ocp_write(tp, 0xF86C, 0xE013);
3193− r8168_mac_ocp_write(tp, 0xF86E, 0xC519);
3194− r8168_mac_ocp_write(tp, 0xF870, 0x74A0);
3195− r8168_mac_ocp_write(tp, 0xF872, 0x48C4);
3196− r8168_mac_ocp_write(tp, 0xF874, 0x8CA0);
3197− r8168_mac_ocp_write(tp, 0xF876, 0xC516);
3198− r8168_mac_ocp_write(tp, 0xF878, 0x74A4);
3199− r8168_mac_ocp_write(tp, 0xF87A, 0x48C8);
3200− r8168_mac_ocp_write(tp, 0xF87C, 0x48CA);
3201− r8168_mac_ocp_write(tp, 0xF87E, 0x9CA4);
3202− r8168_mac_ocp_write(tp, 0xF880, 0xC512);
3203− r8168_mac_ocp_write(tp, 0xF882, 0x1B00);
3204− r8168_mac_ocp_write(tp, 0xF884, 0x9BA0);
3205− r8168_mac_ocp_write(tp, 0xF886, 0x1B1C);
3206− r8168_mac_ocp_write(tp, 0xF888, 0x483F);
3207− r8168_mac_ocp_write(tp, 0xF88A, 0x9BA2);
3208− r8168_mac_ocp_write(tp, 0xF88C, 0x1B04);
3209− r8168_mac_ocp_write(tp, 0xF88E, 0xC508);
3210− r8168_mac_ocp_write(tp, 0xF890, 0x9BA0);
3211− r8168_mac_ocp_write(tp, 0xF892, 0xC505);
3212− r8168_mac_ocp_write(tp, 0xF894, 0xBD00);
3213− r8168_mac_ocp_write(tp, 0xF896, 0xC502);
3214− r8168_mac_ocp_write(tp, 0xF898, 0xBD00);
3215− r8168_mac_ocp_write(tp, 0xF89A, 0x0300);
3216− r8168_mac_ocp_write(tp, 0xF89C, 0x051E);
3217− r8168_mac_ocp_write(tp, 0xF89E, 0xE434);
3218− r8168_mac_ocp_write(tp, 0xF8A0, 0xE018);
3219− r8168_mac_ocp_write(tp, 0xF8A2, 0xE092);
3220− r8168_mac_ocp_write(tp, 0xF8A4, 0xDE20);
3221− r8168_mac_ocp_write(tp, 0xF8A6, 0xD3C0);
3222− r8168_mac_ocp_write(tp, 0xF8A8, 0xC50F);
3223− r8168_mac_ocp_write(tp, 0xF8AA, 0x76A4);
3224− r8168_mac_ocp_write(tp, 0xF8AC, 0x49E3);
3225− r8168_mac_ocp_write(tp, 0xF8AE, 0xF007);
3226− r8168_mac_ocp_write(tp, 0xF8B0, 0x49C0);
3227− r8168_mac_ocp_write(tp, 0xF8B2, 0xF103);
3228− r8168_mac_ocp_write(tp, 0xF8B4, 0xC607);
3229− r8168_mac_ocp_write(tp, 0xF8B6, 0xBE00);
3230− r8168_mac_ocp_write(tp, 0xF8B8, 0xC606);
3231− r8168_mac_ocp_write(tp, 0xF8BA, 0xBE00);
3232− r8168_mac_ocp_write(tp, 0xF8BC, 0xC602);
3233− r8168_mac_ocp_write(tp, 0xF8BE, 0xBE00);
3234− r8168_mac_ocp_write(tp, 0xF8C0, 0x0C4C);
3235− r8168_mac_ocp_write(tp, 0xF8C2, 0x0C28);
3236− r8168_mac_ocp_write(tp, 0xF8C4, 0x0C2C);
3237− r8168_mac_ocp_write(tp, 0xF8C6, 0xDC00);
3238− r8168_mac_ocp_write(tp, 0xF8C8, 0xC707);
3239− r8168_mac_ocp_write(tp, 0xF8CA, 0x1D00);
3240− r8168_mac_ocp_write(tp, 0xF8CC, 0x8DE2);
3241− r8168_mac_ocp_write(tp, 0xF8CE, 0x48C1);
3242− r8168_mac_ocp_write(tp, 0xF8D0, 0xC502);
3243− r8168_mac_ocp_write(tp, 0xF8D2, 0xBD00);
3244− r8168_mac_ocp_write(tp, 0xF8D4, 0x00AA);
3245− r8168_mac_ocp_write(tp, 0xF8D6, 0xE0C0);
3246− r8168_mac_ocp_write(tp, 0xF8D8, 0xC502);
3247− r8168_mac_ocp_write(tp, 0xF8DA, 0xBD00);
3248− r8168_mac_ocp_write(tp, 0xF8DC, 0x0132);
3165+ rtl8411b_fix_phy_down(tp);
32493166
32503167 r8168_mac_ocp_write(tp, 0xFC26, 0x8000);
32513168

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t