Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
phy.h
Go to the documentation of this file.
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_PHY_H_
56 #define _ISCI_PHY_H_
57 
58 #include <scsi/sas.h>
59 #include <scsi/libsas.h>
60 #include "isci.h"
61 #include "sas.h"
62 
63 /* This is the timeout value for the SATA phy to wait for a SIGNATURE FIS
64  * before restarting the starting state machine. Technically, the old parallel
65  * ATA specification required up to 30 seconds for a device to issue its
66  * signature FIS as a result of a soft reset. Now we see that devices respond
67  * generally within 15 seconds, but we'll use 25 for now.
68  */
69 #define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000
70 
71 /* This is the timeout for the SATA OOB/SN because the hardware does not
72  * recognize a hot plug after OOB signal but before the SN signals. We need to
73  * make sure after a hotplug timeout if we have not received the speed event
74  * notification from the hardware that we restart the hardware OOB state
75  * machine.
76  */
77 #define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250
78 
87 struct isci_phy {
100  union {
101  struct sas_identify_frame iaf;
103  } frame_rcvd;
104 };
105 
106 static inline struct isci_phy *to_iphy(struct asd_sas_phy *sas_phy)
107 {
108  struct isci_phy *iphy = container_of(sas_phy, typeof(*iphy), sas_phy);
109 
110  return iphy;
111 }
112 
113 struct sci_phy_cap {
114  union {
115  struct {
116  /*
117  * The SAS specification indicates the start bit shall
118  * always be set to
119  * 1. This implementation will have the start bit set
120  * to 0 if the PHY CAPABILITIES were either not
121  * received or speed negotiation failed.
122  */
125  u8 res1:2;
127 
134  u32 res2:17;
136  };
138  };
139 } __packed;
140 
141 /* this data structure reflects the link layer transmit identification reg */
143  union {
144  struct {
155  };
157  };
158 } __packed;
159 
160 
173  struct isci_port *iport;
174 
180 
186 };
187 
199  struct sas_identify_frame rcvd_iaf;
200 
206 
207 };
208 
221 
227 
228 };
229 
241 
246 
251 
256 
262 
268 
274 
280 
286 
292 
298 
304 
312 
319 
325 
331 
337 };
338 
376 #define PHY_STATES {\
377  C(PHY_INITIAL),\
378  C(PHY_STOPPED),\
379  C(PHY_STARTING),\
380  C(PHY_SUB_INITIAL),\
381  C(PHY_SUB_AWAIT_OSSP_EN),\
382  C(PHY_SUB_AWAIT_SAS_SPEED_EN),\
383  C(PHY_SUB_AWAIT_IAF_UF),\
384  C(PHY_SUB_AWAIT_SAS_POWER),\
385  C(PHY_SUB_AWAIT_SATA_POWER),\
386  C(PHY_SUB_AWAIT_SATA_PHY_EN),\
387  C(PHY_SUB_AWAIT_SATA_SPEED_EN),\
388  C(PHY_SUB_AWAIT_SIG_FIS_UF),\
389  C(PHY_SUB_FINAL),\
390  C(PHY_READY),\
391  C(PHY_RESETTING),\
392  C(PHY_FINAL),\
393  }
394 #undef C
395 #define C(a) SCI_##a
396 enum sci_phy_states PHY_STATES;
397 #undef C
398 
399 void sci_phy_construct(
400  struct isci_phy *iphy,
401  struct isci_port *iport,
402  u8 phy_index);
403 
404 struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy);
405 
406 void sci_phy_set_port(
407  struct isci_phy *iphy,
408  struct isci_port *iport);
409 
411  struct isci_phy *iphy,
412  struct scu_transport_layer_registers __iomem *transport_layer_registers,
413  struct scu_link_layer_registers __iomem *link_layer_registers);
414 
416  struct isci_phy *iphy);
417 
419  struct isci_phy *iphy);
420 
422  struct isci_phy *iphy);
423 
424 void sci_phy_resume(
425  struct isci_phy *iphy);
426 
428  struct isci_phy *iphy,
429  u32 device_id);
430 
432  struct isci_phy *iphy,
433  u32 event_code);
434 
436  struct isci_phy *iphy,
437  u32 frame_index);
438 
440  struct isci_phy *iphy);
441 
443  struct isci_phy *iphy,
444  struct sci_sas_address *sas_address);
445 
447  struct isci_phy *iphy,
448  struct sci_sas_address *sas_address);
449 
450 struct sci_phy_proto;
452  struct isci_phy *iphy,
453  struct sci_phy_proto *protocols);
454 enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy);
455 
456 struct isci_host;
457 void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index);
458 int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf);
459 
460 #endif /* !defined(_ISCI_PHY_H_) */