1 1.4 chs /* $NetBSD: cpi_nubusvar.h,v 1.4 2012/10/27 17:17:59 chs Exp $ */ 2 1.1 hauke 3 1.1 hauke /*- 4 1.1 hauke * Copyright (c) 2008 Hauke Fath 5 1.1 hauke * 6 1.1 hauke * Redistribution and use in source and binary forms, with or without 7 1.1 hauke * modification, are permitted provided that the following conditions 8 1.1 hauke * are met: 9 1.1 hauke * 1. Redistributions of source code must retain the above copyright 10 1.1 hauke * notice, this list of conditions and the following disclaimer. 11 1.1 hauke * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 hauke * notice, this list of conditions and the following disclaimer in the 13 1.1 hauke * documentation and/or other materials provided with the distribution. 14 1.1 hauke * 15 1.1 hauke * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 1.1 hauke * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 1.1 hauke * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 1.1 hauke * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 1.1 hauke * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 1.1 hauke * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 1.1 hauke * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 1.1 hauke * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 1.1 hauke * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 1.1 hauke * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 1.1 hauke */ 26 1.1 hauke 27 1.1 hauke #ifndef CPI_NUBUSVAR_H 28 1.1 hauke #define CPI_NUBUSVAR_H 29 1.1 hauke 30 1.1 hauke /* Where we find the Z8536 CIO in Nubus slot space */ 31 1.1 hauke #define CIO_BASE_OFFSET 0x060010 32 1.1 hauke 33 1.1 hauke /* Max. length of card name string */ 34 1.1 hauke #define CPI_CARD_NAME_LEN 64 35 1.1 hauke 36 1.1 hauke /* The CIO lives on the top 8 bit of the 32 bit data bus. */ 37 1.1 hauke enum cio_regs { 38 1.1 hauke CIO_PORTC = 0x03, 39 1.1 hauke CIO_PORTB = 0x07, 40 1.1 hauke CIO_PORTA = 0x0b, 41 1.1 hauke CIO_CTRL = 0x0f 42 1.1 hauke }; 43 1.1 hauke 44 1.1 hauke #define CPI_UNIT(c) (minor(c) & 0x1f) 45 1.1 hauke 46 1.1 hauke enum lp_state { 47 1.1 hauke LP_INITIAL = 0, /* device is closed */ 48 1.1 hauke LP_OPENING, /* device is about to be opened */ 49 1.1 hauke LP_OPEN, /* device is open */ 50 1.1 hauke LP_BUSY, /* busy with data output */ 51 1.1 hauke LP_ASLEEP, /* waiting for output completion */ 52 1.1 hauke }; 53 1.1 hauke 54 1.1 hauke /* Bit masks for Centronics status + handshake lines */ 55 1.1 hauke enum hsk_lines { 56 1.1 hauke CPI_RESET = 0x01, /* PB0 */ 57 1.1 hauke CPI_STROBE = 0x08, /* PC3 */ 58 1.1 hauke CPI_BUSY = 0x40, /* PC0 */ 59 1.1 hauke CPI_SELECT = 0x20, /* PB5 */ 60 1.1 hauke CPI_FAULT = 0x02, /* PB1 */ 61 1.1 hauke CPI_PAPER_EMPTY = 0x02, /* PC1 */ 62 1.1 hauke CPI_ACK = 0x04 /* PC2 */ 63 1.1 hauke }; 64 1.1 hauke 65 1.3 hauke /* 66 1.3 hauke * The CPI board glue logic divides the 10 MHz Nubus clock by 2, and 67 1.3 hauke * feeds it to the 8536 CIO (pin 16). The CIO divides the PCLK clock 68 1.3 hauke * by 2 internally before providing it to its counters. 69 1.3 hauke */ 70 1.3 hauke #define CPI_CLK_FREQ (10000000 / 4) 71 1.3 hauke 72 1.3 hauke /* CPI configuration options - we might grow more */ 73 1.3 hauke enum cpi_cf_flags { 74 1.3 hauke CPI_CTC12_IS_TIMECOUNTER = 0x01 75 1.3 hauke }; 76 1.3 hauke #define CPI_OPTIONS_MASK (CPI_CTC12_IS_TIMECOUNTER) 77 1.3 hauke 78 1.1 hauke struct cpi_softc { 79 1.1 hauke nubus_slot sc_slot; /* Nubus slot number */ 80 1.3 hauke char sc_cardname[CPI_CARD_NAME_LEN]; 81 1.1 hauke 82 1.1 hauke bus_addr_t sc_basepa; /* base physical address */ 83 1.1 hauke bus_space_tag_t sc_bst; 84 1.1 hauke bus_space_handle_t sc_bsh; 85 1.1 hauke 86 1.1 hauke ulong sc_intcount; /* Hard interrupts */ 87 1.1 hauke ulong sc_bytestoport; /* Bytes written to port */ 88 1.1 hauke 89 1.1 hauke struct callout sc_wakeupchan; 90 1.1 hauke 91 1.1 hauke #define CPI_BUFSIZE 0x0800 92 1.1 hauke char *sc_printbuf; /* Driver's print buffer */ 93 1.1 hauke size_t sc_bufbytes; /* # of bytes in buffer */ 94 1.1 hauke u_char *sc_cp; /* Next byte to send */ 95 1.1 hauke 96 1.1 hauke u_char sc_lpstate; 97 1.3 hauke 98 1.3 hauke ulong sc_options; 99 1.3 hauke 100 1.3 hauke struct timecounter sc_timecounter; 101 1.1 hauke }; 102 1.1 hauke 103 1.1 hauke #endif /* CPI_NUBUSVAR_H */ 104