uec_phy.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. * Copyright (C) 2005 Freescale Semiconductor, Inc.
  3. *
  4. * Author: Shlomi Gridish
  5. *
  6. * Description: UCC GETH Driver -- PHY handling
  7. * Driver for UEC on QE
  8. * Based on 8260_io/fcc_enet.c
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. *
  15. */
  16. #include "common.h"
  17. #include "net.h"
  18. #include "malloc.h"
  19. #include "asm/errno.h"
  20. #include "asm/immap_qe.h"
  21. #include "asm/io.h"
  22. #include "qe.h"
  23. #include "uccf.h"
  24. #include "uec.h"
  25. #include "uec_phy.h"
  26. #include "miiphy.h"
  27. #if defined(CONFIG_QE)
  28. #define ugphy_printk(format, arg...) \
  29. printf(format "\n", ## arg)
  30. #define ugphy_dbg(format, arg...) \
  31. ugphy_printk(format , ## arg)
  32. #define ugphy_err(format, arg...) \
  33. ugphy_printk(format , ## arg)
  34. #define ugphy_info(format, arg...) \
  35. ugphy_printk(format , ## arg)
  36. #define ugphy_warn(format, arg...) \
  37. ugphy_printk(format , ## arg)
  38. #ifdef UEC_VERBOSE_DEBUG
  39. #define ugphy_vdbg ugphy_dbg
  40. #else
  41. #define ugphy_vdbg(ugeth, fmt, args...) do { } while (0)
  42. #endif /* UEC_VERBOSE_DEBUG */
  43. static void config_genmii_advert (struct uec_mii_info *mii_info);
  44. static void genmii_setup_forced (struct uec_mii_info *mii_info);
  45. static void genmii_restart_aneg (struct uec_mii_info *mii_info);
  46. static int gbit_config_aneg (struct uec_mii_info *mii_info);
  47. static int genmii_config_aneg (struct uec_mii_info *mii_info);
  48. static int genmii_update_link (struct uec_mii_info *mii_info);
  49. static int genmii_read_status (struct uec_mii_info *mii_info);
  50. u16 phy_read (struct uec_mii_info *mii_info, u16 regnum);
  51. void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val);
  52. /* Write value to the PHY for this device to the register at regnum, */
  53. /* waiting until the write is done before it returns. All PHY */
  54. /* configuration has to be done through the TSEC1 MIIM regs */
  55. void uec_write_phy_reg (struct eth_device *dev, int mii_id, int regnum, int value)
  56. {
  57. uec_private_t *ugeth = (uec_private_t *) dev->priv;
  58. uec_mii_t *ug_regs;
  59. enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum;
  60. u32 tmp_reg;
  61. ug_regs = ugeth->uec_mii_regs;
  62. /* Stop the MII management read cycle */
  63. out_be32 (&ug_regs->miimcom, 0);
  64. /* Setting up the MII Mangement Address Register */
  65. tmp_reg = ((u32) mii_id << MIIMADD_PHY_ADDRESS_SHIFT) | mii_reg;
  66. out_be32 (&ug_regs->miimadd, tmp_reg);
  67. /* Setting up the MII Mangement Control Register with the value */
  68. out_be32 (&ug_regs->miimcon, (u32) value);
  69. sync();
  70. /* Wait till MII management write is complete */
  71. while ((in_be32 (&ug_regs->miimind)) & MIIMIND_BUSY);
  72. }
  73. /* Reads from register regnum in the PHY for device dev, */
  74. /* returning the value. Clears miimcom first. All PHY */
  75. /* configuration has to be done through the TSEC1 MIIM regs */
  76. int uec_read_phy_reg (struct eth_device *dev, int mii_id, int regnum)
  77. {
  78. uec_private_t *ugeth = (uec_private_t *) dev->priv;
  79. uec_mii_t *ug_regs;
  80. enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum;
  81. u32 tmp_reg;
  82. u16 value;
  83. ug_regs = ugeth->uec_mii_regs;
  84. /* Setting up the MII Mangement Address Register */
  85. tmp_reg = ((u32) mii_id << MIIMADD_PHY_ADDRESS_SHIFT) | mii_reg;
  86. out_be32 (&ug_regs->miimadd, tmp_reg);
  87. /* clear MII management command cycle */
  88. out_be32 (&ug_regs->miimcom, 0);
  89. sync();
  90. /* Perform an MII management read cycle */
  91. out_be32 (&ug_regs->miimcom, MIIMCOM_READ_CYCLE);
  92. /* Wait till MII management write is complete */
  93. while ((in_be32 (&ug_regs->miimind)) &
  94. (MIIMIND_NOT_VALID | MIIMIND_BUSY));
  95. /* Read MII management status */
  96. value = (u16) in_be32 (&ug_regs->miimstat);
  97. if (value == 0xffff)
  98. ugphy_vdbg
  99. ("read wrong value : mii_id %d,mii_reg %d, base %08x",
  100. mii_id, mii_reg, (u32) & (ug_regs->miimcfg));
  101. return (value);
  102. }
  103. void mii_clear_phy_interrupt (struct uec_mii_info *mii_info)
  104. {
  105. if (mii_info->phyinfo->ack_interrupt)
  106. mii_info->phyinfo->ack_interrupt (mii_info);
  107. }
  108. void mii_configure_phy_interrupt (struct uec_mii_info *mii_info,
  109. u32 interrupts)
  110. {
  111. mii_info->interrupts = interrupts;
  112. if (mii_info->phyinfo->config_intr)
  113. mii_info->phyinfo->config_intr (mii_info);
  114. }
  115. /* Writes MII_ADVERTISE with the appropriate values, after
  116. * sanitizing advertise to make sure only supported features
  117. * are advertised
  118. */
  119. static void config_genmii_advert (struct uec_mii_info *mii_info)
  120. {
  121. u32 advertise;
  122. u16 adv;
  123. /* Only allow advertising what this PHY supports */
  124. mii_info->advertising &= mii_info->phyinfo->features;
  125. advertise = mii_info->advertising;
  126. /* Setup standard advertisement */
  127. adv = phy_read (mii_info, PHY_ANAR);
  128. adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
  129. if (advertise & ADVERTISED_10baseT_Half)
  130. adv |= ADVERTISE_10HALF;
  131. if (advertise & ADVERTISED_10baseT_Full)
  132. adv |= ADVERTISE_10FULL;
  133. if (advertise & ADVERTISED_100baseT_Half)
  134. adv |= ADVERTISE_100HALF;
  135. if (advertise & ADVERTISED_100baseT_Full)
  136. adv |= ADVERTISE_100FULL;
  137. phy_write (mii_info, PHY_ANAR, adv);
  138. }
  139. static void genmii_setup_forced (struct uec_mii_info *mii_info)
  140. {
  141. u16 ctrl;
  142. u32 features = mii_info->phyinfo->features;
  143. ctrl = phy_read (mii_info, PHY_BMCR);
  144. ctrl &= ~(PHY_BMCR_DPLX | PHY_BMCR_100_MBPS |
  145. PHY_BMCR_1000_MBPS | PHY_BMCR_AUTON);
  146. ctrl |= PHY_BMCR_RESET;
  147. switch (mii_info->speed) {
  148. case SPEED_1000:
  149. if (features & (SUPPORTED_1000baseT_Half
  150. | SUPPORTED_1000baseT_Full)) {
  151. ctrl |= PHY_BMCR_1000_MBPS;
  152. break;
  153. }
  154. mii_info->speed = SPEED_100;
  155. case SPEED_100:
  156. if (features & (SUPPORTED_100baseT_Half
  157. | SUPPORTED_100baseT_Full)) {
  158. ctrl |= PHY_BMCR_100_MBPS;
  159. break;
  160. }
  161. mii_info->speed = SPEED_10;
  162. case SPEED_10:
  163. if (features & (SUPPORTED_10baseT_Half
  164. | SUPPORTED_10baseT_Full))
  165. break;
  166. default: /* Unsupported speed! */
  167. ugphy_err ("%s: Bad speed!", mii_info->dev->name);
  168. break;
  169. }
  170. phy_write (mii_info, PHY_BMCR, ctrl);
  171. }
  172. /* Enable and Restart Autonegotiation */
  173. static void genmii_restart_aneg (struct uec_mii_info *mii_info)
  174. {
  175. u16 ctl;
  176. ctl = phy_read (mii_info, PHY_BMCR);
  177. ctl |= (PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
  178. phy_write (mii_info, PHY_BMCR, ctl);
  179. }
  180. static int gbit_config_aneg (struct uec_mii_info *mii_info)
  181. {
  182. u16 adv;
  183. u32 advertise;
  184. if (mii_info->autoneg) {
  185. /* Configure the ADVERTISE register */
  186. config_genmii_advert (mii_info);
  187. advertise = mii_info->advertising;
  188. adv = phy_read (mii_info, MII_1000BASETCONTROL);
  189. adv &= ~(MII_1000BASETCONTROL_FULLDUPLEXCAP |
  190. MII_1000BASETCONTROL_HALFDUPLEXCAP);
  191. if (advertise & SUPPORTED_1000baseT_Half)
  192. adv |= MII_1000BASETCONTROL_HALFDUPLEXCAP;
  193. if (advertise & SUPPORTED_1000baseT_Full)
  194. adv |= MII_1000BASETCONTROL_FULLDUPLEXCAP;
  195. phy_write (mii_info, MII_1000BASETCONTROL, adv);
  196. /* Start/Restart aneg */
  197. genmii_restart_aneg (mii_info);
  198. } else
  199. genmii_setup_forced (mii_info);
  200. return 0;
  201. }
  202. static int marvell_config_aneg (struct uec_mii_info *mii_info)
  203. {
  204. /* The Marvell PHY has an errata which requires
  205. * that certain registers get written in order
  206. * to restart autonegotiation */
  207. phy_write (mii_info, PHY_BMCR, PHY_BMCR_RESET);
  208. phy_write (mii_info, 0x1d, 0x1f);
  209. phy_write (mii_info, 0x1e, 0x200c);
  210. phy_write (mii_info, 0x1d, 0x5);
  211. phy_write (mii_info, 0x1e, 0);
  212. phy_write (mii_info, 0x1e, 0x100);
  213. gbit_config_aneg (mii_info);
  214. return 0;
  215. }
  216. static int genmii_config_aneg (struct uec_mii_info *mii_info)
  217. {
  218. if (mii_info->autoneg) {
  219. config_genmii_advert (mii_info);
  220. genmii_restart_aneg (mii_info);
  221. } else
  222. genmii_setup_forced (mii_info);
  223. return 0;
  224. }
  225. static int genmii_update_link (struct uec_mii_info *mii_info)
  226. {
  227. u16 status;
  228. /* Status is read once to clear old link state */
  229. phy_read (mii_info, PHY_BMSR);
  230. /*
  231. * Wait if the link is up, and autonegotiation is in progress
  232. * (ie - we're capable and it's not done)
  233. */
  234. status = phy_read(mii_info, PHY_BMSR);
  235. if ((status & PHY_BMSR_LS) && (status & PHY_BMSR_AUTN_ABLE)
  236. && !(status & PHY_BMSR_AUTN_COMP)) {
  237. int i = 0;
  238. while (!(status & PHY_BMSR_AUTN_COMP)) {
  239. /*
  240. * Timeout reached ?
  241. */
  242. if (i > UGETH_AN_TIMEOUT) {
  243. mii_info->link = 0;
  244. return 0;
  245. }
  246. i++;
  247. udelay(1000); /* 1 ms */
  248. status = phy_read(mii_info, PHY_BMSR);
  249. }
  250. mii_info->link = 1;
  251. udelay(500000); /* another 500 ms (results in faster booting) */
  252. } else {
  253. if (status & PHY_BMSR_LS)
  254. mii_info->link = 1;
  255. else
  256. mii_info->link = 0;
  257. }
  258. return 0;
  259. }
  260. static int genmii_read_status (struct uec_mii_info *mii_info)
  261. {
  262. u16 status;
  263. int err;
  264. /* Update the link, but return if there
  265. * was an error */
  266. err = genmii_update_link (mii_info);
  267. if (err)
  268. return err;
  269. if (mii_info->autoneg) {
  270. status = phy_read (mii_info, PHY_ANLPAR);
  271. if (status & (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD))
  272. mii_info->duplex = DUPLEX_FULL;
  273. else
  274. mii_info->duplex = DUPLEX_HALF;
  275. if (status & (PHY_ANLPAR_TXFD | PHY_ANLPAR_TX))
  276. mii_info->speed = SPEED_100;
  277. else
  278. mii_info->speed = SPEED_10;
  279. mii_info->pause = 0;
  280. }
  281. /* On non-aneg, we assume what we put in BMCR is the speed,
  282. * though magic-aneg shouldn't prevent this case from occurring
  283. */
  284. return 0;
  285. }
  286. static int marvell_read_status (struct uec_mii_info *mii_info)
  287. {
  288. u16 status;
  289. int err;
  290. /* Update the link, but return if there
  291. * was an error */
  292. err = genmii_update_link (mii_info);
  293. if (err)
  294. return err;
  295. /* If the link is up, read the speed and duplex */
  296. /* If we aren't autonegotiating, assume speeds
  297. * are as set */
  298. if (mii_info->autoneg && mii_info->link) {
  299. int speed;
  300. status = phy_read (mii_info, MII_M1011_PHY_SPEC_STATUS);
  301. /* Get the duplexity */
  302. if (status & MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX)
  303. mii_info->duplex = DUPLEX_FULL;
  304. else
  305. mii_info->duplex = DUPLEX_HALF;
  306. /* Get the speed */
  307. speed = status & MII_M1011_PHY_SPEC_STATUS_SPD_MASK;
  308. switch (speed) {
  309. case MII_M1011_PHY_SPEC_STATUS_1000:
  310. mii_info->speed = SPEED_1000;
  311. break;
  312. case MII_M1011_PHY_SPEC_STATUS_100:
  313. mii_info->speed = SPEED_100;
  314. break;
  315. default:
  316. mii_info->speed = SPEED_10;
  317. break;
  318. }
  319. mii_info->pause = 0;
  320. }
  321. return 0;
  322. }
  323. static int marvell_ack_interrupt (struct uec_mii_info *mii_info)
  324. {
  325. /* Clear the interrupts by reading the reg */
  326. phy_read (mii_info, MII_M1011_IEVENT);
  327. return 0;
  328. }
  329. static int marvell_config_intr (struct uec_mii_info *mii_info)
  330. {
  331. if (mii_info->interrupts == MII_INTERRUPT_ENABLED)
  332. phy_write (mii_info, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
  333. else
  334. phy_write (mii_info, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
  335. return 0;
  336. }
  337. static int dm9161_init (struct uec_mii_info *mii_info)
  338. {
  339. /* Reset the PHY */
  340. phy_write (mii_info, PHY_BMCR, phy_read (mii_info, PHY_BMCR) |
  341. PHY_BMCR_RESET);
  342. /* PHY and MAC connect */
  343. phy_write (mii_info, PHY_BMCR, phy_read (mii_info, PHY_BMCR) &
  344. ~PHY_BMCR_ISO);
  345. phy_write (mii_info, MII_DM9161_SCR, MII_DM9161_SCR_INIT);
  346. config_genmii_advert (mii_info);
  347. /* Start/restart aneg */
  348. genmii_config_aneg (mii_info);
  349. return 0;
  350. }
  351. static int dm9161_config_aneg (struct uec_mii_info *mii_info)
  352. {
  353. return 0;
  354. }
  355. static int dm9161_read_status (struct uec_mii_info *mii_info)
  356. {
  357. u16 status;
  358. int err;
  359. /* Update the link, but return if there was an error */
  360. err = genmii_update_link (mii_info);
  361. if (err)
  362. return err;
  363. /* If the link is up, read the speed and duplex
  364. If we aren't autonegotiating assume speeds are as set */
  365. if (mii_info->autoneg && mii_info->link) {
  366. status = phy_read (mii_info, MII_DM9161_SCSR);
  367. if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_100H))
  368. mii_info->speed = SPEED_100;
  369. else
  370. mii_info->speed = SPEED_10;
  371. if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_10F))
  372. mii_info->duplex = DUPLEX_FULL;
  373. else
  374. mii_info->duplex = DUPLEX_HALF;
  375. }
  376. return 0;
  377. }
  378. static int dm9161_ack_interrupt (struct uec_mii_info *mii_info)
  379. {
  380. /* Clear the interrupt by reading the reg */
  381. phy_read (mii_info, MII_DM9161_INTR);
  382. return 0;
  383. }
  384. static int dm9161_config_intr (struct uec_mii_info *mii_info)
  385. {
  386. if (mii_info->interrupts == MII_INTERRUPT_ENABLED)
  387. phy_write (mii_info, MII_DM9161_INTR, MII_DM9161_INTR_INIT);
  388. else
  389. phy_write (mii_info, MII_DM9161_INTR, MII_DM9161_INTR_STOP);
  390. return 0;
  391. }
  392. static void dm9161_close (struct uec_mii_info *mii_info)
  393. {
  394. }
  395. static struct phy_info phy_info_dm9161 = {
  396. .phy_id = 0x0181b880,
  397. .phy_id_mask = 0x0ffffff0,
  398. .name = "Davicom DM9161E",
  399. .init = dm9161_init,
  400. .config_aneg = dm9161_config_aneg,
  401. .read_status = dm9161_read_status,
  402. .close = dm9161_close,
  403. };
  404. static struct phy_info phy_info_dm9161a = {
  405. .phy_id = 0x0181b8a0,
  406. .phy_id_mask = 0x0ffffff0,
  407. .name = "Davicom DM9161A",
  408. .features = MII_BASIC_FEATURES,
  409. .init = dm9161_init,
  410. .config_aneg = dm9161_config_aneg,
  411. .read_status = dm9161_read_status,
  412. .ack_interrupt = dm9161_ack_interrupt,
  413. .config_intr = dm9161_config_intr,
  414. .close = dm9161_close,
  415. };
  416. static struct phy_info phy_info_marvell = {
  417. .phy_id = 0x01410c00,
  418. .phy_id_mask = 0xffffff00,
  419. .name = "Marvell 88E11x1",
  420. .features = MII_GBIT_FEATURES,
  421. .config_aneg = &marvell_config_aneg,
  422. .read_status = &marvell_read_status,
  423. .ack_interrupt = &marvell_ack_interrupt,
  424. .config_intr = &marvell_config_intr,
  425. };
  426. static struct phy_info phy_info_genmii = {
  427. .phy_id = 0x00000000,
  428. .phy_id_mask = 0x00000000,
  429. .name = "Generic MII",
  430. .features = MII_BASIC_FEATURES,
  431. .config_aneg = genmii_config_aneg,
  432. .read_status = genmii_read_status,
  433. };
  434. static struct phy_info *phy_info[] = {
  435. &phy_info_dm9161,
  436. &phy_info_dm9161a,
  437. &phy_info_marvell,
  438. &phy_info_genmii,
  439. NULL
  440. };
  441. u16 phy_read (struct uec_mii_info *mii_info, u16 regnum)
  442. {
  443. return mii_info->mdio_read (mii_info->dev, mii_info->mii_id, regnum);
  444. }
  445. void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val)
  446. {
  447. mii_info->mdio_write (mii_info->dev, mii_info->mii_id, regnum, val);
  448. }
  449. /* Use the PHY ID registers to determine what type of PHY is attached
  450. * to device dev. return a struct phy_info structure describing that PHY
  451. */
  452. struct phy_info *uec_get_phy_info (struct uec_mii_info *mii_info)
  453. {
  454. u16 phy_reg;
  455. u32 phy_ID;
  456. int i;
  457. struct phy_info *theInfo = NULL;
  458. /* Grab the bits from PHYIR1, and put them in the upper half */
  459. phy_reg = phy_read (mii_info, PHY_PHYIDR1);
  460. phy_ID = (phy_reg & 0xffff) << 16;
  461. /* Grab the bits from PHYIR2, and put them in the lower half */
  462. phy_reg = phy_read (mii_info, PHY_PHYIDR2);
  463. phy_ID |= (phy_reg & 0xffff);
  464. /* loop through all the known PHY types, and find one that */
  465. /* matches the ID we read from the PHY. */
  466. for (i = 0; phy_info[i]; i++)
  467. if (phy_info[i]->phy_id ==
  468. (phy_ID & phy_info[i]->phy_id_mask)) {
  469. theInfo = phy_info[i];
  470. break;
  471. }
  472. /* This shouldn't happen, as we have generic PHY support */
  473. if (theInfo == NULL) {
  474. ugphy_info ("UEC: PHY id %x is not supported!", phy_ID);
  475. return NULL;
  476. } else {
  477. ugphy_info ("UEC: PHY is %s (%x)", theInfo->name, phy_ID);
  478. }
  479. return theInfo;
  480. }
  481. void marvell_phy_interface_mode (struct eth_device *dev,
  482. enet_interface_e mode)
  483. {
  484. uec_private_t *uec = (uec_private_t *) dev->priv;
  485. struct uec_mii_info *mii_info;
  486. u16 status;
  487. if (!uec->mii_info) {
  488. printf ("%s: the PHY not initialized\n", __FUNCTION__);
  489. return;
  490. }
  491. mii_info = uec->mii_info;
  492. if (mode == ENET_100_RGMII) {
  493. phy_write (mii_info, 0x00, 0x9140);
  494. phy_write (mii_info, 0x1d, 0x001f);
  495. phy_write (mii_info, 0x1e, 0x200c);
  496. phy_write (mii_info, 0x1d, 0x0005);
  497. phy_write (mii_info, 0x1e, 0x0000);
  498. phy_write (mii_info, 0x1e, 0x0100);
  499. phy_write (mii_info, 0x09, 0x0e00);
  500. phy_write (mii_info, 0x04, 0x01e1);
  501. phy_write (mii_info, 0x00, 0x9140);
  502. phy_write (mii_info, 0x00, 0x1000);
  503. udelay (100000);
  504. phy_write (mii_info, 0x00, 0x2900);
  505. phy_write (mii_info, 0x14, 0x0cd2);
  506. phy_write (mii_info, 0x00, 0xa100);
  507. phy_write (mii_info, 0x09, 0x0000);
  508. phy_write (mii_info, 0x1b, 0x800b);
  509. phy_write (mii_info, 0x04, 0x05e1);
  510. phy_write (mii_info, 0x00, 0xa100);
  511. phy_write (mii_info, 0x00, 0x2100);
  512. udelay (1000000);
  513. } else if (mode == ENET_10_RGMII) {
  514. phy_write (mii_info, 0x14, 0x8e40);
  515. phy_write (mii_info, 0x1b, 0x800b);
  516. phy_write (mii_info, 0x14, 0x0c82);
  517. phy_write (mii_info, 0x00, 0x8100);
  518. udelay (1000000);
  519. }
  520. /* handle 88e1111 rev.B2 erratum 5.6 */
  521. if (mii_info->autoneg) {
  522. status = phy_read (mii_info, PHY_BMCR);
  523. phy_write (mii_info, PHY_BMCR, status | PHY_BMCR_AUTON);
  524. }
  525. /* now the B2 will correctly report autoneg completion status */
  526. }
  527. void change_phy_interface_mode (struct eth_device *dev, enet_interface_e mode)
  528. {
  529. #ifdef CONFIG_PHY_MODE_NEED_CHANGE
  530. marvell_phy_interface_mode (dev, mode);
  531. #endif
  532. }
  533. #endif /* CONFIG_QE */