xref: /rk3399_rockchip-uboot/include/linux/mtd/fsmc_nand.h (revision 7f0730a02e412015b0fc4e78dc41aef14e8a3d8c)
1*7f0730a0SVipin KUMAR /*
2*7f0730a0SVipin KUMAR  * (C) Copyright 2010
3*7f0730a0SVipin KUMAR  * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
4*7f0730a0SVipin KUMAR  *
5*7f0730a0SVipin KUMAR  * See file CREDITS for list of people who contributed to this
6*7f0730a0SVipin KUMAR  * project.
7*7f0730a0SVipin KUMAR  *
8*7f0730a0SVipin KUMAR  * This program is free software; you can redistribute it and/or
9*7f0730a0SVipin KUMAR  * modify it under the terms of the GNU General Public License as
10*7f0730a0SVipin KUMAR  * published by the Free Software Foundation; either version 2 of
11*7f0730a0SVipin KUMAR  * the License, or (at your option) any later version.
12*7f0730a0SVipin KUMAR  *
13*7f0730a0SVipin KUMAR  * This program is distributed in the hope that it will be useful,
14*7f0730a0SVipin KUMAR  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15*7f0730a0SVipin KUMAR  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*7f0730a0SVipin KUMAR  * GNU General Public License for more details.
17*7f0730a0SVipin KUMAR  *
18*7f0730a0SVipin KUMAR  * You should have received a copy of the GNU General Public License
19*7f0730a0SVipin KUMAR  * along with this program; if not, write to the Free Software
20*7f0730a0SVipin KUMAR  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21*7f0730a0SVipin KUMAR  * MA 02111-1307 USA
22*7f0730a0SVipin KUMAR  */
23*7f0730a0SVipin KUMAR 
24*7f0730a0SVipin KUMAR #ifndef __FSMC_NAND_H__
25*7f0730a0SVipin KUMAR #define __FSMC_NAND_H__
26*7f0730a0SVipin KUMAR 
27*7f0730a0SVipin KUMAR #include <linux/mtd/nand.h>
28*7f0730a0SVipin KUMAR 
29*7f0730a0SVipin KUMAR struct fsmc_regs {
30*7f0730a0SVipin KUMAR 	u32 ctrl;			/* 0x00 */
31*7f0730a0SVipin KUMAR 	u8 reserved_1[0x40 - 0x04];
32*7f0730a0SVipin KUMAR 	u32 pc;				/* 0x40 */
33*7f0730a0SVipin KUMAR 	u32 sts;			/* 0x44 */
34*7f0730a0SVipin KUMAR 	u32 comm;			/* 0x48 */
35*7f0730a0SVipin KUMAR 	u32 attrib;			/* 0x4c */
36*7f0730a0SVipin KUMAR 	u32 ioata;			/* 0x50 */
37*7f0730a0SVipin KUMAR 	u32 ecc1;			/* 0x54 */
38*7f0730a0SVipin KUMAR 	u32 ecc2;			/* 0x58 */
39*7f0730a0SVipin KUMAR 	u32 ecc3;			/* 0x5c */
40*7f0730a0SVipin KUMAR 	u8 reserved_2[0xfe0 - 0x60];
41*7f0730a0SVipin KUMAR 	u32 peripid0;			/* 0xfe0 */
42*7f0730a0SVipin KUMAR 	u32 peripid1;			/* 0xfe4 */
43*7f0730a0SVipin KUMAR 	u32 peripid2;			/* 0xfe8 */
44*7f0730a0SVipin KUMAR 	u32 peripid3;			/* 0xfec */
45*7f0730a0SVipin KUMAR 	u32 pcellid0;			/* 0xff0 */
46*7f0730a0SVipin KUMAR 	u32 pcellid1;			/* 0xff4 */
47*7f0730a0SVipin KUMAR 	u32 pcellid2;			/* 0xff8 */
48*7f0730a0SVipin KUMAR 	u32 pcellid3;			/* 0xffc */
49*7f0730a0SVipin KUMAR };
50*7f0730a0SVipin KUMAR 
51*7f0730a0SVipin KUMAR /* ctrl register definitions */
52*7f0730a0SVipin KUMAR #define FSMC_WP			(1 << 7)
53*7f0730a0SVipin KUMAR 
54*7f0730a0SVipin KUMAR /* pc register definitions */
55*7f0730a0SVipin KUMAR #define FSMC_RESET		(1 << 0)
56*7f0730a0SVipin KUMAR #define FSMC_WAITON		(1 << 1)
57*7f0730a0SVipin KUMAR #define FSMC_ENABLE		(1 << 2)
58*7f0730a0SVipin KUMAR #define FSMC_DEVTYPE_NAND	(1 << 3)
59*7f0730a0SVipin KUMAR #define FSMC_DEVWID_8		(0 << 4)
60*7f0730a0SVipin KUMAR #define FSMC_DEVWID_16		(1 << 4)
61*7f0730a0SVipin KUMAR #define FSMC_ECCEN		(1 << 6)
62*7f0730a0SVipin KUMAR #define FSMC_ECCPLEN_512	(0 << 7)
63*7f0730a0SVipin KUMAR #define FSMC_ECCPLEN_256	(1 << 7)
64*7f0730a0SVipin KUMAR #define FSMC_TCLR_1		(1 << 9)
65*7f0730a0SVipin KUMAR #define FSMC_TAR_1		(1 << 13)
66*7f0730a0SVipin KUMAR 
67*7f0730a0SVipin KUMAR /* sts register definitions */
68*7f0730a0SVipin KUMAR #define FSMC_CODE_RDY		(1 << 15)
69*7f0730a0SVipin KUMAR 
70*7f0730a0SVipin KUMAR /* comm register definitions */
71*7f0730a0SVipin KUMAR #define FSMC_TSET_0		(0 << 0)
72*7f0730a0SVipin KUMAR #define FSMC_TWAIT_6		(6 << 8)
73*7f0730a0SVipin KUMAR #define FSMC_THOLD_4		(4 << 16)
74*7f0730a0SVipin KUMAR #define FSMC_THIZ_1		(1 << 24)
75*7f0730a0SVipin KUMAR 
76*7f0730a0SVipin KUMAR /* peripid2 register definitions */
77*7f0730a0SVipin KUMAR #define FSMC_REVISION_MSK	(0xf)
78*7f0730a0SVipin KUMAR #define FSMC_REVISION_SHFT	(0x4)
79*7f0730a0SVipin KUMAR 
80*7f0730a0SVipin KUMAR #define FSMC_VER8		0x8
81*7f0730a0SVipin KUMAR 
82*7f0730a0SVipin KUMAR /*
83*7f0730a0SVipin KUMAR  * There are 13 bytes of ecc for every 512 byte block and it has to be read
84*7f0730a0SVipin KUMAR  * consecutively and immediately after the 512 byte data block for hardware to
85*7f0730a0SVipin KUMAR  * generate the error bit offsets
86*7f0730a0SVipin KUMAR  * Managing the ecc bytes in the following way is easier. This way is similar to
87*7f0730a0SVipin KUMAR  * oobfree structure maintained already in u-boot nand driver
88*7f0730a0SVipin KUMAR  */
89*7f0730a0SVipin KUMAR #define FSMC_MAX_ECCPLACE_ENTRIES	32
90*7f0730a0SVipin KUMAR 
91*7f0730a0SVipin KUMAR struct fsmc_nand_eccplace {
92*7f0730a0SVipin KUMAR 	u32 offset;
93*7f0730a0SVipin KUMAR 	u32 length;
94*7f0730a0SVipin KUMAR };
95*7f0730a0SVipin KUMAR 
96*7f0730a0SVipin KUMAR struct fsmc_eccplace {
97*7f0730a0SVipin KUMAR 	struct fsmc_nand_eccplace eccplace[FSMC_MAX_ECCPLACE_ENTRIES];
98*7f0730a0SVipin KUMAR };
99*7f0730a0SVipin KUMAR 
100*7f0730a0SVipin KUMAR extern int fsmc_nand_init(struct nand_chip *nand);
101*7f0730a0SVipin KUMAR #endif
102