11.3Shauke/*	$NetBSD: z8536reg.h,v 1.3 2012/01/31 22:13:19 hauke Exp $	*/
21.1Shauke
31.1Shauke/*-
41.1Shauke * Copyright (c) 2008 Hauke Fath
51.1Shauke *
61.1Shauke * Redistribution and use in source and binary forms, with or without
71.1Shauke * modification, are permitted provided that the following conditions
81.1Shauke * are met:
91.1Shauke * 1. Redistributions of source code must retain the above copyright
101.1Shauke *    notice, this list of conditions and the following disclaimer.
111.1Shauke * 2. Redistributions in binary form must reproduce the above copyright
121.1Shauke *    notice, this list of conditions and the following disclaimer in the
131.1Shauke *    documentation and/or other materials provided with the distribution.
141.1Shauke *
151.1Shauke * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161.1Shauke * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171.1Shauke * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181.1Shauke * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191.1Shauke * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201.1Shauke * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211.1Shauke * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221.1Shauke * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231.1Shauke * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241.1Shauke * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251.1Shauke */
261.1Shauke
271.1Shauke/*
281.1Shauke * Zilog Z8536 CIO (Counter/Timer and Parallel I/O Unit)
291.1Shauke * Register Definitions
301.1Shauke *
311.1Shauke * The CIO has four registers: One control register, and three data
321.1Shauke * registers for ports A/B/C. To set up the CIO through the control
331.1Shauke * register, first write the number of the internal register to it,
341.1Shauke * then access or set the selected register contents. Once selected,
351.1Shauke * an internal register can be polled continuously by reading out the
361.1Shauke * control port.
371.1Shauke *
381.1Shauke * Internal registers are read-writable, except where noted.
391.1Shauke */
401.1Shauke#define Z8536_IOSIZE		0x04
411.1Shauke
421.1Shauke#define Z8536_MICR		0x00	/* Master Interrupt Control Register */
431.1Shauke#define       MICR_RESET	0x01	/* Chip Reset */
441.1Shauke#define	      MICR_RJA		0x02	/* Only z8036 (ZBUS version) */
451.1Shauke#define	      MICR_CTVIS	0x04	/* CT     vector includes status */
461.1Shauke#define	      MICR_PBVIS	0x08	/* Port B vector includes status */
471.1Shauke#define	      MICR_PAVIS	0x10	/* Port A vector includes status */
481.1Shauke#define	      MICR_NV		0x20	/* No Vector (NV) */
491.1Shauke#define	      MICR_DLC		0x40	/* Disable Lower Chain (DLC) */
501.1Shauke#define	      MICR_MIE		0x80	/* Master Interrupt Enable (MIE) */
511.1Shauke
521.1Shauke#define Z8536_MCCR         	0x01	/* Master Configuration Register */
531.1Shauke#define       MCCR_CTINDPT   	0x00 	/* Counter/Timers Independent */
541.1Shauke#define       MCCR_CT1GT2  	0x01 	/* CT 1 /OUTPUT gates CT 2 */
551.1Shauke#define       MCCR_CT1TR2  	0x02 	/* CT 1 /OUTPUT triggers CT 2 */
561.1Shauke#define       MCCR_CT1CT2  	0x03 	/* CT 1 /OUTPUT is CT 2's COUNT */
571.1Shauke#define       MCCR_PAE     	0x04 	/* Port A Enable */
581.1Shauke#define       MCCR_PLC     	0x08 	/* Port Link Control (A/B) */
591.1Shauke#define       MCCR_PC_CT3E    	0x10 	/* Counter/Timer 3 + Port C Enable */
601.1Shauke#define       MCCR_CT2E    	0x20 	/* Counter/Timer 2 Enable */
611.1Shauke#define       MCCR_CT1E    	0x40	/* Counter/Timer 1 Enable */
621.1Shauke#define       MCCR_PBE     	0x80	/* Port B Enable */
631.1Shauke
641.1Shauke/* Interrupt Vector Registers */
651.1Shauke#define Z8536_IVRA       	0x02	/* Port A Interrupt Vector */
661.1Shauke#define Z8536_IVRB       	0x03	/* Port B Interrupt Vector */
671.1Shauke#define Z8536_IVRCT		0x04	/* Counter/Timer Interrupt Vector */
681.1Shauke
691.1Shauke/* Port C setup */
701.1Shauke#define Z8536_DPPRC        	0x05	/* Port C Data Path Polarity */
711.1Shauke#define Z8536_DDRC         	0x06	/* Port C Data Direction */
721.1Shauke#define Z8536_SIOCRC       	0x07	/* Port C Special I/O Control */
731.1Shauke
741.1Shauke#define Z8536_PCSRA        	0x08	/* Port A Command and Status */
751.1Shauke#define Z8536_PCSRB        	0x09	/* Port B Command and Status */
761.1Shauke
771.1Shauke/* Z8536_PCSRA + Z8536_PCSRB command and status bits */
781.1Shauke#define      PCSR_IOE		0x01	/* Interrupt on error */
791.1Shauke#define      PCSR_PMF		0x02	/* Pattern match flag (RO) */
801.1Shauke#define      PCSR_IRF		0x04	/* Input register full (RO) */
811.1Shauke#define      PCSR_ORE		0x08	/* Output register empty (RO) */
821.1Shauke#define      PCSR_ERR		0x10	/* Interrupt error */
831.1Shauke#define      PCSR_IP		0x20	/* Interrupt pending */
841.1Shauke#define      PCSR_IE		0x40	/* Interrupt enable */
851.1Shauke#define      PCSR_IUS		0x80	/* Interrupt under service */
861.1Shauke/* PCSR{A,B} interrupt bits: IUS/IE/IP */
871.1Shauke#define       PCSR_NULL		0x00  	/* Null Code */
881.1Shauke#define       PCSR_CLR_IP_IUS	0x20  	/* Clear IP and IUS */
891.1Shauke#define       PCSR_SET_IUS	0x40  	/* Set Interrupt Under Service */
901.1Shauke#define       PCSR_CLR_IUS	0x60  	/* Clear Interrupt Under Service */
911.1Shauke#define       PCSR_SET_IP	0x80  	/* Set Interrupt Pending */
921.1Shauke#define       PCSR_CLR_IP	0xA0  	/* Clear Interrupt Pending */
931.1Shauke#define       PCSR_SET_IE	0xC0  	/* Set Interrupt Enable */
941.1Shauke#define       PCSR_CLR_IE	0xE0  	/* Clear Interrupt Enable */
951.1Shauke
961.1Shauke/* Counter/Timer 1..3 Command and Status Registers */
971.1Shauke#define Z8536_CTCSR1       	0x0A 	/* CT 1 Command and Status */
981.1Shauke#define Z8536_CTCSR2       	0x0B 	/* CT 2 Command and Status */
991.1Shauke#define Z8536_CTCSR3       	0x0C 	/* CT 3 Command and Status */
1001.1Shauke
1011.1Shauke/* CTCSR setup bits */
1021.1Shauke#define       CTCS_CIP     	0x01 	/* Count in Progress (RO) */
1031.1Shauke#define       CTCS_TCB     	0x02 	/* Trigger Command Bit (WO) */
1041.1Shauke#define       CTCS_GCB     	0x04 	/* Gate Command Bit */
1051.1Shauke#define       CTCS_RCC     	0x08 	/* Read Counter Control */
1061.1Shauke#define       CTCS_ERR     	0x10 	/* Interrupt Error (RO) */
1071.1Shauke#define       CTCS_IP      	0x20 	/* Interrupt Pending */
1081.1Shauke#define       CTCS_IE      	0x40 	/* Interrupt Enable */
1091.1Shauke#define       CTCS_IUS     	0x80 	/* Interrupt Under Service */
1101.1Shauke
1111.1Shauke/* CTCSR interrupt bits: IUS/IE/IP */
1121.1Shauke#define       CTCS_NULL		0x00  	/* Null Code */
1131.1Shauke#define       CTCS_CLR_IP_IUS	0x20  	/* Clear IP and IUS */
1141.1Shauke#define       CTCS_SET_IUS	0x40  	/* Set Interrupt Under Service */
1151.1Shauke#define       CTCS_CLR_IUS	0x60  	/* Clear Interrupt Under Service */
1161.1Shauke#define       CTCS_SET_IP	0x80  	/* Set Interrupt Pending */
1171.1Shauke#define       CTCS_CLR_IP	0xA0  	/* Clear Interrupt Pending */
1181.1Shauke#define       CTCS_SET_IE	0xC0  	/* Set Interrupt Enable */
1191.1Shauke#define       CTCS_CLR_IE	0xE0  	/* Clear Interrupt Enable */
1201.1Shauke
1211.3Shauke/* Avoid changing intr bits unintendedly */
1221.3Shauke#define	CTCSR_MASK(FLAGS)	((FLAGS) & 0x3f)
1231.3Shauke
1241.1Shauke/* The port data registers are directly accessible at their own IO address */
1251.1Shauke#define Z8536_PDRA         	0x0D	/* Port A Data Register */
1261.1Shauke#define Z8536_PDRB         	0x0E	/* Port B Data Register */
1271.1Shauke#define Z8536_PDRC         	0x0F	/* Port C Data Register */
1281.1Shauke
1291.1Shauke/* Bytewise access to current count registers (read-only) */
1301.1Shauke#define Z8536_CTCCR1_MSB 	0x10	/* CT 1 Current Count MSB  */
1311.1Shauke#define Z8536_CTCCR1_LSB 	0x11	/* CT 1 Current Count LSB  */
1321.1Shauke#define Z8536_CTCCR2_MSB 	0x12	/* CT 2 Current Count MSB  */
1331.1Shauke#define Z8536_CTCCR2_LSB 	0x13	/* CT 2 Current Count LSB  */
1341.1Shauke#define Z8536_CTCCR3_MSB 	0x14	/* CT 3 Current Count MSB  */
1351.1Shauke#define Z8536_CTCCR3_LSB 	0x15	/* CT 3 Current Count LSB  */
1361.1Shauke
1371.1Shauke/* Bytewise access to time constant registers */
1381.1Shauke#define Z8536_CTTCR1_MSB 	0x16	/* CT 1 Time Constant MSB  */
1391.1Shauke#define Z8536_CTTCR1_LSB 	0x17	/* CT 1 Time Constant LSB  */
1401.1Shauke#define Z8536_CTTCR2_MSB 	0x18	/* CT 2 Time Constant MSB  */
1411.1Shauke#define Z8536_CTTCR2_LSB 	0x19	/* CT 2 Time Constant LSB  */
1421.1Shauke#define Z8536_CTTCR3_MSB 	0x1A	/* CT 3 Time Constant MSB  */
1431.1Shauke#define Z8536_CTTCR3_LSB 	0x1B	/* CT 3 Time Constant LSB  */
1441.1Shauke
1451.1Shauke/* Counter/Timer Mode specification */
1461.1Shauke#define Z8536_CTMSR1       	0x1C 	/* CT 1 Mode Specification */
1471.1Shauke#define Z8536_CTMSR2       	0x1D 	/* CT 2 Mode Specification */
1481.1Shauke#define Z8536_CTMSR3       	0x1E 	/* CT 3 Mode Specification */
1491.1Shauke#define       CTMS_DCS_PULSE	0x00  	/* Pulse Output */
1501.1Shauke#define       CTMS_DCS_ONESHOT	0x01  	/* One-Shot Output */
1511.1Shauke#define       CTMS_DCS_SQUARE	0x02  	/* Square Wave Output */
1521.1Shauke#define       CTMS_REB		0x04  	/* Retrigger Enable */
1531.1Shauke#define       CTMS_EGE		0x08  	/* External Gate Enable */
1541.1Shauke#define       CTMS_ETE		0x10  	/* External Trigger Enable  */
1551.1Shauke#define       CTMS_ECE		0x20  	/* External Count Enable */
1561.1Shauke#define       CTMS_EOE		0x40  	/* External Output Enable */
1571.1Shauke#define       CTMS_CSC		0x80  	/* Continuous / Single Cycle */
1581.1Shauke
1591.1Shauke#define Z8536_CVR         	0x1F	/* Current Interrupt Vector (RO) */
1601.1Shauke
1611.1Shauke/* Port A specification registers */
1621.1Shauke#define Z8536_PMSRA        	0x20	/* Port A Mode Specification */
1631.1Shauke#define Z8536_PHSRA        	0x21	/* Port A Handshake Specification */
1641.1Shauke#define Z8536_DPPRA        	0x22	/* Port A Data Path Polarity */
1651.1Shauke#define Z8536_DDRA         	0x23	/* Port A Data Direction */
1661.1Shauke#define Z8536_SIOCRA       	0x24	/* Port A Special I/O Control */
1671.1Shauke#define Z8536_PPRA         	0x25	/* Port A Pattern Polarity */
1681.1Shauke#define Z8536_PTRA         	0x26	/* Port A Pattern Transition */
1691.1Shauke#define Z8536_PMRA         	0x27	/* Port A Pattern Mask */
1701.1Shauke
1711.1Shauke/* Port B specification registers */
1721.1Shauke#define Z8536_PMSRB        	0x28	/* Port B Mode Specification */
1731.1Shauke#define Z8536_PHSRB        	0x29	/* Port B Handshake Specification */
1741.1Shauke#define Z8536_DPPRB        	0x2A	/* Port B Data Path Polarity */
1751.1Shauke#define Z8536_DDRB         	0x2B	/* Port B Data Direction */
1761.1Shauke#define Z8536_SIOCRB       	0x2C	/* Port B Special I/O Control */
1771.1Shauke#define Z8536_PPRB         	0x2D	/* Port B Pattern Polarity */
1781.1Shauke#define Z8536_PTRB         	0x2E	/* Port B Pattern Transition */
1791.1Shauke#define Z8536_PMRB         	0x2F	/* Port B Pattern Mask */
1801.1Shauke
1811.1Shauke/* Bit definitions, common to ports A and B */
1821.1Shauke
1831.1Shauke/* Z8536_PMSRA + Z8536_PMSRB port mode specification bits */
1841.1Shauke#define       PMSR_LPM		0x01	/* Bit mode: latched */
1851.1Shauke#define       PMSR_DTE		0x01	/* Hsk mode: deskew timer enable */
1861.1Shauke/*
1871.1Shauke *	PMS1	PMS0	Pattern mode specification
1881.1Shauke *	0	0	disable pattern match
1891.1Shauke *	0	1	"and" mode, transition-triggered interrupt
1901.1Shauke *	1	0	"or" mode, transition-triggered interrupt
1911.1Shauke *	1	1	"or-priority encoded vector" mode, level-
1921.1Shauke *			triggered interrupt (only transparent LPM mode)
1931.1Shauke */
1941.1Shauke#define       PMSR_PMS0		0x02
1951.1Shauke#define       PMSR_PMS1		0x04
1961.1Shauke#define       PMSR_PMS_OFF	0x00	/* Disable pattern match */
1971.1Shauke#define       PMSR_PMS_AND	0x02	/* "and" mode, transition-triggered */
1981.1Shauke#define       PMSR_PMS_OR	0x04	/* "or" mode, transition-triggered */
1991.1Shauke/*
2001.1Shauke * "or-priority encoded vector" mode, level-triggered interrupt
2011.1Shauke * (only in transparent LPM mode)
2021.1Shauke */
2031.1Shauke#define       PMSR_PMS_OR_PEV	0x06
2041.1Shauke#define       PMSR_IMO		0x08	/* Interrupt on match only */
2051.1Shauke#define       PMSR_SB		0x10	/* Single buffered mode */
2061.1Shauke#define       PMSR_ITB		0x20	/* Interrupt on two bytes */
2071.1Shauke/*
2081.1Shauke *	PTS1	PTS0	Port type selects
2091.1Shauke *	0	0	bit port
2101.1Shauke *	0	1	input port
2111.1Shauke *	1	0	output port
2121.1Shauke *	1	1	bidirectional port
2131.1Shauke */
2141.1Shauke#define       PMSR_PTS0		0x40
2151.1Shauke#define       PMSR_PTS1		0x80
2161.1Shauke#define       PMSR_PTS_BIT	0x00
2171.1Shauke#define       PMSR_PTS_IN	0x40
2181.1Shauke#define       PMSR_PTS_OUT	0x80
2191.1Shauke#define       PMSR_PTS_BIDI	0xC0
2201.1Shauke/*
2211.1Shauke * Z8536_PHSRA + Z8536_PHSRB port handshake specification bits
2221.1Shauke * Bits 0-2 set deskew timer for output ports
2231.1Shauke *
2241.1Shauke *	RWS2	RWS1	RWS0	Status signals on port C
2251.1Shauke *	0	0	0	REQUEST/-WAIT disabled
2261.1Shauke *	0	0	1	output -WAIT
2271.1Shauke *	0	1	1	input -WAIT
2281.1Shauke *	1	0	0	special REQUEST
2291.1Shauke *	1	0	1	output REQUEST
2301.1Shauke *	1	1	1	input REQUEST
2311.1Shauke */
2321.1Shauke#define	      PHSR_RWS0		0x08
2331.1Shauke#define	      PHSR_RWS1		0x10
2341.1Shauke#define	      PHSR_RWS2		0x20
2351.1Shauke/*
2361.1Shauke *	HTS1	HTS0	Handshake type specification
2371.1Shauke *	0	0	interlocked handshake
2381.1Shauke *	0	1	strobed handshake
2391.1Shauke *	1	0	pulsed handshake
2401.1Shauke *	1	1	three-wire-handshake
2411.1Shauke */
2421.1Shauke#define       PHSR_HTS0		0x40
2431.1Shauke#define	      PHSR_HTS1		0x80
2441.1Shauke#define	      PHSR_HTS_INT	0x00
2451.1Shauke#define	      PHSR_HTS_STR	0x40
2461.1Shauke#define	      PHSR_HTS_PUL	0x80
2471.1Shauke#define	      PHSR_HTS_TWI	0xC0
248