isci: remove base_phy abstraction
[deliverable/linux.git] / drivers / scsi / isci / core / scic_sds_controller.c
1 /*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56 #include <linux/device.h>
57 #include "scic_controller.h"
58 #include "scic_phy.h"
59 #include "scic_port.h"
60 #include "scic_remote_device.h"
61 #include "scic_sds_controller.h"
62 #include "scu_registers.h"
63 #include "scic_sds_phy.h"
64 #include "scic_sds_port_configuration_agent.h"
65 #include "scic_sds_port.h"
66 #include "scic_sds_remote_device.h"
67 #include "scic_sds_request.h"
68 #include "sci_environment.h"
69 #include "sci_util.h"
70 #include "scu_completion_codes.h"
71 #include "scu_constants.h"
72 #include "scu_event_codes.h"
73 #include "scu_remote_node_context.h"
74 #include "scu_task_context.h"
75 #include "scu_unsolicited_frame.h"
76
77 #define SCU_CONTEXT_RAM_INIT_STALL_TIME 200
78
79 /**
80 * smu_dcc_get_max_ports() -
81 *
82 * This macro returns the maximum number of logical ports supported by the
83 * hardware. The caller passes in the value read from the device context
84 * capacity register and this macro will mash and shift the value appropriately.
85 */
86 #define smu_dcc_get_max_ports(dcc_value) \
87 (\
88 (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_MASK) \
89 >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_SHIFT) + 1 \
90 )
91
92 /**
93 * smu_dcc_get_max_task_context() -
94 *
95 * This macro returns the maximum number of task contexts supported by the
96 * hardware. The caller passes in the value read from the device context
97 * capacity register and this macro will mash and shift the value appropriately.
98 */
99 #define smu_dcc_get_max_task_context(dcc_value) \
100 (\
101 (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_MASK) \
102 >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_SHIFT) + 1 \
103 )
104
105 /**
106 * smu_dcc_get_max_remote_node_context() -
107 *
108 * This macro returns the maximum number of remote node contexts supported by
109 * the hardware. The caller passes in the value read from the device context
110 * capacity register and this macro will mash and shift the value appropriately.
111 */
112 #define smu_dcc_get_max_remote_node_context(dcc_value) \
113 (\
114 (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_MASK) \
115 >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_SHIFT) + 1 \
116 )
117
118
119 static void scic_sds_controller_power_control_timer_handler(
120 void *controller);
121 #define SCIC_SDS_CONTROLLER_MIN_TIMER_COUNT 3
122 #define SCIC_SDS_CONTROLLER_MAX_TIMER_COUNT 3
123
124 /**
125 *
126 *
127 * The number of milliseconds to wait for a phy to start.
128 */
129 #define SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT 100
130
131 /**
132 *
133 *
134 * The number of milliseconds to wait while a given phy is consuming power
135 * before allowing another set of phys to consume power. Ultimately, this will
136 * be specified by OEM parameter.
137 */
138 #define SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL 500
139
140 /**
141 * COMPLETION_QUEUE_CYCLE_BIT() -
142 *
143 * This macro will return the cycle bit of the completion queue entry
144 */
145 #define COMPLETION_QUEUE_CYCLE_BIT(x) ((x) & 0x80000000)
146
147 /**
148 * NORMALIZE_GET_POINTER() -
149 *
150 * This macro will normalize the completion queue get pointer so its value can
151 * be used as an index into an array
152 */
153 #define NORMALIZE_GET_POINTER(x) \
154 ((x) & SMU_COMPLETION_QUEUE_GET_POINTER_MASK)
155
156 /**
157 * NORMALIZE_PUT_POINTER() -
158 *
159 * This macro will normalize the completion queue put pointer so its value can
160 * be used as an array inde
161 */
162 #define NORMALIZE_PUT_POINTER(x) \
163 ((x) & SMU_COMPLETION_QUEUE_PUT_POINTER_MASK)
164
165
166 /**
167 * NORMALIZE_GET_POINTER_CYCLE_BIT() -
168 *
169 * This macro will normalize the completion queue cycle pointer so it matches
170 * the completion queue cycle bit
171 */
172 #define NORMALIZE_GET_POINTER_CYCLE_BIT(x) \
173 ((SMU_CQGR_CYCLE_BIT & (x)) << (31 - SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_SHIFT))
174
175 /**
176 * NORMALIZE_EVENT_POINTER() -
177 *
178 * This macro will normalize the completion queue event entry so its value can
179 * be used as an index.
180 */
181 #define NORMALIZE_EVENT_POINTER(x) \
182 (\
183 ((x) & SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_MASK) \
184 >> SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_SHIFT \
185 )
186
187 /**
188 * INCREMENT_COMPLETION_QUEUE_GET() -
189 *
190 * This macro will increment the controllers completion queue index value and
191 * possibly toggle the cycle bit if the completion queue index wraps back to 0.
192 */
193 #define INCREMENT_COMPLETION_QUEUE_GET(controller, index, cycle) \
194 INCREMENT_QUEUE_GET(\
195 (index), \
196 (cycle), \
197 (controller)->completion_queue_entries, \
198 SMU_CQGR_CYCLE_BIT \
199 )
200
201 /**
202 * INCREMENT_EVENT_QUEUE_GET() -
203 *
204 * This macro will increment the controllers event queue index value and
205 * possibly toggle the event cycle bit if the event queue index wraps back to 0.
206 */
207 #define INCREMENT_EVENT_QUEUE_GET(controller, index, cycle) \
208 INCREMENT_QUEUE_GET(\
209 (index), \
210 (cycle), \
211 (controller)->completion_event_entries, \
212 SMU_CQGR_EVENT_CYCLE_BIT \
213 )
214
215 static void scic_sds_controller_initialize_power_control(struct scic_sds_controller *scic)
216 {
217 struct isci_host *ihost = sci_object_get_association(scic);
218 scic->power_control.timer = isci_timer_create(ihost,
219 scic,
220 scic_sds_controller_power_control_timer_handler);
221
222 memset(scic->power_control.requesters, 0,
223 sizeof(scic->power_control.requesters));
224
225 scic->power_control.phys_waiting = 0;
226 scic->power_control.phys_granted_power = 0;
227 }
228
229 int scic_controller_mem_init(struct scic_sds_controller *scic)
230 {
231 struct device *dev = scic_to_dev(scic);
232 dma_addr_t dma_handle;
233 enum sci_status result;
234
235 scic->completion_queue = dmam_alloc_coherent(dev,
236 scic->completion_queue_entries * sizeof(u32),
237 &dma_handle, GFP_KERNEL);
238 if (!scic->completion_queue)
239 return -ENOMEM;
240
241 writel(lower_32_bits(dma_handle),
242 &scic->smu_registers->completion_queue_lower);
243 writel(upper_32_bits(dma_handle),
244 &scic->smu_registers->completion_queue_upper);
245
246 scic->remote_node_context_table = dmam_alloc_coherent(dev,
247 scic->remote_node_entries *
248 sizeof(union scu_remote_node_context),
249 &dma_handle, GFP_KERNEL);
250 if (!scic->remote_node_context_table)
251 return -ENOMEM;
252
253 writel(lower_32_bits(dma_handle),
254 &scic->smu_registers->remote_node_context_lower);
255 writel(upper_32_bits(dma_handle),
256 &scic->smu_registers->remote_node_context_upper);
257
258 scic->task_context_table = dmam_alloc_coherent(dev,
259 scic->task_context_entries *
260 sizeof(struct scu_task_context),
261 &dma_handle, GFP_KERNEL);
262 if (!scic->task_context_table)
263 return -ENOMEM;
264
265 writel(lower_32_bits(dma_handle),
266 &scic->smu_registers->host_task_table_lower);
267 writel(upper_32_bits(dma_handle),
268 &scic->smu_registers->host_task_table_upper);
269
270 result = scic_sds_unsolicited_frame_control_construct(scic);
271 if (result)
272 return result;
273
274 /*
275 * Inform the silicon as to the location of the UF headers and
276 * address table.
277 */
278 writel(lower_32_bits(scic->uf_control.headers.physical_address),
279 &scic->scu_registers->sdma.uf_header_base_address_lower);
280 writel(upper_32_bits(scic->uf_control.headers.physical_address),
281 &scic->scu_registers->sdma.uf_header_base_address_upper);
282
283 writel(lower_32_bits(scic->uf_control.address_table.physical_address),
284 &scic->scu_registers->sdma.uf_address_table_lower);
285 writel(upper_32_bits(scic->uf_control.address_table.physical_address),
286 &scic->scu_registers->sdma.uf_address_table_upper);
287
288 return 0;
289 }
290
291 /**
292 * This method initializes the task context data for the controller.
293 * @this_controller:
294 *
295 */
296 static void
297 scic_sds_controller_assign_task_entries(struct scic_sds_controller *controller)
298 {
299 u32 task_assignment;
300
301 /*
302 * Assign all the TCs to function 0
303 * TODO: Do we actually need to read this register to write it back?
304 */
305
306 task_assignment =
307 readl(&controller->smu_registers->task_context_assignment[0]);
308
309 task_assignment |= (SMU_TCA_GEN_VAL(STARTING, 0)) |
310 (SMU_TCA_GEN_VAL(ENDING, controller->task_context_entries - 1)) |
311 (SMU_TCA_GEN_BIT(RANGE_CHECK_ENABLE));
312
313 writel(task_assignment,
314 &controller->smu_registers->task_context_assignment[0]);
315
316 }
317
318 /**
319 * This method initializes the hardware completion queue.
320 *
321 *
322 */
323 static void scic_sds_controller_initialize_completion_queue(
324 struct scic_sds_controller *this_controller)
325 {
326 u32 index;
327 u32 completion_queue_control_value;
328 u32 completion_queue_get_value;
329 u32 completion_queue_put_value;
330
331 this_controller->completion_queue_get = 0;
332
333 completion_queue_control_value = (
334 SMU_CQC_QUEUE_LIMIT_SET(this_controller->completion_queue_entries - 1)
335 | SMU_CQC_EVENT_LIMIT_SET(this_controller->completion_event_entries - 1)
336 );
337
338 writel(completion_queue_control_value,
339 &this_controller->smu_registers->completion_queue_control);
340
341
342 /* Set the completion queue get pointer and enable the queue */
343 completion_queue_get_value = (
344 (SMU_CQGR_GEN_VAL(POINTER, 0))
345 | (SMU_CQGR_GEN_VAL(EVENT_POINTER, 0))
346 | (SMU_CQGR_GEN_BIT(ENABLE))
347 | (SMU_CQGR_GEN_BIT(EVENT_ENABLE))
348 );
349
350 writel(completion_queue_get_value,
351 &this_controller->smu_registers->completion_queue_get);
352
353 /* Set the completion queue put pointer */
354 completion_queue_put_value = (
355 (SMU_CQPR_GEN_VAL(POINTER, 0))
356 | (SMU_CQPR_GEN_VAL(EVENT_POINTER, 0))
357 );
358
359 writel(completion_queue_put_value,
360 &this_controller->smu_registers->completion_queue_put);
361
362
363 /* Initialize the cycle bit of the completion queue entries */
364 for (index = 0; index < this_controller->completion_queue_entries; index++) {
365 /*
366 * If get.cycle_bit != completion_queue.cycle_bit
367 * its not a valid completion queue entry
368 * so at system start all entries are invalid */
369 this_controller->completion_queue[index] = 0x80000000;
370 }
371 }
372
373 /**
374 * This method initializes the hardware unsolicited frame queue.
375 *
376 *
377 */
378 static void scic_sds_controller_initialize_unsolicited_frame_queue(
379 struct scic_sds_controller *this_controller)
380 {
381 u32 frame_queue_control_value;
382 u32 frame_queue_get_value;
383 u32 frame_queue_put_value;
384
385 /* Write the queue size */
386 frame_queue_control_value =
387 SCU_UFQC_GEN_VAL(QUEUE_SIZE, this_controller->uf_control.address_table.count);
388
389 writel(frame_queue_control_value,
390 &this_controller->scu_registers->sdma.unsolicited_frame_queue_control);
391
392 /* Setup the get pointer for the unsolicited frame queue */
393 frame_queue_get_value = (
394 SCU_UFQGP_GEN_VAL(POINTER, 0)
395 | SCU_UFQGP_GEN_BIT(ENABLE_BIT)
396 );
397
398 writel(frame_queue_get_value,
399 &this_controller->scu_registers->sdma.unsolicited_frame_get_pointer);
400 /* Setup the put pointer for the unsolicited frame queue */
401 frame_queue_put_value = SCU_UFQPP_GEN_VAL(POINTER, 0);
402 writel(frame_queue_put_value,
403 &this_controller->scu_registers->sdma.unsolicited_frame_put_pointer);
404 }
405
406 /**
407 * This method enables the hardware port task scheduler.
408 *
409 *
410 */
411 static void scic_sds_controller_enable_port_task_scheduler(
412 struct scic_sds_controller *this_controller)
413 {
414 u32 port_task_scheduler_value;
415
416 port_task_scheduler_value =
417 readl(&this_controller->scu_registers->peg0.ptsg.control);
418 port_task_scheduler_value |=
419 (SCU_PTSGCR_GEN_BIT(ETM_ENABLE) | SCU_PTSGCR_GEN_BIT(PTSG_ENABLE));
420 writel(port_task_scheduler_value,
421 &this_controller->scu_registers->peg0.ptsg.control);
422 }
423
424 /**
425 *
426 *
427 * This macro is used to delay between writes to the AFE registers during AFE
428 * initialization.
429 */
430 #define AFE_REGISTER_WRITE_DELAY 10
431
432 /* Initialize the AFE for this phy index. We need to read the AFE setup from
433 * the OEM parameters none
434 */
435 static void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic)
436 {
437 const struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
438 u32 afe_status;
439 u32 phy_id;
440
441 /* Clear DFX Status registers */
442 writel(0x0081000f, &scic->scu_registers->afe.afe_dfx_master_control0);
443 udelay(AFE_REGISTER_WRITE_DELAY);
444
445 /* Configure bias currents to normal */
446 if (is_a0())
447 writel(0x00005500, &scic->scu_registers->afe.afe_bias_control);
448 else
449 writel(0x00005A00, &scic->scu_registers->afe.afe_bias_control);
450
451 udelay(AFE_REGISTER_WRITE_DELAY);
452
453 /* Enable PLL */
454 if (is_b0())
455 writel(0x80040A08, &scic->scu_registers->afe.afe_pll_control0);
456 else
457 writel(0x80040908, &scic->scu_registers->afe.afe_pll_control0);
458
459 udelay(AFE_REGISTER_WRITE_DELAY);
460
461 /* Wait for the PLL to lock */
462 do {
463 afe_status = readl(&scic->scu_registers->afe.afe_common_block_status);
464 udelay(AFE_REGISTER_WRITE_DELAY);
465 } while ((afe_status & 0x00001000) == 0);
466
467 if (is_b0()) {
468 /* Shorten SAS SNW lock time (RxLock timer value from 76 us to 50 us) */
469 writel(0x7bcc96ad, &scic->scu_registers->afe.afe_pmsn_master_control0);
470 udelay(AFE_REGISTER_WRITE_DELAY);
471 }
472
473 for (phy_id = 0; phy_id < SCI_MAX_PHYS; phy_id++) {
474 const struct sci_phy_oem_params *oem_phy = &oem->phys[phy_id];
475
476 if (is_b0()) {
477 /* Configure transmitter SSC parameters */
478 writel(0x00030000, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_ssc_control);
479 udelay(AFE_REGISTER_WRITE_DELAY);
480 } else {
481 /*
482 * All defaults, except the Receive Word Alignament/Comma Detect
483 * Enable....(0xe800) */
484 writel(0x00004512, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control0);
485 udelay(AFE_REGISTER_WRITE_DELAY);
486
487 writel(0x0050100F, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control1);
488 udelay(AFE_REGISTER_WRITE_DELAY);
489 }
490
491 /*
492 * Power up TX and RX out from power down (PWRDNTX and PWRDNRX)
493 * & increase TX int & ext bias 20%....(0xe85c) */
494 if (is_a0())
495 writel(0x000003D4, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control);
496 else if (is_a2())
497 writel(0x000003F0, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control);
498 else {
499 /* Power down TX and RX (PWRDNTX and PWRDNRX) */
500 writel(0x000003d7, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control);
501 udelay(AFE_REGISTER_WRITE_DELAY);
502
503 /*
504 * Power up TX and RX out from power down (PWRDNTX and PWRDNRX)
505 * & increase TX int & ext bias 20%....(0xe85c) */
506 writel(0x000003d4, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control);
507 }
508 udelay(AFE_REGISTER_WRITE_DELAY);
509
510 if (is_a0() || is_a2()) {
511 /* Enable TX equalization (0xe824) */
512 writel(0x00040000, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_control);
513 udelay(AFE_REGISTER_WRITE_DELAY);
514 }
515
516 /*
517 * RDPI=0x0(RX Power On), RXOOBDETPDNC=0x0, TPD=0x0(TX Power On),
518 * RDD=0x0(RX Detect Enabled) ....(0xe800) */
519 writel(0x00004100, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control0);
520 udelay(AFE_REGISTER_WRITE_DELAY);
521
522 /* Leave DFE/FFE on */
523 if (is_a0())
524 writel(0x3F09983F, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control0);
525 else if (is_a2())
526 writel(0x3F11103F, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control0);
527 else {
528 writel(0x3F11103F, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control0);
529 udelay(AFE_REGISTER_WRITE_DELAY);
530 /* Enable TX equalization (0xe824) */
531 writel(0x00040000, &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_control);
532 }
533 udelay(AFE_REGISTER_WRITE_DELAY);
534
535 writel(oem_phy->afe_tx_amp_control0,
536 &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control0);
537 udelay(AFE_REGISTER_WRITE_DELAY);
538
539 writel(oem_phy->afe_tx_amp_control1,
540 &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control1);
541 udelay(AFE_REGISTER_WRITE_DELAY);
542
543 writel(oem_phy->afe_tx_amp_control2,
544 &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control2);
545 udelay(AFE_REGISTER_WRITE_DELAY);
546
547 writel(oem_phy->afe_tx_amp_control3,
548 &scic->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control3);
549 udelay(AFE_REGISTER_WRITE_DELAY);
550 }
551
552 /* Transfer control to the PEs */
553 writel(0x00010f00, &scic->scu_registers->afe.afe_dfx_master_control0);
554 udelay(AFE_REGISTER_WRITE_DELAY);
555 }
556
557 /*
558 * ****************************************************************************-
559 * * SCIC SDS Controller Internal Start/Stop Routines
560 * ****************************************************************************- */
561
562
563 /**
564 * This method will attempt to transition into the ready state for the
565 * controller and indicate that the controller start operation has completed
566 * if all criteria are met.
567 * @this_controller: This parameter indicates the controller object for which
568 * to transition to ready.
569 * @status: This parameter indicates the status value to be pass into the call
570 * to scic_cb_controller_start_complete().
571 *
572 * none.
573 */
574 static void scic_sds_controller_transition_to_ready(
575 struct scic_sds_controller *scic,
576 enum sci_status status)
577 {
578 struct isci_host *ihost = sci_object_get_association(scic);
579
580 if (scic->state_machine.current_state_id ==
581 SCI_BASE_CONTROLLER_STATE_STARTING) {
582 /*
583 * We move into the ready state, because some of the phys/ports
584 * may be up and operational.
585 */
586 sci_base_state_machine_change_state(&scic->state_machine,
587 SCI_BASE_CONTROLLER_STATE_READY);
588
589 isci_host_start_complete(ihost, status);
590 }
591 }
592
593 static void scic_sds_controller_timeout_handler(void *_scic)
594 {
595 struct scic_sds_controller *scic = _scic;
596 struct isci_host *ihost = sci_object_get_association(scic);
597 struct sci_base_state_machine *sm = &scic->state_machine;
598
599 if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING)
600 scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT);
601 else if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STOPPING) {
602 sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_FAILED);
603 isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT);
604 } else /* / @todo Now what do we want to do in this case? */
605 dev_err(scic_to_dev(scic),
606 "%s: Controller timer fired when controller was not "
607 "in a state being timed.\n",
608 __func__);
609 }
610
611 static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller *scic)
612 {
613 u32 index;
614 enum sci_status port_status;
615 enum sci_status status = SCI_SUCCESS;
616
617 for (index = 0; index < scic->logical_port_entries; index++) {
618 struct scic_sds_port *sci_port = &scic->port_table[index];
619 scic_sds_port_handler_t stop;
620
621 stop = sci_port->state_handlers->stop_handler;
622 port_status = stop(sci_port);
623
624 if ((port_status != SCI_SUCCESS) &&
625 (port_status != SCI_FAILURE_INVALID_STATE)) {
626 status = SCI_FAILURE;
627
628 dev_warn(scic_to_dev(scic),
629 "%s: Controller stop operation failed to "
630 "stop port %d because of status %d.\n",
631 __func__,
632 sci_port->logical_port_index,
633 port_status);
634 }
635 }
636
637 return status;
638 }
639
640 static inline void scic_sds_controller_phy_timer_start(
641 struct scic_sds_controller *scic)
642 {
643 isci_timer_start(scic->phy_startup_timer,
644 SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT);
645
646 scic->phy_startup_timer_pending = true;
647 }
648
649 static void scic_sds_controller_phy_timer_stop(struct scic_sds_controller *scic)
650 {
651 isci_timer_stop(scic->phy_startup_timer);
652
653 scic->phy_startup_timer_pending = false;
654 }
655
656 /**
657 * scic_sds_controller_start_next_phy - start phy
658 * @scic: controller
659 *
660 * If all the phys have been started, then attempt to transition the
661 * controller to the READY state and inform the user
662 * (scic_cb_controller_start_complete()).
663 */
664 static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *scic)
665 {
666 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
667 struct scic_sds_phy *sci_phy;
668 enum sci_status status;
669
670 status = SCI_SUCCESS;
671
672 if (scic->phy_startup_timer_pending)
673 return status;
674
675 if (scic->next_phy_to_start >= SCI_MAX_PHYS) {
676 bool is_controller_start_complete = true;
677 u32 state;
678 u8 index;
679
680 for (index = 0; index < SCI_MAX_PHYS; index++) {
681 sci_phy = &scic->phy_table[index];
682 state = sci_phy->state_machine.current_state_id;
683
684 if (!scic_sds_phy_get_port(sci_phy))
685 continue;
686
687 /* The controller start operation is complete iff:
688 * - all links have been given an opportunity to start
689 * - have no indication of a connected device
690 * - have an indication of a connected device and it has
691 * finished the link training process.
692 */
693 if ((sci_phy->is_in_link_training == false &&
694 state == SCI_BASE_PHY_STATE_INITIAL) ||
695 (sci_phy->is_in_link_training == false &&
696 state == SCI_BASE_PHY_STATE_STOPPED) ||
697 (sci_phy->is_in_link_training == true &&
698 state == SCI_BASE_PHY_STATE_STARTING)) {
699 is_controller_start_complete = false;
700 break;
701 }
702 }
703
704 /*
705 * The controller has successfully finished the start process.
706 * Inform the SCI Core user and transition to the READY state. */
707 if (is_controller_start_complete == true) {
708 scic_sds_controller_transition_to_ready(scic, SCI_SUCCESS);
709 scic_sds_controller_phy_timer_stop(scic);
710 }
711 } else {
712 sci_phy = &scic->phy_table[scic->next_phy_to_start];
713
714 if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
715 if (scic_sds_phy_get_port(sci_phy) == NULL) {
716 scic->next_phy_to_start++;
717
718 /* Caution recursion ahead be forwarned
719 *
720 * The PHY was never added to a PORT in MPC mode
721 * so start the next phy in sequence This phy
722 * will never go link up and will not draw power
723 * the OEM parameters either configured the phy
724 * incorrectly for the PORT or it was never
725 * assigned to a PORT
726 */
727 return scic_sds_controller_start_next_phy(scic);
728 }
729 }
730
731 status = scic_sds_phy_start(sci_phy);
732
733 if (status == SCI_SUCCESS) {
734 scic_sds_controller_phy_timer_start(scic);
735 } else {
736 dev_warn(scic_to_dev(scic),
737 "%s: Controller stop operation failed "
738 "to stop phy %d because of status "
739 "%d.\n",
740 __func__,
741 scic->phy_table[scic->next_phy_to_start].phy_index,
742 status);
743 }
744
745 scic->next_phy_to_start++;
746 }
747
748 return status;
749 }
750
751 static void scic_sds_controller_phy_startup_timeout_handler(void *_scic)
752 {
753 struct scic_sds_controller *scic = _scic;
754 enum sci_status status;
755
756 scic->phy_startup_timer_pending = false;
757 status = SCI_FAILURE;
758 while (status != SCI_SUCCESS)
759 status = scic_sds_controller_start_next_phy(scic);
760 }
761
762 static enum sci_status scic_sds_controller_initialize_phy_startup(struct scic_sds_controller *scic)
763 {
764 struct isci_host *ihost = sci_object_get_association(scic);
765
766 scic->phy_startup_timer = isci_timer_create(ihost,
767 scic,
768 scic_sds_controller_phy_startup_timeout_handler);
769
770 if (scic->phy_startup_timer == NULL)
771 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
772 else {
773 scic->next_phy_to_start = 0;
774 scic->phy_startup_timer_pending = false;
775 }
776
777 return SCI_SUCCESS;
778 }
779
780 static enum sci_status scic_sds_controller_stop_phys(struct scic_sds_controller *scic)
781 {
782 u32 index;
783 enum sci_status status;
784 enum sci_status phy_status;
785
786 status = SCI_SUCCESS;
787
788 for (index = 0; index < SCI_MAX_PHYS; index++) {
789 phy_status = scic_sds_phy_stop(&scic->phy_table[index]);
790
791 if (
792 (phy_status != SCI_SUCCESS)
793 && (phy_status != SCI_FAILURE_INVALID_STATE)
794 ) {
795 status = SCI_FAILURE;
796
797 dev_warn(scic_to_dev(scic),
798 "%s: Controller stop operation failed to stop "
799 "phy %d because of status %d.\n",
800 __func__,
801 scic->phy_table[index].phy_index, phy_status);
802 }
803 }
804
805 return status;
806 }
807
808 static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controller *scic)
809 {
810 u32 index;
811 enum sci_status status;
812 enum sci_status device_status;
813
814 status = SCI_SUCCESS;
815
816 for (index = 0; index < scic->remote_node_entries; index++) {
817 if (scic->device_table[index] != NULL) {
818 /* / @todo What timeout value do we want to provide to this request? */
819 device_status = scic_remote_device_stop(scic->device_table[index], 0);
820
821 if ((device_status != SCI_SUCCESS) &&
822 (device_status != SCI_FAILURE_INVALID_STATE)) {
823 dev_warn(scic_to_dev(scic),
824 "%s: Controller stop operation failed "
825 "to stop device 0x%p because of "
826 "status %d.\n",
827 __func__,
828 scic->device_table[index], device_status);
829 }
830 }
831 }
832
833 return status;
834 }
835
836 static void scic_sds_controller_power_control_timer_start(struct scic_sds_controller *scic)
837 {
838 isci_timer_start(scic->power_control.timer,
839 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
840
841 scic->power_control.timer_started = true;
842 }
843
844 static void scic_sds_controller_power_control_timer_stop(struct scic_sds_controller *scic)
845 {
846 if (scic->power_control.timer_started) {
847 isci_timer_stop(scic->power_control.timer);
848 scic->power_control.timer_started = false;
849 }
850 }
851
852 static void scic_sds_controller_power_control_timer_restart(struct scic_sds_controller *scic)
853 {
854 scic_sds_controller_power_control_timer_stop(scic);
855 scic_sds_controller_power_control_timer_start(scic);
856 }
857
858 static void scic_sds_controller_power_control_timer_handler(
859 void *controller)
860 {
861 struct scic_sds_controller *this_controller;
862
863 this_controller = (struct scic_sds_controller *)controller;
864
865 this_controller->power_control.phys_granted_power = 0;
866
867 if (this_controller->power_control.phys_waiting == 0) {
868 this_controller->power_control.timer_started = false;
869 } else {
870 struct scic_sds_phy *the_phy = NULL;
871 u8 i;
872
873 for (i = 0;
874 (i < SCI_MAX_PHYS)
875 && (this_controller->power_control.phys_waiting != 0);
876 i++) {
877 if (this_controller->power_control.requesters[i] != NULL) {
878 if (this_controller->power_control.phys_granted_power <
879 this_controller->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
880 the_phy = this_controller->power_control.requesters[i];
881 this_controller->power_control.requesters[i] = NULL;
882 this_controller->power_control.phys_waiting--;
883 this_controller->power_control.phys_granted_power++;
884 scic_sds_phy_consume_power_handler(the_phy);
885 } else {
886 break;
887 }
888 }
889 }
890
891 /*
892 * It doesn't matter if the power list is empty, we need to start the
893 * timer in case another phy becomes ready.
894 */
895 scic_sds_controller_power_control_timer_start(this_controller);
896 }
897 }
898
899 /**
900 * This method inserts the phy in the stagger spinup control queue.
901 * @this_controller:
902 *
903 *
904 */
905 void scic_sds_controller_power_control_queue_insert(
906 struct scic_sds_controller *this_controller,
907 struct scic_sds_phy *the_phy)
908 {
909 BUG_ON(the_phy == NULL);
910
911 if (this_controller->power_control.phys_granted_power <
912 this_controller->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
913 this_controller->power_control.phys_granted_power++;
914 scic_sds_phy_consume_power_handler(the_phy);
915
916 /*
917 * stop and start the power_control timer. When the timer fires, the
918 * no_of_phys_granted_power will be set to 0
919 */
920 scic_sds_controller_power_control_timer_restart(this_controller);
921 } else {
922 /* Add the phy in the waiting list */
923 this_controller->power_control.requesters[the_phy->phy_index] = the_phy;
924 this_controller->power_control.phys_waiting++;
925 }
926 }
927
928 /**
929 * This method removes the phy from the stagger spinup control queue.
930 * @this_controller:
931 *
932 *
933 */
934 void scic_sds_controller_power_control_queue_remove(
935 struct scic_sds_controller *this_controller,
936 struct scic_sds_phy *the_phy)
937 {
938 BUG_ON(the_phy == NULL);
939
940 if (this_controller->power_control.requesters[the_phy->phy_index] != NULL) {
941 this_controller->power_control.phys_waiting--;
942 }
943
944 this_controller->power_control.requesters[the_phy->phy_index] = NULL;
945 }
946
947 /*
948 * ****************************************************************************-
949 * * SCIC SDS Controller Completion Routines
950 * ****************************************************************************- */
951
952 /**
953 * This method returns a true value if the completion queue has entries that
954 * can be processed
955 * @this_controller:
956 *
957 * bool true if the completion queue has entries to process false if the
958 * completion queue has no entries to process
959 */
960 static bool scic_sds_controller_completion_queue_has_entries(
961 struct scic_sds_controller *this_controller)
962 {
963 u32 get_value = this_controller->completion_queue_get;
964 u32 get_index = get_value & SMU_COMPLETION_QUEUE_GET_POINTER_MASK;
965
966 if (
967 NORMALIZE_GET_POINTER_CYCLE_BIT(get_value)
968 == COMPLETION_QUEUE_CYCLE_BIT(this_controller->completion_queue[get_index])
969 ) {
970 return true;
971 }
972
973 return false;
974 }
975
976 /**
977 * This method processes a task completion notification. This is called from
978 * within the controller completion handler.
979 * @this_controller:
980 * @completion_entry:
981 *
982 */
983 static void scic_sds_controller_task_completion(
984 struct scic_sds_controller *this_controller,
985 u32 completion_entry)
986 {
987 u32 index;
988 struct scic_sds_request *io_request;
989
990 index = SCU_GET_COMPLETION_INDEX(completion_entry);
991 io_request = this_controller->io_request_table[index];
992
993 /* Make sure that we really want to process this IO request */
994 if (
995 (io_request != NULL)
996 && (io_request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG)
997 && (
998 scic_sds_io_tag_get_sequence(io_request->io_tag)
999 == this_controller->io_request_sequence[index]
1000 )
1001 ) {
1002 /* Yep this is a valid io request pass it along to the io request handler */
1003 scic_sds_io_request_tc_completion(io_request, completion_entry);
1004 }
1005 }
1006
1007 /**
1008 * This method processes an SDMA completion event. This is called from within
1009 * the controller completion handler.
1010 * @this_controller:
1011 * @completion_entry:
1012 *
1013 */
1014 static void scic_sds_controller_sdma_completion(
1015 struct scic_sds_controller *this_controller,
1016 u32 completion_entry)
1017 {
1018 u32 index;
1019 struct scic_sds_request *io_request;
1020 struct scic_sds_remote_device *device;
1021
1022 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1023
1024 switch (scu_get_command_request_type(completion_entry)) {
1025 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC:
1026 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC:
1027 io_request = this_controller->io_request_table[index];
1028 dev_warn(scic_to_dev(this_controller),
1029 "%s: SCIC SDS Completion type SDMA %x for io request "
1030 "%p\n",
1031 __func__,
1032 completion_entry,
1033 io_request);
1034 /* @todo For a post TC operation we need to fail the IO
1035 * request
1036 */
1037 break;
1038
1039 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC:
1040 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC:
1041 case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC:
1042 device = this_controller->device_table[index];
1043 dev_warn(scic_to_dev(this_controller),
1044 "%s: SCIC SDS Completion type SDMA %x for remote "
1045 "device %p\n",
1046 __func__,
1047 completion_entry,
1048 device);
1049 /* @todo For a port RNC operation we need to fail the
1050 * device
1051 */
1052 break;
1053
1054 default:
1055 dev_warn(scic_to_dev(this_controller),
1056 "%s: SCIC SDS Completion unknown SDMA completion "
1057 "type %x\n",
1058 __func__,
1059 completion_entry);
1060 break;
1061
1062 }
1063 }
1064
1065 /**
1066 *
1067 * @this_controller:
1068 * @completion_entry:
1069 *
1070 * This method processes an unsolicited frame message. This is called from
1071 * within the controller completion handler. none
1072 */
1073 static void scic_sds_controller_unsolicited_frame(
1074 struct scic_sds_controller *this_controller,
1075 u32 completion_entry)
1076 {
1077 u32 index;
1078 u32 frame_index;
1079
1080 struct scu_unsolicited_frame_header *frame_header;
1081 struct scic_sds_phy *phy;
1082 struct scic_sds_remote_device *device;
1083
1084 enum sci_status result = SCI_FAILURE;
1085
1086 frame_index = SCU_GET_FRAME_INDEX(completion_entry);
1087
1088 frame_header
1089 = this_controller->uf_control.buffers.array[frame_index].header;
1090 this_controller->uf_control.buffers.array[frame_index].state
1091 = UNSOLICITED_FRAME_IN_USE;
1092
1093 if (SCU_GET_FRAME_ERROR(completion_entry)) {
1094 /*
1095 * / @todo If the IAF frame or SIGNATURE FIS frame has an error will
1096 * / this cause a problem? We expect the phy initialization will
1097 * / fail if there is an error in the frame. */
1098 scic_sds_controller_release_frame(this_controller, frame_index);
1099 return;
1100 }
1101
1102 if (frame_header->is_address_frame) {
1103 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1104 phy = &this_controller->phy_table[index];
1105 if (phy != NULL) {
1106 result = scic_sds_phy_frame_handler(phy, frame_index);
1107 }
1108 } else {
1109
1110 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1111
1112 if (index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
1113 /*
1114 * This is a signature fis or a frame from a direct attached SATA
1115 * device that has not yet been created. In either case forwared
1116 * the frame to the PE and let it take care of the frame data. */
1117 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1118 phy = &this_controller->phy_table[index];
1119 result = scic_sds_phy_frame_handler(phy, frame_index);
1120 } else {
1121 if (index < this_controller->remote_node_entries)
1122 device = this_controller->device_table[index];
1123 else
1124 device = NULL;
1125
1126 if (device != NULL)
1127 result = scic_sds_remote_device_frame_handler(device, frame_index);
1128 else
1129 scic_sds_controller_release_frame(this_controller, frame_index);
1130 }
1131 }
1132
1133 if (result != SCI_SUCCESS) {
1134 /*
1135 * / @todo Is there any reason to report some additional error message
1136 * / when we get this failure notifiction? */
1137 }
1138 }
1139
1140 /**
1141 * This method processes an event completion entry. This is called from within
1142 * the controller completion handler.
1143 * @this_controller:
1144 * @completion_entry:
1145 *
1146 */
1147 static void scic_sds_controller_event_completion(
1148 struct scic_sds_controller *this_controller,
1149 u32 completion_entry)
1150 {
1151 u32 index;
1152 struct scic_sds_request *io_request;
1153 struct scic_sds_remote_device *device;
1154 struct scic_sds_phy *phy;
1155
1156 index = SCU_GET_COMPLETION_INDEX(completion_entry);
1157
1158 switch (scu_get_event_type(completion_entry)) {
1159 case SCU_EVENT_TYPE_SMU_COMMAND_ERROR:
1160 /* / @todo The driver did something wrong and we need to fix the condtion. */
1161 dev_err(scic_to_dev(this_controller),
1162 "%s: SCIC Controller 0x%p received SMU command error "
1163 "0x%x\n",
1164 __func__,
1165 this_controller,
1166 completion_entry);
1167 break;
1168
1169 case SCU_EVENT_TYPE_SMU_PCQ_ERROR:
1170 case SCU_EVENT_TYPE_SMU_ERROR:
1171 case SCU_EVENT_TYPE_FATAL_MEMORY_ERROR:
1172 /*
1173 * / @todo This is a hardware failure and its likely that we want to
1174 * / reset the controller. */
1175 dev_err(scic_to_dev(this_controller),
1176 "%s: SCIC Controller 0x%p received fatal controller "
1177 "event 0x%x\n",
1178 __func__,
1179 this_controller,
1180 completion_entry);
1181 break;
1182
1183 case SCU_EVENT_TYPE_TRANSPORT_ERROR:
1184 io_request = this_controller->io_request_table[index];
1185 scic_sds_io_request_event_handler(io_request, completion_entry);
1186 break;
1187
1188 case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
1189 switch (scu_get_event_specifier(completion_entry)) {
1190 case SCU_EVENT_SPECIFIC_SMP_RESPONSE_NO_PE:
1191 case SCU_EVENT_SPECIFIC_TASK_TIMEOUT:
1192 io_request = this_controller->io_request_table[index];
1193 if (io_request != NULL)
1194 scic_sds_io_request_event_handler(io_request, completion_entry);
1195 else
1196 dev_warn(scic_to_dev(this_controller),
1197 "%s: SCIC Controller 0x%p received "
1198 "event 0x%x for io request object "
1199 "that doesnt exist.\n",
1200 __func__,
1201 this_controller,
1202 completion_entry);
1203
1204 break;
1205
1206 case SCU_EVENT_SPECIFIC_IT_NEXUS_TIMEOUT:
1207 device = this_controller->device_table[index];
1208 if (device != NULL)
1209 scic_sds_remote_device_event_handler(device, completion_entry);
1210 else
1211 dev_warn(scic_to_dev(this_controller),
1212 "%s: SCIC Controller 0x%p received "
1213 "event 0x%x for remote device object "
1214 "that doesnt exist.\n",
1215 __func__,
1216 this_controller,
1217 completion_entry);
1218
1219 break;
1220 }
1221 break;
1222
1223 case SCU_EVENT_TYPE_BROADCAST_CHANGE:
1224 /*
1225 * direct the broadcast change event to the phy first and then let
1226 * the phy redirect the broadcast change to the port object */
1227 case SCU_EVENT_TYPE_ERR_CNT_EVENT:
1228 /*
1229 * direct error counter event to the phy object since that is where
1230 * we get the event notification. This is a type 4 event. */
1231 case SCU_EVENT_TYPE_OSSP_EVENT:
1232 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
1233 phy = &this_controller->phy_table[index];
1234 scic_sds_phy_event_handler(phy, completion_entry);
1235 break;
1236
1237 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
1238 case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
1239 case SCU_EVENT_TYPE_RNC_OPS_MISC:
1240 if (index < this_controller->remote_node_entries) {
1241 device = this_controller->device_table[index];
1242
1243 if (device != NULL)
1244 scic_sds_remote_device_event_handler(device, completion_entry);
1245 } else
1246 dev_err(scic_to_dev(this_controller),
1247 "%s: SCIC Controller 0x%p received event 0x%x "
1248 "for remote device object 0x%0x that doesnt "
1249 "exist.\n",
1250 __func__,
1251 this_controller,
1252 completion_entry,
1253 index);
1254
1255 break;
1256
1257 default:
1258 dev_warn(scic_to_dev(this_controller),
1259 "%s: SCIC Controller received unknown event code %x\n",
1260 __func__,
1261 completion_entry);
1262 break;
1263 }
1264 }
1265
1266 /**
1267 * This method is a private routine for processing the completion queue entries.
1268 * @this_controller:
1269 *
1270 */
1271 static void scic_sds_controller_process_completions(
1272 struct scic_sds_controller *this_controller)
1273 {
1274 u32 completion_count = 0;
1275 u32 completion_entry;
1276 u32 get_index;
1277 u32 get_cycle;
1278 u32 event_index;
1279 u32 event_cycle;
1280
1281 dev_dbg(scic_to_dev(this_controller),
1282 "%s: completion queue begining get:0x%08x\n",
1283 __func__,
1284 this_controller->completion_queue_get);
1285
1286 /* Get the component parts of the completion queue */
1287 get_index = NORMALIZE_GET_POINTER(this_controller->completion_queue_get);
1288 get_cycle = SMU_CQGR_CYCLE_BIT & this_controller->completion_queue_get;
1289
1290 event_index = NORMALIZE_EVENT_POINTER(this_controller->completion_queue_get);
1291 event_cycle = SMU_CQGR_EVENT_CYCLE_BIT & this_controller->completion_queue_get;
1292
1293 while (
1294 NORMALIZE_GET_POINTER_CYCLE_BIT(get_cycle)
1295 == COMPLETION_QUEUE_CYCLE_BIT(this_controller->completion_queue[get_index])
1296 ) {
1297 completion_count++;
1298
1299 completion_entry = this_controller->completion_queue[get_index];
1300 INCREMENT_COMPLETION_QUEUE_GET(this_controller, get_index, get_cycle);
1301
1302 dev_dbg(scic_to_dev(this_controller),
1303 "%s: completion queue entry:0x%08x\n",
1304 __func__,
1305 completion_entry);
1306
1307 switch (SCU_GET_COMPLETION_TYPE(completion_entry)) {
1308 case SCU_COMPLETION_TYPE_TASK:
1309 scic_sds_controller_task_completion(this_controller, completion_entry);
1310 break;
1311
1312 case SCU_COMPLETION_TYPE_SDMA:
1313 scic_sds_controller_sdma_completion(this_controller, completion_entry);
1314 break;
1315
1316 case SCU_COMPLETION_TYPE_UFI:
1317 scic_sds_controller_unsolicited_frame(this_controller, completion_entry);
1318 break;
1319
1320 case SCU_COMPLETION_TYPE_EVENT:
1321 INCREMENT_EVENT_QUEUE_GET(this_controller, event_index, event_cycle);
1322 scic_sds_controller_event_completion(this_controller, completion_entry);
1323 break;
1324
1325 case SCU_COMPLETION_TYPE_NOTIFY:
1326 /*
1327 * Presently we do the same thing with a notify event that we do with the
1328 * other event codes. */
1329 INCREMENT_EVENT_QUEUE_GET(this_controller, event_index, event_cycle);
1330 scic_sds_controller_event_completion(this_controller, completion_entry);
1331 break;
1332
1333 default:
1334 dev_warn(scic_to_dev(this_controller),
1335 "%s: SCIC Controller received unknown "
1336 "completion type %x\n",
1337 __func__,
1338 completion_entry);
1339 break;
1340 }
1341 }
1342
1343 /* Update the get register if we completed one or more entries */
1344 if (completion_count > 0) {
1345 this_controller->completion_queue_get =
1346 SMU_CQGR_GEN_BIT(ENABLE)
1347 | SMU_CQGR_GEN_BIT(EVENT_ENABLE)
1348 | event_cycle | SMU_CQGR_GEN_VAL(EVENT_POINTER, event_index)
1349 | get_cycle | SMU_CQGR_GEN_VAL(POINTER, get_index);
1350
1351 writel(this_controller->completion_queue_get,
1352 &this_controller->smu_registers->completion_queue_get);
1353
1354 }
1355
1356 dev_dbg(scic_to_dev(this_controller),
1357 "%s: completion queue ending get:0x%08x\n",
1358 __func__,
1359 this_controller->completion_queue_get);
1360
1361 }
1362
1363 bool scic_sds_controller_isr(struct scic_sds_controller *scic)
1364 {
1365 if (scic_sds_controller_completion_queue_has_entries(scic)) {
1366 return true;
1367 } else {
1368 /*
1369 * we have a spurious interrupt it could be that we have already
1370 * emptied the completion queue from a previous interrupt */
1371 writel(SMU_ISR_COMPLETION, &scic->smu_registers->interrupt_status);
1372
1373 /*
1374 * There is a race in the hardware that could cause us not to be notified
1375 * of an interrupt completion if we do not take this step. We will mask
1376 * then unmask the interrupts so if there is another interrupt pending
1377 * the clearing of the interrupt source we get the next interrupt message. */
1378 writel(0xFF000000, &scic->smu_registers->interrupt_mask);
1379 writel(0, &scic->smu_registers->interrupt_mask);
1380 }
1381
1382 return false;
1383 }
1384
1385 void scic_sds_controller_completion_handler(struct scic_sds_controller *scic)
1386 {
1387 /* Empty out the completion queue */
1388 if (scic_sds_controller_completion_queue_has_entries(scic))
1389 scic_sds_controller_process_completions(scic);
1390
1391 /* Clear the interrupt and enable all interrupts again */
1392 writel(SMU_ISR_COMPLETION, &scic->smu_registers->interrupt_status);
1393 /* Could we write the value of SMU_ISR_COMPLETION? */
1394 writel(0xFF000000, &scic->smu_registers->interrupt_mask);
1395 writel(0, &scic->smu_registers->interrupt_mask);
1396 }
1397
1398 bool scic_sds_controller_error_isr(struct scic_sds_controller *scic)
1399 {
1400 u32 interrupt_status;
1401
1402 interrupt_status =
1403 readl(&scic->smu_registers->interrupt_status);
1404 interrupt_status &= (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND);
1405
1406 if (interrupt_status != 0) {
1407 /*
1408 * There is an error interrupt pending so let it through and handle
1409 * in the callback */
1410 return true;
1411 }
1412
1413 /*
1414 * There is a race in the hardware that could cause us not to be notified
1415 * of an interrupt completion if we do not take this step. We will mask
1416 * then unmask the error interrupts so if there was another interrupt
1417 * pending we will be notified.
1418 * Could we write the value of (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND)? */
1419 writel(0xff, &scic->smu_registers->interrupt_mask);
1420 writel(0, &scic->smu_registers->interrupt_mask);
1421
1422 return false;
1423 }
1424
1425 void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
1426 {
1427 u32 interrupt_status;
1428
1429 interrupt_status =
1430 readl(&scic->smu_registers->interrupt_status);
1431
1432 if ((interrupt_status & SMU_ISR_QUEUE_SUSPEND) &&
1433 scic_sds_controller_completion_queue_has_entries(scic)) {
1434
1435 scic_sds_controller_process_completions(scic);
1436 writel(SMU_ISR_QUEUE_SUSPEND, &scic->smu_registers->interrupt_status);
1437 } else {
1438 dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
1439 interrupt_status);
1440
1441 sci_base_state_machine_change_state(&scic->state_machine,
1442 SCI_BASE_CONTROLLER_STATE_FAILED);
1443
1444 return;
1445 }
1446
1447 /* If we dont process any completions I am not sure that we want to do this.
1448 * We are in the middle of a hardware fault and should probably be reset.
1449 */
1450 writel(0, &scic->smu_registers->interrupt_mask);
1451 }
1452
1453
1454
1455
1456 void scic_sds_controller_link_up(struct scic_sds_controller *scic,
1457 struct scic_sds_port *port, struct scic_sds_phy *phy)
1458 {
1459 switch (scic->state_machine.current_state_id) {
1460 case SCI_BASE_CONTROLLER_STATE_STARTING:
1461 scic_sds_controller_phy_timer_stop(scic);
1462 scic->port_agent.link_up_handler(scic, &scic->port_agent,
1463 port, phy);
1464 scic_sds_controller_start_next_phy(scic);
1465 break;
1466 case SCI_BASE_CONTROLLER_STATE_READY:
1467 scic->port_agent.link_up_handler(scic, &scic->port_agent,
1468 port, phy);
1469 break;
1470 default:
1471 dev_dbg(scic_to_dev(scic),
1472 "%s: SCIC Controller linkup event from phy %d in "
1473 "unexpected state %d\n", __func__, phy->phy_index,
1474 scic->state_machine.current_state_id);
1475 }
1476 }
1477
1478 void scic_sds_controller_link_down(struct scic_sds_controller *scic,
1479 struct scic_sds_port *port, struct scic_sds_phy *phy)
1480 {
1481 switch (scic->state_machine.current_state_id) {
1482 case SCI_BASE_CONTROLLER_STATE_STARTING:
1483 case SCI_BASE_CONTROLLER_STATE_READY:
1484 scic->port_agent.link_down_handler(scic, &scic->port_agent,
1485 port, phy);
1486 break;
1487 default:
1488 dev_dbg(scic_to_dev(scic),
1489 "%s: SCIC Controller linkdown event from phy %d in "
1490 "unexpected state %d\n",
1491 __func__,
1492 phy->phy_index,
1493 scic->state_machine.current_state_id);
1494 }
1495 }
1496
1497 /**
1498 * This is a helper method to determine if any remote devices on this
1499 * controller are still in the stopping state.
1500 *
1501 */
1502 static bool scic_sds_controller_has_remote_devices_stopping(
1503 struct scic_sds_controller *controller)
1504 {
1505 u32 index;
1506
1507 for (index = 0; index < controller->remote_node_entries; index++) {
1508 if ((controller->device_table[index] != NULL) &&
1509 (controller->device_table[index]->state_machine.current_state_id
1510 == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING))
1511 return true;
1512 }
1513
1514 return false;
1515 }
1516
1517 /**
1518 * This method is called by the remote device to inform the controller
1519 * object that the remote device has stopped.
1520 */
1521 void scic_sds_controller_remote_device_stopped(struct scic_sds_controller *scic,
1522 struct scic_sds_remote_device *sci_dev)
1523 {
1524 if (scic->state_machine.current_state_id !=
1525 SCI_BASE_CONTROLLER_STATE_STOPPING) {
1526 dev_dbg(scic_to_dev(scic),
1527 "SCIC Controller 0x%p remote device stopped event "
1528 "from device 0x%p in unexpected state %d\n",
1529 scic, sci_dev,
1530 scic->state_machine.current_state_id);
1531 return;
1532 }
1533
1534 if (!scic_sds_controller_has_remote_devices_stopping(scic)) {
1535 sci_base_state_machine_change_state(&scic->state_machine,
1536 SCI_BASE_CONTROLLER_STATE_STOPPED);
1537 }
1538 }
1539
1540 /**
1541 * This method will write to the SCU PCP register the request value. The method
1542 * is used to suspend/resume ports, devices, and phys.
1543 * @this_controller:
1544 *
1545 *
1546 */
1547 void scic_sds_controller_post_request(
1548 struct scic_sds_controller *this_controller,
1549 u32 request)
1550 {
1551 dev_dbg(scic_to_dev(this_controller),
1552 "%s: SCIC Controller 0x%p post request 0x%08x\n",
1553 __func__,
1554 this_controller,
1555 request);
1556
1557 writel(request, &this_controller->smu_registers->post_context_port);
1558 }
1559
1560 /**
1561 * This method will copy the soft copy of the task context into the physical
1562 * memory accessible by the controller.
1563 * @this_controller: This parameter specifies the controller for which to copy
1564 * the task context.
1565 * @this_request: This parameter specifies the request for which the task
1566 * context is being copied.
1567 *
1568 * After this call is made the SCIC_SDS_IO_REQUEST object will always point to
1569 * the physical memory version of the task context. Thus, all subsequent
1570 * updates to the task context are performed in the TC table (i.e. DMAable
1571 * memory). none
1572 */
1573 void scic_sds_controller_copy_task_context(
1574 struct scic_sds_controller *this_controller,
1575 struct scic_sds_request *this_request)
1576 {
1577 struct scu_task_context *task_context_buffer;
1578
1579 task_context_buffer = scic_sds_controller_get_task_context_buffer(
1580 this_controller, this_request->io_tag
1581 );
1582
1583 memcpy(
1584 task_context_buffer,
1585 this_request->task_context_buffer,
1586 SCI_FIELD_OFFSET(struct scu_task_context, sgl_snapshot_ac)
1587 );
1588
1589 /*
1590 * Now that the soft copy of the TC has been copied into the TC
1591 * table accessible by the silicon. Thus, any further changes to
1592 * the TC (e.g. TC termination) occur in the appropriate location. */
1593 this_request->task_context_buffer = task_context_buffer;
1594 }
1595
1596 /**
1597 * This method returns the task context buffer for the given io tag.
1598 * @this_controller:
1599 * @io_tag:
1600 *
1601 * struct scu_task_context*
1602 */
1603 struct scu_task_context *scic_sds_controller_get_task_context_buffer(
1604 struct scic_sds_controller *this_controller,
1605 u16 io_tag
1606 ) {
1607 u16 task_index = scic_sds_io_tag_get_index(io_tag);
1608
1609 if (task_index < this_controller->task_context_entries) {
1610 return &this_controller->task_context_table[task_index];
1611 }
1612
1613 return NULL;
1614 }
1615
1616 /**
1617 * This method returnst the sequence value from the io tag value
1618 * @this_controller:
1619 * @io_tag:
1620 *
1621 * u16
1622 */
1623
1624 /**
1625 * This method returns the IO request associated with the tag value
1626 * @this_controller:
1627 * @io_tag:
1628 *
1629 * SCIC_SDS_IO_REQUEST_T* NULL if there is no valid IO request at the tag value
1630 */
1631 struct scic_sds_request *scic_sds_controller_get_io_request_from_tag(
1632 struct scic_sds_controller *this_controller,
1633 u16 io_tag
1634 ) {
1635 u16 task_index;
1636 u16 task_sequence;
1637
1638 task_index = scic_sds_io_tag_get_index(io_tag);
1639
1640 if (task_index < this_controller->task_context_entries) {
1641 if (this_controller->io_request_table[task_index] != NULL) {
1642 task_sequence = scic_sds_io_tag_get_sequence(io_tag);
1643
1644 if (task_sequence == this_controller->io_request_sequence[task_index]) {
1645 return this_controller->io_request_table[task_index];
1646 }
1647 }
1648 }
1649
1650 return NULL;
1651 }
1652
1653 /**
1654 * This method allocates remote node index and the reserves the remote node
1655 * context space for use. This method can fail if there are no more remote
1656 * node index available.
1657 * @this_controller: This is the controller object which contains the set of
1658 * free remote node ids
1659 * @the_devce: This is the device object which is requesting the a remote node
1660 * id
1661 * @node_id: This is the remote node id that is assinged to the device if one
1662 * is available
1663 *
1664 * enum sci_status SCI_FAILURE_OUT_OF_RESOURCES if there are no available remote
1665 * node index available.
1666 */
1667 enum sci_status scic_sds_controller_allocate_remote_node_context(
1668 struct scic_sds_controller *this_controller,
1669 struct scic_sds_remote_device *the_device,
1670 u16 *node_id)
1671 {
1672 u16 node_index;
1673 u32 remote_node_count = scic_sds_remote_device_node_count(the_device);
1674
1675 node_index = scic_sds_remote_node_table_allocate_remote_node(
1676 &this_controller->available_remote_nodes, remote_node_count
1677 );
1678
1679 if (node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
1680 this_controller->device_table[node_index] = the_device;
1681
1682 *node_id = node_index;
1683
1684 return SCI_SUCCESS;
1685 }
1686
1687 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
1688 }
1689
1690 /**
1691 * This method frees the remote node index back to the available pool. Once
1692 * this is done the remote node context buffer is no longer valid and can
1693 * not be used.
1694 * @this_controller:
1695 * @the_device:
1696 * @node_id:
1697 *
1698 */
1699 void scic_sds_controller_free_remote_node_context(
1700 struct scic_sds_controller *this_controller,
1701 struct scic_sds_remote_device *the_device,
1702 u16 node_id)
1703 {
1704 u32 remote_node_count = scic_sds_remote_device_node_count(the_device);
1705
1706 if (this_controller->device_table[node_id] == the_device) {
1707 this_controller->device_table[node_id] = NULL;
1708
1709 scic_sds_remote_node_table_release_remote_node_index(
1710 &this_controller->available_remote_nodes, remote_node_count, node_id
1711 );
1712 }
1713 }
1714
1715 /**
1716 * This method returns the union scu_remote_node_context for the specified remote
1717 * node id.
1718 * @this_controller:
1719 * @node_id:
1720 *
1721 * union scu_remote_node_context*
1722 */
1723 union scu_remote_node_context *scic_sds_controller_get_remote_node_context_buffer(
1724 struct scic_sds_controller *this_controller,
1725 u16 node_id
1726 ) {
1727 if (
1728 (node_id < this_controller->remote_node_entries)
1729 && (this_controller->device_table[node_id] != NULL)
1730 ) {
1731 return &this_controller->remote_node_context_table[node_id];
1732 }
1733
1734 return NULL;
1735 }
1736
1737 /**
1738 *
1739 * @resposne_buffer: This is the buffer into which the D2H register FIS will be
1740 * constructed.
1741 * @frame_header: This is the frame header returned by the hardware.
1742 * @frame_buffer: This is the frame buffer returned by the hardware.
1743 *
1744 * This method will combind the frame header and frame buffer to create a SATA
1745 * D2H register FIS none
1746 */
1747 void scic_sds_controller_copy_sata_response(
1748 void *response_buffer,
1749 void *frame_header,
1750 void *frame_buffer)
1751 {
1752 memcpy(
1753 response_buffer,
1754 frame_header,
1755 sizeof(u32)
1756 );
1757
1758 memcpy(
1759 (char *)((char *)response_buffer + sizeof(u32)),
1760 frame_buffer,
1761 sizeof(struct sata_fis_reg_d2h) - sizeof(u32)
1762 );
1763 }
1764
1765 /**
1766 * This method releases the frame once this is done the frame is available for
1767 * re-use by the hardware. The data contained in the frame header and frame
1768 * buffer is no longer valid. The UF queue get pointer is only updated if UF
1769 * control indicates this is appropriate.
1770 * @this_controller:
1771 * @frame_index:
1772 *
1773 */
1774 void scic_sds_controller_release_frame(
1775 struct scic_sds_controller *this_controller,
1776 u32 frame_index)
1777 {
1778 if (scic_sds_unsolicited_frame_control_release_frame(
1779 &this_controller->uf_control, frame_index) == true)
1780 writel(this_controller->uf_control.get,
1781 &this_controller->scu_registers->sdma.unsolicited_frame_get_pointer);
1782 }
1783
1784 /**
1785 * This method sets user parameters and OEM parameters to default values.
1786 * Users can override these values utilizing the scic_user_parameters_set()
1787 * and scic_oem_parameters_set() methods.
1788 * @scic: This parameter specifies the controller for which to set the
1789 * configuration parameters to their default values.
1790 *
1791 */
1792 static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic)
1793 {
1794 struct isci_host *ihost = sci_object_get_association(scic);
1795 u16 index;
1796
1797 /* Default to APC mode. */
1798 scic->oem_parameters.sds1.controller.mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE;
1799
1800 /* Default to APC mode. */
1801 scic->oem_parameters.sds1.controller.max_concurrent_dev_spin_up = 1;
1802
1803 /* Default to no SSC operation. */
1804 scic->oem_parameters.sds1.controller.do_enable_ssc = false;
1805
1806 /* Initialize all of the port parameter information to narrow ports. */
1807 for (index = 0; index < SCI_MAX_PORTS; index++) {
1808 scic->oem_parameters.sds1.ports[index].phy_mask = 0;
1809 }
1810
1811 /* Initialize all of the phy parameter information. */
1812 for (index = 0; index < SCI_MAX_PHYS; index++) {
1813 /* Default to 6G (i.e. Gen 3) for now. */
1814 scic->user_parameters.sds1.phys[index].max_speed_generation = 3;
1815
1816 /* the frequencies cannot be 0 */
1817 scic->user_parameters.sds1.phys[index].align_insertion_frequency = 0x7f;
1818 scic->user_parameters.sds1.phys[index].in_connection_align_insertion_frequency = 0xff;
1819 scic->user_parameters.sds1.phys[index].notify_enable_spin_up_insertion_frequency = 0x33;
1820
1821 /*
1822 * Previous Vitesse based expanders had a arbitration issue that
1823 * is worked around by having the upper 32-bits of SAS address
1824 * with a value greater then the Vitesse company identifier.
1825 * Hence, usage of 0x5FCFFFFF. */
1826 scic->oem_parameters.sds1.phys[index].sas_address.low = 0x1 + ihost->id;
1827 scic->oem_parameters.sds1.phys[index].sas_address.high = 0x5FCFFFFF;
1828 }
1829
1830 scic->user_parameters.sds1.stp_inactivity_timeout = 5;
1831 scic->user_parameters.sds1.ssp_inactivity_timeout = 5;
1832 scic->user_parameters.sds1.stp_max_occupancy_timeout = 5;
1833 scic->user_parameters.sds1.ssp_max_occupancy_timeout = 20;
1834 scic->user_parameters.sds1.no_outbound_task_timeout = 20;
1835 }
1836
1837 /**
1838 * scic_controller_get_suggested_start_timeout() - This method returns the
1839 * suggested scic_controller_start() timeout amount. The user is free to
1840 * use any timeout value, but this method provides the suggested minimum
1841 * start timeout value. The returned value is based upon empirical
1842 * information determined as a result of interoperability testing.
1843 * @controller: the handle to the controller object for which to return the
1844 * suggested start timeout.
1845 *
1846 * This method returns the number of milliseconds for the suggested start
1847 * operation timeout.
1848 */
1849 u32 scic_controller_get_suggested_start_timeout(
1850 struct scic_sds_controller *sc)
1851 {
1852 /* Validate the user supplied parameters. */
1853 if (sc == NULL)
1854 return 0;
1855
1856 /*
1857 * The suggested minimum timeout value for a controller start operation:
1858 *
1859 * Signature FIS Timeout
1860 * + Phy Start Timeout
1861 * + Number of Phy Spin Up Intervals
1862 * ---------------------------------
1863 * Number of milliseconds for the controller start operation.
1864 *
1865 * NOTE: The number of phy spin up intervals will be equivalent
1866 * to the number of phys divided by the number phys allowed
1867 * per interval - 1 (once OEM parameters are supported).
1868 * Currently we assume only 1 phy per interval. */
1869
1870 return SCIC_SDS_SIGNATURE_FIS_TIMEOUT
1871 + SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT
1872 + ((SCI_MAX_PHYS - 1) * SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
1873 }
1874
1875 /**
1876 * scic_controller_stop() - This method will stop an individual controller
1877 * object.This method will invoke the associated user callback upon
1878 * completion. The completion callback is called when the following
1879 * conditions are met: -# the method return status is SCI_SUCCESS. -# the
1880 * controller has been quiesced. This method will ensure that all IO
1881 * requests are quiesced, phys are stopped, and all additional operation by
1882 * the hardware is halted.
1883 * @controller: the handle to the controller object to stop.
1884 * @timeout: This parameter specifies the number of milliseconds in which the
1885 * stop operation should complete.
1886 *
1887 * The controller must be in the STARTED or STOPPED state. Indicate if the
1888 * controller stop method succeeded or failed in some way. SCI_SUCCESS if the
1889 * stop operation successfully began. SCI_WARNING_ALREADY_IN_STATE if the
1890 * controller is already in the STOPPED state. SCI_FAILURE_INVALID_STATE if the
1891 * controller is not either in the STARTED or STOPPED states.
1892 */
1893 enum sci_status scic_controller_stop(
1894 struct scic_sds_controller *scic,
1895 u32 timeout)
1896 {
1897 if (scic->state_machine.current_state_id !=
1898 SCI_BASE_CONTROLLER_STATE_READY) {
1899 dev_warn(scic_to_dev(scic),
1900 "SCIC Controller stop operation requested in "
1901 "invalid state\n");
1902 return SCI_FAILURE_INVALID_STATE;
1903 }
1904
1905 isci_timer_start(scic->timeout_timer, timeout);
1906 sci_base_state_machine_change_state(&scic->state_machine,
1907 SCI_BASE_CONTROLLER_STATE_STOPPING);
1908 return SCI_SUCCESS;
1909 }
1910
1911 /**
1912 * scic_controller_reset() - This method will reset the supplied core
1913 * controller regardless of the state of said controller. This operation is
1914 * considered destructive. In other words, all current operations are wiped
1915 * out. No IO completions for outstanding devices occur. Outstanding IO
1916 * requests are not aborted or completed at the actual remote device.
1917 * @controller: the handle to the controller object to reset.
1918 *
1919 * Indicate if the controller reset method succeeded or failed in some way.
1920 * SCI_SUCCESS if the reset operation successfully started. SCI_FATAL_ERROR if
1921 * the controller reset operation is unable to complete.
1922 */
1923 enum sci_status scic_controller_reset(
1924 struct scic_sds_controller *scic)
1925 {
1926 switch (scic->state_machine.current_state_id) {
1927 case SCI_BASE_CONTROLLER_STATE_RESET:
1928 case SCI_BASE_CONTROLLER_STATE_READY:
1929 case SCI_BASE_CONTROLLER_STATE_STOPPED:
1930 case SCI_BASE_CONTROLLER_STATE_FAILED:
1931 /*
1932 * The reset operation is not a graceful cleanup, just
1933 * perform the state transition.
1934 */
1935 sci_base_state_machine_change_state(&scic->state_machine,
1936 SCI_BASE_CONTROLLER_STATE_RESETTING);
1937 return SCI_SUCCESS;
1938 default:
1939 dev_warn(scic_to_dev(scic),
1940 "SCIC Controller reset operation requested in "
1941 "invalid state\n");
1942 return SCI_FAILURE_INVALID_STATE;
1943 }
1944 }
1945
1946 /**
1947 * scic_controller_start_io() - This method is called by the SCI user to
1948 * send/start an IO request. If the method invocation is successful, then
1949 * the IO request has been queued to the hardware for processing.
1950 * @controller: the handle to the controller object for which to start an IO
1951 * request.
1952 * @remote_device: the handle to the remote device object for which to start an
1953 * IO request.
1954 * @io_request: the handle to the io request object to start.
1955 * @io_tag: This parameter specifies a previously allocated IO tag that the
1956 * user desires to be utilized for this request. This parameter is optional.
1957 * The user is allowed to supply SCI_CONTROLLER_INVALID_IO_TAG as the value
1958 * for this parameter.
1959 *
1960 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
1961 * to ensure that each of the methods that may allocate or free available IO
1962 * tags are handled in a mutually exclusive manner. This method is one of said
1963 * methods requiring proper critical code section protection (e.g. semaphore,
1964 * spin-lock, etc.). - For SATA, the user is required to manage NCQ tags. As a
1965 * result, it is expected the user will have set the NCQ tag field in the host
1966 * to device register FIS prior to calling this method. There is also a
1967 * requirement for the user to call scic_stp_io_set_ncq_tag() prior to invoking
1968 * the scic_controller_start_io() method. scic_controller_allocate_tag() for
1969 * more information on allocating a tag. Indicate if the controller
1970 * successfully started the IO request. SCI_IO_SUCCESS if the IO request was
1971 * successfully started. Determine the failure situations and return values.
1972 */
1973 enum sci_io_status scic_controller_start_io(
1974 struct scic_sds_controller *scic,
1975 struct scic_sds_remote_device *rdev,
1976 struct scic_sds_request *req,
1977 u16 io_tag)
1978 {
1979 enum sci_status status;
1980
1981 if (scic->state_machine.current_state_id !=
1982 SCI_BASE_CONTROLLER_STATE_READY) {
1983 dev_warn(scic_to_dev(scic), "invalid state to start I/O");
1984 return SCI_FAILURE_INVALID_STATE;
1985 }
1986
1987 status = scic_sds_remote_device_start_io(scic, rdev, req);
1988 if (status != SCI_SUCCESS)
1989 return status;
1990
1991 scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req;
1992 scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(req));
1993 return SCI_SUCCESS;
1994 }
1995
1996 /**
1997 * scic_controller_terminate_request() - This method is called by the SCI Core
1998 * user to terminate an ongoing (i.e. started) core IO request. This does
1999 * not abort the IO request at the target, but rather removes the IO request
2000 * from the host controller.
2001 * @controller: the handle to the controller object for which to terminate a
2002 * request.
2003 * @remote_device: the handle to the remote device object for which to
2004 * terminate a request.
2005 * @request: the handle to the io or task management request object to
2006 * terminate.
2007 *
2008 * Indicate if the controller successfully began the terminate process for the
2009 * IO request. SCI_SUCCESS if the terminate process was successfully started
2010 * for the request. Determine the failure situations and return values.
2011 */
2012 enum sci_status scic_controller_terminate_request(
2013 struct scic_sds_controller *scic,
2014 struct scic_sds_remote_device *rdev,
2015 struct scic_sds_request *req)
2016 {
2017 enum sci_status status;
2018
2019 if (scic->state_machine.current_state_id !=
2020 SCI_BASE_CONTROLLER_STATE_READY) {
2021 dev_warn(scic_to_dev(scic),
2022 "invalid state to terminate request\n");
2023 return SCI_FAILURE_INVALID_STATE;
2024 }
2025
2026 status = scic_sds_io_request_terminate(req);
2027 if (status != SCI_SUCCESS)
2028 return status;
2029
2030 /*
2031 * Utilize the original post context command and or in the POST_TC_ABORT
2032 * request sub-type.
2033 */
2034 scic_sds_controller_post_request(scic,
2035 scic_sds_request_get_post_context(req) |
2036 SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT);
2037 return SCI_SUCCESS;
2038 }
2039
2040 /**
2041 * scic_controller_complete_io() - This method will perform core specific
2042 * completion operations for an IO request. After this method is invoked,
2043 * the user should consider the IO request as invalid until it is properly
2044 * reused (i.e. re-constructed).
2045 * @controller: The handle to the controller object for which to complete the
2046 * IO request.
2047 * @remote_device: The handle to the remote device object for which to complete
2048 * the IO request.
2049 * @io_request: the handle to the io request object to complete.
2050 *
2051 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2052 * to ensure that each of the methods that may allocate or free available IO
2053 * tags are handled in a mutually exclusive manner. This method is one of said
2054 * methods requiring proper critical code section protection (e.g. semaphore,
2055 * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
2056 * Core user, using the scic_controller_allocate_io_tag() method, then it is
2057 * the responsibility of the caller to invoke the scic_controller_free_io_tag()
2058 * method to free the tag (i.e. this method will not free the IO tag). Indicate
2059 * if the controller successfully completed the IO request. SCI_SUCCESS if the
2060 * completion process was successful.
2061 */
2062 enum sci_status scic_controller_complete_io(
2063 struct scic_sds_controller *scic,
2064 struct scic_sds_remote_device *rdev,
2065 struct scic_sds_request *request)
2066 {
2067 enum sci_status status;
2068 u16 index;
2069
2070 switch (scic->state_machine.current_state_id) {
2071 case SCI_BASE_CONTROLLER_STATE_STOPPING:
2072 /* XXX: Implement this function */
2073 return SCI_FAILURE;
2074 case SCI_BASE_CONTROLLER_STATE_READY:
2075 status = scic_sds_remote_device_complete_io(scic, rdev, request);
2076 if (status != SCI_SUCCESS)
2077 return status;
2078
2079 index = scic_sds_io_tag_get_index(request->io_tag);
2080 scic->io_request_table[index] = NULL;
2081 return SCI_SUCCESS;
2082 default:
2083 dev_warn(scic_to_dev(scic), "invalid state to complete I/O");
2084 return SCI_FAILURE_INVALID_STATE;
2085 }
2086
2087 }
2088
2089 enum sci_status scic_controller_continue_io(struct scic_sds_request *sci_req)
2090 {
2091 struct scic_sds_controller *scic = sci_req->owning_controller;
2092
2093 if (scic->state_machine.current_state_id !=
2094 SCI_BASE_CONTROLLER_STATE_READY) {
2095 dev_warn(scic_to_dev(scic), "invalid state to continue I/O");
2096 return SCI_FAILURE_INVALID_STATE;
2097 }
2098
2099 scic->io_request_table[scic_sds_io_tag_get_index(sci_req->io_tag)] = sci_req;
2100 scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(sci_req));
2101 return SCI_SUCCESS;
2102 }
2103
2104 /**
2105 * scic_controller_start_task() - This method is called by the SCIC user to
2106 * send/start a framework task management request.
2107 * @controller: the handle to the controller object for which to start the task
2108 * management request.
2109 * @remote_device: the handle to the remote device object for which to start
2110 * the task management request.
2111 * @task_request: the handle to the task request object to start.
2112 * @io_tag: This parameter specifies a previously allocated IO tag that the
2113 * user desires to be utilized for this request. Note this not the io_tag
2114 * of the request being managed. It is to be utilized for the task request
2115 * itself. This parameter is optional. The user is allowed to supply
2116 * SCI_CONTROLLER_INVALID_IO_TAG as the value for this parameter.
2117 *
2118 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2119 * to ensure that each of the methods that may allocate or free available IO
2120 * tags are handled in a mutually exclusive manner. This method is one of said
2121 * methods requiring proper critical code section protection (e.g. semaphore,
2122 * spin-lock, etc.). - The user must synchronize this task with completion
2123 * queue processing. If they are not synchronized then it is possible for the
2124 * io requests that are being managed by the task request can complete before
2125 * starting the task request. scic_controller_allocate_tag() for more
2126 * information on allocating a tag. Indicate if the controller successfully
2127 * started the IO request. SCI_TASK_SUCCESS if the task request was
2128 * successfully started. SCI_TASK_FAILURE_REQUIRES_SCSI_ABORT This value is
2129 * returned if there is/are task(s) outstanding that require termination or
2130 * completion before this request can succeed.
2131 */
2132 enum sci_task_status scic_controller_start_task(
2133 struct scic_sds_controller *scic,
2134 struct scic_sds_remote_device *rdev,
2135 struct scic_sds_request *req,
2136 u16 task_tag)
2137 {
2138 enum sci_status status;
2139
2140 if (scic->state_machine.current_state_id !=
2141 SCI_BASE_CONTROLLER_STATE_READY) {
2142 dev_warn(scic_to_dev(scic),
2143 "%s: SCIC Controller starting task from invalid "
2144 "state\n",
2145 __func__);
2146 return SCI_TASK_FAILURE_INVALID_STATE;
2147 }
2148
2149 status = scic_sds_remote_device_start_task(scic, rdev, req);
2150 switch (status) {
2151 case SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS:
2152 scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req;
2153
2154 /*
2155 * We will let framework know this task request started successfully,
2156 * although core is still woring on starting the request (to post tc when
2157 * RNC is resumed.)
2158 */
2159 return SCI_SUCCESS;
2160 case SCI_SUCCESS:
2161 scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req;
2162
2163 scic_sds_controller_post_request(scic,
2164 scic_sds_request_get_post_context(req));
2165 break;
2166 default:
2167 break;
2168 }
2169
2170 return status;
2171 }
2172
2173 /**
2174 * scic_controller_get_port_handle() - This method simply provides the user
2175 * with a unique handle for a given SAS/SATA core port index.
2176 * @controller: This parameter represents the handle to the controller object
2177 * from which to retrieve a port (SAS or SATA) handle.
2178 * @port_index: This parameter specifies the port index in the controller for
2179 * which to retrieve the port handle. 0 <= port_index < maximum number of
2180 * phys.
2181 * @port_handle: This parameter specifies the retrieved port handle to be
2182 * provided to the caller.
2183 *
2184 * Indicate if the retrieval of the port handle was successful. SCI_SUCCESS
2185 * This value is returned if the retrieval was successful.
2186 * SCI_FAILURE_INVALID_PORT This value is returned if the supplied port id is
2187 * not in the supported range.
2188 */
2189 enum sci_status scic_controller_get_port_handle(
2190 struct scic_sds_controller *scic,
2191 u8 port_index,
2192 struct scic_sds_port **port_handle)
2193 {
2194 if (port_index < scic->logical_port_entries) {
2195 *port_handle = &scic->port_table[port_index];
2196
2197 return SCI_SUCCESS;
2198 }
2199
2200 return SCI_FAILURE_INVALID_PORT;
2201 }
2202
2203 /**
2204 * scic_controller_get_phy_handle() - This method simply provides the user with
2205 * a unique handle for a given SAS/SATA phy index/identifier.
2206 * @controller: This parameter represents the handle to the controller object
2207 * from which to retrieve a phy (SAS or SATA) handle.
2208 * @phy_index: This parameter specifies the phy index in the controller for
2209 * which to retrieve the phy handle. 0 <= phy_index < maximum number of phys.
2210 * @phy_handle: This parameter specifies the retrieved phy handle to be
2211 * provided to the caller.
2212 *
2213 * Indicate if the retrieval of the phy handle was successful. SCI_SUCCESS This
2214 * value is returned if the retrieval was successful. SCI_FAILURE_INVALID_PHY
2215 * This value is returned if the supplied phy id is not in the supported range.
2216 */
2217 enum sci_status scic_controller_get_phy_handle(
2218 struct scic_sds_controller *scic,
2219 u8 phy_index,
2220 struct scic_sds_phy **phy_handle)
2221 {
2222 if (phy_index < ARRAY_SIZE(scic->phy_table)) {
2223 *phy_handle = &scic->phy_table[phy_index];
2224
2225 return SCI_SUCCESS;
2226 }
2227
2228 dev_err(scic_to_dev(scic),
2229 "%s: Controller:0x%p PhyId:0x%x invalid phy index\n",
2230 __func__, scic, phy_index);
2231
2232 return SCI_FAILURE_INVALID_PHY;
2233 }
2234
2235 /**
2236 * scic_controller_allocate_io_tag() - This method will allocate a tag from the
2237 * pool of free IO tags. Direct allocation of IO tags by the SCI Core user
2238 * is optional. The scic_controller_start_io() method will allocate an IO
2239 * tag if this method is not utilized and the tag is not supplied to the IO
2240 * construct routine. Direct allocation of IO tags may provide additional
2241 * performance improvements in environments capable of supporting this usage
2242 * model. Additionally, direct allocation of IO tags also provides
2243 * additional flexibility to the SCI Core user. Specifically, the user may
2244 * retain IO tags across the lives of multiple IO requests.
2245 * @controller: the handle to the controller object for which to allocate the
2246 * tag.
2247 *
2248 * IO tags are a protected resource. It is incumbent upon the SCI Core user to
2249 * ensure that each of the methods that may allocate or free available IO tags
2250 * are handled in a mutually exclusive manner. This method is one of said
2251 * methods requiring proper critical code section protection (e.g. semaphore,
2252 * spin-lock, etc.). An unsigned integer representing an available IO tag.
2253 * SCI_CONTROLLER_INVALID_IO_TAG This value is returned if there are no
2254 * currently available tags to be allocated. All return other values indicate a
2255 * legitimate tag.
2256 */
2257 u16 scic_controller_allocate_io_tag(
2258 struct scic_sds_controller *scic)
2259 {
2260 u16 task_context;
2261 u16 sequence_count;
2262
2263 if (!sci_pool_empty(scic->tci_pool)) {
2264 sci_pool_get(scic->tci_pool, task_context);
2265
2266 sequence_count = scic->io_request_sequence[task_context];
2267
2268 return scic_sds_io_tag_construct(sequence_count, task_context);
2269 }
2270
2271 return SCI_CONTROLLER_INVALID_IO_TAG;
2272 }
2273
2274 /**
2275 * scic_controller_free_io_tag() - This method will free an IO tag to the pool
2276 * of free IO tags. This method provides the SCI Core user more flexibility
2277 * with regards to IO tags. The user may desire to keep an IO tag after an
2278 * IO request has completed, because they plan on re-using the tag for a
2279 * subsequent IO request. This method is only legal if the tag was
2280 * allocated via scic_controller_allocate_io_tag().
2281 * @controller: This parameter specifies the handle to the controller object
2282 * for which to free/return the tag.
2283 * @io_tag: This parameter represents the tag to be freed to the pool of
2284 * available tags.
2285 *
2286 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2287 * to ensure that each of the methods that may allocate or free available IO
2288 * tags are handled in a mutually exclusive manner. This method is one of said
2289 * methods requiring proper critical code section protection (e.g. semaphore,
2290 * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
2291 * Core user, using the scic_controller_allocate_io_tag() method, then it is
2292 * the responsibility of the caller to invoke this method to free the tag. This
2293 * method returns an indication of whether the tag was successfully put back
2294 * (freed) to the pool of available tags. SCI_SUCCESS This return value
2295 * indicates the tag was successfully placed into the pool of available IO
2296 * tags. SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied tag
2297 * is not a valid IO tag value.
2298 */
2299 enum sci_status scic_controller_free_io_tag(
2300 struct scic_sds_controller *scic,
2301 u16 io_tag)
2302 {
2303 u16 sequence;
2304 u16 index;
2305
2306 BUG_ON(io_tag == SCI_CONTROLLER_INVALID_IO_TAG);
2307
2308 sequence = scic_sds_io_tag_get_sequence(io_tag);
2309 index = scic_sds_io_tag_get_index(io_tag);
2310
2311 if (!sci_pool_full(scic->tci_pool)) {
2312 if (sequence == scic->io_request_sequence[index]) {
2313 scic_sds_io_sequence_increment(
2314 scic->io_request_sequence[index]);
2315
2316 sci_pool_put(scic->tci_pool, index);
2317
2318 return SCI_SUCCESS;
2319 }
2320 }
2321
2322 return SCI_FAILURE_INVALID_IO_TAG;
2323 }
2324
2325 void scic_controller_enable_interrupts(
2326 struct scic_sds_controller *scic)
2327 {
2328 BUG_ON(scic->smu_registers == NULL);
2329 writel(0, &scic->smu_registers->interrupt_mask);
2330 }
2331
2332 void scic_controller_disable_interrupts(
2333 struct scic_sds_controller *scic)
2334 {
2335 BUG_ON(scic->smu_registers == NULL);
2336 writel(0xffffffff, &scic->smu_registers->interrupt_mask);
2337 }
2338
2339 static enum sci_status scic_controller_set_mode(
2340 struct scic_sds_controller *scic,
2341 enum sci_controller_mode operating_mode)
2342 {
2343 enum sci_status status = SCI_SUCCESS;
2344
2345 if ((scic->state_machine.current_state_id ==
2346 SCI_BASE_CONTROLLER_STATE_INITIALIZING) ||
2347 (scic->state_machine.current_state_id ==
2348 SCI_BASE_CONTROLLER_STATE_INITIALIZED)) {
2349 switch (operating_mode) {
2350 case SCI_MODE_SPEED:
2351 scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
2352 scic->task_context_entries = SCU_IO_REQUEST_COUNT;
2353 scic->uf_control.buffers.count =
2354 SCU_UNSOLICITED_FRAME_COUNT;
2355 scic->completion_event_entries = SCU_EVENT_COUNT;
2356 scic->completion_queue_entries =
2357 SCU_COMPLETION_QUEUE_COUNT;
2358 break;
2359
2360 case SCI_MODE_SIZE:
2361 scic->remote_node_entries = SCI_MIN_REMOTE_DEVICES;
2362 scic->task_context_entries = SCI_MIN_IO_REQUESTS;
2363 scic->uf_control.buffers.count =
2364 SCU_MIN_UNSOLICITED_FRAMES;
2365 scic->completion_event_entries = SCU_MIN_EVENTS;
2366 scic->completion_queue_entries =
2367 SCU_MIN_COMPLETION_QUEUE_ENTRIES;
2368 break;
2369
2370 default:
2371 status = SCI_FAILURE_INVALID_PARAMETER_VALUE;
2372 break;
2373 }
2374 } else
2375 status = SCI_FAILURE_INVALID_STATE;
2376
2377 return status;
2378 }
2379
2380 /**
2381 * scic_sds_controller_reset_hardware() -
2382 *
2383 * This method will reset the controller hardware.
2384 */
2385 static void scic_sds_controller_reset_hardware(
2386 struct scic_sds_controller *scic)
2387 {
2388 /* Disable interrupts so we dont take any spurious interrupts */
2389 scic_controller_disable_interrupts(scic);
2390
2391 /* Reset the SCU */
2392 writel(0xFFFFFFFF, &scic->smu_registers->soft_reset_control);
2393
2394 /* Delay for 1ms to before clearing the CQP and UFQPR. */
2395 udelay(1000);
2396
2397 /* The write to the CQGR clears the CQP */
2398 writel(0x00000000, &scic->smu_registers->completion_queue_get);
2399
2400 /* The write to the UFQGP clears the UFQPR */
2401 writel(0, &scic->scu_registers->sdma.unsolicited_frame_get_pointer);
2402 }
2403
2404 enum sci_status scic_user_parameters_set(
2405 struct scic_sds_controller *scic,
2406 union scic_user_parameters *scic_parms)
2407 {
2408 u32 state = scic->state_machine.current_state_id;
2409
2410 if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
2411 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
2412 state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
2413 u16 index;
2414
2415 /*
2416 * Validate the user parameters. If they are not legal, then
2417 * return a failure.
2418 */
2419 for (index = 0; index < SCI_MAX_PHYS; index++) {
2420 struct sci_phy_user_params *user_phy;
2421
2422 user_phy = &scic_parms->sds1.phys[index];
2423
2424 if (!((user_phy->max_speed_generation <=
2425 SCIC_SDS_PARM_MAX_SPEED) &&
2426 (user_phy->max_speed_generation >
2427 SCIC_SDS_PARM_NO_SPEED)))
2428 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2429
2430 if (user_phy->in_connection_align_insertion_frequency <
2431 3)
2432 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2433
2434 if ((user_phy->in_connection_align_insertion_frequency <
2435 3) ||
2436 (user_phy->align_insertion_frequency == 0) ||
2437 (user_phy->
2438 notify_enable_spin_up_insertion_frequency ==
2439 0))
2440 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2441 }
2442
2443 if ((scic_parms->sds1.stp_inactivity_timeout == 0) ||
2444 (scic_parms->sds1.ssp_inactivity_timeout == 0) ||
2445 (scic_parms->sds1.stp_max_occupancy_timeout == 0) ||
2446 (scic_parms->sds1.ssp_max_occupancy_timeout == 0) ||
2447 (scic_parms->sds1.no_outbound_task_timeout == 0))
2448 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2449
2450 memcpy(&scic->user_parameters, scic_parms, sizeof(*scic_parms));
2451
2452 return SCI_SUCCESS;
2453 }
2454
2455 return SCI_FAILURE_INVALID_STATE;
2456 }
2457
2458 enum sci_status scic_oem_parameters_set(
2459 struct scic_sds_controller *scic,
2460 union scic_oem_parameters *scic_parms)
2461 {
2462 u32 state = scic->state_machine.current_state_id;
2463
2464 if (state == SCI_BASE_CONTROLLER_STATE_RESET ||
2465 state == SCI_BASE_CONTROLLER_STATE_INITIALIZING ||
2466 state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
2467 u16 index;
2468 u8 combined_phy_mask = 0;
2469
2470 /*
2471 * Validate the oem parameters. If they are not legal, then
2472 * return a failure. */
2473 for (index = 0; index < SCI_MAX_PORTS; index++) {
2474 if (scic_parms->sds1.ports[index].phy_mask > SCIC_SDS_PARM_PHY_MASK_MAX)
2475 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2476 }
2477
2478 for (index = 0; index < SCI_MAX_PHYS; index++) {
2479 if ((scic_parms->sds1.phys[index].sas_address.high == 0) &&
2480 (scic_parms->sds1.phys[index].sas_address.low == 0))
2481 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2482 }
2483
2484 if (scic_parms->sds1.controller.mode_type ==
2485 SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE) {
2486 for (index = 0; index < SCI_MAX_PHYS; index++) {
2487 if (scic_parms->sds1.ports[index].phy_mask != 0)
2488 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2489 }
2490 } else if (scic_parms->sds1.controller.mode_type ==
2491 SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
2492 for (index = 0; index < SCI_MAX_PHYS; index++)
2493 combined_phy_mask |= scic_parms->sds1.ports[index].phy_mask;
2494
2495 if (combined_phy_mask == 0)
2496 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2497 } else
2498 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2499
2500 if (scic_parms->sds1.controller.max_concurrent_dev_spin_up >
2501 MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT)
2502 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2503
2504 scic->oem_parameters.sds1 = scic_parms->sds1;
2505
2506 return SCI_SUCCESS;
2507 }
2508
2509 return SCI_FAILURE_INVALID_STATE;
2510 }
2511
2512 void scic_oem_parameters_get(
2513 struct scic_sds_controller *scic,
2514 union scic_oem_parameters *scic_parms)
2515 {
2516 memcpy(scic_parms, (&scic->oem_parameters), sizeof(*scic_parms));
2517 }
2518
2519 #define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS 853
2520 #define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS 1280
2521 #define INTERRUPT_COALESCE_TIMEOUT_MAX_US 2700000
2522 #define INTERRUPT_COALESCE_NUMBER_MAX 256
2523 #define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN 7
2524 #define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX 28
2525
2526 /**
2527 * scic_controller_set_interrupt_coalescence() - This method allows the user to
2528 * configure the interrupt coalescence.
2529 * @controller: This parameter represents the handle to the controller object
2530 * for which its interrupt coalesce register is overridden.
2531 * @coalesce_number: Used to control the number of entries in the Completion
2532 * Queue before an interrupt is generated. If the number of entries exceed
2533 * this number, an interrupt will be generated. The valid range of the input
2534 * is [0, 256]. A setting of 0 results in coalescing being disabled.
2535 * @coalesce_timeout: Timeout value in microseconds. The valid range of the
2536 * input is [0, 2700000] . A setting of 0 is allowed and results in no
2537 * interrupt coalescing timeout.
2538 *
2539 * Indicate if the user successfully set the interrupt coalesce parameters.
2540 * SCI_SUCCESS The user successfully updated the interrutp coalescence.
2541 * SCI_FAILURE_INVALID_PARAMETER_VALUE The user input value is out of range.
2542 */
2543 static enum sci_status scic_controller_set_interrupt_coalescence(
2544 struct scic_sds_controller *scic_controller,
2545 u32 coalesce_number,
2546 u32 coalesce_timeout)
2547 {
2548 u8 timeout_encode = 0;
2549 u32 min = 0;
2550 u32 max = 0;
2551
2552 /* Check if the input parameters fall in the range. */
2553 if (coalesce_number > INTERRUPT_COALESCE_NUMBER_MAX)
2554 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2555
2556 /*
2557 * Defined encoding for interrupt coalescing timeout:
2558 * Value Min Max Units
2559 * ----- --- --- -----
2560 * 0 - - Disabled
2561 * 1 13.3 20.0 ns
2562 * 2 26.7 40.0
2563 * 3 53.3 80.0
2564 * 4 106.7 160.0
2565 * 5 213.3 320.0
2566 * 6 426.7 640.0
2567 * 7 853.3 1280.0
2568 * 8 1.7 2.6 us
2569 * 9 3.4 5.1
2570 * 10 6.8 10.2
2571 * 11 13.7 20.5
2572 * 12 27.3 41.0
2573 * 13 54.6 81.9
2574 * 14 109.2 163.8
2575 * 15 218.5 327.7
2576 * 16 436.9 655.4
2577 * 17 873.8 1310.7
2578 * 18 1.7 2.6 ms
2579 * 19 3.5 5.2
2580 * 20 7.0 10.5
2581 * 21 14.0 21.0
2582 * 22 28.0 41.9
2583 * 23 55.9 83.9
2584 * 24 111.8 167.8
2585 * 25 223.7 335.5
2586 * 26 447.4 671.1
2587 * 27 894.8 1342.2
2588 * 28 1.8 2.7 s
2589 * Others Undefined */
2590
2591 /*
2592 * Use the table above to decide the encode of interrupt coalescing timeout
2593 * value for register writing. */
2594 if (coalesce_timeout == 0)
2595 timeout_encode = 0;
2596 else{
2597 /* make the timeout value in unit of (10 ns). */
2598 coalesce_timeout = coalesce_timeout * 100;
2599 min = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS / 10;
2600 max = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS / 10;
2601
2602 /* get the encode of timeout for register writing. */
2603 for (timeout_encode = INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN;
2604 timeout_encode <= INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX;
2605 timeout_encode++) {
2606 if (min <= coalesce_timeout && max > coalesce_timeout)
2607 break;
2608 else if (coalesce_timeout >= max && coalesce_timeout < min * 2
2609 && coalesce_timeout <= INTERRUPT_COALESCE_TIMEOUT_MAX_US * 100) {
2610 if ((coalesce_timeout - max) < (2 * min - coalesce_timeout))
2611 break;
2612 else{
2613 timeout_encode++;
2614 break;
2615 }
2616 } else {
2617 max = max * 2;
2618 min = min * 2;
2619 }
2620 }
2621
2622 if (timeout_encode == INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX + 1)
2623 /* the value is out of range. */
2624 return SCI_FAILURE_INVALID_PARAMETER_VALUE;
2625 }
2626
2627 writel(SMU_ICC_GEN_VAL(NUMBER, coalesce_number) |
2628 SMU_ICC_GEN_VAL(TIMER, timeout_encode),
2629 &scic_controller->smu_registers->interrupt_coalesce_control);
2630
2631
2632 scic_controller->interrupt_coalesce_number = (u16)coalesce_number;
2633 scic_controller->interrupt_coalesce_timeout = coalesce_timeout / 100;
2634
2635 return SCI_SUCCESS;
2636 }
2637
2638
2639 struct scic_sds_controller *scic_controller_alloc(struct device *dev)
2640 {
2641 return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL);
2642 }
2643
2644 enum sci_status scic_controller_initialize(
2645 struct scic_sds_controller *scic)
2646 {
2647 struct sci_base_state_machine *sm = &scic->state_machine;
2648 enum sci_status result = SCI_SUCCESS;
2649 struct isci_host *ihost;
2650 u32 index, state;
2651
2652 if (scic->state_machine.current_state_id !=
2653 SCI_BASE_CONTROLLER_STATE_RESET) {
2654 dev_warn(scic_to_dev(scic),
2655 "SCIC Controller initialize operation requested "
2656 "in invalid state\n");
2657 return SCI_FAILURE_INVALID_STATE;
2658 }
2659
2660
2661 ihost = sci_object_get_association(scic);
2662
2663 sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING);
2664
2665 scic->timeout_timer = isci_timer_create(ihost,
2666 scic,
2667 scic_sds_controller_timeout_handler);
2668
2669 scic_sds_controller_initialize_phy_startup(scic);
2670
2671 scic_sds_controller_initialize_power_control(scic);
2672
2673 /*
2674 * There is nothing to do here for B0 since we do not have to
2675 * program the AFE registers.
2676 * / @todo The AFE settings are supposed to be correct for the B0 but
2677 * / presently they seem to be wrong. */
2678 scic_sds_controller_afe_initialization(scic);
2679
2680 if (result == SCI_SUCCESS) {
2681 u32 status;
2682 u32 terminate_loop;
2683
2684 /* Take the hardware out of reset */
2685 writel(0, &scic->smu_registers->soft_reset_control);
2686
2687 /*
2688 * / @todo Provide meaningfull error code for hardware failure
2689 * result = SCI_FAILURE_CONTROLLER_HARDWARE; */
2690 result = SCI_FAILURE;
2691 terminate_loop = 100;
2692
2693 while (terminate_loop-- && (result != SCI_SUCCESS)) {
2694 /* Loop until the hardware reports success */
2695 udelay(SCU_CONTEXT_RAM_INIT_STALL_TIME);
2696 status = readl(&scic->smu_registers->control_status);
2697
2698 if ((status & SCU_RAM_INIT_COMPLETED) ==
2699 SCU_RAM_INIT_COMPLETED)
2700 result = SCI_SUCCESS;
2701 }
2702 }
2703
2704 if (result == SCI_SUCCESS) {
2705 u32 max_supported_ports;
2706 u32 max_supported_devices;
2707 u32 max_supported_io_requests;
2708 u32 device_context_capacity;
2709
2710 /*
2711 * Determine what are the actaul device capacities that the
2712 * hardware will support */
2713 device_context_capacity =
2714 readl(&scic->smu_registers->device_context_capacity);
2715
2716
2717 max_supported_ports = smu_dcc_get_max_ports(device_context_capacity);
2718 max_supported_devices = smu_dcc_get_max_remote_node_context(device_context_capacity);
2719 max_supported_io_requests = smu_dcc_get_max_task_context(device_context_capacity);
2720
2721 /*
2722 * Make all PEs that are unassigned match up with the
2723 * logical ports
2724 */
2725 for (index = 0; index < max_supported_ports; index++) {
2726 struct scu_port_task_scheduler_group_registers *ptsg =
2727 &scic->scu_registers->peg0.ptsg;
2728
2729 writel(index, &ptsg->protocol_engine[index]);
2730 }
2731
2732 /* Record the smaller of the two capacity values */
2733 scic->logical_port_entries =
2734 min(max_supported_ports, scic->logical_port_entries);
2735
2736 scic->task_context_entries =
2737 min(max_supported_io_requests,
2738 scic->task_context_entries);
2739
2740 scic->remote_node_entries =
2741 min(max_supported_devices, scic->remote_node_entries);
2742
2743 /*
2744 * Now that we have the correct hardware reported minimum values
2745 * build the MDL for the controller. Default to a performance
2746 * configuration.
2747 */
2748 scic_controller_set_mode(scic, SCI_MODE_SPEED);
2749 }
2750
2751 /* Initialize hardware PCI Relaxed ordering in DMA engines */
2752 if (result == SCI_SUCCESS) {
2753 u32 dma_configuration;
2754
2755 /* Configure the payload DMA */
2756 dma_configuration =
2757 readl(&scic->scu_registers->sdma.pdma_configuration);
2758 dma_configuration |=
2759 SCU_PDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
2760 writel(dma_configuration,
2761 &scic->scu_registers->sdma.pdma_configuration);
2762
2763 /* Configure the control DMA */
2764 dma_configuration =
2765 readl(&scic->scu_registers->sdma.cdma_configuration);
2766 dma_configuration |=
2767 SCU_CDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE);
2768 writel(dma_configuration,
2769 &scic->scu_registers->sdma.cdma_configuration);
2770 }
2771
2772 /*
2773 * Initialize the PHYs before the PORTs because the PHY registers
2774 * are accessed during the port initialization.
2775 */
2776 if (result == SCI_SUCCESS) {
2777 /* Initialize the phys */
2778 for (index = 0;
2779 (result == SCI_SUCCESS) && (index < SCI_MAX_PHYS);
2780 index++) {
2781 result = scic_sds_phy_initialize(
2782 &scic->phy_table[index],
2783 &scic->scu_registers->peg0.pe[index].tl,
2784 &scic->scu_registers->peg0.pe[index].ll);
2785 }
2786 }
2787
2788 if (result == SCI_SUCCESS) {
2789 /* Initialize the logical ports */
2790 for (index = 0;
2791 (index < scic->logical_port_entries) &&
2792 (result == SCI_SUCCESS);
2793 index++) {
2794 result = scic_sds_port_initialize(
2795 &scic->port_table[index],
2796 &scic->scu_registers->peg0.ptsg.port[index],
2797 &scic->scu_registers->peg0.ptsg.protocol_engine,
2798 &scic->scu_registers->peg0.viit[index]);
2799 }
2800 }
2801
2802 if (result == SCI_SUCCESS)
2803 result = scic_sds_port_configuration_agent_initialize(
2804 scic,
2805 &scic->port_agent);
2806
2807 /* Advance the controller state machine */
2808 if (result == SCI_SUCCESS)
2809 state = SCI_BASE_CONTROLLER_STATE_INITIALIZED;
2810 else
2811 state = SCI_BASE_CONTROLLER_STATE_FAILED;
2812 sci_base_state_machine_change_state(sm, state);
2813
2814 return result;
2815 }
2816
2817 enum sci_status scic_controller_start(struct scic_sds_controller *scic,
2818 u32 timeout)
2819 {
2820 enum sci_status result;
2821 u16 index;
2822
2823 if (scic->state_machine.current_state_id !=
2824 SCI_BASE_CONTROLLER_STATE_INITIALIZED) {
2825 dev_warn(scic_to_dev(scic),
2826 "SCIC Controller start operation requested in "
2827 "invalid state\n");
2828 return SCI_FAILURE_INVALID_STATE;
2829 }
2830
2831 /* Build the TCi free pool */
2832 sci_pool_initialize(scic->tci_pool);
2833 for (index = 0; index < scic->task_context_entries; index++)
2834 sci_pool_put(scic->tci_pool, index);
2835
2836 /* Build the RNi free pool */
2837 scic_sds_remote_node_table_initialize(
2838 &scic->available_remote_nodes,
2839 scic->remote_node_entries);
2840
2841 /*
2842 * Before anything else lets make sure we will not be
2843 * interrupted by the hardware.
2844 */
2845 scic_controller_disable_interrupts(scic);
2846
2847 /* Enable the port task scheduler */
2848 scic_sds_controller_enable_port_task_scheduler(scic);
2849
2850 /* Assign all the task entries to scic physical function */
2851 scic_sds_controller_assign_task_entries(scic);
2852
2853 /* Now initialze the completion queue */
2854 scic_sds_controller_initialize_completion_queue(scic);
2855
2856 /* Initialize the unsolicited frame queue for use */
2857 scic_sds_controller_initialize_unsolicited_frame_queue(scic);
2858
2859 /* Start all of the ports on this controller */
2860 for (index = 0; index < scic->logical_port_entries; index++) {
2861 struct scic_sds_port *sci_port = &scic->port_table[index];
2862
2863 result = sci_port->state_handlers->start_handler(
2864 sci_port);
2865 if (result)
2866 return result;
2867 }
2868
2869 scic_sds_controller_start_next_phy(scic);
2870
2871 isci_timer_start(scic->timeout_timer, timeout);
2872
2873 sci_base_state_machine_change_state(&scic->state_machine,
2874 SCI_BASE_CONTROLLER_STATE_STARTING);
2875
2876 return SCI_SUCCESS;
2877 }
2878
2879 /**
2880 *
2881 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
2882 * object.
2883 *
2884 * This method implements the actions taken by the struct scic_sds_controller on entry
2885 * to the SCI_BASE_CONTROLLER_STATE_INITIAL. - Set the state handlers to the
2886 * controllers initial state. none This function should initialze the
2887 * controller object.
2888 */
2889 static void scic_sds_controller_initial_state_enter(
2890 struct sci_base_object *object)
2891 {
2892 struct scic_sds_controller *this_controller;
2893
2894 this_controller = (struct scic_sds_controller *)object;
2895
2896 sci_base_state_machine_change_state(&this_controller->state_machine,
2897 SCI_BASE_CONTROLLER_STATE_RESET);
2898 }
2899
2900 /**
2901 *
2902 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
2903 * object.
2904 *
2905 * This method implements the actions taken by the struct scic_sds_controller on exit
2906 * from the SCI_BASE_CONTROLLER_STATE_STARTING. - This function stops the
2907 * controller starting timeout timer. none
2908 */
2909 static inline void scic_sds_controller_starting_state_exit(
2910 struct sci_base_object *object)
2911 {
2912 struct scic_sds_controller *scic = (struct scic_sds_controller *)object;
2913
2914 isci_timer_stop(scic->timeout_timer);
2915 }
2916
2917 /**
2918 *
2919 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
2920 * object.
2921 *
2922 * This method implements the actions taken by the struct scic_sds_controller on entry
2923 * to the SCI_BASE_CONTROLLER_STATE_READY. - Set the state handlers to the
2924 * controllers ready state. none
2925 */
2926 static void scic_sds_controller_ready_state_enter(
2927 struct sci_base_object *object)
2928 {
2929 struct scic_sds_controller *this_controller;
2930
2931 this_controller = (struct scic_sds_controller *)object;
2932
2933 /* set the default interrupt coalescence number and timeout value. */
2934 scic_controller_set_interrupt_coalescence(
2935 this_controller, 0x10, 250);
2936 }
2937
2938 /**
2939 *
2940 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
2941 * object.
2942 *
2943 * This method implements the actions taken by the struct scic_sds_controller on exit
2944 * from the SCI_BASE_CONTROLLER_STATE_READY. - This function does nothing. none
2945 */
2946 static void scic_sds_controller_ready_state_exit(
2947 struct sci_base_object *object)
2948 {
2949 struct scic_sds_controller *this_controller;
2950
2951 this_controller = (struct scic_sds_controller *)object;
2952
2953 /* disable interrupt coalescence. */
2954 scic_controller_set_interrupt_coalescence(this_controller, 0, 0);
2955 }
2956
2957 /**
2958 *
2959 * @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
2960 * object.
2961 *
2962 * This method implements the actions taken by the struct scic_sds_controller on entry
2963 * to the SCI_BASE_CONTROLLER_STATE_READY. - Set the state handlers to the
2964 * controllers ready state. - Stop the phys on this controller - Stop the ports
2965 * on this controller - Stop all of the remote devices on this controller none
2966 */
2967 static void scic_sds_controller_stopping_state_enter(
2968 struct sci_base_object *object)
2969 {
2970 struct scic_sds_controller *this_controller;
2971
2972 this_controller = (struct scic_sds_controller *)object;
2973
2974 /* Stop all of the components for this controller */
2975 scic_sds_controller_stop_phys(this_controller);
2976 scic_sds_controller_stop_ports(this_controller);
2977 scic_sds_controller_stop_devices(this_controller);
2978 }
2979
2980 /**
2981 *
2982 * @object: This is the struct sci_base_object which is cast to a struct
2983 * scic_sds_controller object.
2984 *
2985 * This funciton implements the actions taken by the struct scic_sds_controller
2986 * on exit from the SCI_BASE_CONTROLLER_STATE_STOPPING. -
2987 * This function stops the controller stopping timeout timer.
2988 */
2989 static inline void scic_sds_controller_stopping_state_exit(
2990 struct sci_base_object *object)
2991 {
2992 struct scic_sds_controller *scic =
2993 (struct scic_sds_controller *)object;
2994
2995 isci_timer_stop(scic->timeout_timer);
2996 }
2997
2998 static void scic_sds_controller_resetting_state_enter(struct sci_base_object *object)
2999 {
3000 struct scic_sds_controller *scic;
3001
3002 scic = container_of(object, typeof(*scic), parent);
3003 scic_sds_controller_reset_hardware(scic);
3004 sci_base_state_machine_change_state(&scic->state_machine,
3005 SCI_BASE_CONTROLLER_STATE_RESET);
3006 }
3007
3008 static const struct sci_base_state scic_sds_controller_state_table[] = {
3009 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3010 .enter_state = scic_sds_controller_initial_state_enter,
3011 },
3012 [SCI_BASE_CONTROLLER_STATE_RESET] = {},
3013 [SCI_BASE_CONTROLLER_STATE_INITIALIZING] = {},
3014 [SCI_BASE_CONTROLLER_STATE_INITIALIZED] = {},
3015 [SCI_BASE_CONTROLLER_STATE_STARTING] = {
3016 .exit_state = scic_sds_controller_starting_state_exit,
3017 },
3018 [SCI_BASE_CONTROLLER_STATE_READY] = {
3019 .enter_state = scic_sds_controller_ready_state_enter,
3020 .exit_state = scic_sds_controller_ready_state_exit,
3021 },
3022 [SCI_BASE_CONTROLLER_STATE_RESETTING] = {
3023 .enter_state = scic_sds_controller_resetting_state_enter,
3024 },
3025 [SCI_BASE_CONTROLLER_STATE_STOPPING] = {
3026 .enter_state = scic_sds_controller_stopping_state_enter,
3027 .exit_state = scic_sds_controller_stopping_state_exit,
3028 },
3029 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
3030 [SCI_BASE_CONTROLLER_STATE_FAILED] = {}
3031 };
3032
3033 /**
3034 * scic_controller_construct() - This method will attempt to construct a
3035 * controller object utilizing the supplied parameter information.
3036 * @c: This parameter specifies the controller to be constructed.
3037 * @scu_base: mapped base address of the scu registers
3038 * @smu_base: mapped base address of the smu registers
3039 *
3040 * Indicate if the controller was successfully constructed or if it failed in
3041 * some way. SCI_SUCCESS This value is returned if the controller was
3042 * successfully constructed. SCI_WARNING_TIMER_CONFLICT This value is returned
3043 * if the interrupt coalescence timer may cause SAS compliance issues for SMP
3044 * Target mode response processing. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE
3045 * This value is returned if the controller does not support the supplied type.
3046 * SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION This value is returned if the
3047 * controller does not support the supplied initialization data version.
3048 */
3049 enum sci_status scic_controller_construct(struct scic_sds_controller *scic,
3050 void __iomem *scu_base,
3051 void __iomem *smu_base)
3052 {
3053 u8 i;
3054
3055 sci_base_state_machine_construct(&scic->state_machine,
3056 &scic->parent, scic_sds_controller_state_table,
3057 SCI_BASE_CONTROLLER_STATE_INITIAL);
3058
3059 sci_base_state_machine_start(&scic->state_machine);
3060
3061 scic->scu_registers = scu_base;
3062 scic->smu_registers = smu_base;
3063
3064 scic_sds_port_configuration_agent_construct(&scic->port_agent);
3065
3066 /* Construct the ports for this controller */
3067 for (i = 0; i < SCI_MAX_PORTS; i++)
3068 scic_sds_port_construct(&scic->port_table[i], i, scic);
3069 scic_sds_port_construct(&scic->port_table[i], SCIC_SDS_DUMMY_PORT, scic);
3070
3071 /* Construct the phys for this controller */
3072 for (i = 0; i < SCI_MAX_PHYS; i++) {
3073 /* Add all the PHYs to the dummy port */
3074 scic_sds_phy_construct(&scic->phy_table[i],
3075 &scic->port_table[SCI_MAX_PORTS], i);
3076 }
3077
3078 scic->invalid_phy_mask = 0;
3079
3080 /* Set the default maximum values */
3081 scic->completion_event_entries = SCU_EVENT_COUNT;
3082 scic->completion_queue_entries = SCU_COMPLETION_QUEUE_COUNT;
3083 scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
3084 scic->logical_port_entries = SCI_MAX_PORTS;
3085 scic->task_context_entries = SCU_IO_REQUEST_COUNT;
3086 scic->uf_control.buffers.count = SCU_UNSOLICITED_FRAME_COUNT;
3087 scic->uf_control.address_table.count = SCU_UNSOLICITED_FRAME_COUNT;
3088
3089 /* Initialize the User and OEM parameters to default values. */
3090 scic_sds_controller_set_default_config_parameters(scic);
3091
3092 return scic_controller_reset(scic);
3093 }
This page took 0.097321 seconds and 5 git commands to generate.