ar71xx: don't init PCI irqs on the AR7240 if the PCIe subsystem are in reset
[openwrt.git] / target / linux / ar71xx / files / drivers / net / phy / micrel.c
1 /*
2 * Driver for Micrel/Kendin PHYs
3 *
4 * Copyright (c) 2008-2009 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 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 return phy_driver_register(&ksz8041_phy_driver);
65 }
66
67 static void __exit micrel_phy_exit(void)
68 {
69 phy_driver_unregister(&ksz8041_phy_driver);
70 }
71
72 #ifdef MODULE
73 module_init(micrel_phy_init);
74 module_exit(micrel_phy_exit);
75 #else
76 subsys_initcall(micrel_phy_init);
77 #endif
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.044264 seconds and 5 git commands to generate.