nand.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * (C) Copyright 2008
  3. * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de
  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 <config.h>
  25. #if defined(CONFIG_CMD_NAND)
  26. #include <asm/gpio.h>
  27. #include <nand.h>
  28. /*
  29. * hardware specific access to control-lines
  30. */
  31. static void quad100hd_hwcontrol(struct mtd_info *mtd, int cmd)
  32. {
  33. switch(cmd) {
  34. case NAND_CTL_SETCLE:
  35. gpio_write_bit(CFG_NAND_CLE, 1);
  36. break;
  37. case NAND_CTL_CLRCLE:
  38. gpio_write_bit(CFG_NAND_CLE, 0);
  39. break;
  40. case NAND_CTL_SETALE:
  41. gpio_write_bit(CFG_NAND_ALE, 1);
  42. break;
  43. case NAND_CTL_CLRALE:
  44. gpio_write_bit(CFG_NAND_ALE, 0);
  45. break;
  46. case NAND_CTL_SETNCE:
  47. gpio_write_bit(CFG_NAND_CE, 0);
  48. break;
  49. case NAND_CTL_CLRNCE:
  50. gpio_write_bit(CFG_NAND_CE, 1);
  51. break;
  52. }
  53. }
  54. static int quad100hd_nand_ready(struct mtd_info *mtd)
  55. {
  56. return gpio_read_in_bit(CFG_NAND_RDY);
  57. }
  58. /*
  59. * Main initialization routine
  60. */
  61. int board_nand_init(struct nand_chip *nand)
  62. {
  63. /* Set address of hardware control function */
  64. nand->hwcontrol = quad100hd_hwcontrol;
  65. nand->dev_ready = quad100hd_nand_ready;
  66. nand->eccmode = NAND_ECC_SOFT;
  67. /* 15 us command delay time */
  68. nand->chip_delay = 20;
  69. /* Return happy */
  70. return 0;
  71. }
  72. #endif /* CONFIG_CMD_NAND */