e61d2843332376301f80ffe02c6f98040b0068a0
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2818 / include / mach / rk2818_nand.h
1
2 /*
3  * arch/arm/mach-rk2818/include/mach/rk2818_nand.h
4  *
5  * Copyright (C) 2010 RockChip, Inc.
6  * Author: 
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  */
17  
18 #ifndef __ASM_ARCH_RK2818_NAND_H
19 #define __ASM_ARCH_RK2818_NAND_H
20
21
22 //BCHCTL¼Ä´æÆ÷
23 #define     BCH_WR                  0x0002
24 #define     BCH_RST                 0x0001
25 //FLCTL¼Ä´æÆ÷
26 #define     FL_RDY                      (0x1<<20)
27 #define     FL_LBA_EN                   (0x1<<11)
28 #define     FL_COR_EN                   (0x1<<10)
29 #define     FL_INT_EN                   (0x1<<9)
30 #define     FL_INTCLR                   (0x1<<8)
31 #define     FL_STMOD                    (0x1<<7)
32 #define     FL_TRCNT                    (0x3<<5)
33 #define     FL_STADDR                   (0x1<<4)
34 #define     FL_BYPASS                   (0x1<<3)
35 #define     FL_START                    (0x1<<2)
36 #define     FL_RDN                      (0x1<<1)
37 #define     FL_RST                      (0x1<<0)
38 //FMCTL¼Ä´æÆ÷
39 #define     FMC_WP                      (0x1<<8)
40 #define     FMC_FRDY                            (0x1<<9)
41 #define     FMC_FRDY_INT_EN     (0x1<<10)
42 #define     FMC_FRDY_INT_CLR            (0x1<<11)
43 //FMWAIT¼Ä´æÆ÷
44 #define     FMW_RWCS_OFFSET             0
45 #define     FMW_RWPW_OFFSET     5
46 #define     FMW_RDY                              (0x1<<11)
47 #define     FMW_CSRW_OFFSET             12
48 #define     FMW_DLY_OFFSET              16
49 #define     FMW_DLY_DBG                 (0x1<<23)
50
51 struct rk2818_nand_timing {
52         unsigned int    tCH;  /* Enable signal hold time */
53         unsigned int    tCS;  /* Enable signal setup time */
54         unsigned int    tWH;  /* ND_nWE high duration */
55         unsigned int    tWP;  /* ND_nWE pulse time */
56         unsigned int    tRH;  /* ND_nRE high duration */
57         unsigned int    tRP;  /* ND_nRE pulse width */
58         unsigned int    tR;   /* ND_nWE high to ND_nRE low for read */
59         unsigned int    tWHR; /* ND_nWE high to ND_nRE low for status read */
60         unsigned int    tAR;  /* ND_ALE low to ND_nRE low delay */
61 };
62
63 struct rk2818_nand_cmdset {
64         uint16_t        read1;
65         uint16_t        read2;
66         uint16_t        program;
67         uint16_t        read_status;
68         uint16_t        read_id;
69         uint16_t        erase;
70         uint16_t        reset;
71         uint16_t        lock;
72         uint16_t        unlock;
73         uint16_t        lock_status;
74 };
75
76 typedef volatile struct tagCHIP_IF
77 {
78             uint32_t data;
79             uint32_t addr;
80             uint32_t cmd;
81             uint32_t RESERVED[0x3d];
82 }CHIP_IF, *pCHIP_IF;
83
84 //NANDC Registers
85 typedef volatile struct tagNANDC
86 {
87        volatile  uint32_t FMCTL; 
88        volatile  uint32_t FMWAIT;
89        volatile  uint32_t FLCTL;
90        volatile  uint32_t BCHCTL; 
91        volatile  uint32_t BCHST; 
92        volatile  uint32_t RESERVED1[(0x200-0x14)/4];   //FLR
93        volatile  uint32_t spare[0x200/4]; 
94        volatile  uint32_t RESERVED2[0x400/4]; 
95        volatile  CHIP_IF chip[8];
96        volatile  uint32_t buf[0x800/4]; 
97 }NANDC, *pNANDC;
98
99 struct rk2818_nand_flash {
100         const struct rk2818_nand_timing *timing;        /* NAND Flash timing */
101         const struct rk2818_nand_cmdset *cmdset;
102
103         uint32_t page_per_block;                /* Pages per block (PG_PER_BLK) */
104         uint32_t page_size;                     /* Page size in bytes (PAGE_SZ) */
105         uint32_t flash_width;                   /* Width of Flash memory (DWIDTH_M) */
106         uint32_t num_blocks;                    /* Number of physical blocks in Flash */
107         uint32_t chip_id;
108 };
109
110 struct rk2818_nand_platform_data {
111         
112         int width;                      /* data bus width in bytes */
113         int hw_ecc;                     /* 1:hw ecc,    0: soft ecc */
114         struct mtd_partition *parts;
115         unsigned int    nr_parts;
116        size_t           num_flash;
117 };
118
119
120 #endif /* __ASM_ARCH_RK2818_NAND_H */
121