1
2
3
4
5
6
7#ifndef ST_SMI_H
8#define ST_SMI_H
9
10
11
12
13#define FLASH_START_ADDRESS CONFIG_SYS_FLASH_BASE
14#define FLASH_BANK_SIZE CONFIG_SYS_FLASH_BANK_SIZE
15
16#define SMIBANK0_BASE (FLASH_START_ADDRESS)
17#define SMIBANK1_BASE (SMIBANK0_BASE + FLASH_BANK_SIZE)
18#define SMIBANK2_BASE (SMIBANK1_BASE + FLASH_BANK_SIZE)
19#define SMIBANK3_BASE (SMIBANK2_BASE + FLASH_BANK_SIZE)
20
21#define BANK0 0
22#define BANK1 1
23#define BANK2 2
24#define BANK3 3
25
26struct smi_regs {
27 u32 smi_cr1;
28 u32 smi_cr2;
29 u32 smi_sr;
30 u32 smi_tr;
31 u32 smi_rr;
32};
33
34
35#define BANK_EN 0x0000000F
36#define DSEL_TIME 0x00000060
37#define PRESCAL5 0x00000500
38#define PRESCALA 0x00000A00
39#define PRESCAL3 0x00000300
40#define PRESCAL4 0x00000400
41#define SW_MODE 0x10000000
42#define WB_MODE 0x20000000
43#define FAST_MODE 0x00008000
44#define HOLD1 0x00010000
45
46
47#define RD_STATUS_REG 0x00000400
48#define WE 0x00000800
49#define BANK0_SEL 0x00000000
50#define BANK1_SEL 0x00001000
51#define BANK2_SEL 0x00002000
52#define BANK3_SEL 0x00003000
53#define BANKSEL_SHIFT 12
54#define SEND 0x00000080
55#define TX_LEN_1 0x00000001
56#define TX_LEN_2 0x00000002
57#define TX_LEN_3 0x00000003
58#define TX_LEN_4 0x00000004
59#define RX_LEN_1 0x00000010
60#define RX_LEN_2 0x00000020
61#define RX_LEN_3 0x00000030
62#define RX_LEN_4 0x00000040
63#define TFIE 0x00000100
64#define WCIE 0x00000200
65
66
67#define INT_WCF_CLR 0xFFFFFDFF
68#define INT_TFF_CLR 0xFFFFFEFF
69#define WIP_BIT 0x00000001
70#define WEL_BIT 0x00000002
71#define RSR 0x00000005
72#define TFF 0x00000100
73#define WCF 0x00000200
74#define ERF1 0x00000400
75#define ERF2 0x00000800
76#define WM0 0x00001000
77#define WM1 0x00002000
78#define WM2 0x00004000
79#define WM3 0x00008000
80#define WM_SHIFT 12
81
82
83#define READ_ID 0x0000009F
84#define BULK_ERASE 0x000000C7
85#define SECTOR_ERASE 0x000000D8
86#define WRITE_ENABLE 0x00000006
87
88struct flash_dev {
89 u32 density;
90 ulong size;
91 ushort sector_count;
92};
93
94#define SFLASH_PAGE_SIZE 0x100
95#define XFER_FINISH_TOUT 15
96#define WMODE_TOUT 15
97
98extern void smi_init(void);
99
100#endif
101