comparison services/ffs/drv.h @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /******************************************************************************
2 * Flash File System (ffs)
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com
4 *
5 * ffs low level flash driver
6 *
7 * $Id: drv.h 1.15.1.25.1.1.1.20 Mon, 17 Nov 2003 08:51:37 +0100 tsj $
8 *
9 ******************************************************************************/
10
11 #ifndef TARGET
12 #define TARGET 1
13 #define _RVF 1
14 #endif
15
16 /******************************************************************************
17 * Compile constants
18 ******************************************************************************/
19
20 // FFS driver version (in four-digit BCD format). Format is MMID, where MM
21 // is major revision number, incremented e.g. for major revision or support
22 // for new flash family/driver. I is minor revision that is incremented for
23 // minor changes or when a bug is corrected. D is incremented when support
24 // of another device is added.
25 #define FFS_DRV_VERSION ((uint16) 0x1011)
26
27 // Default Allocation granularity of ffs data sectors (as power of two)
28 #define FFS_ATOM_LOG2 4
29
30
31 /******************************************************************************
32 * Macros
33 ******************************************************************************/
34
35 // Convert between address and block index. Only works if all blocks are the
36 // same size!
37 #define block2addr(block) (dev.base + dev.binfo[block].offset)
38
39 // Note that it is *VERY* important that pointers to hardware and flash are
40 // declared volatile, otherwise the compiler optimizes some reads and writes
41 // out and this results in non-working code!
42 #define FLASH_WRITE_HALFWORD(addr, data) *(volatile uint16 *) (addr) = (data)
43 #define FLASH_READ_HALFWORD(addr) *((volatile uint16 *) (addr))
44
45 #if (TARGET == 1)
46
47 #include "../../include/config.h"
48 #include "../../bsp/mem.h"
49 #if (CHIPSET == 12)
50 #include "sys_inth.h"
51 #else
52 #include "../../bsp/inth.h"
53 #endif
54
55 #if (CHIPSET == 3)
56 #define INT_REQUESTED (*(volatile uint16 *) INTH_IT_REG) & \
57 ~(*(volatile uint16 *) INTH_MASK_REG)
58 #elif (CHIPSET == 4 || CHIPSET == 5 || CHIPSET == 6 || CHIPSET == 7 || CHIPSET == 8 || CHIPSET == 9 || CHIPSET == 10 || CHIPSET == 11)
59 #define INT_REQUESTED ((*(volatile uint16 *) INTH_IT_REG1) & \
60 ~(*(volatile uint16 *) INTH_MASK_REG1)) || \
61 ((*(volatile uint16 *) INTH_IT_REG2) & \
62 ~(*(volatile uint16 *) INTH_MASK_REG2))
63 #elif (CHIPSET == 12)
64 #define INT_REQUESTED ((*(volatile uint16 *) C_INTH_IT_REG1) & \
65 ~(*(volatile uint16 *) C_INTH_MASK_REG1)) || \
66 ((*(volatile uint16 *) C_INTH_IT_REG2) & \
67 ~(*(volatile uint16 *) C_INTH_MASK_REG2))
68 #endif
69 #endif // (TARGET == 1)
70
71
72 /******************************************************************************
73 * Types
74 ******************************************************************************/
75
76 // Flash driver identifiers.
77 enum FFS_DRIVER {
78 FFS_DRIVER_NULL = 0, // Null driver
79
80 FFS_DRIVER_AMD = 2, // AMD dual/multi-bank driver
81 FFS_DRIVER_AMD_SB = 3, // AMD single-bank driver
82
83 FFS_DRIVER_SST = 8, // SST dual/multi-bank driver
84 FFS_DRIVER_SST_SB = 9, // SST single-bank driver
85
86 FFS_DRIVER_INTEL = 16, // Intel dual/multi-bank driver
87 FFS_DRIVER_INTEL_SB = 17, // Intel single-bank driver
88
89 FFS_DRIVER_AMD_PSEUDO_SB = 32, // Test driver
90 FFS_DRIVER_TEST = 34, // Test driver
91
92 FFS_DRIVER_RAM = 64 // Ram driver
93 };
94
95
96 // Manufacturer identifiers. These should never have to be changed. They are
97 // ordered in alphabetically ascending order.
98 enum FFS_MANUFACTURER {
99 MANUFACT_AMD = 0x01,
100 MANUFACT_ATMEL = 0x1F,
101 MANUFACT_FUJITSU = 0x04,
102 MANUFACT_INTEL = 0x89,
103 MANUFACT_MXIC = 0xC2,
104 MANUFACT_SAMSUNG = 0xEC,
105 MANUFACT_SHARP = 0xB0,
106 MANUFACT_SST = 0xBF,
107 MANUFACT_TOSHIBA = 0x98,
108 MANUFACT_RAM = 0xFE, // Ram
109 MANUFACT_TEST = 0x54 // 'T'est manufacturer
110 };
111
112
113 // Flash block information for one ffs block (flash sector). Note that the
114 // ffs block definition might be of a smaller size then the physical flash
115 // sector. The ffs blocks must be defined in ascending order of addresses.
116 struct block_info_s {
117 uint32 offset;
118 uint8 size_ld; // log2 of block size
119 uint8 unused1;
120 uint8 unused2;
121 uint8 unused3;
122 };
123
124
125 // General flash information for one flash device
126 struct flash_info_s {
127 const struct block_info_s *binfo; // block info array for this device
128 char *base; // base flash address of ffs blocks
129 uint16 manufact; // read with flash A0 = 0
130 uint16 device; // read with flash A0 = 1
131 uint8 driver; // flash driver type
132 uint8 numblocks; // number of blocks defined for use by ffs
133 };
134 extern const struct flash_info_s flash_info[];
135
136 enum DEVICE_STATE {
137 DEV_READ,
138 DEV_ERASE,
139 DEV_ERASE_SUSPEND,
140 DEV_WRITE
141 };
142
143
144 // Note that it is *VERY* important that pointers to hardware and flash are
145 // declared volatile, otherwise the compiler optimizes some reads and writes
146 // out and this results in non-working code!
147 struct dev_s {
148 char *base; // base flash address of ffs blocks
149 struct block_info_s *binfo;
150 uint16 manufact;
151 uint16 device;
152 volatile uint16 *addr; // address being written or erased
153 uint16 data; // data currently being written (dev.state = WRITE)
154 uint32 blocksize;
155 uint8 blocksize_ld;
156 uint8 atomlog2;
157 uint8 driver;
158 uint8 state; // state of device (DEVICE_STATE)
159 uint8 numblocks;
160 uint8 atomsize;
161 uint8 atomnotmask;
162 };
163 extern struct dev_s dev;
164
165
166 // Flash low level driver function pointers
167 struct ffsdrv_s {
168 int (* init)(void);
169 void (* erase)(uint8 block);
170 void (* write_halfword)(volatile uint16 *dst, uint16 value);
171 void (* write)(void *dst, const void *src, uint16 size);
172 void (* write_end)(void);
173 void (* erase_suspend)(void);
174 void (* erase_resume)(void);
175 };
176 extern const struct ffsdrv_s ffsdrv; /* const added for FreeCalypso */
177
178
179 /******************************************************************************
180 * Function Prototypes
181 ******************************************************************************/
182
183 void ffsdrv_write_byte(void *dst, uint8 value);
184 effs_t ffsdrv_init(void);
185
186 //extern int ffs_ram_image_address;
187 // We do it in a different way in FreeCalypso