From owner-svn-src-head@FreeBSD.ORG Wed Feb 6 01:03:14 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2B932A02; Wed, 6 Feb 2013 01:03:14 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 014EF227; Wed, 6 Feb 2013 01:03:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1613Dmt009458; Wed, 6 Feb 2013 01:03:13 GMT (envelope-from ganbold@svn.freebsd.org) Received: (from ganbold@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1613DRB009456; Wed, 6 Feb 2013 01:03:13 GMT (envelope-from ganbold@svn.freebsd.org) Message-Id: <201302060103.r1613DRB009456@svn.freebsd.org> From: Ganbold Tsagaankhuu Date: Wed, 6 Feb 2013 01:03:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246375 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2013 01:03:14 -0000 Author: ganbold (doc committer) Date: Wed Feb 6 01:03:13 2013 New Revision: 246375 URL: http://svnweb.freebsd.org/changeset/base/246375 Log: Use and set gpio pin to high to power up usb. Approved by: gonzo@ Modified: head/sys/arm/allwinner/a10_ehci.c Modified: head/sys/arm/allwinner/a10_ehci.c ============================================================================== --- head/sys/arm/allwinner/a10_ehci.c Wed Feb 6 00:43:10 2013 (r246374) +++ head/sys/arm/allwinner/a10_ehci.c Wed Feb 6 01:03:13 2013 (r246375) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -58,6 +59,8 @@ __FBSDID("$FreeBSD$"); #include #include +#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 */