nand.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #if defined(CONFIG_CMD_NAND)
  25. #include <nand.h>
  26. #if defined(CONFIG_IDS852_REV1)
  27. /*
  28. * hardware specific access to control-lines
  29. */
  30. static void nc650_hwcontrol(struct mtd_info *mtd, int cmd)
  31. {
  32. struct nand_chip *this = mtd->priv;
  33. switch(cmd) {
  34. case NAND_CTL_SETCLE:
  35. this->IO_ADDR_W += 2;
  36. break;
  37. case NAND_CTL_CLRCLE:
  38. this->IO_ADDR_W -= 2;
  39. break;
  40. case NAND_CTL_SETALE:
  41. this->IO_ADDR_W += 1;
  42. break;
  43. case NAND_CTL_CLRALE:
  44. this->IO_ADDR_W -= 1;
  45. break;
  46. case NAND_CTL_SETNCE:
  47. case NAND_CTL_CLRNCE:
  48. /* nop */
  49. break;
  50. }
  51. }
  52. #elif defined(CONFIG_IDS852_REV2)
  53. /*
  54. * hardware specific access to control-lines
  55. */
  56. static void nc650_hwcontrol(struct mtd_info *mtd, int cmd)
  57. {
  58. struct nand_chip *this = mtd->priv;
  59. switch(cmd) {
  60. case NAND_CTL_SETCLE:
  61. *(((volatile __u8 *) this->IO_ADDR_W) + 0xa) = 0;
  62. break;
  63. case NAND_CTL_CLRCLE:
  64. *(((volatile __u8 *) this->IO_ADDR_W) + 0x8) = 0;
  65. break;
  66. case NAND_CTL_SETALE:
  67. *(((volatile __u8 *) this->IO_ADDR_W) + 0x9) = 0;
  68. break;
  69. case NAND_CTL_CLRALE:
  70. *(((volatile __u8 *) this->IO_ADDR_W) + 0x8) = 0;
  71. break;
  72. case NAND_CTL_SETNCE:
  73. *(((volatile __u8 *) this->IO_ADDR_W) + 0x8) = 0;
  74. break;
  75. case NAND_CTL_CLRNCE:
  76. *(((volatile __u8 *) this->IO_ADDR_W) + 0xc) = 0;
  77. break;
  78. }
  79. }
  80. #else
  81. #error Unknown IDS852 module revision
  82. #endif
  83. /*
  84. * Board-specific NAND initialization. The following members of the
  85. * argument are board-specific (per include/linux/mtd/nand.h):
  86. * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
  87. * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
  88. * - hwcontrol: hardwarespecific function for accesing control-lines
  89. * - dev_ready: hardwarespecific function for accesing device ready/busy line
  90. * - enable_hwecc?: function to enable (reset) hardware ecc generator. Must
  91. * only be provided if a hardware ECC is available
  92. * - eccmode: mode of ecc, see defines
  93. * - chip_delay: chip dependent delay for transfering data from array to
  94. * read regs (tR)
  95. * - options: various chip options. They can partly be set to inform
  96. * nand_scan about special functionality. See the defines for further
  97. * explanation
  98. * Members with a "?" were not set in the merged testing-NAND branch,
  99. * so they are not set here either.
  100. */
  101. int board_nand_init(struct nand_chip *nand)
  102. {
  103. nand->hwcontrol = nc650_hwcontrol;
  104. nand->eccmode = NAND_ECC_SOFT;
  105. nand->chip_delay = 12;
  106. /* nand->options = NAND_SAMSUNG_LP_OPTIONS;*/
  107. return 0;
  108. }
  109. #endif