usb-musb.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * linux/arch/arm/mach-omap2/usb-musb.c
  3. *
  4. * This file will contain the board specific details for the
  5. * MENTOR USB OTG controller on OMAP3430
  6. *
  7. * Copyright (C) 2007-2008 Texas Instruments
  8. * Copyright (C) 2008 Nokia Corporation
  9. * Author: Vikram Pandita
  10. *
  11. * Generalization by:
  12. * Felipe Balbi <felipe.balbi@nokia.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/types.h>
  19. #include <linux/errno.h>
  20. #include <linux/delay.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/clk.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/io.h>
  25. #include <linux/usb/musb.h>
  26. #include <mach/hardware.h>
  27. #include <mach/irqs.h>
  28. #include <mach/am35xx.h>
  29. #include <plat/usb.h>
  30. #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined (CONFIG_USB_MUSB_AM35X)
  31. static struct resource musb_resources[] = {
  32. [0] = { /* start and end set dynamically */
  33. .flags = IORESOURCE_MEM,
  34. },
  35. [1] = { /* general IRQ */
  36. .start = INT_243X_HS_USB_MC,
  37. .flags = IORESOURCE_IRQ,
  38. .name = "mc",
  39. },
  40. [2] = { /* DMA IRQ */
  41. .start = INT_243X_HS_USB_DMA,
  42. .flags = IORESOURCE_IRQ,
  43. .name = "dma",
  44. },
  45. };
  46. static struct musb_hdrc_config musb_config = {
  47. .multipoint = 1,
  48. .dyn_fifo = 1,
  49. .num_eps = 16,
  50. .ram_bits = 12,
  51. };
  52. static struct musb_hdrc_platform_data musb_plat = {
  53. #ifdef CONFIG_USB_MUSB_OTG
  54. .mode = MUSB_OTG,
  55. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  56. .mode = MUSB_HOST,
  57. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  58. .mode = MUSB_PERIPHERAL,
  59. #endif
  60. /* .clock is set dynamically */
  61. .config = &musb_config,
  62. /* REVISIT charge pump on TWL4030 can supply up to
  63. * 100 mA ... but this value is board-specific, like
  64. * "mode", and should be passed to usb_musb_init().
  65. */
  66. .power = 50, /* up to 100 mA */
  67. };
  68. static u64 musb_dmamask = DMA_BIT_MASK(32);
  69. static struct platform_device musb_device = {
  70. .name = "musb-omap2430",
  71. .id = -1,
  72. .dev = {
  73. .dma_mask = &musb_dmamask,
  74. .coherent_dma_mask = DMA_BIT_MASK(32),
  75. .platform_data = &musb_plat,
  76. },
  77. .num_resources = ARRAY_SIZE(musb_resources),
  78. .resource = musb_resources,
  79. };
  80. void __init usb_musb_init(struct omap_musb_board_data *board_data)
  81. {
  82. if (cpu_is_omap243x()) {
  83. musb_resources[0].start = OMAP243X_HS_BASE;
  84. } else if (cpu_is_omap3517() || cpu_is_omap3505()) {
  85. musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
  86. musb_resources[1].start = INT_35XX_USBOTG_IRQ;
  87. } else if (cpu_is_omap34xx()) {
  88. musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
  89. } else if (cpu_is_omap44xx()) {
  90. musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
  91. musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
  92. musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
  93. }
  94. musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
  95. /*
  96. * REVISIT: This line can be removed once all the platforms using
  97. * musb_core.c have been converted to use use clkdev.
  98. */
  99. musb_plat.clock = "ick";
  100. musb_plat.board_data = board_data;
  101. musb_plat.power = board_data->power >> 1;
  102. musb_plat.mode = board_data->mode;
  103. musb_plat.extvbus = board_data->extvbus;
  104. if (platform_device_register(&musb_device) < 0)
  105. printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
  106. }
  107. #else
  108. void __init usb_musb_init(struct omap_musb_board_data *board_data)
  109. {
  110. }
  111. #endif /* CONFIG_USB_MUSB_SOC */