blob: ebdda3fe80bbdde4caf9b45b04080e8f0eaef055 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2019 MediaTek Inc.
4 */
5#include <linux/module.h>
6#include <linux/phy.h>
7#include <linux/of.h>
8
9#define PHY_ID_TJA1100 0x0180dc48
10#define TJA1100_LINKUP BIT(15)
11
12#define PHY_ID_TJA1101 0x0180DD00U
13
14
15static int nxp_config_init(struct phy_device *phydev)
16{
17 phydev->supported = SUPPORTED_100baseT_Full;
18 phydev->advertising = SUPPORTED_100baseT_Full;
19 phydev->state = PHY_NOLINK;
20 phydev->autoneg = AUTONEG_DISABLE;
21
22 return 0;
23}
24
25static int nxp_read_status(struct phy_device *phydev)
26{
27 int val;
28
29 phydev->duplex = 1;
30 phydev->pause = 0;
31 phydev->speed = SPEED_100;
32
33 val = phy_read(phydev, MII_RESV1);
34 if (val < 0)
35 return val;
36
37 if (val & TJA1100_LINKUP)
38 phydev->link = 1;
39 else
40 phydev->link = 0;
41
42 return 0;
43}
44
45static struct phy_driver nxp_tja1100_driver[] = {
46 {
47 .phy_id = PHY_ID_TJA1100,
48 .phy_id_mask = 0xffffffff,
49 .name = "NXP TJA1100",
50 .config_init = nxp_config_init,
51 .read_status = nxp_read_status,
52 },
53 {
54 .phy_id = PHY_ID_TJA1101,
55 .phy_id_mask = 0xffffffff,
56 .name = "NXP TJA1101",
57 .config_init = nxp_config_init,
58 .read_status = nxp_read_status,
59 }
60};
61
62module_phy_driver(nxp_tja1100_driver);
63
64static struct mdio_device_id __maybe_unused nxp_tbl[] = {
65 { PHY_ID_TJA1100, 0xffffffff },
66 { PHY_ID_TJA1101, 0xffffffff },
67 { }
68};
69
70MODULE_DEVICE_TABLE(mdio, nxp_tbl);