From owner-p4-projects@FreeBSD.ORG Tue Dec 25 22:47:48 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E2E4C16A419; Tue, 25 Dec 2007 22:47:47 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 514A916A417 for ; Tue, 25 Dec 2007 22:47:47 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 373D113C4DB for ; Tue, 25 Dec 2007 22:47:47 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lBPMlkPA072994 for ; Tue, 25 Dec 2007 22:47:47 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lBPMlkG7072991 for perforce@freebsd.org; Tue, 25 Dec 2007 22:47:46 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 25 Dec 2007 22:47:46 GMT Message-Id: <200712252247.lBPMlkG7072991@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 131630 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Dec 2007 22:47:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=131630 Change 131630 by hselasky@hselasky_laptop001 on 2007/12/25 22:46:45 Correct VBUS and PULLUP pin. Make sure that the clocks are turned on and off in the correct order. Affected files ... .. //depot/projects/usb/src/sys/arm/at91/at91_udp.c#2 edit Differences ... ==== //depot/projects/usb/src/sys/arm/at91/at91_udp.c#2 (text+ko) ==== @@ -51,11 +51,11 @@ /* Pin Definitions - do they belong here or somewhere else ? */ -#define VBUS_MASK AT91C_PIO_PD4 -#define VBUS_BASE AT91RM92_PIOD_BASE +#define VBUS_MASK AT91C_PIO_PB24 +#define VBUS_BASE AT91RM92_PIOB_BASE -#define PULLUP_MASK AT91C_PIO_PD5 -#define PULLUP_BASE AT91RM92_PIOD_BASE +#define PULLUP_MASK AT91C_PIO_PB22 +#define PULLUP_BASE AT91RM92_PIOB_BASE static device_probe_t at91_udp_probe; static device_attach_t at91_udp_attach; @@ -72,8 +72,13 @@ static void at91_vbus_interrupt(struct at91_udp_softc *sc) { + uint32_t temp; uint8_t vbus_val; + /* XXX temporary clear interrupts here */ + + temp = at91_pio_gpio_clear_interrupt(VBUS_BASE); + /* just forward it */ vbus_val = at91_pio_gpio_get(VBUS_BASE, VBUS_MASK); @@ -87,8 +92,8 @@ { struct at91_udp_softc *sc = arg; + at91_pmc_clock_enable(sc->sc_iclk); at91_pmc_clock_enable(sc->sc_fclk); - at91_pmc_clock_enable(sc->sc_iclk); return; } @@ -97,8 +102,8 @@ { struct at91_udp_softc *sc = arg; + at91_pmc_clock_disable(sc->sc_fclk); at91_pmc_clock_disable(sc->sc_iclk); - at91_pmc_clock_disable(sc->sc_fclk); return; } @@ -152,6 +157,7 @@ * configure VBUS input pin, enable deglitch and enable * interrupt : */ + at91_pio_use_gpio(VBUS_BASE, VBUS_MASK); at91_pio_gpio_input(VBUS_BASE, VBUS_MASK); at91_pio_gpio_set_deglitch(VBUS_BASE, VBUS_MASK, 1); at91_pio_gpio_set_interrupt(VBUS_BASE, VBUS_MASK, 1); @@ -159,10 +165,15 @@ /* * configure PULLUP output pin : */ + at91_pio_use_gpio(PULLUP_BASE, PULLUP_MASK); at91_pio_gpio_output(PULLUP_BASE, PULLUP_MASK, 0); at91_udp_pull_down(sc); + /* wait 10ms for pulldown to stabilise */ + + DELAY(10000); + sc->sc_iclk = at91_pmc_clock_ref("udc_clk"); sc->sc_fclk = at91_pmc_clock_ref("udpck"); @@ -225,19 +236,6 @@ sc->sc_vbus_intr_hdl = NULL; goto error; } - /* - * turn on the clocks from the AT91's point of view. Keep the unit - * in reset. - */ - at91_pmc_clock_enable(sc->sc_iclk); - at91_pmc_clock_enable(sc->sc_fclk); - - /* disable Transceiver */ - AT91_UDP_WRITE_4(&(sc->sc_dci), AT91_UDP_TXVC, AT91_UDP_TXVC_DIS); - - /* disable and clear all interrupts */ - AT91_UDP_WRITE_4(&(sc->sc_dci), AT91_UDP_IDR, 0xFFFFFFFF); - AT91_UDP_WRITE_4(&(sc->sc_dci), AT91_UDP_ICR, 0xFFFFFFFF); err = at9100_dci_init(&(sc->sc_dci)); if (!err) {