xref: /linux/drivers/net/phy/mediatek/mtk-fe-soc.c (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Driver for MT7628 Embedded Switch internal Fast Ethernet PHYs
4  */
5 #include <linux/module.h>
6 #include <linux/phy.h>
7 
8 #define MTK_FPHY_ID_MT7628	0x03a29410
9 #define MTK_EXT_PAGE_ACCESS	0x1f
10 
mt7628_phy_read_page(struct phy_device * phydev)11 static int mt7628_phy_read_page(struct phy_device *phydev)
12 {
13 	return __phy_read(phydev, MTK_EXT_PAGE_ACCESS);
14 }
15 
mt7628_phy_write_page(struct phy_device * phydev,int page)16 static int mt7628_phy_write_page(struct phy_device *phydev, int page)
17 {
18 	return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page);
19 }
20 
mt7628_phy_config_init(struct phy_device * phydev)21 static int mt7628_phy_config_init(struct phy_device *phydev)
22 {
23 	/*
24 	 * This undocumented bit is required for the PHYs to be able to
25 	 * establish 100mbps links.
26 	 */
27 	return phy_modify_paged(phydev, 0x8000, 30, BIT(13), BIT(13));
28 }
29 
30 static struct phy_driver mtk_soc_fe_phy_driver[] = {
31 	{
32 		PHY_ID_MATCH_EXACT(MTK_FPHY_ID_MT7628),
33 		.name		= "MediaTek MT7628 PHY",
34 		.config_init	= mt7628_phy_config_init,
35 		.read_page	= mt7628_phy_read_page,
36 		.write_page	= mt7628_phy_write_page,
37 		.suspend	= genphy_suspend,
38 		.resume		= genphy_resume,
39 	},
40 };
41 
42 module_phy_driver(mtk_soc_fe_phy_driver);
43 static const struct mdio_device_id __maybe_unused mtk_soc_fe_phy_tbl[] = {
44 	{ PHY_ID_MATCH_EXACT(MTK_FPHY_ID_MT7628) },
45 	{ }
46 };
47 
48 MODULE_DESCRIPTION("MediaTek SoC Fast Ethernet PHY driver");
49 MODULE_AUTHOR("Joris Vaisvila <joey@tinyisr.com>");
50 MODULE_LICENSE("GPL");
51 
52 MODULE_DEVICE_TABLE(mdio, mtk_soc_fe_phy_tbl);
53