mcx.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (C) 2011 Ilya Yanok, Emcraft Systems
  3. *
  4. * Based on ti/evm/evm.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc.
  19. */
  20. #include <common.h>
  21. #include <asm/io.h>
  22. #include <asm/arch/mem.h>
  23. #include <asm/arch/mmc_host_def.h>
  24. #include <asm/arch/mux.h>
  25. #include <asm/arch/sys_proto.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/gpio.h>
  28. #include <asm/omap_gpio.h>
  29. #include "errno.h"
  30. #include <i2c.h>
  31. #ifdef CONFIG_USB_EHCI
  32. #include <usb.h>
  33. #include <asm/ehci-omap.h>
  34. #endif
  35. #include "mcx.h"
  36. DECLARE_GLOBAL_DATA_PTR;
  37. #define HOT_WATER_BUTTON 38
  38. #ifdef CONFIG_USB_EHCI
  39. static struct omap_usbhs_board_data usbhs_bdata = {
  40. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  41. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  42. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  43. };
  44. int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  45. {
  46. return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
  47. }
  48. int ehci_hcd_stop(int index)
  49. {
  50. return omap_ehci_hcd_stop();
  51. }
  52. #endif
  53. /*
  54. * Routine: board_init
  55. * Description: Early hardware init.
  56. */
  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. return 0;
  63. }
  64. #ifdef CONFIG_BOARD_LATE_INIT
  65. int board_late_init(void)
  66. {
  67. if (gpio_request(HOT_WATER_BUTTON, "hot-water-button") < 0) {
  68. puts("Failed to get hot-water-button pin\n");
  69. return -ENODEV;
  70. }
  71. gpio_direction_input(HOT_WATER_BUTTON);
  72. /*
  73. * if hot-water-button is pressed
  74. * change bootcmd
  75. */
  76. if (gpio_get_value(HOT_WATER_BUTTON))
  77. return 0;
  78. setenv("bootcmd", "run swupdate");
  79. return 0;
  80. }
  81. #endif
  82. /*
  83. * Routine: set_muxconf_regs
  84. * Description: Setting up the configuration Mux registers specific to the
  85. * hardware. Many pins need to be moved from protect to primary
  86. * mode.
  87. */
  88. void set_muxconf_regs(void)
  89. {
  90. MUX_MCX();
  91. }
  92. #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
  93. int board_mmc_init(bd_t *bis)
  94. {
  95. return omap_mmc_init(0, 0, 0);
  96. }
  97. #endif
  98. #ifdef CONFIG_USB_EHCI_OMAP
  99. #define USB_HOST_PWR_EN 132
  100. int board_usb_init(void)
  101. {
  102. if (gpio_request(USB_HOST_PWR_EN, "USB_HOST_PWR_EN") < 0) {
  103. puts("Failed to get USB_HOST_PWR_EN pin\n");
  104. return -ENODEV;
  105. }
  106. gpio_direction_output(USB_HOST_PWR_EN, 1);
  107. return 0;
  108. }
  109. #endif