summaryrefslogtreecommitdiffstats
path: root/sys/arm/allwinner/a10_ehci.c
diff options
context:
space:
mode:
authorganbold <ganbold@FreeBSD.org>2013-02-06 01:03:13 +0000
committerganbold <ganbold@FreeBSD.org>2013-02-06 01:03:13 +0000
commite1ce6ad8dd8348d781f3da2548bc66a336e4a5fc (patch)
tree065f7a84cca267307a483f702e223f019013bf1a /sys/arm/allwinner/a10_ehci.c
parent34f6d259a30c45a17229a6742c75eaf1a57452f6 (diff)
downloadFreeBSD-src-e1ce6ad8dd8348d781f3da2548bc66a336e4a5fc.zip
FreeBSD-src-e1ce6ad8dd8348d781f3da2548bc66a336e4a5fc.tar.gz
Use and set gpio pin to high to power up usb.
Approved by: gonzo@
Diffstat (limited to 'sys/arm/allwinner/a10_ehci.c')
-rw-r--r--sys/arm/allwinner/a10_ehci.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/arm/allwinner/a10_ehci.c b/sys/arm/allwinner/a10_ehci.c
index d3a90d0..0d1636b 100644
--- a/sys/arm/allwinner/a10_ehci.c
+++ b/sys/arm/allwinner/a10_ehci.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/condvar.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/gpio.h>
#include <machine/bus.h>
#include <dev/ofw/ofw_bus.h>
@@ -58,6 +59,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/controller/ehci.h>
#include <dev/usb/controller/ehcireg.h>
+#include "gpio_if.h"
+
#include "a10_clk.h"
#define EHCI_HC_DEVSTR "Allwinner Integrated USB 2.0 controller"
@@ -70,8 +73,9 @@ __FBSDID("$FreeBSD$");
#define SW_ULPI_BYPASS (1 << 0)
#define SW_AHB_INCRX_ALIGN (1 << 8)
-#define SW_AHB_INCR4 (1 << 9)
+#define SW_AHB_INCR4 (1 << 9)
#define SW_AHB_INCR8 (1 << 10)
+#define GPIO_USB2_PWR 227
#define A10_READ_4(sc, reg) \
bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg)
@@ -101,6 +105,7 @@ a10_ehci_attach(device_t self)
{
ehci_softc_t *sc = device_get_softc(self);
bus_space_handle_t bsh;
+ device_t sc_gpio_dev;
int err;
int rid;
uint32_t reg_value = 0;
@@ -153,6 +158,13 @@ a10_ehci_attach(device_t self)
sprintf(sc->sc_vendor, "Allwinner");
+ /* Get the GPIO device, we need this to give power to USB */
+ sc_gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
+ if (sc_gpio_dev == NULL) {
+ device_printf(self, "Error: failed to get the GPIO device\n");
+ goto error;
+ }
+
err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
if (err) {
@@ -166,6 +178,10 @@ a10_ehci_attach(device_t self)
/* Enable clock for USB */
a10_clk_usb_activate();
+ /* Give power to USB */
+ GPIO_PIN_SETFLAGS(sc_gpio_dev, GPIO_USB2_PWR, GPIO_PIN_OUTPUT);
+ GPIO_PIN_SET(sc_gpio_dev, GPIO_USB2_PWR, GPIO_PIN_HIGH);
+
/* Enable passby */
reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE);
reg_value |= SW_AHB_INCR8; /* AHB INCR8 enable */
OpenPOWER on IntegriCloud