[][Change the proprietary mdio ioctl to upstream format]
[Description]
Change the proprietary mdio ioctl to upstream format.
This patch can reduce the size of ioctl data from 28 bytes to 12 bytes.
[Release-log]
N/A
Change-Id: Ic7d5446e43c8f1078fc9bec7ee06bf2f938bca08
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/4538828
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c
index 82aa6ca..ab5e1f8 100755
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c
@@ -36,7 +36,7 @@
struct mtk_eth_debug eth_debug;
-void mt7530_mdio_w32(struct mtk_eth *eth, u32 reg, u32 val)
+void mt7530_mdio_w32(struct mtk_eth *eth, u16 reg, u32 val)
{
mutex_lock(ð->mii_bus->mdio_lock);
@@ -374,7 +374,7 @@
*read_data = _mtk_mdio_read(eth, phy_addr, phy_register);
}
-void mii_mgr_write_combine(struct mtk_eth *eth, u32 phy_addr, u32 phy_register,
+void mii_mgr_write_combine(struct mtk_eth *eth, u16 phy_addr, u16 phy_register,
u32 write_data)
{
if (mt7530_exist(eth) && phy_addr == 31)
@@ -384,12 +384,12 @@
_mtk_mdio_write(eth, phy_addr, phy_register, write_data);
}
-static void mii_mgr_read_cl45(struct mtk_eth *eth, u32 port, u32 devad, u32 reg, u32 *data)
+static void mii_mgr_read_cl45(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 *data)
{
mtk_cl45_ind_read(eth, port, devad, reg, data);
}
-static void mii_mgr_write_cl45(struct mtk_eth *eth, u32 port, u32 devad, u32 reg, u32 data)
+static void mii_mgr_write_cl45(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 data)
{
mtk_cl45_ind_write(eth, port, devad, reg, data);
}
@@ -416,12 +416,14 @@
goto err_copy;
mii_mgr_write_combine(eth, mii.phy_id, mii.reg_num,
mii.val_in);
-
return 0;
case MTKETH_MII_READ_CL45:
if (copy_from_user(&mii, ifr->ifr_data, sizeof(mii)))
goto err_copy;
- mii_mgr_read_cl45(eth, mii.port_num, mii.dev_addr, mii.reg_addr,
+ mii_mgr_read_cl45(eth,
+ mdio_phy_id_prtad(mii.phy_id),
+ mdio_phy_id_devad(mii.phy_id),
+ mii.reg_num,
&mii.val_out);
if (copy_to_user(ifr->ifr_data, &mii, sizeof(mii)))
goto err_copy;
@@ -430,8 +432,11 @@
case MTKETH_MII_WRITE_CL45:
if (copy_from_user(&mii, ifr->ifr_data, sizeof(mii)))
goto err_copy;
- mii_mgr_write_cl45(eth, mii.port_num, mii.dev_addr, mii.reg_addr,
- mii.val_in);
+ mii_mgr_write_cl45(eth,
+ mdio_phy_id_prtad(mii.phy_id),
+ mdio_phy_id_devad(mii.phy_id),
+ mii.reg_num,
+ mii.val_in);
return 0;
case MTKETH_ESW_REG_READ:
if (!mt7530_exist(eth))
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.h b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.h
index c7924f4..0e96a60 100755
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.h
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.h
@@ -51,13 +51,10 @@
};
struct mtk_mii_ioctl_data {
- unsigned int phy_id;
- unsigned int reg_num;
+ u16 phy_id;
+ u16 reg_num;
unsigned int val_in;
unsigned int val_out;
- unsigned int port_num;
- unsigned int dev_addr;
- unsigned int reg_addr;
};
#if defined(CONFIG_NET_DSA_MT7530) || defined(CONFIG_MT753X_GSW)
@@ -72,12 +69,12 @@
}
#endif
-extern u32 _mtk_mdio_read(struct mtk_eth *eth, int phy_addr, int phy_reg);
-extern u32 _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr,
- u32 phy_register, u32 write_data);
+extern u32 _mtk_mdio_read(struct mtk_eth *eth, u16 phy_addr, u16 phy_reg);
+extern u32 _mtk_mdio_write(struct mtk_eth *eth, u16 phy_addr,
+ u16 phy_register, u16 write_data);
-extern u32 mtk_cl45_ind_read(struct mtk_eth *eth, u32 port, u32 devad, u32 reg, u32 *data);
-extern u32 mtk_cl45_ind_write(struct mtk_eth *eth, u32 port, u32 devad, u32 reg, u32 data);
+extern u32 mtk_cl45_ind_read(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 *data);
+extern u32 mtk_cl45_ind_write(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 data);
int debug_proc_init(struct mtk_eth *eth);
void debug_proc_exit(void);
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 8c6bca5..04128d6 100755
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -98,8 +98,8 @@
return -1;
}
-u32 _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr,
- u32 phy_register, u32 write_data)
+u32 _mtk_mdio_write(struct mtk_eth *eth, u16 phy_addr,
+ u16 phy_register, u16 write_data)
{
if (mtk_mdio_busy_wait(eth))
return -1;
@@ -117,7 +117,7 @@
return 0;
}
-u32 _mtk_mdio_read(struct mtk_eth *eth, int phy_addr, int phy_reg)
+u32 _mtk_mdio_read(struct mtk_eth *eth, u16 phy_addr, u16 phy_reg)
{
u32 d;
@@ -152,7 +152,7 @@
return _mtk_mdio_read(eth, phy_addr, phy_reg);
}
-u32 mtk_cl45_ind_read(struct mtk_eth *eth, u32 port, u32 devad, u32 reg, u32 *data)
+u32 mtk_cl45_ind_read(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 *data)
{
mutex_lock(ð->mii_bus->mdio_lock);
@@ -166,7 +166,7 @@
return 0;
}
-u32 mtk_cl45_ind_write(struct mtk_eth *eth, u32 port, u32 devad, u32 reg, u32 data)
+u32 mtk_cl45_ind_write(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 data)
{
mutex_lock(ð->mii_bus->mdio_lock);