xref: /linux/drivers/scsi/sym53c8xx_2/sym_fw.h (revision 5111eefa17615bdf17ca00ec2cdca16302c7697e)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
31da177e4SLinus Torvalds  * of PCI-SCSI IO processors.
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * This driver is derived from the Linux sym53c8xx driver.
81da177e4SLinus Torvalds  * Copyright (C) 1998-2000  Gerard Roudier
91da177e4SLinus Torvalds  *
101da177e4SLinus Torvalds  * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
111da177e4SLinus Torvalds  * a port of the FreeBSD ncr driver to Linux-1.2.13.
121da177e4SLinus Torvalds  *
131da177e4SLinus Torvalds  * The original ncr driver has been written for 386bsd and FreeBSD by
141da177e4SLinus Torvalds  *         Wolfgang Stanglmeier        <wolf@cologne.de>
151da177e4SLinus Torvalds  *         Stefan Esser                <se@mi.Uni-Koeln.de>
161da177e4SLinus Torvalds  * Copyright (C) 1994  Wolfgang Stanglmeier
171da177e4SLinus Torvalds  *
181da177e4SLinus Torvalds  * Other major contributions:
191da177e4SLinus Torvalds  *
201da177e4SLinus Torvalds  * NVRAM detection and reading.
211da177e4SLinus Torvalds  * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
221da177e4SLinus Torvalds  *
231da177e4SLinus Torvalds  *-----------------------------------------------------------------------------
241da177e4SLinus Torvalds  *
251da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or modify
261da177e4SLinus Torvalds  * it under the terms of the GNU General Public License as published by
271da177e4SLinus Torvalds  * the Free Software Foundation; either version 2 of the License, or
281da177e4SLinus Torvalds  * (at your option) any later version.
291da177e4SLinus Torvalds  *
301da177e4SLinus Torvalds  * This program is distributed in the hope that it will be useful,
311da177e4SLinus Torvalds  * but WITHOUT ANY WARRANTY; without even the implied warranty of
321da177e4SLinus Torvalds  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
331da177e4SLinus Torvalds  * GNU General Public License for more details.
341da177e4SLinus Torvalds  *
351da177e4SLinus Torvalds  * You should have received a copy of the GNU General Public License
361da177e4SLinus Torvalds  * along with this program; if not, write to the Free Software
371da177e4SLinus Torvalds  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
381da177e4SLinus Torvalds  */
391da177e4SLinus Torvalds 
401da177e4SLinus Torvalds #ifndef	SYM_FW_H
411da177e4SLinus Torvalds #define	SYM_FW_H
421da177e4SLinus Torvalds /*
431da177e4SLinus Torvalds  *  Macro used to generate interfaces for script A.
441da177e4SLinus Torvalds  */
451da177e4SLinus Torvalds #define SYM_GEN_FW_A(s)							\
461da177e4SLinus Torvalds 	SYM_GEN_A(s, start)		SYM_GEN_A(s, getjob_begin)	\
471da177e4SLinus Torvalds 	SYM_GEN_A(s, getjob_end)					\
481da177e4SLinus Torvalds 	SYM_GEN_A(s, select)		SYM_GEN_A(s, wf_sel_done)	\
491da177e4SLinus Torvalds 	SYM_GEN_A(s, send_ident)					\
501da177e4SLinus Torvalds 	SYM_GEN_A(s, dispatch)		SYM_GEN_A(s, init)		\
511da177e4SLinus Torvalds 	SYM_GEN_A(s, clrack)		SYM_GEN_A(s, complete_error)	\
521da177e4SLinus Torvalds 	SYM_GEN_A(s, done)		SYM_GEN_A(s, done_end)		\
531da177e4SLinus Torvalds 	SYM_GEN_A(s, idle)		SYM_GEN_A(s, ungetjob)		\
541da177e4SLinus Torvalds 	SYM_GEN_A(s, reselect)						\
551da177e4SLinus Torvalds 	SYM_GEN_A(s, resel_tag)		SYM_GEN_A(s, resel_dsa)		\
561da177e4SLinus Torvalds 	SYM_GEN_A(s, resel_no_tag)					\
571da177e4SLinus Torvalds 	SYM_GEN_A(s, data_in)		SYM_GEN_A(s, data_in2)		\
581da177e4SLinus Torvalds 	SYM_GEN_A(s, data_out)		SYM_GEN_A(s, data_out2)		\
591da177e4SLinus Torvalds 	SYM_GEN_A(s, pm0_data)		SYM_GEN_A(s, pm1_data)
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds /*
621da177e4SLinus Torvalds  *  Macro used to generate interfaces for script B.
631da177e4SLinus Torvalds  */
641da177e4SLinus Torvalds #define SYM_GEN_FW_B(s)							\
651da177e4SLinus Torvalds 	SYM_GEN_B(s, no_data)						\
661da177e4SLinus Torvalds 	SYM_GEN_B(s, sel_for_abort)	SYM_GEN_B(s, sel_for_abort_1)	\
671da177e4SLinus Torvalds 	SYM_GEN_B(s, msg_bad)		SYM_GEN_B(s, msg_weird)		\
681da177e4SLinus Torvalds 	SYM_GEN_B(s, wdtr_resp)		SYM_GEN_B(s, send_wdtr)		\
691da177e4SLinus Torvalds 	SYM_GEN_B(s, sdtr_resp)		SYM_GEN_B(s, send_sdtr)		\
701da177e4SLinus Torvalds 	SYM_GEN_B(s, ppr_resp)		SYM_GEN_B(s, send_ppr)		\
711da177e4SLinus Torvalds 	SYM_GEN_B(s, nego_bad_phase)					\
721da177e4SLinus Torvalds 	SYM_GEN_B(s, ident_break) 	SYM_GEN_B(s, ident_break_atn)	\
731da177e4SLinus Torvalds 	SYM_GEN_B(s, sdata_in)		SYM_GEN_B(s, resel_bad_lun)	\
741da177e4SLinus Torvalds 	SYM_GEN_B(s, bad_i_t_l)		SYM_GEN_B(s, bad_i_t_l_q)	\
751da177e4SLinus Torvalds 	SYM_GEN_B(s, wsr_ma_helper)
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds /*
781da177e4SLinus Torvalds  *  Macro used to generate interfaces for script Z.
791da177e4SLinus Torvalds  */
801da177e4SLinus Torvalds #define SYM_GEN_FW_Z(s)							\
811da177e4SLinus Torvalds 	SYM_GEN_Z(s, snooptest)		SYM_GEN_Z(s, snoopend)
821da177e4SLinus Torvalds 
831da177e4SLinus Torvalds /*
841da177e4SLinus Torvalds  *  Generates structure interface that contains
851da177e4SLinus Torvalds  *  offsets within script A, B and Z.
861da177e4SLinus Torvalds  */
871da177e4SLinus Torvalds #define	SYM_GEN_A(s, label)	s label;
881da177e4SLinus Torvalds #define	SYM_GEN_B(s, label)	s label;
891da177e4SLinus Torvalds #define	SYM_GEN_Z(s, label)	s label;
901da177e4SLinus Torvalds struct sym_fwa_ofs {
911da177e4SLinus Torvalds 	SYM_GEN_FW_A(u_short)
921da177e4SLinus Torvalds };
931da177e4SLinus Torvalds struct sym_fwb_ofs {
941da177e4SLinus Torvalds 	SYM_GEN_FW_B(u_short)
951da177e4SLinus Torvalds 	SYM_GEN_B(u_short, start64)
961da177e4SLinus Torvalds 	SYM_GEN_B(u_short, pm_handle)
971da177e4SLinus Torvalds };
981da177e4SLinus Torvalds struct sym_fwz_ofs {
991da177e4SLinus Torvalds 	SYM_GEN_FW_Z(u_short)
1001da177e4SLinus Torvalds };
1011da177e4SLinus Torvalds 
1021da177e4SLinus Torvalds /*
1031da177e4SLinus Torvalds  *  Generates structure interface that contains
1041da177e4SLinus Torvalds  *  bus addresses within script A, B and Z.
1051da177e4SLinus Torvalds  */
1061da177e4SLinus Torvalds struct sym_fwa_ba {
1071da177e4SLinus Torvalds 	SYM_GEN_FW_A(u32)
1081da177e4SLinus Torvalds };
1091da177e4SLinus Torvalds struct sym_fwb_ba {
1101da177e4SLinus Torvalds 	SYM_GEN_FW_B(u32)
1111da177e4SLinus Torvalds 	SYM_GEN_B(u32, start64);
1121da177e4SLinus Torvalds 	SYM_GEN_B(u32, pm_handle);
1131da177e4SLinus Torvalds };
1141da177e4SLinus Torvalds struct sym_fwz_ba {
1151da177e4SLinus Torvalds 	SYM_GEN_FW_Z(u32)
1161da177e4SLinus Torvalds };
1171da177e4SLinus Torvalds #undef	SYM_GEN_A
1181da177e4SLinus Torvalds #undef	SYM_GEN_B
1191da177e4SLinus Torvalds #undef	SYM_GEN_Z
1201da177e4SLinus Torvalds 
1211da177e4SLinus Torvalds /*
1221da177e4SLinus Torvalds  *  Let cc know about the name of the controller data structure.
1231da177e4SLinus Torvalds  *  We need this for function prototype declarations just below.
1241da177e4SLinus Torvalds  */
1251da177e4SLinus Torvalds struct sym_hcb;
1261da177e4SLinus Torvalds 
1271da177e4SLinus Torvalds /*
1281da177e4SLinus Torvalds  *  Generic structure that defines a firmware.
1291da177e4SLinus Torvalds  */
1301da177e4SLinus Torvalds struct sym_fw {
1311da177e4SLinus Torvalds 	char	*name;		/* Name we want to print out	*/
1321da177e4SLinus Torvalds 	u32	*a_base;	/* Pointer to script A template	*/
1331da177e4SLinus Torvalds 	int	a_size;		/* Size of script A		*/
1341da177e4SLinus Torvalds 	struct	sym_fwa_ofs
1351da177e4SLinus Torvalds 		*a_ofs;		/* Useful offsets in script A	*/
1361da177e4SLinus Torvalds 	u32	*b_base;	/* Pointer to script B template	*/
1371da177e4SLinus Torvalds 	int	b_size;		/* Size of script B		*/
1381da177e4SLinus Torvalds 	struct	sym_fwb_ofs
1391da177e4SLinus Torvalds 		*b_ofs;		/* Useful offsets in script B	*/
1401da177e4SLinus Torvalds 	u32	*z_base;	/* Pointer to script Z template	*/
1411da177e4SLinus Torvalds 	int	z_size;		/* Size of script Z		*/
1421da177e4SLinus Torvalds 	struct	sym_fwz_ofs
1431da177e4SLinus Torvalds 		*z_ofs;		/* Useful offsets in script Z	*/
1441da177e4SLinus Torvalds 	/* Setup and patch methods for this firmware */
1451da177e4SLinus Torvalds 	void	(*setup)(struct sym_hcb *, struct sym_fw *);
146*5111eefaSMatthew Wilcox 	void	(*patch)(struct Scsi_Host *);
1471da177e4SLinus Torvalds };
1481da177e4SLinus Torvalds 
1491da177e4SLinus Torvalds /*
1501da177e4SLinus Torvalds  *  Macro used to declare a firmware.
1511da177e4SLinus Torvalds  */
1521da177e4SLinus Torvalds #define SYM_FW_ENTRY(fw, name)					\
1531da177e4SLinus Torvalds {								\
1541da177e4SLinus Torvalds 	name,							\
1551da177e4SLinus Torvalds 	(u32 *) &fw##a_scr, sizeof(fw##a_scr), &fw##a_ofs,	\
1561da177e4SLinus Torvalds 	(u32 *) &fw##b_scr, sizeof(fw##b_scr), &fw##b_ofs,	\
1571da177e4SLinus Torvalds 	(u32 *) &fw##z_scr, sizeof(fw##z_scr), &fw##z_ofs,	\
1581da177e4SLinus Torvalds 	fw##_setup, fw##_patch					\
1591da177e4SLinus Torvalds }
1601da177e4SLinus Torvalds 
1611da177e4SLinus Torvalds /*
1621da177e4SLinus Torvalds  *  Macros used from the C code to get useful
1631da177e4SLinus Torvalds  *  SCRIPTS bus addresses.
1641da177e4SLinus Torvalds  */
1651da177e4SLinus Torvalds #define SCRIPTA_BA(np, label)	(np->fwa_bas.label)
1661da177e4SLinus Torvalds #define SCRIPTB_BA(np, label)	(np->fwb_bas.label)
1671da177e4SLinus Torvalds #define SCRIPTZ_BA(np, label)	(np->fwz_bas.label)
1681da177e4SLinus Torvalds 
1691da177e4SLinus Torvalds /*
1701da177e4SLinus Torvalds  *  Macros used by scripts definitions.
1711da177e4SLinus Torvalds  *
1721da177e4SLinus Torvalds  *  HADDR_1 generates a reference to a field of the controller data.
1731da177e4SLinus Torvalds  *  HADDR_2 generates a reference to a field of the controller data
1741da177e4SLinus Torvalds  *          with offset.
1751da177e4SLinus Torvalds  *  RADDR_1 generates a reference to a script processor register.
1761da177e4SLinus Torvalds  *  RADDR_2 generates a reference to a script processor register
1771da177e4SLinus Torvalds  *          with offset.
1781da177e4SLinus Torvalds  *  PADDR_A generates a reference to another part of script A.
1791da177e4SLinus Torvalds  *  PADDR_B generates a reference to another part of script B.
1801da177e4SLinus Torvalds  *
1811da177e4SLinus Torvalds  *  SYM_GEN_PADDR_A and SYM_GEN_PADDR_B are used to define respectively
1821da177e4SLinus Torvalds  *  the PADDR_A and PADDR_B macros for each firmware by setting argument
1831da177e4SLinus Torvalds  *  `s' to the name of the corresponding structure.
1841da177e4SLinus Torvalds  *
1851da177e4SLinus Torvalds  *  SCR_DATA_ZERO is used to allocate a DWORD of data in scripts areas.
1861da177e4SLinus Torvalds  */
1871da177e4SLinus Torvalds 
1881da177e4SLinus Torvalds #define	RELOC_SOFTC	0x40000000
1891da177e4SLinus Torvalds #define	RELOC_LABEL_A	0x50000000
1901da177e4SLinus Torvalds #define	RELOC_REGISTER	0x60000000
1911da177e4SLinus Torvalds #define	RELOC_LABEL_B	0x80000000
1921da177e4SLinus Torvalds #define	RELOC_MASK	0xf0000000
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds #define	HADDR_1(label)	   (RELOC_SOFTC    | offsetof(struct sym_hcb, label))
1951da177e4SLinus Torvalds #define	HADDR_2(label,ofs) (RELOC_SOFTC    | \
1961da177e4SLinus Torvalds 				(offsetof(struct sym_hcb, label)+(ofs)))
1971da177e4SLinus Torvalds #define	RADDR_1(label)	   (RELOC_REGISTER | REG(label))
1981da177e4SLinus Torvalds #define	RADDR_2(label,ofs) (RELOC_REGISTER | ((REG(label))+(ofs)))
1991da177e4SLinus Torvalds 
2001da177e4SLinus Torvalds #define SYM_GEN_PADDR_A(s, label) (RELOC_LABEL_A  | offsetof(s, label))
2011da177e4SLinus Torvalds #define SYM_GEN_PADDR_B(s, label) (RELOC_LABEL_B  | offsetof(s, label))
2021da177e4SLinus Torvalds 
2031da177e4SLinus Torvalds #define SCR_DATA_ZERO	0xf00ff00f
2041da177e4SLinus Torvalds 
2051da177e4SLinus Torvalds #endif	/* SYM_FW_H */
206