57f7277a69f5dd49f8ef777bd996fdb83d17e087
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk29 / include / mach / rk29_nand.h
1
2 /*
3  * arch/arm/mach-rk29/include/mach/rk29_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_RK29_NAND_H
19 #define __ASM_ARCH_RK29_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 #define     FMC_WIDTH_16                                (0x1<<12)
44 //FMWAIT¼Ä´æÆ÷
45 #define     FMW_RWCS_OFFSET             0
46 #define     FMW_RWPW_OFFSET     5
47 #define     FMW_RDY                              (0x1<<11)
48 #define     FMW_CSRW_OFFSET             12
49 #define     FMW_DLY_OFFSET              24//16
50
51 struct rk29_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 rk29_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 FMCTL1; 
95        volatile  uint32_t FMWAIT1;
96        volatile  uint32_t FLCTL1;
97        volatile  uint32_t BCHCTL1; 
98        volatile  uint32_t BCHST1; 
99        volatile  uint32_t RESERVED2[(0x200-0x14)/4]; 
100            volatile  uint32_t RESERVED3[0x200/4]; 
101        volatile  CHIP_IF chip[8];
102        volatile  uint32_t buf[0x800/4]; 
103 }NANDC, *pNANDC;
104
105 struct rk29_nand_flash {
106         const struct rk29_nand_timing *timing;        /* NAND Flash timing */
107         const struct rk29_nand_cmdset *cmdset;
108
109         uint32_t page_per_block;                /* Pages per block (PG_PER_BLK) */
110         uint32_t page_size;                             /* Page size in bytes (PAGE_SZ) */
111         uint32_t flash_width;                   /* Width of Flash memory (DWIDTH_M) */
112         uint32_t num_blocks;                    /* Number of physical blocks in Flash */
113         uint32_t chip_id;
114 };
115
116 struct rk29_nand_platform_data {
117         
118         int width;                      /* data bus width in bytes */
119         int hw_ecc;                     /* 1:hw ecc,    0: soft ecc */
120         struct mtd_partition *parts;
121         unsigned int    nr_parts;
122        size_t           num_flash;
123     int (*io_init)(void);
124     int (*io_deinit)(void);
125 };
126
127
128 #endif /* __ASM_ARCH_RK29_NAND_H */
129