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 --- a/drivers/net/phy/Kconfig
18 +++ b/drivers/net/phy/Kconfig
21 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
24 + tristate "Drivers for ICPlus PHYs"
26 + Currently supports the IP175C PHY.
29 tristate "Drivers for PHY emulation on fixed speed/link"
31 --- a/drivers/net/phy/Makefile
32 +++ b/drivers/net/phy/Makefile
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
40 +++ b/drivers/net/phy/icplus.c
43 + * Driver for ICPlus PHYs
45 + * Copyright (c) 2007 Freescale Semiconductor, Inc.
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.
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>
73 +#include <asm/uaccess.h>
75 +MODULE_DESCRIPTION("ICPlus IP175C PHY driver");
76 +MODULE_AUTHOR("Michael Barkowski");
77 +MODULE_LICENSE("GPL");
79 +static int ip175c_config_init(struct phy_device *phydev)
82 + static int full_reset_performed = 0;
84 + if (full_reset_performed == 0) {
87 + err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
91 + /* ensure no bus delays overlap reset period */
92 + err = phydev->bus->read(phydev->bus, 30, 0);
94 + /* data sheet specifies reset period is 2 msec */
97 + /* enable IP175C mode */
98 + err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
102 + /* Set MII0 speed and duplex (in PHY mode) */
103 + err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
107 + /* reset switch ports */
108 + for (i = 0; i < 5; i++) {
109 + err = phydev->bus->write(phydev->bus, i,
110 + MII_BMCR, BMCR_RESET);
115 + for (i = 0; i < 5; i++)
116 + err = phydev->bus->read(phydev->bus, i, MII_BMCR);
120 + full_reset_performed = 1;
123 + if (phydev->addr != 4) {
124 + phydev->state = PHY_RUNNING;
125 + phydev->speed = SPEED_100;
126 + phydev->duplex = DUPLEX_FULL;
128 + netif_carrier_on(phydev->attached_dev);
134 +static int ip175c_read_status(struct phy_device *phydev)
136 + if (phydev->addr == 4) /* WAN port */
137 + genphy_read_status(phydev);
139 + /* Don't need to read status for switch ports */
140 + phydev->irq = PHY_IGNORE_INTERRUPT;
145 +static int ip175c_config_aneg(struct phy_device *phydev)
147 + if (phydev->addr == 4) /* WAN port */
148 + genphy_config_aneg(phydev);
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,},
164 +static int __init ip175c_init(void)
166 + return phy_driver_register(&ip175c_driver);
169 +static void __exit ip175c_exit(void)
171 + phy_driver_unregister(&ip175c_driver);
174 +module_init(ip175c_init);
175 +module_exit(ip175c_exit);