Commit Graph

3282 Commits

Author SHA1 Message Date
Hans Petter Selasky
dd5a01badc Add basic support for isochronous transfers in host mode to the
ISP/SAF1761 driver.

Sponsored by:	DARPA, AFRL
2014-06-01 10:22:18 +00:00
Hans Petter Selasky
4be86ee126 It appears the ISP/SAF1761 sometimes is busy when reading the status
word of the PTD and simply returns a value of zero. Retry a few times
before giving up.

Sponsored by:	DARPA, AFRL
2014-05-30 16:44:03 +00:00
Hans Petter Selasky
ce19294c0e Make driver detach code in USB mass storage test optional.
Sponsored by:	DARPA, AFRL
2014-05-30 13:45:20 +00:00
Hans Petter Selasky
74c1f36628 Add ISP/SAF1761 bootloader bus interface file.
Sponsored by:	DARPA, AFRL
2014-05-30 13:42:11 +00:00
Hans Petter Selasky
e045de0740 Add support for basic read, write and read capacity disk operations to
the USB mass storage test utility file.

Sponsored by:	DARPA, AFRL
2014-05-30 07:30:24 +00:00
Hans Petter Selasky
2994bac4ba Add some more spinlocks to protect the state of the USB transfer
queue. Rename some functions to indicate locking requirements.

MFC after:	1 week
2014-05-29 11:11:19 +00:00
Hans Petter Selasky
0b4dc07df8 Hook the ISP/SAF1761 driver into MIPS kernel builds.
- Update FDT file for BERI DE4 boards.
- Add needed kernel configuration keywords.
- Rename module to saf1761otg so that the device unit number does not
interfere with the hardware ID in dmesg.

Sponsored by:	DARPA, AFRL
2014-05-29 10:46:09 +00:00
Hans Petter Selasky
580bc2220a Optimise the ISP/SAF1761 driver:
- Use an interrupt filter for handling the data path interrupts. This
increases the throughput significantly.
- Implement support for USB suspend and resume in USB host mode.

Sponsored by:	DARPA, AFRL
2014-05-29 10:06:18 +00:00
Hans Petter Selasky
4272b84663 Fixes for ISP/SAF1761 host mode:
- Make the USB hardware skip PTDs which are not allocated.
- Peek host memory twice. Sometimes the PTD status is incorrectly
returned as zero.
- Ensure the host channel is always freed when software TD
is completing.
- Add correct configuration of interrupt polarity and type.
- Set CERR to 2 for asynchronous traffic to avoid having to
reactivate the PTD when a NAK token is received.
- Fix detection of STALL PID.

Sponsored by:	DARPA, AFRL
2014-05-28 16:28:22 +00:00
Hans Petter Selasky
6df8a79713 - Correct bus space resource type for register access.
- Add configuration of interrupt type and polarity via FDT.

Sponsored by:	DARPA, AFRL
2014-05-27 10:12:16 +00:00
Hans Petter Selasky
21c85d9d3b Multiple fixes and improvements:
- Put "_LE_" into the register access macros to indicate little endian
byte order is expected by the hardware.
- Avoid using the bounce buffer when not strictly needed. Try to move
data directly using bus-space functions first.
- Ensure we preserve the reserved bits in the power down mode
register. Else the hardware goes into a non-recoverable state.
- Always use 32-bit access when writing or reading registers or FIFOs,
because the hardware is 32-bit oriented and don't really understand 8-
and 16-bit access.
- Correct writes to the memory address register. There is no need to
shift the register offset.
- Correct interval for interrupt endpoints.
- Optimise 90ns internal memory buffer read delay.
- Rename PDT into PTD, which is how the datasheet writes it.
- Add missing programming for activating host controller PTDs.

Sponsored by:	DARPA, AFRL
2014-05-27 10:01:19 +00:00
Kevin Lo
d32048bb6d - Improve performance by fixing incorrect Rx/Tx handling
- Rename definition of AXGE_* to reflect reality
- Add new USB IDs
2014-05-27 08:14:54 +00:00
Kevin Lo
26c79a7652 Remove r264317 by accident.
Spotted by:	Kuan-Chung Chiu
2014-05-27 01:47:23 +00:00
Hans Petter Selasky
3bee4e7bdb Make SAF1761 driver endian safe.
Sponsored by:	DARPA, AFRL
2014-05-25 06:42:43 +00:00
Hans Petter Selasky
1593e8754e - Give firmware loading more time.
MFC after:	3 days
2014-05-22 12:01:43 +00:00
Hans Petter Selasky
c73bbf989d - Fix a bug where the TLBPC value was forced to being odd for IN
direction isochronous transfers.
- Remove setting of fields which does not belong to the respective
TRBs. These fields are currently set as zero and this is more a
cosmetic change.

