/* $Id: loop.s,v 1.23 2000/03/20 09:49:06 warner Exp $
*
* Firmware for the Keyspan PDA Serial Adapter, a USB serial port based on
* the EzUSB microcontroller.
*
* (C) Copyright 2000 Brian Warner <warner@lothar.com>
*
* 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.
*
* "Keyspan PDA Serial Adapter" is probably a copyright of Keyspan, the
* company.
*
* This serial adapter is basically an EzUSB chip and an RS-232 line driver
* in a little widget that has a DB-9 on one end and a USB plug on the other.
* It uses the EzUSB's internal UART0 (using the pins from Port C) and timer2
* as a baud-rate generator. The wiring is:
* PC0/RxD0 <- rxd (DB9 pin 2) PC4 <- dsr pin 6
* PC1/TxD0 -> txd pin 3 PC5 <- ri pin 9
* PC2 -> rts pin 7 PC6 <- dcd pin 1
* PC3 <- cts pin 8 PC7 -> dtr pin 4
* PB1 -> line driver standby
*
* The EzUSB register constants below come from their excellent documentation
* and sample code (which used to be available at www.anchorchips.com, but
* that has now been absorbed into Cypress' site and the CD-ROM contents
* don't appear to be available online anymore). If we get multiple
* EzUSB-based drivers into the kernel, it might be useful to pull them out
* into a separate .h file.
*
* THEORY OF OPERATION:
*
* There are two 256-byte ring buffers, one for tx, one for rx.
*
* EP2out is pure tx data. When it appears, the data is copied into the tx
* ring and serial transmission is started if it wasn't already running. The
* "tx buffer empty" interrupt may kick off another character if the ring
* still has data. If the host is tx-blocked because the ring filled up,
* it will request a "tx unthrottle" interrupt. If sending a serial character
* empties the ring below the desired threshold, we set a bit that will send
* up the tx unthrottle message as soon as the rx buffer becomes free.
*
* EP2in (interrupt) is used to send both rx chars and rx status messages
* (only "tx unthrottle" at this time) back up to the host. The first byte
* of the rx message indicates data (0) or status msg (1). Status messages
* are sent before any data.
*