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 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
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 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
45 index 0000000..af3f1f2
47 +++ b/drivers/net/phy/icplus.c
50 + * Driver for ICPlus PHYs
52 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
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.
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>
80 +#include <asm/uaccess.h>
82 +MODULE_DESCRIPTION("ICPlus IP175C PHY driver");
83 +MODULE_AUTHOR("Michael Barkowski");
84 +MODULE_LICENSE("GPL");
86 +static int ip175c_config_init(struct phy_device *phydev)
89 + static int full_reset_performed = 0;
91 + if (full_reset_performed == 0) {
94 + err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
98 + /* ensure no bus delays overlap reset period */
99 + err = phydev->bus->read(phydev->bus, 30, 0);
101 + /* data sheet specifies reset period is 2 msec */
104 + /* enable IP175C mode */
105 + err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
109 + /* Set MII0 speed and duplex (in PHY mode) */
110 + err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
114 + /* reset switch ports */
115 + for (i = 0; i < 5; i++) {
116 + err = phydev->bus->write(phydev->bus, i,
117 + MII_BMCR, BMCR_RESET);
122 + for (i = 0; i < 5; i++)
123 + err = phydev->bus->read(phydev->bus, i, MII_BMCR);
127 + full_reset_performed = 1;
130 + if (phydev->addr != 4) {
131 + phydev->state = PHY_RUNNING;
132 + phydev->speed = SPEED_100;
133 + phydev->duplex = DUPLEX_FULL;
135 + netif_carrier_on(phydev->attached_dev);
141 +static int ip175c_read_status(struct phy_device *phydev)
143 + if (phydev->addr == 4) /* WAN port */
144 + genphy_read_status(phydev);
146 + /* Don't need to read status for switch ports */
147 + phydev->irq = PHY_IGNORE_INTERRUPT;
152 +static int ip175c_config_aneg(struct phy_device *phydev)
154 + if (phydev->addr == 4) /* WAN port */
155 + genphy_config_aneg(phydev);
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,},
171 +static int __init ip175c_init(void)
173 + return phy_driver_register(&ip175c_driver);
176 +static void __exit ip175c_exit(void)
178 + phy_driver_unregister(&ip175c_driver);
181 +module_init(ip175c_init);
182 +module_exit(ip175c_exit);