hawkboard.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Modified for Hawkboard - Syed Mohammed Khasim <khasim@beagleboard.org>
  3. *
  4. * Copyright (C) 2008 Sekhar Nori, Texas Instruments, Inc. <nsekhar@ti.com>
  5. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  6. * Copyright (C) 2004 Texas Instruments.
  7. * Copyright (C) 2012 Sughosh Ganu <urwithsughosh@gmail.com>.
  8. *
  9. * ----------------------------------------------------------------------------
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. * ----------------------------------------------------------------------------
  24. */
  25. #include <common.h>
  26. #include <asm/errno.h>
  27. #include <asm/arch/hardware.h>
  28. #include <asm/io.h>
  29. #include <asm/arch/davinci_misc.h>
  30. #include <asm/arch/pinmux_defs.h>
  31. #include <asm/arch/da8xx-usb.h>
  32. #include <ns16550.h>
  33. DECLARE_GLOBAL_DATA_PTR;
  34. const struct pinmux_resource pinmuxes[] = {
  35. PINMUX_ITEM(emac_pins_mii),
  36. PINMUX_ITEM(emac_pins_mdio),
  37. PINMUX_ITEM(emifa_pins_cs3),
  38. PINMUX_ITEM(emifa_pins_cs4),
  39. PINMUX_ITEM(emifa_pins_nand),
  40. PINMUX_ITEM(uart2_pins_txrx),
  41. PINMUX_ITEM(uart2_pins_rtscts),
  42. };
  43. const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
  44. const struct lpsc_resource lpsc[] = {
  45. { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
  46. { DAVINCI_LPSC_SPI1 }, /* Serial Flash */
  47. { DAVINCI_LPSC_EMAC }, /* image download */
  48. { DAVINCI_LPSC_UART2 }, /* console */
  49. { DAVINCI_LPSC_GPIO },
  50. };
  51. const int lpsc_size = ARRAY_SIZE(lpsc);
  52. int board_init(void)
  53. {
  54. /* arch number of the board */
  55. gd->bd->bi_arch_number = MACH_TYPE_OMAPL138_HAWKBOARD;
  56. /* address of boot parameters */
  57. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  58. return 0;
  59. }
  60. int board_early_init_f(void)
  61. {
  62. /*
  63. * Kick Registers need to be set to allow access to Pin Mux registers
  64. */
  65. writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0);
  66. writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1);
  67. /* set cfgchip3 to select mii */
  68. writel(readl(&davinci_syscfg_regs->cfgchip3) &
  69. ~(1 << 8), &davinci_syscfg_regs->cfgchip3);
  70. return 0;
  71. }
  72. int misc_init_r(void)
  73. {
  74. char buf[32];
  75. printf("ARM Clock : %s MHz\n",
  76. strmhz(buf, clk_get(DAVINCI_ARM_CLKID)));
  77. return 0;
  78. }
  79. int usb_phy_on(void)
  80. {
  81. u32 timeout;
  82. u32 cfgchip2;
  83. cfgchip2 = readl(&davinci_syscfg_regs->cfgchip2);
  84. cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN |
  85. CFGCHIP2_OTGMODE | CFGCHIP2_REFFREQ |
  86. CFGCHIP2_USB1PHYCLKMUX);
  87. cfgchip2 |= CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN | CFGCHIP2_PHY_PLLON |
  88. CFGCHIP2_REFFREQ_24MHZ | CFGCHIP2_USB2PHYCLKMUX |
  89. CFGCHIP2_USB1SUSPENDM;
  90. writel(cfgchip2, &davinci_syscfg_regs->cfgchip2);
  91. /* wait until the usb phy pll locks */
  92. timeout = DA8XX_USB_OTG_TIMEOUT;
  93. while (timeout--)
  94. if (readl(&davinci_syscfg_regs->cfgchip2) & CFGCHIP2_PHYCLKGD)
  95. return 1;
  96. /* USB phy was not turned on */
  97. return 0;
  98. }
  99. void usb_phy_off(void)
  100. {
  101. u32 cfgchip2;
  102. /*
  103. * Power down the on-chip PHY.
  104. */
  105. cfgchip2 = readl(&davinci_syscfg_regs->cfgchip2);
  106. cfgchip2 &= ~(CFGCHIP2_PHY_PLLON | CFGCHIP2_USB1SUSPENDM);
  107. cfgchip2 |= CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN | CFGCHIP2_RESET;
  108. writel(cfgchip2, &davinci_syscfg_regs->cfgchip2);
  109. }