change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8825 / regs_nfc.h
1 /*
2  * arch/arm/mach-sc8800s/include/mach/regs_nfc.h
3  *
4  * Chip nand flash controller registers Definitions
5  *
6  * Copyright (C) 2010 Spreadtrum International Ltd.
7  *
8  * 2010-05-25: yingchun li <yingchun.li@spreadtrum.com>
9  *            initial version
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License version 2 as
13  *  published by the Free Software Foundation.
14  */
15
16 #ifndef _SC8810_REG_NFC_H_
17 #define _SC8810_REG_NFC_H_
18
19 #include <asm/arch/chip_drv_config_extern.h>
20
21 #define NFC_REG_BASE    (0x21100000)
22
23 #define NFC_MBUF_ADDR   (NFC_REG_BASE + 0x2000)
24 #define NFC_SBUF_ADDR   (NFC_REG_BASE + 0x4000)
25
26 #define NFC_CMD         (NFC_REG_BASE + 0x0000)
27 #define NFC_CFG0        (NFC_REG_BASE + 0x0004)
28 #define NFC_CFG1        (NFC_REG_BASE + 0x0008)
29 #define NFC_TIMING      (NFC_REG_BASE + 0x0010)
30 #define NFC_TIEOUT      (NFC_REG_BASE + 0x0014)
31 #define NFC_ID_STS      (NFC_REG_BASE + 0x0018)
32 #define NFC_STS_EN      (NFC_REG_BASE + 0x0020)
33 #define NFC_CLR_RAW     (NFC_REG_BASE + 0x0024)
34
35 #define NFC_ECC_CFG0    (NFC_REG_BASE + 0x0030)
36 #define NFC_ECC_CFG1    (NFC_REG_BASE + 0x0034)
37
38 #define NFC_ECC_STS0    (NFC_REG_BASE + 0x0040)
39 #define NFC_ECC_STS1    (NFC_REG_BASE + 0x0044)
40 #define NFC_ECC_STS2    (NFC_REG_BASE + 0x0048)
41 #define NFC_ECC_STS3    (NFC_REG_BASE + 0x004C)
42
43 #define NFC_START_ADDR0 (NFC_REG_BASE + 0x0060)
44 #define NFC_START_ADDR1 (NFC_REG_BASE + 0x0064)
45 #define NFC_START_ADDR2 (NFC_REG_BASE + 0x0068)
46 #define NFC_START_ADDR3 (NFC_REG_BASE + 0x006C)
47 #define NFC_START_ADDR4 (NFC_REG_BASE + 0x0070)
48 #define NFC_START_ADDR5 (NFC_REG_BASE + 0x0074)
49 #define NFC_START_ADDR6 (NFC_REG_BASE + 0x0078)
50 #define NFC_START_ADDR7 (NFC_REG_BASE + 0x007C)
51
52 #define NFC_END_ADDR0   (NFC_REG_BASE + 0x0080)
53 #define NFC_END_ADDR1   (NFC_REG_BASE + 0x0084)
54 #define NFC_END_ADDR2   (NFC_REG_BASE + 0x0088)
55 #define NFC_END_ADDR3   (NFC_REG_BASE + 0x008c)
56 #define NFC_END_ADDR4   (NFC_REG_BASE + 0x0090)
57 #define NFC_END_ADDR5   (NFC_REG_BASE + 0x0094)
58 #define NFC_END_ADDR6   (NFC_REG_BASE + 0x0098)
59 #define NFC_END_ADDR7   (NFC_REG_BASE + 0x009C)
60
61
62
63 //bit define NFC_CMD
64 #define NFC_CMD_VALID           (1 << 31)
65 #define NFC_BLKNUM_OFFSET       (16)
66 //bit define NFC_CFG0
67 #define NFC_SP_SIZE_OFFSET      16
68 #define NFC_CMD_SET_OFFSET      15
69 #define NFC_ADVANCE             (1 << 14)
70 #define NFC_ADDR_3CYCLES        0
71 #define NFC_ADDR_4CYCLES        (1 << 12)
72 #define NFC_ADDR_5CYCLES        (2 << 12)
73 #define NFC_PAGE_TYPE_512       0
74 #define NFC_PAGE_TYPE_1K        (1 << 9)
75 #define NFC_PAGE_TYPE_2K        (2 << 9)
76 #define NFC_PAGE_TYPE_4K        (3 << 9)
77 #define NFC_PAGE_TYPE_8K        (4 << 9)
78
79 #define NFC_CS1_SEL             (1 << 6)
80 #define NFC_BUS_WIDTH_16        (1 << 5)
81 #define NFC_NFC_MEM_SWITCH      (1 << 4)
82 #define NFC_MEM_NFC_SWITCH      (1 << 3)
83 #define NFC_WPN                 (1 << 2)
84 #define NFC_CMD_CLR             (1 << 1)
85 #define NFC_RBN                 (1 << 0)
86 //bit define NFC_CFG1
87 #define NFC_DMA_RX_EN           (1 << 1)
88 #define NFC_DMA_TX_EN           (1 << 0)
89 //bit define NFC_TIMING
90 #define NFC_ACS_OFFSET          (0)
91 #define NFC_RWH_OFFSET          (5)
92 #define NFC_RWL_OFFSET          (10)
93 #define NFC_ACR_OFFSET          (16)
94 #define NFC_RR_OFFSET           (21)
95 #define NFC_CEH_OFFSET          (26)
96 //bit define NFC_INT_STS_EN
97 #define NFC_DONE_EN             (1 << 0)
98 #define NFC_ECC_DONE_EN         (1 << 1)
99 #define NFC_ERR_EN              (1 << 2)
100 #define NFC_WP_EN               (1 << 3)
101 #define NFC_TO_EN               (1 << 4)
102
103 #define NFC_DONE_STS            (1 << 16)
104 #define NFC_ECC_DONE_STS        (1 << 16)
105 #define NFC_ERR_STS             (1 << 16)
106 #define NFC_WP_STS              (1 << 16)
107 #define NFC_TO_STS              (1 << 16)
108
109 #define NFC_DONE_RAW            (1 << 0)
110 #define NFC_ECC_DONE_RAW        (1 << 1)
111 #define NFC_ERR_RAW             (1 << 2)
112 #define NFC_WP_RAW              (1 << 3)
113 #define NFC_TO_RAW              (1 << 4)
114
115 #define NFC_DONE_CLR            (1 << 16)
116 #define NFC_ECC_DONE_CLR        (1 << 17)
117 #define NFC_ERR_CLR             (1 << 18)
118 #define NFC_WP_CLR              (1 << 19)
119 #define NFC_TO_CLR              (1 << 20)
120
121 #define NFC_ECC_SP_POS_OFFSET   (24)
122 #define NFC_ECC_SP_SIZE_OFFSET  (16)
123 #define NFC_ECC_NUM_OFFSET      (8)
124 #define NFC_ECC_MODE_OFFSET     (4)
125 #define NFC_ECC_MODE_1BIT       (0 << 4)
126 #define NFC_ECC_MODE_2BIT       (1 << 4)
127 #define NFC_ECC_MODE_4BIT       (2 << 4)
128 #define NFC_ECC_MODE_8BIT       (3 << 4)
129 #define NFC_ECC_MODE_12BIT      (4 << 4)
130 #define NFC_ECC_MODE_16BIT      (5 << 4)
131 #define NFC_ECC_MODE_24BIT      (6 << 4)
132 #define NFC_ECC_SP_ENDIAN       (1 << 3)
133 #define NFC_ECC_DECODE          (1 << 2)
134 #define NFC_ECC_AUTO_EN         (1 << 1)
135 #define NFC_ECC_ACTIVE          (1 << 0)
136
137 //bit define NFC_ECC_CFG1
138 #define NFC_ECC_MAIN_ADDR_OFFSET        (16)
139 #define NFC_ECC_LOC_MAIN                (1 << 15)
140 #define NFC_ECC_ERR_NUM_MASK            (0x1f)
141 struct sc8810_ecc_param {
142         u8 mode; //1, 2, 4, 8,12,16,24
143         u8 ecc_num; //max is 8
144         u8 sp_size; //spare part size
145         u8 ecc_pos; //ecc postion
146         u16 m_size;// main part size;
147         u8 *p_mbuf;
148         u8 *p_sbuf;
149         u8 *sts;
150 };
151 unsigned int sc8810_ecc_encode(struct sc8810_ecc_param *param);
152 unsigned int ecc_mode_convert(u32 mode);
153
154 #endif 
155