twister.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (C) 2011
  3. * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
  4. *
  5. * Copyright (C) 2009 TechNexion Ltd.
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <netdev.h>
  11. #include <asm/io.h>
  12. #include <asm/arch/mem.h>
  13. #include <asm/arch/mux.h>
  14. #include <asm/arch/sys_proto.h>
  15. #include <asm/omap_gpio.h>
  16. #include <asm/arch/mmc_host_def.h>
  17. #include <i2c.h>
  18. #include <spl.h>
  19. #include <mmc.h>
  20. #include <asm/gpio.h>
  21. #ifdef CONFIG_USB_EHCI
  22. #include <usb.h>
  23. #include <asm/ehci-omap.h>
  24. #endif
  25. #include "twister.h"
  26. DECLARE_GLOBAL_DATA_PTR;
  27. /* Timing definitions for Ethernet Controller */
  28. static const u32 gpmc_smc911[] = {
  29. NET_GPMC_CONFIG1,
  30. NET_GPMC_CONFIG2,
  31. NET_GPMC_CONFIG3,
  32. NET_GPMC_CONFIG4,
  33. NET_GPMC_CONFIG5,
  34. NET_GPMC_CONFIG6,
  35. };
  36. static const u32 gpmc_XR16L2751[] = {
  37. XR16L2751_GPMC_CONFIG1,
  38. XR16L2751_GPMC_CONFIG2,
  39. XR16L2751_GPMC_CONFIG3,
  40. XR16L2751_GPMC_CONFIG4,
  41. XR16L2751_GPMC_CONFIG5,
  42. XR16L2751_GPMC_CONFIG6,
  43. };
  44. #ifdef CONFIG_USB_EHCI
  45. static struct omap_usbhs_board_data usbhs_bdata = {
  46. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  47. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  48. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  49. };
  50. int ehci_hcd_init(int index, enum usb_init_type init,
  51. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  52. {
  53. return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
  54. }
  55. int ehci_hcd_stop(int index)
  56. {
  57. return omap_ehci_hcd_stop();
  58. }
  59. #endif
  60. int board_init(void)
  61. {
  62. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  63. /* boot param addr */
  64. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  65. /* Chip select 1 and 3 are used for XR16L2751 UART controller */
  66. enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[1],
  67. XR16L2751_UART1_BASE, GPMC_SIZE_16M);
  68. enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[3],
  69. XR16L2751_UART2_BASE, GPMC_SIZE_16M);
  70. gpio_request(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, "USB_PHY1_RESET");
  71. gpio_direction_output(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, 1);
  72. return 0;
  73. }
  74. #ifndef CONFIG_SPL_BUILD
  75. int misc_init_r(void)
  76. {
  77. char *eth_addr;
  78. struct tam3517_module_info info;
  79. int ret;
  80. omap_die_id_display();
  81. eth_addr = getenv("ethaddr");
  82. if (eth_addr)
  83. return 0;
  84. TAM3517_READ_EEPROM(&info, ret);
  85. if (!ret)
  86. TAM3517_READ_MAC_FROM_EEPROM(&info);
  87. return 0;
  88. }
  89. #endif
  90. /*
  91. * Routine: set_muxconf_regs
  92. * Description: Setting up the configuration Mux registers specific to the
  93. * hardware. Many pins need to be moved from protect to primary
  94. * mode.
  95. */
  96. void set_muxconf_regs(void)
  97. {
  98. MUX_TWISTER();
  99. }
  100. int board_eth_init(bd_t *bis)
  101. {
  102. davinci_emac_initialize();
  103. /* init cs for extern lan */
  104. enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5],
  105. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  106. if (smc911x_initialize(0, CONFIG_SMC911X_BASE) <= 0)
  107. printf("\nError initializing SMC911x controlleri\n");
  108. return 0;
  109. }
  110. #if defined(CONFIG_OMAP_HSMMC)
  111. int board_mmc_init(bd_t *bis)
  112. {
  113. return omap_mmc_init(0, 0, 0, -1, -1);
  114. }
  115. #endif
  116. #ifdef CONFIG_SPL_OS_BOOT
  117. /*
  118. * Do board specific preparation before SPL
  119. * Linux boot
  120. */
  121. void spl_board_prepare_for_linux(void)
  122. {
  123. /* init cs for extern lan */
  124. enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5],
  125. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  126. }
  127. int spl_start_uboot(void)
  128. {
  129. int val = 0;
  130. if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) {
  131. gpio_direction_input(SPL_OS_BOOT_KEY);
  132. val = gpio_get_value(SPL_OS_BOOT_KEY);
  133. gpio_free(SPL_OS_BOOT_KEY);
  134. }
  135. return val;
  136. }
  137. #endif