106106/* * \brief PHY ID definitions */
107107#define DP83848C_ID 0x20005C90 /* *< PHY Identifier - DP83848C */
108108#define LAN8720_ID 0x0007C0F0 /* *< PHY Identifier - LAN8720 */
109+ #define KSZ8041_ID 0x00221510 /* *< PHY Identifier - KSZ8041 */
109110
110111
111112/* * \brief PHY status structure used to indicate current status of PHY.
@@ -350,9 +351,11 @@ bool lpc_phy_init(LPC17_EMAC *lpc17_emac, int rmii)
350351 lpc_mii_write (DP8_BMCR_REG, tmp);
351352
352353 /* Enable RMII mode for PHY */
353- if (rmii)
354- lpc_mii_write (DP8_PHY_RBR_REG, DP8_RBR_RMII_MODE);
355-
354+ if (rmii) {
355+ /* Mode is set with config pins on KSZ8041 */
356+ if (phy_id != KSZ8041_ID)
357+ lpc_mii_write (DP8_PHY_RBR_REG, DP8_RBR_RMII_MODE);
358+ }
356359 /* The link is not set active at this point, but will be detected
357360 later */
358361
@@ -377,14 +380,14 @@ int32_t lpc_phy_sts_sm(LPC17_EMAC *lpc17_emac)
377380 lpc_mii_read_noblock (DP8_PHY_STAT_REG);
378381 phyustate = 2 ;
379382 }
380- else if (phy_id == LAN8720_ID) {
383+ else if (phy_id == LAN8720_ID || phy_id == KSZ8041_ID ) {
381384 lpc_mii_read_noblock (DP8_PHY_SCSR_REG);
382385 phyustate = 1 ;
383386 }
384387 break ;
385388
386389 case 1 :
387- if (phy_id == LAN8720_ID) {
390+ if (phy_id == LAN8720_ID || phy_id == KSZ8041_ID ) {
388391 tmp = lpc_mii_read_data ();
389392 // we get speed and duplex here.
390393 phy_lan7420_sts_tmp = (tmp & PHY_SCSR_DUPLEX) ? LNK_STAT_FULLDUPLEX : 0 ;
@@ -408,7 +411,7 @@ int32_t lpc_phy_sts_sm(LPC17_EMAC *lpc17_emac)
408411 data |= (tmp & DP8_FULLDUPLEX) ? LNK_STAT_FULLDUPLEX : 0 ;
409412 data |= (tmp & DP8_SPEED10MBPS) ? LNK_STAT_SPEED10MPS : 0 ;
410413 }
411- else if (phy_id == LAN8720_ID) {
414+ else if (phy_id == LAN8720_ID || phy_id == KSZ8041_ID) {
412415 // we only get the link status here.
413416 phy_lan7420_sts_tmp |= (tmp & DP8_LINK_STATUS) ? LNK_STAT_VALID : 0 ;
414417 data = phy_lan7420_sts_tmp;
0 commit comments