usbsetting.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. *
  3. * arch/arm/mach-meson6/usbsetting.c
  4. *
  5. * make default settings
  6. *
  7. * Copyright (C) 2011 AMLOGIC, INC.
  8. *
  9. * by Victor Wan 2012.02.14 @Santa Clara, CA
  10. *
  11. * License terms: GNU General Public License (GPL) version 2
  12. * Platform machine definition.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/mm.h>
  17. #include <linux/sched.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/ioport.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/io.h>
  22. #include <linux/slab.h>
  23. #include <linux/dma-mapping.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/delay.h>
  27. #include <plat/platform.h>
  28. #include <plat/lm.h>
  29. #include <plat/regops.h>
  30. #include <mach/hardware.h>
  31. #include <mach/memory.h>
  32. #include <mach/clock.h>
  33. #include <mach/reg_addr.h>
  34. #include <mach/usbclock.h>
  35. struct lm_device * alloc_usb_lm_device(int port_index)
  36. {
  37. struct lm_device * ld;
  38. if(port_index != USB_PORT_IDX_A && port_index != USB_PORT_IDX_B){
  39. printk(KERN_ERR "wrong port index (%d) in alloc_usb_im_device\n",port_index);
  40. return 0;
  41. }
  42. ld = kzalloc(sizeof(struct lm_device),GFP_KERNEL);
  43. if(!ld){
  44. printk(KERN_ERR "out of memory to alloc usb lm device\n");
  45. return 0;
  46. }
  47. ld->type = LM_DEVICE_TYPE_USB;
  48. ld->dma_mask_room = DMA_BIT_MASK(32);
  49. /* Default clock setting */
  50. ld->clock.sel = USB_PHY_CLK_SEL_XTAL;
  51. ld->clock.div = 1;
  52. ld->clock.src = 24000000;
  53. ld->param.usb.port_idx = port_index;
  54. if(port_index == USB_PORT_IDX_A){
  55. ld->id = 0; //lm0
  56. ld->irq = INT_USB_A;
  57. ld->resource.start = IO_USB_A_BASE;
  58. ld->resource.end = SZ_256K;
  59. ld->param.usb.port_type = USB_PORT_TYPE_OTG;
  60. ld->param.usb.port_speed = USB_PORT_SPEED_DEFAULT;
  61. ld->param.usb.dma_config = USB_DMA_BURST_DEFAULT;
  62. ld->param.usb.phy_tune_reg = P_USB_ADDR0;
  63. }else{
  64. ld->id = 1; //lm1
  65. ld->irq = INT_USB_B;
  66. ld->resource.start = IO_USB_B_BASE;
  67. ld->resource.end = SZ_256K;
  68. ld->param.usb.port_type = USB_PORT_TYPE_HOST;
  69. ld->param.usb.port_speed = USB_PORT_SPEED_DEFAULT;
  70. ld->param.usb.dma_config = USB_DMA_BURST_DEFAULT;
  71. ld->param.usb.phy_tune_reg = P_USB_ADDR8;
  72. }
  73. return ld;
  74. }
  75. EXPORT_SYMBOL(alloc_usb_lm_device);