dev-usb-usbd.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  7. * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com>
  8. * Copyright (C) 2012 Broadcom Corporation
  9. */
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/dma-mapping.h>
  14. #include <bcm63xx_cpu.h>
  15. #include <bcm63xx_dev_usb_usbd.h>
  16. #define NUM_MMIO 2
  17. #define NUM_IRQ 7
  18. static struct resource usbd_resources[NUM_MMIO + NUM_IRQ];
  19. static u64 usbd_dmamask = DMA_BIT_MASK(32);
  20. static struct platform_device bcm63xx_usbd_device = {
  21. .name = "bcm63xx_udc",
  22. .id = -1,
  23. .num_resources = ARRAY_SIZE(usbd_resources),
  24. .resource = usbd_resources,
  25. .dev = {
  26. .dma_mask = &usbd_dmamask,
  27. .coherent_dma_mask = DMA_BIT_MASK(32),
  28. },
  29. };
  30. int __init bcm63xx_usbd_register(const struct bcm63xx_usbd_platform_data *pd)
  31. {
  32. const int irq_list[NUM_IRQ] = { IRQ_USBD,
  33. IRQ_USBD_RXDMA0, IRQ_USBD_TXDMA0,
  34. IRQ_USBD_RXDMA1, IRQ_USBD_TXDMA1,
  35. IRQ_USBD_RXDMA2, IRQ_USBD_TXDMA2 };
  36. int i;
  37. if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368())
  38. return 0;
  39. usbd_resources[0].start = bcm63xx_regset_address(RSET_USBD);
  40. usbd_resources[0].end = usbd_resources[0].start + RSET_USBD_SIZE - 1;
  41. usbd_resources[0].flags = IORESOURCE_MEM;
  42. usbd_resources[1].start = bcm63xx_regset_address(RSET_USBDMA);
  43. usbd_resources[1].end = usbd_resources[1].start + RSET_USBDMA_SIZE - 1;
  44. usbd_resources[1].flags = IORESOURCE_MEM;
  45. for (i = 0; i < NUM_IRQ; i++) {
  46. struct resource *r = &usbd_resources[NUM_MMIO + i];
  47. r->start = r->end = bcm63xx_get_irq_number(irq_list[i]);
  48. r->flags = IORESOURCE_IRQ;
  49. }
  50. platform_device_add_data(&bcm63xx_usbd_device, pd, sizeof(*pd));
  51. return platform_device_register(&bcm63xx_usbd_device);
  52. }