Lines Matching +full:need +full:- +full:phy +full:- +full:for +full:- +full:wake
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
4 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
30 /* Make MII read/write commands for the FEC. */
77 * mii_init -- Initialize the MII for MII command without ethernet
82 volatile FEC_T *fecp = (FEC_T *) (info->miibase); in mii_reset()
85 fecp->ecr = FEC_ECR_RESET; in mii_reset()
87 for (i = 0; (fecp->ecr & FEC_ECR_RESET) && (i < FEC_RESET_DELAY); ++i) { in mii_reset()
94 /* send command to phy using mii, wait for result */
105 info = dev->priv; in mii_send()
107 ep = (FEC_T *) info->miibase; in mii_send()
109 ep->mmfr = mii_cmd; /* command to phy */ in mii_send()
111 /* wait for mii complete */ in mii_send()
112 while (!(ep->eir & FEC_EIR_MII) && (j < MCFFEC_TOUT_LOOP)) { in mii_send()
118 return -1; in mii_send()
121 mii_reply = ep->mmfr; /* result from phy */ in mii_send()
122 ep->eir = FEC_EIR_MII; /* clear MII complete */ in mii_send()
128 return (mii_reply & 0xffff); /* data read from phy */ in mii_send()
136 FEC_INFO_T *info = dev->priv; in mii_discover_phy()
141 if (info->phyname_init) in mii_discover_phy()
142 return info->phy_addr; in mii_discover_phy()
144 phyaddr = -1; /* didn't find a PHY yet */ in mii_discover_phy()
145 for (pass = 1; pass <= MAX_PHY_PASSES && phyaddr < 0; ++pass) { in mii_discover_phy()
147 /* PHY may need more time to recover from reset. in mii_discover_phy()
150 * With 11 passes this gives it 100ms to wake up. in mii_discover_phy()
155 for (phyno = 0; phyno < 32 && phyaddr < 0; ++phyno) { in mii_discover_phy()
159 printf("PHY type 0x%x pass %d type\n", phytype, pass); in mii_discover_phy()
169 printf("PHY @ 0x%x pass %d\n", phyno, pass); in mii_discover_phy()
172 for (i = 0; (i < ARRAY_SIZE(phyinfo)) in mii_discover_phy()
176 printf("phyid %x - %s\n", in mii_discover_phy()
180 strcpy(info->phy_name, phyinfo[i].strid); in mii_discover_phy()
181 info->phyname_init = 1; in mii_discover_phy()
191 strcpy(info->phy_name, "unknown"); in mii_discover_phy()
192 info->phyname_init = 1; in mii_discover_phy()
199 printf("No PHY device found.\n"); in mii_discover_phy()
218 info = dev->priv; in __mii_init()
220 fecp = (FEC_T *) info->miibase; in __mii_init()
227 fecp->eimr = 0; in __mii_init()
230 fecp->eir = 0xffffffff; in __mii_init()
233 miispd = (gd->bus_clk / 1000000) / 5; in __mii_init()
234 fecp->mscr = miispd << 1; in __mii_init()
236 info->phy_addr = mii_discover_phy(dev); in __mii_init()
241 /* Read PHY control register */ in __mii_init()
242 miiphy_read(dev->name, info->phy_addr, MII_BMCR, &status); in __mii_init()
244 /* If phy set to autonegotiate, wait for autonegotiation done, in __mii_init()
245 * if phy is not autonegotiating, just wait for link up. in __mii_init()
252 /* Read PHY status register */ in __mii_init()
253 miiphy_read(dev->name, info->phy_addr, MII_BMSR, &status); in __mii_init()
263 /* adapt to the duplex and speed settings of the phy */ in __mii_init()
264 info->dup_spd = miiphy_duplex(dev->name, info->phy_addr) << 16; in __mii_init()
265 info->dup_spd |= miiphy_speed(dev->name, info->phy_addr); in __mii_init()
269 * Read and write a MII PHY register, routines used by MII Utilities
273 * no PHY connected...
274 * For now always return 0.