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