]> git.sur5r.net Git - openocd/blob - src/flash/at91sam7.h
Gheorghe Guran <roatlasro@yahoo.com> redone at91sam7 driver. Old driver source file...
[openocd] / src / flash / 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 #include "flash.h"
27 #include "target.h"
28
29
30 typedef struct at91sam7_flash_bank_s
31 {
32     /* chip id register */
33     u32 cidr;
34     u16 cidr_ext;
35     u16 cidr_nvptyp;
36     u16 cidr_arch;
37     u16 cidr_sramsiz;
38     u16 cidr_nvpsiz;
39     u16 cidr_nvpsiz2;
40     u16 cidr_eproc;
41     u16 cidr_version;
42     char *target_name;
43
44     /* flash auto-detection */
45     u8  flash_autodetection;
46
47     /* flash geometry */
48     u16 pages_per_sector;
49     u16 pagesize;
50     u16 pages_in_lockregion;
51
52     /* nv memory bits */
53     u16 num_lockbits_on;
54     u16 lockbits;
55     u16 num_nvmbits;
56     u16 num_nvmbits_on;
57     u16 nvmbits;
58     u8  securitybit;
59
60     /* 0: not init
61        1: fmcn for nvbits (1uS)
62        2: fmcn for flash (1.5uS) */
63     u8  flashmode;
64
65     /* main clock status */
66     u8  mck_valid;
67     u32 mck_freq;
68
69     /* external clock frequency */
70     u32 ext_freq;
71
72 } at91sam7_flash_bank_t;
73
74
75 /* AT91SAM7 control registers */
76 #define DBGU_CIDR           0xFFFFF240
77 #define CKGR_MCFR           0xFFFFFC24
78 #define CKGR_MOR            0xFFFFFC20
79 #define CKGR_MCFR_MAINRDY      0x10000
80 #define CKGR_PLLR           0xFFFFFC2c
81 #define CKGR_PLLR_DIV             0xff
82 #define CKGR_PLLR_MUL       0x07ff0000
83 #define PMC_MCKR            0xFFFFFC30
84 #define PMC_MCKR_CSS              0x03
85 #define PMC_MCKR_PRES             0x1c
86
87 /* Flash Controller Commands */
88 #define WP      0x01
89 #define SLB     0x02
90 #define WPL     0x03
91 #define CLB     0x04
92 #define EA      0x08
93 #define SGPB    0x0B
94 #define CGPB    0x0D
95 #define SSB     0x0F
96
97 /* MC_FSR bit definitions */
98 #define MC_FSR_FRDY         1
99 #define MC_FSR_EOL          2
100
101 /* AT91SAM7 constants */
102 #define RC_FREQ         32000
103
104 /* Flash timing modes */
105 #define FMR_TIMING_NONE     0
106 #define FMR_TIMING_NVBITS   1
107 #define FMR_TIMING_FLASH    2
108
109 /* Flash size constants */
110 #define FLASH_SIZE_8KB      1
111 #define FLASH_SIZE_16KB     2
112 #define FLASH_SIZE_32KB     3
113 #define FLASH_SIZE_64KB     5
114 #define FLASH_SIZE_128KB    7
115 #define FLASH_SIZE_256KB    9
116 #define FLASH_SIZE_512KB    10
117 #define FLASH_SIZE_1024KB   12
118 #define FLASH_SIZE_2048KB   14
119
120 #endif /* AT91SAM7_H */