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)
598 const struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
602 /* Clear DFX Status registers */
603 scu_afe_register_write(scic, afe_dfx_master_control0, 0x0081000f);
604 udelay(AFE_REGISTER_WRITE_DELAY);
606 /* Configure bias currents to normal */
608 scu_afe_register_write(scic, afe_bias_control, 0x00005500);
610 scu_afe_register_write(scic, afe_bias_control, 0x00005A00);
612 udelay(AFE_REGISTER_WRITE_DELAY);
616 scu_afe_register_write(scic, afe_pll_control0, 0x80040A08);
618 scu_afe_register_write(scic, afe_pll_control0, 0x80040908);
620 udelay(AFE_REGISTER_WRITE_DELAY);
622 /* Wait for the PLL to lock */
624 afe_status = scu_afe_register_read(
625 scic, afe_common_block_status);
626 udelay(AFE_REGISTER_WRITE_DELAY);
627 } while ((afe_status & 0x00001000) == 0);
630 /* Shorten SAS SNW lock time (RxLock timer value from 76 us to 50 us) */
631 scu_afe_register_write(scic, afe_pmsn_master_control0, 0x7bcc96ad);
632 udelay(AFE_REGISTER_WRITE_DELAY);
635 for (phy_id = 0; phy_id < SCI_MAX_PHYS; phy_id++) {
636 const struct sci_phy_oem_params *oem_phy = &oem->phys[phy_id];
639 /* Configure transmitter SSC parameters */
640 scu_afe_txreg_write(scic, phy_id, afe_tx_ssc_control, 0x00030000);
641 udelay(AFE_REGISTER_WRITE_DELAY);
644 * All defaults, except the Receive Word Alignament/Comma Detect
645 * Enable....(0xe800) */
646 scu_afe_txreg_write(scic, phy_id, afe_xcvr_control0, 0x00004512);
647 udelay(AFE_REGISTER_WRITE_DELAY);
649 scu_afe_txreg_write(scic, phy_id, afe_xcvr_control1, 0x0050100F);
650 udelay(AFE_REGISTER_WRITE_DELAY);
654 * Power up TX and RX out from power down (PWRDNTX and PWRDNRX)
655 * & increase TX int & ext bias 20%....(0xe85c) */
657 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003D4);
659 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003F0);
661 /* Power down TX and RX (PWRDNTX and PWRDNRX) */
662 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003d7);
663 udelay(AFE_REGISTER_WRITE_DELAY);
666 * Power up TX and RX out from power down (PWRDNTX and PWRDNRX)
667 * & increase TX int & ext bias 20%....(0xe85c) */
668 scu_afe_txreg_write(scic, phy_id, afe_channel_control, 0x000003d4);
670 udelay(AFE_REGISTER_WRITE_DELAY);
672 if (is_a0() || is_a2()) {
673 /* Enable TX equalization (0xe824) */
674 scu_afe_txreg_write(scic, phy_id, afe_tx_control, 0x00040000);
675 udelay(AFE_REGISTER_WRITE_DELAY);
679 * RDPI=0x0(RX Power On), RXOOBDETPDNC=0x0, TPD=0x0(TX Power On),
680 * RDD=0x0(RX Detect Enabled) ....(0xe800) */
681 scu_afe_txreg_write(scic, phy_id, afe_xcvr_control0, 0x00004100);
682 udelay(AFE_REGISTER_WRITE_DELAY);
684 /* Leave DFE/FFE on */
686 scu_afe_txreg_write(scic, phy_id, afe_rx_ssc_control0, 0x3F09983F);
688 scu_afe_txreg_write(scic, phy_id, afe_rx_ssc_control0, 0x3F11103F);
690 scu_afe_txreg_write(scic, phy_id, afe_rx_ssc_control0, 0x3F11103F);
691 udelay(AFE_REGISTER_WRITE_DELAY);
692 /* Enable TX equalization (0xe824) */
693 scu_afe_txreg_write(scic, phy_id, afe_tx_control, 0x00040000);
695 udelay(AFE_REGISTER_WRITE_DELAY);
697 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control0);
698 udelay(AFE_REGISTER_WRITE_DELAY);
700 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control1);
701 udelay(AFE_REGISTER_WRITE_DELAY);
703 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control2);
704 udelay(AFE_REGISTER_WRITE_DELAY);
706 scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control3);
707 udelay(AFE_REGISTER_WRITE_DELAY);
710 /* Transfer control to the PEs */
711 scu_afe_register_write(scic, afe_dfx_master_control0, 0x00010f00);
712 udelay(AFE_REGISTER_WRITE_DELAY);
716 * ****************************************************************************-
717 * * SCIC SDS Controller Internal Start/Stop Routines
718 * ****************************************************************************- */
722 * This method will attempt to transition into the ready state for the
723 * controller and indicate that the controller start operation has completed
724 * if all criteria are met.
725 * @this_controller: This parameter indicates the controller object for which
726 * to transition to ready.
727 * @status: This parameter indicates the status value to be pass into the call
728 * to scic_cb_controller_start_complete().
732 static void scic_sds_controller_transition_to_ready(
733 struct scic_sds_controller *this_controller,
734 enum sci_status status)
736 if (this_controller->parent.state_machine.current_state_id
737 == SCI_BASE_CONTROLLER_STATE_STARTING) {
739 * We move into the ready state, because some of the phys/ports
740 * may be up and operational. */
741 sci_base_state_machine_change_state(
742 scic_sds_controller_get_base_state_machine(this_controller),
743 SCI_BASE_CONTROLLER_STATE_READY
746 isci_event_controller_start_complete(this_controller, status);
751 * This method is the general timeout handler for the controller. It will take
752 * the correct timetout action based on the current controller state
754 void scic_sds_controller_timeout_handler(
755 struct scic_sds_controller *scic)
757 enum sci_base_controller_states current_state;
759 current_state = sci_base_state_machine_get_state(
760 scic_sds_controller_get_base_state_machine(scic));
762 if (current_state == SCI_BASE_CONTROLLER_STATE_STARTING) {
763 scic_sds_controller_transition_to_ready(
764 scic, SCI_FAILURE_TIMEOUT);
765 } else if (current_state == SCI_BASE_CONTROLLER_STATE_STOPPING) {
766 sci_base_state_machine_change_state(
767 scic_sds_controller_get_base_state_machine(scic),
768 SCI_BASE_CONTROLLER_STATE_FAILED);
769 isci_event_controller_stop_complete(scic, SCI_FAILURE_TIMEOUT);
770 } else /* / @todo Now what do we want to do in this case? */
771 dev_err(scic_to_dev(scic),
772 "%s: Controller timer fired when controller was not "
773 "in a state being timed.\n",
777 enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller *scic)
780 enum sci_status port_status;
781 enum sci_status status = SCI_SUCCESS;
783 for (index = 0; index < scic->logical_port_entries; index++) {
784 struct scic_sds_port *sci_port = &scic->port_table[index];
785 SCI_BASE_PORT_HANDLER_T stop;
787 stop = sci_port->state_handlers->parent.stop_handler;
788 port_status = stop(&sci_port->parent);
790 if ((port_status != SCI_SUCCESS) &&
791 (port_status != SCI_FAILURE_INVALID_STATE)) {
792 status = SCI_FAILURE;
794 dev_warn(scic_to_dev(scic),
795 "%s: Controller stop operation failed to "
796 "stop port %d because of status %d.\n",
798 sci_port->logical_port_index,
811 static void scic_sds_controller_phy_timer_start(
812 struct scic_sds_controller *this_controller)
814 isci_event_timer_start(
816 this_controller->phy_startup_timer,
817 SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT
820 this_controller->phy_startup_timer_pending = true;
828 void scic_sds_controller_phy_timer_stop(
829 struct scic_sds_controller *this_controller)
831 isci_event_timer_stop(
833 this_controller->phy_startup_timer
836 this_controller->phy_startup_timer_pending = false;
840 * This method is called internally by the controller object to start the next
841 * phy on the controller. If all the phys have been started, then this
842 * method will attempt to transition the controller to the READY state and
843 * inform the user (scic_cb_controller_start_complete()).
844 * @this_controller: This parameter specifies the controller object for which
845 * to start the next phy.
849 enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *scic)
851 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
852 struct scic_sds_phy *sci_phy;
853 enum sci_status status;
855 status = SCI_SUCCESS;
857 if (scic->phy_startup_timer_pending)
860 if (scic->next_phy_to_start >= SCI_MAX_PHYS) {
861 bool is_controller_start_complete = true;
865 for (index = 0; index < SCI_MAX_PHYS; index++) {
866 sci_phy = &scic->phy_table[index];
867 state = sci_phy->parent.state_machine.current_state_id;
869 if (!scic_sds_phy_get_port(sci_phy))
872 /* The controller start operation is complete iff:
873 * - all links have been given an opportunity to start
874 * - have no indication of a connected device
875 * - have an indication of a connected device and it has
876 * finished the link training process.
878 if ((sci_phy->is_in_link_training == false &&
879 state == SCI_BASE_PHY_STATE_INITIAL) ||
880 (sci_phy->is_in_link_training == false &&
881 state == SCI_BASE_PHY_STATE_STOPPED) ||
882 (sci_phy->is_in_link_training == true &&
883 state == SCI_BASE_PHY_STATE_STARTING)) {
884 is_controller_start_complete = false;
890 * The controller has successfully finished the start process.
891 * Inform the SCI Core user and transition to the READY state. */
892 if (is_controller_start_complete == true) {
893 scic_sds_controller_transition_to_ready(scic, SCI_SUCCESS);
894 scic_sds_controller_phy_timer_stop(scic);
897 sci_phy = &scic->phy_table[scic->next_phy_to_start];
899 if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
900 if (scic_sds_phy_get_port(sci_phy) == NULL) {
901 scic->next_phy_to_start++;
903 /* Caution recursion ahead be forwarned
905 * The PHY was never added to a PORT in MPC mode
906 * so start the next phy in sequence This phy
907 * will never go link up and will not draw power
908 * the OEM parameters either configured the phy
909 * incorrectly for the PORT or it was never
912 return scic_sds_controller_start_next_phy(scic);
916 status = scic_sds_phy_start(sci_phy);
918 if (status == SCI_SUCCESS) {
919 scic_sds_controller_phy_timer_start(scic);
921 dev_warn(scic_to_dev(scic),
922 "%s: Controller stop operation failed "
923 "to stop phy %d because of status "
926 scic->phy_table[scic->next_phy_to_start].phy_index,
930 scic->next_phy_to_start++;
942 enum sci_status scic_sds_controller_stop_phys(
943 struct scic_sds_controller *this_controller)
946 enum sci_status status;
947 enum sci_status phy_status;
949 status = SCI_SUCCESS;
951 for (index = 0; index < SCI_MAX_PHYS; index++) {
952 phy_status = scic_sds_phy_stop(&this_controller->phy_table[index]);
955 (phy_status != SCI_SUCCESS)
956 && (phy_status != SCI_FAILURE_INVALID_STATE)
958 status = SCI_FAILURE;
960 dev_warn(scic_to_dev(this_controller),
961 "%s: Controller stop operation failed to stop "
962 "phy %d because of status %d.\n",
964 this_controller->phy_table[index].phy_index, phy_status);
977 enum sci_status scic_sds_controller_stop_devices(
978 struct scic_sds_controller *this_controller)
981 enum sci_status status;
982 enum sci_status device_status;
984 status = SCI_SUCCESS;
986 for (index = 0; index < this_controller->remote_node_entries; index++) {
987 if (this_controller->device_table[index] != NULL) {
988 /* / @todo What timeout value do we want to provide to this request? */
989 device_status = scic_remote_device_stop(this_controller->device_table[index], 0);
991 if ((device_status != SCI_SUCCESS) &&
992 (device_status != SCI_FAILURE_INVALID_STATE)) {
993 dev_warn(scic_to_dev(this_controller),
994 "%s: Controller stop operation failed "
995 "to stop device 0x%p because of "
998 this_controller->device_table[index], device_status);
1007 * ****************************************************************************-
1008 * * SCIC SDS Controller Power Control (Staggered Spinup)
1009 * ****************************************************************************- */
1014 * This method starts the power control timer for this controller object.
1016 static void scic_sds_controller_power_control_timer_start(
1017 struct scic_sds_controller *this_controller)
1019 isci_event_timer_start(
1020 this_controller, this_controller->power_control.timer,
1021 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL
1024 this_controller->power_control.timer_started = true;
1028 * This method stops the power control timer for this controller object.
1032 void scic_sds_controller_power_control_timer_stop(struct scic_sds_controller *scic)
1034 if (scic->power_control.timer_started) {
1035 isci_event_timer_stop(scic, scic->power_control.timer);
1036 scic->power_control.timer_started = false;
1041 * This method stops and starts the power control timer for this controller object.
1045 void scic_sds_controller_power_control_timer_restart(
1046 struct scic_sds_controller *scic)
1048 scic_sds_controller_power_control_timer_stop(scic);
1049 scic_sds_controller_power_control_timer_start(scic);
1057 static void scic_sds_controller_power_control_timer_handler(
1060 struct scic_sds_controller *this_controller;
1062 this_controller = (struct scic_sds_controller *)controller;
1064 this_controller->power_control.phys_granted_power = 0;
1066 if (this_controller->power_control.phys_waiting == 0) {
1067 this_controller->power_control.timer_started = false;
1069 struct scic_sds_phy *the_phy = NULL;
1074 && (this_controller->power_control.phys_waiting != 0);
1076 if (this_controller->power_control.requesters[i] != NULL) {
1077 if (this_controller->power_control.phys_granted_power <
1078 this_controller->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
1079 the_phy = this_controller->power_control.requesters[i];
1080 this_controller->power_control.requesters[i] = NULL;
1081 this_controller->power_control.phys_waiting--;
1082 this_controller->power_control.phys_granted_power++;
1083 scic_sds_phy_consume_power_handler(the_phy);
1091 * It doesn't matter if the power list is empty, we need to start the
1092 * timer in case another phy becomes ready.
1094 scic_sds_controller_power_control_timer_start(this_controller);
1099 * This method inserts the phy in the stagger spinup control queue.
1104 void scic_sds_controller_power_control_queue_insert(
1105 struct scic_sds_controller *this_controller,
1106 struct scic_sds_phy *the_phy)
1108 BUG_ON(the_phy == NULL);
1110 if (this_controller->power_control.phys_granted_power <
1111 this_controller->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
1112 this_controller->power_control.phys_granted_power++;
1113 scic_sds_phy_consume_power_handler(the_phy);
1116 * stop and start the power_control timer. When the timer fires, the
1117 * no_of_phys_granted_power will be set to 0
1119 scic_sds_controller_power_control_timer_restart(this_controller);
1121 /* Add the phy in the waiting list */
1122 this_controller->power_control.requesters[the_phy->phy_index] = the_phy;
1123 this_controller->power_control.phys_waiting++;
1128 * This method removes the phy from the stagger spinup control queue.
1133 void scic_sds_controller_power_control_queue_remove(
1134 struct scic_sds_controller *this_controller,
1135 struct scic_sds_phy *the_phy)
1137 BUG_ON(the_phy == NULL);
1139 if (this_controller->power_control.requesters[the_phy->phy_index] != NULL) {
1140 this_controller->power_control.phys_waiting--;
1143 this_controller->power_control.requesters[the_phy->phy_index] = NULL;
1147 * ****************************************************************************-
1148 * * SCIC SDS Controller Completion Routines
1149 * ****************************************************************************- */
1152 * This method returns a true value if the completion queue has entries that
1156 * bool true if the completion queue has entries to process false if the
1157 * completion queue has no entries to process
1159 static bool scic_sds_controller_completion_queue_has_entries(
1160 struct scic_sds_controller *this_controller)
1162 u32 get_value = this_controller->completion_queue_get;
1163 u32 get_index = get_value & SMU_COMPLETION_QUEUE_GET_POINTER_MASK;
1166 NORMALIZE_GET_POINTER_CYCLE_BIT(get_value)
1167 == COMPLETION_QUEUE_CYCLE_BIT(this_controller->completion_queue[get_index])
1175 /* --------------------------------------------------------------------------- */
1178 * This method processes a task completion notification. This is called from
1179 * within the controller completion handler.
1181 * @completion_entry:
1184 static void scic_sds_controller_task_completion(
1185 struct scic_sds_controller *this_controller,
1186 u32 completion_entry)
1189 struct scic_sds_request *io_request;
1191 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1192 io_request = this_controller->io_request_table[index];
1194 /* Make sure that we really want to process this IO request */
1196 (io_request != NULL)
1197 && (io_request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG)
1199 scic_sds_io_tag_get_sequence(io_request->io_tag)
1200 == this_controller->io_request_sequence[index]
1203 /* Yep this is a valid io request pass it along to the io request handler */
1204 scic_sds_io_request_tc_completion(io_request, completion_entry);
1209 * This method processes an SDMA completion event. This is called from within
1210 * the controller completion handler.
1212 * @completion_entry:
1215 static void scic_sds_controller_sdma_completion(
1216 struct scic_sds_controller *this_controller,
1217 u32 completion_entry)
1220 struct scic_sds_request *io_request;
1221 struct scic_sds_remote_device *device;
1223 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1225 switch (scu_get_command_request_type(completion_entry)) {
1226 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC:
1227 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC:
1228 io_request = this_controller->io_request_table[index];
1229 dev_warn(scic_to_dev(this_controller),
1230 "%s: SCIC SDS Completion type SDMA %x for io request "
1235 /* @todo For a post TC operation we need to fail the IO
1240 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC:
1241 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC:
1242 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC:
1243 device = this_controller->device_table[index];
1244 dev_warn(scic_to_dev(this_controller),
1245 "%s: SCIC SDS Completion type SDMA %x for remote "
1250 /* @todo For a port RNC operation we need to fail the
1256 dev_warn(scic_to_dev(this_controller),
1257 "%s: SCIC SDS Completion unknown SDMA completion "
1269 * @completion_entry:
1271 * This method processes an unsolicited frame message. This is called from
1272 * within the controller completion handler. none
1274 static void scic_sds_controller_unsolicited_frame(
1275 struct scic_sds_controller *this_controller,
1276 u32 completion_entry)
1281 struct scu_unsolicited_frame_header *frame_header;
1282 struct scic_sds_phy *phy;
1283 struct scic_sds_remote_device *device;
1285 enum sci_status result = SCI_FAILURE;
1287 frame_index = SCU_GET_FRAME_INDEX(completion_entry);
1290 = this_controller->uf_control.buffers.array[frame_index].header;
1291 this_controller->uf_control.buffers.array[frame_index].state
1292 = UNSOLICITED_FRAME_IN_USE;
1294 if (SCU_GET_FRAME_ERROR(completion_entry)) {
1296 * / @todo If the IAF frame or SIGNATURE FIS frame has an error will
1297 * / this cause a problem? We expect the phy initialization will
1298 * / fail if there is an error in the frame. */
1299 scic_sds_controller_release_frame(this_controller, frame_index);
1303 if (frame_header->is_address_frame) {
1304 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1305 phy = &this_controller->phy_table[index];
1307 result = scic_sds_phy_frame_handler(phy, frame_index);
1311 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1313 if (index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
1315 * This is a signature fis or a frame from a direct attached SATA
1316 * device that has not yet been created. In either case forwared
1317 * the frame to the PE and let it take care of the frame data. */
1318 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1319 phy = &this_controller->phy_table[index];
1320 result = scic_sds_phy_frame_handler(phy, frame_index);
1322 if (index < this_controller->remote_node_entries)
1323 device = this_controller->device_table[index];
1328 result = scic_sds_remote_device_frame_handler(device, frame_index);
1330 scic_sds_controller_release_frame(this_controller, frame_index);
1334 if (result != SCI_SUCCESS) {
1336 * / @todo Is there any reason to report some additional error message
1337 * / when we get this failure notifiction? */
1342 * This method processes an event completion entry. This is called from within
1343 * the controller completion handler.
1345 * @completion_entry:
1348 static void scic_sds_controller_event_completion(
1349 struct scic_sds_controller *this_controller,
1350 u32 completion_entry)
1353 struct scic_sds_request *io_request;
1354 struct scic_sds_remote_device *device;
1355 struct scic_sds_phy *phy;
1357 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1359 switch (scu_get_event_type(completion_entry)) {
1360 case SCU_EVENT_TYPE_SMU_COMMAND_ERROR:
1361 /* / @todo The driver did something wrong and we need to fix the condtion. */
1362 dev_err(scic_to_dev(this_controller),
1363 "%s: SCIC Controller 0x%p received SMU command error "
1370 case SCU_EVENT_TYPE_SMU_PCQ_ERROR:
1371 case SCU_EVENT_TYPE_SMU_ERROR:
1372 case SCU_EVENT_TYPE_FATAL_MEMORY_ERROR:
1374 * / @todo This is a hardware failure and its likely that we want to
1375 * / reset the controller. */
1376 dev_err(scic_to_dev(this_controller),
1377 "%s: SCIC Controller 0x%p received fatal controller "
1384 case SCU_EVENT_TYPE_TRANSPORT_ERROR:
1385 io_request = this_controller->io_request_table[index];
1386 scic_sds_io_request_event_handler(io_request, completion_entry);
1389 case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
1390 switch (scu_get_event_specifier(completion_entry)) {
1391 case SCU_EVENT_SPECIFIC_SMP_RESPONSE_NO_PE:
1392 case SCU_EVENT_SPECIFIC_TASK_TIMEOUT:
1393 io_request = this_controller->io_request_table[index];
1394 if (io_request != NULL)
1395 scic_sds_io_request_event_handler(io_request, completion_entry);
1397 dev_warn(scic_to_dev(this_controller),
1398 "%s: SCIC Controller 0x%p received "
1399 "event 0x%x for io request object "
1400 "that doesnt exist.\n",
1407 case SCU_EVENT_SPECIFIC_IT_NEXUS_TIMEOUT:
1408 device = this_controller->device_table[index];
1410 scic_sds_remote_device_event_handler(device, completion_entry);
1412 dev_warn(scic_to_dev(this_controller),
1413 "%s: SCIC Controller 0x%p received "
1414 "event 0x%x for remote device object "
1415 "that doesnt exist.\n",
1424 case SCU_EVENT_TYPE_BROADCAST_CHANGE:
1426 * direct the broadcast change event to the phy first and then let
1427 * the phy redirect the broadcast change to the port object */
1428 case SCU_EVENT_TYPE_ERR_CNT_EVENT:
1430 * direct error counter event to the phy object since that is where
1431 * we get the event notification. This is a type 4 event. */
1432 case SCU_EVENT_TYPE_OSSP_EVENT:
1433 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1434 phy = &this_controller->phy_table[index];
1435 scic_sds_phy_event_handler(phy, completion_entry);
1438 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
1439 case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
1440 case SCU_EVENT_TYPE_RNC_OPS_MISC:
1441 if (index < this_controller->remote_node_entries) {
1442 device = this_controller->device_table[index];
1445 scic_sds_remote_device_event_handler(device, completion_entry);
1447 dev_err(scic_to_dev(this_controller),
1448 "%s: SCIC Controller 0x%p received event 0x%x "
1449 "for remote device object 0x%0x that doesnt "
1459 dev_warn(scic_to_dev(this_controller),
1460 "%s: SCIC Controller received unknown event code %x\n",
1468 * This method is a private routine for processing the completion queue entries.
1472 static void scic_sds_controller_process_completions(
1473 struct scic_sds_controller *this_controller)
1475 u32 completion_count = 0;
1476 u32 completion_entry;
1482 dev_dbg(scic_to_dev(this_controller),
1483 "%s: completion queue begining get:0x%08x\n",
1485 this_controller->completion_queue_get);
1487 /* Get the component parts of the completion queue */
1488 get_index = NORMALIZE_GET_POINTER(this_controller->completion_queue_get);
1489 get_cycle = SMU_CQGR_CYCLE_BIT & this_controller->completion_queue_get;
1491 event_index = NORMALIZE_EVENT_POINTER(this_controller->completion_queue_get);
1492 event_cycle = SMU_CQGR_EVENT_CYCLE_BIT & this_controller->completion_queue_get;
1495 NORMALIZE_GET_POINTER_CYCLE_BIT(get_cycle)
1496 == COMPLETION_QUEUE_CYCLE_BIT(this_controller->completion_queue[get_index])
1500 completion_entry = this_controller->completion_queue[get_index];
1501 INCREMENT_COMPLETION_QUEUE_GET(this_controller, get_index, get_cycle);
1503 dev_dbg(scic_to_dev(this_controller),
1504 "%s: completion queue entry:0x%08x\n",
1508 switch (SCU_GET_COMPLETION_TYPE(completion_entry)) {
1509 case SCU_COMPLETION_TYPE_TASK:
1510 scic_sds_controller_task_completion(this_controller, completion_entry);
1513 case SCU_COMPLETION_TYPE_SDMA:
1514 scic_sds_controller_sdma_completion(this_controller, completion_entry);
1517 case SCU_COMPLETION_TYPE_UFI:
1518 scic_sds_controller_unsolicited_frame(this_controller, completion_entry);
1521 case SCU_COMPLETION_TYPE_EVENT:
1522 INCREMENT_EVENT_QUEUE_GET(this_controller, event_index, event_cycle);
1523 scic_sds_controller_event_completion(this_controller, completion_entry);
1526 case SCU_COMPLETION_TYPE_NOTIFY:
1528 * Presently we do the same thing with a notify event that we do with the
1529 * other event codes. */
1530 INCREMENT_EVENT_QUEUE_GET(this_controller, event_index, event_cycle);
1531 scic_sds_controller_event_completion(this_controller, completion_entry);
1535 dev_warn(scic_to_dev(this_controller),
1536 "%s: SCIC Controller received unknown "
1537 "completion type %x\n",
1544 /* Update the get register if we completed one or more entries */
1545 if (completion_count > 0) {
1546 this_controller->completion_queue_get =
1547 SMU_CQGR_GEN_BIT(ENABLE)
1548 | SMU_CQGR_GEN_BIT(EVENT_ENABLE)
1549 | event_cycle | SMU_CQGR_GEN_VAL(EVENT_POINTER, event_index)
1550 | get_cycle | SMU_CQGR_GEN_VAL(POINTER, get_index);
1552 SMU_CQGR_WRITE(this_controller,
1553 this_controller->completion_queue_get);
1556 dev_dbg(scic_to_dev(this_controller),
1557 "%s: completion queue ending get:0x%08x\n",
1559 this_controller->completion_queue_get);
1563 bool scic_sds_controller_isr(struct scic_sds_controller *scic)
1565 if (scic_sds_controller_completion_queue_has_entries(scic)) {
1569 * we have a spurious interrupt it could be that we have already
1570 * emptied the completion queue from a previous interrupt */
1571 SMU_ISR_WRITE(scic, SMU_ISR_COMPLETION);
1574 * There is a race in the hardware that could cause us not to be notified
1575 * of an interrupt completion if we do not take this step. We will mask
1576 * then unmask the interrupts so if there is another interrupt pending
1577 * the clearing of the interrupt source we get the next interrupt message. */
1578 SMU_IMR_WRITE(scic, 0xFF000000);
1579 SMU_IMR_WRITE(scic, 0x00000000);
1585 void scic_sds_controller_completion_handler(struct scic_sds_controller *scic)
1587 /* Empty out the completion queue */
1588 if (scic_sds_controller_completion_queue_has_entries(scic))
1589 scic_sds_controller_process_completions(scic);
1591 /* Clear the interrupt and enable all interrupts again */
1592 SMU_ISR_WRITE(scic, SMU_ISR_COMPLETION);
1593 /* Could we write the value of SMU_ISR_COMPLETION? */
1594 SMU_IMR_WRITE(scic, 0xFF000000);
1595 SMU_IMR_WRITE(scic, 0x00000000);
1598 bool scic_sds_controller_error_isr(struct scic_sds_controller *scic)
1600 u32 interrupt_status;
1602 interrupt_status = SMU_ISR_READ(scic);
1604 interrupt_status &= (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND);
1606 if (interrupt_status != 0) {
1608 * There is an error interrupt pending so let it through and handle
1609 * in the callback */
1614 * There is a race in the hardware that could cause us not to be notified
1615 * of an interrupt completion if we do not take this step. We will mask
1616 * then unmask the error interrupts so if there was another interrupt
1617 * pending we will be notified.
1618 * Could we write the value of (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND)? */
1619 SMU_IMR_WRITE(scic, 0x000000FF);
1620 SMU_IMR_WRITE(scic, 0x00000000);
1625 void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
1627 u32 interrupt_status;
1629 interrupt_status = SMU_ISR_READ(scic);
1631 if ((interrupt_status & SMU_ISR_QUEUE_SUSPEND) &&
1632 scic_sds_controller_completion_queue_has_entries(scic)) {
1634 scic_sds_controller_process_completions(scic);
1635 SMU_ISR_WRITE(scic, SMU_ISR_QUEUE_SUSPEND);
1638 dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
1641 sci_base_state_machine_change_state(
1642 scic_sds_controller_get_base_state_machine(scic),
1643 SCI_BASE_CONTROLLER_STATE_FAILED);
1649 * If we dont process any completions I am not sure that we want to do this.
1650 * We are in the middle of a hardware fault and should probably be reset. */
1651 SMU_IMR_WRITE(scic, 0x00000000);
1655 u32 scic_sds_controller_get_object_size(void)
1657 return sizeof(struct scic_sds_controller);
1661 void scic_sds_controller_link_up(
1662 struct scic_sds_controller *scic,
1663 struct scic_sds_port *sci_port,
1664 struct scic_sds_phy *sci_phy)
1666 scic_sds_controller_phy_handler_t link_up;
1669 state = scic->parent.state_machine.current_state_id;
1670 link_up = scic_sds_controller_state_handler_table[state].link_up;
1673 link_up(scic, sci_port, sci_phy);
1675 dev_dbg(scic_to_dev(scic),
1676 "%s: SCIC Controller linkup event from phy %d in "
1677 "unexpected state %d\n",
1680 sci_base_state_machine_get_state(
1681 scic_sds_controller_get_base_state_machine(
1686 void scic_sds_controller_link_down(
1687 struct scic_sds_controller *scic,
1688 struct scic_sds_port *sci_port,
1689 struct scic_sds_phy *sci_phy)
1692 scic_sds_controller_phy_handler_t link_down;
1694 state = scic->parent.state_machine.current_state_id;
1695 link_down = scic_sds_controller_state_handler_table[state].link_down;
1698 link_down(scic, sci_port, sci_phy);
1700 dev_dbg(scic_to_dev(scic),
1701 "%s: SCIC Controller linkdown event from phy %d in "
1702 "unexpected state %d\n",
1704 sci_phy->phy_index, state);
1708 * This method is called by the remote device to inform the controller
1709 * that this remote device has started.
1713 void scic_sds_controller_remote_device_started(struct scic_sds_controller *scic,
1714 struct scic_sds_remote_device *sci_dev)
1717 scic_sds_controller_device_handler_t started;
1719 state = scic->parent.state_machine.current_state_id;
1720 started = scic_sds_controller_state_handler_table[state].remote_device_started_handler;
1723 started(scic, sci_dev);
1725 dev_dbg(scic_to_dev(scic),
1726 "%s: SCIC Controller 0x%p remote device started event "
1727 "from device 0x%p in unexpected state %d\n",
1728 __func__, scic, sci_dev, state);
1733 * This is a helper method to determine if any remote devices on this
1734 * controller are still in the stopping state.
1737 bool scic_sds_controller_has_remote_devices_stopping(
1738 struct scic_sds_controller *this_controller)
1742 for (index = 0; index < this_controller->remote_node_entries; index++) {
1743 if ((this_controller->device_table[index] != NULL) &&
1744 (this_controller->device_table[index]->parent.state_machine.current_state_id
1745 == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING))
1753 * This method is called by the remote device to inform the controller
1754 * object that the remote device has stopped.
1758 void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
1759 struct scic_sds_remote_device *sci_dev)
1763 scic_sds_controller_device_handler_t stopped;
1765 state = scic->parent.state_machine.current_state_id;
1766 stopped = scic_sds_controller_state_handler_table[state].remote_device_stopped_handler;
1769 stopped(scic, sci_dev);
1771 dev_dbg(scic_to_dev(scic),
1772 "%s: SCIC Controller 0x%p remote device stopped event "
1773 "from device 0x%p in unexpected state %d\n",
1774 __func__, scic, sci_dev, state);
1781 * This method will write to the SCU PCP register the request value. The method
1782 * is used to suspend/resume ports, devices, and phys.
1787 void scic_sds_controller_post_request(
1788 struct scic_sds_controller *this_controller,
1791 dev_dbg(scic_to_dev(this_controller),
1792 "%s: SCIC Controller 0x%p post request 0x%08x\n",
1797 SMU_PCP_WRITE(this_controller, request);
1801 * This method will copy the soft copy of the task context into the physical
1802 * memory accessible by the controller.
1803 * @this_controller: This parameter specifies the controller for which to copy
1805 * @this_request: This parameter specifies the request for which the task
1806 * context is being copied.
1808 * After this call is made the SCIC_SDS_IO_REQUEST object will always point to
1809 * the physical memory version of the task context. Thus, all subsequent
1810 * updates to the task context are performed in the TC table (i.e. DMAable
1813 void scic_sds_controller_copy_task_context(
1814 struct scic_sds_controller *this_controller,
1815 struct scic_sds_request *this_request)
1817 struct scu_task_context *task_context_buffer;
1819 task_context_buffer = scic_sds_controller_get_task_context_buffer(
1820 this_controller, this_request->io_tag
1824 task_context_buffer,
1825 this_request->task_context_buffer,
1826 SCI_FIELD_OFFSET(struct scu_task_context, sgl_snapshot_ac)
1830 * Now that the soft copy of the TC has been copied into the TC
1831 * table accessible by the silicon. Thus, any further changes to
1832 * the TC (e.g. TC termination) occur in the appropriate location. */
1833 this_request->task_context_buffer = task_context_buffer;
1837 * This method returns the task context buffer for the given io tag.
1841 * struct scu_task_context*
1843 struct scu_task_context *scic_sds_controller_get_task_context_buffer(
1844 struct scic_sds_controller *this_controller,
1847 u16 task_index = scic_sds_io_tag_get_index(io_tag);
1849 if (task_index < this_controller->task_context_entries) {
1850 return &this_controller->task_context_table[task_index];
1857 * This method returnst the sequence value from the io tag value
1865 * This method returns the IO request associated with the tag value
1869 * SCIC_SDS_IO_REQUEST_T* NULL if there is no valid IO request at the tag value
1871 struct scic_sds_request *scic_sds_controller_get_io_request_from_tag(
1872 struct scic_sds_controller *this_controller,
1878 task_index = scic_sds_io_tag_get_index(io_tag);
1880 if (task_index < this_controller->task_context_entries) {
1881 if (this_controller->io_request_table[task_index] != NULL) {
1882 task_sequence = scic_sds_io_tag_get_sequence(io_tag);
1884 if (task_sequence == this_controller->io_request_sequence[task_index]) {
1885 return this_controller->io_request_table[task_index];
1894 * This method allocates remote node index and the reserves the remote node
1895 * context space for use. This method can fail if there are no more remote
1896 * node index available.
1897 * @this_controller: This is the controller object which contains the set of
1898 * free remote node ids
1899 * @the_devce: This is the device object which is requesting the a remote node
1901 * @node_id: This is the remote node id that is assinged to the device if one
1904 * enum sci_status SCI_FAILURE_OUT_OF_RESOURCES if there are no available remote
1905 * node index available.
1907 enum sci_status scic_sds_controller_allocate_remote_node_context(
1908 struct scic_sds_controller *this_controller,
1909 struct scic_sds_remote_device *the_device,
1913 u32 remote_node_count = scic_sds_remote_device_node_count(the_device);
1915 node_index = scic_sds_remote_node_table_allocate_remote_node(
1916 &this_controller->available_remote_nodes, remote_node_count
1919 if (node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
1920 this_controller->device_table[node_index] = the_device;
1922 *node_id = node_index;
1927 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
1931 * This method frees the remote node index back to the available pool. Once
1932 * this is done the remote node context buffer is no longer valid and can
1939 void scic_sds_controller_free_remote_node_context(
1940 struct scic_sds_controller *this_controller,
1941 struct scic_sds_remote_device *the_device,
1944 u32 remote_node_count = scic_sds_remote_device_node_count(the_device);
1946 if (this_controller->device_table[node_id] == the_device) {
1947 this_controller->device_table[node_id] = NULL;
1949 scic_sds_remote_node_table_release_remote_node_index(
1950 &this_controller->available_remote_nodes, remote_node_count, node_id
1956 * This method returns the union scu_remote_node_context for the specified remote
1961 * union scu_remote_node_context*
1963 union scu_remote_node_context *scic_sds_controller_get_remote_node_context_buffer(
1964 struct scic_sds_controller *this_controller,
1968 (node_id < this_controller->remote_node_entries)
1969 && (this_controller->device_table[node_id] != NULL)
1971 return &this_controller->remote_node_context_table[node_id];
1979 * @resposne_buffer: This is the buffer into which the D2H register FIS will be
1981 * @frame_header: This is the frame header returned by the hardware.
1982 * @frame_buffer: This is the frame buffer returned by the hardware.
1984 * This method will combind the frame header and frame buffer to create a SATA
1985 * D2H register FIS none
1987 void scic_sds_controller_copy_sata_response(
1988 void *response_buffer,
1999 (char *)((char *)response_buffer + sizeof(u32)),
2001 sizeof(struct sata_fis_reg_d2h) - sizeof(u32)
2006 * This method releases the frame once this is done the frame is available for
2007 * re-use by the hardware. The data contained in the frame header and frame
2008 * buffer is no longer valid. The UF queue get pointer is only updated if UF
2009 * control indicates this is appropriate.
2014 void scic_sds_controller_release_frame(
2015 struct scic_sds_controller *this_controller,
2018 if (scic_sds_unsolicited_frame_control_release_frame(
2019 &this_controller->uf_control, frame_index) == true)
2020 SCU_UFQGP_WRITE(this_controller, this_controller->uf_control.get);
2024 * This method sets user parameters and OEM parameters to default values.
2025 * Users can override these values utilizing the scic_user_parameters_set()
2026 * and scic_oem_parameters_set() methods.
2027 * @scic: This parameter specifies the controller for which to set the
2028 * configuration parameters to their default values.
2031 static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic)
2033 struct isci_host *ihost = sci_object_get_association(scic);
2036 /* Default to APC mode. */
2037 scic->oem_parameters.sds1.controller.mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE;
2039 /* Default to APC mode. */
2040 scic->oem_parameters.sds1.controller.max_concurrent_dev_spin_up = 1;
2042 /* Default to no SSC operation. */
2043 scic->oem_parameters.sds1.controller.do_enable_ssc = false;
2045 /* Initialize all of the port parameter information to narrow ports. */
2046 for (index = 0; index < SCI_MAX_PORTS; index++) {
2047 scic->oem_parameters.sds1.ports[index].phy_mask = 0;
2050 /* Initialize all of the phy parameter information. */
2051 for (index = 0; index < SCI_MAX_PHYS; index++) {
2052 /* Default to 6G (i.e. Gen 3) for now. */
2053 scic->user_parameters.sds1.phys[index].max_speed_generation = 3;
2055 /* the frequencies cannot be 0 */
2056 scic->user_parameters.sds1.phys[index].align_insertion_frequency = 0x7f;
2057 scic->user_parameters.sds1.phys[index].in_connection_align_insertion_frequency = 0xff;
2058 scic->user_parameters.sds1.phys[index].notify_enable_spin_up_insertion_frequency = 0x33;
2061 * Previous Vitesse based expanders had a arbitration issue that
2062 * is worked around by having the upper 32-bits of SAS address
2063 * with a value greater then the Vitesse company identifier.
2064 * Hence, usage of 0x5FCFFFFF. */
2065 scic->oem_parameters.sds1.phys[index].sas_address.low = 0x1 + ihost->id;
2066 scic->oem_parameters.sds1.phys[index].sas_address.high = 0x5FCFFFFF;
2069 scic->user_parameters.sds1.stp_inactivity_timeout = 5;
2070 scic->user_parameters.sds1.ssp_inactivity_timeout = 5;
2071 scic->user_parameters.sds1.stp_max_occupancy_timeout = 5;
2072 scic->user_parameters.sds1.ssp_max_occupancy_timeout = 20;
2073 scic->user_parameters.sds1.no_outbound_task_timeout = 20;
2077 enum sci_status scic_controller_construct(struct scic_sds_controller *controller,
2078 void __iomem *scu_base,
2079 void __iomem *smu_base)
2083 sci_base_controller_construct(
2084 &controller->parent,
2085 scic_sds_controller_state_table,
2086 controller->memory_descriptors,
2087 ARRAY_SIZE(controller->memory_descriptors),
2091 controller->scu_registers = scu_base;
2092 controller->smu_registers = smu_base;
2094 scic_sds_port_configuration_agent_construct(&controller->port_agent);
2096 /* Construct the ports for this controller */
2097 for (index = 0; index < SCI_MAX_PORTS; index++)
2098 scic_sds_port_construct(&controller->port_table[index],
2100 scic_sds_port_construct(&controller->port_table[index],
2101 SCIC_SDS_DUMMY_PORT, controller);
2103 /* Construct the phys for this controller */
2104 for (index = 0; index < SCI_MAX_PHYS; index++) {
2105 /* Add all the PHYs to the dummy port */
2106 scic_sds_phy_construct(
2107 &controller->phy_table[index],
2108 &controller->port_table[SCI_MAX_PORTS],
2113 controller->invalid_phy_mask = 0;
2115 /* Set the default maximum values */
2116 controller->completion_event_entries = SCU_EVENT_COUNT;
2117 controller->completion_queue_entries = SCU_COMPLETION_QUEUE_COUNT;
2118 controller->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
2119 controller->logical_port_entries = SCI_MAX_PORTS;
2120 controller->task_context_entries = SCU_IO_REQUEST_COUNT;
2121 controller->uf_control.buffers.count = SCU_UNSOLICITED_FRAME_COUNT;
2122 controller->uf_control.address_table.count = SCU_UNSOLICITED_FRAME_COUNT;
2124 /* Initialize the User and OEM parameters to default values. */
2125 scic_sds_controller_set_default_config_parameters(controller);
2127 return scic_controller_reset(controller);
2130 /* --------------------------------------------------------------------------- */
2132 enum sci_status scic_controller_initialize(
2133 struct scic_sds_controller *scic)
2135 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2136 sci_base_controller_handler_t initialize;
2139 state = scic->parent.state_machine.current_state_id;
2140 initialize = scic_sds_controller_state_handler_table[state].base.initialize;
2143 status = initialize(&scic->parent);
2145 dev_warn(scic_to_dev(scic),
2146 "%s: SCIC Controller initialize operation requested "
2147 "in invalid state %d\n",
2149 sci_base_state_machine_get_state(
2150 scic_sds_controller_get_base_state_machine(
2156 /* --------------------------------------------------------------------------- */
2158 u32 scic_controller_get_suggested_start_timeout(
2159 struct scic_sds_controller *sc)
2161 /* Validate the user supplied parameters. */
2166 * The suggested minimum timeout value for a controller start operation:
2168 * Signature FIS Timeout
2169 * + Phy Start Timeout
2170 * + Number of Phy Spin Up Intervals
2171 * ---------------------------------
2172 * Number of milliseconds for the controller start operation.
2174 * NOTE: The number of phy spin up intervals will be equivalent
2175 * to the number of phys divided by the number phys allowed
2176 * per interval - 1 (once OEM parameters are supported).
2177 * Currently we assume only 1 phy per interval. */
2179 return SCIC_SDS_SIGNATURE_FIS_TIMEOUT
2180 + SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT
2181 + ((SCI_MAX_PHYS - 1) * SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
2184 /* --------------------------------------------------------------------------- */
2186 enum sci_status scic_controller_start(
2187 struct scic_sds_controller *scic,
2190 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2191 sci_base_controller_timed_handler_t start;
2194 state = scic->parent.state_machine.current_state_id;
2195 start = scic_sds_controller_state_handler_table[state].base.start;
2198 status = start(&scic->parent, timeout);
2200 dev_warn(scic_to_dev(scic),
2201 "%s: SCIC Controller start operation requested in "
2202 "invalid state %d\n",
2204 sci_base_state_machine_get_state(
2205 scic_sds_controller_get_base_state_machine(
2211 /* --------------------------------------------------------------------------- */
2213 enum sci_status scic_controller_stop(
2214 struct scic_sds_controller *scic,
2217 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2218 sci_base_controller_timed_handler_t stop;
2221 state = scic->parent.state_machine.current_state_id;
2222 stop = scic_sds_controller_state_handler_table[state].base.stop;
2225 status = stop(&scic->parent, timeout);
2227 dev_warn(scic_to_dev(scic),
2228 "%s: SCIC Controller stop operation requested in "
2229 "invalid state %d\n",
2231 sci_base_state_machine_get_state(
2232 scic_sds_controller_get_base_state_machine(
2238 /* --------------------------------------------------------------------------- */
2240 enum sci_status scic_controller_reset(
2241 struct scic_sds_controller *scic)
2243 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2244 sci_base_controller_handler_t reset;
2247 state = scic->parent.state_machine.current_state_id;
2248 reset = scic_sds_controller_state_handler_table[state].base.reset;
2251 status = reset(&scic->parent);
2253 dev_warn(scic_to_dev(scic),
2254 "%s: SCIC Controller reset operation requested in "
2255 "invalid state %d\n",
2257 sci_base_state_machine_get_state(
2258 scic_sds_controller_get_base_state_machine(
2264 enum sci_io_status scic_controller_start_io(
2265 struct scic_sds_controller *scic,
2266 struct scic_sds_remote_device *remote_device,
2267 struct scic_sds_request *io_request,
2271 sci_base_controller_start_request_handler_t start_io;
2273 state = scic->parent.state_machine.current_state_id;
2274 start_io = scic_sds_controller_state_handler_table[state].base.start_io;
2276 return start_io(&scic->parent,
2277 (struct sci_base_remote_device *) remote_device,
2278 (struct sci_base_request *)io_request, io_tag);
2281 /* --------------------------------------------------------------------------- */
2283 enum sci_status scic_controller_terminate_request(
2284 struct scic_sds_controller *scic,
2285 struct scic_sds_remote_device *remote_device,
2286 struct scic_sds_request *request)
2288 sci_base_controller_request_handler_t terminate_request;
2291 state = scic->parent.state_machine.current_state_id;
2292 terminate_request = scic_sds_controller_state_handler_table[state].terminate_request;
2294 return terminate_request(&scic->parent,
2295 (struct sci_base_remote_device *)remote_device,
2296 (struct sci_base_request *)request);
2299 /* --------------------------------------------------------------------------- */
2301 enum sci_status scic_controller_complete_io(
2302 struct scic_sds_controller *scic,
2303 struct scic_sds_remote_device *remote_device,
2304 struct scic_sds_request *io_request)
2307 sci_base_controller_request_handler_t complete_io;
2309 state = scic->parent.state_machine.current_state_id;
2310 complete_io = scic_sds_controller_state_handler_table[state].base.complete_io;
2312 return complete_io(&scic->parent,
2313 (struct sci_base_remote_device *)remote_device,
2314 (struct sci_base_request *)io_request);
2317 /* --------------------------------------------------------------------------- */
2320 enum sci_task_status scic_controller_start_task(
2321 struct scic_sds_controller *scic,
2322 struct scic_sds_remote_device *remote_device,
2323 struct scic_sds_request *task_request,
2327 sci_base_controller_start_request_handler_t start_task;
2328 enum sci_task_status status = SCI_TASK_FAILURE_INVALID_STATE;
2330 state = scic->parent.state_machine.current_state_id;
2331 start_task = scic_sds_controller_state_handler_table[state].base.start_task;
2334 status = start_task(&scic->parent,
2335 (struct sci_base_remote_device *)remote_device,
2336 (struct sci_base_request *)task_request,
2339 dev_warn(scic_to_dev(scic),
2340 "%s: SCIC Controller starting task from invalid "
2347 /* --------------------------------------------------------------------------- */
2349 enum sci_status scic_controller_complete_task(
2350 struct scic_sds_controller *scic,
2351 struct scic_sds_remote_device *remote_device,
2352 struct scic_sds_request *task_request)
2355 sci_base_controller_request_handler_t complete_task;
2356 enum sci_status status = SCI_FAILURE_INVALID_STATE;
2358 state = scic->parent.state_machine.current_state_id;
2359 complete_task = scic_sds_controller_state_handler_table[state].base.complete_task;
2362 status = complete_task(&scic->parent,
2363 (struct sci_base_remote_device *)remote_device,
2364 (struct sci_base_request *)task_request);
2366 dev_warn(scic_to_dev(scic),
2367 "%s: SCIC Controller completing task from invalid "
2375 /* --------------------------------------------------------------------------- */
2377 enum sci_status scic_controller_get_port_handle(
2378 struct scic_sds_controller *scic,
2380 struct scic_sds_port **port_handle)
2382 if (port_index < scic->logical_port_entries) {
2383 *port_handle = &scic->port_table[port_index];
2388 return SCI_FAILURE_INVALID_PORT;
2391 /* --------------------------------------------------------------------------- */
2393 enum sci_status scic_controller_get_phy_handle(
2394 struct scic_sds_controller *scic,
2396 struct scic_sds_phy **phy_handle)
2398 if (phy_index < ARRAY_SIZE(scic->phy_table)) {
2399 *phy_handle = &scic->phy_table[phy_index];
2404 dev_err(scic_to_dev(scic),
2405 "%s: Controller:0x%p PhyId:0x%x invalid phy index\n",
2406 __func__, scic, phy_index);
2408 return SCI_FAILURE_INVALID_PHY;
2411 /* --------------------------------------------------------------------------- */
2413 u16 scic_controller_allocate_io_tag(
2414 struct scic_sds_controller *scic)
2419 if (!sci_pool_empty(scic->tci_pool)) {
2420 sci_pool_get(scic->tci_pool, task_context);
2422 sequence_count = scic->io_request_sequence[task_context];
2424 return scic_sds_io_tag_construct(sequence_count, task_context);
2427 return SCI_CONTROLLER_INVALID_IO_TAG;
2430 /* --------------------------------------------------------------------------- */
2432 enum sci_status scic_controller_free_io_tag(
2433 struct scic_sds_controller *scic,
2439 BUG_ON(io_tag == SCI_CONTROLLER_INVALID_IO_TAG);
2441 sequence = scic_sds_io_tag_get_sequence(io_tag);
2442 index = scic_sds_io_tag_get_index(io_tag);
2444 if (!sci_pool_full(scic->tci_pool)) {
2445 if (sequence == scic->io_request_sequence[index]) {
2446 scic_sds_io_sequence_increment(
2447 scic->io_request_sequence[index]);
2449 sci_pool_put(scic->tci_pool, index);
2455 return SCI_FAILURE_INVALID_IO_TAG;
2458 /* --------------------------------------------------------------------------- */
2460 void scic_controller_enable_interrupts(
2461 struct scic_sds_controller *scic)
2463 BUG_ON(scic->smu_registers == NULL);
2464 SMU_IMR_WRITE(scic, 0x00000000);
2467 /* --------------------------------------------------------------------------- */
2469 void scic_controller_disable_interrupts(
2470 struct scic_sds_controller *scic)
2472 BUG_ON(scic->smu_registers == NULL);
2473 SMU_IMR_WRITE(scic, 0xffffffff);
2476 /* --------------------------------------------------------------------------- */
2478 enum sci_status scic_controller_set_mode(
2479 struct scic_sds_controller *scic,
2480 enum sci_controller_mode operating_mode)
2482 enum sci_status status = SCI_SUCCESS;
2484 if ((scic->parent.state_machine.current_state_id ==
2485 SCI_BASE_CONTROLLER_STATE_INITIALIZING) ||
2486 (scic->parent.state_machine.current_state_id ==
2487 SCI_BASE_CONTROLLER_STATE_INITIALIZED)) {
2488 switch (operating_mode) {
2489 case SCI_MODE_SPEED:
2490 scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
2491 scic->task_context_entries = SCU_IO_REQUEST_COUNT;
2492 scic->uf_control.buffers.count =
2493 SCU_UNSOLICITED_FRAME_COUNT;
2494 scic->completion_event_entries = SCU_EVENT_COUNT;
2495 scic->completion_queue_entries =
2496 SCU_COMPLETION_QUEUE_COUNT;
2497 scic_sds_controller_build_memory_descriptor_table(scic);
2501 scic->remote_node_entries = SCI_MIN_REMOTE_DEVICES;
2502 scic->task_context_entries = SCI_MIN_IO_REQUESTS;
2503 scic->uf_control.buffers.count =
2504 SCU_MIN_UNSOLICITED_FRAMES;
2505 scic->completion_event_entries = SCU_MIN_EVENTS;
2506 scic->completion_queue_entries =
2507 SCU_MIN_COMPLETION_QUEUE_ENTRIES;
2508 scic_sds_controller_build_memory_descriptor_table(scic);
2512 status = SCI_FAILURE_INVALID_PARAMETER_VALUE;
2516 status = SCI_FAILURE_INVALID_STATE;
2522 * scic_sds_controller_reset_hardware() -
2524 * This method will reset the controller hardware.
2526 void scic_sds_controller_reset_hardware(
2527 struct scic_sds_controller *scic)
2529 /* Disable interrupts so we dont take any spurious interrupts */
2530 scic_controller_disable_interrupts(scic);
2533 SMU_SMUSRCR_WRITE(scic, 0xFFFFFFFF);
2535 /* Delay for 1ms to before clearing the CQP and UFQPR. */
2538 /* The write to the CQGR clears the CQP */
2539 SMU_CQGR_WRITE(scic, 0x00000000);
2541 /* The write to the UFQGP clears the UFQPR */
2542 SCU_UFQGP_WRITE(scic, 0x00000000);
2545 /* --------------------------------------------------------------------------- */
2547 enum sci_status scic_user_parameters_set(
2548 struct scic_sds_controller *scic,
2549 union scic_user_parameters *scic_parms)
2552 (scic->parent.state_machine.current_state_id
2553 == SCI_BASE_CONTROLLER_STATE_RESET)
2554 || (scic->parent.state_machine.current_state_id
2555 == SCI_BASE_CONTROLLER_STATE_INITIALIZING)
2556 || (scic->parent.state_machine.current_state_id
2557 == SCI_BASE_CONTROLLER_STATE_INITIALIZED)
2562 * Validate the user parameters. If they are not legal, then
2563 * return a failure. */
2564 for (index = 0; index < SCI_MAX_PHYS; index++) {
2565 if (!(scic_parms->sds1.phys[index].max_speed_generation
2566 <= SCIC_SDS_PARM_MAX_SPEED
2567 && scic_parms->sds1.phys[index].max_speed_generation
2568 > SCIC_SDS_PARM_NO_SPEED))
2569 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2571 if (scic_parms->sds1.phys[index].in_connection_align_insertion_frequency < 3)
2572 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2574 (scic_parms->sds1.phys[index].in_connection_align_insertion_frequency < 3) ||
2575 (scic_parms->sds1.phys[index].align_insertion_frequency == 0) ||
2576 (scic_parms->sds1.phys[index].notify_enable_spin_up_insertion_frequency == 0)
2578 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2581 if ((scic_parms->sds1.stp_inactivity_timeout == 0) ||
2582 (scic_parms->sds1.ssp_inactivity_timeout == 0) ||
2583 (scic_parms->sds1.stp_max_occupancy_timeout == 0) ||
2584 (scic_parms->sds1.ssp_max_occupancy_timeout == 0) ||
2585 (scic_parms->sds1.no_outbound_task_timeout == 0))
2586 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2588 memcpy(&scic->user_parameters, scic_parms, sizeof(*scic_parms));
2593 return SCI_FAILURE_INVALID_STATE;
2596 /* --------------------------------------------------------------------------- */
2598 void scic_user_parameters_get(
2599 struct scic_sds_controller *scic,
2600 union scic_user_parameters *scic_parms)
2602 memcpy(scic_parms, (&scic->user_parameters), sizeof(*scic_parms));
2605 /* --------------------------------------------------------------------------- */
2607 enum sci_status scic_oem_parameters_set(
2608 struct scic_sds_controller *scic,
2609 union scic_oem_parameters *scic_parms)
2611 u32 state = scic->parent.state_machine.current_state_id;
2613 if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
2614 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
2615 state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
2617 u8 combined_phy_mask = 0;
2620 * Validate the oem parameters. If they are not legal, then
2621 * return a failure. */
2622 for (index = 0; index < SCI_MAX_PORTS; index++) {
2623 if (scic_parms->sds1.ports[index].phy_mask > SCIC_SDS_PARM_PHY_MASK_MAX) {
2624 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2628 for (index = 0; index < SCI_MAX_PHYS; index++) {
2630 scic_parms->sds1.phys[index].sas_address.high == 0
2631 && scic_parms->sds1.phys[index].sas_address.low == 0
2633 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2637 if (scic_parms->sds1.controller.mode_type == SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE) {
2638 for (index = 0; index < SCI_MAX_PHYS; index++) {
2639 if (scic_parms->sds1.ports[index].phy_mask != 0)
2640 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2642 } else if (scic_parms->sds1.controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
2643 for (index = 0; index < SCI_MAX_PHYS; index++)
2644 combined_phy_mask |= scic_parms->sds1.ports[index].phy_mask;
2646 if (combined_phy_mask == 0)
2647 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2649 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2652 if (scic_parms->sds1.controller.max_concurrent_dev_spin_up > MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT)
2653 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2655 scic->oem_parameters.sds1 = scic_parms->sds1;
2660 return SCI_FAILURE_INVALID_STATE;
2663 /* --------------------------------------------------------------------------- */
2665 void scic_oem_parameters_get(
2666 struct scic_sds_controller *scic,
2667 union scic_oem_parameters *scic_parms)
2669 memcpy(scic_parms, (&scic->oem_parameters), sizeof(*scic_parms));
2672 /* --------------------------------------------------------------------------- */
2675 #define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS 853
2676 #define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS 1280
2677 #define INTERRUPT_COALESCE_TIMEOUT_MAX_US 2700000
2678 #define INTERRUPT_COALESCE_NUMBER_MAX 256
2679 #define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN 7
2680 #define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX 28
2682 enum sci_status scic_controller_set_interrupt_coalescence(
2683 struct scic_sds_controller *scic_controller,
2684 u32 coalesce_number,
2685 u32 coalesce_timeout)
2687 u8 timeout_encode = 0;
2691 /* Check if the input parameters fall in the range. */
2692 if (coalesce_number > INTERRUPT_COALESCE_NUMBER_MAX)
2693 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2696 * Defined encoding for interrupt coalescing timeout:
2697 * Value Min Max Units
2698 * ----- --- --- -----
2728 * Others Undefined */
2731 * Use the table above to decide the encode of interrupt coalescing timeout
2732 * value for register writing. */
2733 if (coalesce_timeout == 0)
2736 /* make the timeout value in unit of (10 ns). */
2737 coalesce_timeout = coalesce_timeout * 100;
2738 min = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS / 10;
2739 max = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS / 10;
2741 /* get the encode of timeout for register writing. */
2742 for (timeout_encode = INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN;
2743 timeout_encode <= INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX;
2745 if (min <= coalesce_timeout && max > coalesce_timeout)
2747 else if (coalesce_timeout >= max && coalesce_timeout < min * 2
2748 && coalesce_timeout <= INTERRUPT_COALESCE_TIMEOUT_MAX_US * 100) {
2749 if ((coalesce_timeout - max) < (2 * min - coalesce_timeout))
2761 if (timeout_encode == INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX + 1)
2762 /* the value is out of range. */
2763 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2768 (SMU_ICC_GEN_VAL(NUMBER, coalesce_number) |
2769 SMU_ICC_GEN_VAL(TIMER, timeout_encode))
2772 scic_controller->interrupt_coalesce_number = (u16)coalesce_number;
2773 scic_controller->interrupt_coalesce_timeout = coalesce_timeout / 100;
2779 struct scic_sds_controller *scic_controller_alloc(struct device *dev)
2781 return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL);
2785 * *****************************************************************************
2786 * * DEFAULT STATE HANDLERS
2787 * ***************************************************************************** */
2791 * @controller: This is struct sci_base_controller object which is cast into a
2792 * struct scic_sds_controller object.
2793 * @remote_device: This is struct sci_base_remote_device which, if it was used, would
2794 * be cast to a struct scic_sds_remote_device.
2795 * @io_request: This is the struct sci_base_request which, if it was used, would be
2796 * cast to a SCIC_SDS_IO_REQUEST.
2797 * @io_tag: This is the IO tag to be assigned to the IO request or
2798 * SCI_CONTROLLER_INVALID_IO_TAG.
2800 * This method is called when the struct scic_sds_controller default start io/task
2801 * handler is in place. - Issue a warning message enum sci_status
2802 * SCI_FAILURE_INVALID_STATE
2804 static enum sci_status scic_sds_controller_default_start_operation_handler(
2805 struct sci_base_controller *controller,
2806 struct sci_base_remote_device *remote_device,
2807 struct sci_base_request *io_request,
2810 struct scic_sds_controller *this_controller;
2812 this_controller = (struct scic_sds_controller *)controller;
2814 dev_warn(scic_to_dev(this_controller),
2815 "%s: SCIC Controller requested to start an io/task from "
2816 "invalid state %d\n",
2818 sci_base_state_machine_get_state(
2819 scic_sds_controller_get_base_state_machine(
2822 return SCI_FAILURE_INVALID_STATE;
2827 * @controller: This is struct sci_base_controller object which is cast into a
2828 * struct scic_sds_controller object.
2829 * @remote_device: This is struct sci_base_remote_device which, if it was used, would
2830 * be cast to a struct scic_sds_remote_device.
2831 * @io_request: This is the struct sci_base_request which, if it was used, would be
2832 * cast to a SCIC_SDS_IO_REQUEST.
2834 * This method is called when the struct scic_sds_controller default request handler
2835 * is in place. - Issue a warning message enum sci_status SCI_FAILURE_INVALID_STATE
2837 static enum sci_status scic_sds_controller_default_request_handler(
2838 struct sci_base_controller *controller,
2839 struct sci_base_remote_device *remote_device,
2840 struct sci_base_request *io_request)
2842 struct scic_sds_controller *this_controller;
2844 this_controller = (struct scic_sds_controller *)controller;
2846 dev_warn(scic_to_dev(this_controller),
2847 "%s: SCIC Controller request operation from invalid state %d\n",
2849 sci_base_state_machine_get_state(
2850 scic_sds_controller_get_base_state_machine(
2853 return SCI_FAILURE_INVALID_STATE;
2857 * *****************************************************************************
2858 * * GENERAL (COMMON) STATE HANDLERS
2859 * ***************************************************************************** */
2863 * @controller: The struct sci_base_controller object which is cast into a
2864 * struct scic_sds_controller object.
2866 * This method is called when the struct scic_sds_controller is in the ready state
2867 * reset handler is in place. - Transition to
2868 * SCI_BASE_CONTROLLER_STATE_RESETTING enum sci_status SCI_SUCCESS
2870 static enum sci_status scic_sds_controller_general_reset_handler(
2871 struct sci_base_controller *controller)
2873 struct scic_sds_controller *this_controller;
2875 this_controller = (struct scic_sds_controller *)controller;
2878 * The reset operation is not a graceful cleanup just perform the state
2880 sci_base_state_machine_change_state(
2881 scic_sds_controller_get_base_state_machine(this_controller),
2882 SCI_BASE_CONTROLLER_STATE_RESETTING
2889 * *****************************************************************************
2890 * * RESET STATE HANDLERS
2891 * ***************************************************************************** */
2895 * @controller: This is the struct sci_base_controller object which is cast into a
2896 * struct scic_sds_controller object.
2898 * This method is the struct scic_sds_controller initialize handler for the reset
2899 * state. - Currently this function does nothing enum sci_status SCI_FAILURE This
2900 * function is not yet implemented and is a valid request from the reset state.
2902 static enum sci_status scic_sds_controller_reset_state_initialize_handler(
2903 struct sci_base_controller *controller)
2906 enum sci_status result = SCI_SUCCESS;
2907 struct scic_sds_controller *this_controller;
2909 this_controller = (struct scic_sds_controller *)controller;
2911 sci_base_state_machine_change_state(
2912 scic_sds_controller_get_base_state_machine(this_controller),
2913 SCI_BASE_CONTROLLER_STATE_INITIALIZING
2916 this_controller->timeout_timer = isci_event_timer_create(
2918 (void (*)(void *))scic_sds_controller_timeout_handler,
2919 (void (*)(void *))controller);
2921 scic_sds_controller_initialize_phy_startup(this_controller);
2923 scic_sds_controller_initialize_power_control(this_controller);
2926 * There is nothing to do here for B0 since we do not have to
2927 * program the AFE registers.
2928 * / @todo The AFE settings are supposed to be correct for the B0 but
2929 * / presently they seem to be wrong. */
2930 scic_sds_controller_afe_initialization(this_controller);
2932 if (SCI_SUCCESS == result) {
2936 /* Take the hardware out of reset */
2937 SMU_SMUSRCR_WRITE(this_controller, 0x00000000);
2940 * / @todo Provide meaningfull error code for hardware failure
2941 * result = SCI_FAILURE_CONTROLLER_HARDWARE; */
2942 result = SCI_FAILURE;
2943 terminate_loop = 100;
2945 while (terminate_loop-- && (result != SCI_SUCCESS)) {
2946 /* Loop until the hardware reports success */
2947 udelay(SCU_CONTEXT_RAM_INIT_STALL_TIME);
2948 status = SMU_SMUCSR_READ(this_controller);
2950 if ((status & SCU_RAM_INIT_COMPLETED) == SCU_RAM_INIT_COMPLETED) {
2951 result = SCI_SUCCESS;
2956 if (result == SCI_SUCCESS) {
2957 u32 max_supported_ports;
2958 u32 max_supported_devices;
2959 u32 max_supported_io_requests;
2960 u32 device_context_capacity;
2963 * Determine what are the actaul device capacities that the
2964 * hardware will support */
2965 device_context_capacity = SMU_DCC_READ(this_controller);
2967 max_supported_ports =
2968 smu_dcc_get_max_ports(device_context_capacity);
2969 max_supported_devices =
2970 smu_dcc_get_max_remote_node_context(device_context_capacity);
2971 max_supported_io_requests =
2972 smu_dcc_get_max_task_context(device_context_capacity);
2974 /* Make all PEs that are unassigned match up with the logical ports */
2975 for (index = 0; index < max_supported_ports; index++) {
2978 this_controller->scu_registers->peg0.ptsg.protocol_engine[index],
2983 /* Record the smaller of the two capacity values */
2984 this_controller->logical_port_entries =
2985 min(max_supported_ports, this_controller->logical_port_entries);
2987 this_controller->task_context_entries =
2988 min(max_supported_io_requests, this_controller->task_context_entries);
2990 this_controller->remote_node_entries =
2991 min(max_supported_devices, this_controller->remote_node_entries);
2994 * Now that we have the correct hardware reported minimum values
2995 * build the MDL for the controller. Default to a performance
2997 scic_controller_set_mode(this_controller, SCI_MODE_SPEED);
3000 /* Initialize hardware PCI Relaxed ordering in DMA engines */
3001 if (result == SCI_SUCCESS) {
3002 u32 dma_configuration;
3004 /* Configure the payload DMA */
3005 dma_configuration = SCU_PDMACR_READ(this_controller);
3006 dma_configuration |= SCU_PDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
3007 SCU_PDMACR_WRITE(this_controller, dma_configuration);
3009 /* Configure the control DMA */
3010 dma_configuration = SCU_CDMACR_READ(this_controller);
3011 dma_configuration |= SCU_CDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
3012 SCU_CDMACR_WRITE(this_controller, dma_configuration);
3016 * Initialize the PHYs before the PORTs because the PHY registers
3017 * are accessed during the port initialization. */
3018 if (result == SCI_SUCCESS) {
3019 /* Initialize the phys */
3021 (result == SCI_SUCCESS) && (index < SCI_MAX_PHYS);
3023 result = scic_sds_phy_initialize(
3024 &this_controller->phy_table[index],
3025 &this_controller->scu_registers->peg0.pe[index].tl,
3026 &this_controller->scu_registers->peg0.pe[index].ll
3031 if (result == SCI_SUCCESS) {
3032 /* Initialize the logical ports */
3034 (index < this_controller->logical_port_entries)
3035 && (result == SCI_SUCCESS);
3037 result = scic_sds_port_initialize(
3038 &this_controller->port_table[index],
3039 &this_controller->scu_registers->peg0.ptsg.port[index],
3040 &this_controller->scu_registers->peg0.ptsg.protocol_engine,
3041 &this_controller->scu_registers->peg0.viit[index]
3046 if (SCI_SUCCESS == result) {
3047 result = scic_sds_port_configuration_agent_initialize(
3049 &this_controller->port_agent
3053 /* Advance the controller state machine */
3054 if (result == SCI_SUCCESS) {
3055 sci_base_state_machine_change_state(
3056 scic_sds_controller_get_base_state_machine(this_controller),
3057 SCI_BASE_CONTROLLER_STATE_INITIALIZED
3060 sci_base_state_machine_change_state(
3061 scic_sds_controller_get_base_state_machine(this_controller),
3062 SCI_BASE_CONTROLLER_STATE_FAILED
3070 * *****************************************************************************
3071 * * INITIALIZED STATE HANDLERS
3072 * ***************************************************************************** */
3076 * @controller: This is the struct sci_base_controller object which is cast into a
3077 * struct scic_sds_controller object.
3078 * @timeout: This is the allowed time for the controller object to reach the
3081 * This method is the struct scic_sds_controller start handler for the initialized
3082 * state. - Validate we have a good memory descriptor table - Initialze the
3083 * physical memory before programming the hardware - Program the SCU hardware
3084 * with the physical memory addresses passed in the memory descriptor table. -
3085 * Initialzie the TCi pool - Initialize the RNi pool - Initialize the
3086 * completion queue - Initialize the unsolicited frame data - Take the SCU port
3087 * task scheduler out of reset - Start the first phy object. - Transition to
3088 * SCI_BASE_CONTROLLER_STATE_STARTING. enum sci_status SCI_SUCCESS if all of the
3089 * controller start operations complete
3090 * SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD if one or more of the memory
3091 * descriptor fields is invalid.
3093 static enum sci_status scic_sds_controller_initialized_state_start_handler(
3094 struct sci_base_controller *controller,
3098 enum sci_status result;
3099 struct scic_sds_controller *this_controller;
3101 this_controller = (struct scic_sds_controller *)controller;
3103 /* Make sure that the SCI User filled in the memory descriptor table correctly */
3104 result = scic_sds_controller_validate_memory_descriptor_table(this_controller);
3106 if (result == SCI_SUCCESS) {
3107 /* The memory descriptor list looks good so program the hardware */
3108 scic_sds_controller_ram_initialization(this_controller);
3111 if (result == SCI_SUCCESS) {
3112 /* Build the TCi free pool */
3113 sci_pool_initialize(this_controller->tci_pool);
3114 for (index = 0; index < this_controller->task_context_entries; index++) {
3115 sci_pool_put(this_controller->tci_pool, index);
3118 /* Build the RNi free pool */
3119 scic_sds_remote_node_table_initialize(
3120 &this_controller->available_remote_nodes,
3121 this_controller->remote_node_entries
3125 if (result == SCI_SUCCESS) {
3127 * Before anything else lets make sure we will not be interrupted
3128 * by the hardware. */
3129 scic_controller_disable_interrupts(this_controller);
3131 /* Enable the port task scheduler */
3132 scic_sds_controller_enable_port_task_scheduler(this_controller);
3134 /* Assign all the task entries to this controller physical function */
3135 scic_sds_controller_assign_task_entries(this_controller);
3137 /* Now initialze the completion queue */
3138 scic_sds_controller_initialize_completion_queue(this_controller);
3140 /* Initialize the unsolicited frame queue for use */
3141 scic_sds_controller_initialize_unsolicited_frame_queue(this_controller);
3144 /* Start all of the ports on this controller */
3145 for (index = 0; index < this_controller->logical_port_entries &&
3146 result == SCI_SUCCESS; index++) {
3147 struct scic_sds_port *sci_port = &this_controller->port_table[index];
3149 result = sci_port->state_handlers->parent.start_handler(&sci_port->parent);
3152 if (result == SCI_SUCCESS) {
3153 scic_sds_controller_start_next_phy(this_controller);
3155 isci_event_timer_start(this_controller,
3156 this_controller->timeout_timer,
3159 sci_base_state_machine_change_state(
3160 scic_sds_controller_get_base_state_machine(this_controller),
3161 SCI_BASE_CONTROLLER_STATE_STARTING
3169 * *****************************************************************************
3170 * * INITIALIZED STATE HANDLERS
3171 * ***************************************************************************** */
3175 * @controller: This is struct scic_sds_controller which receives the link up
3177 * @port: This is struct scic_sds_port with which the phy is associated.
3178 * @phy: This is the struct scic_sds_phy which has gone link up.
3180 * This method is called when the struct scic_sds_controller is in the starting state
3181 * link up handler is called. This method will perform the following: - Stop
3182 * the phy timer - Start the next phy - Report the link up condition to the
3185 static void scic_sds_controller_starting_state_link_up_handler(
3186 struct scic_sds_controller *this_controller,
3187 struct scic_sds_port *port,
3188 struct scic_sds_phy *phy)
3190 scic_sds_controller_phy_timer_stop(this_controller);
3192 this_controller->port_agent.link_up_handler(
3193 this_controller, &this_controller->port_agent, port, phy
3195 /* scic_sds_port_link_up(port, phy); */
3197 scic_sds_controller_start_next_phy(this_controller);
3202 * @controller: This is struct scic_sds_controller which receives the link down
3204 * @port: This is struct scic_sds_port with which the phy is associated.
3205 * @phy: This is the struct scic_sds_phy which has gone link down.
3207 * This method is called when the struct scic_sds_controller is in the starting state
3208 * link down handler is called. - Report the link down condition to the port
3211 static void scic_sds_controller_starting_state_link_down_handler(
3212 struct scic_sds_controller *this_controller,
3213 struct scic_sds_port *port,
3214 struct scic_sds_phy *phy)
3216 this_controller->port_agent.link_down_handler(
3217 this_controller, &this_controller->port_agent, port, phy
3219 /* scic_sds_port_link_down(port, phy); */
3223 * *****************************************************************************
3224 * * READY STATE HANDLERS
3225 * ***************************************************************************** */
3229 * @controller: The struct sci_base_controller object which is cast into a
3230 * struct scic_sds_controller object.
3231 * @timeout: The timeout for when the stop operation should report a failure.
3233 * This method is called when the struct scic_sds_controller is in the ready state
3234 * stop handler is called. - Start the timeout timer - Transition to
3235 * SCI_BASE_CONTROLLER_STATE_STOPPING. enum sci_status SCI_SUCCESS
3237 static enum sci_status scic_sds_controller_ready_state_stop_handler(
3238 struct sci_base_controller *controller,
3241 struct scic_sds_controller *this_controller;
3243 this_controller = (struct scic_sds_controller *)controller;
3245 isci_event_timer_start(this_controller,
3246 this_controller->timeout_timer,
3249 sci_base_state_machine_change_state(
3250 scic_sds_controller_get_base_state_machine(this_controller),
3251 SCI_BASE_CONTROLLER_STATE_STOPPING
3259 * @controller: This is struct sci_base_controller object which is cast into a
3260 * struct scic_sds_controller object.
3261 * @remote_device: This is struct sci_base_remote_device which is cast to a
3262 * struct scic_sds_remote_device object.
3263 * @io_request: This is the struct sci_base_request which is cast to a
3264 * SCIC_SDS_IO_REQUEST object.
3265 * @io_tag: This is the IO tag to be assigned to the IO request or
3266 * SCI_CONTROLLER_INVALID_IO_TAG.
3268 * This method is called when the struct scic_sds_controller is in the ready state and
3269 * the start io handler is called. - Start the io request on the remote device
3270 * - if successful - assign the io_request to the io_request_table - post the
3271 * request to the hardware enum sci_status SCI_SUCCESS if the start io operation
3272 * succeeds SCI_FAILURE_INSUFFICIENT_RESOURCES if the IO tag could not be
3273 * allocated for the io request. SCI_FAILURE_INVALID_STATE if one or more
3274 * objects are not in a valid state to accept io requests. How does the io_tag
3275 * parameter get assigned to the io request?
3277 static enum sci_status scic_sds_controller_ready_state_start_io_handler(
3278 struct sci_base_controller *controller,
3279 struct sci_base_remote_device *remote_device,
3280 struct sci_base_request *io_request,
3283 enum sci_status status;
3285 struct scic_sds_controller *this_controller;
3286 struct scic_sds_request *the_request;
3287 struct scic_sds_remote_device *the_device;
3289 this_controller = (struct scic_sds_controller *)controller;
3290 the_request = (struct scic_sds_request *)io_request;
3291 the_device = (struct scic_sds_remote_device *)remote_device;
3293 status = scic_sds_remote_device_start_io(this_controller, the_device, the_request);
3295 if (status == SCI_SUCCESS) {
3296 this_controller->io_request_table[
3297 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3299 scic_sds_controller_post_request(
3301 scic_sds_request_get_post_context(the_request)
3310 * @controller: This is struct sci_base_controller object which is cast into a
3311 * struct scic_sds_controller object.
3312 * @remote_device: This is struct sci_base_remote_device which is cast to a
3313 * struct scic_sds_remote_device object.
3314 * @io_request: This is the struct sci_base_request which is cast to a
3315 * SCIC_SDS_IO_REQUEST object.
3317 * This method is called when the struct scic_sds_controller is in the ready state and
3318 * the complete io handler is called. - Complete the io request on the remote
3319 * device - if successful - remove the io_request to the io_request_table
3320 * enum sci_status SCI_SUCCESS if the start io operation succeeds
3321 * SCI_FAILURE_INVALID_STATE if one or more objects are not in a valid state to
3322 * accept io requests.
3324 static enum sci_status scic_sds_controller_ready_state_complete_io_handler(
3325 struct sci_base_controller *controller,
3326 struct sci_base_remote_device *remote_device,
3327 struct sci_base_request *io_request)
3330 enum sci_status status;
3331 struct scic_sds_controller *this_controller;
3332 struct scic_sds_request *the_request;
3333 struct scic_sds_remote_device *the_device;
3335 this_controller = (struct scic_sds_controller *)controller;
3336 the_request = (struct scic_sds_request *)io_request;
3337 the_device = (struct scic_sds_remote_device *)remote_device;
3339 status = scic_sds_remote_device_complete_io(
3340 this_controller, the_device, the_request);
3342 if (status == SCI_SUCCESS) {
3343 index = scic_sds_io_tag_get_index(the_request->io_tag);
3344 this_controller->io_request_table[index] = NULL;
3352 * @controller: This is struct sci_base_controller object which is cast into a
3353 * struct scic_sds_controller object.
3354 * @remote_device: This is struct sci_base_remote_device which is cast to a
3355 * struct scic_sds_remote_device object.
3356 * @io_request: This is the struct sci_base_request which is cast to a
3357 * SCIC_SDS_IO_REQUEST object.
3359 * This method is called when the struct scic_sds_controller is in the ready state and
3360 * the continue io handler is called. enum sci_status
3362 static enum sci_status scic_sds_controller_ready_state_continue_io_handler(
3363 struct sci_base_controller *controller,
3364 struct sci_base_remote_device *remote_device,
3365 struct sci_base_request *io_request)
3367 struct scic_sds_controller *this_controller;
3368 struct scic_sds_request *the_request;
3370 the_request = (struct scic_sds_request *)io_request;
3371 this_controller = (struct scic_sds_controller *)controller;
3373 this_controller->io_request_table[
3374 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3376 scic_sds_controller_post_request(
3378 scic_sds_request_get_post_context(the_request)
3386 * @controller: This is struct sci_base_controller object which is cast into a
3387 * struct scic_sds_controller object.
3388 * @remote_device: This is struct sci_base_remote_device which is cast to a
3389 * struct scic_sds_remote_device object.
3390 * @io_request: This is the struct sci_base_request which is cast to a
3391 * SCIC_SDS_IO_REQUEST object.
3392 * @task_tag: This is the task tag to be assigned to the task request or
3393 * SCI_CONTROLLER_INVALID_IO_TAG.
3395 * This method is called when the struct scic_sds_controller is in the ready state and
3396 * the start task handler is called. - The remote device is requested to start
3397 * the task request - if successful - assign the task to the io_request_table -
3398 * post the request to the SCU hardware enum sci_status SCI_SUCCESS if the start io
3399 * operation succeeds SCI_FAILURE_INSUFFICIENT_RESOURCES if the IO tag could
3400 * not be allocated for the io request. SCI_FAILURE_INVALID_STATE if one or
3401 * more objects are not in a valid state to accept io requests. How does the io
3402 * tag get assigned in this code path?
3404 static enum sci_status scic_sds_controller_ready_state_start_task_handler(
3405 struct sci_base_controller *controller,
3406 struct sci_base_remote_device *remote_device,
3407 struct sci_base_request *io_request,
3410 struct scic_sds_controller *this_controller = (struct scic_sds_controller *)
3412 struct scic_sds_request *the_request = (struct scic_sds_request *)
3414 struct scic_sds_remote_device *the_device = (struct scic_sds_remote_device *)
3416 enum sci_status status;
3418 status = scic_sds_remote_device_start_task(
3419 this_controller, the_device, the_request
3422 if (status == SCI_SUCCESS) {
3423 this_controller->io_request_table[
3424 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3426 scic_sds_controller_post_request(
3428 scic_sds_request_get_post_context(the_request)
3430 } else if (status == SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS) {
3431 this_controller->io_request_table[
3432 scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
3435 * We will let framework know this task request started successfully,
3436 * although core is still woring on starting the request (to post tc when
3437 * RNC is resumed.) */
3438 status = SCI_SUCCESS;
3445 * @controller: This is struct sci_base_controller object which is cast into a
3446 * struct scic_sds_controller object.
3447 * @remote_device: This is struct sci_base_remote_device which is cast to a
3448 * struct scic_sds_remote_device object.
3449 * @io_request: This is the struct sci_base_request which is cast to a
3450 * SCIC_SDS_IO_REQUEST object.
3452 * This method is called when the struct scic_sds_controller is in the ready state and
3453 * the terminate request handler is called. - call the io request terminate
3454 * function - if successful - post the terminate request to the SCU hardware
3455 * enum sci_status SCI_SUCCESS if the start io operation succeeds
3456 * SCI_FAILURE_INVALID_STATE if one or more objects are not in a valid state to
3457 * accept io requests.
3459 static enum sci_status scic_sds_controller_ready_state_terminate_request_handler(
3460 struct sci_base_controller *controller,
3461 struct sci_base_remote_device *remote_device,
3462 struct sci_base_request *io_request)
3464 struct scic_sds_controller *this_controller = (struct scic_sds_controller *)
3466 struct scic_sds_request *the_request = (struct scic_sds_request *)
3468 enum sci_status status;
3470 status = scic_sds_io_request_terminate(the_request);
3471 if (status == SCI_SUCCESS) {
3473 * Utilize the original post context command and or in the POST_TC_ABORT
3474 * request sub-type. */
3475 scic_sds_controller_post_request(
3477 scic_sds_request_get_post_context(the_request)
3478 | SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT
3487 * @controller: This is struct scic_sds_controller which receives the link up
3489 * @port: This is struct scic_sds_port with which the phy is associated.
3490 * @phy: This is the struct scic_sds_phy which has gone link up.
3492 * This method is called when the struct scic_sds_controller is in the starting state
3493 * link up handler is called. This method will perform the following: - Stop
3494 * the phy timer - Start the next phy - Report the link up condition to the
3497 static void scic_sds_controller_ready_state_link_up_handler(
3498 struct scic_sds_controller *this_controller,
3499 struct scic_sds_port *port,
3500 struct scic_sds_phy *phy)
3502 this_controller->port_agent.link_up_handler(
3503 this_controller, &this_controller->port_agent, port, phy
3509 * @controller: This is struct scic_sds_controller which receives the link down
3511 * @port: This is struct scic_sds_port with which the phy is associated.
3512 * @phy: This is the struct scic_sds_phy which has gone link down.
3514 * This method is called when the struct scic_sds_controller is in the starting state
3515 * link down handler is called. - Report the link down condition to the port
3518 static void scic_sds_controller_ready_state_link_down_handler(
3519 struct scic_sds_controller *this_controller,
3520 struct scic_sds_port *port,
3521 struct scic_sds_phy *phy)
3523 this_controller->port_agent.link_down_handler(
3524 this_controller, &this_controller->port_agent, port, phy
3529 * *****************************************************************************
3530 * * STOPPING STATE HANDLERS
3531 * ***************************************************************************** */
3535 * @controller: This is struct sci_base_controller object which is cast into a
3536 * struct scic_sds_controller object.
3537 * @remote_device: This is struct sci_base_remote_device which is cast to a
3538 * struct scic_sds_remote_device object.
3539 * @io_request: This is the struct sci_base_request which is cast to a
3540 * SCIC_SDS_IO_REQUEST object.
3542 * This method is called when the struct scic_sds_controller is in a stopping state
3543 * and the complete io handler is called. - This function is not yet
3544 * implemented enum sci_status SCI_FAILURE
3546 static enum sci_status scic_sds_controller_stopping_state_complete_io_handler(
3547 struct sci_base_controller *controller,
3548 struct sci_base_remote_device *remote_device,
3549 struct sci_base_request *io_request)
3551 struct scic_sds_controller *this_controller;
3553 this_controller = (struct scic_sds_controller *)controller;
3555 /* / @todo Implement this function */
3561 * @controller: This is struct sci_base_controller object which is cast into a
3562 * struct scic_sds_controller object.
3563 * @remote_device: This is struct sci_base_remote_device which is cast to a
3564 * struct scic_sds_remote_device object.
3566 * This method is called when the struct scic_sds_controller is in a stopping state
3567 * and the remote device has stopped.
3569 void scic_sds_controller_stopping_state_device_stopped_handler(
3570 struct scic_sds_controller *controller,
3571 struct scic_sds_remote_device *remote_device
3574 if (!scic_sds_controller_has_remote_devices_stopping(controller)) {
3575 sci_base_state_machine_change_state(
3576 &controller->parent.state_machine,
3577 SCI_BASE_CONTROLLER_STATE_STOPPED
3582 const struct scic_sds_controller_state_handler scic_sds_controller_state_handler_table[] = {
3583 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3584 .base.start_io = scic_sds_controller_default_start_operation_handler,
3585 .base.complete_io = scic_sds_controller_default_request_handler,
3586 .base.continue_io = scic_sds_controller_default_request_handler,
3587 .terminate_request = scic_sds_controller_default_request_handler,
3589 [SCI_BASE_CONTROLLER_STATE_RESET] = {
3590 .base.reset = scic_sds_controller_general_reset_handler,
3591 .base.initialize = scic_sds_controller_reset_state_initialize_handler,
3592 .base.start_io = scic_sds_controller_default_start_operation_handler,
3593 .base.complete_io = scic_sds_controller_default_request_handler,
3594 .base.continue_io = scic_sds_controller_default_request_handler,
3595 .terminate_request = scic_sds_controller_default_request_handler,
3597 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {
3598 .base.start_io = scic_sds_controller_default_start_operation_handler,
3599 .base.complete_io = scic_sds_controller_default_request_handler,
3600 .base.continue_io = scic_sds_controller_default_request_handler,
3601 .terminate_request = scic_sds_controller_default_request_handler,
3603 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {
3604 .base.start = scic_sds_controller_initialized_state_start_handler,
3605 .base.start_io = scic_sds_controller_default_start_operation_handler,
3606 .base.complete_io = scic_sds_controller_default_request_handler,
3607 .base.continue_io = scic_sds_controller_default_request_handler,
3608 .terminate_request = scic_sds_controller_default_request_handler,
3610 [SCI_BASE_CONTROLLER_STATE_STARTING] = {
3611 .base.start_io = scic_sds_controller_default_start_operation_handler,
3612 .base.complete_io = scic_sds_controller_default_request_handler,
3613 .base.continue_io = scic_sds_controller_default_request_handler,
3614 .terminate_request = scic_sds_controller_default_request_handler,
3615 .link_up = scic_sds_controller_starting_state_link_up_handler,
3616 .link_down = scic_sds_controller_starting_state_link_down_handler
3618 [SCI_BASE_CONTROLLER_STATE_READY] = {
3619 .base.stop = scic_sds_controller_ready_state_stop_handler,
3620 .base.reset = scic_sds_controller_general_reset_handler,
3621 .base.start_io = scic_sds_controller_ready_state_start_io_handler,
3622 .base.complete_io = scic_sds_controller_ready_state_complete_io_handler,
3623 .base.continue_io = scic_sds_controller_ready_state_continue_io_handler,
3624 .base.start_task = scic_sds_controller_ready_state_start_task_handler,
3625 .base.complete_task = scic_sds_controller_ready_state_complete_io_handler,
3626 .terminate_request = scic_sds_controller_ready_state_terminate_request_handler,
3627 .link_up = scic_sds_controller_ready_state_link_up_handler,
3628 .link_down = scic_sds_controller_ready_state_link_down_handler
3630 [SCI_BASE_CONTROLLER_STATE_RESETTING] = {
3631 .base.start_io = scic_sds_controller_default_start_operation_handler,
3632 .base.complete_io = scic_sds_controller_default_request_handler,
3633 .base.continue_io = scic_sds_controller_default_request_handler,
3634 .terminate_request = scic_sds_controller_default_request_handler,
3636 [SCI_BASE_CONTROLLER_STATE_STOPPING] = {
3637 .base.start_io = scic_sds_controller_default_start_operation_handler,
3638 .base.complete_io = scic_sds_controller_stopping_state_complete_io_handler,
3639 .base.continue_io = scic_sds_controller_default_request_handler,
3640 .terminate_request = scic_sds_controller_default_request_handler,
3641 .remote_device_stopped_handler = scic_sds_controller_stopping_state_device_stopped_handler,
3643 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {
3644 .base.reset = scic_sds_controller_general_reset_handler,
3645 .base.start_io = scic_sds_controller_default_start_operation_handler,
3646 .base.complete_io = scic_sds_controller_default_request_handler,
3647 .base.continue_io = scic_sds_controller_default_request_handler,
3648 .terminate_request = scic_sds_controller_default_request_handler,
3650 [SCI_BASE_CONTROLLER_STATE_FAILED] = {
3651 .base.reset = scic_sds_controller_general_reset_handler,
3652 .base.start_io = scic_sds_controller_default_start_operation_handler,
3653 .base.complete_io = scic_sds_controller_default_request_handler,
3654 .base.continue_io = scic_sds_controller_default_request_handler,
3655 .terminate_request = scic_sds_controller_default_request_handler,
3661 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3664 * This method implements the actions taken by the struct scic_sds_controller on entry
3665 * to the SCI_BASE_CONTROLLER_STATE_INITIAL. - Set the state handlers to the
3666 * controllers initial state. none This function should initialze the
3667 * controller object.
3669 static void scic_sds_controller_initial_state_enter(
3670 struct sci_base_object *object)
3672 struct scic_sds_controller *this_controller;
3674 this_controller = (struct scic_sds_controller *)object;
3676 sci_base_state_machine_change_state(
3677 &this_controller->parent.state_machine, SCI_BASE_CONTROLLER_STATE_RESET);
3682 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3685 * This method implements the actions taken by the struct scic_sds_controller on exit
3686 * from the SCI_BASE_CONTROLLER_STATE_STARTING. - This function stops the
3687 * controller starting timeout timer. none
3689 static void scic_sds_controller_starting_state_exit(
3690 struct sci_base_object *object)
3692 struct scic_sds_controller *scic = (struct scic_sds_controller *)object;
3694 isci_event_timer_stop(scic, scic->timeout_timer);
3699 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3702 * This method implements the actions taken by the struct scic_sds_controller on entry
3703 * to the SCI_BASE_CONTROLLER_STATE_READY. - Set the state handlers to the
3704 * controllers ready state. none
3706 static void scic_sds_controller_ready_state_enter(
3707 struct sci_base_object *object)
3709 struct scic_sds_controller *this_controller;
3711 this_controller = (struct scic_sds_controller *)object;
3713 /* set the default interrupt coalescence number and timeout value. */
3714 scic_controller_set_interrupt_coalescence(
3715 this_controller, 0x10, 250);
3720 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3723 * This method implements the actions taken by the struct scic_sds_controller on exit
3724 * from the SCI_BASE_CONTROLLER_STATE_READY. - This function does nothing. none
3726 static void scic_sds_controller_ready_state_exit(
3727 struct sci_base_object *object)
3729 struct scic_sds_controller *this_controller;
3731 this_controller = (struct scic_sds_controller *)object;
3733 /* disable interrupt coalescence. */
3734 scic_controller_set_interrupt_coalescence(this_controller, 0, 0);
3739 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3742 * This method implements the actions taken by the struct scic_sds_controller on entry
3743 * to the SCI_BASE_CONTROLLER_STATE_READY. - Set the state handlers to the
3744 * controllers ready state. - Stop the phys on this controller - Stop the ports
3745 * on this controller - Stop all of the remote devices on this controller none
3747 static void scic_sds_controller_stopping_state_enter(
3748 struct sci_base_object *object)
3750 struct scic_sds_controller *this_controller;
3752 this_controller = (struct scic_sds_controller *)object;
3754 /* Stop all of the components for this controller */
3755 scic_sds_controller_stop_phys(this_controller);
3756 scic_sds_controller_stop_ports(this_controller);
3757 scic_sds_controller_stop_devices(this_controller);
3762 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3765 * This method implements the actions taken by the struct scic_sds_controller on exit
3766 * from the SCI_BASE_CONTROLLER_STATE_STOPPING. - This function stops the
3767 * controller stopping timeout timer. none
3769 static void scic_sds_controller_stopping_state_exit(
3770 struct sci_base_object *object)
3772 struct scic_sds_controller *this_controller;
3774 this_controller = (struct scic_sds_controller *)object;
3776 isci_event_timer_stop(this_controller, this_controller->timeout_timer);
3781 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
3784 * This method implements the actions taken by the struct scic_sds_controller on entry
3785 * to the SCI_BASE_CONTROLLER_STATE_RESETTING. - Set the state handlers to the
3786 * controllers resetting state. - Write to the SCU hardware reset register to
3787 * force a reset - Transition to the SCI_BASE_CONTROLLER_STATE_RESET none
3789 static void scic_sds_controller_resetting_state_enter(
3790 struct sci_base_object *object)
3792 struct scic_sds_controller *this_controller;
3794 this_controller = (struct scic_sds_controller *)object;
3796 scic_sds_controller_reset_hardware(this_controller);
3798 sci_base_state_machine_change_state(
3799 scic_sds_controller_get_base_state_machine(this_controller),
3800 SCI_BASE_CONTROLLER_STATE_RESET
3804 /* --------------------------------------------------------------------------- */
3806 const struct sci_base_state scic_sds_controller_state_table[] = {
3807 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3808 .enter_state = scic_sds_controller_initial_state_enter,
3810 [SCI_BASE_CONTROLLER_STATE_RESET] = {},
3811 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {},
3812 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {},
3813 [SCI_BASE_CONTROLLER_STATE_STARTING] = {
3814 .exit_state = scic_sds_controller_starting_state_exit,
3816 [SCI_BASE_CONTROLLER_STATE_READY] = {
3817 .enter_state = scic_sds_controller_ready_state_enter,
3818 .exit_state = scic_sds_controller_ready_state_exit,
3820 [SCI_BASE_CONTROLLER_STATE_RESETTING] = {
3821 .enter_state = scic_sds_controller_resetting_state_enter,
3823 [SCI_BASE_CONTROLLER_STATE_STOPPING] = {
3824 .enter_state = scic_sds_controller_stopping_state_enter,
3825 .exit_state = scic_sds_controller_stopping_state_exit,
3827 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
3828 [SCI_BASE_CONTROLLER_STATE_FAILED] = {}