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

clk: st: clkgen-pll: embed soc clock outputs within compatible data

In order to avoid relying on the old style description via the DT
clock-output-names, add compatible data describing the flexgen
outputs clocks for all STiH407/STiH410 and STiH418 SOCs.

In order to ease transition between the two methods, this commit
introduce the new compatible without removing the old method.
Once DTs will be fixed, the method relying on DT clock-output-names
will be removed from this driver as well as old compatibles.

Signed-off-by: Alain Volmat <avolmat@me.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://lore.kernel.org/r/20210331201632.24530-5-avolmat@me.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Alain Volmat and committed by
Stephen Boyd
92ef1b2b fa745c71

+106 -14
+106 -14
drivers/clk/st/clkgen-pll.c
··· 57 57 const struct clk_ops *ops; 58 58 }; 59 59 60 + struct clkgen_clk_out { 61 + const char *name; 62 + unsigned long flags; 63 + }; 64 + 65 + struct clkgen_pll_data_clks { 66 + struct clkgen_pll_data *data; 67 + const struct clkgen_clk_out *outputs; 68 + }; 69 + 70 + 60 71 static const struct clk_ops stm_pll3200c32_ops; 61 72 static const struct clk_ops stm_pll3200c32_a9_ops; 62 73 static const struct clk_ops stm_pll4600c28_ops; ··· 85 74 .ops = &stm_pll3200c32_ops, 86 75 }; 87 76 77 + static const struct clkgen_pll_data_clks st_pll3200c32_cx_0_legacy_data = { 78 + .data = (struct clkgen_pll_data *)&st_pll3200c32_cx_0, 79 + }; 80 + 81 + static const struct clkgen_clk_out st_pll3200c32_ax_0_clks[] = { 82 + { .name = "clk-s-a0-pll-odf-0", }, 83 + }; 84 + 85 + static const struct clkgen_pll_data_clks st_pll3200c32_a0_data = { 86 + .data = (struct clkgen_pll_data *)&st_pll3200c32_cx_0, 87 + .outputs = st_pll3200c32_ax_0_clks, 88 + }; 89 + 90 + static const struct clkgen_clk_out st_pll3200c32_cx_0_clks[] = { 91 + { .name = "clk-s-c0-pll0-odf-0", }, 92 + }; 93 + 94 + static const struct clkgen_pll_data_clks st_pll3200c32_c0_data = { 95 + .data = (struct clkgen_pll_data *)&st_pll3200c32_cx_0, 96 + .outputs = st_pll3200c32_cx_0_clks, 97 + }; 98 + 88 99 static const struct clkgen_pll_data st_pll3200c32_cx_1 = { 89 100 /* 407 C0 PLL1 */ 90 101 .pdn_status = CLKGEN_FIELD(0x2c8, 0x1, 8), ··· 118 85 .odf = { CLKGEN_FIELD(0x2dc, C32_ODF_MASK, 0) }, 119 86 .odf_gate = { CLKGEN_FIELD(0x2dc, 0x1, 6) }, 120 87 .ops = &stm_pll3200c32_ops, 88 + }; 89 + 90 + static const struct clkgen_pll_data_clks st_pll3200c32_cx_1_legacy_data = { 91 + .data = (struct clkgen_pll_data *)&st_pll3200c32_cx_1, 92 + }; 93 + 94 + static const struct clkgen_clk_out st_pll3200c32_cx_1_clks[] = { 95 + { .name = "clk-s-c0-pll1-odf-0", }, 96 + }; 97 + 98 + static const struct clkgen_pll_data_clks st_pll3200c32_c1_data = { 99 + .data = (struct clkgen_pll_data *)&st_pll3200c32_cx_1, 100 + .outputs = st_pll3200c32_cx_1_clks, 121 101 }; 122 102 123 103 static const struct clkgen_pll_data st_pll3200c32_407_a9 = { ··· 150 104 .ops = &stm_pll3200c32_a9_ops, 151 105 }; 152 106 107 + static const struct clkgen_clk_out st_pll3200c32_407_a9_clks[] = { 108 + { .name = "clockgen-a9-pll-odf", }, 109 + }; 110 + 111 + static const struct clkgen_pll_data_clks st_pll3200c32_407_a9_data = { 112 + .data = (struct clkgen_pll_data *)&st_pll3200c32_407_a9, 113 + .outputs = st_pll3200c32_407_a9_clks, 114 + }; 115 + 153 116 static struct clkgen_pll_data st_pll4600c28_418_a9 = { 154 117 /* 418 A9 */ 155 118 .pdn_status = CLKGEN_FIELD(0x1a8, 0x1, 0), ··· 173 118 .switch2pll = CLKGEN_FIELD(0x1a4, 0x1, 1), 174 119 .lock = &clkgen_a9_lock, 175 120 .ops = &stm_pll4600c28_ops, 121 + }; 122 + 123 + static const struct clkgen_clk_out st_pll4600c28_418_a9_clks[] = { 124 + { .name = "clockgen-a9-pll-odf", }, 125 + }; 126 + 127 + static const struct clkgen_pll_data_clks st_pll4600c28_418_a9_data = { 128 + .data = (struct clkgen_pll_data *)&st_pll4600c28_418_a9, 129 + .outputs = st_pll4600c28_418_a9_clks, 176 130 }; 177 131 178 132 /** ··· 748 684 749 685 750 686 static void __init clkgen_c32_pll_setup(struct device_node *np, 751 - struct clkgen_pll_data *data) 687 + struct clkgen_pll_data_clks *datac) 752 688 { 753 689 struct clk *clk; 754 690 const char *parent_name, *pll_name; ··· 768 704 769 705 of_clk_detect_critical(np, 0, &pll_flags); 770 706 771 - clk = clkgen_pll_register(parent_name, data, pll_base, pll_flags, 772 - np->name, data->lock); 707 + clk = clkgen_pll_register(parent_name, datac->data, pll_base, pll_flags, 708 + np->name, datac->data->lock); 773 709 if (IS_ERR(clk)) 774 710 return; 775 711 776 712 pll_name = __clk_get_name(clk); 777 713 778 - num_odfs = data->num_odfs; 714 + num_odfs = datac->data->num_odfs; 779 715 780 716 clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 781 717 if (!clk_data) ··· 793 729 const char *clk_name; 794 730 unsigned long odf_flags = 0; 795 731 796 - if (of_property_read_string_index(np, "clock-output-names", 797 - odf, &clk_name)) 798 - return; 732 + if (datac->outputs) { 733 + clk_name = datac->outputs[odf].name; 734 + odf_flags = datac->outputs[odf].flags; 735 + } else { 736 + if (of_property_read_string_index(np, 737 + "clock-output-names", 738 + odf, &clk_name)) 739 + return; 799 740 800 - of_clk_detect_critical(np, odf, &odf_flags); 741 + of_clk_detect_critical(np, odf, &odf_flags); 742 + } 801 743 802 - clk = clkgen_odf_register(pll_name, pll_base, data, odf_flags, 803 - odf, &clkgena_c32_odf_lock, clk_name); 744 + clk = clkgen_odf_register(pll_name, pll_base, datac->data, 745 + odf_flags, odf, &clkgena_c32_odf_lock, 746 + clk_name); 804 747 if (IS_ERR(clk)) 805 748 goto err; 806 749 ··· 825 754 static void __init clkgen_c32_pll0_setup(struct device_node *np) 826 755 { 827 756 clkgen_c32_pll_setup(np, 828 - (struct clkgen_pll_data *) &st_pll3200c32_cx_0); 757 + (struct clkgen_pll_data_clks *) &st_pll3200c32_cx_0_legacy_data); 829 758 } 830 759 CLK_OF_DECLARE(c32_pll0, "st,clkgen-pll0", clkgen_c32_pll0_setup); 760 + 761 + static void __init clkgen_c32_pll0_a0_setup(struct device_node *np) 762 + { 763 + clkgen_c32_pll_setup(np, 764 + (struct clkgen_pll_data_clks *) &st_pll3200c32_a0_data); 765 + } 766 + CLK_OF_DECLARE(c32_pll0_a0, "st,clkgen-pll0-a0", clkgen_c32_pll0_a0_setup); 767 + 768 + static void __init clkgen_c32_pll0_c0_setup(struct device_node *np) 769 + { 770 + clkgen_c32_pll_setup(np, 771 + (struct clkgen_pll_data_clks *) &st_pll3200c32_c0_data); 772 + } 773 + CLK_OF_DECLARE(c32_pll0_c0, "st,clkgen-pll0-c0", clkgen_c32_pll0_c0_setup); 831 774 832 775 static void __init clkgen_c32_pll1_setup(struct device_node *np) 833 776 { 834 777 clkgen_c32_pll_setup(np, 835 - (struct clkgen_pll_data *) &st_pll3200c32_cx_1); 778 + (struct clkgen_pll_data_clks *) &st_pll3200c32_cx_1_legacy_data); 836 779 } 837 780 CLK_OF_DECLARE(c32_pll1, "st,clkgen-pll1", clkgen_c32_pll1_setup); 781 + 782 + static void __init clkgen_c32_pll1_c0_setup(struct device_node *np) 783 + { 784 + clkgen_c32_pll_setup(np, 785 + (struct clkgen_pll_data_clks *) &st_pll3200c32_c1_data); 786 + } 787 + CLK_OF_DECLARE(c32_pll1_c0, "st,clkgen-pll1-c0", clkgen_c32_pll1_c0_setup); 838 788 839 789 static void __init clkgen_c32_plla9_setup(struct device_node *np) 840 790 { 841 791 clkgen_c32_pll_setup(np, 842 - (struct clkgen_pll_data *) &st_pll3200c32_407_a9); 792 + (struct clkgen_pll_data_clks *) &st_pll3200c32_407_a9_data); 843 793 } 844 794 CLK_OF_DECLARE(c32_plla9, "st,stih407-clkgen-plla9", clkgen_c32_plla9_setup); 845 795 846 796 static void __init clkgen_c28_plla9_setup(struct device_node *np) 847 797 { 848 798 clkgen_c32_pll_setup(np, 849 - (struct clkgen_pll_data *) &st_pll4600c28_418_a9); 799 + (struct clkgen_pll_data_clks *) &st_pll4600c28_418_a9_data); 850 800 } 851 801 CLK_OF_DECLARE(c28_plla9, "st,stih418-clkgen-plla9", clkgen_c28_plla9_setup);