1 // SPDX-License-Identifier: GPL-2.0+
5 * CORTINA is a registered trademark of Cortina Systems, Inc.
8 #include <linux/module.h>
11 #define PHY_ID_CS4340 0x13e51002
13 #define VILLA_GLOBAL_CHIP_ID_LSB 0x0
14 #define VILLA_GLOBAL_CHIP_ID_MSB 0x1
16 #define VILLA_GLOBAL_GPIO_1_INTS 0x017
18 static int cortina_read_reg(struct phy_device *phydev, u16 regnum)
20 return mdiobus_c45_read(phydev->mdio.bus, phydev->mdio.addr, 0, regnum);
23 static int cortina_read_status(struct phy_device *phydev)
25 int gpio_int_status, ret = 0;
27 gpio_int_status = cortina_read_reg(phydev, VILLA_GLOBAL_GPIO_1_INTS);
28 if (gpio_int_status < 0) {
29 ret = gpio_int_status;
33 if (gpio_int_status & 0x8) {
34 /* up when edc_convergedS set */
35 phydev->speed = SPEED_10000;
36 phydev->duplex = DUPLEX_FULL;
46 static int cortina_probe(struct phy_device *phydev)
49 int id_lsb = 0, id_msb = 0;
51 /* Read device id from phy registers. */
52 id_lsb = cortina_read_reg(phydev, VILLA_GLOBAL_CHIP_ID_LSB);
56 phy_id = id_lsb << 16;
58 id_msb = cortina_read_reg(phydev, VILLA_GLOBAL_CHIP_ID_MSB);
64 /* Make sure the device tree binding matched the driver with the
67 if (phy_id != phydev->drv->phy_id) {
68 phydev_err(phydev, "Error matching phy with %s driver\n",
76 static struct phy_driver cortina_driver[] = {
78 .phy_id = PHY_ID_CS4340,
79 .phy_id_mask = 0xffffffff,
80 .name = "Cortina CS4340",
81 .features = PHY_10GBIT_FEATURES,
82 .config_aneg = gen10g_config_aneg,
83 .read_status = cortina_read_status,
84 .probe = cortina_probe,
88 module_phy_driver(cortina_driver);
90 static struct mdio_device_id __maybe_unused cortina_tbl[] = {
91 { PHY_ID_CS4340, 0xffffffff},
95 MODULE_DEVICE_TABLE(mdio, cortina_tbl);
97 MODULE_DESCRIPTION("Cortina EDC CDR 10G Ethernet PHY driver");
99 MODULE_LICENSE("GPL");