162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family 462306a36Sopenharmony_ci * of PCI-SCSI IO processors. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr> 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * This driver is derived from the Linux sym53c8xx driver. 962306a36Sopenharmony_ci * Copyright (C) 1998-2000 Gerard Roudier 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The sym53c8xx driver is derived from the ncr53c8xx driver that had been 1262306a36Sopenharmony_ci * a port of the FreeBSD ncr driver to Linux-1.2.13. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * The original ncr driver has been written for 386bsd and FreeBSD by 1562306a36Sopenharmony_ci * Wolfgang Stanglmeier <wolf@cologne.de> 1662306a36Sopenharmony_ci * Stefan Esser <se@mi.Uni-Koeln.de> 1762306a36Sopenharmony_ci * Copyright (C) 1994 Wolfgang Stanglmeier 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * Other major contributions: 2062306a36Sopenharmony_ci * 2162306a36Sopenharmony_ci * NVRAM detection and reading. 2262306a36Sopenharmony_ci * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk> 2362306a36Sopenharmony_ci * 2462306a36Sopenharmony_ci *----------------------------------------------------------------------------- 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#ifndef SYM_FW_H 2862306a36Sopenharmony_ci#define SYM_FW_H 2962306a36Sopenharmony_ci/* 3062306a36Sopenharmony_ci * Macro used to generate interfaces for script A. 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_ci#define SYM_GEN_FW_A(s) \ 3362306a36Sopenharmony_ci SYM_GEN_A(s, start) SYM_GEN_A(s, getjob_begin) \ 3462306a36Sopenharmony_ci SYM_GEN_A(s, getjob_end) \ 3562306a36Sopenharmony_ci SYM_GEN_A(s, select) SYM_GEN_A(s, wf_sel_done) \ 3662306a36Sopenharmony_ci SYM_GEN_A(s, send_ident) \ 3762306a36Sopenharmony_ci SYM_GEN_A(s, dispatch) SYM_GEN_A(s, init) \ 3862306a36Sopenharmony_ci SYM_GEN_A(s, clrack) SYM_GEN_A(s, complete_error) \ 3962306a36Sopenharmony_ci SYM_GEN_A(s, done) SYM_GEN_A(s, done_end) \ 4062306a36Sopenharmony_ci SYM_GEN_A(s, idle) SYM_GEN_A(s, ungetjob) \ 4162306a36Sopenharmony_ci SYM_GEN_A(s, reselect) \ 4262306a36Sopenharmony_ci SYM_GEN_A(s, resel_tag) SYM_GEN_A(s, resel_dsa) \ 4362306a36Sopenharmony_ci SYM_GEN_A(s, resel_no_tag) \ 4462306a36Sopenharmony_ci SYM_GEN_A(s, data_in) SYM_GEN_A(s, data_in2) \ 4562306a36Sopenharmony_ci SYM_GEN_A(s, data_out) SYM_GEN_A(s, data_out2) \ 4662306a36Sopenharmony_ci SYM_GEN_A(s, pm0_data) SYM_GEN_A(s, pm1_data) 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* 4962306a36Sopenharmony_ci * Macro used to generate interfaces for script B. 5062306a36Sopenharmony_ci */ 5162306a36Sopenharmony_ci#define SYM_GEN_FW_B(s) \ 5262306a36Sopenharmony_ci SYM_GEN_B(s, no_data) \ 5362306a36Sopenharmony_ci SYM_GEN_B(s, sel_for_abort) SYM_GEN_B(s, sel_for_abort_1) \ 5462306a36Sopenharmony_ci SYM_GEN_B(s, msg_bad) SYM_GEN_B(s, msg_weird) \ 5562306a36Sopenharmony_ci SYM_GEN_B(s, wdtr_resp) SYM_GEN_B(s, send_wdtr) \ 5662306a36Sopenharmony_ci SYM_GEN_B(s, sdtr_resp) SYM_GEN_B(s, send_sdtr) \ 5762306a36Sopenharmony_ci SYM_GEN_B(s, ppr_resp) SYM_GEN_B(s, send_ppr) \ 5862306a36Sopenharmony_ci SYM_GEN_B(s, nego_bad_phase) \ 5962306a36Sopenharmony_ci SYM_GEN_B(s, ident_break) SYM_GEN_B(s, ident_break_atn) \ 6062306a36Sopenharmony_ci SYM_GEN_B(s, sdata_in) SYM_GEN_B(s, resel_bad_lun) \ 6162306a36Sopenharmony_ci SYM_GEN_B(s, bad_i_t_l) SYM_GEN_B(s, bad_i_t_l_q) \ 6262306a36Sopenharmony_ci SYM_GEN_B(s, wsr_ma_helper) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* 6562306a36Sopenharmony_ci * Macro used to generate interfaces for script Z. 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_ci#define SYM_GEN_FW_Z(s) \ 6862306a36Sopenharmony_ci SYM_GEN_Z(s, snooptest) SYM_GEN_Z(s, snoopend) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/* 7162306a36Sopenharmony_ci * Generates structure interface that contains 7262306a36Sopenharmony_ci * offsets within script A, B and Z. 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci#define SYM_GEN_A(s, label) s label; 7562306a36Sopenharmony_ci#define SYM_GEN_B(s, label) s label; 7662306a36Sopenharmony_ci#define SYM_GEN_Z(s, label) s label; 7762306a36Sopenharmony_cistruct sym_fwa_ofs { 7862306a36Sopenharmony_ci SYM_GEN_FW_A(u_short) 7962306a36Sopenharmony_ci}; 8062306a36Sopenharmony_cistruct sym_fwb_ofs { 8162306a36Sopenharmony_ci SYM_GEN_FW_B(u_short) 8262306a36Sopenharmony_ci SYM_GEN_B(u_short, start64) 8362306a36Sopenharmony_ci SYM_GEN_B(u_short, pm_handle) 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_cistruct sym_fwz_ofs { 8662306a36Sopenharmony_ci SYM_GEN_FW_Z(u_short) 8762306a36Sopenharmony_ci}; 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* 9062306a36Sopenharmony_ci * Generates structure interface that contains 9162306a36Sopenharmony_ci * bus addresses within script A, B and Z. 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_cistruct sym_fwa_ba { 9462306a36Sopenharmony_ci SYM_GEN_FW_A(u32) 9562306a36Sopenharmony_ci}; 9662306a36Sopenharmony_cistruct sym_fwb_ba { 9762306a36Sopenharmony_ci SYM_GEN_FW_B(u32) 9862306a36Sopenharmony_ci SYM_GEN_B(u32, start64); 9962306a36Sopenharmony_ci SYM_GEN_B(u32, pm_handle); 10062306a36Sopenharmony_ci}; 10162306a36Sopenharmony_cistruct sym_fwz_ba { 10262306a36Sopenharmony_ci SYM_GEN_FW_Z(u32) 10362306a36Sopenharmony_ci}; 10462306a36Sopenharmony_ci#undef SYM_GEN_A 10562306a36Sopenharmony_ci#undef SYM_GEN_B 10662306a36Sopenharmony_ci#undef SYM_GEN_Z 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci/* 10962306a36Sopenharmony_ci * Let cc know about the name of the controller data structure. 11062306a36Sopenharmony_ci * We need this for function prototype declarations just below. 11162306a36Sopenharmony_ci */ 11262306a36Sopenharmony_cistruct sym_hcb; 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* 11562306a36Sopenharmony_ci * Generic structure that defines a firmware. 11662306a36Sopenharmony_ci */ 11762306a36Sopenharmony_cistruct sym_fw { 11862306a36Sopenharmony_ci char *name; /* Name we want to print out */ 11962306a36Sopenharmony_ci u32 *a_base; /* Pointer to script A template */ 12062306a36Sopenharmony_ci int a_size; /* Size of script A */ 12162306a36Sopenharmony_ci struct sym_fwa_ofs 12262306a36Sopenharmony_ci *a_ofs; /* Useful offsets in script A */ 12362306a36Sopenharmony_ci u32 *b_base; /* Pointer to script B template */ 12462306a36Sopenharmony_ci int b_size; /* Size of script B */ 12562306a36Sopenharmony_ci struct sym_fwb_ofs 12662306a36Sopenharmony_ci *b_ofs; /* Useful offsets in script B */ 12762306a36Sopenharmony_ci u32 *z_base; /* Pointer to script Z template */ 12862306a36Sopenharmony_ci int z_size; /* Size of script Z */ 12962306a36Sopenharmony_ci struct sym_fwz_ofs 13062306a36Sopenharmony_ci *z_ofs; /* Useful offsets in script Z */ 13162306a36Sopenharmony_ci /* Setup and patch methods for this firmware */ 13262306a36Sopenharmony_ci void (*setup)(struct sym_hcb *, struct sym_fw *); 13362306a36Sopenharmony_ci void (*patch)(struct Scsi_Host *); 13462306a36Sopenharmony_ci}; 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* 13762306a36Sopenharmony_ci * Macro used to declare a firmware. 13862306a36Sopenharmony_ci */ 13962306a36Sopenharmony_ci#define SYM_FW_ENTRY(fw, name) \ 14062306a36Sopenharmony_ci{ \ 14162306a36Sopenharmony_ci name, \ 14262306a36Sopenharmony_ci (u32 *) &fw##a_scr, sizeof(fw##a_scr), &fw##a_ofs, \ 14362306a36Sopenharmony_ci (u32 *) &fw##b_scr, sizeof(fw##b_scr), &fw##b_ofs, \ 14462306a36Sopenharmony_ci (u32 *) &fw##z_scr, sizeof(fw##z_scr), &fw##z_ofs, \ 14562306a36Sopenharmony_ci fw##_setup, fw##_patch \ 14662306a36Sopenharmony_ci} 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/* 14962306a36Sopenharmony_ci * Macros used from the C code to get useful 15062306a36Sopenharmony_ci * SCRIPTS bus addresses. 15162306a36Sopenharmony_ci */ 15262306a36Sopenharmony_ci#define SCRIPTA_BA(np, label) (np->fwa_bas.label) 15362306a36Sopenharmony_ci#define SCRIPTB_BA(np, label) (np->fwb_bas.label) 15462306a36Sopenharmony_ci#define SCRIPTZ_BA(np, label) (np->fwz_bas.label) 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci/* 15762306a36Sopenharmony_ci * Macros used by scripts definitions. 15862306a36Sopenharmony_ci * 15962306a36Sopenharmony_ci * HADDR_1 generates a reference to a field of the controller data. 16062306a36Sopenharmony_ci * HADDR_2 generates a reference to a field of the controller data 16162306a36Sopenharmony_ci * with offset. 16262306a36Sopenharmony_ci * RADDR_1 generates a reference to a script processor register. 16362306a36Sopenharmony_ci * RADDR_2 generates a reference to a script processor register 16462306a36Sopenharmony_ci * with offset. 16562306a36Sopenharmony_ci * PADDR_A generates a reference to another part of script A. 16662306a36Sopenharmony_ci * PADDR_B generates a reference to another part of script B. 16762306a36Sopenharmony_ci * 16862306a36Sopenharmony_ci * SYM_GEN_PADDR_A and SYM_GEN_PADDR_B are used to define respectively 16962306a36Sopenharmony_ci * the PADDR_A and PADDR_B macros for each firmware by setting argument 17062306a36Sopenharmony_ci * `s' to the name of the corresponding structure. 17162306a36Sopenharmony_ci * 17262306a36Sopenharmony_ci * SCR_DATA_ZERO is used to allocate a DWORD of data in scripts areas. 17362306a36Sopenharmony_ci */ 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci#define RELOC_SOFTC 0x40000000 17662306a36Sopenharmony_ci#define RELOC_LABEL_A 0x50000000 17762306a36Sopenharmony_ci#define RELOC_REGISTER 0x60000000 17862306a36Sopenharmony_ci#define RELOC_LABEL_B 0x80000000 17962306a36Sopenharmony_ci#define RELOC_MASK 0xf0000000 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci#define HADDR_1(label) (RELOC_SOFTC | offsetof(struct sym_hcb, label)) 18262306a36Sopenharmony_ci#define HADDR_2(label,ofs) (RELOC_SOFTC | \ 18362306a36Sopenharmony_ci (offsetof(struct sym_hcb, label)+(ofs))) 18462306a36Sopenharmony_ci#define RADDR_1(label) (RELOC_REGISTER | REG(label)) 18562306a36Sopenharmony_ci#define RADDR_2(label,ofs) (RELOC_REGISTER | ((REG(label))+(ofs))) 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci#define SYM_GEN_PADDR_A(s, label) (RELOC_LABEL_A | offsetof(s, label)) 18862306a36Sopenharmony_ci#define SYM_GEN_PADDR_B(s, label) (RELOC_LABEL_B | offsetof(s, label)) 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci#define SCR_DATA_ZERO 0xf00ff00f 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci#endif /* SYM_FW_H */ 193