Skip to content
Snippets Groups Projects
Select Git revision
5 results Searching

clk_stm32f.c

Blame
  • Forked from Reform / reform-boundary-uboot
    Source project has a limited visibility.
    clk_stm32f.c 12.50 KiB
    /*
     * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
     * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
     *
     * SPDX-License-Identifier:	GPL-2.0+
     */
    
    #include <common.h>
    #include <clk-uclass.h>
    #include <dm.h>
    #include <stm32_rcc.h>
    
    #include <asm/io.h>
    #include <asm/arch/stm32.h>
    #include <asm/arch/stm32_pwr.h>
    
    #include <dt-bindings/mfd/stm32f7-rcc.h>
    
    #define RCC_CR_HSION			BIT(0)
    #define RCC_CR_HSEON			BIT(16)
    #define RCC_CR_HSERDY			BIT(17)
    #define RCC_CR_HSEBYP			BIT(18)
    #define RCC_CR_CSSON			BIT(19)
    #define RCC_CR_PLLON			BIT(24)
    #define RCC_CR_PLLRDY			BIT(25)
    #define RCC_CR_PLLSAION			BIT(28)
    #define RCC_CR_PLLSAIRDY		BIT(29)
    
    #define RCC_PLLCFGR_PLLM_MASK		GENMASK(5, 0)
    #define RCC_PLLCFGR_PLLN_MASK		GENMASK(14, 6)
    #define RCC_PLLCFGR_PLLP_MASK		GENMASK(17, 16)
    #define RCC_PLLCFGR_PLLQ_MASK		GENMASK(27, 24)
    #define RCC_PLLCFGR_PLLSRC		BIT(22)
    #define RCC_PLLCFGR_PLLM_SHIFT		0
    #define RCC_PLLCFGR_PLLN_SHIFT		6
    #define RCC_PLLCFGR_PLLP_SHIFT		16
    #define RCC_PLLCFGR_PLLQ_SHIFT		24
    
    #define RCC_CFGR_AHB_PSC_MASK		GENMASK(7, 4)
    #define RCC_CFGR_APB1_PSC_MASK		GENMASK(12, 10)
    #define RCC_CFGR_APB2_PSC_MASK		GENMASK(15, 13)
    #define RCC_CFGR_SW0			BIT(0)
    #define RCC_CFGR_SW1			BIT(1)
    #define RCC_CFGR_SW_MASK		GENMASK(1, 0)
    #define RCC_CFGR_SW_HSI			0
    #define RCC_CFGR_SW_HSE			RCC_CFGR_SW0
    #define RCC_CFGR_SW_PLL			RCC_CFGR_SW1
    #define RCC_CFGR_SWS0			BIT(2)
    #define RCC_CFGR_SWS1			BIT(3)
    #define RCC_CFGR_SWS_MASK		GENMASK(3, 2)
    #define RCC_CFGR_SWS_HSI		0
    #define RCC_CFGR_SWS_HSE		RCC_CFGR_SWS0
    #define RCC_CFGR_SWS_PLL		RCC_CFGR_SWS1
    #define RCC_CFGR_HPRE_SHIFT		4
    #define RCC_CFGR_PPRE1_SHIFT		10
    #define RCC_CFGR_PPRE2_SHIFT		13
    
    #define RCC_PLLCFGR_PLLSAIN_MASK	GENMASK(14, 6)
    #define RCC_PLLCFGR_PLLSAIP_MASK	GENMASK(17, 16)
    #define RCC_PLLSAICFGR_PLLSAIN_SHIFT	6
    #define RCC_PLLSAICFGR_PLLSAIP_SHIFT	16
    #define RCC_PLLSAICFGR_PLLSAIP_4	BIT(17)
    #define RCC_PLLSAICFGR_PLLSAIQ_4	BIT(26)
    #define RCC_PLLSAICFGR_PLLSAIR_2	BIT(29)
    
    #define RCC_DCKCFGRX_CK48MSEL		BIT(27)
    #define RCC_DCKCFGRX_SDMMC1SEL		BIT(28)
    #define RCC_DCKCFGR2_SDMMC2SEL		BIT(29)
    
    #define RCC_APB2ENR_SAI1EN		BIT(22)