17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_ECPPVAR_H 287c478bd9Sstevel@tonic-gate #define _SYS_ECPPVAR_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/note.h> 31*c5d54b67SRichard Lowe #include <sys/sysmacros.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate struct ecppunit; 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * Hardware-abstraction structure 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate struct ecpp_hw { 437c478bd9Sstevel@tonic-gate int (*map_regs)(struct ecppunit *); /* map registers */ 447c478bd9Sstevel@tonic-gate void (*unmap_regs)(struct ecppunit *); /* unmap registers */ 457c478bd9Sstevel@tonic-gate int (*config_chip)(struct ecppunit *); /* configure SuperIO */ 467c478bd9Sstevel@tonic-gate void (*config_mode)(struct ecppunit *); /* config new mode */ 477c478bd9Sstevel@tonic-gate void (*mask_intr)(struct ecppunit *); /* mask interrupts */ 487c478bd9Sstevel@tonic-gate void (*unmask_intr)(struct ecppunit *); /* unmask interrupts */ 497c478bd9Sstevel@tonic-gate int (*dma_start)(struct ecppunit *); /* start DMA transfer */ 507c478bd9Sstevel@tonic-gate int (*dma_stop)(struct ecppunit *, size_t *); /* stop DMA xfer */ 517c478bd9Sstevel@tonic-gate size_t (*dma_getcnt)(struct ecppunit *); /* get DMA counter */ 527c478bd9Sstevel@tonic-gate ddi_dma_attr_t *attr; /* DMA attributes */ 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #define ECPP_MAP_REGS(pp) (pp)->hw->map_regs(pp) 567c478bd9Sstevel@tonic-gate #define ECPP_UNMAP_REGS(pp) (pp)->hw->unmap_regs(pp) 577c478bd9Sstevel@tonic-gate #define ECPP_CONFIG_CHIP(pp) (pp)->hw->config_chip(pp) 587c478bd9Sstevel@tonic-gate #define ECPP_CONFIG_MODE(pp) (pp)->hw->config_mode(pp) 597c478bd9Sstevel@tonic-gate #define ECPP_MASK_INTR(pp) (pp)->hw->mask_intr(pp) 607c478bd9Sstevel@tonic-gate #define ECPP_UNMASK_INTR(pp) (pp)->hw->unmask_intr(pp) 617c478bd9Sstevel@tonic-gate #define ECPP_DMA_START(pp) (pp)->hw->dma_start(pp) 627c478bd9Sstevel@tonic-gate #define ECPP_DMA_STOP(pp, cnt) (pp)->hw->dma_stop(pp, cnt) 637c478bd9Sstevel@tonic-gate #define ECPP_DMA_GETCNT(pp) (pp)->hw->dma_getcnt(pp) 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* NSC 87332/97317 and EBus DMAC */ 667c478bd9Sstevel@tonic-gate struct ecpp_ebus { 677c478bd9Sstevel@tonic-gate struct config_reg *c_reg; /* configuration registers */ 687c478bd9Sstevel@tonic-gate ddi_acc_handle_t c_handle; /* handle for conf regs */ 697c478bd9Sstevel@tonic-gate struct cheerio_dma_reg *dmac; /* ebus dmac registers */ 707c478bd9Sstevel@tonic-gate ddi_acc_handle_t d_handle; /* handle for dmac registers */ 717c478bd9Sstevel@tonic-gate struct config2_reg *c2_reg; /* 97317 2nd level conf regs */ 727c478bd9Sstevel@tonic-gate ddi_acc_handle_t c2_handle; /* handle for c2_reg */ 737c478bd9Sstevel@tonic-gate }; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* Southbridge SuperIO and 8237 DMAC */ 767c478bd9Sstevel@tonic-gate struct ecpp_m1553 { 777c478bd9Sstevel@tonic-gate struct isaspace *isa_space; /* all of isa space */ 787c478bd9Sstevel@tonic-gate ddi_acc_handle_t d_handle; /* handle for isa space */ 797c478bd9Sstevel@tonic-gate uint8_t chn; /* 8237 dma channel */ 807c478bd9Sstevel@tonic-gate int isadma_entered; /* Southbridge DMA workaround */ 817c478bd9Sstevel@tonic-gate }; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate #if defined(__x86) 847c478bd9Sstevel@tonic-gate struct ecpp_x86 { 857c478bd9Sstevel@tonic-gate uint8_t chn; 867c478bd9Sstevel@tonic-gate }; 877c478bd9Sstevel@tonic-gate #endif 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Hardware binding structure 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate struct ecpp_hw_bind { 937c478bd9Sstevel@tonic-gate char *name; /* binding name */ 947c478bd9Sstevel@tonic-gate struct ecpp_hw *hw; /* hw description */ 957c478bd9Sstevel@tonic-gate char *info; /* info string */ 967c478bd9Sstevel@tonic-gate }; 977c478bd9Sstevel@tonic-gate 9808ec77c5SRichard Lowe /* ecpp e_busy states */ 9908ec77c5SRichard Lowe typedef enum { 10008ec77c5SRichard Lowe ECPP_IDLE = 1, /* No ongoing transfers */ 10108ec77c5SRichard Lowe ECPP_BUSY = 2, /* Ongoing transfers on the cable */ 10208ec77c5SRichard Lowe ECPP_DATA = 3, /* Not used */ 10308ec77c5SRichard Lowe ECPP_ERR = 4, /* Bad status in Centronics mode */ 10408ec77c5SRichard Lowe ECPP_FLUSH = 5 /* Currently flushing the q */ 10508ec77c5SRichard Lowe } ecpp_busy_t; 10608ec77c5SRichard Lowe 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * ecpp soft state structure 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate struct ecppunit { 1117c478bd9Sstevel@tonic-gate kmutex_t umutex; /* lock for this structure */ 1127c478bd9Sstevel@tonic-gate int instance; /* instance number */ 1137c478bd9Sstevel@tonic-gate dev_info_t *dip; /* device information */ 1147c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t ecpp_trap_cookie; /* interrupt cookie */ 11508ec77c5SRichard Lowe ecpp_busy_t e_busy; /* ecpp busy flag */ 1167c478bd9Sstevel@tonic-gate kcondvar_t pport_cv; /* cv to signal idle state */ 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * common SuperIO registers 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate struct info_reg *i_reg; /* info registers */ 1217c478bd9Sstevel@tonic-gate struct fifo_reg *f_reg; /* fifo register */ 1227c478bd9Sstevel@tonic-gate ddi_acc_handle_t i_handle; 1237c478bd9Sstevel@tonic-gate ddi_acc_handle_t f_handle; 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * DMA support 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate ddi_dma_handle_t dma_handle; /* DMA handle */ 1287c478bd9Sstevel@tonic-gate ddi_dma_cookie_t dma_cookie; /* current cookie */ 1297c478bd9Sstevel@tonic-gate uint_t dma_cookie_count; /* # of cookies */ 1307c478bd9Sstevel@tonic-gate uint_t dma_nwin; /* # of DMA windows */ 1317c478bd9Sstevel@tonic-gate uint_t dma_curwin; /* current window number */ 1327c478bd9Sstevel@tonic-gate uint_t dma_dir; /* transfer direction */ 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * hardware-dependent stuff 1357c478bd9Sstevel@tonic-gate */ 1367c478bd9Sstevel@tonic-gate struct ecpp_hw *hw; /* operations/attributes */ 1377c478bd9Sstevel@tonic-gate union { /* hw-dependent data */ 1387c478bd9Sstevel@tonic-gate struct ecpp_ebus ebus; 1397c478bd9Sstevel@tonic-gate struct ecpp_m1553 m1553; 1407c478bd9Sstevel@tonic-gate #if defined(__x86) 1417c478bd9Sstevel@tonic-gate struct ecpp_x86 x86; 1427c478bd9Sstevel@tonic-gate #endif 1437c478bd9Sstevel@tonic-gate } uh; 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * DDI/STREAMS stuff 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate boolean_t oflag; /* instance open flag */ 1487c478bd9Sstevel@tonic-gate queue_t *readq; /* pointer to readq */ 1497c478bd9Sstevel@tonic-gate queue_t *writeq; /* pointer to writeq */ 1507c478bd9Sstevel@tonic-gate mblk_t *msg; /* current message block */ 1517c478bd9Sstevel@tonic-gate boolean_t suspended; /* driver suspended status */ 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Modes of operation 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate int current_mode; /* 1284 mode */ 1567c478bd9Sstevel@tonic-gate uchar_t current_phase; /* 1284 phase */ 1577c478bd9Sstevel@tonic-gate uchar_t backchannel; /* backchannel mode supported */ 1587c478bd9Sstevel@tonic-gate uchar_t io_mode; /* transfer mode: PIO/DMA */ 1597c478bd9Sstevel@tonic-gate /* 1607c478bd9Sstevel@tonic-gate * Ioctls support 1617c478bd9Sstevel@tonic-gate */ 1627c478bd9Sstevel@tonic-gate struct ecpp_transfer_parms xfer_parms; /* transfer parameters */ 1637c478bd9Sstevel@tonic-gate struct ecpp_regs regs; /* control/status registers */ 1647c478bd9Sstevel@tonic-gate uint8_t saved_dsr; /* store the dsr returned from TESTIO */ 1657c478bd9Sstevel@tonic-gate boolean_t timeout_error; /* store the timeout for GETERR */ 1667c478bd9Sstevel@tonic-gate uchar_t port; /* xfer type: dma/pio/tfifo */ 1677c478bd9Sstevel@tonic-gate struct prn_timeouts prn_timeouts; /* prnio timeouts */ 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * ecpp.conf parameters 1707c478bd9Sstevel@tonic-gate */ 1717c478bd9Sstevel@tonic-gate uchar_t init_seq; /* centronics init seq */ 1727c478bd9Sstevel@tonic-gate uint32_t wsrv_retry; /* delay (ms) before next wsrv */ 1737c478bd9Sstevel@tonic-gate uint32_t wait_for_busy; /* wait for BUSY to deassert */ 1747c478bd9Sstevel@tonic-gate uint32_t data_setup_time; /* pio centronics handshake */ 1757c478bd9Sstevel@tonic-gate uint32_t strobe_pulse_width; /* pio centronics handshake */ 1767c478bd9Sstevel@tonic-gate uint8_t fast_centronics; /* DMA/PIO centronics */ 1777c478bd9Sstevel@tonic-gate uint8_t fast_compat; /* DMA/PIO 1284 compatible mode */ 1787c478bd9Sstevel@tonic-gate uint32_t ecp_rev_speed; /* rev xfer speed in ECP, bytes/sec */ 1797c478bd9Sstevel@tonic-gate uint32_t rev_watchdog; /* rev xfer watchdog period, ms */ 1807c478bd9Sstevel@tonic-gate /* 1817c478bd9Sstevel@tonic-gate * Timeouts 1827c478bd9Sstevel@tonic-gate */ 1837c478bd9Sstevel@tonic-gate timeout_id_t timeout_id; /* io transfers timer */ 1847c478bd9Sstevel@tonic-gate timeout_id_t fifo_timer_id; /* drain SuperIO FIFO */ 1857c478bd9Sstevel@tonic-gate timeout_id_t wsrv_timer_id; /* wsrv timeout */ 1867c478bd9Sstevel@tonic-gate /* 1877c478bd9Sstevel@tonic-gate * Softintr data 1887c478bd9Sstevel@tonic-gate */ 1897c478bd9Sstevel@tonic-gate ddi_softintr_t softintr_id; 1907c478bd9Sstevel@tonic-gate int softintr_flags; /* flags indicating softintr task */ 1917c478bd9Sstevel@tonic-gate uint8_t softintr_pending; 1927c478bd9Sstevel@tonic-gate /* 1937c478bd9Sstevel@tonic-gate * Misc stuff 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate caddr_t ioblock; /* transfer buffer block */ 1967c478bd9Sstevel@tonic-gate size_t xfercnt; /* # of bytes to transfer */ 1977c478bd9Sstevel@tonic-gate size_t resid; /* # of bytes not transferred */ 1987c478bd9Sstevel@tonic-gate caddr_t next_byte; /* next byte for PIO transfer */ 1997c478bd9Sstevel@tonic-gate caddr_t last_byte; /* last byte for PIO transfer */ 2007c478bd9Sstevel@tonic-gate uint32_t ecpp_drain_counter; /* allows fifo to drain */ 2017c478bd9Sstevel@tonic-gate uchar_t dma_cancelled; /* flushed while dma'ing */ 2027c478bd9Sstevel@tonic-gate uint8_t tfifo_intr; /* TFIFO switch interrupt workaround */ 2037c478bd9Sstevel@tonic-gate size_t nread; /* requested read */ 2047c478bd9Sstevel@tonic-gate size_t last_dmacnt; /* DMA counter value for rev watchdog */ 2057c478bd9Sstevel@tonic-gate uint32_t rev_timeout_cnt; /* number of watchdog invocations */ 2067c478bd9Sstevel@tonic-gate /* 2077c478bd9Sstevel@tonic-gate * Spurious interrupt detection 2087c478bd9Sstevel@tonic-gate */ 2097c478bd9Sstevel@tonic-gate hrtime_t lastspur; /* last time spurious intrs started */ 2107c478bd9Sstevel@tonic-gate long nspur; /* spurious intrs counter */ 2117c478bd9Sstevel@tonic-gate /* 2127c478bd9Sstevel@tonic-gate * Statistics 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate kstat_t *ksp; /* kstat pointer */ 2157c478bd9Sstevel@tonic-gate kstat_t *intrstats; /* kstat interrupt counter */ 2167c478bd9Sstevel@tonic-gate /* 2177c478bd9Sstevel@tonic-gate * number of bytes, transferred in and out in each mode 2187c478bd9Sstevel@tonic-gate */ 2197c478bd9Sstevel@tonic-gate uint32_t ctxpio_obytes; 2207c478bd9Sstevel@tonic-gate uint32_t obytes[ECPP_EPP_MODE+1]; 2217c478bd9Sstevel@tonic-gate uint32_t ibytes[ECPP_EPP_MODE+1]; 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * other stats 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate uint32_t to_mode[ECPP_EPP_MODE+1]; /* # transitions to mode */ 2267c478bd9Sstevel@tonic-gate uint32_t xfer_tout; /* # transfer timeouts */ 2277c478bd9Sstevel@tonic-gate uint32_t ctx_cf; /* # periph check failures */ 2287c478bd9Sstevel@tonic-gate uint32_t joblen; /* of bytes xfer'd since open */ 2297c478bd9Sstevel@tonic-gate uint32_t isr_reattempt_high; /* max times isr has looped */ 2307c478bd9Sstevel@tonic-gate /* 2317c478bd9Sstevel@tonic-gate * interrupt stats 2327c478bd9Sstevel@tonic-gate */ 2337c478bd9Sstevel@tonic-gate uint_t intr_hard; 2347c478bd9Sstevel@tonic-gate uint_t intr_spurious; 2357c478bd9Sstevel@tonic-gate uint_t intr_soft; 2367c478bd9Sstevel@tonic-gate /* 2377c478bd9Sstevel@tonic-gate * identify second register set for ecp mode on Sx86 2387c478bd9Sstevel@tonic-gate */ 2397c478bd9Sstevel@tonic-gate int noecpregs; 2407c478bd9Sstevel@tonic-gate }; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ecppunit::umutex, ecppunit)) 2437c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::dip)) 2447c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::instance)) 2457c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::i_reg)) 2467c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::f_reg)) 2477c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::i_handle)) 2487c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::f_handle)) 2497c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::ecpp_trap_cookie)) 2507c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::readq)) 2517c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ecppunit::writeq)) 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate /* 2547c478bd9Sstevel@tonic-gate * current_phase values 2557c478bd9Sstevel@tonic-gate */ 2567c478bd9Sstevel@tonic-gate #define ECPP_PHASE_INIT 0x00 /* initialization */ 2577c478bd9Sstevel@tonic-gate #define ECPP_PHASE_NEGO 0x01 /* negotiation */ 2587c478bd9Sstevel@tonic-gate #define ECPP_PHASE_TERM 0x02 /* termination */ 2597c478bd9Sstevel@tonic-gate #define ECPP_PHASE_PO 0x03 /* power-on */ 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate #define ECPP_PHASE_C_FWD_DMA 0x10 /* cntrx/compat fwd dma xfer */ 2627c478bd9Sstevel@tonic-gate #define ECPP_PHASE_C_FWD_PIO 0x11 /* cntrx/compat fwd PIO xfer */ 2637c478bd9Sstevel@tonic-gate #define ECPP_PHASE_C_IDLE 0x12 /* cntrx/compat idle */ 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate #define ECPP_PHASE_NIBT_REVDATA 0x20 /* nibble/byte reverse data */ 2667c478bd9Sstevel@tonic-gate #define ECPP_PHASE_NIBT_AVAIL 0x21 /* nibble/byte reverse data available */ 2677c478bd9Sstevel@tonic-gate #define ECPP_PHASE_NIBT_NAVAIL 0x22 /* nibble/byte reverse data not avail */ 2687c478bd9Sstevel@tonic-gate #define ECPP_PHASE_NIBT_REVIDLE 0x22 /* nibble/byte reverse idle */ 2697c478bd9Sstevel@tonic-gate #define ECPP_PHASE_NIBT_REVINTR 0x23 /* nibble/byte reverse interrupt */ 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_SETUP 0x30 /* ecp setup */ 2727c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_FWD_XFER 0x31 /* ecp forward transfer */ 2737c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_FWD_IDLE 0x32 /* ecp forward idle */ 2747c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_FWD_REV 0x33 /* ecp forward to reverse */ 2757c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_REV_XFER 0x34 /* ecp reverse transfer */ 2767c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_REV_IDLE 0x35 /* ecp reverse idle */ 2777c478bd9Sstevel@tonic-gate #define ECPP_PHASE_ECP_REV_FWD 0x36 /* ecp reverse to forward */ 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate #define ECPP_PHASE_EPP_INIT_IDLE 0x40 /* epp init phase */ 2807c478bd9Sstevel@tonic-gate #define ECPP_PHASE_EPP_IDLE 0x41 /* epp all-round phase */ 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate #define FAILURE_PHASE 0x80 2837c478bd9Sstevel@tonic-gate #define UNDEFINED_PHASE 0x81 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate /* ecpp return values */ 2867c478bd9Sstevel@tonic-gate #define SUCCESS 1 2877c478bd9Sstevel@tonic-gate #define FAILURE 2 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate #define TRUE 1 2907c478bd9Sstevel@tonic-gate #define FALSE 0 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* message type */ 2937c478bd9Sstevel@tonic-gate #define ECPP_BACKCHANNEL 0x45 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate /* transfer modes */ 2967c478bd9Sstevel@tonic-gate #define ECPP_DMA 0x1 2977c478bd9Sstevel@tonic-gate #define ECPP_PIO 0x2 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate /* tuneable timing defaults */ 3007c478bd9Sstevel@tonic-gate #define CENTRONICS_RETRY 750 /* 750 milliseconds */ 3017c478bd9Sstevel@tonic-gate #define WAIT_FOR_BUSY 1000 /* 1000 microseconds */ 3027c478bd9Sstevel@tonic-gate #define SUSPEND_TOUT 10 /* # seconds before suspend fails */ 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate /* Centronics hanshaking defaults */ 3057c478bd9Sstevel@tonic-gate #define DATA_SETUP_TIME 2 /* 2 uSec Data Setup Time (2x min) */ 3067c478bd9Sstevel@tonic-gate #define STROBE_PULSE_WIDTH 2 /* 2 uSec Strobe Pulse (2x min) */ 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate /* 1284 Extensibility Request values */ 3097c478bd9Sstevel@tonic-gate #define ECPP_XREQ_NIBBLE 0x00 /* Nibble Mode Rev Channel Transfer */ 3107c478bd9Sstevel@tonic-gate #define ECPP_XREQ_BYTE 0x01 /* Byte Mode Rev Channel Transfer */ 3117c478bd9Sstevel@tonic-gate #define ECPP_XREQ_ID 0x04 /* Request Device ID */ 3127c478bd9Sstevel@tonic-gate #define ECPP_XREQ_ECP 0x10 /* Request ECP Mode */ 3137c478bd9Sstevel@tonic-gate #define ECPP_XREQ_ECPRLE 0x30 /* Request ECP Mode with RLE */ 3147c478bd9Sstevel@tonic-gate #define ECPP_XREQ_EPP 0x40 /* Request EPP Mode */ 3157c478bd9Sstevel@tonic-gate #define ECPP_XREQ_XLINK 0x80 /* Request Extensibility Link */ 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate /* softintr flags */ 3187c478bd9Sstevel@tonic-gate #define ECPP_SOFTINTR_PIONEXT 0x1 /* write next byte in PIO mode */ 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate /* Stream defaults */ 3217c478bd9Sstevel@tonic-gate #define IO_BLOCK_SZ 1024 * 128 /* transfer buffer size */ 3227c478bd9Sstevel@tonic-gate #define ECPPHIWAT 32 * 1024 * 6 3237c478bd9Sstevel@tonic-gate #define ECPPLOWAT 32 * 1024 * 4 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate /* Loop timers */ 3267c478bd9Sstevel@tonic-gate #define ECPP_REG_WRITE_MAX_LOOP 100 /* cpu is faster than superio */ 3277c478bd9Sstevel@tonic-gate #define ECPP_ISR_MAX_DELAY 30 /* DMAC slow PENDING status */ 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate /* misc constants */ 3307c478bd9Sstevel@tonic-gate #define ECPP_FIFO_SZ 16 /* FIFO size */ 3317c478bd9Sstevel@tonic-gate #define FIFO_DRAIN_PERIOD 250000 /* max FIFO drain period in usec */ 3327c478bd9Sstevel@tonic-gate #define NIBBLE_REV_BLKSZ 1024 /* send up to # bytes at a time */ 3337c478bd9Sstevel@tonic-gate #define FWD_TIMEOUT_DEFAULT 90 /* forward xfer timeout in seconds */ 3347c478bd9Sstevel@tonic-gate #define REV_TIMEOUT_DEFAULT 0 /* reverse xfer timeout in seconds */ 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate /* ECP mode constants */ 3377c478bd9Sstevel@tonic-gate #define ECP_REV_BLKSZ 1024 /* send up to # bytes at a time */ 3387c478bd9Sstevel@tonic-gate #define ECP_REV_BLKSZ_MAX (4 * 1024) /* maximum of # bytes */ 3397c478bd9Sstevel@tonic-gate #define ECP_REV_SPEED (1 * 1024 * 1024) /* bytes/sec */ 3407c478bd9Sstevel@tonic-gate #define ECP_REV_MINTOUT 5 /* min ECP rev xfer timeout in ms */ 3417c478bd9Sstevel@tonic-gate #define REV_WATCHDOG 100 /* poll DMA counter every # ms */ 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate /* spurious interrupt detection */ 3447c478bd9Sstevel@tonic-gate #define SPUR_CRITICAL 100 /* number of interrupts... */ 3457c478bd9Sstevel@tonic-gate #define SPUR_PERIOD 1000000000 /* in # ns */ 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate /* 3487c478bd9Sstevel@tonic-gate * Copyin/copyout states 3497c478bd9Sstevel@tonic-gate */ 3507c478bd9Sstevel@tonic-gate #define ECPP_STRUCTIN 0 3517c478bd9Sstevel@tonic-gate #define ECPP_STRUCTOUT 1 3527c478bd9Sstevel@tonic-gate #define ECPP_ADDRIN 2 3537c478bd9Sstevel@tonic-gate #define ECPP_ADDROUT 3 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate /* 3567c478bd9Sstevel@tonic-gate * As other ioctls require the same structure, put inner struct's into union 3577c478bd9Sstevel@tonic-gate */ 3587c478bd9Sstevel@tonic-gate struct ecpp_copystate { 3597c478bd9Sstevel@tonic-gate int state; /* see above */ 3607c478bd9Sstevel@tonic-gate void *uaddr; /* user address of the following structure */ 3617c478bd9Sstevel@tonic-gate union { 3627c478bd9Sstevel@tonic-gate struct ecpp_device_id devid; 3637c478bd9Sstevel@tonic-gate struct prn_1284_device_id prn_devid; 3647c478bd9Sstevel@tonic-gate struct prn_interface_info prn_if; 3657c478bd9Sstevel@tonic-gate } un; 3667c478bd9Sstevel@tonic-gate }; 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* 3697c478bd9Sstevel@tonic-gate * The structure is dynamically created for each M_IOCTL and is bound to mblk 3707c478bd9Sstevel@tonic-gate */ 3717c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ecpp_copystate)) 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate /* kstat structure */ 3747c478bd9Sstevel@tonic-gate struct ecppkstat { 3757c478bd9Sstevel@tonic-gate /* 3767c478bd9Sstevel@tonic-gate * number of bytes, transferred in and out in each mode 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate struct kstat_named ek_ctx_obytes; 3797c478bd9Sstevel@tonic-gate struct kstat_named ek_ctxpio_obytes; 3807c478bd9Sstevel@tonic-gate struct kstat_named ek_nib_ibytes; 3817c478bd9Sstevel@tonic-gate struct kstat_named ek_ecp_obytes; 3827c478bd9Sstevel@tonic-gate struct kstat_named ek_ecp_ibytes; 3837c478bd9Sstevel@tonic-gate struct kstat_named ek_epp_obytes; 3847c478bd9Sstevel@tonic-gate struct kstat_named ek_epp_ibytes; 3857c478bd9Sstevel@tonic-gate struct kstat_named ek_diag_obytes; 3867c478bd9Sstevel@tonic-gate /* 3877c478bd9Sstevel@tonic-gate * number of transitions to particular mode 3887c478bd9Sstevel@tonic-gate */ 3897c478bd9Sstevel@tonic-gate struct kstat_named ek_to_ctx; 3907c478bd9Sstevel@tonic-gate struct kstat_named ek_to_nib; 3917c478bd9Sstevel@tonic-gate struct kstat_named ek_to_ecp; 3927c478bd9Sstevel@tonic-gate struct kstat_named ek_to_epp; 3937c478bd9Sstevel@tonic-gate struct kstat_named ek_to_diag; 3947c478bd9Sstevel@tonic-gate /* 3957c478bd9Sstevel@tonic-gate * other stats 3967c478bd9Sstevel@tonic-gate */ 3977c478bd9Sstevel@tonic-gate struct kstat_named ek_xfer_tout; /* # transfer timeouts */ 3987c478bd9Sstevel@tonic-gate struct kstat_named ek_ctx_cf; /* # periph check failures */ 3997c478bd9Sstevel@tonic-gate struct kstat_named ek_joblen; /* # bytes xfer'd since open */ 4007c478bd9Sstevel@tonic-gate struct kstat_named ek_isr_reattempt_high; /* max # times */ 4017c478bd9Sstevel@tonic-gate /* isr has looped */ 4027c478bd9Sstevel@tonic-gate struct kstat_named ek_mode; /* 1284 mode */ 4037c478bd9Sstevel@tonic-gate struct kstat_named ek_phase; /* 1284 ECP phase */ 4047c478bd9Sstevel@tonic-gate struct kstat_named ek_backchan; /* backchannel mode supported */ 4057c478bd9Sstevel@tonic-gate struct kstat_named ek_iomode; /* transfer mode: pio/dma */ 4067c478bd9Sstevel@tonic-gate struct kstat_named ek_state; /* ecpp busy flag */ 4077c478bd9Sstevel@tonic-gate }; 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate /* Macros for superio programming */ 4107c478bd9Sstevel@tonic-gate #define PP_PUTB(x, y, z) ddi_put8(x, y, z) 4117c478bd9Sstevel@tonic-gate #define PP_GETB(x, y) ddi_get8(x, y) 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate #define DSR_READ(pp) PP_GETB((pp)->i_handle, &(pp)->i_reg->dsr) 4147c478bd9Sstevel@tonic-gate #define DCR_READ(pp) PP_GETB((pp)->i_handle, &(pp)->i_reg->dcr) 4157c478bd9Sstevel@tonic-gate #define ECR_READ(pp) \ 4167c478bd9Sstevel@tonic-gate (pp->noecpregs) ? 0xff : PP_GETB((pp)->f_handle, &(pp)->f_reg->ecr) 4177c478bd9Sstevel@tonic-gate #define DATAR_READ(pp) PP_GETB((pp)->i_handle, &(pp)->i_reg->ir.datar) 4187c478bd9Sstevel@tonic-gate #define DFIFO_READ(pp) \ 4197c478bd9Sstevel@tonic-gate (pp->noecpregs) ? 0xff : PP_GETB((pp)->f_handle, &(pp)->f_reg->fr.dfifo) 4207c478bd9Sstevel@tonic-gate #define TFIFO_READ(pp) \ 4217c478bd9Sstevel@tonic-gate (pp->noecpregs) ? 0xff : PP_GETB((pp)->f_handle, &(pp)->f_reg->fr.tfifo) 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate #define DCR_WRITE(pp, val) PP_PUTB((pp)->i_handle, &(pp)->i_reg->dcr, val) 4247c478bd9Sstevel@tonic-gate #define ECR_WRITE(pp, val) \ 4257c478bd9Sstevel@tonic-gate if (!pp->noecpregs) PP_PUTB((pp)->f_handle, &(pp)->f_reg->ecr, val) 4267c478bd9Sstevel@tonic-gate #define DATAR_WRITE(pp, val) \ 4277c478bd9Sstevel@tonic-gate PP_PUTB((pp)->i_handle, &(pp)->i_reg->ir.datar, val) 4287c478bd9Sstevel@tonic-gate #define DFIFO_WRITE(pp, val) \ 4297c478bd9Sstevel@tonic-gate if (!pp->noecpregs) PP_PUTB((pp)->f_handle, &(pp)->f_reg->fr.dfifo, val) 4307c478bd9Sstevel@tonic-gate #define TFIFO_WRITE(pp, val) \ 4317c478bd9Sstevel@tonic-gate if (!pp->noecpregs) PP_PUTB((pp)->f_handle, &(pp)->f_reg->fr.tfifo, val) 4327c478bd9Sstevel@tonic-gate 4337c478bd9Sstevel@tonic-gate /* 4347c478bd9Sstevel@tonic-gate * Macros to manipulate register bits 4357c478bd9Sstevel@tonic-gate */ 4367c478bd9Sstevel@tonic-gate #define OR_SET_BYTE_R(handle, addr, val) \ 4377c478bd9Sstevel@tonic-gate { \ 4387c478bd9Sstevel@tonic-gate uint8_t tmpval; \ 4397c478bd9Sstevel@tonic-gate tmpval = ddi_get8(handle, (uint8_t *)addr); \ 4407c478bd9Sstevel@tonic-gate tmpval |= val; \ 4417c478bd9Sstevel@tonic-gate ddi_put8(handle, (uint8_t *)addr, tmpval); \ 4427c478bd9Sstevel@tonic-gate } 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate #define OR_SET_LONG_R(handle, addr, val) \ 4457c478bd9Sstevel@tonic-gate { \ 4467c478bd9Sstevel@tonic-gate uint32_t tmpval; \ 4477c478bd9Sstevel@tonic-gate tmpval = ddi_get32(handle, (uint32_t *)addr); \ 4487c478bd9Sstevel@tonic-gate tmpval |= val; \ 4497c478bd9Sstevel@tonic-gate ddi_put32(handle, (uint32_t *)addr, tmpval); \ 4507c478bd9Sstevel@tonic-gate } 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate #define AND_SET_BYTE_R(handle, addr, val) \ 4537c478bd9Sstevel@tonic-gate { \ 4547c478bd9Sstevel@tonic-gate uint8_t tmpval; \ 4557c478bd9Sstevel@tonic-gate tmpval = ddi_get8(handle, (uint8_t *)addr); \ 4567c478bd9Sstevel@tonic-gate tmpval &= val; \ 4577c478bd9Sstevel@tonic-gate ddi_put8(handle, (uint8_t *)addr, tmpval); \ 4587c478bd9Sstevel@tonic-gate } 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate #define AND_SET_LONG_R(handle, addr, val) \ 4617c478bd9Sstevel@tonic-gate { \ 4627c478bd9Sstevel@tonic-gate uint32_t tmpval; \ 4637c478bd9Sstevel@tonic-gate tmpval = ddi_get32(handle, (uint32_t *)addr); \ 4647c478bd9Sstevel@tonic-gate tmpval &= val; \ 4657c478bd9Sstevel@tonic-gate ddi_put32(handle, (uint32_t *)addr, tmpval); \ 4667c478bd9Sstevel@tonic-gate } 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate #define NOR_SET_LONG_R(handle, addr, val, mask) \ 4697c478bd9Sstevel@tonic-gate { \ 4707c478bd9Sstevel@tonic-gate uint32_t tmpval; \ 4717c478bd9Sstevel@tonic-gate tmpval = ddi_get32(handle, (uint32_t *)addr); \ 4727c478bd9Sstevel@tonic-gate tmpval &= ~(mask); \ 4737c478bd9Sstevel@tonic-gate tmpval |= val; \ 4747c478bd9Sstevel@tonic-gate ddi_put32(handle, (uint32_t *)addr, tmpval); \ 4757c478bd9Sstevel@tonic-gate } 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate /* 4787c478bd9Sstevel@tonic-gate * Macros for Cheerio/RIO DMAC programming 4797c478bd9Sstevel@tonic-gate */ 4807c478bd9Sstevel@tonic-gate #define SET_DMAC_CSR(pp, val) ddi_put32(pp->uh.ebus.d_handle, \ 4817c478bd9Sstevel@tonic-gate ((uint32_t *)&pp->uh.ebus.dmac->csr), \ 4827c478bd9Sstevel@tonic-gate ((uint32_t)val)) 4837c478bd9Sstevel@tonic-gate #define GET_DMAC_CSR(pp) ddi_get32(pp->uh.ebus.d_handle, \ 4847c478bd9Sstevel@tonic-gate (uint32_t *)&(pp->uh.ebus.dmac->csr)) 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate #define SET_DMAC_ACR(pp, val) ddi_put32(pp->uh.ebus.d_handle, \ 4877c478bd9Sstevel@tonic-gate ((uint32_t *)&pp->uh.ebus.dmac->acr), \ 4887c478bd9Sstevel@tonic-gate ((uint32_t)val)) 4897c478bd9Sstevel@tonic-gate 4907c478bd9Sstevel@tonic-gate #define GET_DMAC_ACR(pp) ddi_get32(pp->uh.ebus.d_handle, \ 4917c478bd9Sstevel@tonic-gate (uint32_t *)&pp->uh.ebus.dmac->acr) 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate #define SET_DMAC_BCR(pp, val) ddi_put32(pp->uh.ebus.d_handle, \ 4947c478bd9Sstevel@tonic-gate ((uint32_t *)&pp->uh.ebus.dmac->bcr), \ 4957c478bd9Sstevel@tonic-gate ((uint32_t)val)) 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate #define GET_DMAC_BCR(pp) ddi_get32(pp->uh.ebus.d_handle, \ 4987c478bd9Sstevel@tonic-gate ((uint32_t *)&pp->uh.ebus.dmac->bcr)) 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate #define DMAC_RESET_TIMEOUT 10000 /* in usec */ 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate /* 5037c478bd9Sstevel@tonic-gate * Macros to distinguish between PIO and DMA Compatibility mode 5047c478bd9Sstevel@tonic-gate */ 5057c478bd9Sstevel@tonic-gate #define COMPAT_PIO(pp) (((pp)->io_mode == ECPP_PIO) && \ 5067c478bd9Sstevel@tonic-gate ((pp)->current_mode == ECPP_CENTRONICS || \ 5077c478bd9Sstevel@tonic-gate (pp)->current_mode == ECPP_COMPAT_MODE)) 5087c478bd9Sstevel@tonic-gate 5097c478bd9Sstevel@tonic-gate #define COMPAT_DMA(pp) (((pp)->io_mode == ECPP_DMA) && \ 5107c478bd9Sstevel@tonic-gate ((pp)->current_mode == ECPP_CENTRONICS || \ 5117c478bd9Sstevel@tonic-gate (pp)->current_mode == ECPP_COMPAT_MODE)) 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate /* 5147c478bd9Sstevel@tonic-gate * Other useful macros 5157c478bd9Sstevel@tonic-gate */ 5167c478bd9Sstevel@tonic-gate #define NELEM(a) (sizeof (a) / sizeof (*(a))) 5177c478bd9Sstevel@tonic-gate 5187c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5197c478bd9Sstevel@tonic-gate } 5207c478bd9Sstevel@tonic-gate #endif 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate #endif /* _SYS_ECPPVAR_H */ 523