]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/mousse/flash.h
ARM: highbank: use default prompt
[karo-tx-uboot.git] / board / mousse / flash.h
1 #ifndef FLASH_LIB_H
2 #define FLASH_LIB_H
3
4 #include <common.h>
5
6 /* PIO operations max */
7 #define FLASH_PROGRAM_POLLS             100000
8
9 /* 10 Seconds default */
10 #define FLASH_ERASE_SECTOR_TIMEOUT      (10*1000 /*SEC*/ )
11
12 /* Flash device info structure */
13 typedef struct flash_dev_s {
14     char        name[24];               /* Bank Name */
15     int         bank;                   /* Bank 0 or 1 */
16     unsigned int base;                  /* Base address */
17     int         sectors;                /* Sector count */
18     int         lgSectorSize;           /* Log2(usable bytes/sector) */
19     int         vendorID;               /* Expected vendor ID */
20     int         deviceID;               /* Expected device ID */
21     int         found;                  /* Set if found by flashLibInit */
22     int         swap;                   /* Set for bank 1 if byte swap req'd */
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 /* AMD 29F040 */
32 #define FLASH0_BANK                     0
33 #define FLASH0_VENDOR_ID                0x01
34 #define FLASH0_DEVICE_ID                0x49
35
36 /* AMD29LV160DB */
37 #define FLASH1_BANK                     1
38 #define FLASH1_VENDOR_ID                0x0001
39 #define FLASH1_DEVICE_ID                0x2249
40
41 extern  flash_dev_t                     flashDev[];
42 extern  int                             flashDevCount;
43
44 /*
45  * Device pointers
46  *
47  * These must be kept in sync with the table in flashLib.c.
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]) /* 960K */
53 #define FLASH_DEV_BANK0_BOOT            (&flashDev[4]) /* PLCC */
54 #define FLASH_DEV_BANK0_HIGH            (&flashDev[5]) /* 512K PLCC shadow */
55
56 unsigned long flash_init(void);
57 int flashEraseSector(flash_dev_t *dev, int sector);
58 int flashErase(flash_dev_t *dev);
59 int flashRead(flash_dev_t *dev, int pos, char *buf, int len);
60 int flashWrite(flash_dev_t *dev, int pos, char *buf, int len);
61 int flashWritable(flash_dev_t *dev, int pos, int len);
62 int flashDiag(flash_dev_t *dev);
63 int flashDiagAll(void);
64
65 ulong flash_get_size (vu_long *addr, flash_info_t *info);
66 void flash_print_info  (flash_info_t *info);
67 int  flash_erase (flash_info_t *info, int s_first, int s_last);
68 int  write_buff  (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
69
70 /*
71  * Flash info indices.
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  /* !FLASH_LIB_H */