da830evm.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
  3. *
  4. * Base on code from TI. Original Notices follow:
  5. *
  6. * (C) Copyright 2008, Texas Instruments, Inc. http://www.ti.com/
  7. *
  8. * Modified for DA8xx EVM.
  9. *
  10. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  11. *
  12. * Parts are shamelessly stolen from various TI sources, original copyright
  13. * follows:
  14. * -----------------------------------------------------------------
  15. *
  16. * Copyright (C) 2004 Texas Instruments.
  17. *
  18. * ----------------------------------------------------------------------------
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation; either version 2 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32. * ----------------------------------------------------------------------------
  33. */
  34. #include <common.h>
  35. #include <i2c.h>
  36. #include <asm/arch/hardware.h>
  37. #include <asm/arch/emif_defs.h>
  38. #include <asm/io.h>
  39. #include "../common/misc.h"
  40. DECLARE_GLOBAL_DATA_PTR;
  41. #define pinmux &davinci_syscfg_regs->pinmux
  42. /* SPI0 pin muxer settings */
  43. static const struct pinmux_config spi0_pins[] = {
  44. { pinmux[7], 1, 3 },
  45. { pinmux[7], 1, 4 },
  46. { pinmux[7], 1, 5 },
  47. { pinmux[7], 1, 6 },
  48. { pinmux[7], 1, 7 }
  49. };
  50. /* EMIF-A bus pins for 8-bit NAND support on CS3 */
  51. static const struct pinmux_config emifa_nand_pins[] = {
  52. { pinmux[13], 1, 6 },
  53. { pinmux[13], 1, 7 },
  54. { pinmux[14], 1, 0 },
  55. { pinmux[14], 1, 1 },
  56. { pinmux[14], 1, 2 },
  57. { pinmux[14], 1, 3 },
  58. { pinmux[14], 1, 4 },
  59. { pinmux[14], 1, 5 },
  60. { pinmux[15], 1, 7 },
  61. { pinmux[16], 1, 0 },
  62. { pinmux[18], 1, 1 },
  63. { pinmux[18], 1, 4 },
  64. { pinmux[18], 1, 5 },
  65. };
  66. /* UART pin muxer settings */
  67. static const struct pinmux_config uart_pins[] = {
  68. { pinmux[8], 2, 7 },
  69. { pinmux[9], 2, 0 }
  70. };
  71. /* I2C pin muxer settings */
  72. static const struct pinmux_config i2c_pins[] = {
  73. { pinmux[9], 2, 3 },
  74. { pinmux[9], 2, 4 }
  75. };
  76. /* USB0_DRVVBUS pin muxer settings */
  77. static const struct pinmux_config usb_pins[] = {
  78. { pinmux[9], 1, 1 }
  79. };
  80. static const struct pinmux_resource pinmuxes[] = {
  81. #ifdef CONFIG_SPI_FLASH
  82. PINMUX_ITEM(spi0_pins),
  83. #endif
  84. PINMUX_ITEM(uart_pins),
  85. PINMUX_ITEM(i2c_pins),
  86. #ifdef CONFIG_USB_DA8XX
  87. PINMUX_ITEM(usb_pins),
  88. #endif
  89. #ifdef CONFIG_USE_NAND
  90. PINMUX_ITEM(emifa_nand_pins),
  91. #endif
  92. };
  93. int board_init(void)
  94. {
  95. #ifndef CONFIG_USE_IRQ
  96. /*
  97. * Mask all IRQs by clearing the global enable and setting
  98. * the enable clear for all the 90 interrupts.
  99. */
  100. writel(0, &davinci_aintc_regs->ger);
  101. writel(0, &davinci_aintc_regs->hier);
  102. writel(0xffffffff, &davinci_aintc_regs->ecr1);
  103. writel(0xffffffff, &davinci_aintc_regs->ecr2);
  104. writel(0xffffffff, &davinci_aintc_regs->ecr3);
  105. #endif
  106. #ifdef CONFIG_NAND_DAVINCI
  107. /* EMIFA 100MHz clock select */
  108. writel(readl(&davinci_syscfg_regs->cfgchip3) & ~2,
  109. &davinci_syscfg_regs->cfgchip3);
  110. /* NAND CS setup */
  111. writel((DAVINCI_ABCR_WSETUP(0) |
  112. DAVINCI_ABCR_WSTROBE(2) |
  113. DAVINCI_ABCR_WHOLD(0) |
  114. DAVINCI_ABCR_RSETUP(0) |
  115. DAVINCI_ABCR_RSTROBE(2) |
  116. DAVINCI_ABCR_RHOLD(0) |
  117. DAVINCI_ABCR_TA(2) |
  118. DAVINCI_ABCR_ASIZE_8BIT),
  119. &davinci_emif_regs->AB2CR);
  120. #endif
  121. /* arch number of the board */
  122. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA830_EVM;
  123. /* address of boot parameters */
  124. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  125. /*
  126. * Power on required peripherals
  127. * ARM does not have access by default to PSC0 and PSC1
  128. * assuming here that the DSP bootloader has set the IOPU
  129. * such that PSC access is available to ARM
  130. */
  131. lpsc_on(DAVINCI_LPSC_AEMIF); /* NAND, NOR */
  132. lpsc_on(DAVINCI_LPSC_SPI0); /* Serial Flash */
  133. lpsc_on(DAVINCI_LPSC_EMAC); /* image download */
  134. lpsc_on(DAVINCI_LPSC_UART2); /* console */
  135. lpsc_on(DAVINCI_LPSC_GPIO);
  136. /* setup the SUSPSRC for ARM to control emulation suspend */
  137. writel(readl(&davinci_syscfg_regs->suspsrc) &
  138. ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
  139. DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
  140. DAVINCI_SYSCFG_SUSPSRC_UART2),
  141. &davinci_syscfg_regs->suspsrc);
  142. /* configure pinmux settings */
  143. if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
  144. return 1;
  145. /* enable the console UART */
  146. writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
  147. DAVINCI_UART_PWREMU_MGMT_UTRST),
  148. &davinci_uart2_ctrl_regs->pwremu_mgmt);
  149. return(0);
  150. }