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