blob: 79bf7ef1fcfd6a210c409acb282251ef30cb1341 [file] [log] [blame]
Andrew Lunnab064182019-01-21 19:08:49 +01001// SPDX-License-Identifier: GPL-2.0+
Michael Schmitz31dd83b2018-04-19 14:05:18 +12002/* Driver for Asix PHYs
3 *
4 * Author: Michael Schmitz <schmitzmic@gmail.com>
Michael Schmitz31dd83b2018-04-19 14:05:18 +12005 */
6#include <linux/kernel.h>
7#include <linux/errno.h>
8#include <linux/init.h>
9#include <linux/module.h>
10#include <linux/mii.h>
11#include <linux/phy.h>
12
13#define PHY_ID_ASIX_AX88796B 0x003b1841
14
15MODULE_DESCRIPTION("Asix PHY driver");
16MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
17MODULE_LICENSE("GPL");
18
19/**
20 * asix_soft_reset - software reset the PHY via BMCR_RESET bit
21 * @phydev: target phy_device struct
22 *
23 * Description: Perform a software PHY reset using the standard
24 * BMCR_RESET bit and poll for the reset bit to be cleared.
25 * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation
26 * such as used on the Individual Computers' X-Surf 100 Zorro card.
27 *
28 * Returns: 0 on success, < 0 on failure
29 */
30static int asix_soft_reset(struct phy_device *phydev)
31{
32 int ret;
33
34 /* Asix PHY won't reset unless reset bit toggles */
35 ret = phy_write(phydev, MII_BMCR, 0);
36 if (ret < 0)
37 return ret;
38
39 return genphy_soft_reset(phydev);
40}
41
42static struct phy_driver asix_driver[] = { {
43 .phy_id = PHY_ID_ASIX_AX88796B,
44 .name = "Asix Electronics AX88796B",
45 .phy_id_mask = 0xfffffff0,
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +020046 /* PHY_BASIC_FEATURES */
Michael Schmitz31dd83b2018-04-19 14:05:18 +120047 .soft_reset = asix_soft_reset,
48} };
49
50module_phy_driver(asix_driver);
51
52static struct mdio_device_id __maybe_unused asix_tbl[] = {
53 { PHY_ID_ASIX_AX88796B, 0xfffffff0 },
54 { }
55};
56
57MODULE_DEVICE_TABLE(mdio, asix_tbl);