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