onenand_uboot.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * drivers/mtd/onenand/onenand_uboot.c
  3. *
  4. * Copyright (C) 2005-2008 Samsung Electronics
  5. * Kyungmin Park <kyungmin.park@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. /*
  12. * OneNAND initialization at U-Boot
  13. */
  14. #include <common.h>
  15. #include <linux/mtd/compat.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/onenand.h>
  18. struct mtd_info onenand_mtd;
  19. struct onenand_chip onenand_chip;
  20. static __attribute__((unused)) char dev_name[] = "onenand0";
  21. void onenand_init(void)
  22. {
  23. memset(&onenand_mtd, 0, sizeof(struct mtd_info));
  24. memset(&onenand_chip, 0, sizeof(struct onenand_chip));
  25. onenand_mtd.priv = &onenand_chip;
  26. #ifdef CONFIG_USE_ONENAND_BOARD_INIT
  27. /*
  28. * It's used for some board init required
  29. */
  30. onenand_board_init(&onenand_mtd);
  31. #else
  32. onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE;
  33. #endif
  34. onenand_scan(&onenand_mtd, 1);
  35. puts("OneNAND: ");
  36. print_size(onenand_mtd.size, "\n");
  37. #ifdef CONFIG_MTD_PARTITIONS
  38. /*
  39. * Add MTD device so that we can reference it later
  40. * via the mtdcore infrastructure (e.g. ubi).
  41. */
  42. onenand_mtd.name = dev_name;
  43. add_mtd_device(&onenand_mtd);
  44. #endif
  45. }