• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionea3e163f21b65420f0a8e17af519006e69904b43 (tree)
Time2022-07-25 22:38:47
AuthorMatt Ranostay <mranostay@ti.c...>
CommiterTom Rini

Log Message

phy: ti: j721e-wiz: use OF data for device specific data

Move device specific data into OF data structure so it
is easier to maintain and we can get rid of if statements.

Based on: https://lore.kernel.org/linux-phy/20220526064121.27625-1-rogerq@kernel.org/T/#u

Cc: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Matt Ranostay <mranostay@ti.com>

Change Summary

Incremental Difference

--- a/drivers/phy/ti/phy-j721e-wiz.c
+++ b/drivers/phy/ti/phy-j721e-wiz.c
@@ -221,6 +221,44 @@ enum wiz_type {
221221 AM64_WIZ_10G,
222222 };
223223
224+struct wiz_data {
225+ enum wiz_type type;
226+ const struct reg_field *pll0_refclk_mux_sel;
227+ const struct reg_field *pll1_refclk_mux_sel;
228+ const struct reg_field *refclk_dig_sel;
229+ const struct reg_field *pma_cmn_refclk1_dig_div;
230+ const struct wiz_clk_mux_sel *clk_mux_sel;
231+ unsigned int clk_div_sel_num;
232+};
233+
234+static const struct wiz_data j721e_16g_data = {
235+ .type = J721E_WIZ_16G,
236+ .pll0_refclk_mux_sel = &pll0_refclk_mux_sel,
237+ .pll1_refclk_mux_sel = &pll1_refclk_mux_sel,
238+ .refclk_dig_sel = &refclk_dig_sel_16g,
239+ .pma_cmn_refclk1_dig_div = &pma_cmn_refclk1_dig_div,
240+ .clk_mux_sel = clk_mux_sel_16g,
241+ .clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_16G,
242+};
243+
244+static const struct wiz_data j721e_10g_data = {
245+ .type = J721E_WIZ_10G,
246+ .pll0_refclk_mux_sel = &pll0_refclk_mux_sel,
247+ .pll1_refclk_mux_sel = &pll1_refclk_mux_sel,
248+ .refclk_dig_sel = &refclk_dig_sel_10g,
249+ .clk_mux_sel = clk_mux_sel_10g,
250+ .clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G,
251+};
252+
253+static struct wiz_data am64_10g_data = {
254+ .type = AM64_WIZ_10G,
255+ .pll0_refclk_mux_sel = &pll0_refclk_mux_sel,
256+ .pll1_refclk_mux_sel = &pll1_refclk_mux_sel,
257+ .refclk_dig_sel = &refclk_dig_sel_10g,
258+ .clk_mux_sel = clk_mux_sel_10g,
259+ .clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G,
260+};
261+
224262 #define WIZ_TYPEC_DIR_DEBOUNCE_MIN 100 /* ms */
225263 #define WIZ_TYPEC_DIR_DEBOUNCE_MAX 1000
226264
@@ -253,6 +291,7 @@ struct wiz {
253291 u32 lane_phy_type[WIZ_MAX_LANES];
254292 struct clk *input_clks[WIZ_MAX_INPUT_CLOCKS];
255293 unsigned int id;
294+ const struct wiz_data *data;
256295 };
257296
258297 struct wiz_div_clk {
@@ -667,7 +706,7 @@ static int wiz_regfield_init(struct wiz *wiz)
667706 struct regmap *regmap = wiz->regmap;
668707 int num_lanes = wiz->num_lanes;
669708 struct udevice *dev = wiz->dev;
670- enum wiz_type type;
709+ const struct wiz_data *data = wiz->data;
671710 int i;
672711
673712 wiz->por_en = devm_regmap_field_alloc(dev, regmap, por_en);
@@ -704,36 +743,31 @@ static int wiz_regfield_init(struct wiz *wiz)
704743 return PTR_ERR(wiz->div_sel_field[CMN_REFCLK]);
705744 }
706745
707- wiz->div_sel_field[CMN_REFCLK1] =
708- devm_regmap_field_alloc(dev, regmap, pma_cmn_refclk1_dig_div);
709- if (IS_ERR(wiz->div_sel_field[CMN_REFCLK1])) {
710- dev_err(dev, "PMA_CMN_REFCLK1_DIG_DIV reg field init failed\n");
711- return PTR_ERR(wiz->div_sel_field[CMN_REFCLK1]);
746+ if (data->pma_cmn_refclk1_dig_div) {
747+ wiz->div_sel_field[CMN_REFCLK1] =
748+ devm_regmap_field_alloc(dev, regmap, *data->pma_cmn_refclk1_dig_div);
749+ if (IS_ERR(wiz->div_sel_field[CMN_REFCLK1])) {
750+ dev_err(dev, "PMA_CMN_REFCLK1_DIG_DIV reg field init failed\n");
751+ return PTR_ERR(wiz->div_sel_field[CMN_REFCLK1]);
752+ }
712753 }
713754
714755 wiz->mux_sel_field[PLL0_REFCLK] =
715- devm_regmap_field_alloc(dev, regmap, pll0_refclk_mux_sel);
756+ devm_regmap_field_alloc(dev, regmap, *data->pll0_refclk_mux_sel);
716757 if (IS_ERR(wiz->mux_sel_field[PLL0_REFCLK])) {
717758 dev_err(dev, "PLL0_REFCLK_SEL reg field init failed\n");
718759 return PTR_ERR(wiz->mux_sel_field[PLL0_REFCLK]);
719760 }
720761
721762 wiz->mux_sel_field[PLL1_REFCLK] =
722- devm_regmap_field_alloc(dev, regmap, pll1_refclk_mux_sel);
763+ devm_regmap_field_alloc(dev, regmap, *data->pll1_refclk_mux_sel);
723764 if (IS_ERR(wiz->mux_sel_field[PLL1_REFCLK])) {
724765 dev_err(dev, "PLL1_REFCLK_SEL reg field init failed\n");
725766 return PTR_ERR(wiz->mux_sel_field[PLL1_REFCLK]);
726767 }
727768
728- type = dev_get_driver_data(dev);
729- if (type == J721E_WIZ_10G || type == AM64_WIZ_10G)
730- wiz->mux_sel_field[REFCLK_DIG] =
731- devm_regmap_field_alloc(dev, regmap,
732- refclk_dig_sel_10g);
733- else
734- wiz->mux_sel_field[REFCLK_DIG] =
735- devm_regmap_field_alloc(dev, regmap,
736- refclk_dig_sel_16g);
769+ wiz->mux_sel_field[REFCLK_DIG] =
770+ devm_regmap_field_alloc(dev, regmap, *data->refclk_dig_sel);
737771 if (IS_ERR(wiz->mux_sel_field[REFCLK_DIG])) {
738772 dev_err(dev, "REFCLK_DIG_SEL reg field init failed\n");
739773 return PTR_ERR(wiz->mux_sel_field[REFCLK_DIG]);
@@ -1059,14 +1093,12 @@ static int j721e_wiz_probe(struct udevice *dev)
10591093 wiz->num_lanes = num_lanes;
10601094 wiz->dev = dev;
10611095 wiz->clk_div_sel = clk_div_sel;
1062- wiz->type = dev_get_driver_data(dev);
1063- if (wiz->type == J721E_WIZ_10G || wiz->type == AM64_WIZ_10G) {
1064- wiz->clk_mux_sel = clk_mux_sel_10g;
1065- wiz->clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G;
1066- } else {
1067- wiz->clk_mux_sel = clk_mux_sel_16g;
1068- wiz->clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_16G;
1069- }
1096+
1097+ wiz->data = (struct wiz_data *)dev_get_driver_data(dev);
1098+ wiz->type = wiz->data->type;
1099+
1100+ wiz->clk_mux_sel = (struct wiz_clk_mux_sel *)wiz->data->clk_mux_sel;
1101+ wiz->clk_div_sel_num = wiz->data->clk_div_sel_num;
10701102
10711103 rc = wiz_get_lane_phy_types(dev, wiz);
10721104 if (rc) {
@@ -1133,13 +1165,13 @@ static int j721e_wiz_remove(struct udevice *dev)
11331165
11341166 static const struct udevice_id j721e_wiz_ids[] = {
11351167 {
1136- .compatible = "ti,j721e-wiz-16g", .data = J721E_WIZ_16G,
1168+ .compatible = "ti,j721e-wiz-16g", .data = (ulong)&j721e_16g_data,
11371169 },
11381170 {
1139- .compatible = "ti,j721e-wiz-10g", .data = J721E_WIZ_10G,
1171+ .compatible = "ti,j721e-wiz-10g", .data = (ulong)&j721e_10g_data,
11401172 },
11411173 {
1142- .compatible = "ti,am64-wiz-10g", .data = AM64_WIZ_10G,
1174+ .compatible = "ti,am64-wiz-10g", .data = (ulong)&am64_10g_data,
11431175 },
11441176 {}
11451177 };