dm355evm.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 2009 David Brownell
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <common.h>
  19. #include <nand.h>
  20. #include <asm/io.h>
  21. #include <asm/arch/hardware.h>
  22. #include <asm/arch/emif_defs.h>
  23. #include <asm/arch/nand_defs.h>
  24. #include "../common/misc.h"
  25. DECLARE_GLOBAL_DATA_PTR;
  26. /*
  27. * With the DM355 EVM, u-boot is *always* a third stage loader,
  28. * unless a JTAG debugger handles the first two stages:
  29. *
  30. * - 1st stage is ROM Boot Loader (RBL), which searches for a
  31. * second stage loader in one of three places based on SW7:
  32. * NAND (with MMC/SD fallback), MMC/SD, or UART.
  33. *
  34. * - 2nd stage is User Boot Loader (UBL), using at most 30KB
  35. * of on-chip SRAM, responsible for lowlevel init, and for
  36. * loading the third stage loader into DRAM.
  37. *
  38. * - 3rd stage, that's us!
  39. */
  40. int board_init(void)
  41. {
  42. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM355_EVM;
  43. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  44. /* We expect the UBL to have handled "lowlevel init", which
  45. * involves setting up at least:
  46. * - clocks
  47. * + PLL1 (for ARM and peripherals) and PLL2 (for DDR)
  48. * + clock divisors for those PLLs
  49. * + LPSC_DDR module enabled
  50. * + LPSC_TIMER0 module (still) enabled
  51. * - EMIF
  52. * + DDR init and timings
  53. * + AEMIF timings (for NAND and DM9000)
  54. * - pinmux
  55. *
  56. * Some of that is repeated here, mostly as a precaution.
  57. */
  58. /* AEMIF: Some "address" lines are available as GPIOs. A3..A13
  59. * could be too if we used A12 as a GPIO during NAND chipselect
  60. * (and Linux did too), letting us control the LED on A7/GPIO61.
  61. */
  62. REG(PINMUX2) = 0x0c08;
  63. /* UART0 may still be in SyncReset if we didn't boot from UART */
  64. davinci_enable_uart0();
  65. /* EDMA may be in SyncReset too; turn it on, Linux won't (yet) */
  66. lpsc_on(DAVINCI_LPSC_TPCC);
  67. lpsc_on(DAVINCI_LPSC_TPTC0);
  68. lpsc_on(DAVINCI_LPSC_TPTC1);
  69. return 0;
  70. }
  71. #ifdef CONFIG_NAND_DAVINCI
  72. static void nand_dm355evm_select_chip(struct mtd_info *mtd, int chip)
  73. {
  74. struct nand_chip *this = mtd->priv;
  75. u32 wbase = (u32) this->IO_ADDR_W;
  76. u32 rbase = (u32) this->IO_ADDR_R;
  77. if (chip == 1) {
  78. __set_bit(14, &wbase);
  79. __set_bit(14, &rbase);
  80. } else {
  81. __clear_bit(14, &wbase);
  82. __clear_bit(14, &rbase);
  83. }
  84. this->IO_ADDR_W = (void *)wbase;
  85. this->IO_ADDR_R = (void *)rbase;
  86. }
  87. int board_nand_init(struct nand_chip *nand)
  88. {
  89. davinci_nand_init(nand);
  90. nand->select_chip = nand_dm355evm_select_chip;
  91. return 0;
  92. }
  93. #endif