4d7a95d66c76b8a0a615d75385d57f6c0138729b
[openwrt/staging/dedeckeh.git] / target / linux / brcm2708 / patches-3.18 / 0046-fiq_fsm-Implement-hack-for-Split-Interrupt-transacti.patch
1 From 099581aeb11b7eafbca02c9e69f6e6c8de0c57ec Mon Sep 17 00:00:00 2001
2 From: P33M <P33M@github.com>
3 Date: Fri, 20 Jun 2014 17:23:20 +0100
4 Subject: [PATCH 046/114] fiq_fsm: Implement hack for Split Interrupt
5 transactions
6
7 Hubs aren't too picky about which endpoint we send Control type split
8 transactions to. By treating Interrupt transfers as Control, it is
9 possible to use the non-periodic queue in the OTG core as well as the
10 non-periodic FIFOs in the hub itself. This massively reduces the
11 microframe exclusivity/contention that periodic split transactions
12 otherwise have to enforce.
13
14 It goes without saying that this is a fairly egregious USB specification
15 violation, but it works.
16
17 Original idea by Hans Petter Selasky @ FreeBSD.org.
18 ---
19 drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 32 ++++++++++++++++++++++++++------
20 1 file changed, 26 insertions(+), 6 deletions(-)
21
22 diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c
23 index 130096b..68d4f3b 100644
24 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c
25 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c
26 @@ -1055,10 +1055,11 @@ int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if)
27 for (i=0; i < hcd->core_if->core_params->host_channels; i++) {
28 dwc_otg_cleanup_fiq_channel(hcd, i);
29 }
30 - DWC_PRINTF("FIQ FSM acceleration enabled for :\n%s%s%s",
31 + DWC_PRINTF("FIQ FSM acceleration enabled for :\n%s%s%s%s",
32 (fiq_fsm_mask & 0x1) ? "Non-periodic Split Transactions\n" : "",
33 (fiq_fsm_mask & 0x2) ? "Periodic Split Transactions\n" : "",
34 - (fiq_fsm_mask & 0x4) ? "High-Speed Isochronous Endpoints\n" : "");
35 + (fiq_fsm_mask & 0x4) ? "High-Speed Isochronous Endpoints\n" : "",
36 + (fiq_fsm_mask & 0x8) ? "Interrupt/Control Split Transaction hack enabled\n" : "");
37 }
38 }
39
40 @@ -1789,6 +1790,20 @@ int fiq_fsm_queue_split_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
41 st->hcintmsk_copy.b.chhltd = 1;
42 st->hcintmsk_copy.b.ahberr = 1;
43
44 + /* Hack courtesy of FreeBSD: apparently forcing Interrupt Split transactions
45 + * as Control puts the transfer into the non-periodic request queue and the
46 + * non-periodic handler in the hub. Makes things lots easier.
47 + */
48 + if ((fiq_fsm_mask & 0x8) && hc->ep_type == UE_INTERRUPT) {
49 + st->hcchar_copy.b.multicnt = 0;
50 + st->hcchar_copy.b.oddfrm = 0;
51 + st->hcchar_copy.b.eptype = UE_CONTROL;
52 + if (hc->align_buff) {
53 + st->hcdma_copy.d32 = hc->align_buff;
54 + } else {
55 + st->hcdma_copy.d32 = ((unsigned long) hc->xfer_buff & 0xFFFFFFFF);
56 + }
57 + }
58 DWC_WRITE_REG32(&hc_regs->hcdma, st->hcdma_copy.d32);
59 DWC_WRITE_REG32(&hc_regs->hctsiz, st->hctsiz_copy.d32);
60 DWC_WRITE_REG32(&hc_regs->hcsplt, st->hcsplt_copy.d32);
61 @@ -1842,6 +1857,9 @@ int fiq_fsm_queue_split_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
62 }
63 }
64 }
65 + if ((fiq_fsm_mask & 0x8) && hc->ep_type == UE_INTERRUPT)
66 + start_immediate = 1;
67 +
68 fiq_print(FIQDBG_INT, hcd->fiq_state, "FSMQ %01d %01d", hc->hc_num, start_immediate);
69 fiq_print(FIQDBG_INT, hcd->fiq_state, "%08d", hfnum.b.frrem);
70 //fiq_print(FIQDBG_INT, hcd->fiq_state, "H:%02dP:%02d", hub_addr, port_addr);
71 @@ -1873,11 +1891,13 @@ int fiq_fsm_queue_split_transaction(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
72 }
73 break;
74 case UE_INTERRUPT:
75 - if (start_immediate) {
76 + if (fiq_fsm_mask & 0x8) {
77 + st->fsm = FIQ_NP_SSPLIT_STARTED;
78 + } else if (start_immediate) {
79 st->fsm = FIQ_PER_SSPLIT_STARTED;
80 - } else {
81 - st->fsm = FIQ_PER_SSPLIT_QUEUED;
82 - }
83 + } else {
84 + st->fsm = FIQ_PER_SSPLIT_QUEUED;
85 + }
86 default:
87 break;
88 }
89 --
90 1.8.3.2
91