From owner-svn-src-stable-8@FreeBSD.ORG Wed Dec 9 22:40:27 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F6AC106566B; Wed, 9 Dec 2009 22:40:27 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4C9098FC17; Wed, 9 Dec 2009 22:40:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nB9MeRZ5042227; Wed, 9 Dec 2009 22:40:27 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nB9MeR3W042224; Wed, 9 Dec 2009 22:40:27 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200912092240.nB9MeR3W042224@svn.freebsd.org> From: Andrew Thompson Date: Wed, 9 Dec 2009 22:40:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200331 - stable/8/sys/dev/usb/controller X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2009 22:40:27 -0000 Author: thompsa Date: Wed Dec 9 22:40:27 2009 New Revision: 200331 URL: http://svn.freebsd.org/changeset/base/200331 Log: MFC r199676 Correct register access for USB device side operation on the musb controller. Submitted by: Hans Petter Selasky Modified: stable/8/sys/dev/usb/controller/musb_otg.c stable/8/sys/dev/usb/controller/musb_otg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/controller/musb_otg.c ============================================================================== --- stable/8/sys/dev/usb/controller/musb_otg.c Wed Dec 9 22:39:09 2009 (r200330) +++ stable/8/sys/dev/usb/controller/musb_otg.c Wed Dec 9 22:40:27 2009 (r200331) @@ -1539,18 +1539,18 @@ musbotg_clear_stall_sub(struct musbotg_s /* Configure endpoint */ switch (ep_type) { case UE_INTERRUPT: - MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, wMaxPacket); + MUSB2_WRITE_2(sc, MUSB2_REG_TXMAXP, wMaxPacket); MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRH, MUSB2_MASK_CSRH_TXMODE | temp); break; case UE_ISOCHRONOUS: - MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, wMaxPacket); + MUSB2_WRITE_2(sc, MUSB2_REG_TXMAXP, wMaxPacket); MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRH, MUSB2_MASK_CSRH_TXMODE | MUSB2_MASK_CSRH_TXISO | temp); break; case UE_BULK: - MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, wMaxPacket); + MUSB2_WRITE_2(sc, MUSB2_REG_TXMAXP, wMaxPacket); MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRH, MUSB2_MASK_CSRH_TXMODE | temp); break; @@ -1600,18 +1600,18 @@ musbotg_clear_stall_sub(struct musbotg_s /* Configure endpoint */ switch (ep_type) { case UE_INTERRUPT: - MUSB2_WRITE_1(sc, MUSB2_REG_RXMAXP, wMaxPacket); + MUSB2_WRITE_2(sc, MUSB2_REG_RXMAXP, wMaxPacket); MUSB2_WRITE_1(sc, MUSB2_REG_RXCSRH, MUSB2_MASK_CSRH_RXNYET | temp); break; case UE_ISOCHRONOUS: - MUSB2_WRITE_1(sc, MUSB2_REG_RXMAXP, wMaxPacket); + MUSB2_WRITE_2(sc, MUSB2_REG_RXMAXP, wMaxPacket); MUSB2_WRITE_1(sc, MUSB2_REG_RXCSRH, MUSB2_MASK_CSRH_RXNYET | MUSB2_MASK_CSRH_RXISO | temp); break; case UE_BULK: - MUSB2_WRITE_1(sc, MUSB2_REG_RXMAXP, wMaxPacket); + MUSB2_WRITE_2(sc, MUSB2_REG_RXMAXP, wMaxPacket); MUSB2_WRITE_1(sc, MUSB2_REG_RXCSRH, temp); break; default: @@ -1688,12 +1688,14 @@ usb_error_t musbotg_init(struct musbotg_softc *sc) { struct usb_hw_ep_profile *pf; + uint16_t offset; uint8_t nrx; uint8_t ntx; uint8_t temp; uint8_t fsize; uint8_t frx; uint8_t ftx; + uint8_t dynfifo; DPRINTFN(1, "start\n"); @@ -1776,11 +1778,20 @@ musbotg_init(struct musbotg_softc *sc) DPRINTFN(2, "Config Data: 0x%02x\n", sc->sc_conf_data); + dynfifo = (sc->sc_conf_data & MUSB2_MASK_CD_DYNFIFOSZ) ? 1 : 0; + + if (dynfifo) { + DPRINTFN(0, "Dynamic FIFO sizing detected! " + "Assuming 16Kbytes of FIFO RAM\n"); + } + DPRINTFN(2, "HW version: 0x%04x\n", MUSB2_READ_1(sc, MUSB2_REG_HWVERS)); /* initialise endpoint profiles */ + offset = 0; + for (temp = 1; temp <= sc->sc_ep_max; temp++) { pf = sc->sc_hw_ep_profile + temp; @@ -1791,9 +1802,45 @@ musbotg_init(struct musbotg_softc *sc) frx = (fsize & MUSB2_MASK_RX_FSIZE) / 16;; ftx = (fsize & MUSB2_MASK_TX_FSIZE); - DPRINTF("Endpoint %u FIFO size: IN=%u, OUT=%u\n", - temp, pf->max_in_frame_size, - pf->max_out_frame_size); + DPRINTF("Endpoint %u FIFO size: IN=%u, OUT=%u, DYN=%d\n", + temp, ftx, frx, dynfifo); + + if (dynfifo) { + if (frx && (temp <= nrx)) { + if (temp < 8) { + frx = 10; /* 1K */ + MUSB2_WRITE_1(sc, MUSB2_REG_RXFIFOSZ, + MUSB2_VAL_FIFOSZ_512 | + MUSB2_MASK_FIFODB); + } else { + frx = 7; /* 128 bytes */ + MUSB2_WRITE_1(sc, MUSB2_REG_RXFIFOSZ, + MUSB2_VAL_FIFOSZ_128); + } + + MUSB2_WRITE_2(sc, MUSB2_REG_RXFIFOADD, + offset >> 3); + + offset += (1 << frx); + } + if (ftx && (temp <= ntx)) { + if (temp < 8) { + ftx = 10; /* 1K */ + MUSB2_WRITE_1(sc, MUSB2_REG_TXFIFOSZ, + MUSB2_VAL_FIFOSZ_512 | + MUSB2_MASK_FIFODB); + } else { + ftx = 7; /* 128 bytes */ + MUSB2_WRITE_1(sc, MUSB2_REG_TXFIFOSZ, + MUSB2_VAL_FIFOSZ_128); + } + + MUSB2_WRITE_2(sc, MUSB2_REG_TXFIFOADD, + offset >> 3); + + offset += (1 << ftx); + } + } if (frx && ftx && (temp <= nrx) && (temp <= ntx)) { pf->max_in_frame_size = 1 << ftx; @@ -1824,6 +1871,8 @@ musbotg_init(struct musbotg_softc *sc) } } + DPRINTFN(2, "Dynamic FIFO size = %d bytes\n", offset); + /* turn on default interrupts */ MUSB2_WRITE_1(sc, MUSB2_REG_INTUSBE, Modified: stable/8/sys/dev/usb/controller/musb_otg.h ============================================================================== --- stable/8/sys/dev/usb/controller/musb_otg.h Wed Dec 9 22:39:09 2009 (r200330) +++ stable/8/sys/dev/usb/controller/musb_otg.h Wed Dec 9 22:40:27 2009 (r200331) @@ -191,7 +191,7 @@ #define MUSB2_REG_EPFIFO(n) (0x0020 + (4*(n))) -#define MUSB2_REG_CONFDATA 0x000F /* EPN=0 */ +#define MUSB2_REG_CONFDATA (0x000F + MUSB2_REG_INDEXED_CSR) /* EPN=0 */ #define MUSB2_MASK_CD_UTMI_DW 0x01 #define MUSB2_MASK_CD_SOFTCONE 0x02 #define MUSB2_MASK_CD_DYNFIFOSZ 0x04