108-MIPS-BCM63XX-add-support-for-the-on-chip-EHCI-contro.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. From e38f13bd6408769c0b565bb1079024f496eee121 Mon Sep 17 00:00:00 2001
  2. From: Florian Fainelli <florian@openwrt.org>
  3. Date: Mon, 28 Jan 2013 20:06:27 +0100
  4. Subject: [PATCH 09/11] MIPS: BCM63XX: add support for the on-chip EHCI
  5. controller
  6. Broadcom BCM63XX SoCs include an on-chip EHCI controller which can be
  7. driven by the generic ehci-platform driver by using specific power
  8. on/off/suspend callbacks to manage clocks and hardware specific
  9. configuration.
  10. Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
  11. Signed-off-by: Florian Fainelli <florian@openwrt.org>
  12. ---
  13. arch/mips/bcm63xx/Makefile | 2 +-
  14. arch/mips/bcm63xx/dev-usb-ehci.c | 92 ++++++++++++++++++++
  15. .../asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h | 6 ++
  16. 3 files changed, 99 insertions(+), 1 deletion(-)
  17. create mode 100644 arch/mips/bcm63xx/dev-usb-ehci.c
  18. create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h
  19. --- a/arch/mips/bcm63xx/Makefile
  20. +++ b/arch/mips/bcm63xx/Makefile
  21. @@ -1,7 +1,8 @@
  22. obj-y += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \
  23. setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
  24. dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
  25. - dev-wdt.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o
  26. + dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \
  27. + usb-common.o
  28. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  29. obj-y += boards/
  30. --- /dev/null
  31. +++ b/arch/mips/bcm63xx/dev-usb-ehci.c
  32. @@ -0,0 +1,92 @@
  33. +/*
  34. + * This file is subject to the terms and conditions of the GNU General Public
  35. + * License. See the file "COPYING" in the main directory of this archive
  36. + * for more details.
  37. + *
  38. + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  39. + * Copyright (C) 2013 Florian Fainelli <florian@openwrt.org>
  40. + */
  41. +
  42. +#include <linux/init.h>
  43. +#include <linux/kernel.h>
  44. +#include <linux/platform_device.h>
  45. +#include <linux/clk.h>
  46. +#include <linux/delay.h>
  47. +#include <linux/usb/ehci_pdriver.h>
  48. +#include <linux/dma-mapping.h>
  49. +
  50. +#include <bcm63xx_cpu.h>
  51. +#include <bcm63xx_regs.h>
  52. +#include <bcm63xx_io.h>
  53. +#include <bcm63xx_usb_priv.h>
  54. +#include <bcm63xx_dev_usb_ehci.h>
  55. +
  56. +static struct resource ehci_resources[] = {
  57. + {
  58. + .start = -1, /* filled at runtime */
  59. + .end = -1, /* filled at runtime */
  60. + .flags = IORESOURCE_MEM,
  61. + },
  62. + {
  63. + .start = -1, /* filled at runtime */
  64. + .flags = IORESOURCE_IRQ,
  65. + },
  66. +};
  67. +
  68. +static u64 ehci_dmamask = DMA_BIT_MASK(32);
  69. +
  70. +static struct clk *usb_host_clock;
  71. +
  72. +static int bcm63xx_ehci_power_on(struct platform_device *pdev)
  73. +{
  74. + usb_host_clock = clk_get(&pdev->dev, "usbh");
  75. + if (IS_ERR_OR_NULL(usb_host_clock))
  76. + return -ENODEV;
  77. +
  78. + clk_prepare_enable(usb_host_clock);
  79. +
  80. + bcm63xx_usb_priv_ehci_cfg_set();
  81. +
  82. + return 0;
  83. +}
  84. +
  85. +static void bcm63xx_ehci_power_off(struct platform_device *pdev)
  86. +{
  87. + if (!IS_ERR_OR_NULL(usb_host_clock)) {
  88. + clk_disable_unprepare(usb_host_clock);
  89. + clk_put(usb_host_clock);
  90. + }
  91. +}
  92. +
  93. +static struct usb_ehci_pdata bcm63xx_ehci_pdata = {
  94. + .big_endian_desc = 1,
  95. + .big_endian_mmio = 1,
  96. + .power_on = bcm63xx_ehci_power_on,
  97. + .power_off = bcm63xx_ehci_power_off,
  98. + .power_suspend = bcm63xx_ehci_power_off,
  99. +};
  100. +
  101. +static struct platform_device bcm63xx_ehci_device = {
  102. + .name = "ehci-platform",
  103. + .id = -1,
  104. + .num_resources = ARRAY_SIZE(ehci_resources),
  105. + .resource = ehci_resources,
  106. + .dev = {
  107. + .platform_data = &bcm63xx_ehci_pdata,
  108. + .dma_mask = &ehci_dmamask,
  109. + .coherent_dma_mask = DMA_BIT_MASK(32),
  110. + },
  111. +};
  112. +
  113. +int __init bcm63xx_ehci_register(void)
  114. +{
  115. + if (!BCMCPU_IS_6328() && !BCMCPU_IS_6358() && !BCMCPU_IS_6362() && !BCMCPU_IS_6368())
  116. + return 0;
  117. +
  118. + ehci_resources[0].start = bcm63xx_regset_address(RSET_EHCI0);
  119. + ehci_resources[0].end = ehci_resources[0].start;
  120. + ehci_resources[0].end += RSET_EHCI_SIZE - 1;
  121. + ehci_resources[1].start = bcm63xx_get_irq_number(IRQ_EHCI0);
  122. +
  123. + return platform_device_register(&bcm63xx_ehci_device);
  124. +}
  125. --- /dev/null
  126. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h
  127. @@ -0,0 +1,6 @@
  128. +#ifndef BCM63XX_DEV_USB_EHCI_H_
  129. +#define BCM63XX_DEV_USB_EHCI_H_
  130. +
  131. +int bcm63xx_ehci_register(void);
  132. +
  133. +#endif /* BCM63XX_DEV_USB_EHCI_H_ */