isci: fixup SAS iaf protocols data structure
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / isci / core / scic_sds_phy.h
blobb0cebdc669eb8720504054853bfb30634c20ebdf
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.
5 * GPL LICENSE SUMMARY
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
24 * BSD LICENSE
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
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.
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.
56 #ifndef _SCIC_SDS_PHY_H_
57 #define _SCIC_SDS_PHY_H_
59 #include "intel_sas.h"
60 #include "scic_phy.h"
61 #include "scu_registers.h"
62 #include "sci_base_state_machine.h"
63 #include <scsi/libsas.h>
65 struct scic_sds_port;
66 /**
69 * This is the timeout value for the SATA phy to wait for a SIGNATURE FIS
70 * before restarting the starting state machine. Technically, the old parallel
71 * ATA specification required up to 30 seconds for a device to issue its
72 * signature FIS as a result of a soft reset. Now we see that devices respond
73 * generally within 15 seconds, but we'll use 25 for now.
75 #define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000
77 /**
80 * This is the timeout for the SATA OOB/SN because the hardware does not
81 * recognize a hot plug after OOB signal but before the SN signals. We need to
82 * make sure after a hotplug timeout if we have not received the speed event
83 * notification from the hardware that we restart the hardware OOB state
84 * machine.
86 #define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250
88 enum scic_sds_phy_states {
89 /**
90 * Simply the initial state for the base domain state machine.
92 SCI_BASE_PHY_STATE_INITIAL,
94 /**
95 * This state indicates that the phy has successfully been stopped.
96 * In this state no new IO operations are permitted on this phy.
97 * This state is entered from the INITIAL state.
98 * This state is entered from the STARTING state.
99 * This state is entered from the READY state.
100 * This state is entered from the RESETTING state.
102 SCI_BASE_PHY_STATE_STOPPED,
105 * This state indicates that the phy is in the process of becomming
106 * ready. In this state no new IO operations are permitted on this phy.
107 * This state is entered from the STOPPED state.
108 * This state is entered from the READY state.
109 * This state is entered from the RESETTING state.
111 SCI_BASE_PHY_STATE_STARTING,
114 * This state indicates the the phy is now ready. Thus, the user
115 * is able to perform IO operations utilizing this phy as long as it
116 * is currently part of a valid port.
117 * This state is entered from the STARTING state.
119 SCI_BASE_PHY_STATE_READY,
122 * This state indicates that the phy is in the process of being reset.
123 * In this state no new IO operations are permitted on this phy.
124 * This state is entered from the READY state.
126 SCI_BASE_PHY_STATE_RESETTING,
129 * Simply the final state for the base phy state machine.
131 SCI_BASE_PHY_STATE_FINAL,
136 * enum scic_sds_phy_starting_substates -
140 enum scic_sds_phy_starting_substates {
142 * Initial state
144 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL,
147 * Wait state for the hardware OSSP event type notification
149 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN,
152 * Wait state for the PHY speed notification
154 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN,
157 * Wait state for the IAF Unsolicited frame notification
159 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF,
162 * Wait state for the request to consume power
164 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER,
167 * Wait state for request to consume power
169 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER,
172 * Wait state for the SATA PHY notification
174 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN,
177 * Wait for the SATA PHY speed notification
179 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN,
182 * Wait state for the SIGNATURE FIS unsolicited frame notification
184 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF,
187 * Exit state for this state machine
189 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL,
192 struct scic_sds_port;
193 struct scic_sds_controller;
196 * This enumeration provides a named phy type for the state machine
200 enum scic_sds_phy_protocol {
202 * This is an unknown phy type since there is either nothing on the other
203 * end or we have not detected the phy type as yet.
205 SCIC_SDS_PHY_PROTOCOL_UNKNOWN,
208 * This is a SAS PHY
210 SCIC_SDS_PHY_PROTOCOL_SAS,
213 * This is a SATA PHY
215 SCIC_SDS_PHY_PROTOCOL_SATA,
217 SCIC_SDS_MAX_PHY_PROTOCOLS
220 struct isci_phy;
222 * struct scic_sds_phy - This structure contains or references all of the data
223 * necessary to represent the core phy object and SCU harware protocol
224 * engine.
228 struct scic_sds_phy {
230 * This field depicts the peer object for the phy.
232 struct isci_phy *iphy;
235 * This field contains the information for the base phy state machine.
237 struct sci_base_state_machine state_machine;
240 * This field specifies the port object that owns/contains this phy.
242 struct scic_sds_port *owning_port;
245 * This field indicates whether the phy supports 1.5 Gb/s, 3.0 Gb/s,
246 * or 6.0 Gb/s operation.
248 enum sas_linkrate max_negotiated_speed;
251 * This member specifies the protocol being utilized on this phy. This
252 * field contains a legitamite value once the PHY has link trained with
253 * a remote phy.
255 enum scic_sds_phy_protocol protocol;
258 * This field specifies the index with which this phy is associated (0-3).
260 u8 phy_index;
263 * This member indicates if this particular PHY has received a BCN while
264 * it had no port assignement. This BCN will be reported once the phy is
265 * assigned to a port.
267 bool bcn_received_while_port_unassigned;
270 * This field indicates if this PHY is currently in the process of
271 * link training (i.e. it has started OOB, but has yet to perform
272 * IAF exchange/Signature FIS reception).
274 bool is_in_link_training;
277 * This field contains a reference to the timer utilized in detecting
278 * when a signature FIS timeout has occurred. The signature FIS is the
279 * first FIS sent by an attached SATA device after OOB/SN.
281 void *sata_timeout_timer;
283 const struct scic_sds_phy_state_handler *state_handlers;
285 struct sci_base_state_machine starting_substate_machine;
288 * This field is the pointer to the transport layer register for the SCU
289 * hardware.
291 struct scu_transport_layer_registers __iomem *transport_layer_registers;
294 * This field points to the link layer register set within the SCU.
296 struct scu_link_layer_registers __iomem *link_layer_registers;
300 typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *);
301 typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32);
302 typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32);
303 typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *);
306 * struct scic_sds_phy_state_handler -
310 struct scic_sds_phy_state_handler {
312 * The start_handler specifies the method invoked when there is an
313 * attempt to start a phy.
315 scic_sds_phy_handler_t start_handler;
318 * The stop_handler specifies the method invoked when there is an
319 * attempt to stop a phy.
321 scic_sds_phy_handler_t stop_handler;
324 * The reset_handler specifies the method invoked when there is an
325 * attempt to reset a phy.
327 scic_sds_phy_handler_t reset_handler;
330 * The destruct_handler specifies the method invoked when attempting to
331 * destruct a phy.
333 scic_sds_phy_handler_t destruct_handler;
336 * The state handler for unsolicited frames received from the SCU hardware.
338 scic_sds_phy_frame_handler_t frame_handler;
341 * The state handler for events received from the SCU hardware.
343 scic_sds_phy_event_handler_t event_handler;
346 * The state handler for staggered spinup.
348 scic_sds_phy_power_handler_t consume_power_handler;
353 * scic_sds_phy_get_index() -
355 * This macro returns the phy index for the specified phy
357 #define scic_sds_phy_get_index(phy) \
358 ((phy)->phy_index)
361 * scic_sds_phy_get_controller() - This macro returns the controller for this
362 * phy
366 #define scic_sds_phy_get_controller(phy) \
367 (scic_sds_port_get_controller((phy)->owning_port))
370 * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for
371 * this phy object
375 #define scic_sds_phy_set_state_handlers(phy, handlers) \
376 ((phy)->state_handlers = (handlers))
379 * scic_sds_phy_set_base_state_handlers() -
381 * This macro set the base state handlers for the phy object.
383 #define scic_sds_phy_set_base_state_handlers(phy, state_id) \
384 scic_sds_phy_set_state_handlers(\
385 (phy), \
386 &scic_sds_phy_state_handler_table[(state_id)] \
389 void scic_sds_phy_construct(
390 struct scic_sds_phy *this_phy,
391 struct scic_sds_port *owning_port,
392 u8 phy_index);
394 struct scic_sds_port *scic_sds_phy_get_port(
395 struct scic_sds_phy *this_phy);
397 void scic_sds_phy_set_port(
398 struct scic_sds_phy *this_phy,
399 struct scic_sds_port *owning_port);
401 enum sci_status scic_sds_phy_initialize(
402 struct scic_sds_phy *this_phy,
403 struct scu_transport_layer_registers __iomem *transport_layer_registers,
404 struct scu_link_layer_registers __iomem *link_layer_registers);
406 enum sci_status scic_sds_phy_start(
407 struct scic_sds_phy *this_phy);
409 enum sci_status scic_sds_phy_stop(
410 struct scic_sds_phy *this_phy);
412 enum sci_status scic_sds_phy_reset(
413 struct scic_sds_phy *this_phy);
415 void scic_sds_phy_resume(
416 struct scic_sds_phy *this_phy);
418 void scic_sds_phy_setup_transport(
419 struct scic_sds_phy *this_phy,
420 u32 device_id);
422 enum sci_status scic_sds_phy_event_handler(
423 struct scic_sds_phy *this_phy,
424 u32 event_code);
426 enum sci_status scic_sds_phy_frame_handler(
427 struct scic_sds_phy *this_phy,
428 u32 frame_index);
430 enum sci_status scic_sds_phy_consume_power_handler(
431 struct scic_sds_phy *this_phy);
433 void scic_sds_phy_get_sas_address(
434 struct scic_sds_phy *this_phy,
435 struct sci_sas_address *sas_address);
437 void scic_sds_phy_get_attached_sas_address(
438 struct scic_sds_phy *this_phy,
439 struct sci_sas_address *sas_address);
441 void scic_sds_phy_get_protocols(
442 struct scic_sds_phy *sci_phy,
443 struct scic_phy_proto *protocols);
445 #endif /* _SCIC_SDS_PHY_H_ */