usb-musb.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 "omap_device.h"
  27. #include "soc.h"
  28. #include "mux.h"
  29. #include "usb.h"
  30. static struct musb_hdrc_config musb_config = {
  31. .multipoint = 1,
  32. .dyn_fifo = 1,
  33. .num_eps = 16,
  34. .ram_bits = 12,
  35. };
  36. static struct musb_hdrc_platform_data musb_plat = {
  37. .mode = MUSB_OTG,
  38. /* .clock is set dynamically */
  39. .config = &musb_config,
  40. /* REVISIT charge pump on TWL4030 can supply up to
  41. * 100 mA ... but this value is board-specific, like
  42. * "mode", and should be passed to usb_musb_init().
  43. */
  44. .power = 50, /* up to 100 mA */
  45. };
  46. static u64 musb_dmamask = DMA_BIT_MASK(32);
  47. static struct omap_musb_board_data musb_default_board_data = {
  48. .interface_type = MUSB_INTERFACE_ULPI,
  49. .mode = MUSB_OTG,
  50. .power = 100,
  51. };
  52. void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
  53. {
  54. struct omap_hwmod *oh;
  55. struct platform_device *pdev;
  56. struct device *dev;
  57. int bus_id = -1;
  58. const char *oh_name, *name;
  59. struct omap_musb_board_data *board_data;
  60. if (musb_board_data)
  61. board_data = musb_board_data;
  62. else
  63. board_data = &musb_default_board_data;
  64. /*
  65. * REVISIT: This line can be removed once all the platforms using
  66. * musb_core.c have been converted to use use clkdev.
  67. */
  68. musb_plat.clock = "ick";
  69. musb_plat.board_data = board_data;
  70. musb_plat.power = board_data->power >> 1;
  71. musb_plat.mode = board_data->mode;
  72. musb_plat.extvbus = board_data->extvbus;
  73. oh_name = "usb_otg_hs";
  74. name = "musb-omap2430";
  75. oh = omap_hwmod_lookup(oh_name);
  76. if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
  77. __func__, oh_name))
  78. return;
  79. pdev = omap_device_build(name, bus_id, oh, &musb_plat,
  80. sizeof(musb_plat));
  81. if (IS_ERR(pdev)) {
  82. pr_err("Could not build omap_device for %s %s\n",
  83. name, oh_name);
  84. return;
  85. }
  86. dev = &pdev->dev;
  87. get_device(dev);
  88. dev->dma_mask = &musb_dmamask;
  89. dev->coherent_dma_mask = musb_dmamask;
  90. put_device(dev);
  91. }