<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter 5. Advanced board driver functions</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><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="ch04s06.html" title="Exit function" /><link rel="next" href="ch05s02.html" title="Hardware ECC support" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Advanced board driver functions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s06.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 5. Advanced board driver functions"><div class="titlepage"><div><div><h2 class="title"><a id="boarddriversadvanced"></a>Chapter 5. Advanced board driver functions</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch05.html#Multiple_chip_control">Multiple chip control</a></span></dt><dt><span class="sect1"><a href="ch05s02.html">Hardware ECC support</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s02.html#Functions_and_constants">Functions and constants</a></span></dt><dt><span class="sect2"><a href="ch05s02.html#Hardware_ECC_with_syndrome_calculation">Hardware ECC with syndrome calculation</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s03.html">Bad block table support</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s03.html#Flash_based_tables">Flash based tables</a></span></dt><dt><span class="sect2"><a href="ch05s03.html#User_defined_tables">User defined tables</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s04.html">Spare area (auto)placement</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s04.html#Placement_defined_by_fs_driver">Placement defined by fs driver</a></span></dt><dt><span class="sect2"><a href="ch05s04.html#Automatic_placement">Automatic placement</a></span></dt><dt><span class="sect2"><a href="ch05s04.html#User_space_placement_selection">User space placement selection</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s05.html">Spare area autoplacement default schemes</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s05.html#pagesize_256">256 byte pagesize</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#pagesize_512">512 byte pagesize</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#pagesize_2048">2048 byte pagesize</a></span></dt></dl></dd></dl></div><p> This chapter describes the advanced functionality of the NAND driver. For a list of functions which can be overridden by the board driver see the documentation of the nand_chip structure. </p><div class="sect1" title="Multiple chip control"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Multiple_chip_control"></a>Multiple chip control</h2></div></div></div><p> The nand driver can control chip arrays. Therefor the board driver must provide an own select_chip function. This function must (de)select the requested chip. The function pointer in the nand_chip structure must be set before calling nand_scan(). The maxchip parameter of nand_scan() defines the maximum number of chips to scan for. Make sure that the select_chip function can handle the requested number of chips. </p><p> The nand driver concatenates the chips to one virtual chip and provides this virtual chip to the MTD layer. </p><p> <span class="emphasis"><em>Note: The driver can only handle linear chip arrays of equally sized chips. There is no support for parallel arrays which extend the buswidth.</em></span> </p><p> <span class="emphasis"><em>GPIO based example</em></span> </p><pre class="programlisting"> static void board_select_chip (struct mtd_info *mtd, int chip) { /* Deselect all chips, set all nCE pins high */ GPIO(BOARD_NAND_NCE) |= 0xff; if (chip >= 0) GPIO(BOARD_NAND_NCE) &= ~ (1 << chip); } </pre><p> <span class="emphasis"><em>Address lines based example.</em></span> Its assumed that the nCE pins are connected to an address decoder. </p><pre class="programlisting"> static void board_select_chip (struct mtd_info *mtd, int chip) { struct nand_chip *this = (struct nand_chip *) mtd->priv; /* Deselect all chips */ this->IO_ADDR_R &= ~BOARD_NAND_ADDR_MASK; this->IO_ADDR_W &= ~BOARD_NAND_ADDR_MASK; switch (chip) { case 0: this->IO_ADDR_R |= BOARD_NAND_ADDR_CHIP0; this->IO_ADDR_W |= BOARD_NAND_ADDR_CHIP0; break; .... case n: this->IO_ADDR_R |= BOARD_NAND_ADDR_CHIPn; this->IO_ADDR_W |= BOARD_NAND_ADDR_CHIPn; break; } } </pre></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s06.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Exit function </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Hardware ECC support</td></tr></table></div></body></html>