Skip to content

Commit 112cd17

Browse files
jacob-wienecke-nxpdanieldegrasse
authored andcommitted
drivers: mdio_nxp_enet_qos: fix CR overwrite
Current Implementation to write to MAC_MDIO_ADDRESS causes CR to be set to 0. This leads to the divide always being 42 (on FRDM_MCXN947) so, by default the clock is running at ~3.6MHz which is out of spec range (1.0-2.5MHz) This stops the do_transaction function from overwriting CR. It also saves off the CR register before DMA reset Signed-off-by: Jacob Wienecke <[email protected]>
1 parent 0dd63fc commit 112cd17

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

drivers/ethernet/eth_nxp_enet_qos/eth_nxp_enet_qos_mac.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ static void eth_nxp_enet_qos_phy_cb(const struct device *phy,
393393

394394
static inline int enet_qos_dma_reset(enet_qos_t *base)
395395
{
396+
/* Save off ENET->MAC_MDIO_ADDRESS: CR Field Prior to Reset */
397+
int cr = 0;
398+
399+
cr = ENET_QOS_REG_GET(MAC_MDIO_ADDRESS, CR, base->MAC_MDIO_ADDRESS);
396400
/* Set the software reset of the DMA */
397401
base->DMA_MODE |= ENET_QOS_REG_PREP(DMA_MODE, SWR, 0b1);
398402

@@ -426,6 +430,7 @@ static inline int enet_qos_dma_reset(enet_qos_t *base)
426430
return -EIO;
427431

428432
done:
433+
base->MAC_MDIO_ADDRESS = ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, CR, cr);
429434
return 0;
430435
}
431436

drivers/mdio/mdio_nxp_enet_qos.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ static int do_transaction(struct mdio_transaction *mdio)
6363
ret = -EINVAL;
6464
goto done;
6565
}
66+
base->MAC_MDIO_ADDRESS &= ~(
67+
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, GOC_1, 0b1) |
68+
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, GOC_0, 0b1) |
69+
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, PA, 0b11111) |
70+
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, RDA, 0b11111));
6671

67-
base->MAC_MDIO_ADDRESS =
72+
base->MAC_MDIO_ADDRESS |=
6873
/* OP command */
6974
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, GOC_1, goc_1_code) |
7075
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, GOC_0, 0b1) |
@@ -73,7 +78,7 @@ static int do_transaction(struct mdio_transaction *mdio)
7378
/* Register address */
7479
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, RDA, mdio->regaddr);
7580

76-
base->MAC_MDIO_ADDRESS =
81+
base->MAC_MDIO_ADDRESS |=
7782
/* Start the transaction */
7883
ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, GB, 0b1);
7984

0 commit comments

Comments
 (0)