]> git.sur5r.net Git - openocd/blob - src/flash/nor/at91sam7.h
eb35433739f15a3be18223b31e733dae6162d76f
[openocd] / src / flash / nor / at91sam7.h
1 /***************************************************************************
2  *   Copyright (C) 2006 by Magnus Lundin                                   *
3  *   lundin@mlu.mine.nu                                                    *
4  *                                                                         *
5  *   Copyright (C) 2006 by Gheorghe Guran (atlas)                          *
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU General Public License as published by  *
9  *   the Free Software Foundation; either version 2 of the License, or     *
10  *   (at your option) any later version.                                   *
11  *                                                                         *
12  *   This program is distributed in the hope that it will be useful,       *
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15  *   GNU General Public License for more details.                          *
16  *                                                                         *
17  *   You should have received a copy of the GNU General Public License     *
18  *   along with this program; if not, write to the                         *
19  *   Free Software Foundation, Inc.,                                       *
20  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
21  ***************************************************************************/
22
23 #ifndef AT91SAM7_H
24 #define AT91SAM7_H
25
26 struct at91sam7_flash_bank
27 {
28         /* chip id register */
29         uint32_t cidr;
30         uint16_t cidr_ext;
31         uint16_t cidr_nvptyp;
32         uint16_t cidr_arch;
33         uint16_t cidr_sramsiz;
34         uint16_t cidr_nvpsiz;
35         uint16_t cidr_nvpsiz2;
36         uint16_t cidr_eproc;
37         uint16_t cidr_version;
38         char *target_name;
39
40         /* flash auto-detection */
41         uint8_t  flash_autodetection;
42
43         /* flash geometry */
44         uint16_t pages_per_sector;
45         uint16_t pagesize;
46         uint16_t pages_in_lockregion;
47
48         /* nv memory bits */
49         uint16_t num_lockbits_on;
50         uint16_t lockbits;
51         uint16_t num_nvmbits;
52         uint16_t num_nvmbits_on;
53         uint16_t nvmbits;
54         uint8_t  securitybit;
55
56         /* 0: not init
57          * 1: fmcn for nvbits (1uS)
58          * 2: fmcn for flash (1.5uS) */
59         uint8_t  flashmode;
60
61         /* main clock status */
62         uint8_t  mck_valid;
63         uint32_t mck_freq;
64
65         /* external clock frequency */
66         uint32_t ext_freq;
67
68 };
69
70
71 /* AT91SAM7 control registers */
72 #define DBGU_CIDR                       0xFFFFF240
73 #define CKGR_MCFR                       0xFFFFFC24
74 #define CKGR_MOR                        0xFFFFFC20
75 #define CKGR_MCFR_MAINRDY       0x10000
76 #define CKGR_PLLR                       0xFFFFFC2c
77 #define CKGR_PLLR_DIV           0xff
78 #define CKGR_PLLR_MUL           0x07ff0000
79 #define PMC_MCKR                        0xFFFFFC30
80 #define PMC_MCKR_CSS            0x03
81 #define PMC_MCKR_PRES           0x1c
82
83 /* Flash Controller Commands */
84 #define WP              0x01
85 #define SLB             0x02
86 #define WPL             0x03
87 #define CLB             0x04
88 #define EA              0x08
89 #define SGPB    0x0B
90 #define CGPB    0x0D
91 #define SSB             0x0F
92
93 /* MC_FSR bit definitions */
94 #define MC_FSR_FRDY                     1
95 #define MC_FSR_EOL                      2
96
97 /* AT91SAM7 constants */
98 #define RC_FREQ                         32000
99
100 /* Flash timing modes */
101 #define FMR_TIMING_NONE         0
102 #define FMR_TIMING_NVBITS       1
103 #define FMR_TIMING_FLASH        2
104
105 /* Flash size constants */
106 #define FLASH_SIZE_8KB          1
107 #define FLASH_SIZE_16KB         2
108 #define FLASH_SIZE_32KB         3
109 #define FLASH_SIZE_64KB         5
110 #define FLASH_SIZE_128KB        7
111 #define FLASH_SIZE_256KB        9
112 #define FLASH_SIZE_512KB        10
113 #define FLASH_SIZE_1024KB       12
114 #define FLASH_SIZE_2048KB       14
115
116 #endif /* AT91SAM7_H */