18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * mesh.h: definitions for the driver for the MESH SCSI bus adaptor
48c2ecf20Sopenharmony_ci * (Macintosh Enhanced SCSI Hardware) found on Power Macintosh computers.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 1996 Paul Mackerras.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci#ifndef _MESH_H
98c2ecf20Sopenharmony_ci#define _MESH_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * Registers in the MESH controller.
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct mesh_regs {
168c2ecf20Sopenharmony_ci	unsigned char	count_lo;
178c2ecf20Sopenharmony_ci	char pad0[15];
188c2ecf20Sopenharmony_ci	unsigned char	count_hi;
198c2ecf20Sopenharmony_ci	char pad1[15];
208c2ecf20Sopenharmony_ci	unsigned char	fifo;
218c2ecf20Sopenharmony_ci	char pad2[15];
228c2ecf20Sopenharmony_ci	unsigned char	sequence;
238c2ecf20Sopenharmony_ci	char pad3[15];
248c2ecf20Sopenharmony_ci	unsigned char	bus_status0;
258c2ecf20Sopenharmony_ci	char pad4[15];
268c2ecf20Sopenharmony_ci	unsigned char	bus_status1;
278c2ecf20Sopenharmony_ci	char pad5[15];
288c2ecf20Sopenharmony_ci	unsigned char	fifo_count;
298c2ecf20Sopenharmony_ci	char pad6[15];
308c2ecf20Sopenharmony_ci	unsigned char	exception;
318c2ecf20Sopenharmony_ci	char pad7[15];
328c2ecf20Sopenharmony_ci	unsigned char	error;
338c2ecf20Sopenharmony_ci	char pad8[15];
348c2ecf20Sopenharmony_ci	unsigned char	intr_mask;
358c2ecf20Sopenharmony_ci	char pad9[15];
368c2ecf20Sopenharmony_ci	unsigned char	interrupt;
378c2ecf20Sopenharmony_ci	char pad10[15];
388c2ecf20Sopenharmony_ci	unsigned char	source_id;
398c2ecf20Sopenharmony_ci	char pad11[15];
408c2ecf20Sopenharmony_ci	unsigned char	dest_id;
418c2ecf20Sopenharmony_ci	char pad12[15];
428c2ecf20Sopenharmony_ci	unsigned char	sync_params;
438c2ecf20Sopenharmony_ci	char pad13[15];
448c2ecf20Sopenharmony_ci	unsigned char	mesh_id;
458c2ecf20Sopenharmony_ci	char pad14[15];
468c2ecf20Sopenharmony_ci	unsigned char	sel_timeout;
478c2ecf20Sopenharmony_ci	char pad15[15];
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* Bits in the sequence register. */
518c2ecf20Sopenharmony_ci#define SEQ_DMA_MODE	0x80	/* use DMA for data transfer */
528c2ecf20Sopenharmony_ci#define SEQ_TARGET	0x40	/* put the controller into target mode */
538c2ecf20Sopenharmony_ci#define SEQ_ATN		0x20	/* assert ATN signal */
548c2ecf20Sopenharmony_ci#define SEQ_ACTIVE_NEG	0x10	/* use active negation on REQ/ACK */
558c2ecf20Sopenharmony_ci#define SEQ_CMD		0x0f	/* command bits: */
568c2ecf20Sopenharmony_ci#define SEQ_ARBITRATE	1	/*  get the bus */
578c2ecf20Sopenharmony_ci#define SEQ_SELECT	2	/*  select a target */
588c2ecf20Sopenharmony_ci#define SEQ_COMMAND	3	/*  send a command */
598c2ecf20Sopenharmony_ci#define SEQ_STATUS	4	/*  receive status */
608c2ecf20Sopenharmony_ci#define SEQ_DATAOUT	5	/*  send data */
618c2ecf20Sopenharmony_ci#define SEQ_DATAIN	6	/*  receive data */
628c2ecf20Sopenharmony_ci#define SEQ_MSGOUT	7	/*  send a message */
638c2ecf20Sopenharmony_ci#define SEQ_MSGIN	8	/*  receive a message */
648c2ecf20Sopenharmony_ci#define SEQ_BUSFREE	9	/*  look for bus free */
658c2ecf20Sopenharmony_ci#define SEQ_ENBPARITY	0x0a	/*  enable parity checking */
668c2ecf20Sopenharmony_ci#define SEQ_DISPARITY	0x0b	/*  disable parity checking */
678c2ecf20Sopenharmony_ci#define SEQ_ENBRESEL	0x0c	/*  enable reselection */
688c2ecf20Sopenharmony_ci#define SEQ_DISRESEL	0x0d	/*  disable reselection */
698c2ecf20Sopenharmony_ci#define SEQ_RESETMESH	0x0e	/*  reset the controller */
708c2ecf20Sopenharmony_ci#define SEQ_FLUSHFIFO	0x0f	/*  clear out the FIFO */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Bits in the bus_status0 and bus_status1 registers:
738c2ecf20Sopenharmony_ci   these correspond directly to the SCSI bus control signals. */
748c2ecf20Sopenharmony_ci#define BS0_REQ		0x20
758c2ecf20Sopenharmony_ci#define BS0_ACK		0x10
768c2ecf20Sopenharmony_ci#define BS0_ATN		0x08
778c2ecf20Sopenharmony_ci#define BS0_MSG		0x04
788c2ecf20Sopenharmony_ci#define BS0_CD		0x02
798c2ecf20Sopenharmony_ci#define BS0_IO		0x01
808c2ecf20Sopenharmony_ci#define BS1_RST		0x80
818c2ecf20Sopenharmony_ci#define BS1_BSY		0x40
828c2ecf20Sopenharmony_ci#define BS1_SEL		0x20
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/* Bus phases defined by the bits in bus_status0 */
858c2ecf20Sopenharmony_ci#define BS0_PHASE	(BS0_MSG+BS0_CD+BS0_IO)
868c2ecf20Sopenharmony_ci#define BP_DATAOUT	0
878c2ecf20Sopenharmony_ci#define BP_DATAIN	BS0_IO
888c2ecf20Sopenharmony_ci#define BP_COMMAND	BS0_CD
898c2ecf20Sopenharmony_ci#define BP_STATUS	(BS0_CD+BS0_IO)
908c2ecf20Sopenharmony_ci#define BP_MSGOUT	(BS0_MSG+BS0_CD)
918c2ecf20Sopenharmony_ci#define BP_MSGIN	(BS0_MSG+BS0_CD+BS0_IO)
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* Bits in the exception register. */
948c2ecf20Sopenharmony_ci#define EXC_SELWATN	0x20	/* (as target) we were selected with ATN */
958c2ecf20Sopenharmony_ci#define EXC_SELECTED	0x10	/* (as target) we were selected w/o ATN */
968c2ecf20Sopenharmony_ci#define EXC_RESELECTED	0x08	/* (as initiator) we were reselected */
978c2ecf20Sopenharmony_ci#define EXC_ARBLOST	0x04	/* we lost arbitration */
988c2ecf20Sopenharmony_ci#define EXC_PHASEMM	0x02	/* SCSI phase mismatch */
998c2ecf20Sopenharmony_ci#define EXC_SELTO	0x01	/* selection timeout */
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/* Bits in the error register */
1028c2ecf20Sopenharmony_ci#define ERR_UNEXPDISC	0x40	/* target unexpectedly disconnected */
1038c2ecf20Sopenharmony_ci#define ERR_SCSIRESET	0x20	/* SCSI bus got reset on us */
1048c2ecf20Sopenharmony_ci#define ERR_SEQERR	0x10	/* we did something the chip didn't like */
1058c2ecf20Sopenharmony_ci#define ERR_PARITY	0x01	/* parity error was detected */
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci/* Bits in the interrupt and intr_mask registers */
1088c2ecf20Sopenharmony_ci#define INT_ERROR	0x04	/* error interrupt */
1098c2ecf20Sopenharmony_ci#define INT_EXCEPTION	0x02	/* exception interrupt */
1108c2ecf20Sopenharmony_ci#define INT_CMDDONE	0x01	/* command done interrupt */
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/* Fields in the sync_params register */
1138c2ecf20Sopenharmony_ci#define SYNC_OFF(x)	((x) >> 4)	/* offset field */
1148c2ecf20Sopenharmony_ci#define SYNC_PER(x)	((x) & 0xf)	/* period field */
1158c2ecf20Sopenharmony_ci#define SYNC_PARAMS(o, p)	(((o) << 4) | (p))
1168c2ecf20Sopenharmony_ci#define ASYNC_PARAMS	2	/* sync_params value for async xfers */
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/*
1198c2ecf20Sopenharmony_ci * Assuming a clock frequency of 50MHz:
1208c2ecf20Sopenharmony_ci *
1218c2ecf20Sopenharmony_ci * The transfer period with SYNC_PER(sync_params) == x
1228c2ecf20Sopenharmony_ci * is (x + 2) * 40ns, except that x == 0 gives 100ns.
1238c2ecf20Sopenharmony_ci *
1248c2ecf20Sopenharmony_ci * The units of the sel_timeout register are 10ms.
1258c2ecf20Sopenharmony_ci */
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#endif /* _MESH_H */
129