aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Bresticker <abrestic@chromium.org>2015-04-07 16:38:45 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-08 14:58:15 -0400
commit5f9755d26fbfcb6787a6746653f1760fef0d5ba5 (patch)
tree0096a69a71bd906fea0cf390ddb1f21b03588d1a
parent2790460e145d198fe6925d405301a49b2d8cb03f (diff)
stmmac: Add an optional register interface clock
The DWMAC block on certain SoCs (such as IMG Pistachio) have a second clock which must be enabled in order to access the peripheral's register interface, so add support for requesting and enabling an optional "pclk". Signed-off-by: Andrew Bresticker <abrestic@chromium.org> Cc: James Hartley <james.hartley@imgtec.com> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/net/stmmac.txt7
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c15
3 files changed, 20 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index 8ca65cec52ae..29aca8591b16 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -35,10 +35,11 @@ Optional properties:
35- reset-names: Should contain the reset signal name "stmmaceth", if a 35- reset-names: Should contain the reset signal name "stmmaceth", if a
36 reset phandle is given 36 reset phandle is given
37- max-frame-size: See ethernet.txt file in the same directory 37- max-frame-size: See ethernet.txt file in the same directory
38- clocks: If present, the first clock should be the GMAC main clock, 38- clocks: If present, the first clock should be the GMAC main clock and
39 further clocks may be specified in derived bindings. 39 the second clock should be peripheral's register interface clock. Further
40 clocks may be specified in derived bindings.
40- clock-names: One name for each entry in the clocks property, the 41- clock-names: One name for each entry in the clocks property, the
41 first one should be "stmmaceth". 42 first one should be "stmmaceth" and the second one should be "pclk".
42- clk_ptp_ref: this is the PTP reference clock; in case of the PTP is 43- clk_ptp_ref: this is the PTP reference clock; in case of the PTP is
43 available this clock is used for programming the Timestamp Addend Register. 44 available this clock is used for programming the Timestamp Addend Register.
44 If not passed then the system clock will be used and this is fine on some 45 If not passed then the system clock will be used and this is fine on some
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index c0a391983372..2ac9552d1fa3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -97,6 +97,7 @@ struct stmmac_priv {
97 int wolopts; 97 int wolopts;
98 int wol_irq; 98 int wol_irq;
99 struct clk *stmmac_clk; 99 struct clk *stmmac_clk;
100 struct clk *pclk;
100 struct reset_control *stmmac_rst; 101 struct reset_control *stmmac_rst;
101 int clk_csr; 102 int clk_csr;
102 struct timer_list eee_ctrl_timer; 103 struct timer_list eee_ctrl_timer;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 5336594abed1..06103cad7c77 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2849,6 +2849,16 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
2849 } 2849 }
2850 clk_prepare_enable(priv->stmmac_clk); 2850 clk_prepare_enable(priv->stmmac_clk);
2851 2851
2852 priv->pclk = devm_clk_get(priv->device, "pclk");
2853 if (IS_ERR(priv->pclk)) {
2854 if (PTR_ERR(priv->pclk) == -EPROBE_DEFER) {
2855 ret = -EPROBE_DEFER;
2856 goto error_pclk_get;
2857 }
2858 priv->pclk = NULL;
2859 }
2860 clk_prepare_enable(priv->pclk);
2861
2852 priv->stmmac_rst = devm_reset_control_get(priv->device, 2862 priv->stmmac_rst = devm_reset_control_get(priv->device,
2853 STMMAC_RESOURCE_NAME); 2863 STMMAC_RESOURCE_NAME);
2854 if (IS_ERR(priv->stmmac_rst)) { 2864 if (IS_ERR(priv->stmmac_rst)) {
@@ -2934,6 +2944,8 @@ error_mdio_register:
2934error_netdev_register: 2944error_netdev_register:
2935 netif_napi_del(&priv->napi); 2945 netif_napi_del(&priv->napi);
2936error_hw_init: 2946error_hw_init:
2947 clk_disable_unprepare(priv->pclk);
2948error_pclk_get:
2937 clk_disable_unprepare(priv->stmmac_clk); 2949 clk_disable_unprepare(priv->stmmac_clk);
2938error_clk_get: 2950error_clk_get:
2939 free_netdev(ndev); 2951 free_netdev(ndev);
@@ -2965,6 +2977,7 @@ int stmmac_dvr_remove(struct net_device *ndev)
2965 unregister_netdev(ndev); 2977 unregister_netdev(ndev);
2966 if (priv->stmmac_rst) 2978 if (priv->stmmac_rst)
2967 reset_control_assert(priv->stmmac_rst); 2979 reset_control_assert(priv->stmmac_rst);
2980 clk_disable_unprepare(priv->pclk);
2968 clk_disable_unprepare(priv->stmmac_clk); 2981 clk_disable_unprepare(priv->stmmac_clk);
2969 free_netdev(ndev); 2982 free_netdev(ndev);
2970 2983
@@ -3011,6 +3024,7 @@ int stmmac_suspend(struct net_device *ndev)
3011 stmmac_set_mac(priv->ioaddr, false); 3024 stmmac_set_mac(priv->ioaddr, false);
3012 pinctrl_pm_select_sleep_state(priv->device); 3025 pinctrl_pm_select_sleep_state(priv->device);
3013 /* Disable clock in case of PWM is off */ 3026 /* Disable clock in case of PWM is off */
3027 clk_disable(priv->pclk);
3014 clk_disable(priv->stmmac_clk); 3028 clk_disable(priv->stmmac_clk);
3015 } 3029 }
3016 spin_unlock_irqrestore(&priv->lock, flags); 3030 spin_unlock_irqrestore(&priv->lock, flags);
@@ -3051,6 +3065,7 @@ int stmmac_resume(struct net_device *ndev)
3051 pinctrl_pm_select_default_state(priv->device); 3065 pinctrl_pm_select_default_state(priv->device);
3052 /* enable the clk prevously disabled */ 3066 /* enable the clk prevously disabled */
3053 clk_enable(priv->stmmac_clk); 3067 clk_enable(priv->stmmac_clk);
3068 clk_enable(priv->pclk);
3054 /* reset the phy so that it's ready */ 3069 /* reset the phy so that it's ready */
3055 if (priv->mii) 3070 if (priv->mii)
3056 stmmac_mdio_reset(priv->mii); 3071 stmmac_mdio_reset(priv->mii);