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