1 /*
2  * Copyright (C) 2006 Micron Technology Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8 
9 #ifndef	_MTD_NAND_OMAP2_H
10 #define	_MTD_NAND_OMAP2_H
11 
12 #include <linux/mtd/partitions.h>
13 
14 #define	GPMC_BCH_NUM_REMAINDER	8
15 
16 enum nand_io {
17 	NAND_OMAP_PREFETCH_POLLED = 0,	/* prefetch polled mode, default */
18 	NAND_OMAP_POLLED,		/* polled mode, without prefetch */
19 	NAND_OMAP_PREFETCH_DMA,		/* prefetch enabled sDMA mode */
20 	NAND_OMAP_PREFETCH_IRQ		/* prefetch enabled irq mode */
21 };
22 
23 enum omap_ecc {
24 	/* 1-bit  ECC calculation by GPMC, Error detection by Software */
25 	OMAP_ECC_HAM1_CODE_HW = 0,
26 	/* 4-bit  ECC calculation by GPMC, Error detection by Software */
27 	OMAP_ECC_BCH4_CODE_HW_DETECTION_SW,
28 	/* 4-bit  ECC calculation by GPMC, Error detection by ELM */
29 	OMAP_ECC_BCH4_CODE_HW,
30 	/* 8-bit  ECC calculation by GPMC, Error detection by Software */
31 	OMAP_ECC_BCH8_CODE_HW_DETECTION_SW,
32 	/* 8-bit  ECC calculation by GPMC, Error detection by ELM */
33 	OMAP_ECC_BCH8_CODE_HW,
34 };
35 
36 struct gpmc_nand_regs {
37 	void __iomem	*gpmc_status;
38 	void __iomem	*gpmc_nand_command;
39 	void __iomem	*gpmc_nand_address;
40 	void __iomem	*gpmc_nand_data;
41 	void __iomem	*gpmc_prefetch_config1;
42 	void __iomem	*gpmc_prefetch_config2;
43 	void __iomem	*gpmc_prefetch_control;
44 	void __iomem	*gpmc_prefetch_status;
45 	void __iomem	*gpmc_ecc_config;
46 	void __iomem	*gpmc_ecc_control;
47 	void __iomem	*gpmc_ecc_size_config;
48 	void __iomem	*gpmc_ecc1_result;
49 	void __iomem	*gpmc_bch_result0[GPMC_BCH_NUM_REMAINDER];
50 	void __iomem	*gpmc_bch_result1[GPMC_BCH_NUM_REMAINDER];
51 	void __iomem	*gpmc_bch_result2[GPMC_BCH_NUM_REMAINDER];
52 	void __iomem	*gpmc_bch_result3[GPMC_BCH_NUM_REMAINDER];
53 };
54 
55 struct omap_nand_platform_data {
56 	int			cs;
57 	struct mtd_partition	*parts;
58 	int			nr_parts;
59 	bool			dev_ready;
60 	enum nand_io		xfer_type;
61 	int			devsize;
62 	enum omap_ecc           ecc_opt;
63 	struct gpmc_nand_regs	reg;
64 
65 	/* for passing the partitions */
66 	struct device_node	*of_node;
67 	struct device_node	*elm_of_node;
68 };
69 #endif
70