rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | // 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 | static 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 | |
| 22 | static 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 | |
| 42 | static 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 | |
| 52 | module_phy_driver(nxp_tja1100_driver); |
| 53 | |
| 54 | static struct mdio_device_id __maybe_unused nxp_tbl[] = { |
| 55 | { PHY_ID_TJA1100, 0xfffffff0 }, |
| 56 | { } |
| 57 | }; |
| 58 | |
| 59 | MODULE_DEVICE_TABLE(mdio, nxp_tbl); |