162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
362306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive
462306a36Sopenharmony_ci * for more details.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * ioc.h: Definitions for SGI I/O Controller
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright (C) 1996 David S. Miller
962306a36Sopenharmony_ci * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle
1062306a36Sopenharmony_ci * Copyright (C) 2001, 2003 Ladislav Michl
1162306a36Sopenharmony_ci */
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef _SGI_IOC_H
1462306a36Sopenharmony_ci#define _SGI_IOC_H
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include <linux/types.h>
1762306a36Sopenharmony_ci#include <asm/sgi/pi1.h>
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*
2062306a36Sopenharmony_ci * All registers are 8-bit wide aligned on 32-bit boundary. Bad things
2162306a36Sopenharmony_ci * happen if you try word access them. You have been warned.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistruct sgioc_uart_regs {
2562306a36Sopenharmony_ci	u8 _ctrl1[3];
2662306a36Sopenharmony_ci	volatile u8 ctrl1;
2762306a36Sopenharmony_ci	u8 _data1[3];
2862306a36Sopenharmony_ci	volatile u8 data1;
2962306a36Sopenharmony_ci	u8 _ctrl2[3];
3062306a36Sopenharmony_ci	volatile u8 ctrl2;
3162306a36Sopenharmony_ci	u8 _data2[3];
3262306a36Sopenharmony_ci	volatile u8 data2;
3362306a36Sopenharmony_ci};
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_cistruct sgioc_keyb_regs {
3662306a36Sopenharmony_ci	u8 _data[3];
3762306a36Sopenharmony_ci	volatile u8 data;
3862306a36Sopenharmony_ci	u8 _command[3];
3962306a36Sopenharmony_ci	volatile u8 command;
4062306a36Sopenharmony_ci};
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cistruct sgint_regs {
4362306a36Sopenharmony_ci	u8 _istat0[3];
4462306a36Sopenharmony_ci	volatile u8 istat0;		/* Interrupt status zero */
4562306a36Sopenharmony_ci#define SGINT_ISTAT0_FFULL	0x01
4662306a36Sopenharmony_ci#define SGINT_ISTAT0_SCSI0	0x02
4762306a36Sopenharmony_ci#define SGINT_ISTAT0_SCSI1	0x04
4862306a36Sopenharmony_ci#define SGINT_ISTAT0_ENET	0x08
4962306a36Sopenharmony_ci#define SGINT_ISTAT0_GFXDMA	0x10
5062306a36Sopenharmony_ci#define SGINT_ISTAT0_PPORT	0x20
5162306a36Sopenharmony_ci#define SGINT_ISTAT0_HPC2	0x40
5262306a36Sopenharmony_ci#define SGINT_ISTAT0_LIO2	0x80
5362306a36Sopenharmony_ci	u8 _imask0[3];
5462306a36Sopenharmony_ci	volatile u8 imask0;		/* Interrupt mask zero */
5562306a36Sopenharmony_ci	u8 _istat1[3];
5662306a36Sopenharmony_ci	volatile u8 istat1;		/* Interrupt status one */
5762306a36Sopenharmony_ci#define SGINT_ISTAT1_ISDNI	0x01
5862306a36Sopenharmony_ci#define SGINT_ISTAT1_PWR	0x02
5962306a36Sopenharmony_ci#define SGINT_ISTAT1_ISDNH	0x04
6062306a36Sopenharmony_ci#define SGINT_ISTAT1_LIO3	0x08
6162306a36Sopenharmony_ci#define SGINT_ISTAT1_HPC3	0x10
6262306a36Sopenharmony_ci#define SGINT_ISTAT1_AFAIL	0x20
6362306a36Sopenharmony_ci#define SGINT_ISTAT1_VIDEO	0x40
6462306a36Sopenharmony_ci#define SGINT_ISTAT1_GIO2	0x80
6562306a36Sopenharmony_ci	u8 _imask1[3];
6662306a36Sopenharmony_ci	volatile u8 imask1;		/* Interrupt mask one */
6762306a36Sopenharmony_ci	u8 _vmeistat[3];
6862306a36Sopenharmony_ci	volatile u8 vmeistat;		/* VME interrupt status */
6962306a36Sopenharmony_ci	u8 _cmeimask0[3];
7062306a36Sopenharmony_ci	volatile u8 cmeimask0;		/* VME interrupt mask zero */
7162306a36Sopenharmony_ci	u8 _cmeimask1[3];
7262306a36Sopenharmony_ci	volatile u8 cmeimask1;		/* VME interrupt mask one */
7362306a36Sopenharmony_ci	u8 _cmepol[3];
7462306a36Sopenharmony_ci	volatile u8 cmepol;		/* VME polarity */
7562306a36Sopenharmony_ci	u8 _tclear[3];
7662306a36Sopenharmony_ci	volatile u8 tclear;
7762306a36Sopenharmony_ci	u8 _errstat[3];
7862306a36Sopenharmony_ci	volatile u8 errstat;	/* Error status reg, reserved on INT2 */
7962306a36Sopenharmony_ci	u32 _unused0[2];
8062306a36Sopenharmony_ci	u8 _tcnt0[3];
8162306a36Sopenharmony_ci	volatile u8 tcnt0;		/* counter 0 */
8262306a36Sopenharmony_ci	u8 _tcnt1[3];
8362306a36Sopenharmony_ci	volatile u8 tcnt1;		/* counter 1 */
8462306a36Sopenharmony_ci	u8 _tcnt2[3];
8562306a36Sopenharmony_ci	volatile u8 tcnt2;		/* counter 2 */
8662306a36Sopenharmony_ci	u8 _tcword[3];
8762306a36Sopenharmony_ci	volatile u8 tcword;		/* control word */
8862306a36Sopenharmony_ci#define SGINT_TCWORD_BCD	0x01	/* Use BCD mode for counters */
8962306a36Sopenharmony_ci#define SGINT_TCWORD_MMASK	0x0e	/* Mode bitmask. */
9062306a36Sopenharmony_ci#define SGINT_TCWORD_MITC	0x00	/* IRQ on terminal count (doesn't work) */
9162306a36Sopenharmony_ci#define SGINT_TCWORD_MOS	0x02	/* One-shot IRQ mode. */
9262306a36Sopenharmony_ci#define SGINT_TCWORD_MRGEN	0x04	/* Normal rate generation */
9362306a36Sopenharmony_ci#define SGINT_TCWORD_MSWGEN	0x06	/* Square wave generator mode */
9462306a36Sopenharmony_ci#define SGINT_TCWORD_MSWST	0x08	/* Software strobe */
9562306a36Sopenharmony_ci#define SGINT_TCWORD_MHWST	0x0a	/* Hardware strobe */
9662306a36Sopenharmony_ci#define SGINT_TCWORD_CMASK	0x30	/* Command mask */
9762306a36Sopenharmony_ci#define SGINT_TCWORD_CLAT	0x00	/* Latch command */
9862306a36Sopenharmony_ci#define SGINT_TCWORD_CLSB	0x10	/* LSB read/write */
9962306a36Sopenharmony_ci#define SGINT_TCWORD_CMSB	0x20	/* MSB read/write */
10062306a36Sopenharmony_ci#define SGINT_TCWORD_CALL	0x30	/* Full counter read/write */
10162306a36Sopenharmony_ci#define SGINT_TCWORD_CNT0	0x00	/* Select counter zero */
10262306a36Sopenharmony_ci#define SGINT_TCWORD_CNT1	0x40	/* Select counter one */
10362306a36Sopenharmony_ci#define SGINT_TCWORD_CNT2	0x80	/* Select counter two */
10462306a36Sopenharmony_ci#define SGINT_TCWORD_CRBCK	0xc0	/* Readback command */
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci/*
10862306a36Sopenharmony_ci * The timer is the good old 8254.  Unlike in PCs it's clocked at exactly 1MHz
10962306a36Sopenharmony_ci */
11062306a36Sopenharmony_ci#define SGINT_TIMER_CLOCK	1000000
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/*
11362306a36Sopenharmony_ci * This is the constant we're using for calibrating the counter.
11462306a36Sopenharmony_ci */
11562306a36Sopenharmony_ci#define SGINT_TCSAMP_COUNTER	((SGINT_TIMER_CLOCK / HZ) + 255)
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci/* We need software copies of these because they are write only. */
11862306a36Sopenharmony_ciextern u8 sgi_ioc_reset, sgi_ioc_write;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_cistruct sgioc_regs {
12162306a36Sopenharmony_ci	struct pi1_regs pport;
12262306a36Sopenharmony_ci	u32 _unused0[2];
12362306a36Sopenharmony_ci	struct sgioc_uart_regs uart;
12462306a36Sopenharmony_ci	struct sgioc_keyb_regs kbdmouse;
12562306a36Sopenharmony_ci	u8 _gcsel[3];
12662306a36Sopenharmony_ci	volatile u8 gcsel;
12762306a36Sopenharmony_ci	u8 _genctrl[3];
12862306a36Sopenharmony_ci	volatile u8 genctrl;
12962306a36Sopenharmony_ci	u8 _panel[3];
13062306a36Sopenharmony_ci	volatile u8 panel;
13162306a36Sopenharmony_ci#define SGIOC_PANEL_POWERON	0x01
13262306a36Sopenharmony_ci#define SGIOC_PANEL_POWERINTR	0x02
13362306a36Sopenharmony_ci#define SGIOC_PANEL_VOLDNINTR	0x10
13462306a36Sopenharmony_ci#define SGIOC_PANEL_VOLDNHOLD	0x20
13562306a36Sopenharmony_ci#define SGIOC_PANEL_VOLUPINTR	0x40
13662306a36Sopenharmony_ci#define SGIOC_PANEL_VOLUPHOLD	0x80
13762306a36Sopenharmony_ci	u32 _unused1;
13862306a36Sopenharmony_ci	u8 _sysid[3];
13962306a36Sopenharmony_ci	volatile u8 sysid;
14062306a36Sopenharmony_ci#define SGIOC_SYSID_FULLHOUSE	0x01
14162306a36Sopenharmony_ci#define SGIOC_SYSID_BOARDREV(x) (((x) & 0x1e) >> 1)
14262306a36Sopenharmony_ci#define SGIOC_SYSID_CHIPREV(x)	(((x) & 0xe0) >> 5)
14362306a36Sopenharmony_ci	u32 _unused2;
14462306a36Sopenharmony_ci	u8 _read[3];
14562306a36Sopenharmony_ci	volatile u8 read;
14662306a36Sopenharmony_ci	u32 _unused3;
14762306a36Sopenharmony_ci	u8 _dmasel[3];
14862306a36Sopenharmony_ci	volatile u8 dmasel;
14962306a36Sopenharmony_ci#define SGIOC_DMASEL_SCLK10MHZ	0x00	/* use 10MHZ serial clock */
15062306a36Sopenharmony_ci#define SGIOC_DMASEL_ISDNB	0x01	/* enable isdn B */
15162306a36Sopenharmony_ci#define SGIOC_DMASEL_ISDNA	0x02	/* enable isdn A */
15262306a36Sopenharmony_ci#define SGIOC_DMASEL_PPORT	0x04	/* use parallel DMA */
15362306a36Sopenharmony_ci#define SGIOC_DMASEL_SCLK667MHZ 0x10	/* use 6.67MHZ serial clock */
15462306a36Sopenharmony_ci#define SGIOC_DMASEL_SCLKEXT	0x20	/* use external serial clock */
15562306a36Sopenharmony_ci	u32 _unused4;
15662306a36Sopenharmony_ci	u8 _reset[3];
15762306a36Sopenharmony_ci	volatile u8 reset;
15862306a36Sopenharmony_ci#define SGIOC_RESET_PPORT	0x01	/* 0=parport reset, 1=nornal */
15962306a36Sopenharmony_ci#define SGIOC_RESET_KBDMOUSE	0x02	/* 0=kbdmouse reset, 1=normal */
16062306a36Sopenharmony_ci#define SGIOC_RESET_EISA	0x04	/* 0=eisa reset, 1=normal */
16162306a36Sopenharmony_ci#define SGIOC_RESET_ISDN	0x08	/* 0=isdn reset, 1=normal */
16262306a36Sopenharmony_ci#define SGIOC_RESET_LC0OFF	0x10	/* guiness: turn led off (red, else green) */
16362306a36Sopenharmony_ci#define SGIOC_RESET_LC1OFF	0x20	/* guiness: turn led off (green, else amber) */
16462306a36Sopenharmony_ci	u32 _unused5;
16562306a36Sopenharmony_ci	u8 _write[3];
16662306a36Sopenharmony_ci	volatile u8 write;
16762306a36Sopenharmony_ci#define SGIOC_WRITE_NTHRESH	0x01	/* use 4.5db threshold */
16862306a36Sopenharmony_ci#define SGIOC_WRITE_TPSPEED	0x02	/* use 100ohm TP speed */
16962306a36Sopenharmony_ci#define SGIOC_WRITE_EPSEL	0x04	/* force cable mode: 1=AUI 0=TP */
17062306a36Sopenharmony_ci#define SGIOC_WRITE_EASEL	0x08	/* 1=autoselect 0=manual cable selection */
17162306a36Sopenharmony_ci#define SGIOC_WRITE_U1AMODE	0x10	/* 1=PC 0=MAC UART mode */
17262306a36Sopenharmony_ci#define SGIOC_WRITE_U0AMODE	0x20	/* 1=PC 0=MAC UART mode */
17362306a36Sopenharmony_ci#define SGIOC_WRITE_MLO		0x40	/* 1=4.75V 0=+5V */
17462306a36Sopenharmony_ci#define SGIOC_WRITE_MHI		0x80	/* 1=5.25V 0=+5V */
17562306a36Sopenharmony_ci	u32 _unused6;
17662306a36Sopenharmony_ci	struct sgint_regs int3;
17762306a36Sopenharmony_ci	u32 _unused7[16];
17862306a36Sopenharmony_ci	volatile u32 extio;		/* FullHouse only */
17962306a36Sopenharmony_ci#define EXTIO_S0_IRQ_3		0x8000	/* S0: vid.vsync */
18062306a36Sopenharmony_ci#define EXTIO_S0_IRQ_2		0x4000	/* S0: gfx.fifofull */
18162306a36Sopenharmony_ci#define EXTIO_S0_IRQ_1		0x2000	/* S0: gfx.int */
18262306a36Sopenharmony_ci#define EXTIO_S0_RETRACE	0x1000
18362306a36Sopenharmony_ci#define EXTIO_SG_IRQ_3		0x0800	/* SG: vid.vsync */
18462306a36Sopenharmony_ci#define EXTIO_SG_IRQ_2		0x0400	/* SG: gfx.fifofull */
18562306a36Sopenharmony_ci#define EXTIO_SG_IRQ_1		0x0200	/* SG: gfx.int */
18662306a36Sopenharmony_ci#define EXTIO_SG_RETRACE	0x0100
18762306a36Sopenharmony_ci#define EXTIO_GIO_33MHZ		0x0080
18862306a36Sopenharmony_ci#define EXTIO_EISA_BUSERR	0x0040
18962306a36Sopenharmony_ci#define EXTIO_MC_BUSERR		0x0020
19062306a36Sopenharmony_ci#define EXTIO_HPC3_BUSERR	0x0010
19162306a36Sopenharmony_ci#define EXTIO_S0_STAT_1		0x0008
19262306a36Sopenharmony_ci#define EXTIO_S0_STAT_0		0x0004
19362306a36Sopenharmony_ci#define EXTIO_SG_STAT_1		0x0002
19462306a36Sopenharmony_ci#define EXTIO_SG_STAT_0		0x0001
19562306a36Sopenharmony_ci};
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ciextern struct sgioc_regs *sgioc;
19862306a36Sopenharmony_ciextern struct sgint_regs *sgint;
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci#endif
201