mx31moboard-smartbot.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/delay.h>
  15. #include <linux/gpio.h>
  16. #include <linux/init.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/i2c.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/types.h>
  21. #include <linux/usb/otg.h>
  22. #include <linux/usb/ulpi.h>
  23. #include "board-mx31moboard.h"
  24. #include "common.h"
  25. #include "devices-imx31.h"
  26. #include "ehci.h"
  27. #include "hardware.h"
  28. #include "iomux-mx3.h"
  29. #include "ulpi.h"
  30. static unsigned int smartbot_pins[] = {
  31. /* UART1 */
  32. MX31_PIN_CTS2__CTS2, MX31_PIN_RTS2__RTS2,
  33. MX31_PIN_TXD2__TXD2, MX31_PIN_RXD2__RXD2,
  34. /* ENABLES */
  35. MX31_PIN_DTR_DCE1__GPIO2_8, MX31_PIN_DSR_DCE1__GPIO2_9,
  36. MX31_PIN_RI_DCE1__GPIO2_10, MX31_PIN_DCD_DCE1__GPIO2_11,
  37. };
  38. static const struct imxuart_platform_data uart_pdata __initconst = {
  39. .flags = IMXUART_HAVE_RTSCTS,
  40. };
  41. static const struct fsl_usb2_platform_data usb_pdata __initconst = {
  42. .operating_mode = FSL_USB2_DR_DEVICE,
  43. .phy_mode = FSL_USB2_PHY_ULPI,
  44. };
  45. #if defined(CONFIG_USB_ULPI)
  46. static int smartbot_otg_init(struct platform_device *pdev)
  47. {
  48. return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  49. }
  50. static struct mxc_usbh_platform_data otg_host_pdata __initdata = {
  51. .init = smartbot_otg_init,
  52. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  53. };
  54. static int __init smartbot_otg_host_init(void)
  55. {
  56. struct platform_device *pdev;
  57. otg_host_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
  58. ULPI_OTG_DRVVBUS_EXT);
  59. if (!otg_host_pdata.otg)
  60. return -ENODEV;
  61. pdev = imx31_add_mxc_ehci_otg(&otg_host_pdata);
  62. return PTR_ERR_OR_ZERO(pdev);
  63. }
  64. #else
  65. static inline int smartbot_otg_host_init(void) { return 0; }
  66. #endif
  67. #define POWER_EN IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1)
  68. #define DSPIC_RST_B IOMUX_TO_GPIO(MX31_PIN_DSR_DCE1)
  69. #define TRSLAT_RST_B IOMUX_TO_GPIO(MX31_PIN_RI_DCE1)
  70. #define TRSLAT_SRC_CHOICE IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)
  71. static void smartbot_resets_init(void)
  72. {
  73. if (!gpio_request(POWER_EN, "power-enable")) {
  74. gpio_direction_output(POWER_EN, 0);
  75. gpio_export(POWER_EN, false);
  76. }
  77. if (!gpio_request(DSPIC_RST_B, "dspic-rst")) {
  78. gpio_direction_output(DSPIC_RST_B, 0);
  79. gpio_export(DSPIC_RST_B, false);
  80. }
  81. if (!gpio_request(TRSLAT_RST_B, "translator-rst")) {
  82. gpio_direction_output(TRSLAT_RST_B, 0);
  83. gpio_export(TRSLAT_RST_B, false);
  84. }
  85. if (!gpio_request(TRSLAT_SRC_CHOICE, "translator-src-choice")) {
  86. gpio_direction_output(TRSLAT_SRC_CHOICE, 0);
  87. gpio_export(TRSLAT_SRC_CHOICE, false);
  88. }
  89. }
  90. /*
  91. * system init for baseboard usage. Will be called by mx31moboard init.
  92. */
  93. void __init mx31moboard_smartbot_init(int board)
  94. {
  95. printk(KERN_INFO "Initializing mx31smartbot peripherals\n");
  96. mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
  97. "smartbot");
  98. imx31_add_imx_uart1(&uart_pdata);
  99. switch (board) {
  100. case MX31SMARTBOT:
  101. imx31_add_fsl_usb2_udc(&usb_pdata);
  102. break;
  103. case MX31EYEBOT:
  104. smartbot_otg_host_init();
  105. break;
  106. default:
  107. printk(KERN_WARNING "Unknown board %d, USB OTG not initialized",
  108. board);
  109. }
  110. smartbot_resets_init();
  111. }