105-MIPS-BCM63XX-add-support-for-the-on-chip-OHCI-contro.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. From 30d22baef255c99a12c4858ce4ab0d45f0d8c9ae Mon Sep 17 00:00:00 2001
  2. From: Florian Fainelli <florian@openwrt.org>
  3. Date: Mon, 28 Jan 2013 20:06:24 +0100
  4. Subject: [PATCH 06/11] MIPS: BCM63XX: add support for the on-chip OHCI
  5. controller
  6. Broadcom BCM63XX SoCs include an on-chip OHCI controller which can be
  7. driven by the ohci-platform generic driver by using specific power
  8. on/off/suspend callback 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-ohci.c | 94 ++++++++++++++++++++
  15. .../asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h | 6 ++
  16. 3 files changed, 101 insertions(+), 1 deletion(-)
  17. create mode 100644 arch/mips/bcm63xx/dev-usb-ohci.c
  18. create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
  19. --- a/arch/mips/bcm63xx/Makefile
  20. +++ b/arch/mips/bcm63xx/Makefile
  21. @@ -1,7 +1,7 @@
  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-usbd.o usb-common.o
  26. + dev-wdt.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o
  27. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  28. obj-y += boards/
  29. --- /dev/null
  30. +++ b/arch/mips/bcm63xx/dev-usb-ohci.c
  31. @@ -0,0 +1,94 @@
  32. +/*
  33. + * This file is subject to the terms and conditions of the GNU General Public
  34. + * License. See the file "COPYING" in the main directory of this archive
  35. + * for more details.
  36. + *
  37. + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  38. + * Copyright (C) 2013 Florian Fainelli <florian@openwrt.org>
  39. + */
  40. +
  41. +#include <linux/init.h>
  42. +#include <linux/kernel.h>
  43. +#include <linux/platform_device.h>
  44. +#include <linux/usb/ohci_pdriver.h>
  45. +#include <linux/dma-mapping.h>
  46. +#include <linux/clk.h>
  47. +#include <linux/delay.h>
  48. +
  49. +#include <bcm63xx_cpu.h>
  50. +#include <bcm63xx_regs.h>
  51. +#include <bcm63xx_io.h>
  52. +#include <bcm63xx_usb_priv.h>
  53. +#include <bcm63xx_dev_usb_ohci.h>
  54. +
  55. +static struct resource ohci_resources[] = {
  56. + {
  57. + .start = -1, /* filled at runtime */
  58. + .end = -1, /* filled at runtime */
  59. + .flags = IORESOURCE_MEM,
  60. + },
  61. + {
  62. + .start = -1, /* filled at runtime */
  63. + .flags = IORESOURCE_IRQ,
  64. + },
  65. +};
  66. +
  67. +static u64 ohci_dmamask = DMA_BIT_MASK(32);
  68. +
  69. +static struct clk *usb_host_clock;
  70. +
  71. +static int bcm63xx_ohci_power_on(struct platform_device *pdev)
  72. +{
  73. + usb_host_clock = clk_get(&pdev->dev, "usbh");
  74. + if (IS_ERR_OR_NULL(usb_host_clock))
  75. + return -ENODEV;
  76. +
  77. + clk_prepare_enable(usb_host_clock);
  78. +
  79. + bcm63xx_usb_priv_ohci_cfg_set();
  80. +
  81. + return 0;
  82. +}
  83. +
  84. +static void bcm63xx_ohci_power_off(struct platform_device *pdev)
  85. +{
  86. + if (!IS_ERR_OR_NULL(usb_host_clock)) {
  87. + clk_disable_unprepare(usb_host_clock);
  88. + clk_put(usb_host_clock);
  89. + }
  90. +}
  91. +
  92. +static struct usb_ohci_pdata bcm63xx_ohci_pdata = {
  93. + .big_endian_desc = 1,
  94. + .big_endian_mmio = 1,
  95. + .no_big_frame_no = 1,
  96. + .num_ports = 1,
  97. + .power_on = bcm63xx_ohci_power_on,
  98. + .power_off = bcm63xx_ohci_power_off,
  99. + .power_suspend = bcm63xx_ohci_power_off,
  100. +};
  101. +
  102. +static struct platform_device bcm63xx_ohci_device = {
  103. + .name = "ohci-platform",
  104. + .id = -1,
  105. + .num_resources = ARRAY_SIZE(ohci_resources),
  106. + .resource = ohci_resources,
  107. + .dev = {
  108. + .platform_data = &bcm63xx_ohci_pdata,
  109. + .dma_mask = &ohci_dmamask,
  110. + .coherent_dma_mask = DMA_BIT_MASK(32),
  111. + },
  112. +};
  113. +
  114. +int __init bcm63xx_ohci_register(void)
  115. +{
  116. + if (BCMCPU_IS_6345() || BCMCPU_IS_6338())
  117. + return -ENODEV;
  118. +
  119. + ohci_resources[0].start = bcm63xx_regset_address(RSET_OHCI0);
  120. + ohci_resources[0].end = ohci_resources[0].start;
  121. + ohci_resources[0].end += RSET_OHCI_SIZE - 1;
  122. + ohci_resources[1].start = bcm63xx_get_irq_number(IRQ_OHCI0);
  123. +
  124. + return platform_device_register(&bcm63xx_ohci_device);
  125. +}
  126. --- /dev/null
  127. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
  128. @@ -0,0 +1,6 @@
  129. +#ifndef BCM63XX_DEV_USB_OHCI_H_
  130. +#define BCM63XX_DEV_USB_OHCI_H_
  131. +
  132. +int bcm63xx_ohci_register(void);
  133. +
  134. +#endif /* BCM63XX_DEV_USB_OHCI_H_ */