gianfar_phy.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. * drivers/net/gianfar_phy.c
  3. *
  4. * Gianfar Ethernet Driver -- PHY handling
  5. * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
  6. * Based on 8260_io/fcc_enet.c
  7. *
  8. * Author: Andy Fleming
  9. * Maintainer: Kumar Gala (kumar.gala@freescale.com)
  10. *
  11. * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. */
  19. #include <linux/config.h>
  20. #include <linux/kernel.h>
  21. #include <linux/sched.h>
  22. #include <linux/string.h>
  23. #include <linux/errno.h>
  24. #include <linux/slab.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/etherdevice.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/mm.h>
  33. #include <asm/io.h>
  34. #include <asm/irq.h>
  35. #include <asm/uaccess.h>
  36. #include <linux/module.h>
  37. #include <linux/version.h>
  38. #include <linux/crc32.h>
  39. #include <linux/mii.h>
  40. #include "gianfar.h"
  41. #include "gianfar_phy.h"
  42. static void config_genmii_advert(struct gfar_mii_info *mii_info);
  43. static void genmii_setup_forced(struct gfar_mii_info *mii_info);
  44. static void genmii_restart_aneg(struct gfar_mii_info *mii_info);
  45. static int gbit_config_aneg(struct gfar_mii_info *mii_info);
  46. static int genmii_config_aneg(struct gfar_mii_info *mii_info);
  47. static int genmii_update_link(struct gfar_mii_info *mii_info);
  48. static int genmii_read_status(struct gfar_mii_info *mii_info);
  49. u16 phy_read(struct gfar_mii_info *mii_info, u16 regnum);
  50. void phy_write(struct gfar_mii_info *mii_info, u16 regnum, u16 val);
  51. /* Write value to the PHY for this device to the register at regnum, */
  52. /* waiting until the write is done before it returns. All PHY */
  53. /* configuration has to be done through the TSEC1 MIIM regs */
  54. void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
  55. {
  56. struct gfar_private *priv = netdev_priv(dev);
  57. struct gfar *regbase = priv->phyregs;
  58. /* Set the PHY address and the register address we want to write */
  59. gfar_write(&regbase->miimadd, (mii_id << 8) | regnum);
  60. /* Write out the value we want */
  61. gfar_write(&regbase->miimcon, value);
  62. /* Wait for the transaction to finish */
  63. while (gfar_read(&regbase->miimind) & MIIMIND_BUSY)
  64. cpu_relax();
  65. }
  66. /* Reads from register regnum in the PHY for device dev, */
  67. /* returning the value. Clears miimcom first. All PHY */
  68. /* configuration has to be done through the TSEC1 MIIM regs */
  69. int read_phy_reg(struct net_device *dev, int mii_id, int regnum)
  70. {
  71. struct gfar_private *priv = netdev_priv(dev);
  72. struct gfar *regbase = priv->phyregs;
  73. u16 value;
  74. /* Set the PHY address and the register address we want to read */
  75. gfar_write(&regbase->miimadd, (mii_id << 8) | regnum);
  76. /* Clear miimcom, and then initiate a read */
  77. gfar_write(&regbase->miimcom, 0);
  78. gfar_write(&regbase->miimcom, MII_READ_COMMAND);
  79. /* Wait for the transaction to finish */
  80. while (gfar_read(&regbase->miimind) & (MIIMIND_NOTVALID | MIIMIND_BUSY))
  81. cpu_relax();
  82. /* Grab the value of the register from miimstat */
  83. value = gfar_read(&regbase->miimstat);
  84. return value;
  85. }
  86. void mii_clear_phy_interrupt(struct gfar_mii_info *mii_info)
  87. {
  88. if(mii_info->phyinfo->ack_interrupt)
  89. mii_info->phyinfo->ack_interrupt(mii_info);
  90. }
  91. void mii_configure_phy_interrupt(struct gfar_mii_info *mii_info, u32 interrupts)
  92. {
  93. mii_info->interrupts = interrupts;
  94. if(mii_info->phyinfo->config_intr)
  95. mii_info->phyinfo->config_intr(mii_info);
  96. }
  97. /* Writes MII_ADVERTISE with the appropriate values, after
  98. * sanitizing advertise to make sure only supported features
  99. * are advertised
  100. */
  101. static void config_genmii_advert(struct gfar_mii_info *mii_info)
  102. {
  103. u32 advertise;
  104. u16 adv;
  105. /* Only allow advertising what this PHY supports */
  106. mii_info->advertising &= mii_info->phyinfo->features;
  107. advertise = mii_info->advertising;
  108. /* Setup standard advertisement */
  109. adv = phy_read(mii_info, MII_ADVERTISE);
  110. adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
  111. if (advertise & ADVERTISED_10baseT_Half)
  112. adv |= ADVERTISE_10HALF;
  113. if (advertise & ADVERTISED_10baseT_Full)
  114. adv |= ADVERTISE_10FULL;
  115. if (advertise & ADVERTISED_100baseT_Half)
  116. adv |= ADVERTISE_100HALF;
  117. if (advertise & ADVERTISED_100baseT_Full)
  118. adv |= ADVERTISE_100FULL;
  119. phy_write(mii_info, MII_ADVERTISE, adv);
  120. }
  121. static void genmii_setup_forced(struct gfar_mii_info *mii_info)
  122. {
  123. u16 ctrl;
  124. u32 features = mii_info->phyinfo->features;
  125. ctrl = phy_read(mii_info, MII_BMCR);
  126. ctrl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_SPEED1000|BMCR_ANENABLE);
  127. ctrl |= BMCR_RESET;
  128. switch(mii_info->speed) {
  129. case SPEED_1000:
  130. if(features & (SUPPORTED_1000baseT_Half
  131. | SUPPORTED_1000baseT_Full)) {
  132. ctrl |= BMCR_SPEED1000;
  133. break;
  134. }
  135. mii_info->speed = SPEED_100;
  136. case SPEED_100:
  137. if (features & (SUPPORTED_100baseT_Half
  138. | SUPPORTED_100baseT_Full)) {
  139. ctrl |= BMCR_SPEED100;
  140. break;
  141. }
  142. mii_info->speed = SPEED_10;
  143. case SPEED_10:
  144. if (features & (SUPPORTED_10baseT_Half
  145. | SUPPORTED_10baseT_Full))
  146. break;
  147. default: /* Unsupported speed! */
  148. printk(KERN_ERR "%s: Bad speed!\n",
  149. mii_info->dev->name);
  150. break;
  151. }
  152. phy_write(mii_info, MII_BMCR, ctrl);
  153. }
  154. /* Enable and Restart Autonegotiation */
  155. static void genmii_restart_aneg(struct gfar_mii_info *mii_info)
  156. {
  157. u16 ctl;
  158. ctl = phy_read(mii_info, MII_BMCR);
  159. ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
  160. phy_write(mii_info, MII_BMCR, ctl);
  161. }
  162. static int gbit_config_aneg(struct gfar_mii_info *mii_info)
  163. {
  164. u16 adv;
  165. u32 advertise;
  166. if(mii_info->autoneg) {
  167. /* Configure the ADVERTISE register */
  168. config_genmii_advert(mii_info);
  169. advertise = mii_info->advertising;
  170. adv = phy_read(mii_info, MII_1000BASETCONTROL);
  171. adv &= ~(MII_1000BASETCONTROL_FULLDUPLEXCAP |
  172. MII_1000BASETCONTROL_HALFDUPLEXCAP);
  173. if (advertise & SUPPORTED_1000baseT_Half)
  174. adv |= MII_1000BASETCONTROL_HALFDUPLEXCAP;
  175. if (advertise & SUPPORTED_1000baseT_Full)
  176. adv |= MII_1000BASETCONTROL_FULLDUPLEXCAP;
  177. phy_write(mii_info, MII_1000BASETCONTROL, adv);
  178. /* Start/Restart aneg */
  179. genmii_restart_aneg(mii_info);
  180. } else
  181. genmii_setup_forced(mii_info);
  182. return 0;
  183. }
  184. static int marvell_config_aneg(struct gfar_mii_info *mii_info)
  185. {
  186. /* The Marvell PHY has an errata which requires
  187. * that certain registers get written in order
  188. * to restart autonegotiation */
  189. phy_write(mii_info, MII_BMCR, BMCR_RESET);
  190. phy_write(mii_info, 0x1d, 0x1f);
  191. phy_write(mii_info, 0x1e, 0x200c);
  192. phy_write(mii_info, 0x1d, 0x5);
  193. phy_write(mii_info, 0x1e, 0);
  194. phy_write(mii_info, 0x1e, 0x100);
  195. gbit_config_aneg(mii_info);
  196. return 0;
  197. }
  198. static int genmii_config_aneg(struct gfar_mii_info *mii_info)
  199. {
  200. if (mii_info->autoneg) {
  201. config_genmii_advert(mii_info);
  202. genmii_restart_aneg(mii_info);
  203. } else
  204. genmii_setup_forced(mii_info);
  205. return 0;
  206. }
  207. static int genmii_update_link(struct gfar_mii_info *mii_info)
  208. {
  209. u16 status;
  210. /* Do a fake read */
  211. phy_read(mii_info, MII_BMSR);
  212. /* Read link and autonegotiation status */
  213. status = phy_read(mii_info, MII_BMSR);
  214. if ((status & BMSR_LSTATUS) == 0)
  215. mii_info->link = 0;
  216. else
  217. mii_info->link = 1;
  218. /* If we are autonegotiating, and not done,
  219. * return an error */
  220. if (mii_info->autoneg && !(status & BMSR_ANEGCOMPLETE))
  221. return -EAGAIN;
  222. return 0;
  223. }
  224. static int genmii_read_status(struct gfar_mii_info *mii_info)
  225. {
  226. u16 status;
  227. int err;
  228. /* Update the link, but return if there
  229. * was an error */
  230. err = genmii_update_link(mii_info);
  231. if (err)
  232. return err;
  233. if (mii_info->autoneg) {
  234. status = phy_read(mii_info, MII_LPA);
  235. if (status & (LPA_10FULL | LPA_100FULL))
  236. mii_info->duplex = DUPLEX_FULL;
  237. else
  238. mii_info->duplex = DUPLEX_HALF;
  239. if (status & (LPA_100FULL | LPA_100HALF))
  240. mii_info->speed = SPEED_100;
  241. else
  242. mii_info->speed = SPEED_10;
  243. mii_info->pause = 0;
  244. }
  245. /* On non-aneg, we assume what we put in BMCR is the speed,
  246. * though magic-aneg shouldn't prevent this case from occurring
  247. */
  248. return 0;
  249. }
  250. static int marvell_read_status(struct gfar_mii_info *mii_info)
  251. {
  252. u16 status;
  253. int err;
  254. /* Update the link, but return if there
  255. * was an error */
  256. err = genmii_update_link(mii_info);
  257. if (err)
  258. return err;
  259. /* If the link is up, read the speed and duplex */
  260. /* If we aren't autonegotiating, assume speeds
  261. * are as set */
  262. if (mii_info->autoneg && mii_info->link) {
  263. int speed;
  264. status = phy_read(mii_info, MII_M1011_PHY_SPEC_STATUS);
  265. #if 0
  266. /* If speed and duplex aren't resolved,
  267. * return an error. Isn't this handled
  268. * by checking aneg?
  269. */
  270. if ((status & MII_M1011_PHY_SPEC_STATUS_RESOLVED) == 0)
  271. return -EAGAIN;
  272. #endif
  273. /* Get the duplexity */
  274. if (status & MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX)
  275. mii_info->duplex = DUPLEX_FULL;
  276. else
  277. mii_info->duplex = DUPLEX_HALF;
  278. /* Get the speed */
  279. speed = status & MII_M1011_PHY_SPEC_STATUS_SPD_MASK;
  280. switch(speed) {
  281. case MII_M1011_PHY_SPEC_STATUS_1000:
  282. mii_info->speed = SPEED_1000;
  283. break;
  284. case MII_M1011_PHY_SPEC_STATUS_100:
  285. mii_info->speed = SPEED_100;
  286. break;
  287. default:
  288. mii_info->speed = SPEED_10;
  289. break;
  290. }
  291. mii_info->pause = 0;
  292. }
  293. return 0;
  294. }
  295. static int cis820x_read_status(struct gfar_mii_info *mii_info)
  296. {
  297. u16 status;
  298. int err;
  299. /* Update the link, but return if there
  300. * was an error */
  301. err = genmii_update_link(mii_info);
  302. if (err)
  303. return err;
  304. /* If the link is up, read the speed and duplex */
  305. /* If we aren't autonegotiating, assume speeds
  306. * are as set */
  307. if (mii_info->autoneg && mii_info->link) {
  308. int speed;
  309. status = phy_read(mii_info, MII_CIS8201_AUX_CONSTAT);
  310. if (status & MII_CIS8201_AUXCONSTAT_DUPLEX)
  311. mii_info->duplex = DUPLEX_FULL;
  312. else
  313. mii_info->duplex = DUPLEX_HALF;
  314. speed = status & MII_CIS8201_AUXCONSTAT_SPEED;
  315. switch (speed) {
  316. case MII_CIS8201_AUXCONSTAT_GBIT:
  317. mii_info->speed = SPEED_1000;
  318. break;
  319. case MII_CIS8201_AUXCONSTAT_100:
  320. mii_info->speed = SPEED_100;
  321. break;
  322. default:
  323. mii_info->speed = SPEED_10;
  324. break;
  325. }
  326. }
  327. return 0;
  328. }
  329. static int marvell_ack_interrupt(struct gfar_mii_info *mii_info)
  330. {
  331. /* Clear the interrupts by reading the reg */
  332. phy_read(mii_info, MII_M1011_IEVENT);
  333. return 0;
  334. }
  335. static int marvell_config_intr(struct gfar_mii_info *mii_info)
  336. {
  337. if(mii_info->interrupts == MII_INTERRUPT_ENABLED)
  338. phy_write(mii_info, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
  339. else
  340. phy_write(mii_info, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
  341. return 0;
  342. }
  343. static int cis820x_init(struct gfar_mii_info *mii_info)
  344. {
  345. phy_write(mii_info, MII_CIS8201_AUX_CONSTAT,
  346. MII_CIS8201_AUXCONSTAT_INIT);
  347. phy_write(mii_info, MII_CIS8201_EXT_CON1,
  348. MII_CIS8201_EXTCON1_INIT);
  349. return 0;
  350. }
  351. static int cis820x_ack_interrupt(struct gfar_mii_info *mii_info)
  352. {
  353. phy_read(mii_info, MII_CIS8201_ISTAT);
  354. return 0;
  355. }
  356. static int cis820x_config_intr(struct gfar_mii_info *mii_info)
  357. {
  358. if(mii_info->interrupts == MII_INTERRUPT_ENABLED)
  359. phy_write(mii_info, MII_CIS8201_IMASK, MII_CIS8201_IMASK_MASK);
  360. else
  361. phy_write(mii_info, MII_CIS8201_IMASK, 0);
  362. return 0;
  363. }
  364. #define DM9161_DELAY 10
  365. static int dm9161_read_status(struct gfar_mii_info *mii_info)
  366. {
  367. u16 status;
  368. int err;
  369. /* Update the link, but return if there
  370. * was an error */
  371. err = genmii_update_link(mii_info);
  372. if (err)
  373. return err;
  374. /* If the link is up, read the speed and duplex */
  375. /* If we aren't autonegotiating, assume speeds
  376. * are as set */
  377. if (mii_info->autoneg && mii_info->link) {
  378. status = phy_read(mii_info, MII_DM9161_SCSR);
  379. if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_100H))
  380. mii_info->speed = SPEED_100;
  381. else
  382. mii_info->speed = SPEED_10;
  383. if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_10F))
  384. mii_info->duplex = DUPLEX_FULL;
  385. else
  386. mii_info->duplex = DUPLEX_HALF;
  387. }
  388. return 0;
  389. }
  390. static int dm9161_config_aneg(struct gfar_mii_info *mii_info)
  391. {
  392. struct dm9161_private *priv = mii_info->priv;
  393. if(0 == priv->resetdone)
  394. return -EAGAIN;
  395. return 0;
  396. }
  397. static void dm9161_timer(unsigned long data)
  398. {
  399. struct gfar_mii_info *mii_info = (struct gfar_mii_info *)data;
  400. struct dm9161_private *priv = mii_info->priv;
  401. u16 status = phy_read(mii_info, MII_BMSR);
  402. if (status & BMSR_ANEGCOMPLETE) {
  403. priv->resetdone = 1;
  404. } else
  405. mod_timer(&priv->timer, jiffies + DM9161_DELAY * HZ);
  406. }
  407. static int dm9161_init(struct gfar_mii_info *mii_info)
  408. {
  409. struct dm9161_private *priv;
  410. /* Allocate the private data structure */
  411. priv = kmalloc(sizeof(struct dm9161_private), GFP_KERNEL);
  412. if (NULL == priv)
  413. return -ENOMEM;
  414. mii_info->priv = priv;
  415. /* Reset is not done yet */
  416. priv->resetdone = 0;
  417. /* Isolate the PHY */
  418. phy_write(mii_info, MII_BMCR, BMCR_ISOLATE);
  419. /* Do not bypass the scrambler/descrambler */
  420. phy_write(mii_info, MII_DM9161_SCR, MII_DM9161_SCR_INIT);
  421. /* Clear 10BTCSR to default */
  422. phy_write(mii_info, MII_DM9161_10BTCSR, MII_DM9161_10BTCSR_INIT);
  423. /* Reconnect the PHY, and enable Autonegotiation */
  424. phy_write(mii_info, MII_BMCR, BMCR_ANENABLE);
  425. /* Start a timer for DM9161_DELAY seconds to wait
  426. * for the PHY to be ready */
  427. init_timer(&priv->timer);
  428. priv->timer.function = &dm9161_timer;
  429. priv->timer.data = (unsigned long) mii_info;
  430. mod_timer(&priv->timer, jiffies + DM9161_DELAY * HZ);
  431. return 0;
  432. }
  433. static void dm9161_close(struct gfar_mii_info *mii_info)
  434. {
  435. struct dm9161_private *priv = mii_info->priv;
  436. del_timer_sync(&priv->timer);
  437. kfree(priv);
  438. }
  439. #if 0
  440. static int dm9161_ack_interrupt(struct gfar_mii_info *mii_info)
  441. {
  442. phy_read(mii_info, MII_DM9161_INTR);
  443. return 0;
  444. }
  445. #endif
  446. /* Cicada 820x */
  447. static struct phy_info phy_info_cis820x = {
  448. 0x000fc440,
  449. "Cicada Cis8204",
  450. 0x000fffc0,
  451. .features = MII_GBIT_FEATURES,
  452. .init = &cis820x_init,
  453. .config_aneg = &gbit_config_aneg,
  454. .read_status = &cis820x_read_status,
  455. .ack_interrupt = &cis820x_ack_interrupt,
  456. .config_intr = &cis820x_config_intr,
  457. };
  458. static struct phy_info phy_info_dm9161 = {
  459. .phy_id = 0x0181b880,
  460. .name = "Davicom DM9161E",
  461. .phy_id_mask = 0x0ffffff0,
  462. .init = dm9161_init,
  463. .config_aneg = dm9161_config_aneg,
  464. .read_status = dm9161_read_status,
  465. .close = dm9161_close,
  466. };
  467. static struct phy_info phy_info_marvell = {
  468. .phy_id = 0x01410c00,
  469. .phy_id_mask = 0xffffff00,
  470. .name = "Marvell 88E1101/88E1111",
  471. .features = MII_GBIT_FEATURES,
  472. .config_aneg = &marvell_config_aneg,
  473. .read_status = &marvell_read_status,
  474. .ack_interrupt = &marvell_ack_interrupt,
  475. .config_intr = &marvell_config_intr,
  476. };
  477. static struct phy_info phy_info_genmii= {
  478. .phy_id = 0x00000000,
  479. .phy_id_mask = 0x00000000,
  480. .name = "Generic MII",
  481. .features = MII_BASIC_FEATURES,
  482. .config_aneg = genmii_config_aneg,
  483. .read_status = genmii_read_status,
  484. };
  485. static struct phy_info *phy_info[] = {
  486. &phy_info_cis820x,
  487. &phy_info_marvell,
  488. &phy_info_dm9161,
  489. &phy_info_genmii,
  490. NULL
  491. };
  492. u16 phy_read(struct gfar_mii_info *mii_info, u16 regnum)
  493. {
  494. u16 retval;
  495. unsigned long flags;
  496. spin_lock_irqsave(&mii_info->mdio_lock, flags);
  497. retval = mii_info->mdio_read(mii_info->dev, mii_info->mii_id, regnum);
  498. spin_unlock_irqrestore(&mii_info->mdio_lock, flags);
  499. return retval;
  500. }
  501. void phy_write(struct gfar_mii_info *mii_info, u16 regnum, u16 val)
  502. {
  503. unsigned long flags;
  504. spin_lock_irqsave(&mii_info->mdio_lock, flags);
  505. mii_info->mdio_write(mii_info->dev,
  506. mii_info->mii_id,
  507. regnum, val);
  508. spin_unlock_irqrestore(&mii_info->mdio_lock, flags);
  509. }
  510. /* Use the PHY ID registers to determine what type of PHY is attached
  511. * to device dev. return a struct phy_info structure describing that PHY
  512. */
  513. struct phy_info * get_phy_info(struct gfar_mii_info *mii_info)
  514. {
  515. u16 phy_reg;
  516. u32 phy_ID;
  517. int i;
  518. struct phy_info *theInfo = NULL;
  519. struct net_device *dev = mii_info->dev;
  520. /* Grab the bits from PHYIR1, and put them in the upper half */
  521. phy_reg = phy_read(mii_info, MII_PHYSID1);
  522. phy_ID = (phy_reg & 0xffff) << 16;
  523. /* Grab the bits from PHYIR2, and put them in the lower half */
  524. phy_reg = phy_read(mii_info, MII_PHYSID2);
  525. phy_ID |= (phy_reg & 0xffff);
  526. /* loop through all the known PHY types, and find one that */
  527. /* matches the ID we read from the PHY. */
  528. for (i = 0; phy_info[i]; i++)
  529. if (phy_info[i]->phy_id ==
  530. (phy_ID & phy_info[i]->phy_id_mask)) {
  531. theInfo = phy_info[i];
  532. break;
  533. }
  534. /* This shouldn't happen, as we have generic PHY support */
  535. if (theInfo == NULL) {
  536. printk("%s: PHY id %x is not supported!\n", dev->name, phy_ID);
  537. return NULL;
  538. } else {
  539. printk("%s: PHY is %s (%x)\n", dev->name, theInfo->name,
  540. phy_ID);
  541. }
  542. return theInfo;
  543. }