Johnson Leung | 097c2aa | 2008-02-03 03:50:54 -0800 | [diff] [blame] | 1 | /* |
| 2 | * drivers/net/phy/realtek.c |
| 3 | * |
| 4 | * Driver for Realtek PHYs |
| 5 | * |
| 6 | * Author: Johnson Leung <r58129@freescale.com> |
| 7 | * |
| 8 | * Copyright (c) 2004 Freescale Semiconductor, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
| 12 | * Free Software Foundation; either version 2 of the License, or (at your |
| 13 | * option) any later version. |
| 14 | * |
| 15 | */ |
| 16 | #include <linux/phy.h> |
Paul Gortmaker | 9d9779e | 2011-07-03 15:21:01 -0400 | [diff] [blame] | 17 | #include <linux/module.h> |
Johnson Leung | 097c2aa | 2008-02-03 03:50:54 -0800 | [diff] [blame] | 18 | |
| 19 | #define RTL821x_PHYSR 0x11 |
| 20 | #define RTL821x_PHYSR_DUPLEX 0x2000 |
| 21 | #define RTL821x_PHYSR_SPEED 0xc000 |
| 22 | #define RTL821x_INER 0x12 |
| 23 | #define RTL821x_INER_INIT 0x6400 |
| 24 | #define RTL821x_INSR 0x13 |
| 25 | |
| 26 | MODULE_DESCRIPTION("Realtek PHY driver"); |
| 27 | MODULE_AUTHOR("Johnson Leung"); |
| 28 | MODULE_LICENSE("GPL"); |
| 29 | |
| 30 | static int rtl821x_ack_interrupt(struct phy_device *phydev) |
| 31 | { |
| 32 | int err; |
| 33 | |
| 34 | err = phy_read(phydev, RTL821x_INSR); |
| 35 | |
| 36 | return (err < 0) ? err : 0; |
| 37 | } |
| 38 | |
| 39 | static int rtl821x_config_intr(struct phy_device *phydev) |
| 40 | { |
| 41 | int err; |
| 42 | |
| 43 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) |
| 44 | err = phy_write(phydev, RTL821x_INER, |
| 45 | RTL821x_INER_INIT); |
| 46 | else |
| 47 | err = phy_write(phydev, RTL821x_INER, 0); |
| 48 | |
| 49 | return err; |
| 50 | } |
| 51 | |
| 52 | /* RTL8211B */ |
| 53 | static struct phy_driver rtl821x_driver = { |
| 54 | .phy_id = 0x001cc912, |
| 55 | .name = "RTL821x Gigabit Ethernet", |
| 56 | .phy_id_mask = 0x001fffff, |
| 57 | .features = PHY_GBIT_FEATURES, |
| 58 | .flags = PHY_HAS_INTERRUPT, |
| 59 | .config_aneg = &genphy_config_aneg, |
| 60 | .read_status = &genphy_read_status, |
| 61 | .ack_interrupt = &rtl821x_ack_interrupt, |
| 62 | .config_intr = &rtl821x_config_intr, |
| 63 | .driver = { .owner = THIS_MODULE,}, |
| 64 | }; |
| 65 | |
| 66 | static int __init realtek_init(void) |
| 67 | { |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 68 | return phy_driver_register(&rtl821x_driver); |
Johnson Leung | 097c2aa | 2008-02-03 03:50:54 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | static void __exit realtek_exit(void) |
| 72 | { |
| 73 | phy_driver_unregister(&rtl821x_driver); |
| 74 | } |
| 75 | |
| 76 | module_init(realtek_init); |
| 77 | module_exit(realtek_exit); |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 78 | |
Uwe Kleine-König | cf93c94 | 2010-10-03 23:43:32 +0000 | [diff] [blame] | 79 | static struct mdio_device_id __maybe_unused realtek_tbl[] = { |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 80 | { 0x001cc912, 0x001fffff }, |
| 81 | { } |
| 82 | }; |
| 83 | |
| 84 | MODULE_DEVICE_TABLE(mdio, realtek_tbl); |