esd405ep_nand.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 *mtd, int cmd, unsigned int ctrl)
  31. {
  32. struct nand_chip *this = mtd->priv;
  33. if (ctrl & NAND_CTRL_CHANGE) {
  34. if ( ctrl & NAND_CLE )
  35. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_CLE);
  36. else
  37. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CFG_NAND_CLE);
  38. if ( ctrl & NAND_ALE )
  39. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_ALE);
  40. else
  41. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CFG_NAND_ALE);
  42. if ( ctrl & NAND_NCE )
  43. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CFG_NAND_CE);
  44. else
  45. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_CE);
  46. }
  47. if (cmd != NAND_CMD_NONE)
  48. writeb(cmd, this->IO_ADDR_W);
  49. }
  50. /*
  51. * read device ready pin
  52. */
  53. static int esd405ep_nand_device_ready(struct mtd_info *mtdinfo)
  54. {
  55. if (in_be32((void *)GPIO0_IR) & CFG_NAND_RDY)
  56. return 1;
  57. return 0;
  58. }
  59. int board_nand_init(struct nand_chip *nand)
  60. {
  61. /*
  62. * Set NAND-FLASH GPIO signals to defaults
  63. */
  64. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
  65. out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CFG_NAND_CE);
  66. /*
  67. * Initialize nand_chip structure
  68. */
  69. nand->cmd_ctrl = esd405ep_nand_hwcontrol;
  70. nand->dev_ready = esd405ep_nand_device_ready;
  71. nand->ecc.mode = NAND_ECC_SOFT;
  72. nand->chip_delay = NAND_BIG_DELAY_US;
  73. nand->options = NAND_SAMSUNG_LP_OPTIONS;
  74. return 0;
  75. }
  76. #endif