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
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 #include <linux/device.h>
57 #include "scic_controller.h"
59 #include "scic_port.h"
60 #include "scic_remote_device.h"
61 #include "scic_sds_controller.h"
62 #include "scic_sds_controller_registers.h"
63 #include "scic_sds_pci.h"
64 #include "scic_sds_phy.h"
65 #include "scic_sds_port_configuration_agent.h"
66 #include "scic_sds_port.h"
67 #include "scic_sds_remote_device.h"
68 #include "scic_sds_request.h"
69 #include "sci_environment.h"
71 #include "scu_completion_codes.h"
72 #include "scu_constants.h"
73 #include "scu_event_codes.h"
74 #include "scu_remote_node_context.h"
75 #include "scu_task_context.h"
76 #include "scu_unsolicited_frame.h"
78 #define SCU_CONTEXT_RAM_INIT_STALL_TIME 200
81 * smu_dcc_get_max_ports() -
83 * This macro returns the maximum number of logical ports supported by the
84 * hardware. The caller passes in the value read from the device context
85 * capacity register and this macro will mash and shift the value appropriately.
87 #define smu_dcc_get_max_ports(dcc_value) \
89 (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_MASK) \
90 >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_SHIFT) + 1 \
94 * smu_dcc_get_max_task_context() -
96 * This macro returns the maximum number of task contexts supported by the
97 * hardware. The caller passes in the value read from the device context
98 * capacity register and this macro will mash and shift the value appropriately.
100 #define smu_dcc_get_max_task_context(dcc_value) \
102 (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_MASK) \
103 >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_SHIFT) + 1 \
107 * smu_dcc_get_max_remote_node_context() -
109 * This macro returns the maximum number of remote node contexts supported by
110 * the hardware. The caller passes in the value read from the device context
111 * capacity register and this macro will mash and shift the value appropriately.
113 #define smu_dcc_get_max_remote_node_context(dcc_value) \
115 (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_MASK) \
116 >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_SHIFT) + 1 \
120 static void scic_sds_controller_power_control_timer_handler(
122 #define SCIC_SDS_CONTROLLER_MIN_TIMER_COUNT 3
123 #define SCIC_SDS_CONTROLLER_MAX_TIMER_COUNT 3
128 * The number of milliseconds to wait for a phy to start.
130 #define SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT 100
135 * The number of milliseconds to wait while a given phy is consuming power
136 * before allowing another set of phys to consume power. Ultimately, this will
137 * be specified by OEM parameter.
139 #define SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL 500
142 * COMPLETION_QUEUE_CYCLE_BIT() -
144 * This macro will return the cycle bit of the completion queue entry
146 #define COMPLETION_QUEUE_CYCLE_BIT(x) ((x) & 0x80000000)
149 * NORMALIZE_GET_POINTER() -
151 * This macro will normalize the completion queue get pointer so its value can
152 * be used as an index into an array
154 #define NORMALIZE_GET_POINTER(x) \
155 ((x) & SMU_COMPLETION_QUEUE_GET_POINTER_MASK)
158 * NORMALIZE_PUT_POINTER() -
160 * This macro will normalize the completion queue put pointer so its value can
161 * be used as an array inde
163 #define NORMALIZE_PUT_POINTER(x) \
164 ((x) & SMU_COMPLETION_QUEUE_PUT_POINTER_MASK)
168 * NORMALIZE_GET_POINTER_CYCLE_BIT() -
170 * This macro will normalize the completion queue cycle pointer so it matches
171 * the completion queue cycle bit
173 #define NORMALIZE_GET_POINTER_CYCLE_BIT(x) \
174 ((SMU_CQGR_CYCLE_BIT & (x)) << (31 - SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_SHIFT))
177 * NORMALIZE_EVENT_POINTER() -
179 * This macro will normalize the completion queue event entry so its value can
180 * be used as an index.
182 #define NORMALIZE_EVENT_POINTER(x) \
184 ((x) & SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_MASK) \
185 >> SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_SHIFT \
189 * INCREMENT_COMPLETION_QUEUE_GET() -
191 * This macro will increment the controllers completion queue index value and
192 * possibly toggle the cycle bit if the completion queue index wraps back to 0.
194 #define INCREMENT_COMPLETION_QUEUE_GET(controller, index, cycle) \
195 INCREMENT_QUEUE_GET(\
198 (controller)->completion_queue_entries, \
203 * INCREMENT_EVENT_QUEUE_GET() -
205 * This macro will increment the controllers event queue index value and
206 * possibly toggle the event cycle bit if the event queue index wraps back to 0.
208 #define INCREMENT_EVENT_QUEUE_GET(controller, index, cycle) \
209 INCREMENT_QUEUE_GET(\
212 (controller)->completion_event_entries, \
213 SMU_CQGR_EVENT_CYCLE_BIT \
216 struct sci_base_memory_descriptor_list *
217 sci_controller_get_memory_descriptor_list_handle(struct scic_sds_controller *scic)
219 return &scic->parent.mdl;
223 * ****************************************************************************-
224 * * SCIC SDS Controller Initialization Methods
225 * ****************************************************************************- */
228 * This timer is used to start another phy after we have given up on the
229 * previous phy to transition to the ready state.
233 static void scic_sds_controller_phy_startup_timeout_handler(
236 enum sci_status status;
237 struct scic_sds_controller *this_controller;
239 this_controller = (struct scic_sds_controller *)controller;
241 this_controller->phy_startup_timer_pending = false;
243 status = SCI_FAILURE;
245 while (status != SCI_SUCCESS) {
246 status = scic_sds_controller_start_next_phy(this_controller);
253 * This method initializes the phy startup operations for controller start.
255 enum sci_status scic_sds_controller_initialize_phy_startup(
256 struct scic_sds_controller *this_controller)
258 this_controller->phy_startup_timer = isci_event_timer_create(
260 scic_sds_controller_phy_startup_timeout_handler,
264 if (this_controller->phy_startup_timer == NULL) {
265 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
267 this_controller->next_phy_to_start = 0;
268 this_controller->phy_startup_timer_pending = false;
277 * This method initializes the power control operations for the controller
280 void scic_sds_controller_initialize_power_control(
281 struct scic_sds_controller *this_controller)
283 this_controller->power_control.timer = isci_event_timer_create(
285 scic_sds_controller_power_control_timer_handler,
290 this_controller->power_control.requesters,
292 sizeof(this_controller->power_control.requesters)
295 this_controller->power_control.phys_waiting = 0;
296 this_controller->power_control.phys_granted_power = 0;
299 /* --------------------------------------------------------------------------- */
301 #define SCU_REMOTE_NODE_CONTEXT_ALIGNMENT (32)
302 #define SCU_TASK_CONTEXT_ALIGNMENT (256)
303 #define SCU_UNSOLICITED_FRAME_ADDRESS_ALIGNMENT (64)
304 #define SCU_UNSOLICITED_FRAME_BUFFER_ALIGNMENT (1024)
305 #define SCU_UNSOLICITED_FRAME_HEADER_ALIGNMENT (64)
307 /* --------------------------------------------------------------------------- */
310 * This method builds the memory descriptor table for this controller.
311 * @this_controller: This parameter specifies the controller object for which
312 * to build the memory table.
315 void scic_sds_controller_build_memory_descriptor_table(
316 struct scic_sds_controller *this_controller)
318 sci_base_mde_construct(
319 &this_controller->memory_descriptors[SCU_MDE_COMPLETION_QUEUE],
320 SCU_COMPLETION_RAM_ALIGNMENT,
321 (sizeof(u32) * this_controller->completion_queue_entries),
322 (SCI_MDE_ATTRIBUTE_CACHEABLE | SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS)
325 sci_base_mde_construct(
326 &this_controller->memory_descriptors[SCU_MDE_REMOTE_NODE_CONTEXT],
327 SCU_REMOTE_NODE_CONTEXT_ALIGNMENT,
328 this_controller->remote_node_entries * sizeof(union scu_remote_node_context),
329 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
332 sci_base_mde_construct(
333 &this_controller->memory_descriptors[SCU_MDE_TASK_CONTEXT],
334 SCU_TASK_CONTEXT_ALIGNMENT,
335 this_controller->task_context_entries * sizeof(struct scu_task_context),
336 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
340 * The UF buffer address table size must be programmed to a power
341 * of 2. Find the first power of 2 that is equal to or greater then
342 * the number of unsolicited frame buffers to be utilized. */
343 scic_sds_unsolicited_frame_control_set_address_table_count(
344 &this_controller->uf_control
347 sci_base_mde_construct(
348 &this_controller->memory_descriptors[SCU_MDE_UF_BUFFER],
349 SCU_UNSOLICITED_FRAME_BUFFER_ALIGNMENT,
350 scic_sds_unsolicited_frame_control_get_mde_size(this_controller->uf_control),
351 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
356 * This method validates the driver supplied memory descriptor table.
361 enum sci_status scic_sds_controller_validate_memory_descriptor_table(
362 struct scic_sds_controller *this_controller)
366 mde_list_valid = sci_base_mde_is_valid(
367 &this_controller->memory_descriptors[SCU_MDE_COMPLETION_QUEUE],
368 SCU_COMPLETION_RAM_ALIGNMENT,
369 (sizeof(u32) * this_controller->completion_queue_entries),
370 (SCI_MDE_ATTRIBUTE_CACHEABLE | SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS)
373 if (mde_list_valid == false)
374 return SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD;
376 mde_list_valid = sci_base_mde_is_valid(
377 &this_controller->memory_descriptors[SCU_MDE_REMOTE_NODE_CONTEXT],
378 SCU_REMOTE_NODE_CONTEXT_ALIGNMENT,
379 this_controller->remote_node_entries * sizeof(union scu_remote_node_context),
380 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
383 if (mde_list_valid == false)
384 return SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD;
386 mde_list_valid = sci_base_mde_is_valid(
387 &this_controller->memory_descriptors[SCU_MDE_TASK_CONTEXT],
388 SCU_TASK_CONTEXT_ALIGNMENT,
389 this_controller->task_context_entries * sizeof(struct scu_task_context),
390 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
393 if (mde_list_valid == false)
394 return SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD;
396 mde_list_valid = sci_base_mde_is_valid(
397 &this_controller->memory_descriptors[SCU_MDE_UF_BUFFER],
398 SCU_UNSOLICITED_FRAME_BUFFER_ALIGNMENT,
399 scic_sds_unsolicited_frame_control_get_mde_size(this_controller->uf_control),
400 SCI_MDE_ATTRIBUTE_PHYSICALLY_CONTIGUOUS
403 if (mde_list_valid == false)
404 return SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD;
410 * This method initializes the controller with the physical memory addresses
411 * that are used to communicate with the driver.
415 void scic_sds_controller_ram_initialization(
416 struct scic_sds_controller *this_controller)
418 struct sci_physical_memory_descriptor *mde;
421 * The completion queue is actually placed in cacheable memory
422 * Therefore it no longer comes out of memory in the MDL. */
423 mde = &this_controller->memory_descriptors[SCU_MDE_COMPLETION_QUEUE];
424 this_controller->completion_queue = (u32 *)mde->virtual_address;
425 SMU_CQBAR_WRITE(this_controller, mde->physical_address);
428 * Program the location of the Remote Node Context table
430 mde = &this_controller->memory_descriptors[SCU_MDE_REMOTE_NODE_CONTEXT];
431 this_controller->remote_node_context_table = (union scu_remote_node_context *)
432 mde->virtual_address;
433 SMU_RNCBAR_WRITE(this_controller, mde->physical_address);
435 /* Program the location of the Task Context table into the SCU. */
436 mde = &this_controller->memory_descriptors[SCU_MDE_TASK_CONTEXT];
437 this_controller->task_context_table = (struct scu_task_context *)
438 mde->virtual_address;
439 SMU_HTTBAR_WRITE(this_controller, mde->physical_address);
441 mde = &this_controller->memory_descriptors[SCU_MDE_UF_BUFFER];
442 scic_sds_unsolicited_frame_control_construct(
443 &this_controller->uf_control, mde, this_controller
447 * Inform the silicon as to the location of the UF headers and
451 this_controller->uf_control.headers.physical_address);
454 this_controller->uf_control.address_table.physical_address);
458 * This method initializes the task context data for the controller.
462 void scic_sds_controller_assign_task_entries(
463 struct scic_sds_controller *this_controller)
468 * Assign all the TCs to function 0
469 * TODO: Do we actually need to read this register to write it back? */
470 task_assignment = SMU_TCA_READ(this_controller, 0);
475 | (SMU_TCA_GEN_VAL(STARTING, 0))
476 | (SMU_TCA_GEN_VAL(ENDING, this_controller->task_context_entries - 1))
477 | (SMU_TCA_GEN_BIT(RANGE_CHECK_ENABLE))
480 SMU_TCA_WRITE(this_controller, 0, task_assignment);
484 * This method initializes the hardware completion queue.
488 void scic_sds_controller_initialize_completion_queue(
489 struct scic_sds_controller *this_controller)
492 u32 completion_queue_control_value;
493 u32 completion_queue_get_value;
494 u32 completion_queue_put_value;
496 this_controller->completion_queue_get = 0;
498 completion_queue_control_value = (
499 SMU_CQC_QUEUE_LIMIT_SET(this_controller->completion_queue_entries - 1)
500 | SMU_CQC_EVENT_LIMIT_SET(this_controller->completion_event_entries - 1)
503 SMU_CQC_WRITE(this_controller, completion_queue_control_value);
505 /* Set the completion queue get pointer and enable the queue */
506 completion_queue_get_value = (
507 (SMU_CQGR_GEN_VAL(POINTER, 0))
508 | (SMU_CQGR_GEN_VAL(EVENT_POINTER, 0))
509 | (SMU_CQGR_GEN_BIT(ENABLE))
510 | (SMU_CQGR_GEN_BIT(EVENT_ENABLE))
513 SMU_CQGR_WRITE(this_controller, completion_queue_get_value);
515 /* Set the completion queue put pointer */
516 completion_queue_put_value = (
517 (SMU_CQPR_GEN_VAL(POINTER, 0))
518 | (SMU_CQPR_GEN_VAL(EVENT_POINTER, 0))
521 SMU_CQPR_WRITE(this_controller, completion_queue_put_value);
523 /* Initialize the cycle bit of the completion queue entries */
524 for (index = 0; index < this_controller->completion_queue_entries; index++) {
526 * If get.cycle_bit != completion_queue.cycle_bit
527 * its not a valid completion queue entry
528 * so at system start all entries are invalid */
529 this_controller->completion_queue[index] = 0x80000000;
534 * This method initializes the hardware unsolicited frame queue.
538 void scic_sds_controller_initialize_unsolicited_frame_queue(
539 struct scic_sds_controller *this_controller)
541 u32 frame_queue_control_value;
542 u32 frame_queue_get_value;
543 u32 frame_queue_put_value;
545 /* Write the queue size */
546 frame_queue_control_value =
547 SCU_UFQC_GEN_VAL(QUEUE_SIZE, this_controller->uf_control.address_table.count);
549 SCU_UFQC_WRITE(this_controller, frame_queue_control_value);
551 /* Setup the get pointer for the unsolicited frame queue */
552 frame_queue_get_value = (
553 SCU_UFQGP_GEN_VAL(POINTER, 0)
554 | SCU_UFQGP_GEN_BIT(ENABLE_BIT)
557 SCU_UFQGP_WRITE(this_controller, frame_queue_get_value);
559 /* Setup the put pointer for the unsolicited frame queue */
560 frame_queue_put_value = SCU_UFQPP_GEN_VAL(POINTER, 0);
562 SCU_UFQPP_WRITE(this_controller, frame_queue_put_value);
566 * This method enables the hardware port task scheduler.
570 void scic_sds_controller_enable_port_task_scheduler(
571 struct scic_sds_controller *this_controller)
573 u32 port_task_scheduler_value;
575 port_task_scheduler_value = SCU_PTSGCR_READ(this_controller);
577 port_task_scheduler_value |=
578 (SCU_PTSGCR_GEN_BIT(ETM_ENABLE) | SCU_PTSGCR_GEN_BIT(PTSG_ENABLE));
580 SCU_PTSGCR_WRITE(this_controller, port_task_scheduler_value);
583 /* --------------------------------------------------------------------------- */
588 * This macro is used to delay between writes to the AFE registers during AFE
591 #define AFE_REGISTER_WRITE_DELAY 10
593 /* Initialize the AFE for this phy index. We need to read the AFE setup from
594 * the OEM parameters none
596 void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic)
601 /* Clear DFX Status registers */
602 scu_afe_register_write(scic, afe_dfx_master_control0, 0x0081000f);
603 udelay(AFE_REGISTER_WRITE_DELAY);
605 /* Configure bias currents to normal */
607 scu_afe_register_write(scic, afe_bias_control, 0x00005500);
609 scu_afe_register_write(scic, afe_bias_control, 0x00005A00);
611 udelay(AFE_REGISTER_WRITE_DELAY);
615 scu_afe_register_write(scic, afe_pll_control0, 0x80040A08);
617 scu_afe_register_write(scic, afe_pll_control0, 0x80040908);
619 udelay(AFE_REGISTER_WRITE_DELAY);
621 /* Wait for the PLL to lock */
623 afe_status = scu_afe_register_read(
624 scic, afe_common_block_status);
625 udelay(AFE_REGISTER_WRITE_DELAY);
626 } while ((afe_status & 0x00001000) == 0);
629 /* Shorten SAS SNW lock time (RxLock timer value from 76 us to 50 us) */
630 scu_afe_register_write(scic, afe_pmsn_master_control0, 0x7bcc96ad);
631 udelay(AFE_REGISTER_WRITE_DELAY);
634 for (phy_id = 0; phy_id < SCI_MAX_PHYS; phy_id++) {
636 /* Configure transmitter SSC parameters */
637 scu_afe_txreg_write(scic, phy_id, afe_tx_ssc_control, 0x00030000);
638 udelay(AFE_REGISTER_WRITE_DELAY);
641 * All defaults, except the Receive Word Alignament/Comma Detect
642 * Enable....(0xe800) */
643 scu_afe_txreg_write(scic, phy_id, afe_xcvr_control0, 0x00004512);
644 udelay(AFE_REGISTER_WRITE_DELAY);
646 scu_afe_txreg_write(scic, phy_id, afe_xcvr_control1, 0x0050100F);
647 udelay(AFE_REGISTER_WRITE_DELAY);
651 * Power up TX and RX out from power down (PWRDNTX and PWRDNRX)
652 * & increase TX int & ext bias 20%....(0xe85c) */
654 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003D4);
656 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003F0);
658 /* Power down TX and RX (PWRDNTX and PWRDNRX) */
659 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003d7);
660 udelay(AFE_REGISTER_WRITE_DELAY);
663 * Power up TX and RX out from power down (PWRDNTX and PWRDNRX)
664 * & increase TX int & ext bias 20%....(0xe85c) */
665 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003d4);
667 udelay(AFE_REGISTER_WRITE_DELAY);
669 if (is_a0() || is_a2()) {
670 /* Enable TX equalization (0xe824) */
671 scu_afe_txreg_write(scic, phy_id, afe_tx_control, 0x00040000);
672 udelay(AFE_REGISTER_WRITE_DELAY);
676 * RDPI=0x0(RX Power On), RXOOBDETPDNC=0x0, TPD=0x0(TX Power On),
677 * RDD=0x0(RX Detect Enabled) ....(0xe800) */
678 scu_afe_txreg_write(scic, phy_id, afe_xcvr_control0, 0x00004100);
679 udelay(AFE_REGISTER_WRITE_DELAY);
681 /* Leave DFE/FFE on */
683 scu_afe_txreg_write(scic, phy_id, afe_rx_ssc_control0, 0x3F09983F);
685 scu_afe_txreg_write(scic, phy_id, afe_rx_ssc_control0, 0x3F11103F);
687 scu_afe_txreg_write(scic, phy_id, afe_rx_ssc_control0, 0x3F11103F);
688 udelay(AFE_REGISTER_WRITE_DELAY);
689 /* Enable TX equalization (0xe824) */
690 scu_afe_txreg_write(scic, phy_id, afe_tx_control, 0x00040000);
692 udelay(AFE_REGISTER_WRITE_DELAY);
694 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, 0x000E7C03);
695 udelay(AFE_REGISTER_WRITE_DELAY);
697 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control1, 0x000E7C03);
698 udelay(AFE_REGISTER_WRITE_DELAY);
700 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control2, 0x000E7C03);
701 udelay(AFE_REGISTER_WRITE_DELAY);
703 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control3, 0x000E7C03);
704 udelay(AFE_REGISTER_WRITE_DELAY);
707 /* Transfer control to the PEs */
708 scu_afe_register_write(scic, afe_dfx_master_control0, 0x00010f00);
709 udelay(AFE_REGISTER_WRITE_DELAY);
713 * ****************************************************************************-
714 * * SCIC SDS Controller Internal Start/Stop Routines
715 * ****************************************************************************- */
719 * This method will attempt to transition into the ready state for the
720 * controller and indicate that the controller start operation has completed
721 * if all criteria are met.
722 * @this_controller: This parameter indicates the controller object for which
723 * to transition to ready.
724 * @status: This parameter indicates the status value to be pass into the call
725 * to scic_cb_controller_start_complete().
729 static void scic_sds_controller_transition_to_ready(
730 struct scic_sds_controller *this_controller,
731 enum sci_status status)
733 if (this_controller->parent.state_machine.current_state_id
734 == SCI_BASE_CONTROLLER_STATE_STARTING) {
736 * We move into the ready state, because some of the phys/ports
737 * may be up and operational. */
738 sci_base_state_machine_change_state(
739 scic_sds_controller_get_base_state_machine(this_controller),
740 SCI_BASE_CONTROLLER_STATE_READY
743 isci_event_controller_start_complete(this_controller, status);
748 * This method is the general timeout handler for the controller. It will take
749 * the correct timetout action based on the current controller state
751 void scic_sds_controller_timeout_handler(
752 struct scic_sds_controller *scic)
754 enum sci_base_controller_states current_state;
756 current_state = sci_base_state_machine_get_state(
757 scic_sds_controller_get_base_state_machine(scic));
759 if (current_state == SCI_BASE_CONTROLLER_STATE_STARTING) {
760 scic_sds_controller_transition_to_ready(
761 scic, SCI_FAILURE_TIMEOUT);
762 } else if (current_state == SCI_BASE_CONTROLLER_STATE_STOPPING) {
763 sci_base_state_machine_change_state(
764 scic_sds_controller_get_base_state_machine(scic),
765 SCI_BASE_CONTROLLER_STATE_FAILED);
766 isci_event_controller_stop_complete(scic, SCI_FAILURE_TIMEOUT);
767 } else /* / @todo Now what do we want to do in this case? */
768 dev_err(scic_to_dev(scic),
769 "%s: Controller timer fired when controller was not "
770 "in a state being timed.\n",
774 enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller *scic)
777 enum sci_status port_status;
778 enum sci_status status = SCI_SUCCESS;
780 for (index = 0; index < scic->logical_port_entries; index++) {
781 struct scic_sds_port *sci_port = &scic->port_table[index];
782 SCI_BASE_PORT_HANDLER_T stop;
784 stop = sci_port->state_handlers->parent.stop_handler;
785 port_status = stop(&sci_port->parent);
787 if ((port_status != SCI_SUCCESS) &&
788 (port_status != SCI_FAILURE_INVALID_STATE)) {
789 status = SCI_FAILURE;
791 dev_warn(scic_to_dev(scic),
792 "%s: Controller stop operation failed to "
793 "stop port %d because of status %d.\n",
795 sci_port->logical_port_index,
808 static void scic_sds_controller_phy_timer_start(
809 struct scic_sds_controller *this_controller)
811 isci_event_timer_start(
813 this_controller->phy_startup_timer,
814 SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT
817 this_controller->phy_startup_timer_pending = true;
825 void scic_sds_controller_phy_timer_stop(
826 struct scic_sds_controller *this_controller)
828 isci_event_timer_stop(
830 this_controller->phy_startup_timer
833 this_controller->phy_startup_timer_pending = false;
837 * This method is called internally by the controller object to start the next
838 * phy on the controller. If all the phys have been started, then this
839 * method will attempt to transition the controller to the READY state and
840 * inform the user (scic_cb_controller_start_complete()).
841 * @this_controller: This parameter specifies the controller object for which
842 * to start the next phy.
846 enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *scic)
848 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
849 struct scic_sds_phy *sci_phy;
850 enum sci_status status;
852 status = SCI_SUCCESS;
854 if (scic->phy_startup_timer_pending)
857 if (scic->next_phy_to_start >= SCI_MAX_PHYS) {
858 bool is_controller_start_complete = true;
862 for (index = 0; index < SCI_MAX_PHYS; index++) {
863 sci_phy = &scic->phy_table[index];
864 state = sci_phy->parent.state_machine.current_state_id;
866 if (!scic_sds_phy_get_port(sci_phy))
869 /* The controller start operation is complete iff:
870 * - all links have been given an opportunity to start
871 * - have no indication of a connected device
872 * - have an indication of a connected device and it has
873 * finished the link training process.
875 if ((sci_phy->is_in_link_training == false &&
876 state == SCI_BASE_PHY_STATE_INITIAL) ||
877 (sci_phy->is_in_link_training == false &&
878 state == SCI_BASE_PHY_STATE_STOPPED) ||
879 (sci_phy->is_in_link_training == true &&
880 state == SCI_BASE_PHY_STATE_STARTING)) {
881 is_controller_start_complete = false;
887 * The controller has successfully finished the start process.
888 * Inform the SCI Core user and transition to the READY state. */
889 if (is_controller_start_complete == true) {
890 scic_sds_controller_transition_to_ready(scic, SCI_SUCCESS);
891 scic_sds_controller_phy_timer_stop(scic);
894 sci_phy = &scic->phy_table[scic->next_phy_to_start];
896 if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
897 if (scic_sds_phy_get_port(sci_phy) == NULL) {
898 scic->next_phy_to_start++;
900 /* Caution recursion ahead be forwarned
902 * The PHY was never added to a PORT in MPC mode
903 * so start the next phy in sequence This phy
904 * will never go link up and will not draw power
905 * the OEM parameters either configured the phy
906 * incorrectly for the PORT or it was never
909 return scic_sds_controller_start_next_phy(scic);
913 status = scic_sds_phy_start(sci_phy);
915 if (status == SCI_SUCCESS) {
916 scic_sds_controller_phy_timer_start(scic);
918 dev_warn(scic_to_dev(scic),
919 "%s: Controller stop operation failed "
920 "to stop phy %d because of status "
923 scic->phy_table[scic->next_phy_to_start].phy_index,
927 scic->next_phy_to_start++;
939 enum sci_status scic_sds_controller_stop_phys(
940 struct scic_sds_controller *this_controller)
943 enum sci_status status;
944 enum sci_status phy_status;
946 status = SCI_SUCCESS;
948 for (index = 0; index < SCI_MAX_PHYS; index++) {
949 phy_status = scic_sds_phy_stop(&this_controller->phy_table[index]);
952 (phy_status != SCI_SUCCESS)
953 && (phy_status != SCI_FAILURE_INVALID_STATE)
955 status = SCI_FAILURE;
957 dev_warn(scic_to_dev(this_controller),
958 "%s: Controller stop operation failed to stop "
959 "phy %d because of status %d.\n",
961 this_controller->phy_table[index].phy_index, phy_status);
974 enum sci_status scic_sds_controller_stop_devices(
975 struct scic_sds_controller *this_controller)
978 enum sci_status status;
979 enum sci_status device_status;
981 status = SCI_SUCCESS;
983 for (index = 0; index < this_controller->remote_node_entries; index++) {
984 if (this_controller->device_table[index] != NULL) {
985 /* / @todo What timeout value do we want to provide to this request? */
986 device_status = scic_remote_device_stop(this_controller->device_table[index], 0);
988 if ((device_status != SCI_SUCCESS) &&
989 (device_status != SCI_FAILURE_INVALID_STATE)) {
990 dev_warn(scic_to_dev(this_controller),
991 "%s: Controller stop operation failed "
992 "to stop device 0x%p because of "
995 this_controller->device_table[index], device_status);
1004 * ****************************************************************************-
1005 * * SCIC SDS Controller Power Control (Staggered Spinup)
1006 * ****************************************************************************- */
1011 * This method starts the power control timer for this controller object.
1013 static void scic_sds_controller_power_control_timer_start(
1014 struct scic_sds_controller *this_controller)
1016 isci_event_timer_start(
1017 this_controller, this_controller->power_control.timer,
1018 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL
1021 this_controller->power_control.timer_started = true;
1025 * This method stops the power control timer for this controller object.
1029 void scic_sds_controller_power_control_timer_stop(struct scic_sds_controller *scic)
1031 if (scic->power_control.timer_started) {
1032 isci_event_timer_stop(scic, scic->power_control.timer);
1033 scic->power_control.timer_started = false;
1038 * This method stops and starts the power control timer for this controller object.
1042 void scic_sds_controller_power_control_timer_restart(
1043 struct scic_sds_controller *scic)
1045 scic_sds_controller_power_control_timer_stop(scic);
1046 scic_sds_controller_power_control_timer_start(scic);
1054 static void scic_sds_controller_power_control_timer_handler(
1057 struct scic_sds_controller *this_controller;
1059 this_controller = (struct scic_sds_controller *)controller;
1061 this_controller->power_control.phys_granted_power = 0;
1063 if (this_controller->power_control.phys_waiting == 0) {
1064 this_controller->power_control.timer_started = false;
1066 struct scic_sds_phy *the_phy = NULL;
1071 && (this_controller->power_control.phys_waiting != 0);
1073 if (this_controller->power_control.requesters[i] != NULL) {
1074 if (this_controller->power_control.phys_granted_power <
1075 this_controller->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
1076 the_phy = this_controller->power_control.requesters[i];
1077 this_controller->power_control.requesters[i] = NULL;
1078 this_controller->power_control.phys_waiting--;
1079 this_controller->power_control.phys_granted_power++;
1080 scic_sds_phy_consume_power_handler(the_phy);
1088 * It doesn't matter if the power list is empty, we need to start the
1089 * timer in case another phy becomes ready.
1091 scic_sds_controller_power_control_timer_start(this_controller);
1096 * This method inserts the phy in the stagger spinup control queue.
1101 void scic_sds_controller_power_control_queue_insert(
1102 struct scic_sds_controller *this_controller,
1103 struct scic_sds_phy *the_phy)
1105 BUG_ON(the_phy == NULL);
1107 if (this_controller->power_control.phys_granted_power <
1108 this_controller->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
1109 this_controller->power_control.phys_granted_power++;
1110 scic_sds_phy_consume_power_handler(the_phy);
1113 * stop and start the power_control timer. When the timer fires, the
1114 * no_of_phys_granted_power will be set to 0
1116 scic_sds_controller_power_control_timer_restart(this_controller);
1118 /* Add the phy in the waiting list */
1119 this_controller->power_control.requesters[the_phy->phy_index] = the_phy;
1120 this_controller->power_control.phys_waiting++;
1125 * This method removes the phy from the stagger spinup control queue.
1130 void scic_sds_controller_power_control_queue_remove(
1131 struct scic_sds_controller *this_controller,
1132 struct scic_sds_phy *the_phy)
1134 BUG_ON(the_phy == NULL);
1136 if (this_controller->power_control.requesters[the_phy->phy_index] != NULL) {
1137 this_controller->power_control.phys_waiting--;
1140 this_controller->power_control.requesters[the_phy->phy_index] = NULL;
1144 * ****************************************************************************-
1145 * * SCIC SDS Controller Completion Routines
1146 * ****************************************************************************- */
1149 * This method returns a true value if the completion queue has entries that
1153 * bool true if the completion queue has entries to process false if the
1154 * completion queue has no entries to process
1156 static bool scic_sds_controller_completion_queue_has_entries(
1157 struct scic_sds_controller *this_controller)
1159 u32 get_value = this_controller->completion_queue_get;
1160 u32 get_index = get_value & SMU_COMPLETION_QUEUE_GET_POINTER_MASK;
1163 NORMALIZE_GET_POINTER_CYCLE_BIT(get_value)
1164 == COMPLETION_QUEUE_CYCLE_BIT(this_controller->completion_queue[get_index])
1172 /* --------------------------------------------------------------------------- */
1175 * This method processes a task completion notification. This is called from
1176 * within the controller completion handler.
1178 * @completion_entry:
1181 static void scic_sds_controller_task_completion(
1182 struct scic_sds_controller *this_controller,
1183 u32 completion_entry)
1186 struct scic_sds_request *io_request;
1188 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1189 io_request = this_controller->io_request_table[index];
1191 /* Make sure that we really want to process this IO request */
1193 (io_request != NULL)
1194 && (io_request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG)
1196 scic_sds_io_tag_get_sequence(io_request->io_tag)
1197 == this_controller->io_request_sequence[index]
1200 /* Yep this is a valid io request pass it along to the io request handler */
1201 scic_sds_io_request_tc_completion(io_request, completion_entry);
1206 * This method processes an SDMA completion event. This is called from within
1207 * the controller completion handler.
1209 * @completion_entry:
1212 static void scic_sds_controller_sdma_completion(
1213 struct scic_sds_controller *this_controller,
1214 u32 completion_entry)
1217 struct scic_sds_request *io_request;
1218 struct scic_sds_remote_device *device;
1220 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1222 switch (scu_get_command_request_type(completion_entry)) {
1223 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC:
1224 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC:
1225 io_request = this_controller->io_request_table[index];
1226 dev_warn(scic_to_dev(this_controller),
1227 "%s: SCIC SDS Completion type SDMA %x for io request "
1232 /* @todo For a post TC operation we need to fail the IO
1237 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC:
1238 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC:
1239 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC:
1240 device = this_controller->device_table[index];
1241 dev_warn(scic_to_dev(this_controller),
1242 "%s: SCIC SDS Completion type SDMA %x for remote "
1247 /* @todo For a port RNC operation we need to fail the
1253 dev_warn(scic_to_dev(this_controller),
1254 "%s: SCIC SDS Completion unknown SDMA completion "
1266 * @completion_entry:
1268 * This method processes an unsolicited frame message. This is called from
1269 * within the controller completion handler. none
1271 static void scic_sds_controller_unsolicited_frame(
1272 struct scic_sds_controller *this_controller,
1273 u32 completion_entry)
1278 struct scu_unsolicited_frame_header *frame_header;
1279 struct scic_sds_phy *phy;
1280 struct scic_sds_remote_device *device;
1282 enum sci_status result = SCI_FAILURE;
1284 frame_index = SCU_GET_FRAME_INDEX(completion_entry);
1287 = this_controller->uf_control.buffers.array[frame_index].header;
1288 this_controller->uf_control.buffers.array[frame_index].state
1289 = UNSOLICITED_FRAME_IN_USE;
1291 if (SCU_GET_FRAME_ERROR(completion_entry)) {
1293 * / @todo If the IAF frame or SIGNATURE FIS frame has an error will
1294 * / this cause a problem? We expect the phy initialization will
1295 * / fail if there is an error in the frame. */
1296 scic_sds_controller_release_frame(this_controller, frame_index);
1300 if (frame_header->is_address_frame) {
1301 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1302 phy = &this_controller->phy_table[index];
1304 result = scic_sds_phy_frame_handler(phy, frame_index);
1308 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1310 if (index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
1312 * This is a signature fis or a frame from a direct attached SATA
1313 * device that has not yet been created. In either case forwared
1314 * the frame to the PE and let it take care of the frame data. */
1315 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1316 phy = &this_controller->phy_table[index];
1317 result = scic_sds_phy_frame_handler(phy, frame_index);
1319 if (index < this_controller->remote_node_entries)
1320 device = this_controller->device_table[index];
1325 result = scic_sds_remote_device_frame_handler(device, frame_index);
1327 scic_sds_controller_release_frame(this_controller, frame_index);
1331 if (result != SCI_SUCCESS) {
1333 * / @todo Is there any reason to report some additional error message
1334 * / when we get this failure notifiction? */
1339 * This method processes an event completion entry. This is called from within
1340 * the controller completion handler.
1342 * @completion_entry:
1345 static void scic_sds_controller_event_completion(
1346 struct scic_sds_controller *this_controller,
1347 u32 completion_entry)
1350 struct scic_sds_request *io_request;
1351 struct scic_sds_remote_device *device;
1352 struct scic_sds_phy *phy;
1354 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1356 switch (scu_get_event_type(completion_entry)) {
1357 case SCU_EVENT_TYPE_SMU_COMMAND_ERROR:
1358 /* / @todo The driver did something wrong and we need to fix the condtion. */
1359 dev_err(scic_to_dev(this_controller),
1360 "%s: SCIC Controller 0x%p received SMU command error "
1367 case SCU_EVENT_TYPE_SMU_PCQ_ERROR:
1368 case SCU_EVENT_TYPE_SMU_ERROR:
1369 case SCU_EVENT_TYPE_FATAL_MEMORY_ERROR:
1371 * / @todo This is a hardware failure and its likely that we want to
1372 * / reset the controller. */
1373 dev_err(scic_to_dev(this_controller),
1374 "%s: SCIC Controller 0x%p received fatal controller "
1381 case SCU_EVENT_TYPE_TRANSPORT_ERROR:
1382 io_request = this_controller->io_request_table[index];
1383 scic_sds_io_request_event_handler(io_request, completion_entry);
1386 case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
1387 switch (scu_get_event_specifier(completion_entry)) {
1388 case SCU_EVENT_SPECIFIC_SMP_RESPONSE_NO_PE:
1389 case SCU_EVENT_SPECIFIC_TASK_TIMEOUT:
1390 io_request = this_controller->io_request_table[index];
1391 if (io_request != NULL)
1392 scic_sds_io_request_event_handler(io_request, completion_entry);
1394 dev_warn(scic_to_dev(this_controller),
1395 "%s: SCIC Controller 0x%p received "
1396 "event 0x%x for io request object "
1397 "that doesnt exist.\n",
1404 case SCU_EVENT_SPECIFIC_IT_NEXUS_TIMEOUT:
1405 device = this_controller->device_table[index];
1407 scic_sds_remote_device_event_handler(device, completion_entry);
1409 dev_warn(scic_to_dev(this_controller),
1410 "%s: SCIC Controller 0x%p received "
1411 "event 0x%x for remote device object "
1412 "that doesnt exist.\n",
1421 case SCU_EVENT_TYPE_BROADCAST_CHANGE:
1423 * direct the broadcast change event to the phy first and then let
1424 * the phy redirect the broadcast change to the port object */
1425 case SCU_EVENT_TYPE_ERR_CNT_EVENT:
1427 * direct error counter event to the phy object since that is where
1428 * we get the event notification. This is a type 4 event. */
1429 case SCU_EVENT_TYPE_OSSP_EVENT:
1430 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1431 phy = &this_controller->phy_table[index];
1432 scic_sds_phy_event_handler(phy, completion_entry);
1435 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
1436 case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
1437 case SCU_EVENT_TYPE_RNC_OPS_MISC:
1438 if (index < this_controller->remote_node_entries) {
1439 device = this_controller->device_table[index];
1442 scic_sds_remote_device_event_handler(device, completion_entry);
1444 dev_err(scic_to_dev(this_controller),
1445 "%s: SCIC Controller 0x%p received event 0x%x "
1446 "for remote device object 0x%0x that doesnt "
1456 dev_warn(scic_to_dev(this_controller),
1457 "%s: SCIC Controller received unknown event code %x\n",
1465 * This method is a private routine for processing the completion queue entries.
1469 static void scic_sds_controller_process_completions(
1470 struct scic_sds_controller *this_controller)
1472 u32 completion_count = 0;
1473 u32 completion_entry;
1479 dev_dbg(scic_to_dev(this_controller),
1480 "%s: completion queue begining get:0x%08x\n",
1482 this_controller->completion_queue_get);
1484 /* Get the component parts of the completion queue */
1485 get_index = NORMALIZE_GET_POINTER(this_controller->completion_queue_get);
1486 get_cycle = SMU_CQGR_CYCLE_BIT & this_controller->completion_queue_get;
1488 event_index = NORMALIZE_EVENT_POINTER(this_controller->completion_queue_get);
1489 event_cycle = SMU_CQGR_EVENT_CYCLE_BIT & this_controller->completion_queue_get;
1492 NORMALIZE_GET_POINTER_CYCLE_BIT(get_cycle)
1493 == COMPLETION_QUEUE_CYCLE_BIT(this_controller->completion_queue[get_index])
1497 completion_entry = this_controller->completion_queue[get_index];
1498 INCREMENT_COMPLETION_QUEUE_GET(this_controller, get_index, get_cycle);
1500 dev_dbg(scic_to_dev(this_controller),
1501 "%s: completion queue entry:0x%08x\n",
1505 switch (SCU_GET_COMPLETION_TYPE(completion_entry)) {
1506 case SCU_COMPLETION_TYPE_TASK:
1507 scic_sds_controller_task_completion(this_controller, completion_entry);
1510 case SCU_COMPLETION_TYPE_SDMA:
1511 scic_sds_controller_sdma_completion(this_controller, completion_entry);
1514 case SCU_COMPLETION_TYPE_UFI:
1515 scic_sds_controller_unsolicited_frame(this_controller, completion_entry);
1518 case SCU_COMPLETION_TYPE_EVENT:
1519 INCREMENT_EVENT_QUEUE_GET(this_controller, event_index, event_cycle);
1520 scic_sds_controller_event_completion(this_controller, completion_entry);
1523 case SCU_COMPLETION_TYPE_NOTIFY:
1525 * Presently we do the same thing with a notify event that we do with the
1526 * other event codes. */
1527 INCREMENT_EVENT_QUEUE_GET(this_controller, event_index, event_cycle);
1528 scic_sds_controller_event_completion(this_controller, completion_entry);
1532 dev_warn(scic_to_dev(this_controller),
1533 "%s: SCIC Controller received unknown "
1534 "completion type %x\n",
1541 /* Update the get register if we completed one or more entries */
1542 if (completion_count > 0) {
1543 this_controller->completion_queue_get =
1544 SMU_CQGR_GEN_BIT(ENABLE)
1545 | SMU_CQGR_GEN_BIT(EVENT_ENABLE)
1546 | event_cycle | SMU_CQGR_GEN_VAL(EVENT_POINTER, event_index)
1547 | get_cycle | SMU_CQGR_GEN_VAL(POINTER, get_index);
1549 SMU_CQGR_WRITE(this_controller,
1550 this_controller->completion_queue_get);
1553 dev_dbg(scic_to_dev(this_controller),
1554 "%s: completion queue ending get:0x%08x\n",
1556 this_controller->completion_queue_get);
1560 bool scic_sds_controller_isr(struct scic_sds_controller *scic)
1562 if (scic_sds_controller_completion_queue_has_entries(scic)) {
1566 * we have a spurious interrupt it could be that we have already
1567 * emptied the completion queue from a previous interrupt */
1568 SMU_ISR_WRITE(scic, SMU_ISR_COMPLETION);
1571 * There is a race in the hardware that could cause us not to be notified
1572 * of an interrupt completion if we do not take this step. We will mask
1573 * then unmask the interrupts so if there is another interrupt pending
1574 * the clearing of the interrupt source we get the next interrupt message. */
1575 SMU_IMR_WRITE(scic, 0xFF000000);
1576 SMU_IMR_WRITE(scic, 0x00000000);
1582 void scic_sds_controller_completion_handler(struct scic_sds_controller *scic)
1584 /* Empty out the completion queue */
1585 if (scic_sds_controller_completion_queue_has_entries(scic))
1586 scic_sds_controller_process_completions(scic);
1588 /* Clear the interrupt and enable all interrupts again */
1589 SMU_ISR_WRITE(scic, SMU_ISR_COMPLETION);
1590 /* Could we write the value of SMU_ISR_COMPLETION? */
1591 SMU_IMR_WRITE(scic, 0xFF000000);
1592 SMU_IMR_WRITE(scic, 0x00000000);
1595 bool scic_sds_controller_error_isr(struct scic_sds_controller *scic)
1597 u32 interrupt_status;
1599 interrupt_status = SMU_ISR_READ(scic);
1601 interrupt_status &= (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND);
1603 if (interrupt_status != 0) {
1605 * There is an error interrupt pending so let it through and handle
1606 * in the callback */
1611 * There is a race in the hardware that could cause us not to be notified
1612 * of an interrupt completion if we do not take this step. We will mask
1613 * then unmask the error interrupts so if there was another interrupt
1614 * pending we will be notified.
1615 * Could we write the value of (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND)? */
1616 SMU_IMR_WRITE(scic, 0x000000FF);
1617 SMU_IMR_WRITE(scic, 0x00000000);
1622 void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
1624 u32 interrupt_status;
1626 interrupt_status = SMU_ISR_READ(scic);
1628 if ((interrupt_status & SMU_ISR_QUEUE_SUSPEND) &&
1629 scic_sds_controller_completion_queue_has_entries(scic)) {
1631 scic_sds_controller_process_completions(scic);
1632 SMU_ISR_WRITE(scic, SMU_ISR_QUEUE_SUSPEND);
1635 dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
1638 sci_base_state_machine_change_state(
1639 scic_sds_controller_get_base_state_machine(scic),
1640 SCI_BASE_CONTROLLER_STATE_FAILED);
1646 * If we dont process any completions I am not sure that we want to do this.
1647 * We are in the middle of a hardware fault and should probably be reset. */
1648 SMU_IMR_WRITE(scic, 0x00000000);
1652 u32 scic_sds_controller_get_object_size(void)
1654 return sizeof(struct scic_sds_controller);
1658 void scic_sds_controller_link_up(
1659 struct scic_sds_controller *scic,
1660 struct scic_sds_port *sci_port,
1661 struct scic_sds_phy *sci_phy)
1663 scic_sds_controller_phy_handler_t link_up;
1666 state = scic->parent.state_machine.current_state_id;
1667 link_up = scic_sds_controller_state_handler_table[state].link_up;
1670 link_up(scic, sci_port, sci_phy);
1672 dev_dbg(scic_to_dev(scic),
1673 "%s: SCIC Controller linkup event from phy %d in "
1674 "unexpected state %d\n",
1677 sci_base_state_machine_get_state(
1678 scic_sds_controller_get_base_state_machine(
1683 void scic_sds_controller_link_down(
1684 struct scic_sds_controller *scic,
1685 struct scic_sds_port *sci_port,
1686 struct scic_sds_phy *sci_phy)
1689 scic_sds_controller_phy_handler_t link_down;
1691 state = scic->parent.state_machine.current_state_id;
1692 link_down = scic_sds_controller_state_handler_table[state].link_down;
1695 link_down(scic, sci_port, sci_phy);
1697 dev_dbg(scic_to_dev(scic),
1698 "%s: SCIC Controller linkdown event from phy %d in "
1699 "unexpected state %d\n",
1701 sci_phy->phy_index, state);
1705 * This method is called by the remote device to inform the controller
1706 * that this remote device has started.
1710 void scic_sds_controller_remote_device_started(struct scic_sds_controller *scic,
1711 struct scic_sds_remote_device *sci_dev)
1714 scic_sds_controller_device_handler_t started;
1716 state = scic->parent.state_machine.current_state_id;
1717 started = scic_sds_controller_state_handler_table[state].remote_device_started_handler;
1720 started(scic, sci_dev);
1722 dev_dbg(scic_to_dev(scic),
1723 "%s: SCIC Controller 0x%p remote device started event "
1724 "from device 0x%p in unexpected state %d\n",
1725 __func__, scic, sci_dev, state);
1730 * This is a helper method to determine if any remote devices on this
1731 * controller are still in the stopping state.
1734 bool scic_sds_controller_has_remote_devices_stopping(
1735 struct scic_sds_controller *this_controller)
1739 for (index = 0; index < this_controller->remote_node_entries; index++) {
1740 if ((this_controller->device_table[index] != NULL) &&
1741 (this_controller->device_table[index]->parent.state_machine.current_state_id
1742 == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING))
1750 * This method is called by the remote device to inform the controller
1751 * object that the remote device has stopped.
1755 void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
1756 struct scic_sds_remote_device *sci_dev)
1760 scic_sds_controller_device_handler_t stopped;
1762 state = scic->parent.state_machine.current_state_id;
1763 stopped = scic_sds_controller_state_handler_table[state].remote_device_stopped_handler;
1766 stopped(scic, sci_dev);
1768 dev_dbg(scic_to_dev(scic),
1769 "%s: SCIC Controller 0x%p remote device stopped event "
1770 "from device 0x%p in unexpected state %d\n",
1771 __func__, scic, sci_dev, state);
1778 * This method will write to the SCU PCP register the request value. The method
1779 * is used to suspend/resume ports, devices, and phys.
1784 void scic_sds_controller_post_request(
1785 struct scic_sds_controller *this_controller,
1788 dev_dbg(scic_to_dev(this_controller),
1789 "%s: SCIC Controller 0x%p post request 0x%08x\n",
1794 SMU_PCP_WRITE(this_controller, request);
1798 * This method will copy the soft copy of the task context into the physical
1799 * memory accessible by the controller.
1800 * @this_controller: This parameter specifies the controller for which to copy
1802 * @this_request: This parameter specifies the request for which the task
1803 * context is being copied.
1805 * After this call is made the SCIC_SDS_IO_REQUEST object will always point to
1806 * the physical memory version of the task context. Thus, all subsequent
1807 * updates to the task context are performed in the TC table (i.e. DMAable
1810 void scic_sds_controller_copy_task_context(
1811 struct scic_sds_controller *this_controller,
1812 struct scic_sds_request *this_request)
1814 struct scu_task_context *task_context_buffer;
1816 task_context_buffer = scic_sds_controller_get_task_context_buffer(
1817 this_controller, this_request->io_tag
1821 task_context_buffer,
1822 this_request->task_context_buffer,
1823 SCI_FIELD_OFFSET(struct scu_task_context, sgl_snapshot_ac)
1827 * Now that the soft copy of the TC has been copied into the TC
1828 * table accessible by the silicon. Thus, any further changes to
1829 * the TC (e.g. TC termination) occur in the appropriate location. */
1830 this_request->task_context_buffer = task_context_buffer;
1834 * This method returns the task context buffer for the given io tag.
1838 * struct scu_task_context*
1840 struct scu_task_context *scic_sds_controller_get_task_context_buffer(
1841 struct scic_sds_controller *this_controller,
1844 u16 task_index = scic_sds_io_tag_get_index(io_tag);
1846 if (task_index < this_controller->task_context_entries) {
1847 return &this_controller->task_context_table[task_index];
1854 * This method returnst the sequence value from the io tag value
1862 * This method returns the IO request associated with the tag value
1866 * SCIC_SDS_IO_REQUEST_T* NULL if there is no valid IO request at the tag value
1868 struct scic_sds_request *scic_sds_controller_get_io_request_from_tag(
1869 struct scic_sds_controller *this_controller,
1875 task_index = scic_sds_io_tag_get_index(io_tag);
1877 if (task_index < this_controller->task_context_entries) {
1878 if (this_controller->io_request_table[task_index] != NULL) {
1879 task_sequence = scic_sds_io_tag_get_sequence(io_tag);
1881 if (task_sequence == this_controller->io_request_sequence[task_index]) {
1882 return this_controller->io_request_table[task_index];
1891 * This method allocates remote node index and the reserves the remote node
1892 * context space for use. This method can fail if there are no more remote
1893 * node index available.
1894 * @this_controller: This is the controller object which contains the set of
1895 * free remote node ids
1896 * @the_devce: This is the device object which is requesting the a remote node
1898 * @node_id: This is the remote node id that is assinged to the device if one
1901 * enum sci_status SCI_FAILURE_OUT_OF_RESOURCES if there are no available remote
1902 * node index available.
1904 enum sci_status scic_sds_controller_allocate_remote_node_context(
1905 struct scic_sds_controller *this_controller,
1906 struct scic_sds_remote_device *the_device,
1910 u32 remote_node_count = scic_sds_remote_device_node_count(the_device);
1912 node_index = scic_sds_remote_node_table_allocate_remote_node(
1913 &this_controller->available_remote_nodes, remote_node_count
1916 if (node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
1917 this_controller->device_table[node_index] = the_device;
1919 *node_id = node_index;
1924 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
1928 * This method frees the remote node index back to the available pool. Once
1929 * this is done the remote node context buffer is no longer valid and can
1936 void scic_sds_controller_free_remote_node_context(
1937 struct scic_sds_controller *this_controller,
1938 struct scic_sds_remote_device *the_device,
1941 u32 remote_node_count = scic_sds_remote_device_node_count(the_device);
1943 if (this_controller->device_table[node_id] == the_device) {
1944 this_controller->device_table[node_id] = NULL;
1946 scic_sds_remote_node_table_release_remote_node_index(
1947 &this_controller->available_remote_nodes, remote_node_count, node_id
1953 * This method returns the union scu_remote_node_context for the specified remote
1958 * union scu_remote_node_context*
1960 union scu_remote_node_context *scic_sds_controller_get_remote_node_context_buffer(
1961 struct scic_sds_controller *this_controller,
1965 (node_id < this_controller->remote_node_entries)
1966 && (this_controller->device_table[node_id] != NULL)
1968 return &this_controller->remote_node_context_table[node_id];
1976 * @resposne_buffer: This is the buffer into which the D2H register FIS will be
1978 * @frame_header: This is the frame header returned by the hardware.
1979 * @frame_buffer: This is the frame buffer returned by the hardware.
1981 * This method will combind the frame header and frame buffer to create a SATA
1982 * D2H register FIS none
1984 void scic_sds_controller_copy_sata_response(
1985 void *response_buffer,
1996 (char *)((char *)response_buffer + sizeof(u32)),
1998 sizeof(struct sata_fis_reg_d2h) - sizeof(u32)
2003 * This method releases the frame once this is done the frame is available for
2004 * re-use by the hardware. The data contained in the frame header and frame
2005 * buffer is no longer valid. The UF queue get pointer is only updated if UF
2006 * control indicates this is appropriate.
2011 void scic_sds_controller_release_frame(
2012 struct scic_sds_controller *this_controller,
2015 if (scic_sds_unsolicited_frame_control_release_frame(
2016 &this_controller->uf_control, frame_index) == true)
2017 SCU_UFQGP_WRITE(this_controller, this_controller->uf_control.get);
2021 * This method sets user parameters and OEM parameters to default values.
2022 * Users can override these values utilizing the scic_user_parameters_set()
2023 * and scic_oem_parameters_set() methods.
2024 * @scic: This parameter specifies the controller for which to set the
2025 * configuration parameters to their default values.
2028 static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic)
2032 /* Default to APC mode. */
2033 scic->oem_parameters.sds1.controller.mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE;
2035 /* Default to APC mode. */
2036 scic->oem_parameters.sds1.controller.max_concurrent_dev_spin_up = 1;
2038 /* Default to no SSC operation. */
2039 scic->oem_parameters.sds1.controller.do_enable_ssc = false;
2041 /* Initialize all of the port parameter information to narrow ports. */
2042 for (index = 0; index < SCI_MAX_PORTS; index++) {
2043 scic->oem_parameters.sds1.ports[index].phy_mask = 0;
2046 /* Initialize all of the phy parameter information. */
2047 for (index = 0; index < SCI_MAX_PHYS; index++) {
2048 /* Default to 6G (i.e. Gen 3) for now. */
2049 scic->user_parameters.sds1.phys[index].max_speed_generation = 3;
2051 /* the frequencies cannot be 0 */
2052 scic->user_parameters.sds1.phys[index].align_insertion_frequency = 0x7f;
2053 scic->user_parameters.sds1.phys[index].in_connection_align_insertion_frequency = 0xff;
2054 scic->user_parameters.sds1.phys[index].notify_enable_spin_up_insertion_frequency = 0x33;
2057 * Previous Vitesse based expanders had a arbitration issue that
2058 * is worked around by having the upper 32-bits of SAS address
2059 * with a value greater then the Vitesse company identifier.
2060 * Hence, usage of 0x5FCFFFFF. */
2061 scic->oem_parameters.sds1.phys[index].sas_address.low = 0x00000001;
2062 scic->oem_parameters.sds1.phys[index].sas_address.high = 0x5FCFFFFF;
2065 scic->user_parameters.sds1.stp_inactivity_timeout = 5;
2066 scic->user_parameters.sds1.ssp_inactivity_timeout = 5;
2067 scic->user_parameters.sds1.stp_max_occupancy_timeout = 5;
2068 scic->user_parameters.sds1.ssp_max_occupancy_timeout = 20;
2069 scic->user_parameters.sds1.no_outbound_task_timeout = 20;
2073 enum sci_status scic_controller_construct(struct scic_sds_controller *controller,
2074 void __iomem *scu_base,
2075 void __iomem *smu_base)
2079 sci_base_controller_construct(
2080 &controller->parent,
2081 scic_sds_controller_state_table,
2082 controller->memory_descriptors,
2083 ARRAY_SIZE(controller->memory_descriptors),
2087 controller->scu_registers = scu_base;
2088 controller->smu_registers = smu_base;
2090 scic_sds_port_configuration_agent_construct(&controller->port_agent);
2092 /* Construct the ports for this controller */
2093 for (index = 0; index < SCI_MAX_PORTS; index++)
2094 scic_sds_port_construct(&controller->port_table[index],
2096 scic_sds_port_construct(&controller->port_table[index],
2097 SCIC_SDS_DUMMY_PORT, controller);
2099 /* Construct the phys for this controller */
2100 for (index = 0; index < SCI_MAX_PHYS; index++) {
2101 /* Add all the PHYs to the dummy port */
2102 scic_sds_phy_construct(
2103 &controller->phy_table[index],
2104 &controller->port_table[SCI_MAX_PORTS],
2109 controller->invalid_phy_mask = 0;
2111 /* Set the default maximum values */
2112 controller->completion_event_entries = SCU_EVENT_COUNT;
2113 controller->completion_queue_entries = SCU_COMPLETION_QUEUE_COUNT;
2114 controller->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
2115 controller->logical_port_entries = SCI_MAX_PORTS;
2116 controller->task_context_entries = SCU_IO_REQUEST_COUNT;
2117 controller->uf_control.buffers.count = SCU_UNSOLICITED_FRAME_COUNT;
2118 controller->uf_control.address_table.count = SCU_UNSOLICITED_FRAME_COUNT;
2120 /* Initialize the User and OEM parameters to default values. */
2121 scic_sds_controller_set_default_config_parameters(controller);
2123 return scic_controller_reset(controller);
2126 /* --------------------------------------------------------------------------- */
2128 enum sci_status scic_controller_initialize(
2129 struct scic_sds_controller *scic)
2131 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2132 sci_base_controller_handler_t initialize;
2135 state = scic->parent.state_machine.current_state_id;
2136 initialize = scic_sds_controller_state_handler_table[state].base.initialize;
2139 status = initialize(&scic->parent);
2141 dev_warn(scic_to_dev(scic),
2142 "%s: SCIC Controller initialize operation requested "
2143 "in invalid state %d\n",
2145 sci_base_state_machine_get_state(
2146 scic_sds_controller_get_base_state_machine(
2152 /* --------------------------------------------------------------------------- */
2154 u32 scic_controller_get_suggested_start_timeout(
2155 struct scic_sds_controller *sc)
2157 /* Validate the user supplied parameters. */
2162 * The suggested minimum timeout value for a controller start operation:
2164 * Signature FIS Timeout
2165 * + Phy Start Timeout
2166 * + Number of Phy Spin Up Intervals
2167 * ---------------------------------
2168 * Number of milliseconds for the controller start operation.
2170 * NOTE: The number of phy spin up intervals will be equivalent
2171 * to the number of phys divided by the number phys allowed
2172 * per interval - 1 (once OEM parameters are supported).
2173 * Currently we assume only 1 phy per interval. */
2175 return SCIC_SDS_SIGNATURE_FIS_TIMEOUT
2176 + SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT
2177 + ((SCI_MAX_PHYS - 1) * SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
2180 /* --------------------------------------------------------------------------- */
2182 enum sci_status scic_controller_start(
2183 struct scic_sds_controller *scic,
2186 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2187 sci_base_controller_timed_handler_t start;
2190 state = scic->parent.state_machine.current_state_id;
2191 start = scic_sds_controller_state_handler_table[state].base.start;
2194 status = start(&scic->parent, timeout);
2196 dev_warn(scic_to_dev(scic),
2197 "%s: SCIC Controller start operation requested in "
2198 "invalid state %d\n",
2200 sci_base_state_machine_get_state(
2201 scic_sds_controller_get_base_state_machine(
2207 /* --------------------------------------------------------------------------- */
2209 enum sci_status scic_controller_stop(
2210 struct scic_sds_controller *scic,
2213 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2214 sci_base_controller_timed_handler_t stop;
2217 state = scic->parent.state_machine.current_state_id;
2218 stop = scic_sds_controller_state_handler_table[state].base.stop;
2221 status = stop(&scic->parent, timeout);
2223 dev_warn(scic_to_dev(scic),
2224 "%s: SCIC Controller stop operation requested in "
2225 "invalid state %d\n",
2227 sci_base_state_machine_get_state(
2228 scic_sds_controller_get_base_state_machine(
2234 /* --------------------------------------------------------------------------- */
2236 enum sci_status scic_controller_reset(
2237 struct scic_sds_controller *scic)
2239 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2240 sci_base_controller_handler_t reset;
2243 state = scic->parent.state_machine.current_state_id;
2244 reset = scic_sds_controller_state_handler_table[state].base.reset;
2247 status = reset(&scic->parent);
2249 dev_warn(scic_to_dev(scic),
2250 "%s: SCIC Controller reset operation requested in "
2251 "invalid state %d\n",
2253 sci_base_state_machine_get_state(
2254 scic_sds_controller_get_base_state_machine(
2260 enum sci_io_status scic_controller_start_io(
2261 struct scic_sds_controller *scic,
2262 struct scic_sds_remote_device *remote_device,
2263 struct scic_sds_request *io_request,
2267 sci_base_controller_start_request_handler_t start_io;
2269 state = scic->parent.state_machine.current_state_id;
2270 start_io = scic_sds_controller_state_handler_table[state].base.start_io;
2272 return start_io(&scic->parent,
2273 (struct sci_base_remote_device *) remote_device,
2274 (struct sci_base_request *)io_request, io_tag);
2277 /* --------------------------------------------------------------------------- */
2279 enum sci_status scic_controller_terminate_request(
2280 struct scic_sds_controller *scic,
2281 struct scic_sds_remote_device *remote_device,
2282 struct scic_sds_request *request)
2284 sci_base_controller_request_handler_t terminate_request;
2287 state = scic->parent.state_machine.current_state_id;
2288 terminate_request = scic_sds_controller_state_handler_table[state].terminate_request;
2290 return terminate_request(&scic->parent,
2291 (struct sci_base_remote_device *)remote_device,
2292 (struct sci_base_request *)request);
2295 /* --------------------------------------------------------------------------- */
2297 enum sci_status scic_controller_complete_io(
2298 struct scic_sds_controller *scic,
2299 struct scic_sds_remote_device *remote_device,
2300 struct scic_sds_request *io_request)
2303 sci_base_controller_request_handler_t complete_io;
2305 state = scic->parent.state_machine.current_state_id;
2306 complete_io = scic_sds_controller_state_handler_table[state].base.complete_io;
2308 return complete_io(&scic->parent,
2309 (struct sci_base_remote_device *)remote_device,
2310 (struct sci_base_request *)io_request);
2313 /* --------------------------------------------------------------------------- */
2316 enum sci_task_status scic_controller_start_task(
2317 struct scic_sds_controller *scic,
2318 struct scic_sds_remote_device *remote_device,
2319 struct scic_sds_request *task_request,
2323 sci_base_controller_start_request_handler_t start_task;
2324 enum sci_task_status status = SCI_TASK_FAILURE_INVALID_STATE;
2326 state = scic->parent.state_machine.current_state_id;
2327 start_task = scic_sds_controller_state_handler_table[state].base.start_task;
2330 status = start_task(&scic->parent,
2331 (struct sci_base_remote_device *)remote_device,
2332 (struct sci_base_request *)task_request,
2335 dev_warn(scic_to_dev(scic),
2336 "%s: SCIC Controller starting task from invalid "
2343 /* --------------------------------------------------------------------------- */
2345 enum sci_status scic_controller_complete_task(
2346 struct scic_sds_controller *scic,
2347 struct scic_sds_remote_device *remote_device,
2348 struct scic_sds_request *task_request)
2351 sci_base_controller_request_handler_t complete_task;
2352 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2354 state = scic->parent.state_machine.current_state_id;
2355 complete_task = scic_sds_controller_state_handler_table[state].base.complete_task;
2358 status = complete_task(&scic->parent,
2359 (struct sci_base_remote_device *)remote_device,
2360 (struct sci_base_request *)task_request);
2362 dev_warn(scic_to_dev(scic),
2363 "%s: SCIC Controller completing task from invalid "
2371 /* --------------------------------------------------------------------------- */
2373 enum sci_status scic_controller_get_port_handle(
2374 struct scic_sds_controller *scic,
2376 struct scic_sds_port **port_handle)
2378 if (port_index < scic->logical_port_entries) {
2379 *port_handle = &scic->port_table[port_index];
2384 return SCI_FAILURE_INVALID_PORT;
2387 /* --------------------------------------------------------------------------- */
2389 enum sci_status scic_controller_get_phy_handle(
2390 struct scic_sds_controller *scic,
2392 struct scic_sds_phy **phy_handle)
2394 if (phy_index < ARRAY_SIZE(scic->phy_table)) {
2395 *phy_handle = &scic->phy_table[phy_index];
2400 dev_err(scic_to_dev(scic),
2401 "%s: Controller:0x%p PhyId:0x%x invalid phy index\n",
2402 __func__, scic, phy_index);
2404 return SCI_FAILURE_INVALID_PHY;
2407 /* --------------------------------------------------------------------------- */
2409 u16 scic_controller_allocate_io_tag(
2410 struct scic_sds_controller *scic)
2415 if (!sci_pool_empty(scic->tci_pool)) {
2416 sci_pool_get(scic->tci_pool, task_context);
2418 sequence_count = scic->io_request_sequence[task_context];
2420 return scic_sds_io_tag_construct(sequence_count, task_context);
2423 return SCI_CONTROLLER_INVALID_IO_TAG;
2426 /* --------------------------------------------------------------------------- */
2428 enum sci_status scic_controller_free_io_tag(
2429 struct scic_sds_controller *scic,
2435 BUG_ON(io_tag == SCI_CONTROLLER_INVALID_IO_TAG);
2437 sequence = scic_sds_io_tag_get_sequence(io_tag);
2438 index = scic_sds_io_tag_get_index(io_tag);
2440 if (!sci_pool_full(scic->tci_pool)) {
2441 if (sequence == scic->io_request_sequence[index]) {
2442 scic_sds_io_sequence_increment(
2443 scic->io_request_sequence[index]);
2445 sci_pool_put(scic->tci_pool, index);
2451 return SCI_FAILURE_INVALID_IO_TAG;
2454 /* --------------------------------------------------------------------------- */
2456 void scic_controller_enable_interrupts(
2457 struct scic_sds_controller *scic)
2459 BUG_ON(scic->smu_registers == NULL);
2460 SMU_IMR_WRITE(scic, 0x00000000);
2463 /* --------------------------------------------------------------------------- */
2465 void scic_controller_disable_interrupts(
2466 struct scic_sds_controller *scic)
2468 BUG_ON(scic->smu_registers == NULL);
2469 SMU_IMR_WRITE(scic, 0xffffffff);
2472 /* --------------------------------------------------------------------------- */
2474 enum sci_status scic_controller_set_mode(
2475 struct scic_sds_controller *scic,
2476 enum sci_controller_mode operating_mode)
2478 enum sci_status status = SCI_SUCCESS;
2480 if ((scic->parent.state_machine.current_state_id ==
2481 SCI_BASE_CONTROLLER_STATE_INITIALIZING) ||
2482 (scic->parent.state_machine.current_state_id ==
2483 SCI_BASE_CONTROLLER_STATE_INITIALIZED)) {
2484 switch (operating_mode) {
2485 case SCI_MODE_SPEED:
2486 scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
2487 scic->task_context_entries = SCU_IO_REQUEST_COUNT;
2488 scic->uf_control.buffers.count =
2489 SCU_UNSOLICITED_FRAME_COUNT;
2490 scic->completion_event_entries = SCU_EVENT_COUNT;
2491 scic->completion_queue_entries =
2492 SCU_COMPLETION_QUEUE_COUNT;
2493 scic_sds_controller_build_memory_descriptor_table(scic);
2497 scic->remote_node_entries = SCI_MIN_REMOTE_DEVICES;
2498 scic->task_context_entries = SCI_MIN_IO_REQUESTS;
2499 scic->uf_control.buffers.count =
2500 SCU_MIN_UNSOLICITED_FRAMES;
2501 scic->completion_event_entries = SCU_MIN_EVENTS;
2502 scic->completion_queue_entries =
2503 SCU_MIN_COMPLETION_QUEUE_ENTRIES;
2504 scic_sds_controller_build_memory_descriptor_table(scic);
2508 status = SCI_FAILURE_INVALID_PARAMETER_VALUE;
2512 status = SCI_FAILURE_INVALID_STATE;
2518 * scic_sds_controller_reset_hardware() -
2520 * This method will reset the controller hardware.
2522 void scic_sds_controller_reset_hardware(
2523 struct scic_sds_controller *scic)
2525 /* Disable interrupts so we dont take any spurious interrupts */
2526 scic_controller_disable_interrupts(scic);
2529 SMU_SMUSRCR_WRITE(scic, 0xFFFFFFFF);
2531 /* Delay for 1ms to before clearing the CQP and UFQPR. */
2534 /* The write to the CQGR clears the CQP */
2535 SMU_CQGR_WRITE(scic, 0x00000000);
2537 /* The write to the UFQGP clears the UFQPR */
2538 SCU_UFQGP_WRITE(scic, 0x00000000);
2541 /* --------------------------------------------------------------------------- */
2543 enum sci_status scic_user_parameters_set(
2544 struct scic_sds_controller *scic,
2545 union scic_user_parameters *scic_parms)
2548 (scic->parent.state_machine.current_state_id
2549 == SCI_BASE_CONTROLLER_STATE_RESET)
2550 || (scic->parent.state_machine.current_state_id
2551 == SCI_BASE_CONTROLLER_STATE_INITIALIZING)
2552 || (scic->parent.state_machine.current_state_id
2553 == SCI_BASE_CONTROLLER_STATE_INITIALIZED)
2558 * Validate the user parameters. If they are not legal, then
2559 * return a failure. */
2560 for (index = 0; index < SCI_MAX_PHYS; index++) {
2561 if (!(scic_parms->sds1.phys[index].max_speed_generation
2562 <= SCIC_SDS_PARM_MAX_SPEED
2563 && scic_parms->sds1.phys[index].max_speed_generation
2564 > SCIC_SDS_PARM_NO_SPEED))
2565 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2567 if (scic_parms->sds1.phys[index].in_connection_align_insertion_frequency < 3)
2568 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2570 (scic_parms->sds1.phys[index].in_connection_align_insertion_frequency < 3) ||
2571 (scic_parms->sds1.phys[index].align_insertion_frequency == 0) ||
2572 (scic_parms->sds1.phys[index].notify_enable_spin_up_insertion_frequency == 0)
2574 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2577 if ((scic_parms->sds1.stp_inactivity_timeout == 0) ||
2578 (scic_parms->sds1.ssp_inactivity_timeout == 0) ||
2579 (scic_parms->sds1.stp_max_occupancy_timeout == 0) ||
2580 (scic_parms->sds1.ssp_max_occupancy_timeout == 0) ||
2581 (scic_parms->sds1.no_outbound_task_timeout == 0))
2582 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2584 memcpy(&scic->user_parameters, scic_parms, sizeof(*scic_parms));
2589 return SCI_FAILURE_INVALID_STATE;
2592 /* --------------------------------------------------------------------------- */
2594 void scic_user_parameters_get(
2595 struct scic_sds_controller *scic,
2596 union scic_user_parameters *scic_parms)
2598 memcpy(scic_parms, (&scic->user_parameters), sizeof(*scic_parms));
2601 /* --------------------------------------------------------------------------- */
2603 enum sci_status scic_oem_parameters_set(
2604 struct scic_sds_controller *scic,
2605 union scic_oem_parameters *scic_parms)
2608 (scic->parent.state_machine.current_state_id
2609 == SCI_BASE_CONTROLLER_STATE_RESET)
2610 || (scic->parent.state_machine.current_state_id
2611 == SCI_BASE_CONTROLLER_STATE_INITIALIZING)
2612 || (scic->parent.state_machine.current_state_id
2613 == SCI_BASE_CONTROLLER_STATE_INITIALIZED)
2616 u8 combined_phy_mask = 0;
2619 * Validate the oem parameters. If they are not legal, then
2620 * return a failure. */
2621 for (index = 0; index < SCI_MAX_PORTS; index++) {
2622 if (scic_parms->sds1.ports[index].phy_mask > SCIC_SDS_PARM_PHY_MASK_MAX) {
2623 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2627 for (index = 0; index < SCI_MAX_PHYS; index++) {
2629 scic_parms->sds1.phys[index].sas_address.high == 0
2630 && scic_parms->sds1.phys[index].sas_address.low == 0
2632 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2636 if (scic_parms->sds1.controller.mode_type == SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE) {
2637 for (index = 0; index < SCI_MAX_PHYS; index++) {
2638 if (scic_parms->sds1.ports[index].phy_mask != 0)
2639 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2641 } else if (scic_parms->sds1.controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
2642 for (index = 0; index < SCI_MAX_PHYS; index++)
2643 combined_phy_mask |= scic_parms->sds1.ports[index].phy_mask;
2645 if (combined_phy_mask == 0)
2646 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2648 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2651 if (scic_parms->sds1.controller.max_concurrent_dev_spin_up > MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT)
2652 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2654 memcpy(&scic->oem_parameters, scic_parms, sizeof(*scic_parms));
2658 return SCI_FAILURE_INVALID_STATE;
2661 /* --------------------------------------------------------------------------- */
2663 void scic_oem_parameters_get(
2664 struct scic_sds_controller *scic,
2665 union scic_oem_parameters *scic_parms)
2667 memcpy(scic_parms, (&scic->oem_parameters), sizeof(*scic_parms));
2670 /* --------------------------------------------------------------------------- */
2673 #define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS 853
2674 #define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS 1280
2675 #define INTERRUPT_COALESCE_TIMEOUT_MAX_US 2700000
2676 #define INTERRUPT_COALESCE_NUMBER_MAX 256
2677 #define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN 7
2678 #define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX 28
2680 enum sci_status scic_controller_set_interrupt_coalescence(
2681 struct scic_sds_controller *scic_controller,
2682 u32 coalesce_number,
2683 u32 coalesce_timeout)
2685 u8 timeout_encode = 0;
2689 /* Check if the input parameters fall in the range. */
2690 if (coalesce_number > INTERRUPT_COALESCE_NUMBER_MAX)
2691 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2694 * Defined encoding for interrupt coalescing timeout:
2695 * Value Min Max Units
2696 * ----- --- --- -----
2726 * Others Undefined */
2729 * Use the table above to decide the encode of interrupt coalescing timeout
2730 * value for register writing. */
2731 if (coalesce_timeout == 0)
2734 /* make the timeout value in unit of (10 ns). */
2735 coalesce_timeout = coalesce_timeout * 100;
2736 min = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS / 10;
2737 max = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS / 10;
2739 /* get the encode of timeout for register writing. */
2740 for (timeout_encode = INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN;
2741 timeout_encode <= INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX;
2743 if (min <= coalesce_timeout && max > coalesce_timeout)
2745 else if (coalesce_timeout >= max && coalesce_timeout < min * 2
2746 && coalesce_timeout <= INTERRUPT_COALESCE_TIMEOUT_MAX_US * 100) {
2747 if ((coalesce_timeout - max) < (2 * min - coalesce_timeout))
2759 if (timeout_encode == INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX + 1)
2760 /* the value is out of range. */
2761 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2766 (SMU_ICC_GEN_VAL(NUMBER, coalesce_number) |
2767 SMU_ICC_GEN_VAL(TIMER, timeout_encode))
2770 scic_controller->interrupt_coalesce_number = (u16)coalesce_number;
2771 scic_controller->interrupt_coalesce_timeout = coalesce_timeout / 100;
2777 struct scic_sds_controller *scic_controller_alloc(struct device *dev)
2779 return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL);
2783 * *****************************************************************************
2784 * * DEFAULT STATE HANDLERS
2785 * ***************************************************************************** */
2789 * @controller: This is struct sci_base_controller object which is cast into a
2790 * struct scic_sds_controller object.
2791 * @remote_device: This is struct sci_base_remote_device which, if it was used, would
2792 * be cast to a struct scic_sds_remote_device.
2793 * @io_request: This is the struct sci_base_request which, if it was used, would be
2794 * cast to a SCIC_SDS_IO_REQUEST.
2795 * @io_tag: This is the IO tag to be assigned to the IO request or
2796 * SCI_CONTROLLER_INVALID_IO_TAG.
2798 * This method is called when the struct scic_sds_controller default start io/task
2799 * handler is in place. - Issue a warning message enum sci_status
2800 * SCI_FAILURE_INVALID_STATE
2802 static enum sci_status scic_sds_controller_default_start_operation_handler(
2803 struct sci_base_controller *controller,
2804 struct sci_base_remote_device *remote_device,
2805 struct sci_base_request *io_request,
2808 struct scic_sds_controller *this_controller;
2810 this_controller = (struct scic_sds_controller *)controller;
2812 dev_warn(scic_to_dev(this_controller),
2813 "%s: SCIC Controller requested to start an io/task from "
2814 "invalid state %d\n",
2816 sci_base_state_machine_get_state(
2817 scic_sds_controller_get_base_state_machine(
2820 return SCI_FAILURE_INVALID_STATE;
2825 * @controller: This is struct sci_base_controller object which is cast into a
2826 * struct scic_sds_controller object.
2827 * @remote_device: This is struct sci_base_remote_device which, if it was used, would
2828 * be cast to a struct scic_sds_remote_device.
2829 * @io_request: This is the struct sci_base_request which, if it was used, would be
2830 * cast to a SCIC_SDS_IO_REQUEST.
2832 * This method is called when the struct scic_sds_controller default request handler
2833 * is in place. - Issue a warning message enum sci_status SCI_FAILURE_INVALID_STATE
2835 static enum sci_status scic_sds_controller_default_request_handler(
2836 struct sci_base_controller *controller,
2837 struct sci_base_remote_device *remote_device,
2838 struct sci_base_request *io_request)
2840 struct scic_sds_controller *this_controller;
2842 this_controller = (struct scic_sds_controller *)controller;
2844 dev_warn(scic_to_dev(this_controller),
2845 "%s: SCIC Controller request operation from invalid state %d\n",
2847 sci_base_state_machine_get_state(
2848 scic_sds_controller_get_base_state_machine(
2851 return SCI_FAILURE_INVALID_STATE;
2855 * *****************************************************************************
2856 * * GENERAL (COMMON) STATE HANDLERS
2857 * ***************************************************************************** */
2861 * @controller: The struct sci_base_controller object which is cast into a
2862 * struct scic_sds_controller object.
2864 * This method is called when the struct scic_sds_controller is in the ready state
2865 * reset handler is in place. - Transition to
2866 * SCI_BASE_CONTROLLER_STATE_RESETTING enum sci_status SCI_SUCCESS
2868 static enum sci_status scic_sds_controller_general_reset_handler(
2869 struct sci_base_controller *controller)
2871 struct scic_sds_controller *this_controller;
2873 this_controller = (struct scic_sds_controller *)controller;
2876 * The reset operation is not a graceful cleanup just perform the state
2878 sci_base_state_machine_change_state(
2879 scic_sds_controller_get_base_state_machine(this_controller),
2880 SCI_BASE_CONTROLLER_STATE_RESETTING
2887 * *****************************************************************************
2888 * * RESET STATE HANDLERS
2889 * ***************************************************************************** */
2893 * @controller: This is the struct sci_base_controller object which is cast into a
2894 * struct scic_sds_controller object.
2896 * This method is the struct scic_sds_controller initialize handler for the reset
2897 * state. - Currently this function does nothing enum sci_status SCI_FAILURE This
2898 * function is not yet implemented and is a valid request from the reset state.
2900 static enum sci_status scic_sds_controller_reset_state_initialize_handler(
2901 struct sci_base_controller *controller)
2904 enum sci_status result = SCI_SUCCESS;
2905 struct scic_sds_controller *this_controller;
2907 this_controller = (struct scic_sds_controller *)controller;
2909 sci_base_state_machine_change_state(
2910 scic_sds_controller_get_base_state_machine(this_controller),
2911 SCI_BASE_CONTROLLER_STATE_INITIALIZING
2914 this_controller->timeout_timer = isci_event_timer_create(
2916 (void (*)(void *))scic_sds_controller_timeout_handler,
2917 (void (*)(void *))controller);
2919 scic_sds_controller_initialize_phy_startup(this_controller);
2921 scic_sds_controller_initialize_power_control(this_controller);
2924 * There is nothing to do here for B0 since we do not have to
2925 * program the AFE registers.
2926 * / @todo The AFE settings are supposed to be correct for the B0 but
2927 * / presently they seem to be wrong. */
2928 scic_sds_controller_afe_initialization(this_controller);
2930 if (SCI_SUCCESS == result) {
2934 /* Take the hardware out of reset */
2935 SMU_SMUSRCR_WRITE(this_controller, 0x00000000);
2938 * / @todo Provide meaningfull error code for hardware failure
2939 * result = SCI_FAILURE_CONTROLLER_HARDWARE; */
2940 result = SCI_FAILURE;
2941 terminate_loop = 100;
2943 while (terminate_loop-- && (result != SCI_SUCCESS)) {
2944 /* Loop until the hardware reports success */
2945 udelay(SCU_CONTEXT_RAM_INIT_STALL_TIME);
2946 status = SMU_SMUCSR_READ(this_controller);
2948 if ((status & SCU_RAM_INIT_COMPLETED) == SCU_RAM_INIT_COMPLETED) {
2949 result = SCI_SUCCESS;
2954 if (result == SCI_SUCCESS) {
2955 u32 max_supported_ports;
2956 u32 max_supported_devices;
2957 u32 max_supported_io_requests;
2958 u32 device_context_capacity;
2961 * Determine what are the actaul device capacities that the
2962 * hardware will support */
2963 device_context_capacity = SMU_DCC_READ(this_controller);
2965 max_supported_ports =
2966 smu_dcc_get_max_ports(device_context_capacity);
2967 max_supported_devices =
2968 smu_dcc_get_max_remote_node_context(device_context_capacity);
2969 max_supported_io_requests =
2970 smu_dcc_get_max_task_context(device_context_capacity);
2972 /* Make all PEs that are unassigned match up with the logical ports */
2973 for (index = 0; index < max_supported_ports; index++) {
2976 this_controller->scu_registers->peg0.ptsg.protocol_engine[index],
2981 /* Record the smaller of the two capacity values */
2982 this_controller->logical_port_entries =
2983 min(max_supported_ports, this_controller->logical_port_entries);
2985 this_controller->task_context_entries =
2986 min(max_supported_io_requests, this_controller->task_context_entries);
2988 this_controller->remote_node_entries =
2989 min(max_supported_devices, this_controller->remote_node_entries);
2992 * Now that we have the correct hardware reported minimum values
2993 * build the MDL for the controller. Default to a performance
2995 scic_controller_set_mode(this_controller, SCI_MODE_SPEED);
2998 /* Initialize hardware PCI Relaxed ordering in DMA engines */
2999 if (result == SCI_SUCCESS) {
3000 u32 dma_configuration;
3002 /* Configure the payload DMA */
3003 dma_configuration = SCU_PDMACR_READ(this_controller);
3004 dma_configuration |= SCU_PDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
3005 SCU_PDMACR_WRITE(this_controller, dma_configuration);
3007 /* Configure the control DMA */
3008 dma_configuration = SCU_CDMACR_READ(this_controller);
3009 dma_configuration |= SCU_CDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
3010 SCU_CDMACR_WRITE(this_controller, dma_configuration);
3014 * Initialize the PHYs before the PORTs because the PHY registers
3015 * are accessed during the port initialization. */
3016 if (result == SCI_SUCCESS) {
3017 /* Initialize the phys */
3019 (result == SCI_SUCCESS) && (index < SCI_MAX_PHYS);
3021 result = scic_sds_phy_initialize(
3022 &this_controller->phy_table[index],
3023 &this_controller->scu_registers->peg0.pe[index].tl,
3024 &this_controller->scu_registers->peg0.pe[index].ll
3029 if (result == SCI_SUCCESS) {
3030 /* Initialize the logical ports */
3032 (index < this_controller->logical_port_entries)
3033 && (result == SCI_SUCCESS);
3035 result = scic_sds_port_initialize(
3036 &this_controller->port_table[index],
3037 &this_controller->scu_registers->peg0.ptsg.port[index],
3038 &this_controller->scu_registers->peg0.ptsg.protocol_engine,
3039 &this_controller->scu_registers->peg0.viit[index]
3044 if (SCI_SUCCESS == result) {
3045 result = scic_sds_port_configuration_agent_initialize(
3047 &this_controller->port_agent
3051 /* Advance the controller state machine */
3052 if (result == SCI_SUCCESS) {
3053 sci_base_state_machine_change_state(
3054 scic_sds_controller_get_base_state_machine(this_controller),
3055 SCI_BASE_CONTROLLER_STATE_INITIALIZED
3058 sci_base_state_machine_change_state(
3059 scic_sds_controller_get_base_state_machine(this_controller),
3060 SCI_BASE_CONTROLLER_STATE_FAILED
3068 * *****************************************************************************
3069 * * INITIALIZED STATE HANDLERS
3070 * ***************************************************************************** */
3074 * @controller: This is the struct sci_base_controller object which is cast into a
3075 * struct scic_sds_controller object.
3076 * @timeout: This is the allowed time for the controller object to reach the
3079 * This method is the struct scic_sds_controller start handler for the initialized
3080 * state. - Validate we have a good memory descriptor table - Initialze the
3081 * physical memory before programming the hardware - Program the SCU hardware
3082 * with the physical memory addresses passed in the memory descriptor table. -
3083 * Initialzie the TCi pool - Initialize the RNi pool - Initialize the
3084 * completion queue - Initialize the unsolicited frame data - Take the SCU port
3085 * task scheduler out of reset - Start the first phy object. - Transition to
3086 * SCI_BASE_CONTROLLER_STATE_STARTING. enum sci_status SCI_SUCCESS if all of the
3087 * controller start operations complete
3088 * SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD if one or more of the memory
3089 * descriptor fields is invalid.
3091 static enum sci_status scic_sds_controller_initialized_state_start_handler(
3092 struct sci_base_controller *controller,
3096 enum sci_status result;
3097 struct scic_sds_controller *this_controller;
3099 this_controller = (struct scic_sds_controller *)controller;
3101 /* Make sure that the SCI User filled in the memory descriptor table correctly */
3102 result = scic_sds_controller_validate_memory_descriptor_table(this_controller);
3104 if (result == SCI_SUCCESS) {
3105 /* The memory descriptor list looks good so program the hardware */
3106 scic_sds_controller_ram_initialization(this_controller);
3109 if (result == SCI_SUCCESS) {
3110 /* Build the TCi free pool */
3111 sci_pool_initialize(this_controller->tci_pool);
3112 for (index = 0; index < this_controller->task_context_entries; index++) {
3113 sci_pool_put(this_controller->tci_pool, index);
3116 /* Build the RNi free pool */
3117 scic_sds_remote_node_table_initialize(
3118 &this_controller->available_remote_nodes,
3119 this_controller->remote_node_entries
3123 if (result == SCI_SUCCESS) {
3125 * Before anything else lets make sure we will not be interrupted
3126 * by the hardware. */
3127 scic_controller_disable_interrupts(this_controller);
3129 /* Enable the port task scheduler */
3130 scic_sds_controller_enable_port_task_scheduler(this_controller);
3132 /* Assign all the task entries to this controller physical function */
3133 scic_sds_controller_assign_task_entries(this_controller);
3135 /* Now initialze the completion queue */
3136 scic_sds_controller_initialize_completion_queue(this_controller);
3138 /* Initialize the unsolicited frame queue for use */
3139 scic_sds_controller_initialize_unsolicited_frame_queue(this_controller);
3142 /* Start all of the ports on this controller */
3143 for (index = 0; index < this_controller->logical_port_entries &&
3144 result == SCI_SUCCESS; index++) {
3145 struct scic_sds_port *sci_port = &this_controller->port_table[index];
3147 result = sci_port->state_handlers->parent.start_handler(&sci_port->parent);
3150 if (result == SCI_SUCCESS) {
3151 scic_sds_controller_start_next_phy(this_controller);
3153 isci_event_timer_start(this_controller,
3154 this_controller->timeout_timer,
3157 sci_base_state_machine_change_state(
3158 scic_sds_controller_get_base_state_machine(this_controller),
3159 SCI_BASE_CONTROLLER_STATE_STARTING
3167 * *****************************************************************************
3168 * * INITIALIZED STATE HANDLERS
3169 * ***************************************************************************** */
3173 * @controller: This is struct scic_sds_controller which receives the link up
3175 * @port: This is struct scic_sds_port with which the phy is associated.
3176 * @phy: This is the struct scic_sds_phy which has gone link up.
3178 * This method is called when the struct scic_sds_controller is in the starting state
3179 * link up handler is called. This method will perform the following: - Stop
3180 * the phy timer - Start the next phy - Report the link up condition to the
3183 static void scic_sds_controller_starting_state_link_up_handler(
3184 struct scic_sds_controller *this_controller,
3185 struct scic_sds_port *port,
3186 struct scic_sds_phy *phy)
3188 scic_sds_controller_phy_timer_stop(this_controller);
3190 this_controller->port_agent.link_up_handler(
3191 this_controller, &this_controller->port_agent, port, phy
3193 /* scic_sds_port_link_up(port, phy); */
3195 scic_sds_controller_start_next_phy(this_controller);
3200 * @controller: This is struct scic_sds_controller which receives the link down
3202 * @port: This is struct scic_sds_port with which the phy is associated.
3203 * @phy: This is the struct scic_sds_phy which has gone link down.
3205 * This method is called when the struct scic_sds_controller is in the starting state
3206 * link down handler is called. - Report the link down condition to the port
3209 static void scic_sds_controller_starting_state_link_down_handler(
3210 struct scic_sds_controller *this_controller,
3211 struct scic_sds_port *port,
3212 struct scic_sds_phy *phy)
3214 this_controller->port_agent.link_down_handler(
3215 this_controller, &this_controller->port_agent, port, phy
3217 /* scic_sds_port_link_down(port, phy); */
3221 * *****************************************************************************
3222 * * READY STATE HANDLERS
3223 * ***************************************************************************** */
3227 * @controller: The struct sci_base_controller object which is cast into a
3228 * struct scic_sds_controller object.
3229 * @timeout: The timeout for when the stop operation should report a failure.
3231 * This method is called when the struct scic_sds_controller is in the ready state
3232 * stop handler is called. - Start the timeout timer - Transition to
3233 * SCI_BASE_CONTROLLER_STATE_STOPPING. enum sci_status SCI_SUCCESS
3235 static enum sci_status scic_sds_controller_ready_state_stop_handler(
3236 struct sci_base_controller *controller,
3239 struct scic_sds_controller *this_controller;
3241 this_controller = (struct scic_sds_controller *)controller;
3243 isci_event_timer_start(this_controller,
3244 this_controller->timeout_timer,
3247 sci_base_state_machine_change_state(
3248 scic_sds_controller_get_base_state_machine(this_controller),
3249 SCI_BASE_CONTROLLER_STATE_STOPPING
3257 * @controller: This is struct sci_base_controller object which is cast into a
3258 * struct scic_sds_controller object.
3259 * @remote_device: This is struct sci_base_remote_device which is cast to a
3260 * struct scic_sds_remote_device object.
3261 * @io_request: This is the struct sci_base_request which is cast to a
3262 * SCIC_SDS_IO_REQUEST object.
3263 * @io_tag: This is the IO tag to be assigned to the IO request or
3264 * SCI_CONTROLLER_INVALID_IO_TAG.
3266 * This method is called when the struct scic_sds_controller is in the ready state and
3267 * the start io handler is called. - Start the io request on the remote device
3268 * - if successful - assign the io_request to the io_request_table - post the
3269 * request to the hardware enum sci_status SCI_SUCCESS if the start io operation
3270 * succeeds SCI_FAILURE_INSUFFICIENT_RESOURCES if the IO tag could not be
3271 * allocated for the io request. SCI_FAILURE_INVALID_STATE if one or more
3272 * objects are not in a valid state to accept io requests. How does the io_tag
3273 * parameter get assigned to the io request?
3275 static enum sci_status scic_sds_controller_ready_state_start_io_handler(
3276 struct sci_base_controller *controller,
3277 struct sci_base_remote_device *remote_device,
3278 struct sci_base_request *io_request,
3281 enum sci_status status;
3283 struct scic_sds_controller *this_controller;
3284 struct scic_sds_request *the_request;
3285 struct scic_sds_remote_device *the_device;
3287 this_controller = (struct scic_sds_controller *)controller;
3288 the_request = (struct scic_sds_request *)io_request;
3289 the_device = (struct scic_sds_remote_device *)remote_device;
3291 status = scic_sds_remote_device_start_io(this_controller, the_device, the_request);
3293 if (status == SCI_SUCCESS) {
3294 this_controller->io_request_table[
3295 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3297 scic_sds_controller_post_request(
3299 scic_sds_request_get_post_context(the_request)
3308 * @controller: This is struct sci_base_controller object which is cast into a
3309 * struct scic_sds_controller object.
3310 * @remote_device: This is struct sci_base_remote_device which is cast to a
3311 * struct scic_sds_remote_device object.
3312 * @io_request: This is the struct sci_base_request which is cast to a
3313 * SCIC_SDS_IO_REQUEST object.
3315 * This method is called when the struct scic_sds_controller is in the ready state and
3316 * the complete io handler is called. - Complete the io request on the remote
3317 * device - if successful - remove the io_request to the io_request_table
3318 * enum sci_status SCI_SUCCESS if the start io operation succeeds
3319 * SCI_FAILURE_INVALID_STATE if one or more objects are not in a valid state to
3320 * accept io requests.
3322 static enum sci_status scic_sds_controller_ready_state_complete_io_handler(
3323 struct sci_base_controller *controller,
3324 struct sci_base_remote_device *remote_device,
3325 struct sci_base_request *io_request)
3328 enum sci_status status;
3329 struct scic_sds_controller *this_controller;
3330 struct scic_sds_request *the_request;
3331 struct scic_sds_remote_device *the_device;
3333 this_controller = (struct scic_sds_controller *)controller;
3334 the_request = (struct scic_sds_request *)io_request;
3335 the_device = (struct scic_sds_remote_device *)remote_device;
3337 status = scic_sds_remote_device_complete_io(
3338 this_controller, the_device, the_request);
3340 if (status == SCI_SUCCESS) {
3341 index = scic_sds_io_tag_get_index(the_request->io_tag);
3342 this_controller->io_request_table[index] = NULL;
3350 * @controller: This is struct sci_base_controller object which is cast into a
3351 * struct scic_sds_controller object.
3352 * @remote_device: This is struct sci_base_remote_device which is cast to a
3353 * struct scic_sds_remote_device object.
3354 * @io_request: This is the struct sci_base_request which is cast to a
3355 * SCIC_SDS_IO_REQUEST object.
3357 * This method is called when the struct scic_sds_controller is in the ready state and
3358 * the continue io handler is called. enum sci_status
3360 static enum sci_status scic_sds_controller_ready_state_continue_io_handler(
3361 struct sci_base_controller *controller,
3362 struct sci_base_remote_device *remote_device,
3363 struct sci_base_request *io_request)
3365 struct scic_sds_controller *this_controller;
3366 struct scic_sds_request *the_request;
3368 the_request = (struct scic_sds_request *)io_request;
3369 this_controller = (struct scic_sds_controller *)controller;
3371 this_controller->io_request_table[
3372 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3374 scic_sds_controller_post_request(
3376 scic_sds_request_get_post_context(the_request)
3384 * @controller: This is struct sci_base_controller object which is cast into a
3385 * struct scic_sds_controller object.
3386 * @remote_device: This is struct sci_base_remote_device which is cast to a
3387 * struct scic_sds_remote_device object.
3388 * @io_request: This is the struct sci_base_request which is cast to a
3389 * SCIC_SDS_IO_REQUEST object.
3390 * @task_tag: This is the task tag to be assigned to the task request or
3391 * SCI_CONTROLLER_INVALID_IO_TAG.
3393 * This method is called when the struct scic_sds_controller is in the ready state and
3394 * the start task handler is called. - The remote device is requested to start
3395 * the task request - if successful - assign the task to the io_request_table -
3396 * post the request to the SCU hardware enum sci_status SCI_SUCCESS if the start io
3397 * operation succeeds SCI_FAILURE_INSUFFICIENT_RESOURCES if the IO tag could
3398 * not be allocated for the io request. SCI_FAILURE_INVALID_STATE if one or
3399 * more objects are not in a valid state to accept io requests. How does the io
3400 * tag get assigned in this code path?
3402 static enum sci_status scic_sds_controller_ready_state_start_task_handler(
3403 struct sci_base_controller *controller,
3404 struct sci_base_remote_device *remote_device,
3405 struct sci_base_request *io_request,
3408 struct scic_sds_controller *this_controller = (struct scic_sds_controller *)
3410 struct scic_sds_request *the_request = (struct scic_sds_request *)
3412 struct scic_sds_remote_device *the_device = (struct scic_sds_remote_device *)
3414 enum sci_status status;
3416 status = scic_sds_remote_device_start_task(
3417 this_controller, the_device, the_request
3420 if (status == SCI_SUCCESS) {
3421 this_controller->io_request_table[
3422 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3424 scic_sds_controller_post_request(
3426 scic_sds_request_get_post_context(the_request)
3428 } else if (status == SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS) {
3429 this_controller->io_request_table[
3430 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3433 * We will let framework know this task request started successfully,
3434 * although core is still woring on starting the request (to post tc when
3435 * RNC is resumed.) */
3436 status = SCI_SUCCESS;
3443 * @controller: This is struct sci_base_controller object which is cast into a
3444 * struct scic_sds_controller object.
3445 * @remote_device: This is struct sci_base_remote_device which is cast to a
3446 * struct scic_sds_remote_device object.
3447 * @io_request: This is the struct sci_base_request which is cast to a
3448 * SCIC_SDS_IO_REQUEST object.
3450 * This method is called when the struct scic_sds_controller is in the ready state and
3451 * the terminate request handler is called. - call the io request terminate
3452 * function - if successful - post the terminate request to the SCU hardware
3453 * enum sci_status SCI_SUCCESS if the start io operation succeeds
3454 * SCI_FAILURE_INVALID_STATE if one or more objects are not in a valid state to
3455 * accept io requests.
3457 static enum sci_status scic_sds_controller_ready_state_terminate_request_handler(
3458 struct sci_base_controller *controller,
3459 struct sci_base_remote_device *remote_device,
3460 struct sci_base_request *io_request)
3462 struct scic_sds_controller *this_controller = (struct scic_sds_controller *)
3464 struct scic_sds_request *the_request = (struct scic_sds_request *)
3466 enum sci_status status;
3468 status = scic_sds_io_request_terminate(the_request);
3469 if (status == SCI_SUCCESS) {
3471 * Utilize the original post context command and or in the POST_TC_ABORT
3472 * request sub-type. */
3473 scic_sds_controller_post_request(
3475 scic_sds_request_get_post_context(the_request)
3476 | SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT
3485 * @controller: This is struct scic_sds_controller which receives the link up
3487 * @port: This is struct scic_sds_port with which the phy is associated.
3488 * @phy: This is the struct scic_sds_phy which has gone link up.
3490 * This method is called when the struct scic_sds_controller is in the starting state
3491 * link up handler is called. This method will perform the following: - Stop
3492 * the phy timer - Start the next phy - Report the link up condition to the
3495 static void scic_sds_controller_ready_state_link_up_handler(
3496 struct scic_sds_controller *this_controller,
3497 struct scic_sds_port *port,
3498 struct scic_sds_phy *phy)
3500 this_controller->port_agent.link_up_handler(
3501 this_controller, &this_controller->port_agent, port, phy
3507 * @controller: This is struct scic_sds_controller which receives the link down
3509 * @port: This is struct scic_sds_port with which the phy is associated.
3510 * @phy: This is the struct scic_sds_phy which has gone link down.
3512 * This method is called when the struct scic_sds_controller is in the starting state
3513 * link down handler is called. - Report the link down condition to the port
3516 static void scic_sds_controller_ready_state_link_down_handler(
3517 struct scic_sds_controller *this_controller,
3518 struct scic_sds_port *port,
3519 struct scic_sds_phy *phy)
3521 this_controller->port_agent.link_down_handler(
3522 this_controller, &this_controller->port_agent, port, phy
3527 * *****************************************************************************
3528 * * STOPPING STATE HANDLERS
3529 * ***************************************************************************** */
3533 * @controller: This is struct sci_base_controller object which is cast into a
3534 * struct scic_sds_controller object.
3535 * @remote_device: This is struct sci_base_remote_device which is cast to a
3536 * struct scic_sds_remote_device object.
3537 * @io_request: This is the struct sci_base_request which is cast to a
3538 * SCIC_SDS_IO_REQUEST object.
3540 * This method is called when the struct scic_sds_controller is in a stopping state
3541 * and the complete io handler is called. - This function is not yet
3542 * implemented enum sci_status SCI_FAILURE
3544 static enum sci_status scic_sds_controller_stopping_state_complete_io_handler(
3545 struct sci_base_controller *controller,
3546 struct sci_base_remote_device *remote_device,
3547 struct sci_base_request *io_request)
3549 struct scic_sds_controller *this_controller;
3551 this_controller = (struct scic_sds_controller *)controller;
3553 /* / @todo Implement this function */
3559 * @controller: This is struct sci_base_controller object which is cast into a
3560 * struct scic_sds_controller object.
3561 * @remote_device: This is struct sci_base_remote_device which is cast to a
3562 * struct scic_sds_remote_device object.
3564 * This method is called when the struct scic_sds_controller is in a stopping state
3565 * and the remote device has stopped.
3567 void scic_sds_controller_stopping_state_device_stopped_handler(
3568 struct scic_sds_controller *controller,
3569 struct scic_sds_remote_device *remote_device
3572 if (!scic_sds_controller_has_remote_devices_stopping(controller)) {
3573 sci_base_state_machine_change_state(
3574 &controller->parent.state_machine,
3575 SCI_BASE_CONTROLLER_STATE_STOPPED
3580 const struct scic_sds_controller_state_handler scic_sds_controller_state_handler_table[] = {
3581 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3582 .base.start_io = scic_sds_controller_default_start_operation_handler,
3583 .base.complete_io = scic_sds_controller_default_request_handler,
3584 .base.continue_io = scic_sds_controller_default_request_handler,
3585 .terminate_request = scic_sds_controller_default_request_handler,
3587 [SCI_BASE_CONTROLLER_STATE_RESET] = {
3588 .base.reset = scic_sds_controller_general_reset_handler,
3589 .base.initialize = scic_sds_controller_reset_state_initialize_handler,
3590 .base.start_io = scic_sds_controller_default_start_operation_handler,
3591 .base.complete_io = scic_sds_controller_default_request_handler,
3592 .base.continue_io = scic_sds_controller_default_request_handler,
3593 .terminate_request = scic_sds_controller_default_request_handler,
3595 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {
3596 .base.start_io = scic_sds_controller_default_start_operation_handler,
3597 .base.complete_io = scic_sds_controller_default_request_handler,
3598 .base.continue_io = scic_sds_controller_default_request_handler,
3599 .terminate_request = scic_sds_controller_default_request_handler,
3601 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {
3602 .base.start = scic_sds_controller_initialized_state_start_handler,
3603 .base.start_io = scic_sds_controller_default_start_operation_handler,
3604 .base.complete_io = scic_sds_controller_default_request_handler,
3605 .base.continue_io = scic_sds_controller_default_request_handler,
3606 .terminate_request = scic_sds_controller_default_request_handler,
3608 [SCI_BASE_CONTROLLER_STATE_STARTING] = {
3609 .base.start_io = scic_sds_controller_default_start_operation_handler,
3610 .base.complete_io = scic_sds_controller_default_request_handler,
3611 .base.continue_io = scic_sds_controller_default_request_handler,
3612 .terminate_request = scic_sds_controller_default_request_handler,
3613 .link_up = scic_sds_controller_starting_state_link_up_handler,
3614 .link_down = scic_sds_controller_starting_state_link_down_handler
3616 [SCI_BASE_CONTROLLER_STATE_READY] = {
3617 .base.stop = scic_sds_controller_ready_state_stop_handler,
3618 .base.reset = scic_sds_controller_general_reset_handler,
3619 .base.start_io = scic_sds_controller_ready_state_start_io_handler,
3620 .base.complete_io = scic_sds_controller_ready_state_complete_io_handler,
3621 .base.continue_io = scic_sds_controller_ready_state_continue_io_handler,
3622 .base.start_task = scic_sds_controller_ready_state_start_task_handler,
3623 .base.complete_task = scic_sds_controller_ready_state_complete_io_handler,
3624 .terminate_request = scic_sds_controller_ready_state_terminate_request_handler,
3625 .link_up = scic_sds_controller_ready_state_link_up_handler,
3626 .link_down = scic_sds_controller_ready_state_link_down_handler
3628 [SCI_BASE_CONTROLLER_STATE_RESETTING] = {
3629 .base.start_io = scic_sds_controller_default_start_operation_handler,
3630 .base.complete_io = scic_sds_controller_default_request_handler,
3631 .base.continue_io = scic_sds_controller_default_request_handler,
3632 .terminate_request = scic_sds_controller_default_request_handler,
3634 [SCI_BASE_CONTROLLER_STATE_STOPPING] = {
3635 .base.start_io = scic_sds_controller_default_start_operation_handler,
3636 .base.complete_io = scic_sds_controller_stopping_state_complete_io_handler,
3637 .base.continue_io = scic_sds_controller_default_request_handler,
3638 .terminate_request = scic_sds_controller_default_request_handler,
3639 .remote_device_stopped_handler = scic_sds_controller_stopping_state_device_stopped_handler,
3641 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {
3642 .base.reset = scic_sds_controller_general_reset_handler,
3643 .base.start_io = scic_sds_controller_default_start_operation_handler,
3644 .base.complete_io = scic_sds_controller_default_request_handler,
3645 .base.continue_io = scic_sds_controller_default_request_handler,
3646 .terminate_request = scic_sds_controller_default_request_handler,
3648 [SCI_BASE_CONTROLLER_STATE_FAILED] = {
3649 .base.reset = scic_sds_controller_general_reset_handler,
3650 .base.start_io = scic_sds_controller_default_start_operation_handler,
3651 .base.complete_io = scic_sds_controller_default_request_handler,
3652 .base.continue_io = scic_sds_controller_default_request_handler,
3653 .terminate_request = scic_sds_controller_default_request_handler,
3659 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3662 * This method implements the actions taken by the struct scic_sds_controller on entry
3663 * to the SCI_BASE_CONTROLLER_STATE_INITIAL. - Set the state handlers to the
3664 * controllers initial state. none This function should initialze the
3665 * controller object.
3667 static void scic_sds_controller_initial_state_enter(
3668 struct sci_base_object *object)
3670 struct scic_sds_controller *this_controller;
3672 this_controller = (struct scic_sds_controller *)object;
3674 sci_base_state_machine_change_state(
3675 &this_controller->parent.state_machine, SCI_BASE_CONTROLLER_STATE_RESET);
3680 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3683 * This method implements the actions taken by the struct scic_sds_controller on exit
3684 * from the SCI_BASE_CONTROLLER_STATE_STARTING. - This function stops the
3685 * controller starting timeout timer. none
3687 static void scic_sds_controller_starting_state_exit(
3688 struct sci_base_object *object)
3690 struct scic_sds_controller *scic = (struct scic_sds_controller *)object;
3692 isci_event_timer_stop(scic, scic->timeout_timer);
3697 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3700 * This method implements the actions taken by the struct scic_sds_controller on entry
3701 * to the SCI_BASE_CONTROLLER_STATE_READY. - Set the state handlers to the
3702 * controllers ready state. none
3704 static void scic_sds_controller_ready_state_enter(
3705 struct sci_base_object *object)
3707 struct scic_sds_controller *this_controller;
3709 this_controller = (struct scic_sds_controller *)object;
3711 /* set the default interrupt coalescence number and timeout value. */
3712 scic_controller_set_interrupt_coalescence(
3713 this_controller, 0x10, 250);
3718 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3721 * This method implements the actions taken by the struct scic_sds_controller on exit
3722 * from the SCI_BASE_CONTROLLER_STATE_READY. - This function does nothing. none
3724 static void scic_sds_controller_ready_state_exit(
3725 struct sci_base_object *object)
3727 struct scic_sds_controller *this_controller;
3729 this_controller = (struct scic_sds_controller *)object;
3731 /* disable interrupt coalescence. */
3732 scic_controller_set_interrupt_coalescence(this_controller, 0, 0);
3737 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3740 * This method implements the actions taken by the struct scic_sds_controller on entry
3741 * to the SCI_BASE_CONTROLLER_STATE_READY. - Set the state handlers to the
3742 * controllers ready state. - Stop the phys on this controller - Stop the ports
3743 * on this controller - Stop all of the remote devices on this controller none
3745 static void scic_sds_controller_stopping_state_enter(
3746 struct sci_base_object *object)
3748 struct scic_sds_controller *this_controller;
3750 this_controller = (struct scic_sds_controller *)object;
3752 /* Stop all of the components for this controller */
3753 scic_sds_controller_stop_phys(this_controller);
3754 scic_sds_controller_stop_ports(this_controller);
3755 scic_sds_controller_stop_devices(this_controller);
3760 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3763 * This method implements the actions taken by the struct scic_sds_controller on exit
3764 * from the SCI_BASE_CONTROLLER_STATE_STOPPING. - This function stops the
3765 * controller stopping timeout timer. none
3767 static void scic_sds_controller_stopping_state_exit(
3768 struct sci_base_object *object)
3770 struct scic_sds_controller *this_controller;
3772 this_controller = (struct scic_sds_controller *)object;
3774 isci_event_timer_stop(this_controller, this_controller->timeout_timer);
3779 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3782 * This method implements the actions taken by the struct scic_sds_controller on entry
3783 * to the SCI_BASE_CONTROLLER_STATE_RESETTING. - Set the state handlers to the
3784 * controllers resetting state. - Write to the SCU hardware reset register to
3785 * force a reset - Transition to the SCI_BASE_CONTROLLER_STATE_RESET none
3787 static void scic_sds_controller_resetting_state_enter(
3788 struct sci_base_object *object)
3790 struct scic_sds_controller *this_controller;
3792 this_controller = (struct scic_sds_controller *)object;
3794 scic_sds_controller_reset_hardware(this_controller);
3796 sci_base_state_machine_change_state(
3797 scic_sds_controller_get_base_state_machine(this_controller),
3798 SCI_BASE_CONTROLLER_STATE_RESET
3802 /* --------------------------------------------------------------------------- */
3804 const struct sci_base_state scic_sds_controller_state_table[] = {
3805 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3806 .enter_state = scic_sds_controller_initial_state_enter,
3808 [SCI_BASE_CONTROLLER_STATE_RESET] = {},
3809 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {},
3810 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {},
3811 [SCI_BASE_CONTROLLER_STATE_STARTING] = {
3812 .exit_state = scic_sds_controller_starting_state_exit,
3814 [SCI_BASE_CONTROLLER_STATE_READY] = {
3815 .enter_state = scic_sds_controller_ready_state_enter,
3816 .exit_state = scic_sds_controller_ready_state_exit,
3818 [SCI_BASE_CONTROLLER_STATE_RESETTING] = {
3819 .enter_state = scic_sds_controller_resetting_state_enter,
3821 [SCI_BASE_CONTROLLER_STATE_STOPPING] = {
3822 .enter_state = scic_sds_controller_stopping_state_enter,
3823 .exit_state = scic_sds_controller_stopping_state_exit,
3825 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
3826 [SCI_BASE_CONTROLLER_STATE_FAILED] = {}