diff options
author | Murali Karicheri | 2014-06-13 10:14:15 -0500 |
---|---|---|
committer | Murali Karicheri | 2014-12-03 10:30:10 -0600 |
commit | 260df23623ccde037facc32d3860277eb87be2ba (patch) | |
tree | 2ab75a6b7e726c21f324c0035a2c2a6db32aa161 /drivers/net/ethernet/ti/keystone_ethss.c | |
parent | 9cd26ee3442966e76d28321b20d9ce9d48e16495 (diff) | |
download | linux-260df23623ccde037facc32d3860277eb87be2ba.tar.gz linux-260df23623ccde037facc32d3860277eb87be2ba.tar.xz linux-260df23623ccde037facc32d3860277eb87be2ba.zip |
net: keystone: ethss: fix compiler error when CPTS is disabled
Currently if CPTS is disabled, network driver doesn't compile.
This patch addresses this issue. While at it move the code a bit
so that ptp_filter_init() is called from cpts registration function.
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Diffstat (limited to 'drivers/net/ethernet/ti/keystone_ethss.c')
-rw-r--r-- | drivers/net/ethernet/ti/keystone_ethss.c | 146 |
1 files changed, 84 insertions, 62 deletions
diff --git a/drivers/net/ethernet/ti/keystone_ethss.c b/drivers/net/ethernet/ti/keystone_ethss.c index 65b81df5148..7fa411db024 100644 --- a/drivers/net/ethernet/ti/keystone_ethss.c +++ b/drivers/net/ethernet/ti/keystone_ethss.c | |||
@@ -2816,13 +2816,20 @@ static inline void cpsw_register_cpts(struct cpsw_priv *cpsw_dev) | |||
2816 | if (cpsw_dev->cpts_registered > 0) | 2816 | if (cpsw_dev->cpts_registered > 0) |
2817 | goto done; | 2817 | goto done; |
2818 | 2818 | ||
2819 | if (ptp_filter_init(phy_ptp_filter, ARRAY_SIZE(phy_ptp_filter))) { | ||
2820 | dev_err(cpsw_dev->dev, "bad ptp filter\n"); | ||
2821 | return; | ||
2822 | } | ||
2823 | |||
2819 | cpsw_dev->cpts.filter = cpsw_ptp_filter; | 2824 | cpsw_dev->cpts.filter = cpsw_ptp_filter; |
2820 | cpsw_dev->cpts.filter_size = ARRAY_SIZE(cpsw_ptp_filter); | 2825 | cpsw_dev->cpts.filter_size = ARRAY_SIZE(cpsw_ptp_filter); |
2821 | 2826 | ||
2822 | /* Let cpts calculate the mult and shift */ | 2827 | /* Let cpts calculate the mult and shift */ |
2823 | if (cpts_register(cpsw_dev->dev, &cpsw_dev->cpts, | 2828 | if (cpts_register(cpsw_dev->dev, &cpsw_dev->cpts, |
2824 | cpsw_dev->cpts.cc.mult, cpsw_dev->cpts.cc.shift)) | 2829 | cpsw_dev->cpts.cc.mult, cpsw_dev->cpts.cc.shift)) { |
2825 | dev_err(cpsw_dev->dev, "error registering cpts device\n"); | 2830 | dev_err(cpsw_dev->dev, "error registering cpts device\n"); |
2831 | return; | ||
2832 | } | ||
2826 | 2833 | ||
2827 | done: | 2834 | done: |
2828 | ++cpsw_dev->cpts_registered; | 2835 | ++cpsw_dev->cpts_registered; |
@@ -2845,6 +2852,76 @@ static inline void cpsw_unregister_cpts(struct cpsw_priv *cpsw_dev) | |||
2845 | cpsw_dev->cpts.filter_size = 0; | 2852 | cpsw_dev->cpts.filter_size = 0; |
2846 | cpts_unregister(&cpsw_dev->cpts); | 2853 | cpts_unregister(&cpsw_dev->cpts); |
2847 | } | 2854 | } |
2855 | |||
2856 | static void cpsw_update_cpts_dt_params(struct cpsw_priv *cpsw_dev, | ||
2857 | struct device_node *node) | ||
2858 | { | ||
2859 | int ret; | ||
2860 | |||
2861 | ret = of_property_read_u32(node, "cpts_reg_ofs", | ||
2862 | &cpsw_dev->cpts_reg_ofs); | ||
2863 | if (ret < 0) | ||
2864 | dev_err(cpsw_dev->dev, | ||
2865 | "missing cpts reg offset, err %d\n", ret); | ||
2866 | |||
2867 | ret = of_property_read_u32(node, "cpts_rftclk_sel", | ||
2868 | &cpsw_dev->cpts.rftclk_sel); | ||
2869 | if (ret < 0) { | ||
2870 | dev_err(cpsw_dev->dev, | ||
2871 | "missing cpts rftclk_sel, err %d\n", ret); | ||
2872 | cpsw_dev->cpts.rftclk_sel = 0; | ||
2873 | } | ||
2874 | |||
2875 | ret = of_property_read_u32(node, "cpts_rftclk_freq", | ||
2876 | &cpsw_dev->cpts.rftclk_freq); | ||
2877 | if (ret < 0) { | ||
2878 | dev_vdbg(cpsw_dev->dev, "cpts rftclk freq not defined\n"); | ||
2879 | cpsw_dev->cpts.rftclk_freq = 0; | ||
2880 | } | ||
2881 | |||
2882 | ret = of_property_read_u32(node, "cpts_ts_comp_length", | ||
2883 | &cpsw_dev->cpts.ts_comp_length); | ||
2884 | if (ret < 0) { | ||
2885 | dev_err(cpsw_dev->dev, | ||
2886 | "missing cpts ts_comp length, err %d\n", ret); | ||
2887 | cpsw_dev->cpts.ts_comp_length = 1; | ||
2888 | } | ||
2889 | |||
2890 | if (of_property_read_u32(node, "cpts_ts_comp_polarity", | ||
2891 | &cpsw_dev->cpts.ts_comp_polarity)) | ||
2892 | cpsw_dev->cpts.ts_comp_polarity = 1; | ||
2893 | |||
2894 | if (of_property_read_u32(node, "cpts_clock_mult", | ||
2895 | &cpsw_dev->cpts.cc.mult)) { | ||
2896 | dev_err(cpsw_dev->dev, | ||
2897 | "Missing cpts_clock_mult property in the DT.\n"); | ||
2898 | cpsw_dev->cpts.cc.mult = 0; | ||
2899 | } | ||
2900 | |||
2901 | if (of_property_read_u32(node, "cpts_clock_shift", | ||
2902 | &cpsw_dev->cpts.cc.shift)) { | ||
2903 | dev_err(cpsw_dev->dev, | ||
2904 | "Missing cpts_clock_shift property in the DT.\n"); | ||
2905 | cpsw_dev->cpts.cc.shift = 0; | ||
2906 | } | ||
2907 | |||
2908 | if (of_property_read_u32(node, "cpts_clock_div", | ||
2909 | &cpsw_dev->cpts.cc_div)) { | ||
2910 | dev_err(cpsw_dev->dev, | ||
2911 | "Missing cpts_clock_div property in the DT.\n"); | ||
2912 | cpsw_dev->cpts.cc_div = 1; | ||
2913 | } | ||
2914 | |||
2915 | cpsw_dev->cpts.ignore_adjfreq = | ||
2916 | of_property_read_bool(node, "cpts-ignore-adjfreq"); | ||
2917 | |||
2918 | ret = of_property_read_u32(node, "num_slaves", &cpsw_dev->num_slaves); | ||
2919 | if (ret < 0) { | ||
2920 | dev_err(cpsw_dev->dev, | ||
2921 | "missing num_slaves parameter, err %d\n", ret); | ||
2922 | cpsw_dev->num_slaves = 2; | ||
2923 | } | ||
2924 | } | ||
2848 | #else | 2925 | #else |
2849 | static inline int cpsw_mark_pkt_txtstamp(struct cpsw_intf *cpsw_intf, | 2926 | static inline int cpsw_mark_pkt_txtstamp(struct cpsw_intf *cpsw_intf, |
2850 | struct netcp_packet *p_info) | 2927 | struct netcp_packet *p_info) |
@@ -2865,6 +2942,11 @@ static inline void cpsw_register_cpts(struct cpsw_priv *cpsw_dev) | |||
2865 | static inline void cpsw_unregister_cpts(struct cpsw_priv *cpsw_dev) | 2942 | static inline void cpsw_unregister_cpts(struct cpsw_priv *cpsw_dev) |
2866 | { | 2943 | { |
2867 | } | 2944 | } |
2945 | |||
2946 | static void cpsw_update_cpts_dt_params(struct cpsw_priv *cpsw_dev, | ||
2947 | struct device_node *node) | ||
2948 | { | ||
2949 | } | ||
2868 | #endif /* CONFIG_TI_CPTS */ | 2950 | #endif /* CONFIG_TI_CPTS */ |
2869 | 2951 | ||
2870 | static int cpsw_serdes_init(struct cpsw_priv *cpsw_dev) | 2952 | static int cpsw_serdes_init(struct cpsw_priv *cpsw_dev) |
@@ -3204,11 +3286,6 @@ static int cpsw_probe(struct netcp_device *netcp_device, | |||
3204 | return -ENODEV; | 3286 | return -ENODEV; |
3205 | } | 3287 | } |
3206 | 3288 | ||
3207 | if (ptp_filter_init(phy_ptp_filter, ARRAY_SIZE(phy_ptp_filter))) { | ||
3208 | dev_err(dev, "bad ptp filter\n"); | ||
3209 | return -EINVAL; | ||
3210 | } | ||
3211 | |||
3212 | cpsw_dev = devm_kzalloc(dev, sizeof(struct cpsw_priv), GFP_KERNEL); | 3289 | cpsw_dev = devm_kzalloc(dev, sizeof(struct cpsw_priv), GFP_KERNEL); |
3213 | if (!cpsw_dev) { | 3290 | if (!cpsw_dev) { |
3214 | dev_err(dev, "cpsw_dev memory allocation failed\n"); | 3291 | dev_err(dev, "cpsw_dev memory allocation failed\n"); |
@@ -3355,62 +3432,7 @@ static int cpsw_probe(struct netcp_device *netcp_device, | |||
3355 | if (ret < 0) | 3432 | if (ret < 0) |
3356 | dev_err(dev, "missing ale reg offset, err %d\n", ret); | 3433 | dev_err(dev, "missing ale reg offset, err %d\n", ret); |
3357 | 3434 | ||
3358 | ret = of_property_read_u32(node, "cpts_reg_ofs", | 3435 | cpsw_update_cpts_dt_params(cpsw_dev, node); |
3359 | &cpsw_dev->cpts_reg_ofs); | ||
3360 | if (ret < 0) | ||
3361 | dev_err(dev, "missing cpts reg offset, err %d\n", ret); | ||
3362 | |||
3363 | ret = of_property_read_u32(node, "cpts_rftclk_sel", | ||
3364 | &cpsw_dev->cpts.rftclk_sel); | ||
3365 | if (ret < 0) { | ||
3366 | dev_err(dev, "missing cpts rftclk_sel, err %d\n", ret); | ||
3367 | cpsw_dev->cpts.rftclk_sel = 0; | ||
3368 | } | ||
3369 | |||
3370 | ret = of_property_read_u32(node, "cpts_rftclk_freq", | ||
3371 | &cpsw_dev->cpts.rftclk_freq); | ||
3372 | if (ret < 0) { | ||
3373 | dev_vdbg(dev, "cpts rftclk freq not defined\n"); | ||
3374 | cpsw_dev->cpts.rftclk_freq = 0; | ||
3375 | } | ||
3376 | |||
3377 | ret = of_property_read_u32(node, "cpts_ts_comp_length", | ||
3378 | &cpsw_dev->cpts.ts_comp_length); | ||
3379 | if (ret < 0) { | ||
3380 | dev_err(dev, "missing cpts ts_comp length, err %d\n", ret); | ||
3381 | cpsw_dev->cpts.ts_comp_length = 1; | ||
3382 | } | ||
3383 | |||
3384 | if (of_property_read_u32(node, "cpts_ts_comp_polarity", | ||
3385 | &cpsw_dev->cpts.ts_comp_polarity)) | ||
3386 | cpsw_dev->cpts.ts_comp_polarity = 1; | ||
3387 | |||
3388 | if (of_property_read_u32(node, "cpts_clock_mult", | ||
3389 | &cpsw_dev->cpts.cc.mult)) { | ||
3390 | pr_err("Missing cpts_clock_mult property in the DT.\n"); | ||
3391 | cpsw_dev->cpts.cc.mult = 0; | ||
3392 | } | ||
3393 | |||
3394 | if (of_property_read_u32(node, "cpts_clock_shift", | ||
3395 | &cpsw_dev->cpts.cc.shift)) { | ||
3396 | pr_err("Missing cpts_clock_shift property in the DT.\n"); | ||
3397 | cpsw_dev->cpts.cc.shift = 0; | ||
3398 | } | ||
3399 | |||
3400 | if (of_property_read_u32(node, "cpts_clock_div", | ||
3401 | &cpsw_dev->cpts.cc_div)) { | ||
3402 | pr_err("Missing cpts_clock_div property in the DT.\n"); | ||
3403 | cpsw_dev->cpts.cc_div = 1; | ||
3404 | } | ||
3405 | |||
3406 | cpsw_dev->cpts.ignore_adjfreq = | ||
3407 | of_property_read_bool(node, "cpts-ignore-adjfreq"); | ||
3408 | |||
3409 | ret = of_property_read_u32(node, "num_slaves", &cpsw_dev->num_slaves); | ||
3410 | if (ret < 0) { | ||
3411 | dev_err(dev, "missing num_slaves parameter, err %d\n", ret); | ||
3412 | cpsw_dev->num_slaves = 2; | ||
3413 | } | ||
3414 | 3436 | ||
3415 | ret = of_property_read_u32(node, "ale_ageout", &cpsw_dev->ale_ageout); | 3437 | ret = of_property_read_u32(node, "ale_ageout", &cpsw_dev->ale_ageout); |
3416 | if (ret < 0) { | 3438 | if (ret < 0) { |