CC: [email protected] BCC: [email protected] CC: [email protected] TO: Appana Durga Kedareswara Rao <[email protected]> CC: Michal Simek <[email protected]> CC: Radhey Shyam Pandey <[email protected]> CC: Sarath Babu Naidu Gaddam <[email protected]> CC: Swati Agarwal <[email protected]>
tree: https://github.com/Xilinx/linux-xlnx xlnx_rebase_v5.15_LTS head: 1e67f149fb5eb4f5eb4e0d4f69194eac6d2497d7 commit: 353f790929055728585095cb890b378ee0471607 [224/1197] net: axienet: Add clock support :::::: branch date: 8 days ago :::::: commit date: 5 months ago config: x86_64-randconfig-c022-20220627 (https://download.01.org/0day-ci/archive/20220628/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> cocci warnings: (new ones prefixed by >>) >> drivers/net/ethernet/xilinx/xilinx_axienet_main.c:2828:47-48: WARNING this >> kind of initialization is deprecated vim +2828 drivers/net/ethernet/xilinx/xilinx_axienet_main.c a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2811 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2812 /** 2be586205ca2b8 Srikanth Thokala 2015-05-05 2813 * axienet_probe - Axi Ethernet probe function. 95219aa538e11d Srikanth Thokala 2015-05-05 2814 * @pdev: Pointer to platform device structure. 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2815 * b0d081c524b46c Michal Simek 2015-05-05 2816 * Return: 0, on success 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2817 * Non-zero error value on failure. 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2818 * 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2819 * This is the probe routine for Axi Ethernet driver. This is called before 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2820 * any other driver routines are invoked. It allocates and sets up the Ethernet 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2821 * device. Parses through device tree and populates fields of 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2822 * axienet_local. It registers the Ethernet device. 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2823 */ 2be586205ca2b8 Srikanth Thokala 2015-05-05 2824 static int axienet_probe(struct platform_device *pdev) 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2825 { 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 2826 int (*axienet_clk_init)(struct platform_device *pdev, 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 2827 struct clk **axi_aclk, struct clk **axis_clk, 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 @2828 struct clk **ref_clk, struct clk **tmpclk) = 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 2829 axienet_clk_init; c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2830 int ret = 0; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2831 struct device_node *np; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2832 struct axienet_local *lp; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2833 struct net_device *ndev; 83216e3988cd19 Michael Walle 2021-04-12 2834 u8 mac_addr[ETH_ALEN]; daef06520f0d07 Radhey Shyam Pandey 2020-01-24 2835 struct resource *ethres, dmares; 5fff0151b3244d Andre Przywara 2020-03-24 2836 int addr_width = 32; 8495659bf93c8e Srikanth Thokala 2015-05-05 2837 u32 value; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2838 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2839 ndev = alloc_etherdev(sizeof(*lp)); 41de8d4cff21a2 Joe Perches 2012-01-29 2840 if (!ndev) 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2841 return -ENOMEM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2842 95219aa538e11d Srikanth Thokala 2015-05-05 2843 platform_set_drvdata(pdev, ndev); 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2844 95219aa538e11d Srikanth Thokala 2015-05-05 2845 SET_NETDEV_DEV(ndev, &pdev->dev); 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2846 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */ 28e24c62ab3062 Eric Dumazet 2013-12-02 2847 ndev->features = NETIF_F_SG; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2848 ndev->netdev_ops = &axienet_netdev_ops; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2849 ndev->ethtool_ops = &axienet_ethtool_ops; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2850 d894be57ca92c8 Jarod Wilson 2016-10-20 2851 /* MTU range: 64 - 9000 */ d894be57ca92c8 Jarod Wilson 2016-10-20 2852 ndev->min_mtu = 64; d894be57ca92c8 Jarod Wilson 2016-10-20 2853 ndev->max_mtu = XAE_JUMBO_MTU; d894be57ca92c8 Jarod Wilson 2016-10-20 2854 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2855 lp = netdev_priv(ndev); 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2856 lp->ndev = ndev; 95219aa538e11d Srikanth Thokala 2015-05-05 2857 lp->dev = &pdev->dev; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2858 lp->options = XAE_OPTION_DEFAULTS; 8b09ca823ffb4e Robert Hancock 2019-06-06 2859 lp->rx_bd_num = RX_BD_NUM_DEFAULT; 8b09ca823ffb4e Robert Hancock 2019-06-06 2860 lp->tx_bd_num = TX_BD_NUM_DEFAULT; 57baf8cc70ea4c Robert Hancock 2021-02-12 2861 b11bfb9a19f9d7 Robert Hancock 2021-03-25 2862 lp->axi_clk = devm_clk_get_optional(&pdev->dev, "s_axi_lite_clk"); b11bfb9a19f9d7 Robert Hancock 2021-03-25 2863 if (!lp->axi_clk) { b11bfb9a19f9d7 Robert Hancock 2021-03-25 2864 /* For backward compatibility, if named AXI clock is not present, b11bfb9a19f9d7 Robert Hancock 2021-03-25 2865 * treat the first clock specified as the AXI clock. b11bfb9a19f9d7 Robert Hancock 2021-03-25 2866 */ b11bfb9a19f9d7 Robert Hancock 2021-03-25 2867 lp->axi_clk = devm_clk_get_optional(&pdev->dev, NULL); b11bfb9a19f9d7 Robert Hancock 2021-03-25 2868 } b11bfb9a19f9d7 Robert Hancock 2021-03-25 2869 if (IS_ERR(lp->axi_clk)) { b11bfb9a19f9d7 Robert Hancock 2021-03-25 2870 ret = PTR_ERR(lp->axi_clk); 57baf8cc70ea4c Robert Hancock 2021-02-12 2871 goto free_netdev; 57baf8cc70ea4c Robert Hancock 2021-02-12 2872 } b11bfb9a19f9d7 Robert Hancock 2021-03-25 2873 ret = clk_prepare_enable(lp->axi_clk); 57baf8cc70ea4c Robert Hancock 2021-02-12 2874 if (ret) { b11bfb9a19f9d7 Robert Hancock 2021-03-25 2875 dev_err(&pdev->dev, "Unable to enable AXI clock: %d\n", ret); 57baf8cc70ea4c Robert Hancock 2021-02-12 2876 goto free_netdev; 57baf8cc70ea4c Robert Hancock 2021-02-12 2877 } 57baf8cc70ea4c Robert Hancock 2021-02-12 2878 b11bfb9a19f9d7 Robert Hancock 2021-03-25 2879 lp->misc_clks[0].id = "axis_clk"; b11bfb9a19f9d7 Robert Hancock 2021-03-25 2880 lp->misc_clks[1].id = "ref_clk"; b11bfb9a19f9d7 Robert Hancock 2021-03-25 2881 lp->misc_clks[2].id = "mgt_clk"; b11bfb9a19f9d7 Robert Hancock 2021-03-25 2882 b11bfb9a19f9d7 Robert Hancock 2021-03-25 2883 ret = devm_clk_bulk_get_optional(&pdev->dev, XAE_NUM_MISC_CLOCKS, lp->misc_clks); b11bfb9a19f9d7 Robert Hancock 2021-03-25 2884 if (ret) b11bfb9a19f9d7 Robert Hancock 2021-03-25 2885 goto cleanup_clk; b11bfb9a19f9d7 Robert Hancock 2021-03-25 2886 b11bfb9a19f9d7 Robert Hancock 2021-03-25 2887 ret = clk_bulk_prepare_enable(XAE_NUM_MISC_CLOCKS, lp->misc_clks); b11bfb9a19f9d7 Robert Hancock 2021-03-25 2888 if (ret) b11bfb9a19f9d7 Robert Hancock 2021-03-25 2889 goto cleanup_clk; b11bfb9a19f9d7 Robert Hancock 2021-03-25 2890 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2891 /* Map device registers */ 47651c51c02fc4 Yang Yingliang 2021-06-10 2892 lp->regs = devm_platform_get_and_ioremap_resource(pdev, 0, ðres); fcc028c106e575 Krzysztof Kozlowski 2015-07-09 2893 if (IS_ERR(lp->regs)) { fcc028c106e575 Krzysztof Kozlowski 2015-07-09 2894 ret = PTR_ERR(lp->regs); 59cd4f19267a0a Robert Hancock 2021-03-11 2895 goto cleanup_clk; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2896 } 7fa0043d5c74c6 Robert Hancock 2019-06-11 2897 lp->regs_start = ethres->start; 46aa27df885321 Srikanth Thokala 2015-05-05 2898 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2899 /* Setup checksum offload, but default to off if not specified */ 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2900 lp->features = 0; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2901 a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2902 if (pdev->dev.of_node) { a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2903 const struct of_device_id *match; a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2904 a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2905 match = of_match_node(axienet_of_match, pdev->dev.of_node); 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 2906 if (match && match->data) { a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2907 lp->axienet_config = match->data; 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 2908 axienet_clk_init = lp->axienet_config->clk_init; 353f7909290557 Appana Durga Kedareswara Rao 2021-01-22 2909 } a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2910 } a2fc9e93fefa1f Appana Durga Kedareswara Rao 2020-01-24 2911 8495659bf93c8e Srikanth Thokala 2015-05-05 2912 ret = of_property_read_u32(pdev->dev.of_node, "xlnx,txcsum", &value); 8495659bf93c8e Srikanth Thokala 2015-05-05 2913 if (!ret) { c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2914 dev_info(&pdev->dev, "TX_CSUM %d\n", value); c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2915 8495659bf93c8e Srikanth Thokala 2015-05-05 2916 switch (value) { 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2917 case 1: 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2918 lp->csum_offload_on_tx_path = 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2919 XAE_FEATURE_PARTIAL_TX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2920 lp->features |= XAE_FEATURE_PARTIAL_TX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2921 /* Can checksum TCP/UDP over IPv4. */ c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2922 ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2923 break; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2924 case 2: 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2925 lp->csum_offload_on_tx_path = 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2926 XAE_FEATURE_FULL_TX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2927 lp->features |= XAE_FEATURE_FULL_TX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2928 /* Can checksum TCP/UDP over IPv4. */ c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2929 ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2930 break; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2931 default: 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2932 lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2933 } 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2934 } 8495659bf93c8e Srikanth Thokala 2015-05-05 2935 ret = of_property_read_u32(pdev->dev.of_node, "xlnx,rxcsum", &value); 8495659bf93c8e Srikanth Thokala 2015-05-05 2936 if (!ret) { c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2937 dev_info(&pdev->dev, "RX_CSUM %d\n", value); c9e6ca8b3f1707 Appana Durga Kedareswara Rao 2021-01-22 2938 8495659bf93c8e Srikanth Thokala 2015-05-05 2939 switch (value) { 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2940 case 1: 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2941 lp->csum_offload_on_rx_path = 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2942 XAE_FEATURE_PARTIAL_RX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2943 lp->features |= XAE_FEATURE_PARTIAL_RX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2944 break; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2945 case 2: 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2946 lp->csum_offload_on_rx_path = 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2947 XAE_FEATURE_FULL_RX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2948 lp->features |= XAE_FEATURE_FULL_RX_CSUM; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2949 break; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2950 default: 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2951 lp->csum_offload_on_rx_path = XAE_NO_CSUM_OFFLOAD; 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2952 } 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2953 } 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2954 /* For supporting jumbo frames, the Axi Ethernet hardware must have f080a8c35d8932 Srikanth Thokala 2015-05-05 2955 * a larger Rx/Tx Memory. Typically, the size must be large so that f080a8c35d8932 Srikanth Thokala 2015-05-05 2956 * we can enable jumbo option and start supporting jumbo frames. f080a8c35d8932 Srikanth Thokala 2015-05-05 2957 * Here we check for memory allocated for Rx/Tx in the hardware from f080a8c35d8932 Srikanth Thokala 2015-05-05 2958 * the device-tree and accordingly set flags. f080a8c35d8932 Srikanth Thokala 2015-05-05 2959 */ 8495659bf93c8e Srikanth Thokala 2015-05-05 2960 of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem); ee06b1728b9564 Alvaro G. M 2017-07-17 2961 6c8f06bb2e5147 Robert Hancock 2021-02-12 2962 lp->switch_x_sgmii = of_property_read_bool(pdev->dev.of_node, 6c8f06bb2e5147 Robert Hancock 2021-02-12 2963 "xlnx,switch-x-sgmii"); 6c8f06bb2e5147 Robert Hancock 2021-02-12 2964 ee06b1728b9564 Alvaro G. M 2017-07-17 2965 /* Start with the proprietary, and broken phy_type */ ee06b1728b9564 Alvaro G. M 2017-07-17 2966 ret = of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &value); ee06b1728b9564 Alvaro G. M 2017-07-17 2967 if (!ret) { ee06b1728b9564 Alvaro G. M 2017-07-17 2968 switch (value) { ee06b1728b9564 Alvaro G. M 2017-07-17 2969 case XAE_PHY_TYPE_MII: ee06b1728b9564 Alvaro G. M 2017-07-17 2970 lp->phy_mode = PHY_INTERFACE_MODE_MII; ee06b1728b9564 Alvaro G. M 2017-07-17 2971 break; ee06b1728b9564 Alvaro G. M 2017-07-17 2972 case XAE_PHY_TYPE_GMII: ee06b1728b9564 Alvaro G. M 2017-07-17 2973 lp->phy_mode = PHY_INTERFACE_MODE_GMII; ee06b1728b9564 Alvaro G. M 2017-07-17 2974 break; ee06b1728b9564 Alvaro G. M 2017-07-17 2975 case XAE_PHY_TYPE_RGMII_2_0: ee06b1728b9564 Alvaro G. M 2017-07-17 2976 lp->phy_mode = PHY_INTERFACE_MODE_RGMII_ID; ee06b1728b9564 Alvaro G. M 2017-07-17 2977 break; ee06b1728b9564 Alvaro G. M 2017-07-17 2978 case XAE_PHY_TYPE_SGMII: ee06b1728b9564 Alvaro G. M 2017-07-17 2979 lp->phy_mode = PHY_INTERFACE_MODE_SGMII; ee06b1728b9564 Alvaro G. M 2017-07-17 2980 break; ee06b1728b9564 Alvaro G. M 2017-07-17 2981 case XAE_PHY_TYPE_1000BASE_X: ee06b1728b9564 Alvaro G. M 2017-07-17 2982 lp->phy_mode = PHY_INTERFACE_MODE_1000BASEX; ee06b1728b9564 Alvaro G. M 2017-07-17 2983 break; ee06b1728b9564 Alvaro G. M 2017-07-17 2984 default: 9dce88e232cf19 Appana Durga Kedareswara Rao 2020-01-24 2985 /* Don't error out as phy-type is an optional property */ 9dce88e232cf19 Appana Durga Kedareswara Rao 2020-01-24 2986 break; ee06b1728b9564 Alvaro G. M 2017-07-17 2987 } ee06b1728b9564 Alvaro G. M 2017-07-17 2988 } else { 0c65b2b90d13c1 Andrew Lunn 2019-11-04 2989 ret = of_get_phy_mode(pdev->dev.of_node, &lp->phy_mode); 0c65b2b90d13c1 Andrew Lunn 2019-11-04 2990 if (ret) 59cd4f19267a0a Robert Hancock 2021-03-11 2991 goto cleanup_clk; ee06b1728b9564 Alvaro G. M 2017-07-17 2992 } 6c8f06bb2e5147 Robert Hancock 2021-02-12 2993 if (lp->switch_x_sgmii && lp->phy_mode != PHY_INTERFACE_MODE_SGMII && 6c8f06bb2e5147 Robert Hancock 2021-02-12 2994 lp->phy_mode != PHY_INTERFACE_MODE_1000BASEX) { 6c8f06bb2e5147 Robert Hancock 2021-02-12 2995 dev_err(&pdev->dev, "xlnx,switch-x-sgmii only supported with SGMII or 1000BaseX\n"); 6c8f06bb2e5147 Robert Hancock 2021-02-12 2996 ret = -EINVAL; 59cd4f19267a0a Robert Hancock 2021-03-11 2997 goto cleanup_clk; 6c8f06bb2e5147 Robert Hancock 2021-02-12 2998 } 8a3b7a252dca9f Daniel Borkmann 2012-01-19 2999 f6420dd2cc68a9 Appana Durga Kedareswara Rao 2020-01-24 3000 lp->eth_hasnobuf = of_property_read_bool(pdev->dev.of_node, f6420dd2cc68a9 Appana Durga Kedareswara Rao 2020-01-24 3001 "xlnx,eth-hasnobuf"); bf05571deda79b Appana Durga Kedareswara Rao 2020-01-24 3002 lp->eth_hasptp = of_property_read_bool(pdev->dev.of_node, bf05571deda79b Appana Durga Kedareswara Rao 2020-01-24 3003 "xlnx,eth-hasptp"); f6420dd2cc68a9 Appana Durga Kedareswara Rao 2020-01-24 3004 9dce88e232cf19 Appana Durga Kedareswara Rao 2020-01-24 3005 if (lp->axienet_config->mactype == XAXIENET_1G && !lp->eth_hasnobuf) 9dce88e232cf19 Appana Durga Kedareswara Rao 2020-01-24 3006 lp->eth_irq = platform_get_irq(pdev, 0); bf05571deda79b Appana Durga Kedareswara Rao 2020-01-24 3007 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
