actl_nand.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2008 Extreme Engineering Solutions, Inc.
  3. *
  4. * This driver support NAND devices which have address lines
  5. * connected as ALE and CLE inputs.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <nand.h>
  27. #include <asm/io.h>
  28. /*
  29. * Hardware specific access to control-lines
  30. */
  31. static void nand_addr_hwcontrol(struct mtd_info *mtd, int cmd, uint ctrl)
  32. {
  33. struct nand_chip *this = mtd->priv;
  34. ulong IO_ADDR_W;
  35. if (ctrl & NAND_CTRL_CHANGE) {
  36. IO_ADDR_W = (ulong)this->IO_ADDR_W;
  37. IO_ADDR_W &= ~(CONFIG_SYS_NAND_ACTL_CLE |
  38. CONFIG_SYS_NAND_ACTL_ALE |
  39. CONFIG_SYS_NAND_ACTL_NCE);
  40. if (ctrl & NAND_CLE)
  41. IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_CLE;
  42. if (ctrl & NAND_ALE)
  43. IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_ALE;
  44. if (ctrl & NAND_NCE)
  45. IO_ADDR_W |= CONFIG_SYS_NAND_ACTL_NCE;
  46. this->IO_ADDR_W = (void *)IO_ADDR_W;
  47. }
  48. if (cmd != NAND_CMD_NONE)
  49. writeb(cmd, this->IO_ADDR_W);
  50. }
  51. int board_nand_init(struct nand_chip *nand)
  52. {
  53. nand->ecc.mode = NAND_ECC_SOFT;
  54. nand->cmd_ctrl = nand_addr_hwcontrol;
  55. nand->chip_delay = CONFIG_SYS_NAND_ACTL_DELAY;
  56. return 0;
  57. }