PageRenderTime 102ms CodeModel.GetById 41ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/arm/mach-omap2/usb-musb.c

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