162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * 6522 Versatile Interface Adapter (VIA) 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * There are two of these on the Mac II. Some IRQ's are vectored 662306a36Sopenharmony_ci * via them as are assorted bits and bobs - eg rtc, adb. The picture 762306a36Sopenharmony_ci * is a bit incomplete as the Mac documentation doesn't cover this well 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _ASM_MAC_VIA_H_ 1162306a36Sopenharmony_ci#define _ASM_MAC_VIA_H_ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* 1462306a36Sopenharmony_ci * Base addresses for the VIAs. There are two in every machine, 1562306a36Sopenharmony_ci * although on some machines the second is an RBV or an OSS. 1662306a36Sopenharmony_ci * The OSS is different enough that it's handled separately. 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * Do not use these values directly; use the via1 and via2 variables 1962306a36Sopenharmony_ci * instead (and don't forget to check rbv_present when using via2!) 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define VIA1_BASE (0x50F00000) 2362306a36Sopenharmony_ci#define VIA2_BASE (0x50F02000) 2462306a36Sopenharmony_ci#define RBV_BASE (0x50F26000) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * Not all of these are true post MacII I think. 2862306a36Sopenharmony_ci * CSA: probably the ones CHRP marks as 'unused' change purposes 2962306a36Sopenharmony_ci * when the IWM becomes the SWIM. 3062306a36Sopenharmony_ci * http://www.rs6000.ibm.com/resource/technology/chrpio/via5.mak.html 3162306a36Sopenharmony_ci * ftp://ftp.austin.ibm.com/pub/technology/spec/chrp/inwork/CHRP_IORef_1.0.pdf 3262306a36Sopenharmony_ci * 3362306a36Sopenharmony_ci * also, http://developer.apple.com/technotes/hw/hw_09.html claims the 3462306a36Sopenharmony_ci * following changes for IIfx: 3562306a36Sopenharmony_ci * VIA1A_vSccWrReq not available and that VIA1A_vSync has moved to an IOP. 3662306a36Sopenharmony_ci * Also, "All of the functionality of VIA2 has been moved to other chips". 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define VIA1A_vSccWrReq 0x80 /* SCC write. (input) 4062306a36Sopenharmony_ci * [CHRP] SCC WREQ: Reflects the state of the 4162306a36Sopenharmony_ci * Wait/Request pins from the SCC. 4262306a36Sopenharmony_ci * [Macintosh Family Hardware] 4362306a36Sopenharmony_ci * as CHRP on SE/30,II,IIx,IIcx,IIci. 4462306a36Sopenharmony_ci * on IIfx, "0 means an active request" 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci#define VIA1A_vRev8 0x40 /* Revision 8 board ??? 4762306a36Sopenharmony_ci * [CHRP] En WaitReqB: Lets the WaitReq_L 4862306a36Sopenharmony_ci * signal from port B of the SCC appear on 4962306a36Sopenharmony_ci * the PA7 input pin. Output. 5062306a36Sopenharmony_ci * [Macintosh Family] On the SE/30, this 5162306a36Sopenharmony_ci * is the bit to flip screen buffers. 5262306a36Sopenharmony_ci * 0=alternate, 1=main. 5362306a36Sopenharmony_ci * on II,IIx,IIcx,IIci,IIfx this is a bit 5462306a36Sopenharmony_ci * for Rev ID. 0=II,IIx, 1=IIcx,IIci,IIfx 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_ci#define VIA1A_vHeadSel 0x20 /* Head select for IWM. 5762306a36Sopenharmony_ci * [CHRP] unused. 5862306a36Sopenharmony_ci * [Macintosh Family] "Floppy disk 5962306a36Sopenharmony_ci * state-control line SEL" on all but IIfx 6062306a36Sopenharmony_ci */ 6162306a36Sopenharmony_ci#define VIA1A_vOverlay 0x10 /* [Macintosh Family] On SE/30,II,IIx,IIcx 6262306a36Sopenharmony_ci * this bit enables the "Overlay" address 6362306a36Sopenharmony_ci * map in the address decoders as it is on 6462306a36Sopenharmony_ci * reset for mapping the ROM over the reset 6562306a36Sopenharmony_ci * vector. 1=use overlay map. 6662306a36Sopenharmony_ci * On the IIci,IIfx it is another bit of the 6762306a36Sopenharmony_ci * CPU ID: 0=normal IIci, 1=IIci with parity 6862306a36Sopenharmony_ci * feature or IIfx. 6962306a36Sopenharmony_ci * [CHRP] En WaitReqA: Lets the WaitReq_L 7062306a36Sopenharmony_ci * signal from port A of the SCC appear 7162306a36Sopenharmony_ci * on the PA7 input pin (CHRP). Output. 7262306a36Sopenharmony_ci * [MkLinux] "Drive Select" 7362306a36Sopenharmony_ci * (with 0x20 being 'disk head select') 7462306a36Sopenharmony_ci */ 7562306a36Sopenharmony_ci#define VIA1A_vSync 0x08 /* [CHRP] Sync Modem: modem clock select: 7662306a36Sopenharmony_ci * 1: select the external serial clock to 7762306a36Sopenharmony_ci * drive the SCC's /RTxCA pin. 7862306a36Sopenharmony_ci * 0: Select the 3.6864MHz clock to drive 7962306a36Sopenharmony_ci * the SCC cell. 8062306a36Sopenharmony_ci * [Macintosh Family] Correct on all but IIfx 8162306a36Sopenharmony_ci */ 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/* Macintosh Family Hardware sez: bits 0-2 of VIA1A are volume control 8462306a36Sopenharmony_ci * on Macs which had the PWM sound hardware. Reserved on newer models. 8562306a36Sopenharmony_ci * On IIci,IIfx, bits 1-2 are the rest of the CPU ID: 8662306a36Sopenharmony_ci * bit 2: 1=IIci, 0=IIfx 8762306a36Sopenharmony_ci * bit 1: 1 on both IIci and IIfx. 8862306a36Sopenharmony_ci * MkLinux sez bit 0 is 'burnin flag' in this case. 8962306a36Sopenharmony_ci * CHRP sez: VIA1A bits 0-2 and 5 are 'unused': if programmed as 9062306a36Sopenharmony_ci * inputs, these bits will read 0. 9162306a36Sopenharmony_ci */ 9262306a36Sopenharmony_ci#define VIA1A_vVolume 0x07 /* Audio volume mask for PWM */ 9362306a36Sopenharmony_ci#define VIA1A_CPUID0 0x02 /* CPU id bit 0 on RBV, others */ 9462306a36Sopenharmony_ci#define VIA1A_CPUID1 0x04 /* CPU id bit 0 on RBV, others */ 9562306a36Sopenharmony_ci#define VIA1A_CPUID2 0x10 /* CPU id bit 0 on RBV, others */ 9662306a36Sopenharmony_ci#define VIA1A_CPUID3 0x40 /* CPU id bit 0 on RBV, others */ 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci/* Info on VIA1B is from Macintosh Family Hardware & MkLinux. 9962306a36Sopenharmony_ci * CHRP offers no info. */ 10062306a36Sopenharmony_ci#define VIA1B_vSound 0x80 /* Sound enable (for compatibility with 10162306a36Sopenharmony_ci * PWM hardware) 0=enabled. 10262306a36Sopenharmony_ci * Also, on IIci w/parity, shows parity error 10362306a36Sopenharmony_ci * 0=error, 1=OK. */ 10462306a36Sopenharmony_ci#define VIA1B_vMystery 0x40 /* On IIci, parity enable. 0=enabled,1=disabled 10562306a36Sopenharmony_ci * On SE/30, vertical sync interrupt enable. 10662306a36Sopenharmony_ci * 0=enabled. This vSync interrupt shows up 10762306a36Sopenharmony_ci * as a slot $E interrupt. */ 10862306a36Sopenharmony_ci#define VIA1B_vADBS2 0x20 /* ADB state input bit 1 (unused on IIfx) */ 10962306a36Sopenharmony_ci#define VIA1B_vADBS1 0x10 /* ADB state input bit 0 (unused on IIfx) */ 11062306a36Sopenharmony_ci#define VIA1B_vADBInt 0x08 /* ADB interrupt 0=interrupt (unused on IIfx)*/ 11162306a36Sopenharmony_ci#define VIA1B_vRTCEnb 0x04 /* Enable Real time clock. 0=enabled. */ 11262306a36Sopenharmony_ci#define VIA1B_vRTCClk 0x02 /* Real time clock serial-clock line. */ 11362306a36Sopenharmony_ci#define VIA1B_vRTCData 0x01 /* Real time clock serial-data line. */ 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci/* MkLinux defines the following "VIA1 Register B contents where they 11662306a36Sopenharmony_ci * differ from standard VIA1". From the naming scheme, we assume they 11762306a36Sopenharmony_ci * correspond to a VIA work-alike named 'EVR'. */ 11862306a36Sopenharmony_ci#define EVRB_XCVR 0x08 /* XCVR_SESSION* */ 11962306a36Sopenharmony_ci#define EVRB_FULL 0x10 /* VIA_FULL */ 12062306a36Sopenharmony_ci#define EVRB_SYSES 0x20 /* SYS_SESSION */ 12162306a36Sopenharmony_ci#define EVRB_AUXIE 0x00 /* Enable A/UX Interrupt Scheme */ 12262306a36Sopenharmony_ci#define EVRB_AUXID 0x40 /* Disable A/UX Interrupt Scheme */ 12362306a36Sopenharmony_ci#define EVRB_SFTWRIE 0x00 /* Software Interrupt ReQuest */ 12462306a36Sopenharmony_ci#define EVRB_SFTWRID 0x80 /* Software Interrupt ReQuest */ 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci/* 12762306a36Sopenharmony_ci * VIA2 A register is the interrupt lines raised off the nubus 12862306a36Sopenharmony_ci * slots. 12962306a36Sopenharmony_ci * The below info is from 'Macintosh Family Hardware.' 13062306a36Sopenharmony_ci * MkLinux calls the 'IIci internal video IRQ' below the 'RBV slot 0 irq.' 13162306a36Sopenharmony_ci * It also notes that the slot $9 IRQ is the 'Ethernet IRQ' and 13262306a36Sopenharmony_ci * defines the 'Video IRQ' as 0x40 for the 'EVR' VIA work-alike. 13362306a36Sopenharmony_ci * Perhaps OSS uses vRAM1 and vRAM2 for ADB. 13462306a36Sopenharmony_ci */ 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci#define VIA2A_vRAM1 0x80 /* RAM size bit 1 (IIci: reserved) */ 13762306a36Sopenharmony_ci#define VIA2A_vRAM0 0x40 /* RAM size bit 0 (IIci: internal video IRQ) */ 13862306a36Sopenharmony_ci#define VIA2A_vIRQE 0x20 /* IRQ from slot $E */ 13962306a36Sopenharmony_ci#define VIA2A_vIRQD 0x10 /* IRQ from slot $D */ 14062306a36Sopenharmony_ci#define VIA2A_vIRQC 0x08 /* IRQ from slot $C */ 14162306a36Sopenharmony_ci#define VIA2A_vIRQB 0x04 /* IRQ from slot $B */ 14262306a36Sopenharmony_ci#define VIA2A_vIRQA 0x02 /* IRQ from slot $A */ 14362306a36Sopenharmony_ci#define VIA2A_vIRQ9 0x01 /* IRQ from slot $9 */ 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci/* RAM size bits decoded as follows: 14662306a36Sopenharmony_ci * bit1 bit0 size of ICs in bank A 14762306a36Sopenharmony_ci * 0 0 256 kbit 14862306a36Sopenharmony_ci * 0 1 1 Mbit 14962306a36Sopenharmony_ci * 1 0 4 Mbit 15062306a36Sopenharmony_ci * 1 1 16 Mbit 15162306a36Sopenharmony_ci */ 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci/* 15462306a36Sopenharmony_ci * Register B has the fun stuff in it 15562306a36Sopenharmony_ci */ 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci#define VIA2B_vVBL 0x80 /* VBL output to VIA1 (60.15Hz) driven by 15862306a36Sopenharmony_ci * timer T1. 15962306a36Sopenharmony_ci * on IIci, parity test: 0=test mode. 16062306a36Sopenharmony_ci * [MkLinux] RBV_PARODD: 1=odd,0=even. */ 16162306a36Sopenharmony_ci#define VIA2B_vSndJck 0x40 /* External sound jack status. 16262306a36Sopenharmony_ci * 0=plug is inserted. On SE/30, always 0 */ 16362306a36Sopenharmony_ci#define VIA2B_vTfr0 0x20 /* Transfer mode bit 0 ack from NuBus */ 16462306a36Sopenharmony_ci#define VIA2B_vTfr1 0x10 /* Transfer mode bit 1 ack from NuBus */ 16562306a36Sopenharmony_ci#define VIA2B_vMode32 0x08 /* 24/32bit switch - doubles as cache flush 16662306a36Sopenharmony_ci * on II, AMU/PMMU control. 16762306a36Sopenharmony_ci * if AMU, 0=24bit to 32bit translation 16862306a36Sopenharmony_ci * if PMMU, 1=PMMU is accessing page table. 16962306a36Sopenharmony_ci * on SE/30 tied low. 17062306a36Sopenharmony_ci * on IIx,IIcx,IIfx, unused. 17162306a36Sopenharmony_ci * on IIci/RBV, cache control. 0=flush cache. 17262306a36Sopenharmony_ci */ 17362306a36Sopenharmony_ci#define VIA2B_vPower 0x04 /* Power off, 0=shut off power. 17462306a36Sopenharmony_ci * on SE/30 this signal sent to PDS card. */ 17562306a36Sopenharmony_ci#define VIA2B_vBusLk 0x02 /* Lock NuBus transactions, 0=locked. 17662306a36Sopenharmony_ci * on SE/30 sent to PDS card. */ 17762306a36Sopenharmony_ci#define VIA2B_vCDis 0x01 /* Cache control. On IIci, 1=disable cache card 17862306a36Sopenharmony_ci * on others, 0=disable processor's instruction 17962306a36Sopenharmony_ci * and data caches. */ 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/* Apple sez: http://developer.apple.com/technotes/ov/ov_04.html 18262306a36Sopenharmony_ci * Another example of a valid function that has no ROM support is the use 18362306a36Sopenharmony_ci * of the alternate video page for page-flipping animation. Since there 18462306a36Sopenharmony_ci * is no ROM call to flip pages, it is necessary to go play with the 18562306a36Sopenharmony_ci * right bit in the VIA chip (6522 Versatile Interface Adapter). 18662306a36Sopenharmony_ci * [CSA: don't know which one this is, but it's one of 'em!] 18762306a36Sopenharmony_ci */ 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci/* 19062306a36Sopenharmony_ci * 6522 registers - see databook. 19162306a36Sopenharmony_ci * CSA: Assignments for VIA1 confirmed from CHRP spec. 19262306a36Sopenharmony_ci */ 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci/* partial address decode. 0xYYXX : XX part for RBV, YY part for VIA */ 19562306a36Sopenharmony_ci/* Note: 15 VIA regs, 8 RBV regs */ 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci#define vBufB 0x0000 /* [VIA/RBV] Register B */ 19862306a36Sopenharmony_ci#define vBufAH 0x0200 /* [VIA only] Buffer A, with handshake. DON'T USE! */ 19962306a36Sopenharmony_ci#define vDirB 0x0400 /* [VIA only] Data Direction Register B. */ 20062306a36Sopenharmony_ci#define vDirA 0x0600 /* [VIA only] Data Direction Register A. */ 20162306a36Sopenharmony_ci#define vT1CL 0x0800 /* [VIA only] Timer one counter low. */ 20262306a36Sopenharmony_ci#define vT1CH 0x0a00 /* [VIA only] Timer one counter high. */ 20362306a36Sopenharmony_ci#define vT1LL 0x0c00 /* [VIA only] Timer one latches low. */ 20462306a36Sopenharmony_ci#define vT1LH 0x0e00 /* [VIA only] Timer one latches high. */ 20562306a36Sopenharmony_ci#define vT2CL 0x1000 /* [VIA only] Timer two counter low. */ 20662306a36Sopenharmony_ci#define vT2CH 0x1200 /* [VIA only] Timer two counter high. */ 20762306a36Sopenharmony_ci#define vSR 0x1400 /* [VIA only] Shift register. */ 20862306a36Sopenharmony_ci#define vACR 0x1600 /* [VIA only] Auxiliary control register. */ 20962306a36Sopenharmony_ci#define vPCR 0x1800 /* [VIA only] Peripheral control register. */ 21062306a36Sopenharmony_ci /* CHRP sez never ever to *write* this. 21162306a36Sopenharmony_ci * Mac family says never to *change* this. 21262306a36Sopenharmony_ci * In fact we need to initialize it once at start. */ 21362306a36Sopenharmony_ci#define vIFR 0x1a00 /* [VIA/RBV] Interrupt flag register. */ 21462306a36Sopenharmony_ci#define vIER 0x1c00 /* [VIA/RBV] Interrupt enable register. */ 21562306a36Sopenharmony_ci#define vBufA 0x1e00 /* [VIA/RBV] register A (no handshake) */ 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci/* The RBV only decodes the bottom eight address lines; the VIA doesn't 21862306a36Sopenharmony_ci * decode the bottom eight -- so vBufB | rBufB will always get you BufB */ 21962306a36Sopenharmony_ci/* CSA: in fact, only bits 0,1, and 4 seem to be decoded. 22062306a36Sopenharmony_ci * BUT note the values for rIER and rIFR, where the top 8 bits *do* seem 22162306a36Sopenharmony_ci * to matter. In fact *all* of the top 8 bits seem to matter; 22262306a36Sopenharmony_ci * setting rIER=0x1813 and rIFR=0x1803 doesn't work, either. 22362306a36Sopenharmony_ci * Perhaps some sort of 'compatibility mode' is built-in? [21-May-1999] 22462306a36Sopenharmony_ci */ 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci#define rBufB 0x0000 /* [VIA/RBV] Register B */ 22762306a36Sopenharmony_ci#define rExp 0x0001 /* [RBV only] RBV future expansion (always 0) */ 22862306a36Sopenharmony_ci#define rSIFR 0x0002 /* [RBV only] RBV slot interrupts register. */ 22962306a36Sopenharmony_ci#define rIFR 0x1a03 /* [VIA/RBV] RBV interrupt flag register. */ 23062306a36Sopenharmony_ci#define rMonP 0x0010 /* [RBV only] RBV video monitor type. */ 23162306a36Sopenharmony_ci#define rChpT 0x0011 /* [RBV only] RBV test mode register (reads as 0). */ 23262306a36Sopenharmony_ci#define rSIER 0x0012 /* [RBV only] RBV slot interrupt enables. */ 23362306a36Sopenharmony_ci#define rIER 0x1c13 /* [VIA/RBV] RBV interrupt flag enable register. */ 23462306a36Sopenharmony_ci#define rBufA rSIFR /* the 'slot interrupts register' is BufA on a VIA */ 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci/* 23762306a36Sopenharmony_ci * Video monitor parameters, for rMonP: 23862306a36Sopenharmony_ci */ 23962306a36Sopenharmony_ci#define RBV_DEPTH 0x07 /* bits per pixel: 000=1,001=2,010=4,011=8 */ 24062306a36Sopenharmony_ci#define RBV_MONID 0x38 /* monitor type, as below. */ 24162306a36Sopenharmony_ci#define RBV_VIDOFF 0x40 /* 1 turns off onboard video */ 24262306a36Sopenharmony_ci/* Supported monitor types: */ 24362306a36Sopenharmony_ci#define MON_15BW (1<<3) /* 15" BW portrait. */ 24462306a36Sopenharmony_ci#define MON_IIGS (2<<3) /* 12" color (modified IIGS monitor). */ 24562306a36Sopenharmony_ci#define MON_15RGB (5<<3) /* 15" RGB portrait. */ 24662306a36Sopenharmony_ci#define MON_12OR13 (6<<3) /* 12" BW or 13" RGB. */ 24762306a36Sopenharmony_ci#define MON_NONE (7<<3) /* No monitor attached. */ 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci/* To clarify IER manipulations */ 25062306a36Sopenharmony_ci#define IER_SET_BIT(b) (0x80 | (1<<(b)) ) 25162306a36Sopenharmony_ci#define IER_CLR_BIT(b) (0x7F & (1<<(b)) ) 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ciextern volatile __u8 *via1,*via2; 25662306a36Sopenharmony_ciextern int rbv_present,via_alt_mapping; 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_cistruct irq_desc; 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ciextern void via_l2_flush(int writeback); 26162306a36Sopenharmony_ciextern void via_register_interrupts(void); 26262306a36Sopenharmony_ciextern void via_irq_enable(int); 26362306a36Sopenharmony_ciextern void via_irq_disable(int); 26462306a36Sopenharmony_ciextern void via_nubus_irq_startup(int irq); 26562306a36Sopenharmony_ciextern void via_nubus_irq_shutdown(int irq); 26662306a36Sopenharmony_ciextern void via1_irq(struct irq_desc *desc); 26762306a36Sopenharmony_ciextern void via1_set_head(int); 26862306a36Sopenharmony_ciextern int via2_scsi_drq_pending(void); 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ci#endif /* _ASM_MAC_VIA_H_ */ 273