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