]>
Commit | Line | Data |
---|---|---|
00db8189 AF |
1 | /* |
2 | * drivers/net/phy/marvell.c | |
3 | * | |
4 | * Driver for Marvell PHYs | |
5 | * | |
6 | * Author: Andy Fleming | |
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 | */ | |
00db8189 | 16 | #include <linux/kernel.h> |
00db8189 AF |
17 | #include <linux/string.h> |
18 | #include <linux/errno.h> | |
19 | #include <linux/unistd.h> | |
20 | #include <linux/slab.h> | |
21 | #include <linux/interrupt.h> | |
22 | #include <linux/init.h> | |
23 | #include <linux/delay.h> | |
24 | #include <linux/netdevice.h> | |
25 | #include <linux/etherdevice.h> | |
26 | #include <linux/skbuff.h> | |
27 | #include <linux/spinlock.h> | |
28 | #include <linux/mm.h> | |
29 | #include <linux/module.h> | |
00db8189 AF |
30 | #include <linux/mii.h> |
31 | #include <linux/ethtool.h> | |
32 | #include <linux/phy.h> | |
33 | ||
34 | #include <asm/io.h> | |
35 | #include <asm/irq.h> | |
36 | #include <asm/uaccess.h> | |
37 | ||
38 | #define MII_M1011_IEVENT 0x13 | |
39 | #define MII_M1011_IEVENT_CLEAR 0x0000 | |
40 | ||
41 | #define MII_M1011_IMASK 0x12 | |
42 | #define MII_M1011_IMASK_INIT 0x6400 | |
43 | #define MII_M1011_IMASK_CLEAR 0x0000 | |
44 | ||
45 | MODULE_DESCRIPTION("Marvell PHY driver"); | |
46 | MODULE_AUTHOR("Andy Fleming"); | |
47 | MODULE_LICENSE("GPL"); | |
48 | ||
49 | static int marvell_ack_interrupt(struct phy_device *phydev) | |
50 | { | |
51 | int err; | |
52 | ||
53 | /* Clear the interrupts by reading the reg */ | |
54 | err = phy_read(phydev, MII_M1011_IEVENT); | |
55 | ||
56 | if (err < 0) | |
57 | return err; | |
58 | ||
59 | return 0; | |
60 | } | |
61 | ||
62 | static int marvell_config_intr(struct phy_device *phydev) | |
63 | { | |
64 | int err; | |
65 | ||
66 | if(phydev->interrupts == PHY_INTERRUPT_ENABLED) | |
67 | err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT); | |
68 | else | |
69 | err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR); | |
70 | ||
71 | return err; | |
72 | } | |
73 | ||
74 | static int marvell_config_aneg(struct phy_device *phydev) | |
75 | { | |
76 | int err; | |
77 | ||
78 | /* The Marvell PHY has an errata which requires | |
79 | * that certain registers get written in order | |
80 | * to restart autonegotiation */ | |
81 | err = phy_write(phydev, MII_BMCR, BMCR_RESET); | |
82 | ||
83 | if (err < 0) | |
84 | return err; | |
85 | ||
86 | err = phy_write(phydev, 0x1d, 0x1f); | |
87 | if (err < 0) | |
88 | return err; | |
89 | ||
90 | err = phy_write(phydev, 0x1e, 0x200c); | |
91 | if (err < 0) | |
92 | return err; | |
93 | ||
94 | err = phy_write(phydev, 0x1d, 0x5); | |
95 | if (err < 0) | |
96 | return err; | |
97 | ||
98 | err = phy_write(phydev, 0x1e, 0); | |
99 | if (err < 0) | |
100 | return err; | |
101 | ||
102 | err = phy_write(phydev, 0x1e, 0x100); | |
103 | if (err < 0) | |
104 | return err; | |
105 | ||
106 | ||
107 | err = genphy_config_aneg(phydev); | |
108 | ||
109 | return err; | |
110 | } | |
111 | ||
112 | ||
113 | static struct phy_driver m88e1101_driver = { | |
114 | .phy_id = 0x01410c00, | |
115 | .phy_id_mask = 0xffffff00, | |
116 | .name = "Marvell 88E1101", | |
117 | .features = PHY_GBIT_FEATURES, | |
118 | .flags = PHY_HAS_INTERRUPT, | |
119 | .config_aneg = &marvell_config_aneg, | |
120 | .read_status = &genphy_read_status, | |
121 | .ack_interrupt = &marvell_ack_interrupt, | |
122 | .config_intr = &marvell_config_intr, | |
123 | .driver = { .owner = THIS_MODULE,}, | |
124 | }; | |
125 | ||
126 | static int __init marvell_init(void) | |
127 | { | |
128 | return phy_driver_register(&m88e1101_driver); | |
129 | } | |
130 | ||
131 | static void __exit marvell_exit(void) | |
132 | { | |
133 | phy_driver_unregister(&m88e1101_driver); | |
134 | } | |
135 | ||
136 | module_init(marvell_init); | |
137 | module_exit(marvell_exit); |