Merge branch 'akpm'
[linux-2.6/next.git] / arch / blackfin / include / mach-common / pll.h
blob382178b361af55c83ad982e4ef40d4c0b3fd172b
1 /*
2 * Copyright 2005-2010 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
5 */
7 #ifndef _MACH_COMMON_PLL_H
8 #define _MACH_COMMON_PLL_H
10 #ifndef __ASSEMBLY__
12 #include <asm/blackfin.h>
13 #include <asm/irqflags.h>
15 #ifndef bfin_iwr_restore
16 static inline void
17 bfin_iwr_restore(unsigned long iwr0, unsigned long iwr1, unsigned long iwr2)
19 #ifdef SIC_IWR
20 bfin_write_SIC_IWR(iwr0);
21 #else
22 bfin_write_SIC_IWR0(iwr0);
23 # ifdef SIC_IWR1
24 bfin_write_SIC_IWR1(iwr1);
25 # endif
26 # ifdef SIC_IWR2
27 bfin_write_SIC_IWR2(iwr2);
28 # endif
29 #endif
31 #endif
33 #ifndef bfin_iwr_save
34 static inline void
35 bfin_iwr_save(unsigned long niwr0, unsigned long niwr1, unsigned long niwr2,
36 unsigned long *iwr0, unsigned long *iwr1, unsigned long *iwr2)
38 #ifdef SIC_IWR
39 *iwr0 = bfin_read_SIC_IWR();
40 #else
41 *iwr0 = bfin_read_SIC_IWR0();
42 # ifdef SIC_IWR1
43 *iwr1 = bfin_read_SIC_IWR1();
44 # endif
45 # ifdef SIC_IWR2
46 *iwr2 = bfin_read_SIC_IWR2();
47 # endif
48 #endif
49 bfin_iwr_restore(niwr0, niwr1, niwr2);
51 #endif
53 static inline void _bfin_write_pll_relock(u32 addr, unsigned int val)
55 unsigned long flags, iwr0, iwr1, iwr2;
57 if (val == bfin_read_PLL_CTL())
58 return;
60 flags = hard_local_irq_save();
61 /* Enable the PLL Wakeup bit in SIC IWR */
62 bfin_iwr_save(IWR_ENABLE(0), 0, 0, &iwr0, &iwr1, &iwr2);
64 bfin_write16(addr, val);
65 SSYNC();
66 asm("IDLE;");
68 bfin_iwr_restore(iwr0, iwr1, iwr2);
69 hard_local_irq_restore(flags);
72 /* Writing to PLL_CTL initiates a PLL relock sequence */
73 static inline void bfin_write_PLL_CTL(unsigned int val)
75 _bfin_write_pll_relock(PLL_CTL, val);
78 /* Writing to VR_CTL initiates a PLL relock sequence */
79 static inline void bfin_write_VR_CTL(unsigned int val)
81 _bfin_write_pll_relock(VR_CTL, val);
84 #endif
86 #endif