usb-musb.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 <plat/usb.h>
  29. #ifdef CONFIG_USB_MUSB_SOC
  30. static struct resource musb_resources[] = {
  31. [0] = { /* start and end set dynamically */
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = { /* general IRQ */
  35. .start = INT_243X_HS_USB_MC,
  36. .flags = IORESOURCE_IRQ,
  37. },
  38. [2] = { /* DMA IRQ */
  39. .start = INT_243X_HS_USB_DMA,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static struct musb_hdrc_config musb_config = {
  44. .multipoint = 1,
  45. .dyn_fifo = 1,
  46. .num_eps = 16,
  47. .ram_bits = 12,
  48. };
  49. static struct musb_hdrc_platform_data musb_plat = {
  50. #ifdef CONFIG_USB_MUSB_OTG
  51. .mode = MUSB_OTG,
  52. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  53. .mode = MUSB_HOST,
  54. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  55. .mode = MUSB_PERIPHERAL,
  56. #endif
  57. /* .clock is set dynamically */
  58. .config = &musb_config,
  59. /* REVISIT charge pump on TWL4030 can supply up to
  60. * 100 mA ... but this value is board-specific, like
  61. * "mode", and should be passed to usb_musb_init().
  62. */
  63. .power = 50, /* up to 100 mA */
  64. };
  65. static u64 musb_dmamask = DMA_BIT_MASK(32);
  66. static struct platform_device musb_device = {
  67. .name = "musb_hdrc",
  68. .id = -1,
  69. .dev = {
  70. .dma_mask = &musb_dmamask,
  71. .coherent_dma_mask = DMA_BIT_MASK(32),
  72. .platform_data = &musb_plat,
  73. },
  74. .num_resources = ARRAY_SIZE(musb_resources),
  75. .resource = musb_resources,
  76. };
  77. void __init usb_musb_init(struct omap_musb_board_data *board_data)
  78. {
  79. if (cpu_is_omap243x()) {
  80. musb_resources[0].start = OMAP243X_HS_BASE;
  81. } else if (cpu_is_omap34xx()) {
  82. musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
  83. } else if (cpu_is_omap44xx()) {
  84. musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
  85. musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
  86. musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
  87. }
  88. musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
  89. /*
  90. * REVISIT: This line can be removed once all the platforms using
  91. * musb_core.c have been converted to use use clkdev.
  92. */
  93. musb_plat.clock = "ick";
  94. musb_plat.board_data = board_data;
  95. musb_plat.power = board_data->power >> 1;
  96. musb_plat.mode = board_data->mode;
  97. musb_plat.extvbus = board_data->extvbus;
  98. if (platform_device_register(&musb_device) < 0)
  99. printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
  100. }
  101. #else
  102. void __init usb_musb_init(struct omap_musb_board_data *board_data)
  103. {
  104. }
  105. #endif /* CONFIG_USB_MUSB_SOC */