Commit 277eaf57e5fc5b5030e9428cf3163670dea2ebfc
Committed by
Ye Li
1 parent
23650e03d6
Exists in
smarc_8mq_lf_v2020.04
and in
4 other branches
MLK-23165-16 net: eqos: implement callbaks to get interface and set txclk rate
Implement the callbacks to get phy mode interface and txclk rate configuration. Reviewed-by: Ye Li <ye.li@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com> (cherry picked from commit ad2f34236694493b94c2cf6801eef4b7212eb89b)
Showing 1 changed file with 40 additions and 2 deletions Side-by-side Diff
drivers/net/dwc_eth_qos.c
... | ... | @@ -39,6 +39,7 @@ |
39 | 39 | #include <phy.h> |
40 | 40 | #include <reset.h> |
41 | 41 | #include <wait_bit.h> |
42 | +#include <asm/arch/clock.h> | |
42 | 43 | #include <asm/gpio.h> |
43 | 44 | #include <asm/io.h> |
44 | 45 | #include <eth_phy.h> |
... | ... | @@ -833,7 +834,7 @@ |
833 | 834 | static ulong eqos_get_tick_clk_rate_imx(struct udevice *dev) |
834 | 835 | { |
835 | 836 | /* TODO: retrieve from CSR clock */ |
836 | - return 100 * 1000000; | |
837 | + return imx_get_eqos_csr_clk(); | |
837 | 838 | } |
838 | 839 | |
839 | 840 | static int eqos_calibrate_pads_stm32(struct udevice *dev) |
... | ... | @@ -959,6 +960,33 @@ |
959 | 960 | |
960 | 961 | static int eqos_set_tx_clk_speed_imx(struct udevice *dev) |
961 | 962 | { |
963 | + struct eqos_priv *eqos = dev_get_priv(dev); | |
964 | + ulong rate; | |
965 | + int ret; | |
966 | + | |
967 | + debug("%s(dev=%p):\n", __func__, dev); | |
968 | + | |
969 | + switch (eqos->phy->speed) { | |
970 | + case SPEED_1000: | |
971 | + rate = 125 * 1000 * 1000; | |
972 | + break; | |
973 | + case SPEED_100: | |
974 | + rate = 25 * 1000 * 1000; | |
975 | + break; | |
976 | + case SPEED_10: | |
977 | + rate = 2.5 * 1000 * 1000; | |
978 | + break; | |
979 | + default: | |
980 | + pr_err("invalid speed %d", eqos->phy->speed); | |
981 | + return -EINVAL; | |
982 | + } | |
983 | + | |
984 | + ret = imx_eqos_txclk_set_rate(rate); | |
985 | + if (ret < 0) { | |
986 | + pr_err("imx (tx_clk, %lu) failed: %d", rate, ret); | |
987 | + return ret; | |
988 | + } | |
989 | + | |
962 | 990 | return 0; |
963 | 991 | } |
964 | 992 | |
... | ... | @@ -1798,7 +1826,17 @@ |
1798 | 1826 | |
1799 | 1827 | static phy_interface_t eqos_get_interface_imx(struct udevice *dev) |
1800 | 1828 | { |
1801 | - return PHY_INTERFACE_MODE_RGMII; | |
1829 | + const char *phy_mode; | |
1830 | + phy_interface_t interface = PHY_INTERFACE_MODE_NONE; | |
1831 | + | |
1832 | + debug("%s(dev=%p):\n", __func__, dev); | |
1833 | + | |
1834 | + phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", | |
1835 | + NULL); | |
1836 | + if (phy_mode) | |
1837 | + interface = phy_get_interface_by_name(phy_mode); | |
1838 | + | |
1839 | + return interface; | |
1802 | 1840 | } |
1803 | 1841 | |
1804 | 1842 | static int eqos_remove_resources_tegra186(struct udevice *dev) |