183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0 */ 2177ba1f9SLey Foon Tan /* 3177ba1f9SLey Foon Tan * Copyright (C) 2016-2017 Intel Corporation 4177ba1f9SLey Foon Tan */ 5177ba1f9SLey Foon Tan 6177ba1f9SLey Foon Tan #ifndef CLOCK_MANAGER_ARRIA10 7177ba1f9SLey Foon Tan #define CLOCK_MANAGER_ARRIA10 8177ba1f9SLey Foon Tan 9177ba1f9SLey Foon Tan #ifndef __ASSEMBLER__ 10177ba1f9SLey Foon Tan 11177ba1f9SLey Foon Tan struct socfpga_clock_manager_main_pll { 12177ba1f9SLey Foon Tan u32 vco0; 13177ba1f9SLey Foon Tan u32 vco1; 14177ba1f9SLey Foon Tan u32 en; 15177ba1f9SLey Foon Tan u32 ens; 16177ba1f9SLey Foon Tan u32 enr; 17177ba1f9SLey Foon Tan u32 bypass; 18177ba1f9SLey Foon Tan u32 bypasss; 19177ba1f9SLey Foon Tan u32 bypassr; 20177ba1f9SLey Foon Tan u32 mpuclk; 21177ba1f9SLey Foon Tan u32 nocclk; 22177ba1f9SLey Foon Tan u32 cntr2clk; 23177ba1f9SLey Foon Tan u32 cntr3clk; 24177ba1f9SLey Foon Tan u32 cntr4clk; 25177ba1f9SLey Foon Tan u32 cntr5clk; 26177ba1f9SLey Foon Tan u32 cntr6clk; 27177ba1f9SLey Foon Tan u32 cntr7clk; 28177ba1f9SLey Foon Tan u32 cntr8clk; 29177ba1f9SLey Foon Tan u32 cntr9clk; 30177ba1f9SLey Foon Tan u32 pad_0x48_0x5b[5]; 31177ba1f9SLey Foon Tan u32 cntr15clk; 32177ba1f9SLey Foon Tan u32 outrst; 33177ba1f9SLey Foon Tan u32 outrststat; 34177ba1f9SLey Foon Tan u32 nocdiv; 35177ba1f9SLey Foon Tan u32 pad_0x6c_0x80[5]; 36177ba1f9SLey Foon Tan }; 37177ba1f9SLey Foon Tan 38177ba1f9SLey Foon Tan struct socfpga_clock_manager_per_pll { 39177ba1f9SLey Foon Tan u32 vco0; 40177ba1f9SLey Foon Tan u32 vco1; 41177ba1f9SLey Foon Tan u32 en; 42177ba1f9SLey Foon Tan u32 ens; 43177ba1f9SLey Foon Tan u32 enr; 44177ba1f9SLey Foon Tan u32 bypass; 45177ba1f9SLey Foon Tan u32 bypasss; 46177ba1f9SLey Foon Tan u32 bypassr; 47177ba1f9SLey Foon Tan u32 pad_0x20_0x27[2]; 48177ba1f9SLey Foon Tan u32 cntr2clk; 49177ba1f9SLey Foon Tan u32 cntr3clk; 50177ba1f9SLey Foon Tan u32 cntr4clk; 51177ba1f9SLey Foon Tan u32 cntr5clk; 52177ba1f9SLey Foon Tan u32 cntr6clk; 53177ba1f9SLey Foon Tan u32 cntr7clk; 54177ba1f9SLey Foon Tan u32 cntr8clk; 55177ba1f9SLey Foon Tan u32 cntr9clk; 56177ba1f9SLey Foon Tan u32 pad_0x48_0x5f[6]; 57177ba1f9SLey Foon Tan u32 outrst; 58177ba1f9SLey Foon Tan u32 outrststat; 59177ba1f9SLey Foon Tan u32 emacctl; 60177ba1f9SLey Foon Tan u32 gpiodiv; 61177ba1f9SLey Foon Tan u32 pad_0x70_0x80[4]; 62177ba1f9SLey Foon Tan }; 63177ba1f9SLey Foon Tan 64177ba1f9SLey Foon Tan struct socfpga_clock_manager_altera { 65177ba1f9SLey Foon Tan u32 mpuclk; 66177ba1f9SLey Foon Tan u32 nocclk; 67177ba1f9SLey Foon Tan u32 mainmisc0; 68177ba1f9SLey Foon Tan u32 mainmisc1; 69177ba1f9SLey Foon Tan u32 perimisc0; 70177ba1f9SLey Foon Tan u32 perimisc1; 71177ba1f9SLey Foon Tan }; 72177ba1f9SLey Foon Tan 73177ba1f9SLey Foon Tan struct socfpga_clock_manager { 74177ba1f9SLey Foon Tan /* clkmgr */ 75177ba1f9SLey Foon Tan u32 ctrl; 76177ba1f9SLey Foon Tan u32 intr; 77177ba1f9SLey Foon Tan u32 intrs; 78177ba1f9SLey Foon Tan u32 intrr; 79177ba1f9SLey Foon Tan u32 intren; 80177ba1f9SLey Foon Tan u32 intrens; 81177ba1f9SLey Foon Tan u32 intrenr; 82177ba1f9SLey Foon Tan u32 stat; 83177ba1f9SLey Foon Tan u32 testioctrl; 84177ba1f9SLey Foon Tan u32 _pad_0x24_0x40[7]; 85177ba1f9SLey Foon Tan /* mainpllgrp */ 86177ba1f9SLey Foon Tan struct socfpga_clock_manager_main_pll main_pll; 87177ba1f9SLey Foon Tan /* perpllgrp */ 88177ba1f9SLey Foon Tan struct socfpga_clock_manager_per_pll per_pll; 89177ba1f9SLey Foon Tan struct socfpga_clock_manager_altera altera; 90177ba1f9SLey Foon Tan }; 91177ba1f9SLey Foon Tan 92*0b8f6378SMarek Vasut #ifdef CONFIG_SPL_BUILD 93177ba1f9SLey Foon Tan int cm_basic_init(const void *blob); 94*0b8f6378SMarek Vasut #endif 95177ba1f9SLey Foon Tan 96177ba1f9SLey Foon Tan unsigned int cm_get_l4_sp_clk_hz(void); 97177ba1f9SLey Foon Tan unsigned long cm_get_mpu_clk_hz(void); 98177ba1f9SLey Foon Tan 99177ba1f9SLey Foon Tan unsigned int cm_get_qspi_controller_clk_hz(void); 100177ba1f9SLey Foon Tan 101177ba1f9SLey Foon Tan #endif /* __ASSEMBLER__ */ 102177ba1f9SLey Foon Tan 103177ba1f9SLey Foon Tan #define CLKMGR_ALTERAGRP_MPU_CLK_OFFSET 0x140 104177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOC_CLK_OFFSET 0x144 105177ba1f9SLey Foon Tan #define LOCKED_MASK (CLKMGR_CLKMGR_STAT_MAINPLLLOCKED_SET_MSK | \ 106177ba1f9SLey Foon Tan CLKMGR_CLKMGR_STAT_PERPLLLOCKED_SET_MSK) 107177ba1f9SLey Foon Tan 108177ba1f9SLey Foon Tan /* value */ 109177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_BYPASS_RESET 0x0000003f 110177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_BYPASS_RESET 0x000000ff 111177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_RESET 0x00010053 112177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO1_RESET 0x00010001 113177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_RESET 0x00010053 114177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO1_RESET 0x00010001 115177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_PSRC_EOSC 0x0 116177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC 0x1 117177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_PSRC_F2S 0x2 118177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PSRC_EOSC 0x0 119177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC 0x1 120177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PSRC_F2S 0x2 121177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PSRC_MAIN 0x3 122177ba1f9SLey Foon Tan 123177ba1f9SLey Foon Tan /* mask */ 124177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_EN_S2FUSER0CLKEN_SET_MSK BIT(6) 125177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_EN_HMCPLLREFCLKEN_SET_MSK BIT(7) 126177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_STAT_MAINPLLLOCKED_SET_MSK BIT(8) 127177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_STAT_PERPLLLOCKED_SET_MSK BIT(9) 128177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_STAT_BOOTCLKSRC_SET_MSK BIT(17) 129177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_BGPWRDN_SET_MSK BIT(0) 130177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_PWRDN_SET_MSK BIT(1) 131177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_EN_SET_MSK BIT(2) 132177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_OUTRSTALL_SET_MSK BIT(3) 133177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_REGEXTSEL_SET_MSK BIT(4) 134177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_BGPWRDN_SET_MSK BIT(0) 135177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PWRDN_SET_MSK BIT(1) 136177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_EN_SET_MSK BIT(2) 137177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_OUTRSTALL_SET_MSK BIT(3) 138177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_REGEXTSEL_SET_MSK BIT(4) 139177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_MAINPLLACHIEVED_SET_MSK BIT(0) 140177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_PERPLLACHIEVED_SET_MSK BIT(1) 141177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_MAINPLLLOST_SET_MSK BIT(2) 142177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_PERPLLLOST_SET_MSK BIT(3) 143177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_MAINPLLRFSLIP_SET_MSK BIT(8) 144177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_PERPLLRFSLIP_SET_MSK BIT(9) 145177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_MAINPLLFBSLIP_SET_MSK BIT(10) 146177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_INTR_PERPLLFBSLIP_SET_MSK BIT(11) 147177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_CTL_BOOTMOD_SET_MSK BIT(0) 148177ba1f9SLey Foon Tan #define CLKMGR_CLKMGR_CTL_BOOTCLK_INTOSC_SET_MSK 0x00000300 149177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_EN_RESET 0x00000f7f 150177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK BIT(5) 151177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_PSRC_MSK 0x00000003 152177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO1_NUMER_MSK 0x00001fff 153177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO1_DENOM_MSK 0x0000003f 154177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_CNTRCLK_MSK 0x000003ff 155177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PSRC_MSK 0x00000003 156177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO1_NUMER_MSK 0x00001fff 157177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO1_DENOM_MSK 0x0000003f 158177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTRCLK_MSK 0x000003ff 159177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_MSK 0x00000007 160177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_CNT_MSK 0x000003ff 161177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_MAIN 0 162177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_PERI 1 163177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_OSC1 2 164177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_INTOSC 3 165177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_FPGA 4 166177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_MSK 0x00000003 167177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_CNT_MSK 0x000003ff 168177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_MSK 0x00000007 169177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_MAIN 0 170177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_PERI 1 171177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_OSC1 2 172177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_INTOSC 3 173177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_FPGA 4 174177ba1f9SLey Foon Tan 175177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_SRC_MSK 0x00000007 176177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_SRC_MAIN 0 177177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_SRC_PERI 1 178177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_SRC_OSC1 2 179177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_SRC_INTOSC 3 180177ba1f9SLey Foon Tan #define CLKMGR_PERPLLGRP_SRC_FPGA 4 181177ba1f9SLey Foon Tan 182177ba1f9SLey Foon Tan /* bit shifting macro */ 183177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO0_PSRC_LSB 8 184177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO0_PSRC_LSB 8 185177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_VCO1_DENOM_LSB 16 186177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_VCO1_DENOM_LSB 16 187177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB 16 188177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_LSB 16 189177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB 0 190177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB 8 191177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_L4SPCLK_LSB 16 192177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_CSATCLK_LSB 24 193177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_CSTRACECLK_LSB 26 194177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCDIV_CSPDBGCLK_LSB 28 195177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_SRC_LSB 16 196177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB 16 197177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_NOCCLK_SRC_LSB 16 198177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_CNTR7CLK_SRC_LSB 16 199177ba1f9SLey Foon Tan #define CLKMGR_MAINPLL_CNTR9CLK_SRC_LSB 16 200177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTR2CLK_SRC_LSB 16 201177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTR3CLK_SRC_LSB 16 202177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTR4CLK_SRC_LSB 16 203177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTR5CLK_SRC_LSB 16 204177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTR6CLK_SRC_LSB 16 205177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_CNTR8CLK_SRC_LSB 16 206177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_EMACCTL_EMAC0SEL_LSB 26 207177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_EMACCTL_EMAC1SEL_LSB 27 208177ba1f9SLey Foon Tan #define CLKMGR_PERPLL_EMACCTL_EMAC2SEL_LSB 28 209177ba1f9SLey Foon Tan 210177ba1f9SLey Foon Tan /* PLL ramping work around */ 211177ba1f9SLey Foon Tan #define CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ 900000000 212177ba1f9SLey Foon Tan #define CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ 300000000 213177ba1f9SLey Foon Tan #define CLKMGR_PLL_RAMP_MPUCLK_INCREMENT_HZ 100000000 214177ba1f9SLey Foon Tan #define CLKMGR_PLL_RAMP_NOCCLK_INCREMENT_HZ 33000000 215177ba1f9SLey Foon Tan 216177ba1f9SLey Foon Tan #define CLKMGR_STAT_BUSY BIT(0) 217177ba1f9SLey Foon Tan 218177ba1f9SLey Foon Tan #endif /* CLOCK_MANAGER_ARRIA10 */ 219