1#ifndef FLASH_LIB_H
2#define FLASH_LIB_H
3
4#include <common.h>
5
6
7#define FLASH_PROGRAM_POLLS 100000
8
9
10#define FLASH_ERASE_SECTOR_TIMEOUT (10*1000 )
11
12
13typedef struct flash_dev_s {
14 char name[24];
15 int bank;
16 unsigned int base;
17 int sectors;
18 int lgSectorSize;
19 int vendorID;
20 int deviceID;
21 int found;
22 int swap;
23} flash_dev_t;
24
25#define FLASH_MAX_POS(dev) \
26 ((dev)->sectors << (dev)->lgSectorSize)
27
28#define FLASH_SECTOR_POS(dev, sector) \
29 ((sector) << (dev)->lgSectorSize)
30
31
32#define FLASH0_BANK 0
33#define FLASH0_VENDOR_ID 0x01
34#define FLASH0_DEVICE_ID 0x49
35
36
37#define FLASH1_BANK 1
38#define FLASH1_VENDOR_ID 0x0001
39#define FLASH1_DEVICE_ID 0x2249
40
41extern flash_dev_t flashDev[];
42extern int flashDevCount;
43
44
45
46
47
48
49#define FLASH_DEV_BANK0_SA0 (&flashDev[0])
50#define FLASH_DEV_BANK0_SA1 (&flashDev[1])
51#define FLASH_DEV_BANK0_SA2 (&flashDev[2])
52#define FLASH_DEV_BANK0_LOW (&flashDev[3])
53#define FLASH_DEV_BANK0_BOOT (&flashDev[4])
54#define FLASH_DEV_BANK0_HIGH (&flashDev[5])
55
56unsigned long flash_init(void);
57int flashEraseSector(flash_dev_t *dev, int sector);
58int flashErase(flash_dev_t *dev);
59int flashRead(flash_dev_t *dev, int pos, char *buf, int len);
60int flashWrite(flash_dev_t *dev, int pos, char *buf, int len);
61int flashWritable(flash_dev_t *dev, int pos, int len);
62int flashDiag(flash_dev_t *dev);
63int flashDiagAll(void);
64
65ulong flash_get_size (vu_long *addr, flash_info_t *info);
66void flash_print_info (flash_info_t *info);
67int flash_erase (flash_info_t *info, int s_first, int s_last);
68int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
69
70
71
72
73#define FLASH_BANK_KERNEL 0
74#define FLASH_BANK_BOOT 1
75#define FLASH_BANK_AUX 2
76#define FIRST_SECTOR 0
77
78#endif
79