1230557Sjimharris/*-
2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license.  When using or
3230557Sjimharris * redistributing this file, you may do so under either license.
4230557Sjimharris *
5230557Sjimharris * GPL LICENSE SUMMARY
6230557Sjimharris *
7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8230557Sjimharris *
9230557Sjimharris * This program is free software; you can redistribute it and/or modify
10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as
11230557Sjimharris * published by the Free Software Foundation.
12230557Sjimharris *
13230557Sjimharris * This program is distributed in the hope that it will be useful, but
14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of
15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16230557Sjimharris * General Public License for more details.
17230557Sjimharris *
18230557Sjimharris * You should have received a copy of the GNU General Public License
19230557Sjimharris * along with this program; if not, write to the Free Software
20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21230557Sjimharris * The full GNU General Public License is included in this distribution
22230557Sjimharris * in the file called LICENSE.GPL.
23230557Sjimharris *
24230557Sjimharris * BSD LICENSE
25230557Sjimharris *
26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27230557Sjimharris * All rights reserved.
28230557Sjimharris *
29230557Sjimharris * Redistribution and use in source and binary forms, with or without
30230557Sjimharris * modification, are permitted provided that the following conditions
31230557Sjimharris * are met:
32230557Sjimharris *
33230557Sjimharris *   * Redistributions of source code must retain the above copyright
34230557Sjimharris *     notice, this list of conditions and the following disclaimer.
35230557Sjimharris *   * Redistributions in binary form must reproduce the above copyright
36230557Sjimharris *     notice, this list of conditions and the following disclaimer in
37230557Sjimharris *     the documentation and/or other materials provided with the
38230557Sjimharris *     distribution.
39230557Sjimharris *
40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51230557Sjimharris *
52230557Sjimharris * $FreeBSD$
53230557Sjimharris */
54230557Sjimharris#ifndef _SCIC_SGPIO_H_
55230557Sjimharris#define _SCIC_SGPIO_H_
56230557Sjimharris
57230557Sjimharris/**
58230557Sjimharris* @file
59230557Sjimharris*
60230557Sjimharris* @brief This file contains all of the interface methods that can be called
61230557Sjimharris*        by an SCI user on an Serialized General Purpose IO (SGPIO) object.
62230557Sjimharris*/
63230557Sjimharris
64230557Sjimharris#ifdef __cplusplus
65230557Sjimharrisextern "C" {
66230557Sjimharris#endif // __cplusplus
67230557Sjimharris
68230557Sjimharris#include <dev/isci/scil/sci_types.h>
69230557Sjimharris
70230557Sjimharris//Programmable Blink Pattern Durations
71230557Sjimharris#define SGPIO_BLINK_DURATION_125    0x0
72230557Sjimharris#define SGPIO_BLINK_DURATION_250    0x1
73230557Sjimharris#define SGPIO_BLINK_DURATION_375    0x2
74230557Sjimharris#define SGPIO_BLINK_DURATION_500    0x3
75230557Sjimharris#define SGPIO_BLINK_DURATION_625    0x4
76230557Sjimharris#define SGPIO_BLINK_DURATION_750    0x5
77230557Sjimharris#define SGPIO_BLINK_DURATION_875    0x6
78230557Sjimharris#define SGPIO_BLINK_DURATION_1000   0x7
79230557Sjimharris#define SGPIO_BLINK_DURATION_1250   0x8
80230557Sjimharris#define SGPIO_BLINK_DURATION_1375   0x9
81230557Sjimharris#define SGPIO_BLINK_DURATION_1500   0xA
82230557Sjimharris#define SGPIO_BLINK_DURATION_1625   0xB
83230557Sjimharris#define SGPIO_BLINK_DURATION_1750   0xC
84230557Sjimharris#define SGPIO_BLINK_DURATION_1875   0xD
85230557Sjimharris#define SGPIO_BLINK_DURATION_2000   0xF
86230557Sjimharris
87230557Sjimharris#define ENABLE_SGPIO_FUNCTIONALITY  1
88230557Sjimharris#define DISABLE_SGPIO_FUNCTIONALITY 0
89230557Sjimharris
90230557Sjimharris#define SGPIO_HARDWARE_CONTROL      0x00000443
91230557Sjimharris#define SGPIO_SOFTWARE_CONTROL      0x00000444
92230557Sjimharris
93230557Sjimharris#define PHY_0_MASK                  0x01
94230557Sjimharris#define PHY_1_MASK                  0x02
95230557Sjimharris#define PHY_2_MASK                  0x04
96230557Sjimharris#define PHY_3_MASK                  0x08
97230557Sjimharris
98230557Sjimharris#define SGODSR_INVERT_BIT 0x4
99230557Sjimharris
100230557Sjimharris#define SGODSR_ERROR_LED_SHIFT 8
101230557Sjimharris#define SGODSR_LOCATE_LED_SHIFT 4
102230557Sjimharris#define SGODSR_ACTIVITY_LED_SHIFT 0
103230557Sjimharris
104230557Sjimharris#define SGPIO_BLINK_PATTERN_A 0x1
105230557Sjimharris#define SGPIO_BLINK_PATTERN_B 0x2
106230557Sjimharris
107230557Sjimharris/**
108230557Sjimharris* @brief This will set the vendor specific code in the SGPIO Vendor Specific Code
109230557Sjimharris*        register that is sent on the sLoad wire at the start of each
110230557Sjimharris*        bit stream.
111230557Sjimharris*
112230557Sjimharris* @param[in] SCI_CONTROLLER_HANDLE_T controller
113230557Sjimharris* @param]in] vendor_specific_sequence - Vendor specific sequence set in the
114230557Sjimharris*         SGVSCR register.
115230557Sjimharris*
116230557Sjimharris*/
117230557Sjimharrisvoid scic_sgpio_set_vendor_code(
118230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
119230557Sjimharris   U8 vendor_specific_sequence
120230557Sjimharris);
121230557Sjimharris
122230557Sjimharris/**
123230557Sjimharris* @brief Use this to set both programmable blink patterns A & B in the
124230557Sjimharris*        SGPBR(Programmable Blink Register). Will set identical patterns
125230557Sjimharris*        on both SGPIO units.
126230557Sjimharris*
127230557Sjimharris* @param[in] SCI_CONTROLLER_HANDLE_T controller
128230557Sjimharris* @param[in] pattern_a_high - High(LED on) duration time for pattern A
129230557Sjimharris* @param[in] pattern_a_low - Low(LED off) duration time for pattern A
130230557Sjimharris* @param[in] pattern_b_high - High(LED on) duration time for pattern B
131230557Sjimharris* @param[in] pattern_b_low - Low(LED off) duration time for pattern B
132230557Sjimharris*
133230557Sjimharris*/
134230557Sjimharrisvoid scic_sgpio_set_blink_patterns(
135230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
136230557Sjimharris   U8 pattern_a_low,
137230557Sjimharris   U8 pattern_a_high,
138230557Sjimharris   U8 pattern_b_low,
139230557Sjimharris   U8 pattern_b_high
140230557Sjimharris);
141230557Sjimharris
142230557Sjimharris
143230557Sjimharris/**
144230557Sjimharris* @brief This will set the functionality enable bit in the SGPIO interface
145230557Sjimharris*        control register, when set the bus pins will be used for SGPIO
146230557Sjimharris*        signaling, if not the bus pins are used for direct led control.
147230557Sjimharris*
148230557Sjimharris* @param[in] SCI_CONTROLLER_HANDLE_T controller
149230557Sjimharris* @param[in] BOOL sgpio_mode - indication for SGPIO signaling.
150230557Sjimharris*
151230557Sjimharris*/
152230557Sjimharrisvoid scic_sgpio_set_functionality(
153230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
154230557Sjimharris   BOOL sgpio_mode
155230557Sjimharris);
156230557Sjimharris
157230557Sjimharris/**
158230557Sjimharris * @brief Communicates with hardware to set the blink pattern
159230557Sjimharris *        of the error, locate, and activity LED's for phys
160230557Sjimharris *        specified by the phy_mask parameter.
161230557Sjimharris *        Function intend to be used to LEDs management
162230557Sjimharris *        in non-inteligent backplanes.
163230557Sjimharris *
164230557Sjimharris * @param[in] SCI_CONTROLLER_HANDLE_T controller
165230557Sjimharris * @param[in] phy_mask - This field is a bit mask that specifies the phys
166230557Sjimharris *                       to be updated.
167230557Sjimharris * @param[in] error - If TRUE, apply pattern for the error LED
168230557Sjimharris * @param[in] locate - If TRUE, apply pattern for the locate LED
169230557Sjimharris * @param[in] activity - If TRUE, apply pattern for the activity LED
170230557Sjimharris * @param[in] pattern_selection - One of two patterns (A or B).
171230557Sjimharris *            "A" and "B" patterns should be previously defined
172230557Sjimharris *            by scic_sgpio_set_blink_patterns()
173230557Sjimharris *
174230557Sjimharris * @return none
175230557Sjimharris */
176230557Sjimharrisvoid scic_sgpio_apply_led_blink_pattern(
177230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
178230557Sjimharris   U32 phy_mask,
179230557Sjimharris   BOOL error,
180230557Sjimharris   BOOL locate,
181230557Sjimharris   BOOL activity,
182230557Sjimharris   U8 pattern_selection
183230557Sjimharris);
184230557Sjimharris
185230557Sjimharris/**
186230557Sjimharris * @brief Communicates with hardware to set the blink pattern
187230557Sjimharris *        of the error, locate, and activity LED's for all
188230557Sjimharris *        phys in the port. Function intend to be used to LEDs
189230557Sjimharris *        management in non-inteligent backplanes.
190230557Sjimharris *
191230557Sjimharris * @param[in] SCI_CONTROLLER_HANDLE_T controller
192230557Sjimharris * @param[in] port_handle - port handle is used to identify SGPIO bay
193230557Sjimharris * @param[in] error - If TRUE, apply pattern for the error LED
194230557Sjimharris * @param[in] locate - If TRUE, apply pattern for the locate LED
195230557Sjimharris * @param[in] activity - If TRUE, apply pattern for the activity LED
196230557Sjimharris * @param[in] pattern_selection - One of two patterns (A or B).
197230557Sjimharris *            "A" and "B" patterns should be previously defined
198230557Sjimharris *            by scic_sgpio_set_blink_patterns()
199230557Sjimharris *
200230557Sjimharris * @return none
201230557Sjimharris */
202230557Sjimharrisvoid scic_sgpio_set_led_blink_pattern(
203230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
204230557Sjimharris   SCI_PORT_HANDLE_T port_handle,
205230557Sjimharris   BOOL error,
206230557Sjimharris   BOOL locate,
207230557Sjimharris   BOOL activity,
208230557Sjimharris   U8 pattern_selection
209230557Sjimharris);
210230557Sjimharris
211230557Sjimharris/**
212230557Sjimharris * @brief Communicates with hardware to set the state of the error, locate,
213230557Sjimharris *        and activity LED's.
214230557Sjimharris *
215230557Sjimharris * @param[in] SCI_CONTROLLER_HANDLE_T controller
216230557Sjimharris * @param[in] phy_mask - This field is a bit mask that specifies the phys
217230557Sjimharris *                       to be updated.
218230557Sjimharris * @param[in] error - State to be set for the error LED
219230557Sjimharris * @param[in] locate - State to be set for the locate LED
220230557Sjimharris * @param[in] activity - State to be set for the activity LED
221230557Sjimharris *
222230557Sjimharris * @return none
223230557Sjimharris */
224230557Sjimharrisvoid scic_sgpio_update_led_state(
225230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
226230557Sjimharris   U32 phy_mask,
227230557Sjimharris   BOOL error,
228230557Sjimharris   BOOL locate,
229230557Sjimharris   BOOL activity
230230557Sjimharris);
231230557Sjimharris
232230557Sjimharris/**
233230557Sjimharris * @brief Communicates with hardware to set the state of the error, locate,
234230557Sjimharris *        and activity LED's for all phys in the port.
235230557Sjimharris *
236230557Sjimharris * @param[in] SCI_CONTROLLER_HANDLE_T controller
237230557Sjimharris * @param[in] port_handle - port handle is used to identify SGPIO bay
238230557Sjimharris * @param[in] error - State to be set for the error LED
239230557Sjimharris * @param[in] locate - State to be set for the locate LED
240230557Sjimharris * @param[in] activity - State to be set for the activity LED
241230557Sjimharris *
242230557Sjimharris * @return none
243230557Sjimharris */
244230557Sjimharrisvoid scic_sgpio_set_led_state(
245230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
246230557Sjimharris   SCI_PORT_HANDLE_T port_handle,
247230557Sjimharris   BOOL error,
248230557Sjimharris   BOOL locate,
249230557Sjimharris   BOOL activity
250230557Sjimharris);
251230557Sjimharris
252230557Sjimharris/**
253230557Sjimharris * @brief This will set all Activity LED's to hardware controlled
254230557Sjimharris *
255230557Sjimharris * @param[in] BOOL is_hardware_controlled - indication for the Activity LED's
256230557Sjimharris *         to be hardware controlled or driver controlled.
257230557Sjimharris * @return none
258230557Sjimharris */
259230557Sjimharrisvoid scic_sgpio_set_to_hardware_control(
260230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller,
261230557Sjimharris   BOOL is_hardware_controlled
262230557Sjimharris);
263230557Sjimharris
264230557Sjimharris/**
265230557Sjimharris * @brief Reads and returns the data-in from the SGPIO port for the specified controller.
266230557Sjimharris *        Bits 00:02 - Drive 0 input data
267230557Sjimharris *        Bits 04:06 - Drive 1 input data
268230557Sjimharris *        Bits 08:10 - Drive 2 input data
269230557Sjimharris *        Bits 12:14 - Drive 3 input data
270230557Sjimharris *
271230557Sjimharris * @param[in] SCI_CONTROLLER_HANDLE_T controller
272230557Sjimharris * @return U32 - Value read from SGPIO, 0xffffffff indicates hardware not readable
273230557Sjimharris */
274230557SjimharrisU32 scic_sgpio_read(
275230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller
276230557Sjimharris);
277230557Sjimharris
278230557Sjimharris/**
279230557Sjimharris * @brief Initializes the SCU for Hardware SGPIO LED control.
280230557Sjimharris *
281230557Sjimharris * @param[in] SCI_CONTROLLER_HANDLE_T controller
282230557Sjimharris */
283230557Sjimharrisvoid scic_sgpio_hardware_initialize(
284230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller
285230557Sjimharris);
286230557Sjimharris/**
287230557Sjimharris* @brief Initializes the SCU for Software SGPIO signaling of LED control.
288230557Sjimharris*
289230557Sjimharris* @param[in] SCI_CONTROLLER_HANDLE_T controller
290230557Sjimharris*/
291230557Sjimharrisvoid scic_sgpio_initialize(
292230557Sjimharris   SCI_CONTROLLER_HANDLE_T controller
293230557Sjimharris);
294230557Sjimharris
295230557Sjimharris#ifdef __cplusplus
296230557Sjimharris}
297230557Sjimharris#endif // __cplusplus
298230557Sjimharris
299230557Sjimharris#endif // _SCIC_SGPIO_H_
300