panda.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. * (C) Copyright 2010
  3. * Texas Instruments Incorporated, <www.ti.com>
  4. * Steve Sakoman <steve@sakoman.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/arch/sys_proto.h>
  26. #include <asm/arch/mmc_host_def.h>
  27. #include <asm/arch/clock.h>
  28. #include <asm/arch/gpio.h>
  29. #include <asm/gpio.h>
  30. #include "panda_mux_data.h"
  31. #ifdef CONFIG_USB_EHCI
  32. #include <usb.h>
  33. #include <asm/arch/ehci.h>
  34. #include <asm/ehci-omap.h>
  35. #endif
  36. #define PANDA_ULPI_PHY_TYPE_GPIO 182
  37. #define PANDA_BOARD_ID_1_GPIO 101
  38. #define PANDA_ES_BOARD_ID_1_GPIO 48
  39. #define PANDA_BOARD_ID_2_GPIO 171
  40. #define PANDA_ES_BOARD_ID_3_GPIO 3
  41. #define PANDA_ES_BOARD_ID_4_GPIO 2
  42. DECLARE_GLOBAL_DATA_PTR;
  43. const struct omap_sysinfo sysinfo = {
  44. "Board: OMAP4 Panda\n"
  45. };
  46. struct omap4_scrm_regs *const scrm = (struct omap4_scrm_regs *)0x4a30a000;
  47. /**
  48. * @brief board_init
  49. *
  50. * @return 0
  51. */
  52. int board_init(void)
  53. {
  54. gpmc_init();
  55. gd->bd->bi_arch_number = MACH_TYPE_OMAP4_PANDA;
  56. gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
  57. return 0;
  58. }
  59. int board_eth_init(bd_t *bis)
  60. {
  61. return 0;
  62. }
  63. /*
  64. * Routine: get_board_revision
  65. * Description: Detect if we are running on a panda revision A1-A6,
  66. * or an ES panda board. This can be done by reading
  67. * the level of GPIOs and checking the processor revisions.
  68. * This should result in:
  69. * Panda 4430:
  70. * GPIO171, GPIO101, GPIO182: 0 1 1 => A1-A5
  71. * GPIO171, GPIO101, GPIO182: 1 0 1 => A6
  72. * Panda ES:
  73. * GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 0 1 1 => B1/B2
  74. * GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 1 1 1 => B3
  75. */
  76. int get_board_revision(void)
  77. {
  78. int board_id0, board_id1, board_id2;
  79. int board_id3, board_id4;
  80. int board_id;
  81. int processor_rev = omap_revision();
  82. /* Setup the mux for the common board ID pins (gpio 171 and 182) */
  83. writew((IEN | M3), (*ctrl)->control_padconf_core_base + UNIPRO_TX0);
  84. writew((IEN | M3), (*ctrl)->control_padconf_core_base + FREF_CLK2_OUT);
  85. board_id0 = gpio_get_value(PANDA_ULPI_PHY_TYPE_GPIO);
  86. board_id2 = gpio_get_value(PANDA_BOARD_ID_2_GPIO);
  87. if ((processor_rev >= OMAP4460_ES1_0 &&
  88. processor_rev <= OMAP4460_ES1_1)) {
  89. /*
  90. * Setup the mux for the ES specific board ID pins (gpio 101,
  91. * 2 and 3.
  92. */
  93. writew((IEN | M3), (*ctrl)->control_padconf_core_base +
  94. GPMC_A24);
  95. writew((IEN | M3), (*ctrl)->control_padconf_core_base +
  96. UNIPRO_RY0);
  97. writew((IEN | M3), (*ctrl)->control_padconf_core_base +
  98. UNIPRO_RX1);
  99. board_id1 = gpio_get_value(PANDA_ES_BOARD_ID_1_GPIO);
  100. board_id3 = gpio_get_value(PANDA_ES_BOARD_ID_3_GPIO);
  101. board_id4 = gpio_get_value(PANDA_ES_BOARD_ID_4_GPIO);
  102. #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  103. setenv("board_name", strcat(CONFIG_SYS_BOARD, "-es"));
  104. #endif
  105. board_id = ((board_id4 << 4) | (board_id3 << 3) |
  106. (board_id2 << 2) | (board_id1 << 1) | (board_id0));
  107. } else {
  108. /* Setup the mux for the Ax specific board ID pins (gpio 101) */
  109. writew((IEN | M3), (*ctrl)->control_padconf_core_base +
  110. FREF_CLK2_OUT);
  111. board_id1 = gpio_get_value(PANDA_BOARD_ID_1_GPIO);
  112. board_id = ((board_id2 << 2) | (board_id1 << 1) | (board_id0));
  113. #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  114. if ((board_id >= 0x3) && (processor_rev == OMAP4430_ES2_3))
  115. setenv("board_name", strcat(CONFIG_SYS_BOARD, "-a4"));
  116. #endif
  117. }
  118. return board_id;
  119. }
  120. /**
  121. * @brief misc_init_r - Configure Panda board specific configurations
  122. * such as power configurations, ethernet initialization as phase2 of
  123. * boot sequence
  124. *
  125. * @return 0
  126. */
  127. int misc_init_r(void)
  128. {
  129. int phy_type;
  130. u32 auxclk, altclksrc;
  131. /* EHCI is not supported on ES1.0 */
  132. if (omap_revision() == OMAP4430_ES1_0)
  133. return 0;
  134. get_board_revision();
  135. gpio_direction_input(PANDA_ULPI_PHY_TYPE_GPIO);
  136. phy_type = gpio_get_value(PANDA_ULPI_PHY_TYPE_GPIO);
  137. if (phy_type == 1) {
  138. /* ULPI PHY supplied by auxclk3 derived from sys_clk */
  139. debug("ULPI PHY supplied by auxclk3\n");
  140. auxclk = readl(&scrm->auxclk3);
  141. /* Select sys_clk */
  142. auxclk &= ~AUXCLK_SRCSELECT_MASK;
  143. auxclk |= AUXCLK_SRCSELECT_SYS_CLK << AUXCLK_SRCSELECT_SHIFT;
  144. /* Set the divisor to 2 */
  145. auxclk &= ~AUXCLK_CLKDIV_MASK;
  146. auxclk |= AUXCLK_CLKDIV_2 << AUXCLK_CLKDIV_SHIFT;
  147. /* Request auxilary clock #3 */
  148. auxclk |= AUXCLK_ENABLE_MASK;
  149. writel(auxclk, &scrm->auxclk3);
  150. } else {
  151. /* ULPI PHY supplied by auxclk1 derived from PER dpll */
  152. debug("ULPI PHY supplied by auxclk1\n");
  153. auxclk = readl(&scrm->auxclk1);
  154. /* Select per DPLL */
  155. auxclk &= ~AUXCLK_SRCSELECT_MASK;
  156. auxclk |= AUXCLK_SRCSELECT_PER_DPLL << AUXCLK_SRCSELECT_SHIFT;
  157. /* Set the divisor to 16 */
  158. auxclk &= ~AUXCLK_CLKDIV_MASK;
  159. auxclk |= AUXCLK_CLKDIV_16 << AUXCLK_CLKDIV_SHIFT;
  160. /* Request auxilary clock #3 */
  161. auxclk |= AUXCLK_ENABLE_MASK;
  162. writel(auxclk, &scrm->auxclk1);
  163. }
  164. altclksrc = readl(&scrm->altclksrc);
  165. /* Activate alternate system clock supplier */
  166. altclksrc &= ~ALTCLKSRC_MODE_MASK;
  167. altclksrc |= ALTCLKSRC_MODE_ACTIVE;
  168. /* enable clocks */
  169. altclksrc |= ALTCLKSRC_ENABLE_INT_MASK | ALTCLKSRC_ENABLE_EXT_MASK;
  170. writel(altclksrc, &scrm->altclksrc);
  171. return 0;
  172. }
  173. void set_muxconf_regs_essential(void)
  174. {
  175. do_set_mux((*ctrl)->control_padconf_core_base,
  176. core_padconf_array_essential,
  177. sizeof(core_padconf_array_essential) /
  178. sizeof(struct pad_conf_entry));
  179. do_set_mux((*ctrl)->control_padconf_wkup_base,
  180. wkup_padconf_array_essential,
  181. sizeof(wkup_padconf_array_essential) /
  182. sizeof(struct pad_conf_entry));
  183. if (omap_revision() >= OMAP4460_ES1_0)
  184. do_set_mux((*ctrl)->control_padconf_wkup_base,
  185. wkup_padconf_array_essential_4460,
  186. sizeof(wkup_padconf_array_essential_4460) /
  187. sizeof(struct pad_conf_entry));
  188. }
  189. void set_muxconf_regs_non_essential(void)
  190. {
  191. do_set_mux((*ctrl)->control_padconf_core_base,
  192. core_padconf_array_non_essential,
  193. sizeof(core_padconf_array_non_essential) /
  194. sizeof(struct pad_conf_entry));
  195. if (omap_revision() < OMAP4460_ES1_0)
  196. do_set_mux((*ctrl)->control_padconf_core_base,
  197. core_padconf_array_non_essential_4430,
  198. sizeof(core_padconf_array_non_essential_4430) /
  199. sizeof(struct pad_conf_entry));
  200. else
  201. do_set_mux((*ctrl)->control_padconf_core_base,
  202. core_padconf_array_non_essential_4460,
  203. sizeof(core_padconf_array_non_essential_4460) /
  204. sizeof(struct pad_conf_entry));
  205. do_set_mux((*ctrl)->control_padconf_wkup_base,
  206. wkup_padconf_array_non_essential,
  207. sizeof(wkup_padconf_array_non_essential) /
  208. sizeof(struct pad_conf_entry));
  209. if (omap_revision() < OMAP4460_ES1_0)
  210. do_set_mux((*ctrl)->control_padconf_wkup_base,
  211. wkup_padconf_array_non_essential_4430,
  212. sizeof(wkup_padconf_array_non_essential_4430) /
  213. sizeof(struct pad_conf_entry));
  214. }
  215. #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_GENERIC_MMC)
  216. int board_mmc_init(bd_t *bis)
  217. {
  218. return omap_mmc_init(0, 0, 0, -1, -1);
  219. }
  220. #endif
  221. #ifdef CONFIG_USB_EHCI
  222. static struct omap_usbhs_board_data usbhs_bdata = {
  223. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  224. .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
  225. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  226. };
  227. int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  228. {
  229. int ret;
  230. unsigned int utmi_clk;
  231. /* Now we can enable our port clocks */
  232. utmi_clk = readl((void *)CM_L3INIT_HSUSBHOST_CLKCTRL);
  233. utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
  234. sr32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, 0, 32, utmi_clk);
  235. ret = omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
  236. if (ret < 0)
  237. return ret;
  238. return 0;
  239. }
  240. int ehci_hcd_stop(int index)
  241. {
  242. return omap_ehci_hcd_stop();
  243. }
  244. #endif
  245. /*
  246. * get_board_rev() - get board revision
  247. */
  248. u32 get_board_rev(void)
  249. {
  250. return 0x20;
  251. }