Skip to content

Commit 61a7cbb

Browse files
P33Mpopcornmix
authored andcommitted
dwc_otg: fiq_fsm: Base commit for driver rewrite
This commit removes the previous FIQ fixes entirely and adds fiq_fsm. This rewrite features much more complete support for split transactions and takes into account several OTG hardware bugs. High-speed isochronous transactions are also capable of being performed by fiq_fsm. All driver options have been removed and replaced with: - dwc_otg.fiq_enable (bool) - dwc_otg.fiq_fsm_enable (bool) - dwc_otg.fiq_fsm_mask (bitmask) - dwc_otg.nak_holdoff (unsigned int) Defaults are specified such that fiq_fsm behaves similarly to the previously implemented FIQ fixes.
1 parent b4c145b commit 61a7cbb

14 files changed

Lines changed: 2865 additions & 950 deletions

‎arch/arm/mach-bcm2708/bcm2708.c‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -328,20 +328,6 @@ static struct resource bcm2708_usb_resources[] = {
328328
},
329329
};
330330

331-
bool fiq_fix_enable = true;
332-
333-
static struct resource bcm2708_usb_resources_no_fiq_fix[] = {
334-
[0] = {
335-
.start = USB_BASE,
336-
.end = USB_BASE + SZ_128K - 1,
337-
.flags = IORESOURCE_MEM,
338-
},
339-
[1] = {
340-
.start = IRQ_USB,
341-
.end = IRQ_USB,
342-
.flags = IORESOURCE_IRQ,
343-
},
344-
};
345331

346332
static u64 usb_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
347333

@@ -724,11 +710,6 @@ void __init bcm2708_init(void)
724710
#endif
725711
bcm_register_device(&bcm2708_systemtimer_device);
726712
bcm_register_device(&bcm2708_fb_device);
727-
if (!fiq_fix_enable)
728-
{
729-
bcm2708_usb_device.resource = bcm2708_usb_resources_no_fiq_fix;
730-
bcm2708_usb_device.num_resources = ARRAY_SIZE(bcm2708_usb_resources_no_fiq_fix);
731-
}
732713
bcm_register_device(&bcm2708_usb_device);
733714
bcm_register_device(&bcm2708_uart1_device);
734715
bcm_register_device(&bcm2708_powerman_device);

‎drivers/usb/host/dwc_otg/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ dwc_otg-objs += dwc_otg_cil.o dwc_otg_cil_intr.o
3636
dwc_otg-objs += dwc_otg_pcd_linux.o dwc_otg_pcd.o dwc_otg_pcd_intr.o
3737
dwc_otg-objs += dwc_otg_hcd.o dwc_otg_hcd_linux.o dwc_otg_hcd_intr.o dwc_otg_hcd_queue.o dwc_otg_hcd_ddma.o
3838
dwc_otg-objs += dwc_otg_adp.o
39-
dwc_otg-objs += dwc_otg_mphi_fix.o
39+
dwc_otg-objs += dwc_otg_fiq_fsm.o
40+
dwc_otg-objs += dwc_otg_fiq_stub.o
4041
ifneq ($(CFI),)
4142
dwc_otg-objs += dwc_otg_cfi.o
4243
endif

‎drivers/usb/host/dwc_otg/dwc_otg_cil_intr.c‎

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include "dwc_otg_driver.h"
4646
#include "dwc_otg_pcd.h"
4747
#include "dwc_otg_hcd.h"
48-
#include "dwc_otg_mphi_fix.h"
4948

