summaryrefslogtreecommitdiff
path: root/drivers/mtd/devices/wmt_sf.h
blob: d6bc1acc63c91e806efecfd32582ac3f6c436fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*++
drivers/mtd/devices/wmt_sf.h

Copyright (c) 2008  WonderMedia Technologies, Inc.

This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation,
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program.  If not, see <http://www.gnu.org/licenses/>.

WonderMedia Technologies, Inc.
10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
--*/

#ifndef __WMT_SF_H__
#define __WMT_SF_H__

#define DRIVER_NAME "MTDSF"
#define MTDSF_TOTAL_SIZE (16 * 1024 * 1024)
#define MTDSF_ERASE_SIZE (64 * 1024)
/*#define MTDSF_PHY_ADDR (0xFF000000)*/
#define MTDSF_BOOT_PHY_ADDR (0xFF000000)
#define MTDSF_NOT_BOOT_PHY_ADDR (0xEF000000)
#define SPI_FLASH_TYPE  			0
#define EMMC_FLASH_TYPE	 			1
#define NAND_FLASH_TYPE				2
#define ROM_EMMC_FLASH_TYPE		3
#define SD_FLASH_TYPE					4
#define USB_FLASH_TYPE				5
#define NAND_FLASH_TYPE 6
#define NOR_FLASH_TYPE  7
#define BOOT_TYPE_8BIT	0
#define BOOT_TYPE_16BIT	1

#define SF_CLOCK_EN	0x0800000

struct sfreg_t {
    unsigned long volatile     CHIP_SEL_0_CFG ;    /* 0xD8002000*/
    unsigned long volatile     Res1 ;              /* 0x04*/
    unsigned long volatile     CHIP_SEL_1_CFG ;    /* 0xD8002008 */
    unsigned long volatile     Res2[13] ;          /* 0x0C */
    unsigned long volatile     SPI_INTF_CFG ;      /* 0xD8002040 */
    unsigned long volatile     Res3[3] ;           /* 0x44 */
    unsigned long volatile     SPI_RD_WR_CTR ;     /* 0xD8002050 */
    unsigned long volatile     Res4[3] ;           /* 0x54 */
    unsigned long volatile     SPI_WR_EN_CTR ;     /* 0xD8002060 */
    unsigned long volatile     Res5[3] ;           /* 0x64 */
    unsigned long volatile     SPI_ER_CTR ;        /* 0xD8002070 */
    unsigned long volatile     SPI_ER_START_ADDR ; /* 0xD8002074 */
    unsigned long volatile     Res6[2] ;           /* 0x78 */
    unsigned long volatile     SPI_ERROR_STATUS ;  /* 0xD8002080 */
    unsigned long volatile     Res7[31] ;          /* 0x84 */
    unsigned long volatile     SPI_MEM_0_SR_ACC ;  /* 0xD8002100 */
    unsigned long volatile     Res8[3] ;           /* 0x104 */
    unsigned long volatile     SPI_MEM_1_SR_ACC ;  /* 0xD8002110 */
    unsigned long volatile     Res9[27] ;          /* 0x114 */
    unsigned long volatile     SPI_PDWN_CTR_0 ;    /* 0xD8002180 */
    unsigned long volatile     Res10[3] ;           /* 0x184 */
    unsigned long volatile     SPI_PDWN_CTR_1 ;    /* 0xD8002190 */
    unsigned long volatile     Res11[27] ;         /* 0x194 */
    unsigned long volatile     SPI_PROG_CMD_CTR ;  /* 0xD8002200 */
    unsigned long volatile     Res12[3] ;          /* 0x204 */
    unsigned long volatile     SPI_USER_CMD_VAL ;  /* 0xD8002210 */
    unsigned long volatile     Res13[59] ;         /* 0x214 */
    unsigned char volatile     SPI_PROG_CMD_WBF[64] ;  /* 0xD8002300 */
    unsigned long volatile     Res14[16] ;         /* 0x340 */
    unsigned char volatile     SPI_PROG_CMD_RBF[64];  /* 0xD8002380 */
};

struct wmt_flash_info_t {
	unsigned int id;
	unsigned int phy;
	unsigned int val;
	unsigned int total;
};

