|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
#define PUN_IOSEL 60
|
|
|
|
|
|
+/* ACM channel */
|
|
|
#define PUN_TTY_CHAN 1
|
|
|
#if PUN_TTY_CHAN >= TTY_CHANNELS
|
|
|
# error "PUN_TTY_CHAN out of range"
|
|
@@ -23,8 +24,8 @@
|
|
|
#define PUN_IRQPOL TTY_IRQPOL(PUN_TTY_CHAN)
|
|
|
#define PUN_IRQ TTY_NIRQ(PUN_TTY_CHAN)
|
|
|
|
|
|
-#define PUN_IRQ_MASK (TTY_STATUS_TX_FULL|TTY_STATUS_RX_EMPTY|\
|
|
|
- TTY_STATUS_DTR_IN)
|
|
|
+#define PUN_IRQ_MASK (TTY_STATUS_TX_HIGH|TTY_STATUS_RX_LOW|\
|
|
|
+ TTY_STATUS_RX_EMPTY|TTY_STATUS_DTR_IN)
|
|
|
|
|
|
static struct abc_dev pun80_iodev;
|
|
|
|
|
@@ -50,12 +51,13 @@ pun80_refresh_input(struct abc_dev *dev, bool advance)
|
|
|
}
|
|
|
|
|
|
PUN_IRQPOL = status;
|
|
|
- pun80_status = ~15 | data_loaded;
|
|
|
|
|
|
- if (status & TTY_STATUS_DTR_IN)
|
|
|
- pun80_status |= 8;
|
|
|
- if (!(status & TTY_STATUS_TX_FULL))
|
|
|
- pun80_status |= 2;
|
|
|
+ pun80_status = 0xe6;
|
|
|
+ pun80_status ^= !!(status & TTY_STATUS_RX_LOW) << 4;
|
|
|
+ pun80_status ^= !!(status & TTY_STATUS_USB_CONFIG) << 3;
|
|
|
+ pun80_status ^= !!(status & TTY_STATUS_DTR_IN) << 2;
|
|
|
+ pun80_status ^= !!(status & TTY_STATUS_TX_HIGH) << 1;
|
|
|
+ pun80_status ^= data_loaded;
|
|
|
|
|
|
dev->inp_data[1] = pun80_status;
|
|
|
|
|
@@ -66,11 +68,13 @@ pun80_refresh_input(struct abc_dev *dev, bool advance)
|
|
|
static ABC_CALLBACK(pun80_callback_out)
|
|
|
{
|
|
|
PUN_DATA = data;
|
|
|
+ CON_DATA = '>';
|
|
|
pun80_refresh_input(dev, false);
|
|
|
}
|
|
|
|
|
|
static ABC_CALLBACK(pun80_callback_inp)
|
|
|
{
|
|
|
+ CON_DATA = '<';
|
|
|
pun80_refresh_input(dev, true);
|
|
|
}
|
|
|
|
|
@@ -84,7 +88,7 @@ IRQHANDLER(tty,PUN_TTY_CHAN)
|
|
|
static struct abc_dev pun80_iodev = {
|
|
|
.callback_mask = (1 << 0)|(1 << 8),
|
|
|
.inp_en = 3,
|
|
|
- .inp_data[1] = 0xf0,
|
|
|
+ .inp_data[1] = 0xf6,
|
|
|
.status_first_out_mask = ~0,
|
|
|
.status_first_inp_mask = ~0,
|
|
|
.callback_out[0] = pun80_callback_out,
|
|
@@ -94,14 +98,29 @@ static struct abc_dev pun80_iodev = {
|
|
|
void pun80_init(void)
|
|
|
{
|
|
|
mask_irq(PUN_IRQ);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Set the TX high water mark to 1/4 = 256 bytes free. This allows
|
|
|
+ * OTIR to be used unconditionally for large transfers after
|
|
|
+ * polling the TX buffer status only once. The buffer is large
|
|
|
+ * enough that this should always be true in practice.
|
|
|
+ *
|
|
|
+ * The RX low water mark is set to 1/8 = 128 bytes occupied for
|
|
|
+ * similar reasons. This is added as a non-FT232H status bit 4 if
|
|
|
+ * 0 (FT232H always has 1 in this bit position.)
|
|
|
+ */
|
|
|
+ PUN_WATERCTL = TTY_WATERCTL_TX_LOW(0x3) | TTY_WATERCTL_TX_HIGH(0xc) |
|
|
|
+ TTY_WATERCTL_RX_LOW(0x1) | TTY_WATERCTL_TX_HIGH(0xc);
|
|
|
+
|
|
|
/*
|
|
|
- * Immediately interrupt on:
|
|
|
+ * Immediately interrupt on any of:
|
|
|
*
|
|
|
* USB configured
|
|
|
- * TX full
|
|
|
+ * DTR asserted (host connected)
|
|
|
+ * TX not past high water mark
|
|
|
* RX not empty
|
|
|
*/
|
|
|
- PUN_IRQPOL = TTY_STATUS_RX_EMPTY;
|
|
|
+ PUN_IRQPOL = TTY_STATUS_RX_EMPTY | TTY_STATUS_RX_LOW | TTY_STATUS_TX_HIGH;
|
|
|
PUN_IRQEN = PUN_IRQ_MASK;
|
|
|
unmask_irq(PUN_IRQ);
|
|
|
|