blob: 04b36beb99578020ca6e874979c14431ae10af05 [file] [log] [blame]
Feng Chenee8403d2024-01-03 14:13:40 +08001/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2/*
3 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
4 */
5
6#ifndef __AML_HWCTRL_H__
7#define __AML_HWCTRL_H__
8
9//#include <asm/arch/secure_apb.h>
10#include <asm/amlogic/arch/cpu_sdio.h>
11#include <asm/io.h>
12#include <clk.h>
13#define AML_NAND_UBOOT
14#define NAND_TWB_TIME_CYCLE 10
15
16#define HHI_NAND_CLK_CNTL1 (0xff63c000 + (0x097 << 2))
17
18#define CE_PAD_DEFAULT \
19 ((AML_NAND_CE0) | \
20 (AML_NAND_CE1 << 4) | \
21 (AML_NAND_CE2 << 8) | \
22 (AML_NAND_CE3 << 12))
23
24#define RB_PAD_DEFAULT (AML_NAND_CE0)
25#define MAX_CHIP_NUM 4
26
27/*** HW controller configuration ***/
28struct hw_controller {
29 struct udevice *device;
30 u32 chip_selected;
31 u32 rb_received;
32 u8 chip_num;
33 u32 ce_enable[MAX_CHIP_NUM];
34 u32 rb_enable[MAX_CHIP_NUM];
35 struct clk xtal;
36 struct clk fdiv2;
37 struct clk mux;
38 struct clk div;
39 struct clk gate;
40 void __iomem *reg_base;
41 void __iomem *nand_clk_reg;
42 void __iomem *spi_cfg;
43 u32 irq;
44};
45
46#ifndef AML_NAND_UBOOT
47#include <linux/types.h>
48#endif /* AML_NAND_UBOOT */
49
50#define NF_REG_INDEX 0
51#define EXTCLK_REG_INDEX 1
52#define EXTPORT_REG_INDEX 2
53
54#define RETURN_PAGE_ALL_0XFF 0x01
55#define RETURN_PAGE_NEED_READRETRY 0x02
56
57#ifdef AML_NAND_UBOOT
58#define MESON_CPU_MAJOR_ID_M8 0x19
59#define MESON_CPU_MAJOR_ID_GX 0x21
60#endif /* AML_NAND_UBOOT */
61
62#ifdef AML_NAND_UBOOT
63static inline int get_cpu_type(void)
64{
65 return MESON_CPU_MAJOR_ID_GX;
66}
67#endif /* AML_NAND_UBOOT */
68
69#define NAND_CYCLE_DELAY ((get_cpu_type() >= MESON_CPU_MAJOR_ID_M8)?(84):(90))
70
71#ifdef AML_NAND_UBOOT
72/* gxb and later, for pxp and ic. */
73#define P_NAND_BASE (SD_EMMC_BASE_C | (1<<11))
74#define NAND_BASE_APB (P_NAND_BASE)
75#define NAND_CLK_REG (SD_EMMC_BASE_C)
76#endif /* AML_NAND_UBOOT */
77
78/* NAND Write Command And Read Status Register */
79#define P_NAND_CMD (0x00)
80/* NAND Configuration Register */
81#define P_NAND_CFG (0x04)
82/* NAND Data Address Register */
83#define P_NAND_DADR (0x08)
84/* NAND Information Address Register */
85#define P_NAND_IADR (0x0c)
86/* NAND Read Data Buffer Register */
87#define P_NAND_BUF (0x10)
88/* NAND Information Register */
89#define P_NAND_INFO (0x14)
90/* NAND DDR interface Register */
91#define P_NAND_DC (0x18)
92/* NAND DDR Address Register */
93#define P_NAND_ADR (0x1c)
94/* NAND DDR Low 32 bits Data Register */
95#define P_NAND_DL (0x20)
96/* NAND DDR High 32 bits Data Register */
97#define P_NAND_DH (0x24)
98/* NAND Command Queus Address Register */
99#define P_NAND_CADR (0x28)
100/* NAND Status Address Register */
101#define P_NAND_SADR (0x2c)
102/* NAND CS2: SDRAM/NAND pin sharing Register */
103#define P_NAND_PINS (0x30)
104/* NAND Version number Register */
105#define P_NAND_VER (0x38)
106
107/*...other way to access cfg...*/
108typedef union _nand_cfg {
109 /** raw register data */
110 u32 d;
111 /** register bits */
112 struct {
113 u32 bus_cyc:5; //0
114 u32 bus_tim:5; //5
115 u32 sync:2; //10
116 u32 cmd_start:1; //12
117 u32 cmd_auto:1; //13
118 u32 apb_mode:1; //14
119 u32 spare_only:1; //15
120 u32 sync_adj:1; //16
121 u32 secure_des:1; //17
122 u32 reserved18:2; //18
123 u32 sts_irq_en:1; //20
124 u32 cmd_irq_en:1; //21
125 u32 reserved22:4; //25
126 u32 oob_on:1; //26
127 u32 oob_mode:1; //27
128 u32 dc_ugt:1; //28
129 u32 nand_wpn:1; //29
130 u32 dma_power:1; //30
131 u32 bus_power:1; //31
132 } b;
133} nand_cfg_t;
134
135typedef struct _nand_reg {
136 volatile u32 cmd;
137 volatile u32 cfg;
138} nand_reg_t;
139
140extern nand_reg_t *p_nand_reg;
141static inline u32 amlnf_read_reg32(volatile uint32_t *_reg)
142{
143 /*---*/
144#ifndef AML_NAND_UBOOT
145 smp_rmb();
146#endif /* AML_NAND_UBOOT */
147 return __raw_readl(_reg);
148};
149
150static inline void amlnf_write_reg32(volatile uint32_t *_reg,
151 const u32 _value)
152{
153 __raw_writel(_value, _reg);
154 /*---*/
155#ifndef AML_NAND_UBOOT
156 smp_mb();
157#endif /* AML_NAND_UBOOT */
158};
159
160static inline void amlnf_set_reg32_bits(volatile uint32_t *_reg,
161 const u32 _value,
162 const u32 _start,
163 const u32 _len)
164{
165 /*---*/
166#ifndef AML_NAND_UBOOT
167 smp_rmb();
168#endif /* AML_NAND_UBOOT */
169 __raw_writel(((__raw_readl(_reg) & ~(((1L << (_len))-1) << (_start)))
170 | ((u32)((_value)&((1L<<(_len))-1)) << (_start))), _reg);
171 /*---*/
172#ifndef AML_NAND_UBOOT
173 smp_wmb();
174#endif /* AML_NAND_UBOOT */
175}
176
177static inline void amlnf_clrset_reg32_bits(volatile uint32_t *_reg,
178 const u32 clr,
179 const u32 set)
180{
181 /*---*/
182#ifndef AML_NAND_UBOOT
183 smp_rmb();
184#endif /* AML_NAND_UBOOT */
185 __raw_writel((__raw_readl(_reg) & ~(clr)) | (set), _reg);
186 /*---*/
187#ifndef AML_NAND_UBOOT
188 smp_wmb();
189#endif /* AML_NAND_UBOOT */
190}
191
192static inline u32 amlnf_get_reg32_bits(volatile uint32_t *_reg,
193 const u32 _start,
194 const u32 _len)
195{
196 /*---*/
197#ifndef AML_NAND_UBOOT
198 smp_rmb();
199#endif /* AML_NAND_UBOOT */
200 return (__raw_readl(_reg) >> (_start)) & ((1L << (_len)) - 1);
201}
202
203static inline void amlnf_set_reg32_mask(volatile uint32_t *_reg,
204 const u32 _mask)
205{
206 /*---*/
207#ifndef AML_NAND_UBOOT
208 smp_rmb();
209#endif /* AML_NAND_UBOOT */
210 __raw_writel((__raw_readl(_reg) | (_mask)), _reg);
211 /*---*/
212#ifndef AML_NAND_UBOOT
213 smp_wmb();
214#endif /* AML_NAND_UBOOT */
215}
216
217static inline void amlnf_clr_reg32_mask(volatile uint32_t *_reg,
218 const u32 _mask)
219{
220 /*---*/
221#ifndef AML_NAND_UBOOT
222 smp_rmb();
223#endif /* AML_NAND_UBOOT */
224 __raw_writel((__raw_readl(_reg) & (~(_mask))), _reg);
225 /*---*/
226#ifndef AML_NAND_UBOOT
227 smp_wmb();
228#endif /* AML_NAND_UBOOT */
229}
230
231/*
232#define nfc_readl(host, reg) \
233 __raw_readl((host)->reg_base + P_##reg)
234#define nfc_writel(host, reg, value) \
235 __raw_writel((value), (host)->reg_base + P_##reg)
236#define nfc_readw(host, reg) \
237 __raw_readw((host)->reg_base + P_##reg)
238#define nfc_writew(host, reg, value) \
239 __raw_writew((value), (host)->reg_base + P_##reg)
240 #define nfc_readb(host, reg) \
241 __raw_readb((host)->reg_base + P_##reg)
242#define nfc_writeb(host, reg, value) \
243 __raw_writeb((value), (host)->reg_base + P_##reg)
244
245#define nfc_set_bits(host, reg) \
246 {\
247 u32 value;\
248 value = __raw_readl((host)->reg_base + P_##reg);\
249 value &= ~((( 1L << (_len) )-1) << (_start)); \
250 value |= ((u32)((_value)&((1L<<(_len))-1)) << (_start));\
251 __raw_writel(value, (host)->reg_base + P_##reg);\
252 }
253*/
254
255#define AMLNF_WRITE_REG(reg, val) (amlnf_write_reg32(reg, (val)))
256#define AMLNF_READ_REG(reg) (amlnf_read_reg32(reg))
257/*
258#define AMLNF_WRITE_REG_BITS(reg, val, start, len) \
259 (amlnf_set_reg32_bits((volatile uint32_t *)(reg), (val), start, len))
260*/
261#define AMLNF_WRITE_REG_BITS(reg, val, start, len) \
262 (amlnf_set_reg32_bits(reg, val, start, len))
263/*
264#define AMLNF_READ_REG_BITS(bus,reg, start, len) \
265 (amlnf_get_reg32_bits(reg,start,len))
266*/
267/*
268#define AMLNF_CLEAR_REG_MASK(reg, mask) \
269 (amlnf_clr_reg32_mask((volatile uint32_t *)(reg), (mask)))
270#define AMLNF_SET_REG_MASK(reg, mask) \
271 (amlnf_set_reg32_mask((volatile uint32_t *)(reg), (mask)))
272*/
273#define AMLNF_CLEAR_REG_MASK(reg, mask) (amlnf_clr_reg32_mask(reg, mask))
274#define AMLNF_SET_REG_MASK(reg, mask) (amlnf_set_reg32_mask(reg, mask))
275
276/*
277#define NFC_SET_TIMING(host, mode, cycles, adjust) \
278 AMLNF_WRITE_REG_BITS((host)->reg_base + P_NAND_CFG, \
279 ((cycles)|((adjust&0xf)<<10)|((mode&7)<<5)), 0, 14)
280#define NFC_SET_CMD_START(host) \
281 AMLNF_SET_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<12)
282
283#define NFC_SET_CMD_AUTO(host) \
284 AMLNF_SET_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<13)
285
286#define NFC_SET_STS_IRQ(host, en) \
287 AMLNF_WRITE_REG_BITS((host)->reg_base + P_NAND_CFG, en, 20, 1)
288
289#define NFC_SET_CMD_IRQ(host, en) \
290 AMLNF_WRITE_REG_BITS((host)->reg_base + P_NAND_CFG, en, 21, 1)
291*/
292#define NFC_SET_TIMING_ASYC(host, bus_tim, bus_cyc) \
293 AMLNF_WRITE_REG_BITS((host)->reg_base + P_NAND_CFG, \
294 ((bus_cyc&31)|((bus_tim&31)<<5)|(0<<10)), \
295 0, \
296 12)
297/*
298#define NFC_SET_TIMING_SYNC(host, bus_tim, bus_cyc, sync_mode) \
299 AMLNF_WRITE_REG_BITS((host)->reg_base + P_NAND_CFG, \
300 (bus_cyc&31)|((bus_tim&31)<<5)|((sync_mode&2)<<10), \
301 0, \
302 12)
303#define NFC_SET_TIMING_SYNC_ADJUST()
304#define NFC_SET_DMA_MODE(host, is_apb, spare_only) \
305 AMLNF_WRITE_REG_BITS((host)->reg_base + P_NAND_CFG, \
306 ((spare_only<<1)|(is_apb)), \
307 14, \
308 2)
309*/
310#define NFC_SET_OOB_MODE(host, mode) \
311 AMLNF_SET_REG_MASK((host)->reg_base + P_NAND_CFG, mode);
312#define NFC_CLR_OOB_MODE(host, mode) \
313 AMLNF_CLEAR_REG_MASK((host)->reg_base + P_NAND_CFG, mode);
314/*
315#define NFC_ENABLE_STS_IRQ(host) \
316 AMLNF_SET_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<20)
317#define NFC_DISABLE_STS_IRQ(host) \
318 AMLNF_CLEAR_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<20)
319*/
320#define NFC_ENABLE_IO_IRQ(host) \
321 AMLNF_SET_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<21)
322#define NFC_DISABLE_IO_IRQ(host) \
323 AMLNF_CLEAR_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<21)
324
325#define NFC_ENABLE_ENCRYPT(host) \
326 AMLNF_SET_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<17)
327#define NFC_DISABLE_ENCRYPT(host) \
328 AMLNF_CLEAR_REG_MASK((host)->reg_base + P_NAND_CFG, 1<<17)
329
330
331/**
332 ADDR operations
333*/
334#define NFC_SET_DADDR(host, a) \
335 (AMLNF_WRITE_REG((host)->reg_base + P_NAND_DADR, (u32)a))
336#define NFC_SET_IADDR(host, a) \
337 (AMLNF_WRITE_REG((host)->reg_base + P_NAND_IADR, (u32)a))
338#define NFC_SET_SADDR(host, a) \
339 (AMLNF_WRITE_REG((host)->reg_base + P_NAND_SADR, (u32)a))
340
341#define NFC_INFO_GET(host) \
342 (AMLNF_READ_REG((host)->reg_base + P_NAND_CMD))
343
344#define NFC_GET_BUF(host) \
345 AMLNF_READ_REG((host)->reg_base + P_NAND_BUF)
346#define NFC_SET_CFG(host, val) \
347 (AMLNF_WRITE_REG((host)->reg_base + P_NAND_CFG, (u32)val))
348
349/*Common Nand Read Flow*/
350 #define CE0 (0xe<<10)
351#define CE1 (0xd<<10)
352#define CE2 (0xb<<10)
353#define CE3 (0x7<<10)
354#define CE_NOT_SEL (0xf<<10)
355#define IO4 ((0xe<<10)|(1<<18))
356#define IO5 ((0xd<<10)|(1<<18))
357#define IO6 ((0xb<<10)|(1<<18))
358#define CLE (0x5<<14)
359#define ALE (0x6<<14)
360#define DWR (0x4<<14)
361#define DRD (0x8<<14)
362#define IDLE (0xc<<14)
363#define RB (1<<20)
364#define STANDBY (0xf<<10)
365
366#define M2N ((0<<17) | (2<<20) | (1<<19))
367#define N2M ((1<<17) | (2<<20) | (1<<19))
368
369#define M2N_NORAN 0x00200000
370#define N2M_NORAN 0x00220000
371
372#define STS ((3<<17) | (2<<20))
373#define ADL ((0<<16) | (3<<20))
374#define ADH ((1<<16) | (3<<20))
375#define AIL ((2<<16) | (3<<20))
376#define AIH ((3<<16) | (3<<20))
377#define ASL ((4<<16) | (3<<20))
378#define ASH ((5<<16) | (3<<20))
379#define SEED ((8<<16) | (3<<20))
380
381#define SEED_OFFSET 0xc2
382
383#define NFC_CMD_IDLE(ce, time) ((ce)|IDLE|(time&0x3ff))
384#define NFC_CMD_CLE(ce, cmd) ((ce)|CLE | (cmd & 0x0ff))
385#define NFC_CMD_ALE(ce, addr) ((ce)|ALE | (addr&0x0ff))
386#define NFC_CMD_STANDBY(time) (STANDBY | (time&0x3ff))
387#define NFC_CMD_ADL(addr) (ADL | (addr&0xffff))
388#define NFC_CMD_ADH(addr) (ADH|((addr>>16)&0xffff))
389#define NFC_CMD_AIL(addr) (AIL | (addr&0xffff))
390#define NFC_CMD_AIH(addr) (AIH|((addr>>16)&0xffff))
391#define NFC_CMD_DWR(ce, data) (ce|DWR | (data&0xff))
392#define NFC_CMD_DRD(ce, size) (ce|DRD|size)
393#define NFC_CMD_RB(ce, time) ((ce)|RB | (time&0x1f))
394#define NFC_CMD_RB_INT(ce, time) \
395 ((ce)|RB|(((ce>>10)^0xf)<<14)|(time&0x1f))
396#define NFC_CMD_RBIO(time, io) (RB|io|(time&0x1f))
397#define NFC_CMD_RBIO_IRQ(time) (RB|IO6|(1<<16)|(time&0x1f))
398#define NFC_CMD_RBIO_INT(io, time) (RB|(((io>>10)^0x7)<<14)|(time&0x1f))
399#define NFC_CMD_SEED(seed) (SEED|(SEED_OFFSET + (seed&0x7fff)))
400#define NFC_CMD_STS(tim) (STS|(tim&3))
401#define NFC_CMD_M2N(ran, ecc, sho, pgsz, pag) \
402 ((ran?M2N:M2N_NORAN)|(ecc<<14)|(sho<<13)|((pgsz&0x7f)<<6)|(pag&0x3f))
403#define NFC_CMD_N2M(ran, ecc, sho, pgsz, pag)\
404 ((ran?N2M:N2M_NORAN)|(ecc<<14)|(sho<<13)|((pgsz&0x7f)<<6)|(pag&0x3f))
405
406/**
407Alias for CMD
408#define NFC_CMD_D_ADR(addr) NFC_CMD_ADL(addr), NFC_CMD_ADH(addr)
409#define NFC_CMD_I_ADR(addr) NFC_CMD_ADI(addr), NFC_CMD_ADI(addr)
410*/
411#define NAND_ECC_NONE (0x0)
412#define NAND_ECC_BCH8 (0x1)
413#define NAND_ECC_BCH8_1K (0x2)
414#define NAND_ECC_BCH24_1K (0x3)
415#define NAND_ECC_BCH30_1K (0x4)
416#define NAND_ECC_BCH40_1K (0x5)
417#define NAND_ECC_BCH50_1K (0x6)
418/*NAND_ECC_BCH50_1K only for mtd general*/
419#define NAND_ECC_BCH60_1K (0x7)
420#define NAND_ECC_BCH_SHORT (0x8)
421
422#define PER_INFO_BYTE 8
423/*Register Operation and Controller Status*/
424#define NFC_SEND_CMD(host, cmd) \
425 (AMLNF_WRITE_REG((host)->reg_base + P_NAND_CMD, cmd))
426#define NFC_READ_INFO(host) \
427 (AMLNF_READ_REG((host)->reg_base + P_NAND_CMD))
428
429/*Send command directly*/
430#define NFC_SEND_CMD_IDLE(host, time) \
431 {\
432 while (NFC_CMDFIFO_SIZE(host) > 0)\
433 ; \
434 NFC_SEND_CMD(host, NFC_CMD_IDLE((host)->chip_selected, time)); \
435 }
436#define NFC_SEND_CMD_CLE(host, ce, cmd) \
437 NFC_SEND_CMD(host, NFC_CMD_CLE(ce, cmd))
438#define NFC_SEND_CMD_ALE(host, ce, addr) \
439 NFC_SEND_CMD(host, NFC_CMD_ALE(ce, addr))
440#define NFC_SEND_CMD_STANDBY(host, time) \
441 NFC_SEND_CMD(host, NFC_CMD_STANDBY(time))
442#define NFC_SEND_CMD_ADL(host, addr) \
443 NFC_SEND_CMD(host, NFC_CMD_ADL(addr))
444#define NFC_SEND_CMD_ADH(host, addr) \
445 NFC_SEND_CMD(host, NFC_CMD_ADH(addr))
446#define NFC_SEND_CMD_AIL(host, addr) \
447 NFC_SEND_CMD(host, NFC_CMD_AIL(addr))
448#define NFC_SEND_CMD_AIH(host, addr) \
449 NFC_SEND_CMD(host, NFC_CMD_AIH(addr))
450#define NFC_SEND_CMD_DWR(host, ce, data) \
451 NFC_SEND_CMD(host, NFC_CMD_DWR(ce, data))
452#define NFC_SEND_CMD_DRD(host, ce, size) \
453 NFC_SEND_CMD(host, NFC_CMD_DRD(ce, size))
454#define NFC_SEND_CMD_RB(host, ce, time) \
455 NFC_SEND_CMD(host, NFC_CMD_RB(ce, time))
456#define NFC_SEND_CMD_SEED(host, seed) \
457 NFC_SEND_CMD(host, NFC_CMD_SEED(seed))
458#define NFC_SEND_CMD_M2N(host, ran, ecc, sho, pgsz, pag) \
459 NFC_SEND_CMD(host, NFC_CMD_M2N(ran, ecc, sho, pgsz, pag))
460#define NFC_SEND_CMD_N2M(host, ran, ecc, sho, pgsz, pag) \
461 NFC_SEND_CMD(host, NFC_CMD_N2M(ran, ecc, sho, pgsz, pag))
462
463#define NFC_SEND_CMD_M2N_RAW(host, ran, len) \
464 NFC_SEND_CMD(host, (ran?M2N:M2N_NORAN)|(len&0x3fff))
465#define NFC_SEND_CMD_N2M_RAW(host, ran, len) \
466 NFC_SEND_CMD(host, (ran?N2M:N2M_NORAN)|(len&0x3fff))
467
468#define NFC_SEND_CMD_STS(host, time, irq) \
469 NFC_SEND_CMD(host, NFC_CMD_STS(time | irq))
470
471#define NFC_SEND_CMD_RB_IRQ(host, time) \
472 NFC_SEND_CMD(host, NFC_CMD_RBIO_IRQ(time))
473
474/*Cmd Info Macros*/
475#define NFC_CMDFIFO_SIZE(host) ((NFC_INFO_GET(host)>>22)&0x1f)
476#define NFC_CHECEK_RB_TIMEOUT(host) ((NFC_INFO_GET(host)>>27)&0x1)
477#define NFC_FIFO_CUR_CMD(host) ((NFC_INFO_GET(host)>>22)&0x3FFFFF)
478#define NFC_GET_RB_STATUS(host, ce) \
479 (((NFC_INFO_GET(host)>>28)&(~(ce>>10)))&0xf)
480
481
482#define NAND_INFO_DONE(a) (((a)>>31)&1)
483#define NAND_ECC_ENABLE(a) (((a)>>30)&1)
484#define NAND_ECC_CNT(a) (((a)>>24)&0x3f)
485#define NAND_ZERO_CNT(a) (((a)>>16)&0x3f)
486#define NAND_INFO_DATA_2INFO(a) ((a)&0xffff)
487#define NAND_INFO_DATA_1INFO(a) ((a)&0xff)
488
489#define POR_CONFIG READ_CBUS_REG(ASSIST_POR_CONFIG)
490
491#define POC_NAND_CFG (1<<2)
492#define POC_NAND_NO_RB (1<<0)
493#define POC_NAND_ASYNC (1<<7)
494/*nand relate define for hw controller*/
495/*ecc type define*/
496#define NAND_ECC_SOFT_MODE 0x00000000
497#define NAND_ECC_SHORT_MODE 0x00000001
498#define NAND_ECC_BCH9_MODE 0x00000002
499#define NAND_ECC_BCH8_MODE 0x00000003
500#define NAND_ECC_BCH12_MODE 0x00000004
501#define NAND_ECC_BCH16_MODE 0x00000005
502#define NAND_ECC_BCH8_1K_MODE 0x00000006
503#define NAND_ECC_BCH16_1K_MODE 0x00000007
504#define NAND_ECC_BCH24_1K_MODE 0x00000008
505#define NAND_ECC_BCH30_1K_MODE 0x00000009
506#define NAND_ECC_BCH40_1K_MODE 0x0000000a
507#define NAND_ECC_BCH50_1K_MODE 0x0000000b
508#define NAND_ECC_BCH60_1K_MODE 0x0000000c
509
510/*ecc page unit define*/
511#define NAND_ECC_UNIT_SIZE 512
512#define NAND_ECC_UNIT_1KSIZE 1024
513#define NAND_ECC_UNIT_SHORT 384
514
515/*ecc type oob size(bytes) needed*/
516#define NAND_BCH9_ECC_SIZE 15
517#define NAND_BCH8_ECC_SIZE 14
518#define NAND_BCH12_ECC_SIZE 20
519#define NAND_BCH16_ECC_SIZE 26
520#define NAND_BCH8_1K_ECC_SIZE 14
521#define NAND_BCH16_1K_ECC_SIZE 28
522#define NAND_BCH24_1K_ECC_SIZE 42
523#define NAND_BCH30_1K_ECC_SIZE 54
524#define NAND_BCH40_1K_ECC_SIZE 70
525#define NAND_BCH50_1K_ECC_SIZE 88
526#define NAND_BCH60_1K_ECC_SIZE 106
527
528#endif /* __HW_CTRL_H__ */