|
4 | 4 | * Copyright (C) 2022 Renesas Electronics Corporation
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +#include <linux/clk.h> |
7 | 8 | #include <linux/dma-mapping.h>
|
8 | 9 | #include <linux/err.h>
|
9 | 10 | #include <linux/etherdevice.h>
|
@@ -1049,7 +1050,7 @@ static void rswitch_rmac_setting(struct rswitch_etha *etha, const u8 *mac)
|
1049 | 1050 | static void rswitch_etha_enable_mii(struct rswitch_etha *etha)
|
1050 | 1051 | {
|
1051 | 1052 | rswitch_modify(etha->addr, MPIC, MPIC_PSMCS_MASK | MPIC_PSMHT_MASK,
|
1052 |
| - MPIC_PSMCS(0x05) | MPIC_PSMHT(0x06)); |
| 1053 | + MPIC_PSMCS(etha->psmcs) | MPIC_PSMHT(0x06)); |
1053 | 1054 | rswitch_modify(etha->addr, MPSM, 0, MPSM_MFF_C45);
|
1054 | 1055 | }
|
1055 | 1056 |
|
@@ -1693,6 +1694,12 @@ static void rswitch_etha_init(struct rswitch_private *priv, int index)
|
1693 | 1694 | etha->index = index;
|
1694 | 1695 | etha->addr = priv->addr + RSWITCH_ETHA_OFFSET + index * RSWITCH_ETHA_SIZE;
|
1695 | 1696 | etha->coma_addr = priv->addr;
|
| 1697 | + |
| 1698 | + /* MPIC.PSMCS = (clk [MHz] / (MDC frequency [MHz] * 2) - 1. |
| 1699 | + * Calculating PSMCS value as MDC frequency = 2.5MHz. So, multiply |
| 1700 | + * both the numerator and the denominator by 10. |
| 1701 | + */ |
| 1702 | + etha->psmcs = clk_get_rate(priv->clk) / 100000 / (25 * 2) - 1; |
1696 | 1703 | }
|
1697 | 1704 |
|
1698 | 1705 | static int rswitch_device_alloc(struct rswitch_private *priv, int index)
|
@@ -1900,6 +1907,10 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
|
1900 | 1907 | return -ENOMEM;
|
1901 | 1908 | spin_lock_init(&priv->lock);
|
1902 | 1909 |
|
| 1910 | + priv->clk = devm_clk_get(&pdev->dev, NULL); |
| 1911 | + if (IS_ERR(priv->clk)) |
| 1912 | + return PTR_ERR(priv->clk); |
| 1913 | + |
1903 | 1914 | attr = soc_device_match(rswitch_soc_no_speed_change);
|
1904 | 1915 | if (attr)
|
1905 | 1916 | priv->etha_no_runtime_change = true;
|
|
0 commit comments