1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;5.&#160;Advanced board driver functions</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="MTD NAND Driver Programming Interface"><link rel="up" href="index.html" title="MTD NAND Driver Programming Interface"><link rel="prev" href="Exit_function.html" title="Exit function"><link rel="next" href="Hardware_ECC_support.html" title="Hardware ECC support"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;5.&#160;Advanced board driver functions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="Exit_function.html">Prev</a>&#160;</td><th width="60%" align="center">&#160;</th><td width="20%" align="right">&#160;<a accesskey="n" href="Hardware_ECC_support.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="boarddriversadvanced"></a>Chapter&#160;5.&#160;Advanced board driver functions</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="boarddriversadvanced.html#Multiple_chip_control">Multiple chip control</a></span></dt><dt><span class="sect1"><a href="Hardware_ECC_support.html">Hardware ECC support</a></span></dt><dd><dl><dt><span class="sect2"><a href="Hardware_ECC_support.html#Functions_and_constants">Functions and constants</a></span></dt><dt><span class="sect2"><a href="Hardware_ECC_support.html#Hardware_ECC_with_syndrome_calculation">Hardware ECC with syndrome calculation</a></span></dt></dl></dd><dt><span class="sect1"><a href="Bad_Block_table_support.html">Bad block table support</a></span></dt><dd><dl><dt><span class="sect2"><a href="Bad_Block_table_support.html#Flash_based_tables">Flash based tables</a></span></dt><dt><span class="sect2"><a href="Bad_Block_table_support.html#User_defined_tables">User defined tables</a></span></dt></dl></dd><dt><span class="sect1"><a href="Spare_area_placement.html">Spare area (auto)placement</a></span></dt><dd><dl><dt><span class="sect2"><a href="Spare_area_placement.html#Placement_defined_by_fs_driver">Placement defined by fs driver</a></span></dt><dt><span class="sect2"><a href="Spare_area_placement.html#Automatic_placement">Automatic placement</a></span></dt></dl></dd><dt><span class="sect1"><a href="Spare_area_autoplacement_default.html">Spare area autoplacement default schemes</a></span></dt><dd><dl><dt><span class="sect2"><a href="Spare_area_autoplacement_default.html#pagesize_256">256 byte pagesize</a></span></dt><dt><span class="sect2"><a href="Spare_area_autoplacement_default.html#pagesize_512">512 byte pagesize</a></span></dt><dt><span class="sect2"><a href="Spare_area_autoplacement_default.html#pagesize_2048">2048 byte pagesize</a></span></dt></dl></dd></dl></div><p>
2		This chapter describes the advanced functionality of the NAND
3		driver. For a list of functions which can be overridden by the board
4		driver see the documentation of the nand_chip structure.
5	</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Multiple_chip_control"></a>Multiple chip control</h2></div></div></div><p>
6			The nand driver can control chip arrays. Therefore the
7			board driver must provide an own select_chip function. This
8			function must (de)select the requested chip.
9			The function pointer in the nand_chip structure must
10			be set before calling nand_scan(). The maxchip parameter
11			of nand_scan() defines the maximum number of chips to
12			scan for. Make sure that the select_chip function can
13			handle the requested number of chips.
14		</p><p>
15			The nand driver concatenates the chips to one virtual
16			chip and provides this virtual chip to the MTD layer.
17		</p><p>
18			<span class="emphasis"><em>Note: The driver can only handle linear chip arrays
19			of equally sized chips. There is no support for
20			parallel arrays which extend the buswidth.</em></span>
21		</p><p>
22			<span class="emphasis"><em>GPIO based example</em></span>
23		</p><pre class="programlisting">
24static void board_select_chip (struct mtd_info *mtd, int chip)
25{
26	/* Deselect all chips, set all nCE pins high */
27	GPIO(BOARD_NAND_NCE) |= 0xff;	
28	if (chip &gt;= 0)
29		GPIO(BOARD_NAND_NCE) &amp;= ~ (1 &lt;&lt; chip);
30}
31		</pre><p>
32			<span class="emphasis"><em>Address lines based example.</em></span>
33			Its assumed that the nCE pins are connected to an
34			address decoder.
35		</p><pre class="programlisting">
36static void board_select_chip (struct mtd_info *mtd, int chip)
37{
38	struct nand_chip *this = (struct nand_chip *) mtd-&gt;priv;
39	
40	/* Deselect all chips */
41	this-&gt;IO_ADDR_R &amp;= ~BOARD_NAND_ADDR_MASK;
42	this-&gt;IO_ADDR_W &amp;= ~BOARD_NAND_ADDR_MASK;
43	switch (chip) {
44	case 0:
45		this-&gt;IO_ADDR_R |= BOARD_NAND_ADDR_CHIP0;
46		this-&gt;IO_ADDR_W |= BOARD_NAND_ADDR_CHIP0;
47		break;
48	....	
49	case n:
50		this-&gt;IO_ADDR_R |= BOARD_NAND_ADDR_CHIPn;
51		this-&gt;IO_ADDR_W |= BOARD_NAND_ADDR_CHIPn;
52		break;
53	}	
54}
55		</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="Exit_function.html">Prev</a>&#160;</td><td width="20%" align="center">&#160;</td><td width="40%" align="right">&#160;<a accesskey="n" href="Hardware_ECC_support.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Exit function&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Hardware ECC support</td></tr></table></div></body></html>
56