esd405ep_nand.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * (C) Copyright 2007
  3. * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
  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 <asm/io.h>
  26. #include <nand.h>
  27. /*
  28. * hardware specific access to control-lines
  29. */
  30. static void esd405ep_nand_hwcontrol(struct mtd_info *mtdinfo, int cmd)
  31. {
  32. switch(cmd) {
  33. case NAND_CTL_SETCLE:
  34. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_CLE);
  35. break;
  36. case NAND_CTL_CLRCLE:
  37. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CFG_NAND_CLE);
  38. break;
  39. case NAND_CTL_SETALE:
  40. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_ALE);
  41. break;
  42. case NAND_CTL_CLRALE:
  43. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CFG_NAND_ALE);
  44. break;
  45. case NAND_CTL_SETNCE:
  46. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CFG_NAND_CE);
  47. break;
  48. case NAND_CTL_CLRNCE:
  49. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_CE);
  50. break;
  51. }
  52. }
  53. /*
  54. * read device ready pin
  55. */
  56. static int esd405ep_nand_device_ready(struct mtd_info *mtdinfo)
  57. {
  58. if (in_be32((void *)GPIO0_IR) & CFG_NAND_RDY)
  59. return 1;
  60. return 0;
  61. }
  62. int board_nand_init(struct nand_chip *nand)
  63. {
  64. /*
  65. * Set NAND-FLASH GPIO signals to defaults
  66. */
  67. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
  68. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_CE);
  69. /*
  70. * Initialize nand_chip structure
  71. */
  72. nand->hwcontrol = esd405ep_nand_hwcontrol;
  73. nand->dev_ready = esd405ep_nand_device_ready;
  74. nand->eccmode = NAND_ECC_SOFT;
  75. nand->chip_delay = NAND_BIG_DELAY_US;
  76. nand->options = NAND_SAMSUNG_LP_OPTIONS;
  77. return 0;
  78. }
  79. #endif