1*00a2749dSAllen Martin /* 2*00a2749dSAllen Martin * Copyright (c) 2011 The Chromium OS Authors. 3*00a2749dSAllen Martin * See file CREDITS for list of people who contributed to this 4*00a2749dSAllen Martin * project. 5*00a2749dSAllen Martin * 6*00a2749dSAllen Martin * This program is free software; you can redistribute it and/or 7*00a2749dSAllen Martin * modify it under the terms of the GNU General Public License as 8*00a2749dSAllen Martin * published by the Free Software Foundation; either version 2 of 9*00a2749dSAllen Martin * the License, or (at your option) any later version. 10*00a2749dSAllen Martin * 11*00a2749dSAllen Martin * This program is distributed in the hope that it will be useful, 12*00a2749dSAllen Martin * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*00a2749dSAllen Martin * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*00a2749dSAllen Martin * GNU General Public License for more details. 15*00a2749dSAllen Martin * 16*00a2749dSAllen Martin * You should have received a copy of the GNU General Public License 17*00a2749dSAllen Martin * along with this program; if not, write to the Free Software 18*00a2749dSAllen Martin * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19*00a2749dSAllen Martin * MA 02111-1307 USA 20*00a2749dSAllen Martin */ 21*00a2749dSAllen Martin 22*00a2749dSAllen Martin /* Tegra2 clock control functions */ 23*00a2749dSAllen Martin 24*00a2749dSAllen Martin #ifndef _CLOCK_H 25*00a2749dSAllen Martin #define _CLOCK_H 26*00a2749dSAllen Martin 27*00a2749dSAllen Martin /* Set of oscillator frequencies supported in the internal API. */ 28*00a2749dSAllen Martin enum clock_osc_freq { 29*00a2749dSAllen Martin /* All in MHz, so 13_0 is 13.0MHz */ 30*00a2749dSAllen Martin CLOCK_OSC_FREQ_13_0, 31*00a2749dSAllen Martin CLOCK_OSC_FREQ_19_2, 32*00a2749dSAllen Martin CLOCK_OSC_FREQ_12_0, 33*00a2749dSAllen Martin CLOCK_OSC_FREQ_26_0, 34*00a2749dSAllen Martin 35*00a2749dSAllen Martin CLOCK_OSC_FREQ_COUNT, 36*00a2749dSAllen Martin }; 37*00a2749dSAllen Martin 38*00a2749dSAllen Martin /* The PLLs supported by the hardware */ 39*00a2749dSAllen Martin enum clock_id { 40*00a2749dSAllen Martin CLOCK_ID_FIRST, 41*00a2749dSAllen Martin CLOCK_ID_CGENERAL = CLOCK_ID_FIRST, 42*00a2749dSAllen Martin CLOCK_ID_MEMORY, 43*00a2749dSAllen Martin CLOCK_ID_PERIPH, 44*00a2749dSAllen Martin CLOCK_ID_AUDIO, 45*00a2749dSAllen Martin CLOCK_ID_USB, 46*00a2749dSAllen Martin CLOCK_ID_DISPLAY, 47*00a2749dSAllen Martin 48*00a2749dSAllen Martin /* now the simple ones */ 49*00a2749dSAllen Martin CLOCK_ID_FIRST_SIMPLE, 50*00a2749dSAllen Martin CLOCK_ID_XCPU = CLOCK_ID_FIRST_SIMPLE, 51*00a2749dSAllen Martin CLOCK_ID_EPCI, 52*00a2749dSAllen Martin CLOCK_ID_SFROM32KHZ, 53*00a2749dSAllen Martin 54*00a2749dSAllen Martin /* These are the base clocks (inputs to the Tegra SOC) */ 55*00a2749dSAllen Martin CLOCK_ID_32KHZ, 56*00a2749dSAllen Martin CLOCK_ID_OSC, 57*00a2749dSAllen Martin 58*00a2749dSAllen Martin CLOCK_ID_COUNT, /* number of clocks */ 59*00a2749dSAllen Martin CLOCK_ID_NONE = -1, 60*00a2749dSAllen Martin }; 61*00a2749dSAllen Martin 62*00a2749dSAllen Martin /* The clocks supported by the hardware */ 63*00a2749dSAllen Martin enum periph_id { 64*00a2749dSAllen Martin PERIPH_ID_FIRST, 65*00a2749dSAllen Martin 66*00a2749dSAllen Martin /* Low word: 31:0 */ 67*00a2749dSAllen Martin PERIPH_ID_CPU = PERIPH_ID_FIRST, 68*00a2749dSAllen Martin PERIPH_ID_RESERVED1, 69*00a2749dSAllen Martin PERIPH_ID_RESERVED2, 70*00a2749dSAllen Martin PERIPH_ID_AC97, 71*00a2749dSAllen Martin PERIPH_ID_RTC, 72*00a2749dSAllen Martin PERIPH_ID_TMR, 73*00a2749dSAllen Martin PERIPH_ID_UART1, 74*00a2749dSAllen Martin PERIPH_ID_UART2, 75*00a2749dSAllen Martin 76*00a2749dSAllen Martin /* 8 */ 77*00a2749dSAllen Martin PERIPH_ID_GPIO, 78*00a2749dSAllen Martin PERIPH_ID_SDMMC2, 79*00a2749dSAllen Martin PERIPH_ID_SPDIF, 80*00a2749dSAllen Martin PERIPH_ID_I2S1, 81*00a2749dSAllen Martin PERIPH_ID_I2C1, 82*00a2749dSAllen Martin PERIPH_ID_NDFLASH, 83*00a2749dSAllen Martin PERIPH_ID_SDMMC1, 84*00a2749dSAllen Martin PERIPH_ID_SDMMC4, 85*00a2749dSAllen Martin 86*00a2749dSAllen Martin /* 16 */ 87*00a2749dSAllen Martin PERIPH_ID_TWC, 88*00a2749dSAllen Martin PERIPH_ID_PWM, 89*00a2749dSAllen Martin PERIPH_ID_I2S2, 90*00a2749dSAllen Martin PERIPH_ID_EPP, 91*00a2749dSAllen Martin PERIPH_ID_VI, 92*00a2749dSAllen Martin PERIPH_ID_2D, 93*00a2749dSAllen Martin PERIPH_ID_USBD, 94*00a2749dSAllen Martin PERIPH_ID_ISP, 95*00a2749dSAllen Martin 96*00a2749dSAllen Martin /* 24 */ 97*00a2749dSAllen Martin PERIPH_ID_3D, 98*00a2749dSAllen Martin PERIPH_ID_IDE, 99*00a2749dSAllen Martin PERIPH_ID_DISP2, 100*00a2749dSAllen Martin PERIPH_ID_DISP1, 101*00a2749dSAllen Martin PERIPH_ID_HOST1X, 102*00a2749dSAllen Martin PERIPH_ID_VCP, 103*00a2749dSAllen Martin PERIPH_ID_RESERVED30, 104*00a2749dSAllen Martin PERIPH_ID_CACHE2, 105*00a2749dSAllen Martin 106*00a2749dSAllen Martin /* Middle word: 63:32 */ 107*00a2749dSAllen Martin PERIPH_ID_MEM, 108*00a2749dSAllen Martin PERIPH_ID_AHBDMA, 109*00a2749dSAllen Martin PERIPH_ID_APBDMA, 110*00a2749dSAllen Martin PERIPH_ID_RESERVED35, 111*00a2749dSAllen Martin PERIPH_ID_KBC, 112*00a2749dSAllen Martin PERIPH_ID_STAT_MON, 113*00a2749dSAllen Martin PERIPH_ID_PMC, 114*00a2749dSAllen Martin PERIPH_ID_FUSE, 115*00a2749dSAllen Martin 116*00a2749dSAllen Martin /* 40 */ 117*00a2749dSAllen Martin PERIPH_ID_KFUSE, 118*00a2749dSAllen Martin PERIPH_ID_SBC1, 119*00a2749dSAllen Martin PERIPH_ID_SNOR, 120*00a2749dSAllen Martin PERIPH_ID_SPI1, 121*00a2749dSAllen Martin PERIPH_ID_SBC2, 122*00a2749dSAllen Martin PERIPH_ID_XIO, 123*00a2749dSAllen Martin PERIPH_ID_SBC3, 124*00a2749dSAllen Martin PERIPH_ID_DVC_I2C, 125*00a2749dSAllen Martin 126*00a2749dSAllen Martin /* 48 */ 127*00a2749dSAllen Martin PERIPH_ID_DSI, 128*00a2749dSAllen Martin PERIPH_ID_TVO, 129*00a2749dSAllen Martin PERIPH_ID_MIPI, 130*00a2749dSAllen Martin PERIPH_ID_HDMI, 131*00a2749dSAllen Martin PERIPH_ID_CSI, 132*00a2749dSAllen Martin PERIPH_ID_TVDAC, 133*00a2749dSAllen Martin PERIPH_ID_I2C2, 134*00a2749dSAllen Martin PERIPH_ID_UART3, 135*00a2749dSAllen Martin 136*00a2749dSAllen Martin /* 56 */ 137*00a2749dSAllen Martin PERIPH_ID_RESERVED56, 138*00a2749dSAllen Martin PERIPH_ID_EMC, 139*00a2749dSAllen Martin PERIPH_ID_USB2, 140*00a2749dSAllen Martin PERIPH_ID_USB3, 141*00a2749dSAllen Martin PERIPH_ID_MPE, 142*00a2749dSAllen Martin PERIPH_ID_VDE, 143*00a2749dSAllen Martin PERIPH_ID_BSEA, 144*00a2749dSAllen Martin PERIPH_ID_BSEV, 145*00a2749dSAllen Martin 146*00a2749dSAllen Martin /* Upper word 95:64 */ 147*00a2749dSAllen Martin PERIPH_ID_SPEEDO, 148*00a2749dSAllen Martin PERIPH_ID_UART4, 149*00a2749dSAllen Martin PERIPH_ID_UART5, 150*00a2749dSAllen Martin PERIPH_ID_I2C3, 151*00a2749dSAllen Martin PERIPH_ID_SBC4, 152*00a2749dSAllen Martin PERIPH_ID_SDMMC3, 153*00a2749dSAllen Martin PERIPH_ID_PCIE, 154*00a2749dSAllen Martin PERIPH_ID_OWR, 155*00a2749dSAllen Martin 156*00a2749dSAllen Martin /* 72 */ 157*00a2749dSAllen Martin PERIPH_ID_AFI, 158*00a2749dSAllen Martin PERIPH_ID_CORESIGHT, 159*00a2749dSAllen Martin PERIPH_ID_RESERVED74, 160*00a2749dSAllen Martin PERIPH_ID_AVPUCQ, 161*00a2749dSAllen Martin PERIPH_ID_RESERVED76, 162*00a2749dSAllen Martin PERIPH_ID_RESERVED77, 163*00a2749dSAllen Martin PERIPH_ID_RESERVED78, 164*00a2749dSAllen Martin PERIPH_ID_RESERVED79, 165*00a2749dSAllen Martin 166*00a2749dSAllen Martin /* 80 */ 167*00a2749dSAllen Martin PERIPH_ID_RESERVED80, 168*00a2749dSAllen Martin PERIPH_ID_RESERVED81, 169*00a2749dSAllen Martin PERIPH_ID_RESERVED82, 170*00a2749dSAllen Martin PERIPH_ID_RESERVED83, 171*00a2749dSAllen Martin PERIPH_ID_IRAMA, 172*00a2749dSAllen Martin PERIPH_ID_IRAMB, 173*00a2749dSAllen Martin PERIPH_ID_IRAMC, 174*00a2749dSAllen Martin PERIPH_ID_IRAMD, 175*00a2749dSAllen Martin 176*00a2749dSAllen Martin /* 88 */ 177*00a2749dSAllen Martin PERIPH_ID_CRAM2, 178*00a2749dSAllen Martin 179*00a2749dSAllen Martin PERIPH_ID_COUNT, 180*00a2749dSAllen Martin PERIPH_ID_NONE = -1, 181*00a2749dSAllen Martin }; 182*00a2749dSAllen Martin 183*00a2749dSAllen Martin /* Converts a clock number to a clock register: 0=L, 1=H, 2=U */ 184*00a2749dSAllen Martin #define PERIPH_REG(id) ((id) >> 5) 185*00a2749dSAllen Martin 186*00a2749dSAllen Martin /* Mask value for a clock (within PERIPH_REG(id)) */ 187*00a2749dSAllen Martin #define PERIPH_MASK(id) (1 << ((id) & 0x1f)) 188*00a2749dSAllen Martin 189*00a2749dSAllen Martin /* return 1 if a PLL ID is in range, and not a simple PLL */ 190*00a2749dSAllen Martin #define clock_id_is_pll(id) ((id) >= CLOCK_ID_FIRST && \ 191*00a2749dSAllen Martin (id) < CLOCK_ID_FIRST_SIMPLE) 192*00a2749dSAllen Martin 193*00a2749dSAllen Martin /* PLL stabilization delay in usec */ 194*00a2749dSAllen Martin #define CLOCK_PLL_STABLE_DELAY_US 300 195*00a2749dSAllen Martin 196*00a2749dSAllen Martin /* return the current oscillator clock frequency */ 197*00a2749dSAllen Martin enum clock_osc_freq clock_get_osc_freq(void); 198*00a2749dSAllen Martin 199*00a2749dSAllen Martin /** 200*00a2749dSAllen Martin * Start PLL using the provided configuration parameters. 201*00a2749dSAllen Martin * 202*00a2749dSAllen Martin * @param id clock id 203*00a2749dSAllen Martin * @param divm input divider 204*00a2749dSAllen Martin * @param divn feedback divider 205*00a2749dSAllen Martin * @param divp post divider 2^n 206*00a2749dSAllen Martin * @param cpcon charge pump setup control 207*00a2749dSAllen Martin * @param lfcon loop filter setup control 208*00a2749dSAllen Martin * 209*00a2749dSAllen Martin * @returns monotonic time in us that the PLL will be stable 210*00a2749dSAllen Martin */ 211*00a2749dSAllen Martin unsigned long clock_start_pll(enum clock_id id, u32 divm, u32 divn, 212*00a2749dSAllen Martin u32 divp, u32 cpcon, u32 lfcon); 213*00a2749dSAllen Martin 214*00a2749dSAllen Martin /** 215*00a2749dSAllen Martin * Read low-level parameters of a PLL. 216*00a2749dSAllen Martin * 217*00a2749dSAllen Martin * @param id clock id to read (note: USB is not supported) 218*00a2749dSAllen Martin * @param divm returns input divider 219*00a2749dSAllen Martin * @param divn returns feedback divider 220*00a2749dSAllen Martin * @param divp returns post divider 2^n 221*00a2749dSAllen Martin * @param cpcon returns charge pump setup control 222*00a2749dSAllen Martin * @param lfcon returns loop filter setup control 223*00a2749dSAllen Martin * 224*00a2749dSAllen Martin * @returns 0 if ok, -1 on error (invalid clock id) 225*00a2749dSAllen Martin */ 226*00a2749dSAllen Martin int clock_ll_read_pll(enum clock_id clkid, u32 *divm, u32 *divn, 227*00a2749dSAllen Martin u32 *divp, u32 *cpcon, u32 *lfcon); 228*00a2749dSAllen Martin 229*00a2749dSAllen Martin /* 230*00a2749dSAllen Martin * Enable a clock 231*00a2749dSAllen Martin * 232*00a2749dSAllen Martin * @param id clock id 233*00a2749dSAllen Martin */ 234*00a2749dSAllen Martin void clock_enable(enum periph_id clkid); 235*00a2749dSAllen Martin 236*00a2749dSAllen Martin /* 237*00a2749dSAllen Martin * Disable a clock 238*00a2749dSAllen Martin * 239*00a2749dSAllen Martin * @param id clock id 240*00a2749dSAllen Martin */ 241*00a2749dSAllen Martin void clock_disable(enum periph_id clkid); 242*00a2749dSAllen Martin 243*00a2749dSAllen Martin /* 244*00a2749dSAllen Martin * Set whether a clock is enabled or disabled. 245*00a2749dSAllen Martin * 246*00a2749dSAllen Martin * @param id clock id 247*00a2749dSAllen Martin * @param enable 1 to enable, 0 to disable 248*00a2749dSAllen Martin */ 249*00a2749dSAllen Martin void clock_set_enable(enum periph_id clkid, int enable); 250*00a2749dSAllen Martin 251*00a2749dSAllen Martin /** 252*00a2749dSAllen Martin * Reset a peripheral. This puts it in reset, waits for a delay, then takes 253*00a2749dSAllen Martin * it out of reset and waits for th delay again. 254*00a2749dSAllen Martin * 255*00a2749dSAllen Martin * @param periph_id peripheral to reset 256*00a2749dSAllen Martin * @param us_delay time to delay in microseconds 257*00a2749dSAllen Martin */ 258*00a2749dSAllen Martin void reset_periph(enum periph_id periph_id, int us_delay); 259*00a2749dSAllen Martin 260*00a2749dSAllen Martin /** 261*00a2749dSAllen Martin * Put a peripheral into or out of reset. 262*00a2749dSAllen Martin * 263*00a2749dSAllen Martin * @param periph_id peripheral to reset 264*00a2749dSAllen Martin * @param enable 1 to put into reset, 0 to take out of reset 265*00a2749dSAllen Martin */ 266*00a2749dSAllen Martin void reset_set_enable(enum periph_id periph_id, int enable); 267*00a2749dSAllen Martin 268*00a2749dSAllen Martin 269*00a2749dSAllen Martin /* CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET/CLR_0 */ 270*00a2749dSAllen Martin enum crc_reset_id { 271*00a2749dSAllen Martin /* Things we can hold in reset for each CPU */ 272*00a2749dSAllen Martin crc_rst_cpu = 1, 273*00a2749dSAllen Martin crc_rst_de = 1 << 2, /* What is de? */ 274*00a2749dSAllen Martin crc_rst_watchdog = 1 << 3, 275*00a2749dSAllen Martin crc_rst_debug = 1 << 4, 276*00a2749dSAllen Martin }; 277*00a2749dSAllen Martin 278*00a2749dSAllen Martin /** 279*00a2749dSAllen Martin * Put parts of the CPU complex into or out of reset.\ 280*00a2749dSAllen Martin * 281*00a2749dSAllen Martin * @param cpu cpu number (0 or 1 on Tegra2) 282*00a2749dSAllen Martin * @param which which parts of the complex to affect (OR of crc_reset_id) 283*00a2749dSAllen Martin * @param reset 1 to assert reset, 0 to de-assert 284*00a2749dSAllen Martin */ 285*00a2749dSAllen Martin void reset_cmplx_set_enable(int cpu, int which, int reset); 286*00a2749dSAllen Martin 287*00a2749dSAllen Martin /** 288*00a2749dSAllen Martin * Set the source for a peripheral clock. This plus the divisor sets the 289*00a2749dSAllen Martin * clock rate. You need to look up the datasheet to see the meaning of the 290*00a2749dSAllen Martin * source parameter as it changes for each peripheral. 291*00a2749dSAllen Martin * 292*00a2749dSAllen Martin * Warning: This function is only for use pre-relocation. Please use 293*00a2749dSAllen Martin * clock_start_periph_pll() instead. 294*00a2749dSAllen Martin * 295*00a2749dSAllen Martin * @param periph_id peripheral to adjust 296*00a2749dSAllen Martin * @param source source clock (0, 1, 2 or 3) 297*00a2749dSAllen Martin */ 298*00a2749dSAllen Martin void clock_ll_set_source(enum periph_id periph_id, unsigned source); 299*00a2749dSAllen Martin 300*00a2749dSAllen Martin /** 301*00a2749dSAllen Martin * Set the source and divisor for a peripheral clock. This sets the 302*00a2749dSAllen Martin * clock rate. You need to look up the datasheet to see the meaning of the 303*00a2749dSAllen Martin * source parameter as it changes for each peripheral. 304*00a2749dSAllen Martin * 305*00a2749dSAllen Martin * Warning: This function is only for use pre-relocation. Please use 306*00a2749dSAllen Martin * clock_start_periph_pll() instead. 307*00a2749dSAllen Martin * 308*00a2749dSAllen Martin * @param periph_id peripheral to adjust 309*00a2749dSAllen Martin * @param source source clock (0, 1, 2 or 3) 310*00a2749dSAllen Martin * @param divisor divisor value to use 311*00a2749dSAllen Martin */ 312*00a2749dSAllen Martin void clock_ll_set_source_divisor(enum periph_id periph_id, unsigned source, 313*00a2749dSAllen Martin unsigned divisor); 314*00a2749dSAllen Martin 315*00a2749dSAllen Martin /** 316*00a2749dSAllen Martin * Start a peripheral PLL clock at the given rate. This also resets the 317*00a2749dSAllen Martin * peripheral. 318*00a2749dSAllen Martin * 319*00a2749dSAllen Martin * @param periph_id peripheral to start 320*00a2749dSAllen Martin * @param parent PLL id of required parent clock 321*00a2749dSAllen Martin * @param rate Required clock rate in Hz 322*00a2749dSAllen Martin * @return rate selected in Hz, or -1U if something went wrong 323*00a2749dSAllen Martin */ 324*00a2749dSAllen Martin unsigned clock_start_periph_pll(enum periph_id periph_id, 325*00a2749dSAllen Martin enum clock_id parent, unsigned rate); 326*00a2749dSAllen Martin 327*00a2749dSAllen Martin /** 328*00a2749dSAllen Martin * Returns the rate of a peripheral clock in Hz. Since the caller almost 329*00a2749dSAllen Martin * certainly knows the parent clock (having just set it) we require that 330*00a2749dSAllen Martin * this be passed in so we don't need to work it out. 331*00a2749dSAllen Martin * 332*00a2749dSAllen Martin * @param periph_id peripheral to start 333*00a2749dSAllen Martin * @param parent PLL id of parent clock (used to calculate rate, you 334*00a2749dSAllen Martin * must know this!) 335*00a2749dSAllen Martin * @return clock rate of peripheral in Hz 336*00a2749dSAllen Martin */ 337*00a2749dSAllen Martin unsigned long clock_get_periph_rate(enum periph_id periph_id, 338*00a2749dSAllen Martin enum clock_id parent); 339*00a2749dSAllen Martin 340*00a2749dSAllen Martin /** 341*00a2749dSAllen Martin * Adjust peripheral PLL clock to the given rate. This does not reset the 342*00a2749dSAllen Martin * peripheral. If a second stage divisor is not available, pass NULL for 343*00a2749dSAllen Martin * extra_div. If it is available, then this parameter will return the 344*00a2749dSAllen Martin * divisor selected (which will be a power of 2 from 1 to 256). 345*00a2749dSAllen Martin * 346*00a2749dSAllen Martin * @param periph_id peripheral to start 347*00a2749dSAllen Martin * @param parent PLL id of required parent clock 348*00a2749dSAllen Martin * @param rate Required clock rate in Hz 349*00a2749dSAllen Martin * @param extra_div value for the second-stage divisor (NULL if one is 350*00a2749dSAllen Martin not available) 351*00a2749dSAllen Martin * @return rate selected in Hz, or -1U if something went wrong 352*00a2749dSAllen Martin */ 353*00a2749dSAllen Martin unsigned clock_adjust_periph_pll_div(enum periph_id periph_id, 354*00a2749dSAllen Martin enum clock_id parent, unsigned rate, int *extra_div); 355*00a2749dSAllen Martin 356*00a2749dSAllen Martin /** 357*00a2749dSAllen Martin * Returns the clock rate of a specified clock, in Hz. 358*00a2749dSAllen Martin * 359*00a2749dSAllen Martin * @param parent PLL id of clock to check 360*00a2749dSAllen Martin * @return rate of clock in Hz 361*00a2749dSAllen Martin */ 362*00a2749dSAllen Martin unsigned clock_get_rate(enum clock_id clkid); 363*00a2749dSAllen Martin 364*00a2749dSAllen Martin /** 365*00a2749dSAllen Martin * Start up a UART using low-level calls 366*00a2749dSAllen Martin * 367*00a2749dSAllen Martin * Prior to relocation clock_start_periph_pll() cannot be called. This 368*00a2749dSAllen Martin * function provides a way to set up a UART using low-level calls which 369*00a2749dSAllen Martin * do not require BSS. 370*00a2749dSAllen Martin * 371*00a2749dSAllen Martin * @param periph_id Peripheral ID of UART to enable (e,g, PERIPH_ID_UART1) 372*00a2749dSAllen Martin */ 373*00a2749dSAllen Martin void clock_ll_start_uart(enum periph_id periph_id); 374*00a2749dSAllen Martin 375*00a2749dSAllen Martin /** 376*00a2749dSAllen Martin * Decode a peripheral ID from a device tree node. 377*00a2749dSAllen Martin * 378*00a2749dSAllen Martin * This works by looking up the peripheral's 'clocks' node and reading out 379*00a2749dSAllen Martin * the second cell, which is the clock number / peripheral ID. 380*00a2749dSAllen Martin * 381*00a2749dSAllen Martin * @param blob FDT blob to use 382*00a2749dSAllen Martin * @param node Node to look at 383*00a2749dSAllen Martin * @return peripheral ID, or PERIPH_ID_NONE if none 384*00a2749dSAllen Martin */ 385*00a2749dSAllen Martin enum periph_id clock_decode_periph_id(const void *blob, int node); 386*00a2749dSAllen Martin 387*00a2749dSAllen Martin /** 388*00a2749dSAllen Martin * Checks if the oscillator bypass is enabled (XOBP bit) 389*00a2749dSAllen Martin * 390*00a2749dSAllen Martin * @return 1 if bypass is enabled, 0 if not 391*00a2749dSAllen Martin */ 392*00a2749dSAllen Martin int clock_get_osc_bypass(void); 393*00a2749dSAllen Martin 394*00a2749dSAllen Martin /* 395*00a2749dSAllen Martin * Checks that clocks are valid and prints a warning if not 396*00a2749dSAllen Martin * 397*00a2749dSAllen Martin * @return 0 if ok, -1 on error 398*00a2749dSAllen Martin */ 399*00a2749dSAllen Martin int clock_verify(void); 400*00a2749dSAllen Martin 401*00a2749dSAllen Martin /* Initialize the clocks */ 402*00a2749dSAllen Martin void clock_init(void); 403*00a2749dSAllen Martin 404*00a2749dSAllen Martin /* Initialize the PLLs */ 405*00a2749dSAllen Martin void clock_early_init(void); 406*00a2749dSAllen Martin 407*00a2749dSAllen Martin #endif 408