probe_roms.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * This file is provided under a dual BSD/GPLv2 license. When using or
  3. * redistributing this file, you may do so under either license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * BSD LICENSE
  25. *
  26. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. *
  33. * * Redistributions of source code must retain the above copyright
  34. * notice, this list of conditions and the following disclaimer.
  35. * * Redistributions in binary form must reproduce the above copyright
  36. * notice, this list of conditions and the following disclaimer in
  37. * the documentation and/or other materials provided with the
  38. * distribution.
  39. * * Neither the name of Intel Corporation nor the names of its
  40. * contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  46. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  47. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  49. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  50. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  51. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  53. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. */
  55. #ifndef _ISCI_PROBE_ROMS_H_
  56. #define _ISCI_PROBE_ROMS_H_
  57. #ifdef __KERNEL__
  58. #include <linux/firmware.h>
  59. #include <linux/pci.h>
  60. #include <linux/efi.h>
  61. #include "isci.h"
  62. #define SCIC_SDS_PARM_NO_SPEED 0
  63. /* generation 1 (i.e. 1.5 Gb/s) */
  64. #define SCIC_SDS_PARM_GEN1_SPEED 1
  65. /* generation 2 (i.e. 3.0 Gb/s) */
  66. #define SCIC_SDS_PARM_GEN2_SPEED 2
  67. /* generation 3 (i.e. 6.0 Gb/s) */
  68. #define SCIC_SDS_PARM_GEN3_SPEED 3
  69. #define SCIC_SDS_PARM_MAX_SPEED SCIC_SDS_PARM_GEN3_SPEED
  70. /* parameters that can be set by module parameters */
  71. struct sci_user_parameters {
  72. struct sci_phy_user_params {
  73. /**
  74. * This field specifies the NOTIFY (ENABLE SPIN UP) primitive
  75. * insertion frequency for this phy index.
  76. */
  77. u32 notify_enable_spin_up_insertion_frequency;
  78. /**
  79. * This method specifies the number of transmitted DWORDs within which
  80. * to transmit a single ALIGN primitive. This value applies regardless
  81. * of what type of device is attached or connection state. A value of
  82. * 0 indicates that no ALIGN primitives will be inserted.
  83. */
  84. u16 align_insertion_frequency;
  85. /**
  86. * This method specifies the number of transmitted DWORDs within which
  87. * to transmit 2 ALIGN primitives. This applies for SAS connections
  88. * only. A minimum value of 3 is required for this field.
  89. */
  90. u16 in_connection_align_insertion_frequency;
  91. /**
  92. * This field indicates the maximum speed generation to be utilized
  93. * by phys in the supplied port.
  94. * - A value of 1 indicates generation 1 (i.e. 1.5 Gb/s).
  95. * - A value of 2 indicates generation 2 (i.e. 3.0 Gb/s).
  96. * - A value of 3 indicates generation 3 (i.e. 6.0 Gb/s).
  97. */
  98. u8 max_speed_generation;
  99. } phys[SCI_MAX_PHYS];
  100. /**
  101. * This field specifies the maximum number of direct attached devices
  102. * that can have power supplied to them simultaneously.
  103. */
  104. u8 max_concurr_spinup;
  105. /**
  106. * This field specifies the number of seconds to allow a phy to consume
  107. * power before yielding to another phy.
  108. *
  109. */
  110. u8 phy_spin_up_delay_interval;
  111. /**
  112. * These timer values specifies how long a link will remain open with no
  113. * activity in increments of a microsecond, it can be in increments of
  114. * 100 microseconds if the upper most bit is set.
  115. *
  116. */
  117. u16 stp_inactivity_timeout;
  118. u16 ssp_inactivity_timeout;
  119. /**
  120. * These timer values specifies how long a link will remain open in increments
  121. * of 100 microseconds.
  122. *
  123. */
  124. u16 stp_max_occupancy_timeout;
  125. u16 ssp_max_occupancy_timeout;
  126. /**
  127. * This timer value specifies how long a link will remain open with no
  128. * outbound traffic in increments of a microsecond.
  129. *
  130. */
  131. u8 no_outbound_task_timeout;
  132. };
  133. #define SCIC_SDS_PARM_PHY_MASK_MIN 0x0
  134. #define SCIC_SDS_PARM_PHY_MASK_MAX 0xF
  135. #define MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT 4
  136. struct sci_oem_params;
  137. int sci_oem_parameters_validate(struct sci_oem_params *oem, u8 version);
  138. struct isci_orom;
  139. struct isci_orom *isci_request_oprom(struct pci_dev *pdev);
  140. struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmware *fw);
  141. struct isci_orom *isci_get_efi_var(struct pci_dev *pdev);
  142. struct isci_oem_hdr {
  143. u8 sig[4];
  144. u8 rev_major;
  145. u8 rev_minor;
  146. u16 len;
  147. u8 checksum;
  148. u8 reserved1;
  149. u16 reserved2;
  150. } __attribute__ ((packed));
  151. #else
  152. #define SCI_MAX_PORTS 4
  153. #define SCI_MAX_PHYS 4
  154. #define SCI_MAX_CONTROLLERS 2
  155. #endif
  156. #define ISCI_FW_NAME "isci/isci_firmware.bin"
  157. #define ROMSIGNATURE 0xaa55
  158. #define ISCI_OEM_SIG "$OEM"
  159. #define ISCI_OEM_SIG_SIZE 4
  160. #define ISCI_ROM_SIG "ISCUOEMB"
  161. #define ISCI_ROM_SIG_SIZE 8
  162. #define ISCI_EFI_VENDOR_GUID \
  163. EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, \
  164. 0x1a, 0x04, 0xc6)
  165. #define ISCI_EFI_VAR_NAME "RstScuO"
  166. #define ISCI_ROM_VER_1_0 0x10
  167. #define ISCI_ROM_VER_1_1 0x11
  168. #define ISCI_ROM_VER_1_3 0x13
  169. #define ISCI_ROM_VER_LATEST ISCI_ROM_VER_1_3
  170. /* Allowed PORT configuration modes APC Automatic PORT configuration mode is
  171. * defined by the OEM configuration parameters providing no PHY_MASK parameters
  172. * for any PORT. i.e. There are no phys assigned to any of the ports at start.
  173. * MPC Manual PORT configuration mode is defined by the OEM configuration
  174. * parameters providing a PHY_MASK value for any PORT. It is assumed that any
  175. * PORT with no PHY_MASK is an invalid port and not all PHYs must be assigned.
  176. * A PORT_PHY mask that assigns just a single PHY to a port and no other PHYs
  177. * being assigned is sufficient to declare manual PORT configuration.
  178. */
  179. enum sci_port_configuration_mode {
  180. SCIC_PORT_MANUAL_CONFIGURATION_MODE = 0,
  181. SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE = 1
  182. };
  183. struct sci_bios_oem_param_block_hdr {
  184. uint8_t signature[ISCI_ROM_SIG_SIZE];
  185. uint16_t total_block_length;
  186. uint8_t hdr_length;
  187. uint8_t version;
  188. uint8_t preboot_source;
  189. uint8_t num_elements;
  190. uint16_t element_length;
  191. uint8_t reserved[8];
  192. } __attribute__ ((packed));
  193. struct sci_oem_params {
  194. struct {
  195. uint8_t mode_type;
  196. uint8_t max_concurr_spin_up;
  197. /*
  198. * This bitfield indicates the OEM's desired default Tx
  199. * Spread Spectrum Clocking (SSC) settings for SATA and SAS.
  200. * NOTE: Default SSC Modulation Frequency is 31.5KHz.
  201. */
  202. union {
  203. struct {
  204. /*
  205. * NOTE: Max spread for SATA is +0 / -5000 PPM.
  206. * Down-spreading SSC (only method allowed for SATA):
  207. * SATA SSC Tx Disabled = 0x0
  208. * SATA SSC Tx at +0 / -1419 PPM Spread = 0x2
  209. * SATA SSC Tx at +0 / -2129 PPM Spread = 0x3
  210. * SATA SSC Tx at +0 / -4257 PPM Spread = 0x6
  211. * SATA SSC Tx at +0 / -4967 PPM Spread = 0x7
  212. */
  213. uint8_t ssc_sata_tx_spread_level:4;
  214. /*
  215. * SAS SSC Tx Disabled = 0x0
  216. *
  217. * NOTE: Max spread for SAS down-spreading +0 /
  218. * -2300 PPM
  219. * Down-spreading SSC:
  220. * SAS SSC Tx at +0 / -1419 PPM Spread = 0x2
  221. * SAS SSC Tx at +0 / -2129 PPM Spread = 0x3
  222. *
  223. * NOTE: Max spread for SAS center-spreading +2300 /
  224. * -2300 PPM
  225. * Center-spreading SSC:
  226. * SAS SSC Tx at +1064 / -1064 PPM Spread = 0x3
  227. * SAS SSC Tx at +2129 / -2129 PPM Spread = 0x6
  228. */
  229. uint8_t ssc_sas_tx_spread_level:3;
  230. /*
  231. * NOTE: Refer to the SSC section of the SAS 2.x
  232. * Specification for proper setting of this field.
  233. * For standard SAS Initiator SAS PHY operation it
  234. * should be 0 for Down-spreading.
  235. * SAS SSC Tx spread type:
  236. * Down-spreading SSC = 0
  237. * Center-spreading SSC = 1
  238. */
  239. uint8_t ssc_sas_tx_type:1;
  240. };
  241. uint8_t do_enable_ssc;
  242. };
  243. /*
  244. * This field indicates length of the SAS/SATA cable between
  245. * host and device.
  246. * This field is used make relationship between analog
  247. * parameters of the phy in the silicon and length of the cable.
  248. * Supported cable attenuation levels:
  249. * "short"- up to 3m, "medium"-3m to 6m, and "long"- more than
  250. * 6m.
  251. *
  252. * This is bit mask field:
  253. *
  254. * BIT: (MSB) 7 6 5 4
  255. * ASSIGNMENT: <phy3><phy2><phy1><phy0> - Medium cable
  256. * length assignment
  257. * BIT: 3 2 1 0 (LSB)
  258. * ASSIGNMENT: <phy3><phy2><phy1><phy0> - Long cable length
  259. * assignment
  260. *
  261. * BITS 7-4 are set when the cable length is assigned to medium
  262. * BITS 3-0 are set when the cable length is assigned to long
  263. *
  264. * The BIT positions are clear when the cable length is
  265. * assigned to short.
  266. *
  267. * Setting the bits for both long and medium cable length is
  268. * undefined.
  269. *
  270. * A value of 0x84 would assign
  271. * phy3 - medium
  272. * phy2 - long
  273. * phy1 - short
  274. * phy0 - short
  275. */
  276. uint8_t cable_selection_mask;
  277. } controller;
  278. struct {
  279. uint8_t phy_mask;
  280. } ports[SCI_MAX_PORTS];
  281. struct sci_phy_oem_params {
  282. struct {
  283. uint32_t high;
  284. uint32_t low;
  285. } sas_address;
  286. uint32_t afe_tx_amp_control0;
  287. uint32_t afe_tx_amp_control1;
  288. uint32_t afe_tx_amp_control2;
  289. uint32_t afe_tx_amp_control3;
  290. } phys[SCI_MAX_PHYS];
  291. } __attribute__ ((packed));
  292. struct isci_orom {
  293. struct sci_bios_oem_param_block_hdr hdr;
  294. struct sci_oem_params ctrl[SCI_MAX_CONTROLLERS];
  295. } __attribute__ ((packed));
  296. #endif