Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: macb: Add support for rx_clk

Some of the platforms like zynqmp ultrascale+ has a
separate clock gate for the rx clock. Add an optional
rx_clk so that the clock can be enabled.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

shubhrajyoti.datta@xilinx.com and committed by
David S. Miller
aead88bd d52bfbda

+30 -6
+1
Documentation/devicetree/bindings/net/macb.txt
··· 21 21 - clock-names: Tuple listing input clock names. 22 22 Required elements: 'pclk', 'hclk' 23 23 Optional elements: 'tx_clk' 24 + Optional elements: 'rx_clk' applies to cdns,zynqmp-gem 24 25 - clocks: Phandles to input clocks. 25 26 26 27 Optional properties for PHY child node:
+26 -5
drivers/net/ethernet/cadence/macb.c
··· 2332 2332 } 2333 2333 2334 2334 static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, 2335 - struct clk **hclk, struct clk **tx_clk) 2335 + struct clk **hclk, struct clk **tx_clk, 2336 + struct clk **rx_clk) 2336 2337 { 2337 2338 int err; 2338 2339 ··· 2355 2354 if (IS_ERR(*tx_clk)) 2356 2355 *tx_clk = NULL; 2357 2356 2357 + *rx_clk = devm_clk_get(&pdev->dev, "rx_clk"); 2358 + if (IS_ERR(*rx_clk)) 2359 + *rx_clk = NULL; 2360 + 2358 2361 err = clk_prepare_enable(*pclk); 2359 2362 if (err) { 2360 2363 dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); ··· 2377 2372 goto err_disable_hclk; 2378 2373 } 2379 2374 2375 + err = clk_prepare_enable(*rx_clk); 2376 + if (err) { 2377 + dev_err(&pdev->dev, "failed to enable rx_clk (%u)\n", err); 2378 + goto err_disable_txclk; 2379 + } 2380 + 2380 2381 return 0; 2382 + 2383 + err_disable_txclk: 2384 + clk_disable_unprepare(*tx_clk); 2381 2385 2382 2386 err_disable_hclk: 2383 2387 clk_disable_unprepare(*hclk); ··· 2777 2763 }; 2778 2764 2779 2765 static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk, 2780 - struct clk **hclk, struct clk **tx_clk) 2766 + struct clk **hclk, struct clk **tx_clk, 2767 + struct clk **rx_clk) 2781 2768 { 2782 2769 int err; 2783 2770 2784 2771 *hclk = NULL; 2785 2772 *tx_clk = NULL; 2773 + *rx_clk = NULL; 2786 2774 2787 2775 *pclk = devm_clk_get(&pdev->dev, "ether_clk"); 2788 2776 if (IS_ERR(*pclk)) ··· 2908 2892 static int macb_probe(struct platform_device *pdev) 2909 2893 { 2910 2894 int (*clk_init)(struct platform_device *, struct clk **, 2911 - struct clk **, struct clk **) 2895 + struct clk **, struct clk **, struct clk **) 2912 2896 = macb_clk_init; 2913 2897 int (*init)(struct platform_device *) = macb_init; 2914 2898 struct device_node *np = pdev->dev.of_node; 2915 2899 struct device_node *phy_node; 2916 2900 const struct macb_config *macb_config = NULL; 2917 - struct clk *pclk, *hclk = NULL, *tx_clk = NULL; 2901 + struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL; 2918 2902 unsigned int queue_mask, num_queues; 2919 2903 struct macb_platform_data *pdata; 2920 2904 bool native_io; ··· 2942 2926 } 2943 2927 } 2944 2928 2945 - err = clk_init(pdev, &pclk, &hclk, &tx_clk); 2929 + err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk); 2946 2930 if (err) 2947 2931 return err; 2948 2932 ··· 2978 2962 bp->pclk = pclk; 2979 2963 bp->hclk = hclk; 2980 2964 bp->tx_clk = tx_clk; 2965 + bp->rx_clk = rx_clk; 2981 2966 if (macb_config) 2982 2967 bp->jumbo_max_len = macb_config->jumbo_max_len; 2983 2968 ··· 3077 3060 clk_disable_unprepare(tx_clk); 3078 3061 clk_disable_unprepare(hclk); 3079 3062 clk_disable_unprepare(pclk); 3063 + clk_disable_unprepare(rx_clk); 3080 3064 3081 3065 return err; 3082 3066 } ··· 3104 3086 clk_disable_unprepare(bp->tx_clk); 3105 3087 clk_disable_unprepare(bp->hclk); 3106 3088 clk_disable_unprepare(bp->pclk); 3089 + clk_disable_unprepare(bp->rx_clk); 3107 3090 free_netdev(dev); 3108 3091 } 3109 3092 ··· 3128 3109 clk_disable_unprepare(bp->tx_clk); 3129 3110 clk_disable_unprepare(bp->hclk); 3130 3111 clk_disable_unprepare(bp->pclk); 3112 + clk_disable_unprepare(bp->rx_clk); 3131 3113 } 3132 3114 3133 3115 return 0; ··· 3148 3128 clk_prepare_enable(bp->pclk); 3149 3129 clk_prepare_enable(bp->hclk); 3150 3130 clk_prepare_enable(bp->tx_clk); 3131 + clk_prepare_enable(bp->rx_clk); 3151 3132 } 3152 3133 3153 3134 netif_device_attach(netdev);
+3 -1
drivers/net/ethernet/cadence/macb.h
··· 772 772 u32 caps; 773 773 unsigned int dma_burst_length; 774 774 int (*clk_init)(struct platform_device *pdev, struct clk **pclk, 775 - struct clk **hclk, struct clk **tx_clk); 775 + struct clk **hclk, struct clk **tx_clk, 776 + struct clk **rx_clk); 776 777 int (*init)(struct platform_device *pdev); 777 778 int jumbo_max_len; 778 779 }; ··· 820 819 struct clk *pclk; 821 820 struct clk *hclk; 822 821 struct clk *tx_clk; 822 + struct clk *rx_clk; 823 823 struct net_device *dev; 824 824 struct napi_struct napi; 825 825 struct net_device_stats stats;