nand_plat.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Genericish driver for memory mapped NAND devices
  3. *
  4. * Copyright (c) 2006-2009 Analog Devices Inc.
  5. * Licensed under the GPL-2 or later.
  6. */
  7. /* Your board must implement the following macros:
  8. * NAND_PLAT_WRITE_CMD(chip, cmd)
  9. * NAND_PLAT_WRITE_ADR(chip, cmd)
  10. * NAND_PLAT_INIT()
  11. *
  12. * It may also implement the following:
  13. * NAND_PLAT_DEV_READY(chip)
  14. */
  15. #include <common.h>
  16. #include <asm/io.h>
  17. #include <nand.h>
  18. static void plat_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  19. {
  20. struct nand_chip *this = mtd->priv;
  21. if (cmd == NAND_CMD_NONE)
  22. return;
  23. if (ctrl & NAND_CLE)
  24. NAND_PLAT_WRITE_CMD(this, cmd);
  25. else
  26. NAND_PLAT_WRITE_ADR(this, cmd);
  27. }
  28. #ifdef NAND_PLAT_DEV_READY
  29. static int plat_dev_ready(struct mtd_info *mtd)
  30. {
  31. return NAND_PLAT_DEV_READY((struct nand_chip *)mtd->priv);
  32. }
  33. #else
  34. # define plat_dev_ready NULL
  35. #endif
  36. int board_nand_init(struct nand_chip *nand)
  37. {
  38. NAND_PLAT_INIT();
  39. nand->cmd_ctrl = plat_cmd_ctrl;
  40. nand->dev_ready = plat_dev_ready;
  41. nand->ecc.mode = NAND_ECC_SOFT;
  42. return 0;
  43. }