diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-05-10 05:28:45 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:47 -0400 |
commit | d35bc1bd18ab9e986cfb67c5a281a70cfd717f05 (patch) | |
tree | 2f02bc1a855f1ccc2f6201f5300d1d823d80c085 /drivers/scsi | |
parent | f1f52e75939b56c40b3d153ae99faf2720250242 (diff) |
isci: uplevel phy infrastructure
Merge core/scic_sds_phy.[ch] into phy.[ch]
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/isci/Makefile | 1 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_phy.h | 302 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_port.h | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.c | 2277 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.h | 439 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port.c | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_port_configuration_agent.h | 1 | ||||
-rw-r--r-- | drivers/scsi/isci/phy.c | 2213 | ||||
-rw-r--r-- | drivers/scsi/isci/phy.h | 574 | ||||
-rw-r--r-- | drivers/scsi/isci/port.c | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 2 |
11 files changed, 2784 insertions, 3031 deletions
diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile index a7d1eb33eca2..2830a97a822a 100644 --- a/drivers/scsi/isci/Makefile +++ b/drivers/scsi/isci/Makefile | |||
@@ -12,4 +12,3 @@ isci-objs := init.o phy.o request.o sata.o \ | |||
12 | smp_request.o \ | 12 | smp_request.o \ |
13 | core/scic_sds_port.o \ | 13 | core/scic_sds_port.o \ |
14 | core/scic_sds_port_configuration_agent.o \ | 14 | core/scic_sds_port_configuration_agent.o \ |
15 | core/scic_sds_phy.o \ | ||
diff --git a/drivers/scsi/isci/core/scic_phy.h b/drivers/scsi/isci/core/scic_phy.h deleted file mode 100644 index f046b4af4b8d..000000000000 --- a/drivers/scsi/isci/core/scic_phy.h +++ /dev/null | |||
@@ -1,302 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_PHY_H_ | ||
57 | #define _SCIC_PHY_H_ | ||
58 | |||
59 | /** | ||
60 | * This file contains all of the interface methods that can be called by an | ||
61 | * SCIC user on a phy (SAS or SATA) object. | ||
62 | * | ||
63 | * | ||
64 | */ | ||
65 | |||
66 | |||
67 | #include <scsi/sas.h> | ||
68 | #include <scsi/libsas.h> | ||
69 | |||
70 | struct scic_sds_phy; | ||
71 | struct scic_sds_port; | ||
72 | |||
73 | |||
74 | enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy); | ||
75 | |||
76 | struct scic_phy_cap { | ||
77 | union { | ||
78 | struct { | ||
79 | /* | ||
80 | * The SAS specification indicates the start bit shall | ||
81 | * always be set to | ||
82 | * 1. This implementation will have the start bit set | ||
83 | * to 0 if the PHY CAPABILITIES were either not | ||
84 | * received or speed negotiation failed. | ||
85 | */ | ||
86 | u8 start:1; | ||
87 | u8 tx_ssc_type:1; | ||
88 | u8 res1:2; | ||
89 | u8 req_logical_linkrate:4; | ||
90 | |||
91 | u32 gen1_no_ssc:1; | ||
92 | u32 gen1_ssc:1; | ||
93 | u32 gen2_no_ssc:1; | ||
94 | u32 gen2_ssc:1; | ||
95 | u32 gen3_no_ssc:1; | ||
96 | u32 gen3_ssc:1; | ||
97 | u32 res2:17; | ||
98 | u32 parity:1; | ||
99 | }; | ||
100 | u32 all; | ||
101 | }; | ||
102 | } __packed; | ||
103 | |||
104 | /* this data structure reflects the link layer transmit identification reg */ | ||
105 | struct scic_phy_proto { | ||
106 | union { | ||
107 | struct { | ||
108 | u16 _r_a:1; | ||
109 | u16 smp_iport:1; | ||
110 | u16 stp_iport:1; | ||
111 | u16 ssp_iport:1; | ||
112 | u16 _r_b:4; | ||
113 | u16 _r_c:1; | ||
114 | u16 smp_tport:1; | ||
115 | u16 stp_tport:1; | ||
116 | u16 ssp_tport:1; | ||
117 | u16 _r_d:4; | ||
118 | }; | ||
119 | u16 all; | ||
120 | }; | ||
121 | } __packed; | ||
122 | |||
123 | |||
124 | /** | ||
125 | * struct scic_phy_properties - This structure defines the properties common to | ||
126 | * all phys that can be retrieved. | ||
127 | * | ||
128 | * | ||
129 | */ | ||
130 | struct scic_phy_properties { | ||
131 | /** | ||
132 | * This field specifies the port that currently contains the | ||
133 | * supplied phy. This field may be set to NULL | ||
134 | * if the phy is not currently contained in a port. | ||
135 | */ | ||
136 | struct scic_sds_port *owning_port; | ||
137 | |||
138 | /** | ||
139 | * This field specifies the link rate at which the phy is | ||
140 | * currently operating. | ||
141 | */ | ||
142 | enum sas_linkrate negotiated_link_rate; | ||
143 | |||
144 | /** | ||
145 | * This field specifies the index of the phy in relation to other | ||
146 | * phys within the controller. This index is zero relative. | ||
147 | */ | ||
148 | u8 index; | ||
149 | }; | ||
150 | |||
151 | /** | ||
152 | * struct scic_sas_phy_properties - This structure defines the properties, | ||
153 | * specific to a SAS phy, that can be retrieved. | ||
154 | * | ||
155 | * | ||
156 | */ | ||
157 | struct scic_sas_phy_properties { | ||
158 | /** | ||
159 | * This field delineates the Identify Address Frame received | ||
160 | * from the remote end point. | ||
161 | */ | ||
162 | struct sas_identify_frame rcvd_iaf; | ||
163 | |||
164 | /** | ||
165 | * This field delineates the Phy capabilities structure received | ||
166 | * from the remote end point. | ||
167 | */ | ||
168 | struct scic_phy_cap rcvd_cap; | ||
169 | |||
170 | }; | ||
171 | |||
172 | /** | ||
173 | * struct scic_sata_phy_properties - This structure defines the properties, | ||
174 | * specific to a SATA phy, that can be retrieved. | ||
175 | * | ||
176 | * | ||
177 | */ | ||
178 | struct scic_sata_phy_properties { | ||
179 | /** | ||
180 | * This field delineates the signature FIS received from the | ||
181 | * attached target. | ||
182 | */ | ||
183 | struct dev_to_host_fis signature_fis; | ||
184 | |||
185 | /** | ||
186 | * This field specifies to the user if a port selector is connected | ||
187 | * on the specified phy. | ||
188 | */ | ||
189 | bool is_port_selector_present; | ||
190 | |||
191 | }; | ||
192 | |||
193 | /** | ||
194 | * enum scic_phy_counter_id - This enumeration depicts the various pieces of | ||
195 | * optional information that can be retrieved for a specific phy. | ||
196 | * | ||
197 | * | ||
198 | */ | ||
199 | enum scic_phy_counter_id { | ||
200 | /** | ||
201 | * This PHY information field tracks the number of frames received. | ||
202 | */ | ||
203 | SCIC_PHY_COUNTER_RECEIVED_FRAME, | ||
204 | |||
205 | /** | ||
206 | * This PHY information field tracks the number of frames transmitted. | ||
207 | */ | ||
208 | SCIC_PHY_COUNTER_TRANSMITTED_FRAME, | ||
209 | |||
210 | /** | ||
211 | * This PHY information field tracks the number of DWORDs received. | ||
212 | */ | ||
213 | SCIC_PHY_COUNTER_RECEIVED_FRAME_WORD, | ||
214 | |||
215 | /** | ||
216 | * This PHY information field tracks the number of DWORDs transmitted. | ||
217 | */ | ||
218 | SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD, | ||
219 | |||
220 | /** | ||
221 | * This PHY information field tracks the number of times DWORD | ||
222 | * synchronization was lost. | ||
223 | */ | ||
224 | SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR, | ||
225 | |||
226 | /** | ||
227 | * This PHY information field tracks the number of received DWORDs with | ||
228 | * running disparity errors. | ||
229 | */ | ||
230 | SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR, | ||
231 | |||
232 | /** | ||
233 | * This PHY information field tracks the number of received frames with a | ||
234 | * CRC error (not including short or truncated frames). | ||
235 | */ | ||
236 | SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR, | ||
237 | |||
238 | /** | ||
239 | * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT) | ||
240 | * primitives received. | ||
241 | */ | ||
242 | SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT, | ||
243 | |||
244 | /** | ||
245 | * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT) | ||
246 | * primitives transmitted. | ||
247 | */ | ||
248 | SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT, | ||
249 | |||
250 | /** | ||
251 | * This PHY information field tracks the number of times the inactivity | ||
252 | * timer for connections on the phy has been utilized. | ||
253 | */ | ||
254 | SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED, | ||
255 | |||
256 | /** | ||
257 | * This PHY information field tracks the number of DONE (CREDIT TIMEOUT) | ||
258 | * primitives received. | ||
259 | */ | ||
260 | SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT, | ||
261 | |||
262 | /** | ||
263 | * This PHY information field tracks the number of DONE (CREDIT TIMEOUT) | ||
264 | * primitives transmitted. | ||
265 | */ | ||
266 | SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT, | ||
267 | |||
268 | /** | ||
269 | * This PHY information field tracks the number of CREDIT BLOCKED | ||
270 | * primitives received. | ||
271 | * @note Depending on remote device implementation, credit blocks | ||
272 | * may occur regularly. | ||
273 | */ | ||
274 | SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED, | ||
275 | |||
276 | /** | ||
277 | * This PHY information field contains the number of short frames | ||
278 | * received. A short frame is simply a frame smaller then what is | ||
279 | * allowed by either the SAS or SATA specification. | ||
280 | */ | ||
281 | SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME, | ||
282 | |||
283 | /** | ||
284 | * This PHY information field contains the number of frames received after | ||
285 | * credit has been exhausted. | ||
286 | */ | ||
287 | SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT, | ||
288 | |||
289 | /** | ||
290 | * This PHY information field contains the number of frames received after | ||
291 | * a DONE has been received. | ||
292 | */ | ||
293 | SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE, | ||
294 | |||
295 | /** | ||
296 | * This PHY information field contains the number of times the phy | ||
297 | * failed to achieve DWORD synchronization during speed negotiation. | ||
298 | */ | ||
299 | SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR | ||
300 | }; | ||
301 | |||
302 | #endif /* _SCIC_PHY_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_port.h b/drivers/scsi/isci/core/scic_port.h index 51e7eede5c88..431dbd2093f3 100644 --- a/drivers/scsi/isci/core/scic_port.h +++ b/drivers/scsi/isci/core/scic_port.h | |||
@@ -58,7 +58,7 @@ | |||
58 | 58 | ||
59 | #include "isci.h" | 59 | #include "isci.h" |
60 | #include "sas.h" | 60 | #include "sas.h" |
61 | #include "scic_phy.h" | 61 | #include "phy.h" |
62 | 62 | ||
63 | struct scic_sds_port; | 63 | struct scic_sds_port; |
64 | 64 | ||
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c deleted file mode 100644 index 150509b0c69e..000000000000 --- a/drivers/scsi/isci/core/scic_sds_phy.c +++ /dev/null | |||
@@ -1,2277 +0,0 @@ | |||
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 | |||
56 | #include <scsi/sas.h> | ||
57 | #include "sas.h" | ||
58 | #include "host.h" | ||
59 | #include "state_machine.h" | ||
60 | #include "scic_phy.h" | ||
61 | #include "scic_sds_phy.h" | ||
62 | #include "scic_sds_port.h" | ||
63 | #include "remote_node_context.h" | ||
64 | #include "scu_event_codes.h" | ||
65 | #include "timers.h" | ||
66 | |||
67 | #define SCIC_SDS_PHY_MIN_TIMER_COUNT (SCI_MAX_PHYS) | ||
68 | #define SCIC_SDS_PHY_MAX_TIMER_COUNT (SCI_MAX_PHYS) | ||
69 | |||
70 | /* Maximum arbitration wait time in micro-seconds */ | ||
71 | #define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700) | ||
72 | |||
73 | enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy) | ||
74 | { | ||
75 | return sci_phy->max_negotiated_speed; | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * ***************************************************************************** | ||
80 | * * SCIC SDS PHY Internal Methods | ||
81 | * ***************************************************************************** */ | ||
82 | |||
83 | /** | ||
84 | * This method will initialize the phy transport layer registers | ||
85 | * @sci_phy: | ||
86 | * @transport_layer_registers | ||
87 | * | ||
88 | * enum sci_status | ||
89 | */ | ||
90 | static enum sci_status scic_sds_phy_transport_layer_initialization( | ||
91 | struct scic_sds_phy *sci_phy, | ||
92 | struct scu_transport_layer_registers __iomem *transport_layer_registers) | ||
93 | { | ||
94 | u32 tl_control; | ||
95 | |||
96 | sci_phy->transport_layer_registers = transport_layer_registers; | ||
97 | |||
98 | writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX, | ||
99 | &sci_phy->transport_layer_registers->stp_rni); | ||
100 | |||
101 | /* | ||
102 | * Hardware team recommends that we enable the STP prefetch for all | ||
103 | * transports | ||
104 | */ | ||
105 | tl_control = readl(&sci_phy->transport_layer_registers->control); | ||
106 | tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH); | ||
107 | writel(tl_control, &sci_phy->transport_layer_registers->control); | ||
108 | |||
109 | return SCI_SUCCESS; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * This method will initialize the phy link layer registers | ||
114 | * @sci_phy: | ||
115 | * @link_layer_registers: | ||
116 | * | ||
117 | * enum sci_status | ||
118 | */ | ||
119 | static enum sci_status | ||
120 | scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, | ||
121 | struct scu_link_layer_registers __iomem *link_layer_registers) | ||
122 | { | ||
123 | struct scic_sds_controller *scic = | ||
124 | sci_phy->owning_port->owning_controller; | ||
125 | int phy_idx = sci_phy->phy_index; | ||
126 | struct sci_phy_user_params *phy_user = | ||
127 | &scic->user_parameters.sds1.phys[phy_idx]; | ||
128 | struct sci_phy_oem_params *phy_oem = | ||
129 | &scic->oem_parameters.sds1.phys[phy_idx]; | ||
130 | u32 phy_configuration; | ||
131 | struct scic_phy_cap phy_cap; | ||
132 | u32 parity_check = 0; | ||
133 | u32 parity_count = 0; | ||
134 | u32 llctl, link_rate; | ||
135 | u32 clksm_value = 0; | ||
136 | |||
137 | sci_phy->link_layer_registers = link_layer_registers; | ||
138 | |||
139 | /* Set our IDENTIFY frame data */ | ||
140 | #define SCI_END_DEVICE 0x01 | ||
141 | |||
142 | writel(SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) | | ||
143 | SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) | | ||
144 | SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) | | ||
145 | SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) | | ||
146 | SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE), | ||
147 | &sci_phy->link_layer_registers->transmit_identification); | ||
148 | |||
149 | /* Write the device SAS Address */ | ||
150 | writel(0xFEDCBA98, | ||
151 | &sci_phy->link_layer_registers->sas_device_name_high); | ||
152 | writel(phy_idx, &sci_phy->link_layer_registers->sas_device_name_low); | ||
153 | |||
154 | /* Write the source SAS Address */ | ||
155 | writel(phy_oem->sas_address.high, | ||
156 | &sci_phy->link_layer_registers->source_sas_address_high); | ||
157 | writel(phy_oem->sas_address.low, | ||
158 | &sci_phy->link_layer_registers->source_sas_address_low); | ||
159 | |||
160 | /* Clear and Set the PHY Identifier */ | ||
161 | writel(0, &sci_phy->link_layer_registers->identify_frame_phy_id); | ||
162 | writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx), | ||
163 | &sci_phy->link_layer_registers->identify_frame_phy_id); | ||
164 | |||
165 | /* Change the initial state of the phy configuration register */ | ||
166 | phy_configuration = | ||
167 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
168 | |||
169 | /* Hold OOB state machine in reset */ | ||
170 | phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
171 | writel(phy_configuration, | ||
172 | &sci_phy->link_layer_registers->phy_configuration); | ||
173 | |||
174 | /* Configure the SNW capabilities */ | ||
175 | phy_cap.all = 0; | ||
176 | phy_cap.start = 1; | ||
177 | phy_cap.gen3_no_ssc = 1; | ||
178 | phy_cap.gen2_no_ssc = 1; | ||
179 | phy_cap.gen1_no_ssc = 1; | ||
180 | if (scic->oem_parameters.sds1.controller.do_enable_ssc == true) { | ||
181 | phy_cap.gen3_ssc = 1; | ||
182 | phy_cap.gen2_ssc = 1; | ||
183 | phy_cap.gen1_ssc = 1; | ||
184 | } | ||
185 | |||
186 | /* | ||
187 | * The SAS specification indicates that the phy_capabilities that | ||
188 | * are transmitted shall have an even parity. Calculate the parity. */ | ||
189 | parity_check = phy_cap.all; | ||
190 | while (parity_check != 0) { | ||
191 | if (parity_check & 0x1) | ||
192 | parity_count++; | ||
193 | parity_check >>= 1; | ||
194 | } | ||
195 | |||
196 | /* | ||
197 | * If parity indicates there are an odd number of bits set, then | ||
198 | * set the parity bit to 1 in the phy capabilities. */ | ||
199 | if ((parity_count % 2) != 0) | ||
200 | phy_cap.parity = 1; | ||
201 | |||
202 | writel(phy_cap.all, &sci_phy->link_layer_registers->phy_capabilities); | ||
203 | |||
204 | /* Set the enable spinup period but disable the ability to send | ||
205 | * notify enable spinup | ||
206 | */ | ||
207 | writel(SCU_ENSPINUP_GEN_VAL(COUNT, | ||
208 | phy_user->notify_enable_spin_up_insertion_frequency), | ||
209 | &sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
210 | |||
211 | /* Write the ALIGN Insertion Ferequency for connected phy and | ||
212 | * inpendent of connected state | ||
213 | */ | ||
214 | clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED, | ||
215 | phy_user->in_connection_align_insertion_frequency); | ||
216 | |||
217 | clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL, | ||
218 | phy_user->align_insertion_frequency); | ||
219 | |||
220 | writel(clksm_value, &sci_phy->link_layer_registers->clock_skew_management); | ||
221 | |||
222 | /* @todo Provide a way to write this register correctly */ | ||
223 | writel(0x02108421, | ||
224 | &sci_phy->link_layer_registers->afe_lookup_table_control); | ||
225 | |||
226 | llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT, | ||
227 | (u8)scic->user_parameters.sds1.no_outbound_task_timeout); | ||
228 | |||
229 | switch(phy_user->max_speed_generation) { | ||
230 | case SCIC_SDS_PARM_GEN3_SPEED: | ||
231 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3; | ||
232 | break; | ||
233 | case SCIC_SDS_PARM_GEN2_SPEED: | ||
234 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2; | ||
235 | break; | ||
236 | default: | ||
237 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1; | ||
238 | break; | ||
239 | } | ||
240 | llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate); | ||
241 | writel(llctl, &sci_phy->link_layer_registers->link_layer_control); | ||
242 | |||
243 | if (is_a0() || is_a2()) { | ||
244 | /* Program the max ARB time for the PHY to 700us so we inter-operate with | ||
245 | * the PMC expander which shuts down PHYs if the expander PHY generates too | ||
246 | * many breaks. This time value will guarantee that the initiator PHY will | ||
247 | * generate the break. | ||
248 | */ | ||
249 | writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME, | ||
250 | &sci_phy->link_layer_registers->maximum_arbitration_wait_timer_timeout); | ||
251 | } | ||
252 | |||
253 | /* | ||
254 | * Set the link layer hang detection to 500ms (0x1F4) from its default | ||
255 | * value of 128ms. Max value is 511 ms. | ||
256 | */ | ||
257 | writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout); | ||
258 | |||
259 | /* We can exit the initial state to the stopped state */ | ||
260 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
261 | SCI_BASE_PHY_STATE_STOPPED); | ||
262 | |||
263 | return SCI_SUCCESS; | ||
264 | } | ||
265 | |||
266 | /** | ||
267 | * This function will handle the sata SIGNATURE FIS timeout condition. It will | ||
268 | * restart the starting substate machine since we dont know what has actually | ||
269 | * happening. | ||
270 | */ | ||
271 | static void scic_sds_phy_sata_timeout(void *phy) | ||
272 | { | ||
273 | struct scic_sds_phy *sci_phy = phy; | ||
274 | |||
275 | dev_dbg(sciphy_to_dev(sci_phy), | ||
276 | "%s: SCIC SDS Phy 0x%p did not receive signature fis before " | ||
277 | "timeout.\n", | ||
278 | __func__, | ||
279 | sci_phy); | ||
280 | |||
281 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); | ||
282 | |||
283 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
284 | SCI_BASE_PHY_STATE_STARTING); | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * This method returns the port currently containing this phy. If the phy is | ||
289 | * currently contained by the dummy port, then the phy is considered to not | ||
290 | * be part of a port. | ||
291 | * @sci_phy: This parameter specifies the phy for which to retrieve the | ||
292 | * containing port. | ||
293 | * | ||
294 | * This method returns a handle to a port that contains the supplied phy. | ||
295 | * NULL This value is returned if the phy is not part of a real | ||
296 | * port (i.e. it's contained in the dummy port). !NULL All other | ||
297 | * values indicate a handle/pointer to the port containing the phy. | ||
298 | */ | ||
299 | struct scic_sds_port *scic_sds_phy_get_port( | ||
300 | struct scic_sds_phy *sci_phy) | ||
301 | { | ||
302 | if (scic_sds_port_get_index(sci_phy->owning_port) == SCIC_SDS_DUMMY_PORT) | ||
303 | return NULL; | ||
304 | |||
305 | return sci_phy->owning_port; | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * This method will assign a port to the phy object. | ||
310 | * @out]: sci_phy This parameter specifies the phy for which to assign a port | ||
311 | * object. | ||
312 | * | ||
313 | * | ||
314 | */ | ||
315 | void scic_sds_phy_set_port( | ||
316 | struct scic_sds_phy *sci_phy, | ||
317 | struct scic_sds_port *sci_port) | ||
318 | { | ||
319 | sci_phy->owning_port = sci_port; | ||
320 | |||
321 | if (sci_phy->bcn_received_while_port_unassigned) { | ||
322 | sci_phy->bcn_received_while_port_unassigned = false; | ||
323 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * This method will initialize the constructed phy | ||
329 | * @sci_phy: | ||
330 | * @link_layer_registers: | ||
331 | * | ||
332 | * enum sci_status | ||
333 | */ | ||
334 | enum sci_status scic_sds_phy_initialize( | ||
335 | struct scic_sds_phy *sci_phy, | ||
336 | struct scu_transport_layer_registers __iomem *transport_layer_registers, | ||
337 | struct scu_link_layer_registers __iomem *link_layer_registers) | ||
338 | { | ||
339 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | ||
340 | struct isci_host *ihost = scic_to_ihost(scic); | ||
341 | |||
342 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | ||
343 | sci_phy->sata_timeout_timer = | ||
344 | isci_timer_create( | ||
345 | ihost, | ||
346 | sci_phy, | ||
347 | scic_sds_phy_sata_timeout); | ||
348 | |||
349 | /* Perfrom the initialization of the TL hardware */ | ||
350 | scic_sds_phy_transport_layer_initialization( | ||
351 | sci_phy, | ||
352 | transport_layer_registers); | ||
353 | |||
354 | /* Perofrm the initialization of the PE hardware */ | ||
355 | scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers); | ||
356 | |||
357 | /* | ||
358 | * There is nothing that needs to be done in this state just | ||
359 | * transition to the stopped state. */ | ||
360 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
361 | SCI_BASE_PHY_STATE_STOPPED); | ||
362 | |||
363 | return SCI_SUCCESS; | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * This method assigns the direct attached device ID for this phy. | ||
368 | * | ||
369 | * @sci_phy The phy for which the direct attached device id is to | ||
370 | * be assigned. | ||
371 | * @device_id The direct attached device ID to assign to the phy. | ||
372 | * This will either be the RNi for the device or an invalid RNi if there | ||
373 | * is no current device assigned to the phy. | ||
374 | */ | ||
375 | void scic_sds_phy_setup_transport( | ||
376 | struct scic_sds_phy *sci_phy, | ||
377 | u32 device_id) | ||
378 | { | ||
379 | u32 tl_control; | ||
380 | |||
381 | writel(device_id, &sci_phy->transport_layer_registers->stp_rni); | ||
382 | |||
383 | /* | ||
384 | * The read should guarantee that the first write gets posted | ||
385 | * before the next write | ||
386 | */ | ||
387 | tl_control = readl(&sci_phy->transport_layer_registers->control); | ||
388 | tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE); | ||
389 | writel(tl_control, &sci_phy->transport_layer_registers->control); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * | ||
394 | * @sci_phy: The phy object to be suspended. | ||
395 | * | ||
396 | * This function will perform the register reads/writes to suspend the SCU | ||
397 | * hardware protocol engine. none | ||
398 | */ | ||
399 | static void scic_sds_phy_suspend( | ||
400 | struct scic_sds_phy *sci_phy) | ||
401 | { | ||
402 | u32 scu_sas_pcfg_value; | ||
403 | |||
404 | scu_sas_pcfg_value = | ||
405 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
406 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); | ||
407 | writel(scu_sas_pcfg_value, | ||
408 | &sci_phy->link_layer_registers->phy_configuration); | ||
409 | |||
410 | scic_sds_phy_setup_transport( | ||
411 | sci_phy, | ||
412 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); | ||
413 | } | ||
414 | |||
415 | void scic_sds_phy_resume(struct scic_sds_phy *sci_phy) | ||
416 | { | ||
417 | u32 scu_sas_pcfg_value; | ||
418 | |||
419 | scu_sas_pcfg_value = | ||
420 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
421 | scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); | ||
422 | writel(scu_sas_pcfg_value, | ||
423 | &sci_phy->link_layer_registers->phy_configuration); | ||
424 | } | ||
425 | |||
426 | void scic_sds_phy_get_sas_address(struct scic_sds_phy *sci_phy, | ||
427 | struct sci_sas_address *sas_address) | ||
428 | { | ||
429 | sas_address->high = readl(&sci_phy->link_layer_registers->source_sas_address_high); | ||
430 | sas_address->low = readl(&sci_phy->link_layer_registers->source_sas_address_low); | ||
431 | } | ||
432 | |||
433 | void scic_sds_phy_get_attached_sas_address(struct scic_sds_phy *sci_phy, | ||
434 | struct sci_sas_address *sas_address) | ||
435 | { | ||
436 | struct sas_identify_frame *iaf; | ||
437 | struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); | ||
438 | |||
439 | iaf = &iphy->frame_rcvd.iaf; | ||
440 | memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE); | ||
441 | } | ||
442 | |||
443 | void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy, | ||
444 | struct scic_phy_proto *protocols) | ||
445 | { | ||
446 | protocols->all = | ||
447 | (u16)(readl(&sci_phy-> | ||
448 | link_layer_registers->transmit_identification) & | ||
449 | 0x0000FFFF); | ||
450 | } | ||
451 | |||
452 | /** | ||
453 | * This method will attempt to start the phy object. This request is only valid | ||
454 | * when the phy is in the stopped state | ||
455 | * @sci_phy: | ||
456 | * | ||
457 | * enum sci_status | ||
458 | */ | ||
459 | enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy) | ||
460 | { | ||
461 | return sci_phy->state_handlers->start_handler(sci_phy); | ||
462 | } | ||
463 | |||
464 | /** | ||
465 | * This method will attempt to stop the phy object. | ||
466 | * @sci_phy: | ||
467 | * | ||
468 | * enum sci_status SCI_SUCCESS if the phy is going to stop SCI_INVALID_STATE | ||
469 | * if the phy is not in a valid state to stop | ||
470 | */ | ||
471 | enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy) | ||
472 | { | ||
473 | return sci_phy->state_handlers->stop_handler(sci_phy); | ||
474 | } | ||
475 | |||
476 | /** | ||
477 | * This method will attempt to reset the phy. This request is only valid when | ||
478 | * the phy is in an ready state | ||
479 | * @sci_phy: | ||
480 | * | ||
481 | * enum sci_status | ||
482 | */ | ||
483 | enum sci_status scic_sds_phy_reset( | ||
484 | struct scic_sds_phy *sci_phy) | ||
485 | { | ||
486 | return sci_phy->state_handlers->reset_handler(sci_phy); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * This method will process the event code received. | ||
491 | * @sci_phy: | ||
492 | * @event_code: | ||
493 | * | ||
494 | * enum sci_status | ||
495 | */ | ||
496 | enum sci_status scic_sds_phy_event_handler( | ||
497 | struct scic_sds_phy *sci_phy, | ||
498 | u32 event_code) | ||
499 | { | ||
500 | return sci_phy->state_handlers->event_handler(sci_phy, event_code); | ||
501 | } | ||
502 | |||
503 | /** | ||
504 | * This method will process the frame index received. | ||
505 | * @sci_phy: | ||
506 | * @frame_index: | ||
507 | * | ||
508 | * enum sci_status | ||
509 | */ | ||
510 | enum sci_status scic_sds_phy_frame_handler( | ||
511 | struct scic_sds_phy *sci_phy, | ||
512 | u32 frame_index) | ||
513 | { | ||
514 | return sci_phy->state_handlers->frame_handler(sci_phy, frame_index); | ||
515 | } | ||
516 | |||
517 | /** | ||
518 | * This method will give the phy permission to consume power | ||
519 | * @sci_phy: | ||
520 | * | ||
521 | * enum sci_status | ||
522 | */ | ||
523 | enum sci_status scic_sds_phy_consume_power_handler( | ||
524 | struct scic_sds_phy *sci_phy) | ||
525 | { | ||
526 | return sci_phy->state_handlers->consume_power_handler(sci_phy); | ||
527 | } | ||
528 | |||
529 | /* | ||
530 | * ***************************************************************************** | ||
531 | * * SCIC SDS PHY HELPER FUNCTIONS | ||
532 | * ***************************************************************************** */ | ||
533 | |||
534 | |||
535 | /** | ||
536 | * | ||
537 | * @sci_phy: The phy object that received SAS PHY DETECTED. | ||
538 | * | ||
539 | * This method continues the link training for the phy as if it were a SAS PHY | ||
540 | * instead of a SATA PHY. This is done because the completion queue had a SAS | ||
541 | * PHY DETECTED event when the state machine was expecting a SATA PHY event. | ||
542 | * none | ||
543 | */ | ||
544 | static void scic_sds_phy_start_sas_link_training( | ||
545 | struct scic_sds_phy *sci_phy) | ||
546 | { | ||
547 | u32 phy_control; | ||
548 | |||
549 | phy_control = | ||
550 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
551 | phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD); | ||
552 | writel(phy_control, | ||
553 | &sci_phy->link_layer_registers->phy_configuration); | ||
554 | |||
555 | sci_base_state_machine_change_state( | ||
556 | &sci_phy->starting_substate_machine, | ||
557 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN | ||
558 | ); | ||
559 | |||
560 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS; | ||
561 | } | ||
562 | |||
563 | /** | ||
564 | * | ||
565 | * @sci_phy: The phy object that received a SATA SPINUP HOLD event | ||
566 | * | ||
567 | * This method continues the link training for the phy as if it were a SATA PHY | ||
568 | * instead of a SAS PHY. This is done because the completion queue had a SATA | ||
569 | * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none | ||
570 | */ | ||
571 | static void scic_sds_phy_start_sata_link_training( | ||
572 | struct scic_sds_phy *sci_phy) | ||
573 | { | ||
574 | sci_base_state_machine_change_state( | ||
575 | &sci_phy->starting_substate_machine, | ||
576 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER | ||
577 | ); | ||
578 | |||
579 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; | ||
580 | } | ||
581 | |||
582 | /** | ||
583 | * scic_sds_phy_complete_link_training - perform processing common to | ||
584 | * all protocols upon completion of link training. | ||
585 | * @sci_phy: This parameter specifies the phy object for which link training | ||
586 | * has completed. | ||
587 | * @max_link_rate: This parameter specifies the maximum link rate to be | ||
588 | * associated with this phy. | ||
589 | * @next_state: This parameter specifies the next state for the phy's starting | ||
590 | * sub-state machine. | ||
591 | * | ||
592 | */ | ||
593 | static void scic_sds_phy_complete_link_training( | ||
594 | struct scic_sds_phy *sci_phy, | ||
595 | enum sas_linkrate max_link_rate, | ||
596 | u32 next_state) | ||
597 | { | ||
598 | sci_phy->max_negotiated_speed = max_link_rate; | ||
599 | |||
600 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
601 | next_state); | ||
602 | } | ||
603 | |||
604 | static void scic_sds_phy_restart_starting_state( | ||
605 | struct scic_sds_phy *sci_phy) | ||
606 | { | ||
607 | /* Stop the current substate machine */ | ||
608 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); | ||
609 | |||
610 | /* Re-enter the base state machine starting state */ | ||
611 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
612 | SCI_BASE_PHY_STATE_STARTING); | ||
613 | } | ||
614 | |||
615 | /* **************************************************************************** | ||
616 | * SCIC SDS PHY general handlers | ||
617 | ************************************************************************** */ | ||
618 | static enum sci_status scic_sds_phy_starting_substate_general_stop_handler( | ||
619 | struct scic_sds_phy *phy) | ||
620 | { | ||
621 | sci_base_state_machine_stop(&phy->starting_substate_machine); | ||
622 | |||
623 | sci_base_state_machine_change_state(&phy->state_machine, | ||
624 | SCI_BASE_PHY_STATE_STOPPED); | ||
625 | |||
626 | return SCI_SUCCESS; | ||
627 | } | ||
628 | |||
629 | /* | ||
630 | * ***************************************************************************** | ||
631 | * * SCIC SDS PHY EVENT_HANDLERS | ||
632 | * ***************************************************************************** */ | ||
633 | |||
634 | /** | ||
635 | * | ||
636 | * @phy: This struct scic_sds_phy object which has received an event. | ||
637 | * @event_code: This is the event code which the phy object is to decode. | ||
638 | * | ||
639 | * This method is called when an event notification is received for the phy | ||
640 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - | ||
641 | * decode the event - sas phy detected causes a state transition to the wait | ||
642 | * for speed event notification. - any other events log a warning message and | ||
643 | * set a failure status enum sci_status SCI_SUCCESS on any valid event notification | ||
644 | * SCI_FAILURE on any unexpected event notifation | ||
645 | */ | ||
646 | static enum sci_status scic_sds_phy_starting_substate_await_ossp_event_handler( | ||
647 | struct scic_sds_phy *sci_phy, | ||
648 | u32 event_code) | ||
649 | { | ||
650 | u32 result = SCI_SUCCESS; | ||
651 | |||
652 | switch (scu_get_event_code(event_code)) { | ||
653 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
654 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
655 | sci_phy->is_in_link_training = true; | ||
656 | break; | ||
657 | |||
658 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
659 | scic_sds_phy_start_sata_link_training(sci_phy); | ||
660 | sci_phy->is_in_link_training = true; | ||
661 | break; | ||
662 | |||
663 | default: | ||
664 | dev_dbg(sciphy_to_dev(sci_phy), | ||
665 | "%s: PHY starting substate machine received " | ||
666 | "unexpected event_code %x\n", | ||
667 | __func__, | ||
668 | event_code); | ||
669 | |||
670 | result = SCI_FAILURE; | ||
671 | break; | ||
672 | } | ||
673 | |||
674 | return result; | ||
675 | } | ||
676 | |||
677 | /** | ||
678 | * | ||
679 | * @phy: This struct scic_sds_phy object which has received an event. | ||
680 | * @event_code: This is the event code which the phy object is to decode. | ||
681 | * | ||
682 | * This method is called when an event notification is received for the phy | ||
683 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - | ||
684 | * decode the event - sas phy detected returns us back to this state. - speed | ||
685 | * event detected causes a state transition to the wait for iaf. - identify | ||
686 | * timeout is an un-expected event and the state machine is restarted. - link | ||
687 | * failure events restart the starting state machine - any other events log a | ||
688 | * warning message and set a failure status enum sci_status SCI_SUCCESS on any valid | ||
689 | * event notification SCI_FAILURE on any unexpected event notifation | ||
690 | */ | ||
691 | static enum sci_status scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler( | ||
692 | struct scic_sds_phy *sci_phy, | ||
693 | u32 event_code) | ||
694 | { | ||
695 | u32 result = SCI_SUCCESS; | ||
696 | |||
697 | switch (scu_get_event_code(event_code)) { | ||
698 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
699 | /* | ||
700 | * Why is this being reported again by the controller? | ||
701 | * We would re-enter this state so just stay here */ | ||
702 | break; | ||
703 | |||
704 | case SCU_EVENT_SAS_15: | ||
705 | case SCU_EVENT_SAS_15_SSC: | ||
706 | scic_sds_phy_complete_link_training( | ||
707 | sci_phy, | ||
708 | SAS_LINK_RATE_1_5_GBPS, | ||
709 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); | ||
710 | break; | ||
711 | |||
712 | case SCU_EVENT_SAS_30: | ||
713 | case SCU_EVENT_SAS_30_SSC: | ||
714 | scic_sds_phy_complete_link_training( | ||
715 | sci_phy, | ||
716 | SAS_LINK_RATE_3_0_GBPS, | ||
717 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); | ||
718 | break; | ||
719 | |||
720 | case SCU_EVENT_SAS_60: | ||
721 | case SCU_EVENT_SAS_60_SSC: | ||
722 | scic_sds_phy_complete_link_training( | ||
723 | sci_phy, | ||
724 | SAS_LINK_RATE_6_0_GBPS, | ||
725 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); | ||
726 | break; | ||
727 | |||
728 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
729 | /* | ||
730 | * We were doing SAS PHY link training and received a SATA PHY event | ||
731 | * continue OOB/SN as if this were a SATA PHY */ | ||
732 | scic_sds_phy_start_sata_link_training(sci_phy); | ||
733 | break; | ||
734 | |||
735 | case SCU_EVENT_LINK_FAILURE: | ||
736 | /* Link failure change state back to the starting state */ | ||
737 | scic_sds_phy_restart_starting_state(sci_phy); | ||
738 | break; | ||
739 | |||
740 | default: | ||
741 | dev_warn(sciphy_to_dev(sci_phy), | ||
742 | "%s: PHY starting substate machine received " | ||
743 | "unexpected event_code %x\n", | ||
744 | __func__, | ||
745 | event_code); | ||
746 | |||
747 | result = SCI_FAILURE; | ||
748 | break; | ||
749 | } | ||
750 | |||
751 | return result; | ||
752 | } | ||
753 | |||
754 | /** | ||
755 | * | ||
756 | * @phy: This struct scic_sds_phy object which has received an event. | ||
757 | * @event_code: This is the event code which the phy object is to decode. | ||
758 | * | ||
759 | * This method is called when an event notification is received for the phy | ||
760 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - | ||
761 | * decode the event - sas phy detected event backs up the state machine to the | ||
762 | * await speed notification. - identify timeout is an un-expected event and the | ||
763 | * state machine is restarted. - link failure events restart the starting state | ||
764 | * machine - any other events log a warning message and set a failure status | ||
765 | * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any | ||
766 | * unexpected event notifation | ||
767 | */ | ||
768 | static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_event_handler( | ||
769 | struct scic_sds_phy *sci_phy, | ||
770 | u32 event_code) | ||
771 | { | ||
772 | u32 result = SCI_SUCCESS; | ||
773 | |||
774 | switch (scu_get_event_code(event_code)) { | ||
775 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
776 | /* Backup the state machine */ | ||
777 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
778 | break; | ||
779 | |||
780 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
781 | /* | ||
782 | * We were doing SAS PHY link training and received a SATA PHY event | ||
783 | * continue OOB/SN as if this were a SATA PHY */ | ||
784 | scic_sds_phy_start_sata_link_training(sci_phy); | ||
785 | break; | ||
786 | |||
787 | case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT: | ||
788 | case SCU_EVENT_LINK_FAILURE: | ||
789 | case SCU_EVENT_HARD_RESET_RECEIVED: | ||
790 | /* Start the oob/sn state machine over again */ | ||
791 | scic_sds_phy_restart_starting_state(sci_phy); | ||
792 | break; | ||
793 | |||
794 | default: | ||
795 | dev_warn(sciphy_to_dev(sci_phy), | ||
796 | "%s: PHY starting substate machine received " | ||
797 | "unexpected event_code %x\n", | ||
798 | __func__, | ||
799 | event_code); | ||
800 | |||
801 | result = SCI_FAILURE; | ||
802 | break; | ||
803 | } | ||
804 | |||
805 | return result; | ||
806 | } | ||
807 | |||
808 | /** | ||
809 | * | ||
810 | * @phy: This struct scic_sds_phy object which has received an event. | ||
811 | * @event_code: This is the event code which the phy object is to decode. | ||
812 | * | ||
813 | * This method is called when an event notification is received for the phy | ||
814 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_POWER. - | ||
815 | * decode the event - link failure events restart the starting state machine - | ||
816 | * any other events log a warning message and set a failure status enum sci_status | ||
817 | * SCI_SUCCESS on a link failure event SCI_FAILURE on any unexpected event | ||
818 | * notifation | ||
819 | */ | ||
820 | static enum sci_status scic_sds_phy_starting_substate_await_sas_power_event_handler( | ||
821 | struct scic_sds_phy *sci_phy, | ||
822 | u32 event_code) | ||
823 | { | ||
824 | u32 result = SCI_SUCCESS; | ||
825 | |||
826 | switch (scu_get_event_code(event_code)) { | ||
827 | case SCU_EVENT_LINK_FAILURE: | ||
828 | /* Link failure change state back to the starting state */ | ||
829 | scic_sds_phy_restart_starting_state(sci_phy); | ||
830 | break; | ||
831 | |||
832 | default: | ||
833 | dev_warn(sciphy_to_dev(sci_phy), | ||
834 | "%s: PHY starting substate machine received unexpected " | ||
835 | "event_code %x\n", | ||
836 | __func__, | ||
837 | event_code); | ||
838 | |||
839 | result = SCI_FAILURE; | ||
840 | break; | ||
841 | } | ||
842 | |||
843 | return result; | ||
844 | } | ||
845 | |||
846 | /** | ||
847 | * | ||
848 | * @phy: This struct scic_sds_phy object which has received an event. | ||
849 | * @event_code: This is the event code which the phy object is to decode. | ||
850 | * | ||
851 | * This method is called when an event notification is received for the phy | ||
852 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - | ||
853 | * decode the event - link failure events restart the starting state machine - | ||
854 | * sata spinup hold events are ignored since they are expected - any other | ||
855 | * events log a warning message and set a failure status enum sci_status SCI_SUCCESS | ||
856 | * on a link failure event SCI_FAILURE on any unexpected event notifation | ||
857 | */ | ||
858 | static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_handler( | ||
859 | struct scic_sds_phy *sci_phy, | ||
860 | u32 event_code) | ||
861 | { | ||
862 | u32 result = SCI_SUCCESS; | ||
863 | |||
864 | switch (scu_get_event_code(event_code)) { | ||
865 | case SCU_EVENT_LINK_FAILURE: | ||
866 | /* Link failure change state back to the starting state */ | ||
867 | scic_sds_phy_restart_starting_state(sci_phy); | ||
868 | break; | ||
869 | |||
870 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
871 | /* These events are received every 10ms and are expected while in this state */ | ||
872 | break; | ||
873 | |||
874 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
875 | /* | ||
876 | * There has been a change in the phy type before OOB/SN for the | ||
877 | * SATA finished start down the SAS link traning path. */ | ||
878 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
879 | break; | ||
880 | |||
881 | default: | ||
882 | dev_warn(sciphy_to_dev(sci_phy), | ||
883 | "%s: PHY starting substate machine received " | ||
884 | "unexpected event_code %x\n", | ||
885 | __func__, | ||
886 | event_code); | ||
887 | |||
888 | result = SCI_FAILURE; | ||
889 | break; | ||
890 | } | ||
891 | |||
892 | return result; | ||
893 | } | ||
894 | |||
895 | /** | ||
896 | * scic_sds_phy_starting_substate_await_sata_phy_event_handler - | ||
897 | * @phy: This struct scic_sds_phy object which has received an event. | ||
898 | * @event_code: This is the event code which the phy object is to decode. | ||
899 | * | ||
900 | * This method is called when an event notification is received for the phy | ||
901 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - | ||
902 | * decode the event - link failure events restart the starting state machine - | ||
903 | * sata spinup hold events are ignored since they are expected - sata phy | ||
904 | * detected event change to the wait speed event - any other events log a | ||
905 | * warning message and set a failure status enum sci_status SCI_SUCCESS on a link | ||
906 | * failure event SCI_FAILURE on any unexpected event notifation | ||
907 | */ | ||
908 | static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler( | ||
909 | struct scic_sds_phy *sci_phy, u32 event_code) | ||
910 | { | ||
911 | u32 result = SCI_SUCCESS; | ||
912 | |||
913 | switch (scu_get_event_code(event_code)) { | ||
914 | case SCU_EVENT_LINK_FAILURE: | ||
915 | /* Link failure change state back to the starting state */ | ||
916 | scic_sds_phy_restart_starting_state(sci_phy); | ||
917 | break; | ||
918 | |||
919 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
920 | /* These events might be received since we dont know how many may be in | ||
921 | * the completion queue while waiting for power | ||
922 | */ | ||
923 | break; | ||
924 | |||
925 | case SCU_EVENT_SATA_PHY_DETECTED: | ||
926 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; | ||
927 | |||
928 | /* We have received the SATA PHY notification change state */ | ||
929 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
930 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | ||
931 | break; | ||
932 | |||
933 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
934 | /* There has been a change in the phy type before OOB/SN for the | ||
935 | * SATA finished start down the SAS link traning path. | ||
936 | */ | ||
937 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
938 | break; | ||
939 | |||
940 | default: | ||
941 | dev_warn(sciphy_to_dev(sci_phy), | ||
942 | "%s: PHY starting substate machine received " | ||
943 | "unexpected event_code %x\n", | ||
944 | __func__, | ||
945 | event_code); | ||
946 | |||
947 | result = SCI_FAILURE; | ||
948 | break; | ||
949 | } | ||
950 | |||
951 | return result; | ||
952 | } | ||
953 | |||
954 | /** | ||
955 | * | ||
956 | * @phy: This struct scic_sds_phy object which has received an event. | ||
957 | * @event_code: This is the event code which the phy object is to decode. | ||
958 | * | ||
959 | * This method is called when an event notification is received for the phy | ||
960 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. | ||
961 | * - decode the event - sata phy detected returns us back to this state. - | ||
962 | * speed event detected causes a state transition to the wait for signature. - | ||
963 | * link failure events restart the starting state machine - any other events | ||
964 | * log a warning message and set a failure status enum sci_status SCI_SUCCESS on any | ||
965 | * valid event notification SCI_FAILURE on any unexpected event notifation | ||
966 | */ | ||
967 | static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_handler( | ||
968 | struct scic_sds_phy *sci_phy, | ||
969 | u32 event_code) | ||
970 | { | ||
971 | u32 result = SCI_SUCCESS; | ||
972 | |||
973 | switch (scu_get_event_code(event_code)) { | ||
974 | case SCU_EVENT_SATA_PHY_DETECTED: | ||
975 | /* | ||
976 | * The hardware reports multiple SATA PHY detected events | ||
977 | * ignore the extras */ | ||
978 | break; | ||
979 | |||
980 | case SCU_EVENT_SATA_15: | ||
981 | case SCU_EVENT_SATA_15_SSC: | ||
982 | scic_sds_phy_complete_link_training( | ||
983 | sci_phy, | ||
984 | SAS_LINK_RATE_1_5_GBPS, | ||
985 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
986 | break; | ||
987 | |||
988 | case SCU_EVENT_SATA_30: | ||
989 | case SCU_EVENT_SATA_30_SSC: | ||
990 | scic_sds_phy_complete_link_training( | ||
991 | sci_phy, | ||
992 | SAS_LINK_RATE_3_0_GBPS, | ||
993 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
994 | break; | ||
995 | |||
996 | case SCU_EVENT_SATA_60: | ||
997 | case SCU_EVENT_SATA_60_SSC: | ||
998 | scic_sds_phy_complete_link_training( | ||
999 | sci_phy, | ||
1000 | SAS_LINK_RATE_6_0_GBPS, | ||
1001 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
1002 | break; | ||
1003 | |||
1004 | case SCU_EVENT_LINK_FAILURE: | ||
1005 | /* Link failure change state back to the starting state */ | ||
1006 | scic_sds_phy_restart_starting_state(sci_phy); | ||
1007 | break; | ||
1008 | |||
1009 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
1010 | /* | ||
1011 | * There has been a change in the phy type before OOB/SN for the | ||
1012 | * SATA finished start down the SAS link traning path. */ | ||
1013 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
1014 | break; | ||
1015 | |||
1016 | default: | ||
1017 | dev_warn(sciphy_to_dev(sci_phy), | ||
1018 | "%s: PHY starting substate machine received " | ||
1019 | "unexpected event_code %x\n", | ||
1020 | __func__, | ||
1021 | event_code); | ||
1022 | |||
1023 | result = SCI_FAILURE; | ||
1024 | break; | ||
1025 | } | ||
1026 | |||
1027 | return result; | ||
1028 | } | ||
1029 | |||
1030 | /** | ||
1031 | * scic_sds_phy_starting_substate_await_sig_fis_event_handler - | ||
1032 | * @phy: This struct scic_sds_phy object which has received an event. | ||
1033 | * @event_code: This is the event code which the phy object is to decode. | ||
1034 | * | ||
1035 | * This method is called when an event notification is received for the phy | ||
1036 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - | ||
1037 | * decode the event - sas phy detected event backs up the state machine to the | ||
1038 | * await speed notification. - identify timeout is an un-expected event and the | ||
1039 | * state machine is restarted. - link failure events restart the starting state | ||
1040 | * machine - any other events log a warning message and set a failure status | ||
1041 | * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any | ||
1042 | * unexpected event notifation | ||
1043 | */ | ||
1044 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler( | ||
1045 | struct scic_sds_phy *sci_phy, u32 event_code) | ||
1046 | { | ||
1047 | u32 result = SCI_SUCCESS; | ||
1048 | |||
1049 | switch (scu_get_event_code(event_code)) { | ||
1050 | case SCU_EVENT_SATA_PHY_DETECTED: | ||
1051 | /* Backup the state machine */ | ||
1052 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1053 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | ||
1054 | break; | ||
1055 | |||
1056 | case SCU_EVENT_LINK_FAILURE: | ||
1057 | /* Link failure change state back to the starting state */ | ||
1058 | scic_sds_phy_restart_starting_state(sci_phy); | ||
1059 | break; | ||
1060 | |||
1061 | default: | ||
1062 | dev_warn(sciphy_to_dev(sci_phy), | ||
1063 | "%s: PHY starting substate machine received " | ||
1064 | "unexpected event_code %x\n", | ||
1065 | __func__, | ||
1066 | event_code); | ||
1067 | |||
1068 | result = SCI_FAILURE; | ||
1069 | break; | ||
1070 | } | ||
1071 | |||
1072 | return result; | ||
1073 | } | ||
1074 | |||
1075 | |||
1076 | /* | ||
1077 | * ***************************************************************************** | ||
1078 | * * SCIC SDS PHY FRAME_HANDLERS | ||
1079 | * ***************************************************************************** */ | ||
1080 | |||
1081 | /** | ||
1082 | * | ||
1083 | * @phy: This is struct scic_sds_phy object which is being requested to decode the | ||
1084 | * frame data. | ||
1085 | * @frame_index: This is the index of the unsolicited frame which was received | ||
1086 | * for this phy. | ||
1087 | * | ||
1088 | * This method decodes the unsolicited frame when the struct scic_sds_phy is in the | ||
1089 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Get the UF Header - If the UF | ||
1090 | * is an IAF - Copy IAF data to local phy object IAF data buffer. - Change | ||
1091 | * starting substate to wait power. - else - log warning message of unexpected | ||
1092 | * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS | ||
1093 | */ | ||
1094 | static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler( | ||
1095 | struct scic_sds_phy *sci_phy, u32 frame_index) | ||
1096 | { | ||
1097 | enum sci_status result; | ||
1098 | u32 *frame_words; | ||
1099 | struct sas_identify_frame iaf; | ||
1100 | struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); | ||
1101 | |||
1102 | result = scic_sds_unsolicited_frame_control_get_header( | ||
1103 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), | ||
1104 | frame_index, | ||
1105 | (void **)&frame_words); | ||
1106 | |||
1107 | if (result != SCI_SUCCESS) | ||
1108 | return result; | ||
1109 | |||
1110 | sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32)); | ||
1111 | if (iaf.frame_type == 0) { | ||
1112 | u32 state; | ||
1113 | |||
1114 | memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf)); | ||
1115 | if (iaf.smp_tport) { | ||
1116 | /* We got the IAF for an expander PHY go to the final | ||
1117 | * state since there are no power requirements for | ||
1118 | * expander phys. | ||
1119 | */ | ||
1120 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL; | ||
1121 | } else { | ||
1122 | /* We got the IAF we can now go to the await spinup | ||
1123 | * semaphore state | ||
1124 | */ | ||
1125 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER; | ||
1126 | } | ||
1127 | sci_base_state_machine_change_state( | ||
1128 | &sci_phy->starting_substate_machine, | ||
1129 | state); | ||
1130 | result = SCI_SUCCESS; | ||
1131 | } else | ||
1132 | dev_warn(sciphy_to_dev(sci_phy), | ||
1133 | "%s: PHY starting substate machine received " | ||
1134 | "unexpected frame id %x\n", | ||
1135 | __func__, | ||
1136 | frame_index); | ||
1137 | |||
1138 | scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy), | ||
1139 | frame_index); | ||
1140 | |||
1141 | return result; | ||
1142 | } | ||
1143 | |||
1144 | /** | ||
1145 | * | ||
1146 | * @phy: This is struct scic_sds_phy object which is being requested to decode the | ||
1147 | * frame data. | ||
1148 | * @frame_index: This is the index of the unsolicited frame which was received | ||
1149 | * for this phy. | ||
1150 | * | ||
1151 | * This method decodes the unsolicited frame when the struct scic_sds_phy is in the | ||
1152 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Get the UF Header - If | ||
1153 | * the UF is an SIGNATURE FIS - Copy IAF data to local phy object SIGNATURE FIS | ||
1154 | * data buffer. - else - log warning message of unexpected unsolicted frame - | ||
1155 | * release frame buffer enum sci_status SCI_SUCCESS Must decode the SIGNATURE FIS | ||
1156 | * data | ||
1157 | */ | ||
1158 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler( | ||
1159 | struct scic_sds_phy *sci_phy, | ||
1160 | u32 frame_index) | ||
1161 | { | ||
1162 | enum sci_status result; | ||
1163 | struct dev_to_host_fis *frame_header; | ||
1164 | u32 *fis_frame_data; | ||
1165 | struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); | ||
1166 | |||
1167 | result = scic_sds_unsolicited_frame_control_get_header( | ||
1168 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), | ||
1169 | frame_index, | ||
1170 | (void **)&frame_header); | ||
1171 | |||
1172 | if (result != SCI_SUCCESS) | ||
1173 | return result; | ||
1174 | |||
1175 | if ((frame_header->fis_type == FIS_REGD2H) && | ||
1176 | !(frame_header->status & ATA_BUSY)) { | ||
1177 | scic_sds_unsolicited_frame_control_get_buffer( | ||
1178 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), | ||
1179 | frame_index, | ||
1180 | (void **)&fis_frame_data); | ||
1181 | |||
1182 | scic_sds_controller_copy_sata_response(&iphy->frame_rcvd.fis, | ||
1183 | frame_header, | ||
1184 | fis_frame_data); | ||
1185 | |||
1186 | /* got IAF we can now go to the await spinup semaphore state */ | ||
1187 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1188 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | ||
1189 | |||
1190 | result = SCI_SUCCESS; | ||
1191 | } else | ||
1192 | dev_warn(sciphy_to_dev(sci_phy), | ||
1193 | "%s: PHY starting substate machine received " | ||
1194 | "unexpected frame id %x\n", | ||
1195 | __func__, | ||
1196 | frame_index); | ||
1197 | |||
1198 | /* Regardless of the result we are done with this frame with it */ | ||
1199 | scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy), | ||
1200 | frame_index); | ||
1201 | |||
1202 | return result; | ||
1203 | } | ||
1204 | |||
1205 | /* | ||
1206 | * ***************************************************************************** | ||
1207 | * * SCIC SDS PHY POWER_HANDLERS | ||
1208 | * ***************************************************************************** */ | ||
1209 | |||
1210 | /* | ||
1211 | * This method is called by the struct scic_sds_controller when the phy object is | ||
1212 | * granted power. - The notify enable spinups are turned on for this phy object | ||
1213 | * - The phy state machine is transitioned to the | ||
1214 | * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS | ||
1215 | */ | ||
1216 | static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler( | ||
1217 | struct scic_sds_phy *sci_phy) | ||
1218 | { | ||
1219 | u32 enable_spinup; | ||
1220 | |||
1221 | enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1222 | enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); | ||
1223 | writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1224 | |||
1225 | /* Change state to the final state this substate machine has run to completion */ | ||
1226 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1227 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | ||
1228 | |||
1229 | return SCI_SUCCESS; | ||
1230 | } | ||
1231 | |||
1232 | /* | ||
1233 | * This method is called by the struct scic_sds_controller when the phy object is | ||
1234 | * granted power. - The phy state machine is transitioned to the | ||
1235 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS | ||
1236 | */ | ||
1237 | static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler( | ||
1238 | struct scic_sds_phy *sci_phy) | ||
1239 | { | ||
1240 | u32 scu_sas_pcfg_value; | ||
1241 | |||
1242 | /* Release the spinup hold state and reset the OOB state machine */ | ||
1243 | scu_sas_pcfg_value = | ||
1244 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
1245 | scu_sas_pcfg_value &= | ||
1246 | ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); | ||
1247 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
1248 | writel(scu_sas_pcfg_value, | ||
1249 | &sci_phy->link_layer_registers->phy_configuration); | ||
1250 | |||
1251 | /* Now restart the OOB operation */ | ||
1252 | scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
1253 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | ||
1254 | writel(scu_sas_pcfg_value, | ||
1255 | &sci_phy->link_layer_registers->phy_configuration); | ||
1256 | |||
1257 | /* Change state to the final state this substate machine has run to completion */ | ||
1258 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1259 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); | ||
1260 | |||
1261 | return SCI_SUCCESS; | ||
1262 | } | ||
1263 | |||
1264 | static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy, | ||
1265 | const char *func) | ||
1266 | { | ||
1267 | dev_dbg(sciphy_to_dev(sci_phy), | ||
1268 | "%s: in wrong state: %d\n", func, | ||
1269 | sci_base_state_machine_get_state(&sci_phy->state_machine)); | ||
1270 | return SCI_FAILURE_INVALID_STATE; | ||
1271 | } | ||
1272 | |||
1273 | static enum sci_status | ||
1274 | scic_sds_phy_default_start_handler(struct scic_sds_phy *sci_phy) | ||
1275 | { | ||
1276 | return default_phy_handler(sci_phy, __func__); | ||
1277 | } | ||
1278 | |||
1279 | static enum sci_status | ||
1280 | scic_sds_phy_default_stop_handler(struct scic_sds_phy *sci_phy) | ||
1281 | { | ||
1282 | return default_phy_handler(sci_phy, __func__); | ||
1283 | } | ||
1284 | |||
1285 | static enum sci_status | ||
1286 | scic_sds_phy_default_reset_handler(struct scic_sds_phy *sci_phy) | ||
1287 | { | ||
1288 | return default_phy_handler(sci_phy, __func__); | ||
1289 | } | ||
1290 | |||
1291 | static enum sci_status | ||
1292 | scic_sds_phy_default_destroy_handler(struct scic_sds_phy *sci_phy) | ||
1293 | { | ||
1294 | return default_phy_handler(sci_phy, __func__); | ||
1295 | } | ||
1296 | |||
1297 | static enum sci_status | ||
1298 | scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy, | ||
1299 | u32 frame_index) | ||
1300 | { | ||
1301 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | ||
1302 | |||
1303 | default_phy_handler(sci_phy, __func__); | ||
1304 | scic_sds_controller_release_frame(scic, frame_index); | ||
1305 | |||
1306 | return SCI_FAILURE_INVALID_STATE; | ||
1307 | } | ||
1308 | |||
1309 | static enum sci_status | ||
1310 | scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy, | ||
1311 | u32 event_code) | ||
1312 | { | ||
1313 | return default_phy_handler(sci_phy, __func__); | ||
1314 | } | ||
1315 | |||
1316 | static enum sci_status | ||
1317 | scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy) | ||
1318 | { | ||
1319 | return default_phy_handler(sci_phy, __func__); | ||
1320 | } | ||
1321 | |||
1322 | |||
1323 | |||
1324 | static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = { | ||
1325 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | ||
1326 | .start_handler = scic_sds_phy_default_start_handler, | ||
1327 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1328 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1329 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1330 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1331 | .event_handler = scic_sds_phy_default_event_handler, | ||
1332 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1333 | }, | ||
1334 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { | ||
1335 | .start_handler = scic_sds_phy_default_start_handler, | ||
1336 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1337 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1338 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1339 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1340 | .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler, | ||
1341 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1342 | }, | ||
1343 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { | ||
1344 | .start_handler = scic_sds_phy_default_start_handler, | ||
1345 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1346 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1347 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1348 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1349 | .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler, | ||
1350 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1351 | }, | ||
1352 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { | ||
1353 | .start_handler = scic_sds_phy_default_start_handler, | ||
1354 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1355 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1356 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1357 | .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler, | ||
1358 | .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler, | ||
1359 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1360 | }, | ||
1361 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { | ||
1362 | .start_handler = scic_sds_phy_default_start_handler, | ||
1363 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1364 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1365 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1366 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1367 | .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler, | ||
1368 | .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler | ||
1369 | }, | ||
1370 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { | ||
1371 | .start_handler = scic_sds_phy_default_start_handler, | ||
1372 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1373 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1374 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1375 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1376 | .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler, | ||
1377 | .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler | ||
1378 | }, | ||
1379 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { | ||
1380 | .start_handler = scic_sds_phy_default_start_handler, | ||
1381 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1382 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1383 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1384 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1385 | .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler, | ||
1386 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1387 | }, | ||
1388 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { | ||
1389 | .start_handler = scic_sds_phy_default_start_handler, | ||
1390 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1391 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1392 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1393 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1394 | .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler, | ||
1395 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1396 | }, | ||
1397 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { | ||
1398 | .start_handler = scic_sds_phy_default_start_handler, | ||
1399 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1400 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1401 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1402 | .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler, | ||
1403 | .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler, | ||
1404 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1405 | }, | ||
1406 | [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { | ||
1407 | .start_handler = scic_sds_phy_default_start_handler, | ||
1408 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1409 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1410 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1411 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1412 | .event_handler = scic_sds_phy_default_event_handler, | ||
1413 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1414 | } | ||
1415 | }; | ||
1416 | |||
1417 | /** | ||
1418 | * scic_sds_phy_set_starting_substate_handlers() - | ||
1419 | * | ||
1420 | * This macro sets the starting substate handlers by state_id | ||
1421 | */ | ||
1422 | #define scic_sds_phy_set_starting_substate_handlers(phy, state_id) \ | ||
1423 | scic_sds_phy_set_state_handlers(\ | ||
1424 | (phy), \ | ||
1425 | &scic_sds_phy_starting_substate_handler_table[(state_id)] \ | ||
1426 | ) | ||
1427 | |||
1428 | /* | ||
1429 | * **************************************************************************** | ||
1430 | * * PHY STARTING SUBSTATE METHODS | ||
1431 | * **************************************************************************** */ | ||
1432 | |||
1433 | /** | ||
1434 | * scic_sds_phy_starting_initial_substate_enter - | ||
1435 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1436 | * | ||
1437 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1438 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL. - The initial state | ||
1439 | * handlers are put in place for the struct scic_sds_phy object. - The state is | ||
1440 | * changed to the wait phy type event notification. none | ||
1441 | */ | ||
1442 | static void scic_sds_phy_starting_initial_substate_enter(void *object) | ||
1443 | { | ||
1444 | struct scic_sds_phy *sci_phy = object; | ||
1445 | |||
1446 | scic_sds_phy_set_starting_substate_handlers( | ||
1447 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | ||
1448 | |||
1449 | /* This is just an temporary state go off to the starting state */ | ||
1450 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1451 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); | ||
1452 | } | ||
1453 | |||
1454 | /** | ||
1455 | * | ||
1456 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1457 | * | ||
1458 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1459 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_PHY_TYPE_EN. - Set the | ||
1460 | * struct scic_sds_phy object state handlers for this state. none | ||
1461 | */ | ||
1462 | static void scic_sds_phy_starting_await_ossp_en_substate_enter(void *object) | ||
1463 | { | ||
1464 | struct scic_sds_phy *sci_phy = object; | ||
1465 | |||
1466 | scic_sds_phy_set_starting_substate_handlers( | ||
1467 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN | ||
1468 | ); | ||
1469 | } | ||
1470 | |||
1471 | /** | ||
1472 | * | ||
1473 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1474 | * | ||
1475 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1476 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - Set the | ||
1477 | * struct scic_sds_phy object state handlers for this state. none | ||
1478 | */ | ||
1479 | static void scic_sds_phy_starting_await_sas_speed_en_substate_enter( | ||
1480 | void *object) | ||
1481 | { | ||
1482 | struct scic_sds_phy *sci_phy = object; | ||
1483 | |||
1484 | scic_sds_phy_set_starting_substate_handlers( | ||
1485 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN | ||
1486 | ); | ||
1487 | } | ||
1488 | |||
1489 | /** | ||
1490 | * | ||
1491 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1492 | * | ||
1493 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1494 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Set the | ||
1495 | * struct scic_sds_phy object state handlers for this state. none | ||
1496 | */ | ||
1497 | static void scic_sds_phy_starting_await_iaf_uf_substate_enter(void *object) | ||
1498 | { | ||
1499 | struct scic_sds_phy *sci_phy = object; | ||
1500 | |||
1501 | scic_sds_phy_set_starting_substate_handlers( | ||
1502 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF | ||
1503 | ); | ||
1504 | } | ||
1505 | |||
1506 | /** | ||
1507 | * | ||
1508 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1509 | * | ||
1510 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1511 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Set the | ||
1512 | * struct scic_sds_phy object state handlers for this state. - Add this phy object to | ||
1513 | * the power control queue none | ||
1514 | */ | ||
1515 | static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object) | ||
1516 | { | ||
1517 | struct scic_sds_phy *sci_phy = object; | ||
1518 | |||
1519 | scic_sds_phy_set_starting_substate_handlers( | ||
1520 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER | ||
1521 | ); | ||
1522 | |||
1523 | scic_sds_controller_power_control_queue_insert( | ||
1524 | scic_sds_phy_get_controller(sci_phy), | ||
1525 | sci_phy | ||
1526 | ); | ||
1527 | } | ||
1528 | |||
1529 | /** | ||
1530 | * | ||
1531 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1532 | * | ||
1533 | * This method will perform the actions required by the struct scic_sds_phy on exiting | ||
1534 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Remove the | ||
1535 | * struct scic_sds_phy object from the power control queue. none | ||
1536 | */ | ||
1537 | static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object) | ||
1538 | { | ||
1539 | struct scic_sds_phy *sci_phy = object; | ||
1540 | |||
1541 | scic_sds_controller_power_control_queue_remove( | ||
1542 | scic_sds_phy_get_controller(sci_phy), sci_phy | ||
1543 | ); | ||
1544 | } | ||
1545 | |||
1546 | /** | ||
1547 | * | ||
1548 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1549 | * | ||
1550 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1551 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Set the | ||
1552 | * struct scic_sds_phy object state handlers for this state. - Add this phy object to | ||
1553 | * the power control queue none | ||
1554 | */ | ||
1555 | static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object) | ||
1556 | { | ||
1557 | struct scic_sds_phy *sci_phy = object; | ||
1558 | |||
1559 | scic_sds_phy_set_starting_substate_handlers( | ||
1560 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER | ||
1561 | ); | ||
1562 | |||
1563 | scic_sds_controller_power_control_queue_insert( | ||
1564 | scic_sds_phy_get_controller(sci_phy), | ||
1565 | sci_phy | ||
1566 | ); | ||
1567 | } | ||
1568 | |||
1569 | /** | ||
1570 | * | ||
1571 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1572 | * | ||
1573 | * This method will perform the actions required by the struct scic_sds_phy on exiting | ||
1574 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Remove the | ||
1575 | * struct scic_sds_phy object from the power control queue. none | ||
1576 | */ | ||
1577 | static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object) | ||
1578 | { | ||
1579 | struct scic_sds_phy *sci_phy = object; | ||
1580 | |||
1581 | scic_sds_controller_power_control_queue_remove( | ||
1582 | scic_sds_phy_get_controller(sci_phy), | ||
1583 | sci_phy | ||
1584 | ); | ||
1585 | } | ||
1586 | |||
1587 | /** | ||
1588 | * | ||
1589 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1590 | * | ||
1591 | * This function will perform the actions required by the struct scic_sds_phy on | ||
1592 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the | ||
1593 | * struct scic_sds_phy object state handlers for this state. none | ||
1594 | */ | ||
1595 | static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object) | ||
1596 | { | ||
1597 | struct scic_sds_phy *sci_phy = object; | ||
1598 | |||
1599 | scic_sds_phy_set_starting_substate_handlers( | ||
1600 | sci_phy, | ||
1601 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); | ||
1602 | |||
1603 | isci_timer_start(sci_phy->sata_timeout_timer, | ||
1604 | SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); | ||
1605 | } | ||
1606 | |||
1607 | /** | ||
1608 | * | ||
1609 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1610 | * | ||
1611 | * This method will perform the actions required by the struct scic_sds_phy | ||
1612 | * on exiting | ||
1613 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer | ||
1614 | * that was started on entry to await sata phy event notification none | ||
1615 | */ | ||
1616 | static inline void scic_sds_phy_starting_await_sata_phy_substate_exit( | ||
1617 | void *object) | ||
1618 | { | ||
1619 | struct scic_sds_phy *sci_phy = object; | ||
1620 | |||
1621 | isci_timer_stop(sci_phy->sata_timeout_timer); | ||
1622 | } | ||
1623 | |||
1624 | /** | ||
1625 | * | ||
1626 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1627 | * | ||
1628 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1629 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - Set the | ||
1630 | * struct scic_sds_phy object state handlers for this state. none | ||
1631 | */ | ||
1632 | static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object) | ||
1633 | { | ||
1634 | struct scic_sds_phy *sci_phy = object; | ||
1635 | |||
1636 | scic_sds_phy_set_starting_substate_handlers( | ||
1637 | sci_phy, | ||
1638 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | ||
1639 | |||
1640 | isci_timer_start(sci_phy->sata_timeout_timer, | ||
1641 | SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); | ||
1642 | } | ||
1643 | |||
1644 | /** | ||
1645 | * | ||
1646 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1647 | * | ||
1648 | * This function will perform the actions required by the | ||
1649 | * struct scic_sds_phy on exiting | ||
1650 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer | ||
1651 | * that was started on entry to await sata phy event notification none | ||
1652 | */ | ||
1653 | static inline void scic_sds_phy_starting_await_sata_speed_substate_exit( | ||
1654 | void *object) | ||
1655 | { | ||
1656 | struct scic_sds_phy *sci_phy = object; | ||
1657 | |||
1658 | isci_timer_stop(sci_phy->sata_timeout_timer); | ||
1659 | } | ||
1660 | |||
1661 | /** | ||
1662 | * | ||
1663 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1664 | * | ||
1665 | * This function will perform the actions required by the struct scic_sds_phy on | ||
1666 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the | ||
1667 | * struct scic_sds_phy object state handlers for this state. | ||
1668 | * - Start the SIGNATURE FIS | ||
1669 | * timeout timer none | ||
1670 | */ | ||
1671 | static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object) | ||
1672 | { | ||
1673 | bool continue_to_ready_state; | ||
1674 | struct scic_sds_phy *sci_phy = object; | ||
1675 | |||
1676 | scic_sds_phy_set_starting_substate_handlers( | ||
1677 | sci_phy, | ||
1678 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
1679 | |||
1680 | continue_to_ready_state = scic_sds_port_link_detected( | ||
1681 | sci_phy->owning_port, | ||
1682 | sci_phy); | ||
1683 | |||
1684 | if (continue_to_ready_state) { | ||
1685 | /* | ||
1686 | * Clear the PE suspend condition so we can actually | ||
1687 | * receive SIG FIS | ||
1688 | * The hardware will not respond to the XRDY until the PE | ||
1689 | * suspend condition is cleared. | ||
1690 | */ | ||
1691 | scic_sds_phy_resume(sci_phy); | ||
1692 | |||
1693 | isci_timer_start(sci_phy->sata_timeout_timer, | ||
1694 | SCIC_SDS_SIGNATURE_FIS_TIMEOUT); | ||
1695 | } else | ||
1696 | sci_phy->is_in_link_training = false; | ||
1697 | } | ||
1698 | |||
1699 | /** | ||
1700 | * | ||
1701 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1702 | * | ||
1703 | * This function will perform the actions required by the | ||
1704 | * struct scic_sds_phy on exiting | ||
1705 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE | ||
1706 | * FIS timeout timer. none | ||
1707 | */ | ||
1708 | static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit( | ||
1709 | void *object) | ||
1710 | { | ||
1711 | struct scic_sds_phy *sci_phy = object; | ||
1712 | |||
1713 | isci_timer_stop(sci_phy->sata_timeout_timer); | ||
1714 | } | ||
1715 | |||
1716 | /** | ||
1717 | * | ||
1718 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1719 | * | ||
1720 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1721 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. - Set the struct scic_sds_phy | ||
1722 | * object state handlers for this state. - Change base state machine to the | ||
1723 | * ready state. none | ||
1724 | */ | ||
1725 | static void scic_sds_phy_starting_final_substate_enter(void *object) | ||
1726 | { | ||
1727 | struct scic_sds_phy *sci_phy = object; | ||
1728 | |||
1729 | scic_sds_phy_set_starting_substate_handlers(sci_phy, | ||
1730 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | ||
1731 | |||
1732 | /* State machine has run to completion so exit out and change | ||
1733 | * the base state machine to the ready state | ||
1734 | */ | ||
1735 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1736 | SCI_BASE_PHY_STATE_READY); | ||
1737 | } | ||
1738 | |||
1739 | /* --------------------------------------------------------------------------- */ | ||
1740 | |||
1741 | static const struct sci_base_state scic_sds_phy_starting_substates[] = { | ||
1742 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | ||
1743 | .enter_state = scic_sds_phy_starting_initial_substate_enter, | ||
1744 | }, | ||
1745 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { | ||
1746 | .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter, | ||
1747 | }, | ||
1748 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { | ||
1749 | .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter, | ||
1750 | }, | ||
1751 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { | ||
1752 | .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter, | ||
1753 | }, | ||
1754 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { | ||
1755 | .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter, | ||
1756 | .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit, | ||
1757 | }, | ||
1758 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { | ||
1759 | .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter, | ||
1760 | .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit | ||
1761 | }, | ||
1762 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { | ||
1763 | .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter, | ||
1764 | .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit | ||
1765 | }, | ||
1766 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { | ||
1767 | .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter, | ||
1768 | .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit | ||
1769 | }, | ||
1770 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { | ||
1771 | .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter, | ||
1772 | .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit | ||
1773 | }, | ||
1774 | [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { | ||
1775 | .enter_state = scic_sds_phy_starting_final_substate_enter, | ||
1776 | } | ||
1777 | }; | ||
1778 | |||
1779 | /* | ||
1780 | * This method takes the struct scic_sds_phy from a stopped state and | ||
1781 | * attempts to start it. - The phy state machine is transitioned to the | ||
1782 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS | ||
1783 | */ | ||
1784 | static enum sci_status | ||
1785 | scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy) | ||
1786 | { | ||
1787 | struct isci_host *ihost; | ||
1788 | struct scic_sds_controller *scic; | ||
1789 | |||
1790 | scic = scic_sds_phy_get_controller(sci_phy), | ||
1791 | ihost = scic_to_ihost(scic); | ||
1792 | |||
1793 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | ||
1794 | sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy, | ||
1795 | scic_sds_phy_sata_timeout); | ||
1796 | |||
1797 | if (sci_phy->sata_timeout_timer) | ||
1798 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1799 | SCI_BASE_PHY_STATE_STARTING); | ||
1800 | |||
1801 | return SCI_SUCCESS; | ||
1802 | } | ||
1803 | |||
1804 | static enum sci_status | ||
1805 | scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy) | ||
1806 | { | ||
1807 | return SCI_SUCCESS; | ||
1808 | } | ||
1809 | |||
1810 | static enum sci_status | ||
1811 | scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy) | ||
1812 | { | ||
1813 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1814 | SCI_BASE_PHY_STATE_STOPPED); | ||
1815 | |||
1816 | return SCI_SUCCESS; | ||
1817 | } | ||
1818 | |||
1819 | static enum sci_status | ||
1820 | scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy) | ||
1821 | { | ||
1822 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1823 | SCI_BASE_PHY_STATE_RESETTING); | ||
1824 | |||
1825 | return SCI_SUCCESS; | ||
1826 | } | ||
1827 | |||
1828 | /** | ||
1829 | * scic_sds_phy_ready_state_event_handler - | ||
1830 | * @phy: This is the struct scic_sds_phy object which has received the event. | ||
1831 | * | ||
1832 | * This method request the struct scic_sds_phy handle the received event. The only | ||
1833 | * event that we are interested in while in the ready state is the link failure | ||
1834 | * event. - decoded event is a link failure - transition the struct scic_sds_phy back | ||
1835 | * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will | ||
1836 | * report a warning message enum sci_status SCI_SUCCESS if the event received is a | ||
1837 | * link failure SCI_FAILURE_INVALID_STATE for any other event received. | ||
1838 | */ | ||
1839 | static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1840 | u32 event_code) | ||
1841 | { | ||
1842 | enum sci_status result = SCI_FAILURE; | ||
1843 | |||
1844 | switch (scu_get_event_code(event_code)) { | ||
1845 | case SCU_EVENT_LINK_FAILURE: | ||
1846 | /* Link failure change state back to the starting state */ | ||
1847 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1848 | SCI_BASE_PHY_STATE_STARTING); | ||
1849 | result = SCI_SUCCESS; | ||
1850 | break; | ||
1851 | |||
1852 | case SCU_EVENT_BROADCAST_CHANGE: | ||
1853 | /* Broadcast change received. Notify the port. */ | ||
1854 | if (scic_sds_phy_get_port(sci_phy) != NULL) | ||
1855 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); | ||
1856 | else | ||
1857 | sci_phy->bcn_received_while_port_unassigned = true; | ||
1858 | break; | ||
1859 | |||
1860 | default: | ||
1861 | dev_warn(sciphy_to_dev(sci_phy), | ||
1862 | "%sP SCIC PHY 0x%p ready state machine received " | ||
1863 | "unexpected event_code %x\n", | ||
1864 | __func__, sci_phy, event_code); | ||
1865 | |||
1866 | result = SCI_FAILURE_INVALID_STATE; | ||
1867 | break; | ||
1868 | } | ||
1869 | |||
1870 | return result; | ||
1871 | } | ||
1872 | |||
1873 | static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1874 | u32 event_code) | ||
1875 | { | ||
1876 | enum sci_status result = SCI_FAILURE; | ||
1877 | |||
1878 | switch (scu_get_event_code(event_code)) { | ||
1879 | case SCU_EVENT_HARD_RESET_TRANSMITTED: | ||
1880 | /* Link failure change state back to the starting state */ | ||
1881 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1882 | SCI_BASE_PHY_STATE_STARTING); | ||
1883 | result = SCI_SUCCESS; | ||
1884 | break; | ||
1885 | |||
1886 | default: | ||
1887 | dev_warn(sciphy_to_dev(sci_phy), | ||
1888 | "%s: SCIC PHY 0x%p resetting state machine received " | ||
1889 | "unexpected event_code %x\n", | ||
1890 | __func__, sci_phy, event_code); | ||
1891 | |||
1892 | result = SCI_FAILURE_INVALID_STATE; | ||
1893 | break; | ||
1894 | } | ||
1895 | |||
1896 | return result; | ||
1897 | } | ||
1898 | |||
1899 | /* --------------------------------------------------------------------------- */ | ||
1900 | |||
1901 | static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { | ||
1902 | [SCI_BASE_PHY_STATE_INITIAL] = { | ||
1903 | .start_handler = scic_sds_phy_default_start_handler, | ||
1904 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1905 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1906 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1907 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1908 | .event_handler = scic_sds_phy_default_event_handler, | ||
1909 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1910 | }, | ||
1911 | [SCI_BASE_PHY_STATE_STOPPED] = { | ||
1912 | .start_handler = scic_sds_phy_stopped_state_start_handler, | ||
1913 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1914 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1915 | .destruct_handler = scic_sds_phy_stopped_state_destroy_handler, | ||
1916 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1917 | .event_handler = scic_sds_phy_default_event_handler, | ||
1918 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1919 | }, | ||
1920 | [SCI_BASE_PHY_STATE_STARTING] = { | ||
1921 | .start_handler = scic_sds_phy_default_start_handler, | ||
1922 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1923 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1924 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1925 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1926 | .event_handler = scic_sds_phy_default_event_handler, | ||
1927 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1928 | }, | ||
1929 | [SCI_BASE_PHY_STATE_READY] = { | ||
1930 | .start_handler = scic_sds_phy_default_start_handler, | ||
1931 | .stop_handler = scic_sds_phy_ready_state_stop_handler, | ||
1932 | .reset_handler = scic_sds_phy_ready_state_reset_handler, | ||
1933 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1934 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1935 | .event_handler = scic_sds_phy_ready_state_event_handler, | ||
1936 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1937 | }, | ||
1938 | [SCI_BASE_PHY_STATE_RESETTING] = { | ||
1939 | .start_handler = scic_sds_phy_default_start_handler, | ||
1940 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1941 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1942 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1943 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1944 | .event_handler = scic_sds_phy_resetting_state_event_handler, | ||
1945 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1946 | }, | ||
1947 | [SCI_BASE_PHY_STATE_FINAL] = { | ||
1948 | .start_handler = scic_sds_phy_default_start_handler, | ||
1949 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1950 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1951 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1952 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1953 | .event_handler = scic_sds_phy_default_event_handler, | ||
1954 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1955 | } | ||
1956 | }; | ||
1957 | |||
1958 | /* | ||
1959 | * **************************************************************************** | ||
1960 | * * PHY STATE PRIVATE METHODS | ||
1961 | * **************************************************************************** */ | ||
1962 | |||
1963 | /** | ||
1964 | * | ||
1965 | * @sci_phy: This is the struct scic_sds_phy object to stop. | ||
1966 | * | ||
1967 | * This method will stop the struct scic_sds_phy object. This does not reset the | ||
1968 | * protocol engine it just suspends it and places it in a state where it will | ||
1969 | * not cause the end device to power up. none | ||
1970 | */ | ||
1971 | static void scu_link_layer_stop_protocol_engine( | ||
1972 | struct scic_sds_phy *sci_phy) | ||
1973 | { | ||
1974 | u32 scu_sas_pcfg_value; | ||
1975 | u32 enable_spinup_value; | ||
1976 | |||
1977 | /* Suspend the protocol engine and place it in a sata spinup hold state */ | ||
1978 | scu_sas_pcfg_value = | ||
1979 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
1980 | scu_sas_pcfg_value |= | ||
1981 | (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | | ||
1982 | SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) | | ||
1983 | SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD)); | ||
1984 | writel(scu_sas_pcfg_value, | ||
1985 | &sci_phy->link_layer_registers->phy_configuration); | ||
1986 | |||
1987 | /* Disable the notify enable spinup primitives */ | ||
1988 | enable_spinup_value = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1989 | enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE); | ||
1990 | writel(enable_spinup_value, &sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1991 | } | ||
1992 | |||
1993 | /** | ||
1994 | * | ||
1995 | * | ||
1996 | * This method will start the OOB/SN state machine for this struct scic_sds_phy object. | ||
1997 | */ | ||
1998 | static void scu_link_layer_start_oob( | ||
1999 | struct scic_sds_phy *sci_phy) | ||
2000 | { | ||
2001 | u32 scu_sas_pcfg_value; | ||
2002 | |||
2003 | scu_sas_pcfg_value = | ||
2004 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
2005 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | ||
2006 | scu_sas_pcfg_value &= | ||
2007 | ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | | ||
2008 | SCU_SAS_PCFG_GEN_BIT(HARD_RESET)); | ||
2009 | writel(scu_sas_pcfg_value, | ||
2010 | &sci_phy->link_layer_registers->phy_configuration); | ||
2011 | } | ||
2012 | |||
2013 | /** | ||
2014 | * | ||
2015 | * | ||
2016 | * This method will transmit a hard reset request on the specified phy. The SCU | ||
2017 | * hardware requires that we reset the OOB state machine and set the hard reset | ||
2018 | * bit in the phy configuration register. We then must start OOB over with the | ||
2019 | * hard reset bit set. | ||
2020 | */ | ||
2021 | static void scu_link_layer_tx_hard_reset( | ||
2022 | struct scic_sds_phy *sci_phy) | ||
2023 | { | ||
2024 | u32 phy_configuration_value; | ||
2025 | |||
2026 | /* | ||
2027 | * SAS Phys must wait for the HARD_RESET_TX event notification to transition | ||
2028 | * to the starting state. */ | ||
2029 | phy_configuration_value = | ||
2030 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
2031 | phy_configuration_value |= | ||
2032 | (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) | | ||
2033 | SCU_SAS_PCFG_GEN_BIT(OOB_RESET)); | ||
2034 | writel(phy_configuration_value, | ||
2035 | &sci_phy->link_layer_registers->phy_configuration); | ||
2036 | |||
2037 | /* Now take the OOB state machine out of reset */ | ||
2038 | phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | ||
2039 | phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
2040 | writel(phy_configuration_value, | ||
2041 | &sci_phy->link_layer_registers->phy_configuration); | ||
2042 | } | ||
2043 | |||
2044 | /* | ||
2045 | * **************************************************************************** | ||
2046 | * * PHY BASE STATE METHODS | ||
2047 | * **************************************************************************** */ | ||
2048 | |||
2049 | /** | ||
2050 | * | ||
2051 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2052 | * | ||
2053 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2054 | * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state | ||
2055 | * handlers for the phy object base state machine initial state. none | ||
2056 | */ | ||
2057 | static void scic_sds_phy_initial_state_enter(void *object) | ||
2058 | { | ||
2059 | struct scic_sds_phy *sci_phy = object; | ||
2060 | |||
2061 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_INITIAL); | ||
2062 | } | ||
2063 | |||
2064 | /** | ||
2065 | * | ||
2066 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2067 | * | ||
2068 | * This function will perform the actions required by the struct scic_sds_phy on | ||
2069 | * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state | ||
2070 | * handlers for the phy object base state machine initial state. - The SCU | ||
2071 | * hardware is requested to stop the protocol engine. none | ||
2072 | */ | ||
2073 | static void scic_sds_phy_stopped_state_enter(void *object) | ||
2074 | { | ||
2075 | struct scic_sds_phy *sci_phy = object; | ||
2076 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | ||
2077 | struct isci_host *ihost = scic_to_ihost(scic); | ||
2078 | |||
2079 | /* | ||
2080 | * @todo We need to get to the controller to place this PE in a | ||
2081 | * reset state | ||
2082 | */ | ||
2083 | |||
2084 | scic_sds_phy_set_base_state_handlers(sci_phy, | ||
2085 | SCI_BASE_PHY_STATE_STOPPED); | ||
2086 | |||
2087 | if (sci_phy->sata_timeout_timer != NULL) { | ||
2088 | isci_del_timer(ihost, sci_phy->sata_timeout_timer); | ||
2089 | |||
2090 | sci_phy->sata_timeout_timer = NULL; | ||
2091 | } | ||
2092 | |||
2093 | scu_link_layer_stop_protocol_engine(sci_phy); | ||
2094 | |||
2095 | if (sci_phy->state_machine.previous_state_id != | ||
2096 | SCI_BASE_PHY_STATE_INITIAL) | ||
2097 | scic_sds_controller_link_down( | ||
2098 | scic_sds_phy_get_controller(sci_phy), | ||
2099 | scic_sds_phy_get_port(sci_phy), | ||
2100 | sci_phy); | ||
2101 | } | ||
2102 | |||
2103 | /** | ||
2104 | * | ||
2105 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2106 | * | ||
2107 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2108 | * entering the SCI_BASE_PHY_STATE_STARTING. - This function sets the state | ||
2109 | * handlers for the phy object base state machine starting state. - The SCU | ||
2110 | * hardware is requested to start OOB/SN on this protocl engine. - The phy | ||
2111 | * starting substate machine is started. - If the previous state was the ready | ||
2112 | * state then the struct scic_sds_controller is informed that the phy has gone link | ||
2113 | * down. none | ||
2114 | */ | ||
2115 | static void scic_sds_phy_starting_state_enter(void *object) | ||
2116 | { | ||
2117 | struct scic_sds_phy *sci_phy = object; | ||
2118 | |||
2119 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_STARTING); | ||
2120 | |||
2121 | scu_link_layer_stop_protocol_engine(sci_phy); | ||
2122 | scu_link_layer_start_oob(sci_phy); | ||
2123 | |||
2124 | /* We don't know what kind of phy we are going to be just yet */ | ||
2125 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; | ||
2126 | sci_phy->bcn_received_while_port_unassigned = false; | ||
2127 | |||
2128 | /* Change over to the starting substate machine to continue */ | ||
2129 | sci_base_state_machine_start(&sci_phy->starting_substate_machine); | ||
2130 | |||
2131 | if (sci_phy->state_machine.previous_state_id | ||
2132 | == SCI_BASE_PHY_STATE_READY) { | ||
2133 | scic_sds_controller_link_down( | ||
2134 | scic_sds_phy_get_controller(sci_phy), | ||
2135 | scic_sds_phy_get_port(sci_phy), | ||
2136 | sci_phy | ||
2137 | ); | ||
2138 | } | ||
2139 | } | ||
2140 | |||
2141 | /** | ||
2142 | * | ||
2143 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2144 | * | ||
2145 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2146 | * entering the SCI_BASE_PHY_STATE_READY. - This function sets the state | ||
2147 | * handlers for the phy object base state machine ready state. - The SCU | ||
2148 | * hardware protocol engine is resumed. - The struct scic_sds_controller is informed | ||
2149 | * that the phy object has gone link up. none | ||
2150 | */ | ||
2151 | static void scic_sds_phy_ready_state_enter(void *object) | ||
2152 | { | ||
2153 | struct scic_sds_phy *sci_phy = object; | ||
2154 | |||
2155 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_READY); | ||
2156 | |||
2157 | scic_sds_controller_link_up( | ||
2158 | scic_sds_phy_get_controller(sci_phy), | ||
2159 | scic_sds_phy_get_port(sci_phy), | ||
2160 | sci_phy | ||
2161 | ); | ||
2162 | } | ||
2163 | |||
2164 | /** | ||
2165 | * | ||
2166 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2167 | * | ||
2168 | * This method will perform the actions required by the struct scic_sds_phy on exiting | ||
2169 | * the SCI_BASE_PHY_STATE_INITIAL. This function suspends the SCU hardware | ||
2170 | * protocol engine represented by this struct scic_sds_phy object. none | ||
2171 | */ | ||
2172 | static void scic_sds_phy_ready_state_exit(void *object) | ||
2173 | { | ||
2174 | struct scic_sds_phy *sci_phy = object; | ||
2175 | |||
2176 | scic_sds_phy_suspend(sci_phy); | ||
2177 | } | ||
2178 | |||
2179 | /** | ||
2180 | * | ||
2181 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2182 | * | ||
2183 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2184 | * entering the SCI_BASE_PHY_STATE_RESETTING. - This function sets the state | ||
2185 | * handlers for the phy object base state machine resetting state. none | ||
2186 | */ | ||
2187 | static void scic_sds_phy_resetting_state_enter(void *object) | ||
2188 | { | ||
2189 | struct scic_sds_phy *sci_phy = object; | ||
2190 | |||
2191 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_RESETTING); | ||
2192 | |||
2193 | /* | ||
2194 | * The phy is being reset, therefore deactivate it from the port. | ||
2195 | * In the resetting state we don't notify the user regarding | ||
2196 | * link up and link down notifications. */ | ||
2197 | scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false); | ||
2198 | |||
2199 | if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { | ||
2200 | scu_link_layer_tx_hard_reset(sci_phy); | ||
2201 | } else { | ||
2202 | /* | ||
2203 | * The SCU does not need to have a discrete reset state so | ||
2204 | * just go back to the starting state. | ||
2205 | */ | ||
2206 | sci_base_state_machine_change_state( | ||
2207 | &sci_phy->state_machine, | ||
2208 | SCI_BASE_PHY_STATE_STARTING); | ||
2209 | } | ||
2210 | } | ||
2211 | |||
2212 | /** | ||
2213 | * | ||
2214 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2215 | * | ||
2216 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2217 | * entering the SCI_BASE_PHY_STATE_FINAL. - This function sets the state | ||
2218 | * handlers for the phy object base state machine final state. none | ||
2219 | */ | ||
2220 | static void scic_sds_phy_final_state_enter(void *object) | ||
2221 | { | ||
2222 | struct scic_sds_phy *sci_phy = object; | ||
2223 | |||
2224 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_FINAL); | ||
2225 | |||
2226 | /* Nothing to do here */ | ||
2227 | } | ||
2228 | |||
2229 | /* --------------------------------------------------------------------------- */ | ||
2230 | |||
2231 | static const struct sci_base_state scic_sds_phy_state_table[] = { | ||
2232 | [SCI_BASE_PHY_STATE_INITIAL] = { | ||
2233 | .enter_state = scic_sds_phy_initial_state_enter, | ||
2234 | }, | ||
2235 | [SCI_BASE_PHY_STATE_STOPPED] = { | ||
2236 | .enter_state = scic_sds_phy_stopped_state_enter, | ||
2237 | }, | ||
2238 | [SCI_BASE_PHY_STATE_STARTING] = { | ||
2239 | .enter_state = scic_sds_phy_starting_state_enter, | ||
2240 | }, | ||
2241 | [SCI_BASE_PHY_STATE_READY] = { | ||
2242 | .enter_state = scic_sds_phy_ready_state_enter, | ||
2243 | .exit_state = scic_sds_phy_ready_state_exit, | ||
2244 | }, | ||
2245 | [SCI_BASE_PHY_STATE_RESETTING] = { | ||
2246 | .enter_state = scic_sds_phy_resetting_state_enter, | ||
2247 | }, | ||
2248 | [SCI_BASE_PHY_STATE_FINAL] = { | ||
2249 | .enter_state = scic_sds_phy_final_state_enter, | ||
2250 | }, | ||
2251 | }; | ||
2252 | |||
2253 | void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, | ||
2254 | struct scic_sds_port *owning_port, u8 phy_index) | ||
2255 | { | ||
2256 | sci_base_state_machine_construct(&sci_phy->state_machine, | ||
2257 | sci_phy, | ||
2258 | scic_sds_phy_state_table, | ||
2259 | SCI_BASE_PHY_STATE_INITIAL); | ||
2260 | |||
2261 | sci_base_state_machine_start(&sci_phy->state_machine); | ||
2262 | |||
2263 | /* Copy the rest of the input data to our locals */ | ||
2264 | sci_phy->owning_port = owning_port; | ||
2265 | sci_phy->phy_index = phy_index; | ||
2266 | sci_phy->bcn_received_while_port_unassigned = false; | ||
2267 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; | ||
2268 | sci_phy->link_layer_registers = NULL; | ||
2269 | sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; | ||
2270 | sci_phy->sata_timeout_timer = NULL; | ||
2271 | |||
2272 | /* Initialize the the substate machines */ | ||
2273 | sci_base_state_machine_construct(&sci_phy->starting_substate_machine, | ||
2274 | sci_phy, | ||
2275 | scic_sds_phy_starting_substates, | ||
2276 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | ||
2277 | } | ||
diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h deleted file mode 100644 index 0d7bab3fc93b..000000000000 --- a/drivers/scsi/isci/core/scic_sds_phy.h +++ /dev/null | |||
@@ -1,439 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_SDS_PHY_H_ | ||
57 | #define _SCIC_SDS_PHY_H_ | ||
58 | |||
59 | #include "sas.h" | ||
60 | #include "scic_phy.h" | ||
61 | #include "registers.h" | ||
62 | #include "state_machine.h" | ||
63 | #include <scsi/libsas.h> | ||
64 | |||
65 | struct scic_sds_port; | ||
66 | /** | ||
67 | * | ||
68 | * | ||
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. | ||
74 | */ | ||
75 | #define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000 | ||
76 | |||
77 | /** | ||
78 | * | ||
79 | * | ||
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. | ||
85 | */ | ||
86 | #define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250 | ||
87 | |||
88 | enum scic_sds_phy_states { | ||
89 | /** | ||
90 | * Simply the initial state for the base domain state machine. | ||
91 | */ | ||
92 | SCI_BASE_PHY_STATE_INITIAL, | ||
93 | |||
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. | ||
101 | */ | ||
102 | SCI_BASE_PHY_STATE_STOPPED, | ||
103 | |||
104 | /** | ||
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. | ||
110 | */ | ||
111 | SCI_BASE_PHY_STATE_STARTING, | ||
112 | |||
113 | /** | ||
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. | ||
118 | */ | ||
119 | SCI_BASE_PHY_STATE_READY, | ||
120 | |||
121 | /** | ||
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. | ||
125 | */ | ||
126 | SCI_BASE_PHY_STATE_RESETTING, | ||
127 | |||
128 | /** | ||
129 | * Simply the final state for the base phy state machine. | ||
130 | */ | ||
131 | SCI_BASE_PHY_STATE_FINAL, | ||
132 | }; | ||
133 | |||
134 | |||
135 | /** | ||
136 | * enum scic_sds_phy_starting_substates - | ||
137 | * | ||
138 | * | ||
139 | */ | ||
140 | enum scic_sds_phy_starting_substates { | ||
141 | /** | ||
142 | * Initial state | ||
143 | */ | ||
144 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL, | ||
145 | |||
146 | /** | ||
147 | * Wait state for the hardware OSSP event type notification | ||
148 | */ | ||
149 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN, | ||
150 | |||
151 | /** | ||
152 | * Wait state for the PHY speed notification | ||
153 | */ | ||
154 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN, | ||
155 | |||
156 | /** | ||
157 | * Wait state for the IAF Unsolicited frame notification | ||
158 | */ | ||
159 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF, | ||
160 | |||
161 | /** | ||
162 | * Wait state for the request to consume power | ||
163 | */ | ||
164 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER, | ||
165 | |||
166 | /** | ||
167 | * Wait state for request to consume power | ||
168 | */ | ||
169 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER, | ||
170 | |||
171 | /** | ||
172 | * Wait state for the SATA PHY notification | ||
173 | */ | ||
174 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN, | ||
175 | |||
176 | /** | ||
177 | * Wait for the SATA PHY speed notification | ||
178 | */ | ||
179 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN, | ||
180 | |||
181 | /** | ||
182 | * Wait state for the SIGNATURE FIS unsolicited frame notification | ||
183 | */ | ||
184 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF, | ||
185 | |||
186 | /** | ||
187 | * Exit state for this state machine | ||
188 | */ | ||
189 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL, | ||
190 | }; | ||
191 | |||
192 | struct scic_sds_port; | ||
193 | struct scic_sds_controller; | ||
194 | |||
195 | /** | ||
196 | * This enumeration provides a named phy type for the state machine | ||
197 | * | ||
198 | * | ||
199 | */ | ||
200 | enum scic_sds_phy_protocol { | ||
201 | /** | ||
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. | ||
204 | */ | ||
205 | SCIC_SDS_PHY_PROTOCOL_UNKNOWN, | ||
206 | |||
207 | /** | ||
208 | * This is a SAS PHY | ||
209 | */ | ||
210 | SCIC_SDS_PHY_PROTOCOL_SAS, | ||
211 | |||
212 | /** | ||
213 | * This is a SATA PHY | ||
214 | */ | ||
215 | SCIC_SDS_PHY_PROTOCOL_SATA, | ||
216 | |||
217 | SCIC_SDS_MAX_PHY_PROTOCOLS | ||
218 | }; | ||
219 | |||
220 | /** | ||
221 | * struct scic_sds_phy - This structure contains or references all of the data | ||
222 | * necessary to represent the core phy object and SCU harware protocol | ||
223 | * engine. | ||
224 | * | ||
225 | * | ||
226 | */ | ||
227 | struct scic_sds_phy { | ||
228 | /** | ||
229 | * This field contains the information for the base phy state machine. | ||
230 | */ | ||
231 | struct sci_base_state_machine state_machine; | ||
232 | |||
233 | /** | ||
234 | * This field specifies the port object that owns/contains this phy. | ||
235 | */ | ||
236 | struct scic_sds_port *owning_port; | ||
237 | |||
238 | /** | ||
239 | * This field indicates whether the phy supports 1.5 Gb/s, 3.0 Gb/s, | ||
240 | * or 6.0 Gb/s operation. | ||
241 | */ | ||
242 | enum sas_linkrate max_negotiated_speed; | ||
243 | |||
244 | /** | ||
245 | * This member specifies the protocol being utilized on this phy. This | ||
246 | * field contains a legitamite value once the PHY has link trained with | ||
247 | * a remote phy. | ||
248 | */ | ||
249 | enum scic_sds_phy_protocol protocol; | ||
250 | |||
251 | /** | ||
252 | * This field specifies the index with which this phy is associated (0-3). | ||
253 | */ | ||
254 | u8 phy_index; | ||
255 | |||
256 | /** | ||
257 | * This member indicates if this particular PHY has received a BCN while | ||
258 | * it had no port assignement. This BCN will be reported once the phy is | ||
259 | * assigned to a port. | ||
260 | */ | ||
261 | bool bcn_received_while_port_unassigned; | ||
262 | |||
263 | /** | ||
264 | * This field indicates if this PHY is currently in the process of | ||
265 | * link training (i.e. it has started OOB, but has yet to perform | ||
266 | * IAF exchange/Signature FIS reception). | ||
267 | */ | ||
268 | bool is_in_link_training; | ||
269 | |||
270 | /** | ||
271 | * This field contains a reference to the timer utilized in detecting | ||
272 | * when a signature FIS timeout has occurred. The signature FIS is the | ||
273 | * first FIS sent by an attached SATA device after OOB/SN. | ||
274 | */ | ||
275 | void *sata_timeout_timer; | ||
276 | |||
277 | const struct scic_sds_phy_state_handler *state_handlers; | ||
278 | |||
279 | struct sci_base_state_machine starting_substate_machine; | ||
280 | |||
281 | /** | ||
282 | * This field is the pointer to the transport layer register for the SCU | ||
283 | * hardware. | ||
284 | */ | ||
285 | struct scu_transport_layer_registers __iomem *transport_layer_registers; | ||
286 | |||
287 | /** | ||
288 | * This field points to the link layer register set within the SCU. | ||
289 | */ | ||
290 | struct scu_link_layer_registers __iomem *link_layer_registers; | ||
291 | |||
292 | }; | ||
293 | |||
294 | typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *); | ||
295 | typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32); | ||
296 | typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32); | ||
297 | typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *); | ||
298 | |||
299 | /** | ||
300 | * struct scic_sds_phy_state_handler - | ||
301 | * | ||
302 | * | ||
303 | */ | ||
304 | struct scic_sds_phy_state_handler { | ||
305 | /** | ||
306 | * The start_handler specifies the method invoked when there is an | ||
307 | * attempt to start a phy. | ||
308 | */ | ||
309 | scic_sds_phy_handler_t start_handler; | ||
310 | |||
311 | /** | ||
312 | * The stop_handler specifies the method invoked when there is an | ||
313 | * attempt to stop a phy. | ||
314 | */ | ||
315 | scic_sds_phy_handler_t stop_handler; | ||
316 | |||
317 | /** | ||
318 | * The reset_handler specifies the method invoked when there is an | ||
319 | * attempt to reset a phy. | ||
320 | */ | ||
321 | scic_sds_phy_handler_t reset_handler; | ||
322 | |||
323 | /** | ||
324 | * The destruct_handler specifies the method invoked when attempting to | ||
325 | * destruct a phy. | ||
326 | */ | ||
327 | scic_sds_phy_handler_t destruct_handler; | ||
328 | |||
329 | /** | ||
330 | * The state handler for unsolicited frames received from the SCU hardware. | ||
331 | */ | ||
332 | scic_sds_phy_frame_handler_t frame_handler; | ||
333 | |||
334 | /** | ||
335 | * The state handler for events received from the SCU hardware. | ||
336 | */ | ||
337 | scic_sds_phy_event_handler_t event_handler; | ||
338 | |||
339 | /** | ||
340 | * The state handler for staggered spinup. | ||
341 | */ | ||
342 | scic_sds_phy_power_handler_t consume_power_handler; | ||
343 | |||
344 | }; | ||
345 | |||
346 | /** | ||
347 | * scic_sds_phy_get_index() - | ||
348 | * | ||
349 | * This macro returns the phy index for the specified phy | ||
350 | */ | ||
351 | #define scic_sds_phy_get_index(phy) \ | ||
352 | ((phy)->phy_index) | ||
353 | |||
354 | /** | ||
355 | * scic_sds_phy_get_controller() - This macro returns the controller for this | ||
356 | * phy | ||
357 | * | ||
358 | * | ||
359 | */ | ||
360 | #define scic_sds_phy_get_controller(phy) \ | ||
361 | (scic_sds_port_get_controller((phy)->owning_port)) | ||
362 | |||
363 | /** | ||
364 | * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for | ||
365 | * this phy object | ||
366 | * | ||
367 | * | ||
368 | */ | ||
369 | #define scic_sds_phy_set_state_handlers(phy, handlers) \ | ||
370 | ((phy)->state_handlers = (handlers)) | ||
371 | |||
372 | /** | ||
373 | * scic_sds_phy_set_base_state_handlers() - | ||
374 | * | ||
375 | * This macro set the base state handlers for the phy object. | ||
376 | */ | ||
377 | #define scic_sds_phy_set_base_state_handlers(phy, state_id) \ | ||
378 | scic_sds_phy_set_state_handlers(\ | ||
379 | (phy), \ | ||
380 | &scic_sds_phy_state_handler_table[(state_id)] \ | ||
381 | ) | ||
382 | |||
383 | void scic_sds_phy_construct( | ||
384 | struct scic_sds_phy *this_phy, | ||
385 | struct scic_sds_port *owning_port, | ||
386 | u8 phy_index); | ||
387 | |||
388 | struct scic_sds_port *scic_sds_phy_get_port( | ||
389 | struct scic_sds_phy *this_phy); | ||
390 | |||
391 | void scic_sds_phy_set_port( | ||
392 | struct scic_sds_phy *this_phy, | ||
393 | struct scic_sds_port *owning_port); | ||
394 | |||
395 | enum sci_status scic_sds_phy_initialize( | ||
396 | struct scic_sds_phy *this_phy, | ||
397 | struct scu_transport_layer_registers __iomem *transport_layer_registers, | ||
398 | struct scu_link_layer_registers __iomem *link_layer_registers); | ||
399 | |||
400 | enum sci_status scic_sds_phy_start( | ||
401 | struct scic_sds_phy *this_phy); | ||
402 | |||
403 | enum sci_status scic_sds_phy_stop( | ||
404 | struct scic_sds_phy *this_phy); | ||
405 | |||
406 | enum sci_status scic_sds_phy_reset( | ||
407 | struct scic_sds_phy *this_phy); | ||
408 | |||
409 | void scic_sds_phy_resume( | ||
410 | struct scic_sds_phy *this_phy); | ||
411 | |||
412 | void scic_sds_phy_setup_transport( | ||
413 | struct scic_sds_phy *this_phy, | ||
414 | u32 device_id); | ||
415 | |||
416 | enum sci_status scic_sds_phy_event_handler( | ||
417 | struct scic_sds_phy *this_phy, | ||
418 | u32 event_code); | ||
419 | |||
420 | enum sci_status scic_sds_phy_frame_handler( | ||
421 | struct scic_sds_phy *this_phy, | ||
422 | u32 frame_index); | ||
423 | |||
424 | enum sci_status scic_sds_phy_consume_power_handler( | ||
425 | struct scic_sds_phy *this_phy); | ||
426 | |||
427 | void scic_sds_phy_get_sas_address( | ||
428 | struct scic_sds_phy *this_phy, | ||
429 | struct sci_sas_address *sas_address); | ||
430 | |||
431 | void scic_sds_phy_get_attached_sas_address( | ||
432 | struct scic_sds_phy *this_phy, | ||
433 | struct sci_sas_address *sas_address); | ||
434 | |||
435 | void scic_sds_phy_get_protocols( | ||
436 | struct scic_sds_phy *sci_phy, | ||
437 | struct scic_phy_proto *protocols); | ||
438 | |||
439 | #endif /* _SCIC_SDS_PHY_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c index a9f3ce111b86..11b516a9a130 100644 --- a/drivers/scsi/isci/core/scic_sds_port.c +++ b/drivers/scsi/isci/core/scic_sds_port.c | |||
@@ -54,9 +54,7 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "host.h" | 56 | #include "host.h" |
57 | #include "scic_phy.h" | ||
58 | #include "scic_port.h" | 57 | #include "scic_port.h" |
59 | #include "scic_sds_phy.h" | ||
60 | #include "scic_sds_port.h" | 58 | #include "scic_sds_port.h" |
61 | #include "remote_device.h" | 59 | #include "remote_device.h" |
62 | #include "remote_node_context.h" | 60 | #include "remote_node_context.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h index 56a40a712589..7fd161700475 100644 --- a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h +++ b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h | |||
@@ -64,7 +64,6 @@ | |||
64 | */ | 64 | */ |
65 | 65 | ||
66 | #include "scic_sds_port.h" | 66 | #include "scic_sds_port.h" |
67 | #include "scic_sds_phy.h" | ||
68 | 67 | ||
69 | struct scic_sds_controller; | 68 | struct scic_sds_controller; |
70 | struct scic_sds_port_configuration_agent; | 69 | struct scic_sds_port_configuration_agent; |
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c index 1134395c970e..b92d51f25481 100644 --- a/drivers/scsi/isci/phy.c +++ b/drivers/scsi/isci/phy.c | |||
@@ -56,12 +56,2219 @@ | |||
56 | #include "isci.h" | 56 | #include "isci.h" |
57 | #include "host.h" | 57 | #include "host.h" |
58 | #include "phy.h" | 58 | #include "phy.h" |
59 | #include "scu_event_codes.h" | ||
59 | #include "scic_port.h" | 60 | #include "scic_port.h" |
60 | #include "scic_config_parameters.h" | 61 | #include "scic_config_parameters.h" |
62 | #include "timers.h" | ||
61 | 63 | ||
62 | struct scic_sds_phy; | 64 | /* Maximum arbitration wait time in micro-seconds */ |
63 | extern enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy); | 65 | #define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700) |
64 | extern enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy); | 66 | |
67 | enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy) | ||
68 | { | ||
69 | return sci_phy->max_negotiated_speed; | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * ***************************************************************************** | ||
74 | * * SCIC SDS PHY Internal Methods | ||
75 | * ***************************************************************************** */ | ||
76 | |||
77 | /** | ||
78 | * This method will initialize the phy transport layer registers | ||
79 | * @sci_phy: | ||
80 | * @transport_layer_registers | ||
81 | * | ||
82 | * enum sci_status | ||
83 | */ | ||
84 | static enum sci_status scic_sds_phy_transport_layer_initialization( | ||
85 | struct scic_sds_phy *sci_phy, | ||
86 | struct scu_transport_layer_registers __iomem *transport_layer_registers) | ||
87 | { | ||
88 | u32 tl_control; | ||
89 | |||
90 | sci_phy->transport_layer_registers = transport_layer_registers; | ||
91 | |||
92 | writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX, | ||
93 | &sci_phy->transport_layer_registers->stp_rni); | ||
94 | |||
95 | /* | ||
96 | * Hardware team recommends that we enable the STP prefetch for all | ||
97 | * transports | ||
98 | */ | ||
99 | tl_control = readl(&sci_phy->transport_layer_registers->control); | ||
100 | tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH); | ||
101 | writel(tl_control, &sci_phy->transport_layer_registers->control); | ||
102 | |||
103 | return SCI_SUCCESS; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * This method will initialize the phy link layer registers | ||
108 | * @sci_phy: | ||
109 | * @link_layer_registers: | ||
110 | * | ||
111 | * enum sci_status | ||
112 | */ | ||
113 | static enum sci_status | ||
114 | scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, | ||
115 | struct scu_link_layer_registers __iomem *link_layer_registers) | ||
116 | { | ||
117 | struct scic_sds_controller *scic = | ||
118 | sci_phy->owning_port->owning_controller; | ||
119 | int phy_idx = sci_phy->phy_index; | ||
120 | struct sci_phy_user_params *phy_user = | ||
121 | &scic->user_parameters.sds1.phys[phy_idx]; | ||
122 | struct sci_phy_oem_params *phy_oem = | ||
123 | &scic->oem_parameters.sds1.phys[phy_idx]; | ||
124 | u32 phy_configuration; | ||
125 | struct scic_phy_cap phy_cap; | ||
126 | u32 parity_check = 0; | ||
127 | u32 parity_count = 0; | ||
128 | u32 llctl, link_rate; | ||
129 | u32 clksm_value = 0; | ||
130 | |||
131 | sci_phy->link_layer_registers = link_layer_registers; | ||
132 | |||
133 | /* Set our IDENTIFY frame data */ | ||
134 | #define SCI_END_DEVICE 0x01 | ||
135 | |||
136 | writel(SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) | | ||
137 | SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) | | ||
138 | SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) | | ||
139 | SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) | | ||
140 | SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE), | ||
141 | &sci_phy->link_layer_registers->transmit_identification); | ||
142 | |||
143 | /* Write the device SAS Address */ | ||
144 | writel(0xFEDCBA98, | ||
145 | &sci_phy->link_layer_registers->sas_device_name_high); | ||
146 | writel(phy_idx, &sci_phy->link_layer_registers->sas_device_name_low); | ||
147 | |||
148 | /* Write the source SAS Address */ | ||
149 | writel(phy_oem->sas_address.high, | ||
150 | &sci_phy->link_layer_registers->source_sas_address_high); | ||
151 | writel(phy_oem->sas_address.low, | ||
152 | &sci_phy->link_layer_registers->source_sas_address_low); | ||
153 | |||
154 | /* Clear and Set the PHY Identifier */ | ||
155 | writel(0, &sci_phy->link_layer_registers->identify_frame_phy_id); | ||
156 | writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx), | ||
157 | &sci_phy->link_layer_registers->identify_frame_phy_id); | ||
158 | |||
159 | /* Change the initial state of the phy configuration register */ | ||
160 | phy_configuration = | ||
161 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
162 | |||
163 | /* Hold OOB state machine in reset */ | ||
164 | phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
165 | writel(phy_configuration, | ||
166 | &sci_phy->link_layer_registers->phy_configuration); | ||
167 | |||
168 | /* Configure the SNW capabilities */ | ||
169 | phy_cap.all = 0; | ||
170 | phy_cap.start = 1; | ||
171 | phy_cap.gen3_no_ssc = 1; | ||
172 | phy_cap.gen2_no_ssc = 1; | ||
173 | phy_cap.gen1_no_ssc = 1; | ||
174 | if (scic->oem_parameters.sds1.controller.do_enable_ssc == true) { | ||
175 | phy_cap.gen3_ssc = 1; | ||
176 | phy_cap.gen2_ssc = 1; | ||
177 | phy_cap.gen1_ssc = 1; | ||
178 | } | ||
179 | |||
180 | /* | ||
181 | * The SAS specification indicates that the phy_capabilities that | ||
182 | * are transmitted shall have an even parity. Calculate the parity. */ | ||
183 | parity_check = phy_cap.all; | ||
184 | while (parity_check != 0) { | ||
185 | if (parity_check & 0x1) | ||
186 | parity_count++; | ||
187 | parity_check >>= 1; | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * If parity indicates there are an odd number of bits set, then | ||
192 | * set the parity bit to 1 in the phy capabilities. */ | ||
193 | if ((parity_count % 2) != 0) | ||
194 | phy_cap.parity = 1; | ||
195 | |||
196 | writel(phy_cap.all, &sci_phy->link_layer_registers->phy_capabilities); | ||
197 | |||
198 | /* Set the enable spinup period but disable the ability to send | ||
199 | * notify enable spinup | ||
200 | */ | ||
201 | writel(SCU_ENSPINUP_GEN_VAL(COUNT, | ||
202 | phy_user->notify_enable_spin_up_insertion_frequency), | ||
203 | &sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
204 | |||
205 | /* Write the ALIGN Insertion Ferequency for connected phy and | ||
206 | * inpendent of connected state | ||
207 | */ | ||
208 | clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED, | ||
209 | phy_user->in_connection_align_insertion_frequency); | ||
210 | |||
211 | clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL, | ||
212 | phy_user->align_insertion_frequency); | ||
213 | |||
214 | writel(clksm_value, &sci_phy->link_layer_registers->clock_skew_management); | ||
215 | |||
216 | /* @todo Provide a way to write this register correctly */ | ||
217 | writel(0x02108421, | ||
218 | &sci_phy->link_layer_registers->afe_lookup_table_control); | ||
219 | |||
220 | llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT, | ||
221 | (u8)scic->user_parameters.sds1.no_outbound_task_timeout); | ||
222 | |||
223 | switch(phy_user->max_speed_generation) { | ||
224 | case SCIC_SDS_PARM_GEN3_SPEED: | ||
225 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3; | ||
226 | break; | ||
227 | case SCIC_SDS_PARM_GEN2_SPEED: | ||
228 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2; | ||
229 | break; | ||
230 | default: | ||
231 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1; | ||
232 | break; | ||
233 | } | ||
234 | llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate); | ||
235 | writel(llctl, &sci_phy->link_layer_registers->link_layer_control); | ||
236 | |||
237 | if (is_a0() || is_a2()) { | ||
238 | /* Program the max ARB time for the PHY to 700us so we inter-operate with | ||
239 | * the PMC expander which shuts down PHYs if the expander PHY generates too | ||
240 | * many breaks. This time value will guarantee that the initiator PHY will | ||
241 | * generate the break. | ||
242 | */ | ||
243 | writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME, | ||
244 | &sci_phy->link_layer_registers->maximum_arbitration_wait_timer_timeout); | ||
245 | } | ||
246 | |||
247 | /* | ||
248 | * Set the link layer hang detection to 500ms (0x1F4) from its default | ||
249 | * value of 128ms. Max value is 511 ms. | ||
250 | */ | ||
251 | writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout); | ||
252 | |||
253 | /* We can exit the initial state to the stopped state */ | ||
254 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
255 | SCI_BASE_PHY_STATE_STOPPED); | ||
256 | |||
257 | return SCI_SUCCESS; | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * This function will handle the sata SIGNATURE FIS timeout condition. It will | ||
262 | * restart the starting substate machine since we dont know what has actually | ||
263 | * happening. | ||
264 | */ | ||
265 | static void scic_sds_phy_sata_timeout(void *phy) | ||
266 | { | ||
267 | struct scic_sds_phy *sci_phy = phy; | ||
268 | |||
269 | dev_dbg(sciphy_to_dev(sci_phy), | ||
270 | "%s: SCIC SDS Phy 0x%p did not receive signature fis before " | ||
271 | "timeout.\n", | ||
272 | __func__, | ||
273 | sci_phy); | ||
274 | |||
275 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); | ||
276 | |||
277 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
278 | SCI_BASE_PHY_STATE_STARTING); | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * This method returns the port currently containing this phy. If the phy is | ||
283 | * currently contained by the dummy port, then the phy is considered to not | ||
284 | * be part of a port. | ||
285 | * @sci_phy: This parameter specifies the phy for which to retrieve the | ||
286 | * containing port. | ||
287 | * | ||
288 | * This method returns a handle to a port that contains the supplied phy. | ||
289 | * NULL This value is returned if the phy is not part of a real | ||
290 | * port (i.e. it's contained in the dummy port). !NULL All other | ||
291 | * values indicate a handle/pointer to the port containing the phy. | ||
292 | */ | ||
293 | struct scic_sds_port *scic_sds_phy_get_port( | ||
294 | struct scic_sds_phy *sci_phy) | ||
295 | { | ||
296 | if (scic_sds_port_get_index(sci_phy->owning_port) == SCIC_SDS_DUMMY_PORT) | ||
297 | return NULL; | ||
298 | |||
299 | return sci_phy->owning_port; | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * This method will assign a port to the phy object. | ||
304 | * @out]: sci_phy This parameter specifies the phy for which to assign a port | ||
305 | * object. | ||
306 | * | ||
307 | * | ||
308 | */ | ||
309 | void scic_sds_phy_set_port( | ||
310 | struct scic_sds_phy *sci_phy, | ||
311 | struct scic_sds_port *sci_port) | ||
312 | { | ||
313 | sci_phy->owning_port = sci_port; | ||
314 | |||
315 | if (sci_phy->bcn_received_while_port_unassigned) { | ||
316 | sci_phy->bcn_received_while_port_unassigned = false; | ||
317 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * This method will initialize the constructed phy | ||
323 | * @sci_phy: | ||
324 | * @link_layer_registers: | ||
325 | * | ||
326 | * enum sci_status | ||
327 | */ | ||
328 | enum sci_status scic_sds_phy_initialize( | ||
329 | struct scic_sds_phy *sci_phy, | ||
330 | struct scu_transport_layer_registers __iomem *transport_layer_registers, | ||
331 | struct scu_link_layer_registers __iomem *link_layer_registers) | ||
332 | { | ||
333 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | ||
334 | struct isci_host *ihost = scic_to_ihost(scic); | ||
335 | |||
336 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | ||
337 | sci_phy->sata_timeout_timer = | ||
338 | isci_timer_create( | ||
339 | ihost, | ||
340 | sci_phy, | ||
341 | scic_sds_phy_sata_timeout); | ||
342 | |||
343 | /* Perfrom the initialization of the TL hardware */ | ||
344 | scic_sds_phy_transport_layer_initialization( | ||
345 | sci_phy, | ||
346 | transport_layer_registers); | ||
347 | |||
348 | /* Perofrm the initialization of the PE hardware */ | ||
349 | scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers); | ||
350 | |||
351 | /* | ||
352 | * There is nothing that needs to be done in this state just | ||
353 | * transition to the stopped state. */ | ||
354 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
355 | SCI_BASE_PHY_STATE_STOPPED); | ||
356 | |||
357 | return SCI_SUCCESS; | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * This method assigns the direct attached device ID for this phy. | ||
362 | * | ||
363 | * @sci_phy The phy for which the direct attached device id is to | ||
364 | * be assigned. | ||
365 | * @device_id The direct attached device ID to assign to the phy. | ||
366 | * This will either be the RNi for the device or an invalid RNi if there | ||
367 | * is no current device assigned to the phy. | ||
368 | */ | ||
369 | void scic_sds_phy_setup_transport( | ||
370 | struct scic_sds_phy *sci_phy, | ||
371 | u32 device_id) | ||
372 | { | ||
373 | u32 tl_control; | ||
374 | |||
375 | writel(device_id, &sci_phy->transport_layer_registers->stp_rni); | ||
376 | |||
377 | /* | ||
378 | * The read should guarantee that the first write gets posted | ||
379 | * before the next write | ||
380 | */ | ||
381 | tl_control = readl(&sci_phy->transport_layer_registers->control); | ||
382 | tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE); | ||
383 | writel(tl_control, &sci_phy->transport_layer_registers->control); | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * | ||
388 | * @sci_phy: The phy object to be suspended. | ||
389 | * | ||
390 | * This function will perform the register reads/writes to suspend the SCU | ||
391 | * hardware protocol engine. none | ||
392 | */ | ||
393 | static void scic_sds_phy_suspend( | ||
394 | struct scic_sds_phy *sci_phy) | ||
395 | { | ||
396 | u32 scu_sas_pcfg_value; | ||
397 | |||
398 | scu_sas_pcfg_value = | ||
399 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
400 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); | ||
401 | writel(scu_sas_pcfg_value, | ||
402 | &sci_phy->link_layer_registers->phy_configuration); | ||
403 | |||
404 | scic_sds_phy_setup_transport( | ||
405 | sci_phy, | ||
406 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); | ||
407 | } | ||
408 | |||
409 | void scic_sds_phy_resume(struct scic_sds_phy *sci_phy) | ||
410 | { | ||
411 | u32 scu_sas_pcfg_value; | ||
412 | |||
413 | scu_sas_pcfg_value = | ||
414 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
415 | scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); | ||
416 | writel(scu_sas_pcfg_value, | ||
417 | &sci_phy->link_layer_registers->phy_configuration); | ||
418 | } | ||
419 | |||
420 | void scic_sds_phy_get_sas_address(struct scic_sds_phy *sci_phy, | ||
421 | struct sci_sas_address *sas_address) | ||
422 | { | ||
423 | sas_address->high = readl(&sci_phy->link_layer_registers->source_sas_address_high); | ||
424 | sas_address->low = readl(&sci_phy->link_layer_registers->source_sas_address_low); | ||
425 | } | ||
426 | |||
427 | void scic_sds_phy_get_attached_sas_address(struct scic_sds_phy *sci_phy, | ||
428 | struct sci_sas_address *sas_address) | ||
429 | { | ||
430 | struct sas_identify_frame *iaf; | ||
431 | struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); | ||
432 | |||
433 | iaf = &iphy->frame_rcvd.iaf; | ||
434 | memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE); | ||
435 | } | ||
436 | |||
437 | void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy, | ||
438 | struct scic_phy_proto *protocols) | ||
439 | { | ||
440 | protocols->all = | ||
441 | (u16)(readl(&sci_phy-> | ||
442 | link_layer_registers->transmit_identification) & | ||
443 | 0x0000FFFF); | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * This method will attempt to start the phy object. This request is only valid | ||
448 | * when the phy is in the stopped state | ||
449 | * @sci_phy: | ||
450 | * | ||
451 | * enum sci_status | ||
452 | */ | ||
453 | enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy) | ||
454 | { | ||
455 | return sci_phy->state_handlers->start_handler(sci_phy); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * This method will attempt to stop the phy object. | ||
460 | * @sci_phy: | ||
461 | * | ||
462 | * enum sci_status SCI_SUCCESS if the phy is going to stop SCI_INVALID_STATE | ||
463 | * if the phy is not in a valid state to stop | ||
464 | */ | ||
465 | enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy) | ||
466 | { | ||
467 | return sci_phy->state_handlers->stop_handler(sci_phy); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * This method will attempt to reset the phy. This request is only valid when | ||
472 | * the phy is in an ready state | ||
473 | * @sci_phy: | ||
474 | * | ||
475 | * enum sci_status | ||
476 | */ | ||
477 | enum sci_status scic_sds_phy_reset( | ||
478 | struct scic_sds_phy *sci_phy) | ||
479 | { | ||
480 | return sci_phy->state_handlers->reset_handler(sci_phy); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * This method will process the event code received. | ||
485 | * @sci_phy: | ||
486 | * @event_code: | ||
487 | * | ||
488 | * enum sci_status | ||
489 | */ | ||
490 | enum sci_status scic_sds_phy_event_handler( | ||
491 | struct scic_sds_phy *sci_phy, | ||
492 | u32 event_code) | ||
493 | { | ||
494 | return sci_phy->state_handlers->event_handler(sci_phy, event_code); | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * This method will process the frame index received. | ||
499 | * @sci_phy: | ||
500 | * @frame_index: | ||
501 | * | ||
502 | * enum sci_status | ||
503 | */ | ||
504 | enum sci_status scic_sds_phy_frame_handler( | ||
505 | struct scic_sds_phy *sci_phy, | ||
506 | u32 frame_index) | ||
507 | { | ||
508 | return sci_phy->state_handlers->frame_handler(sci_phy, frame_index); | ||
509 | } | ||
510 | |||
511 | /** | ||
512 | * This method will give the phy permission to consume power | ||
513 | * @sci_phy: | ||
514 | * | ||
515 | * enum sci_status | ||
516 | */ | ||
517 | enum sci_status scic_sds_phy_consume_power_handler( | ||
518 | struct scic_sds_phy *sci_phy) | ||
519 | { | ||
520 | return sci_phy->state_handlers->consume_power_handler(sci_phy); | ||
521 | } | ||
522 | |||
523 | /* | ||
524 | * ***************************************************************************** | ||
525 | * * SCIC SDS PHY HELPER FUNCTIONS | ||
526 | * ***************************************************************************** */ | ||
527 | |||
528 | |||
529 | /** | ||
530 | * | ||
531 | * @sci_phy: The phy object that received SAS PHY DETECTED. | ||
532 | * | ||
533 | * This method continues the link training for the phy as if it were a SAS PHY | ||
534 | * instead of a SATA PHY. This is done because the completion queue had a SAS | ||
535 | * PHY DETECTED event when the state machine was expecting a SATA PHY event. | ||
536 | * none | ||
537 | */ | ||
538 | static void scic_sds_phy_start_sas_link_training( | ||
539 | struct scic_sds_phy *sci_phy) | ||
540 | { | ||
541 | u32 phy_control; | ||
542 | |||
543 | phy_control = | ||
544 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
545 | phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD); | ||
546 | writel(phy_control, | ||
547 | &sci_phy->link_layer_registers->phy_configuration); | ||
548 | |||
549 | sci_base_state_machine_change_state( | ||
550 | &sci_phy->starting_substate_machine, | ||
551 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN | ||
552 | ); | ||
553 | |||
554 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS; | ||
555 | } | ||
556 | |||
557 | /** | ||
558 | * | ||
559 | * @sci_phy: The phy object that received a SATA SPINUP HOLD event | ||
560 | * | ||
561 | * This method continues the link training for the phy as if it were a SATA PHY | ||
562 | * instead of a SAS PHY. This is done because the completion queue had a SATA | ||
563 | * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none | ||
564 | */ | ||
565 | static void scic_sds_phy_start_sata_link_training( | ||
566 | struct scic_sds_phy *sci_phy) | ||
567 | { | ||
568 | sci_base_state_machine_change_state( | ||
569 | &sci_phy->starting_substate_machine, | ||
570 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER | ||
571 | ); | ||
572 | |||
573 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; | ||
574 | } | ||
575 | |||
576 | /** | ||
577 | * scic_sds_phy_complete_link_training - perform processing common to | ||
578 | * all protocols upon completion of link training. | ||
579 | * @sci_phy: This parameter specifies the phy object for which link training | ||
580 | * has completed. | ||
581 | * @max_link_rate: This parameter specifies the maximum link rate to be | ||
582 | * associated with this phy. | ||
583 | * @next_state: This parameter specifies the next state for the phy's starting | ||
584 | * sub-state machine. | ||
585 | * | ||
586 | */ | ||
587 | static void scic_sds_phy_complete_link_training( | ||
588 | struct scic_sds_phy *sci_phy, | ||
589 | enum sas_linkrate max_link_rate, | ||
590 | u32 next_state) | ||
591 | { | ||
592 | sci_phy->max_negotiated_speed = max_link_rate; | ||
593 | |||
594 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
595 | next_state); | ||
596 | } | ||
597 | |||
598 | static void scic_sds_phy_restart_starting_state( | ||
599 | struct scic_sds_phy *sci_phy) | ||
600 | { | ||
601 | /* Stop the current substate machine */ | ||
602 | sci_base_state_machine_stop(&sci_phy->starting_substate_machine); | ||
603 | |||
604 | /* Re-enter the base state machine starting state */ | ||
605 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
606 | SCI_BASE_PHY_STATE_STARTING); | ||
607 | } | ||
608 | |||
609 | /* **************************************************************************** | ||
610 | * SCIC SDS PHY general handlers | ||
611 | ************************************************************************** */ | ||
612 | static enum sci_status scic_sds_phy_starting_substate_general_stop_handler( | ||
613 | struct scic_sds_phy *phy) | ||
614 | { | ||
615 | sci_base_state_machine_stop(&phy->starting_substate_machine); | ||
616 | |||
617 | sci_base_state_machine_change_state(&phy->state_machine, | ||
618 | SCI_BASE_PHY_STATE_STOPPED); | ||
619 | |||
620 | return SCI_SUCCESS; | ||
621 | } | ||
622 | |||
623 | /* | ||
624 | * ***************************************************************************** | ||
625 | * * SCIC SDS PHY EVENT_HANDLERS | ||
626 | * ***************************************************************************** */ | ||
627 | |||
628 | /** | ||
629 | * | ||
630 | * @phy: This struct scic_sds_phy object which has received an event. | ||
631 | * @event_code: This is the event code which the phy object is to decode. | ||
632 | * | ||
633 | * This method is called when an event notification is received for the phy | ||
634 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - | ||
635 | * decode the event - sas phy detected causes a state transition to the wait | ||
636 | * for speed event notification. - any other events log a warning message and | ||
637 | * set a failure status enum sci_status SCI_SUCCESS on any valid event notification | ||
638 | * SCI_FAILURE on any unexpected event notifation | ||
639 | */ | ||
640 | static enum sci_status scic_sds_phy_starting_substate_await_ossp_event_handler( | ||
641 | struct scic_sds_phy *sci_phy, | ||
642 | u32 event_code) | ||
643 | { | ||
644 | u32 result = SCI_SUCCESS; | ||
645 | |||
646 | switch (scu_get_event_code(event_code)) { | ||
647 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
648 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
649 | sci_phy->is_in_link_training = true; | ||
650 | break; | ||
651 | |||
652 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
653 | scic_sds_phy_start_sata_link_training(sci_phy); | ||
654 | sci_phy->is_in_link_training = true; | ||
655 | break; | ||
656 | |||
657 | default: | ||
658 | dev_dbg(sciphy_to_dev(sci_phy), | ||
659 | "%s: PHY starting substate machine received " | ||
660 | "unexpected event_code %x\n", | ||
661 | __func__, | ||
662 | event_code); | ||
663 | |||
664 | result = SCI_FAILURE; | ||
665 | break; | ||
666 | } | ||
667 | |||
668 | return result; | ||
669 | } | ||
670 | |||
671 | /** | ||
672 | * | ||
673 | * @phy: This struct scic_sds_phy object which has received an event. | ||
674 | * @event_code: This is the event code which the phy object is to decode. | ||
675 | * | ||
676 | * This method is called when an event notification is received for the phy | ||
677 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - | ||
678 | * decode the event - sas phy detected returns us back to this state. - speed | ||
679 | * event detected causes a state transition to the wait for iaf. - identify | ||
680 | * timeout is an un-expected event and the state machine is restarted. - link | ||
681 | * failure events restart the starting state machine - any other events log a | ||
682 | * warning message and set a failure status enum sci_status SCI_SUCCESS on any valid | ||
683 | * event notification SCI_FAILURE on any unexpected event notifation | ||
684 | */ | ||
685 | static enum sci_status scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler( | ||
686 | struct scic_sds_phy *sci_phy, | ||
687 | u32 event_code) | ||
688 | { | ||
689 | u32 result = SCI_SUCCESS; | ||
690 | |||
691 | switch (scu_get_event_code(event_code)) { | ||
692 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
693 | /* | ||
694 | * Why is this being reported again by the controller? | ||
695 | * We would re-enter this state so just stay here */ | ||
696 | break; | ||
697 | |||
698 | case SCU_EVENT_SAS_15: | ||
699 | case SCU_EVENT_SAS_15_SSC: | ||
700 | scic_sds_phy_complete_link_training( | ||
701 | sci_phy, | ||
702 | SAS_LINK_RATE_1_5_GBPS, | ||
703 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); | ||
704 | break; | ||
705 | |||
706 | case SCU_EVENT_SAS_30: | ||
707 | case SCU_EVENT_SAS_30_SSC: | ||
708 | scic_sds_phy_complete_link_training( | ||
709 | sci_phy, | ||
710 | SAS_LINK_RATE_3_0_GBPS, | ||
711 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); | ||
712 | break; | ||
713 | |||
714 | case SCU_EVENT_SAS_60: | ||
715 | case SCU_EVENT_SAS_60_SSC: | ||
716 | scic_sds_phy_complete_link_training( | ||
717 | sci_phy, | ||
718 | SAS_LINK_RATE_6_0_GBPS, | ||
719 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF); | ||
720 | break; | ||
721 | |||
722 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
723 | /* | ||
724 | * We were doing SAS PHY link training and received a SATA PHY event | ||
725 | * continue OOB/SN as if this were a SATA PHY */ | ||
726 | scic_sds_phy_start_sata_link_training(sci_phy); | ||
727 | break; | ||
728 | |||
729 | case SCU_EVENT_LINK_FAILURE: | ||
730 | /* Link failure change state back to the starting state */ | ||
731 | scic_sds_phy_restart_starting_state(sci_phy); | ||
732 | break; | ||
733 | |||
734 | default: | ||
735 | dev_warn(sciphy_to_dev(sci_phy), | ||
736 | "%s: PHY starting substate machine received " | ||
737 | "unexpected event_code %x\n", | ||
738 | __func__, | ||
739 | event_code); | ||
740 | |||
741 | result = SCI_FAILURE; | ||
742 | break; | ||
743 | } | ||
744 | |||
745 | return result; | ||
746 | } | ||
747 | |||
748 | /** | ||
749 | * | ||
750 | * @phy: This struct scic_sds_phy object which has received an event. | ||
751 | * @event_code: This is the event code which the phy object is to decode. | ||
752 | * | ||
753 | * This method is called when an event notification is received for the phy | ||
754 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - | ||
755 | * decode the event - sas phy detected event backs up the state machine to the | ||
756 | * await speed notification. - identify timeout is an un-expected event and the | ||
757 | * state machine is restarted. - link failure events restart the starting state | ||
758 | * machine - any other events log a warning message and set a failure status | ||
759 | * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any | ||
760 | * unexpected event notifation | ||
761 | */ | ||
762 | static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_event_handler( | ||
763 | struct scic_sds_phy *sci_phy, | ||
764 | u32 event_code) | ||
765 | { | ||
766 | u32 result = SCI_SUCCESS; | ||
767 | |||
768 | switch (scu_get_event_code(event_code)) { | ||
769 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
770 | /* Backup the state machine */ | ||
771 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
772 | break; | ||
773 | |||
774 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
775 | /* | ||
776 | * We were doing SAS PHY link training and received a SATA PHY event | ||
777 | * continue OOB/SN as if this were a SATA PHY */ | ||
778 | scic_sds_phy_start_sata_link_training(sci_phy); | ||
779 | break; | ||
780 | |||
781 | case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT: | ||
782 | case SCU_EVENT_LINK_FAILURE: | ||
783 | case SCU_EVENT_HARD_RESET_RECEIVED: | ||
784 | /* Start the oob/sn state machine over again */ | ||
785 | scic_sds_phy_restart_starting_state(sci_phy); | ||
786 | break; | ||
787 | |||
788 | default: | ||
789 | dev_warn(sciphy_to_dev(sci_phy), | ||
790 | "%s: PHY starting substate machine received " | ||
791 | "unexpected event_code %x\n", | ||
792 | __func__, | ||
793 | event_code); | ||
794 | |||
795 | result = SCI_FAILURE; | ||
796 | break; | ||
797 | } | ||
798 | |||
799 | return result; | ||
800 | } | ||
801 | |||
802 | /** | ||
803 | * | ||
804 | * @phy: This struct scic_sds_phy object which has received an event. | ||
805 | * @event_code: This is the event code which the phy object is to decode. | ||
806 | * | ||
807 | * This method is called when an event notification is received for the phy | ||
808 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_POWER. - | ||
809 | * decode the event - link failure events restart the starting state machine - | ||
810 | * any other events log a warning message and set a failure status enum sci_status | ||
811 | * SCI_SUCCESS on a link failure event SCI_FAILURE on any unexpected event | ||
812 | * notifation | ||
813 | */ | ||
814 | static enum sci_status scic_sds_phy_starting_substate_await_sas_power_event_handler( | ||
815 | struct scic_sds_phy *sci_phy, | ||
816 | u32 event_code) | ||
817 | { | ||
818 | u32 result = SCI_SUCCESS; | ||
819 | |||
820 | switch (scu_get_event_code(event_code)) { | ||
821 | case SCU_EVENT_LINK_FAILURE: | ||
822 | /* Link failure change state back to the starting state */ | ||
823 | scic_sds_phy_restart_starting_state(sci_phy); | ||
824 | break; | ||
825 | |||
826 | default: | ||
827 | dev_warn(sciphy_to_dev(sci_phy), | ||
828 | "%s: PHY starting substate machine received unexpected " | ||
829 | "event_code %x\n", | ||
830 | __func__, | ||
831 | event_code); | ||
832 | |||
833 | result = SCI_FAILURE; | ||
834 | break; | ||
835 | } | ||
836 | |||
837 | return result; | ||
838 | } | ||
839 | |||
840 | /** | ||
841 | * | ||
842 | * @phy: This struct scic_sds_phy object which has received an event. | ||
843 | * @event_code: This is the event code which the phy object is to decode. | ||
844 | * | ||
845 | * This method is called when an event notification is received for the phy | ||
846 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - | ||
847 | * decode the event - link failure events restart the starting state machine - | ||
848 | * sata spinup hold events are ignored since they are expected - any other | ||
849 | * events log a warning message and set a failure status enum sci_status SCI_SUCCESS | ||
850 | * on a link failure event SCI_FAILURE on any unexpected event notifation | ||
851 | */ | ||
852 | static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_handler( | ||
853 | struct scic_sds_phy *sci_phy, | ||
854 | u32 event_code) | ||
855 | { | ||
856 | u32 result = SCI_SUCCESS; | ||
857 | |||
858 | switch (scu_get_event_code(event_code)) { | ||
859 | case SCU_EVENT_LINK_FAILURE: | ||
860 | /* Link failure change state back to the starting state */ | ||
861 | scic_sds_phy_restart_starting_state(sci_phy); | ||
862 | break; | ||
863 | |||
864 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
865 | /* These events are received every 10ms and are expected while in this state */ | ||
866 | break; | ||
867 | |||
868 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
869 | /* | ||
870 | * There has been a change in the phy type before OOB/SN for the | ||
871 | * SATA finished start down the SAS link traning path. */ | ||
872 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
873 | break; | ||
874 | |||
875 | default: | ||
876 | dev_warn(sciphy_to_dev(sci_phy), | ||
877 | "%s: PHY starting substate machine received " | ||
878 | "unexpected event_code %x\n", | ||
879 | __func__, | ||
880 | event_code); | ||
881 | |||
882 | result = SCI_FAILURE; | ||
883 | break; | ||
884 | } | ||
885 | |||
886 | return result; | ||
887 | } | ||
888 | |||
889 | /** | ||
890 | * scic_sds_phy_starting_substate_await_sata_phy_event_handler - | ||
891 | * @phy: This struct scic_sds_phy object which has received an event. | ||
892 | * @event_code: This is the event code which the phy object is to decode. | ||
893 | * | ||
894 | * This method is called when an event notification is received for the phy | ||
895 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - | ||
896 | * decode the event - link failure events restart the starting state machine - | ||
897 | * sata spinup hold events are ignored since they are expected - sata phy | ||
898 | * detected event change to the wait speed event - any other events log a | ||
899 | * warning message and set a failure status enum sci_status SCI_SUCCESS on a link | ||
900 | * failure event SCI_FAILURE on any unexpected event notifation | ||
901 | */ | ||
902 | static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler( | ||
903 | struct scic_sds_phy *sci_phy, u32 event_code) | ||
904 | { | ||
905 | u32 result = SCI_SUCCESS; | ||
906 | |||
907 | switch (scu_get_event_code(event_code)) { | ||
908 | case SCU_EVENT_LINK_FAILURE: | ||
909 | /* Link failure change state back to the starting state */ | ||
910 | scic_sds_phy_restart_starting_state(sci_phy); | ||
911 | break; | ||
912 | |||
913 | case SCU_EVENT_SATA_SPINUP_HOLD: | ||
914 | /* These events might be received since we dont know how many may be in | ||
915 | * the completion queue while waiting for power | ||
916 | */ | ||
917 | break; | ||
918 | |||
919 | case SCU_EVENT_SATA_PHY_DETECTED: | ||
920 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; | ||
921 | |||
922 | /* We have received the SATA PHY notification change state */ | ||
923 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
924 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | ||
925 | break; | ||
926 | |||
927 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
928 | /* There has been a change in the phy type before OOB/SN for the | ||
929 | * SATA finished start down the SAS link traning path. | ||
930 | */ | ||
931 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
932 | break; | ||
933 | |||
934 | default: | ||
935 | dev_warn(sciphy_to_dev(sci_phy), | ||
936 | "%s: PHY starting substate machine received " | ||
937 | "unexpected event_code %x\n", | ||
938 | __func__, | ||
939 | event_code); | ||
940 | |||
941 | result = SCI_FAILURE; | ||
942 | break; | ||
943 | } | ||
944 | |||
945 | return result; | ||
946 | } | ||
947 | |||
948 | /** | ||
949 | * | ||
950 | * @phy: This struct scic_sds_phy object which has received an event. | ||
951 | * @event_code: This is the event code which the phy object is to decode. | ||
952 | * | ||
953 | * This method is called when an event notification is received for the phy | ||
954 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. | ||
955 | * - decode the event - sata phy detected returns us back to this state. - | ||
956 | * speed event detected causes a state transition to the wait for signature. - | ||
957 | * link failure events restart the starting state machine - any other events | ||
958 | * log a warning message and set a failure status enum sci_status SCI_SUCCESS on any | ||
959 | * valid event notification SCI_FAILURE on any unexpected event notifation | ||
960 | */ | ||
961 | static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_handler( | ||
962 | struct scic_sds_phy *sci_phy, | ||
963 | u32 event_code) | ||
964 | { | ||
965 | u32 result = SCI_SUCCESS; | ||
966 | |||
967 | switch (scu_get_event_code(event_code)) { | ||
968 | case SCU_EVENT_SATA_PHY_DETECTED: | ||
969 | /* | ||
970 | * The hardware reports multiple SATA PHY detected events | ||
971 | * ignore the extras */ | ||
972 | break; | ||
973 | |||
974 | case SCU_EVENT_SATA_15: | ||
975 | case SCU_EVENT_SATA_15_SSC: | ||
976 | scic_sds_phy_complete_link_training( | ||
977 | sci_phy, | ||
978 | SAS_LINK_RATE_1_5_GBPS, | ||
979 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
980 | break; | ||
981 | |||
982 | case SCU_EVENT_SATA_30: | ||
983 | case SCU_EVENT_SATA_30_SSC: | ||
984 | scic_sds_phy_complete_link_training( | ||
985 | sci_phy, | ||
986 | SAS_LINK_RATE_3_0_GBPS, | ||
987 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
988 | break; | ||
989 | |||
990 | case SCU_EVENT_SATA_60: | ||
991 | case SCU_EVENT_SATA_60_SSC: | ||
992 | scic_sds_phy_complete_link_training( | ||
993 | sci_phy, | ||
994 | SAS_LINK_RATE_6_0_GBPS, | ||
995 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
996 | break; | ||
997 | |||
998 | case SCU_EVENT_LINK_FAILURE: | ||
999 | /* Link failure change state back to the starting state */ | ||
1000 | scic_sds_phy_restart_starting_state(sci_phy); | ||
1001 | break; | ||
1002 | |||
1003 | case SCU_EVENT_SAS_PHY_DETECTED: | ||
1004 | /* | ||
1005 | * There has been a change in the phy type before OOB/SN for the | ||
1006 | * SATA finished start down the SAS link traning path. */ | ||
1007 | scic_sds_phy_start_sas_link_training(sci_phy); | ||
1008 | break; | ||
1009 | |||
1010 | default: | ||
1011 | dev_warn(sciphy_to_dev(sci_phy), | ||
1012 | "%s: PHY starting substate machine received " | ||
1013 | "unexpected event_code %x\n", | ||
1014 | __func__, | ||
1015 | event_code); | ||
1016 | |||
1017 | result = SCI_FAILURE; | ||
1018 | break; | ||
1019 | } | ||
1020 | |||
1021 | return result; | ||
1022 | } | ||
1023 | |||
1024 | /** | ||
1025 | * scic_sds_phy_starting_substate_await_sig_fis_event_handler - | ||
1026 | * @phy: This struct scic_sds_phy object which has received an event. | ||
1027 | * @event_code: This is the event code which the phy object is to decode. | ||
1028 | * | ||
1029 | * This method is called when an event notification is received for the phy | ||
1030 | * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - | ||
1031 | * decode the event - sas phy detected event backs up the state machine to the | ||
1032 | * await speed notification. - identify timeout is an un-expected event and the | ||
1033 | * state machine is restarted. - link failure events restart the starting state | ||
1034 | * machine - any other events log a warning message and set a failure status | ||
1035 | * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any | ||
1036 | * unexpected event notifation | ||
1037 | */ | ||
1038 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler( | ||
1039 | struct scic_sds_phy *sci_phy, u32 event_code) | ||
1040 | { | ||
1041 | u32 result = SCI_SUCCESS; | ||
1042 | |||
1043 | switch (scu_get_event_code(event_code)) { | ||
1044 | case SCU_EVENT_SATA_PHY_DETECTED: | ||
1045 | /* Backup the state machine */ | ||
1046 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1047 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | ||
1048 | break; | ||
1049 | |||
1050 | case SCU_EVENT_LINK_FAILURE: | ||
1051 | /* Link failure change state back to the starting state */ | ||
1052 | scic_sds_phy_restart_starting_state(sci_phy); | ||
1053 | break; | ||
1054 | |||
1055 | default: | ||
1056 | dev_warn(sciphy_to_dev(sci_phy), | ||
1057 | "%s: PHY starting substate machine received " | ||
1058 | "unexpected event_code %x\n", | ||
1059 | __func__, | ||
1060 | event_code); | ||
1061 | |||
1062 | result = SCI_FAILURE; | ||
1063 | break; | ||
1064 | } | ||
1065 | |||
1066 | return result; | ||
1067 | } | ||
1068 | |||
1069 | |||
1070 | /* | ||
1071 | * ***************************************************************************** | ||
1072 | * * SCIC SDS PHY FRAME_HANDLERS | ||
1073 | * ***************************************************************************** */ | ||
1074 | |||
1075 | /** | ||
1076 | * | ||
1077 | * @phy: This is struct scic_sds_phy object which is being requested to decode the | ||
1078 | * frame data. | ||
1079 | * @frame_index: This is the index of the unsolicited frame which was received | ||
1080 | * for this phy. | ||
1081 | * | ||
1082 | * This method decodes the unsolicited frame when the struct scic_sds_phy is in the | ||
1083 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Get the UF Header - If the UF | ||
1084 | * is an IAF - Copy IAF data to local phy object IAF data buffer. - Change | ||
1085 | * starting substate to wait power. - else - log warning message of unexpected | ||
1086 | * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS | ||
1087 | */ | ||
1088 | static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler( | ||
1089 | struct scic_sds_phy *sci_phy, u32 frame_index) | ||
1090 | { | ||
1091 | enum sci_status result; | ||
1092 | u32 *frame_words; | ||
1093 | struct sas_identify_frame iaf; | ||
1094 | struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); | ||
1095 | |||
1096 | result = scic_sds_unsolicited_frame_control_get_header( | ||
1097 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), | ||
1098 | frame_index, | ||
1099 | (void **)&frame_words); | ||
1100 | |||
1101 | if (result != SCI_SUCCESS) | ||
1102 | return result; | ||
1103 | |||
1104 | sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32)); | ||
1105 | if (iaf.frame_type == 0) { | ||
1106 | u32 state; | ||
1107 | |||
1108 | memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf)); | ||
1109 | if (iaf.smp_tport) { | ||
1110 | /* We got the IAF for an expander PHY go to the final | ||
1111 | * state since there are no power requirements for | ||
1112 | * expander phys. | ||
1113 | */ | ||
1114 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL; | ||
1115 | } else { | ||
1116 | /* We got the IAF we can now go to the await spinup | ||
1117 | * semaphore state | ||
1118 | */ | ||
1119 | state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER; | ||
1120 | } | ||
1121 | sci_base_state_machine_change_state( | ||
1122 | &sci_phy->starting_substate_machine, | ||
1123 | state); | ||
1124 | result = SCI_SUCCESS; | ||
1125 | } else | ||
1126 | dev_warn(sciphy_to_dev(sci_phy), | ||
1127 | "%s: PHY starting substate machine received " | ||
1128 | "unexpected frame id %x\n", | ||
1129 | __func__, | ||
1130 | frame_index); | ||
1131 | |||
1132 | scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy), | ||
1133 | frame_index); | ||
1134 | |||
1135 | return result; | ||
1136 | } | ||
1137 | |||
1138 | /** | ||
1139 | * | ||
1140 | * @phy: This is struct scic_sds_phy object which is being requested to decode the | ||
1141 | * frame data. | ||
1142 | * @frame_index: This is the index of the unsolicited frame which was received | ||
1143 | * for this phy. | ||
1144 | * | ||
1145 | * This method decodes the unsolicited frame when the struct scic_sds_phy is in the | ||
1146 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Get the UF Header - If | ||
1147 | * the UF is an SIGNATURE FIS - Copy IAF data to local phy object SIGNATURE FIS | ||
1148 | * data buffer. - else - log warning message of unexpected unsolicted frame - | ||
1149 | * release frame buffer enum sci_status SCI_SUCCESS Must decode the SIGNATURE FIS | ||
1150 | * data | ||
1151 | */ | ||
1152 | static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler( | ||
1153 | struct scic_sds_phy *sci_phy, | ||
1154 | u32 frame_index) | ||
1155 | { | ||
1156 | enum sci_status result; | ||
1157 | struct dev_to_host_fis *frame_header; | ||
1158 | u32 *fis_frame_data; | ||
1159 | struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); | ||
1160 | |||
1161 | result = scic_sds_unsolicited_frame_control_get_header( | ||
1162 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), | ||
1163 | frame_index, | ||
1164 | (void **)&frame_header); | ||
1165 | |||
1166 | if (result != SCI_SUCCESS) | ||
1167 | return result; | ||
1168 | |||
1169 | if ((frame_header->fis_type == FIS_REGD2H) && | ||
1170 | !(frame_header->status & ATA_BUSY)) { | ||
1171 | scic_sds_unsolicited_frame_control_get_buffer( | ||
1172 | &(scic_sds_phy_get_controller(sci_phy)->uf_control), | ||
1173 | frame_index, | ||
1174 | (void **)&fis_frame_data); | ||
1175 | |||
1176 | scic_sds_controller_copy_sata_response(&iphy->frame_rcvd.fis, | ||
1177 | frame_header, | ||
1178 | fis_frame_data); | ||
1179 | |||
1180 | /* got IAF we can now go to the await spinup semaphore state */ | ||
1181 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1182 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | ||
1183 | |||
1184 | result = SCI_SUCCESS; | ||
1185 | } else | ||
1186 | dev_warn(sciphy_to_dev(sci_phy), | ||
1187 | "%s: PHY starting substate machine received " | ||
1188 | "unexpected frame id %x\n", | ||
1189 | __func__, | ||
1190 | frame_index); | ||
1191 | |||
1192 | /* Regardless of the result we are done with this frame with it */ | ||
1193 | scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy), | ||
1194 | frame_index); | ||
1195 | |||
1196 | return result; | ||
1197 | } | ||
1198 | |||
1199 | /* | ||
1200 | * ***************************************************************************** | ||
1201 | * * SCIC SDS PHY POWER_HANDLERS | ||
1202 | * ***************************************************************************** */ | ||
1203 | |||
1204 | /* | ||
1205 | * This method is called by the struct scic_sds_controller when the phy object is | ||
1206 | * granted power. - The notify enable spinups are turned on for this phy object | ||
1207 | * - The phy state machine is transitioned to the | ||
1208 | * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS | ||
1209 | */ | ||
1210 | static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler( | ||
1211 | struct scic_sds_phy *sci_phy) | ||
1212 | { | ||
1213 | u32 enable_spinup; | ||
1214 | |||
1215 | enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1216 | enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); | ||
1217 | writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1218 | |||
1219 | /* Change state to the final state this substate machine has run to completion */ | ||
1220 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1221 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | ||
1222 | |||
1223 | return SCI_SUCCESS; | ||
1224 | } | ||
1225 | |||
1226 | /* | ||
1227 | * This method is called by the struct scic_sds_controller when the phy object is | ||
1228 | * granted power. - The phy state machine is transitioned to the | ||
1229 | * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS | ||
1230 | */ | ||
1231 | static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler( | ||
1232 | struct scic_sds_phy *sci_phy) | ||
1233 | { | ||
1234 | u32 scu_sas_pcfg_value; | ||
1235 | |||
1236 | /* Release the spinup hold state and reset the OOB state machine */ | ||
1237 | scu_sas_pcfg_value = | ||
1238 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
1239 | scu_sas_pcfg_value &= | ||
1240 | ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); | ||
1241 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
1242 | writel(scu_sas_pcfg_value, | ||
1243 | &sci_phy->link_layer_registers->phy_configuration); | ||
1244 | |||
1245 | /* Now restart the OOB operation */ | ||
1246 | scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
1247 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | ||
1248 | writel(scu_sas_pcfg_value, | ||
1249 | &sci_phy->link_layer_registers->phy_configuration); | ||
1250 | |||
1251 | /* Change state to the final state this substate machine has run to completion */ | ||
1252 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1253 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); | ||
1254 | |||
1255 | return SCI_SUCCESS; | ||
1256 | } | ||
1257 | |||
1258 | static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy, | ||
1259 | const char *func) | ||
1260 | { | ||
1261 | dev_dbg(sciphy_to_dev(sci_phy), | ||
1262 | "%s: in wrong state: %d\n", func, | ||
1263 | sci_base_state_machine_get_state(&sci_phy->state_machine)); | ||
1264 | return SCI_FAILURE_INVALID_STATE; | ||
1265 | } | ||
1266 | |||
1267 | static enum sci_status | ||
1268 | scic_sds_phy_default_start_handler(struct scic_sds_phy *sci_phy) | ||
1269 | { | ||
1270 | return default_phy_handler(sci_phy, __func__); | ||
1271 | } | ||
1272 | |||
1273 | static enum sci_status | ||
1274 | scic_sds_phy_default_stop_handler(struct scic_sds_phy *sci_phy) | ||
1275 | { | ||
1276 | return default_phy_handler(sci_phy, __func__); | ||
1277 | } | ||
1278 | |||
1279 | static enum sci_status | ||
1280 | scic_sds_phy_default_reset_handler(struct scic_sds_phy *sci_phy) | ||
1281 | { | ||
1282 | return default_phy_handler(sci_phy, __func__); | ||
1283 | } | ||
1284 | |||
1285 | static enum sci_status | ||
1286 | scic_sds_phy_default_destroy_handler(struct scic_sds_phy *sci_phy) | ||
1287 | { | ||
1288 | return default_phy_handler(sci_phy, __func__); | ||
1289 | } | ||
1290 | |||
1291 | static enum sci_status | ||
1292 | scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy, | ||
1293 | u32 frame_index) | ||
1294 | { | ||
1295 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | ||
1296 | |||
1297 | default_phy_handler(sci_phy, __func__); | ||
1298 | scic_sds_controller_release_frame(scic, frame_index); | ||
1299 | |||
1300 | return SCI_FAILURE_INVALID_STATE; | ||
1301 | } | ||
1302 | |||
1303 | static enum sci_status | ||
1304 | scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy, | ||
1305 | u32 event_code) | ||
1306 | { | ||
1307 | return default_phy_handler(sci_phy, __func__); | ||
1308 | } | ||
1309 | |||
1310 | static enum sci_status | ||
1311 | scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy) | ||
1312 | { | ||
1313 | return default_phy_handler(sci_phy, __func__); | ||
1314 | } | ||
1315 | |||
1316 | |||
1317 | |||
1318 | static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = { | ||
1319 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | ||
1320 | .start_handler = scic_sds_phy_default_start_handler, | ||
1321 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1322 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1323 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1324 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1325 | .event_handler = scic_sds_phy_default_event_handler, | ||
1326 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1327 | }, | ||
1328 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { | ||
1329 | .start_handler = scic_sds_phy_default_start_handler, | ||
1330 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1331 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1332 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1333 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1334 | .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler, | ||
1335 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1336 | }, | ||
1337 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { | ||
1338 | .start_handler = scic_sds_phy_default_start_handler, | ||
1339 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1340 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1341 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1342 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1343 | .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler, | ||
1344 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1345 | }, | ||
1346 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { | ||
1347 | .start_handler = scic_sds_phy_default_start_handler, | ||
1348 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1349 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1350 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1351 | .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler, | ||
1352 | .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler, | ||
1353 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1354 | }, | ||
1355 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { | ||
1356 | .start_handler = scic_sds_phy_default_start_handler, | ||
1357 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1358 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1359 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1360 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1361 | .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler, | ||
1362 | .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler | ||
1363 | }, | ||
1364 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { | ||
1365 | .start_handler = scic_sds_phy_default_start_handler, | ||
1366 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1367 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1368 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1369 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1370 | .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler, | ||
1371 | .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler | ||
1372 | }, | ||
1373 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { | ||
1374 | .start_handler = scic_sds_phy_default_start_handler, | ||
1375 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1376 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1377 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1378 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1379 | .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler, | ||
1380 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1381 | }, | ||
1382 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { | ||
1383 | .start_handler = scic_sds_phy_default_start_handler, | ||
1384 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1385 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1386 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1387 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1388 | .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler, | ||
1389 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1390 | }, | ||
1391 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { | ||
1392 | .start_handler = scic_sds_phy_default_start_handler, | ||
1393 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1394 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1395 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1396 | .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler, | ||
1397 | .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler, | ||
1398 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1399 | }, | ||
1400 | [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { | ||
1401 | .start_handler = scic_sds_phy_default_start_handler, | ||
1402 | .stop_handler = scic_sds_phy_starting_substate_general_stop_handler, | ||
1403 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1404 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1405 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1406 | .event_handler = scic_sds_phy_default_event_handler, | ||
1407 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1408 | } | ||
1409 | }; | ||
1410 | |||
1411 | /** | ||
1412 | * scic_sds_phy_set_starting_substate_handlers() - | ||
1413 | * | ||
1414 | * This macro sets the starting substate handlers by state_id | ||
1415 | */ | ||
1416 | #define scic_sds_phy_set_starting_substate_handlers(phy, state_id) \ | ||
1417 | scic_sds_phy_set_state_handlers(\ | ||
1418 | (phy), \ | ||
1419 | &scic_sds_phy_starting_substate_handler_table[(state_id)] \ | ||
1420 | ) | ||
1421 | |||
1422 | /* | ||
1423 | * **************************************************************************** | ||
1424 | * * PHY STARTING SUBSTATE METHODS | ||
1425 | * **************************************************************************** */ | ||
1426 | |||
1427 | /** | ||
1428 | * scic_sds_phy_starting_initial_substate_enter - | ||
1429 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1430 | * | ||
1431 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1432 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL. - The initial state | ||
1433 | * handlers are put in place for the struct scic_sds_phy object. - The state is | ||
1434 | * changed to the wait phy type event notification. none | ||
1435 | */ | ||
1436 | static void scic_sds_phy_starting_initial_substate_enter(void *object) | ||
1437 | { | ||
1438 | struct scic_sds_phy *sci_phy = object; | ||
1439 | |||
1440 | scic_sds_phy_set_starting_substate_handlers( | ||
1441 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | ||
1442 | |||
1443 | /* This is just an temporary state go off to the starting state */ | ||
1444 | sci_base_state_machine_change_state(&sci_phy->starting_substate_machine, | ||
1445 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); | ||
1446 | } | ||
1447 | |||
1448 | /** | ||
1449 | * | ||
1450 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1451 | * | ||
1452 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1453 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_PHY_TYPE_EN. - Set the | ||
1454 | * struct scic_sds_phy object state handlers for this state. none | ||
1455 | */ | ||
1456 | static void scic_sds_phy_starting_await_ossp_en_substate_enter(void *object) | ||
1457 | { | ||
1458 | struct scic_sds_phy *sci_phy = object; | ||
1459 | |||
1460 | scic_sds_phy_set_starting_substate_handlers( | ||
1461 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN | ||
1462 | ); | ||
1463 | } | ||
1464 | |||
1465 | /** | ||
1466 | * | ||
1467 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1468 | * | ||
1469 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1470 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - Set the | ||
1471 | * struct scic_sds_phy object state handlers for this state. none | ||
1472 | */ | ||
1473 | static void scic_sds_phy_starting_await_sas_speed_en_substate_enter( | ||
1474 | void *object) | ||
1475 | { | ||
1476 | struct scic_sds_phy *sci_phy = object; | ||
1477 | |||
1478 | scic_sds_phy_set_starting_substate_handlers( | ||
1479 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN | ||
1480 | ); | ||
1481 | } | ||
1482 | |||
1483 | /** | ||
1484 | * | ||
1485 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1486 | * | ||
1487 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1488 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Set the | ||
1489 | * struct scic_sds_phy object state handlers for this state. none | ||
1490 | */ | ||
1491 | static void scic_sds_phy_starting_await_iaf_uf_substate_enter(void *object) | ||
1492 | { | ||
1493 | struct scic_sds_phy *sci_phy = object; | ||
1494 | |||
1495 | scic_sds_phy_set_starting_substate_handlers( | ||
1496 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF | ||
1497 | ); | ||
1498 | } | ||
1499 | |||
1500 | /** | ||
1501 | * | ||
1502 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1503 | * | ||
1504 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1505 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Set the | ||
1506 | * struct scic_sds_phy object state handlers for this state. - Add this phy object to | ||
1507 | * the power control queue none | ||
1508 | */ | ||
1509 | static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object) | ||
1510 | { | ||
1511 | struct scic_sds_phy *sci_phy = object; | ||
1512 | |||
1513 | scic_sds_phy_set_starting_substate_handlers( | ||
1514 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER | ||
1515 | ); | ||
1516 | |||
1517 | scic_sds_controller_power_control_queue_insert( | ||
1518 | scic_sds_phy_get_controller(sci_phy), | ||
1519 | sci_phy | ||
1520 | ); | ||
1521 | } | ||
1522 | |||
1523 | /** | ||
1524 | * | ||
1525 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1526 | * | ||
1527 | * This method will perform the actions required by the struct scic_sds_phy on exiting | ||
1528 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Remove the | ||
1529 | * struct scic_sds_phy object from the power control queue. none | ||
1530 | */ | ||
1531 | static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object) | ||
1532 | { | ||
1533 | struct scic_sds_phy *sci_phy = object; | ||
1534 | |||
1535 | scic_sds_controller_power_control_queue_remove( | ||
1536 | scic_sds_phy_get_controller(sci_phy), sci_phy | ||
1537 | ); | ||
1538 | } | ||
1539 | |||
1540 | /** | ||
1541 | * | ||
1542 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1543 | * | ||
1544 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1545 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Set the | ||
1546 | * struct scic_sds_phy object state handlers for this state. - Add this phy object to | ||
1547 | * the power control queue none | ||
1548 | */ | ||
1549 | static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object) | ||
1550 | { | ||
1551 | struct scic_sds_phy *sci_phy = object; | ||
1552 | |||
1553 | scic_sds_phy_set_starting_substate_handlers( | ||
1554 | sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER | ||
1555 | ); | ||
1556 | |||
1557 | scic_sds_controller_power_control_queue_insert( | ||
1558 | scic_sds_phy_get_controller(sci_phy), | ||
1559 | sci_phy | ||
1560 | ); | ||
1561 | } | ||
1562 | |||
1563 | /** | ||
1564 | * | ||
1565 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1566 | * | ||
1567 | * This method will perform the actions required by the struct scic_sds_phy on exiting | ||
1568 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Remove the | ||
1569 | * struct scic_sds_phy object from the power control queue. none | ||
1570 | */ | ||
1571 | static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object) | ||
1572 | { | ||
1573 | struct scic_sds_phy *sci_phy = object; | ||
1574 | |||
1575 | scic_sds_controller_power_control_queue_remove( | ||
1576 | scic_sds_phy_get_controller(sci_phy), | ||
1577 | sci_phy | ||
1578 | ); | ||
1579 | } | ||
1580 | |||
1581 | /** | ||
1582 | * | ||
1583 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1584 | * | ||
1585 | * This function will perform the actions required by the struct scic_sds_phy on | ||
1586 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the | ||
1587 | * struct scic_sds_phy object state handlers for this state. none | ||
1588 | */ | ||
1589 | static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object) | ||
1590 | { | ||
1591 | struct scic_sds_phy *sci_phy = object; | ||
1592 | |||
1593 | scic_sds_phy_set_starting_substate_handlers( | ||
1594 | sci_phy, | ||
1595 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN); | ||
1596 | |||
1597 | isci_timer_start(sci_phy->sata_timeout_timer, | ||
1598 | SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); | ||
1599 | } | ||
1600 | |||
1601 | /** | ||
1602 | * | ||
1603 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1604 | * | ||
1605 | * This method will perform the actions required by the struct scic_sds_phy | ||
1606 | * on exiting | ||
1607 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer | ||
1608 | * that was started on entry to await sata phy event notification none | ||
1609 | */ | ||
1610 | static inline void scic_sds_phy_starting_await_sata_phy_substate_exit( | ||
1611 | void *object) | ||
1612 | { | ||
1613 | struct scic_sds_phy *sci_phy = object; | ||
1614 | |||
1615 | isci_timer_stop(sci_phy->sata_timeout_timer); | ||
1616 | } | ||
1617 | |||
1618 | /** | ||
1619 | * | ||
1620 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1621 | * | ||
1622 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1623 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - Set the | ||
1624 | * struct scic_sds_phy object state handlers for this state. none | ||
1625 | */ | ||
1626 | static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object) | ||
1627 | { | ||
1628 | struct scic_sds_phy *sci_phy = object; | ||
1629 | |||
1630 | scic_sds_phy_set_starting_substate_handlers( | ||
1631 | sci_phy, | ||
1632 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN); | ||
1633 | |||
1634 | isci_timer_start(sci_phy->sata_timeout_timer, | ||
1635 | SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); | ||
1636 | } | ||
1637 | |||
1638 | /** | ||
1639 | * | ||
1640 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1641 | * | ||
1642 | * This function will perform the actions required by the | ||
1643 | * struct scic_sds_phy on exiting | ||
1644 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer | ||
1645 | * that was started on entry to await sata phy event notification none | ||
1646 | */ | ||
1647 | static inline void scic_sds_phy_starting_await_sata_speed_substate_exit( | ||
1648 | void *object) | ||
1649 | { | ||
1650 | struct scic_sds_phy *sci_phy = object; | ||
1651 | |||
1652 | isci_timer_stop(sci_phy->sata_timeout_timer); | ||
1653 | } | ||
1654 | |||
1655 | /** | ||
1656 | * | ||
1657 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1658 | * | ||
1659 | * This function will perform the actions required by the struct scic_sds_phy on | ||
1660 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the | ||
1661 | * struct scic_sds_phy object state handlers for this state. | ||
1662 | * - Start the SIGNATURE FIS | ||
1663 | * timeout timer none | ||
1664 | */ | ||
1665 | static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object) | ||
1666 | { | ||
1667 | bool continue_to_ready_state; | ||
1668 | struct scic_sds_phy *sci_phy = object; | ||
1669 | |||
1670 | scic_sds_phy_set_starting_substate_handlers( | ||
1671 | sci_phy, | ||
1672 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF); | ||
1673 | |||
1674 | continue_to_ready_state = scic_sds_port_link_detected( | ||
1675 | sci_phy->owning_port, | ||
1676 | sci_phy); | ||
1677 | |||
1678 | if (continue_to_ready_state) { | ||
1679 | /* | ||
1680 | * Clear the PE suspend condition so we can actually | ||
1681 | * receive SIG FIS | ||
1682 | * The hardware will not respond to the XRDY until the PE | ||
1683 | * suspend condition is cleared. | ||
1684 | */ | ||
1685 | scic_sds_phy_resume(sci_phy); | ||
1686 | |||
1687 | isci_timer_start(sci_phy->sata_timeout_timer, | ||
1688 | SCIC_SDS_SIGNATURE_FIS_TIMEOUT); | ||
1689 | } else | ||
1690 | sci_phy->is_in_link_training = false; | ||
1691 | } | ||
1692 | |||
1693 | /** | ||
1694 | * | ||
1695 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1696 | * | ||
1697 | * This function will perform the actions required by the | ||
1698 | * struct scic_sds_phy on exiting | ||
1699 | * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE | ||
1700 | * FIS timeout timer. none | ||
1701 | */ | ||
1702 | static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit( | ||
1703 | void *object) | ||
1704 | { | ||
1705 | struct scic_sds_phy *sci_phy = object; | ||
1706 | |||
1707 | isci_timer_stop(sci_phy->sata_timeout_timer); | ||
1708 | } | ||
1709 | |||
1710 | /** | ||
1711 | * | ||
1712 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
1713 | * | ||
1714 | * This method will perform the actions required by the struct scic_sds_phy on | ||
1715 | * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. - Set the struct scic_sds_phy | ||
1716 | * object state handlers for this state. - Change base state machine to the | ||
1717 | * ready state. none | ||
1718 | */ | ||
1719 | static void scic_sds_phy_starting_final_substate_enter(void *object) | ||
1720 | { | ||
1721 | struct scic_sds_phy *sci_phy = object; | ||
1722 | |||
1723 | scic_sds_phy_set_starting_substate_handlers(sci_phy, | ||
1724 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); | ||
1725 | |||
1726 | /* State machine has run to completion so exit out and change | ||
1727 | * the base state machine to the ready state | ||
1728 | */ | ||
1729 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1730 | SCI_BASE_PHY_STATE_READY); | ||
1731 | } | ||
1732 | |||
1733 | /* --------------------------------------------------------------------------- */ | ||
1734 | |||
1735 | static const struct sci_base_state scic_sds_phy_starting_substates[] = { | ||
1736 | [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { | ||
1737 | .enter_state = scic_sds_phy_starting_initial_substate_enter, | ||
1738 | }, | ||
1739 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { | ||
1740 | .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter, | ||
1741 | }, | ||
1742 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { | ||
1743 | .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter, | ||
1744 | }, | ||
1745 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { | ||
1746 | .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter, | ||
1747 | }, | ||
1748 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { | ||
1749 | .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter, | ||
1750 | .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit, | ||
1751 | }, | ||
1752 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { | ||
1753 | .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter, | ||
1754 | .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit | ||
1755 | }, | ||
1756 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { | ||
1757 | .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter, | ||
1758 | .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit | ||
1759 | }, | ||
1760 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { | ||
1761 | .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter, | ||
1762 | .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit | ||
1763 | }, | ||
1764 | [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { | ||
1765 | .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter, | ||
1766 | .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit | ||
1767 | }, | ||
1768 | [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { | ||
1769 | .enter_state = scic_sds_phy_starting_final_substate_enter, | ||
1770 | } | ||
1771 | }; | ||
1772 | |||
1773 | /* | ||
1774 | * This method takes the struct scic_sds_phy from a stopped state and | ||
1775 | * attempts to start it. - The phy state machine is transitioned to the | ||
1776 | * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS | ||
1777 | */ | ||
1778 | static enum sci_status | ||
1779 | scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy) | ||
1780 | { | ||
1781 | struct isci_host *ihost; | ||
1782 | struct scic_sds_controller *scic; | ||
1783 | |||
1784 | scic = scic_sds_phy_get_controller(sci_phy), | ||
1785 | ihost = scic_to_ihost(scic); | ||
1786 | |||
1787 | /* Create the SIGNATURE FIS Timeout timer for this phy */ | ||
1788 | sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy, | ||
1789 | scic_sds_phy_sata_timeout); | ||
1790 | |||
1791 | if (sci_phy->sata_timeout_timer) | ||
1792 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1793 | SCI_BASE_PHY_STATE_STARTING); | ||
1794 | |||
1795 | return SCI_SUCCESS; | ||
1796 | } | ||
1797 | |||
1798 | static enum sci_status | ||
1799 | scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy) | ||
1800 | { | ||
1801 | return SCI_SUCCESS; | ||
1802 | } | ||
1803 | |||
1804 | static enum sci_status | ||
1805 | scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy) | ||
1806 | { | ||
1807 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1808 | SCI_BASE_PHY_STATE_STOPPED); | ||
1809 | |||
1810 | return SCI_SUCCESS; | ||
1811 | } | ||
1812 | |||
1813 | static enum sci_status | ||
1814 | scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy) | ||
1815 | { | ||
1816 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1817 | SCI_BASE_PHY_STATE_RESETTING); | ||
1818 | |||
1819 | return SCI_SUCCESS; | ||
1820 | } | ||
1821 | |||
1822 | /** | ||
1823 | * scic_sds_phy_ready_state_event_handler - | ||
1824 | * @phy: This is the struct scic_sds_phy object which has received the event. | ||
1825 | * | ||
1826 | * This method request the struct scic_sds_phy handle the received event. The only | ||
1827 | * event that we are interested in while in the ready state is the link failure | ||
1828 | * event. - decoded event is a link failure - transition the struct scic_sds_phy back | ||
1829 | * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will | ||
1830 | * report a warning message enum sci_status SCI_SUCCESS if the event received is a | ||
1831 | * link failure SCI_FAILURE_INVALID_STATE for any other event received. | ||
1832 | */ | ||
1833 | static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1834 | u32 event_code) | ||
1835 | { | ||
1836 | enum sci_status result = SCI_FAILURE; | ||
1837 | |||
1838 | switch (scu_get_event_code(event_code)) { | ||
1839 | case SCU_EVENT_LINK_FAILURE: | ||
1840 | /* Link failure change state back to the starting state */ | ||
1841 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1842 | SCI_BASE_PHY_STATE_STARTING); | ||
1843 | result = SCI_SUCCESS; | ||
1844 | break; | ||
1845 | |||
1846 | case SCU_EVENT_BROADCAST_CHANGE: | ||
1847 | /* Broadcast change received. Notify the port. */ | ||
1848 | if (scic_sds_phy_get_port(sci_phy) != NULL) | ||
1849 | scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); | ||
1850 | else | ||
1851 | sci_phy->bcn_received_while_port_unassigned = true; | ||
1852 | break; | ||
1853 | |||
1854 | default: | ||
1855 | dev_warn(sciphy_to_dev(sci_phy), | ||
1856 | "%sP SCIC PHY 0x%p ready state machine received " | ||
1857 | "unexpected event_code %x\n", | ||
1858 | __func__, sci_phy, event_code); | ||
1859 | |||
1860 | result = SCI_FAILURE_INVALID_STATE; | ||
1861 | break; | ||
1862 | } | ||
1863 | |||
1864 | return result; | ||
1865 | } | ||
1866 | |||
1867 | static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy, | ||
1868 | u32 event_code) | ||
1869 | { | ||
1870 | enum sci_status result = SCI_FAILURE; | ||
1871 | |||
1872 | switch (scu_get_event_code(event_code)) { | ||
1873 | case SCU_EVENT_HARD_RESET_TRANSMITTED: | ||
1874 | /* Link failure change state back to the starting state */ | ||
1875 | sci_base_state_machine_change_state(&sci_phy->state_machine, | ||
1876 | SCI_BASE_PHY_STATE_STARTING); | ||
1877 | result = SCI_SUCCESS; | ||
1878 | break; | ||
1879 | |||
1880 | default: | ||
1881 | dev_warn(sciphy_to_dev(sci_phy), | ||
1882 | "%s: SCIC PHY 0x%p resetting state machine received " | ||
1883 | "unexpected event_code %x\n", | ||
1884 | __func__, sci_phy, event_code); | ||
1885 | |||
1886 | result = SCI_FAILURE_INVALID_STATE; | ||
1887 | break; | ||
1888 | } | ||
1889 | |||
1890 | return result; | ||
1891 | } | ||
1892 | |||
1893 | /* --------------------------------------------------------------------------- */ | ||
1894 | |||
1895 | static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { | ||
1896 | [SCI_BASE_PHY_STATE_INITIAL] = { | ||
1897 | .start_handler = scic_sds_phy_default_start_handler, | ||
1898 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1899 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1900 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1901 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1902 | .event_handler = scic_sds_phy_default_event_handler, | ||
1903 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1904 | }, | ||
1905 | [SCI_BASE_PHY_STATE_STOPPED] = { | ||
1906 | .start_handler = scic_sds_phy_stopped_state_start_handler, | ||
1907 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1908 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1909 | .destruct_handler = scic_sds_phy_stopped_state_destroy_handler, | ||
1910 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1911 | .event_handler = scic_sds_phy_default_event_handler, | ||
1912 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1913 | }, | ||
1914 | [SCI_BASE_PHY_STATE_STARTING] = { | ||
1915 | .start_handler = scic_sds_phy_default_start_handler, | ||
1916 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1917 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1918 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1919 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1920 | .event_handler = scic_sds_phy_default_event_handler, | ||
1921 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1922 | }, | ||
1923 | [SCI_BASE_PHY_STATE_READY] = { | ||
1924 | .start_handler = scic_sds_phy_default_start_handler, | ||
1925 | .stop_handler = scic_sds_phy_ready_state_stop_handler, | ||
1926 | .reset_handler = scic_sds_phy_ready_state_reset_handler, | ||
1927 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1928 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1929 | .event_handler = scic_sds_phy_ready_state_event_handler, | ||
1930 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1931 | }, | ||
1932 | [SCI_BASE_PHY_STATE_RESETTING] = { | ||
1933 | .start_handler = scic_sds_phy_default_start_handler, | ||
1934 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1935 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1936 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1937 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1938 | .event_handler = scic_sds_phy_resetting_state_event_handler, | ||
1939 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1940 | }, | ||
1941 | [SCI_BASE_PHY_STATE_FINAL] = { | ||
1942 | .start_handler = scic_sds_phy_default_start_handler, | ||
1943 | .stop_handler = scic_sds_phy_default_stop_handler, | ||
1944 | .reset_handler = scic_sds_phy_default_reset_handler, | ||
1945 | .destruct_handler = scic_sds_phy_default_destroy_handler, | ||
1946 | .frame_handler = scic_sds_phy_default_frame_handler, | ||
1947 | .event_handler = scic_sds_phy_default_event_handler, | ||
1948 | .consume_power_handler = scic_sds_phy_default_consume_power_handler | ||
1949 | } | ||
1950 | }; | ||
1951 | |||
1952 | /* | ||
1953 | * **************************************************************************** | ||
1954 | * * PHY STATE PRIVATE METHODS | ||
1955 | * **************************************************************************** */ | ||
1956 | |||
1957 | /** | ||
1958 | * | ||
1959 | * @sci_phy: This is the struct scic_sds_phy object to stop. | ||
1960 | * | ||
1961 | * This method will stop the struct scic_sds_phy object. This does not reset the | ||
1962 | * protocol engine it just suspends it and places it in a state where it will | ||
1963 | * not cause the end device to power up. none | ||
1964 | */ | ||
1965 | static void scu_link_layer_stop_protocol_engine( | ||
1966 | struct scic_sds_phy *sci_phy) | ||
1967 | { | ||
1968 | u32 scu_sas_pcfg_value; | ||
1969 | u32 enable_spinup_value; | ||
1970 | |||
1971 | /* Suspend the protocol engine and place it in a sata spinup hold state */ | ||
1972 | scu_sas_pcfg_value = | ||
1973 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
1974 | scu_sas_pcfg_value |= | ||
1975 | (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | | ||
1976 | SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) | | ||
1977 | SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD)); | ||
1978 | writel(scu_sas_pcfg_value, | ||
1979 | &sci_phy->link_layer_registers->phy_configuration); | ||
1980 | |||
1981 | /* Disable the notify enable spinup primitives */ | ||
1982 | enable_spinup_value = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1983 | enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE); | ||
1984 | writel(enable_spinup_value, &sci_phy->link_layer_registers->notify_enable_spinup_control); | ||
1985 | } | ||
1986 | |||
1987 | /** | ||
1988 | * | ||
1989 | * | ||
1990 | * This method will start the OOB/SN state machine for this struct scic_sds_phy object. | ||
1991 | */ | ||
1992 | static void scu_link_layer_start_oob( | ||
1993 | struct scic_sds_phy *sci_phy) | ||
1994 | { | ||
1995 | u32 scu_sas_pcfg_value; | ||
1996 | |||
1997 | scu_sas_pcfg_value = | ||
1998 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
1999 | scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | ||
2000 | scu_sas_pcfg_value &= | ||
2001 | ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | | ||
2002 | SCU_SAS_PCFG_GEN_BIT(HARD_RESET)); | ||
2003 | writel(scu_sas_pcfg_value, | ||
2004 | &sci_phy->link_layer_registers->phy_configuration); | ||
2005 | } | ||
2006 | |||
2007 | /** | ||
2008 | * | ||
2009 | * | ||
2010 | * This method will transmit a hard reset request on the specified phy. The SCU | ||
2011 | * hardware requires that we reset the OOB state machine and set the hard reset | ||
2012 | * bit in the phy configuration register. We then must start OOB over with the | ||
2013 | * hard reset bit set. | ||
2014 | */ | ||
2015 | static void scu_link_layer_tx_hard_reset( | ||
2016 | struct scic_sds_phy *sci_phy) | ||
2017 | { | ||
2018 | u32 phy_configuration_value; | ||
2019 | |||
2020 | /* | ||
2021 | * SAS Phys must wait for the HARD_RESET_TX event notification to transition | ||
2022 | * to the starting state. */ | ||
2023 | phy_configuration_value = | ||
2024 | readl(&sci_phy->link_layer_registers->phy_configuration); | ||
2025 | phy_configuration_value |= | ||
2026 | (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) | | ||
2027 | SCU_SAS_PCFG_GEN_BIT(OOB_RESET)); | ||
2028 | writel(phy_configuration_value, | ||
2029 | &sci_phy->link_layer_registers->phy_configuration); | ||
2030 | |||
2031 | /* Now take the OOB state machine out of reset */ | ||
2032 | phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); | ||
2033 | phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | ||
2034 | writel(phy_configuration_value, | ||
2035 | &sci_phy->link_layer_registers->phy_configuration); | ||
2036 | } | ||
2037 | |||
2038 | /* | ||
2039 | * **************************************************************************** | ||
2040 | * * PHY BASE STATE METHODS | ||
2041 | * **************************************************************************** */ | ||
2042 | |||
2043 | /** | ||
2044 | * | ||
2045 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2046 | * | ||
2047 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2048 | * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state | ||
2049 | * handlers for the phy object base state machine initial state. none | ||
2050 | */ | ||
2051 | static void scic_sds_phy_initial_state_enter(void *object) | ||
2052 | { | ||
2053 | struct scic_sds_phy *sci_phy = object; | ||
2054 | |||
2055 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_INITIAL); | ||
2056 | } | ||
2057 | |||
2058 | /** | ||
2059 | * | ||
2060 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2061 | * | ||
2062 | * This function will perform the actions required by the struct scic_sds_phy on | ||
2063 | * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state | ||
2064 | * handlers for the phy object base state machine initial state. - The SCU | ||
2065 | * hardware is requested to stop the protocol engine. none | ||
2066 | */ | ||
2067 | static void scic_sds_phy_stopped_state_enter(void *object) | ||
2068 | { | ||
2069 | struct scic_sds_phy *sci_phy = object; | ||
2070 | struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); | ||
2071 | struct isci_host *ihost = scic_to_ihost(scic); | ||
2072 | |||
2073 | /* | ||
2074 | * @todo We need to get to the controller to place this PE in a | ||
2075 | * reset state | ||
2076 | */ | ||
2077 | |||
2078 | scic_sds_phy_set_base_state_handlers(sci_phy, | ||
2079 | SCI_BASE_PHY_STATE_STOPPED); | ||
2080 | |||
2081 | if (sci_phy->sata_timeout_timer != NULL) { | ||
2082 | isci_del_timer(ihost, sci_phy->sata_timeout_timer); | ||
2083 | |||
2084 | sci_phy->sata_timeout_timer = NULL; | ||
2085 | } | ||
2086 | |||
2087 | scu_link_layer_stop_protocol_engine(sci_phy); | ||
2088 | |||
2089 | if (sci_phy->state_machine.previous_state_id != | ||
2090 | SCI_BASE_PHY_STATE_INITIAL) | ||
2091 | scic_sds_controller_link_down( | ||
2092 | scic_sds_phy_get_controller(sci_phy), | ||
2093 | scic_sds_phy_get_port(sci_phy), | ||
2094 | sci_phy); | ||
2095 | } | ||
2096 | |||
2097 | /** | ||
2098 | * | ||
2099 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2100 | * | ||
2101 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2102 | * entering the SCI_BASE_PHY_STATE_STARTING. - This function sets the state | ||
2103 | * handlers for the phy object base state machine starting state. - The SCU | ||
2104 | * hardware is requested to start OOB/SN on this protocl engine. - The phy | ||
2105 | * starting substate machine is started. - If the previous state was the ready | ||
2106 | * state then the struct scic_sds_controller is informed that the phy has gone link | ||
2107 | * down. none | ||
2108 | */ | ||
2109 | static void scic_sds_phy_starting_state_enter(void *object) | ||
2110 | { | ||
2111 | struct scic_sds_phy *sci_phy = object; | ||
2112 | |||
2113 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_STARTING); | ||
2114 | |||
2115 | scu_link_layer_stop_protocol_engine(sci_phy); | ||
2116 | scu_link_layer_start_oob(sci_phy); | ||
2117 | |||
2118 | /* We don't know what kind of phy we are going to be just yet */ | ||
2119 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; | ||
2120 | sci_phy->bcn_received_while_port_unassigned = false; | ||
2121 | |||
2122 | /* Change over to the starting substate machine to continue */ | ||
2123 | sci_base_state_machine_start(&sci_phy->starting_substate_machine); | ||
2124 | |||
2125 | if (sci_phy->state_machine.previous_state_id | ||
2126 | == SCI_BASE_PHY_STATE_READY) { | ||
2127 | scic_sds_controller_link_down( | ||
2128 | scic_sds_phy_get_controller(sci_phy), | ||
2129 | scic_sds_phy_get_port(sci_phy), | ||
2130 | sci_phy | ||
2131 | ); | ||
2132 | } | ||
2133 | } | ||
2134 | |||
2135 | /** | ||
2136 | * | ||
2137 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2138 | * | ||
2139 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2140 | * entering the SCI_BASE_PHY_STATE_READY. - This function sets the state | ||
2141 | * handlers for the phy object base state machine ready state. - The SCU | ||
2142 | * hardware protocol engine is resumed. - The struct scic_sds_controller is informed | ||
2143 | * that the phy object has gone link up. none | ||
2144 | */ | ||
2145 | static void scic_sds_phy_ready_state_enter(void *object) | ||
2146 | { | ||
2147 | struct scic_sds_phy *sci_phy = object; | ||
2148 | |||
2149 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_READY); | ||
2150 | |||
2151 | scic_sds_controller_link_up( | ||
2152 | scic_sds_phy_get_controller(sci_phy), | ||
2153 | scic_sds_phy_get_port(sci_phy), | ||
2154 | sci_phy | ||
2155 | ); | ||
2156 | } | ||
2157 | |||
2158 | /** | ||
2159 | * | ||
2160 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2161 | * | ||
2162 | * This method will perform the actions required by the struct scic_sds_phy on exiting | ||
2163 | * the SCI_BASE_PHY_STATE_INITIAL. This function suspends the SCU hardware | ||
2164 | * protocol engine represented by this struct scic_sds_phy object. none | ||
2165 | */ | ||
2166 | static void scic_sds_phy_ready_state_exit(void *object) | ||
2167 | { | ||
2168 | struct scic_sds_phy *sci_phy = object; | ||
2169 | |||
2170 | scic_sds_phy_suspend(sci_phy); | ||
2171 | } | ||
2172 | |||
2173 | /** | ||
2174 | * | ||
2175 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2176 | * | ||
2177 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2178 | * entering the SCI_BASE_PHY_STATE_RESETTING. - This function sets the state | ||
2179 | * handlers for the phy object base state machine resetting state. none | ||
2180 | */ | ||
2181 | static void scic_sds_phy_resetting_state_enter(void *object) | ||
2182 | { | ||
2183 | struct scic_sds_phy *sci_phy = object; | ||
2184 | |||
2185 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_RESETTING); | ||
2186 | |||
2187 | /* | ||
2188 | * The phy is being reset, therefore deactivate it from the port. | ||
2189 | * In the resetting state we don't notify the user regarding | ||
2190 | * link up and link down notifications. */ | ||
2191 | scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false); | ||
2192 | |||
2193 | if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { | ||
2194 | scu_link_layer_tx_hard_reset(sci_phy); | ||
2195 | } else { | ||
2196 | /* | ||
2197 | * The SCU does not need to have a discrete reset state so | ||
2198 | * just go back to the starting state. | ||
2199 | */ | ||
2200 | sci_base_state_machine_change_state( | ||
2201 | &sci_phy->state_machine, | ||
2202 | SCI_BASE_PHY_STATE_STARTING); | ||
2203 | } | ||
2204 | } | ||
2205 | |||
2206 | /** | ||
2207 | * | ||
2208 | * @object: This is the object which is cast to a struct scic_sds_phy object. | ||
2209 | * | ||
2210 | * This method will perform the actions required by the struct scic_sds_phy on | ||
2211 | * entering the SCI_BASE_PHY_STATE_FINAL. - This function sets the state | ||
2212 | * handlers for the phy object base state machine final state. none | ||
2213 | */ | ||
2214 | static void scic_sds_phy_final_state_enter(void *object) | ||
2215 | { | ||
2216 | struct scic_sds_phy *sci_phy = object; | ||
2217 | |||
2218 | scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_FINAL); | ||
2219 | |||
2220 | /* Nothing to do here */ | ||
2221 | } | ||
2222 | |||
2223 | /* --------------------------------------------------------------------------- */ | ||
2224 | |||
2225 | static const struct sci_base_state scic_sds_phy_state_table[] = { | ||
2226 | [SCI_BASE_PHY_STATE_INITIAL] = { | ||
2227 | .enter_state = scic_sds_phy_initial_state_enter, | ||
2228 | }, | ||
2229 | [SCI_BASE_PHY_STATE_STOPPED] = { | ||
2230 | .enter_state = scic_sds_phy_stopped_state_enter, | ||
2231 | }, | ||
2232 | [SCI_BASE_PHY_STATE_STARTING] = { | ||
2233 | .enter_state = scic_sds_phy_starting_state_enter, | ||
2234 | }, | ||
2235 | [SCI_BASE_PHY_STATE_READY] = { | ||
2236 | .enter_state = scic_sds_phy_ready_state_enter, | ||
2237 | .exit_state = scic_sds_phy_ready_state_exit, | ||
2238 | }, | ||
2239 | [SCI_BASE_PHY_STATE_RESETTING] = { | ||
2240 | .enter_state = scic_sds_phy_resetting_state_enter, | ||
2241 | }, | ||
2242 | [SCI_BASE_PHY_STATE_FINAL] = { | ||
2243 | .enter_state = scic_sds_phy_final_state_enter, | ||
2244 | }, | ||
2245 | }; | ||
2246 | |||
2247 | void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, | ||
2248 | struct scic_sds_port *owning_port, u8 phy_index) | ||
2249 | { | ||
2250 | sci_base_state_machine_construct(&sci_phy->state_machine, | ||
2251 | sci_phy, | ||
2252 | scic_sds_phy_state_table, | ||
2253 | SCI_BASE_PHY_STATE_INITIAL); | ||
2254 | |||
2255 | sci_base_state_machine_start(&sci_phy->state_machine); | ||
2256 | |||
2257 | /* Copy the rest of the input data to our locals */ | ||
2258 | sci_phy->owning_port = owning_port; | ||
2259 | sci_phy->phy_index = phy_index; | ||
2260 | sci_phy->bcn_received_while_port_unassigned = false; | ||
2261 | sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; | ||
2262 | sci_phy->link_layer_registers = NULL; | ||
2263 | sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; | ||
2264 | sci_phy->sata_timeout_timer = NULL; | ||
2265 | |||
2266 | /* Initialize the the substate machines */ | ||
2267 | sci_base_state_machine_construct(&sci_phy->starting_substate_machine, | ||
2268 | sci_phy, | ||
2269 | scic_sds_phy_starting_substates, | ||
2270 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); | ||
2271 | } | ||
65 | 2272 | ||
66 | void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) | 2273 | void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) |
67 | { | 2274 | { |
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h index 3a95adbb508c..093fd473366c 100644 --- a/drivers/scsi/isci/phy.h +++ b/drivers/scsi/isci/phy.h | |||
@@ -57,7 +57,105 @@ | |||
57 | 57 | ||
58 | #include <scsi/sas.h> | 58 | #include <scsi/sas.h> |
59 | #include <scsi/libsas.h> | 59 | #include <scsi/libsas.h> |
60 | #include "scic_sds_phy.h" | 60 | #include "state_machine.h" |
61 | |||
62 | /* This is the timeout value for the SATA phy to wait for a SIGNATURE FIS | ||
63 | * before restarting the starting state machine. Technically, the old parallel | ||
64 | * ATA specification required up to 30 seconds for a device to issue its | ||
65 | * signature FIS as a result of a soft reset. Now we see that devices respond | ||
66 | * generally within 15 seconds, but we'll use 25 for now. | ||
67 | */ | ||
68 | #define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000 | ||
69 | |||
70 | /* This is the timeout for the SATA OOB/SN because the hardware does not | ||
71 | * recognize a hot plug after OOB signal but before the SN signals. We need to | ||
72 | * make sure after a hotplug timeout if we have not received the speed event | ||
73 | * notification from the hardware that we restart the hardware OOB state | ||
74 | * machine. | ||
75 | */ | ||
76 | #define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250 | ||
77 | |||
78 | enum scic_sds_phy_protocol { | ||
79 | SCIC_SDS_PHY_PROTOCOL_UNKNOWN, | ||
80 | SCIC_SDS_PHY_PROTOCOL_SAS, | ||
81 | SCIC_SDS_PHY_PROTOCOL_SATA, | ||
82 | SCIC_SDS_MAX_PHY_PROTOCOLS | ||
83 | }; | ||
84 | |||
85 | /** | ||
86 | * struct scic_sds_phy - This structure contains or references all of the data | ||
87 | * necessary to represent the core phy object and SCU harware protocol | ||
88 | * engine. | ||
89 | * | ||
90 | * | ||
91 | */ | ||
92 | struct scic_sds_phy { | ||
93 | /** | ||
94 | * This field contains the information for the base phy state machine. | ||
95 | */ | ||
96 | struct sci_base_state_machine state_machine; | ||
97 | |||
98 | /** | ||
99 | * This field specifies the port object that owns/contains this phy. | ||
100 | */ | ||
101 | struct scic_sds_port *owning_port; | ||
102 | |||
103 | /** | ||
104 | * This field indicates whether the phy supports 1.5 Gb/s, 3.0 Gb/s, | ||
105 | * or 6.0 Gb/s operation. | ||
106 | */ | ||
107 | enum sas_linkrate max_negotiated_speed; | ||
108 | |||
109 | /** | ||
110 | * This member specifies the protocol being utilized on this phy. This | ||
111 | * field contains a legitamite value once the PHY has link trained with | ||
112 | * a remote phy. | ||
113 | */ | ||
114 | enum scic_sds_phy_protocol protocol; | ||
115 | |||
116 | /** | ||
117 | * This field specifies the index with which this phy is associated (0-3). | ||
118 | */ | ||
119 | u8 phy_index; | ||
120 | |||
121 | /** | ||
122 | * This member indicates if this particular PHY has received a BCN while | ||
123 | * it had no port assignement. This BCN will be reported once the phy is | ||
124 | * assigned to a port. | ||
125 | */ | ||
126 | bool bcn_received_while_port_unassigned; | ||
127 | |||
128 | /** | ||
129 | * This field indicates if this PHY is currently in the process of | ||
130 | * link training (i.e. it has started OOB, but has yet to perform | ||
131 | * IAF exchange/Signature FIS reception). | ||
132 | */ | ||
133 | bool is_in_link_training; | ||
134 | |||
135 | /** | ||
136 | * This field contains a reference to the timer utilized in detecting | ||
137 | * when a signature FIS timeout has occurred. The signature FIS is the | ||
138 | * first FIS sent by an attached SATA device after OOB/SN. | ||
139 | */ | ||
140 | void *sata_timeout_timer; | ||
141 | |||
142 | const struct scic_sds_phy_state_handler *state_handlers; | ||
143 | |||
144 | struct sci_base_state_machine starting_substate_machine; | ||
145 | |||
146 | /** | ||
147 | * This field is the pointer to the transport layer register for the SCU | ||
148 | * hardware. | ||
149 | */ | ||
150 | struct scu_transport_layer_registers __iomem *transport_layer_registers; | ||
151 | |||
152 | /** | ||
153 | * This field points to the link layer register set within the SCU. | ||
154 | */ | ||
155 | struct scu_link_layer_registers __iomem *link_layer_registers; | ||
156 | |||
157 | }; | ||
158 | |||
61 | 159 | ||
62 | struct isci_phy { | 160 | struct isci_phy { |
63 | struct scic_sds_phy sci; | 161 | struct scic_sds_phy sci; |
@@ -85,6 +183,480 @@ static inline struct isci_phy *sci_phy_to_iphy(struct scic_sds_phy *sci_phy) | |||
85 | return iphy; | 183 | return iphy; |
86 | } | 184 | } |
87 | 185 | ||
186 | struct scic_phy_cap { | ||
187 | union { | ||
188 | struct { | ||
189 | /* | ||
190 | * The SAS specification indicates the start bit shall | ||
191 | * always be set to | ||
192 | * 1. This implementation will have the start bit set | ||
193 | * to 0 if the PHY CAPABILITIES were either not | ||
194 | * received or speed negotiation failed. | ||
195 | */ | ||
196 | u8 start:1; | ||
197 | u8 tx_ssc_type:1; | ||
198 | u8 res1:2; | ||
199 | u8 req_logical_linkrate:4; | ||
200 | |||
201 | u32 gen1_no_ssc:1; | ||
202 | u32 gen1_ssc:1; | ||
203 | u32 gen2_no_ssc:1; | ||
204 | u32 gen2_ssc:1; | ||
205 | u32 gen3_no_ssc:1; | ||
206 | u32 gen3_ssc:1; | ||
207 | u32 res2:17; | ||
208 | u32 parity:1; | ||
209 | }; | ||
210 | u32 all; | ||
211 | }; | ||
212 | } __packed; | ||
213 | |||
214 | /* this data structure reflects the link layer transmit identification reg */ | ||
215 | struct scic_phy_proto { | ||
216 | union { | ||
217 | struct { | ||
218 | u16 _r_a:1; | ||
219 | u16 smp_iport:1; | ||
220 | u16 stp_iport:1; | ||
221 | u16 ssp_iport:1; | ||
222 | u16 _r_b:4; | ||
223 | u16 _r_c:1; | ||
224 | u16 smp_tport:1; | ||
225 | u16 stp_tport:1; | ||
226 | u16 ssp_tport:1; | ||
227 | u16 _r_d:4; | ||
228 | }; | ||
229 | u16 all; | ||
230 | }; | ||
231 | } __packed; | ||
232 | |||
233 | |||
234 | /** | ||
235 | * struct scic_phy_properties - This structure defines the properties common to | ||
236 | * all phys that can be retrieved. | ||
237 | * | ||
238 | * | ||
239 | */ | ||
240 | struct scic_phy_properties { | ||
241 | /** | ||
242 | * This field specifies the port that currently contains the | ||
243 | * supplied phy. This field may be set to NULL | ||
244 | * if the phy is not currently contained in a port. | ||
245 | */ | ||
246 | struct scic_sds_port *owning_port; | ||
247 | |||
248 | /** | ||
249 | * This field specifies the link rate at which the phy is | ||
250 | * currently operating. | ||
251 | */ | ||
252 | enum sas_linkrate negotiated_link_rate; | ||
253 | |||
254 | /** | ||
255 | * This field specifies the index of the phy in relation to other | ||
256 | * phys within the controller. This index is zero relative. | ||
257 | */ | ||
258 | u8 index; | ||
259 | }; | ||
260 | |||
261 | /** | ||
262 | * struct scic_sas_phy_properties - This structure defines the properties, | ||
263 | * specific to a SAS phy, that can be retrieved. | ||
264 | * | ||
265 | * | ||
266 | */ | ||
267 | struct scic_sas_phy_properties { | ||
268 | /** | ||
269 | * This field delineates the Identify Address Frame received | ||
270 | * from the remote end point. | ||
271 | */ | ||
272 | struct sas_identify_frame rcvd_iaf; | ||
273 | |||
274 | /** | ||
275 | * This field delineates the Phy capabilities structure received | ||
276 | * from the remote end point. | ||
277 | */ | ||
278 | struct scic_phy_cap rcvd_cap; | ||
279 | |||
280 | }; | ||
281 | |||
282 | /** | ||
283 | * struct scic_sata_phy_properties - This structure defines the properties, | ||
284 | * specific to a SATA phy, that can be retrieved. | ||
285 | * | ||
286 | * | ||
287 | */ | ||
288 | struct scic_sata_phy_properties { | ||
289 | /** | ||
290 | * This field delineates the signature FIS received from the | ||
291 | * attached target. | ||
292 | */ | ||
293 | struct dev_to_host_fis signature_fis; | ||
294 | |||
295 | /** | ||
296 | * This field specifies to the user if a port selector is connected | ||
297 | * on the specified phy. | ||
298 | */ | ||
299 | bool is_port_selector_present; | ||
300 | |||
301 | }; | ||
302 | |||
303 | /** | ||
304 | * enum scic_phy_counter_id - This enumeration depicts the various pieces of | ||
305 | * optional information that can be retrieved for a specific phy. | ||
306 | * | ||
307 | * | ||
308 | */ | ||
309 | enum scic_phy_counter_id { | ||
310 | /** | ||
311 | * This PHY information field tracks the number of frames received. | ||
312 | */ | ||
313 | SCIC_PHY_COUNTER_RECEIVED_FRAME, | ||
314 | |||
315 | /** | ||
316 | * This PHY information field tracks the number of frames transmitted. | ||
317 | */ | ||
318 | SCIC_PHY_COUNTER_TRANSMITTED_FRAME, | ||
319 | |||
320 | /** | ||
321 | * This PHY information field tracks the number of DWORDs received. | ||
322 | */ | ||
323 | SCIC_PHY_COUNTER_RECEIVED_FRAME_WORD, | ||
324 | |||
325 | /** | ||
326 | * This PHY information field tracks the number of DWORDs transmitted. | ||
327 | */ | ||
328 | SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD, | ||
329 | |||
330 | /** | ||
331 | * This PHY information field tracks the number of times DWORD | ||
332 | * synchronization was lost. | ||
333 | */ | ||
334 | SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR, | ||
335 | |||
336 | /** | ||
337 | * This PHY information field tracks the number of received DWORDs with | ||
338 | * running disparity errors. | ||
339 | */ | ||
340 | SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR, | ||
341 | |||
342 | /** | ||
343 | * This PHY information field tracks the number of received frames with a | ||
344 | * CRC error (not including short or truncated frames). | ||
345 | */ | ||
346 | SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR, | ||
347 | |||
348 | /** | ||
349 | * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT) | ||
350 | * primitives received. | ||
351 | */ | ||
352 | SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT, | ||
353 | |||
354 | /** | ||
355 | * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT) | ||
356 | * primitives transmitted. | ||
357 | */ | ||
358 | SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT, | ||
359 | |||
360 | /** | ||
361 | * This PHY information field tracks the number of times the inactivity | ||
362 | * timer for connections on the phy has been utilized. | ||
363 | */ | ||
364 | SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED, | ||
365 | |||
366 | /** | ||
367 | * This PHY information field tracks the number of DONE (CREDIT TIMEOUT) | ||
368 | * primitives received. | ||
369 | */ | ||
370 | SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT, | ||
371 | |||
372 | /** | ||
373 | * This PHY information field tracks the number of DONE (CREDIT TIMEOUT) | ||
374 | * primitives transmitted. | ||
375 | */ | ||
376 | SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT, | ||
377 | |||
378 | /** | ||
379 | * This PHY information field tracks the number of CREDIT BLOCKED | ||
380 | * primitives received. | ||
381 | * @note Depending on remote device implementation, credit blocks | ||
382 | * may occur regularly. | ||
383 | */ | ||
384 | SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED, | ||
385 | |||
386 | /** | ||
387 | * This PHY information field contains the number of short frames | ||
388 | * received. A short frame is simply a frame smaller then what is | ||
389 | * allowed by either the SAS or SATA specification. | ||
390 | */ | ||
391 | SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME, | ||
392 | |||
393 | /** | ||
394 | * This PHY information field contains the number of frames received after | ||
395 | * credit has been exhausted. | ||
396 | */ | ||
397 | SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT, | ||
398 | |||
399 | /** | ||
400 | * This PHY information field contains the number of frames received after | ||
401 | * a DONE has been received. | ||
402 | */ | ||
403 | SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE, | ||
404 | |||
405 | /** | ||
406 | * This PHY information field contains the number of times the phy | ||
407 | * failed to achieve DWORD synchronization during speed negotiation. | ||
408 | */ | ||
409 | SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR | ||
410 | }; | ||
411 | |||
412 | enum scic_sds_phy_states { | ||
413 | /** | ||
414 | * Simply the initial state for the base domain state machine. | ||
415 | */ | ||
416 | SCI_BASE_PHY_STATE_INITIAL, | ||
417 | |||
418 | /** | ||
419 | * This state indicates that the phy has successfully been stopped. | ||
420 | * In this state no new IO operations are permitted on this phy. | ||
421 | * This state is entered from the INITIAL state. | ||
422 | * This state is entered from the STARTING state. | ||
423 | * This state is entered from the READY state. | ||
424 | * This state is entered from the RESETTING state. | ||
425 | */ | ||
426 | SCI_BASE_PHY_STATE_STOPPED, | ||
427 | |||
428 | /** | ||
429 | * This state indicates that the phy is in the process of becomming | ||
430 | * ready. In this state no new IO operations are permitted on this phy. | ||
431 | * This state is entered from the STOPPED state. | ||
432 | * This state is entered from the READY state. | ||
433 | * This state is entered from the RESETTING state. | ||
434 | */ | ||
435 | SCI_BASE_PHY_STATE_STARTING, | ||
436 | |||
437 | /** | ||
438 | * This state indicates the the phy is now ready. Thus, the user | ||
439 | * is able to perform IO operations utilizing this phy as long as it | ||
440 | * is currently part of a valid port. | ||
441 | * This state is entered from the STARTING state. | ||
442 | */ | ||
443 | SCI_BASE_PHY_STATE_READY, | ||
444 | |||
445 | /** | ||
446 | * This state indicates that the phy is in the process of being reset. | ||
447 | * In this state no new IO operations are permitted on this phy. | ||
448 | * This state is entered from the READY state. | ||
449 | */ | ||
450 | SCI_BASE_PHY_STATE_RESETTING, | ||
451 | |||
452 | /** | ||
453 | * Simply the final state for the base phy state machine. | ||
454 | */ | ||
455 | SCI_BASE_PHY_STATE_FINAL, | ||
456 | }; | ||
457 | |||
458 | |||
459 | /** | ||
460 | * enum scic_sds_phy_starting_substates - | ||
461 | * | ||
462 | * | ||
463 | */ | ||
464 | enum scic_sds_phy_starting_substates { | ||
465 | /** | ||
466 | * Initial state | ||
467 | */ | ||
468 | SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL, | ||
469 | |||
470 | /** | ||
471 | * Wait state for the hardware OSSP event type notification | ||
472 | */ | ||
473 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN, | ||
474 | |||
475 | /** | ||
476 | * Wait state for the PHY speed notification | ||
477 | */ | ||
478 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN, | ||
479 | |||
480 | /** | ||
481 | * Wait state for the IAF Unsolicited frame notification | ||
482 | */ | ||
483 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF, | ||
484 | |||
485 | /** | ||
486 | * Wait state for the request to consume power | ||
487 | */ | ||
488 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER, | ||
489 | |||
490 | /** | ||
491 | * Wait state for request to consume power | ||
492 | */ | ||
493 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER, | ||
494 | |||
495 | /** | ||
496 | * Wait state for the SATA PHY notification | ||
497 | */ | ||
498 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN, | ||
499 | |||
500 | /** | ||
501 | * Wait for the SATA PHY speed notification | ||
502 | */ | ||
503 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN, | ||
504 | |||
505 | /** | ||
506 | * Wait state for the SIGNATURE FIS unsolicited frame notification | ||
507 | */ | ||
508 | SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF, | ||
509 | |||
510 | /** | ||
511 | * Exit state for this state machine | ||
512 | */ | ||
513 | SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL, | ||
514 | }; | ||
515 | |||
516 | |||
517 | |||
518 | typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *); | ||
519 | typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32); | ||
520 | typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32); | ||
521 | typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *); | ||
522 | |||
523 | struct scic_sds_phy_state_handler { | ||
524 | /** | ||
525 | * The start_handler specifies the method invoked when there is an | ||
526 | * attempt to start a phy. | ||
527 | */ | ||
528 | scic_sds_phy_handler_t start_handler; | ||
529 | |||
530 | /** | ||
531 | * The stop_handler specifies the method invoked when there is an | ||
532 | * attempt to stop a phy. | ||
533 | */ | ||
534 | scic_sds_phy_handler_t stop_handler; | ||
535 | |||
536 | /** | ||
537 | * The reset_handler specifies the method invoked when there is an | ||
538 | * attempt to reset a phy. | ||
539 | */ | ||
540 | scic_sds_phy_handler_t reset_handler; | ||
541 | |||
542 | /** | ||
543 | * The destruct_handler specifies the method invoked when attempting to | ||
544 | * destruct a phy. | ||
545 | */ | ||
546 | scic_sds_phy_handler_t destruct_handler; | ||
547 | |||
548 | /** | ||
549 | * The state handler for unsolicited frames received from the SCU hardware. | ||
550 | */ | ||
551 | scic_sds_phy_frame_handler_t frame_handler; | ||
552 | |||
553 | /** | ||
554 | * The state handler for events received from the SCU hardware. | ||
555 | */ | ||
556 | scic_sds_phy_event_handler_t event_handler; | ||
557 | |||
558 | /** | ||
559 | * The state handler for staggered spinup. | ||
560 | */ | ||
561 | scic_sds_phy_power_handler_t consume_power_handler; | ||
562 | |||
563 | }; | ||
564 | |||
565 | /** | ||
566 | * scic_sds_phy_get_index() - | ||
567 | * | ||
568 | * This macro returns the phy index for the specified phy | ||
569 | */ | ||
570 | #define scic_sds_phy_get_index(phy) \ | ||
571 | ((phy)->phy_index) | ||
572 | |||
573 | /** | ||
574 | * scic_sds_phy_get_controller() - This macro returns the controller for this | ||
575 | * phy | ||
576 | * | ||
577 | * | ||
578 | */ | ||
579 | #define scic_sds_phy_get_controller(phy) \ | ||
580 | (scic_sds_port_get_controller((phy)->owning_port)) | ||
581 | |||
582 | /** | ||
583 | * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for | ||
584 | * this phy object | ||
585 | * | ||
586 | * | ||
587 | */ | ||
588 | #define scic_sds_phy_set_state_handlers(phy, handlers) \ | ||
589 | ((phy)->state_handlers = (handlers)) | ||
590 | |||
591 | /** | ||
592 | * scic_sds_phy_set_base_state_handlers() - | ||
593 | * | ||
594 | * This macro set the base state handlers for the phy object. | ||
595 | */ | ||
596 | #define scic_sds_phy_set_base_state_handlers(phy, state_id) \ | ||
597 | scic_sds_phy_set_state_handlers(\ | ||
598 | (phy), \ | ||
599 | &scic_sds_phy_state_handler_table[(state_id)] \ | ||
600 | ) | ||
601 | |||
602 | void scic_sds_phy_construct( | ||
603 | struct scic_sds_phy *this_phy, | ||
604 | struct scic_sds_port *owning_port, | ||
605 | u8 phy_index); | ||
606 | |||
607 | struct scic_sds_port *scic_sds_phy_get_port( | ||
608 | struct scic_sds_phy *this_phy); | ||
609 | |||
610 | void scic_sds_phy_set_port( | ||
611 | struct scic_sds_phy *this_phy, | ||
612 | struct scic_sds_port *owning_port); | ||
613 | |||
614 | enum sci_status scic_sds_phy_initialize( | ||
615 | struct scic_sds_phy *this_phy, | ||
616 | struct scu_transport_layer_registers __iomem *transport_layer_registers, | ||
617 | struct scu_link_layer_registers __iomem *link_layer_registers); | ||
618 | |||
619 | enum sci_status scic_sds_phy_start( | ||
620 | struct scic_sds_phy *this_phy); | ||
621 | |||
622 | enum sci_status scic_sds_phy_stop( | ||
623 | struct scic_sds_phy *this_phy); | ||
624 | |||
625 | enum sci_status scic_sds_phy_reset( | ||
626 | struct scic_sds_phy *this_phy); | ||
627 | |||
628 | void scic_sds_phy_resume( | ||
629 | struct scic_sds_phy *this_phy); | ||
630 | |||
631 | void scic_sds_phy_setup_transport( | ||
632 | struct scic_sds_phy *this_phy, | ||
633 | u32 device_id); | ||
634 | |||
635 | enum sci_status scic_sds_phy_event_handler( | ||
636 | struct scic_sds_phy *this_phy, | ||
637 | u32 event_code); | ||
638 | |||
639 | enum sci_status scic_sds_phy_frame_handler( | ||
640 | struct scic_sds_phy *this_phy, | ||
641 | u32 frame_index); | ||
642 | |||
643 | enum sci_status scic_sds_phy_consume_power_handler( | ||
644 | struct scic_sds_phy *this_phy); | ||
645 | |||
646 | void scic_sds_phy_get_sas_address( | ||
647 | struct scic_sds_phy *this_phy, | ||
648 | struct sci_sas_address *sas_address); | ||
649 | |||
650 | void scic_sds_phy_get_attached_sas_address( | ||
651 | struct scic_sds_phy *this_phy, | ||
652 | struct sci_sas_address *sas_address); | ||
653 | |||
654 | struct scic_phy_proto; | ||
655 | void scic_sds_phy_get_protocols( | ||
656 | struct scic_sds_phy *sci_phy, | ||
657 | struct scic_phy_proto *protocols); | ||
658 | enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy); | ||
659 | |||
88 | struct isci_host; | 660 | struct isci_host; |
89 | void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index); | 661 | void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index); |
90 | int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf); | 662 | int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf); |
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index d4bf6d2d8c9b..321935d9560b 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -55,8 +55,6 @@ | |||
55 | 55 | ||
56 | #include <linux/workqueue.h> | 56 | #include <linux/workqueue.h> |
57 | #include "isci.h" | 57 | #include "isci.h" |
58 | #include "scic_phy.h" | ||
59 | #include "scic_sds_phy.h" | ||
60 | #include "scic_port.h" | 58 | #include "scic_port.h" |
61 | #include "port.h" | 59 | #include "port.h" |
62 | #include "request.h" | 60 | #include "request.h" |
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index 23390102514f..2baa215cb275 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -57,9 +57,7 @@ | |||
57 | #include "port.h" | 57 | #include "port.h" |
58 | #include "remote_device.h" | 58 | #include "remote_device.h" |
59 | #include "request.h" | 59 | #include "request.h" |
60 | #include "scic_phy.h" | ||
61 | #include "scic_port.h" | 60 | #include "scic_port.h" |
62 | #include "scic_sds_phy.h" | ||
63 | #include "scic_sds_port.h" | 61 | #include "scic_sds_port.h" |
64 | #include "remote_node_context.h" | 62 | #include "remote_node_context.h" |
65 | #include "scu_event_codes.h" | 63 | #include "scu_event_codes.h" |