r8169: Remove firmware code
PATCH 1/5 r8169: Remove firmware code
Some codes are belong to binary codes and should be removed.
--- drivers/net/ethernet/realtek/r8169.c | 26 -------------------------- 1 file changed, 26 deletions(-)
drivers/net/ethernet/realtek/r8169.c +0 -26
@@ -3408,32 +3408,6 @@ static void rtl8411_hw_phy_config(struct rtl8169_private *tp)static void rtl8168g_1_hw_phy_config (struct rtl8169_private *tp) { -static const u16 mac_ocp_patch[] = { -0xe008 ,0xe01b ,0xe01d ,0xe01f , -0xe021 ,0xe023 ,0xe025 ,0xe027 , -0x49d2 ,0xf10d ,0x766c ,0x49e2 , -0xf00a ,0x1ec0 ,0x8ee1 ,0xc60a , - -0x77c0 ,0x4870 ,0x9fc0 ,0x1ea0 , -0xc707 ,0x8ee1 ,0x9d6c ,0xc603 , -0xbe00 ,0xb416 ,0x0076 ,0xe86c , -0xc602 ,0xbe00 ,0x0000 ,0xc602 , - -0xbe00 ,0x0000 ,0xc602 ,0xbe00 , -0x0000 ,0xc602 ,0xbe00 ,0x0000 , -0xc602 ,0xbe00 ,0x0000 ,0xc602 , -0xbe00 ,0x0000 ,0xc602 ,0xbe00 , - -0x0000 ,0x0000 ,0x0000 ,0x0000 - }; -u32 i; - -/* Patch code for GPHY reset */ -for (i =0 ; i <ARRAY_SIZE (mac_ocp_patch); i++) -r8168_mac_ocp_write (tp,0xf800 +2 *i, mac_ocp_patch[i]); -r8168_mac_ocp_write (tp,0xfc26 ,0x8000 ); -r8168_mac_ocp_write (tp,0xfc28 ,0x0075 ); -rtl_apply_firmware (tp);if (r8168_phy_ocp_read (tp,0xa460 ) &0x0100 )
Signature · 1 line
1.8.1
PATCH 2/5 r8169: Update PHY settings of RTL8111G
- Replace the current settings with rtl_writephy and rtl_readphy. For the hardware, the settings are same with previous ones. This make the setting method like the previous chips.
- Add new PHY settings.
--- drivers/net/ethernet/realtek/r8169.c | 72 +++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 21 deletions(-)
drivers/net/ethernet/realtek/r8169.c +51 -21
@@ -1029,14 +1029,6 @@ static u16 r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg) (RTL_R32(GPHY_OCP) & 0xffff) : ~0; } -static void rtl_w1w0_phy_ocp (struct rtl8169_private *tp,int reg,int p,int m) -{ -int val; - - val =r8168_phy_ocp_read (tp, reg); -r8168_phy_ocp_write (tp, reg, (val | p) & ~m); -} -static void r8168_mac_ocp_write (struct rtl8169_private *tp,u32 reg,u32 data) {void __iomem *ioaddr = tp->mmio_addr;
@@ -3410,23 +3402,61 @@ static void rtl8168g_1_hw_phy_config(struct rtl8169_private *tp) {rtl_apply_firmware (tp); -if (r8168_phy_ocp_read (tp,0xa460 ) &0x0100 ) -rtl_w1w0_phy_ocp (tp,0xbcc4 ,0x0000 ,0x8000 ); -else -rtl_w1w0_phy_ocp (tp,0xbcc4 ,0x8000 ,0x0000 ); +rtl_writephy (tp,0x1f ,0x0a46 ); +if (rtl_readphy (tp,0x10 ) &0x0100 ) { +rtl_writephy (tp,0x1f ,0x0bcc ); +rtl_w1w0_phy (tp,0x12 ,0x0000 ,0x8000 ); + }else { +rtl_writephy (tp,0x1f ,0x0bcc ); +rtl_w1w0_phy (tp,0x12 ,0x8000 ,0x0000 ); + } -if (r8168_phy_ocp_read (tp,0xa466 ) &0x0100 ) -rtl_w1w0_phy_ocp (tp,0xc41a ,0x0002 ,0x0000 ); -else -rtl_w1w0_phy_ocp (tp,0xbcc4 ,0x0000 ,0x0002 ); +rtl_writephy (tp,0x1f ,0x0a46 ); +if (rtl_readphy (tp,0x13 ) &0x0100 ) { +rtl_writephy (tp,0x1f ,0x0c41 ); +rtl_w1w0_phy (tp,0x15 ,0x0002 ,0x0000 ); + }else { +rtl_writephy (tp,0x1f ,0x0c41 ); +rtl_w1w0_phy (tp,0x15 ,0x0000 ,0x0002 ); + } -rtl_w1w0_phy_ocp (tp,0xa442 ,0x000c ,0x0000 ); -rtl_w1w0_phy_ocp (tp,0xa4b2 ,0x0004 ,0x0000 ); +/* Enable PHY auto speed down */ +rtl_writephy (tp,0x1f ,0x0a44 ); +rtl_w1w0_phy (tp,0x11 ,0x000c ,0x0000 ); + +rtl_writephy (tp,0x1f ,0x0bcc ); +rtl_w1w0_phy (tp,0x14 ,0x0100 ,0x0000 ); +rtl_writephy (tp,0x1f ,0x0a44 ); +rtl_w1w0_phy (tp,0x11 ,0x00c0 ,0x0000 ); +rtl_writephy (tp,0x1f ,0x0a43 ); +rtl_writephy (tp,0x13 ,0x8084 ); +rtl_w1w0_phy (tp,0x14 ,0x0000 ,0x6000 ); +rtl_w1w0_phy (tp,0x10 ,0x1003 ,0x0000 ); + +/* EEE auto-fallback function */ +rtl_writephy (tp,0x1f ,0x0a4b ); +rtl_w1w0_phy (tp,0x11 ,0x0004 ,0x0000 ); + +/* Enable UC LPF tune function */ +rtl_writephy (tp,0x1f ,0x0a43 ); +rtl_writephy (tp,0x13 ,0x8012 ); +rtl_w1w0_phy (tp,0x14 ,0x8000 ,0x0000 ); + +rtl_writephy (tp,0x1f ,0x0c42 ); +rtl_w1w0_phy (tp,0x11 ,0x4000 ,0x2000 ); -r8168_phy_ocp_write (tp,0xa436 ,0x8012 ); -rtl_w1w0_phy_ocp (tp,0xa438 ,0x8000 ,0x0000 ); +/* Improve SWR Efficiency */ +rtl_writephy (tp,0x1f ,0x0bcd ); +rtl_writephy (tp,0x14 ,0x5065 ); +rtl_writephy (tp,0x14 ,0xd065 ); +rtl_writephy (tp,0x1f ,0x0bc8 ); +rtl_writephy (tp,0x11 ,0x5655 ); +rtl_writephy (tp,0x1f ,0x0bcd ); +rtl_writephy (tp,0x14 ,0x1065 ); +rtl_writephy (tp,0x14 ,0x9065 ); +rtl_writephy (tp,0x14 ,0x1065 ); -rtl_w1w0_phy_ocp (tp,0xc422 ,0x4000 ,0x2000 ); +rtl_writephy (tp,0x1f ,0x0000 ); }static void rtl8102e_hw_phy_config (struct rtl8169_private *tp)
Signature · 1 line
1.8.1
PATCH 3/5 r8169: Modify the method for setting firmware
In reply to Hayes WangRemove useless action PHY_READ_EFUSE, and define the new action PHY_MDIO_CHG.
PHY_MDIO_CHG is used to modify the mdio operation. By the way, the firmware could support setting mac ocp.
--- drivers/net/ethernet/realtek/r8169.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
drivers/net/ethernet/realtek/r8169.c +32 -4
@@ -1074,6 +1074,21 @@ static int r8168g_mdio_read(struct rtl8169_private *tp, int reg)return r8168_phy_ocp_read (tp, tp->ocp_base + reg *2 ); } +static void mac_mcu_write (struct rtl8169_private *tp,int reg,int value) +{ +if (reg ==0x1f ) { + tp->ocp_base = value <<4 ; +return ; + } + +r8168_mac_ocp_write (tp, tp->ocp_base + reg, value); +} + +static int mac_mcu_read (struct rtl8169_private *tp,int reg) +{ +return r8168_mac_ocp_read (tp, tp->ocp_base + reg); +} +DECLARE_RTL_COND (rtl_phyar_cond) {void __iomem *ioaddr = tp->mmio_addr;
@@ -2139,7 +2154,7 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,#define PHY_DATA_OR 0x10000000#define PHY_DATA_AND 0x20000000#define PHY_BJMPN 0x30000000 -#define PHY_READ_EFUSE 0x40000000 +#define PHY_MDIO_CHG 0x40000000#define PHY_READ_MAC_BYTE 0x50000000#define PHY_WRITE_MAC_BYTE 0x60000000#define PHY_CLEAR_READCOUNT 0x70000000
@@ -2227,7 +2242,7 @@ static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,case PHY_READ :case PHY_DATA_OR :case PHY_DATA_AND : -case PHY_READ_EFUSE : +case PHY_MDIO_CHG :case PHY_CLEAR_READCOUNT :case PHY_WRITE :case PHY_WRITE_PREVIOUS :
@@ -2291,10 +2306,13 @@ out:static void rtl_phy_write_fw (struct rtl8169_private *tp,struct rtl_fw *rtl_fw) {struct rtl_fw_phy_action *pa = &rtl_fw->phy_action; +struct mdio_ops org, *ops = &tp->mdio_ops;u32 predata, count;size_t index; predata = count =0 ; + org.write = ops->write; + org.read = ops->read;for (index =0 ; index < pa->size; ) {u32 action =le32_to_cpu (pa->code[index]);
@@ -2321,8 +2339,15 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)case PHY_BJMPN : index -= regno;break ; -case PHY_READ_EFUSE : - predata =rtl8168d_efuse_read (tp, regno); +case PHY_MDIO_CHG : +if (data ==0 ) { + ops->write = org.write; + ops->read = org.read; + }else if (data ==1 ) { + ops->write = mac_mcu_write; + ops->read = mac_mcu_read; + } + index++;break ;case PHY_CLEAR_READCOUNT :
@@ -2365,6 +2390,9 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)BUG (); } } + + ops->write = org.write; + ops->read = org.read; }static void rtl_release_firmware (struct rtl8169_private *tp)
Signature · 1 line
1.8.1
Re: [PATCH 3/5] r8169: Modify the method for setting firmware
Hayes Wang <[email protected]> :
Quoted 6 lines
Remove useless action
PHY_READ_EFUSE, and define the new actionPHY_MDIO_CHG.
PHY_MDIO_CHGis used to modify the mdio operation. By the way, the firmware could support setting mac ocp.
[...]
Quoted 4 lines
drivers/net/ethernet/realtek/r8169.c +0
-0
[...]
Quoted 4 lines
drivers/net/ethernet/realtek/r8169.c +0
-0@@ -2321,8 +2339,15 @@ static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)case PHY_BJMPN : index -= regno;break ;
drivers/net/ethernet/realtek/r8169.c static void rtl_phy_write_fw(struct rtl8169_private *tp, struct rtl_fw *rtl_fw) · line 2349
Quoted 10 lines
drivers/net/ethernet/realtek/r8169.c +8
-2-case PHY_READ_EFUSE : - predata =rtl8168d_efuse_read (tp, regno); +case PHY_MDIO_CHG : +if (data ==0 ) { + ops->write = org.write; + ops->read = org.read; + }else if (data ==1 ) { + ops->write = mac_mcu_write; + ops->read = mac_mcu_read; + }
Did you check that none of rtl_nic/rtl8168d-{1, 2}.fw uses PHY_READ_EFUSE ?
Signature · 1 line
Ueimor
RE: [PATCH 3/5] r8169: Modify the method for setting firmware
Francois Romieu [mailto:[email protected]]
[...]
Quoted 4 lines
Did you check that none of rtl_nic/rtl8168d-{1, 2}.fw uses
PHY_READ_EFUSE?
I have made sure that none of the current firmwares use PHY_READ_EFUSE.
Best Regards,
Hayes
PATCH 4/5 r8169: Update the RTL8111G parameters
In reply to Hayes Wang- replace rtl8168g-1.fw with rtl8168g-2.fw which support new method.
- fix PHY power down is useless.
- disable rx early which causes the rx abnormal.
- fix the conflict between jumbo frame and flow control.
--- drivers/net/ethernet/realtek/r8169.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169.c +16 -2
@@ -47,7 +47,7 @@#define FIRMWARE_8402_1 "rtl_nic/rtl8402-1.fw"#define FIRMWARE_8411_1 "rtl_nic/rtl8411-1.fw"#define FIRMWARE_8106E_1 "rtl_nic/rtl8106e-1.fw" -#define FIRMWARE_8168G_1 "rtl_nic/rtl8168g-1.fw" +#define FIRMWARE_8168G_1 "rtl_nic/rtl8168g-2.fw"#ifdef RTL8169_DEBUG #define assert (expr) \
@@ -329,6 +329,7 @@ enum rtl_registers {#define RXCFG_FIFO_SHIFT 13/* No threshold before first PCI xfer */ #define RX_FIFO_THRESH (7 << RXCFG_FIFO_SHIFT) +#define RX_EARLY_OFF (1 << 11)#define RXCFG_DMA_SHIFT 8/* Unlimited maximum PCI burst. */ #define RX_DMA_BURST (7 << RXCFG_DMA_SHIFT)
@@ -4077,6 +4078,10 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)case RTL_GIGA_MAC_VER_33 :RTL_W8 (PMCH ,RTL_R8 (PMCH ) & ~0x80 );break ; +case RTL_GIGA_MAC_VER_40 : +case RTL_GIGA_MAC_VER_41 : +RTL_W8 (PMCH ,RTL_R8 (PMCH ) & ~0x40 ); +break ; } }
@@ -4094,6 +4099,10 @@ static void r8168_pll_power_up(struct rtl8169_private *tp)case RTL_GIGA_MAC_VER_33 :RTL_W8 (PMCH ,RTL_R8 (PMCH ) |0x80 );break ; +case RTL_GIGA_MAC_VER_40 : +case RTL_GIGA_MAC_VER_41 : +RTL_W8 (PMCH ,RTL_R8 (PMCH ) |0x40 ); +break ; }r8168_phy_power_up (tp);
@@ -4199,6 +4208,10 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)case RTL_GIGA_MAC_VER_34 :RTL_W32 (RxConfig,RX128_INT_EN |RX_MULTI_EN |RX_DMA_BURST );break ; +case RTL_GIGA_MAC_VER_40 : +case RTL_GIGA_MAC_VER_41 : +RTL_W32 (RxConfig,RX128_INT_EN |RX_DMA_BURST |RX_EARLY_OFF ); +break ;default :RTL_W32 (RxConfig,RX128_INT_EN |RX_DMA_BURST );break ;
@@ -5190,7 +5203,8 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)/* Adjust EEE LED frequency */ RTL_W8 (EEE_LED ,RTL_R8 (EEE_LED ) & ~0x07 ); -rtl_w1w0_eri (tp,0x2fc ,ERIAR_MASK_0001 ,0x01 ,0x02 ,ERIAR_EXGMAC ); +rtl_w1w0_eri (tp,0x2fc ,ERIAR_MASK_0001 ,0x01 ,0x06 ,ERIAR_EXGMAC ); +rtl_w1w0_eri (tp,0x1b0 ,ERIAR_MASK_0011 ,0x0000 ,0x1000 ,ERIAR_EXGMAC ); }static void rtl_hw_start_8168 (struct net_device *dev)
Signature · 1 line
1.8.1
Re: [PATCH 4/5] r8169: Update the RTL8111G parameters
Hayes Wang <[email protected]> :
Quoted 6 lines
- replace rtl8168g-1.fw with rtl8168g-2.fw which support new method.
- fix PHY power down is useless.
- disable rx early which causes the rx abnormal.
- fix the conflict between jumbo frame and flow control.Signed-off-by Hayes Wang <[email protected]>
It seems ok.
Signature · 1 line
Ueimor
PATCH 5/5 r8169: fix could not dump registers
In reply to Hayes WangFor new version of Fedora and Ubuntu, we see all 0xff when dumping the hw regs through ethtool. Using a loop to read registers could fix it.
--- drivers/net/ethernet/realtek/r8169.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169.c +5 -1
@@ -1880,12 +1880,16 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) {struct rtl8169_private *tp =netdev_priv (dev); +void __iomem *ioaddr = tp->mmio_addr; +u32 *d = (u32 *)p; +int i;if (regs->len >R8169_REGS_SIZE ) regs->len =R8169_REGS_SIZE ;rtl_lock_work (tp); -memcpy_fromio (p, tp->mmio_addr, regs->len); +for (i =0 ; i < regs->len; i +=4 ) + *d++ =RTL_R32 (i);rtl_unlock_work (tp); }
Signature · 1 line
1.8.1
Re: [PATCH 5/5] r8169: fix could not dump registers
Hayes Wang <[email protected]> :
Quoted 3 lines
For new version of Fedora and Ubuntu, we see all
0xffwhen dumping the hw regs through ethtool. Using a loop to read registers could fix it.
/me wonders...
Will I be wrong if I reformulate so as to outline the role of 4 bytes aligned accesses when walking the registers area ?
Signature · 1 line
Ueimor
David Miller
maintainerFrancois please review this series, thanks.
David Miller <[email protected]> :
[...]
Quoted 1 line
Francois please review this series, thanks.
It does not seem wrong but I'll give it a try before sending a pull request.
Signature · 1 line
Ueimor
Hayes Wang <[email protected]> :
Quoted 1 line
Some codes are belong to binary codes and should be removed.
Ok (almost).
Signature · 1 line
Ueimor