Skip to content

Commit 3a0f26f

Browse files
robhancocksedkartben
authored andcommitted
drivers: ethernet: vsc8541: add RGMII clock delay configuration
As the code noted, the RGMII RX and TX clock delay values may need to change depending on the MAC configuration or the PCB layout. Add properties to allow configuring these in the device tree, defaulting to the previous hard-coded values if not present. Signed-off-by: Robert Hancock <[email protected]>
1 parent 8ad4447 commit 3a0f26f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

drivers/ethernet/phy/phy_microchip_vsc8541.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct mc_vsc8541_config {
8585
uint8_t addr;
8686
const struct device *mdio_dev;
8787
enum vsc8541_interface microchip_interface_type;
88+
uint8_t rgmii_rx_clk_delay;
89+
uint8_t rgmii_tx_clk_delay;
8890
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios)
8991
const struct gpio_dt_spec reset_gpio;
9092
#endif
@@ -150,9 +152,9 @@ static int phy_mc_vsc8541_verify_phy_id(const struct device *dev)
150152
*/
151153
static int phy_mc_vsc8541_reset(const struct device *dev)
152154
{
155+
const struct mc_vsc8541_config *cfg = dev->config;
153156

154157
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios)
155-
const struct mc_vsc8541_config *cfg = dev->config;
156158

157159
if (!cfg->reset_gpio.port) {
158160
LOG_WRN("missing reset port definition");
@@ -227,12 +229,11 @@ static int phy_mc_vsc8541_reset(const struct device *dev)
227229
}
228230

229231
/* configure the RGMII clk delay */
230-
/* this is highly hardware dependent and may vary between pcb designs */
231232
reg = 0x0;
232233
/* RX_CLK delay */
233-
reg |= (0x5 << 4);
234+
reg |= (cfg->rgmii_rx_clk_delay << 4);
234235
/* TX_CLK delay */
235-
reg |= (0x5 << 0);
236+
reg |= (cfg->rgmii_tx_clk_delay << 0);
236237
ret = phy_mc_vsc8541_write(dev, PHY_REG_PAGE2_RGMII_CONTROL, reg);
237238
if (ret) {
238239
return ret;
@@ -440,7 +441,6 @@ void phy_mc_vsc8541_link_monitor(void *arg1, void *arg2, void *arg3)
440441
{
441442
const struct device *dev = arg1;
442443
struct mc_vsc8541_data *data = dev->data;
443-
const struct mc_vsc8541_config *cfg = dev->config;
444444

445445
struct phy_link_state new_state;
446446

@@ -565,6 +565,8 @@ static DEVICE_API(ethphy, mc_vsc8541_phy_api) = {
565565
.addr = DT_INST_REG_ADDR(n), \
566566
.mdio_dev = DEVICE_DT_GET(DT_INST_PARENT(n)), \
567567
.microchip_interface_type = DT_INST_ENUM_IDX(n, microchip_interface_type), \
568+
.rgmii_rx_clk_delay = DT_INST_PROP(n, microchip_rgmii_rx_clk_delay), \
569+
.rgmii_tx_clk_delay = DT_INST_PROP(n, microchip_rgmii_tx_clk_delay), \
568570
RESET_GPIO(n) INTERRUPT_GPIO(n)}; \
569571
\
570572
static struct mc_vsc8541_data mc_vsc8541_##n##_data; \

dts/bindings/ethernet/phy/microchip,vsc8541-phy.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,17 @@ properties:
2828
- "rmii"
2929
- "gmii"
3030
- "rgmii"
31+
32+
microchip,rgmii-rx-clk-delay:
33+
type: int
34+
default: 5
35+
description: |
36+
Used to configure the RX clock delay for RGMII interface. The value can be
37+
0 to 7. Refer to the datasheet for more details on the delay settings.
38+
39+
microchip,rgmii-tx-clk-delay:
40+
type: int
41+
default: 5
42+
description: |
43+
Used to configure the TX clock delay for RGMII interface. The value can be
44+
0 to 7. Refer to the datasheet for more details on the delay settings.

0 commit comments

Comments
 (0)