[ar71xx] parse mac address on RouterBOARDs
[openwrt.git] / target / linux / ar71xx / files / drivers / net / phy / micrel.c
1 /*
2 * Driver for Micrel/Kendin PHYs
3 *
4 * Copyright (c) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 *
11 */
12
13 #include <linux/delay.h>
14 #include <linux/skbuff.h>
15 #include <linux/phy.h>
16
17 #define KSZ_REG_INT_CTRL 0x1b
18
19 #define KSZ_INT_LU_EN (1 << 8) /* enable Link Up interrupt */
20 #define KSZ_INT_RF_EN (1 << 9) /* enable Remote Fault interrupt */
21 #define KSZ_INT_LD_EN (1 << 10) /* enable Link Down interrupt */
22
23 #define KSZ_INT_INIT (KSZ_INT_LU_EN | KSZ_INT_LD_EN)
24
25 static int ksz8041_ack_interrupt(struct phy_device *phydev)
26 {
27 int err;
28
29 err = phy_read(phydev, KSZ_REG_INT_CTRL);
30
31 return (err < 0) ? err : 0;
32 }
33
34 static int ksz8041_config_intr(struct phy_device *phydev)
35 {
36 int err;
37
38 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
39 err = phy_write(phydev, KSZ_REG_INT_CTRL,
40 KSZ_INT_INIT);
41 else
42 err = phy_write(phydev, KSZ_REG_INT_CTRL, 0);
43
44 return err;
45 }
46
47 static struct phy_driver ksz8041_phy_driver = {
48 .phy_id = 0x00221512,
49 .name = "Micrel/Kendin KSZ8041",
50 .phy_id_mask = 0x001fffff,
51 .features = PHY_BASIC_FEATURES,
52 .flags = PHY_HAS_INTERRUPT,
53 .config_aneg = genphy_config_aneg,
54 .read_status = genphy_read_status,
55 .ack_interrupt = ksz8041_ack_interrupt,
56 .config_intr = ksz8041_config_intr,
57 .driver = {
58 .owner = THIS_MODULE,
59 },
60 };
61
62 static int __init micrel_phy_init(void)
63 {
64 int ret;
65
66 ret = phy_driver_register(&ksz8041_phy_driver);
67
68 return ret;
69 }
70
71 static void __exit micrel_phy_exit(void)
72 {
73 phy_driver_unregister(&ksz8041_phy_driver);
74 }
75
76 module_init(micrel_phy_init);
77 module_exit(micrel_phy_exit);
78
79 MODULE_DESCRIPTION("Micrel/Kendin PHY driver");
80 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
81 MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
82 MODULE_LICENSE("GPL v2");
This page took 0.046333 seconds and 5 git commands to generate.