130-usb-ehci-fot2g.patch 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. --- a/arch/arm/mach-gemini/devices.c
  2. +++ b/arch/arm/mach-gemini/devices.c
  3. @@ -188,3 +188,64 @@ int platform_register_ethernet(struct ge
  4. return platform_device_register(&ethernet_device);
  5. }
  6. +
  7. +static struct resource usb0_resources[] = {
  8. + {
  9. + .start = GEMINI_USB0_BASE,
  10. + .end = GEMINI_USB0_BASE + 0xfff,
  11. + .flags = IORESOURCE_MEM,
  12. + },
  13. + {
  14. + .start = IRQ_USB0,
  15. + .end = IRQ_USB0,
  16. + .flags = IORESOURCE_IRQ,
  17. + },
  18. +};
  19. +
  20. +static struct resource usb1_resources[] = {
  21. + {
  22. + .start = GEMINI_USB1_BASE,
  23. + .end = GEMINI_USB1_BASE + 0xfff,
  24. + .flags = IORESOURCE_MEM,
  25. + },
  26. + {
  27. + .start = IRQ_USB1,
  28. + .end = IRQ_USB1,
  29. + .flags = IORESOURCE_IRQ,
  30. + },
  31. +};
  32. +
  33. +static u64 usb0_dmamask = 0xffffffffUL;
  34. +static u64 usb1_dmamask = 0xffffffffUL;
  35. +
  36. +static struct platform_device usb_device[] = {
  37. + {
  38. + .name = "ehci-fotg2",
  39. + .id = 0,
  40. + .dev = {
  41. + .dma_mask = &usb0_dmamask,
  42. + .coherent_dma_mask = 0xffffffff,
  43. + },
  44. + .num_resources = ARRAY_SIZE(usb0_resources),
  45. + .resource = usb0_resources,
  46. + },
  47. + {
  48. + .name = "ehci-fotg2",
  49. + .id = 1,
  50. + .dev = {
  51. + .dma_mask = &usb1_dmamask,
  52. + .coherent_dma_mask = 0xffffffff,
  53. + },
  54. + .num_resources = ARRAY_SIZE(usb1_resources),
  55. + .resource = usb1_resources,
  56. + },
  57. +};
  58. +
  59. +int __init platform_register_usb(unsigned int id)
  60. +{
  61. + if (id > 1)
  62. + return -EINVAL;
  63. +
  64. + return platform_device_register(&usb_device[id]);
  65. +}
  66. +
  67. --- a/arch/arm/mach-gemini/common.h
  68. +++ b/arch/arm/mach-gemini/common.h
  69. @@ -28,6 +28,7 @@ extern int platform_register_pflash(unsi
  70. unsigned int nr_parts);
  71. extern int platform_register_watchdog(void);
  72. extern int platform_register_ethernet(struct gemini_gmac_platform_data *pdata);
  73. +extern int platform_register_usb(unsigned int id);
  74. extern void gemini_restart(enum reboot_mode mode, const char *cmd);
  75. --- a/drivers/usb/host/ehci-hcd.c
  76. +++ b/drivers/usb/host/ehci-hcd.c
  77. @@ -346,11 +346,13 @@ static void ehci_silence_controller(stru
  78. ehci->rh_state = EHCI_RH_HALTED;
  79. ehci_turn_off_all_ports(ehci);
  80. +#ifndef CONFIG_ARCH_GEMINI
  81. /* make BIOS/etc use companion controller during reboot */
  82. ehci_writel(ehci, 0, &ehci->regs->configured_flag);
  83. /* unblock posted writes */
  84. ehci_readl(ehci, &ehci->regs->configured_flag);
  85. +#endif
  86. spin_unlock_irq(&ehci->lock);
  87. }
  88. @@ -602,7 +604,9 @@ static int ehci_run (struct usb_hcd *hcd
  89. // Philips, Intel, and maybe others need CMD_RUN before the
  90. // root hub will detect new devices (why?); NEC doesn't
  91. ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
  92. +#ifndef CONFIG_ARCH_GEMINI
  93. ehci->command |= CMD_RUN;
  94. +#endif
  95. ehci_writel(ehci, ehci->command, &ehci->regs->command);
  96. dbg_cmd (ehci, "init", ehci->command);
  97. @@ -622,9 +626,11 @@ static int ehci_run (struct usb_hcd *hcd
  98. */
  99. down_write(&ehci_cf_port_reset_rwsem);
  100. ehci->rh_state = EHCI_RH_RUNNING;
  101. +#ifndef CONFIG_ARCH_GEMINI
  102. ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
  103. ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
  104. msleep(5);
  105. +#endif
  106. up_write(&ehci_cf_port_reset_rwsem);
  107. ehci->last_periodic_enable = ktime_get_real();
  108. @@ -762,9 +768,10 @@ static irqreturn_t ehci_irq (struct usb_
  109. pcd_status = status;
  110. /* resume root hub? */
  111. +#ifndef CONFIG_ARCH_GEMINI
  112. if (ehci->rh_state == EHCI_RH_SUSPENDED)
  113. usb_hcd_resume_root_hub(hcd);
  114. -
  115. +#endif
  116. /* get per-port change detect bits */
  117. if (ehci->has_ppcd)
  118. ppcd = status >> 16;
  119. @@ -1243,6 +1250,11 @@ MODULE_DESCRIPTION(DRIVER_DESC);
  120. MODULE_AUTHOR (DRIVER_AUTHOR);
  121. MODULE_LICENSE ("GPL");
  122. +#ifdef CONFIG_ARCH_GEMINI
  123. +#include "ehci-fotg2.c"
  124. +#define PLATFORM_DRIVER ehci_fotg2_driver
  125. +#endif
  126. +
  127. #ifdef CONFIG_USB_EHCI_FSL
  128. #include "ehci-fsl.c"
  129. #define PLATFORM_DRIVER ehci_fsl_driver
  130. --- a/drivers/usb/host/ehci-timer.c
  131. +++ b/drivers/usb/host/ehci-timer.c
  132. @@ -208,7 +208,9 @@ static void ehci_handle_controller_death
  133. /* Clean up the mess */
  134. ehci->rh_state = EHCI_RH_HALTED;
  135. +#ifndef CONFIG_ARCH_GEMINI
  136. ehci_writel(ehci, 0, &ehci->regs->configured_flag);
  137. +#endif
  138. ehci_writel(ehci, 0, &ehci->regs->intr_enable);
  139. ehci_work(ehci);
  140. end_unlink_async(ehci);
  141. --- a/drivers/usb/host/ehci.h
  142. +++ b/drivers/usb/host/ehci.h
  143. @@ -656,7 +656,12 @@ static inline unsigned int
  144. ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
  145. {
  146. if (ehci_is_TDI(ehci)) {
  147. - switch ((portsc >> (ehci->has_hostpc ? 25 : 26)) & 3) {
  148. +#ifdef CONFIG_ARCH_GEMINI
  149. + portsc = readl(ehci_to_hcd(ehci)->regs + 0x80);
  150. + switch ((portsc>>22)&3) {
  151. +#else
  152. + switch ((portsc>>26)&3) {
  153. +#endif
  154. case 0:
  155. return 0;
  156. case 1:
  157. --- a/drivers/usb/host/ehci-hub.c
  158. +++ b/drivers/usb/host/ehci-hub.c
  159. @@ -1075,6 +1075,11 @@ int ehci_hub_control(
  160. /* see what we found out */
  161. temp = check_reset_complete (ehci, wIndex, status_reg,
  162. ehci_readl(ehci, status_reg));
  163. +#ifdef CONFIG_ARCH_GEMINI
  164. + /* restart schedule */
  165. + ehci->command |= CMD_RUN;
  166. + ehci_writel(ehci, ehci->command, &ehci->regs->command);
  167. +#endif
  168. }
  169. /* transfer dedicated ports to the companion hc */
  170. --- a/include/linux/usb/ehci_def.h
  171. +++ b/include/linux/usb/ehci_def.h
  172. @@ -110,8 +110,13 @@ struct ehci_regs {
  173. u32 frame_list; /* points to periodic list */
  174. /* ASYNCLISTADDR: offset 0x18 */
  175. u32 async_next; /* address of next async queue head */
  176. -
  177. +#ifndef CONFIG_ARCH_GEMINI
  178. u32 reserved1[2];
  179. +#else
  180. + u32 reserved1;
  181. + /* PORTSC: offset 0x20 for Faraday OTG */
  182. + u32 port_status[1];
  183. +#endif
  184. /* TXFILLTUNING: offset 0x24 */
  185. u32 txfill_tuning; /* TX FIFO Tuning register */
  186. @@ -123,8 +128,11 @@ struct ehci_regs {
  187. u32 configured_flag;
  188. #define FLAG_CF (1<<0) /* true: we'll support "high speed" */
  189. +#ifndef CONFIG_ARCH_GEMINI
  190. /* PORTSC: offset 0x44 */
  191. u32 port_status[0]; /* up to N_PORTS */
  192. +#endif
  193. +
  194. /* EHCI 1.1 addendum */
  195. #define PORTSC_SUSPEND_STS_ACK 0
  196. #define PORTSC_SUSPEND_STS_NYET 1