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
7 phylib: add the ICPlus IP175C PHY driver
9 The ICPlus IP175C sports a 100Mbit/s 4-port switch in addition
10 to a dedicated 100Mbit/s WAN port.
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>
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
23 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
26 + tristate "Drivers for ICPlus PHYs"
28 + Currently supports the IP175C PHY.
31 tristate "Drivers for PHY emulation on fixed speed/link"
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 ===================================================================
46 +++ linux-2.6.22.19/drivers/net/phy/icplus.c
49 + * Driver for ICPlus PHYs
51 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
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.
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>
79 +#include <asm/uaccess.h>
81 +MODULE_DESCRIPTION("ICPlus IP175C PHY driver");
82 +MODULE_AUTHOR("Michael Barkowski");
83 +MODULE_LICENSE("GPL");
85 +static int ip175c_config_init(struct phy_device *phydev)
88 + static int full_reset_performed = 0;
90 + if (full_reset_performed == 0) {
93 + err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
97 + /* ensure no bus delays overlap reset period */
98 + err = phydev->bus->read(phydev->bus, 30, 0);
100 + /* data sheet specifies reset period is 2 msec */
103 + /* enable IP175C mode */
104 + err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
108 + /* Set MII0 speed and duplex (in PHY mode) */
109 + err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
113 + /* reset switch ports */
114 + for (i = 0; i < 5; i++) {
115 + err = phydev->bus->write(phydev->bus, i,
116 + MII_BMCR, BMCR_RESET);
121 + for (i = 0; i < 5; i++)
122 + err = phydev->bus->read(phydev->bus, i, MII_BMCR);
126 + full_reset_performed = 1;
129 + if (phydev->addr != 4) {
130 + phydev->state = PHY_RUNNING;
131 + phydev->speed = SPEED_100;
132 + phydev->duplex = DUPLEX_FULL;
134 + netif_carrier_on(phydev->attached_dev);
140 +static int ip175c_read_status(struct phy_device *phydev)
142 + if (phydev->addr == 4) /* WAN port */
143 + genphy_read_status(phydev);
145 + /* Don't need to read status for switch ports */
146 + phydev->irq = PHY_IGNORE_INTERRUPT;
151 +static int ip175c_config_aneg(struct phy_device *phydev)
153 + if (phydev->addr == 4) /* WAN port */
154 + genphy_config_aneg(phydev);
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,},
170 +static int __init ip175c_init(void)
172 + return phy_driver_register(&ip175c_driver);
175 +static void __exit ip175c_exit(void)
177 + phy_driver_unregister(&ip175c_driver);
180 +module_init(ip175c_init);
181 +module_exit(ip175c_exit);