/* SPI flash erase control register, 0x70 */
#define SF_SEC_ER_EN           0x8000 /* [15:15] */
#define SF_SEC_ER_DIS          0x0 /* [15:15] */
#define SF_CHIP_ER_EN          0x1 /* [0:0] */
#define SF_CHIP_ER_DIS          0x0 /* [0:0] */

#define FLASH_UNKNOW 0xFFFFFFFF

#define SF_BIT_WR_PROT_ERR         0x20 /* [5:5] */
#define SF_BIT_MEM_REGION_ERR      0x10 /* [4:4] */
#define SF_BIT_PWR_DWN_ACC_ERR     0x8 /* [3:3] */
#define SF_BIT_PCMD_OP_ERR         0x4 /* [2:2] */
#define SF_BIT_PCMD_ACC_ERR        0x2 /* [1:1] */
#define SF_BIT_MASLOCK_ERR         0x1 /* [0:0] */
#define BIT_SEQUENCE_ERROR	0x00300030
#define BIT_TIMEOUT		0x80000000

#define ERR_OK        0x0
#define ERR_TIMOUT        0x11
#define ERR_PROG_ERROR	0x22

#define EON_MANUFACT	0x1C
#define NUMONYX_MANUFACT	0x20
#define MXIC_MANUFACT	0xC2
#define SPANSION_MANUFACT	0x01
#define SST_MANUFACT	0xBF
#define WB_MANUFACT 0xEF
#define ATMEL_MANUF    0x1F
#define GD_MANUF    0xC8

/* EON */
#define EON_25P16_ID	0x2015 /* 2 MB */
#define EON_25P64_ID	0x2017 /* 8 MB */
#define EON_25Q64_ID	0x3017 /* 8 MB */
#define EON_25F40_ID	0x3113 /* 512 KB */
#define EON_25F16_ID	0x3115 /* 2 MB */

/* NUMONYX */
#define	NX_25P16_ID	0x2015 /* 2 MB */
#define	NX_25P64_ID	0x2017 /* 8 MB */

/* MXIC */
#define	MX_L512_ID	0x2010 /* 64 KB , 4KB*/
#define	MX_L1605D_ID	0x2015 /* 2 MB */
#define	MX_L3205D_ID	0x2016 /* 4 MB */
#define	MX_L6405D_ID	0x2017 /* 8 MB */
#define	MX_L1635D_ID	0x2415 /* 2 MB */
#define	MX_L3235D_ID	0x5E16 /* 4 MB */
#define	MX_L12805D_ID	0x2018 /* 16 MB */

/* SPANSION */
#define SPAN_FL016A_ID	0x0214 /* 2 MB */
#define SPAN_FL064A_ID	0x0216 /* 8 MB */

/* SST */
#define SST_VF016B_ID	0x2541 /* 2 MB */

/* WinBond */
#define WB_X40BV_ID    0x3013 /* 512KB */
#define WB_X16A_ID	0x3015	/* 2 MB */
#define WB_X16C_ID	0x4015	/* 2 MB */
#define WB_X32_ID	0x3016	/* 4 MB */
#define WB_X64_ID	0x3017	/* 8 MB */
#define WB_X64_25Q64_ID	0x4017	/* 8 MB */
#define WB_X128_ID	0x4018	/* 16 MB */

/* ATMEL */
#define AT_25DF041A_ID 0x4401 /* 512KB */

/* GD -Giga Device- */
#define GD_25Q40_ID			0x4013 /* 512KB */
#define GD_25Q128_ID		0x4018 /* 16MB */

/* ST M25P64 CMD */
#define SF_CMD_WREN      0x06
#define SF_CMD_WRDI      0x04
#define SF_CMD_RDID      0x9F
#define SF_CMD_RDSR      0x05
#define SF_CMD_WRSR      0x01
#define SF_CMD_READ      0x03
#define SF_CMD_FAST_READ 0x0B
#define SF_CMD_PP        0x02
#define SF_CMD_SE        0xD8
#define SF_CMD_BE        0xC7
#define SF_CMD_RES       0xAB

/* SPI Interface Configuration Register(0x40) */
#define SF_MANUAL_MODE 0x40

/* SPI Programmable Command Mode Control Register(0x200) */
#define SF_RUN_CMD   0x01

struct wm_sf_dev_t {
	unsigned int id;
	unsigned int size; /* KBytes */
};

#define SF_IDALL(x, y)	((x<<16)|y)
void shift_partition_content(int index);

#endif /* __WMT_SF_H__ */