sh_eth.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. * sh_eth.c - Driver for Renesas ethernet controler.
  3. *
  4. * Copyright (C) 2008, 2011 Renesas Solutions Corp.
  5. * Copyright (c) 2008, 2011 Nobuhiro Iwamatsu
  6. * Copyright (c) 2007 Carlos Munoz <carlos@kenati.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <config.h>
  23. #include <common.h>
  24. #include <malloc.h>
  25. #include <net.h>
  26. #include <netdev.h>
  27. #include <miiphy.h>
  28. #include <asm/errno.h>
  29. #include <asm/io.h>
  30. #include "sh_eth.h"
  31. #ifndef CONFIG_SH_ETHER_USE_PORT
  32. # error "Please define CONFIG_SH_ETHER_USE_PORT"
  33. #endif
  34. #ifndef CONFIG_SH_ETHER_PHY_ADDR
  35. # error "Please define CONFIG_SH_ETHER_PHY_ADDR"
  36. #endif
  37. #ifdef CONFIG_SH_ETHER_CACHE_WRITEBACK
  38. #define flush_cache_wback(addr, len) \
  39. dcache_wback_range((u32)addr, (u32)(addr + len - 1))
  40. #else
  41. #define flush_cache_wback(...)
  42. #endif
  43. #define TIMEOUT_CNT 1000
  44. int sh_eth_send(struct eth_device *dev, void *packet, int len)
  45. {
  46. struct sh_eth_dev *eth = dev->priv;
  47. int port = eth->port, ret = 0, timeout;
  48. struct sh_eth_info *port_info = &eth->port_info[port];
  49. if (!packet || len > 0xffff) {
  50. printf(SHETHER_NAME ": %s: Invalid argument\n", __func__);
  51. ret = -EINVAL;
  52. goto err;
  53. }
  54. /* packet must be a 4 byte boundary */
  55. if ((int)packet & 3) {
  56. printf(SHETHER_NAME ": %s: packet not 4 byte alligned\n", __func__);
  57. ret = -EFAULT;
  58. goto err;
  59. }
  60. /* Update tx descriptor */
  61. flush_cache_wback(packet, len);
  62. port_info->tx_desc_cur->td2 = ADDR_TO_PHY(packet);
  63. port_info->tx_desc_cur->td1 = len << 16;
  64. /* Must preserve the end of descriptor list indication */
  65. if (port_info->tx_desc_cur->td0 & TD_TDLE)
  66. port_info->tx_desc_cur->td0 = TD_TACT | TD_TFP | TD_TDLE;
  67. else
  68. port_info->tx_desc_cur->td0 = TD_TACT | TD_TFP;
  69. /* Restart the transmitter if disabled */
  70. if (!(inl(EDTRR(port)) & EDTRR_TRNS))
  71. outl(EDTRR_TRNS, EDTRR(port));
  72. /* Wait until packet is transmitted */
  73. timeout = TIMEOUT_CNT;
  74. while (port_info->tx_desc_cur->td0 & TD_TACT && timeout--)
  75. udelay(100);
  76. if (timeout < 0) {
  77. printf(SHETHER_NAME ": transmit timeout\n");
  78. ret = -ETIMEDOUT;
  79. goto err;
  80. }
  81. port_info->tx_desc_cur++;
  82. if (port_info->tx_desc_cur >= port_info->tx_desc_base + NUM_TX_DESC)
  83. port_info->tx_desc_cur = port_info->tx_desc_base;
  84. err:
  85. return ret;
  86. }
  87. int sh_eth_recv(struct eth_device *dev)
  88. {
  89. struct sh_eth_dev *eth = dev->priv;
  90. int port = eth->port, len = 0;
  91. struct sh_eth_info *port_info = &eth->port_info[port];
  92. uchar *packet;
  93. /* Check if the rx descriptor is ready */
  94. if (!(port_info->rx_desc_cur->rd0 & RD_RACT)) {
  95. /* Check for errors */
  96. if (!(port_info->rx_desc_cur->rd0 & RD_RFE)) {
  97. len = port_info->rx_desc_cur->rd1 & 0xffff;
  98. packet = (uchar *)
  99. ADDR_TO_P2(port_info->rx_desc_cur->rd2);
  100. NetReceive(packet, len);
  101. }
  102. /* Make current descriptor available again */
  103. if (port_info->rx_desc_cur->rd0 & RD_RDLE)
  104. port_info->rx_desc_cur->rd0 = RD_RACT | RD_RDLE;
  105. else
  106. port_info->rx_desc_cur->rd0 = RD_RACT;
  107. /* Point to the next descriptor */
  108. port_info->rx_desc_cur++;
  109. if (port_info->rx_desc_cur >=
  110. port_info->rx_desc_base + NUM_RX_DESC)
  111. port_info->rx_desc_cur = port_info->rx_desc_base;
  112. }
  113. /* Restart the receiver if disabled */
  114. if (!(inl(EDRRR(port)) & EDRRR_R))
  115. outl(EDRRR_R, EDRRR(port));
  116. return len;
  117. }
  118. static int sh_eth_reset(struct sh_eth_dev *eth)
  119. {
  120. int port = eth->port;
  121. #if defined(SH_ETH_TYPE_GETHER)
  122. int ret = 0, i;
  123. /* Start e-dmac transmitter and receiver */
  124. outl(EDSR_ENALL, EDSR(port));
  125. /* Perform a software reset and wait for it to complete */
  126. outl(EDMR_SRST, EDMR(port));
  127. for (i = 0; i < TIMEOUT_CNT ; i++) {
  128. if (!(inl(EDMR(port)) & EDMR_SRST))
  129. break;
  130. udelay(1000);
  131. }
  132. if (i == TIMEOUT_CNT) {
  133. printf(SHETHER_NAME ": Software reset timeout\n");
  134. ret = -EIO;
  135. }
  136. return ret;
  137. #else
  138. outl(inl(EDMR(port)) | EDMR_SRST, EDMR(port));
  139. udelay(3000);
  140. outl(inl(EDMR(port)) & ~EDMR_SRST, EDMR(port));
  141. return 0;
  142. #endif
  143. }
  144. static int sh_eth_tx_desc_init(struct sh_eth_dev *eth)
  145. {
  146. int port = eth->port, i, ret = 0;
  147. u32 tmp_addr;
  148. struct sh_eth_info *port_info = &eth->port_info[port];
  149. struct tx_desc_s *cur_tx_desc;
  150. /*
  151. * Allocate tx descriptors. They must be TX_DESC_SIZE bytes aligned
  152. */
  153. port_info->tx_desc_malloc = malloc(NUM_TX_DESC *
  154. sizeof(struct tx_desc_s) +
  155. TX_DESC_SIZE - 1);
  156. if (!port_info->tx_desc_malloc) {
  157. printf(SHETHER_NAME ": malloc failed\n");
  158. ret = -ENOMEM;
  159. goto err;
  160. }
  161. tmp_addr = (u32) (((int)port_info->tx_desc_malloc + TX_DESC_SIZE - 1) &
  162. ~(TX_DESC_SIZE - 1));
  163. flush_cache_wback(tmp_addr, NUM_TX_DESC * sizeof(struct tx_desc_s));
  164. /* Make sure we use a P2 address (non-cacheable) */
  165. port_info->tx_desc_base = (struct tx_desc_s *)ADDR_TO_P2(tmp_addr);
  166. port_info->tx_desc_cur = port_info->tx_desc_base;
  167. /* Initialize all descriptors */
  168. for (cur_tx_desc = port_info->tx_desc_base, i = 0; i < NUM_TX_DESC;
  169. cur_tx_desc++, i++) {
  170. cur_tx_desc->td0 = 0x00;
  171. cur_tx_desc->td1 = 0x00;
  172. cur_tx_desc->td2 = 0x00;
  173. }
  174. /* Mark the end of the descriptors */
  175. cur_tx_desc--;
  176. cur_tx_desc->td0 |= TD_TDLE;
  177. /* Point the controller to the tx descriptor list. Must use physical
  178. addresses */
  179. outl(ADDR_TO_PHY(port_info->tx_desc_base), TDLAR(port));
  180. #if defined(SH_ETH_TYPE_GETHER)
  181. outl(ADDR_TO_PHY(port_info->tx_desc_base), TDFAR(port));
  182. outl(ADDR_TO_PHY(cur_tx_desc), TDFXR(port));
  183. outl(0x01, TDFFR(port));/* Last discriptor bit */
  184. #endif
  185. err:
  186. return ret;
  187. }
  188. static int sh_eth_rx_desc_init(struct sh_eth_dev *eth)
  189. {
  190. int port = eth->port, i , ret = 0;
  191. struct sh_eth_info *port_info = &eth->port_info[port];
  192. struct rx_desc_s *cur_rx_desc;
  193. u32 tmp_addr;
  194. u8 *rx_buf;
  195. /*
  196. * Allocate rx descriptors. They must be RX_DESC_SIZE bytes aligned
  197. */
  198. port_info->rx_desc_malloc = malloc(NUM_RX_DESC *
  199. sizeof(struct rx_desc_s) +
  200. RX_DESC_SIZE - 1);
  201. if (!port_info->rx_desc_malloc) {
  202. printf(SHETHER_NAME ": malloc failed\n");
  203. ret = -ENOMEM;
  204. goto err;
  205. }
  206. tmp_addr = (u32) (((int)port_info->rx_desc_malloc + RX_DESC_SIZE - 1) &
  207. ~(RX_DESC_SIZE - 1));
  208. flush_cache_wback(tmp_addr, NUM_RX_DESC * sizeof(struct rx_desc_s));
  209. /* Make sure we use a P2 address (non-cacheable) */
  210. port_info->rx_desc_base = (struct rx_desc_s *)ADDR_TO_P2(tmp_addr);
  211. port_info->rx_desc_cur = port_info->rx_desc_base;
  212. /*
  213. * Allocate rx data buffers. They must be 32 bytes aligned and in
  214. * P2 area
  215. */
  216. port_info->rx_buf_malloc = malloc(NUM_RX_DESC * MAX_BUF_SIZE + 31);
  217. if (!port_info->rx_buf_malloc) {
  218. printf(SHETHER_NAME ": malloc failed\n");
  219. ret = -ENOMEM;
  220. goto err_buf_malloc;
  221. }
  222. tmp_addr = (u32)(((int)port_info->rx_buf_malloc + (32 - 1)) &
  223. ~(32 - 1));
  224. port_info->rx_buf_base = (u8 *)ADDR_TO_P2(tmp_addr);
  225. /* Initialize all descriptors */
  226. for (cur_rx_desc = port_info->rx_desc_base,
  227. rx_buf = port_info->rx_buf_base, i = 0;
  228. i < NUM_RX_DESC; cur_rx_desc++, rx_buf += MAX_BUF_SIZE, i++) {
  229. cur_rx_desc->rd0 = RD_RACT;
  230. cur_rx_desc->rd1 = MAX_BUF_SIZE << 16;
  231. cur_rx_desc->rd2 = (u32) ADDR_TO_PHY(rx_buf);
  232. }
  233. /* Mark the end of the descriptors */
  234. cur_rx_desc--;
  235. cur_rx_desc->rd0 |= RD_RDLE;
  236. /* Point the controller to the rx descriptor list */
  237. outl(ADDR_TO_PHY(port_info->rx_desc_base), RDLAR(port));
  238. #if defined(SH_ETH_TYPE_GETHER)
  239. outl(ADDR_TO_PHY(port_info->rx_desc_base), RDFAR(port));
  240. outl(ADDR_TO_PHY(cur_rx_desc), RDFXR(port));
  241. outl(RDFFR_RDLF, RDFFR(port));
  242. #endif
  243. return ret;
  244. err_buf_malloc:
  245. free(port_info->rx_desc_malloc);
  246. port_info->rx_desc_malloc = NULL;
  247. err:
  248. return ret;
  249. }
  250. static void sh_eth_tx_desc_free(struct sh_eth_dev *eth)
  251. {
  252. int port = eth->port;
  253. struct sh_eth_info *port_info = &eth->port_info[port];
  254. if (port_info->tx_desc_malloc) {
  255. free(port_info->tx_desc_malloc);
  256. port_info->tx_desc_malloc = NULL;
  257. }
  258. }
  259. static void sh_eth_rx_desc_free(struct sh_eth_dev *eth)
  260. {
  261. int port = eth->port;
  262. struct sh_eth_info *port_info = &eth->port_info[port];
  263. if (port_info->rx_desc_malloc) {
  264. free(port_info->rx_desc_malloc);
  265. port_info->rx_desc_malloc = NULL;
  266. }
  267. if (port_info->rx_buf_malloc) {
  268. free(port_info->rx_buf_malloc);
  269. port_info->rx_buf_malloc = NULL;
  270. }
  271. }
  272. static int sh_eth_desc_init(struct sh_eth_dev *eth)
  273. {
  274. int ret = 0;
  275. ret = sh_eth_tx_desc_init(eth);
  276. if (ret)
  277. goto err_tx_init;
  278. ret = sh_eth_rx_desc_init(eth);
  279. if (ret)
  280. goto err_rx_init;
  281. return ret;
  282. err_rx_init:
  283. sh_eth_tx_desc_free(eth);
  284. err_tx_init:
  285. return ret;
  286. }
  287. static int sh_eth_phy_config(struct sh_eth_dev *eth)
  288. {
  289. int port = eth->port, ret = 0;
  290. struct sh_eth_info *port_info = &eth->port_info[port];
  291. struct eth_device *dev = port_info->dev;
  292. struct phy_device *phydev;
  293. phydev = phy_connect(
  294. miiphy_get_dev_by_name(dev->name),
  295. port_info->phy_addr, dev, CONFIG_SH_ETHER_PHY_MODE);
  296. port_info->phydev = phydev;
  297. phy_config(phydev);
  298. return ret;
  299. }
  300. static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
  301. {
  302. int port = eth->port, ret = 0;
  303. u32 val;
  304. struct sh_eth_info *port_info = &eth->port_info[port];
  305. struct eth_device *dev = port_info->dev;
  306. struct phy_device *phy;
  307. /* Configure e-dmac registers */
  308. outl((inl(EDMR(port)) & ~EMDR_DESC_R) | EDMR_EL, EDMR(port));
  309. outl(0, EESIPR(port));
  310. outl(0, TRSCER(port));
  311. outl(0, TFTR(port));
  312. outl((FIFO_SIZE_T | FIFO_SIZE_R), FDR(port));
  313. outl(RMCR_RST, RMCR(port));
  314. #if defined(SH_ETH_TYPE_GETHER)
  315. outl(0, RPADIR(port));
  316. #endif
  317. outl((FIFO_F_D_RFF | FIFO_F_D_RFD), FCFTR(port));
  318. /* Configure e-mac registers */
  319. outl(0, ECSIPR(port));
  320. /* Set Mac address */
  321. val = dev->enetaddr[0] << 24 | dev->enetaddr[1] << 16 |
  322. dev->enetaddr[2] << 8 | dev->enetaddr[3];
  323. outl(val, MAHR(port));
  324. val = dev->enetaddr[4] << 8 | dev->enetaddr[5];
  325. outl(val, MALR(port));
  326. outl(RFLR_RFL_MIN, RFLR(port));
  327. #if defined(SH_ETH_TYPE_GETHER)
  328. outl(0, PIPR(port));
  329. outl(APR_AP, APR(port));
  330. outl(MPR_MP, MPR(port));
  331. outl(TPAUSER_TPAUSE, TPAUSER(port));
  332. #endif
  333. #if defined(CONFIG_CPU_SH7734)
  334. outl(CONFIG_SH_ETHER_SH7734_MII, RMII_MII(port));
  335. #endif
  336. /* Configure phy */
  337. ret = sh_eth_phy_config(eth);
  338. if (ret) {
  339. printf(SHETHER_NAME ": phy config timeout\n");
  340. goto err_phy_cfg;
  341. }
  342. phy = port_info->phydev;
  343. ret = phy_startup(phy);
  344. if (ret) {
  345. printf(SHETHER_NAME ": phy startup failure\n");
  346. return ret;
  347. }
  348. val = 0;
  349. /* Set the transfer speed */
  350. if (phy->speed == 100) {
  351. printf(SHETHER_NAME ": 100Base/");
  352. #if defined(SH_ETH_TYPE_GETHER)
  353. outl(GECMR_100B, GECMR(port));
  354. #elif defined(CONFIG_CPU_SH7757)
  355. outl(1, RTRATE(port));
  356. #elif defined(CONFIG_CPU_SH7724)
  357. val = ECMR_RTM;
  358. #endif
  359. } else if (phy->speed == 10) {
  360. printf(SHETHER_NAME ": 10Base/");
  361. #if defined(SH_ETH_TYPE_GETHER)
  362. outl(GECMR_10B, GECMR(port));
  363. #elif defined(CONFIG_CPU_SH7757)
  364. outl(0, RTRATE(port));
  365. #endif
  366. }
  367. #if defined(SH_ETH_TYPE_GETHER)
  368. else if (phy->speed == 1000) {
  369. printf(SHETHER_NAME ": 1000Base/");
  370. outl(GECMR_1000B, GECMR(port));
  371. }
  372. #endif
  373. /* Check if full duplex mode is supported by the phy */
  374. if (phy->duplex) {
  375. printf("Full\n");
  376. outl(val | (ECMR_CHG_DM|ECMR_RE|ECMR_TE|ECMR_DM), ECMR(port));
  377. } else {
  378. printf("Half\n");
  379. outl(val | (ECMR_CHG_DM|ECMR_RE|ECMR_TE), ECMR(port));
  380. }
  381. return ret;
  382. err_phy_cfg:
  383. return ret;
  384. }
  385. static void sh_eth_start(struct sh_eth_dev *eth)
  386. {
  387. /*
  388. * Enable the e-dmac receiver only. The transmitter will be enabled when
  389. * we have something to transmit
  390. */
  391. outl(EDRRR_R, EDRRR(eth->port));
  392. }
  393. static void sh_eth_stop(struct sh_eth_dev *eth)
  394. {
  395. outl(~EDRRR_R, EDRRR(eth->port));
  396. }
  397. int sh_eth_init(struct eth_device *dev, bd_t *bd)
  398. {
  399. int ret = 0;
  400. struct sh_eth_dev *eth = dev->priv;
  401. ret = sh_eth_reset(eth);
  402. if (ret)
  403. goto err;
  404. ret = sh_eth_desc_init(eth);
  405. if (ret)
  406. goto err;
  407. ret = sh_eth_config(eth, bd);
  408. if (ret)
  409. goto err_config;
  410. sh_eth_start(eth);
  411. return ret;
  412. err_config:
  413. sh_eth_tx_desc_free(eth);
  414. sh_eth_rx_desc_free(eth);
  415. err:
  416. return ret;
  417. }
  418. void sh_eth_halt(struct eth_device *dev)
  419. {
  420. struct sh_eth_dev *eth = dev->priv;
  421. sh_eth_stop(eth);
  422. }
  423. int sh_eth_initialize(bd_t *bd)
  424. {
  425. int ret = 0;
  426. struct sh_eth_dev *eth = NULL;
  427. struct eth_device *dev = NULL;
  428. eth = (struct sh_eth_dev *)malloc(sizeof(struct sh_eth_dev));
  429. if (!eth) {
  430. printf(SHETHER_NAME ": %s: malloc failed\n", __func__);
  431. ret = -ENOMEM;
  432. goto err;
  433. }
  434. dev = (struct eth_device *)malloc(sizeof(struct eth_device));
  435. if (!dev) {
  436. printf(SHETHER_NAME ": %s: malloc failed\n", __func__);
  437. ret = -ENOMEM;
  438. goto err;
  439. }
  440. memset(dev, 0, sizeof(struct eth_device));
  441. memset(eth, 0, sizeof(struct sh_eth_dev));
  442. eth->port = CONFIG_SH_ETHER_USE_PORT;
  443. eth->port_info[eth->port].phy_addr = CONFIG_SH_ETHER_PHY_ADDR;
  444. dev->priv = (void *)eth;
  445. dev->iobase = 0;
  446. dev->init = sh_eth_init;
  447. dev->halt = sh_eth_halt;
  448. dev->send = sh_eth_send;
  449. dev->recv = sh_eth_recv;
  450. eth->port_info[eth->port].dev = dev;
  451. sprintf(dev->name, SHETHER_NAME);
  452. /* Register Device to EtherNet subsystem */
  453. eth_register(dev);
  454. bb_miiphy_buses[0].priv = eth;
  455. miiphy_register(dev->name, bb_miiphy_read, bb_miiphy_write);
  456. if (!eth_getenv_enetaddr("ethaddr", dev->enetaddr))
  457. puts("Please set MAC address\n");
  458. return ret;
  459. err:
  460. if (dev)
  461. free(dev);
  462. if (eth)
  463. free(eth);
  464. printf(SHETHER_NAME ": Failed\n");
  465. return ret;
  466. }
  467. /******* for bb_miiphy *******/
  468. static int sh_eth_bb_init(struct bb_miiphy_bus *bus)
  469. {
  470. return 0;
  471. }
  472. static int sh_eth_bb_mdio_active(struct bb_miiphy_bus *bus)
  473. {
  474. struct sh_eth_dev *eth = bus->priv;
  475. int port = eth->port;
  476. outl(inl(PIR(port)) | PIR_MMD, PIR(port));
  477. return 0;
  478. }
  479. static int sh_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus)
  480. {
  481. struct sh_eth_dev *eth = bus->priv;
  482. int port = eth->port;
  483. outl(inl(PIR(port)) & ~PIR_MMD, PIR(port));
  484. return 0;
  485. }
  486. static int sh_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v)
  487. {
  488. struct sh_eth_dev *eth = bus->priv;
  489. int port = eth->port;
  490. if (v)
  491. outl(inl(PIR(port)) | PIR_MDO, PIR(port));
  492. else
  493. outl(inl(PIR(port)) & ~PIR_MDO, PIR(port));
  494. return 0;
  495. }
  496. static int sh_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v)
  497. {
  498. struct sh_eth_dev *eth = bus->priv;
  499. int port = eth->port;
  500. *v = (inl(PIR(port)) & PIR_MDI) >> 3;
  501. return 0;
  502. }
  503. static int sh_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v)
  504. {
  505. struct sh_eth_dev *eth = bus->priv;
  506. int port = eth->port;
  507. if (v)
  508. outl(inl(PIR(port)) | PIR_MDC, PIR(port));
  509. else
  510. outl(inl(PIR(port)) & ~PIR_MDC, PIR(port));
  511. return 0;
  512. }
  513. static int sh_eth_bb_delay(struct bb_miiphy_bus *bus)
  514. {
  515. udelay(10);
  516. return 0;
  517. }
  518. struct bb_miiphy_bus bb_miiphy_buses[] = {
  519. {
  520. .name = "sh_eth",
  521. .init = sh_eth_bb_init,
  522. .mdio_active = sh_eth_bb_mdio_active,
  523. .mdio_tristate = sh_eth_bb_mdio_tristate,
  524. .set_mdio = sh_eth_bb_set_mdio,
  525. .get_mdio = sh_eth_bb_get_mdio,
  526. .set_mdc = sh_eth_bb_set_mdc,
  527. .delay = sh_eth_bb_delay,
  528. }
  529. };
  530. int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses);