xref: /openbmc/linux/arch/m68k/include/asm/mac_via.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
249148020SSam Ravnborg /*
349148020SSam Ravnborg  *	6522 Versatile Interface Adapter (VIA)
449148020SSam Ravnborg  *
549148020SSam Ravnborg  *	There are two of these on the Mac II. Some IRQ's are vectored
649148020SSam Ravnborg  *	via them as are assorted bits and bobs - eg rtc, adb. The picture
749148020SSam Ravnborg  *	is a bit incomplete as the Mac documentation doesn't cover this well
849148020SSam Ravnborg  */
949148020SSam Ravnborg 
1049148020SSam Ravnborg #ifndef _ASM_MAC_VIA_H_
1149148020SSam Ravnborg #define _ASM_MAC_VIA_H_
1249148020SSam Ravnborg 
1349148020SSam Ravnborg /*
1449148020SSam Ravnborg  * Base addresses for the VIAs. There are two in every machine,
1549148020SSam Ravnborg  * although on some machines the second is an RBV or an OSS.
1649148020SSam Ravnborg  * The OSS is different enough that it's handled separately.
1749148020SSam Ravnborg  *
1849148020SSam Ravnborg  * Do not use these values directly; use the via1 and via2 variables
1949148020SSam Ravnborg  * instead (and don't forget to check rbv_present when using via2!)
2049148020SSam Ravnborg  */
2149148020SSam Ravnborg 
2249148020SSam Ravnborg #define VIA1_BASE	(0x50F00000)
2349148020SSam Ravnborg #define VIA2_BASE	(0x50F02000)
2449148020SSam Ravnborg #define  RBV_BASE	(0x50F26000)
2549148020SSam Ravnborg 
2649148020SSam Ravnborg /*
2749148020SSam Ravnborg  *	Not all of these are true post MacII I think.
2849148020SSam Ravnborg  *      CSA: probably the ones CHRP marks as 'unused' change purposes
2949148020SSam Ravnborg  *      when the IWM becomes the SWIM.
3049148020SSam Ravnborg  *      http://www.rs6000.ibm.com/resource/technology/chrpio/via5.mak.html
3149148020SSam Ravnborg  *      ftp://ftp.austin.ibm.com/pub/technology/spec/chrp/inwork/CHRP_IORef_1.0.pdf
3249148020SSam Ravnborg  *
3349148020SSam Ravnborg  * also, http://developer.apple.com/technotes/hw/hw_09.html claims the
3449148020SSam Ravnborg  * following changes for IIfx:
3549148020SSam Ravnborg  * VIA1A_vSccWrReq not available and that VIA1A_vSync has moved to an IOP.
3649148020SSam Ravnborg  * Also, "All of the functionality of VIA2 has been moved to other chips".
3749148020SSam Ravnborg  */
3849148020SSam Ravnborg 
3949148020SSam Ravnborg #define VIA1A_vSccWrReq	0x80	/* SCC write. (input)
4049148020SSam Ravnborg 				 * [CHRP] SCC WREQ: Reflects the state of the
4149148020SSam Ravnborg 				 * Wait/Request pins from the SCC.
4249148020SSam Ravnborg 				 * [Macintosh Family Hardware]
4349148020SSam Ravnborg 				 * as CHRP on SE/30,II,IIx,IIcx,IIci.
4449148020SSam Ravnborg 				 * on IIfx, "0 means an active request"
4549148020SSam Ravnborg 				 */
4649148020SSam Ravnborg #define VIA1A_vRev8	0x40	/* Revision 8 board ???
4749148020SSam Ravnborg                                  * [CHRP] En WaitReqB: Lets the WaitReq_L
4849148020SSam Ravnborg 				 * signal from port B of the SCC appear on
4949148020SSam Ravnborg 				 * the PA7 input pin. Output.
5049148020SSam Ravnborg 				 * [Macintosh Family] On the SE/30, this
5149148020SSam Ravnborg 				 * is the bit to flip screen buffers.
5249148020SSam Ravnborg 				 * 0=alternate, 1=main.
5349148020SSam Ravnborg 				 * on II,IIx,IIcx,IIci,IIfx this is a bit
5449148020SSam Ravnborg 				 * for Rev ID. 0=II,IIx, 1=IIcx,IIci,IIfx
5549148020SSam Ravnborg 				 */
5649148020SSam Ravnborg #define VIA1A_vHeadSel	0x20	/* Head select for IWM.
5749148020SSam Ravnborg 				 * [CHRP] unused.
5849148020SSam Ravnborg 				 * [Macintosh Family] "Floppy disk
5949148020SSam Ravnborg 				 * state-control line SEL" on all but IIfx
6049148020SSam Ravnborg 				 */
6149148020SSam Ravnborg #define VIA1A_vOverlay	0x10    /* [Macintosh Family] On SE/30,II,IIx,IIcx
6249148020SSam Ravnborg 				 * this bit enables the "Overlay" address
6349148020SSam Ravnborg 				 * map in the address decoders as it is on
6449148020SSam Ravnborg 				 * reset for mapping the ROM over the reset
6549148020SSam Ravnborg 				 * vector. 1=use overlay map.
6649148020SSam Ravnborg 				 * On the IIci,IIfx it is another bit of the
6749148020SSam Ravnborg 				 * CPU ID: 0=normal IIci, 1=IIci with parity
6849148020SSam Ravnborg 				 * feature or IIfx.
6949148020SSam Ravnborg 				 * [CHRP] En WaitReqA: Lets the WaitReq_L
7049148020SSam Ravnborg 				 * signal from port A of the SCC appear
7149148020SSam Ravnborg 				 * on the PA7 input pin (CHRP). Output.
7249148020SSam Ravnborg 				 * [MkLinux] "Drive Select"
7349148020SSam Ravnborg 				 *  (with 0x20 being 'disk head select')
7449148020SSam Ravnborg 				 */
7549148020SSam Ravnborg #define VIA1A_vSync	0x08    /* [CHRP] Sync Modem: modem clock select:
7649148020SSam Ravnborg                                  * 1: select the external serial clock to
7749148020SSam Ravnborg 				 *    drive the SCC's /RTxCA pin.
7849148020SSam Ravnborg 				 * 0: Select the 3.6864MHz clock to drive
7949148020SSam Ravnborg 				 *    the SCC cell.
8049148020SSam Ravnborg 				 * [Macintosh Family] Correct on all but IIfx
8149148020SSam Ravnborg 				 */
8249148020SSam Ravnborg 
8349148020SSam Ravnborg /* Macintosh Family Hardware sez: bits 0-2 of VIA1A are volume control
8449148020SSam Ravnborg  * on Macs which had the PWM sound hardware.  Reserved on newer models.
8549148020SSam Ravnborg  * On IIci,IIfx, bits 1-2 are the rest of the CPU ID:
8649148020SSam Ravnborg  * bit 2: 1=IIci, 0=IIfx
8749148020SSam Ravnborg  * bit 1: 1 on both IIci and IIfx.
8849148020SSam Ravnborg  * MkLinux sez bit 0 is 'burnin flag' in this case.
8949148020SSam Ravnborg  * CHRP sez: VIA1A bits 0-2 and 5 are 'unused': if programmed as
9049148020SSam Ravnborg  * inputs, these bits will read 0.
9149148020SSam Ravnborg  */
9249148020SSam Ravnborg #define VIA1A_vVolume	0x07	/* Audio volume mask for PWM */
9349148020SSam Ravnborg #define VIA1A_CPUID0	0x02	/* CPU id bit 0 on RBV, others */
9449148020SSam Ravnborg #define VIA1A_CPUID1	0x04	/* CPU id bit 0 on RBV, others */
9549148020SSam Ravnborg #define VIA1A_CPUID2	0x10	/* CPU id bit 0 on RBV, others */
9649148020SSam Ravnborg #define VIA1A_CPUID3	0x40	/* CPU id bit 0 on RBV, others */
9749148020SSam Ravnborg 
9849148020SSam Ravnborg /* Info on VIA1B is from Macintosh Family Hardware & MkLinux.
9949148020SSam Ravnborg  * CHRP offers no info. */
10049148020SSam Ravnborg #define VIA1B_vSound	0x80	/* Sound enable (for compatibility with
10149148020SSam Ravnborg 				 * PWM hardware) 0=enabled.
10249148020SSam Ravnborg 				 * Also, on IIci w/parity, shows parity error
10349148020SSam Ravnborg 				 * 0=error, 1=OK. */
10449148020SSam Ravnborg #define VIA1B_vMystery	0x40    /* On IIci, parity enable. 0=enabled,1=disabled
10549148020SSam Ravnborg 				 * On SE/30, vertical sync interrupt enable.
10649148020SSam Ravnborg 				 * 0=enabled. This vSync interrupt shows up
10749148020SSam Ravnborg 				 * as a slot $E interrupt. */
10849148020SSam Ravnborg #define VIA1B_vADBS2	0x20	/* ADB state input bit 1 (unused on IIfx) */
10949148020SSam Ravnborg #define VIA1B_vADBS1	0x10	/* ADB state input bit 0 (unused on IIfx) */
11049148020SSam Ravnborg #define VIA1B_vADBInt	0x08	/* ADB interrupt 0=interrupt (unused on IIfx)*/
11149148020SSam Ravnborg #define VIA1B_vRTCEnb	0x04	/* Enable Real time clock. 0=enabled. */
11249148020SSam Ravnborg #define VIA1B_vRTCClk	0x02    /* Real time clock serial-clock line. */
11349148020SSam Ravnborg #define VIA1B_vRTCData	0x01    /* Real time clock serial-data line. */
11449148020SSam Ravnborg 
11549148020SSam Ravnborg /* MkLinux defines the following "VIA1 Register B contents where they
11649148020SSam Ravnborg  * differ from standard VIA1".  From the naming scheme, we assume they
11749148020SSam Ravnborg  * correspond to a VIA work-alike named 'EVR'. */
11849148020SSam Ravnborg #define	EVRB_XCVR	0x08	/* XCVR_SESSION* */
11949148020SSam Ravnborg #define	EVRB_FULL	0x10	/* VIA_FULL */
12049148020SSam Ravnborg #define	EVRB_SYSES	0x20	/* SYS_SESSION */
12149148020SSam Ravnborg #define	EVRB_AUXIE	0x00	/* Enable A/UX Interrupt Scheme */
12249148020SSam Ravnborg #define	EVRB_AUXID	0x40	/* Disable A/UX Interrupt Scheme */
12349148020SSam Ravnborg #define	EVRB_SFTWRIE	0x00	/* Software Interrupt ReQuest */
12449148020SSam Ravnborg #define	EVRB_SFTWRID	0x80	/* Software Interrupt ReQuest */
12549148020SSam Ravnborg 
12649148020SSam Ravnborg /*
12749148020SSam Ravnborg  *	VIA2 A register is the interrupt lines raised off the nubus
12849148020SSam Ravnborg  *	slots.
12949148020SSam Ravnborg  *      The below info is from 'Macintosh Family Hardware.'
13049148020SSam Ravnborg  *      MkLinux calls the 'IIci internal video IRQ' below the 'RBV slot 0 irq.'
13149148020SSam Ravnborg  *      It also notes that the slot $9 IRQ is the 'Ethernet IRQ' and
13249148020SSam Ravnborg  *      defines the 'Video IRQ' as 0x40 for the 'EVR' VIA work-alike.
13349148020SSam Ravnborg  *      Perhaps OSS uses vRAM1 and vRAM2 for ADB.
13449148020SSam Ravnborg  */
13549148020SSam Ravnborg 
13649148020SSam Ravnborg #define VIA2A_vRAM1	0x80	/* RAM size bit 1 (IIci: reserved) */
13749148020SSam Ravnborg #define VIA2A_vRAM0	0x40	/* RAM size bit 0 (IIci: internal video IRQ) */
13849148020SSam Ravnborg #define VIA2A_vIRQE	0x20	/* IRQ from slot $E */
13949148020SSam Ravnborg #define VIA2A_vIRQD	0x10	/* IRQ from slot $D */
14049148020SSam Ravnborg #define VIA2A_vIRQC	0x08	/* IRQ from slot $C */
14149148020SSam Ravnborg #define VIA2A_vIRQB	0x04	/* IRQ from slot $B */
14249148020SSam Ravnborg #define VIA2A_vIRQA	0x02	/* IRQ from slot $A */
14349148020SSam Ravnborg #define VIA2A_vIRQ9	0x01	/* IRQ from slot $9 */
14449148020SSam Ravnborg 
14549148020SSam Ravnborg /* RAM size bits decoded as follows:
14649148020SSam Ravnborg  * bit1 bit0  size of ICs in bank A
14749148020SSam Ravnborg  *  0    0    256 kbit
14849148020SSam Ravnborg  *  0    1    1 Mbit
14949148020SSam Ravnborg  *  1    0    4 Mbit
15049148020SSam Ravnborg  *  1    1   16 Mbit
15149148020SSam Ravnborg  */
15249148020SSam Ravnborg 
15349148020SSam Ravnborg /*
15449148020SSam Ravnborg  *	Register B has the fun stuff in it
15549148020SSam Ravnborg  */
15649148020SSam Ravnborg 
15749148020SSam Ravnborg #define VIA2B_vVBL	0x80	/* VBL output to VIA1 (60.15Hz) driven by
15849148020SSam Ravnborg 				 * timer T1.
15949148020SSam Ravnborg 				 * on IIci, parity test: 0=test mode.
16049148020SSam Ravnborg 				 * [MkLinux] RBV_PARODD: 1=odd,0=even. */
16149148020SSam Ravnborg #define VIA2B_vSndJck	0x40	/* External sound jack status.
16249148020SSam Ravnborg 				 * 0=plug is inserted.  On SE/30, always 0 */
16349148020SSam Ravnborg #define VIA2B_vTfr0	0x20	/* Transfer mode bit 0 ack from NuBus */
16449148020SSam Ravnborg #define VIA2B_vTfr1	0x10	/* Transfer mode bit 1 ack from NuBus */
16549148020SSam Ravnborg #define VIA2B_vMode32	0x08	/* 24/32bit switch - doubles as cache flush
16649148020SSam Ravnborg 				 * on II, AMU/PMMU control.
16749148020SSam Ravnborg 				 *   if AMU, 0=24bit to 32bit translation
16849148020SSam Ravnborg 				 *   if PMMU, 1=PMMU is accessing page table.
16949148020SSam Ravnborg 				 * on SE/30 tied low.
17049148020SSam Ravnborg 				 * on IIx,IIcx,IIfx, unused.
17149148020SSam Ravnborg 				 * on IIci/RBV, cache control. 0=flush cache.
17249148020SSam Ravnborg 				 */
17349148020SSam Ravnborg #define VIA2B_vPower	0x04	/* Power off, 0=shut off power.
17449148020SSam Ravnborg 				 * on SE/30 this signal sent to PDS card. */
17549148020SSam Ravnborg #define VIA2B_vBusLk	0x02	/* Lock NuBus transactions, 0=locked.
17649148020SSam Ravnborg 				 * on SE/30 sent to PDS card. */
17749148020SSam Ravnborg #define VIA2B_vCDis	0x01	/* Cache control. On IIci, 1=disable cache card
17849148020SSam Ravnborg 				 * on others, 0=disable processor's instruction
17949148020SSam Ravnborg 				 * and data caches. */
18049148020SSam Ravnborg 
18149148020SSam Ravnborg /* Apple sez: http://developer.apple.com/technotes/ov/ov_04.html
18249148020SSam Ravnborg  * Another example of a valid function that has no ROM support is the use
18349148020SSam Ravnborg  * of the alternate video page for page-flipping animation. Since there
18449148020SSam Ravnborg  * is no ROM call to flip pages, it is necessary to go play with the
18549148020SSam Ravnborg  * right bit in the VIA chip (6522 Versatile Interface Adapter).
18649148020SSam Ravnborg  * [CSA: don't know which one this is, but it's one of 'em!]
18749148020SSam Ravnborg  */
18849148020SSam Ravnborg 
18949148020SSam Ravnborg /*
19049148020SSam Ravnborg  *	6522 registers - see databook.
19149148020SSam Ravnborg  * CSA: Assignments for VIA1 confirmed from CHRP spec.
19249148020SSam Ravnborg  */
19349148020SSam Ravnborg 
19449148020SSam Ravnborg /* partial address decode.  0xYYXX : XX part for RBV, YY part for VIA */
19549148020SSam Ravnborg /* Note: 15 VIA regs, 8 RBV regs */
19649148020SSam Ravnborg 
19749148020SSam Ravnborg #define vBufB	0x0000	/* [VIA/RBV]  Register B */
19849148020SSam Ravnborg #define vBufAH	0x0200  /* [VIA only] Buffer A, with handshake. DON'T USE! */
19949148020SSam Ravnborg #define vDirB	0x0400  /* [VIA only] Data Direction Register B. */
20049148020SSam Ravnborg #define vDirA	0x0600  /* [VIA only] Data Direction Register A. */
20149148020SSam Ravnborg #define vT1CL	0x0800  /* [VIA only] Timer one counter low. */
20249148020SSam Ravnborg #define vT1CH	0x0a00  /* [VIA only] Timer one counter high. */
20349148020SSam Ravnborg #define vT1LL	0x0c00  /* [VIA only] Timer one latches low. */
20449148020SSam Ravnborg #define vT1LH	0x0e00  /* [VIA only] Timer one latches high. */
20549148020SSam Ravnborg #define vT2CL	0x1000  /* [VIA only] Timer two counter low. */
20649148020SSam Ravnborg #define vT2CH	0x1200  /* [VIA only] Timer two counter high. */
20749148020SSam Ravnborg #define vSR	0x1400  /* [VIA only] Shift register. */
20825985edcSLucas De Marchi #define vACR	0x1600  /* [VIA only] Auxiliary control register. */
20949148020SSam Ravnborg #define vPCR	0x1800  /* [VIA only] Peripheral control register. */
21049148020SSam Ravnborg                         /*            CHRP sez never ever to *write* this.
21149148020SSam Ravnborg 			 *            Mac family says never to *change* this.
21249148020SSam Ravnborg 			 * In fact we need to initialize it once at start. */
21349148020SSam Ravnborg #define vIFR	0x1a00  /* [VIA/RBV]  Interrupt flag register. */
21449148020SSam Ravnborg #define vIER	0x1c00  /* [VIA/RBV]  Interrupt enable register. */
21549148020SSam Ravnborg #define vBufA	0x1e00  /* [VIA/RBV] register A (no handshake) */
21649148020SSam Ravnborg 
21749148020SSam Ravnborg /* The RBV only decodes the bottom eight address lines; the VIA doesn't
21849148020SSam Ravnborg  * decode the bottom eight -- so vBufB | rBufB will always get you BufB */
21949148020SSam Ravnborg /* CSA: in fact, only bits 0,1, and 4 seem to be decoded.
22049148020SSam Ravnborg  * BUT note the values for rIER and rIFR, where the top 8 bits *do* seem
22149148020SSam Ravnborg  * to matter.  In fact *all* of the top 8 bits seem to matter;
22249148020SSam Ravnborg  * setting rIER=0x1813 and rIFR=0x1803 doesn't work, either.
22349148020SSam Ravnborg  * Perhaps some sort of 'compatibility mode' is built-in? [21-May-1999]
22449148020SSam Ravnborg  */
22549148020SSam Ravnborg 
22649148020SSam Ravnborg #define rBufB   0x0000  /* [VIA/RBV]  Register B */
22749148020SSam Ravnborg #define rExp	0x0001	/* [RBV only] RBV future expansion (always 0) */
22849148020SSam Ravnborg #define rSIFR	0x0002  /* [RBV only] RBV slot interrupts register. */
22949148020SSam Ravnborg #define rIFR	0x1a03  /* [VIA/RBV]  RBV interrupt flag register. */
23049148020SSam Ravnborg #define rMonP   0x0010  /* [RBV only] RBV video monitor type. */
23149148020SSam Ravnborg #define rChpT   0x0011  /* [RBV only] RBV test mode register (reads as 0). */
23249148020SSam Ravnborg #define rSIER   0x0012  /* [RBV only] RBV slot interrupt enables. */
23349148020SSam Ravnborg #define rIER    0x1c13  /* [VIA/RBV]  RBV interrupt flag enable register. */
23449148020SSam Ravnborg #define rBufA	rSIFR   /* the 'slot interrupts register' is BufA on a VIA */
23549148020SSam Ravnborg 
23649148020SSam Ravnborg /*
23749148020SSam Ravnborg  * Video monitor parameters, for rMonP:
23849148020SSam Ravnborg  */
23949148020SSam Ravnborg #define RBV_DEPTH  0x07	/* bits per pixel: 000=1,001=2,010=4,011=8 */
24049148020SSam Ravnborg #define RBV_MONID  0x38	/* monitor type, as below. */
24149148020SSam Ravnborg #define RBV_VIDOFF 0x40	/* 1 turns off onboard video */
24249148020SSam Ravnborg /* Supported monitor types: */
24349148020SSam Ravnborg #define MON_15BW   (1<<3) /* 15" BW portrait. */
24449148020SSam Ravnborg #define MON_IIGS   (2<<3) /* 12" color (modified IIGS monitor). */
24549148020SSam Ravnborg #define MON_15RGB  (5<<3) /* 15" RGB portrait. */
24649148020SSam Ravnborg #define MON_12OR13 (6<<3) /* 12" BW or 13" RGB. */
24749148020SSam Ravnborg #define MON_NONE   (7<<3) /* No monitor attached. */
24849148020SSam Ravnborg 
24949148020SSam Ravnborg /* To clarify IER manipulations */
25049148020SSam Ravnborg #define IER_SET_BIT(b) (0x80 | (1<<(b)) )
25149148020SSam Ravnborg #define IER_CLR_BIT(b) (0x7F & (1<<(b)) )
25249148020SSam Ravnborg 
25349148020SSam Ravnborg #ifndef __ASSEMBLY__
25449148020SSam Ravnborg 
25549148020SSam Ravnborg extern volatile __u8 *via1,*via2;
25649148020SSam Ravnborg extern int rbv_present,via_alt_mapping;
25749148020SSam Ravnborg 
25854b278b5SPeter Zijlstra struct irq_desc;
25954b278b5SPeter Zijlstra 
260*bcc44f6bSFinn Thain extern void via_l2_flush(int writeback);
261ed04c97dSFinn Thain extern void via_register_interrupts(void);
262ed04c97dSFinn Thain extern void via_irq_enable(int);
263ed04c97dSFinn Thain extern void via_irq_disable(int);
264c4af5da7SFinn Thain extern void via_nubus_irq_startup(int irq);
265c4af5da7SFinn Thain extern void via_nubus_irq_shutdown(int irq);
266bd0b9ac4SThomas Gleixner extern void via1_irq(struct irq_desc *desc);
267ed04c97dSFinn Thain extern void via1_set_head(int);
26830c0527dSFinn Thain extern int via2_scsi_drq_pending(void);
26930c0527dSFinn Thain 
27049148020SSam Ravnborg #endif /* __ASSEMBLY__ */
27149148020SSam Ravnborg 
27249148020SSam Ravnborg #endif /* _ASM_MAC_VIA_H_ */
273