diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2014-12-23 02:40:23 -0500 |
---|---|---|
committer | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2014-12-23 08:26:27 -0500 |
commit | 01e5200d169a442651f823e4941ca61d78ec2b8d (patch) | |
tree | 3981911d641c5db3b2c79229a6f5efb8a2eee18f | |
parent | c913e1b32b0a237fbf21b12fa7c2912f274e3495 (diff) |
clk: samsung: exynos4415: Use samsung_cmu_register_one() to simplify code
This patch uses the samsung_cmu_register_one() to simplify code
for Exynos4415.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
-rw-r--r-- | drivers/clk/samsung/clk-exynos4415.c | 216 |
1 files changed, 48 insertions, 168 deletions
diff --git a/drivers/clk/samsung/clk-exynos4415.c b/drivers/clk/samsung/clk-exynos4415.c index 2123fc251e0f..6c78b09c829f 100644 --- a/drivers/clk/samsung/clk-exynos4415.c +++ b/drivers/clk/samsung/clk-exynos4415.c | |||
@@ -113,19 +113,6 @@ | |||
113 | #define DIV_CPU0 0x14500 | 113 | #define DIV_CPU0 0x14500 |
114 | #define DIV_CPU1 0x14504 | 114 | #define DIV_CPU1 0x14504 |
115 | 115 | ||
116 | enum exynos4415_plls { | ||
117 | apll, epll, g3d_pll, isp_pll, disp_pll, | ||
118 | nr_plls, | ||
119 | }; | ||
120 | |||
121 | static struct samsung_clk_provider *exynos4415_ctx; | ||
122 | |||
123 | /* | ||
124 | * Support for CMU save/restore across system suspends | ||
125 | */ | ||
126 | #ifdef CONFIG_PM_SLEEP | ||
127 | static struct samsung_clk_reg_dump *exynos4415_clk_regs; | ||
128 | |||
129 | static unsigned long exynos4415_cmu_clk_regs[] __initdata = { | 116 | static unsigned long exynos4415_cmu_clk_regs[] __initdata = { |
130 | SRC_LEFTBUS, | 117 | SRC_LEFTBUS, |
131 | DIV_LEFTBUS, | 118 | DIV_LEFTBUS, |
@@ -219,41 +206,6 @@ static unsigned long exynos4415_cmu_clk_regs[] __initdata = { | |||
219 | DIV_CPU1, | 206 | DIV_CPU1, |
220 | }; | 207 | }; |
221 | 208 | ||
222 | static int exynos4415_clk_suspend(void) | ||
223 | { | ||
224 | samsung_clk_save(exynos4415_ctx->reg_base, exynos4415_clk_regs, | ||
225 | ARRAY_SIZE(exynos4415_cmu_clk_regs)); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static void exynos4415_clk_resume(void) | ||
231 | { | ||
232 | samsung_clk_restore(exynos4415_ctx->reg_base, exynos4415_clk_regs, | ||
233 | ARRAY_SIZE(exynos4415_cmu_clk_regs)); | ||
234 | } | ||
235 | |||
236 | static struct syscore_ops exynos4415_clk_syscore_ops = { | ||
237 | .suspend = exynos4415_clk_suspend, | ||
238 | .resume = exynos4415_clk_resume, | ||
239 | }; | ||
240 | |||
241 | static void exynos4415_clk_sleep_init(void) | ||
242 | { | ||
243 | exynos4415_clk_regs = | ||
244 | samsung_clk_alloc_reg_dump(exynos4415_cmu_clk_regs, | ||
245 | ARRAY_SIZE(exynos4415_cmu_clk_regs)); | ||
246 | if (!exynos4415_clk_regs) { | ||
247 | pr_warn("%s: Failed to allocate sleep save data\n", __func__); | ||
248 | return; | ||
249 | } | ||
250 | |||
251 | register_syscore_ops(&exynos4415_clk_syscore_ops); | ||
252 | } | ||
253 | #else | ||
254 | static inline void exynos4415_clk_sleep_init(void) { } | ||
255 | #endif | ||
256 | |||
257 | /* list of all parent clock list */ | 209 | /* list of all parent clock list */ |
258 | PNAME(mout_g3d_pllsrc_p) = { "fin_pll", }; | 210 | PNAME(mout_g3d_pllsrc_p) = { "fin_pll", }; |
259 | 211 | ||
@@ -959,56 +911,40 @@ static struct samsung_pll_rate_table exynos4415_epll_rates[] = { | |||
959 | { /* sentinel */ } | 911 | { /* sentinel */ } |
960 | }; | 912 | }; |
961 | 913 | ||
962 | static struct samsung_pll_clock exynos4415_plls[nr_plls] __initdata = { | 914 | static struct samsung_pll_clock exynos4415_plls[] __initdata = { |
963 | [apll] = PLL(pll_35xx, CLK_FOUT_APLL, "fout_apll", "fin_pll", | 915 | PLL(pll_35xx, CLK_FOUT_APLL, "fout_apll", "fin_pll", |
964 | APLL_LOCK, APLL_CON0, NULL), | 916 | APLL_LOCK, APLL_CON0, exynos4415_pll_rates), |
965 | [epll] = PLL(pll_36xx, CLK_FOUT_EPLL, "fout_epll", "fin_pll", | 917 | PLL(pll_36xx, CLK_FOUT_EPLL, "fout_epll", "fin_pll", |
966 | EPLL_LOCK, EPLL_CON0, NULL), | 918 | EPLL_LOCK, EPLL_CON0, exynos4415_epll_rates), |
967 | [g3d_pll] = PLL(pll_35xx, CLK_FOUT_G3D_PLL, "fout_g3d_pll", | 919 | PLL(pll_35xx, CLK_FOUT_G3D_PLL, "fout_g3d_pll", "mout_g3d_pllsrc", |
968 | "mout_g3d_pllsrc", G3D_PLL_LOCK, G3D_PLL_CON0, NULL), | 920 | G3D_PLL_LOCK, G3D_PLL_CON0, exynos4415_pll_rates), |
969 | [isp_pll] = PLL(pll_35xx, CLK_FOUT_ISP_PLL, "fout_isp_pll", "fin_pll", | 921 | PLL(pll_35xx, CLK_FOUT_ISP_PLL, "fout_isp_pll", "fin_pll", |
970 | ISP_PLL_LOCK, ISP_PLL_CON0, NULL), | 922 | ISP_PLL_LOCK, ISP_PLL_CON0, exynos4415_pll_rates), |
971 | [disp_pll] = PLL(pll_35xx, CLK_FOUT_DISP_PLL, "fout_disp_pll", | 923 | PLL(pll_35xx, CLK_FOUT_DISP_PLL, "fout_disp_pll", |
972 | "fin_pll", DISP_PLL_LOCK, DISP_PLL_CON0, NULL), | 924 | "fin_pll", DISP_PLL_LOCK, DISP_PLL_CON0, exynos4415_pll_rates), |
925 | }; | ||
926 | |||
927 | static struct samsung_cmu_info cmu_info __initdata = { | ||
928 | .pll_clks = exynos4415_plls, | ||
929 | .nr_pll_clks = ARRAY_SIZE(exynos4415_plls), | ||
930 | .mux_clks = exynos4415_mux_clks, | ||
931 | .nr_mux_clks = ARRAY_SIZE(exynos4415_mux_clks), | ||
932 | .div_clks = exynos4415_div_clks, | ||
933 | .nr_div_clks = ARRAY_SIZE(exynos4415_div_clks), | ||
934 | .gate_clks = exynos4415_gate_clks, | ||
935 | .nr_gate_clks = ARRAY_SIZE(exynos4415_gate_clks), | ||
936 | .fixed_clks = exynos4415_fixed_rate_clks, | ||
937 | .nr_fixed_clks = ARRAY_SIZE(exynos4415_fixed_rate_clks), | ||
938 | .fixed_factor_clks = exynos4415_fixed_factor_clks, | ||
939 | .nr_fixed_factor_clks = ARRAY_SIZE(exynos4415_fixed_factor_clks), | ||
940 | .nr_clk_ids = CLK_NR_CLKS, | ||
941 | .clk_regs = exynos4415_cmu_clk_regs, | ||
942 | .nr_clk_regs = ARRAY_SIZE(exynos4415_cmu_clk_regs), | ||
973 | }; | 943 | }; |
974 | 944 | ||
975 | static void __init exynos4415_cmu_init(struct device_node *np) | 945 | static void __init exynos4415_cmu_init(struct device_node *np) |
976 | { | 946 | { |
977 | void __iomem *reg_base; | 947 | samsung_cmu_register_one(np, &cmu_info); |
978 | |||
979 | reg_base = of_iomap(np, 0); | ||
980 | if (!reg_base) | ||
981 | panic("%s: failed to map registers\n", __func__); | ||
982 | |||
983 | exynos4415_ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS); | ||
984 | if (!exynos4415_ctx) | ||
985 | panic("%s: unable to allocate context.\n", __func__); | ||
986 | |||
987 | exynos4415_plls[apll].rate_table = exynos4415_pll_rates; | ||
988 | exynos4415_plls[epll].rate_table = exynos4415_epll_rates; | ||
989 | exynos4415_plls[g3d_pll].rate_table = exynos4415_pll_rates; | ||
990 | exynos4415_plls[isp_pll].rate_table = exynos4415_pll_rates; | ||
991 | exynos4415_plls[disp_pll].rate_table = exynos4415_pll_rates; | ||
992 | |||
993 | samsung_clk_register_fixed_factor(exynos4415_ctx, | ||
994 | exynos4415_fixed_factor_clks, | ||
995 | ARRAY_SIZE(exynos4415_fixed_factor_clks)); | ||
996 | samsung_clk_register_fixed_rate(exynos4415_ctx, | ||
997 | exynos4415_fixed_rate_clks, | ||
998 | ARRAY_SIZE(exynos4415_fixed_rate_clks)); | ||
999 | |||
1000 | samsung_clk_register_pll(exynos4415_ctx, exynos4415_plls, | ||
1001 | ARRAY_SIZE(exynos4415_plls), reg_base); | ||
1002 | samsung_clk_register_mux(exynos4415_ctx, exynos4415_mux_clks, | ||
1003 | ARRAY_SIZE(exynos4415_mux_clks)); | ||
1004 | samsung_clk_register_div(exynos4415_ctx, exynos4415_div_clks, | ||
1005 | ARRAY_SIZE(exynos4415_div_clks)); | ||
1006 | samsung_clk_register_gate(exynos4415_ctx, exynos4415_gate_clks, | ||
1007 | ARRAY_SIZE(exynos4415_gate_clks)); | ||
1008 | |||
1009 | exynos4415_clk_sleep_init(); | ||
1010 | |||
1011 | samsung_clk_of_add_provider(np, exynos4415_ctx); | ||
1012 | } | 948 | } |
1013 | CLK_OF_DECLARE(exynos4415_cmu, "samsung,exynos4415-cmu", exynos4415_cmu_init); | 949 | CLK_OF_DECLARE(exynos4415_cmu, "samsung,exynos4415-cmu", exynos4415_cmu_init); |
1014 | 950 | ||
@@ -1027,16 +963,6 @@ CLK_OF_DECLARE(exynos4415_cmu, "samsung,exynos4415-cmu", exynos4415_cmu_init); | |||
1027 | #define SRC_DMC 0x300 | 963 | #define SRC_DMC 0x300 |
1028 | #define DIV_DMC1 0x504 | 964 | #define DIV_DMC1 0x504 |
1029 | 965 | ||
1030 | enum exynos4415_dmc_plls { | ||
1031 | mpll, bpll, | ||
1032 | nr_dmc_plls, | ||
1033 | }; | ||
1034 | |||
1035 | static struct samsung_clk_provider *exynos4415_dmc_ctx; | ||
1036 | |||
1037 | #ifdef CONFIG_PM_SLEEP | ||
1038 | static struct samsung_clk_reg_dump *exynos4415_dmc_clk_regs; | ||
1039 | |||
1040 | static unsigned long exynos4415_cmu_dmc_clk_regs[] __initdata = { | 966 | static unsigned long exynos4415_cmu_dmc_clk_regs[] __initdata = { |
1041 | MPLL_LOCK, | 967 | MPLL_LOCK, |
1042 | MPLL_CON0, | 968 | MPLL_CON0, |
@@ -1050,42 +976,6 @@ static unsigned long exynos4415_cmu_dmc_clk_regs[] __initdata = { | |||
1050 | DIV_DMC1, | 976 | DIV_DMC1, |
1051 | }; | 977 | }; |
1052 | 978 | ||
1053 | static int exynos4415_dmc_clk_suspend(void) | ||
1054 | { | ||
1055 | samsung_clk_save(exynos4415_dmc_ctx->reg_base, | ||
1056 | exynos4415_dmc_clk_regs, | ||
1057 | ARRAY_SIZE(exynos4415_cmu_dmc_clk_regs)); | ||
1058 | return 0; | ||
1059 | } | ||
1060 | |||
1061 | static void exynos4415_dmc_clk_resume(void) | ||
1062 | { | ||
1063 | samsung_clk_restore(exynos4415_dmc_ctx->reg_base, | ||
1064 | exynos4415_dmc_clk_regs, | ||
1065 | ARRAY_SIZE(exynos4415_cmu_dmc_clk_regs)); | ||
1066 | } | ||
1067 | |||
1068 | static struct syscore_ops exynos4415_dmc_clk_syscore_ops = { | ||
1069 | .suspend = exynos4415_dmc_clk_suspend, | ||
1070 | .resume = exynos4415_dmc_clk_resume, | ||
1071 | }; | ||
1072 | |||
1073 | static void exynos4415_dmc_clk_sleep_init(void) | ||
1074 | { | ||
1075 | exynos4415_dmc_clk_regs = | ||
1076 | samsung_clk_alloc_reg_dump(exynos4415_cmu_dmc_clk_regs, | ||
1077 | ARRAY_SIZE(exynos4415_cmu_dmc_clk_regs)); | ||
1078 | if (!exynos4415_dmc_clk_regs) { | ||
1079 | pr_warn("%s: Failed to allocate sleep save data\n", __func__); | ||
1080 | return; | ||
1081 | } | ||
1082 | |||
1083 | register_syscore_ops(&exynos4415_dmc_clk_syscore_ops); | ||
1084 | } | ||
1085 | #else | ||
1086 | static inline void exynos4415_dmc_clk_sleep_init(void) { } | ||
1087 | #endif /* CONFIG_PM_SLEEP */ | ||
1088 | |||
1089 | PNAME(mout_mpll_p) = { "fin_pll", "fout_mpll", }; | 979 | PNAME(mout_mpll_p) = { "fin_pll", "fout_mpll", }; |
1090 | PNAME(mout_bpll_p) = { "fin_pll", "fout_bpll", }; | 980 | PNAME(mout_bpll_p) = { "fin_pll", "fout_bpll", }; |
1091 | PNAME(mbpll_p) = { "mout_mpll", "mout_bpll", }; | 981 | PNAME(mbpll_p) = { "mout_mpll", "mout_bpll", }; |
@@ -1107,38 +997,28 @@ static struct samsung_div_clock exynos4415_dmc_div_clks[] __initdata = { | |||
1107 | DIV(CLK_DMC_DIV_MPLL_PRE, "div_mpll_pre", "mout_mpll", DIV_DMC1, 8, 2), | 997 | DIV(CLK_DMC_DIV_MPLL_PRE, "div_mpll_pre", "mout_mpll", DIV_DMC1, 8, 2), |
1108 | }; | 998 | }; |
1109 | 999 | ||
1110 | static struct samsung_pll_clock exynos4415_dmc_plls[nr_dmc_plls] __initdata = { | 1000 | static struct samsung_pll_clock exynos4415_dmc_plls[] __initdata = { |
1111 | [mpll] = PLL(pll_35xx, CLK_DMC_FOUT_MPLL, "fout_mpll", "fin_pll", | 1001 | PLL(pll_35xx, CLK_DMC_FOUT_MPLL, "fout_mpll", "fin_pll", |
1112 | MPLL_LOCK, MPLL_CON0, NULL), | 1002 | MPLL_LOCK, MPLL_CON0, exynos4415_pll_rates), |
1113 | [bpll] = PLL(pll_35xx, CLK_DMC_FOUT_BPLL, "fout_bpll", "fin_pll", | 1003 | PLL(pll_35xx, CLK_DMC_FOUT_BPLL, "fout_bpll", "fin_pll", |
1114 | BPLL_LOCK, BPLL_CON0, NULL), | 1004 | BPLL_LOCK, BPLL_CON0, exynos4415_pll_rates), |
1005 | }; | ||
1006 | |||
1007 | static struct samsung_cmu_info cmu_dmc_info __initdata = { | ||
1008 | .pll_clks = exynos4415_dmc_plls, | ||
1009 | .nr_pll_clks = ARRAY_SIZE(exynos4415_dmc_plls), | ||
1010 | .mux_clks = exynos4415_dmc_mux_clks, | ||
1011 | .nr_mux_clks = ARRAY_SIZE(exynos4415_dmc_mux_clks), | ||
1012 | .div_clks = exynos4415_dmc_div_clks, | ||
1013 | .nr_div_clks = ARRAY_SIZE(exynos4415_dmc_div_clks), | ||
1014 | .nr_clk_ids = NR_CLKS_DMC, | ||
1015 | .clk_regs = exynos4415_cmu_dmc_clk_regs, | ||
1016 | .nr_clk_regs = ARRAY_SIZE(exynos4415_cmu_dmc_clk_regs), | ||
1115 | }; | 1017 | }; |
1116 | 1018 | ||
1117 | static void __init exynos4415_cmu_dmc_init(struct device_node *np) | 1019 | static void __init exynos4415_cmu_dmc_init(struct device_node *np) |
1118 | { | 1020 | { |
1119 | void __iomem *reg_base; | 1021 | samsung_cmu_register_one(np, &cmu_dmc_info); |
1120 | |||
1121 | reg_base = of_iomap(np, 0); | ||
1122 | if (!reg_base) | ||
1123 | panic("%s: failed to map registers\n", __func__); | ||
1124 | |||
1125 | exynos4415_dmc_ctx = samsung_clk_init(np, reg_base, NR_CLKS_DMC); | ||
1126 | if (!exynos4415_dmc_ctx) | ||
1127 | panic("%s: unable to allocate context.\n", __func__); | ||
1128 | |||
1129 | exynos4415_dmc_plls[mpll].rate_table = exynos4415_pll_rates; | ||
1130 | exynos4415_dmc_plls[bpll].rate_table = exynos4415_pll_rates; | ||
1131 | |||
1132 | samsung_clk_register_pll(exynos4415_dmc_ctx, exynos4415_dmc_plls, | ||
1133 | ARRAY_SIZE(exynos4415_dmc_plls), reg_base); | ||
1134 | samsung_clk_register_mux(exynos4415_dmc_ctx, exynos4415_dmc_mux_clks, | ||
1135 | ARRAY_SIZE(exynos4415_dmc_mux_clks)); | ||
1136 | samsung_clk_register_div(exynos4415_dmc_ctx, exynos4415_dmc_div_clks, | ||
1137 | ARRAY_SIZE(exynos4415_dmc_div_clks)); | ||
1138 | |||
1139 | exynos4415_dmc_clk_sleep_init(); | ||
1140 | |||
1141 | samsung_clk_of_add_provider(np, exynos4415_dmc_ctx); | ||
1142 | } | 1022 | } |
1143 | CLK_OF_DECLARE(exynos4415_cmu_dmc, "samsung,exynos4415-cmu-dmc", | 1023 | CLK_OF_DECLARE(exynos4415_cmu_dmc, "samsung,exynos4415-cmu-dmc", |
1144 | exynos4415_cmu_dmc_init); | 1024 | exynos4415_cmu_dmc_init); |