Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gpmi-nand.h
Go to the documentation of this file.
1 /*
2  * Freescale GPMI NAND Flash Driver
3  *
4  * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
5  * Copyright (C) 2008 Embedded Alley Solutions, Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
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 #ifndef __DRIVERS_MTD_NAND_GPMI_NAND_H
18 #define __DRIVERS_MTD_NAND_GPMI_NAND_H
19 
20 #include <linux/mtd/nand.h>
21 #include <linux/platform_device.h>
22 #include <linux/dma-mapping.h>
23 #include <linux/fsl/mxs-dma.h>
24 
25 #define GPMI_CLK_MAX 5 /* MX6Q needs five clocks */
26 struct resources {
29  unsigned int bch_low_interrupt;
30  unsigned int bch_high_interrupt;
31  unsigned int dma_low_channel;
32  unsigned int dma_high_channel;
34 };
35 
57 struct bch_geometry {
58  unsigned int gf_len;
59  unsigned int ecc_strength;
60  unsigned int page_size;
61  unsigned int metadata_size;
62  unsigned int ecc_chunk_size;
63  unsigned int ecc_chunk_count;
64  unsigned int payload_size;
65  unsigned int auxiliary_size;
67  unsigned int block_mark_byte_offset;
68  unsigned int block_mark_bit_offset;
69 };
70 
78  unsigned int stride_size_in_pages;
80 };
81 
82 /* DMA operations types */
89 };
90 
114 struct nand_timing {
122 };
123 
125  /* flags */
126 #define GPMI_ASYNC_EDO_ENABLED (1 << 0)
127 #define GPMI_TIMING_INIT_OK (1 << 1)
128  int flags;
129 
130  /* System Interface */
131  struct device *dev;
134 
135  /* Resources */
137 
138  /* Flash Hardware */
141 
142  /* BCH */
145 
146  /* NAND Boot issue */
149 
150  /* MTD / NAND */
151  struct nand_chip nand;
152  struct mtd_info mtd;
153 
154  /* General-use Variables */
156  unsigned int command_length;
157 
158  /* passed from upper layer */
161 
162  /* for DMA operations */
164 
166  char *cmd_buffer;
167 
170 
173  unsigned int page_buffer_size;
174 
177 
180 
181  /* DMA channels */
182 #define DMA_CHANS 8
188 
189  /* private */
190  void *private;
191 };
192 
207  /* for HW_GPMI_TIMING0 */
211 
212  /* for HW_GPMI_TIMING1 */
214 #define GPMI_DEFAULT_BUSY_TIMEOUT 0x500 /* default busy timeout value.*/
215 
216  /* for HW_GPMI_CTRL1 */
220 };
221 
246  const unsigned int max_chip_count;
247  const unsigned int max_data_setup_cycles;
248  const unsigned int internal_data_setup_in_ns;
249  const unsigned int max_sample_delay_factor;
250  const unsigned int max_dll_clock_period_in_ns;
251  const unsigned int max_dll_delay_in_ns;
252  unsigned long clock_frequency_in_hz;
253 
254 };
255 
256 /* Common Services */
257 extern int common_nfc_set_geometry(struct gpmi_nand_data *);
258 extern struct dma_chan *get_dma_chan(struct gpmi_nand_data *);
259 extern void prepare_data_dma(struct gpmi_nand_data *,
260  enum dma_data_direction dr);
261 extern int start_dma_without_bch_irq(struct gpmi_nand_data *,
262  struct dma_async_tx_descriptor *);
263 extern int start_dma_with_bch_irq(struct gpmi_nand_data *,
264  struct dma_async_tx_descriptor *);
265 
266 /* GPMI-NAND helper function library */
267 extern int gpmi_init(struct gpmi_nand_data *);
268 extern int gpmi_extra_init(struct gpmi_nand_data *);
269 extern void gpmi_clear_bch(struct gpmi_nand_data *);
270 extern void gpmi_dump_info(struct gpmi_nand_data *);
271 extern int bch_set_geometry(struct gpmi_nand_data *);
272 extern int gpmi_is_ready(struct gpmi_nand_data *, unsigned chip);
273 extern int gpmi_send_command(struct gpmi_nand_data *);
274 extern void gpmi_begin(struct gpmi_nand_data *);
275 extern void gpmi_end(struct gpmi_nand_data *);
276 extern int gpmi_read_data(struct gpmi_nand_data *);
277 extern int gpmi_send_data(struct gpmi_nand_data *);
278 extern int gpmi_send_page(struct gpmi_nand_data *,
280 extern int gpmi_read_page(struct gpmi_nand_data *,
282 
283 /* BCH : Status Block Completion Codes */
284 #define STATUS_GOOD 0x00
285 #define STATUS_ERASED 0xff
286 #define STATUS_UNCORRECTABLE 0xfe
287 
288 /* Use the platform_id to distinguish different Archs. */
289 #define IS_MX23 0x0
290 #define IS_MX28 0x1
291 #define IS_MX6Q 0x2
292 #define GPMI_IS_MX23(x) ((x)->pdev->id_entry->driver_data == IS_MX23)
293 #define GPMI_IS_MX28(x) ((x)->pdev->id_entry->driver_data == IS_MX28)
294 #define GPMI_IS_MX6Q(x) ((x)->pdev->id_entry->driver_data == IS_MX6Q)
295 #endif