123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599 |
- /*****************************************************************************
- ** FILE NAME : ifxhcd_es.c
- ** PROJECT : IFX USB sub-system V3
- ** MODULES : IFX USB sub-system Host and Device driver
- ** SRC VERSION : 1.0
- ** DATE : 1/Jan/2009
- ** AUTHOR : Chen, Howard
- ** DESCRIPTION : The file contain function to enable host mode USB-IF Electrical Test function.
- ** FUNCTIONS :
- ** COMPILER : gcc
- ** REFERENCE : Synopsys DWC-OTG Driver 2.7
- ** COPYRIGHT : Copyright (c) 2010
- ** LANTIQ DEUTSCHLAND GMBH,
- ** Am Campeon 3, 85579 Neubiberg, Germany
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** Version Control Section **
- ** $Author$
- ** $Date$
- ** $Revisions$
- ** $Log$ Revision history
- *****************************************************************************/
- /*
- * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
- * For this code the following notice is applicable:
- *
- * ==========================================================================
- *
- * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
- * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
- * otherwise expressly agreed to in writing between Synopsys and you.
- *
- * The Software IS NOT an item of Licensed Software or Licensed Product under
- * any End User Software License Agreement or Agreement for Licensed Product
- * with Synopsys or any supplement thereto. You are permitted to use and
- * redistribute this Software in source and binary forms, with or without
- * modification, provided that redistributions of source code must retain this
- * notice. You may not view, use, disclose, copy or distribute this file or
- * any information contained herein except pursuant to this license grant from
- * Synopsys. If you do not agree with this notice, including the disclaimer
- * below, then you are not authorized to use the Software.
- *
- * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- * ========================================================================== */
- /*!
- \file ifxhcd_es.c
- \ingroup IFXUSB_DRIVER_V3
- \brief The file contain function to enable host mode USB-IF Electrical Test function.
- */
- #include <linux/version.h>
- #include "ifxusb_version.h"
- #include <linux/kernel.h>
- #include <linux/errno.h>
- #include <linux/dma-mapping.h>
- #include "ifxusb_plat.h"
- #include "ifxusb_regs.h"
- #include "ifxusb_cif.h"
- #include "ifxhcd.h"
- #ifdef __WITH_HS_ELECT_TST__
- /*
- * Quick and dirty hack to implement the HS Electrical Test
- * SINGLE_STEP_GET_DEVICE_DESCRIPTOR feature.
- *
- * This code was copied from our userspace app "hset". It sends a
- * Get Device Descriptor control sequence in two parts, first the
- * Setup packet by itself, followed some time later by the In and
- * Ack packets. Rather than trying to figure out how to add this
- * functionality to the normal driver code, we just hijack the
- * hardware, using these two function to drive the hardware
- * directly.
- */
- void do_setup(ifxusb_core_if_t *_core_if)
- {
- ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
- ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
- ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
- uint32_t *data_fifo = _core_if->data_fifo[0];
- gint_data_t gintsts;
- hctsiz_data_t hctsiz;
- hcchar_data_t hcchar;
- haint_data_t haint;
- hcint_data_t hcint;
- /* Enable HAINTs */
- ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
- /* Enable HCINTs */
- ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /*
- * Send Setup packet (Get Device Descriptor)
- */
- /* Make sure channel is disabled */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- if (hcchar.b.chen) {
- //fprintf(stderr, "Channel already enabled 1, HCCHAR = %08x\n", hcchar.d32);
- hcchar.b.chdis = 1;
- // hcchar.b.chen = 1;
- ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
- //sleep(1);
- mdelay(1000);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //if (hcchar.b.chen) {
- // fprintf(stderr, "** Channel _still_ enabled 1, HCCHAR = %08x **\n", hcchar.d32);
- //}
- }
- /* Set HCTSIZ */
- hctsiz.d32 = 0;
- hctsiz.b.xfersize = 8;
- hctsiz.b.pktcnt = 1;
- hctsiz.b.pid = IFXUSB_HC_PID_SETUP;
- ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
- /* Set HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
- hcchar.b.epdir = 0;
- hcchar.b.epnum = 0;
- hcchar.b.mps = 8;
- hcchar.b.chen = 1;
- ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
- /* Fill FIFO with Setup data for Get Device Descriptor */
- ifxusb_wreg(data_fifo++, 0x01000680);
- ifxusb_wreg(data_fifo++, 0x00080000);
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "Waiting for HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
- /* Wait for host channel interrupt */
- do {
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- } while (gintsts.b.hcintr == 0);
- //fprintf(stderr, "Got HCINTR intr 1, GINTSTS = %08x\n", gintsts.d32);
- /* Disable HCINTs */
- ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
- /* Disable HAINTs */
- ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- }
- void do_in_ack(ifxusb_core_if_t *_core_if)
- {
- ifxusb_core_global_regs_t *global_regs = _core_if->core_global_regs;
- ifxusb_host_global_regs_t *hc_global_regs = _core_if->host_global_regs;
- ifxusb_hc_regs_t *hc_regs = _core_if->hc_regs[0];
- uint32_t *data_fifo = _core_if->data_fifo[0];
- gint_data_t gintsts;
- hctsiz_data_t hctsiz;
- hcchar_data_t hcchar;
- haint_data_t haint;
- hcint_data_t hcint;
- grxsts_data_t grxsts;
- /* Enable HAINTs */
- ifxusb_wreg(&hc_global_regs->haintmsk, 0x0001);
- /* Enable HCINTs */
- ifxusb_wreg(&hc_regs->hcintmsk, 0x04a3);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /*
- * Receive Control In packet
- */
- /* Make sure channel is disabled */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- if (hcchar.b.chen) {
- //fprintf(stderr, "Channel already enabled 2, HCCHAR = %08x\n", hcchar.d32);
- hcchar.b.chdis = 1;
- hcchar.b.chen = 1;
- ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
- //sleep(1);
- mdelay(1000);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //if (hcchar.b.chen) {
- // fprintf(stderr, "** Channel _still_ enabled 2, HCCHAR = %08x **\n", hcchar.d32);
- //}
- }
- /* Set HCTSIZ */
- hctsiz.d32 = 0;
- hctsiz.b.xfersize = 8;
- hctsiz.b.pktcnt = 1;
- hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
- ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
- /* Set HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
- hcchar.b.epdir = 1;
- hcchar.b.epnum = 0;
- hcchar.b.mps = 8;
- hcchar.b.chen = 1;
- ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "Waiting for RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
- /* Wait for receive status queue interrupt */
- do {
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- } while (gintsts.b.rxstsqlvl == 0);
- //fprintf(stderr, "Got RXSTSQLVL intr 1, GINTSTS = %08x\n", gintsts.d32);
- /* Read RXSTS */
- grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
- //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
- /* Clear RXSTSQLVL in GINTSTS */
- gintsts.d32 = 0;
- gintsts.b.rxstsqlvl = 1;
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- switch (grxsts.hb.pktsts) {
- case IFXUSB_HSTS_DATA_UPDT:
- /* Read the data into the host buffer */
- if (grxsts.hb.bcnt > 0) {
- int i;
- int word_count = (grxsts.hb.bcnt + 3) / 4;
- for (i = 0; i < word_count; i++) {
- (void)ifxusb_rreg(data_fifo++);
- }
- }
- //fprintf(stderr, "Received %u bytes\n", (unsigned)grxsts.hb.bcnt);
- break;
- default:
- //fprintf(stderr, "** Unexpected GRXSTS packet status 1 **\n");
- break;
- }
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "Waiting for RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
- /* Wait for receive status queue interrupt */
- do {
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- } while (gintsts.b.rxstsqlvl == 0);
- //fprintf(stderr, "Got RXSTSQLVL intr 2, GINTSTS = %08x\n", gintsts.d32);
- /* Read RXSTS */
- grxsts.d32 = ifxusb_rreg(&global_regs->grxstsp);
- //fprintf(stderr, "GRXSTS: %08x\n", grxsts.d32);
- /* Clear RXSTSQLVL in GINTSTS */
- gintsts.d32 = 0;
- gintsts.b.rxstsqlvl = 1;
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- switch (grxsts.hb.pktsts) {
- case IFXUSB_HSTS_XFER_COMP:
- break;
- default:
- //fprintf(stderr, "** Unexpected GRXSTS packet status 2 **\n");
- break;
- }
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "Waiting for HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
- /* Wait for host channel interrupt */
- do {
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- } while (gintsts.b.hcintr == 0);
- //fprintf(stderr, "Got HCINTR intr 2, GINTSTS = %08x\n", gintsts.d32);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- // usleep(100000);
- // mdelay(100);
- mdelay(1);
- /*
- * Send handshake packet
- */
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /* Make sure channel is disabled */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- if (hcchar.b.chen) {
- //fprintf(stderr, "Channel already enabled 3, HCCHAR = %08x\n", hcchar.d32);
- hcchar.b.chdis = 1;
- hcchar.b.chen = 1;
- ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
- //sleep(1);
- mdelay(1000);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //if (hcchar.b.chen) {
- // fprintf(stderr, "** Channel _still_ enabled 3, HCCHAR = %08x **\n", hcchar.d32);
- //}
- }
- /* Set HCTSIZ */
- hctsiz.d32 = 0;
- hctsiz.b.xfersize = 0;
- hctsiz.b.pktcnt = 1;
- hctsiz.b.pid = IFXUSB_HC_PID_DATA1;
- ifxusb_wreg(&hc_regs->hctsiz, hctsiz.d32);
- /* Set HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- hcchar.b.eptype = IFXUSB_EP_TYPE_CTRL;
- hcchar.b.epdir = 0;
- hcchar.b.epnum = 0;
- hcchar.b.mps = 8;
- hcchar.b.chen = 1;
- ifxusb_wreg(&hc_regs->hcchar, hcchar.d32);
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "Waiting for HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
- /* Wait for host channel interrupt */
- do {
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- } while (gintsts.b.hcintr == 0);
- //fprintf(stderr, "Got HCINTR intr 3, GINTSTS = %08x\n", gintsts.d32);
- /* Disable HCINTs */
- ifxusb_wreg(&hc_regs->hcintmsk, 0x0000);
- /* Disable HAINTs */
- ifxusb_wreg(&hc_global_regs->haintmsk, 0x0000);
- /* Read HAINT */
- haint.d32 = ifxusb_rreg(&hc_global_regs->haint);
- //fprintf(stderr, "HAINT: %08x\n", haint.d32);
- /* Read HCINT */
- hcint.d32 = ifxusb_rreg(&hc_regs->hcint);
- //fprintf(stderr, "HCINT: %08x\n", hcint.d32);
- /* Read HCCHAR */
- hcchar.d32 = ifxusb_rreg(&hc_regs->hcchar);
- //fprintf(stderr, "HCCHAR: %08x\n", hcchar.d32);
- /* Clear HCINT */
- ifxusb_wreg(&hc_regs->hcint, hcint.d32);
- /* Clear HAINT */
- ifxusb_wreg(&hc_global_regs->haint, haint.d32);
- /* Clear GINTSTS */
- ifxusb_wreg(&global_regs->gintsts, gintsts.d32);
- /* Read GINTSTS */
- gintsts.d32 = ifxusb_rreg(&global_regs->gintsts);
- //fprintf(stderr, "GINTSTS: %08x\n", gintsts.d32);
- }
- #endif //__WITH_HS_ELECT_TST__
|