twister.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (C) 2011
  3. * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
  4. *
  5. * Copyright (C) 2009 TechNexion Ltd.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <netdev.h>
  27. #include <asm/io.h>
  28. #include <asm/arch/mem.h>
  29. #include <asm/arch/mux.h>
  30. #include <asm/arch/sys_proto.h>
  31. #include <asm/omap_gpio.h>
  32. #include <asm/arch/mmc_host_def.h>
  33. #include <i2c.h>
  34. #include <asm/gpio.h>
  35. #ifdef CONFIG_USB_EHCI
  36. #include <usb.h>
  37. #include <asm/ehci-omap.h>
  38. #endif
  39. #include "twister.h"
  40. DECLARE_GLOBAL_DATA_PTR;
  41. /* Timing definitions for Ethernet Controller */
  42. static const u32 gpmc_smc911[] = {
  43. NET_GPMC_CONFIG1,
  44. NET_GPMC_CONFIG2,
  45. NET_GPMC_CONFIG3,
  46. NET_GPMC_CONFIG4,
  47. NET_GPMC_CONFIG5,
  48. NET_GPMC_CONFIG6,
  49. };
  50. static const u32 gpmc_XR16L2751[] = {
  51. XR16L2751_GPMC_CONFIG1,
  52. XR16L2751_GPMC_CONFIG2,
  53. XR16L2751_GPMC_CONFIG3,
  54. XR16L2751_GPMC_CONFIG4,
  55. XR16L2751_GPMC_CONFIG5,
  56. XR16L2751_GPMC_CONFIG6,
  57. };
  58. #ifdef CONFIG_USB_EHCI
  59. static struct omap_usbhs_board_data usbhs_bdata = {
  60. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  61. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  62. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  63. };
  64. int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  65. {
  66. return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
  67. }
  68. int ehci_hcd_stop(int index)
  69. {
  70. return omap_ehci_hcd_stop();
  71. }
  72. #endif
  73. int board_init(void)
  74. {
  75. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  76. /* boot param addr */
  77. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  78. /* Chip select 1 and 3 are used for XR16L2751 UART controller */
  79. enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[1],
  80. XR16L2751_UART1_BASE, GPMC_SIZE_16M);
  81. enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[3],
  82. XR16L2751_UART2_BASE, GPMC_SIZE_16M);
  83. gpio_request(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, "USB_PHY1_RESET");
  84. gpio_direction_output(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, 1);
  85. return 0;
  86. }
  87. #ifndef CONFIG_SPL_BUILD
  88. int misc_init_r(void)
  89. {
  90. char *eth_addr;
  91. struct tam3517_module_info info;
  92. int ret;
  93. dieid_num_r();
  94. eth_addr = getenv("ethaddr");
  95. if (eth_addr)
  96. return 0;
  97. TAM3517_READ_EEPROM(&info, ret);
  98. if (!ret)
  99. TAM3517_READ_MAC_FROM_EEPROM(&info);
  100. return 0;
  101. }
  102. #endif
  103. /*
  104. * Routine: set_muxconf_regs
  105. * Description: Setting up the configuration Mux registers specific to the
  106. * hardware. Many pins need to be moved from protect to primary
  107. * mode.
  108. */
  109. void set_muxconf_regs(void)
  110. {
  111. MUX_TWISTER();
  112. }
  113. int board_eth_init(bd_t *bis)
  114. {
  115. davinci_emac_initialize();
  116. /* init cs for extern lan */
  117. enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5],
  118. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  119. if (smc911x_initialize(0, CONFIG_SMC911X_BASE) <= 0)
  120. printf("\nError initializing SMC911x controlleri\n");
  121. return 0;
  122. }
  123. #if defined(CONFIG_OMAP_HSMMC) && \
  124. !defined(CONFIG_SPL_BUILD)
  125. int board_mmc_init(bd_t *bis)
  126. {
  127. return omap_mmc_init(0, 0, 0, -1);
  128. }
  129. #endif
  130. #ifdef CONFIG_SPL_OS_BOOT
  131. /*
  132. * Do board specific preperation before SPL
  133. * Linux boot
  134. */
  135. void spl_board_prepare_for_linux(void)
  136. {
  137. /* init cs for extern lan */
  138. enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5],
  139. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  140. }
  141. int spl_start_uboot(void)
  142. {
  143. int val = 0;
  144. if (!gpio_request(CONFIG_SPL_OS_BOOT_KEY, "U-Boot key")) {
  145. gpio_direction_input(CONFIG_SPL_OS_BOOT_KEY);
  146. val = gpio_get_value(CONFIG_SPL_OS_BOOT_KEY);
  147. gpio_free(CONFIG_SPL_OS_BOOT_KEY);
  148. }
  149. return val;
  150. }
  151. #endif