Lines Matching refs:dev

52 static void ax88180_rx_handler (struct eth_device *dev);
53 static int ax88180_phy_initial (struct eth_device *dev);
54 static void ax88180_media_config (struct eth_device *dev);
55 static unsigned long get_CicadaPHY_media_mode (struct eth_device *dev);
56 static unsigned long get_MarvellPHY_media_mode (struct eth_device *dev);
57 static unsigned short ax88180_mdio_read (struct eth_device *dev,
59 static void ax88180_mdio_write (struct eth_device *dev,
67 static int ax88180_mdio_check_complete (struct eth_device *dev) in ax88180_mdio_check_complete() argument
74 tmpval = INW (dev, MDIOCTRL); in ax88180_mdio_check_complete()
83 ax88180_mdio_read (struct eth_device *dev, unsigned long regaddr) in ax88180_mdio_read() argument
85 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_mdio_read()
88 OUTW (dev, (READ_PHY | (regaddr << 8) | priv->PhyAddr), MDIOCTRL); in ax88180_mdio_read()
90 if (ax88180_mdio_check_complete (dev)) in ax88180_mdio_read()
91 tmpval = INW (dev, MDIODP); in ax88180_mdio_read()
99 ax88180_mdio_write (struct eth_device *dev, unsigned long regaddr, in ax88180_mdio_write() argument
102 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_mdio_write()
104 OUTW (dev, regdata, MDIODP); in ax88180_mdio_write()
106 OUTW (dev, (WRITE_PHY | (regaddr << 8) | priv->PhyAddr), MDIOCTRL); in ax88180_mdio_write()
108 if (!ax88180_mdio_check_complete (dev)) in ax88180_mdio_write()
112 static int ax88180_phy_reset (struct eth_device *dev) in ax88180_phy_reset() argument
116 ax88180_mdio_write (dev, MII_BMCR, (BMCR_RESET | BMCR_ANENABLE)); in ax88180_phy_reset()
119 while (ax88180_mdio_read (dev, MII_BMCR) & BMCR_RESET) { in ax88180_phy_reset()
130 static void ax88180_mac_reset (struct eth_device *dev) in ax88180_mac_reset() argument
157 OUTW (dev, MISC_RESET_MAC, MISC); in ax88180_mac_reset()
158 tmpval = INW (dev, MISC); in ax88180_mac_reset()
161 OUTW (dev, program_seq[i].value, program_seq[i].offset); in ax88180_mac_reset()
164 static int ax88180_poll_tx_complete (struct eth_device *dev) in ax88180_poll_tx_complete() argument
166 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_poll_tx_complete()
174 tmpval = INW (dev, TXBS); in ax88180_poll_tx_complete()
188 static void ax88180_rx_handler (struct eth_device *dev) in ax88180_rx_handler() argument
190 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_rx_handler()
201 rxcurt_ptr = INW (dev, RXCURT); in ax88180_rx_handler()
202 rxbound_ptr = INW (dev, RXBOUND); in ax88180_rx_handler()
210 OUTW (dev, RX_START_READ, RXINDICATOR); in ax88180_rx_handler()
212 data_size = READ_RXBUF (dev) & 0xFFFF; in ax88180_rx_handler()
216 OUTW (dev, RX_STOP_READ, RXINDICATOR); in ax88180_rx_handler()
218 ax88180_mac_reset (dev); in ax88180_rx_handler()
234 *(rxdata + i) = READ_RXBUF (dev); in ax88180_rx_handler()
237 OUTW (dev, RX_STOP_READ, RXINDICATOR); in ax88180_rx_handler()
242 OUTW (dev, rxbound_ptr, RXBOUND); in ax88180_rx_handler()
244 rxcurt_ptr = INW (dev, RXCURT); in ax88180_rx_handler()
245 rxbound_ptr = INW (dev, RXBOUND); in ax88180_rx_handler()
255 static int ax88180_phy_initial (struct eth_device *dev) in ax88180_phy_initial() argument
257 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_phy_initial()
269 priv->PhyID0 = ax88180_mdio_read(dev, MII_PHYSID1); in ax88180_phy_initial()
270 priv->PhyID1 = ax88180_mdio_read(dev, MII_PHYSID2); in ax88180_phy_initial()
279 ax88180_mdio_write(dev, M88E1118_PAGE_SEL, 2); in ax88180_phy_initial()
280 ax88180_mdio_write(dev, M88E1118_CR, in ax88180_phy_initial()
282 ax88180_mdio_write(dev, M88E1118_PAGE_SEL, 3); in ax88180_phy_initial()
283 ax88180_mdio_write(dev, M88E1118_LEDCTL, in ax88180_phy_initial()
285 ax88180_mdio_write(dev, M88E1118_LEDMIX, in ax88180_phy_initial()
287 ax88180_mdio_write(dev, M88E1118_PAGE_SEL, 0); in ax88180_phy_initial()
289 tmp_regval = ax88180_mdio_read(dev, M88E1111_EXT_SSR); in ax88180_phy_initial()
291 ax88180_mdio_write(dev, M88E1111_EXT_SCR, in ax88180_phy_initial()
295 if (ax88180_phy_reset(dev) < 0) in ax88180_phy_initial()
297 ax88180_mdio_write(dev, M88_IER, LINK_CHANGE_INT); in ax88180_phy_initial()
305 ax88180_mdio_write(dev, CIS_IMR, in ax88180_phy_initial()
309 tmp_regval = ax88180_mdio_read(dev, CIS_AUX_CTRL_STATUS); in ax88180_phy_initial()
311 ax88180_mdio_write(dev, CIS_AUX_CTRL_STATUS, tmp_regval); in ax88180_phy_initial()
330 static void ax88180_media_config (struct eth_device *dev) in ax88180_media_config() argument
332 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_media_config()
340 bmsr_val = ax88180_mdio_read (dev, MII_BMSR); in ax88180_media_config()
347 bmsr_val = ax88180_mdio_read (dev, MII_BMSR); in ax88180_media_config()
351 bmcr_val = ax88180_mdio_read (dev, MII_BMCR); in ax88180_media_config()
362 bmsr_val = ax88180_mdio_read (dev, MII_BMSR); in ax88180_media_config()
377 RealMediaMode = get_MarvellPHY_media_mode(dev); in ax88180_media_config()
380 RealMediaMode = get_CicadaPHY_media_mode(dev); in ax88180_media_config()
451 OUTW (dev, rxcfg_val, RXCFG); in ax88180_media_config()
452 OUTW (dev, maccfg0_val, MACCFG0); in ax88180_media_config()
453 OUTW (dev, maccfg1_val, MACCFG1); in ax88180_media_config()
458 static unsigned long get_MarvellPHY_media_mode (struct eth_device *dev) in get_MarvellPHY_media_mode() argument
463 m88_ssr = ax88180_mdio_read (dev, M88_SSR); in get_MarvellPHY_media_mode()
491 static unsigned long get_CicadaPHY_media_mode (struct eth_device *dev) in get_CicadaPHY_media_mode() argument
496 tmp_regval = ax88180_mdio_read (dev, CIS_AUX_CTRL_STATUS); in get_CicadaPHY_media_mode()
524 static void ax88180_halt (struct eth_device *dev) in ax88180_halt() argument
527 OUTW (dev, WAKEMOD, CMD); in ax88180_halt()
530 static int ax88180_init (struct eth_device *dev, bd_t * bd) in ax88180_init() argument
532 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_init()
535 ax88180_mac_reset (dev); in ax88180_init()
538 OUTW (dev, CLEAR_IMR, IMR); in ax88180_init()
541 OUTW (dev, WAKEMOD, CMD); in ax88180_init()
545 dev->enetaddr[0] | (((unsigned short)dev->enetaddr[1]) << 8); in ax88180_init()
546 OUTW (dev, tmp_regval, MACID0); in ax88180_init()
549 dev->enetaddr[2] | (((unsigned short)dev->enetaddr[3]) << 8); in ax88180_init()
550 OUTW (dev, tmp_regval, MACID1); in ax88180_init()
553 dev->enetaddr[4] | (((unsigned short)dev->enetaddr[5]) << 8); in ax88180_init()
554 OUTW (dev, tmp_regval, MACID2); in ax88180_init()
556 ax88180_media_config (dev); in ax88180_init()
558 OUTW (dev, DEFAULT_RXFILTER, RXFILTER); in ax88180_init()
565 OUTW (dev, INW (dev, ISR), ISR); in ax88180_init()
568 OUTW (dev, (RXEN | TXEN | WAKEMOD), CMD); in ax88180_init()
574 static int ax88180_recv (struct eth_device *dev) in ax88180_recv() argument
580 ISR_Status = INW (dev, ISR); in ax88180_recv()
584 OUTW (dev, ISR_Status, ISR); in ax88180_recv()
591 tmp_regval = ax88180_mdio_read (dev, M88_ISR); in ax88180_recv()
592 ax88180_media_config (dev); in ax88180_recv()
596 ax88180_rx_handler (dev); in ax88180_recv()
600 ISR_Status = INW (dev, ISR); in ax88180_recv()
607 static int ax88180_send(struct eth_device *dev, void *packet, int length) in ax88180_send() argument
609 struct ax88180_private *priv = (struct ax88180_private *)dev->priv; in ax88180_send()
633 OUTW (dev, (txcmd_txdp | length | TX_START_WRITE), TXCMD); in ax88180_send()
639 WRITE_TXBUF (dev, *(txdata + i)); in ax88180_send()
642 OUTW (dev, txcmd_txdp | length, TXCMD); in ax88180_send()
643 OUTW (dev, txbs_txdp, TXBS); in ax88180_send()
644 OUTW (dev, (TXDPx_ENABLE | length), TXDES_addr); in ax88180_send()
654 tmp_data = INW (dev, TXBS); in ax88180_send()
657 if (ax88180_poll_tx_complete (dev) < 0) { in ax88180_send()
658 ax88180_mac_reset (dev); in ax88180_send()
668 static void ax88180_read_mac_addr (struct eth_device *dev) in ax88180_read_mac_addr() argument
675 OUTW (dev, RELOAD_EEPROM, PROMCTRL); in ax88180_read_mac_addr()
679 tmp_regval = INW (dev, PROMCTRL); in ax88180_read_mac_addr()
686 macid0_val = INW (dev, MACID0); in ax88180_read_mac_addr()
687 macid1_val = INW (dev, MACID1); in ax88180_read_mac_addr()
688 macid2_val = INW (dev, MACID2); in ax88180_read_mac_addr()
692 dev->enetaddr[0] = (unsigned char)macid0_val; in ax88180_read_mac_addr()
693 dev->enetaddr[1] = (unsigned char)(macid0_val >> 8); in ax88180_read_mac_addr()
694 dev->enetaddr[2] = (unsigned char)macid1_val; in ax88180_read_mac_addr()
695 dev->enetaddr[3] = (unsigned char)(macid1_val >> 8); in ax88180_read_mac_addr()
696 dev->enetaddr[4] = (unsigned char)macid2_val; in ax88180_read_mac_addr()
697 dev->enetaddr[5] = (unsigned char)(macid2_val >> 8); in ax88180_read_mac_addr()
704 struct eth_device *dev; in ax88180_initialize() local
707 dev = (struct eth_device *)malloc (sizeof *dev); in ax88180_initialize()
709 if (NULL == dev) in ax88180_initialize()
712 memset (dev, 0, sizeof *dev); in ax88180_initialize()
721 strcpy(dev->name, "ax88180"); in ax88180_initialize()
722 dev->iobase = AX88180_BASE; in ax88180_initialize()
723 dev->priv = priv; in ax88180_initialize()
724 dev->init = ax88180_init; in ax88180_initialize()
725 dev->halt = ax88180_halt; in ax88180_initialize()
726 dev->send = ax88180_send; in ax88180_initialize()
727 dev->recv = ax88180_recv; in ax88180_initialize()
732 OUTW (dev, (START_BASE >> 8), BASE); in ax88180_initialize()
733 OUTW (dev, DECODE_EN, DECODE); in ax88180_initialize()
739 ax88180_mac_reset (dev); in ax88180_initialize()
742 OUTW (dev, CLEAR_IMR, IMR); in ax88180_initialize()
745 OUTW (dev, WAKEMOD, CMD); in ax88180_initialize()
747 ax88180_read_mac_addr (dev); in ax88180_initialize()
749 eth_register (dev); in ax88180_initialize()
751 return ax88180_phy_initial (dev); in ax88180_initialize()