twister.c 3.3 KB

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