]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/arch/arm/mach-lpc21xx/defines/lpcSCB.h
Merge branch 'master' into can-usb1
[lincan.git] / embedded / arch / arm / mach-lpc21xx / defines / lpcSCB.h
1 /******************************************************************************
2  *
3  * $RCSfile: lpcSCB.h,v $
4  * $Revision: 1.2 $
5  *
6  * Header file for Philips LPC ARM Processors.
7  * Copyright 2004 R O SoftWare
8  *
9  * No guarantees, warrantees, or promises, implied or otherwise.
10  * May be used for hobby or commercial purposes provided copyright
11  * notice remains intact.
12  *
13  *****************************************************************************/
14 #ifndef INC_LPC_SCB_H
15 #define INC_LPC_SCB_H
16
17 // System Control Block Registers
18 typedef struct
19 {
20   // Memory Accelerator Module Registers (MAM)
21   struct
22     {
23     REG_8 cr;                           // Control Register
24     REG_8 _pad0[3];
25     REG_8 tim;                          // Timing Control Register
26     REG32 _pad1[14];
27     } mam;
28
29   // Memory Mapping Control Register
30   REG_8 memmap;
31   REG32 _pad0[15];
32
33   // Phase Locked Loop Registers (PLL)
34   struct
35     {
36     REG_8 con;                          // Control Register
37     REG_8 _pad0[3];
38     REG_8 cfg;                          // Configuration Register
39     REG_8 _pad1[3];
40     REG16 stat;                         // Status Register
41     REG16 _pad2;
42     REG_8 feed;                         // Feed Register
43     REG_8 _pad3[3];
44     REG32 _pad4[4];
45     } pll;
46
47   struct
48     {
49     REG_8 con;                          // Control Register
50     REG_8 _pad0[3];
51     REG_8 cfg;                          // Configuration Register
52     REG_8 _pad1[3];
53     REG16 stat;                         // Status Register
54     REG16 _pad2;
55     REG_8 feed;                         // Feed Register
56     REG_8 _pad3[3];
57     REG32 _pad4[4];
58     } pll48;
59
60   // Power Control Registers
61   struct
62     {
63     REG_8 con;                          // Control Register
64     REG_8 _pad0[3];
65     REG32 conp;                         // Peripherals Register
66     REG32 _pad1[14];
67     } p;
68
69   // VPB Divider Register
70   REG_8 vpbdiv;
71   REG32 _pad1[15];
72
73   // External Interrupt Registers
74   struct
75     {
76     REG_8 flag;                         // Flag Register
77     REG_8 _pad0[3];
78     REG_8 wake;                         // Wakeup Register
79     REG_8 _pad1[3];
80     REG_8 mode;                         // Mode Register
81     REG_8 _pad2[3];
82     REG_8 polar;                        // Polarity Register
83     REG32 _pad3[12];
84     } ext;
85 } scbRegs_t;
86
87
88 ///////////////////////////////////////////////////////////////////////////////
89 // MAM defines
90 #define MAMCR_OFF     0
91 #define MAMCR_PART    1
92 #define MAMCR_FULL    2
93
94 #define MAMTIM_CYCLES (((CCLK) + 19999999) / 20000000)
95
96 ///////////////////////////////////////////////////////////////////////////////
97 // MEMMAP defines
98 #define MEMMAP_BBLK   0                 // Interrupt Vectors in Boot Block
99 #define MEMMAP_FLASH  1                 // Interrupt Vectors in Flash
100 #define MEMMAP_SRAM   2                 // Interrupt Vectors in SRAM
101
102 ///////////////////////////////////////////////////////////////////////////////
103 // PLL defines & computations
104 // Compute the value of PLL_DIV and test range validity
105 // FOSC & PLL_MUL should be defined in project configuration file (config.h)
106 #ifndef CCLK
107 #define CCLK          (FOSC * PLL_MUL)  // CPU Clock Freq.
108 #endif
109
110 #define FCCO_MAX      (320000000)       // Max CC Osc Freq.
111 #define PLL_DIV       (FCCO_MAX / (2 * CCLK)) // PLL Divider
112 #define FCCO          (FOSC * PLL_MUL * 2 * PLL_DIV) // CC Osc. Freq.
113
114 // PLLCON Register Bit Definitions
115 #define PLLCON_PLLE   (1 << 0)          // PLL Enable
116 #define PLLCON_PLLC   (1 << 1)          // PLL Connect
117
118 // PLLCFG Register Bit Definitions
119 #define PLLCFG_MSEL   ((PLL_MUL - 1) << 0) // PLL Multiplier
120 #define PLLCFG_PSEL   ((PLL_DIV - 1) << 5) // PLL Divider
121
122 // PLLSTAT Register Bit Definitions
123 #define PLLSTAT_LOCK  (1 << 10)         // PLL Lock Status Bit
124
125 ///////////////////////////////////////////////////////////////////////////////
126 // VPBDIV defines & computations
127 #define VPBDIV_VALUE  (PBSD & 0x03)     // VPBDIV value
128
129 #endif