47
47
#define STM32F4_RCC_CSR 0x74
48
48
#define STM32F4_RCC_PLLI2SCFGR 0x84
49
49
#define STM32F4_RCC_PLLSAICFGR 0x88
50
+ #define STM32F4_RCC_DCKCFGR 0x8c
51
+
52
+ #define NONE -1
53
+ #define NO_IDX NONE
50
54
51
55
struct stm32f4_gate_data {
52
56
u8 offset ;
@@ -357,6 +361,19 @@ struct stm32f4_pll {
357
361
358
362
#define to_stm32f4_pll (_gate ) container_of(_gate, struct stm32f4_pll, gate)
359
363
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
+
360
377
struct stm32f4_vco_data {
361
378
const char * vco_name ;
362
379
u8 offset ;
@@ -370,6 +387,23 @@ static const struct stm32f4_vco_data vco_data[] = {
370
387
{ "vco-sai" , STM32F4_RCC_PLLSAICFGR , 28 , 29 },
371
388
};
372
389
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
+
373
407
struct stm32f4_div_data {
374
408
u8 shift ;
375
409
u8 width ;
@@ -996,6 +1030,27 @@ static void __init stm32f4_rcc_init(struct device_node *np)
996
1030
clks [PLL_VCO_SAI ] = stm32f4_rcc_register_pll ("vco_in" ,
997
1031
& data -> pll_data [2 ], & stm32f4_clk_lock );
998
1032
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
+
999
1054
sys_parents [1 ] = hse_clk ;
1000
1055
clk_register_mux_table (
1001
1056
NULL , "sys" , sys_parents , ARRAY_SIZE (sys_parents ), 0 ,
0 commit comments