Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static void mxc_nand_command ( struct mtd_info *  mtd,
unsigned  command,
int  column,
int  page_addr 
) [static]

This function is used by the upper layer to write command to NAND Flash for different operations to be carried out on NAND Flash

Parameters:
mtd MTD structure for the NAND Flash
command command for NAND Flash
column column offset for the page read
page_addr page to be read from NAND Flash

Definition at line 856 of file mxc_nd2.c.

References MAIN_AREA0, mxc_nand_command(), send_cmd(), send_prog_page(), send_read_id(), send_read_page(), and SPARE_AREA0.

{
      bool useirq = true;

      DEBUG(MTD_DEBUG_LEVEL3,
            "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
            command, column, page_addr);
      /*
       * Reset command state information
       */
      g_nandfc_info.bStatusRequest = false;

      /*
       * Command pre-processing step
       */
      switch (command) {
      case NAND_CMD_STATUS:
            g_nandfc_info.colAddr = 0;
            g_nandfc_info.bStatusRequest = true;
            break;

      case NAND_CMD_READ0:
            g_nandfc_info.colAddr = column;
            break;

      case NAND_CMD_READOOB:
            g_nandfc_info.colAddr = column;
            command = NAND_CMD_READ0;
            break;

      case NAND_CMD_SEQIN:
            if (column != 0) {

                  /* FIXME: before send SEQIN command for
                   * partial write,We need read one page out.
                   * FSL NFC does not support partial write
                   * It alway send out 512+ecc+512+ecc ...
                   * for large page nand flash. But for small
                   * page nand flash, it did support SPARE
                   * ONLY operation. But to make driver
                   * simple. We take the same as large page,read
                   * whole page out and update. As for MLC nand
                   * NOP(num of operation) = 1. Partial written
                   * on one programed page is not allowed! We
                   * can't limit it on the driver, it need the
                   * upper layer applicaiton take care it
                   */

                  mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr);
            }

            g_nandfc_info.colAddr = column;
            column = 0;

            break;

      case NAND_CMD_PAGEPROG:
#ifndef NFC_AUTO_MODE_ENABLE
            /* FIXME:the NFC interal buffer
             * access has some limitation, it
             * does not allow byte access. To
             * make the code simple and ease use
             * not every time check the address
             * alignment.Use the temp buffer
             * to accomadate the data.since We
             * know data_buf will be at leat 4
             * byte alignment, so we can use
             * memcpy safely
             */
            nfc_memcpy(MAIN_AREA0, data_buf, mtd->writesize);
            copy_spare(mtd, oob_buf, SPARE_AREA0, mtd->oobsize, false);
#endif

            if (IS_LARGE_PAGE_NAND)
                  PROG_PAGE();
            else
                  send_prog_page(0);

            break;

      case NAND_CMD_ERASE1:
            break;
      case NAND_CMD_ERASE2:
            break;
      }

      /*
       * Write out the command to the device.
       */
      send_cmd(mtd, command, useirq);

      mxc_do_addr_cycle(mtd, column, page_addr);

      /*
       * Command post-processing step
       */
      switch (command) {

      case NAND_CMD_READOOB:
      case NAND_CMD_READ0:
            if (IS_LARGE_PAGE_NAND) {
                  /* send read confirm command */
                  send_cmd(mtd, NAND_CMD_READSTART, true);
                  /* read for each AREA */
                  READ_PAGE();
            } else {
                  send_read_page(0);
            }

#ifndef NFC_AUTO_MODE_ENABLE
            /* FIXME, the NFC interal buffer
             * access has some limitation, it
             * does not allow byte access. To
             * make the code simple and ease use
             * not every time check the address
             * alignment.Use the temp buffer
             * to accomadate the data.since We
             * know data_buf will be at leat 4
             * byte alignment, so we can use
             * memcpy safely
             */
            nfc_memcpy(data_buf, MAIN_AREA0, mtd->writesize);
            copy_spare(mtd, oob_buf, SPARE_AREA0, mtd->oobsize, true);
#endif

            break;

      case NAND_CMD_READID:
            send_read_id();
            g_nandfc_info.colAddr = column;
            nfc_memcpy(data_buf, MAIN_AREA0, 2048);

            break;
      }
}


Generated by  Doxygen 1.6.0   Back to index