scic_sgpio.h revision 231136
162587Sitojun/*- 278064Sume * This file is provided under a dual BSD/GPLv2 license. When using or 362587Sitojun * redistributing this file, you may do so under either license. 453541Sshin * 553541Sshin * GPL LICENSE SUMMARY 653541Sshin * 753541Sshin * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 853541Sshin * 953541Sshin * This program is free software; you can redistribute it and/or modify 1053541Sshin * it under the terms of version 2 of the GNU General Public License as 1153541Sshin * published by the Free Software Foundation. 1253541Sshin * 1353541Sshin * This program is distributed in the hope that it will be useful, but 1453541Sshin * WITHOUT ANY WARRANTY; without even the implied warranty of 1553541Sshin * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1653541Sshin * General Public License for more details. 1753541Sshin * 1853541Sshin * You should have received a copy of the GNU General Public License 1953541Sshin * along with this program; if not, write to the Free Software 2053541Sshin * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 2153541Sshin * The full GNU General Public License is included in this distribution 2253541Sshin * in the file called LICENSE.GPL. 2353541Sshin * 2453541Sshin * BSD LICENSE 2553541Sshin * 2653541Sshin * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 2753541Sshin * All rights reserved. 2853541Sshin * 2953541Sshin * Redistribution and use in source and binary forms, with or without 3053541Sshin * modification, are permitted provided that the following conditions 3153541Sshin * are met: 3253541Sshin * 3353541Sshin * * Redistributions of source code must retain the above copyright 3453541Sshin * notice, this list of conditions and the following disclaimer. 3553541Sshin * * Redistributions in binary form must reproduce the above copyright 3653541Sshin * notice, this list of conditions and the following disclaimer in 3753541Sshin * the documentation and/or other materials provided with the 3853541Sshin * distribution. 3953541Sshin * 4053541Sshin * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4153541Sshin * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 4253541Sshin * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 4353541Sshin * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 4453541Sshin * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4553541Sshin * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 4653541Sshin * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 4753541Sshin * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 4853541Sshin * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 4953541Sshin * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 5053541Sshin * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5153541Sshin * 5253541Sshin * $FreeBSD: head/sys/dev/isci/scil/scic_sgpio.h 231136 2012-02-07 17:43:58Z jimharris $ 5353541Sshin */ 5453541Sshin#ifndef _SCIC_SGPIO_H_ 5553541Sshin#define _SCIC_SGPIO_H_ 5653541Sshin 5753541Sshin/** 5853541Sshin* @file 5953541Sshin* 6053541Sshin* @brief This file contains all of the interface methods that can be called 6153541Sshin* by an SCI user on an Serialized General Purpose IO (SGPIO) object. 6253541Sshin*/ 6353541Sshin 6453541Sshin#ifdef __cplusplus 6553541Sshinextern "C" { 6653541Sshin#endif // __cplusplus 6753541Sshin 6853541Sshin#include <dev/isci/scil/sci_types.h> 6978064Sume 7078064Sume//Programmable Blink Pattern Durations 7155009Sshin#define SGPIO_BLINK_DURATION_125 0x0 7253541Sshin#define SGPIO_BLINK_DURATION_250 0x1 7353541Sshin#define SGPIO_BLINK_DURATION_375 0x2 7453541Sshin#define SGPIO_BLINK_DURATION_500 0x3 7553541Sshin#define SGPIO_BLINK_DURATION_625 0x4 7653541Sshin#define SGPIO_BLINK_DURATION_750 0x5 7755679Sshin#define SGPIO_BLINK_DURATION_875 0x6 7853541Sshin#define SGPIO_BLINK_DURATION_1000 0x7 7953541Sshin#define SGPIO_BLINK_DURATION_1250 0x8 8053541Sshin#define SGPIO_BLINK_DURATION_1375 0x9 8153541Sshin#define SGPIO_BLINK_DURATION_1500 0xA 8253541Sshin#define SGPIO_BLINK_DURATION_1625 0xB 8353541Sshin#define SGPIO_BLINK_DURATION_1750 0xC 8453541Sshin#define SGPIO_BLINK_DURATION_1875 0xD 8553541Sshin#define SGPIO_BLINK_DURATION_2000 0xF 8653541Sshin 8792767Sjeff#define ENABLE_SGPIO_FUNCTIONALITY 1 8853541Sshin#define DISABLE_SGPIO_FUNCTIONALITY 0 8953541Sshin 9053541Sshin#define SGPIO_HARDWARE_CONTROL 0x00000443 9153541Sshin#define SGPIO_SOFTWARE_CONTROL 0x00000444 9253541Sshin 9353541Sshin#define PHY_0_MASK 0x01 9453541Sshin#define PHY_1_MASK 0x02 9553541Sshin#define PHY_2_MASK 0x04 9698102Shsu#define PHY_3_MASK 0x08 9762587Sitojun 9855679Sshin#define SGODSR_INVERT_BIT 0x4 9953541Sshin 10053541Sshin#define SGODSR_ERROR_LED_SHIFT 8 10153541Sshin#define SGODSR_LOCATE_LED_SHIFT 4 10253541Sshin#define SGODSR_ACTIVITY_LED_SHIFT 0 10353541Sshin 10453541Sshin#define SGPIO_BLINK_PATTERN_A 0x1 10553541Sshin#define SGPIO_BLINK_PATTERN_B 0x2 10678064Sume 10778064Sume/** 10878064Sume* @brief This will set the vendor specific code in the SGPIO Vendor Specific Code 10955009Sshin* register that is sent on the sLoad wire at the start of each 11078064Sume* bit stream. 11155009Sshin* 11278064Sume* @param[in] SCI_CONTROLLER_HANDLE_T controller 11353541Sshin* @param]in] vendor_specific_sequence - Vendor specific sequence set in the 11453541Sshin* SGVSCR register. 11553541Sshin* 116105199Ssam*/ 117105199Ssamvoid scic_sgpio_set_vendor_code( 118105199Ssam SCI_CONTROLLER_HANDLE_T controller, 119105199Ssam U8 vendor_specific_sequence 120105199Ssam); 121105199Ssam 122105199Ssam/** 12353541Sshin* @brief Use this to set both programmable blink patterns A & B in the 12453541Sshin* SGPBR(Programmable Blink Register). Will set identical patterns 12553541Sshin* on both SGPIO units. 12683366Sjulian* 12753541Sshin* @param[in] SCI_CONTROLLER_HANDLE_T controller 12853541Sshin* @param[in] pattern_a_high - High(LED on) duration time for pattern A 12983366Sjulian* @param[in] pattern_a_low - Low(LED off) duration time for pattern A 13053541Sshin* @param[in] pattern_b_high - High(LED on) duration time for pattern B 13153541Sshin* @param[in] pattern_b_low - Low(LED off) duration time for pattern B 13253541Sshin* 13353541Sshin*/ 13453541Sshinvoid scic_sgpio_set_blink_patterns( 13597658Stanimura SCI_CONTROLLER_HANDLE_T controller, 13653541Sshin U8 pattern_a_low, 13753541Sshin U8 pattern_a_high, 13853541Sshin U8 pattern_b_low, 13953541Sshin U8 pattern_b_high 14053541Sshin); 14153541Sshin 14253541Sshin 14353541Sshin/** 14453541Sshin* @brief This will set the functionality enable bit in the SGPIO interface 14553541Sshin* control register, when set the bus pins will be used for SGPIO 14653541Sshin* signaling, if not the bus pins are used for direct led control. 14753541Sshin* 14853541Sshin* @param[in] SCI_CONTROLLER_HANDLE_T controller 14953541Sshin* @param[in] BOOL sgpio_mode - indication for SGPIO signaling. 15053541Sshin* 15153541Sshin*/ 15253541Sshinvoid scic_sgpio_set_functionality( 15362587Sitojun SCI_CONTROLLER_HANDLE_T controller, 15462587Sitojun BOOL sgpio_mode 15562587Sitojun); 15662587Sitojun 15762587Sitojun/** 15853541Sshin * @brief Communicates with hardware to set the blink pattern 15953541Sshin * of the error, locate, and activity LED's for phys 16053541Sshin * specified by the phy_mask parameter. 16153541Sshin * Function intend to be used to LEDs management 16253541Sshin * in non-inteligent backplanes. 16353541Sshin * 16453541Sshin * @param[in] SCI_CONTROLLER_HANDLE_T controller 16553541Sshin * @param[in] phy_mask - This field is a bit mask that specifies the phys 16653541Sshin * to be updated. 16753541Sshin * @param[in] error - If TRUE, apply pattern for the error LED 16853541Sshin * @param[in] locate - If TRUE, apply pattern for the locate LED 16953541Sshin * @param[in] activity - If TRUE, apply pattern for the activity LED 17053541Sshin * @param[in] pattern_selection - One of two patterns (A or B). 17153541Sshin * "A" and "B" patterns should be previously defined 17253541Sshin * by scic_sgpio_set_blink_patterns() 17353541Sshin * 17453541Sshin * @return none 17553541Sshin */ 17653541Sshinvoid scic_sgpio_apply_led_blink_pattern( 17753541Sshin SCI_CONTROLLER_HANDLE_T controller, 17853541Sshin U32 phy_mask, 17953541Sshin BOOL error, 18078064Sume BOOL locate, 18178064Sume BOOL activity, 18253541Sshin U8 pattern_selection 18353541Sshin); 18453541Sshin 18578064Sume/** 18653541Sshin * @brief Communicates with hardware to set the blink pattern 18753541Sshin * of the error, locate, and activity LED's for all 18853541Sshin * phys in the port. Function intend to be used to LEDs 18953541Sshin * management in non-inteligent backplanes. 19053541Sshin * 19153541Sshin * @param[in] SCI_CONTROLLER_HANDLE_T controller 19253541Sshin * @param[in] port_handle - port handle is used to identify SGPIO bay 19383366Sjulian * @param[in] error - If TRUE, apply pattern for the error LED 19493593Sjhb * @param[in] locate - If TRUE, apply pattern for the locate LED 19553541Sshin * @param[in] activity - If TRUE, apply pattern for the activity LED 19653541Sshin * @param[in] pattern_selection - One of two patterns (A or B). 19753541Sshin * "A" and "B" patterns should be previously defined 19855679Sshin * by scic_sgpio_set_blink_patterns() 19953541Sshin * 20053541Sshin * @return none 20197658Stanimura */ 20297658Stanimuravoid scic_sgpio_set_led_blink_pattern( 20397658Stanimura SCI_CONTROLLER_HANDLE_T controller, 20497658Stanimura SCI_PORT_HANDLE_T port_handle, 20597658Stanimura BOOL error, 20697658Stanimura BOOL locate, 20797658Stanimura BOOL activity, 20897658Stanimura U8 pattern_selection 20978064Sume); 21055679Sshin 21155679Sshin/** 21255679Sshin * @brief Communicates with hardware to set the state of the error, locate, 21355679Sshin * and activity LED's. 21455679Sshin * 21555679Sshin * @param[in] SCI_CONTROLLER_HANDLE_T controller 21655679Sshin * @param[in] phy_mask - This field is a bit mask that specifies the phys 21755679Sshin * to be updated. 21855679Sshin * @param[in] error - State to be set for the error LED 21955679Sshin * @param[in] locate - State to be set for the locate LED 22055679Sshin * @param[in] activity - State to be set for the activity LED 22155679Sshin * 22255679Sshin * @return none 22355679Sshin */ 22455679Sshinvoid scic_sgpio_update_led_state( 22555679Sshin SCI_CONTROLLER_HANDLE_T controller, 22653541Sshin U32 phy_mask, 22753541Sshin BOOL error, 22853541Sshin BOOL locate, 22997658Stanimura BOOL activity 23097658Stanimura); 23178064Sume 23255679Sshin/** 23355679Sshin * @brief Communicates with hardware to set the state of the error, locate, 23455679Sshin * and activity LED's for all phys in the port. 23555679Sshin * 23655679Sshin * @param[in] SCI_CONTROLLER_HANDLE_T controller 23755679Sshin * @param[in] port_handle - port handle is used to identify SGPIO bay 23897658Stanimura * @param[in] error - State to be set for the error LED 23997658Stanimura * @param[in] locate - State to be set for the locate LED 24097658Stanimura * @param[in] activity - State to be set for the activity LED 24197658Stanimura * 24297658Stanimura * @return none 24397658Stanimura */ 24497658Stanimuravoid scic_sgpio_set_led_state( 24597658Stanimura SCI_CONTROLLER_HANDLE_T controller, 24655679Sshin SCI_PORT_HANDLE_T port_handle, 24753541Sshin BOOL error, 24853541Sshin BOOL locate, 24953541Sshin BOOL activity 25053541Sshin); 25162587Sitojun 25283366Sjulian/** 25362587Sitojun * @brief This will set all Activity LED's to hardware controlled 25462587Sitojun * 25562587Sitojun * @param[in] BOOL is_hardware_controlled - indication for the Activity LED's 25662587Sitojun * to be hardware controlled or driver controlled. 25762587Sitojun * @return none 25862587Sitojun */ 25962587Sitojunvoid scic_sgpio_set_to_hardware_control( 26062587Sitojun SCI_CONTROLLER_HANDLE_T controller, 26153541Sshin BOOL is_hardware_controlled 26253541Sshin); 26353541Sshin 26453541Sshin/** 26553541Sshin * @brief Reads and returns the data-in from the SGPIO port for the specified controller. 26653541Sshin * Bits 00:02 - Drive 0 input data 26753541Sshin * Bits 04:06 - Drive 1 input data 26853541Sshin * Bits 08:10 - Drive 2 input data 26953541Sshin * Bits 12:14 - Drive 3 input data 27053541Sshin * 27153541Sshin * @param[in] SCI_CONTROLLER_HANDLE_T controller 27253541Sshin * @return U32 - Value read from SGPIO, 0xffffffff indicates hardware not readable 27353541Sshin */ 27453541SshinU32 scic_sgpio_read( 27553541Sshin SCI_CONTROLLER_HANDLE_T controller 27653541Sshin); 27753541Sshin 27853541Sshin/** 27953541Sshin * @brief Initializes the SCU for Hardware SGPIO LED control. 28053541Sshin * 28153541Sshin * @param[in] SCI_CONTROLLER_HANDLE_T controller 28253541Sshin */ 28353541Sshinvoid scic_sgpio_hardware_initialize( 28453541Sshin SCI_CONTROLLER_HANDLE_T controller 28553541Sshin); 28653541Sshin/** 28753541Sshin* @brief Initializes the SCU for Software SGPIO signaling of LED control. 28853541Sshin* 28953541Sshin* @param[in] SCI_CONTROLLER_HANDLE_T controller 29053541Sshin*/ 29153541Sshinvoid scic_sgpio_initialize( 29253541Sshin SCI_CONTROLLER_HANDLE_T controller 29353541Sshin); 29453541Sshin 29562587Sitojun#ifdef __cplusplus 29662587Sitojun} 29762587Sitojun#endif // __cplusplus 29853541Sshin 29953541Sshin#endif // _SCIC_SGPIO_H_ 30053541Sshin