1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3 * 4 * This file is provided under a dual BSD/GPLv2 license. When using or 5 * redistributing this file, you may do so under either license. 6 * 7 * GPL LICENSE SUMMARY 8 * 9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of version 2 of the GNU General Public License as 13 * published by the Free Software Foundation. 14 * 15 * This program is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 23 * The full GNU General Public License is included in this distribution 24 * in the file called LICENSE.GPL. 25 * 26 * BSD LICENSE 27 * 28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 29 * All rights reserved. 30 * 31 * Redistribution and use in source and binary forms, with or without 32 * modification, are permitted provided that the following conditions 33 * are met: 34 * 35 * * Redistributions of source code must retain the above copyright 36 * notice, this list of conditions and the following disclaimer. 37 * * Redistributions in binary form must reproduce the above copyright 38 * notice, this list of conditions and the following disclaimer in 39 * the documentation and/or other materials provided with the 40 * distribution. 41 * 42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 * 54 * $FreeBSD$ 55 */ 56 #ifndef _SCIC_SGPIO_H_ 57 #define _SCIC_SGPIO_H_ 58 59 /** 60 * @file 61 * 62 * @brief This file contains all of the interface methods that can be called 63 * by an SCI user on an Serialized General Purpose IO (SGPIO) object. 64 */ 65 66 #ifdef __cplusplus 67 extern "C" { 68 #endif // __cplusplus 69 70 #include <dev/isci/scil/sci_types.h> 71 72 //Programmable Blink Pattern Durations 73 #define SGPIO_BLINK_DURATION_125 0x0 74 #define SGPIO_BLINK_DURATION_250 0x1 75 #define SGPIO_BLINK_DURATION_375 0x2 76 #define SGPIO_BLINK_DURATION_500 0x3 77 #define SGPIO_BLINK_DURATION_625 0x4 78 #define SGPIO_BLINK_DURATION_750 0x5 79 #define SGPIO_BLINK_DURATION_875 0x6 80 #define SGPIO_BLINK_DURATION_1000 0x7 81 #define SGPIO_BLINK_DURATION_1250 0x8 82 #define SGPIO_BLINK_DURATION_1375 0x9 83 #define SGPIO_BLINK_DURATION_1500 0xA 84 #define SGPIO_BLINK_DURATION_1625 0xB 85 #define SGPIO_BLINK_DURATION_1750 0xC 86 #define SGPIO_BLINK_DURATION_1875 0xD 87 #define SGPIO_BLINK_DURATION_2000 0xF 88 89 #define ENABLE_SGPIO_FUNCTIONALITY 1 90 #define DISABLE_SGPIO_FUNCTIONALITY 0 91 92 #define SGPIO_HARDWARE_CONTROL 0x00000443 93 #define SGPIO_SOFTWARE_CONTROL 0x00000444 94 95 #define PHY_0_MASK 0x01 96 #define PHY_1_MASK 0x02 97 #define PHY_2_MASK 0x04 98 #define PHY_3_MASK 0x08 99 100 #define SGODSR_INVERT_BIT 0x4 101 102 #define SGODSR_ERROR_LED_SHIFT 8 103 #define SGODSR_LOCATE_LED_SHIFT 4 104 #define SGODSR_ACTIVITY_LED_SHIFT 0 105 106 #define SGPIO_BLINK_PATTERN_A 0x1 107 #define SGPIO_BLINK_PATTERN_B 0x2 108 109 /** 110 * @brief This will set the vendor specific code in the SGPIO Vendor Specific Code 111 * register that is sent on the sLoad wire at the start of each 112 * bit stream. 113 * 114 * @param[in] SCI_CONTROLLER_HANDLE_T controller 115 * @param]in] vendor_specific_sequence - Vendor specific sequence set in the 116 * SGVSCR register. 117 * 118 */ 119 void scic_sgpio_set_vendor_code( 120 SCI_CONTROLLER_HANDLE_T controller, 121 U8 vendor_specific_sequence 122 ); 123 124 /** 125 * @brief Use this to set both programmable blink patterns A & B in the 126 * SGPBR(Programmable Blink Register). Will set identical patterns 127 * on both SGPIO units. 128 * 129 * @param[in] SCI_CONTROLLER_HANDLE_T controller 130 * @param[in] pattern_a_high - High(LED on) duration time for pattern A 131 * @param[in] pattern_a_low - Low(LED off) duration time for pattern A 132 * @param[in] pattern_b_high - High(LED on) duration time for pattern B 133 * @param[in] pattern_b_low - Low(LED off) duration time for pattern B 134 * 135 */ 136 void scic_sgpio_set_blink_patterns( 137 SCI_CONTROLLER_HANDLE_T controller, 138 U8 pattern_a_low, 139 U8 pattern_a_high, 140 U8 pattern_b_low, 141 U8 pattern_b_high 142 ); 143 144 145 /** 146 * @brief This will set the functionality enable bit in the SGPIO interface 147 * control register, when set the bus pins will be used for SGPIO 148 * signaling, if not the bus pins are used for direct led control. 149 * 150 * @param[in] SCI_CONTROLLER_HANDLE_T controller 151 * @param[in] BOOL sgpio_mode - indication for SGPIO signaling. 152 * 153 */ 154 void scic_sgpio_set_functionality( 155 SCI_CONTROLLER_HANDLE_T controller, 156 BOOL sgpio_mode 157 ); 158 159 /** 160 * @brief Communicates with hardware to set the blink pattern 161 * of the error, locate, and activity LED's for phys 162 * specified by the phy_mask parameter. 163 * Function intend to be used to LEDs management 164 * in non-inteligent backplanes. 165 * 166 * @param[in] SCI_CONTROLLER_HANDLE_T controller 167 * @param[in] phy_mask - This field is a bit mask that specifies the phys 168 * to be updated. 169 * @param[in] error - If TRUE, apply pattern for the error LED 170 * @param[in] locate - If TRUE, apply pattern for the locate LED 171 * @param[in] activity - If TRUE, apply pattern for the activity LED 172 * @param[in] pattern_selection - One of two patterns (A or B). 173 * "A" and "B" patterns should be previously defined 174 * by scic_sgpio_set_blink_patterns() 175 * 176 * @return none 177 */ 178 void scic_sgpio_apply_led_blink_pattern( 179 SCI_CONTROLLER_HANDLE_T controller, 180 U32 phy_mask, 181 BOOL error, 182 BOOL locate, 183 BOOL activity, 184 U8 pattern_selection 185 ); 186 187 /** 188 * @brief Communicates with hardware to set the blink pattern 189 * of the error, locate, and activity LED's for all 190 * phys in the port. Function intend to be used to LEDs 191 * management in non-inteligent backplanes. 192 * 193 * @param[in] SCI_CONTROLLER_HANDLE_T controller 194 * @param[in] port_handle - port handle is used to identify SGPIO bay 195 * @param[in] error - If TRUE, apply pattern for the error LED 196 * @param[in] locate - If TRUE, apply pattern for the locate LED 197 * @param[in] activity - If TRUE, apply pattern for the activity LED 198 * @param[in] pattern_selection - One of two patterns (A or B). 199 * "A" and "B" patterns should be previously defined 200 * by scic_sgpio_set_blink_patterns() 201 * 202 * @return none 203 */ 204 void scic_sgpio_set_led_blink_pattern( 205 SCI_CONTROLLER_HANDLE_T controller, 206 SCI_PORT_HANDLE_T port_handle, 207 BOOL error, 208 BOOL locate, 209 BOOL activity, 210 U8 pattern_selection 211 ); 212 213 /** 214 * @brief Communicates with hardware to set the state of the error, locate, 215 * and activity LED's. 216 * 217 * @param[in] SCI_CONTROLLER_HANDLE_T controller 218 * @param[in] phy_mask - This field is a bit mask that specifies the phys 219 * to be updated. 220 * @param[in] error - State to be set for the error LED 221 * @param[in] locate - State to be set for the locate LED 222 * @param[in] activity - State to be set for the activity LED 223 * 224 * @return none 225 */ 226 void scic_sgpio_update_led_state( 227 SCI_CONTROLLER_HANDLE_T controller, 228 U32 phy_mask, 229 BOOL error, 230 BOOL locate, 231 BOOL activity 232 ); 233 234 /** 235 * @brief Communicates with hardware to set the state of the error, locate, 236 * and activity LED's for all phys in the port. 237 * 238 * @param[in] SCI_CONTROLLER_HANDLE_T controller 239 * @param[in] port_handle - port handle is used to identify SGPIO bay 240 * @param[in] error - State to be set for the error LED 241 * @param[in] locate - State to be set for the locate LED 242 * @param[in] activity - State to be set for the activity LED 243 * 244 * @return none 245 */ 246 void scic_sgpio_set_led_state( 247 SCI_CONTROLLER_HANDLE_T controller, 248 SCI_PORT_HANDLE_T port_handle, 249 BOOL error, 250 BOOL locate, 251 BOOL activity 252 ); 253 254 /** 255 * @brief This will set all Activity LED's to hardware controlled 256 * 257 * @param[in] BOOL is_hardware_controlled - indication for the Activity LED's 258 * to be hardware controlled or driver controlled. 259 * @return none 260 */ 261 void scic_sgpio_set_to_hardware_control( 262 SCI_CONTROLLER_HANDLE_T controller, 263 BOOL is_hardware_controlled 264 ); 265 266 /** 267 * @brief Reads and returns the data-in from the SGPIO port for the specified controller. 268 * Bits 00:02 - Drive 0 input data 269 * Bits 04:06 - Drive 1 input data 270 * Bits 08:10 - Drive 2 input data 271 * Bits 12:14 - Drive 3 input data 272 * 273 * @param[in] SCI_CONTROLLER_HANDLE_T controller 274 * @return U32 - Value read from SGPIO, 0xffffffff indicates hardware not readable 275 */ 276 U32 scic_sgpio_read( 277 SCI_CONTROLLER_HANDLE_T controller 278 ); 279 280 /** 281 * @brief Initializes the SCU for Hardware SGPIO LED control. 282 * 283 * @param[in] SCI_CONTROLLER_HANDLE_T controller 284 */ 285 void scic_sgpio_hardware_initialize( 286 SCI_CONTROLLER_HANDLE_T controller 287 ); 288 /** 289 * @brief Initializes the SCU for Software SGPIO signaling of LED control. 290 * 291 * @param[in] SCI_CONTROLLER_HANDLE_T controller 292 */ 293 void scic_sgpio_initialize( 294 SCI_CONTROLLER_HANDLE_T controller 295 ); 296 297 #ifdef __cplusplus 298 } 299 #endif // __cplusplus 300 301 #endif // _SCIC_SGPIO_H_ 302