Lines Matching +full:serdes +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0
3 * Wrapper driver for SERDES used in J721E
5 * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
9 #include <dt-bindings/phy/phy.h>
10 #include <dt-bindings/phy/phy-ti.h>
12 #include <linux/clk.h>
13 #include <linux/clk-provider.h>
25 #include <linux/reset-controller.h>
35 /* SERDES offsets */
125 [TI_WIZ_PLL0_REFCLK] = "pll0-refclk",
126 [TI_WIZ_PLL1_REFCLK] = "pll1-refclk",
127 [TI_WIZ_REFCLK_DIG] = "refclk-dig",
128 [TI_WIZ_PHY_EN_REFCLK] = "phy-en-refclk",
253 .node_name = "pll0-refclk",
257 .node_name = "pll1-refclk",
261 .node_name = "refclk-dig",
274 .node_name = "pll0-refclk",
280 .node_name = "pll1-refclk",
286 .node_name = "refclk-dig",
295 .node_name = "pll0-refclk",
301 .node_name = "pll1-refclk",
307 .node_name = "refclk-dig",
322 .node_name = "cmn-refclk-dig-div",
326 .node_name = "cmn-refclk1-dig-div",
392 struct clk *input_clks[WIZ_MAX_INPUT_CLOCKS];
393 struct clk *output_clks[WIZ_MAX_OUTPUT_CLOCKS];
402 ret = regmap_field_write(wiz->por_en, 0x1); in wiz_reset()
408 ret = regmap_field_write(wiz->por_en, 0x0); in wiz_reset()
417 u32 num_lanes = wiz->num_lanes; in wiz_p_mac_div_sel()
422 if (wiz->lane_phy_type[i] == PHY_TYPE_SGMII || in wiz_p_mac_div_sel()
423 wiz->lane_phy_type[i] == PHY_TYPE_QSGMII || in wiz_p_mac_div_sel()
424 wiz->lane_phy_type[i] == PHY_TYPE_USXGMII) { in wiz_p_mac_div_sel()
425 ret = regmap_field_write(wiz->p_mac_div_sel0[i], 1); in wiz_p_mac_div_sel()
429 ret = regmap_field_write(wiz->p_mac_div_sel1[i], 2); in wiz_p_mac_div_sel()
440 u32 num_lanes = wiz->num_lanes; in wiz_mode_select()
446 if (wiz->lane_phy_type[i] == PHY_TYPE_DP) { in wiz_mode_select()
448 } else if (wiz->lane_phy_type[i] == PHY_TYPE_QSGMII) { in wiz_mode_select()
450 } else if (wiz->lane_phy_type[i] == PHY_TYPE_USXGMII) { in wiz_mode_select()
451 ret = regmap_field_write(wiz->p0_mac_src_sel[i], 0x3); in wiz_mode_select()
452 ret = regmap_field_write(wiz->p0_rxfclk_sel[i], 0x3); in wiz_mode_select()
453 ret = regmap_field_write(wiz->p0_refclk_sel[i], 0x2); in wiz_mode_select()
459 ret = regmap_field_write(wiz->p_standard_mode[i], mode); in wiz_mode_select()
469 u32 num_lanes = wiz->num_lanes; in wiz_init_raw_interface()
474 ret = regmap_field_write(wiz->p_align[i], enable); in wiz_init_raw_interface()
478 ret = regmap_field_write(wiz->p_raw_auto_start[i], enable); in wiz_init_raw_interface()
488 struct device *dev = wiz->dev; in wiz_init()
520 struct regmap *regmap = wiz->regmap; in wiz_regfield_init()
521 struct regmap *scm_regmap = wiz->regmap; /* updated later to scm_regmap if applicable */ in wiz_regfield_init()
522 int num_lanes = wiz->num_lanes; in wiz_regfield_init()
523 struct device *dev = wiz->dev; in wiz_regfield_init()
524 const struct wiz_data *data = wiz->data; in wiz_regfield_init()
527 wiz->por_en = devm_regmap_field_alloc(dev, regmap, por_en); in wiz_regfield_init()
528 if (IS_ERR(wiz->por_en)) { in wiz_regfield_init()
530 return PTR_ERR(wiz->por_en); in wiz_regfield_init()
533 wiz->phy_reset_n = devm_regmap_field_alloc(dev, regmap, in wiz_regfield_init()
535 if (IS_ERR(wiz->phy_reset_n)) { in wiz_regfield_init()
537 return PTR_ERR(wiz->phy_reset_n); in wiz_regfield_init()
540 wiz->pma_cmn_refclk_int_mode = in wiz_regfield_init()
542 if (IS_ERR(wiz->pma_cmn_refclk_int_mode)) { in wiz_regfield_init()
544 return PTR_ERR(wiz->pma_cmn_refclk_int_mode); in wiz_regfield_init()
547 wiz->pma_cmn_refclk_mode = in wiz_regfield_init()
549 if (IS_ERR(wiz->pma_cmn_refclk_mode)) { in wiz_regfield_init()
551 return PTR_ERR(wiz->pma_cmn_refclk_mode); in wiz_regfield_init()
554 wiz->div_sel_field[CMN_REFCLK_DIG_DIV] = in wiz_regfield_init()
556 if (IS_ERR(wiz->div_sel_field[CMN_REFCLK_DIG_DIV])) { in wiz_regfield_init()
558 return PTR_ERR(wiz->div_sel_field[CMN_REFCLK_DIG_DIV]); in wiz_regfield_init()
561 if (data->pma_cmn_refclk1_dig_div) { in wiz_regfield_init()
562 wiz->div_sel_field[CMN_REFCLK1_DIG_DIV] = in wiz_regfield_init()
564 *data->pma_cmn_refclk1_dig_div); in wiz_regfield_init()
565 if (IS_ERR(wiz->div_sel_field[CMN_REFCLK1_DIG_DIV])) { in wiz_regfield_init()
567 return PTR_ERR(wiz->div_sel_field[CMN_REFCLK1_DIG_DIV]); in wiz_regfield_init()
571 if (wiz->scm_regmap) { in wiz_regfield_init()
572 scm_regmap = wiz->scm_regmap; in wiz_regfield_init()
573 wiz->sup_legacy_clk_override = in wiz_regfield_init()
575 if (IS_ERR(wiz->sup_legacy_clk_override)) { in wiz_regfield_init()
577 return PTR_ERR(wiz->sup_legacy_clk_override); in wiz_regfield_init()
581 wiz->mux_sel_field[PLL0_REFCLK] = in wiz_regfield_init()
582 devm_regmap_field_alloc(dev, scm_regmap, *data->pll0_refclk_mux_sel); in wiz_regfield_init()
583 if (IS_ERR(wiz->mux_sel_field[PLL0_REFCLK])) { in wiz_regfield_init()
585 return PTR_ERR(wiz->mux_sel_field[PLL0_REFCLK]); in wiz_regfield_init()
588 wiz->mux_sel_field[PLL1_REFCLK] = in wiz_regfield_init()
589 devm_regmap_field_alloc(dev, scm_regmap, *data->pll1_refclk_mux_sel); in wiz_regfield_init()
590 if (IS_ERR(wiz->mux_sel_field[PLL1_REFCLK])) { in wiz_regfield_init()
592 return PTR_ERR(wiz->mux_sel_field[PLL1_REFCLK]); in wiz_regfield_init()
595 wiz->mux_sel_field[REFCLK_DIG] = devm_regmap_field_alloc(dev, scm_regmap, in wiz_regfield_init()
596 *data->refclk_dig_sel); in wiz_regfield_init()
597 if (IS_ERR(wiz->mux_sel_field[REFCLK_DIG])) { in wiz_regfield_init()
599 return PTR_ERR(wiz->mux_sel_field[REFCLK_DIG]); in wiz_regfield_init()
602 if (data->pma_cmn_refclk1_int_mode) { in wiz_regfield_init()
603 wiz->pma_cmn_refclk1_int_mode = in wiz_regfield_init()
604 devm_regmap_field_alloc(dev, scm_regmap, *data->pma_cmn_refclk1_int_mode); in wiz_regfield_init()
605 if (IS_ERR(wiz->pma_cmn_refclk1_int_mode)) { in wiz_regfield_init()
607 return PTR_ERR(wiz->pma_cmn_refclk1_int_mode); in wiz_regfield_init()
612 wiz->p_enable[i] = devm_regmap_field_alloc(dev, regmap, in wiz_regfield_init()
614 if (IS_ERR(wiz->p_enable[i])) { in wiz_regfield_init()
616 return PTR_ERR(wiz->p_enable[i]); in wiz_regfield_init()
619 wiz->p_align[i] = devm_regmap_field_alloc(dev, regmap, in wiz_regfield_init()
621 if (IS_ERR(wiz->p_align[i])) { in wiz_regfield_init()
623 return PTR_ERR(wiz->p_align[i]); in wiz_regfield_init()
626 wiz->p_raw_auto_start[i] = in wiz_regfield_init()
628 if (IS_ERR(wiz->p_raw_auto_start[i])) { in wiz_regfield_init()
631 return PTR_ERR(wiz->p_raw_auto_start[i]); in wiz_regfield_init()
634 wiz->p_standard_mode[i] = in wiz_regfield_init()
636 if (IS_ERR(wiz->p_standard_mode[i])) { in wiz_regfield_init()
639 return PTR_ERR(wiz->p_standard_mode[i]); in wiz_regfield_init()
642 wiz->p0_fullrt_div[i] = devm_regmap_field_alloc(dev, regmap, p0_fullrt_div[i]); in wiz_regfield_init()
643 if (IS_ERR(wiz->p0_fullrt_div[i])) { in wiz_regfield_init()
645 return PTR_ERR(wiz->p0_fullrt_div[i]); in wiz_regfield_init()
648 wiz->p0_mac_src_sel[i] = devm_regmap_field_alloc(dev, regmap, p0_mac_src_sel[i]); in wiz_regfield_init()
649 if (IS_ERR(wiz->p0_mac_src_sel[i])) { in wiz_regfield_init()
651 return PTR_ERR(wiz->p0_mac_src_sel[i]); in wiz_regfield_init()
654 wiz->p0_rxfclk_sel[i] = devm_regmap_field_alloc(dev, regmap, p0_rxfclk_sel[i]); in wiz_regfield_init()
655 if (IS_ERR(wiz->p0_rxfclk_sel[i])) { in wiz_regfield_init()
657 return PTR_ERR(wiz->p0_rxfclk_sel[i]); in wiz_regfield_init()
660 wiz->p0_refclk_sel[i] = devm_regmap_field_alloc(dev, regmap, p0_refclk_sel[i]); in wiz_regfield_init()
661 if (IS_ERR(wiz->p0_refclk_sel[i])) { in wiz_regfield_init()
663 return PTR_ERR(wiz->p0_refclk_sel[i]); in wiz_regfield_init()
666 wiz->p_mac_div_sel0[i] = in wiz_regfield_init()
668 if (IS_ERR(wiz->p_mac_div_sel0[i])) { in wiz_regfield_init()
671 return PTR_ERR(wiz->p_mac_div_sel0[i]); in wiz_regfield_init()
674 wiz->p_mac_div_sel1[i] = in wiz_regfield_init()
676 if (IS_ERR(wiz->p_mac_div_sel1[i])) { in wiz_regfield_init()
679 return PTR_ERR(wiz->p_mac_div_sel1[i]); in wiz_regfield_init()
683 wiz->typec_ln10_swap = devm_regmap_field_alloc(dev, regmap, in wiz_regfield_init()
685 if (IS_ERR(wiz->typec_ln10_swap)) { in wiz_regfield_init()
687 return PTR_ERR(wiz->typec_ln10_swap); in wiz_regfield_init()
690 wiz->typec_ln23_swap = devm_regmap_field_alloc(dev, regmap, in wiz_regfield_init()
692 if (IS_ERR(wiz->typec_ln23_swap)) { in wiz_regfield_init()
694 return PTR_ERR(wiz->typec_ln23_swap); in wiz_regfield_init()
697 wiz->phy_en_refclk = devm_regmap_field_alloc(dev, regmap, phy_en_refclk); in wiz_regfield_init()
698 if (IS_ERR(wiz->phy_en_refclk)) { in wiz_regfield_init()
700 return PTR_ERR(wiz->phy_en_refclk); in wiz_regfield_init()
709 struct regmap_field *phy_en_refclk = wiz_phy_en_refclk->phy_en_refclk; in wiz_phy_en_refclk_enable()
719 struct regmap_field *phy_en_refclk = wiz_phy_en_refclk->phy_en_refclk; in wiz_phy_en_refclk_disable()
727 struct regmap_field *phy_en_refclk = wiz_phy_en_refclk->phy_en_refclk; in wiz_phy_en_refclk_is_enabled()
744 struct device *dev = wiz->dev; in wiz_phy_en_refclk_register()
746 struct clk *clk; in wiz_phy_en_refclk_register() local
752 return -ENOMEM; in wiz_phy_en_refclk_register()
754 init = &wiz_phy_en_refclk->clk_data; in wiz_phy_en_refclk_register()
756 init->ops = &wiz_phy_en_refclk_ops; in wiz_phy_en_refclk_register()
757 init->flags = 0; in wiz_phy_en_refclk_register()
763 return -ENOMEM; in wiz_phy_en_refclk_register()
766 init->name = clk_name; in wiz_phy_en_refclk_register()
768 wiz_phy_en_refclk->phy_en_refclk = wiz->phy_en_refclk; in wiz_phy_en_refclk_register()
769 wiz_phy_en_refclk->hw.init = init; in wiz_phy_en_refclk_register()
771 clk = devm_clk_register(dev, &wiz_phy_en_refclk->hw); in wiz_phy_en_refclk_register()
775 if (IS_ERR(clk)) in wiz_phy_en_refclk_register()
776 return PTR_ERR(clk); in wiz_phy_en_refclk_register()
778 wiz->output_clks[TI_WIZ_PHY_EN_REFCLK] = clk; in wiz_phy_en_refclk_register()
786 struct regmap_field *field = mux->field; in wiz_clk_mux_get_parent()
790 return clk_mux_val_to_index(hw, (u32 *)mux->table, 0, val); in wiz_clk_mux_get_parent()
796 struct regmap_field *field = mux->field; in wiz_clk_mux_set_parent()
799 val = mux->table[index]; in wiz_clk_mux_set_parent()
812 struct device *dev = wiz->dev; in wiz_mux_clk_register()
818 struct clk *clk; in wiz_mux_clk_register() local
823 return -ENOMEM; in wiz_mux_clk_register()
825 num_parents = mux_sel->num_parents; in wiz_mux_clk_register()
829 return -ENOMEM; in wiz_mux_clk_register()
832 clk = wiz->input_clks[mux_sel->parents[i]]; in wiz_mux_clk_register()
833 if (IS_ERR_OR_NULL(clk)) { in wiz_mux_clk_register()
834 dev_err(dev, "Failed to get parent clk for %s\n", in wiz_mux_clk_register()
836 ret = -EINVAL; in wiz_mux_clk_register()
839 parent_names[i] = __clk_get_name(clk); in wiz_mux_clk_register()
844 init = &mux->clk_data; in wiz_mux_clk_register()
846 init->ops = &wiz_clk_mux_ops; in wiz_mux_clk_register()
847 init->flags = CLK_SET_RATE_NO_REPARENT; in wiz_mux_clk_register()
848 init->parent_names = parent_names; in wiz_mux_clk_register()
849 init->num_parents = num_parents; in wiz_mux_clk_register()
850 init->name = clk_name; in wiz_mux_clk_register()
852 mux->field = field; in wiz_mux_clk_register()
853 mux->table = mux_sel->table; in wiz_mux_clk_register()
854 mux->hw.init = init; in wiz_mux_clk_register()
856 clk = devm_clk_register(dev, &mux->hw); in wiz_mux_clk_register()
857 if (IS_ERR(clk)) { in wiz_mux_clk_register()
858 ret = PTR_ERR(clk); in wiz_mux_clk_register()
862 wiz->output_clks[clk_index] = clk; in wiz_mux_clk_register()
873 struct device *dev = wiz->dev; in wiz_mux_of_clk_register()
879 struct clk *clk; in wiz_mux_of_clk_register() local
884 return -ENOMEM; in wiz_mux_of_clk_register()
888 dev_err(dev, "SERDES clock must have parents\n"); in wiz_mux_of_clk_register()
889 return -EINVAL; in wiz_mux_of_clk_register()
895 return -ENOMEM; in wiz_mux_of_clk_register()
900 node->name); in wiz_mux_of_clk_register()
902 init = &mux->clk_data; in wiz_mux_of_clk_register()
904 init->ops = &wiz_clk_mux_ops; in wiz_mux_of_clk_register()
905 init->flags = CLK_SET_RATE_NO_REPARENT; in wiz_mux_of_clk_register()
906 init->parent_names = parent_names; in wiz_mux_of_clk_register()
907 init->num_parents = num_parents; in wiz_mux_of_clk_register()
908 init->name = clk_name; in wiz_mux_of_clk_register()
910 mux->field = field; in wiz_mux_of_clk_register()
911 mux->table = table; in wiz_mux_of_clk_register()
912 mux->hw.init = init; in wiz_mux_of_clk_register()
914 clk = devm_clk_register(dev, &mux->hw); in wiz_mux_of_clk_register()
915 if (IS_ERR(clk)) in wiz_mux_of_clk_register()
916 return PTR_ERR(clk); in wiz_mux_of_clk_register()
918 ret = of_clk_add_provider(node, of_clk_src_simple_get, clk); in wiz_mux_of_clk_register()
929 struct regmap_field *field = div->field; in wiz_clk_div_recalc_rate()
934 return divider_recalc_rate(hw, parent_rate, val, div->table, 0x0, 2); in wiz_clk_div_recalc_rate()
942 return divider_round_rate(hw, rate, prate, div->table, 2, 0x0); in wiz_clk_div_round_rate()
949 struct regmap_field *field = div->field; in wiz_clk_div_set_rate()
952 val = divider_get_val(rate, parent_rate, div->table, 2, 0x0); in wiz_clk_div_set_rate()
969 struct device *dev = wiz->dev; in wiz_div_clk_register()
974 struct clk *clk; in wiz_div_clk_register() local
979 return -ENOMEM; in wiz_div_clk_register()
982 node->name); in wiz_div_clk_register()
986 return -ENOMEM; in wiz_div_clk_register()
990 init = &div->clk_data; in wiz_div_clk_register()
992 init->ops = &wiz_clk_div_ops; in wiz_div_clk_register()
993 init->flags = 0; in wiz_div_clk_register()
994 init->parent_names = parent_names; in wiz_div_clk_register()
995 init->num_parents = 1; in wiz_div_clk_register()
996 init->name = clk_name; in wiz_div_clk_register()
998 div->field = field; in wiz_div_clk_register()
999 div->table = table; in wiz_div_clk_register()
1000 div->hw.init = init; in wiz_div_clk_register()
1002 clk = devm_clk_register(dev, &div->hw); in wiz_div_clk_register()
1003 if (IS_ERR(clk)) in wiz_div_clk_register()
1004 return PTR_ERR(clk); in wiz_div_clk_register()
1006 ret = of_clk_add_provider(node, of_clk_src_simple_get, clk); in wiz_div_clk_register()
1015 const struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel; in wiz_clock_cleanup()
1016 struct device *dev = wiz->dev; in wiz_clock_cleanup()
1020 switch (wiz->type) { in wiz_clock_cleanup()
1025 of_clk_del_provider(dev->of_node); in wiz_clock_cleanup()
1037 for (i = 0; i < wiz->clk_div_sel_num; i++) { in wiz_clock_cleanup()
1043 of_clk_del_provider(wiz->dev->of_node); in wiz_clock_cleanup()
1048 const struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel; in wiz_clock_register()
1049 struct device *dev = wiz->dev; in wiz_clock_register()
1050 struct device_node *node = dev->of_node; in wiz_clock_register()
1057 ret = wiz_mux_clk_register(wiz, wiz->mux_sel_field[i], &clk_mux_sel[i], clk_index); in wiz_clock_register()
1059 dev_err(dev, "Failed to register clk: %s\n", output_clk_names[clk_index]); in wiz_clock_register()
1066 dev_err(dev, "Failed to add phy-en-refclk\n"); in wiz_clock_register()
1070 wiz->clk_data.clks = wiz->output_clks; in wiz_clock_register()
1071 wiz->clk_data.clk_num = WIZ_MAX_OUTPUT_CLOCKS; in wiz_clock_register()
1072 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &wiz->clk_data); in wiz_clock_register()
1074 dev_err(dev, "Failed to add clock provider: %s\n", node->name); in wiz_clock_register()
1083 rate = clk_get_rate(wiz->input_clks[WIZ_CORE_REFCLK]); in wiz_clock_init()
1085 regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x1); in wiz_clock_init()
1087 regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x3); in wiz_clock_init()
1089 switch (wiz->type) { in wiz_clock_init()
1094 regmap_field_write(wiz->div_sel_field[CMN_REFCLK_DIG_DIV], 0x2); in wiz_clock_init()
1097 regmap_field_write(wiz->div_sel_field[CMN_REFCLK_DIG_DIV], 0x3); in wiz_clock_init()
1100 regmap_field_write(wiz->div_sel_field[CMN_REFCLK_DIG_DIV], 0); in wiz_clock_init()
1108 if (wiz->input_clks[WIZ_CORE_REFCLK1]) { in wiz_clock_init()
1109 rate = clk_get_rate(wiz->input_clks[WIZ_CORE_REFCLK1]); in wiz_clock_init()
1111 regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); in wiz_clock_init()
1113 regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); in wiz_clock_init()
1116 rate = clk_get_rate(wiz->input_clks[WIZ_EXT_REFCLK]); in wiz_clock_init()
1118 regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0); in wiz_clock_init()
1120 regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); in wiz_clock_init()
1125 const struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel; in wiz_clock_probe()
1126 struct device *dev = wiz->dev; in wiz_clock_probe()
1129 struct clk *clk; in wiz_clock_probe() local
1133 clk = devm_clk_get(dev, "core_ref_clk"); in wiz_clock_probe()
1134 if (IS_ERR(clk)) in wiz_clock_probe()
1135 return dev_err_probe(dev, PTR_ERR(clk), in wiz_clock_probe()
1138 wiz->input_clks[WIZ_CORE_REFCLK] = clk; in wiz_clock_probe()
1140 if (wiz->data->pma_cmn_refclk1_int_mode) { in wiz_clock_probe()
1141 clk = devm_clk_get(dev, "core_ref1_clk"); in wiz_clock_probe()
1142 if (IS_ERR(clk)) in wiz_clock_probe()
1143 return dev_err_probe(dev, PTR_ERR(clk), in wiz_clock_probe()
1146 wiz->input_clks[WIZ_CORE_REFCLK1] = clk; in wiz_clock_probe()
1149 clk = devm_clk_get(dev, "ext_ref_clk"); in wiz_clock_probe()
1150 if (IS_ERR(clk)) in wiz_clock_probe()
1151 return dev_err_probe(dev, PTR_ERR(clk), in wiz_clock_probe()
1154 wiz->input_clks[WIZ_EXT_REFCLK] = clk; in wiz_clock_probe()
1158 switch (wiz->type) { in wiz_clock_probe()
1176 ret = dev_err_probe(dev, -EINVAL, "Unable to get %s node\n", node_name); in wiz_clock_probe()
1180 ret = wiz_mux_of_clk_register(wiz, clk_node, wiz->mux_sel_field[i], in wiz_clock_probe()
1191 for (i = 0; i < wiz->clk_div_sel_num; i++) { in wiz_clock_probe()
1195 ret = dev_err_probe(dev, -EINVAL, "Unable to get %s node\n", node_name); in wiz_clock_probe()
1199 ret = wiz_div_clk_register(wiz, clk_node, wiz->div_sel_field[i], in wiz_clock_probe()
1219 struct device *dev = rcdev->dev; in wiz_phy_reset_assert()
1224 ret = regmap_field_write(wiz->phy_reset_n, false); in wiz_phy_reset_assert()
1228 ret = regmap_field_write(wiz->p_enable[id - 1], P_ENABLE_DISABLE); in wiz_phy_reset_assert()
1234 switch (wiz->type) { in wiz_phy_fullrt_div()
1236 if (wiz->lane_phy_type[lane] == PHY_TYPE_PCIE) in wiz_phy_fullrt_div()
1237 return regmap_field_write(wiz->p0_fullrt_div[lane], 0x1); in wiz_phy_fullrt_div()
1245 if (wiz->lane_phy_type[lane] == PHY_TYPE_SGMII) in wiz_phy_fullrt_div()
1246 return regmap_field_write(wiz->p0_fullrt_div[lane], 0x2); in wiz_phy_fullrt_div()
1257 struct device *dev = rcdev->dev; in wiz_phy_reset_deassert()
1262 /* if typec-dir gpio was specified, set LN10 SWAP bit based on that */ in wiz_phy_reset_deassert()
1263 if (wiz->gpio_typec_dir) { in wiz_phy_reset_deassert()
1264 if (wiz->typec_dir_delay) in wiz_phy_reset_deassert()
1265 msleep_interruptible(wiz->typec_dir_delay); in wiz_phy_reset_deassert()
1267 if (gpiod_get_value_cansleep(wiz->gpio_typec_dir)) in wiz_phy_reset_deassert()
1268 regmap_field_write(wiz->typec_ln10_swap, 1); in wiz_phy_reset_deassert()
1270 regmap_field_write(wiz->typec_ln10_swap, 0); in wiz_phy_reset_deassert()
1272 /* if no typec-dir gpio is specified and PHY type is USB3 in wiz_phy_reset_deassert()
1276 u32 num_lanes = wiz->num_lanes; in wiz_phy_reset_deassert()
1280 if (wiz->lane_phy_type[i] == PHY_TYPE_USB3) { in wiz_phy_reset_deassert()
1281 switch (wiz->master_lane_num[i]) { in wiz_phy_reset_deassert()
1283 regmap_field_write(wiz->typec_ln10_swap, 1); in wiz_phy_reset_deassert()
1286 regmap_field_write(wiz->typec_ln23_swap, 1); in wiz_phy_reset_deassert()
1297 ret = regmap_field_write(wiz->phy_reset_n, true); in wiz_phy_reset_deassert()
1301 ret = wiz_phy_fullrt_div(wiz, id - 1); in wiz_phy_reset_deassert()
1305 if (wiz->lane_phy_type[id - 1] == PHY_TYPE_DP) in wiz_phy_reset_deassert()
1306 ret = regmap_field_write(wiz->p_enable[id - 1], P_ENABLE); in wiz_phy_reset_deassert()
1308 ret = regmap_field_write(wiz->p_enable[id - 1], P_ENABLE_FORCE); in wiz_phy_reset_deassert()
1384 .compatible = "ti,j721e-wiz-16g", .data = &j721e_16g_data,
1387 .compatible = "ti,j721e-wiz-10g", .data = &j721e_10g_data,
1390 .compatible = "ti,am64-wiz-10g", .data = &am64_10g_data,
1393 .compatible = "ti,j7200-wiz-10g", .data = &j7200_pg2_10g_data,
1396 .compatible = "ti,j784s4-wiz-10g", .data = &j784s4_10g_data,
1399 .compatible = "ti,j721s2-wiz-10g", .data = &j721s2_10g_data,
1407 struct device_node *serdes; in wiz_get_lane_phy_types() local
1409 serdes = of_get_child_by_name(dev->of_node, "serdes"); in wiz_get_lane_phy_types()
1410 if (!serdes) { in wiz_get_lane_phy_types()
1411 dev_err(dev, "%s: Getting \"serdes\"-node failed\n", __func__); in wiz_get_lane_phy_types()
1412 return -EINVAL; in wiz_get_lane_phy_types()
1415 for_each_child_of_node_scoped(serdes, subnode) { in wiz_get_lane_phy_types()
1427 __func__, subnode->name, ret); in wiz_get_lane_phy_types()
1430 of_property_read_u32(subnode, "cdns,num-lanes", &num_lanes); in wiz_get_lane_phy_types()
1431 of_property_read_u32(subnode, "cdns,phy-type", &phy_type); in wiz_get_lane_phy_types()
1433 dev_dbg(dev, "%s: Lanes %u-%u have phy-type %u\n", __func__, in wiz_get_lane_phy_types()
1434 reg, reg + num_lanes - 1, phy_type); in wiz_get_lane_phy_types()
1437 wiz->master_lane_num[i] = reg; in wiz_get_lane_phy_types()
1438 wiz->lane_phy_type[i] = phy_type; in wiz_get_lane_phy_types()
1448 struct device *dev = &pdev->dev; in wiz_probe()
1449 struct device_node *node = dev->of_node; in wiz_probe()
1463 return -ENOMEM; in wiz_probe()
1468 return -EINVAL; in wiz_probe()
1471 wiz->data = data; in wiz_probe()
1472 wiz->type = data->type; in wiz_probe()
1474 child_node = of_get_child_by_name(node, "serdes"); in wiz_probe()
1476 dev_err(dev, "Failed to get SERDES child DT node\n"); in wiz_probe()
1477 return -ENODEV; in wiz_probe()
1488 ret = -ENOMEM; in wiz_probe()
1499 wiz->scm_regmap = syscon_regmap_lookup_by_phandle(node, "ti,scm"); in wiz_probe()
1500 if (IS_ERR(wiz->scm_regmap)) { in wiz_probe()
1501 if (wiz->type == J7200_WIZ_10G) { in wiz_probe()
1503 ret = -ENODEV; in wiz_probe()
1507 wiz->scm_regmap = NULL; in wiz_probe()
1510 ret = of_property_read_u32(node, "num-lanes", &num_lanes); in wiz_probe()
1512 dev_err(dev, "Failed to read num-lanes property\n"); in wiz_probe()
1518 ret = -ENODEV; in wiz_probe()
1522 wiz->gpio_typec_dir = devm_gpiod_get_optional(dev, "typec-dir", in wiz_probe()
1524 if (IS_ERR(wiz->gpio_typec_dir)) { in wiz_probe()
1525 ret = PTR_ERR(wiz->gpio_typec_dir); in wiz_probe()
1526 if (ret != -EPROBE_DEFER) in wiz_probe()
1527 dev_err(dev, "Failed to request typec-dir gpio: %d\n", in wiz_probe()
1532 if (wiz->gpio_typec_dir) { in wiz_probe()
1533 ret = of_property_read_u32(node, "typec-dir-debounce-ms", in wiz_probe()
1534 &wiz->typec_dir_delay); in wiz_probe()
1535 if (ret && ret != -EINVAL) { in wiz_probe()
1536 dev_err(dev, "Invalid typec-dir-debounce property\n"); in wiz_probe()
1540 /* use min. debounce from Type-C spec if not provided in DT */ in wiz_probe()
1541 if (ret == -EINVAL) in wiz_probe()
1542 wiz->typec_dir_delay = WIZ_TYPEC_DIR_DEBOUNCE_MIN; in wiz_probe()
1544 if (wiz->typec_dir_delay < WIZ_TYPEC_DIR_DEBOUNCE_MIN || in wiz_probe()
1545 wiz->typec_dir_delay > WIZ_TYPEC_DIR_DEBOUNCE_MAX) { in wiz_probe()
1546 ret = -EINVAL; in wiz_probe()
1547 dev_err(dev, "Invalid typec-dir-debounce property\n"); in wiz_probe()
1556 wiz->dev = dev; in wiz_probe()
1557 wiz->regmap = regmap; in wiz_probe()
1558 wiz->num_lanes = num_lanes; in wiz_probe()
1559 wiz->clk_mux_sel = data->clk_mux_sel; in wiz_probe()
1560 wiz->clk_div_sel = clk_div_sel; in wiz_probe()
1561 wiz->clk_div_sel_num = data->clk_div_sel_num; in wiz_probe()
1572 if (wiz->scm_regmap) in wiz_probe()
1573 regmap_field_write(wiz->sup_legacy_clk_override, 1); in wiz_probe()
1575 phy_reset_dev = &wiz->wiz_phy_reset_dev; in wiz_probe()
1576 phy_reset_dev->dev = dev; in wiz_probe()
1577 phy_reset_dev->ops = &wiz_phy_reset_ops; in wiz_probe()
1578 phy_reset_dev->owner = THIS_MODULE; in wiz_probe()
1579 phy_reset_dev->of_node = node; in wiz_probe()
1580 /* Reset for each of the lane and one for the entire SERDES */ in wiz_probe()
1581 phy_reset_dev->nr_resets = num_lanes + 1; in wiz_probe()
1602 for (i = 0; i < wiz->num_lanes; i++) { in wiz_probe()
1603 regmap_field_read(wiz->p_enable[i], &val); in wiz_probe()
1620 dev_WARN(dev, "Unable to create SERDES platform device\n"); in wiz_probe()
1621 ret = -ENOMEM; in wiz_probe()
1624 wiz->serdes_pdev = serdes_pdev; in wiz_probe()
1644 struct device *dev = &pdev->dev; in wiz_remove()
1645 struct device_node *node = dev->of_node; in wiz_remove()
1650 serdes_pdev = wiz->serdes_pdev; in wiz_remove()
1652 of_platform_device_destroy(&serdes_pdev->dev, NULL); in wiz_remove()
1660 struct device_node *node = dev->of_node; in wiz_resume_noirq()
1665 if (wiz->sup_legacy_clk_override) in wiz_resume_noirq()
1666 regmap_field_write(wiz->sup_legacy_clk_override, 1); in wiz_resume_noirq()