[kernel] refresh generic 2.6.22 patches
[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 Index: linux-2.6.22.19/drivers/net/phy/Kconfig
18 ===================================================================
19 --- linux-2.6.22.19.orig/drivers/net/phy/Kconfig
20 +++ linux-2.6.22.19/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 Index: linux-2.6.22.19/drivers/net/phy/Makefile
34 ===================================================================
35 --- linux-2.6.22.19.orig/drivers/net/phy/Makefile
36 +++ linux-2.6.22.19/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 Index: linux-2.6.22.19/drivers/net/phy/icplus.c
44 ===================================================================
45 --- /dev/null
46 +++ linux-2.6.22.19/drivers/net/phy/icplus.c
47 @@ -0,0 +1,134 @@
48 +/*
49 + * Driver for ICPlus PHYs
50 + *
51 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
52 + *
53 + * This program is free software; you can redistribute it and/or modify it
54 + * under the terms of the GNU General Public License as published by the
55 + * Free Software Foundation; either version 2 of the License, or (at your
56 + * option) any later version.
57 + *
58 + */
59 +#include <linux/kernel.h>
60 +#include <linux/string.h>
61 +#include <linux/errno.h>
62 +#include <linux/unistd.h>
63 +#include <linux/slab.h>
64 +#include <linux/interrupt.h>
65 +#include <linux/init.h>
66 +#include <linux/delay.h>
67 +#include <linux/netdevice.h>
68 +#include <linux/etherdevice.h>
69 +#include <linux/skbuff.h>
70 +#include <linux/spinlock.h>
71 +#include <linux/mm.h>
72 +#include <linux/module.h>
73 +#include <linux/mii.h>
74 +#include <linux/ethtool.h>
75 +#include <linux/phy.h>
76 +
77 +#include <asm/io.h>
78 +#include <asm/irq.h>
79 +#include <asm/uaccess.h>
80 +
81 +MODULE_DESCRIPTION("ICPlus IP175C PHY driver");
82 +MODULE_AUTHOR("Michael Barkowski");
83 +MODULE_LICENSE("GPL");
84 +
85 +static int ip175c_config_init(struct phy_device *phydev)
86 +{
87 + int err, i;
88 + static int full_reset_performed = 0;
89 +
90 + if (full_reset_performed == 0) {
91 +
92 + /* master reset */
93 + err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
94 + if (err < 0)
95 + return err;
96 +
97 + /* ensure no bus delays overlap reset period */
98 + err = phydev->bus->read(phydev->bus, 30, 0);
99 +
100 + /* data sheet specifies reset period is 2 msec */
101 + mdelay(2);
102 +
103 + /* enable IP175C mode */
104 + err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
105 + if (err < 0)
106 + return err;
107 +
108 + /* Set MII0 speed and duplex (in PHY mode) */
109 + err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
110 + if (err < 0)
111 + return err;
112 +
113 + /* reset switch ports */
114 + for (i = 0; i < 5; i++) {
115 + err = phydev->bus->write(phydev->bus, i,
116 + MII_BMCR, BMCR_RESET);
117 + if (err < 0)
118 + return err;
119 + }
120 +
121 + for (i = 0; i < 5; i++)
122 + err = phydev->bus->read(phydev->bus, i, MII_BMCR);
123 +
124 + mdelay(2);
125 +
126 + full_reset_performed = 1;
127 + }
128 +
129 + if (phydev->addr != 4) {
130 + phydev->state = PHY_RUNNING;
131 + phydev->speed = SPEED_100;
132 + phydev->duplex = DUPLEX_FULL;
133 + phydev->link = 1;
134 + netif_carrier_on(phydev->attached_dev);
135 + }
136 +
137 + return 0;
138 +}
139 +
140 +static int ip175c_read_status(struct phy_device *phydev)
141 +{
142 + if (phydev->addr == 4) /* WAN port */
143 + genphy_read_status(phydev);
144 + else
145 + /* Don't need to read status for switch ports */
146 + phydev->irq = PHY_IGNORE_INTERRUPT;
147 +
148 + return 0;
149 +}
150 +
151 +static int ip175c_config_aneg(struct phy_device *phydev)
152 +{
153 + if (phydev->addr == 4) /* WAN port */
154 + genphy_config_aneg(phydev);
155 +
156 + return 0;
157 +}
158 +
159 +static struct phy_driver ip175c_driver = {
160 + .phy_id = 0x02430d80,
161 + .name = "ICPlus IP175C",
162 + .phy_id_mask = 0x0ffffff0,
163 + .features = PHY_BASIC_FEATURES,
164 + .config_init = &ip175c_config_init,
165 + .config_aneg = &ip175c_config_aneg,
166 + .read_status = &ip175c_read_status,
167 + .driver = { .owner = THIS_MODULE,},
168 +};
169 +
170 +static int __init ip175c_init(void)
171 +{
172 + return phy_driver_register(&ip175c_driver);
173 +}
174 +
175 +static void __exit ip175c_exit(void)
176 +{
177 + phy_driver_unregister(&ip175c_driver);
178 +}
179 +
180 +module_init(ip175c_init);
181 +module_exit(ip175c_exit);
This page took 0.055215 seconds and 5 git commands to generate.