hawkboard_nand_spl.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Modified for Hawkboard - Syed Mohammed Khasim <khasim@beagleboard.org>
  3. *
  4. * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc. <nsekhar@ti.com>
  5. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  6. * Copyright (C) 2004 Texas Instruments.
  7. *
  8. * ----------------------------------------------------------------------------
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. * ----------------------------------------------------------------------------
  23. */
  24. #include <common.h>
  25. #include <asm/errno.h>
  26. #include <asm/arch/hardware.h>
  27. #include <asm/io.h>
  28. #include <asm/arch/davinci_misc.h>
  29. #include <ns16550.h>
  30. #include <nand.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. #define pinmux(x) (&davinci_syscfg_regs->pinmux[x])
  33. static const struct pinmux_config mii_pins[] = {
  34. { pinmux(2), 8, 1 },
  35. { pinmux(2), 8, 2 },
  36. { pinmux(2), 8, 3 },
  37. { pinmux(2), 8, 4 },
  38. { pinmux(2), 8, 5 },
  39. { pinmux(2), 8, 6 },
  40. { pinmux(2), 8, 7 }
  41. };
  42. static const struct pinmux_config mdio_pins[] = {
  43. { pinmux(4), 8, 0 },
  44. { pinmux(4), 8, 1 }
  45. };
  46. static const struct pinmux_config nand_pins[] = {
  47. { pinmux(7), 1, 1 },
  48. { pinmux(7), 1, 2 },
  49. { pinmux(7), 1, 4 },
  50. { pinmux(7), 1, 5 },
  51. { pinmux(9), 1, 0 },
  52. { pinmux(9), 1, 1 },
  53. { pinmux(9), 1, 2 },
  54. { pinmux(9), 1, 3 },
  55. { pinmux(9), 1, 4 },
  56. { pinmux(9), 1, 5 },
  57. { pinmux(9), 1, 6 },
  58. { pinmux(9), 1, 7 },
  59. { pinmux(12), 1, 5 },
  60. { pinmux(12), 1, 6 }
  61. };
  62. static const struct pinmux_config uart2_pins[] = {
  63. { pinmux(0), 4, 6 },
  64. { pinmux(0), 4, 7 },
  65. { pinmux(4), 2, 4 },
  66. { pinmux(4), 2, 5 }
  67. };
  68. static const struct pinmux_config i2c_pins[] = {
  69. { pinmux(4), 2, 4 },
  70. { pinmux(4), 2, 5 }
  71. };
  72. static const struct pinmux_resource pinmuxes[] = {
  73. PINMUX_ITEM(mii_pins),
  74. PINMUX_ITEM(mdio_pins),
  75. PINMUX_ITEM(i2c_pins),
  76. PINMUX_ITEM(nand_pins),
  77. PINMUX_ITEM(uart2_pins),
  78. };
  79. static const struct lpsc_resource lpsc[] = {
  80. { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
  81. { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
  82. { DAVINCI_LPSC_EMAC }, /* image download */
  83. { DAVINCI_LPSC_UART2 }, /* console */
  84. { DAVINCI_LPSC_GPIO },
  85. };
  86. void board_init_f(ulong bootflag)
  87. {
  88. /*
  89. * Kick Registers need to be set to allow access to Pin Mux registers
  90. */
  91. writel(HAWKBOARD_KICK0_UNLOCK, &davinci_syscfg_regs->kick0);
  92. writel(HAWKBOARD_KICK1_UNLOCK, &davinci_syscfg_regs->kick1);
  93. /* setup the SUSPSRC for ARM to control emulation suspend */
  94. writel(readl(&davinci_syscfg_regs->suspsrc) &
  95. ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
  96. DAVINCI_SYSCFG_SUSPSRC_SPI1 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
  97. DAVINCI_SYSCFG_SUSPSRC_UART2), &davinci_syscfg_regs->suspsrc);
  98. /* Power on required peripherals
  99. * ARM does not have acess by default to PSC0 and PSC1
  100. * assuming here that the DSP bootloader has set the IOPU
  101. * such that PSC access is available to ARM
  102. */
  103. da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc));
  104. /* configure pinmux settings */
  105. davinci_configure_pin_mux_items(pinmuxes,
  106. ARRAY_SIZE(pinmuxes));
  107. writel(readl(&davinci_uart2_ctrl_regs->pwremu_mgmt) |
  108. (DAVINCI_UART_PWREMU_MGMT_FREE) |
  109. (DAVINCI_UART_PWREMU_MGMT_URRST) |
  110. (DAVINCI_UART_PWREMU_MGMT_UTRST),
  111. &davinci_uart2_ctrl_regs->pwremu_mgmt);
  112. NS16550_init((NS16550_t)(DAVINCI_UART2_BASE),
  113. CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
  114. puts("Nand boot...\n");
  115. nand_boot();
  116. }
  117. void puts(const char *str)
  118. {
  119. while (*str)
  120. putc(*str++);
  121. }
  122. void putc(char c)
  123. {
  124. if (gd->flags & GD_FLG_SILENT)
  125. return;
  126. if (c == '\n')
  127. NS16550_putc((NS16550_t)(DAVINCI_UART2_BASE), '\r');
  128. NS16550_putc((NS16550_t)(DAVINCI_UART2_BASE), c);
  129. }
  130. void hang(void)
  131. {
  132. puts("### ERROR ### Please RESET the board ###\n");
  133. for (;;)
  134. ;
  135. }