aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Fernandez <gabriel.fernandez@st.com>2018-03-08 11:54:00 -0500
committerMichael Turquette <mturquette@baylibre.com>2018-03-11 18:40:33 -0400
commite51d297e9a923556e45e5491f5dd29888e38889e (patch)
tree85bf12724aaa350a919f8f83d7aecd93ad12f1d7
parenta97703c59f653f75814865c22ae6b16f5c477530 (diff)
clk: stm32mp1: add Sub System clocks
The RCC handles three sub-system clocks: ck_mpuss, ck_axiss and ck_mcuss. This patch adds also some MUX system and several prescalers. Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com> Signed-off-by: Michael Turquette <mturquette@baylibre.com>
-rw-r--r--drivers/clk/clk-stm32mp1.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c
index 3a99ad7f7048..77d96d9acad6 100644
--- a/drivers/clk/clk-stm32mp1.c
+++ b/drivers/clk/clk-stm32mp1.c
@@ -116,6 +116,42 @@ static const char * const ref4_parents[] = {
116 "ck_hsi", "ck_hse", "ck_csi" 116 "ck_hsi", "ck_hse", "ck_csi"
117}; 117};
118 118
119static const char * const cpu_src[] = {
120 "ck_hsi", "ck_hse", "pll1_p"
121};
122
123static const char * const axi_src[] = {
124 "ck_hsi", "ck_hse", "pll2_p", "pll3_p"
125};
126
127static const char * const per_src[] = {
128 "ck_hsi", "ck_csi", "ck_hse"
129};
130
131static const char * const mcu_src[] = {
132 "ck_hsi", "ck_hse", "ck_csi", "pll3_p"
133};
134
135static const struct clk_div_table axi_div_table[] = {
136 { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 },
137 { 4, 4 }, { 5, 4 }, { 6, 4 }, { 7, 4 },
138 { 0 },
139};
140
141static const struct clk_div_table mcu_div_table[] = {
142 { 0, 1 }, { 1, 2 }, { 2, 4 }, { 3, 8 },
143 { 4, 16 }, { 5, 32 }, { 6, 64 }, { 7, 128 },
144 { 8, 512 }, { 9, 512 }, { 10, 512}, { 11, 512 },
145 { 12, 512 }, { 13, 512 }, { 14, 512}, { 15, 512 },
146 { 0 },
147};
148
149static const struct clk_div_table apb_div_table[] = {
150 { 0, 1 }, { 1, 2 }, { 2, 4 }, { 3, 8 },
151 { 4, 16 }, { 5, 16 }, { 6, 16 }, { 7, 16 },
152 { 0 },
153};
154
119struct clock_config { 155struct clock_config {
120 u32 id; 156 u32 id;
121 const char *name; 157 const char *name;
@@ -781,6 +817,21 @@ _clk_stm32_register_composite(struct device *dev,
781 _STM32_DIV(_div_offset, _div_shift, _div_width,\ 817 _STM32_DIV(_div_offset, _div_shift, _div_width,\
782 _div_flags, _div_table, NULL)\ 818 _div_flags, _div_table, NULL)\
783 819
820#define _STM32_MUX(_offset, _shift, _width, _mux_flags, _ops)\
821 .mux = &(struct stm32_mux_cfg) {\
822 &(struct mux_cfg) {\
823 .reg_off = _offset,\
824 .shift = _shift,\
825 .width = _width,\
826 .mux_flags = _mux_flags,\
827 .table = NULL,\
828 },\
829 .ops = _ops,\
830 }
831
832#define _MUX(_offset, _shift, _width, _mux_flags)\
833 _STM32_MUX(_offset, _shift, _width, _mux_flags, NULL)\
834
784#define PARENT(_parent) ((const char *[]) { _parent}) 835#define PARENT(_parent) ((const char *[]) { _parent})
785 836
786#define _NO_MUX .mux = NULL 837#define _NO_MUX .mux = NULL
@@ -882,6 +933,40 @@ static const struct clock_config stm32mp1_clock_cfg[] = {
882 _GATE(RCC_PLL4CR, 6, 0), 933 _GATE(RCC_PLL4CR, 6, 0),
883 _NO_MUX, 934 _NO_MUX,
884 _DIV(RCC_PLL4CFGR2, 16, 7, 0, NULL)), 935 _DIV(RCC_PLL4CFGR2, 16, 7, 0, NULL)),
936
937 /* MUX system clocks */
938 MUX(CK_PER, "ck_per", per_src, CLK_OPS_PARENT_ENABLE,
939 RCC_CPERCKSELR, 0, 2, 0),
940
941 MUX(CK_MPU, "ck_mpu", cpu_src, CLK_OPS_PARENT_ENABLE |
942 CLK_IS_CRITICAL, RCC_MPCKSELR, 0, 2, 0),
943
944 COMPOSITE(CK_AXI, "ck_axi", axi_src, CLK_IS_CRITICAL |
945 CLK_OPS_PARENT_ENABLE,
946 _NO_GATE,
947 _MUX(RCC_ASSCKSELR, 0, 2, 0),
948 _DIV(RCC_AXIDIVR, 0, 3, 0, axi_div_table)),
949
950 COMPOSITE(CK_MCU, "ck_mcu", mcu_src, CLK_IS_CRITICAL |
951 CLK_OPS_PARENT_ENABLE,
952 _NO_GATE,
953 _MUX(RCC_MSSCKSELR, 0, 2, 0),
954 _DIV(RCC_MCUDIVR, 0, 4, 0, mcu_div_table)),
955
956 DIV_TABLE(NO_ID, "pclk1", "ck_mcu", CLK_IGNORE_UNUSED, RCC_APB1DIVR, 0,
957 3, CLK_DIVIDER_READ_ONLY, apb_div_table),
958
959 DIV_TABLE(NO_ID, "pclk2", "ck_mcu", CLK_IGNORE_UNUSED, RCC_APB2DIVR, 0,
960 3, CLK_DIVIDER_READ_ONLY, apb_div_table),
961
962 DIV_TABLE(NO_ID, "pclk3", "ck_mcu", CLK_IGNORE_UNUSED, RCC_APB3DIVR, 0,
963 3, CLK_DIVIDER_READ_ONLY, apb_div_table),
964
965 DIV_TABLE(NO_ID, "pclk4", "ck_axi", CLK_IGNORE_UNUSED, RCC_APB4DIVR, 0,
966 3, CLK_DIVIDER_READ_ONLY, apb_div_table),
967
968 DIV_TABLE(NO_ID, "pclk5", "ck_axi", CLK_IGNORE_UNUSED, RCC_APB5DIVR, 0,
969 3, CLK_DIVIDER_READ_ONLY, apb_div_table),
885}; 970};
886 971
887struct stm32_clock_match_data { 972struct stm32_clock_match_data {