146fd67f8c4cc32b2251122984225557fe6a70f9
[openwrt-10.03/.git] / target / linux / atheros / files-2.6.26 / drivers / mtd / devices / spiflash.h
1 /*
2  * SPI Flash Memory support header file.
3  *
4  *
5  *
6  * Copyright (c) 2005, Atheros Communications Inc.
7  * Copyright (C) 2006 FON Technology, SL.
8  * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
9  *
10  * This code is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  */
15 #define FLASH_1MB  1
16 #define FLASH_2MB  2
17 #define FLASH_4MB  3
18 #define FLASH_8MB  4
19 #define FLASH_16MB 5
20 #define MAX_FLASH  6
21
22 #define STM_PAGE_SIZE           256
23
24 #define SFI_WRITE_BUFFER_SIZE   4
25 #define SFI_FLASH_ADDR_MASK     0x00ffffff
26
27 #define STM_8MBIT_SIGNATURE     0x13
28 #define STM_M25P80_BYTE_COUNT   1048576
29 #define STM_M25P80_SECTOR_COUNT 16
30 #define STM_M25P80_SECTOR_SIZE  0x10000
31
32 #define STM_16MBIT_SIGNATURE    0x14
33 #define STM_M25P16_BYTE_COUNT   2097152
34 #define STM_M25P16_SECTOR_COUNT 32
35 #define STM_M25P16_SECTOR_SIZE  0x10000
36
37 #define STM_32MBIT_SIGNATURE    0x15
38 #define STM_M25P32_BYTE_COUNT   4194304
39 #define STM_M25P32_SECTOR_COUNT 64
40 #define STM_M25P32_SECTOR_SIZE  0x10000
41
42 #define STM_64MBIT_SIGNATURE    0x16
43 #define STM_M25P64_BYTE_COUNT   8388608
44 #define STM_M25P64_SECTOR_COUNT 128
45 #define STM_M25P64_SECTOR_SIZE  0x10000
46
47 #define STM_128MBIT_SIGNATURE   0x17
48 #define STM_M25P128_BYTE_COUNT   16777216
49 #define STM_M25P128_SECTOR_COUNT 256
50 #define STM_M25P128_SECTOR_SIZE  0x10000
51
52 #define STM_1MB_BYTE_COUNT   STM_M25P80_BYTE_COUNT
53 #define STM_1MB_SECTOR_COUNT STM_M25P80_SECTOR_COUNT
54 #define STM_1MB_SECTOR_SIZE  STM_M25P80_SECTOR_SIZE
55 #define STM_2MB_BYTE_COUNT   STM_M25P16_BYTE_COUNT
56 #define STM_2MB_SECTOR_COUNT STM_M25P16_SECTOR_COUNT
57 #define STM_2MB_SECTOR_SIZE  STM_M25P16_SECTOR_SIZE
58 #define STM_4MB_BYTE_COUNT   STM_M25P32_BYTE_COUNT
59 #define STM_4MB_SECTOR_COUNT STM_M25P32_SECTOR_COUNT
60 #define STM_4MB_SECTOR_SIZE  STM_M25P32_SECTOR_SIZE
61 #define STM_8MB_BYTE_COUNT   STM_M25P64_BYTE_COUNT
62 #define STM_8MB_SECTOR_COUNT STM_M25P64_SECTOR_COUNT
63 #define STM_8MB_SECTOR_SIZE  STM_M25P64_SECTOR_SIZE
64 #define STM_16MB_BYTE_COUNT   STM_M25P128_BYTE_COUNT
65 #define STM_16MB_SECTOR_COUNT STM_M25P128_SECTOR_COUNT
66 #define STM_16MB_SECTOR_SIZE  STM_M25P128_SECTOR_SIZE
67
68 /*
69  * ST Microelectronics Opcodes for Serial Flash
70  */
71
72 #define STM_OP_WR_ENABLE       0x06     /* Write Enable */
73 #define STM_OP_WR_DISABLE      0x04     /* Write Disable */
74 #define STM_OP_RD_STATUS       0x05     /* Read Status */
75 #define STM_OP_WR_STATUS       0x01     /* Write Status */
76 #define STM_OP_RD_DATA         0x03     /* Read Data */
77 #define STM_OP_FAST_RD_DATA    0x0b     /* Fast Read Data */
78 #define STM_OP_PAGE_PGRM       0x02     /* Page Program */
79 #define STM_OP_SECTOR_ERASE    0xd8     /* Sector Erase */
80 #define STM_OP_BULK_ERASE      0xc7     /* Bulk Erase */
81 #define STM_OP_DEEP_PWRDOWN    0xb9     /* Deep Power-Down Mode */
82 #define STM_OP_RD_SIG          0xab     /* Read Electronic Signature */
83
84 #define STM_STATUS_WIP       0x01       /* Write-In-Progress */
85 #define STM_STATUS_WEL       0x02       /* Write Enable Latch */
86 #define STM_STATUS_BP0       0x04       /* Block Protect 0 */
87 #define STM_STATUS_BP1       0x08       /* Block Protect 1 */
88 #define STM_STATUS_BP2       0x10       /* Block Protect 2 */
89 #define STM_STATUS_SRWD      0x80       /* Status Register Write Disable */
90
91 /*
92  * SPI Flash Interface Registers
93  */
94 #define AR531XPLUS_SPI_READ     0x08000000
95 #define AR531XPLUS_SPI_MMR      0x11300000
96 #define AR531XPLUS_SPI_MMR_SIZE 12
97
98 #define AR531XPLUS_SPI_CTL      0x00
99 #define AR531XPLUS_SPI_OPCODE   0x04
100 #define AR531XPLUS_SPI_DATA     0x08
101
102 #define SPI_FLASH_READ          AR531XPLUS_SPI_READ
103 #define SPI_FLASH_MMR           AR531XPLUS_SPI_MMR
104 #define SPI_FLASH_MMR_SIZE      AR531XPLUS_SPI_MMR_SIZE
105 #define SPI_FLASH_CTL           AR531XPLUS_SPI_CTL
106 #define SPI_FLASH_OPCODE        AR531XPLUS_SPI_OPCODE
107 #define SPI_FLASH_DATA          AR531XPLUS_SPI_DATA
108
109 #define SPI_CTL_START           0x00000100
110 #define SPI_CTL_BUSY            0x00010000
111 #define SPI_CTL_TXCNT_MASK      0x0000000f
112 #define SPI_CTL_RXCNT_MASK      0x000000f0
113 #define SPI_CTL_TX_RX_CNT_MASK  0x000000ff
114 #define SPI_CTL_SIZE_MASK       0x00060000
115
116 #define SPI_CTL_CLK_SEL_MASK    0x03000000
117 #define SPI_OPCODE_MASK         0x000000ff
118
119 #define SPI_STATUS_WIP          STM_STATUS_WIP