tao3530.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Maintainer :
  4. * Tapani Utriainen <linuxfae@technexion.com>
  5. */
  6. #include <common.h>
  7. #include <netdev.h>
  8. #include <twl4030.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/mmc_host_def.h>
  11. #include <asm/arch/mem.h>
  12. #include <asm/arch/mux.h>
  13. #include <asm/arch/sys_proto.h>
  14. #include <asm/arch/gpio.h>
  15. #include <asm/gpio.h>
  16. #include <asm/mach-types.h>
  17. #include <usb.h>
  18. #include <asm/ehci-omap.h>
  19. #include "tao3530.h"
  20. DECLARE_GLOBAL_DATA_PTR;
  21. int tao3530_revision(void)
  22. {
  23. int ret = 0;
  24. /* char *label argument is unused in gpio_request() */
  25. ret = gpio_request(65, "");
  26. if (ret) {
  27. puts("Error: GPIO 65 not available\n");
  28. goto out;
  29. }
  30. MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M4));
  31. ret = gpio_request(1, "");
  32. if (ret) {
  33. puts("Error: GPIO 1 not available\n");
  34. goto out2;
  35. }
  36. MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M4));
  37. ret = gpio_direction_input(65);
  38. if (ret) {
  39. puts("Error: GPIO 65 not available for input\n");
  40. goto out3;
  41. }
  42. ret = gpio_direction_input(1);
  43. if (ret) {
  44. puts("Error: GPIO 1 not available for input\n");
  45. goto out3;
  46. }
  47. ret = gpio_get_value(65) << 1 | gpio_get_value(1);
  48. out3:
  49. MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M0));
  50. gpio_free(1);
  51. out2:
  52. MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M0));
  53. gpio_free(65);
  54. out:
  55. return ret;
  56. }
  57. #ifdef CONFIG_SPL_BUILD
  58. /*
  59. * Routine: get_board_mem_timings
  60. * Description: If we use SPL then there is no x-loader nor config header
  61. * so we have to setup the DDR timings ourself on both banks.
  62. */
  63. void get_board_mem_timings(struct board_sdrc_timings *timings)
  64. {
  65. #if defined(CONFIG_SYS_BOARD_OMAP3_HA)
  66. /*
  67. * Switch baseboard LED to red upon power-on
  68. */
  69. MUX_OMAP3_HA();
  70. /* Request a gpio before using it */
  71. gpio_request(111, "");
  72. /* Sets the gpio as output and its value to 1, switch LED to red */
  73. gpio_direction_output(111, 1);
  74. #endif
  75. if (tao3530_revision() < 3) {
  76. /* 256MB / Bank */
  77. timings->mcfg = MCFG(256 << 20, 14); /* RAS-width 14 */
  78. timings->ctrla = HYNIX_V_ACTIMA_165;
  79. timings->ctrlb = HYNIX_V_ACTIMB_165;
  80. } else {
  81. /* 128MB / Bank */
  82. timings->mcfg = MCFG(128 << 20, 13); /* RAS-width 13 */
  83. timings->ctrla = MICRON_V_ACTIMA_165;
  84. timings->ctrlb = MICRON_V_ACTIMB_165;
  85. }
  86. timings->mr = MICRON_V_MR_165;
  87. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  88. }
  89. #endif
  90. /*
  91. * Routine: board_init
  92. * Description: Early hardware init.
  93. */
  94. int board_init(void)
  95. {
  96. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  97. /* board id for Linux */
  98. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_TAO3530;
  99. /* boot param addr */
  100. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  101. return 0;
  102. }
  103. /*
  104. * Routine: misc_init_r
  105. * Description: Configure board specific parts
  106. */
  107. int misc_init_r(void)
  108. {
  109. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  110. struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
  111. twl4030_power_init();
  112. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  113. /* Configure GPIOs to output */
  114. /* GPIO23 */
  115. writel(~(GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
  116. writel(~(GPIO31 | GPIO30 | GPIO22 | GPIO21 |
  117. GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
  118. /* Set GPIOs */
  119. writel(GPIO10 | GPIO8 | GPIO2 | GPIO1,
  120. &gpio6_base->setdataout);
  121. writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  122. GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
  123. switch (tao3530_revision()) {
  124. case 0:
  125. puts("TAO-3530 REV Reserve 1\n");
  126. break;
  127. case 1:
  128. puts("TAO-3530 REV Reserve 2\n");
  129. break;
  130. case 2:
  131. puts("TAO-3530 REV Cx\n");
  132. break;
  133. case 3:
  134. puts("TAO-3530 REV Ax/Bx\n");
  135. break;
  136. default:
  137. puts("Unknown board revision\n");
  138. }
  139. omap_die_id_display();
  140. return 0;
  141. }
  142. /*
  143. * Routine: set_muxconf_regs
  144. * Description: Setting up the configuration Mux registers specific to the
  145. * hardware. Many pins need to be moved from protect to primary
  146. * mode.
  147. */
  148. void set_muxconf_regs(void)
  149. {
  150. MUX_TAO3530();
  151. #if defined(CONFIG_SYS_BOARD_OMAP3_HA)
  152. MUX_OMAP3_HA();
  153. #endif
  154. }
  155. #if defined(CONFIG_MMC)
  156. int board_mmc_init(bd_t *bis)
  157. {
  158. omap_mmc_init(0, 0, 0, -1, -1);
  159. return 0;
  160. }
  161. #endif
  162. #if defined(CONFIG_MMC)
  163. void board_mmc_power_init(void)
  164. {
  165. twl4030_power_mmc_init(0);
  166. }
  167. #endif
  168. #if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
  169. /* Call usb_stop() before starting the kernel */
  170. void show_boot_progress(int val)
  171. {
  172. if (val == BOOTSTAGE_ID_RUN_OS)
  173. usb_stop();
  174. }
  175. static struct omap_usbhs_board_data usbhs_bdata = {
  176. .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
  177. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  178. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
  179. };
  180. int ehci_hcd_init(int index, enum usb_init_type init,
  181. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  182. {
  183. return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
  184. }
  185. int ehci_hcd_stop(int index)
  186. {
  187. return omap_ehci_hcd_stop();
  188. }
  189. #endif /* CONFIG_USB_EHCI_HCD */