xref: /openbmc/linux/drivers/scsi/isci/probe_roms.h (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
1d044af17SDan Williams /*
2d044af17SDan Williams  * This file is provided under a dual BSD/GPLv2 license.  When using or
3d044af17SDan Williams  * redistributing this file, you may do so under either license.
4d044af17SDan Williams  *
5d044af17SDan Williams  * GPL LICENSE SUMMARY
6d044af17SDan Williams  *
7d044af17SDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8d044af17SDan Williams  *
9d044af17SDan Williams  * This program is free software; you can redistribute it and/or modify
10d044af17SDan Williams  * it under the terms of version 2 of the GNU General Public License as
11d044af17SDan Williams  * published by the Free Software Foundation.
12d044af17SDan Williams  *
13d044af17SDan Williams  * This program is distributed in the hope that it will be useful, but
14d044af17SDan Williams  * WITHOUT ANY WARRANTY; without even the implied warranty of
15d044af17SDan Williams  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16d044af17SDan Williams  * General Public License for more details.
17d044af17SDan Williams  *
18d044af17SDan Williams  * You should have received a copy of the GNU General Public License
19d044af17SDan Williams  * along with this program; if not, write to the Free Software
20d044af17SDan Williams  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21d044af17SDan Williams  * The full GNU General Public License is included in this distribution
22d044af17SDan Williams  * in the file called LICENSE.GPL.
23d044af17SDan Williams  *
24d044af17SDan Williams  * BSD LICENSE
25d044af17SDan Williams  *
26d044af17SDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27d044af17SDan Williams  * All rights reserved.
28d044af17SDan Williams  *
29d044af17SDan Williams  * Redistribution and use in source and binary forms, with or without
30d044af17SDan Williams  * modification, are permitted provided that the following conditions
31d044af17SDan Williams  * are met:
32d044af17SDan Williams  *
33d044af17SDan Williams  *   * Redistributions of source code must retain the above copyright
34d044af17SDan Williams  *     notice, this list of conditions and the following disclaimer.
35d044af17SDan Williams  *   * Redistributions in binary form must reproduce the above copyright
36d044af17SDan Williams  *     notice, this list of conditions and the following disclaimer in
37d044af17SDan Williams  *     the documentation and/or other materials provided with the
38d044af17SDan Williams  *     distribution.
39d044af17SDan Williams  *   * Neither the name of Intel Corporation nor the names of its
40d044af17SDan Williams  *     contributors may be used to endorse or promote products derived
41d044af17SDan Williams  *     from this software without specific prior written permission.
42d044af17SDan Williams  *
43d044af17SDan Williams  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44d044af17SDan Williams  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45d044af17SDan Williams  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46d044af17SDan Williams  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47d044af17SDan Williams  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48d044af17SDan Williams  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49d044af17SDan Williams  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50d044af17SDan Williams  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51d044af17SDan Williams  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52d044af17SDan Williams  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53d044af17SDan Williams  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54d044af17SDan Williams  */
55d044af17SDan Williams #ifndef _ISCI_PROBE_ROMS_H_
56d044af17SDan Williams #define _ISCI_PROBE_ROMS_H_
57d044af17SDan Williams 
58d044af17SDan Williams #ifdef __KERNEL__
59d044af17SDan Williams #include <linux/firmware.h>
60d044af17SDan Williams #include <linux/pci.h>
61bf482c60SDave Jiang #include <linux/efi.h>
62ce2b3261SDan Williams #include "isci.h"
63d044af17SDan Williams 
64e2f8db50SDan Williams #define SCIC_SDS_PARM_NO_SPEED   0
65e2f8db50SDan Williams 
66e2f8db50SDan Williams /* generation 1 (i.e. 1.5 Gb/s) */
67e2f8db50SDan Williams #define SCIC_SDS_PARM_GEN1_SPEED 1
68e2f8db50SDan Williams 
69e2f8db50SDan Williams /* generation 2 (i.e. 3.0 Gb/s) */
70e2f8db50SDan Williams #define SCIC_SDS_PARM_GEN2_SPEED 2
71e2f8db50SDan Williams 
72e2f8db50SDan Williams /* generation 3 (i.e. 6.0 Gb/s) */
73e2f8db50SDan Williams #define SCIC_SDS_PARM_GEN3_SPEED 3
74e2f8db50SDan Williams #define SCIC_SDS_PARM_MAX_SPEED SCIC_SDS_PARM_GEN3_SPEED
75e2f8db50SDan Williams 
76e2f8db50SDan Williams /* parameters that can be set by module parameters */
7789a7301fSDan Williams struct sci_user_parameters {
78e2f8db50SDan Williams 	struct sci_phy_user_params {
79e2f8db50SDan Williams 		/**
80e2f8db50SDan Williams 		 * This field specifies the NOTIFY (ENABLE SPIN UP) primitive
81e2f8db50SDan Williams 		 * insertion frequency for this phy index.
82e2f8db50SDan Williams 		 */
83e2f8db50SDan Williams 		u32 notify_enable_spin_up_insertion_frequency;
84e2f8db50SDan Williams 
85e2f8db50SDan Williams 		/**
86e2f8db50SDan Williams 		 * This method specifies the number of transmitted DWORDs within which
87e2f8db50SDan Williams 		 * to transmit a single ALIGN primitive.  This value applies regardless
88e2f8db50SDan Williams 		 * of what type of device is attached or connection state.  A value of
89e2f8db50SDan Williams 		 * 0 indicates that no ALIGN primitives will be inserted.
90e2f8db50SDan Williams 		 */
91e2f8db50SDan Williams 		u16 align_insertion_frequency;
92e2f8db50SDan Williams 
93e2f8db50SDan Williams 		/**
94e2f8db50SDan Williams 		 * This method specifies the number of transmitted DWORDs within which
95e2f8db50SDan Williams 		 * to transmit 2 ALIGN primitives.  This applies for SAS connections
96e2f8db50SDan Williams 		 * only.  A minimum value of 3 is required for this field.
97e2f8db50SDan Williams 		 */
98e2f8db50SDan Williams 		u16 in_connection_align_insertion_frequency;
99e2f8db50SDan Williams 
100e2f8db50SDan Williams 		/**
101e2f8db50SDan Williams 		 * This field indicates the maximum speed generation to be utilized
102e2f8db50SDan Williams 		 * by phys in the supplied port.
103e2f8db50SDan Williams 		 * - A value of 1 indicates generation 1 (i.e. 1.5 Gb/s).
104e2f8db50SDan Williams 		 * - A value of 2 indicates generation 2 (i.e. 3.0 Gb/s).
105e2f8db50SDan Williams 		 * - A value of 3 indicates generation 3 (i.e. 6.0 Gb/s).
106e2f8db50SDan Williams 		 */
107e2f8db50SDan Williams 		u8 max_speed_generation;
108e2f8db50SDan Williams 
109e2f8db50SDan Williams 	} phys[SCI_MAX_PHYS];
110e2f8db50SDan Williams 
111e2f8db50SDan Williams 	/**
112e2f8db50SDan Williams 	 * This field specifies the maximum number of direct attached devices
113e2f8db50SDan Williams 	 * that can have power supplied to them simultaneously.
114e2f8db50SDan Williams 	 */
1157000f7c7SAndrzej Jakowski 	u8 max_concurr_spinup;
116e2f8db50SDan Williams 
117e2f8db50SDan Williams 	/**
118e2f8db50SDan Williams 	 * This field specifies the number of seconds to allow a phy to consume
119e2f8db50SDan Williams 	 * power before yielding to another phy.
120e2f8db50SDan Williams 	 *
121e2f8db50SDan Williams 	 */
122e2f8db50SDan Williams 	u8 phy_spin_up_delay_interval;
123e2f8db50SDan Williams 
124e2f8db50SDan Williams 	/**
125e2f8db50SDan Williams 	 * These timer values specifies how long a link will remain open with no
126e2f8db50SDan Williams 	 * activity in increments of a microsecond, it can be in increments of
127e2f8db50SDan Williams 	 * 100 microseconds if the upper most bit is set.
128e2f8db50SDan Williams 	 *
129e2f8db50SDan Williams 	 */
130e2f8db50SDan Williams 	u16 stp_inactivity_timeout;
131e2f8db50SDan Williams 	u16 ssp_inactivity_timeout;
132e2f8db50SDan Williams 
133e2f8db50SDan Williams 	/**
134e2f8db50SDan Williams 	 * These timer values specifies how long a link will remain open in increments
135e2f8db50SDan Williams 	 * of 100 microseconds.
136e2f8db50SDan Williams 	 *
137e2f8db50SDan Williams 	 */
138e2f8db50SDan Williams 	u16 stp_max_occupancy_timeout;
139e2f8db50SDan Williams 	u16 ssp_max_occupancy_timeout;
140e2f8db50SDan Williams 
141e2f8db50SDan Williams 	/**
142e2f8db50SDan Williams 	 * This timer value specifies how long a link will remain open with no
143e2f8db50SDan Williams 	 * outbound traffic in increments of a microsecond.
144e2f8db50SDan Williams 	 *
145e2f8db50SDan Williams 	 */
146e2f8db50SDan Williams 	u8 no_outbound_task_timeout;
147e2f8db50SDan Williams 
148e2f8db50SDan Williams };
149e2f8db50SDan Williams 
150e2f8db50SDan Williams #define SCIC_SDS_PARM_PHY_MASK_MIN 0x0
151e2f8db50SDan Williams #define SCIC_SDS_PARM_PHY_MASK_MAX 0xF
152e2f8db50SDan Williams #define MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT 4
153e2f8db50SDan Williams 
15489a7301fSDan Williams struct sci_oem_params;
155594e566aSDave Jiang int sci_oem_parameters_validate(struct sci_oem_params *oem, u8 version);
156d044af17SDan Williams 
157e2f8db50SDan Williams struct isci_orom;
158e2f8db50SDan Williams struct isci_orom *isci_request_oprom(struct pci_dev *pdev);
159d044af17SDan Williams struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmware *fw);
1608db37aabSDave Jiang struct isci_orom *isci_get_efi_var(struct pci_dev *pdev);
1613b67c1f3SDan Williams 
1623b67c1f3SDan Williams struct isci_oem_hdr {
1633b67c1f3SDan Williams 	u8 sig[4];
1643b67c1f3SDan Williams 	u8 rev_major;
1653b67c1f3SDan Williams 	u8 rev_minor;
1663b67c1f3SDan Williams 	u16 len;
1673b67c1f3SDan Williams 	u8 checksum;
1683b67c1f3SDan Williams 	u8 reserved1;
1693b67c1f3SDan Williams 	u16 reserved2;
1703b67c1f3SDan Williams } __attribute__ ((packed));
1713b67c1f3SDan Williams 
172d044af17SDan Williams #else
173d044af17SDan Williams #define SCI_MAX_PORTS 4
174d044af17SDan Williams #define SCI_MAX_PHYS 4
175ca507b98SDave Jiang #define SCI_MAX_CONTROLLERS 2
176d044af17SDan Williams #endif
177d044af17SDan Williams 
178d044af17SDan Williams #define ISCI_FW_NAME		"isci/isci_firmware.bin"
179d044af17SDan Williams 
180d044af17SDan Williams #define ROMSIGNATURE		0xaa55
181d044af17SDan Williams 
1823b67c1f3SDan Williams #define ISCI_OEM_SIG		"$OEM"
1833b67c1f3SDan Williams #define ISCI_OEM_SIG_SIZE	4
184d044af17SDan Williams #define ISCI_ROM_SIG		"ISCUOEMB"
185d044af17SDan Williams #define ISCI_ROM_SIG_SIZE	8
186d044af17SDan Williams 
187ca507b98SDave Jiang #define ISCI_EFI_VENDOR_GUID	\
188ca507b98SDave Jiang 	EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, \
189ca507b98SDave Jiang 			0x1a, 0x04, 0xc6)
1902e8320f7SDave Jiang #define ISCI_EFI_VAR_NAME	"RstScuO"
191d044af17SDan Williams 
192594e566aSDave Jiang #define ISCI_ROM_VER_1_0	0x10
193594e566aSDave Jiang #define ISCI_ROM_VER_1_1	0x11
194*9fee607fSJeff Skirvin #define ISCI_ROM_VER_1_3	0x13
195*9fee607fSJeff Skirvin #define ISCI_ROM_VER_LATEST	ISCI_ROM_VER_1_3
196594e566aSDave Jiang 
19707373a5cSHenryk Dembkowski /* Allowed PORT configuration modes APC Automatic PORT configuration mode is
19807373a5cSHenryk Dembkowski  * defined by the OEM configuration parameters providing no PHY_MASK parameters
19907373a5cSHenryk Dembkowski  * for any PORT. i.e. There are no phys assigned to any of the ports at start.
20007373a5cSHenryk Dembkowski  * MPC Manual PORT configuration mode is defined by the OEM configuration
20107373a5cSHenryk Dembkowski  * parameters providing a PHY_MASK value for any PORT.  It is assumed that any
20207373a5cSHenryk Dembkowski  * PORT with no PHY_MASK is an invalid port and not all PHYs must be assigned.
20307373a5cSHenryk Dembkowski  * A PORT_PHY mask that assigns just a single PHY to a port and no other PHYs
20407373a5cSHenryk Dembkowski  * being assigned is sufficient to declare manual PORT configuration.
20507373a5cSHenryk Dembkowski  */
20689a7301fSDan Williams enum sci_port_configuration_mode {
2074eefd251SDan Williams 	SCIC_PORT_MANUAL_CONFIGURATION_MODE = 0,
2084eefd251SDan Williams 	SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE = 1
20907373a5cSHenryk Dembkowski };
21007373a5cSHenryk Dembkowski 
211d044af17SDan Williams struct sci_bios_oem_param_block_hdr {
212d044af17SDan Williams 	uint8_t signature[ISCI_ROM_SIG_SIZE];
213d044af17SDan Williams 	uint16_t total_block_length;
214d044af17SDan Williams 	uint8_t hdr_length;
215d044af17SDan Williams 	uint8_t version;
216d044af17SDan Williams 	uint8_t preboot_source;
217d044af17SDan Williams 	uint8_t num_elements;
218f22be5d8SDan Williams 	uint16_t element_length;
219d044af17SDan Williams 	uint8_t reserved[8];
220d044af17SDan Williams } __attribute__ ((packed));
221d044af17SDan Williams 
22289a7301fSDan Williams struct sci_oem_params {
223d044af17SDan Williams 	struct {
224d044af17SDan Williams 		uint8_t mode_type;
2257000f7c7SAndrzej Jakowski 		uint8_t max_concurr_spin_up;
226594e566aSDave Jiang 		/*
227594e566aSDave Jiang 		 * This bitfield indicates the OEM's desired default Tx
228594e566aSDave Jiang 		 * Spread Spectrum Clocking (SSC) settings for SATA and SAS.
229594e566aSDave Jiang 		 * NOTE: Default SSC Modulation Frequency is 31.5KHz.
230594e566aSDave Jiang 		 */
231594e566aSDave Jiang 		union {
232594e566aSDave Jiang 			struct {
233594e566aSDave Jiang 			/*
234594e566aSDave Jiang 			 * NOTE: Max spread for SATA is +0 / -5000 PPM.
235594e566aSDave Jiang 			 * Down-spreading SSC (only method allowed for SATA):
236594e566aSDave Jiang 			 *  SATA SSC Tx Disabled                    = 0x0
237594e566aSDave Jiang 			 *  SATA SSC Tx at +0 / -1419 PPM Spread    = 0x2
238594e566aSDave Jiang 			 *  SATA SSC Tx at +0 / -2129 PPM Spread    = 0x3
239594e566aSDave Jiang 			 *  SATA SSC Tx at +0 / -4257 PPM Spread    = 0x6
240594e566aSDave Jiang 			 *  SATA SSC Tx at +0 / -4967 PPM Spread    = 0x7
241594e566aSDave Jiang 			 */
242594e566aSDave Jiang 				uint8_t ssc_sata_tx_spread_level:4;
243594e566aSDave Jiang 			/*
244594e566aSDave Jiang 			 * SAS SSC Tx Disabled                     = 0x0
245594e566aSDave Jiang 			 *
246594e566aSDave Jiang 			 * NOTE: Max spread for SAS down-spreading +0 /
247594e566aSDave Jiang 			 *	 -2300 PPM
248594e566aSDave Jiang 			 * Down-spreading SSC:
249594e566aSDave Jiang 			 *  SAS SSC Tx at +0 / -1419 PPM Spread     = 0x2
250594e566aSDave Jiang 			 *  SAS SSC Tx at +0 / -2129 PPM Spread     = 0x3
251594e566aSDave Jiang 			 *
252594e566aSDave Jiang 			 * NOTE: Max spread for SAS center-spreading +2300 /
253594e566aSDave Jiang 			 *	 -2300 PPM
254594e566aSDave Jiang 			 * Center-spreading SSC:
255594e566aSDave Jiang 			 *  SAS SSC Tx at +1064 / -1064 PPM Spread  = 0x3
256594e566aSDave Jiang 			 *  SAS SSC Tx at +2129 / -2129 PPM Spread  = 0x6
257594e566aSDave Jiang 			 */
258594e566aSDave Jiang 				uint8_t ssc_sas_tx_spread_level:3;
259594e566aSDave Jiang 			/*
260594e566aSDave Jiang 			 * NOTE: Refer to the SSC section of the SAS 2.x
261594e566aSDave Jiang 			 * Specification for proper setting of this field.
262594e566aSDave Jiang 			 * For standard SAS Initiator SAS PHY operation it
263594e566aSDave Jiang 			 * should be 0 for Down-spreading.
264594e566aSDave Jiang 			 * SAS SSC Tx spread type:
265594e566aSDave Jiang 			 *  Down-spreading SSC      = 0
266594e566aSDave Jiang 			 *  Center-spreading SSC    = 1
267594e566aSDave Jiang 			 */
268594e566aSDave Jiang 				uint8_t ssc_sas_tx_type:1;
269594e566aSDave Jiang 			};
270d044af17SDan Williams 			uint8_t do_enable_ssc;
271594e566aSDave Jiang 		};
272*9fee607fSJeff Skirvin 		/*
273*9fee607fSJeff Skirvin 		 * This field indicates length of the SAS/SATA cable between
274*9fee607fSJeff Skirvin 		 * host and device.
275*9fee607fSJeff Skirvin 		 * This field is used make relationship between analog
276*9fee607fSJeff Skirvin 		 * parameters of the phy in the silicon and length of the cable.
277*9fee607fSJeff Skirvin 		 * Supported cable attenuation levels:
278*9fee607fSJeff Skirvin 		 * "short"- up to 3m, "medium"-3m to 6m, and "long"- more than
279*9fee607fSJeff Skirvin 		 * 6m.
280*9fee607fSJeff Skirvin 		 *
281*9fee607fSJeff Skirvin 		 * This is bit mask field:
282*9fee607fSJeff Skirvin 		 *
283*9fee607fSJeff Skirvin 		 * BIT:      (MSB) 7     6     5     4
284*9fee607fSJeff Skirvin 		 * ASSIGNMENT:   <phy3><phy2><phy1><phy0>  - Medium cable
285*9fee607fSJeff Skirvin 		 *                                           length assignment
286*9fee607fSJeff Skirvin 		 * BIT:            3     2     1     0  (LSB)
287*9fee607fSJeff Skirvin 		 * ASSIGNMENT:   <phy3><phy2><phy1><phy0>  - Long cable length
288*9fee607fSJeff Skirvin 		 *                                           assignment
289*9fee607fSJeff Skirvin 		 *
290*9fee607fSJeff Skirvin 		 * BITS 7-4 are set when the cable length is assigned to medium
291*9fee607fSJeff Skirvin 		 * BITS 3-0 are set when the cable length is assigned to long
292*9fee607fSJeff Skirvin 		 *
293*9fee607fSJeff Skirvin 		 * The BIT positions are clear when the cable length is
294*9fee607fSJeff Skirvin 		 * assigned to short.
295*9fee607fSJeff Skirvin 		 *
296*9fee607fSJeff Skirvin 		 * Setting the bits for both long and medium cable length is
297*9fee607fSJeff Skirvin 		 * undefined.
298*9fee607fSJeff Skirvin 		 *
299*9fee607fSJeff Skirvin 		 * A value of 0x84 would assign
300*9fee607fSJeff Skirvin 		 *    phy3 - medium
301*9fee607fSJeff Skirvin 		 *    phy2 - long
302*9fee607fSJeff Skirvin 		 *    phy1 - short
303*9fee607fSJeff Skirvin 		 *    phy0 - short
304*9fee607fSJeff Skirvin 		 */
305*9fee607fSJeff Skirvin 		uint8_t cable_selection_mask;
306d044af17SDan Williams 	} controller;
307d044af17SDan Williams 
308d044af17SDan Williams 	struct {
309d044af17SDan Williams 		uint8_t phy_mask;
310d044af17SDan Williams 	} ports[SCI_MAX_PORTS];
311d044af17SDan Williams 
312d044af17SDan Williams 	struct sci_phy_oem_params {
313d044af17SDan Williams 		struct {
314d044af17SDan Williams 			uint32_t high;
315d044af17SDan Williams 			uint32_t low;
316d044af17SDan Williams 		} sas_address;
317d044af17SDan Williams 
318d044af17SDan Williams 		uint32_t afe_tx_amp_control0;
319d044af17SDan Williams 		uint32_t afe_tx_amp_control1;
320d044af17SDan Williams 		uint32_t afe_tx_amp_control2;
321d044af17SDan Williams 		uint32_t afe_tx_amp_control3;
322d044af17SDan Williams 	} phys[SCI_MAX_PHYS];
323d044af17SDan Williams } __attribute__ ((packed));
324d044af17SDan Williams 
325d044af17SDan Williams struct isci_orom {
326d044af17SDan Williams 	struct sci_bios_oem_param_block_hdr hdr;
32789a7301fSDan Williams 	struct sci_oem_params ctrl[SCI_MAX_CONTROLLERS];
328d044af17SDan Williams } __attribute__ ((packed));
329d044af17SDan Williams 
330d044af17SDan Williams #endif
331