nand.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * MPC8360E-RDK support for the NAND on FSL UPM
  3. *
  4. * Copyright (C) 2007 MontaVista Software, Inc.
  5. * Anton Vorontsov <avorontsov@ru.mvista.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. */
  12. #include <config.h>
  13. #include <common.h>
  14. #include <asm/io.h>
  15. #include <asm/immap_83xx.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/fsl_upm.h>
  18. #include <nand.h>
  19. static struct immap *im = (struct immap *)CFG_IMMR;
  20. static const u32 upm_array[] = {
  21. 0x0ff03c30, 0x0ff03c30, 0x0ff03c34, 0x0ff33c30, /* Words 0 to 3 */
  22. 0xfff33c31, 0xfffffc30, 0xfffffc30, 0xfffffc30, /* Words 4 to 7 */
  23. 0x0faf3c30, 0x0faf3c30, 0x0faf3c30, 0x0fff3c34, /* Words 8 to 11 */
  24. 0xffff3c31, 0xfffffc30, 0xfffffc30, 0xfffffc30, /* Words 12 to 15 */
  25. 0x0fa3fc30, 0x0fa3fc30, 0x0fa3fc30, 0x0ff3fc34, /* Words 16 to 19 */
  26. 0xfff3fc31, 0xfffffc30, 0xfffffc30, 0xfffffc30, /* Words 20 to 23 */
  27. 0x0ff33c30, 0x0fa33c30, 0x0fa33c34, 0x0ff33c30, /* Words 24 to 27 */
  28. 0xfff33c31, 0xfff0fc30, 0xfff0fc30, 0xfff0fc30, /* Words 28 to 31 */
  29. 0xfff3fc30, 0xfff3fc30, 0xfff6fc30, 0xfffcfc30, /* Words 32 to 35 */
  30. 0xfffcfc30, 0xfffcfc30, 0xfffcfc30, 0xfffcfc30, /* Words 36 to 39 */
  31. 0xfffcfc30, 0xfffcfc30, 0xfffcfc30, 0xfffcfc30, /* Words 40 to 43 */
  32. 0xfffdfc30, 0xfffffc30, 0xfffffc30, 0xfffffc31, /* Words 44 to 47 */
  33. 0xfffffc30, 0xfffffc00, 0xfffffc00, 0xfffffc00, /* Words 48 to 51 */
  34. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, /* Words 52 to 55 */
  35. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, /* Words 56 to 59 */
  36. 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, /* Words 60 to 63 */
  37. };
  38. static int dev_ready(void)
  39. {
  40. if (in_be32(&im->qepio.ioport[4].pdat) & 0x00002000) {
  41. debug("nand ready\n");
  42. return 1;
  43. }
  44. debug("nand busy\n");
  45. return 0;
  46. }
  47. static struct fsl_upm_nand fun = {
  48. .upm = {
  49. .array = upm_array,
  50. .io_addr = (void *)CFG_NAND_BASE,
  51. },
  52. .width = 1,
  53. .upm_cmd_offset = 8,
  54. .upm_addr_offset = 16,
  55. .dev_ready = dev_ready,
  56. .wait_pattern = 1,
  57. .chip_delay = 50,
  58. };
  59. int board_nand_init(struct nand_chip *nand)
  60. {
  61. fun.upm.mxmr = &im->lbus.mamr;
  62. fun.upm.mdr = &im->lbus.mdr;
  63. fun.upm.mar = &im->lbus.mar;
  64. return fsl_upm_nand_init(nand, &fun);
  65. }