999-icplus.patch 4.4 KB

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