irqchip: bcm2835: Convert to use IRQCHIP_DECLARE macro

This patch converts irq-bcm2835 driver to use the new IRQCHIP_DECLARE and
irqchip_init.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
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>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: add calls to usb_hcd_link_urb_to_ep() and friends

The driver was lacking calls to usb_hcd_link_urb_to_ep(),
usb_hcd_unlink_urb_from_ep(), and usb_hcd_check_unlink_urb(). Add
those now.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: optimize dwc2_hc_handle_tt_clear() a bit

Make dwc2_hc_handle_tt_clear() return early if the device is
hi-speed.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: fix dwc2_hcd_qtd_add()

The logic in dwc2_hcd_qtd_add() was a bit messy, and one of the
error exit paths was broken. Fix it up.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: reduce noisy debug messages

Change the non-aligned buffer debug messages to dev_vdbg(). Also
remove some duplicated debug output when the driver is loaded.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: remove use of bus_to_virt()

Remove the use of bus_to_virt() and just fail the transfer if an
unaligned buffer with no virtual address is found. AFAIK that
can't happen anyway.

Also change setting of coherent DMA mask to the normal 32 bits.
31 bits was only needed when calling bus_to_virt() AFAICR.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: add driver parameter to set AHB config register value

The dwc2 driver sets the value of the DWC2 GAHBCFG register to 0x6,
which is GAHBCFG_HBSTLEN_INCR4. But different platforms may require
different values. In particular, the Broadcom 2835 SOC used in the
Raspberry Pi needs a value of 0x10, otherwise the DWC2 controller
stops working after a short period of heavy USB traffic.

So this patch adds another driver parameter named 'ahbcfg'. The
default value is 0x6. Any platform needing a different value should
add a DT attribute to set it.

This patch also removes the 'ahb_single' driver parameter, since
that bit can now be set using 'ahbcfg'.

This patch does not add DT support to platform.c, I will leave that
to whoever owns the first platform that needs a non-default value.
(Stephen?)

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: add microframe scheduler from downstream Pi kernel

The transfer scheduler in the dwc2 driver is pretty basic, not to
mention buggy. It works fairly well with just a couple of devices
plugged in, but if you add, say, multiple devices with periodic
endpoints, the scheduler breaks down and can't even enumerate all
the devices.

To fix this, import the "microframe scheduler" patch from the
driver in the downstream Raspberry Pi kernel, which is based on
the Synopsys vendor driver. That patch was done by the guys from
raspberrypi.org, including at least Gordon Hollingsworth and
"popcornmix".

I have added a driver parameter for this, enabled by default, in
case anyone has problems with it and needs to disable it. I don't
think we should add a DT binding for that, though, since I plan to
remove the option once any bugs are fixed.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
staging: dwc2: set up all module params

(posted to mailing list by Paul, not signed off, minor mods to set
ahbcfg instead of ahb_single, and to set uframe_sched since then)

FIXME: The parameters should all come from DT.
Matthijs Kooijman writes:
I previously submitted a patch to load everything from DT, which might
serve as inspiration: http://article.gmane.org/gmane.linux.usb.general/85086
(but note this reply: http://article.gmane.org/gmane.linux.usb.general/85104)
HACK: enable DWC2 OTG on RPi

Turn on USB power first in U-Boot:

// msg with 2 parameters, up to 2 responses
setenv prop-2-2 'mw.l 0x00001000 0x00000020 ; mw.l 0x00001004 0x00000000 ; mw.l 0x00001008 \$tag ; mw.l 0x0000100c 0x00000008 ; mw.l 0x00001010 0x00000008 ; mw.l 0x00001014 \$p1 ; mw.l 0x00001018 \$p2 ; mw.l 0x0000101c 0x00000000 ; md.l 0x1000 8'

// send msg, read/dump response
setenv send-rec 'mw 0x2000b8a0 0x00001008 ; md 0x2000b880 1 ; md.l 0x00001000 8'

// set power, devid==p1 (3==USB), state,wait==p2 (3==ON/WAIT)
setenv tag 0x28001 ; setenv p1 3 ; setenv p2 3; run prop-2-2 ; run send-rec

The GPIO pinctrl setup in bcm2835-rpi-b.dts works because the default
output value for GPIO 6 (LAN_RUN/n_reset) just happens to be 1, which
enables the USB/LAN chip.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
ARM: bcm2835: enable some config options useful with USB

(and try a few other options to see if we can get the USB SD card reader
recognizing card plug/unplug events)

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>