Lines Matching refs:dev
54 static void ax88180_rx_handler (struct eth_device *dev);
55 static int ax88180_phy_initial (struct eth_device *dev);
56 static void ax88180_media_config (struct eth_device *dev);
57 static unsigned long get_CicadaPHY_media_mode (struct eth_device *dev);
58 static unsigned long get_MarvellPHY_media_mode (struct eth_device *dev);
59 static unsigned short ax88180_mdio_read (struct eth_device *dev,
61 static void ax88180_mdio_write (struct eth_device *dev,
69 static int ax88180_mdio_check_complete (struct eth_device *dev) in ax88180_mdio_check_complete() argument
76 tmpval = INW (dev, MDIOCTRL); in ax88180_mdio_check_complete()
85 ax88180_mdio_read (struct eth_device *dev, unsigned long regaddr) in ax88180_mdio_read() argument
87 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_mdio_read()
90 OUTW (dev, (READ_PHY | (regaddr << 8) | priv->PhyAddr), MDIOCTRL); in ax88180_mdio_read()
92 if (ax88180_mdio_check_complete (dev)) in ax88180_mdio_read()
93 tmpval = INW (dev, MDIODP); in ax88180_mdio_read()
101 ax88180_mdio_write (struct eth_device *dev, unsigned long regaddr, in ax88180_mdio_write() argument
104 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_mdio_write()
106 OUTW (dev, regdata, MDIODP); in ax88180_mdio_write()
108 OUTW (dev, (WRITE_PHY | (regaddr << 8) | priv->PhyAddr), MDIOCTRL); in ax88180_mdio_write()
110 if (!ax88180_mdio_check_complete (dev)) in ax88180_mdio_write()
114 static int ax88180_phy_reset (struct eth_device *dev) in ax88180_phy_reset() argument
118 ax88180_mdio_write (dev, MII_BMCR, (BMCR_RESET | BMCR_ANENABLE)); in ax88180_phy_reset()
121 while (ax88180_mdio_read (dev, MII_BMCR) & BMCR_RESET) { in ax88180_phy_reset()
132 static void ax88180_mac_reset (struct eth_device *dev) in ax88180_mac_reset() argument
159 OUTW (dev, MISC_RESET_MAC, MISC); in ax88180_mac_reset()
160 tmpval = INW (dev, MISC); in ax88180_mac_reset()
163 OUTW (dev, program_seq[i].value, program_seq[i].offset); in ax88180_mac_reset()
166 static int ax88180_poll_tx_complete (struct eth_device *dev) in ax88180_poll_tx_complete() argument
168 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_poll_tx_complete()
176 tmpval = INW (dev, TXBS); in ax88180_poll_tx_complete()
190 static void ax88180_rx_handler (struct eth_device *dev) in ax88180_rx_handler() argument
192 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_rx_handler()
203 rxcurt_ptr = INW (dev, RXCURT); in ax88180_rx_handler()
204 rxbound_ptr = INW (dev, RXBOUND); in ax88180_rx_handler()
212 OUTW (dev, RX_START_READ, RXINDICATOR); in ax88180_rx_handler()
214 data_size = READ_RXBUF (dev) & 0xFFFF; in ax88180_rx_handler()
218 OUTW (dev, RX_STOP_READ, RXINDICATOR); in ax88180_rx_handler()
220 ax88180_mac_reset (dev); in ax88180_rx_handler()
236 *(rxdata + i) = READ_RXBUF (dev); in ax88180_rx_handler()
239 OUTW (dev, RX_STOP_READ, RXINDICATOR); in ax88180_rx_handler()
244 OUTW (dev, rxbound_ptr, RXBOUND); in ax88180_rx_handler()
246 rxcurt_ptr = INW (dev, RXCURT); in ax88180_rx_handler()
247 rxbound_ptr = INW (dev, RXBOUND); in ax88180_rx_handler()
257 static int ax88180_phy_initial (struct eth_device *dev) in ax88180_phy_initial() argument
259 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_phy_initial()
271 priv->PhyID0 = ax88180_mdio_read(dev, MII_PHYSID1); in ax88180_phy_initial()
272 priv->PhyID1 = ax88180_mdio_read(dev, MII_PHYSID2); in ax88180_phy_initial()
281 ax88180_mdio_write(dev, M88E1118_PAGE_SEL, 2); in ax88180_phy_initial()
282 ax88180_mdio_write(dev, M88E1118_CR, in ax88180_phy_initial()
284 ax88180_mdio_write(dev, M88E1118_PAGE_SEL, 3); in ax88180_phy_initial()
285 ax88180_mdio_write(dev, M88E1118_LEDCTL, in ax88180_phy_initial()
287 ax88180_mdio_write(dev, M88E1118_LEDMIX, in ax88180_phy_initial()
289 ax88180_mdio_write(dev, M88E1118_PAGE_SEL, 0); in ax88180_phy_initial()
291 tmp_regval = ax88180_mdio_read(dev, M88E1111_EXT_SSR); in ax88180_phy_initial()
293 ax88180_mdio_write(dev, M88E1111_EXT_SCR, in ax88180_phy_initial()
297 if (ax88180_phy_reset(dev) < 0) in ax88180_phy_initial()
299 ax88180_mdio_write(dev, M88_IER, LINK_CHANGE_INT); in ax88180_phy_initial()
307 ax88180_mdio_write(dev, CIS_IMR, in ax88180_phy_initial()
311 tmp_regval = ax88180_mdio_read(dev, CIS_AUX_CTRL_STATUS); in ax88180_phy_initial()
313 ax88180_mdio_write(dev, CIS_AUX_CTRL_STATUS, tmp_regval); in ax88180_phy_initial()
332 static void ax88180_media_config (struct eth_device *dev) in ax88180_media_config() argument
334 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_media_config()
342 bmsr_val = ax88180_mdio_read (dev, MII_BMSR); in ax88180_media_config()
349 bmsr_val = ax88180_mdio_read (dev, MII_BMSR); in ax88180_media_config()
353 bmcr_val = ax88180_mdio_read (dev, MII_BMCR); in ax88180_media_config()
364 bmsr_val = ax88180_mdio_read (dev, MII_BMSR); in ax88180_media_config()
379 RealMediaMode = get_MarvellPHY_media_mode(dev); in ax88180_media_config()
382 RealMediaMode = get_CicadaPHY_media_mode(dev); in ax88180_media_config()
453 OUTW (dev, rxcfg_val, RXCFG); in ax88180_media_config()
454 OUTW (dev, maccfg0_val, MACCFG0); in ax88180_media_config()
455 OUTW (dev, maccfg1_val, MACCFG1); in ax88180_media_config()
460 static unsigned long get_MarvellPHY_media_mode (struct eth_device *dev) in get_MarvellPHY_media_mode() argument
465 m88_ssr = ax88180_mdio_read (dev, M88_SSR); in get_MarvellPHY_media_mode()
493 static unsigned long get_CicadaPHY_media_mode (struct eth_device *dev) in get_CicadaPHY_media_mode() argument
498 tmp_regval = ax88180_mdio_read (dev, CIS_AUX_CTRL_STATUS); in get_CicadaPHY_media_mode()
526 static void ax88180_halt (struct eth_device *dev) in ax88180_halt() argument
529 OUTW (dev, WAKEMOD, CMD); in ax88180_halt()
532 static int ax88180_init (struct eth_device *dev, struct bd_info * bd) in ax88180_init() argument
534 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_init()
537 ax88180_mac_reset (dev); in ax88180_init()
540 OUTW (dev, CLEAR_IMR, IMR); in ax88180_init()
543 OUTW (dev, WAKEMOD, CMD); in ax88180_init()
547 dev->enetaddr[0] | (((unsigned short)dev->enetaddr[1]) << 8); in ax88180_init()
548 OUTW (dev, tmp_regval, MACID0); in ax88180_init()
551 dev->enetaddr[2] | (((unsigned short)dev->enetaddr[3]) << 8); in ax88180_init()
552 OUTW (dev, tmp_regval, MACID1); in ax88180_init()
555 dev->enetaddr[4] | (((unsigned short)dev->enetaddr[5]) << 8); in ax88180_init()
556 OUTW (dev, tmp_regval, MACID2); in ax88180_init()
558 ax88180_media_config (dev); in ax88180_init()
560 OUTW (dev, DEFAULT_RXFILTER, RXFILTER); in ax88180_init()
567 OUTW (dev, INW (dev, ISR), ISR); in ax88180_init()
570 OUTW (dev, (RXEN | TXEN | WAKEMOD), CMD); in ax88180_init()
576 static int ax88180_recv (struct eth_device *dev) in ax88180_recv() argument
582 ISR_Status = INW (dev, ISR); in ax88180_recv()
586 OUTW (dev, ISR_Status, ISR); in ax88180_recv()
593 tmp_regval = ax88180_mdio_read (dev, M88_ISR); in ax88180_recv()
594 ax88180_media_config (dev); in ax88180_recv()
598 ax88180_rx_handler (dev); in ax88180_recv()
602 ISR_Status = INW (dev, ISR); in ax88180_recv()
609 static int ax88180_send(struct eth_device *dev, void *packet, int length) in ax88180_send() argument
611 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_send()
635 OUTW (dev, (txcmd_txdp | length | TX_START_WRITE), TXCMD); in ax88180_send()
641 WRITE_TXBUF (dev, *(txdata + i)); in ax88180_send()
644 OUTW (dev, txcmd_txdp | length, TXCMD); in ax88180_send()
645 OUTW (dev, txbs_txdp, TXBS); in ax88180_send()
646 OUTW (dev, (TXDPx_ENABLE | length), TXDES_addr); in ax88180_send()
656 tmp_data = INW (dev, TXBS); in ax88180_send()
659 if (ax88180_poll_tx_complete (dev) < 0) { in ax88180_send()
660 ax88180_mac_reset (dev); in ax88180_send()
670 static void ax88180_read_mac_addr (struct eth_device *dev) in ax88180_read_mac_addr() argument
677 OUTW (dev, RELOAD_EEPROM, PROMCTRL); in ax88180_read_mac_addr()
681 tmp_regval = INW (dev, PROMCTRL); in ax88180_read_mac_addr()
688 macid0_val = INW (dev, MACID0); in ax88180_read_mac_addr()
689 macid1_val = INW (dev, MACID1); in ax88180_read_mac_addr()
690 macid2_val = INW (dev, MACID2); in ax88180_read_mac_addr()
694 dev->enetaddr[0] = (unsigned char)macid0_val; in ax88180_read_mac_addr()
695 dev->enetaddr[1] = (unsigned char)(macid0_val >> 8); in ax88180_read_mac_addr()
696 dev->enetaddr[2] = (unsigned char)macid1_val; in ax88180_read_mac_addr()
697 dev->enetaddr[3] = (unsigned char)(macid1_val >> 8); in ax88180_read_mac_addr()
698 dev->enetaddr[4] = (unsigned char)macid2_val; in ax88180_read_mac_addr()
699 dev->enetaddr[5] = (unsigned char)(macid2_val >> 8); in ax88180_read_mac_addr()
706 struct eth_device *dev; in ax88180_initialize() local
709 dev = (struct eth_device *)malloc (sizeof *dev); in ax88180_initialize()
711 if (NULL == dev) in ax88180_initialize()
714 memset (dev, 0, sizeof *dev); in ax88180_initialize()
723 strcpy(dev->name, "ax88180"); in ax88180_initialize()
724 dev->iobase = AX88180_BASE; in ax88180_initialize()
725 dev->priv = priv; in ax88180_initialize()
726 dev->init = ax88180_init; in ax88180_initialize()
727 dev->halt = ax88180_halt; in ax88180_initialize()
728 dev->send = ax88180_send; in ax88180_initialize()
729 dev->recv = ax88180_recv; in ax88180_initialize()
734 OUTW (dev, (START_BASE >> 8), BASE); in ax88180_initialize()
735 OUTW (dev, DECODE_EN, DECODE); in ax88180_initialize()
741 ax88180_mac_reset (dev); in ax88180_initialize()
744 OUTW (dev, CLEAR_IMR, IMR); in ax88180_initialize()
747 OUTW (dev, WAKEMOD, CMD); in ax88180_initialize()
749 ax88180_read_mac_addr (dev); in ax88180_initialize()
751 eth_register (dev); in ax88180_initialize()
753 return ax88180_phy_initial (dev); in ax88180_initialize()