nand.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * (C) Copyright 2007-2008
  3. * Stelian Pop <stelian.pop <at> 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/hardware.h>
  28. #ifdef CONFIG_CMD_NAND
  29. #include <nand.h>
  30. /*
  31. * hardware specific access to control-lines
  32. */
  33. #define MASK_ALE (1 << 21) /* our ALE is AD21 */
  34. #define MASK_CLE (1 << 22) /* our CLE is AD22 */
  35. static void at91cap9adk_nand_hwcontrol(struct mtd_info *mtd, int cmd)
  36. {
  37. struct nand_chip *this = mtd->priv;
  38. ulong IO_ADDR_W = (ulong) this->IO_ADDR_W;
  39. IO_ADDR_W &= ~(MASK_ALE|MASK_CLE);
  40. switch (cmd) {
  41. case NAND_CTL_SETCLE:
  42. IO_ADDR_W |= MASK_CLE;
  43. break;
  44. case NAND_CTL_SETALE:
  45. IO_ADDR_W |= MASK_ALE;
  46. break;
  47. case NAND_CTL_CLRNCE:
  48. AT91C_BASE_PIOD->PIO_SODR = AT91C_PIO_PD15;
  49. break;
  50. case NAND_CTL_SETNCE:
  51. AT91C_BASE_PIOD->PIO_CODR = AT91C_PIO_PD15;
  52. break;
  53. }
  54. this->IO_ADDR_W = (void *) IO_ADDR_W;
  55. }
  56. int board_nand_init(struct nand_chip *nand)
  57. {
  58. nand->eccmode = NAND_ECC_SOFT;
  59. nand->hwcontrol = at91cap9adk_nand_hwcontrol;
  60. nand->chip_delay = 20;
  61. return 0;
  62. }
  63. #endif