Skip to content

Commit 0008b4e

Browse files
plappermaulrobimarko
authored andcommitted
realtek: RTL838x: remove artifical mdio delays
For some reason 3 of the 4 mdio access functions contain an artifical delay of 10ms. While it might have been part of older Realtek SDKs it can no longer be found in current ones. Remove the delays. While we are here remove the pre-access bus ready checks. It is sufficient to run them after the command start. If anything fails the caller will get an error. This is the same behaviour as for the other targets. Finally cleanup the error handling. Something like this makes no sense at all. err = rtmdio_838x_smi_wait_op(100000); if (err) goto errout; err = 0; errout: Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: openwrt#19901 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 1c92e46 commit 0008b4e

1 file changed

Lines changed: 1 addition & 41 deletions

File tree

  • target/linux/realtek/files-6.12/drivers/net/ethernet

target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,12 +1823,7 @@ int rtmdio_838x_read_phy(u32 port, u32 page, u32 reg, u32 *val)
18231823

18241824
mutex_lock(&rtmdio_lock);
18251825

1826-
err = rtmdio_838x_smi_wait_op(100000);
1827-
if (err)
1828-
goto errout;
1829-
18301826
sw_w32_mask(0xffff0000, port << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
1831-
18321827
v = reg << 20 | page << 3;
18331828
sw_w32(v | park_page, RTL838X_SMI_ACCESS_PHY_CTRL_1);
18341829
sw_w32_mask(0, 1, RTL838X_SMI_ACCESS_PHY_CTRL_1);
@@ -1838,9 +1833,6 @@ int rtmdio_838x_read_phy(u32 port, u32 page, u32 reg, u32 *val)
18381833
goto errout;
18391834

18401835
*val = sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_2) & 0xffff;
1841-
1842-
err = 0;
1843-
18441836
errout:
18451837
mutex_unlock(&rtmdio_lock);
18461838

@@ -1858,26 +1850,15 @@ int rtmdio_838x_write_phy(u32 port, u32 page, u32 reg, u32 val)
18581850
return -ENOTSUPP;
18591851

18601852
mutex_lock(&rtmdio_lock);
1861-
err = rtmdio_838x_smi_wait_op(100000);
1862-
if (err)
1863-
goto errout;
18641853

18651854
sw_w32(BIT(port), RTL838X_SMI_ACCESS_PHY_CTRL_0);
1866-
mdelay(10);
1867-
18681855
sw_w32_mask(0xffff0000, val << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
18691856

18701857
v = reg << 20 | page << 3 | 0x4;
18711858
sw_w32(v | park_page, RTL838X_SMI_ACCESS_PHY_CTRL_1);
18721859
sw_w32_mask(0, 1, RTL838X_SMI_ACCESS_PHY_CTRL_1);
18731860

18741861
err = rtmdio_838x_smi_wait_op(100000);
1875-
if (err)
1876-
goto errout;
1877-
1878-
err = 0;
1879-
1880-
errout:
18811862
mutex_unlock(&rtmdio_lock);
18821863

18831864
return err;
@@ -1891,13 +1872,7 @@ static int rtmdio_838x_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val)
18911872

18921873
mutex_lock(&rtmdio_lock);
18931874

1894-
err = rtmdio_838x_smi_wait_op(100000);
1895-
if (err)
1896-
goto errout;
1897-
18981875
sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
1899-
mdelay(10);
1900-
19011876
sw_w32_mask(0xffff0000, port << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
19021877

19031878
v = addr << 16 | reg;
@@ -1912,9 +1887,6 @@ static int rtmdio_838x_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val)
19121887
goto errout;
19131888

19141889
*val = sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_2) & 0xffff;
1915-
1916-
err = 0;
1917-
19181890
errout:
19191891
mutex_unlock(&rtmdio_lock);
19201892

@@ -1931,29 +1903,17 @@ static int rtmdio_838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val)
19311903
val &= 0xffff;
19321904
mutex_lock(&rtmdio_lock);
19331905

1934-
err = rtmdio_838x_smi_wait_op(100000);
1935-
if (err)
1936-
goto errout;
1937-
19381906
sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
1939-
mdelay(10);
1940-
19411907
sw_w32_mask(0xffff0000, val << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
1942-
19431908
sw_w32_mask(0x1f << 16, addr << 16, RTL838X_SMI_ACCESS_PHY_CTRL_3);
19441909
sw_w32_mask(0xffff, reg, RTL838X_SMI_ACCESS_PHY_CTRL_3);
19451910
/* mmd-access | write | cmd-start */
19461911
v = 1 << 1 | 1 << 2 | 1;
19471912
sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1);
19481913

19491914
err = rtmdio_838x_smi_wait_op(100000);
1950-
if (err)
1951-
goto errout;
1952-
1953-
err = 0;
1954-
1955-
errout:
19561915
mutex_unlock(&rtmdio_lock);
1916+
19571917
return err;
19581918
}
19591919

0 commit comments

Comments
 (0)