MFC after:	3 days
Submitted by:	Horse Ma <HMa@wyse.com>
2014-05-22 11:58:15 +00:00
Hans Petter Selasky
885476cb9a - Stop transfers when RSU init fails.
- Make sure TX/RX lists don't leak and are only allocated once.
- Fix off-by one transfer index computation.
- Give firmware loading more time.

MFC after:	3 days
2014-05-22 06:28:09 +00:00
Hans Petter Selasky
8e14e4a03a Implement interrupt endpoint methods for host mode transfers.
Sponsored by:	DARPA, AFRL
2014-05-21 17:22:41 +00:00
Hans Petter Selasky
400b4e53bd - Split transmit queue into one for each type. Apparently there will
be a race when using a single active queue for all transmit types.
- Last argument of usb_pause_mtx() is ticks and not milliseconds.
- Remove unused watchdog.
- Remove some unused fields from the RSU softc structure.
- Workaround usbd_transfer_start() recursion from inside of completion
callback.

MFC after:	3 days
2014-05-21 16:52:55 +00:00
Hans Petter Selasky
c13c64fa63 - Replace some constants with macros.
- Need to set the pre-fetch memory address when reading the host memory.
- We currently assume that no endianness conversion is needed.

Sponsored by:	DARPA, AFRL
2014-05-21 09:26:02 +00:00
Kevin Lo
61c067adc3 - Configure Rx bulk
- Announce flow control capability to PHY drivers
2014-05-21 08:09:44 +00:00
Hans Petter Selasky
302a703b5b Avoid starting a USB transfer inside the callback function, right
after its been submitted.

MFC after:	3 days
2014-05-21 06:23:52 +00:00
Hans Petter Selasky
aff6e94558 - The DELAY() should not be used in USB drivers.
- The usb_pause_mtx() function takes ticks and not milliseconds as last argument.

MFC after:	3 days
2014-05-20 15:53:17 +00:00
Hans Petter Selasky
b41381aea9 - The DELAY() should not be used in USB drivers.
- The usb_pause_mtx() function takes ticks and not milliseconds as last argument.

MFC after:	3 days
2014-05-20 15:47:37 +00:00
Hans Petter Selasky
6804df87a9 Correct some programming details. The layout of the PDTs were
different from what was initially thought. Fix re-programming of
hardware mode register after reset.

Sponsored by:	DARPA, AFRL
2014-05-20 14:15:03 +00:00
Hans Petter Selasky
7243077c9d Make sure detach code is executed in all cases. This fixes a panic
when debugging is enabled.

Reported by:	Idwer Vollering <vidwer@gmail.com>
MFC after:	3 days
2014-05-20 12:22:53 +00:00
Hans Petter Selasky
e85f0d3141 - Remove no longer used file. FDT is used to attach device drivers. 2014-05-18 09:19:13 +00:00
Hans Petter Selasky
2fe7ad87e9 - Add softc pointer argument to FIFO functions as an optimisation.
- Implement support for interrupt filters in the DWC OTG driver, to
reduce the amount of CPU task switching when only feeding the FIFOs.
- Add common spinlock to the USB bus structure.

MFC after:	2 weeks
2014-05-18 09:13:29 +00:00
Christian Brueffer
73aa8b9a75 Remove some unused variables.
Found with:	Clang Static Analyzer
MFC after:	2 weeks
2014-05-16 21:19:17 +00:00
Hans Petter Selasky
dfe11c1395 Enable host controller interrupts.
Sponsored by:	DARPA, AFRL
2014-05-16 16:36:07 +00:00
Hans Petter Selasky
56a052ffdd Remove old files.
Sponsored by:	DARPA, AFRL
2014-05-16 15:53:47 +00:00
Hans Petter Selasky
4327a6c8c6 Fix a compile warning about unused variable.
Sponsored by:	DARPA, AFRL
2014-05-16 15:53:14 +00:00
Hans Petter Selasky
f46e2f146b Rename "saf1761_dci_xxx" into "saf1761_otg_xxx" to reflect that this
driver supports both host and device side mode.

Sponsored by:	DARPA, AFRL
2014-05-16 15:50:21 +00:00
Hans Petter Selasky
2550c55ed3 Implement basic support for the USB host controller found in the
SAF1761 chip, supporting BULK and CONTROL endpoints. This code is not
yet tested.

Sponsored by:	DARPA, AFRL
2014-05-16 15:41:55 +00:00
Hans Petter Selasky
39c913fb21 - Allow the SAF1761 driver to attach to the root HUB USB driver.
Sponsored by:	DARPA, AFRL
2014-05-16 10:37:25 +00:00
Hans Petter Selasky
fffa71cbfe - Add flattended device tree probe-, attach- and detach code for the
SAF1761 driver, compatible to existing Linux based FDT tables for the
same hardware.

Sponsored by:	DARPA, AFRL
2014-05-16 10:35:21 +00:00
Hans Petter Selasky
a673f4c22b - Correct some programming details for the SAF1761 driver.
- Add some more register details.

