nand.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * (C) Copyright 2007-2008
  3. * Stelian Pop <stelian.pop@leadtechdesign.com>
  4. * Lead Tech Design <www.leadtechdesign.com>
  5. *
  6. * (C) Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <asm/arch/at91cap9.h>
  28. #include <asm/arch/gpio.h>
  29. #include <asm/arch/at91_pio.h>
  30. #include <nand.h>
  31. /*
  32. * hardware specific access to control-lines
  33. */
  34. #define MASK_ALE (1 << 21) /* our ALE is AD21 */
  35. #define MASK_CLE (1 << 22) /* our CLE is AD22 */
  36. static void at91cap9adk_nand_hwcontrol(struct mtd_info *mtd, int cmd)
  37. {
  38. struct nand_chip *this = mtd->priv;
  39. ulong IO_ADDR_W = (ulong) this->IO_ADDR_W;
  40. IO_ADDR_W &= ~(MASK_ALE|MASK_CLE);
  41. switch (cmd) {
  42. case NAND_CTL_SETCLE:
  43. IO_ADDR_W |= MASK_CLE;
  44. break;
  45. case NAND_CTL_SETALE:
  46. IO_ADDR_W |= MASK_ALE;
  47. break;
  48. case NAND_CTL_CLRNCE:
  49. at91_set_gpio_value(AT91_PIN_PD15, 1);
  50. break;
  51. case NAND_CTL_SETNCE:
  52. at91_set_gpio_value(AT91_PIN_PD15, 0);
  53. break;
  54. }
  55. this->IO_ADDR_W = (void *) IO_ADDR_W;
  56. }
  57. int board_nand_init(struct nand_chip *nand)
  58. {
  59. nand->eccmode = NAND_ECC_SOFT;
  60. nand->hwcontrol = at91cap9adk_nand_hwcontrol;
  61. nand->chip_delay = 20;
  62. return 0;
  63. }