5049
#ifdef DEBUG
5150
inline const char *op_state_str(dwc_otg_core_if_t * core_if)
@@ -1319,7 +1318,7 @@ static int32_t dwc_otg_handle_lpm_intr(dwc_otg_core_if_t * core_if)
13191318
/**
13201319
* This function returns the Core Interrupt register.
13211320
*/
1322-
static inline uint32_t dwc_otg_read_common_intr(dwc_otg_core_if_t * core_if, gintmsk_data_t *reenable_gintmsk)
1321+
static inline uint32_t dwc_otg_read_common_intr(dwc_otg_core_if_t * core_if, gintmsk_data_t *reenable_gintmsk, dwc_otg_hcd_t *hcd)
13231322
{
13241323
gahbcfg_data_t gahbcfg = {.d32 = 0 };
13251324
gintsts_data_t gintsts;
@@ -1345,16 +1344,15 @@ static inline uint32_t dwc_otg_read_common_intr(dwc_otg_core_if_t * core_if, gin
13451344
}
13461345
gintsts.d32 = DWC_READ_REG32(&core_if->core_global_regs->gintsts);
13471346
gintmsk.d32 = DWC_READ_REG32(&core_if->core_global_regs->gintmsk);
1348-
{
1349-
unsigned long flags;
1350-
1351-
// Re-enable the saved interrupts
1352-
local_irq_save(flags);
1347+
if(fiq_enable) {
13531348
local_fiq_disable();
1354-
gintmsk.d32 |= gintmsk_common.d32;
1355-
gintsts_saved.d32 &= ~gintmsk_common.d32;
1356-
reenable_gintmsk->d32 = gintmsk.d32;
1357-
local_irq_restore(flags);
1349+
/* Pull in the interrupts that the FIQ has masked */
1350+
gintmsk.d32 |= ~(hcd->fiq_state->gintmsk_saved.d32);
1351+
/* for the upstairs function to reenable - have to read it here in case FIQ triggers again */
1352+
reenable_gintmsk->d32 |= gintmsk.d32;
1353+
reenable_gintmsk->d32 |= ~(hcd->fiq_state->gintmsk_saved.d32);
1354+
reenable_gintmsk->d32 &= gintmsk_common.d32;
1355+
local_fiq_enable();
13581356
}
13591357

13601358
gahbcfg.d32 = DWC_READ_REG32(&core_if->core_global_regs->gahbcfg);
@@ -1366,13 +1364,15 @@ static inline uint32_t dwc_otg_read_common_intr(dwc_otg_core_if_t * core_if, gin
13661364
gintsts.d32, gintmsk.d32);
13671365
}
13681366
#endif
1369-
if (!fiq_fix_enable){
1367+
if (!fiq_enable){
13701368
if (gahbcfg.b.glblintrmsk)
13711369
return ((gintsts.d32 & gintmsk.d32) & gintmsk_common.d32);
13721370
else
13731371
return 0;
1374-
}
1375-
else {
1372+
} else {
1373+
/* Our IRQ kicker is no longer the USB hardware, it's the MPHI interface.
1374+
* Can't trust the global interrupt mask bit in this case.
1375+
*/
13761376
return ((gintsts.d32 & gintmsk.d32) & gintmsk_common.d32);
13771377
}
13781378

@@ -1406,7 +1406,7 @@ int32_t dwc_otg_handle_common_intr(void *dev)
14061406
{
14071407
int retval = 0;
14081408
gintsts_data_t gintsts;
1409-
gintmsk_data_t reenable_gintmsk;
1409+
gintmsk_data_t gintmsk_reenable = { .d32 = 0 };
14101410
gpwrdn_data_t gpwrdn = {.d32 = 0 };
14111411
dwc_otg_device_t *otg_dev = dev;
14121412
dwc_otg_core_if_t *core_if = otg_dev->core_if;
@@ -1428,7 +1428,10 @@ int32_t dwc_otg_handle_common_intr(void *dev)
14281428
}
14291429

14301430
if (core_if->hibernation_suspend <= 0) {
1431-
gintsts.d32 = dwc_otg_read_common_intr(core_if, &reenable_gintmsk);
1431+
/* read_common will have to poke the FIQ's saved mask. We must then clear this mask at the end
1432+
* of this handler - god only knows why it's done like this
1433+
*/
1434+
gintsts.d32 = dwc_otg_read_common_intr(core_if, &gintmsk_reenable, otg_dev->hcd);
14321435

14331436
if (gintsts.b.modemismatch) {
14341437
retval |= dwc_otg_handle_mode_mismatch_intr(core_if);
@@ -1525,11 +1528,16 @@ int32_t dwc_otg_handle_common_intr(void *dev)
15251528
gintsts.b.portintr = 1;
15261529
DWC_WRITE_REG32(&core_if->core_global_regs->gintsts,gintsts.d32);
15271530
retval |= 1;
1528-
reenable_gintmsk.b.portintr = 1;
1531+
gintmsk_reenable.b.portintr = 1;
15291532

15301533
}
1531-
1532-
DWC_WRITE_REG32(&core_if->core_global_regs->gintmsk, reenable_gintmsk.d32);
1534+
/* Did we actually handle anything? if so, unmask the interrupt */
1535+
// fiq_print(FIQDBG_INT, otg_dev->hcd->fiq_state, "CILOUT %1d", retval);
1536+
// fiq_print(FIQDBG_INT, otg_dev->hcd->fiq_state, "%08x", gintsts.d32);
1537+
// fiq_print(FIQDBG_INT, otg_dev->hcd->fiq_state, "%08x", gintmsk_reenable.d32);
1538+
if (retval) {
1539+
DWC_WRITE_REG32(&core_if->core_global_regs->gintmsk, gintmsk_reenable.d32);
1540+
}
15331541

15341542
} else {
15351543
DWC_DEBUGPL(DBG_ANY, "gpwrdn=%08x\n", gpwrdn.d32);
@@ -1583,6 +1591,5 @@ int32_t dwc_otg_handle_common_intr(void *dev)
15831591
}
15841592
if (core_if->lock)
15851593
DWC_SPINUNLOCK(core_if->lock);
1586-
15871594
return retval;
15881595
}

‎drivers/usb/host/dwc_otg/dwc_otg_driver.c‎

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "dwc_otg_core_if.h"
5757
#include "dwc_otg_pcd_if.h"
5858
#include "dwc_otg_hcd_if.h"
59+
#include "dwc_otg_fiq_fsm.h"
5960

6061
#define DWC_DRIVER_VERSION "3.00a 10-AUG-2012"
6162
#define DWC_DRIVER_DESC "HS OTG USB Controller driver"
@@ -64,7 +65,6 @@ bool microframe_schedule=true;
6465

6566
static const char dwc_driver_name[] = "dwc_otg";
6667

67-
extern void* dummy_send;
6868

6969
extern int pcd_init(
7070
#ifdef LM_INTERFACE
@@ -240,13 +240,14 @@ static struct dwc_otg_driver_module_params dwc_otg_module_params = {
240240
.adp_enable = -1,
241241
};
242242

243-
//Global variable to switch the fiq fix on or off (declared in bcm2708.c)
244-
extern bool fiq_fix_enable;
243+
//Global variable to switch the fiq fix on or off
244+
bool fiq_enable = 1;
245245
// Global variable to enable the split transaction fix
246-
bool fiq_split_enable = true;
247-
//Global variable to switch the nak holdoff on or off
248-
bool nak_holdoff_enable = true;
246+
bool fiq_fsm_enable = false;
247+
//Bulk split-transaction NAK holdoff in microframes
248+
uint16_t nak_holdoff = 8;
249249

250+
unsigned short fiq_fsm_mask = 0x01;
250251

251252
/**
252253
* This function shows the Driver Version.
@@ -800,7 +801,7 @@ static int dwc_otg_driver_probe(
800801
dwc_otg_device->os_dep.base = ioremap_nocache(_dev->resource[0].start,
801802
_dev->resource[0].end -
802803
_dev->resource[0].start+1);
803-
if (fiq_fix_enable)
804+
if (fiq_enable)
804805
{
805806
if (!request_mem_region(_dev->resource[1].start,
806807
_dev->resource[1].end - _dev->resource[1].start + 1,
@@ -813,7 +814,6 @@ static int dwc_otg_driver_probe(
813814
dwc_otg_device->os_dep.mphi_base = ioremap_nocache(_dev->resource[1].start,
814815
_dev->resource[1].end -
815816
_dev->resource[1].start + 1);
816-
dummy_send = (void *) kmalloc(16, GFP_ATOMIC);
817817
}
818818

819819
#else
@@ -1071,9 +1071,9 @@ static int __init dwc_otg_driver_init(void)
10711071
int error;
10721072
struct device_driver *drv;
10731073

1074-
if(fiq_split_enable && !fiq_fix_enable) {
1075-
printk(KERN_WARNING "dwc_otg: fiq_split_enable was set without fiq_fix_enable! Correcting.\n");
1076-
fiq_fix_enable = 1;
1074+
if(fiq_fsm_enable && !fiq_enable) {
1075+
printk(KERN_WARNING "dwc_otg: fiq_fsm_enable was set without fiq_enable! Correcting.\n");
1076+
fiq_enable = 1;
10771077
}
10781078

10791079
printk(KERN_INFO "%s: version %s (%s bus)\n", dwc_driver_name,
@@ -1095,9 +1095,9 @@ static int __init dwc_otg_driver_init(void)
10951095
printk(KERN_ERR "%s retval=%d\n", __func__, retval);
10961096
return retval;
10971097
}
1098-
printk(KERN_DEBUG "dwc_otg: FIQ %s\n", fiq_fix_enable ? "enabled":"disabled");
1099-
printk(KERN_DEBUG "dwc_otg: NAK holdoff %s\n", nak_holdoff_enable ? "enabled":"disabled");
1100-
printk(KERN_DEBUG "dwc_otg: FIQ split fix %s\n", fiq_split_enable ? "enabled":"disabled");
1098+
printk(KERN_DEBUG "dwc_otg: FIQ %s\n", fiq_enable ? "enabled":"disabled");
1099+
printk(KERN_DEBUG "dwc_otg: NAK holdoff %s\n", nak_holdoff ? "enabled":"disabled");
1100+
printk(KERN_DEBUG "dwc_otg: FIQ split-transaction FSM %s\n", fiq_fsm_enable ? "enabled":"disabled");
11011101

11021102
error = driver_create_file(drv, &driver_attr_version);
11031103
#ifdef DEBUG
@@ -1378,12 +1378,19 @@ MODULE_PARM_DESC(otg_ver, "OTG revision supported 0=OTG 1.3 1=OTG 2.0");
13781378
module_param(microframe_schedule, bool, 0444);
13791379
MODULE_PARM_DESC(microframe_schedule, "Enable the microframe scheduler");
13801380

1381-
module_param(fiq_fix_enable, bool, 0444);
1382-
MODULE_PARM_DESC(fiq_fix_enable, "Enable the fiq fix");
1383-
module_param(nak_holdoff_enable, bool, 0444);
1384-
MODULE_PARM_DESC(nak_holdoff_enable, "Enable the NAK holdoff");
1385-
module_param(fiq_split_enable, bool, 0444);
1386-
MODULE_PARM_DESC(fiq_split_enable, "Enable the FIQ fix on split transactions");
1381+
module_param(fiq_enable, bool, 0444);
1382+
MODULE_PARM_DESC(fiq_enable, "Enable the FIQ");
1383+
module_param(nak_holdoff, ushort, 0644);
1384+
MODULE_PARM_DESC(nak_holdoff, "Throttle duration for bulk split-transaction endpoints on a NAK. Default 8");
1385+
module_param(fiq_fsm_enable, bool, 0444);
1386+
MODULE_PARM_DESC(fiq_fsm_enable, "Enable the FIQ to perform split transactions as defined by fiq_fsm_mask");
1387+
module_param(fiq_fsm_mask, ushort, 0444);
1388+
MODULE_PARM_DESC(fiq_fsm_mask, "Bitmask of transactions to perform in the FIQ.\n"
1389+
"Bit 0 : Non-periodic split transactions\n"
1390+
"Bit 1 : Periodic split transactions\n"
1391+
"Bit 2 : High-speed multi-transfer isochronous\n"
1392+
"All other bits should be set 0.");
1393+
13871394

13881395
/** @page "Module Parameters"
13891396
*

0 commit comments

Comments
 (0)