Commit Graph

11 Commits

Author SHA1 Message Date
Matthijs Kooijman 9badec2f9f staging: dwc2: interpret all hwcfg and related register at init time
Before, the hwcfg registers were read at device init time, but
interpreted at various parts in the code. This commit unpacks the hwcfg
register values into a struct with properly labeled variables at init
time, which makes all the other code using these values more consise and
easier to read. Some values that were previously stored in the hsotg
struct are now moved into this new struct as well.

In addition to the hwcfg registers, the contents of some fifo size
registers are also unpacked. The hwcfg registers are read-only, so they
can be safely stored. The fifo size registers are read-write registers,
but their power-on values are significant: they give the maximum depth
of the fifo they describe.

This commit mostly moves code, but also attempts to simplify some
expressions from (val >> shift) & (mask >> shift) to
(val & mask) >> shift.

Finally, all of the parameters read from the hardware are debug printed
after unpacking them, so a bunch of debug prints can be removed from
other places.

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-30 14:14:53 -07:00
Matthijs Kooijman f923463335 staging: dwc2: unshift non-bool register value constants
Various register fields wider than one bit have constants defined for
their value. Previously, these registers would define the values as they
appear in the register, so shifted to the right to the position the
value appears in the register.

This commit changes those constants to their natural values (e.g, 0, 1,
2, etc.), as they are after shifting the register value to the right.
This also changes all relevant code to shift the values before comparing
them with constants.

This has the advantage that the values can be stored in smaller
variables (now they always require a u32) and makes the handling of
these values more consistent with other register fields that represent
natural numbers instead of enumerations (e.g., number of host channels).

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-30 14:14:52 -07:00
Paul Zimmerman 725acc861b staging: dwc2: reorder some kernel doc comments and struct members
Reorder the kernel doc comments for 'struct dwc2_core_params' to
match the ordering in the struct itself. Reorder the members of
'struct dwc2_qh' (and its kerneldoc comments) to minimize the
amount of structure padding.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-12 15:21:41 -07:00
Paul Zimmerman 0d012b9866 staging: dwc2: refactor dwc2_host_complete()
The parameters to dwc2_host_complete() didn't make much sense.
The 'context' parameter always came from the ->priv member of the
'dwc2_urb' parameter, and both of those always came from a struct
dwc2_qtd. So just pass in the struct dwc2_qtd instead.

This also allows us to null out the dwc2_qtd->urb member after it
is freed, which the calling code forgot to do in several places,
causing random driver crashes from dereferencing the freed pointer.

This also requires the calls to dwc2_hc_handle_tt_clear() to be
moved before the calls to dwc2_host_complete(), otherwise that
routine would do nothing because dwc2_qtd->urb has already been
freed.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Tested-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-23 14:54:48 -07:00
Stephen Warren 90dbceafe8 staging: dwc2: add const to handling of dwc2_core_params
Now the functions use proper const annotations, the global variable with
default params can be marked const, which prevents these values from
being changed for a specific device (in theory there could be multiple
controllers with different settings, for example).

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
[matthijs@stdin.nl: Split patch from bigger patch, marked
		    dwc2_module_params in pci.c as const and added
		    commit message]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-05-16 15:23:56 -07:00
Matthijs Kooijman ca18f4a678 staging: dwc2: rename dwc2_hcd_intr() to dwc2_handle_hcd_intr()
This makes the function name more clear and consistent with
dwc2_handle_common_intr().

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-05-16 15:22:38 -07:00
Matthijs Kooijman 6aafb00385 staging: dwc2: use irq_return_t for interrupt handlers
The top-level hcd interrupt handlers already used irq_return_t, but the
functions to which it delegates the actual work and the common irq
handler returned plain ints. In addition, they used the IRQ_RETVAL in
the wrong way (but because of the values of the various constants, this
didn't result in wrong behaviour).

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
[matthijs@stdin.nl: Split patch from bigger patch and added commit message]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-05-16 15:22:38 -07:00
Matthijs Kooijman 8284f93b3d staging: dwc2: Make dwc2_set_uninitialized more specific
Before, it was a function that would set all members of a given struct
containing only int members to -1. Now, it is renamed to
dwc_set_all_params and it works only on the dwc2_core_params struct.
This makes sure that all of the slightly dubious casting and assumptions
happen inside the function instead of by the caller.

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-11 13:27:39 -07:00
Matthijs Kooijman b49977a60d staging: dwc2: toggle periodic debugging output separately
This adds a config option USB_DWC2_DEBUG_PERIODIC that allows debugging
output be suppressed for periodic transfers. This helps when debugging
non-periodic transfers while there are also periodic transfers going on
(both to make the debug output less polluted and to prevent all CPU time
going to debug messages).

In addition, a debug message from dwc2_hcd_is_status_changed is removed
entirely, since it often floods the log regardless of periodic
transfers.

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Cc: Paul Zimmerman <Paul.Zimmerman@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-10 19:10:27 -07:00
Paul Zimmerman e62662c7f3 staging: dwc2: remove unneeded arguments from two functions
Remove the unneeded struct device *dev argument from dwc2_hcd_init()
and dwc2_hcd_remove(), and pass in the value through the hsotg->dev
member instead

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-25 17:10:35 -07:00
Paul Zimmerman 7359d482eb staging: HCD files for the DWC2 driver
These files contain the HCD code, and implement the Linux
hc_driver API. Support for both slave mode and buffer DMA mode
of the controller is included.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-11 18:16:37 -07:00