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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __FBSDID("$FreeBSD$");
59 * @brief This file contains the implementation of the SCIC_SDS_PHY public and
63 #include <dev/isci/scil/scic_user_callback.h>
64 #include <dev/isci/scil/scic_phy.h>
65 #include <dev/isci/scil/scic_sds_phy.h>
66 #include <dev/isci/scil/scic_sds_port.h>
67 #include <dev/isci/scil/scic_sds_controller_registers.h>
68 #include <dev/isci/scil/scic_sds_phy_registers.h>
69 #include <dev/isci/scil/scic_sds_logger.h>
70 #include <dev/isci/scil/scic_sds_remote_node_context.h>
71 #include <dev/isci/scil/sci_util.h>
72 #include <dev/isci/scil/scic_sds_controller.h>
73 #include <dev/isci/scil/scu_event_codes.h>
74 #include <dev/isci/scil/sci_base_state.h>
75 #include <dev/isci/scil/intel_ata.h>
76 #include <dev/isci/scil/intel_sata.h>
77 #include <dev/isci/scil/sci_base_state_machine.h>
78 #include <dev/isci/scil/scic_sds_port_registers.h>
80 #define SCIC_SDS_PHY_MIN_TIMER_COUNT (SCI_MAX_PHYS)
81 #define SCIC_SDS_PHY_MAX_TIMER_COUNT (SCI_MAX_PHYS)
83 // Maximum arbitration wait time in micro-seconds
84 #define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
86 #define AFE_REGISTER_WRITE_DELAY 10
88 //*****************************************************************************
89 //* SCIC SDS PHY Internal Methods
90 //*****************************************************************************
93 * @brief This method will initialize the phy transport layer registers
96 * @param[in] transport_layer_registers
101 SCI_STATUS scic_sds_phy_transport_layer_initialization(
102 SCIC_SDS_PHY_T *this_phy,
103 SCU_TRANSPORT_LAYER_REGISTERS_T *transport_layer_registers
109 sci_base_object_get_logger(this_phy),
111 "scic_sds_phy_link_layer_initialization(this_phy:0x%x, link_layer_registers:0x%x)\n",
112 this_phy, transport_layer_registers
115 this_phy->transport_layer_registers = transport_layer_registers;
117 SCU_STPTLDARNI_WRITE(this_phy, SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
119 // Hardware team recommends that we enable the STP prefetch for all transports
120 tl_control = SCU_TLCR_READ(this_phy);
121 tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH);
122 SCU_TLCR_WRITE(this_phy, tl_control);
128 * @brief This method will initialize the phy link layer registers
130 * @param[in] this_phy
131 * @param[in] link_layer_registers
136 SCI_STATUS scic_sds_phy_link_layer_initialization(
137 SCIC_SDS_PHY_T *this_phy,
138 SCU_LINK_LAYER_REGISTERS_T *link_layer_registers
141 U32 phy_configuration;
142 SAS_CAPABILITIES_T phy_capabilities;
143 U32 parity_check = 0;
144 U32 parity_count = 0;
145 U32 link_layer_control;
146 U32 phy_timer_timeout_values;
150 sci_base_object_get_logger(this_phy),
152 "scic_sds_phy_link_layer_initialization(this_phy:0x%x, link_layer_registers:0x%x)\n",
153 this_phy, link_layer_registers
156 this_phy->link_layer_registers = link_layer_registers;
158 // Set our IDENTIFY frame data
159 #define SCI_END_DEVICE 0x01
163 ( SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR)
164 | SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR)
165 | SCU_SAS_TIID_GEN_BIT(STP_INITIATOR)
166 | SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST)
167 | SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE) )
170 // Write the device SAS Address
171 SCU_SAS_TIDNH_WRITE(this_phy, 0xFEDCBA98);
172 SCU_SAS_TIDNL_WRITE(this_phy, this_phy->phy_index);
174 // Write the source SAS Address
175 SCU_SAS_TISSAH_WRITE(
177 this_phy->owning_port->owning_controller->oem_parameters.sds1.phys[
178 this_phy->phy_index].sas_address.sci_format.high
180 SCU_SAS_TISSAL_WRITE(
182 this_phy->owning_port->owning_controller->oem_parameters.sds1.phys[
183 this_phy->phy_index].sas_address.sci_format.low
186 // Clear and Set the PHY Identifier
187 SCU_SAS_TIPID_WRITE(this_phy, 0x00000000);
188 SCU_SAS_TIPID_WRITE(this_phy, SCU_SAS_TIPID_GEN_VALUE(ID, this_phy->phy_index));
190 // Change the initial state of the phy configuration register
191 phy_configuration = SCU_SAS_PCFG_READ(this_phy);
193 // Hold OOB state machine in reset
194 phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
195 SCU_SAS_PCFG_WRITE(this_phy, phy_configuration);
197 // Configure the SNW capabilities
198 phy_capabilities.u.all = 0;
199 phy_capabilities.u.bits.start = 1;
200 phy_capabilities.u.bits.gen3_without_ssc_supported = 1;
201 phy_capabilities.u.bits.gen2_without_ssc_supported = 1;
202 phy_capabilities.u.bits.gen1_without_ssc_supported = 1;
205 * Set up SSC settings according to version of OEM Parameters.
208 U8 header_version, enable_sata, enable_sas,
209 sata_spread, sas_type, sas_spread;
210 OEM_SSC_PARAMETERS_T ssc;
212 header_version = this_phy->owning_port->owning_controller->
213 oem_parameters_version;
215 ssc.bf.ssc_sata_tx_spread_level =
216 this_phy->owning_port->owning_controller->oem_parameters.sds1.controller.ssc_sata_tx_spread_level;
217 ssc.bf.ssc_sas_tx_spread_level =
218 this_phy->owning_port->owning_controller->oem_parameters.sds1.controller.ssc_sas_tx_spread_level;
219 ssc.bf.ssc_sas_tx_type =
220 this_phy->owning_port->owning_controller->oem_parameters.sds1.controller.ssc_sas_tx_type;
221 enable_sata = enable_sas = sata_spread = sas_type = sas_spread = 0;
223 if (header_version == SCI_OEM_PARAM_VER_1_0)
226 * Version 1.0 is merely turning SSC on to default values.;
228 if (ssc.do_enable_ssc != 0)
230 enable_sas = enable_sata = TRUE;
231 sas_type = 0x0; // Downspreading
232 sata_spread = 0x2; // +0 to -1419 PPM
233 sas_spread = 0x2; // +0 to -1419 PPM
236 else // header_version >= SCI_OEM_PARAM_VER_1_1
239 * Version 1.1 can turn on SAS and SATA independently and
240 * specify spread levels. Also can specify spread type for SAS.
242 if ((sata_spread = ssc.bf.ssc_sata_tx_spread_level) != 0)
243 enable_sata = TRUE; // Downspreading only
244 if ((sas_spread = ssc.bf.ssc_sas_tx_spread_level) != 0)
247 sas_type = ssc.bf.ssc_sas_tx_type;
251 if (enable_sas == TRUE)
253 U32 reg_val = scu_afe_register_read(
254 this_phy->owning_port->owning_controller,
255 scu_afe_xcvr[this_phy->phy_index].
257 reg_val |= (0x00100000 | (((U32)sas_type) << 19));
258 scu_afe_register_write(
259 this_phy->owning_port->owning_controller,
260 scu_afe_xcvr[this_phy->phy_index].afe_xcvr_control0,
263 reg_val = scu_afe_register_read(
264 this_phy->owning_port->owning_controller,
265 scu_afe_xcvr[this_phy->phy_index].
267 reg_val |= (((U32)(sas_spread)) << 8);
268 scu_afe_register_write(
269 this_phy->owning_port->owning_controller,
270 scu_afe_xcvr[this_phy->phy_index].afe_tx_ssc_control,
272 phy_capabilities.u.bits.gen3_with_ssc_supported = 1;
273 phy_capabilities.u.bits.gen2_with_ssc_supported = 1;
274 phy_capabilities.u.bits.gen1_with_ssc_supported = 1;
277 if (enable_sata == TRUE)
279 U32 reg_val = scu_afe_register_read(
280 this_phy->owning_port->owning_controller,
281 scu_afe_xcvr[this_phy->phy_index].
283 reg_val |= (U32)sata_spread;
284 scu_afe_register_write(
285 this_phy->owning_port->owning_controller,
286 scu_afe_xcvr[this_phy->phy_index].afe_tx_ssc_control,
289 reg_val = scu_link_layer_register_read(
292 reg_val |= (U32)(1 << 12);
293 scu_link_layer_register_write(
300 // The SAS specification indicates that the phy_capabilities that
301 // are transmitted shall have an even parity. Calculate the parity.
302 parity_check = phy_capabilities.u.all;
303 while (parity_check != 0)
305 if (parity_check & 0x1)
310 // If parity indicates there are an odd number of bits set, then
311 // set the parity bit to 1 in the phy capabilities.
312 if ((parity_count % 2) != 0)
313 phy_capabilities.u.bits.parity = 1;
315 SCU_SAS_PHYCAP_WRITE(this_phy, phy_capabilities.u.all);
317 // Set the enable spinup period but disable the ability to send notify enable spinup
318 SCU_SAS_ENSPINUP_WRITE(
320 SCU_ENSPINUP_GEN_VAL(
322 this_phy->owning_port->owning_controller->user_parameters.sds1.
323 phys[this_phy->phy_index].notify_enable_spin_up_insertion_frequency
327 // Write the ALIGN Insertion Ferequency for connected phy and inpendent of connected state
328 clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL (
330 this_phy->owning_port->owning_controller->user_parameters.sds1.
331 phys[this_phy->phy_index].in_connection_align_insertion_frequency
334 clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL (
336 this_phy->owning_port->owning_controller->user_parameters.sds1.
337 phys[this_phy->phy_index].align_insertion_frequency
340 SCU_SAS_CLKSM_WRITE ( this_phy, clksm_value);
343 #if defined(PBG_HBA_A0_BUILD) || defined(PBG_HBA_A2_BUILD) || defined(PBG_HBA_BETA_BUILD)
344 /// @todo Provide a way to write this register correctly
345 scu_link_layer_register_write(this_phy, afe_lookup_table_control, 0x02108421);
346 #elif defined(PBG_BUILD)
348 (this_phy->owning_port->owning_controller->pci_revision == SCIC_SDS_PCI_REVISION_C0)
349 || (this_phy->owning_port->owning_controller->pci_revision == SCIC_SDS_PCI_REVISION_C1)
352 scu_link_layer_register_write(this_phy, afe_lookup_table_control, 0x04210400);
353 scu_link_layer_register_write(this_phy, sas_primitive_timeout, 0x20A7C05);
357 scu_link_layer_register_write(this_phy, afe_lookup_table_control, 0x02108421);
360 /// @todo Provide a way to write this register correctly
361 scu_link_layer_register_write(this_phy, afe_lookup_table_control, 0x0e739ce7);
364 link_layer_control = SCU_SAS_LLCTL_GEN_VAL(
365 NO_OUTBOUND_TASK_TIMEOUT,
366 (U8) this_phy->owning_port->owning_controller->
367 user_parameters.sds1.no_outbound_task_timeout
370 #if PHY_MAX_LINK_SPEED_GENERATION == SCIC_SDS_PARM_GEN1_SPEED
371 #define COMPILED_MAX_LINK_RATE SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1
372 #elif PHY_MAX_LINK_SPEED_GENERATION == SCIC_SDS_PARM_GEN2_SPEED
373 #define COMPILED_MAX_LINK_RATE SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2
375 #define COMPILED_MAX_LINK_RATE SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3
376 #endif // PHY_MAX_LINK_SPEED_GENERATION
378 if (this_phy->owning_port->owning_controller->user_parameters.sds1.
379 phys[this_phy->phy_index].max_speed_generation == SCIC_SDS_PARM_GEN3_SPEED)
381 link_layer_control |= SCU_SAS_LLCTL_GEN_VAL(
382 MAX_LINK_RATE, COMPILED_MAX_LINK_RATE
385 else if (this_phy->owning_port->owning_controller->user_parameters.sds1.
386 phys[this_phy->phy_index].max_speed_generation == SCIC_SDS_PARM_GEN2_SPEED)
388 link_layer_control |= SCU_SAS_LLCTL_GEN_VAL(
391 SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2,
392 COMPILED_MAX_LINK_RATE)
397 link_layer_control |= SCU_SAS_LLCTL_GEN_VAL(
400 SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1,
401 COMPILED_MAX_LINK_RATE)
405 scu_link_layer_register_write(
406 this_phy, link_layer_control, link_layer_control
409 phy_timer_timeout_values = scu_link_layer_register_read(
411 phy_timer_timeout_values
414 // Clear the default 0x36 (54us) RATE_CHANGE timeout value.
415 phy_timer_timeout_values &= ~SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0xFF);
417 // Set RATE_CHANGE timeout value to 0x3B (59us). This ensures SCU can
418 // lock with 3Gb drive when SCU max rate is set to 1.5Gb.
419 phy_timer_timeout_values |= SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0x3B);
421 scu_link_layer_register_write(
422 this_phy, phy_timer_timeout_values, phy_timer_timeout_values
425 // Program the max ARB time for the PHY to 700us so we inter-operate with
426 // the PMC expander which shuts down PHYs if the expander PHY generates too
427 // many breaks. This time value will guarantee that the initiator PHY will
428 // generate the break.
429 #if defined(PBG_HBA_A0_BUILD) || defined(PBG_HBA_A2_BUILD)
430 scu_link_layer_register_write(
432 maximum_arbitration_wait_timer_timeout,
433 SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME
435 #endif // defined(PBG_HBA_A0_BUILD) || defined(PBG_HBA_A2_BUILD)
437 // Disable the link layer hang detection timer
438 scu_link_layer_register_write(
439 this_phy, link_layer_hang_detection_timeout, 0x00000000
442 // We can exit the initial state to the stopped state
443 sci_base_state_machine_change_state(
444 scic_sds_phy_get_base_state_machine(this_phy),
445 SCI_BASE_PHY_STATE_STOPPED
452 * This function will handle the sata SIGNATURE FIS timeout condition. It
453 * will restart the starting substate machine since we dont know what has
454 * actually happening.
456 * @param[in] cookie This object is cast to the SCIC_SDS_PHY_T object.
460 void scic_sds_phy_sata_timeout( SCI_OBJECT_HANDLE_T cookie)
462 SCIC_SDS_PHY_T * this_phy = (SCIC_SDS_PHY_T *)cookie;
465 sci_base_object_get_logger(this_phy),
467 "SCIC SDS Phy 0x%x did not receive signature fis before timeout.\n",
471 sci_base_state_machine_stop(
472 scic_sds_phy_get_starting_substate_machine(this_phy));
474 sci_base_state_machine_change_state(
475 scic_sds_phy_get_base_state_machine(this_phy),
476 SCI_BASE_PHY_STATE_STARTING
480 //*****************************************************************************
481 //* SCIC SDS PHY External Methods
482 //*****************************************************************************
485 * @brief This method returns the object size for a phy object.
489 U32 scic_sds_phy_get_object_size(void)
491 return sizeof(SCIC_SDS_PHY_T);
495 * @brief This method returns the minimum number of timers required for a
500 U32 scic_sds_phy_get_min_timer_count(void)
502 return SCIC_SDS_PHY_MIN_TIMER_COUNT;
506 * @brief This method returns the maximum number of timers required for a
511 U32 scic_sds_phy_get_max_timer_count(void)
513 return SCIC_SDS_PHY_MAX_TIMER_COUNT;
518 void scic_sds_phy_initialize_state_logging(
519 SCIC_SDS_PHY_T *this_phy
522 sci_base_state_machine_logger_initialize(
523 &this_phy->parent.state_machine_logger,
524 &this_phy->parent.state_machine,
525 &this_phy->parent.parent,
526 scic_cb_logger_log_states,
527 "SCIC_SDS_PHY_T", "base state machine",
531 sci_base_state_machine_logger_initialize(
532 &this_phy->starting_substate_machine_logger,
533 &this_phy->starting_substate_machine,
534 &this_phy->parent.parent,
535 scic_cb_logger_log_states,
536 "SCIC_SDS_PHY_T", "starting substate machine",
540 #endif // SCI_LOGGING
542 #ifdef SCIC_DEBUG_ENABLED
544 * Debug code to record the state transitions in the phy
546 * @param our_observer
547 * @param the_state_machine
549 void scic_sds_phy_observe_state_change(
550 SCI_BASE_OBSERVER_T * our_observer,
551 SCI_BASE_SUBJECT_T * the_subject
554 SCIC_SDS_PHY_T *this_phy;
555 SCI_BASE_STATE_MACHINE_T *the_state_machine;
557 U8 transition_requestor;
559 U32 starting_substate_id;
561 the_state_machine = (SCI_BASE_STATE_MACHINE_T *)the_subject;
562 this_phy = (SCIC_SDS_PHY_T *)the_state_machine->state_machine_owner;
564 if (the_state_machine == &this_phy->parent.state_machine)
566 transition_requestor = 0x01;
568 else if (the_state_machine == &this_phy->starting_substate_machine)
570 transition_requestor = 0x02;
574 transition_requestor = 0xFF;
578 sci_base_state_machine_get_state(&this_phy->parent.state_machine);
579 starting_substate_id =
580 sci_base_state_machine_get_state(&this_phy->starting_substate_machine);
582 this_phy->state_record.state_transition_table[
583 this_phy->state_record.index++] = ( (transition_requestor << 24)
584 | ((U8)base_state_id << 8)
585 | ((U8)starting_substate_id));
587 this_phy->state_record.index =
588 this_phy->state_record.index & (MAX_STATE_TRANSITION_RECORD - 1);
591 #endif // SCIC_DEBUG_ENABLED
593 #ifdef SCIC_DEBUG_ENABLED
595 * This method initializes the state record debug information for the phy
598 * @pre The state machines for the phy object must be constructed before this
599 * function is called.
601 * @param this_phy The phy which is being initialized.
603 void scic_sds_phy_initialize_state_recording(
604 SCIC_SDS_PHY_T *this_phy
607 this_phy->state_record.index = 0;
609 sci_base_observer_initialize(
610 &this_phy->state_record.base_state_observer,
611 scic_sds_phy_observe_state_change,
612 &this_phy->parent.state_machine.parent
615 sci_base_observer_initialize(
616 &this_phy->state_record.starting_state_observer,
617 scic_sds_phy_observe_state_change,
618 &this_phy->starting_substate_machine.parent
621 #endif // SCIC_DEBUG_ENABLED
624 * @brief This method will construct the SCIC_SDS_PHY object
626 * @param[in] this_phy
627 * @param[in] owning_port
628 * @param[in] phy_index
632 void scic_sds_phy_construct(
633 SCIC_SDS_PHY_T *this_phy,
634 SCIC_SDS_PORT_T *owning_port,
638 // Call the base constructor first
639 // Copy the logger from the port (this could be the dummy port)
640 sci_base_phy_construct(
642 sci_base_object_get_logger(owning_port),
643 scic_sds_phy_state_table
646 // Copy the rest of the input data to our locals
647 this_phy->owning_port = owning_port;
648 this_phy->phy_index = phy_index;
649 this_phy->bcn_received_while_port_unassigned = FALSE;
650 this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
651 this_phy->link_layer_registers = NULL;
652 this_phy->max_negotiated_speed = SCI_SAS_NO_LINK_RATE;
653 this_phy->sata_timeout_timer = NULL;
655 // Clear out the identification buffer data
656 memset(&this_phy->phy_type, 0, sizeof(this_phy->phy_type));
658 // Clear out the error counter data
659 memset(this_phy->error_counter, 0, sizeof(this_phy->error_counter));
661 // Initialize the substate machines
662 sci_base_state_machine_construct(
663 &this_phy->starting_substate_machine,
664 &this_phy->parent.parent,
665 scic_sds_phy_starting_substates,
666 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL
670 scic_sds_phy_initialize_state_logging(this_phy);
671 #endif // SCI_LOGGING
673 #ifdef SCIC_DEBUG_ENABLED
674 scic_sds_phy_initialize_state_recording(this_phy);
675 #endif // SCIC_DEBUG_ENABLED
679 * @brief This method returns the port currently containing this phy.
680 * If the phy is currently contained by the dummy port, then
681 * the phy is considered to not be part of a port.
683 * @param[in] this_phy This parameter specifies the phy for which to
684 * retrieve the containing port.
686 * @return This method returns a handle to a port that contains
688 * @retval SCI_INVALID_HANDLE This value is returned if the phy is not
689 * part of a real port (i.e. it's contained in the dummy port).
690 * @retval !SCI_INVALID_HANDLE All other values indicate a handle/pointer
691 * to the port containing the phy.
693 SCI_PORT_HANDLE_T scic_sds_phy_get_port(
694 SCIC_SDS_PHY_T *this_phy
698 sci_base_object_get_logger(this_phy),
700 "scic_phy_get_port(0x%x) enter\n",
704 if (scic_sds_port_get_index(this_phy->owning_port) == SCIC_SDS_DUMMY_PORT)
705 return SCI_INVALID_HANDLE;
707 return this_phy->owning_port;
711 * @brief This method will assign a port to the phy object.
713 * @param[in, out] this_phy This parameter specifies the phy for which
714 * to assign a port object.
715 * @param[in] the_port This parameter is the port to assing to the phy.
717 void scic_sds_phy_set_port(
718 SCIC_SDS_PHY_T * this_phy,
719 SCIC_SDS_PORT_T * the_port
722 this_phy->owning_port = the_port;
724 if (this_phy->bcn_received_while_port_unassigned)
726 this_phy->bcn_received_while_port_unassigned = FALSE;
727 scic_sds_port_broadcast_change_received(this_phy->owning_port, this_phy);
732 * @brief This method will initialize the constructed phy
734 * @param[in] this_phy
735 * @param[in] link_layer_registers
739 SCI_STATUS scic_sds_phy_initialize(
740 SCIC_SDS_PHY_T *this_phy,
741 void *transport_layer_registers,
742 SCU_LINK_LAYER_REGISTERS_T *link_layer_registers
746 sci_base_object_get_logger(this_phy),
748 "scic_sds_phy_initialize(this_phy:0x%x, link_layer_registers:0x%x)\n",
749 this_phy, link_layer_registers
752 // Perfrom the initialization of the TL hardware
753 scic_sds_phy_transport_layer_initialization(this_phy, transport_layer_registers);
755 // Perofrm the initialization of the PE hardware
756 scic_sds_phy_link_layer_initialization(this_phy, link_layer_registers);
758 // There is nothing that needs to be done in this state just
759 // transition to the stopped state.
760 sci_base_state_machine_change_state(
761 scic_sds_phy_get_base_state_machine(this_phy),
762 SCI_BASE_PHY_STATE_STOPPED
769 * This method assigns the direct attached device ID for this phy.
771 * @param[in] this_phy The phy for which the direct attached device id is to
773 * @param[in] device_id The direct attached device ID to assign to the phy.
774 * This will either be the RNi for the device or an invalid RNi if there
775 * is no current device assigned to the phy.
777 void scic_sds_phy_setup_transport(
778 SCIC_SDS_PHY_T * this_phy,
784 SCU_STPTLDARNI_WRITE(this_phy, device_id);
786 // The read should guarntee that the first write gets posted
787 // before the next write
788 tl_control = SCU_TLCR_READ(this_phy);
789 tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE);
790 SCU_TLCR_WRITE(this_phy, tl_control);
794 * This function will perform the register reads/writes to suspend the SCU
795 * hardware protocol engine.
797 * @param[in,out] this_phy The phy object to be suspended.
801 void scic_sds_phy_suspend(
802 SCIC_SDS_PHY_T * this_phy
805 U32 scu_sas_pcfg_value;
807 scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy);
808 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
809 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
811 scic_sds_phy_setup_transport(
812 this_phy, SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
817 * This function will perform the register reads/writes required to resume the
818 * SCU hardware protocol engine.
820 * @param[in,out] this_phy The phy object to resume.
824 void scic_sds_phy_resume(
825 SCIC_SDS_PHY_T * this_phy
828 U32 scu_sas_pcfg_value;
830 scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy);
832 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
834 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
838 * @brief This method returns the local sas address assigned to this phy.
840 * @param[in] this_phy This parameter specifies the phy for which
841 * to retrieve the local SAS address.
842 * @param[out] sas_address This parameter specifies the location into
843 * which to copy the local SAS address.
847 void scic_sds_phy_get_sas_address(
848 SCIC_SDS_PHY_T *this_phy,
849 SCI_SAS_ADDRESS_T *sas_address
853 sci_base_object_get_logger(this_phy),
855 "scic_sds_phy_get_sas_address(this_phy:0x%x, sas_address:0x%x)\n",
856 this_phy, sas_address
859 sas_address->high = SCU_SAS_TISSAH_READ(this_phy);
860 sas_address->low = SCU_SAS_TISSAL_READ(this_phy);
864 * @brief This method returns the remote end-point (i.e. attached)
865 * sas address assigned to this phy.
867 * @param[in] this_phy This parameter specifies the phy for which
868 * to retrieve the remote end-point SAS address.
869 * @param[out] sas_address This parameter specifies the location into
870 * which to copy the remote end-point SAS address.
874 void scic_sds_phy_get_attached_sas_address(
875 SCIC_SDS_PHY_T *this_phy,
876 SCI_SAS_ADDRESS_T *sas_address
880 sci_base_object_get_logger(this_phy),
882 "scic_sds_phy_get_attached_sas_address(0x%x, 0x%x) enter\n",
883 this_phy, sas_address
887 = this_phy->phy_type.sas.identify_address_frame_buffer.sas_address.high;
889 = this_phy->phy_type.sas.identify_address_frame_buffer.sas_address.low;
893 * @brief This method returns the supported protocols assigned to
896 * @param[in] this_phy
897 * @param[out] protocols
899 void scic_sds_phy_get_protocols(
900 SCIC_SDS_PHY_T *this_phy,
901 SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T * protocols
904 U32 tiid_value = SCU_SAS_TIID_READ(this_phy);
906 //Check each bit of this register. please refer to
907 //SAS Transmit Identification Register (SAS_TIID).
908 if (tiid_value & 0x2)
909 protocols->u.bits.smp_target = 1;
911 if (tiid_value & 0x4)
912 protocols->u.bits.stp_target = 1;
914 if (tiid_value & 0x8)
915 protocols->u.bits.ssp_target = 1;
917 if (tiid_value & 0x200)
918 protocols->u.bits.smp_initiator = 1;
920 if ((tiid_value & 0x400))
921 protocols->u.bits.stp_initiator = 1;
923 if (tiid_value & 0x800)
924 protocols->u.bits.ssp_initiator = 1;
927 sci_base_object_get_logger(this_phy),
929 "scic_sds_phy_get_protocols(this_phy:0x%x, protocols:0x%x)\n",
930 this_phy, protocols->u.all
935 * This method returns the supported protocols for the attached phy. If this
936 * is a SAS phy the protocols are returned from the identify address frame.
937 * If this is a SATA phy then protocols are made up and the target phy is an
940 * @note The caller will get the entire set of bits for the protocol value.
942 * @param[in] this_phy The parameter is the phy object for which the attached
943 * phy protcols are to be returned.
944 * @param[out] protocols The parameter is the returned protocols for the
947 void scic_sds_phy_get_attached_phy_protocols(
948 SCIC_SDS_PHY_T *this_phy,
949 SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T * protocols
953 sci_base_object_get_logger(this_phy),
955 "scic_sds_phy_get_attached_phy_protocols(this_phy:0x%x, protocols:0x%x[0x%x])\n",
956 this_phy, protocols, protocols->u.all
959 protocols->u.all = 0;
961 if (this_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS)
964 this_phy->phy_type.sas.identify_address_frame_buffer.protocols.u.all;
966 else if (this_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA)
968 protocols->u.bits.stp_target = 1;
974 * @brief This method release resources in for a scic phy.
976 * @param[in] controller This parameter specifies the core controller, one of
977 * its phy's resources are to be released.
978 * @param[in] this_phy This parameter specifies the phy whose resourse is to
981 void scic_sds_phy_release_resource(
982 SCIC_SDS_CONTROLLER_T * controller,
983 SCIC_SDS_PHY_T * this_phy
987 sci_base_object_get_logger(this_phy),
989 "scic_sds_phy_release_resource(0x%x, 0x%x)\n",
993 //Currently, the only resource to be released is a timer.
994 if (this_phy->sata_timeout_timer != NULL)
996 scic_cb_timer_destroy(controller, this_phy->sata_timeout_timer);
997 this_phy->sata_timeout_timer = NULL;
1002 //*****************************************************************************
1003 //* SCIC SDS PHY Handler Redirects
1004 //*****************************************************************************
1007 * @brief This method will attempt to reset the phy. This
1008 * request is only valid when the phy is in an ready
1011 * @param[in] this_phy
1013 * @return SCI_STATUS
1015 SCI_STATUS scic_sds_phy_reset(
1016 SCIC_SDS_PHY_T * this_phy
1020 sci_base_object_get_logger(this_phy),
1021 SCIC_LOG_OBJECT_PHY,
1022 "scic_sds_phy_reset(this_phy:0x%08x)\n",
1026 return this_phy->state_handlers->parent.reset_handler(
1032 * @brief This method will process the event code recieved.
1034 * @param[in] this_phy
1035 * @param[in] event_code
1037 * @return SCI_STATUS
1039 SCI_STATUS scic_sds_phy_event_handler(
1040 SCIC_SDS_PHY_T *this_phy,
1045 sci_base_object_get_logger(this_phy),
1046 SCIC_LOG_OBJECT_PHY,
1047 "scic_sds_phy_event_handler(this_phy:0x%08x, event_code:%x)\n",
1048 this_phy, event_code
1051 return this_phy->state_handlers->event_handler(this_phy, event_code);
1055 * @brief This method will process the frame index recieved.
1057 * @param[in] this_phy
1058 * @param[in] frame_index
1060 * @return SCI_STATUS
1062 SCI_STATUS scic_sds_phy_frame_handler(
1063 SCIC_SDS_PHY_T *this_phy,
1068 sci_base_object_get_logger(this_phy),
1069 SCIC_LOG_OBJECT_PHY,
1070 "scic_sds_phy_frame_handler(this_phy:0x%08x, frame_index:%d)\n",
1071 this_phy, frame_index
1074 return this_phy->state_handlers->frame_handler(this_phy, frame_index);
1078 * @brief This method will give the phy permission to consume power
1080 * @param[in] this_phy
1082 * @return SCI_STATUS
1084 SCI_STATUS scic_sds_phy_consume_power_handler(
1085 SCIC_SDS_PHY_T *this_phy
1089 sci_base_object_get_logger(this_phy),
1090 SCIC_LOG_OBJECT_PHY,
1091 "scic_sds_phy_consume_power_handler(this_phy:0x%08x)\n",
1095 return this_phy->state_handlers->consume_power_handler(this_phy);
1098 //*****************************************************************************
1099 //* SCIC PHY Public Methods
1100 //*****************************************************************************
1102 SCI_STATUS scic_phy_get_properties(
1103 SCI_PHY_HANDLE_T phy,
1104 SCIC_PHY_PROPERTIES_T * properties
1107 SCIC_SDS_PHY_T *this_phy;
1108 U8 max_speed_generation;
1110 this_phy = (SCIC_SDS_PHY_T *)phy;
1113 sci_base_object_get_logger(this_phy),
1114 SCIC_LOG_OBJECT_PHY,
1115 "scic_phy_get_properties(0x%x, 0x%x) enter\n",
1116 this_phy, properties
1119 if (phy == SCI_INVALID_HANDLE)
1121 return SCI_FAILURE_INVALID_PHY;
1124 memset(properties, 0, sizeof(SCIC_PHY_PROPERTIES_T));
1126 //get max link rate of this phy set by user.
1127 max_speed_generation =
1128 this_phy->owning_port->owning_controller->user_parameters.sds1.
1129 phys[this_phy->phy_index].max_speed_generation;
1131 properties->negotiated_link_rate = this_phy->max_negotiated_speed;
1133 if (max_speed_generation == SCIC_SDS_PARM_GEN3_SPEED)
1134 properties->max_link_rate = SCI_SAS_600_GB;
1135 else if (max_speed_generation == SCIC_SDS_PARM_GEN2_SPEED)
1136 properties->max_link_rate = SCI_SAS_300_GB;
1138 properties->max_link_rate = SCI_SAS_150_GB;
1140 properties->index = this_phy->phy_index;
1141 properties->owning_port = scic_sds_phy_get_port(this_phy);
1143 scic_sds_phy_get_protocols(this_phy, &properties->transmit_iaf.protocols);
1145 properties->transmit_iaf.sas_address.high =
1146 this_phy->owning_port->owning_controller->oem_parameters.sds1.
1147 phys[this_phy->phy_index].sas_address.sci_format.high;
1149 properties->transmit_iaf.sas_address.low =
1150 this_phy->owning_port->owning_controller->oem_parameters.sds1.
1151 phys[this_phy->phy_index].sas_address.sci_format.low;
1156 // ---------------------------------------------------------------------------
1158 SCI_STATUS scic_sas_phy_get_properties(
1159 SCI_PHY_HANDLE_T phy,
1160 SCIC_SAS_PHY_PROPERTIES_T * properties
1163 SCIC_SDS_PHY_T *this_phy;
1164 this_phy = (SCIC_SDS_PHY_T *)phy;
1167 sci_base_object_get_logger(this_phy),
1168 SCIC_LOG_OBJECT_PHY,
1169 "scic_sas_phy_get_properties(0x%x, 0x%x) enter\n",
1170 this_phy, properties
1173 if (this_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS)
1176 &properties->received_iaf,
1177 &this_phy->phy_type.sas.identify_address_frame_buffer,
1178 sizeof(SCI_SAS_IDENTIFY_ADDRESS_FRAME_T)
1181 properties->received_capabilities.u.all
1182 = SCU_SAS_RECPHYCAP_READ(this_phy);
1190 // ---------------------------------------------------------------------------
1192 SCI_STATUS scic_sata_phy_get_properties(
1193 SCI_PHY_HANDLE_T phy,
1194 SCIC_SATA_PHY_PROPERTIES_T * properties
1197 SCIC_SDS_PHY_T *this_phy;
1198 this_phy = (SCIC_SDS_PHY_T *)phy;
1201 sci_base_object_get_logger(this_phy),
1202 SCIC_LOG_OBJECT_PHY,
1203 "scic_sata_phy_get_properties(0x%x, 0x%x) enter\n",
1204 this_phy, properties
1207 if (this_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA)
1210 &properties->signature_fis,
1211 &this_phy->phy_type.sata.signature_fis_buffer,
1212 sizeof(SATA_FIS_REG_D2H_T)
1215 /// @todo add support for port selectors.
1216 properties->is_port_selector_present = FALSE;
1224 // ---------------------------------------------------------------------------
1226 #if !defined(DISABLE_PORT_SELECTORS)
1228 SCI_STATUS scic_sata_phy_send_port_selection_signal(
1229 SCI_PHY_HANDLE_T phy
1232 SCIC_SDS_PHY_T *this_phy;
1233 this_phy = (SCIC_SDS_PHY_T *)phy;
1236 sci_base_object_get_logger(this_phy),
1237 SCIC_LOG_OBJECT_PHY,
1238 "scic_sata_phy_send_port_selection_signals(0x%x) enter\n",
1242 /// @todo To be implemented
1247 #endif // !defined(DISABLE_PORT_SELECTORS)
1249 // ---------------------------------------------------------------------------
1251 #if !defined(DISABLE_PHY_COUNTERS)
1253 SCI_STATUS scic_phy_enable_counter(
1254 SCI_PHY_HANDLE_T phy,
1255 SCIC_PHY_COUNTER_ID_T counter_id
1258 SCIC_SDS_PHY_T *this_phy;
1259 SCI_STATUS status = SCI_SUCCESS;
1260 this_phy = (SCIC_SDS_PHY_T *)phy;
1263 sci_base_object_get_logger(this_phy),
1264 SCIC_LOG_OBJECT_PHY,
1265 "scic_phy_enable_counter(0x%x, 0x%x) enter\n",
1266 this_phy, counter_id
1271 case SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT:
1273 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1274 control |= (1 << SCU_ERR_CNT_RX_DONE_ACK_NAK_TIMEOUT_INDEX);
1275 SCU_SAS_ECENCR_WRITE(this_phy, control);
1278 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT:
1280 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1281 control |= (1 << SCU_ERR_CNT_TX_DONE_ACK_NAK_TIMEOUT_INDEX);
1282 SCU_SAS_ECENCR_WRITE(this_phy, control);
1285 case SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED:
1287 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1288 control |= (1 << SCU_ERR_CNT_INACTIVITY_TIMER_EXPIRED_INDEX);
1289 SCU_SAS_ECENCR_WRITE(this_phy, control);
1292 case SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT:
1294 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1295 control |= (1 << SCU_ERR_CNT_RX_DONE_CREDIT_TIMEOUT_INDEX);
1296 SCU_SAS_ECENCR_WRITE(this_phy, control);
1299 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT:
1301 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1302 control |= (1 << SCU_ERR_CNT_TX_DONE_CREDIT_TIMEOUT_INDEX);
1303 SCU_SAS_ECENCR_WRITE(this_phy, control);
1306 case SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED:
1308 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1309 control |= (1 << SCU_ERR_CNT_RX_CREDIT_BLOCKED_RECEIVED_INDEX);
1310 SCU_SAS_ECENCR_WRITE(this_phy, control);
1314 // These error counters are enabled by default, and cannot be
1315 // disabled. Return SCI_SUCCESS to denote that they are
1316 // enabled, hiding the fact that enabling the counter is
1318 case SCIC_PHY_COUNTER_RECEIVED_FRAME:
1319 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME:
1320 case SCIC_PHY_COUNTER_RECEIVED_FRAME_DWORD:
1321 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD:
1322 case SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR:
1323 case SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR:
1324 case SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR:
1325 case SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME:
1326 case SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT:
1327 case SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE:
1328 case SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR:
1332 status = SCI_FAILURE;
1338 // ---------------------------------------------------------------------------
1340 SCI_STATUS scic_phy_disable_counter(
1341 SCI_PHY_HANDLE_T phy,
1342 SCIC_PHY_COUNTER_ID_T counter_id
1345 SCIC_SDS_PHY_T *this_phy;
1346 SCI_STATUS status = SCI_SUCCESS;
1348 this_phy = (SCIC_SDS_PHY_T *)phy;
1351 sci_base_object_get_logger(this_phy),
1352 SCIC_LOG_OBJECT_PHY,
1353 "scic_phy_disable_counter(0x%x, 0x%x) enter\n",
1354 this_phy, counter_id
1359 case SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT:
1361 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1362 control &= ~(1 << SCU_ERR_CNT_RX_DONE_ACK_NAK_TIMEOUT_INDEX);
1363 SCU_SAS_ECENCR_WRITE(this_phy, control);
1366 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT:
1368 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1369 control &= ~(1 << SCU_ERR_CNT_TX_DONE_ACK_NAK_TIMEOUT_INDEX);
1370 SCU_SAS_ECENCR_WRITE(this_phy, control);
1373 case SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED:
1375 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1376 control &= ~(1 << SCU_ERR_CNT_INACTIVITY_TIMER_EXPIRED_INDEX);
1377 SCU_SAS_ECENCR_WRITE(this_phy, control);
1380 case SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT:
1382 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1383 control &= ~(1 << SCU_ERR_CNT_RX_DONE_CREDIT_TIMEOUT_INDEX);
1384 SCU_SAS_ECENCR_WRITE(this_phy, control);
1387 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT:
1389 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1390 control &= ~(1 << SCU_ERR_CNT_TX_DONE_CREDIT_TIMEOUT_INDEX);
1391 SCU_SAS_ECENCR_WRITE(this_phy, control);
1394 case SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED:
1396 U32 control = SCU_SAS_ECENCR_READ(this_phy);
1397 control &= ~(1 << SCU_ERR_CNT_RX_CREDIT_BLOCKED_RECEIVED_INDEX);
1398 SCU_SAS_ECENCR_WRITE(this_phy, control);
1402 // These error counters cannot be disabled, so return SCI_FAILURE.
1403 case SCIC_PHY_COUNTER_RECEIVED_FRAME:
1404 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME:
1405 case SCIC_PHY_COUNTER_RECEIVED_FRAME_DWORD:
1406 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD:
1407 case SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR:
1408 case SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR:
1409 case SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR:
1410 case SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME:
1411 case SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT:
1412 case SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE:
1413 case SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR:
1415 status = SCI_FAILURE;
1421 // ---------------------------------------------------------------------------
1423 SCI_STATUS scic_phy_get_counter(
1424 SCI_PHY_HANDLE_T phy,
1425 SCIC_PHY_COUNTER_ID_T counter_id,
1429 SCIC_SDS_PHY_T *this_phy;
1430 SCI_STATUS status = SCI_SUCCESS;
1431 this_phy = (SCIC_SDS_PHY_T *)phy;
1434 sci_base_object_get_logger(this_phy),
1435 SCIC_LOG_OBJECT_PHY,
1436 "scic_phy_get_counter(0x%x, 0x%x) enter\n",
1437 this_phy, counter_id
1442 case SCIC_PHY_COUNTER_RECEIVED_FRAME:
1443 *data = scu_link_layer_register_read(this_phy, received_frame_count);
1445 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME:
1446 *data = scu_link_layer_register_read(this_phy, transmit_frame_count);
1448 case SCIC_PHY_COUNTER_RECEIVED_FRAME_DWORD:
1449 *data = scu_link_layer_register_read(this_phy, received_dword_count);
1451 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD:
1452 *data = scu_link_layer_register_read(this_phy, transmit_dword_count);
1454 case SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR:
1455 *data = scu_link_layer_register_read(this_phy, loss_of_sync_error_count);
1457 case SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR:
1458 *data = scu_link_layer_register_read(this_phy, running_disparity_error_count);
1460 case SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR:
1461 *data = scu_link_layer_register_read(this_phy, received_frame_crc_error_count);
1463 case SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT:
1464 *data = this_phy->error_counter[SCU_ERR_CNT_RX_DONE_ACK_NAK_TIMEOUT_INDEX];
1466 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT:
1467 *data = this_phy->error_counter[SCU_ERR_CNT_TX_DONE_ACK_NAK_TIMEOUT_INDEX];
1469 case SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED:
1470 *data = this_phy->error_counter[SCU_ERR_CNT_INACTIVITY_TIMER_EXPIRED_INDEX];
1472 case SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT:
1473 *data = this_phy->error_counter[SCU_ERR_CNT_RX_DONE_CREDIT_TIMEOUT_INDEX];
1475 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT:
1476 *data = this_phy->error_counter[SCU_ERR_CNT_TX_DONE_CREDIT_TIMEOUT_INDEX];
1478 case SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED:
1479 *data = this_phy->error_counter[SCU_ERR_CNT_RX_CREDIT_BLOCKED_RECEIVED_INDEX];
1481 case SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME:
1482 *data = scu_link_layer_register_read(this_phy, received_short_frame_count);
1484 case SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT:
1485 *data = scu_link_layer_register_read(this_phy, received_frame_without_credit_count);
1487 case SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE:
1488 *data = scu_link_layer_register_read(this_phy, received_frame_after_done_count);
1490 case SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR:
1491 *data = scu_link_layer_register_read(this_phy, phy_reset_problem_count);
1494 status = SCI_FAILURE;
1501 // ---------------------------------------------------------------------------
1503 SCI_STATUS scic_phy_clear_counter(
1504 SCI_PHY_HANDLE_T phy,
1505 SCIC_PHY_COUNTER_ID_T counter_id
1508 SCIC_SDS_PHY_T *this_phy;
1509 SCI_STATUS status = SCI_SUCCESS;
1510 this_phy = (SCIC_SDS_PHY_T *)phy;
1513 sci_base_object_get_logger(this_phy),
1514 SCIC_LOG_OBJECT_PHY,
1515 "scic_phy_clear_counter(0x%x, 0x%x) enter\n",
1516 this_phy, counter_id
1521 case SCIC_PHY_COUNTER_RECEIVED_FRAME:
1522 scu_link_layer_register_write(this_phy, received_frame_count, 0);
1524 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME:
1525 scu_link_layer_register_write(this_phy, transmit_frame_count, 0);
1527 case SCIC_PHY_COUNTER_RECEIVED_FRAME_DWORD:
1528 scu_link_layer_register_write(this_phy, received_dword_count, 0);
1530 case SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD:
1531 scu_link_layer_register_write(this_phy, transmit_dword_count, 0);
1533 case SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR:
1534 scu_link_layer_register_write(this_phy, loss_of_sync_error_count, 0);
1536 case SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR:
1537 scu_link_layer_register_write(this_phy, running_disparity_error_count, 0);
1539 case SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR:
1540 scu_link_layer_register_write(this_phy, received_frame_crc_error_count, 0);
1542 case SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT:
1543 this_phy->error_counter[SCU_ERR_CNT_RX_DONE_ACK_NAK_TIMEOUT_INDEX] = 0;
1545 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT:
1546 this_phy->error_counter[SCU_ERR_CNT_TX_DONE_ACK_NAK_TIMEOUT_INDEX] = 0;
1548 case SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED:
1549 this_phy->error_counter[SCU_ERR_CNT_INACTIVITY_TIMER_EXPIRED_INDEX] = 0;
1551 case SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT:
1552 this_phy->error_counter[SCU_ERR_CNT_RX_DONE_CREDIT_TIMEOUT_INDEX] = 0;
1554 case SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT:
1555 this_phy->error_counter[SCU_ERR_CNT_TX_DONE_CREDIT_TIMEOUT_INDEX] = 0;
1557 case SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED:
1558 this_phy->error_counter[SCU_ERR_CNT_RX_CREDIT_BLOCKED_RECEIVED_INDEX] = 0;
1560 case SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME:
1561 scu_link_layer_register_write(this_phy, received_short_frame_count, 0);
1563 case SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT:
1564 scu_link_layer_register_write(this_phy, received_frame_without_credit_count, 0);
1566 case SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE:
1567 scu_link_layer_register_write(this_phy, received_frame_after_done_count, 0);
1569 case SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR:
1570 scu_link_layer_register_write(this_phy, phy_reset_problem_count, 0);
1573 status = SCI_FAILURE;
1579 #endif // !defined(DISABLE_PHY_COUNTERS)
1581 SCI_STATUS scic_phy_stop(
1582 SCI_PHY_HANDLE_T phy
1585 SCIC_SDS_PHY_T *this_phy;
1586 this_phy = (SCIC_SDS_PHY_T *)phy;
1589 sci_base_object_get_logger(this_phy),
1590 SCIC_LOG_OBJECT_PHY,
1591 "scic_phy_stop(this_phy:0x%x)\n",
1595 return this_phy->state_handlers->parent.stop_handler(&this_phy->parent);
1598 SCI_STATUS scic_phy_start(
1599 SCI_PHY_HANDLE_T phy
1602 SCIC_SDS_PHY_T *this_phy;
1603 this_phy = (SCIC_SDS_PHY_T *)phy;
1606 sci_base_object_get_logger(this_phy),
1607 SCIC_LOG_OBJECT_PHY,
1608 "scic_phy_start(this_phy:0x%x)\n",
1612 return this_phy->state_handlers->parent.start_handler(&this_phy->parent);
1615 //******************************************************************************
1616 //* PHY STATE MACHINE
1617 //******************************************************************************
1619 //***************************************************************************
1620 //* DEFAULT HANDLERS
1621 //***************************************************************************
1624 * This is the default method for phy a start request. It will report a
1627 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1628 * SCIC_SDS_PHY object.
1630 * @return SCI_STATUS
1631 * @retval SCI_FAILURE_INVALID_STATE
1633 SCI_STATUS scic_sds_phy_default_start_handler(
1637 SCIC_SDS_PHY_T *this_phy;
1638 this_phy = (SCIC_SDS_PHY_T *)phy;
1641 sci_base_object_get_logger(this_phy),
1642 SCIC_LOG_OBJECT_PHY,
1643 "SCIC Phy 0x%08x requested to start from invalid state %d\n",
1645 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1648 return SCI_FAILURE_INVALID_STATE;
1653 * This is the default method for phy a stop request. It will report a
1656 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1657 * SCIC_SDS_PHY object.
1659 * @return SCI_STATUS
1660 * @retval SCI_FAILURE_INVALID_STATE
1662 SCI_STATUS scic_sds_phy_default_stop_handler(
1666 SCIC_SDS_PHY_T *this_phy;
1667 this_phy = (SCIC_SDS_PHY_T *)phy;
1670 sci_base_object_get_logger(this_phy),
1671 SCIC_LOG_OBJECT_PHY,
1672 "SCIC Phy 0x%08x requested to stop from invalid state %d\n",
1674 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1677 return SCI_FAILURE_INVALID_STATE;
1681 * This is the default method for phy a reset request. It will report a
1684 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1685 * SCIC_SDS_PHY object.
1687 * @return SCI_STATUS
1688 * @retval SCI_FAILURE_INVALID_STATE
1690 SCI_STATUS scic_sds_phy_default_reset_handler(
1691 SCI_BASE_PHY_T * phy
1694 SCIC_SDS_PHY_T *this_phy;
1695 this_phy = (SCIC_SDS_PHY_T *)phy;
1698 sci_base_object_get_logger(this_phy),
1699 SCIC_LOG_OBJECT_PHY,
1700 "SCIC Phy 0x%08x requested to reset from invalid state %d\n",
1702 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1705 return SCI_FAILURE_INVALID_STATE;
1709 * This is the default method for phy a destruct request. It will report a
1712 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1713 * SCIC_SDS_PHY object.
1715 * @return SCI_STATUS
1716 * @retval SCI_FAILURE_INVALID_STATE
1718 SCI_STATUS scic_sds_phy_default_destroy_handler(
1722 SCIC_SDS_PHY_T *this_phy;
1723 this_phy = (SCIC_SDS_PHY_T *)phy;
1725 /// @todo Implement something for the default
1727 sci_base_object_get_logger(this_phy),
1728 SCIC_LOG_OBJECT_PHY,
1729 "SCIC Phy 0x%08x requested to destroy from invalid state %d\n",
1731 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1734 return SCI_FAILURE_INVALID_STATE;
1738 * This is the default method for a phy frame handling request. It will
1739 * report a warning, release the frame and exit.
1741 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1742 * SCIC_SDS_PHY object.
1743 * @param[in] frame_index This is the frame index that was received from the
1746 * @return SCI_STATUS
1747 * @retval SCI_FAILURE_INVALID_STATE
1749 SCI_STATUS scic_sds_phy_default_frame_handler(
1750 SCIC_SDS_PHY_T *this_phy,
1755 sci_base_object_get_logger(this_phy),
1756 SCIC_LOG_OBJECT_PHY,
1757 "SCIC Phy 0x%08x recieved unexpected frame data %d while in state %d\n",
1758 this_phy, frame_index,
1759 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1762 scic_sds_controller_release_frame(
1763 scic_sds_phy_get_controller(this_phy), frame_index);
1765 return SCI_FAILURE_INVALID_STATE;
1769 * This is the default method for a phy event handler. It will report a
1772 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1773 * SCIC_SDS_PHY object.
1774 * @param[in] event_code This is the event code that was received from the SCU
1777 * @return SCI_STATUS
1778 * @retval SCI_FAILURE_INVALID_STATE
1780 SCI_STATUS scic_sds_phy_default_event_handler(
1781 SCIC_SDS_PHY_T *this_phy,
1786 sci_base_object_get_logger(this_phy),
1787 SCIC_LOG_OBJECT_PHY,
1788 "SCIC Phy 0x%08x received unexpected event status %x while in state %d\n",
1789 this_phy, event_code,
1790 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1793 return SCI_FAILURE_INVALID_STATE;
1797 * This is the default method for a phy consume power handler. It will report
1798 * a warning and exit.
1800 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1801 * SCIC_SDS_PHY object.
1803 * @return SCI_STATUS
1804 * @retval SCI_FAILURE_INVALID_STATE
1806 SCI_STATUS scic_sds_phy_default_consume_power_handler(
1807 SCIC_SDS_PHY_T *this_phy
1811 sci_base_object_get_logger(this_phy),
1812 SCIC_LOG_OBJECT_PHY,
1813 "SCIC Phy 0x%08x given unexpected permission to consume power while in state %d\n",
1815 sci_base_state_machine_get_state(&this_phy->parent.state_machine)
1818 return SCI_FAILURE_INVALID_STATE;
1821 //******************************************************************************
1822 //* PHY STOPPED STATE HANDLERS
1823 //******************************************************************************
1826 * This method takes the SCIC_SDS_PHY from a stopped state and attempts to
1828 * - The phy state machine is transitioned to the
1829 * SCI_BASE_PHY_STATE_STARTING.
1831 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1832 * SCIC_SDS_PHY object.
1834 * @return SCI_STATUS
1835 * @retval SCI_SUCCESS
1838 SCI_STATUS scic_sds_phy_stopped_state_start_handler(
1842 SCIC_SDS_PHY_T *this_phy;
1843 this_phy = (SCIC_SDS_PHY_T *)phy;
1847 // Create the SIGNATURE FIS Timeout timer for this phy
1848 this_phy->sata_timeout_timer = scic_cb_timer_create(
1849 scic_sds_phy_get_controller(this_phy),
1850 scic_sds_phy_sata_timeout,
1854 if (this_phy->sata_timeout_timer != NULL)
1856 sci_base_state_machine_change_state(
1857 scic_sds_phy_get_base_state_machine(this_phy),
1858 SCI_BASE_PHY_STATE_STARTING
1866 * This method takes the SCIC_SDS_PHY from a stopped state and destroys it.
1867 * - This function takes no action.
1869 * @todo Shouldnt this function transition the SCI_BASE_PHY::state_machine to
1870 * the SCI_BASE_PHY_STATE_FINAL?
1872 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1873 * SCIC_SDS_PHY object.
1875 * @return SCI_STATUS
1876 * @retval SCI_SUCCESS
1879 SCI_STATUS scic_sds_phy_stopped_state_destroy_handler(
1883 SCIC_SDS_PHY_T *this_phy;
1884 this_phy = (SCIC_SDS_PHY_T *)phy;
1886 /// @todo what do we actually need to do here?
1890 //******************************************************************************
1891 //* PHY STARTING STATE HANDLERS
1892 //******************************************************************************
1894 // All of these state handlers are mapped to the starting sub-state machine
1896 //******************************************************************************
1897 //* PHY READY STATE HANDLERS
1898 //******************************************************************************
1901 * This method takes the SCIC_SDS_PHY from a ready state and attempts to stop
1903 * - The phy state machine is transitioned to the SCI_BASE_PHY_STATE_STOPPED.
1905 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1906 * SCIC_SDS_PHY object.
1908 * @return SCI_STATUS
1909 * @retval SCI_SUCCESS
1912 SCI_STATUS scic_sds_phy_ready_state_stop_handler(
1916 SCIC_SDS_PHY_T *this_phy;
1917 this_phy = (SCIC_SDS_PHY_T *)phy;
1919 sci_base_state_machine_change_state(
1920 scic_sds_phy_get_base_state_machine(this_phy),
1921 SCI_BASE_PHY_STATE_STOPPED
1924 scic_sds_controller_link_down(
1925 scic_sds_phy_get_controller(this_phy),
1926 scic_sds_phy_get_port(this_phy),
1934 * This method takes the SCIC_SDS_PHY from a ready state and attempts to reset
1936 * - The phy state machine is transitioned to the SCI_BASE_PHY_STATE_STARTING.
1938 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
1939 * SCIC_SDS_PHY object.
1941 * @return SCI_STATUS
1942 * @retval SCI_SUCCESS
1945 SCI_STATUS scic_sds_phy_ready_state_reset_handler(
1946 SCI_BASE_PHY_T * phy
1949 SCIC_SDS_PHY_T * this_phy;
1950 this_phy = (SCIC_SDS_PHY_T *)phy;
1952 sci_base_state_machine_change_state(
1953 scic_sds_phy_get_base_state_machine(this_phy),
1954 SCI_BASE_PHY_STATE_RESETTING
1961 * This method request the SCIC_SDS_PHY handle the received event. The only
1962 * event that we are interested in while in the ready state is the link
1964 * - decoded event is a link failure
1965 * - transition the SCIC_SDS_PHY back to the SCI_BASE_PHY_STATE_STARTING
1967 * - any other event recived will report a warning message
1969 * @param[in] phy This is the SCIC_SDS_PHY object which has received the
1972 * @return SCI_STATUS
1973 * @retval SCI_SUCCESS if the event received is a link failure
1974 * @retval SCI_FAILURE_INVALID_STATE for any other event received.
1977 SCI_STATUS scic_sds_phy_ready_state_event_handler(
1978 SCIC_SDS_PHY_T *this_phy,
1982 SCI_STATUS result = SCI_FAILURE;
1984 switch (scu_get_event_code(event_code))
1986 case SCU_EVENT_LINK_FAILURE:
1987 // Link failure change state back to the starting state
1988 sci_base_state_machine_change_state(
1989 scic_sds_phy_get_base_state_machine(this_phy),
1990 SCI_BASE_PHY_STATE_STARTING
1993 result = SCI_SUCCESS;
1996 case SCU_EVENT_BROADCAST_CHANGE:
1997 // Broadcast change received. Notify the port.
1998 if (scic_sds_phy_get_port(this_phy) != SCI_INVALID_HANDLE)
1999 scic_sds_port_broadcast_change_received(this_phy->owning_port, this_phy);
2001 this_phy->bcn_received_while_port_unassigned = TRUE;
2004 case SCU_EVENT_ERR_CNT(RX_CREDIT_BLOCKED_RECEIVED):
2005 case SCU_EVENT_ERR_CNT(TX_DONE_CREDIT_TIMEOUT):
2006 case SCU_EVENT_ERR_CNT(RX_DONE_CREDIT_TIMEOUT):
2007 case SCU_EVENT_ERR_CNT(INACTIVITY_TIMER_EXPIRED):
2008 case SCU_EVENT_ERR_CNT(TX_DONE_ACK_NAK_TIMEOUT):
2009 case SCU_EVENT_ERR_CNT(RX_DONE_ACK_NAK_TIMEOUT):
2011 U32 error_counter_index =
2012 scu_get_event_specifier(event_code) >> SCU_EVENT_SPECIFIC_CODE_SHIFT;
2014 this_phy->error_counter[error_counter_index]++;
2015 result = SCI_SUCCESS;
2021 sci_base_object_get_logger(this_phy),
2022 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2023 "SCIC PHY 0x%x ready state machine recieved unexpected event_code %x\n",
2024 this_phy, event_code
2026 result = SCI_FAILURE_INVALID_STATE;
2033 // ---------------------------------------------------------------------------
2036 * This is the resetting state event handler.
2038 * @param[in] this_phy This is the SCIC_SDS_PHY object which is receiving the
2040 * @param[in] event_code This is the event code to be processed.
2042 * @return SCI_STATUS
2043 * @retval SCI_FAILURE_INVALID_STATE
2046 SCI_STATUS scic_sds_phy_resetting_state_event_handler(
2047 SCIC_SDS_PHY_T *this_phy,
2051 SCI_STATUS result = SCI_FAILURE;
2053 switch (scu_get_event_code(event_code))
2055 case SCU_EVENT_HARD_RESET_TRANSMITTED:
2056 // Link failure change state back to the starting state
2057 sci_base_state_machine_change_state(
2058 scic_sds_phy_get_base_state_machine(this_phy),
2059 SCI_BASE_PHY_STATE_STARTING
2062 result = SCI_SUCCESS;
2067 sci_base_object_get_logger(this_phy),
2068 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2069 "SCIC PHY 0x%x resetting state machine recieved unexpected event_code %x\n",
2070 this_phy, event_code
2073 result = SCI_FAILURE_INVALID_STATE;
2080 // ---------------------------------------------------------------------------
2082 SCIC_SDS_PHY_STATE_HANDLER_T
2083 scic_sds_phy_state_handler_table[SCI_BASE_PHY_MAX_STATES] =
2085 // SCI_BASE_PHY_STATE_INITIAL
2088 scic_sds_phy_default_start_handler,
2089 scic_sds_phy_default_stop_handler,
2090 scic_sds_phy_default_reset_handler,
2091 scic_sds_phy_default_destroy_handler
2093 scic_sds_phy_default_frame_handler,
2094 scic_sds_phy_default_event_handler,
2095 scic_sds_phy_default_consume_power_handler
2097 // SCI_BASE_PHY_STATE_STOPPED
2100 scic_sds_phy_stopped_state_start_handler,
2101 scic_sds_phy_default_stop_handler,
2102 scic_sds_phy_default_reset_handler,
2103 scic_sds_phy_stopped_state_destroy_handler
2105 scic_sds_phy_default_frame_handler,
2106 scic_sds_phy_default_event_handler,
2107 scic_sds_phy_default_consume_power_handler
2109 // SCI_BASE_PHY_STATE_STARTING
2112 scic_sds_phy_default_start_handler,
2113 scic_sds_phy_default_stop_handler,
2114 scic_sds_phy_default_reset_handler,
2115 scic_sds_phy_default_destroy_handler
2117 scic_sds_phy_default_frame_handler,
2118 scic_sds_phy_default_event_handler,
2119 scic_sds_phy_default_consume_power_handler
2121 // SCI_BASE_PHY_STATE_READY
2124 scic_sds_phy_default_start_handler,
2125 scic_sds_phy_ready_state_stop_handler,
2126 scic_sds_phy_ready_state_reset_handler,
2127 scic_sds_phy_default_destroy_handler
2129 scic_sds_phy_default_frame_handler,
2130 scic_sds_phy_ready_state_event_handler,
2131 scic_sds_phy_default_consume_power_handler
2133 // SCI_BASE_PHY_STATE_RESETTING
2136 scic_sds_phy_default_start_handler,
2137 scic_sds_phy_default_stop_handler,
2138 scic_sds_phy_default_reset_handler,
2139 scic_sds_phy_default_destroy_handler
2141 scic_sds_phy_default_frame_handler,
2142 scic_sds_phy_resetting_state_event_handler,
2143 scic_sds_phy_default_consume_power_handler
2145 // SCI_BASE_PHY_STATE_FINAL
2148 scic_sds_phy_default_start_handler,
2149 scic_sds_phy_default_stop_handler,
2150 scic_sds_phy_default_reset_handler,
2151 scic_sds_phy_default_destroy_handler
2153 scic_sds_phy_default_frame_handler,
2154 scic_sds_phy_default_event_handler,
2155 scic_sds_phy_default_consume_power_handler
2159 //****************************************************************************
2160 //* PHY STATE PRIVATE METHODS
2161 //****************************************************************************
2164 * This method will stop the SCIC_SDS_PHY object. This does not reset the
2165 * protocol engine it just suspends it and places it in a state where it will
2166 * not cause the end device to power up.
2168 * @param[in] this_phy This is the SCIC_SDS_PHY object to stop.
2173 void scu_link_layer_stop_protocol_engine(
2174 SCIC_SDS_PHY_T *this_phy
2177 U32 scu_sas_pcfg_value;
2178 U32 enable_spinup_value;
2180 // Suspend the protocol engine and place it in a sata spinup hold state
2181 scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy);
2182 scu_sas_pcfg_value |= (
2183 SCU_SAS_PCFG_GEN_BIT(OOB_RESET)
2184 | SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE)
2185 | SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD)
2187 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
2189 // Disable the notify enable spinup primitives
2190 enable_spinup_value = SCU_SAS_ENSPINUP_READ(this_phy);
2191 enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE);
2192 SCU_SAS_ENSPINUP_WRITE(this_phy, enable_spinup_value);
2196 * This method will start the OOB/SN state machine for this SCIC_SDS_PHY
2199 * @param[in] this_phy This is the SCIC_SDS_PHY object on which to start the
2200 * OOB/SN state machine.
2203 void scu_link_layer_start_oob(
2204 SCIC_SDS_PHY_T *this_phy
2207 U32 scu_sas_pcfg_value;
2209 /* Reset OOB sequence - start */
2210 scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy);
2211 scu_sas_pcfg_value &=
2212 ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | SCU_SAS_PCFG_GEN_BIT(HARD_RESET));
2213 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
2214 SCU_SAS_PCFG_READ(this_phy);
2215 /* Reset OOB sequence - end */
2217 /* Start OOB sequence - start */
2218 scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy);
2219 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
2220 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
2221 SCU_SAS_PCFG_READ(this_phy);
2222 /* Start OOB sequence - end */
2226 * This method will transmit a hard reset request on the specified phy. The
2227 * SCU hardware requires that we reset the OOB state machine and set the hard
2228 * reset bit in the phy configuration register.
2229 * We then must start OOB over with the hard reset bit set.
2231 * @param[in] this_phy
2234 void scu_link_layer_tx_hard_reset(
2235 SCIC_SDS_PHY_T *this_phy
2238 U32 phy_configuration_value;
2240 // SAS Phys must wait for the HARD_RESET_TX event notification to transition
2241 // to the starting state.
2242 phy_configuration_value = SCU_SAS_PCFG_READ(this_phy);
2243 phy_configuration_value |=
2244 (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) | SCU_SAS_PCFG_GEN_BIT(OOB_RESET));
2245 SCU_SAS_PCFG_WRITE(this_phy, phy_configuration_value);
2247 // Now take the OOB state machine out of reset
2248 phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
2249 phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
2250 SCU_SAS_PCFG_WRITE(this_phy, phy_configuration_value);
2253 //****************************************************************************
2254 //* PHY BASE STATE METHODS
2255 //****************************************************************************
2258 * This method will perform the actions required by the SCIC_SDS_PHY on
2259 * entering the SCI_BASE_PHY_STATE_INITIAL.
2260 * - This function sets the state handlers for the phy object base state
2261 * machine initial state.
2263 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2264 * SCIC_SDS_PHY object.
2269 void scic_sds_phy_initial_state_enter(
2270 SCI_BASE_OBJECT_T *object
2273 SCIC_SDS_PHY_T *this_phy;
2274 this_phy = (SCIC_SDS_PHY_T *)object;
2276 scic_sds_phy_set_base_state_handlers(this_phy, SCI_BASE_PHY_STATE_INITIAL);
2280 * This method will perform the actions required by the SCIC_SDS_PHY on
2281 * entering the SCI_BASE_PHY_STATE_INITIAL.
2282 * - This function sets the state handlers for the phy object base state
2283 * machine initial state.
2284 * - The SCU hardware is requested to stop the protocol engine.
2286 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2287 * SCIC_SDS_PHY object.
2292 void scic_sds_phy_stopped_state_enter(
2293 SCI_BASE_OBJECT_T *object
2296 SCIC_SDS_PHY_T *this_phy;
2297 this_phy = (SCIC_SDS_PHY_T *)object;
2299 /// @todo We need to get to the controller to place this PE in a reset state
2300 scic_sds_phy_set_base_state_handlers(this_phy, SCI_BASE_PHY_STATE_STOPPED);
2302 if (this_phy->sata_timeout_timer != NULL)
2304 scic_cb_timer_destroy(
2305 scic_sds_phy_get_controller(this_phy),
2306 this_phy->sata_timeout_timer
2309 this_phy->sata_timeout_timer = NULL;
2312 scu_link_layer_stop_protocol_engine(this_phy);
2316 * This method will perform the actions required by the SCIC_SDS_PHY on
2317 * entering the SCI_BASE_PHY_STATE_STARTING.
2318 * - This function sets the state handlers for the phy object base state
2319 * machine starting state.
2320 * - The SCU hardware is requested to start OOB/SN on this protocol engine.
2321 * - The phy starting substate machine is started.
2322 * - If the previous state was the ready state then the
2323 * SCIC_SDS_CONTROLLER is informed that the phy has gone link down.
2325 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2326 * SCIC_SDS_PHY object.
2331 void scic_sds_phy_starting_state_enter(
2332 SCI_BASE_OBJECT_T *object
2335 SCIC_SDS_PHY_T *this_phy;
2336 this_phy = (SCIC_SDS_PHY_T *)object;
2338 scic_sds_phy_set_base_state_handlers(this_phy, SCI_BASE_PHY_STATE_STARTING);
2340 scu_link_layer_stop_protocol_engine(this_phy);
2341 scu_link_layer_start_oob(this_phy);
2343 // We don't know what kind of phy we are going to be just yet
2344 this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
2345 this_phy->bcn_received_while_port_unassigned = FALSE;
2347 // Change over to the starting substate machine to continue
2348 sci_base_state_machine_start(&this_phy->starting_substate_machine);
2350 if (this_phy->parent.state_machine.previous_state_id
2351 == SCI_BASE_PHY_STATE_READY)
2353 scic_sds_controller_link_down(
2354 scic_sds_phy_get_controller(this_phy),
2355 scic_sds_phy_get_port(this_phy),
2362 * This method will perform the actions required by the SCIC_SDS_PHY on
2363 * entering the SCI_BASE_PHY_STATE_READY.
2364 * - This function sets the state handlers for the phy object base state
2365 * machine ready state.
2366 * - The SCU hardware protocol engine is resumed.
2367 * - The SCIC_SDS_CONTROLLER is informed that the phy object has gone link
2370 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2371 * SCIC_SDS_PHY object.
2376 void scic_sds_phy_ready_state_enter(
2377 SCI_BASE_OBJECT_T *object
2380 SCIC_SDS_PHY_T *this_phy;
2381 this_phy = (SCIC_SDS_PHY_T *)object;
2383 scic_sds_phy_set_base_state_handlers(this_phy, SCI_BASE_PHY_STATE_READY);
2385 scic_sds_controller_link_up(
2386 scic_sds_phy_get_controller(this_phy),
2387 scic_sds_phy_get_port(this_phy),
2393 * This method will perform the actions required by the SCIC_SDS_PHY on
2394 * exiting the SCI_BASE_PHY_STATE_INITIAL. This function suspends the SCU
2395 * hardware protocol engine represented by this SCIC_SDS_PHY object.
2397 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2398 * SCIC_SDS_PHY object.
2403 void scic_sds_phy_ready_state_exit(
2404 SCI_BASE_OBJECT_T *object
2407 SCIC_SDS_PHY_T *this_phy;
2408 this_phy = (SCIC_SDS_PHY_T *)object;
2410 scic_sds_phy_suspend(this_phy);
2414 * This method will perform the actions required by the SCIC_SDS_PHY on
2415 * entering the SCI_BASE_PHY_STATE_RESETTING.
2416 * - This function sets the state handlers for the phy object base state
2417 * machine resetting state.
2419 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2420 * SCIC_SDS_PHY object.
2425 void scic_sds_phy_resetting_state_enter(
2426 SCI_BASE_OBJECT_T *object
2429 SCIC_SDS_PHY_T * this_phy;
2430 this_phy = (SCIC_SDS_PHY_T *)object;
2432 scic_sds_phy_set_base_state_handlers(this_phy, SCI_BASE_PHY_STATE_RESETTING);
2434 // The phy is being reset, therefore deactivate it from the port.
2435 // In the resetting state we don't notify the user regarding
2436 // link up and link down notifications.
2437 scic_sds_port_deactivate_phy(this_phy->owning_port, this_phy, FALSE);
2439 if (this_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS)
2441 scu_link_layer_tx_hard_reset(this_phy);
2445 // The SCU does not need to have a descrete reset state so just go back to
2446 // the starting state.
2447 sci_base_state_machine_change_state(
2448 &this_phy->parent.state_machine,
2449 SCI_BASE_PHY_STATE_STARTING
2455 * This method will perform the actions required by the SCIC_SDS_PHY on
2456 * entering the SCI_BASE_PHY_STATE_FINAL.
2457 * - This function sets the state handlers for the phy object base state
2458 * machine final state.
2460 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
2461 * SCIC_SDS_PHY object.
2466 void scic_sds_phy_final_state_enter(
2467 SCI_BASE_OBJECT_T *object
2470 SCIC_SDS_PHY_T *this_phy;
2471 this_phy = (SCIC_SDS_PHY_T *)object;
2473 scic_sds_phy_set_base_state_handlers(this_phy, SCI_BASE_PHY_STATE_FINAL);
2475 // Nothing to do here
2478 // ---------------------------------------------------------------------------
2480 SCI_BASE_STATE_T scic_sds_phy_state_table[SCI_BASE_PHY_MAX_STATES] =
2483 SCI_BASE_PHY_STATE_INITIAL,
2484 scic_sds_phy_initial_state_enter,
2488 SCI_BASE_PHY_STATE_STOPPED,
2489 scic_sds_phy_stopped_state_enter,
2493 SCI_BASE_PHY_STATE_STARTING,
2494 scic_sds_phy_starting_state_enter,
2498 SCI_BASE_PHY_STATE_READY,
2499 scic_sds_phy_ready_state_enter,
2500 scic_sds_phy_ready_state_exit,
2503 SCI_BASE_PHY_STATE_RESETTING,
2504 scic_sds_phy_resetting_state_enter,
2508 SCI_BASE_PHY_STATE_FINAL,
2509 scic_sds_phy_final_state_enter,
2514 //******************************************************************************
2515 //* PHY STARTING SUB-STATE MACHINE
2516 //******************************************************************************
2518 //*****************************************************************************
2519 //* SCIC SDS PHY HELPER FUNCTIONS
2520 //*****************************************************************************
2524 * This method continues the link training for the phy as if it were a SAS PHY
2525 * instead of a SATA PHY. This is done because the completion queue had a SAS
2526 * PHY DETECTED event when the state machine was expecting a SATA PHY event.
2528 * @param[in] this_phy The phy object that received SAS PHY DETECTED.
2533 void scic_sds_phy_start_sas_link_training(
2534 SCIC_SDS_PHY_T * this_phy
2539 phy_control = SCU_SAS_PCFG_READ(this_phy);
2540 phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD);
2541 SCU_SAS_PCFG_WRITE(this_phy, phy_control);
2543 sci_base_state_machine_change_state(
2544 &this_phy->starting_substate_machine,
2545 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
2548 this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS;
2552 * This method continues the link training for the phy as if it were a SATA
2553 * PHY instead of a SAS PHY. This is done because the completion queue had a
2554 * SATA SPINUP HOLD event when the state machine was expecting a SAS PHY
2557 * @param[in] this_phy The phy object that received a SATA SPINUP HOLD event
2562 void scic_sds_phy_start_sata_link_training(
2563 SCIC_SDS_PHY_T * this_phy
2566 sci_base_state_machine_change_state(
2567 &this_phy->starting_substate_machine,
2568 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
2571 this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
2575 * @brief This method performs processing common to all protocols upon
2576 * completion of link training.
2578 * @param[in,out] this_phy This parameter specifies the phy object for which
2579 * link training has completed.
2580 * @param[in] max_link_rate This parameter specifies the maximum link
2581 * rate to be associated with this phy.
2582 * @param[in] next_state This parameter specifies the next state for the
2583 * phy's starting sub-state machine.
2588 void scic_sds_phy_complete_link_training(
2589 SCIC_SDS_PHY_T * this_phy,
2590 SCI_SAS_LINK_RATE max_link_rate,
2594 this_phy->max_negotiated_speed = max_link_rate;
2596 sci_base_state_machine_change_state(
2597 scic_sds_phy_get_starting_substate_machine(this_phy), next_state
2602 * This method restarts the SCIC_SDS_PHY objects base state machine in the
2603 * starting state from any starting substate.
2605 * @param[in] this_phy The SCIC_SDS_PHY object to restart.
2609 void scic_sds_phy_restart_starting_state(
2610 SCIC_SDS_PHY_T *this_phy
2613 // Stop the current substate machine
2614 sci_base_state_machine_stop(
2615 scic_sds_phy_get_starting_substate_machine(this_phy)
2618 // Re-enter the base state machine starting state
2619 sci_base_state_machine_change_state(
2620 scic_sds_phy_get_base_state_machine(this_phy),
2621 SCI_BASE_PHY_STATE_STARTING
2626 //*****************************************************************************
2627 //* SCIC SDS PHY general handlers
2628 //*****************************************************************************
2631 SCI_STATUS scic_sds_phy_starting_substate_general_stop_handler(
2635 SCIC_SDS_PHY_T *this_phy;
2636 this_phy = (SCIC_SDS_PHY_T *)phy;
2638 sci_base_state_machine_stop(
2639 &this_phy->starting_substate_machine
2642 sci_base_state_machine_change_state(
2643 &phy->state_machine,
2644 SCI_BASE_PHY_STATE_STOPPED
2650 //*****************************************************************************
2651 //* SCIC SDS PHY EVENT_HANDLERS
2652 //*****************************************************************************
2655 * This method is called when an event notification is received for the phy
2656 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN.
2657 * - decode the event
2658 * - sas phy detected causes a state transition to the wait for speed
2659 * event notification.
2660 * - any other events log a warning message and set a failure status
2662 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
2663 * @param[in] event_code This is the event code which the phy object is to
2666 * @return SCI_STATUS
2667 * @retval SCI_SUCCESS on any valid event notification
2668 * @retval SCI_FAILURE on any unexpected event notifation
2671 SCI_STATUS scic_sds_phy_starting_substate_await_ossp_event_handler(
2672 SCIC_SDS_PHY_T *this_phy,
2676 U32 result = SCI_SUCCESS;
2678 switch (scu_get_event_code(event_code))
2680 case SCU_EVENT_SAS_PHY_DETECTED:
2681 scic_sds_phy_start_sas_link_training(this_phy);
2682 this_phy->is_in_link_training = TRUE;
2685 case SCU_EVENT_SATA_SPINUP_HOLD:
2686 scic_sds_phy_start_sata_link_training(this_phy);
2687 this_phy->is_in_link_training = TRUE;
2692 sci_base_object_get_logger(this_phy),
2693 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2694 "PHY starting substate machine recieved unexpected event_code %x\n",
2698 result = SCI_FAILURE;
2706 * This method is called when an event notification is received for the phy
2707 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN.
2708 * - decode the event
2709 * - sas phy detected returns us back to this state.
2710 * - speed event detected causes a state transition to the wait for iaf.
2711 * - identify timeout is an un-expected event and the state machine is
2713 * - link failure events restart the starting state machine
2714 * - any other events log a warning message and set a failure status
2716 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
2717 * @param[in] event_code This is the event code which the phy object is to
2720 * @return SCI_STATUS
2721 * @retval SCI_SUCCESS on any valid event notification
2722 * @retval SCI_FAILURE on any unexpected event notifation
2725 SCI_STATUS scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler(
2726 SCIC_SDS_PHY_T *this_phy,
2730 U32 result = SCI_SUCCESS;
2732 switch (scu_get_event_code(event_code))
2734 case SCU_EVENT_SAS_PHY_DETECTED:
2735 // Why is this being reported again by the controller?
2736 // We would re-enter this state so just stay here
2739 case SCU_EVENT_SAS_15:
2740 case SCU_EVENT_SAS_15_SSC:
2741 scic_sds_phy_complete_link_training(
2742 this_phy, SCI_SAS_150_GB, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
2746 case SCU_EVENT_SAS_30:
2747 case SCU_EVENT_SAS_30_SSC:
2748 scic_sds_phy_complete_link_training(
2749 this_phy, SCI_SAS_300_GB, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
2753 case SCU_EVENT_SAS_60:
2754 case SCU_EVENT_SAS_60_SSC:
2755 scic_sds_phy_complete_link_training(
2756 this_phy, SCI_SAS_600_GB, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
2760 case SCU_EVENT_SATA_SPINUP_HOLD:
2761 // We were doing SAS PHY link training and received a SATA PHY event
2762 // continue OOB/SN as if this were a SATA PHY
2763 scic_sds_phy_start_sata_link_training(this_phy);
2766 case SCU_EVENT_LINK_FAILURE:
2767 // Link failure change state back to the starting state
2768 scic_sds_phy_restart_starting_state(this_phy);
2773 sci_base_object_get_logger(this_phy),
2774 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2775 "PHY starting substate machine recieved unexpected event_code %x\n",
2779 result = SCI_FAILURE;
2787 * This method is called when an event notification is received for the phy
2788 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF.
2789 * - decode the event
2790 * - sas phy detected event backs up the state machine to the await
2791 * speed notification.
2792 * - identify timeout is an un-expected event and the state machine is
2794 * - link failure events restart the starting state machine
2795 * - any other events log a warning message and set a failure status
2797 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
2798 * @param[in] event_code This is the event code which the phy object is to
2801 * @return SCI_STATUS
2802 * @retval SCI_SUCCESS on any valid event notification
2803 * @retval SCI_FAILURE on any unexpected event notifation
2806 SCI_STATUS scic_sds_phy_starting_substate_await_iaf_uf_event_handler(
2807 SCIC_SDS_PHY_T *this_phy,
2811 U32 result = SCI_SUCCESS;
2813 switch (scu_get_event_code(event_code))
2815 case SCU_EVENT_SAS_PHY_DETECTED:
2816 // Backup the state machine
2817 scic_sds_phy_start_sas_link_training(this_phy);
2820 case SCU_EVENT_SATA_SPINUP_HOLD:
2821 // We were doing SAS PHY link training and received a SATA PHY event
2822 // continue OOB/SN as if this were a SATA PHY
2823 scic_sds_phy_start_sata_link_training(this_phy);
2826 case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
2827 case SCU_EVENT_LINK_FAILURE:
2828 case SCU_EVENT_HARD_RESET_RECEIVED:
2829 // Start the oob/sn state machine over again
2830 scic_sds_phy_restart_starting_state(this_phy);
2835 sci_base_object_get_logger(this_phy),
2836 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2837 "PHY starting substate machine recieved unexpected event_code %x\n",
2841 result = SCI_FAILURE;
2849 * This method is called when an event notification is received for the phy
2850 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_POWER.
2851 * - decode the event
2852 * - link failure events restart the starting state machine
2853 * - any other events log a warning message and set a failure status
2855 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
2856 * @param[in] event_code This is the event code which the phy object is to
2859 * @return SCI_STATUS
2860 * @retval SCI_SUCCESS on a link failure event
2861 * @retval SCI_FAILURE on any unexpected event notifation
2864 SCI_STATUS scic_sds_phy_starting_substate_await_sas_power_event_handler(
2865 SCIC_SDS_PHY_T *this_phy,
2869 U32 result = SCI_SUCCESS;
2871 switch (scu_get_event_code(event_code))
2873 case SCU_EVENT_LINK_FAILURE:
2874 // Link failure change state back to the starting state
2875 scic_sds_phy_restart_starting_state(this_phy);
2880 sci_base_object_get_logger(this_phy),
2881 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2882 "PHY starting substate machine recieved unexpected event_code %x\n",
2886 result = SCI_FAILURE;
2894 * This method is called when an event notification is received for the phy
2895 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER.
2896 * - decode the event
2897 * - link failure events restart the starting state machine
2898 * - sata spinup hold events are ignored since they are expected
2899 * - any other events log a warning message and set a failure status
2901 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
2902 * @param[in] event_code This is the event code which the phy object is to
2905 * @return SCI_STATUS
2906 * @retval SCI_SUCCESS on a link failure event
2907 * @retval SCI_FAILURE on any unexpected event notifation
2910 SCI_STATUS scic_sds_phy_starting_substate_await_sata_power_event_handler(
2911 SCIC_SDS_PHY_T *this_phy,
2915 U32 result = SCI_SUCCESS;
2917 switch (scu_get_event_code(event_code))
2919 case SCU_EVENT_LINK_FAILURE:
2920 // Link failure change state back to the starting state
2921 scic_sds_phy_restart_starting_state(this_phy);
2924 case SCU_EVENT_SATA_SPINUP_HOLD:
2925 // These events are received every 10ms and are expected while in this state
2928 case SCU_EVENT_SAS_PHY_DETECTED:
2929 // There has been a change in the phy type before OOB/SN for the
2930 // SATA finished start down the SAS link traning path.
2931 scic_sds_phy_start_sas_link_training(this_phy);
2936 sci_base_object_get_logger(this_phy),
2937 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
2938 "PHY starting substate machine recieved unexpected event_code %x\n",
2942 result = SCI_FAILURE;
2950 * This method is called when an event notification is received for the phy
2951 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN.
2952 * - decode the event
2953 * - link failure events restart the starting state machine
2954 * - sata spinup hold events are ignored since they are expected
2955 * - sata phy detected event change to the wait speed event
2956 * - any other events log a warning message and set a failure status
2958 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
2959 * @param[in] event_code This is the event code which the phy object is to
2962 * @return SCI_STATUS
2963 * @retval SCI_SUCCESS on a link failure event
2964 * @retval SCI_FAILURE on any unexpected event notifation
2967 SCI_STATUS scic_sds_phy_starting_substate_await_sata_phy_event_handler(
2968 SCIC_SDS_PHY_T *this_phy,
2972 U32 result = SCI_SUCCESS;
2974 switch (scu_get_event_code(event_code))
2976 case SCU_EVENT_LINK_FAILURE:
2977 // Link failure change state back to the starting state
2978 scic_sds_phy_restart_starting_state(this_phy);
2981 case SCU_EVENT_SATA_SPINUP_HOLD:
2982 // These events might be received since we dont know how many may be in
2983 // the completion queue while waiting for power
2986 case SCU_EVENT_SATA_PHY_DETECTED:
2987 this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
2989 // We have received the SATA PHY notification change state
2990 sci_base_state_machine_change_state(
2991 scic_sds_phy_get_starting_substate_machine(this_phy),
2992 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN
2996 case SCU_EVENT_SAS_PHY_DETECTED:
2997 // There has been a change in the phy type before OOB/SN for the
2998 // SATA finished start down the SAS link traning path.
2999 scic_sds_phy_start_sas_link_training(this_phy);
3004 sci_base_object_get_logger(this_phy),
3005 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
3006 "PHY starting substate machine recieved unexpected event_code %x\n",
3010 result = SCI_FAILURE;
3018 * This method is called when an event notification is received for the phy
3019 * object when in the state
3020 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN.
3021 * - decode the event
3022 * - sata phy detected returns us back to this state.
3023 * - speed event detected causes a state transition to the wait for
3025 * - link failure events restart the starting state machine
3026 * - any other events log a warning message and set a failure status
3028 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
3029 * @param[in] event_code This is the event code which the phy object is to
3032 * @return SCI_STATUS
3033 * @retval SCI_SUCCESS on any valid event notification
3034 * @retval SCI_FAILURE on any unexpected event notifation
3037 SCI_STATUS scic_sds_phy_starting_substate_await_sata_speed_event_handler(
3038 SCIC_SDS_PHY_T *this_phy,
3042 U32 result = SCI_SUCCESS;
3044 switch (scu_get_event_code(event_code))
3046 case SCU_EVENT_SATA_PHY_DETECTED:
3047 // The hardware reports multiple SATA PHY detected events
3048 // ignore the extras
3051 case SCU_EVENT_SATA_15:
3052 case SCU_EVENT_SATA_15_SSC:
3053 scic_sds_phy_complete_link_training(
3056 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF
3060 case SCU_EVENT_SATA_30:
3061 case SCU_EVENT_SATA_30_SSC:
3062 scic_sds_phy_complete_link_training(
3065 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF
3069 case SCU_EVENT_SATA_60:
3070 case SCU_EVENT_SATA_60_SSC:
3071 scic_sds_phy_complete_link_training(
3074 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF
3078 case SCU_EVENT_LINK_FAILURE:
3079 // Link failure change state back to the starting state
3080 scic_sds_phy_restart_starting_state(this_phy);
3083 case SCU_EVENT_SAS_PHY_DETECTED:
3084 // There has been a change in the phy type before OOB/SN for the
3085 // SATA finished start down the SAS link traning path.
3086 scic_sds_phy_start_sas_link_training(this_phy);
3091 sci_base_object_get_logger(this_phy),
3092 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
3093 "PHY starting substate machine recieved unexpected event_code %x\n",
3097 result = SCI_FAILURE;
3105 * This method is called when an event notification is received for the phy
3106 * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF.
3107 * - decode the event
3108 * - sas phy detected event backs up the state machine to the await
3109 * speed notification.
3110 * - identify timeout is an un-expected event and the state machine is
3112 * - link failure events restart the starting state machine
3113 * - any other events log a warning message and set a failure status
3115 * @param[in] phy This SCIC_SDS_PHY object which has received an event.
3116 * @param[in] event_code This is the event code which the phy object is to
3119 * @return SCI_STATUS
3120 * @retval SCI_SUCCESS on any valid event notification
3121 * @retval SCI_FAILURE on any unexpected event notifation
3124 SCI_STATUS scic_sds_phy_starting_substate_await_sig_fis_event_handler(
3125 SCIC_SDS_PHY_T *this_phy,
3129 U32 result = SCI_SUCCESS;
3131 switch (scu_get_event_code(event_code))
3133 case SCU_EVENT_SATA_PHY_DETECTED:
3134 // Backup the state machine
3135 sci_base_state_machine_change_state(
3136 scic_sds_phy_get_starting_substate_machine(this_phy),
3137 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN
3141 case SCU_EVENT_LINK_FAILURE:
3142 // Link failure change state back to the starting state
3143 scic_sds_phy_restart_starting_state(this_phy);
3148 sci_base_object_get_logger(this_phy),
3149 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_RECEIVED_EVENTS,
3150 "PHY starting substate machine recieved unexpected event_code %x\n",
3154 result = SCI_FAILURE;
3162 //*****************************************************************************
3163 //* SCIC SDS PHY FRAME_HANDLERS
3164 //*****************************************************************************
3167 * This method decodes the unsolicited frame when the SCIC_SDS_PHY is in the
3168 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF.
3169 * - Get the UF Header
3170 * - If the UF is an IAF
3171 * - Copy IAF data to local phy object IAF data buffer.
3172 * - Change starting substate to wait power.
3174 * - log warning message of unexpected unsolicted frame
3175 * - release frame buffer
3177 * @param[in] phy This is SCIC_SDS_PHY object which is being requested to
3178 * decode the frame data.
3179 * @param[in] frame_index This is the index of the unsolicited frame which was
3180 * received for this phy.
3182 * @return SCI_STATUS
3183 * @retval SCI_SUCCESS
3186 SCI_STATUS scic_sds_phy_starting_substate_await_iaf_uf_frame_handler(
3187 SCIC_SDS_PHY_T *this_phy,
3193 SCI_SAS_IDENTIFY_ADDRESS_FRAME_T *identify_frame;
3195 result = scic_sds_unsolicited_frame_control_get_header(
3196 &(scic_sds_phy_get_controller(this_phy)->uf_control),
3198 (void **)&frame_words);
3200 if (result != SCI_SUCCESS)
3205 frame_words[0] = SCIC_SWAP_DWORD(frame_words[0]);
3206 identify_frame = (SCI_SAS_IDENTIFY_ADDRESS_FRAME_T *)frame_words;
3208 if (identify_frame->address_frame_type == 0)
3210 // Byte swap the rest of the frame so we can make
3211 // a copy of the buffer
3212 frame_words[1] = SCIC_SWAP_DWORD(frame_words[1]);
3213 frame_words[2] = SCIC_SWAP_DWORD(frame_words[2]);
3214 frame_words[3] = SCIC_SWAP_DWORD(frame_words[3]);
3215 frame_words[4] = SCIC_SWAP_DWORD(frame_words[4]);
3216 frame_words[5] = SCIC_SWAP_DWORD(frame_words[5]);
3219 &this_phy->phy_type.sas.identify_address_frame_buffer,
3221 sizeof(SCI_SAS_IDENTIFY_ADDRESS_FRAME_T)
3224 if (identify_frame->protocols.u.bits.smp_target)
3226 // We got the IAF for an expander PHY go to the final state since
3227 // there are no power requirements for expander phys.
3228 sci_base_state_machine_change_state(
3229 scic_sds_phy_get_starting_substate_machine(this_phy),
3230 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
3235 // We got the IAF we can now go to the await spinup semaphore state
3236 sci_base_state_machine_change_state(
3237 scic_sds_phy_get_starting_substate_machine(this_phy),
3238 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
3242 result = SCI_SUCCESS;
3247 sci_base_object_get_logger(this_phy),
3248 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_UNSOLICITED_FRAMES,
3249 "PHY starting substate machine recieved unexpected frame id %x\n",
3254 // Regardless of the result release this frame since we are done with it
3255 scic_sds_controller_release_frame(
3256 scic_sds_phy_get_controller(this_phy), frame_index
3263 * This method decodes the unsolicited frame when the SCIC_SDS_PHY is in the
3264 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF.
3265 * - Get the UF Header
3266 * - If the UF is an SIGNATURE FIS
3267 * - Copy IAF data to local phy object SIGNATURE FIS data buffer.
3269 * - log warning message of unexpected unsolicted frame
3270 * - release frame buffer
3272 * @param[in] phy This is SCIC_SDS_PHY object which is being requested to
3273 * decode the frame data.
3274 * @param[in] frame_index This is the index of the unsolicited frame which was
3275 * received for this phy.
3277 * @return SCI_STATUS
3278 * @retval SCI_SUCCESS
3280 * @todo Must decode the SIGNATURE FIS data
3283 SCI_STATUS scic_sds_phy_starting_substate_await_sig_fis_frame_handler(
3284 SCIC_SDS_PHY_T *this_phy,
3290 SATA_FIS_HEADER_T * fis_frame_header;
3291 U32 * fis_frame_data;
3293 result = scic_sds_unsolicited_frame_control_get_header(
3294 &(scic_sds_phy_get_controller(this_phy)->uf_control),
3296 (void **)&frame_words);
3298 if (result != SCI_SUCCESS)
3303 fis_frame_header = (SATA_FIS_HEADER_T *)frame_words;
3306 (fis_frame_header->fis_type == SATA_FIS_TYPE_REGD2H)
3307 && !(fis_frame_header->status & ATA_STATUS_REG_BSY_BIT)
3310 scic_sds_unsolicited_frame_control_get_buffer(
3311 &(scic_sds_phy_get_controller(this_phy)->uf_control),
3313 (void **)&fis_frame_data
3316 scic_sds_controller_copy_sata_response(
3317 &this_phy->phy_type.sata.signature_fis_buffer,
3322 // We got the IAF we can now go to the await spinup semaphore state
3323 sci_base_state_machine_change_state(
3324 scic_sds_phy_get_starting_substate_machine(this_phy),
3325 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
3328 result = SCI_SUCCESS;
3333 sci_base_object_get_logger(this_phy),
3334 SCIC_LOG_OBJECT_PHY | SCIC_LOG_OBJECT_UNSOLICITED_FRAMES,
3335 "PHY starting substate machine recieved unexpected frame id %x\n",
3340 // Regardless of the result release this frame since we are done with it
3341 scic_sds_controller_release_frame(
3342 scic_sds_phy_get_controller(this_phy), frame_index
3348 //*****************************************************************************
3349 //* SCIC SDS PHY POWER_HANDLERS
3350 //*****************************************************************************
3353 * This method is called by the SCIC_SDS_CONTROLLER when the phy object is
3355 * - The notify enable spinups are turned on for this phy object
3356 * - The phy state machine is transitioned to the
3357 * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL.
3359 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
3360 * SCIC_SDS_PHY object.
3362 * @return SCI_STATUS
3363 * @retval SCI_SUCCESS
3366 SCI_STATUS scic_sds_phy_starting_substate_await_sas_power_consume_power_handler(
3367 SCIC_SDS_PHY_T *this_phy
3372 enable_spinup = SCU_SAS_ENSPINUP_READ(this_phy);
3373 enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
3374 SCU_SAS_ENSPINUP_WRITE(this_phy, enable_spinup);
3376 // Change state to the final state this substate machine has run to completion
3377 sci_base_state_machine_change_state(
3378 scic_sds_phy_get_starting_substate_machine(this_phy),
3379 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
3386 * This method is called by the SCIC_SDS_CONTROLLER when the phy object is
3388 * - The phy state machine is transitioned to the
3389 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN.
3391 * @param[in] phy This is the SCI_BASE_PHY object which is cast into a
3392 * SCIC_SDS_PHY object.
3394 * @return SCI_STATUS
3395 * @retval SCI_SUCCESS
3398 SCI_STATUS scic_sds_phy_starting_substate_await_sata_power_consume_power_handler(
3399 SCIC_SDS_PHY_T *this_phy
3402 U32 scu_sas_pcfg_value;
3404 // Release the spinup hold state and reset the OOB state machine
3405 scu_sas_pcfg_value = SCU_SAS_PCFG_READ(this_phy);
3406 scu_sas_pcfg_value &=
3407 ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
3408 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
3409 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
3411 // Now restart the OOB operation
3412 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
3413 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
3414 SCU_SAS_PCFG_WRITE(this_phy, scu_sas_pcfg_value);
3416 // Change state to the final state this substate machine has run to completion
3417 sci_base_state_machine_change_state(
3418 scic_sds_phy_get_starting_substate_machine(this_phy),
3419 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN
3425 // ---------------------------------------------------------------------------
3427 SCIC_SDS_PHY_STATE_HANDLER_T
3428 scic_sds_phy_starting_substate_handler_table[SCIC_SDS_PHY_STARTING_MAX_SUBSTATES] =
3430 // SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL
3433 scic_sds_phy_default_start_handler,
3434 scic_sds_phy_starting_substate_general_stop_handler,
3435 scic_sds_phy_default_reset_handler,
3436 scic_sds_phy_default_destroy_handler
3438 scic_sds_phy_default_frame_handler,
3439 scic_sds_phy_default_event_handler,
3440 scic_sds_phy_default_consume_power_handler
3442 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
3445 scic_sds_phy_default_start_handler,
3446 scic_sds_phy_starting_substate_general_stop_handler,
3447 scic_sds_phy_default_reset_handler,
3448 scic_sds_phy_default_destroy_handler
3450 scic_sds_phy_default_frame_handler,
3451 scic_sds_phy_starting_substate_await_ossp_event_handler,
3452 scic_sds_phy_default_consume_power_handler
3454 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
3457 scic_sds_phy_default_start_handler,
3458 scic_sds_phy_starting_substate_general_stop_handler,
3459 scic_sds_phy_default_reset_handler,
3460 scic_sds_phy_default_destroy_handler
3462 scic_sds_phy_default_frame_handler,
3463 scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
3464 scic_sds_phy_default_consume_power_handler
3466 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
3469 scic_sds_phy_default_start_handler,
3470 scic_sds_phy_default_stop_handler,
3471 scic_sds_phy_default_reset_handler,
3472 scic_sds_phy_default_destroy_handler
3474 scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
3475 scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
3476 scic_sds_phy_default_consume_power_handler
3478 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
3481 scic_sds_phy_default_start_handler,
3482 scic_sds_phy_starting_substate_general_stop_handler,
3483 scic_sds_phy_default_reset_handler,
3484 scic_sds_phy_default_destroy_handler
3486 scic_sds_phy_default_frame_handler,
3487 scic_sds_phy_starting_substate_await_sas_power_event_handler,
3488 scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
3490 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER,
3493 scic_sds_phy_default_start_handler,
3494 scic_sds_phy_starting_substate_general_stop_handler,
3495 scic_sds_phy_default_reset_handler,
3496 scic_sds_phy_default_destroy_handler
3498 scic_sds_phy_default_frame_handler,
3499 scic_sds_phy_starting_substate_await_sata_power_event_handler,
3500 scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
3502 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN,
3505 scic_sds_phy_default_start_handler,
3506 scic_sds_phy_starting_substate_general_stop_handler,
3507 scic_sds_phy_default_reset_handler,
3508 scic_sds_phy_default_destroy_handler
3510 scic_sds_phy_default_frame_handler,
3511 scic_sds_phy_starting_substate_await_sata_phy_event_handler,
3512 scic_sds_phy_default_consume_power_handler
3514 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN,
3517 scic_sds_phy_default_start_handler,
3518 scic_sds_phy_starting_substate_general_stop_handler,
3519 scic_sds_phy_default_reset_handler,
3520 scic_sds_phy_default_destroy_handler
3522 scic_sds_phy_default_frame_handler,
3523 scic_sds_phy_starting_substate_await_sata_speed_event_handler,
3524 scic_sds_phy_default_consume_power_handler
3526 // SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF,
3529 scic_sds_phy_default_start_handler,
3530 scic_sds_phy_starting_substate_general_stop_handler,
3531 scic_sds_phy_default_reset_handler,
3532 scic_sds_phy_default_destroy_handler
3534 scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
3535 scic_sds_phy_starting_substate_await_sig_fis_event_handler,
3536 scic_sds_phy_default_consume_power_handler
3538 // SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
3541 scic_sds_phy_default_start_handler,
3542 scic_sds_phy_starting_substate_general_stop_handler,
3543 scic_sds_phy_default_reset_handler,
3544 scic_sds_phy_default_destroy_handler
3546 scic_sds_phy_default_frame_handler,
3547 scic_sds_phy_default_event_handler,
3548 scic_sds_phy_default_consume_power_handler
3553 * This macro sets the starting substate handlers by state_id
3555 #define scic_sds_phy_set_starting_substate_handlers(phy, state_id) \
3556 scic_sds_phy_set_state_handlers( \
3558 &scic_sds_phy_starting_substate_handler_table[(state_id)] \
3561 //****************************************************************************
3562 //* PHY STARTING SUBSTATE METHODS
3563 //****************************************************************************
3566 * This method will perform the actions required by the SCIC_SDS_PHY on
3567 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL.
3568 * - The initial state handlers are put in place for the SCIC_SDS_PHY
3570 * - The state is changed to the wait phy type event notification.
3572 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3573 * SCIC_SDS_PHY object.
3578 void scic_sds_phy_starting_initial_substate_enter(
3579 SCI_BASE_OBJECT_T *object
3582 SCIC_SDS_PHY_T *this_phy;
3583 this_phy = (SCIC_SDS_PHY_T *)object;
3585 scic_sds_phy_set_starting_substate_handlers(
3586 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
3588 // This is just an temporary state go off to the starting state
3589 sci_base_state_machine_change_state(
3590 scic_sds_phy_get_starting_substate_machine(this_phy),
3591 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
3596 * This method will perform the actions required by the SCIC_SDS_PHY on
3597 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_PHY_TYPE_EN.
3598 * - Set the SCIC_SDS_PHY object state handlers for this state.
3600 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3601 * SCIC_SDS_PHY object.
3606 void scic_sds_phy_starting_await_ossp_en_substate_enter(
3607 SCI_BASE_OBJECT_T *object
3610 SCIC_SDS_PHY_T *this_phy;
3611 this_phy = (SCIC_SDS_PHY_T *)object;
3613 scic_sds_phy_set_starting_substate_handlers(
3614 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
3619 * This method will perform the actions required by the SCIC_SDS_PHY on
3620 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN.
3621 * - Set the SCIC_SDS_PHY object state handlers for this state.
3623 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3624 * SCIC_SDS_PHY object.
3629 void scic_sds_phy_starting_await_sas_speed_en_substate_enter(
3630 SCI_BASE_OBJECT_T *object
3633 SCIC_SDS_PHY_T *this_phy;
3634 this_phy = (SCIC_SDS_PHY_T *)object;
3636 scic_sds_phy_set_starting_substate_handlers(
3637 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
3642 * This method will perform the actions required by the SCIC_SDS_PHY on
3643 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF.
3644 * - Set the SCIC_SDS_PHY object state handlers for this state.
3646 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3647 * SCIC_SDS_PHY object.
3652 void scic_sds_phy_starting_await_iaf_uf_substate_enter(
3653 SCI_BASE_OBJECT_T *object
3656 SCIC_SDS_PHY_T *this_phy;
3657 this_phy = (SCIC_SDS_PHY_T *)object;
3659 scic_sds_phy_set_starting_substate_handlers(
3660 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
3665 * This method will perform the actions required by the SCIC_SDS_PHY on
3666 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER.
3667 * - Set the SCIC_SDS_PHY object state handlers for this state.
3668 * - Add this phy object to the power control queue
3670 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3671 * SCIC_SDS_PHY object.
3676 void scic_sds_phy_starting_await_sas_power_substate_enter(
3677 SCI_BASE_OBJECT_T *object
3680 SCIC_SDS_PHY_T *this_phy;
3681 this_phy = (SCIC_SDS_PHY_T *)object;
3683 scic_sds_phy_set_starting_substate_handlers(
3684 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
3687 scic_sds_controller_power_control_queue_insert(
3688 scic_sds_phy_get_controller(this_phy),
3694 * This method will perform the actions required by the SCIC_SDS_PHY on
3695 * exiting the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER.
3696 * - Remove the SCIC_SDS_PHY object from the power control queue.
3698 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3699 * SCIC_SDS_PHY object.
3704 void scic_sds_phy_starting_await_sas_power_substate_exit(
3705 SCI_BASE_OBJECT_T *object
3708 SCIC_SDS_PHY_T *this_phy;
3709 this_phy = (SCIC_SDS_PHY_T *)object;
3711 scic_sds_controller_power_control_queue_remove(
3712 scic_sds_phy_get_controller(this_phy), this_phy
3717 * This method will perform the actions required by the SCIC_SDS_PHY on
3718 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER.
3719 * - Set the SCIC_SDS_PHY object state handlers for this state.
3720 * - Add this phy object to the power control queue
3722 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3723 * SCIC_SDS_PHY object.
3728 void scic_sds_phy_starting_await_sata_power_substate_enter(
3729 SCI_BASE_OBJECT_T *object
3732 SCIC_SDS_PHY_T *this_phy;
3733 this_phy = (SCIC_SDS_PHY_T *)object;
3735 scic_sds_phy_set_starting_substate_handlers(
3736 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
3739 scic_sds_controller_power_control_queue_insert(
3740 scic_sds_phy_get_controller(this_phy),
3746 * This method will perform the actions required by the SCIC_SDS_PHY on
3747 * exiting the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER.
3748 * - Remove the SCIC_SDS_PHY object from the power control queue.
3750 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3751 * SCIC_SDS_PHY object.
3756 void scic_sds_phy_starting_await_sata_power_substate_exit(
3757 SCI_BASE_OBJECT_T *object
3760 SCIC_SDS_PHY_T *this_phy;
3761 this_phy = (SCIC_SDS_PHY_T *)object;
3763 scic_sds_controller_power_control_queue_remove(
3764 scic_sds_phy_get_controller(this_phy),
3770 * This method will perform the actions required by the SCIC_SDS_PHY on
3771 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN.
3772 * - Set the SCIC_SDS_PHY object state handlers for this state.
3774 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3775 * SCIC_SDS_PHY object.
3780 void scic_sds_phy_starting_await_sata_phy_substate_enter(
3781 SCI_BASE_OBJECT_T *object
3784 SCIC_SDS_PHY_T *this_phy;
3785 this_phy = (SCIC_SDS_PHY_T *)object;
3787 scic_sds_phy_set_starting_substate_handlers(
3788 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN
3791 scic_cb_timer_start(
3792 scic_sds_phy_get_controller(this_phy),
3793 this_phy->sata_timeout_timer,
3794 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT
3799 * This method will perform the actions required by the SCIC_SDS_PHY on
3800 * exiting the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN.
3801 * - stop the timer that was started on entry to await sata phy
3802 * event notification
3804 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3805 * SCIC_SDS_PHY object.
3810 void scic_sds_phy_starting_await_sata_phy_substate_exit(
3811 SCI_BASE_OBJECT_T *object
3814 SCIC_SDS_PHY_T *this_phy;
3815 this_phy = (SCIC_SDS_PHY_T *)object;
3818 scic_sds_phy_get_controller(this_phy),
3819 this_phy->sata_timeout_timer
3824 * This method will perform the actions required by the SCIC_SDS_PHY on
3825 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN.
3826 * - Set the SCIC_SDS_PHY object state handlers for this state.
3828 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3829 * SCIC_SDS_PHY object.
3834 void scic_sds_phy_starting_await_sata_speed_substate_enter(
3835 SCI_BASE_OBJECT_T *object
3838 SCIC_SDS_PHY_T *this_phy;
3839 this_phy = (SCIC_SDS_PHY_T *)object;
3841 scic_sds_phy_set_starting_substate_handlers(
3842 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN
3845 scic_cb_timer_start(
3846 scic_sds_phy_get_controller(this_phy),
3847 this_phy->sata_timeout_timer,
3848 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT
3853 * This method will perform the actions required by the SCIC_SDS_PHY on
3854 * exiting the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN.
3855 * - stop the timer that was started on entry to await sata phy
3856 * event notification
3858 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3859 * SCIC_SDS_PHY object.
3864 void scic_sds_phy_starting_await_sata_speed_substate_exit(
3865 SCI_BASE_OBJECT_T *object
3868 SCIC_SDS_PHY_T *this_phy;
3869 this_phy = (SCIC_SDS_PHY_T *)object;
3872 scic_sds_phy_get_controller(this_phy),
3873 this_phy->sata_timeout_timer
3878 * This method will perform the actions required by the SCIC_SDS_PHY on
3879 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF.
3880 * - Set the SCIC_SDS_PHY object state handlers for this state.
3881 * - Start the SIGNATURE FIS timeout timer
3883 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3884 * SCIC_SDS_PHY object.
3889 void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(
3890 SCI_BASE_OBJECT_T *object
3893 BOOL continue_to_ready_state;
3894 SCIC_SDS_PHY_T * this_phy;
3896 this_phy = (SCIC_SDS_PHY_T *)object;
3898 scic_sds_phy_set_starting_substate_handlers(
3899 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF
3902 continue_to_ready_state = scic_sds_port_link_detected(
3903 this_phy->owning_port,
3907 if (continue_to_ready_state)
3909 // Clear the PE suspend condition so we can actually receive SIG FIS
3910 // The hardware will not respond to the XRDY until the PE suspend
3911 // condition is cleared.
3912 scic_sds_phy_resume(this_phy);
3914 scic_cb_timer_start(
3915 scic_sds_phy_get_controller(this_phy),
3916 this_phy->sata_timeout_timer,
3917 SCIC_SDS_SIGNATURE_FIS_TIMEOUT
3922 this_phy->is_in_link_training = FALSE;
3927 * This method will perform the actions required by the SCIC_SDS_PHY on
3928 * exiting the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF.
3929 * - Stop the SIGNATURE FIS timeout timer.
3931 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3932 * SCIC_SDS_PHY object.
3937 void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(
3938 SCI_BASE_OBJECT_T *object
3941 SCIC_SDS_PHY_T *this_phy;
3942 this_phy = (SCIC_SDS_PHY_T *)object;
3945 scic_sds_phy_get_controller(this_phy),
3946 this_phy->sata_timeout_timer
3951 * This method will perform the actions required by the SCIC_SDS_PHY on
3952 * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL.
3953 * - Set the SCIC_SDS_PHY object state handlers for this state.
3954 * - Change base state machine to the ready state.
3956 * @param[in] object This is the SCI_BASE_OBJECT which is cast to a
3957 * SCIC_SDS_PHY object.
3962 void scic_sds_phy_starting_final_substate_enter(
3963 SCI_BASE_OBJECT_T *object
3966 SCIC_SDS_PHY_T *this_phy;
3967 this_phy = (SCIC_SDS_PHY_T *)object;
3969 scic_sds_phy_set_starting_substate_handlers(
3970 this_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL
3973 // State machine has run to completion so exit out and change
3974 // the base state machine to the ready state
3975 sci_base_state_machine_change_state(
3976 scic_sds_phy_get_base_state_machine(this_phy),
3977 SCI_BASE_PHY_STATE_READY);
3980 // ---------------------------------------------------------------------------
3983 scic_sds_phy_starting_substates[SCIC_SDS_PHY_STARTING_MAX_SUBSTATES] =
3986 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL,
3987 scic_sds_phy_starting_initial_substate_enter,
3991 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN,
3992 scic_sds_phy_starting_await_ossp_en_substate_enter,
3996 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN,
3997 scic_sds_phy_starting_await_sas_speed_en_substate_enter,
4001 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF,
4002 scic_sds_phy_starting_await_iaf_uf_substate_enter,
4006 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER,
4007 scic_sds_phy_starting_await_sas_power_substate_enter,
4008 scic_sds_phy_starting_await_sas_power_substate_exit,
4011 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER,
4012 scic_sds_phy_starting_await_sata_power_substate_enter,
4013 scic_sds_phy_starting_await_sata_power_substate_exit
4016 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN,
4017 scic_sds_phy_starting_await_sata_phy_substate_enter,
4018 scic_sds_phy_starting_await_sata_phy_substate_exit
4021 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN,
4022 scic_sds_phy_starting_await_sata_speed_substate_enter,
4023 scic_sds_phy_starting_await_sata_speed_substate_exit
4026 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF,
4027 scic_sds_phy_starting_await_sig_fis_uf_substate_enter,
4028 scic_sds_phy_starting_await_sig_fis_uf_substate_exit
4031 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL,
4032 scic_sds_phy_starting_final_substate_enter,