Path: blob/master/arch/blackfin/include/mach-common/pll.h
15126 views
/*1* Copyright 2005-2010 Analog Devices Inc.2*3* Licensed under the GPL-2 or later.4*/56#ifndef _MACH_COMMON_PLL_H7#define _MACH_COMMON_PLL_H89#ifndef __ASSEMBLY__1011#include <asm/blackfin.h>12#include <asm/irqflags.h>1314#ifndef bfin_iwr_restore15static inline void16bfin_iwr_restore(unsigned long iwr0, unsigned long iwr1, unsigned long iwr2)17{18#ifdef SIC_IWR19bfin_write_SIC_IWR(iwr0);20#else21bfin_write_SIC_IWR0(iwr0);22# ifdef SIC_IWR123bfin_write_SIC_IWR1(iwr1);24# endif25# ifdef SIC_IWR226bfin_write_SIC_IWR2(iwr2);27# endif28#endif29}30#endif3132#ifndef bfin_iwr_save33static inline void34bfin_iwr_save(unsigned long niwr0, unsigned long niwr1, unsigned long niwr2,35unsigned long *iwr0, unsigned long *iwr1, unsigned long *iwr2)36{37#ifdef SIC_IWR38*iwr0 = bfin_read_SIC_IWR();39#else40*iwr0 = bfin_read_SIC_IWR0();41# ifdef SIC_IWR142*iwr1 = bfin_read_SIC_IWR1();43# endif44# ifdef SIC_IWR245*iwr2 = bfin_read_SIC_IWR2();46# endif47#endif48bfin_iwr_restore(niwr0, niwr1, niwr2);49}50#endif5152static inline void _bfin_write_pll_relock(u32 addr, unsigned int val)53{54unsigned long flags, iwr0, iwr1, iwr2;5556if (val == bfin_read_PLL_CTL())57return;5859flags = hard_local_irq_save();60/* Enable the PLL Wakeup bit in SIC IWR */61bfin_iwr_save(IWR_ENABLE(0), 0, 0, &iwr0, &iwr1, &iwr2);6263bfin_write16(addr, val);64SSYNC();65asm("IDLE;");6667bfin_iwr_restore(iwr0, iwr1, iwr2);68hard_local_irq_restore(flags);69}7071/* Writing to PLL_CTL initiates a PLL relock sequence */72static inline void bfin_write_PLL_CTL(unsigned int val)73{74_bfin_write_pll_relock(PLL_CTL, val);75}7677/* Writing to VR_CTL initiates a PLL relock sequence */78static inline void bfin_write_VR_CTL(unsigned int val)79{80_bfin_write_pll_relock(VR_CTL, val);81}8283#endif8485#endif868788