nand.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * (C) Copyright 2006 Detlev Zundel, dzu@denx.de
  3. * (C) Copyright 2006 DENX Software Engineering
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <asm/io.h>
  25. #if defined(CONFIG_CMD_NAND)
  26. #include <nand.h>
  27. #if defined(CONFIG_IDS852_REV1)
  28. /*
  29. * hardware specific access to control-lines
  30. */
  31. static void nc650_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  32. {
  33. struct nand_chip *this = mtd->priv;
  34. if (ctrl & NAND_CTRL_CHANGE) {
  35. if ( ctrl & NAND_CLE )
  36. this->IO_ADDR_W += 2;
  37. else
  38. this->IO_ADDR_W -= 2;
  39. if ( ctrl & NAND_ALE )
  40. this->IO_ADDR_W += 1;
  41. else
  42. this->IO_ADDR_W -= 1;
  43. }
  44. if (cmd != NAND_CMD_NONE)
  45. writeb(cmd, this->IO_ADDR_W);
  46. }
  47. #elif defined(CONFIG_IDS852_REV2)
  48. /*
  49. * hardware specific access to control-lines
  50. */
  51. static void nc650_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  52. {
  53. struct nand_chip *this = mtd->priv;
  54. if (ctrl & NAND_CTRL_CHANGE) {
  55. if ( ctrl & NAND_CLE )
  56. writeb(0, (volatile __u8 *) this->IO_ADDR_W + 0xa);
  57. else
  58. writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x8);
  59. if ( ctrl & NAND_ALE )
  60. writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x9);
  61. else
  62. writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x8);
  63. if ( ctrl & NAND_NCE )
  64. writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0x8);
  65. else
  66. writeb(0, (volatile __u8 *) this->IO_ADDR_W) + 0xc);
  67. }
  68. if (cmd != NAND_CMD_NONE)
  69. writeb(cmd, this->IO_ADDR_W);
  70. }
  71. #else
  72. #error Unknown IDS852 module revision
  73. #endif
  74. /*
  75. * Board-specific NAND initialization. The following members of the
  76. * argument are board-specific (per include/linux/mtd/nand.h):
  77. * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
  78. * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
  79. * - cmd_ctrl: hardwarespecific function for accesing control-lines
  80. * - dev_ready: hardwarespecific function for accesing device ready/busy line
  81. * - enable_hwecc?: function to enable (reset) hardware ecc generator. Must
  82. * only be provided if a hardware ECC is available
  83. * - eccm.ode: mode of ecc, see defines
  84. * - chip_delay: chip dependent delay for transfering data from array to
  85. * read regs (tR)
  86. * - options: various chip options. They can partly be set to inform
  87. * nand_scan about special functionality. See the defines for further
  88. * explanation
  89. * Members with a "?" were not set in the merged testing-NAND branch,
  90. * so they are not set here either.
  91. */
  92. int board_nand_init(struct nand_chip *nand)
  93. {
  94. nand->cmd_ctrl = nc650_hwcontrol;
  95. nand->ecc.mode = NAND_ECC_SOFT;
  96. nand->chip_delay = 12;
  97. /* nand->options = NAND_SAMSUNG_LP_OPTIONS;*/
  98. return 0;
  99. }
  100. #endif