tao3530.c 4.8 KB

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