Skip to content

Commit 517633e

Browse files
Gabriel-Fernandez-stmbebarino
authored andcommitted
clk: stm32f4: Add post divisor for I2S & SAI PLLs
This patch adds post dividers of I2S & SAI PLLs. These dividers are managed by a dedicated register (RCC_DCKCFGR). The PLL should be off before a set rate. Signed-off-by: Gabriel Fernandez <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 83135ad commit 517633e

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

drivers/clk/clk-stm32f4.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#define STM32F4_RCC_CSR 0x74
4848
#define STM32F4_RCC_PLLI2SCFGR 0x84
4949
#define STM32F4_RCC_PLLSAICFGR 0x88
50+
#define STM32F4_RCC_DCKCFGR 0x8c
51+
52+
#define NONE -1
53+
#define NO_IDX NONE
5054

5155
struct stm32f4_gate_data {
5256
u8 offset;
@@ -357,6 +361,19 @@ struct stm32f4_pll {
357361

358362
#define to_stm32f4_pll(_gate) container_of(_gate, struct stm32f4_pll, gate)
359363

364+
struct stm32f4_pll_post_div_data {
365+
int idx;
366+
u8 pll_num;
367+
const char *name;
368+
const char *parent;
369+
u8 flag;
370+
u8 offset;
371+
u8 shift;
372+
u8 width;
373+
u8 flag_div;
374+
const struct clk_div_table *div_table;
375+
};
376+
360377
struct stm32f4_vco_data {
361378
const char *vco_name;
362379
u8 offset;
@@ -370,6 +387,23 @@ static const struct stm32f4_vco_data vco_data[] = {
370387
{ "vco-sai", STM32F4_RCC_PLLSAICFGR, 28, 29 },
371388
};
372389

390+
391+
static const struct clk_div_table post_divr_table[] = {
392+
{ 0, 2 }, { 1, 4 }, { 2, 8 }, { 3, 16 }, { 0 }
393+
};
394+
395+
#define MAX_POST_DIV 3
396+
static const struct stm32f4_pll_post_div_data post_div_data[MAX_POST_DIV] = {
397+
{ CLK_I2SQ_PDIV, PLL_I2S, "plli2s-q-div", "plli2s-q",
398+
CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 0, 5, 0, NULL},
399+
400+
{ CLK_SAIQ_PDIV, PLL_SAI, "pllsai-q-div", "pllsai-q",
401+
CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 8, 5, 0, NULL },
402+
403+
{ NO_IDX, PLL_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT,
404+
STM32F4_RCC_DCKCFGR, 16, 2, 0, post_divr_table },
405+
};
406+
373407
struct stm32f4_div_data {
374408
u8 shift;
375409
u8 width;
@@ -996,6 +1030,27 @@ static void __init stm32f4_rcc_init(struct device_node *np)
9961030
clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in",
9971031
&data->pll_data[2], &stm32f4_clk_lock);
9981032

1033+
for (n = 0; n < MAX_POST_DIV; n++) {
1034+
const struct stm32f4_pll_post_div_data *post_div;
1035+
struct clk_hw *hw;
1036+
1037+
post_div = &post_div_data[n];
1038+
1039+
hw = clk_register_pll_div(post_div->name,
1040+
post_div->parent,
1041+
post_div->flag,
1042+
base + post_div->offset,
1043+
post_div->shift,
1044+
post_div->width,
1045+
post_div->flag_div,
1046+
post_div->div_table,
1047+
clks[post_div->pll_num],
1048+
&stm32f4_clk_lock);
1049+
1050+
if (post_div->idx != NO_IDX)
1051+
clks[post_div->idx] = hw;
1052+
}
1053+
9991054
sys_parents[1] = hse_clk;
10001055
clk_register_mux_table(
10011056
NULL, "sys", sys_parents, ARRAY_SIZE(sys_parents), 0,

0 commit comments

Comments
 (0)