@@ -585,6 +585,22 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
}
clk_prepare_enable(plat->pclk);
+ plat->tx_clk = devm_clk_get_optional(&pdev->dev, "tx");
+ if (IS_ERR(plat->tx_clk)) {
+ rc = PTR_ERR(plat->tx_clk);
+ dev_err_probe(&pdev->dev, rc, "Cannot get Tx clock\n");
+ goto error_tx_clk_get;
+ }
+ clk_prepare_enable(plat->tx_clk);
+
+ plat->rx_clk = devm_clk_get_optional(&pdev->dev, "rx");
+ if (IS_ERR(plat->rx_clk)) {
+ rc = PTR_ERR(plat->rx_clk);
+ dev_err_probe(&pdev->dev, rc, "Cannot get Rx clock\n");
+ goto error_rx_clk_get;
+ }
+ clk_prepare_enable(plat->rx_clk);
+
/* Fall-back to main clock in case of no PTP ref is passed */
plat->clk_ptp_ref = devm_clk_get_optional(&pdev->dev, "ptp_ref");
if (IS_ERR(plat->clk_ptp_ref)) {
@@ -609,6 +625,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
return plat;
error_hw_init:
+ clk_disable_unprepare(plat->rx_clk);
+error_rx_clk_get:
+ clk_disable_unprepare(plat->tx_clk);
+error_tx_clk_get:
clk_disable_unprepare(plat->pclk);
error_pclk_get:
clk_disable_unprepare(plat->stmmac_clk);
@@ -630,6 +650,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
void stmmac_remove_config_dt(struct platform_device *pdev,
struct plat_stmmacenet_data *plat)
{
+ clk_disable_unprepare(plat->rx_clk);
+ clk_disable_unprepare(plat->tx_clk);
clk_disable_unprepare(plat->pclk);
clk_disable_unprepare(plat->stmmac_clk);
of_node_put(plat->phy_node);
@@ -186,6 +186,8 @@ struct plat_stmmacenet_data {
void *bsp_priv;
struct clk *stmmac_clk;
struct clk *pclk;
+ struct clk *tx_clk;
+ struct clk *rx_clk;
struct clk *clk_ptp_ref;
unsigned int clk_ptp_rate;
unsigned int clk_ref_rate;
Depending on the DW *MAC configuration it can be at least connected to an external Transmit clock, but in some cases to an external Receive clock generator. In order to simplify/unify the sub-drivers code and to prevent having the same clocks named differently add the Tx/Rx clocks support to the generic STMMAC DT-based platform data initialization method under the names "tx" and "rx" respectively. The bindings schema has already been altered in accordance with that. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 22 +++++++++++++++++++ include/linux/stmmac.h | 2 ++ 2 files changed, 24 insertions(+)