Sponsored by:	DARPA, AFRL
2014-05-16 10:30:30 +00:00
Hans Petter Selasky
b9f21c2ce8 Implement USB device side driver code for SAF1761 and compatible
chips, based on datasheet and existing USS820 DCI driver. This code is
not yet tested.

Sponsored by:	DARPA, AFRL
2014-05-14 17:04:02 +00:00
Hans Petter Selasky
f5bf22f3b5 Disable configuration of the host frame interval register until
further, hence it breaks USB support on some non-RPI platforms.
2014-05-14 11:32:15 +00:00
Hans Petter Selasky
40ba168d27 - Isochronous transfers should use the alternate next transfer
descriptor upon receiving a short packet, in host and device mode.
- Correct some comments.
2014-05-13 13:46:38 +00:00
Hans Petter Selasky
1d6b6e9d46 Create driver file templates, kernel module Makefile and add initial
version of register definitions for ISP1761 and SAF1761 compatible
chips.

Sponsored by:	DARPA, AFRL
2014-05-12 09:05:07 +00:00
Hans Petter Selasky
4541f27356 Optimise host mode data roundtrip time. When BULK data is submitted to
the main processing queue, clear the NAK counter for any associated
BULK or CONTROL transfers and poll the endpoint(s) for 1 millisecond
at 125us rate interval, before going into slow, 10ms, NAK polling mode
again.  This has the effect that typical ping-ping protocols respond
quicker when initiated from the USB host.

MFC after:	2 weeks
2014-05-11 08:17:46 +00:00
Hans Petter Selasky
e2192fdfc6 Optimise host channel disabling:
- For non-periodic traffic we only need to wait two SOFs before
disabling the channel.
- Make sure we release the TX FIFO tracking level after the host
channel is disabled.
- Make sure the host channel state gets reset/disabled initially.
- Two minor code style changes.

MFC after:	2 weeks
2014-05-10 07:37:32 +00:00
Hans Petter Selasky
897b7965df Fix a regression issue:
- ACK can be received before data arrives in RX FIFO. Handle this.
- Remove obsolete comment.
- Some minor code styling.

MFC after:	2 weeks
2014-05-09 16:40:41 +00:00
Hans Petter Selasky
81c36cd940 Fix for NULL pointer.
MFC after:	1 week
2014-05-09 14:28:11 +00:00
Hans Petter Selasky
db4300da10 Multiple DWC OTG host mode related fixes and improvements:
- Rework how we allocate and free USB host channels, so that we only
allocate a channel if there is a real packet going out on the USB
cable.

- Use BULK type for control data and status, due to instabilities in
the HW it appears.

- Split FIFO TX levels into one for the periodic FIFO and one for the
non-periodic FIFO.

- Use correct HFNUM mask when scheduling host transactions. The HFNUM
register does not count the full 16-bit range.

- Correct START/COMPLETION slot for TT transactions. For INTERRUPT and
ISOCHRONOUS type transactions the hardware always respects the ODDFRM
bit, which means we need to allocate multiple host channels when
processing such endpoints, to not miss any so-called complete split
opportunities.

- When doing ISOCHRONOUS OUT transfers through a TT send all data
payload in a single ALL-burst. This deacreases the likelyhood for
isochronous data underruns.

- Fixed unbalanced unlock in case of "dwc_otg_init_fifo()" failure.

- Increase interrupt priority.

MFC after:	2 weeks
2014-05-09 14:23:06 +00:00
Hans Petter Selasky
42fabcc35c Reduce the number of interrupts in USB host mode for the DWC OTG
controller driver by piggybacking the SOF interrupt when issuing new
and checking old transfers. Number of interrupts was reduced by 30%
when doing Isochronous transfers.

Use correct GINTMSK_XXX macros when accessing the DWC OTG interrupt
mask register.

Add code to adjust the frame interval register which influences the
SOF rate.

MFC after:	2 weeks
2014-05-06 09:12:32 +00:00
Michael Tuexen
5a1a4f754a Fill in csum_data only for UDP or TCP packets. This fixes a bug where
SCTP were reported to have always a correct checksum if they don't
contain any ethernet padding.

MFC after: 3 days
2014-05-05 17:30:05 +00:00
Hans Petter Selasky
bc99048296 Improve DWC OTG USB host side support for isochronous FULL and HIGH
speed data traffic going directly to a USB device or through a
so-called USB transaction translator.

Add checks that we are not overusing the TX FIFO.

MFC after:	2 weeks
2014-05-05 11:50:52 +00:00
Hans Petter Selasky
8237c62b5d Setting the IMOD value below 0x3F8 can cause IRQ lockups in the Intel
LynxPoint USB 3.0 controllers found in MacBookPro 2013's.

MFC after:	2 days
Tested by:	Huang Wen Hui <huanghwh@gmail.com>
2014-04-27 15:41:44 +00:00