more danube 2 ifxmips transitions
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.22 / 999-icplus.patch
1 From: Michael Barkowski <michael.barkowski@freescale.com>
2 Date: Fri, 11 May 2007 23:24:51 +0000 (-0500)
3 Subject: phylib: add the ICPlus IP175C PHY driver
4 X-Git-Tag: v2.6.23-rc1~1201^2~58
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=0cefeebaf3da39d768bffcf62460fe2088e824ef
6
7 phylib: add the ICPlus IP175C PHY driver
8
9 The ICPlus IP175C sports a 100Mbit/s 4-port switch in addition
10 to a dedicated 100Mbit/s WAN port.
11
12 Signed-off-by: Michael Barkowski <michael.barkowski@freescale.com>
13 Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
14 Signed-off-by: Jeff Garzik <jeff@garzik.org>
15 ---
16
17 diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
18 index 09b6f25..dd09011 100644
19 --- a/drivers/net/phy/Kconfig
20 +++ b/drivers/net/phy/Kconfig
21 @@ -55,6 +55,11 @@ config BROADCOM_PHY
22 ---help---
23 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
24
25 +config ICPLUS_PHY
26 + tristate "Drivers for ICPlus PHYs"
27 + ---help---
28 + Currently supports the IP175C PHY.
29 +
30 config FIXED_PHY
31 tristate "Drivers for PHY emulation on fixed speed/link"
32 ---help---
33 diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
34 index bcd1efb..8885650 100644
35 --- a/drivers/net/phy/Makefile
36 +++ b/drivers/net/phy/Makefile
37 @@ -11,4 +11,5 @@ obj-$(CONFIG_QSEMI_PHY) += qsemi.o
38 obj-$(CONFIG_SMSC_PHY) += smsc.o
39 obj-$(CONFIG_VITESSE_PHY) += vitesse.o
40 obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
41 +obj-$(CONFIG_ICPLUS_PHY) += icplus.o
42 obj-$(CONFIG_FIXED_PHY) += fixed.o
43 diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
44 new file mode 100644
45 index 0000000..af3f1f2
46 --- /dev/null
47 +++ b/drivers/net/phy/icplus.c
48 @@ -0,0 +1,134 @@
49 +/*
50 + * Driver for ICPlus PHYs
51 + *
52 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
53 + *
54 + * This program is free software; you can redistribute it and/or modify it
55 + * under the terms of the GNU General Public License as published by the
56 + * Free Software Foundation; either version 2 of the License, or (at your
57 + * option) any later version.
58 + *
59 + */
60 +#include <linux/kernel.h>
61 +#include <linux/string.h>
62 +#include <linux/errno.h>
63 +#include <linux/unistd.h>
64 +#include <linux/slab.h>
65 +#include <linux/interrupt.h>
66 +#include <linux/init.h>
67 +#include <linux/delay.h>
68 +#include <linux/netdevice.h>
69 +#include <linux/etherdevice.h>
70 +#include <linux/skbuff.h>
71 +#include <linux/spinlock.h>
72 +#include <linux/mm.h>
73 +#include <linux/module.h>
74 +#include <linux/mii.h>
75 +#include <linux/ethtool.h>
76 +#include <linux/phy.h>
77 +
78 +#include <asm/io.h>
79 +#include <asm/irq.h>
80 +#include <asm/uaccess.h>
81 +
82 +MODULE_DESCRIPTION("ICPlus IP175C PHY driver");
83 +MODULE_AUTHOR("Michael Barkowski");
84 +MODULE_LICENSE("GPL");
85 +
86 +static int ip175c_config_init(struct phy_device *phydev)
87 +{
88 + int err, i;
89 + static int full_reset_performed = 0;
90 +
91 + if (full_reset_performed == 0) {
92 +
93 + /* master reset */
94 + err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
95 + if (err < 0)
96 + return err;
97 +
98 + /* ensure no bus delays overlap reset period */
99 + err = phydev->bus->read(phydev->bus, 30, 0);
100 +
101 + /* data sheet specifies reset period is 2 msec */
102 + mdelay(2);
103 +
104 + /* enable IP175C mode */
105 + err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
106 + if (err < 0)
107 + return err;
108 +
109 + /* Set MII0 speed and duplex (in PHY mode) */
110 + err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
111 + if (err < 0)
112 + return err;
113 +
114 + /* reset switch ports */
115 + for (i = 0; i < 5; i++) {
116 + err = phydev->bus->write(phydev->bus, i,
117 + MII_BMCR, BMCR_RESET);
118 + if (err < 0)
119 + return err;
120 + }
121 +
122 + for (i = 0; i < 5; i++)
123 + err = phydev->bus->read(phydev->bus, i, MII_BMCR);
124 +
125 + mdelay(2);
126 +
127 + full_reset_performed = 1;
128 + }
129 +
130 + if (phydev->addr != 4) {
131 + phydev->state = PHY_RUNNING;
132 + phydev->speed = SPEED_100;
133 + phydev->duplex = DUPLEX_FULL;
134 + phydev->link = 1;
135 + netif_carrier_on(phydev->attached_dev);
136 + }
137 +
138 + return 0;
139 +}
140 +
141 +static int ip175c_read_status(struct phy_device *phydev)
142 +{
143 + if (phydev->addr == 4) /* WAN port */
144 + genphy_read_status(phydev);
145 + else
146 + /* Don't need to read status for switch ports */
147 + phydev->irq = PHY_IGNORE_INTERRUPT;
148 +
149 + return 0;
150 +}
151 +
152 +static int ip175c_config_aneg(struct phy_device *phydev)
153 +{
154 + if (phydev->addr == 4) /* WAN port */
155 + genphy_config_aneg(phydev);
156 +
157 + return 0;
158 +}
159 +
160 +static struct phy_driver ip175c_driver = {
161 + .phy_id = 0x02430d80,
162 + .name = "ICPlus IP175C",
163 + .phy_id_mask = 0x0ffffff0,
164 + .features = PHY_BASIC_FEATURES,
165 + .config_init = &ip175c_config_init,
166 + .config_aneg = &ip175c_config_aneg,
167 + .read_status = &ip175c_read_status,
168 + .driver = { .owner = THIS_MODULE,},
169 +};
170 +
171 +static int __init ip175c_init(void)
172 +{
173 + return phy_driver_register(&ip175c_driver);
174 +}
175 +
176 +static void __exit ip175c_exit(void)
177 +{
178 + phy_driver_unregister(&ip175c_driver);
179 +}
180 +
181 +module_init(ip175c_init);
182 +module_exit(ip175c_exit);
This page took 0.048755 seconds and 5 git commands to generate.