blob: 97873c85020328e8899e2e22e4dae04d666b9a59 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +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
12static int tja1100_config_init(struct phy_device *phydev)
13{
14 phydev->supported = SUPPORTED_100baseT_Full;
15 phydev->advertising = SUPPORTED_100baseT_Full;
16 phydev->state = PHY_NOLINK;
17 phydev->autoneg = AUTONEG_DISABLE;
18
19 return 0;
20}
21
22static int tja1100_read_status(struct phy_device *phydev)
23{
24 int val;
25
26 phydev->duplex = 1;
27 phydev->pause = 0;
28 phydev->speed = SPEED_100;
29
30 val = phy_read(phydev, MII_RESV1);
31 if (val < 0)
32 return val;
33
34 if (val & TJA1100_LINKUP)
35 phydev->link = 1;
36 else
37 phydev->link = 0;
38
39 return 0;
40}
41
42static struct phy_driver nxp_tja1100_driver[] = {
43 {
44 .phy_id = PHY_ID_TJA1100,
45 .phy_id_mask = 0xfffffff0,
46 .name = "NXP TJA1100",
47 .config_init = tja1100_config_init,
48 .read_status = tja1100_read_status,
49 }
50};
51
52module_phy_driver(nxp_tja1100_driver);
53
54static struct mdio_device_id __maybe_unused nxp_tbl[] = {
55 { PHY_ID_TJA1100, 0xfffffff0 },
56 { }
57};
58
59MODULE_DEVICE_TABLE(mdio, nxp_tbl);