00001 /* Copyright (c) 2007, Atmel Corporation All rights reserved. 00002 * 00003 * Redistribution and use in source and binary forms, with or without 00004 * modification, are permitted provided that the following conditions are met: 00005 * 00006 * 1. Redistributions of source code must retain the above copyright notice, 00007 * this list of conditions and the following disclaimer. 00008 * 00009 * 2. Redistributions in binary form must reproduce the above copyright notice, 00010 * this list of conditions and the following disclaimer in the documentation 00011 * and/or other materials provided with the distribution. 00012 * 00013 * 3. The name of ATMEL may not be used to endorse or promote products derived 00014 * from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND 00019 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00020 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00023 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00025 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00028 #ifndef _AVR32_PM_H_ 00029 #define _AVR32_PM_H_ 00030 00031 #include <avr32/io.h> 00032 #include "errno.h" 00033 #include "at32stk1000.h" 00034 00035 #define PM_TIMEOUT 500000 00036 00037 #define PM_OSC0_HZ OSC0_FREQ 00038 #define PM_OSC1_HZ OSC1_FREQ 00039 00040 #define PM_OSC0 0 00041 #define PM_OSC1 1 00042 00043 #define PM_PLL0 2 00044 #define PM_PLL1 3 00045 00046 #define PM_PBB_CLOCK 10 00047 #define PM_PBA_CLOCK 11 00048 #define PM_HSB_CLOCK 12 00049 #define PM_CPU_CLOCK 13 00050 00051 #define PM_INT_SOURCES 7 00052 00053 /* CPUMASK */ 00054 #define PM_CPU_DOMAIN 0 00055 #define PM_CPU_DOMAIN_SIZE 1 00056 #define PM_CPU_PICO 0 00057 00058 /*HSB*/ 00059 #define PM_HSB_DOMAIN 1 00060 #define PM_HSB_DOMAIN_SIZE 11 00061 #define PM_HSB_HEBI 32 00062 #define PM_HSB_PBA 33 00063 #define PM_HSB_PBB 34 00064 #define PM_HSB_SDRAMC 35 00065 #define PM_HSB_HSBBRIDGE 36 00066 #define PM_HSB_HISI 37 00067 #define PM_HSB_USB 38 00068 #define PM_HSB_LCDC 39 00069 #define PM_HSB_MACB0 40 00070 #define PM_HSB_MACB1 41 00071 #define PM_HSB_DMAC 42 00072 00073 /*PBA*/ 00074 #define PM_PBA_DOMAIN 2 00075 #define PM_PBA_DOMAIN_SIZE 17 00076 #define PM_PBA_SPI0 64 00077 #define PM_PBA_SPI1 65 00078 #define PM_PBA_TWI 66 00079 #define PM_PBA_USART0 67 00080 #define PM_PBA_USART1 68 00081 #define PM_PBA_USART2 69 00082 #define PM_PBA_USART3 70 00083 #define PM_PBA_SSC0 71 00084 #define PM_PBA_SSC1 72 00085 #define PM_PBA_SSC2 73 00086 #define PM_PBA_PIOA 74 00087 #define PM_PBA_PIOB 75 00088 #define PM_PBA_PIOC 76 00089 #define PM_PBA_PIOD 77 00090 #define PM_PBA_PIOE 78 00091 #define PM_PBA_PIOF 80 00092 #define PM_PBA_HPDC 81 00093 00094 /* PBB */ 00095 #define PM_PBB_DOMAIN 3 00096 #define PM_PBB_DOMAIN_SIZE 15 00097 #define PM_PBB_SM 96 00098 #define PM_PBB_INTC 97 00099 #define PM_PBB_HMATRIX 98 00100 #define PM_PBB_TIMER0 99 00101 #define PM_PBB_TIMER1 100 00102 #define PM_PBB_PWM 101 00103 #define PM_PBB_MACB0 102 00104 #define PM_PBB_MACB1 103 00105 #define PM_PBB_DAC 104 00106 #define PM_PBB_MMCI 105 00107 #define PM_PBB_AUDIOC 106 00108 #define PM_PBB_HISI 107 00109 #define PM_PBB_USB 108 00110 #define PM_PBB_HSMC 109 00111 #define PM_PBB_HSDRAMC 110 00112 #define PM_PBB_HECC 111 00113 00114 struct pll_opt_t{ 00115 unsigned int pll; 00116 unsigned int multiplier; 00117 unsigned int divider; 00118 unsigned int oscillator; 00119 }; 00120 00121 struct clk_sel_opt_t{ 00122 unsigned int clock; 00123 unsigned int divider; 00124 unsigned int div_enable; 00125 }; 00126 00127 struct gen_clk_opt_t{ 00128 unsigned int div; 00129 unsigned int diven; 00130 unsigned int cen; 00131 unsigned int pllsel; 00132 unsigned int oscsel; 00133 }; 00134 00135 /* reset all clocks and set mclk to OSC0 */ 00136 int pm_reset( void ); 00137 00138 /* wait for lock bit to settle */ 00139 int pm_wait_for_lock(unsigned int lockbit); 00140 00141 00142 00143 /* Modify a specific pll */ 00144 int pm_set_pll( volatile struct pll_opt_t *opt ); 00145 00146 /* Read a specific pll */ 00147 int pm_read_pll_frequency( unsigned int pll ); 00148 00149 /*Read a specific oscillator value*/ 00150 int pm_read_osc( unsigned int osc ); 00151 00152 00153 00154 /* Set the source for the main clock */ 00155 int pm_set_mclk_source(unsigned int source); 00156 00157 /* Read the main clock src */ 00158 int pm_read_mclk_source( void ); 00159 00160 /* Read the main clock frequency*/ 00161 int pm_read_mclk( void ); 00162 00163 00164 00165 int pm_read_clock_domain_scaler(unsigned int clock_domain); 00166 00167 /* Select clocks for different domains of the system */ 00168 int pm_set_clock_domain_scaler(volatile struct clk_sel_opt_t *opt); 00169 00170 /* Return the value of the scaling register */ 00171 int pm_read_scaling_register(void); 00172 00173 /* Read the actual clock frequency a specific module is running at*/ 00174 int pm_read_module_frequency(int module); 00175 00176 /* Unmask a single module clock part of a clock domain */ 00177 int pm_unmask_module_clock( unsigned int clock); 00178 00179 /* Mask a single module clock part of a clock domain */ 00180 int pm_mask_module_clock( unsigned int clock); 00181 00182 /* Unmask all module clocks */ 00183 void pm_unmask_all_module_clocks( void ); 00184 00185 /* Mask all module clocks */ 00186 void pm_mask_all_module_clocks( void ); 00187 00188 00189 00190 /* Enable interrupt */ 00191 int pm_interrupt_enable( unsigned int source ); 00192 00193 /* Disable interrupt*/ 00194 int pm_interrupt_disable( unsigned int source ); 00195 00196 /* Status of interrupt*/ 00197 int pm_interrupt_status( unsigned int source ); 00198 00199 /* Clear interrupt */ 00200 int pm_interrupt_clear( unsigned int source ); 00201 00202 /* Clear interrupt */ 00203 int pm_interrupt_mask( unsigned int source ); 00204 00205 00206 00207 /* Modify the generic clock */ 00208 int pm_generic_clock_control( struct gen_clk_opt_t *opt, unsigned char genclk); 00209 00210 00211 #endif /* _AVR32_SYSTEM_MANAGER_H_ */
1.5.3-20071008