dm355evm.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (C) 2009 David Brownell
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <nand.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/hardware.h>
  10. #include <asm/ti-common/davinci_nand.h>
  11. #include <asm/arch/davinci_misc.h>
  12. #include <net.h>
  13. #include <netdev.h>
  14. #ifdef CONFIG_DAVINCI_MMC
  15. #include <mmc.h>
  16. #include <asm/arch/sdmmc_defs.h>
  17. #endif
  18. DECLARE_GLOBAL_DATA_PTR;
  19. /*
  20. * With the DM355 EVM, u-boot is *always* a third stage loader,
  21. * unless a JTAG debugger handles the first two stages:
  22. *
  23. * - 1st stage is ROM Boot Loader (RBL), which searches for a
  24. * second stage loader in one of three places based on SW7:
  25. * NAND (with MMC/SD fallback), MMC/SD, or UART.
  26. *
  27. * - 2nd stage is User Boot Loader (UBL), using at most 30KB
  28. * of on-chip SRAM, responsible for lowlevel init, and for
  29. * loading the third stage loader into DRAM.
  30. *
  31. * - 3rd stage, that's us!
  32. */
  33. int board_init(void)
  34. {
  35. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM355_EVM;
  36. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  37. /* We expect the UBL to have handled "lowlevel init", which
  38. * involves setting up at least:
  39. * - clocks
  40. * + PLL1 (for ARM and peripherals) and PLL2 (for DDR)
  41. * + clock divisors for those PLLs
  42. * + LPSC_DDR module enabled
  43. * + LPSC_TIMER0 module (still) enabled
  44. * - EMIF
  45. * + DDR init and timings
  46. * + AEMIF timings (for NAND and DM9000)
  47. * - pinmux
  48. *
  49. * Some of that is repeated here, mostly as a precaution.
  50. */
  51. /* AEMIF: Some "address" lines are available as GPIOs. A3..A13
  52. * could be too if we used A12 as a GPIO during NAND chipselect
  53. * (and Linux did too), letting us control the LED on A7/GPIO61.
  54. */
  55. REG(PINMUX2) = 0x0c08;
  56. /* UART0 may still be in SyncReset if we didn't boot from UART */
  57. davinci_enable_uart0();
  58. /* EDMA may be in SyncReset too; turn it on, Linux won't (yet) */
  59. lpsc_on(DAVINCI_LPSC_TPCC);
  60. lpsc_on(DAVINCI_LPSC_TPTC0);
  61. lpsc_on(DAVINCI_LPSC_TPTC1);
  62. return 0;
  63. }
  64. #ifdef CONFIG_DRIVER_DM9000
  65. int board_eth_init(bd_t *bis)
  66. {
  67. return dm9000_initialize(bis);
  68. }
  69. #endif
  70. #ifdef CONFIG_NAND_DAVINCI
  71. static void nand_dm355evm_select_chip(struct mtd_info *mtd, int chip)
  72. {
  73. struct nand_chip *this = mtd->priv;
  74. unsigned long wbase = (unsigned long) this->IO_ADDR_W;
  75. unsigned long rbase = (unsigned long) this->IO_ADDR_R;
  76. if (chip == 1) {
  77. __set_bit(14, &wbase);
  78. __set_bit(14, &rbase);
  79. } else {
  80. __clear_bit(14, &wbase);
  81. __clear_bit(14, &rbase);
  82. }
  83. this->IO_ADDR_W = (void *)wbase;
  84. this->IO_ADDR_R = (void *)rbase;
  85. }
  86. int board_nand_init(struct nand_chip *nand)
  87. {
  88. davinci_nand_init(nand);
  89. nand->select_chip = nand_dm355evm_select_chip;
  90. return 0;
  91. }
  92. #endif
  93. #ifdef CONFIG_DAVINCI_MMC
  94. static struct davinci_mmc mmc_sd0 = {
  95. .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
  96. .input_clk = 108000000,
  97. .host_caps = MMC_MODE_4BIT,
  98. .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
  99. .version = MMC_CTLR_VERSION_1,
  100. };
  101. #ifdef CONFIG_DAVINCI_MMC_SD1
  102. static struct davinci_mmc mmc_sd1 = {
  103. .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD1_BASE,
  104. .input_clk = 108000000,
  105. .host_caps = MMC_MODE_4BIT,
  106. .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
  107. .version = MMC_CTLR_VERSION_1,
  108. };
  109. #endif
  110. int board_mmc_init(bd_t *bis)
  111. {
  112. int err;
  113. /* Add slot-0 to mmc subsystem */
  114. err = davinci_mmc_init(bis, &mmc_sd0);
  115. if (err)
  116. return err;
  117. #ifdef CONFIG_DAVINCI_MMC_SD1
  118. /* Add slot-1 to mmc subsystem */
  119. err = davinci_mmc_init(bis, &mmc_sd1);
  120. #endif
  121. return err;
  122. }
  123. #endif