Lines Matching +full:sierra +full:- +full:phy

2  * PMC-Sierra SPC 8001 SAS/SATA based host adapters driver
4 * Copyright (c) 2008-2009 USI Co., Ltd.
18 * 3. Neither the names of the above-listed copyright holders nor the names
48 * read_main_config_table - read the configure table and save it.
53 void __iomem *address = pm8001_ha->main_cfg_tbl_addr; in read_main_config_table()
54 pm8001_ha->main_cfg_tbl.pm8001_tbl.signature = in read_main_config_table()
56 pm8001_ha->main_cfg_tbl.pm8001_tbl.interface_rev = in read_main_config_table()
58 pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev = in read_main_config_table()
60 pm8001_ha->main_cfg_tbl.pm8001_tbl.max_out_io = in read_main_config_table()
62 pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl = in read_main_config_table()
64 pm8001_ha->main_cfg_tbl.pm8001_tbl.ctrl_cap_flag = in read_main_config_table()
66 pm8001_ha->main_cfg_tbl.pm8001_tbl.gst_offset = in read_main_config_table()
68 pm8001_ha->main_cfg_tbl.pm8001_tbl.inbound_queue_offset = in read_main_config_table()
70 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_queue_offset = in read_main_config_table()
72 pm8001_ha->main_cfg_tbl.pm8001_tbl.hda_mode_flag = in read_main_config_table()
76 pm8001_ha->main_cfg_tbl.pm8001_tbl.anolog_setup_table_offset = in read_main_config_table()
80 pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_dump_offset0 = in read_main_config_table()
82 pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_dump_length0 = in read_main_config_table()
84 pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_dump_offset1 = in read_main_config_table()
86 pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_dump_length1 = in read_main_config_table()
91 * read_general_status_table - read the general status table and save it.
96 void __iomem *address = pm8001_ha->general_stat_tbl_addr; in read_general_status_table()
97 pm8001_ha->gs_tbl.pm8001_tbl.gst_len_mpistate = in read_general_status_table()
99 pm8001_ha->gs_tbl.pm8001_tbl.iq_freeze_state0 = in read_general_status_table()
101 pm8001_ha->gs_tbl.pm8001_tbl.iq_freeze_state1 = in read_general_status_table()
103 pm8001_ha->gs_tbl.pm8001_tbl.msgu_tcnt = in read_general_status_table()
105 pm8001_ha->gs_tbl.pm8001_tbl.iop_tcnt = in read_general_status_table()
107 pm8001_ha->gs_tbl.pm8001_tbl.rsvd = in read_general_status_table()
109 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[0] = in read_general_status_table()
111 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[1] = in read_general_status_table()
113 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[2] = in read_general_status_table()
115 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[3] = in read_general_status_table()
117 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[4] = in read_general_status_table()
119 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[5] = in read_general_status_table()
121 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[6] = in read_general_status_table()
123 pm8001_ha->gs_tbl.pm8001_tbl.phy_state[7] = in read_general_status_table()
125 pm8001_ha->gs_tbl.pm8001_tbl.gpio_input_val = in read_general_status_table()
127 pm8001_ha->gs_tbl.pm8001_tbl.rsvd1[0] = in read_general_status_table()
129 pm8001_ha->gs_tbl.pm8001_tbl.rsvd1[1] = in read_general_status_table()
131 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[0] = in read_general_status_table()
133 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[1] = in read_general_status_table()
135 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[2] = in read_general_status_table()
137 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[3] = in read_general_status_table()
139 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[4] = in read_general_status_table()
141 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[5] = in read_general_status_table()
143 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[6] = in read_general_status_table()
145 pm8001_ha->gs_tbl.pm8001_tbl.recover_err_info[7] = in read_general_status_table()
150 * read_inbnd_queue_table - read the inbound queue table and save it.
156 void __iomem *address = pm8001_ha->inbnd_q_tbl_addr; in read_inbnd_queue_table()
159 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = in read_inbnd_queue_table()
161 pm8001_ha->inbnd_q_tbl[i].pi_offset = in read_inbnd_queue_table()
167 * read_outbnd_queue_table - read the outbound queue table and save it.
173 void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; in read_outbnd_queue_table()
176 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = in read_outbnd_queue_table()
178 pm8001_ha->outbnd_q_tbl[i].ci_offset = in read_outbnd_queue_table()
184 * init_default_table_values - init the default table.
191 void __iomem *addressib = pm8001_ha->inbnd_q_tbl_addr; in init_default_table_values()
192 void __iomem *addressob = pm8001_ha->outbnd_q_tbl_addr; in init_default_table_values()
193 u32 ib_offset = pm8001_ha->ib_offset; in init_default_table_values()
194 u32 ob_offset = pm8001_ha->ob_offset; in init_default_table_values()
195 u32 ci_offset = pm8001_ha->ci_offset; in init_default_table_values()
196 u32 pi_offset = pm8001_ha->pi_offset; in init_default_table_values()
198 pm8001_ha->main_cfg_tbl.pm8001_tbl.inbound_q_nppd_hppd = 0; in init_default_table_values()
199 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_hw_event_pid0_3 = 0; in init_default_table_values()
200 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_hw_event_pid4_7 = 0; in init_default_table_values()
201 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_ncq_event_pid0_3 = 0; in init_default_table_values()
202 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_ncq_event_pid4_7 = 0; in init_default_table_values()
203 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_tgt_ITNexus_event_pid0_3 = in init_default_table_values()
205 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_tgt_ITNexus_event_pid4_7 = in init_default_table_values()
207 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_tgt_ssp_event_pid0_3 = 0; in init_default_table_values()
208 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_tgt_ssp_event_pid4_7 = 0; in init_default_table_values()
209 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_tgt_smp_event_pid0_3 = 0; in init_default_table_values()
210 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_tgt_smp_event_pid4_7 = 0; in init_default_table_values()
212 pm8001_ha->main_cfg_tbl.pm8001_tbl.upper_event_log_addr = in init_default_table_values()
213 pm8001_ha->memoryMap.region[AAP1].phys_addr_hi; in init_default_table_values()
214 pm8001_ha->main_cfg_tbl.pm8001_tbl.lower_event_log_addr = in init_default_table_values()
215 pm8001_ha->memoryMap.region[AAP1].phys_addr_lo; in init_default_table_values()
216 pm8001_ha->main_cfg_tbl.pm8001_tbl.event_log_size = in init_default_table_values()
218 pm8001_ha->main_cfg_tbl.pm8001_tbl.event_log_option = 0x01; in init_default_table_values()
219 pm8001_ha->main_cfg_tbl.pm8001_tbl.upper_iop_event_log_addr = in init_default_table_values()
220 pm8001_ha->memoryMap.region[IOP].phys_addr_hi; in init_default_table_values()
221 pm8001_ha->main_cfg_tbl.pm8001_tbl.lower_iop_event_log_addr = in init_default_table_values()
222 pm8001_ha->memoryMap.region[IOP].phys_addr_lo; in init_default_table_values()
223 pm8001_ha->main_cfg_tbl.pm8001_tbl.iop_event_log_size = in init_default_table_values()
225 pm8001_ha->main_cfg_tbl.pm8001_tbl.iop_event_log_option = 0x01; in init_default_table_values()
226 pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_interrupt = 0x01; in init_default_table_values()
227 for (i = 0; i < pm8001_ha->max_q_num; i++) { in init_default_table_values()
228 pm8001_ha->inbnd_q_tbl[i].element_pri_size_cnt = in init_default_table_values()
229 PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x00<<30); in init_default_table_values()
230 pm8001_ha->inbnd_q_tbl[i].upper_base_addr = in init_default_table_values()
231 pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_hi; in init_default_table_values()
232 pm8001_ha->inbnd_q_tbl[i].lower_base_addr = in init_default_table_values()
233 pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_lo; in init_default_table_values()
234 pm8001_ha->inbnd_q_tbl[i].base_virt = in init_default_table_values()
235 (u8 *)pm8001_ha->memoryMap.region[ib_offset + i].virt_ptr; in init_default_table_values()
236 pm8001_ha->inbnd_q_tbl[i].total_length = in init_default_table_values()
237 pm8001_ha->memoryMap.region[ib_offset + i].total_len; in init_default_table_values()
238 pm8001_ha->inbnd_q_tbl[i].ci_upper_base_addr = in init_default_table_values()
239 pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_hi; in init_default_table_values()
240 pm8001_ha->inbnd_q_tbl[i].ci_lower_base_addr = in init_default_table_values()
241 pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo; in init_default_table_values()
242 pm8001_ha->inbnd_q_tbl[i].ci_virt = in init_default_table_values()
243 pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr; in init_default_table_values()
244 pm8001_write_32(pm8001_ha->inbnd_q_tbl[i].ci_virt, 0, 0); in init_default_table_values()
246 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = in init_default_table_values()
249 pm8001_ha->inbnd_q_tbl[i].pi_offset = in init_default_table_values()
251 pm8001_ha->inbnd_q_tbl[i].producer_idx = 0; in init_default_table_values()
252 pm8001_ha->inbnd_q_tbl[i].consumer_index = 0; in init_default_table_values()
254 for (i = 0; i < pm8001_ha->max_q_num; i++) { in init_default_table_values()
255 pm8001_ha->outbnd_q_tbl[i].element_size_cnt = in init_default_table_values()
256 PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x01<<30); in init_default_table_values()
257 pm8001_ha->outbnd_q_tbl[i].upper_base_addr = in init_default_table_values()
258 pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_hi; in init_default_table_values()
259 pm8001_ha->outbnd_q_tbl[i].lower_base_addr = in init_default_table_values()
260 pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_lo; in init_default_table_values()
261 pm8001_ha->outbnd_q_tbl[i].base_virt = in init_default_table_values()
262 (u8 *)pm8001_ha->memoryMap.region[ob_offset + i].virt_ptr; in init_default_table_values()
263 pm8001_ha->outbnd_q_tbl[i].total_length = in init_default_table_values()
264 pm8001_ha->memoryMap.region[ob_offset + i].total_len; in init_default_table_values()
265 pm8001_ha->outbnd_q_tbl[i].pi_upper_base_addr = in init_default_table_values()
266 pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_hi; in init_default_table_values()
267 pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr = in init_default_table_values()
268 pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_lo; in init_default_table_values()
269 pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = in init_default_table_values()
271 pm8001_ha->outbnd_q_tbl[i].pi_virt = in init_default_table_values()
272 pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr; in init_default_table_values()
273 pm8001_write_32(pm8001_ha->outbnd_q_tbl[i].pi_virt, 0, 0); in init_default_table_values()
275 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = in init_default_table_values()
278 pm8001_ha->outbnd_q_tbl[i].ci_offset = in init_default_table_values()
280 pm8001_ha->outbnd_q_tbl[i].consumer_idx = 0; in init_default_table_values()
281 pm8001_ha->outbnd_q_tbl[i].producer_index = 0; in init_default_table_values()
286 * update_main_config_table - update the main default table to the HBA.
291 void __iomem *address = pm8001_ha->main_cfg_tbl_addr; in update_main_config_table()
293 pm8001_ha->main_cfg_tbl.pm8001_tbl.inbound_q_nppd_hppd); in update_main_config_table()
295 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_hw_event_pid0_3); in update_main_config_table()
297 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_hw_event_pid4_7); in update_main_config_table()
299 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_ncq_event_pid0_3); in update_main_config_table()
301 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_ncq_event_pid4_7); in update_main_config_table()
303 pm8001_ha->main_cfg_tbl.pm8001_tbl. in update_main_config_table()
306 pm8001_ha->main_cfg_tbl.pm8001_tbl. in update_main_config_table()
309 pm8001_ha->main_cfg_tbl.pm8001_tbl. in update_main_config_table()
312 pm8001_ha->main_cfg_tbl.pm8001_tbl. in update_main_config_table()
315 pm8001_ha->main_cfg_tbl.pm8001_tbl. in update_main_config_table()
318 pm8001_ha->main_cfg_tbl.pm8001_tbl. in update_main_config_table()
321 pm8001_ha->main_cfg_tbl.pm8001_tbl.upper_event_log_addr); in update_main_config_table()
323 pm8001_ha->main_cfg_tbl.pm8001_tbl.lower_event_log_addr); in update_main_config_table()
325 pm8001_ha->main_cfg_tbl.pm8001_tbl.event_log_size); in update_main_config_table()
327 pm8001_ha->main_cfg_tbl.pm8001_tbl.event_log_option); in update_main_config_table()
329 pm8001_ha->main_cfg_tbl.pm8001_tbl.upper_iop_event_log_addr); in update_main_config_table()
331 pm8001_ha->main_cfg_tbl.pm8001_tbl.lower_iop_event_log_addr); in update_main_config_table()
333 pm8001_ha->main_cfg_tbl.pm8001_tbl.iop_event_log_size); in update_main_config_table()
335 pm8001_ha->main_cfg_tbl.pm8001_tbl.iop_event_log_option); in update_main_config_table()
337 pm8001_ha->main_cfg_tbl.pm8001_tbl.fatal_err_interrupt); in update_main_config_table()
341 * update_inbnd_queue_table - update the inbound queue table to the HBA.
348 void __iomem *address = pm8001_ha->inbnd_q_tbl_addr; in update_inbnd_queue_table()
351 pm8001_ha->inbnd_q_tbl[number].element_pri_size_cnt); in update_inbnd_queue_table()
353 pm8001_ha->inbnd_q_tbl[number].upper_base_addr); in update_inbnd_queue_table()
355 pm8001_ha->inbnd_q_tbl[number].lower_base_addr); in update_inbnd_queue_table()
357 pm8001_ha->inbnd_q_tbl[number].ci_upper_base_addr); in update_inbnd_queue_table()
359 pm8001_ha->inbnd_q_tbl[number].ci_lower_base_addr); in update_inbnd_queue_table()
363 * update_outbnd_queue_table - update the outbound queue table to the HBA.
370 void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; in update_outbnd_queue_table()
373 pm8001_ha->outbnd_q_tbl[number].element_size_cnt); in update_outbnd_queue_table()
375 pm8001_ha->outbnd_q_tbl[number].upper_base_addr); in update_outbnd_queue_table()
377 pm8001_ha->outbnd_q_tbl[number].lower_base_addr); in update_outbnd_queue_table()
379 pm8001_ha->outbnd_q_tbl[number].pi_upper_base_addr); in update_outbnd_queue_table()
381 pm8001_ha->outbnd_q_tbl[number].pi_lower_base_addr); in update_outbnd_queue_table()
383 pm8001_ha->outbnd_q_tbl[number].interrup_vec_cnt_delay); in update_outbnd_queue_table()
387 * pm8001_bar4_shift - function is called to shift BAR base address
409 return -1; in pm8001_bar4_shift()
435 * Using shifted destination address 0x4_0000:0x1074 + 0x4000*(N-4) (N=4:7) in mpi_set_phys_g3_with_ssc()
437 spin_lock_irqsave(&pm8001_ha->lock, flags); in mpi_set_phys_g3_with_ssc()
438 if (-1 == pm8001_bar4_shift(pm8001_ha, in mpi_set_phys_g3_with_ssc()
440 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in mpi_set_phys_g3_with_ssc()
448 /* shift membase 3 for SAS2_SETTINGS_LOCAL_PHY 4 - 7 */ in mpi_set_phys_g3_with_ssc()
449 if (-1 == pm8001_bar4_shift(pm8001_ha, in mpi_set_phys_g3_with_ssc()
451 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in mpi_set_phys_g3_with_ssc()
455 offset = SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET + 0x4000 * (i-4); in mpi_set_phys_g3_with_ssc()
461 Address: (via MEMBASE-III): in mpi_set_phys_g3_with_ssc()
468 Upon power-up this register will read as 0x8990c016, in mpi_set_phys_g3_with_ssc()
471 This will ensure only down-spreading SSC is enabled on the SPC. in mpi_set_phys_g3_with_ssc()
478 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in mpi_set_phys_g3_with_ssc()
502 spin_lock_irqsave(&pm8001_ha->lock, flags); in mpi_set_open_retry_interval_reg()
503 /* shift bar and set the OPEN_REJECT(RETRY) interval time of PHY 0 -3.*/ in mpi_set_open_retry_interval_reg()
504 if (-1 == pm8001_bar4_shift(pm8001_ha, in mpi_set_open_retry_interval_reg()
506 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in mpi_set_open_retry_interval_reg()
514 if (-1 == pm8001_bar4_shift(pm8001_ha, in mpi_set_open_retry_interval_reg()
516 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in mpi_set_open_retry_interval_reg()
520 offset = OPEN_RETRY_INTERVAL_PHY_4_7_OFFSET + 0x4000 * (i-4); in mpi_set_open_retry_interval_reg()
525 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in mpi_set_open_retry_interval_reg()
530 * mpi_init_check - check firmware initialization status.
547 } while ((value != 0) && (--max_wait_count)); in mpi_init_check()
550 return -1; in mpi_init_check()
551 /* check the MPI-State for initialization */ in mpi_init_check()
553 pm8001_mr32(pm8001_ha->general_stat_tbl_addr, in mpi_init_check()
556 return -1; in mpi_init_check()
560 return -1; in mpi_init_check()
565 * check_fw_ready - The LLDD check if the FW is ready, if not, return error.
579 return -1; in check_fw_ready()
586 return -1; in check_fw_ready()
589 /* bit 4-31 of scratch pad1 should be zeros if it is not in check_fw_ready()
594 return -1; in check_fw_ready()
597 /* bit 2, 4-31 of scratch pad2 should be zeros if it is not in check_fw_ready()
601 return -1; in check_fw_ready()
613 if ((--max_wait_count) == 0) in check_fw_ready()
614 return -1; in check_fw_ready()
633 pm8001_ha->main_cfg_tbl_addr = base_addr = in init_pci_device_addresses()
634 pm8001_ha->io_mem[pcibar].memvirtaddr + offset; in init_pci_device_addresses()
635 pm8001_ha->general_stat_tbl_addr = in init_pci_device_addresses()
637 pm8001_ha->inbnd_q_tbl_addr = in init_pci_device_addresses()
639 pm8001_ha->outbnd_q_tbl_addr = in init_pci_device_addresses()
644 * pm8001_chip_init - the main init function that initialize whole PM8001 chip.
651 pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid); in pm8001_chip_init()
655 if (-1 == pm8001_bar4_shift(pm8001_ha, GSM_SM_BASE)) { in pm8001_chip_init()
659 return -1; in pm8001_chip_init()
663 if (-1 == check_fw_ready(pm8001_ha)) { in pm8001_chip_init()
665 return -EBUSY; in pm8001_chip_init()
677 for (i = 0; i < pm8001_ha->max_q_num; i++) in pm8001_chip_init()
679 for (i = 0; i < pm8001_ha->max_q_num; i++) in pm8001_chip_init()
684 /* 7->130ms, 34->500ms, 119->1.5s */ in pm8001_chip_init()
691 return -EBUSY; in pm8001_chip_init()
692 /*This register is a 16-bit timer with a resolution of 1us. This is the in pm8001_chip_init()
712 pci_read_config_word(pm8001_ha->pdev, PCI_DEVICE_ID, &deviceid); in mpi_uninit_check()
714 if (-1 == pm8001_bar4_shift(pm8001_ha, GSM_SM_BASE)) { in mpi_uninit_check()
718 return -1; in mpi_uninit_check()
732 } while ((value != 0) && (--max_wait_count)); in mpi_uninit_check()
737 return -1; in mpi_uninit_check()
740 /* check the MPI-State for termination in progress */ in mpi_uninit_check()
746 pm8001_mr32(pm8001_ha->general_stat_tbl_addr, in mpi_uninit_check()
751 } while (--max_wait_count); in mpi_uninit_check()
755 return -1; in mpi_uninit_check()
761 * soft_reset_ready_check - Function to check FW is ready for soft reset.
769 return -1; in soft_reset_ready_check()
779 spin_lock_irqsave(&pm8001_ha->lock, flags); in soft_reset_ready_check()
780 if (-1 == pm8001_bar4_shift(pm8001_ha, RB6_ACCESS_REG)) { in soft_reset_ready_check()
781 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in soft_reset_ready_check()
785 return -1; in soft_reset_ready_check()
805 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in soft_reset_ready_check()
806 return -1; in soft_reset_ready_check()
808 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in soft_reset_ready_check()
814 * pm8001_chip_soft_rst - soft reset the PM8001 chip, so that the clear all
830 return -1; in pm8001_chip_soft_rst()
836 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
837 if (-1 == pm8001_bar4_shift(pm8001_ha, MBIC_AAP1_ADDR_BASE)) { in pm8001_chip_soft_rst()
838 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
841 return -1; in pm8001_chip_soft_rst()
844 pm8001_dbg(pm8001_ha, INIT, "MBIC - NMI Enable VPE0 (IOP)= 0x%x\n", in pm8001_chip_soft_rst()
848 if (-1 == pm8001_bar4_shift(pm8001_ha, MBIC_IOP_ADDR_BASE)) { in pm8001_chip_soft_rst()
849 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
852 return -1; in pm8001_chip_soft_rst()
855 pm8001_dbg(pm8001_ha, INIT, "MBIC - NMI Enable VPE0 (AAP1)= 0x%x\n", in pm8001_chip_soft_rst()
860 pm8001_dbg(pm8001_ha, INIT, "PCIE -Event Interrupt Enable = 0x%x\n", in pm8001_chip_soft_rst()
865 pm8001_dbg(pm8001_ha, INIT, "PCIE - Event Interrupt = 0x%x\n", in pm8001_chip_soft_rst()
870 pm8001_dbg(pm8001_ha, INIT, "PCIE -Error Interrupt Enable = 0x%x\n", in pm8001_chip_soft_rst()
875 pm8001_dbg(pm8001_ha, INIT, "PCIE - Error Interrupt = 0x%x\n", regVal); in pm8001_chip_soft_rst()
889 if (-1 == pm8001_bar4_shift(pm8001_ha, GSM_ADDR_BASE)) { in pm8001_chip_soft_rst()
890 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
893 return -1; in pm8001_chip_soft_rst()
896 "GSM 0x0(0x00007b88)-GSM Configuration and Reset = 0x%x\n", in pm8001_chip_soft_rst()
913 "GSM 0x0 (0x00007b88 ==> 0x00004088) - GSM Configuration and Reset is set to = 0x%x\n", in pm8001_chip_soft_rst()
917 /* disable GSM - Read Address Parity Check */ in pm8001_chip_soft_rst()
920 "GSM 0x700038 - Read Address Parity Check Enable = 0x%x\n", in pm8001_chip_soft_rst()
924 "GSM 0x700038 - Read Address Parity Check Enable is set to = 0x%x\n", in pm8001_chip_soft_rst()
927 /* disable GSM - Write Address Parity Check */ in pm8001_chip_soft_rst()
930 "GSM 0x700040 - Write Address Parity Check Enable = 0x%x\n", in pm8001_chip_soft_rst()
934 "GSM 0x700040 - Write Address Parity Check Enable is set to = 0x%x\n", in pm8001_chip_soft_rst()
937 /* disable GSM - Write Data Parity Check */ in pm8001_chip_soft_rst()
939 pm8001_dbg(pm8001_ha, INIT, "GSM 0x300048 - Write Data Parity Check Enable = 0x%x\n", in pm8001_chip_soft_rst()
943 "GSM 0x300048 - Write Data Parity Check Enable is set to = 0x%x\n", in pm8001_chip_soft_rst()
948 /* step 5-b: set GPIO-0 output control to tristate anyway */ in pm8001_chip_soft_rst()
949 if (-1 == pm8001_bar4_shift(pm8001_ha, GPIO_ADDR_BASE)) { in pm8001_chip_soft_rst()
950 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
953 return -1; in pm8001_chip_soft_rst()
958 /* set GPIO-0 output control to tri-state */ in pm8001_chip_soft_rst()
964 if (-1 == pm8001_bar4_shift(pm8001_ha, SPC_TOP_LEVEL_ADDR_BASE)) { in pm8001_chip_soft_rst()
965 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
968 return -1; in pm8001_chip_soft_rst()
999 if (-1 == pm8001_bar4_shift(pm8001_ha, GSM_ADDR_BASE)) { in pm8001_chip_soft_rst()
1000 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
1003 return -1; in pm8001_chip_soft_rst()
1006 "GSM 0x0 (0x00007b88)-GSM Configuration and Reset = 0x%x\n", in pm8001_chip_soft_rst()
1019 …pm8001_dbg(pm8001_ha, INIT, "GSM (0x00004088 ==> 0x00007b88) - GSM Configuration and Reset is set … in pm8001_chip_soft_rst()
1022 /* step 12: Restore GSM - Read Address Parity Check */ in pm8001_chip_soft_rst()
1026 "GSM 0x700038 - Read Address Parity Check Enable = 0x%x\n", in pm8001_chip_soft_rst()
1029 pm8001_dbg(pm8001_ha, INIT, "GSM 0x700038 - Read Address Parity Check Enable is set to = 0x%x\n", in pm8001_chip_soft_rst()
1031 /* Restore GSM - Write Address Parity Check */ in pm8001_chip_soft_rst()
1035 "GSM 0x700040 - Write Address Parity Check Enable is set to = 0x%x\n", in pm8001_chip_soft_rst()
1037 /* Restore GSM - Write Data Parity Check */ in pm8001_chip_soft_rst()
1041 "GSM 0x700048 - Write Data Parity Check Enable is set to = 0x%x\n", in pm8001_chip_soft_rst()
1046 if (-1 == pm8001_bar4_shift(pm8001_ha, SPC_TOP_LEVEL_ADDR_BASE)) { in pm8001_chip_soft_rst()
1047 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
1050 return -1; in pm8001_chip_soft_rst()
1056 /* step 14: delay 10 usec - Normal Mode */ in pm8001_chip_soft_rst()
1067 } while ((regVal != toggleVal) && (--max_wait_count)); in pm8001_chip_soft_rst()
1086 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
1087 return -1; in pm8001_chip_soft_rst()
1090 /* step 16 (Normal) - Clear ODMR and ODCR */ in pm8001_chip_soft_rst()
1095 ready - 1 sec timeout */ in pm8001_chip_soft_rst()
1097 if (check_fw_ready(pm8001_ha) == -1) { in pm8001_chip_soft_rst()
1116 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
1117 return -1; in pm8001_chip_soft_rst()
1121 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_chip_soft_rst()
1153 } while ((--i) != 0); in pm8001_hw_chip_rst()
1159 * pm8001_chip_iounmap - which mapped when initialized.
1168 ** bar 0 and 1 - logical BAR0 in pm8001_chip_iounmap()
1169 ** bar 2 and 3 - logical BAR1 in pm8001_chip_iounmap()
1170 ** bar4 - logical BAR2 in pm8001_chip_iounmap()
1171 ** bar5 - logical BAR3 in pm8001_chip_iounmap()
1176 if (pm8001_ha->io_mem[logical].memvirtaddr) { in pm8001_chip_iounmap()
1177 iounmap(pm8001_ha->io_mem[logical].memvirtaddr); in pm8001_chip_iounmap()
1185 * pm8001_chip_intx_interrupt_enable - enable PM8001 chip interrupt
1196 * pm8001_chip_intx_interrupt_disable - disable PM8001 chip interrupt
1208 * pm8001_chip_msix_interrupt_enable - enable PM8001 chip interrupt
1227 * pm8001_chip_msix_interrupt_disable - disable PM8001 chip interrupt
1243 * pm8001_chip_interrupt_enable - enable PM8001 chip interrupt
1258 * pm8001_chip_interrupt_disable - disable PM8001 chip interrupt
1273 * pm8001_mpi_msg_free_get - get the free message buffer for transfer
1289 return -1; in pm8001_mpi_msg_free_get()
1293 consumer_index = pm8001_read_32(circularQ->ci_virt); in pm8001_mpi_msg_free_get()
1294 circularQ->consumer_index = cpu_to_le32(consumer_index); in pm8001_mpi_msg_free_get()
1295 if (((circularQ->producer_idx + bcCount) % PM8001_MPI_QUEUE) == in pm8001_mpi_msg_free_get()
1296 le32_to_cpu(circularQ->consumer_index)) { in pm8001_mpi_msg_free_get()
1298 return -1; in pm8001_mpi_msg_free_get()
1301 offset = circularQ->producer_idx * messageSize; in pm8001_mpi_msg_free_get()
1303 circularQ->producer_idx = (circularQ->producer_idx + bcCount) in pm8001_mpi_msg_free_get()
1307 msgHeader = (struct mpi_msg_hdr *)(circularQ->base_virt + offset); in pm8001_mpi_msg_free_get()
1313 * pm8001_mpi_build_cmd- build the message queue for transfer, update the PI to
1329 struct inbound_queue_table *circularQ = &pm8001_ha->inbnd_q_tbl[q_index]; in pm8001_mpi_build_cmd()
1333 trace_pm80xx_mpi_build_cmd(pm8001_ha->id, opCode, htag, q_index, in pm8001_mpi_build_cmd()
1334 circularQ->producer_idx, le32_to_cpu(circularQ->consumer_index)); in pm8001_mpi_build_cmd()
1336 if (WARN_ON(q_index >= pm8001_ha->max_q_num)) in pm8001_mpi_build_cmd()
1337 return -EINVAL; in pm8001_mpi_build_cmd()
1339 spin_lock_irqsave(&circularQ->iq_lock, flags); in pm8001_mpi_build_cmd()
1340 rv = pm8001_mpi_msg_free_get(circularQ, pm8001_ha->iomb_size, in pm8001_mpi_build_cmd()
1344 rv = -ENOMEM; in pm8001_mpi_build_cmd()
1348 if (nb > (pm8001_ha->iomb_size - sizeof(struct mpi_msg_hdr))) in pm8001_mpi_build_cmd()
1349 nb = pm8001_ha->iomb_size - sizeof(struct mpi_msg_hdr); in pm8001_mpi_build_cmd()
1351 if (nb + sizeof(struct mpi_msg_hdr) < pm8001_ha->iomb_size) in pm8001_mpi_build_cmd()
1352 memset(pMessage + nb, 0, pm8001_ha->iomb_size - in pm8001_mpi_build_cmd()
1360 pm8001_write_32((pMessage - 4), 0, cpu_to_le32(Header)); in pm8001_mpi_build_cmd()
1362 pm8001_cw32(pm8001_ha, circularQ->pi_pci_bar, in pm8001_mpi_build_cmd()
1363 circularQ->pi_offset, circularQ->producer_idx); in pm8001_mpi_build_cmd()
1366 responseQueue, opCode, circularQ->producer_idx, in pm8001_mpi_build_cmd()
1367 circularQ->consumer_index); in pm8001_mpi_build_cmd()
1369 spin_unlock_irqrestore(&circularQ->iq_lock, flags); in pm8001_mpi_build_cmd()
1380 msgHeader = (struct mpi_msg_hdr *)(pMsg - sizeof(struct mpi_msg_hdr)); in pm8001_mpi_msg_free_set()
1381 pOutBoundMsgHeader = (struct mpi_msg_hdr *)(circularQ->base_virt + in pm8001_mpi_msg_free_set()
1382 circularQ->consumer_idx * pm8001_ha->iomb_size); in pm8001_mpi_msg_free_set()
1386 circularQ->consumer_idx, msgHeader); in pm8001_mpi_msg_free_set()
1389 producer_index = pm8001_read_32(circularQ->pi_virt); in pm8001_mpi_msg_free_set()
1390 circularQ->producer_index = cpu_to_le32(producer_index); in pm8001_mpi_msg_free_set()
1393 circularQ->consumer_idx, in pm8001_mpi_msg_free_set()
1394 circularQ->producer_index, msgHeader); in pm8001_mpi_msg_free_set()
1398 circularQ->consumer_idx = (circularQ->consumer_idx + bc) in pm8001_mpi_msg_free_set()
1401 pm8001_cw32(pm8001_ha, circularQ->ci_pci_bar, circularQ->ci_offset, in pm8001_mpi_msg_free_set()
1402 circularQ->consumer_idx); in pm8001_mpi_msg_free_set()
1404 producer_index = pm8001_read_32(circularQ->pi_virt); in pm8001_mpi_msg_free_set()
1405 circularQ->producer_index = cpu_to_le32(producer_index); in pm8001_mpi_msg_free_set()
1407 circularQ->consumer_idx, circularQ->producer_index); in pm8001_mpi_msg_free_set()
1412 * pm8001_mpi_msg_consume- get the MPI message from outbound queue
1427 /* If there are not-yet-delivered messages ... */ in pm8001_mpi_msg_consume()
1428 if (le32_to_cpu(circularQ->producer_index) in pm8001_mpi_msg_consume()
1429 != circularQ->consumer_idx) { in pm8001_mpi_msg_consume()
1432 (circularQ->base_virt + in pm8001_mpi_msg_consume()
1433 circularQ->consumer_idx * pm8001_ha->iomb_size); in pm8001_mpi_msg_consume()
1439 msgHeader_tmp, circularQ->consumer_idx, in pm8001_mpi_msg_consume()
1440 circularQ->producer_index); in pm8001_mpi_msg_consume()
1451 circularQ->consumer_idx, in pm8001_mpi_msg_consume()
1452 circularQ->producer_index, in pm8001_mpi_msg_consume()
1456 circularQ->consumer_idx = in pm8001_mpi_msg_consume()
1457 (circularQ->consumer_idx + in pm8001_mpi_msg_consume()
1465 circularQ->ci_pci_bar, in pm8001_mpi_msg_consume()
1466 circularQ->ci_offset, in pm8001_mpi_msg_consume()
1467 circularQ->consumer_idx); in pm8001_mpi_msg_consume()
1470 circularQ->consumer_idx = in pm8001_mpi_msg_consume()
1471 (circularQ->consumer_idx + in pm8001_mpi_msg_consume()
1477 pm8001_cw32(pm8001_ha, circularQ->ci_pci_bar, in pm8001_mpi_msg_consume()
1478 circularQ->ci_offset, in pm8001_mpi_msg_consume()
1479 circularQ->consumer_idx); in pm8001_mpi_msg_consume()
1484 void *pi_virt = circularQ->pi_virt; in pm8001_mpi_msg_consume()
1486 * kexec-ing and driver doing a doorbell access in pm8001_mpi_msg_consume()
1487 * with the pre-kexec oq interrupt setup in pm8001_mpi_msg_consume()
1493 circularQ->producer_index = cpu_to_le32(producer_index); in pm8001_mpi_msg_consume()
1495 } while (le32_to_cpu(circularQ->producer_index) != in pm8001_mpi_msg_consume()
1496 circularQ->consumer_idx); in pm8001_mpi_msg_consume()
1497 /* while we don't have any more not-yet-delivered message */ in pm8001_mpi_msg_consume()
1514 if (pw->handler != IO_FATAL_ERROR) { in pm8001_work_fn()
1515 pm8001_dev = pw->data; /* Most stash device structure */ in pm8001_work_fn()
1517 || ((pw->handler != IO_XFER_ERROR_BREAK) in pm8001_work_fn()
1518 && (pm8001_dev->dev_type == SAS_PHY_UNUSED))) { in pm8001_work_fn()
1524 switch (pw->handler) { in pm8001_work_fn()
1529 struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; in pm8001_work_fn()
1536 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_work_fn()
1538 spin_lock_irqsave(&t->task_state_lock, flags1); in pm8001_work_fn()
1539 if (unlikely((t->task_state_flags & SAS_TASK_STATE_DONE))) { in pm8001_work_fn()
1540 spin_unlock_irqrestore(&t->task_state_lock, flags1); in pm8001_work_fn()
1541 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1544 spin_unlock_irqrestore(&t->task_state_lock, flags1); in pm8001_work_fn()
1548 ccb = &pm8001_ha->ccb_info[i]; in pm8001_work_fn()
1549 if ((ccb->ccb_tag != PM8001_INVALID_TAG) && in pm8001_work_fn()
1550 (ccb->task == t)) in pm8001_work_fn()
1554 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1557 ts = &t->task_status; in pm8001_work_fn()
1558 ts->resp = SAS_TASK_COMPLETE; in pm8001_work_fn()
1560 ts->stat = SAS_QUEUE_FULL; in pm8001_work_fn()
1561 pm8001_dev = ccb->device; in pm8001_work_fn()
1563 atomic_dec(&pm8001_dev->running_req); in pm8001_work_fn()
1564 spin_lock_irqsave(&t->task_state_lock, flags1); in pm8001_work_fn()
1565 t->task_state_flags &= ~SAS_TASK_STATE_PENDING; in pm8001_work_fn()
1566 t->task_state_flags |= SAS_TASK_STATE_DONE; in pm8001_work_fn()
1567 if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { in pm8001_work_fn()
1568 spin_unlock_irqrestore(&t->task_state_lock, flags1); in pm8001_work_fn()
1570 t, pw->handler, ts->resp, ts->stat); in pm8001_work_fn()
1572 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1574 spin_unlock_irqrestore(&t->task_state_lock, flags1); in pm8001_work_fn()
1577 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1578 t->task_done(t); in pm8001_work_fn()
1585 struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; in pm8001_work_fn()
1600 spin_lock_irqsave(&pm8001_ha->lock, flags); in pm8001_work_fn()
1602 spin_lock_irqsave(&t->task_state_lock, flags1); in pm8001_work_fn()
1604 if (unlikely((t->task_state_flags & SAS_TASK_STATE_DONE))) { in pm8001_work_fn()
1605 spin_unlock_irqrestore(&t->task_state_lock, flags1); in pm8001_work_fn()
1606 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1612 spin_unlock_irqrestore(&t->task_state_lock, flags1); in pm8001_work_fn()
1616 ccb = &pm8001_ha->ccb_info[i]; in pm8001_work_fn()
1617 if ((ccb->ccb_tag != PM8001_INVALID_TAG) && in pm8001_work_fn()
1618 (ccb->task == t)) in pm8001_work_fn()
1622 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1628 pm8001_dev = ccb->device; in pm8001_work_fn()
1629 dev = pm8001_dev->sas_device; in pm8001_work_fn()
1633 ccb->open_retry = 1; /* Snub completion */ in pm8001_work_fn()
1634 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1636 ccb->open_retry = 0; in pm8001_work_fn()
1643 pm8001_dbg(pm8001_ha, IO, "...Reset phy\n"); in pm8001_work_fn()
1650 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1655 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in pm8001_work_fn()
1657 pm8001_dbg(pm8001_ha, IO, "...Reset phy\n"); in pm8001_work_fn()
1667 dev = pm8001_dev->sas_device; in pm8001_work_fn()
1671 dev = pm8001_dev->sas_device; in pm8001_work_fn()
1675 dev = pm8001_dev->sas_device; in pm8001_work_fn()
1679 dev = pm8001_dev->sas_device; in pm8001_work_fn()
1684 struct pm8001_hba_info *pm8001_ha = pw->pm8001_ha; in pm8001_work_fn()
1692 ccb = &pm8001_ha->ccb_info[i]; in pm8001_work_fn()
1693 task = ccb->task; in pm8001_work_fn()
1694 ts = &task->task_status; in pm8001_work_fn()
1697 dev = task->dev; in pm8001_work_fn()
1705 ts->resp = SAS_TASK_COMPLETE; in pm8001_work_fn()
1706 task->task_done(task); in pm8001_work_fn()
1707 } else if (ccb->ccb_tag != PM8001_INVALID_TAG) { in pm8001_work_fn()
1708 /* complete the internal commands/non-sas task */ in pm8001_work_fn()
1709 pm8001_dev = ccb->device; in pm8001_work_fn()
1710 if (pm8001_dev->dcompletion) { in pm8001_work_fn()
1711 complete(pm8001_dev->dcompletion); in pm8001_work_fn()
1712 pm8001_dev->dcompletion = NULL; in pm8001_work_fn()
1714 complete(pm8001_ha->nvmd_completion); in pm8001_work_fn()
1720 pm8001_dev = &pm8001_ha->devices[i]; in pm8001_work_fn()
1721 device_id = pm8001_dev->device_id; in pm8001_work_fn()
1723 PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id); in pm8001_work_fn()
1740 pw->pm8001_ha = pm8001_ha; in pm8001_handle_event()
1741 pw->data = data; in pm8001_handle_event()
1742 pw->handler = handler; in pm8001_handle_event()
1743 INIT_WORK(&pw->work, pm8001_work_fn); in pm8001_handle_event()
1744 queue_work(pm8001_wq, &pw->work); in pm8001_handle_event()
1746 ret = -ENOMEM; in pm8001_handle_event()
1760 pm8001_ha_dev->id |= NCQ_ABORT_ALL_FLAG; in pm8001_send_abort_all()
1761 pm8001_ha_dev->id &= ~NCQ_READ_LOG_FLAG; in pm8001_send_abort_all()
1769 task->task_done = pm8001_task_done; in pm8001_send_abort_all()
1779 task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); in pm8001_send_abort_all()
1780 task_abort.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_send_abort_all()
1806 task->task_done = pm8001_task_done; in pm8001_send_read_log()
1819 task->dev = dev; in pm8001_send_read_log()
1820 task->dev->lldd_dev = pm8001_ha_dev; in pm8001_send_read_log()
1829 pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; in pm8001_send_read_log()
1830 pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; in pm8001_send_read_log()
1841 sata_cmd.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_send_read_log()
1842 sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); in pm8001_send_read_log()
1856 * mpi_ssp_completion- process the event that FW response to the SSP request.
1880 status = le32_to_cpu(psspPayload->status); in mpi_ssp_completion()
1881 tag = le32_to_cpu(psspPayload->tag); in mpi_ssp_completion()
1882 ccb = &pm8001_ha->ccb_info[tag]; in mpi_ssp_completion()
1883 if ((status == IO_ABORTED) && ccb->open_retry) { in mpi_ssp_completion()
1885 ccb->open_retry = 0; in mpi_ssp_completion()
1888 pm8001_dev = ccb->device; in mpi_ssp_completion()
1889 param = le32_to_cpu(psspPayload->param); in mpi_ssp_completion()
1891 t = ccb->task; in mpi_ssp_completion()
1895 if (unlikely(!t || !t->lldd_task || !t->dev)) in mpi_ssp_completion()
1897 ts = &t->task_status; in mpi_ssp_completion()
1902 SAS_ADDR(t->dev->sas_addr)); in mpi_ssp_completion()
1914 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1915 ts->stat = SAS_SAM_STAT_GOOD; in mpi_ssp_completion()
1917 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1918 ts->stat = SAS_PROTO_RESPONSE; in mpi_ssp_completion()
1919 ts->residual = param; in mpi_ssp_completion()
1920 iu = &psspPayload->ssp_resp_iu; in mpi_ssp_completion()
1921 sas_ssp_task_response(pm8001_ha->dev, t, iu); in mpi_ssp_completion()
1924 atomic_dec(&pm8001_dev->running_req); in mpi_ssp_completion()
1928 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1929 ts->stat = SAS_ABORTED_TASK; in mpi_ssp_completion()
1935 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1936 ts->stat = SAS_DATA_UNDERRUN; in mpi_ssp_completion()
1937 ts->residual = param; in mpi_ssp_completion()
1939 atomic_dec(&pm8001_dev->running_req); in mpi_ssp_completion()
1943 ts->resp = SAS_TASK_UNDELIVERED; in mpi_ssp_completion()
1944 ts->stat = SAS_PHY_DOWN; in mpi_ssp_completion()
1948 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1949 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1951 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_completion()
1955 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1956 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1957 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_completion()
1962 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1963 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1964 ts->open_rej_reason = SAS_OREJ_EPROTO; in mpi_ssp_completion()
1969 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1970 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1971 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_ssp_completion()
1975 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1976 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1977 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_completion()
1981 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1982 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1983 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_ssp_completion()
1984 if (!t->uldd_task) in mpi_ssp_completion()
1992 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1993 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
1994 ts->open_rej_reason = SAS_OREJ_BAD_DEST; in mpi_ssp_completion()
1998 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
1999 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2000 ts->open_rej_reason = SAS_OREJ_CONN_RATE; in mpi_ssp_completion()
2005 ts->resp = SAS_TASK_UNDELIVERED; in mpi_ssp_completion()
2006 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2007 ts->open_rej_reason = SAS_OREJ_WRONG_DEST; in mpi_ssp_completion()
2011 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2012 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2013 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_completion()
2017 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2018 ts->stat = SAS_NAK_R_ERR; in mpi_ssp_completion()
2022 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2023 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2027 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2028 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2029 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_completion()
2033 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2034 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2038 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2039 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2043 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2044 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2045 if (!t->uldd_task) in mpi_ssp_completion()
2052 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2053 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2057 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2058 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2062 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2063 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2068 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2069 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2070 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_completion()
2075 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_completion()
2076 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_completion()
2080 psspPayload->ssp_resp_iu.status); in mpi_ssp_completion()
2081 spin_lock_irqsave(&t->task_state_lock, flags); in mpi_ssp_completion()
2082 t->task_state_flags &= ~SAS_TASK_STATE_PENDING; in mpi_ssp_completion()
2083 t->task_state_flags |= SAS_TASK_STATE_DONE; in mpi_ssp_completion()
2084 if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { in mpi_ssp_completion()
2085 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_ssp_completion()
2087 t, status, ts->resp, ts->stat); in mpi_ssp_completion()
2090 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_ssp_completion()
2093 t->task_done(t); in mpi_ssp_completion()
2107 u32 event = le32_to_cpu(psspPayload->event); in mpi_ssp_event()
2108 u32 tag = le32_to_cpu(psspPayload->tag); in mpi_ssp_event()
2109 u32 port_id = le32_to_cpu(psspPayload->port_id); in mpi_ssp_event()
2110 u32 dev_id = le32_to_cpu(psspPayload->device_id); in mpi_ssp_event()
2112 ccb = &pm8001_ha->ccb_info[tag]; in mpi_ssp_event()
2113 t = ccb->task; in mpi_ssp_event()
2114 pm8001_dev = ccb->device; in mpi_ssp_event()
2117 if (unlikely(!t || !t->lldd_task || !t->dev)) in mpi_ssp_event()
2119 ts = &t->task_status; in mpi_ssp_event()
2125 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2126 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2127 ts->residual = 0; in mpi_ssp_event()
2129 atomic_dec(&pm8001_dev->running_req); in mpi_ssp_event()
2137 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2138 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2139 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_event()
2143 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2144 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2145 ts->open_rej_reason = SAS_OREJ_EPROTO; in mpi_ssp_event()
2150 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2151 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2152 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_ssp_event()
2156 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2157 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2158 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_event()
2162 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2163 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2164 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_ssp_event()
2165 if (!t->uldd_task) in mpi_ssp_event()
2173 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2174 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2175 ts->open_rej_reason = SAS_OREJ_BAD_DEST; in mpi_ssp_event()
2179 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2180 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2181 ts->open_rej_reason = SAS_OREJ_CONN_RATE; in mpi_ssp_event()
2186 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2187 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2188 ts->open_rej_reason = SAS_OREJ_WRONG_DEST; in mpi_ssp_event()
2192 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2193 ts->stat = SAS_OPEN_REJECT; in mpi_ssp_event()
2194 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_ssp_event()
2198 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2199 ts->stat = SAS_NAK_R_ERR; in mpi_ssp_event()
2207 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2208 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2212 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2213 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2218 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2219 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2224 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2225 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2229 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2230 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2235 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2236 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2244 ts->resp = SAS_TASK_COMPLETE; in mpi_ssp_event()
2245 ts->stat = SAS_DATA_OVERRUN; in mpi_ssp_event()
2248 spin_lock_irqsave(&t->task_state_lock, flags); in mpi_ssp_event()
2249 t->task_state_flags &= ~SAS_TASK_STATE_PENDING; in mpi_ssp_event()
2250 t->task_state_flags |= SAS_TASK_STATE_DONE; in mpi_ssp_event()
2251 if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { in mpi_ssp_event()
2252 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_ssp_event()
2254 t, event, ts->resp, ts->stat); in mpi_ssp_event()
2257 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_ssp_event()
2260 t->task_done(t); in mpi_ssp_event()
2286 status = le32_to_cpu(psataPayload->status); in mpi_sata_completion()
2287 param = le32_to_cpu(psataPayload->param); in mpi_sata_completion()
2288 tag = le32_to_cpu(psataPayload->tag); in mpi_sata_completion()
2290 ccb = &pm8001_ha->ccb_info[tag]; in mpi_sata_completion()
2291 t = ccb->task; in mpi_sata_completion()
2292 pm8001_dev = ccb->device; in mpi_sata_completion()
2295 if (t->dev && (t->dev->lldd_dev)) in mpi_sata_completion()
2296 pm8001_dev = t->dev->lldd_dev; in mpi_sata_completion()
2302 if ((pm8001_dev && !(pm8001_dev->id & NCQ_READ_LOG_FLAG)) in mpi_sata_completion()
2303 && unlikely(!t || !t->lldd_task || !t->dev)) { in mpi_sata_completion()
2308 ts = &t->task_status; in mpi_sata_completion()
2318 if (!((t->dev->parent) && in mpi_sata_completion()
2319 (dev_is_expander(t->dev->parent->dev_type)))) { in mpi_sata_completion()
2321 sata_addr_low[i] = pm8001_ha->sas_addr[j]; in mpi_sata_completion()
2323 sata_addr_hi[i] = pm8001_ha->sas_addr[j]; in mpi_sata_completion()
2343 pm8001_dev->attached_phy + in mpi_sata_completion()
2352 SAS_ADDR(t->dev->sas_addr)); in mpi_sata_completion()
2359 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2360 ts->stat = SAS_SAM_STAT_GOOD; in mpi_sata_completion()
2363 (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { in mpi_sata_completion()
2372 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2373 ts->stat = SAS_PROTO_RESPONSE; in mpi_sata_completion()
2374 ts->residual = param; in mpi_sata_completion()
2378 sata_resp = &psataPayload->sata_resp[0]; in mpi_sata_completion()
2379 resp = (struct ata_task_resp *)ts->buf; in mpi_sata_completion()
2380 if (t->ata_task.dma_xfer == 0 && in mpi_sata_completion()
2381 t->data_dir == DMA_FROM_DEVICE) { in mpi_sata_completion()
2385 } else if (t->ata_task.use_ncq && in mpi_sata_completion()
2386 t->data_dir != DMA_NONE) { in mpi_sata_completion()
2396 resp->frame_len = len; in mpi_sata_completion()
2397 memcpy(&resp->ending_fis[0], sata_resp, len); in mpi_sata_completion()
2398 ts->buf_valid_size = sizeof(*resp); in mpi_sata_completion()
2404 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2408 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2409 ts->stat = SAS_ABORTED_TASK; in mpi_sata_completion()
2411 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2417 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2418 ts->stat = SAS_DATA_UNDERRUN; in mpi_sata_completion()
2419 ts->residual = param; in mpi_sata_completion()
2421 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2425 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2426 ts->stat = SAS_PHY_DOWN; in mpi_sata_completion()
2428 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2432 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2433 ts->stat = SAS_INTERRUPTED; in mpi_sata_completion()
2435 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2439 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2440 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2441 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_sata_completion()
2443 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2447 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2448 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2449 ts->open_rej_reason = SAS_OREJ_EPROTO; in mpi_sata_completion()
2451 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2456 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2457 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2458 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_sata_completion()
2460 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2464 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2465 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2466 ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; in mpi_sata_completion()
2468 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2472 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2473 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2474 if (!t->uldd_task) { in mpi_sata_completion()
2478 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2479 ts->stat = SAS_QUEUE_FULL; in mpi_sata_completion()
2487 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2488 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2489 ts->open_rej_reason = SAS_OREJ_BAD_DEST; in mpi_sata_completion()
2490 if (!t->uldd_task) { in mpi_sata_completion()
2494 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2495 ts->stat = SAS_QUEUE_FULL; in mpi_sata_completion()
2502 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2503 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2504 ts->open_rej_reason = SAS_OREJ_CONN_RATE; in mpi_sata_completion()
2506 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2510 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2511 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2512 if (!t->uldd_task) { in mpi_sata_completion()
2516 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2517 ts->stat = SAS_QUEUE_FULL; in mpi_sata_completion()
2525 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2526 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2527 ts->open_rej_reason = SAS_OREJ_WRONG_DEST; in mpi_sata_completion()
2529 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2533 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2534 ts->stat = SAS_NAK_R_ERR; in mpi_sata_completion()
2536 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2540 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2541 ts->stat = SAS_NAK_R_ERR; in mpi_sata_completion()
2543 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2547 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2548 ts->stat = SAS_ABORTED_TASK; in mpi_sata_completion()
2550 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2554 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2555 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2557 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2561 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2562 ts->stat = SAS_DATA_UNDERRUN; in mpi_sata_completion()
2564 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2568 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2569 ts->stat = SAS_OPEN_TO; in mpi_sata_completion()
2571 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2575 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2576 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2578 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2582 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2583 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2584 if (!t->uldd_task) { in mpi_sata_completion()
2587 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2588 ts->stat = SAS_QUEUE_FULL; in mpi_sata_completion()
2595 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2596 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2598 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2602 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2603 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2604 if (!t->uldd_task) { in mpi_sata_completion()
2607 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_completion()
2608 ts->stat = SAS_QUEUE_FULL; in mpi_sata_completion()
2616 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2617 ts->stat = SAS_OPEN_REJECT; in mpi_sata_completion()
2618 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_sata_completion()
2620 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2625 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_completion()
2626 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_completion()
2628 atomic_dec(&pm8001_dev->running_req); in mpi_sata_completion()
2631 spin_lock_irqsave(&t->task_state_lock, flags); in mpi_sata_completion()
2632 t->task_state_flags &= ~SAS_TASK_STATE_PENDING; in mpi_sata_completion()
2633 t->task_state_flags |= SAS_TASK_STATE_DONE; in mpi_sata_completion()
2634 if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { in mpi_sata_completion()
2635 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_sata_completion()
2638 t, status, ts->resp, ts->stat); in mpi_sata_completion()
2641 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_sata_completion()
2655 u32 event = le32_to_cpu(psataPayload->event); in mpi_sata_event()
2656 u32 tag = le32_to_cpu(psataPayload->tag); in mpi_sata_event()
2657 u32 port_id = le32_to_cpu(psataPayload->port_id); in mpi_sata_event()
2658 u32 dev_id = le32_to_cpu(psataPayload->device_id); in mpi_sata_event()
2673 ccb = &pm8001_ha->ccb_info[tag]; in mpi_sata_event()
2674 t = ccb->task; in mpi_sata_event()
2675 pm8001_dev = ccb->device; in mpi_sata_event()
2678 if (unlikely(!t || !t->lldd_task || !t->dev)) in mpi_sata_event()
2680 ts = &t->task_status; in mpi_sata_event()
2687 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2688 ts->stat = SAS_DATA_OVERRUN; in mpi_sata_event()
2689 ts->residual = 0; in mpi_sata_event()
2693 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2694 ts->stat = SAS_INTERRUPTED; in mpi_sata_event()
2698 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2699 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2700 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_sata_event()
2704 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2705 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2706 ts->open_rej_reason = SAS_OREJ_EPROTO; in mpi_sata_event()
2711 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2712 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2713 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_sata_event()
2717 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2718 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2719 ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; in mpi_sata_event()
2723 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_event()
2724 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_sata_event()
2725 if (!t->uldd_task) { in mpi_sata_event()
2729 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2730 ts->stat = SAS_QUEUE_FULL; in mpi_sata_event()
2737 ts->resp = SAS_TASK_UNDELIVERED; in mpi_sata_event()
2738 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2739 ts->open_rej_reason = SAS_OREJ_BAD_DEST; in mpi_sata_event()
2743 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2744 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2745 ts->open_rej_reason = SAS_OREJ_CONN_RATE; in mpi_sata_event()
2750 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2751 ts->stat = SAS_OPEN_REJECT; in mpi_sata_event()
2752 ts->open_rej_reason = SAS_OREJ_WRONG_DEST; in mpi_sata_event()
2756 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2757 ts->stat = SAS_NAK_R_ERR; in mpi_sata_event()
2761 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2762 ts->stat = SAS_NAK_R_ERR; in mpi_sata_event()
2766 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2767 ts->stat = SAS_DATA_UNDERRUN; in mpi_sata_event()
2771 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2772 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2776 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2777 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2781 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2782 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2787 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2788 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2792 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2793 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2798 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2799 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2806 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2807 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2812 ts->resp = SAS_TASK_COMPLETE; in mpi_sata_event()
2813 ts->stat = SAS_OPEN_TO; in mpi_sata_event()
2832 status = le32_to_cpu(psmpPayload->status); in mpi_smp_completion()
2833 tag = le32_to_cpu(psmpPayload->tag); in mpi_smp_completion()
2835 ccb = &pm8001_ha->ccb_info[tag]; in mpi_smp_completion()
2836 t = ccb->task; in mpi_smp_completion()
2837 ts = &t->task_status; in mpi_smp_completion()
2838 pm8001_dev = ccb->device; in mpi_smp_completion()
2845 if (unlikely(!t || !t->lldd_task || !t->dev)) in mpi_smp_completion()
2851 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2852 ts->stat = SAS_SAM_STAT_GOOD; in mpi_smp_completion()
2854 atomic_dec(&pm8001_dev->running_req); in mpi_smp_completion()
2858 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2859 ts->stat = SAS_ABORTED_TASK; in mpi_smp_completion()
2861 atomic_dec(&pm8001_dev->running_req); in mpi_smp_completion()
2865 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2866 ts->stat = SAS_DATA_OVERRUN; in mpi_smp_completion()
2867 ts->residual = 0; in mpi_smp_completion()
2869 atomic_dec(&pm8001_dev->running_req); in mpi_smp_completion()
2873 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2874 ts->stat = SAS_PHY_DOWN; in mpi_smp_completion()
2878 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2879 ts->stat = SAS_SAM_STAT_BUSY; in mpi_smp_completion()
2883 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2884 ts->stat = SAS_SAM_STAT_BUSY; in mpi_smp_completion()
2888 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2889 ts->stat = SAS_SAM_STAT_BUSY; in mpi_smp_completion()
2894 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2895 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2896 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_smp_completion()
2901 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2902 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2903 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_smp_completion()
2907 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2908 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2909 ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; in mpi_smp_completion()
2913 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2914 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2915 ts->open_rej_reason = SAS_OREJ_UNKNOWN; in mpi_smp_completion()
2923 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2924 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2925 ts->open_rej_reason = SAS_OREJ_BAD_DEST; in mpi_smp_completion()
2929 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2930 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2931 ts->open_rej_reason = SAS_OREJ_CONN_RATE; in mpi_smp_completion()
2936 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2937 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2938 ts->open_rej_reason = SAS_OREJ_WRONG_DEST; in mpi_smp_completion()
2942 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2943 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_smp_completion()
2947 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2948 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2949 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_smp_completion()
2953 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2954 ts->stat = SAS_QUEUE_FULL; in mpi_smp_completion()
2958 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2959 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2960 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_smp_completion()
2964 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2965 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_smp_completion()
2969 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2970 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2971 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_smp_completion()
2976 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2977 ts->stat = SAS_OPEN_REJECT; in mpi_smp_completion()
2978 ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; in mpi_smp_completion()
2982 ts->resp = SAS_TASK_COMPLETE; in mpi_smp_completion()
2983 ts->stat = SAS_DEV_NO_RESPONSE; in mpi_smp_completion()
2987 spin_lock_irqsave(&t->task_state_lock, flags); in mpi_smp_completion()
2988 t->task_state_flags &= ~SAS_TASK_STATE_PENDING; in mpi_smp_completion()
2989 t->task_state_flags |= SAS_TASK_STATE_DONE; in mpi_smp_completion()
2990 if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { in mpi_smp_completion()
2991 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_smp_completion()
2993 t, status, ts->resp, ts->stat); in mpi_smp_completion()
2996 spin_unlock_irqrestore(&t->task_state_lock, flags); in mpi_smp_completion()
3006 u32 tag = le32_to_cpu(pPayload->tag); in pm8001_mpi_set_dev_state_resp()
3007 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; in pm8001_mpi_set_dev_state_resp()
3008 struct pm8001_device *pm8001_dev = ccb->device; in pm8001_mpi_set_dev_state_resp()
3009 u32 status = le32_to_cpu(pPayload->status); in pm8001_mpi_set_dev_state_resp()
3010 u32 device_id = le32_to_cpu(pPayload->device_id); in pm8001_mpi_set_dev_state_resp()
3011 u8 pds = le32_to_cpu(pPayload->pds_nds) & PDS_BITS; in pm8001_mpi_set_dev_state_resp()
3012 u8 nds = le32_to_cpu(pPayload->pds_nds) & NDS_BITS; in pm8001_mpi_set_dev_state_resp()
3017 complete(pm8001_dev->setds_completion); in pm8001_mpi_set_dev_state_resp()
3025 u32 tag = le32_to_cpu(pPayload->tag); in pm8001_mpi_set_nvmd_resp()
3026 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; in pm8001_mpi_set_nvmd_resp()
3027 u32 dlen_status = le32_to_cpu(pPayload->dlen_status); in pm8001_mpi_set_nvmd_resp()
3029 complete(pm8001_ha->nvmd_completion); in pm8001_mpi_set_nvmd_resp()
3044 u32 tag = le32_to_cpu(pPayload->tag); in pm8001_mpi_get_nvmd_resp()
3045 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; in pm8001_mpi_get_nvmd_resp()
3046 u32 dlen_status = le32_to_cpu(pPayload->dlen_status); in pm8001_mpi_get_nvmd_resp()
3048 le32_to_cpu(pPayload->ir_tda_bn_dps_das_nvm); in pm8001_mpi_get_nvmd_resp()
3049 void *virt_addr = pm8001_ha->memoryMap.region[NVMD].virt_ptr; in pm8001_mpi_get_nvmd_resp()
3050 fw_control_context = ccb->fw_control_context; in pm8001_mpi_get_nvmd_resp()
3056 complete(pm8001_ha->nvmd_completion); in pm8001_mpi_get_nvmd_resp()
3064 /* indirect mode - IR bit set */ in pm8001_mpi_get_nvmd_resp()
3068 memcpy(pm8001_ha->sas_addr, in pm8001_mpi_get_nvmd_resp()
3094 memcpy(fw_control_context->usrAddr, in pm8001_mpi_get_nvmd_resp()
3095 pm8001_ha->memoryMap.region[NVMD].virt_ptr, in pm8001_mpi_get_nvmd_resp()
3096 fw_control_context->len); in pm8001_mpi_get_nvmd_resp()
3097 kfree(ccb->fw_control_context); in pm8001_mpi_get_nvmd_resp()
3100 * fw_control_context->usrAddr in pm8001_mpi_get_nvmd_resp()
3102 complete(pm8001_ha->nvmd_completion); in pm8001_mpi_get_nvmd_resp()
3112 u32 status = le32_to_cpu(pPayload->status); in pm8001_mpi_local_phy_ctl()
3113 u32 phy_id = le32_to_cpu(pPayload->phyop_phyid) & ID_BITS; in pm8001_mpi_local_phy_ctl()
3114 u32 phy_op = le32_to_cpu(pPayload->phyop_phyid) & OP_BITS; in pm8001_mpi_local_phy_ctl()
3115 tag = le32_to_cpu(pPayload->tag); in pm8001_mpi_local_phy_ctl()
3118 "%x phy execute %x phy op failed!\n", in pm8001_mpi_local_phy_ctl()
3122 "%x phy execute %x phy op success!\n", in pm8001_mpi_local_phy_ctl()
3124 pm8001_ha->phy[phy_id].reset_success = true; in pm8001_mpi_local_phy_ctl()
3126 if (pm8001_ha->phy[phy_id].enable_completion) { in pm8001_mpi_local_phy_ctl()
3127 complete(pm8001_ha->phy[phy_id].enable_completion); in pm8001_mpi_local_phy_ctl()
3128 pm8001_ha->phy[phy_id].enable_completion = NULL; in pm8001_mpi_local_phy_ctl()
3135 * pm8001_bytes_dmaed - one of the interface function communication with libsas
3137 * @i: which phy that received the event.
3147 struct pm8001_phy *phy = &pm8001_ha->phy[i]; in pm8001_bytes_dmaed() local
3148 struct asd_sas_phy *sas_phy = &phy->sas_phy; in pm8001_bytes_dmaed()
3149 if (!phy->phy_attached) in pm8001_bytes_dmaed()
3152 if (phy->phy_type & PORT_TYPE_SAS) { in pm8001_bytes_dmaed()
3154 id = (struct sas_identify_frame *)phy->frame_rcvd; in pm8001_bytes_dmaed()
3155 id->dev_type = phy->identify.device_type; in pm8001_bytes_dmaed()
3156 id->initiator_bits = SAS_PROTOCOL_ALL; in pm8001_bytes_dmaed()
3157 id->target_bits = phy->identify.target_port_protocols; in pm8001_bytes_dmaed()
3158 } else if (phy->phy_type & PORT_TYPE_SATA) { in pm8001_bytes_dmaed()
3161 pm8001_dbg(pm8001_ha, MSG, "phy %d byte dmaded.\n", i); in pm8001_bytes_dmaed()
3163 sas_phy->frame_rcvd_size = phy->frame_rcvd_size; in pm8001_bytes_dmaed()
3168 void pm8001_get_lrate_mode(struct pm8001_phy *phy, u8 link_rate) in pm8001_get_lrate_mode() argument
3170 struct sas_phy *sas_phy = phy->sas_phy.phy; in pm8001_get_lrate_mode()
3174 phy->sas_phy.linkrate = SAS_LINK_RATE_12_0_GBPS; in pm8001_get_lrate_mode()
3177 phy->sas_phy.linkrate = SAS_LINK_RATE_6_0_GBPS; in pm8001_get_lrate_mode()
3180 phy->sas_phy.linkrate = SAS_LINK_RATE_3_0_GBPS; in pm8001_get_lrate_mode()
3183 phy->sas_phy.linkrate = SAS_LINK_RATE_1_5_GBPS; in pm8001_get_lrate_mode()
3186 sas_phy->negotiated_linkrate = phy->sas_phy.linkrate; in pm8001_get_lrate_mode()
3187 sas_phy->maximum_linkrate_hw = phy->maximum_linkrate; in pm8001_get_lrate_mode()
3188 sas_phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; in pm8001_get_lrate_mode()
3189 sas_phy->maximum_linkrate = phy->maximum_linkrate; in pm8001_get_lrate_mode()
3190 sas_phy->minimum_linkrate = phy->minimum_linkrate; in pm8001_get_lrate_mode()
3194 * pm8001_get_attached_sas_addr - extract/generate attached SAS address
3195 * @phy: pointer to asd_phy
3205 void pm8001_get_attached_sas_addr(struct pm8001_phy *phy, in pm8001_get_attached_sas_addr() argument
3208 if (phy->sas_phy.frame_rcvd[0] == 0x34 in pm8001_get_attached_sas_addr()
3209 && phy->sas_phy.oob_mode == SATA_OOB_MODE) { in pm8001_get_attached_sas_addr()
3210 struct pm8001_hba_info *pm8001_ha = phy->sas_phy.ha->lldd_ha; in pm8001_get_attached_sas_addr()
3211 /* FIS device-to-host */ in pm8001_get_attached_sas_addr()
3212 u64 addr = be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr); in pm8001_get_attached_sas_addr()
3213 addr += phy->sas_phy.id; in pm8001_get_attached_sas_addr()
3217 (void *) phy->sas_phy.frame_rcvd; in pm8001_get_attached_sas_addr()
3218 memcpy(sas_addr, idframe->sas_addr, SAS_ADDR_SIZE); in pm8001_get_attached_sas_addr()
3223 * pm8001_hw_event_ack_req- For PM8001,some events need to acknowage to FW.
3228 * @phyId: phy id.
3252 * hw_event_sas_phy_up -FW tells me a SAS phy up event.
3262 le32_to_cpu(pPayload->lr_evt_status_phyid_portid); in hw_event_sas_phy_up()
3268 u32 npip_portstate = le32_to_cpu(pPayload->npip_portstate); in hw_event_sas_phy_up()
3270 struct pm8001_port *port = &pm8001_ha->port[port_id]; in hw_event_sas_phy_up()
3271 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; in hw_event_sas_phy_up() local
3273 u8 deviceType = pPayload->sas_identify.dev_type; in hw_event_sas_phy_up()
3274 phy->port = port; in hw_event_sas_phy_up()
3275 port->port_id = port_id; in hw_event_sas_phy_up()
3276 port->port_state = portstate; in hw_event_sas_phy_up()
3277 phy->phy_state = PHY_STATE_LINK_UP_SPC; in hw_event_sas_phy_up()
3279 "HW_EVENT_SAS_PHY_UP port id = %d, phy id = %d\n", in hw_event_sas_phy_up()
3290 port->port_attached = 1; in hw_event_sas_phy_up()
3291 pm8001_get_lrate_mode(phy, link_rate); in hw_event_sas_phy_up()
3295 port->port_attached = 1; in hw_event_sas_phy_up()
3296 pm8001_get_lrate_mode(phy, link_rate); in hw_event_sas_phy_up()
3300 port->port_attached = 1; in hw_event_sas_phy_up()
3301 pm8001_get_lrate_mode(phy, link_rate); in hw_event_sas_phy_up()
3308 phy->phy_type |= PORT_TYPE_SAS; in hw_event_sas_phy_up()
3309 phy->identify.device_type = deviceType; in hw_event_sas_phy_up()
3310 phy->phy_attached = 1; in hw_event_sas_phy_up()
3311 if (phy->identify.device_type == SAS_END_DEVICE) in hw_event_sas_phy_up()
3312 phy->identify.target_port_protocols = SAS_PROTOCOL_SSP; in hw_event_sas_phy_up()
3313 else if (phy->identify.device_type != SAS_PHY_UNUSED) in hw_event_sas_phy_up()
3314 phy->identify.target_port_protocols = SAS_PROTOCOL_SMP; in hw_event_sas_phy_up()
3315 phy->sas_phy.oob_mode = SAS_OOB_MODE; in hw_event_sas_phy_up()
3316 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE, GFP_ATOMIC); in hw_event_sas_phy_up()
3317 spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); in hw_event_sas_phy_up()
3318 memcpy(phy->frame_rcvd, &pPayload->sas_identify, in hw_event_sas_phy_up()
3319 sizeof(struct sas_identify_frame)-4); in hw_event_sas_phy_up()
3320 phy->frame_rcvd_size = sizeof(struct sas_identify_frame) - 4; in hw_event_sas_phy_up()
3321 pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); in hw_event_sas_phy_up()
3322 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); in hw_event_sas_phy_up()
3323 if (pm8001_ha->flags == PM8001F_RUN_TIME) in hw_event_sas_phy_up()
3329 * hw_event_sata_phy_up -FW tells me a SATA phy up event.
3339 le32_to_cpu(pPayload->lr_evt_status_phyid_portid); in hw_event_sata_phy_up()
3345 u32 npip_portstate = le32_to_cpu(pPayload->npip_portstate); in hw_event_sata_phy_up()
3347 struct pm8001_port *port = &pm8001_ha->port[port_id]; in hw_event_sata_phy_up()
3348 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; in hw_event_sata_phy_up() local
3350 pm8001_dbg(pm8001_ha, DEVIO, "HW_EVENT_SATA_PHY_UP port id = %d, phy id = %d\n", in hw_event_sata_phy_up()
3352 phy->port = port; in hw_event_sata_phy_up()
3353 port->port_id = port_id; in hw_event_sata_phy_up()
3354 port->port_state = portstate; in hw_event_sata_phy_up()
3355 phy->phy_state = PHY_STATE_LINK_UP_SPC; in hw_event_sata_phy_up()
3356 port->port_attached = 1; in hw_event_sata_phy_up()
3357 pm8001_get_lrate_mode(phy, link_rate); in hw_event_sata_phy_up()
3358 phy->phy_type |= PORT_TYPE_SATA; in hw_event_sata_phy_up()
3359 phy->phy_attached = 1; in hw_event_sata_phy_up()
3360 phy->sas_phy.oob_mode = SATA_OOB_MODE; in hw_event_sata_phy_up()
3361 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE, GFP_ATOMIC); in hw_event_sata_phy_up()
3362 spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); in hw_event_sata_phy_up()
3363 memcpy(phy->frame_rcvd, ((u8 *)&pPayload->sata_fis - 4), in hw_event_sata_phy_up()
3365 phy->frame_rcvd_size = sizeof(struct dev_to_host_fis); in hw_event_sata_phy_up()
3366 phy->identify.target_port_protocols = SAS_PROTOCOL_SATA; in hw_event_sata_phy_up()
3367 phy->identify.device_type = SAS_SATA_DEV; in hw_event_sata_phy_up()
3368 pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); in hw_event_sata_phy_up()
3369 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); in hw_event_sata_phy_up()
3374 * hw_event_phy_down -we should notify the libsas the phy is down.
3384 le32_to_cpu(pPayload->lr_evt_status_phyid_portid); in hw_event_phy_down()
3388 u32 npip_portstate = le32_to_cpu(pPayload->npip_portstate); in hw_event_phy_down()
3390 struct pm8001_port *port = &pm8001_ha->port[port_id]; in hw_event_phy_down()
3391 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; in hw_event_phy_down() local
3392 port->port_state = portstate; in hw_event_phy_down()
3393 phy->phy_type = 0; in hw_event_phy_down()
3394 phy->identify.device_type = 0; in hw_event_phy_down()
3395 phy->phy_attached = 0; in hw_event_phy_down()
3396 memset(&phy->dev_sas_addr, 0, SAS_ADDR_SIZE); in hw_event_phy_down()
3404 " Last phy Down and port invalid\n"); in hw_event_phy_down()
3405 port->port_attached = 0; in hw_event_phy_down()
3415 " phy Down and PORT_NOT_ESTABLISHED\n"); in hw_event_phy_down()
3416 port->port_attached = 0; in hw_event_phy_down()
3419 pm8001_dbg(pm8001_ha, MSG, " phy Down and PORT_LOSTCOMM\n"); in hw_event_phy_down()
3421 " Last phy Down and port invalid\n"); in hw_event_phy_down()
3422 port->port_attached = 0; in hw_event_phy_down()
3427 port->port_attached = 0; in hw_event_phy_down()
3428 pm8001_dbg(pm8001_ha, DEVIO, " phy Down and(default) = %x\n", in hw_event_phy_down()
3436 * pm8001_mpi_reg_resp -process register device ID response.
3442 * has assigned, from now, inter-communication with FW is no longer using the
3455 htag = le32_to_cpu(registerRespPayload->tag); in pm8001_mpi_reg_resp()
3456 ccb = &pm8001_ha->ccb_info[htag]; in pm8001_mpi_reg_resp()
3457 pm8001_dev = ccb->device; in pm8001_mpi_reg_resp()
3458 status = le32_to_cpu(registerRespPayload->status); in pm8001_mpi_reg_resp()
3459 device_id = le32_to_cpu(registerRespPayload->device_id); in pm8001_mpi_reg_resp()
3465 pm8001_dev->device_id = device_id; in pm8001_mpi_reg_resp()
3498 complete(pm8001_dev->dcompletion); in pm8001_mpi_reg_resp()
3510 status = le32_to_cpu(registerRespPayload->status); in pm8001_mpi_dereg_resp()
3511 device_id = le32_to_cpu(registerRespPayload->device_id); in pm8001_mpi_dereg_resp()
3520 * pm8001_mpi_fw_flash_update_resp - Response from FW for flash update command.
3530 u32 tag = le32_to_cpu(ppayload->tag); in pm8001_mpi_fw_flash_update_resp()
3531 struct pm8001_ccb_info *ccb = &pm8001_ha->ccb_info[tag]; in pm8001_mpi_fw_flash_update_resp()
3533 status = le32_to_cpu(ppayload->status); in pm8001_mpi_fw_flash_update_resp()
3569 kfree(ccb->fw_control_context); in pm8001_mpi_fw_flash_update_resp()
3571 complete(pm8001_ha->nvmd_completion); in pm8001_mpi_fw_flash_update_resp()
3581 status = le32_to_cpu(pPayload->status); in pm8001_mpi_general_event()
3586 pPayload->inb_IOMB_payload[i]); in pm8001_mpi_general_event()
3603 status = le32_to_cpu(pPayload->status); in pm8001_mpi_task_abort_resp()
3604 tag = le32_to_cpu(pPayload->tag); in pm8001_mpi_task_abort_resp()
3606 scp = le32_to_cpu(pPayload->scp); in pm8001_mpi_task_abort_resp()
3607 ccb = &pm8001_ha->ccb_info[tag]; in pm8001_mpi_task_abort_resp()
3608 t = ccb->task; in pm8001_mpi_task_abort_resp()
3609 pm8001_dev = ccb->device; /* retrieve device */ in pm8001_mpi_task_abort_resp()
3613 return -1; in pm8001_mpi_task_abort_resp()
3616 if (t->task_proto == SAS_PROTOCOL_INTERNAL_ABORT) in pm8001_mpi_task_abort_resp()
3617 atomic_dec(&pm8001_dev->running_req); in pm8001_mpi_task_abort_resp()
3619 ts = &t->task_status; in pm8001_mpi_task_abort_resp()
3626 ts->resp = SAS_TASK_COMPLETE; in pm8001_mpi_task_abort_resp()
3627 ts->stat = SAS_SAM_STAT_GOOD; in pm8001_mpi_task_abort_resp()
3631 ts->resp = TMF_RESP_FUNC_FAILED; in pm8001_mpi_task_abort_resp()
3634 spin_lock_irqsave(&t->task_state_lock, flags); in pm8001_mpi_task_abort_resp()
3635 t->task_state_flags &= ~SAS_TASK_STATE_PENDING; in pm8001_mpi_task_abort_resp()
3636 t->task_state_flags |= SAS_TASK_STATE_DONE; in pm8001_mpi_task_abort_resp()
3637 spin_unlock_irqrestore(&t->task_state_lock, flags); in pm8001_mpi_task_abort_resp()
3641 if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) { in pm8001_mpi_task_abort_resp()
3643 pm8001_dev->id &= ~NCQ_ABORT_ALL_FLAG; in pm8001_mpi_task_abort_resp()
3645 t->task_done(t); in pm8001_mpi_task_abort_resp()
3652 * mpi_hw_event -The hw event has come.
3662 le32_to_cpu(pPayload->lr_evt_status_phyid_portid); in mpi_hw_event()
3670 struct sas_ha_struct *sas_ha = pm8001_ha->sas; in mpi_hw_event()
3671 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; in mpi_hw_event() local
3672 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; in mpi_hw_event()
3681 phy->phy_state = 1; in mpi_hw_event()
3683 if (pm8001_ha->flags == PM8001F_RUN_TIME && in mpi_hw_event()
3684 phy->enable_completion != NULL) { in mpi_hw_event()
3685 complete(phy->enable_completion); in mpi_hw_event()
3686 phy->enable_completion = NULL; in mpi_hw_event()
3701 phy->phy_state = 0; in mpi_hw_event()
3705 sas_notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD, in mpi_hw_event()
3710 sas_notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL, in mpi_hw_event()
3712 phy->phy_attached = 0; in mpi_hw_event()
3713 phy->phy_state = 0; in mpi_hw_event()
3719 phy->phy_attached = 0; in mpi_hw_event()
3729 spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); in mpi_hw_event()
3730 sas_phy->sas_prim = HW_EVENT_BROADCAST_CHANGE; in mpi_hw_event()
3731 spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); in mpi_hw_event()
3737 sas_phy_disconnected(&phy->sas_phy); in mpi_hw_event()
3738 phy->phy_attached = 0; in mpi_hw_event()
3739 sas_notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR, GFP_ATOMIC); in mpi_hw_event()
3743 spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); in mpi_hw_event()
3744 sas_phy->sas_prim = HW_EVENT_BROADCAST_EXP; in mpi_hw_event()
3745 spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); in mpi_hw_event()
3755 phy->phy_attached = 0; in mpi_hw_event()
3766 phy->phy_attached = 0; in mpi_hw_event()
3777 phy->phy_attached = 0; in mpi_hw_event()
3788 phy->phy_attached = 0; in mpi_hw_event()
3797 spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); in mpi_hw_event()
3798 sas_phy->sas_prim = HW_EVENT_BROADCAST_SES; in mpi_hw_event()
3799 spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); in mpi_hw_event()
3816 phy->phy_attached = 0; in mpi_hw_event()
3827 phy->phy_attached = 0; in mpi_hw_event()
3834 phy->phy_attached = 0; in mpi_hw_event()
3842 phy->phy_attached = 0; in mpi_hw_event()
3864 * process_one_iomb - process one outbound Queue memory block
4011 spin_lock_irqsave(&pm8001_ha->lock, flags); in process_oq()
4012 circularQ = &pm8001_ha->outbnd_q_tbl[vec]; in process_oq()
4017 process_one_iomb(pm8001_ha, (void *)(pMsg1 - 4)); in process_oq()
4024 circularQ->producer_index = in process_oq()
4025 cpu_to_le32(pm8001_read_32(circularQ->pi_virt)); in process_oq()
4026 if (le32_to_cpu(circularQ->producer_index) == in process_oq()
4027 circularQ->consumer_idx) in process_oq()
4032 spin_unlock_irqrestore(&pm8001_ha->lock, flags); in process_oq()
4051 buf_prd->addr = cpu_to_le64(sg_dma_address(sg)); in pm8001_chip_make_sg()
4052 buf_prd->im_len.len = cpu_to_le32(sg_dma_len(sg)); in pm8001_chip_make_sg()
4053 buf_prd->im_len.e = 0; in pm8001_chip_make_sg()
4060 psmp_cmd->tag = hTag; in build_smp_cmd()
4061 psmp_cmd->device_id = cpu_to_le32(deviceID); in build_smp_cmd()
4062 psmp_cmd->len_ip_ir = cpu_to_le32(1|(1 << 1)); in build_smp_cmd()
4066 * pm8001_chip_smp_req - send a SMP task to FW
4074 struct sas_task *task = ccb->task; in pm8001_chip_smp_req()
4075 struct domain_device *dev = task->dev; in pm8001_chip_smp_req()
4076 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_chip_smp_req()
4084 * DMA-map SMP request, response buffers in pm8001_chip_smp_req()
4086 sg_req = &task->smp_task.smp_req; in pm8001_chip_smp_req()
4087 elem = dma_map_sg(pm8001_ha->dev, sg_req, 1, DMA_TO_DEVICE); in pm8001_chip_smp_req()
4089 return -ENOMEM; in pm8001_chip_smp_req()
4092 sg_resp = &task->smp_task.smp_resp; in pm8001_chip_smp_req()
4093 elem = dma_map_sg(pm8001_ha->dev, sg_resp, 1, DMA_FROM_DEVICE); in pm8001_chip_smp_req()
4095 rc = -ENOMEM; in pm8001_chip_smp_req()
4101 rc = -EINVAL; in pm8001_chip_smp_req()
4106 smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_smp_req()
4108 cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req)); in pm8001_chip_smp_req()
4110 cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_req)-4); in pm8001_chip_smp_req()
4112 cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_resp)); in pm8001_chip_smp_req()
4114 cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_resp)-4); in pm8001_chip_smp_req()
4115 build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, &smp_cmd); in pm8001_chip_smp_req()
4124 dma_unmap_sg(pm8001_ha->dev, &ccb->task->smp_task.smp_resp, 1, in pm8001_chip_smp_req()
4127 dma_unmap_sg(pm8001_ha->dev, &ccb->task->smp_task.smp_req, 1, in pm8001_chip_smp_req()
4133 * pm8001_chip_ssp_io_req - send a SSP task to FW
4140 struct sas_task *task = ccb->task; in pm8001_chip_ssp_io_req()
4141 struct domain_device *dev = task->dev; in pm8001_chip_ssp_io_req()
4142 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_chip_ssp_io_req()
4144 u32 tag = ccb->ccb_tag; in pm8001_chip_ssp_io_req()
4148 memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); in pm8001_chip_ssp_io_req()
4150 cpu_to_le32(data_dir_flags[task->data_dir] << 8 | 0x0);/*0 for in pm8001_chip_ssp_io_req()
4152 ssp_cmd.data_len = cpu_to_le32(task->total_xfer_len); in pm8001_chip_ssp_io_req()
4153 ssp_cmd.device_id = cpu_to_le32(pm8001_dev->device_id); in pm8001_chip_ssp_io_req()
4155 if (task->ssp_task.enable_first_burst) in pm8001_chip_ssp_io_req()
4157 ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_prio << 3); in pm8001_chip_ssp_io_req()
4158 ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); in pm8001_chip_ssp_io_req()
4159 memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd, in pm8001_chip_ssp_io_req()
4160 task->ssp_task.cmd->cmd_len); in pm8001_chip_ssp_io_req()
4163 if (task->num_scatter > 1) { in pm8001_chip_ssp_io_req()
4164 pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd); in pm8001_chip_ssp_io_req()
4165 phys_addr = ccb->ccb_dma_handle; in pm8001_chip_ssp_io_req()
4169 } else if (task->num_scatter == 1) { in pm8001_chip_ssp_io_req()
4170 u64 dma_addr = sg_dma_address(task->scatter); in pm8001_chip_ssp_io_req()
4173 ssp_cmd.len = cpu_to_le32(task->total_xfer_len); in pm8001_chip_ssp_io_req()
4175 } else if (task->num_scatter == 0) { in pm8001_chip_ssp_io_req()
4178 ssp_cmd.len = cpu_to_le32(task->total_xfer_len); in pm8001_chip_ssp_io_req()
4189 struct sas_task *task = ccb->task; in pm8001_chip_sata_req()
4190 struct domain_device *dev = task->dev; in pm8001_chip_sata_req()
4191 struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; in pm8001_chip_sata_req()
4192 u32 tag = ccb->ccb_tag; in pm8001_chip_sata_req()
4203 if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) { in pm8001_chip_sata_req()
4206 } else if (likely(!task->ata_task.device_control_reg_update)) { in pm8001_chip_sata_req()
4207 if (task->ata_task.use_ncq && in pm8001_chip_sata_req()
4208 dev->sata_dev.class != ATA_DEV_ATAPI) { in pm8001_chip_sata_req()
4211 } else if (task->ata_task.dma_xfer) { in pm8001_chip_sata_req()
4219 if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { in pm8001_chip_sata_req()
4220 task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); in pm8001_chip_sata_req()
4223 dir = data_dir_flags[task->data_dir] << 8; in pm8001_chip_sata_req()
4225 sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); in pm8001_chip_sata_req()
4226 sata_cmd.data_len = cpu_to_le32(task->total_xfer_len); in pm8001_chip_sata_req()
4229 sata_cmd.sata_fis = task->ata_task.fis; in pm8001_chip_sata_req()
4230 if (likely(!task->ata_task.device_control_reg_update)) in pm8001_chip_sata_req()
4234 if (task->num_scatter > 1) { in pm8001_chip_sata_req()
4235 pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd); in pm8001_chip_sata_req()
4236 phys_addr = ccb->ccb_dma_handle; in pm8001_chip_sata_req()
4240 } else if (task->num_scatter == 1) { in pm8001_chip_sata_req()
4241 u64 dma_addr = sg_dma_address(task->scatter); in pm8001_chip_sata_req()
4244 sata_cmd.len = cpu_to_le32(task->total_xfer_len); in pm8001_chip_sata_req()
4246 } else if (task->num_scatter == 0) { in pm8001_chip_sata_req()
4249 sata_cmd.len = cpu_to_le32(task->total_xfer_len); in pm8001_chip_sata_req()
4255 if (((pm8001_ha_dev->id & NCQ_READ_LOG_FLAG) || in pm8001_chip_sata_req()
4256 (pm8001_ha_dev->id & NCQ_ABORT_ALL_FLAG) || in pm8001_chip_sata_req()
4257 (pm8001_ha_dev->id & NCQ_2ND_RLE_FLAG))) { in pm8001_chip_sata_req()
4260 pm8001_ha_dev->id &= 0xDFFFFFFF; in pm8001_chip_sata_req()
4261 ts = &task->task_status; in pm8001_chip_sata_req()
4263 spin_lock_irqsave(&task->task_state_lock, flags); in pm8001_chip_sata_req()
4264 ts->resp = SAS_TASK_COMPLETE; in pm8001_chip_sata_req()
4265 ts->stat = SAS_SAM_STAT_GOOD; in pm8001_chip_sata_req()
4266 task->task_state_flags &= ~SAS_TASK_STATE_PENDING; in pm8001_chip_sata_req()
4267 task->task_state_flags |= SAS_TASK_STATE_DONE; in pm8001_chip_sata_req()
4268 if (unlikely((task->task_state_flags & in pm8001_chip_sata_req()
4270 spin_unlock_irqrestore(&task->task_state_lock, in pm8001_chip_sata_req()
4274 task, ts->resp, in pm8001_chip_sata_req()
4275 ts->stat); in pm8001_chip_sata_req()
4278 spin_unlock_irqrestore(&task->task_state_lock, in pm8001_chip_sata_req()
4291 * pm8001_chip_phy_start_req - start phy via PHY_START COMMAND
4293 * @phy_id: the phy id which we wanted to start up.
4305 ** [0:7] PHY Identifier in pm8001_chip_phy_start_req()
4316 pm8001_ha->sas_addr, SAS_ADDR_SIZE); in pm8001_chip_phy_start_req()
4324 * pm8001_chip_phy_stop_req - start phy via PHY_STOP COMMAND
4326 * @phy_id: the phy id which we wanted to start up.
4358 struct domain_device *dev = pm8001_dev->sas_device; in pm8001_chip_reg_dev_req()
4359 struct domain_device *parent_dev = dev->parent; in pm8001_chip_reg_dev_req()
4360 struct pm8001_port *port = dev->port->lldd_port; in pm8001_chip_reg_dev_req()
4365 return -SAS_QUEUE_FULL; in pm8001_chip_reg_dev_req()
4367 payload.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_reg_dev_req()
4371 if (pm8001_dev->dev_type == SAS_SATA_DEV) in pm8001_chip_reg_dev_req()
4373 else if (pm8001_dev->dev_type == SAS_END_DEVICE || in pm8001_chip_reg_dev_req()
4374 dev_is_expander(pm8001_dev->dev_type)) in pm8001_chip_reg_dev_req()
4377 if (parent_dev && dev_is_expander(parent_dev->dev_type)) in pm8001_chip_reg_dev_req()
4378 phy_id = parent_dev->ex_dev.ex_phy->phy_id; in pm8001_chip_reg_dev_req()
4380 phy_id = pm8001_dev->attached_phy; in pm8001_chip_reg_dev_req()
4382 linkrate = (pm8001_dev->sas_device->linkrate < dev->port->linkrate) ? in pm8001_chip_reg_dev_req()
4383 pm8001_dev->sas_device->linkrate : dev->port->linkrate; in pm8001_chip_reg_dev_req()
4385 cpu_to_le32(((port->port_id) & 0x0F) | in pm8001_chip_reg_dev_req()
4392 memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, in pm8001_chip_reg_dev_req()
4423 * pm8001_chip_phy_ctl_req - support the local phy operation
4425 * @phyId: the phy id which we wanted to operate
4426 * @phy_op: the phy operation to request
4458 * pm8001_chip_isr - PM8001 isr handler.
4489 return -EIO; in send_task_abort()
4499 * pm8001_chip_abort_task - SAS abort task when error or exception happened.
4504 struct sas_task *task = ccb->task; in pm8001_chip_abort_task()
4505 struct sas_internal_abort_task *abort = &task->abort_task; in pm8001_chip_abort_task()
4506 struct pm8001_device *pm8001_dev = ccb->device; in pm8001_chip_abort_task()
4511 ccb->ccb_tag, abort->tag); in pm8001_chip_abort_task()
4512 if (pm8001_dev->dev_type == SAS_END_DEVICE) in pm8001_chip_abort_task()
4514 else if (pm8001_dev->dev_type == SAS_SATA_DEV) in pm8001_chip_abort_task()
4518 device_id = pm8001_dev->device_id; in pm8001_chip_abort_task()
4519 rc = send_task_abort(pm8001_ha, opc, device_id, abort->type, in pm8001_chip_abort_task()
4520 abort->tag, ccb->ccb_tag); in pm8001_chip_abort_task()
4527 * pm8001_chip_ssp_tm_req - built the task management command.
4535 struct sas_task *task = ccb->task; in pm8001_chip_ssp_tm_req()
4536 struct domain_device *dev = task->dev; in pm8001_chip_ssp_tm_req()
4537 struct pm8001_device *pm8001_dev = dev->lldd_dev; in pm8001_chip_ssp_tm_req()
4542 sspTMCmd.device_id = cpu_to_le32(pm8001_dev->device_id); in pm8001_chip_ssp_tm_req()
4543 sspTMCmd.relate_tag = cpu_to_le32((u32)tmf->tag_of_task_to_be_managed); in pm8001_chip_ssp_tm_req()
4544 sspTMCmd.tmf = cpu_to_le32(tmf->tmf); in pm8001_chip_ssp_tm_req()
4545 memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8); in pm8001_chip_ssp_tm_req()
4546 sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_ssp_tm_req()
4547 if (pm8001_ha->chip_id != chip_8001) in pm8001_chip_ssp_tm_req()
4565 nvmd_type = ioctl_payload->minor_function; in pm8001_chip_get_nvmd_req()
4568 return -ENOMEM; in pm8001_chip_get_nvmd_req()
4569 fw_control_context->usrAddr = (u8 *)ioctl_payload->func_specific; in pm8001_chip_get_nvmd_req()
4570 fw_control_context->len = ioctl_payload->rd_length; in pm8001_chip_get_nvmd_req()
4576 return -SAS_QUEUE_FULL; in pm8001_chip_get_nvmd_req()
4578 ccb->fw_control_context = fw_control_context; in pm8001_chip_get_nvmd_req()
4580 nvmd_req.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_get_nvmd_req()
4590 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->rd_length); in pm8001_chip_get_nvmd_req()
4592 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_get_nvmd_req()
4594 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_get_nvmd_req()
4599 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->rd_length); in pm8001_chip_get_nvmd_req()
4601 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_get_nvmd_req()
4603 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_get_nvmd_req()
4608 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->rd_length); in pm8001_chip_get_nvmd_req()
4610 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_get_nvmd_req()
4612 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_get_nvmd_req()
4617 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->rd_length); in pm8001_chip_get_nvmd_req()
4619 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_get_nvmd_req()
4621 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_get_nvmd_req()
4626 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->rd_length); in pm8001_chip_get_nvmd_req()
4627 nvmd_req.vpd_offset = cpu_to_le32(ioctl_payload->offset); in pm8001_chip_get_nvmd_req()
4629 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_get_nvmd_req()
4631 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_get_nvmd_req()
4658 nvmd_type = ioctl_payload->minor_function; in pm8001_chip_set_nvmd_req()
4661 return -ENOMEM; in pm8001_chip_set_nvmd_req()
4663 memcpy(pm8001_ha->memoryMap.region[NVMD].virt_ptr, in pm8001_chip_set_nvmd_req()
4664 &ioctl_payload->func_specific, in pm8001_chip_set_nvmd_req()
4665 ioctl_payload->wr_length); in pm8001_chip_set_nvmd_req()
4671 return -SAS_QUEUE_FULL; in pm8001_chip_set_nvmd_req()
4673 ccb->fw_control_context = fw_control_context; in pm8001_chip_set_nvmd_req()
4675 nvmd_req.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_set_nvmd_req()
4684 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->wr_length); in pm8001_chip_set_nvmd_req()
4686 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_set_nvmd_req()
4688 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_set_nvmd_req()
4693 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->wr_length); in pm8001_chip_set_nvmd_req()
4696 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_set_nvmd_req()
4698 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_set_nvmd_req()
4702 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->wr_length); in pm8001_chip_set_nvmd_req()
4705 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_set_nvmd_req()
4707 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_set_nvmd_req()
4711 nvmd_req.resp_len = cpu_to_le32(ioctl_payload->wr_length); in pm8001_chip_set_nvmd_req()
4714 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_hi); in pm8001_chip_set_nvmd_req()
4716 cpu_to_le32(pm8001_ha->memoryMap.region[NVMD].phys_addr_lo); in pm8001_chip_set_nvmd_req()
4732 * pm8001_chip_fw_flash_update_build - support the firmware update operation
4748 payload.cur_image_len = cpu_to_le32(info->cur_image_len); in pm8001_chip_fw_flash_update_build()
4749 payload.cur_image_offset = cpu_to_le32(info->cur_image_offset); in pm8001_chip_fw_flash_update_build()
4750 payload.total_image_len = cpu_to_le32(info->total_image_len); in pm8001_chip_fw_flash_update_build()
4751 payload.len = info->sgl.im_len.len ; in pm8001_chip_fw_flash_update_build()
4753 cpu_to_le32(lower_32_bits(le64_to_cpu(info->sgl.addr))); in pm8001_chip_fw_flash_update_build()
4755 cpu_to_le32(upper_32_bits(le64_to_cpu(info->sgl.addr))); in pm8001_chip_fw_flash_update_build()
4770 void *buffer = pm8001_ha->memoryMap.region[FW_FLASH].virt_ptr; in pm8001_chip_fw_flash_update_req()
4771 dma_addr_t phys_addr = pm8001_ha->memoryMap.region[FW_FLASH].phys_addr; in pm8001_chip_fw_flash_update_req()
4776 return -ENOMEM; in pm8001_chip_fw_flash_update_req()
4777 fw_control = (struct fw_control_info *)&ioctl_payload->func_specific; in pm8001_chip_fw_flash_update_req()
4780 fw_control->len); in pm8001_chip_fw_flash_update_req()
4781 memcpy(buffer, fw_control->buffer, fw_control->len); in pm8001_chip_fw_flash_update_req()
4783 flash_update_info.sgl.im_len.len = cpu_to_le32(fw_control->len); in pm8001_chip_fw_flash_update_req()
4785 flash_update_info.cur_image_offset = fw_control->offset; in pm8001_chip_fw_flash_update_req()
4786 flash_update_info.cur_image_len = fw_control->len; in pm8001_chip_fw_flash_update_req()
4787 flash_update_info.total_image_len = fw_control->size; in pm8001_chip_fw_flash_update_req()
4788 fw_control_context->fw_control = fw_control; in pm8001_chip_fw_flash_update_req()
4789 fw_control_context->virtAddr = buffer; in pm8001_chip_fw_flash_update_req()
4790 fw_control_context->phys_addr = phys_addr; in pm8001_chip_fw_flash_update_req()
4791 fw_control_context->len = fw_control->len; in pm8001_chip_fw_flash_update_req()
4796 return -SAS_QUEUE_FULL; in pm8001_chip_fw_flash_update_req()
4798 ccb->fw_control_context = fw_control_context; in pm8001_chip_fw_flash_update_req()
4801 ccb->ccb_tag); in pm8001_chip_fw_flash_update_req()
4819 struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; in pm8001_get_gsm_dump()
4822 gsm_dump_offset = pm8001_ha->fatal_forensic_shift_offset; in pm8001_get_gsm_dump()
4827 return -EINVAL; in pm8001_get_gsm_dump()
4829 if (pm8001_ha->chip_id == chip_8001) in pm8001_get_gsm_dump()
4843 if (pm8001_ha->chip_id == chip_8001) in pm8001_get_gsm_dump()
4851 if (pm8001_ha->chip_id == chip_8001) { in pm8001_get_gsm_dump()
4853 if (-1 == pm8001_bar4_shift(pm8001_ha, in pm8001_get_gsm_dump()
4855 return -EIO; in pm8001_get_gsm_dump()
4858 if (-1 == pm80xx_bar4_shift(pm8001_ha, in pm8001_get_gsm_dump()
4860 return -EIO; in pm8001_get_gsm_dump()
4879 if (-1 == pm8001_bar4_shift(pm8001_ha, 0)) in pm8001_get_gsm_dump()
4880 return -EIO; in pm8001_get_gsm_dump()
4881 pm8001_ha->fatal_forensic_shift_offset += 1024; in pm8001_get_gsm_dump()
4883 if (pm8001_ha->fatal_forensic_shift_offset >= 0x100000) in pm8001_get_gsm_dump()
4884 pm8001_ha->fatal_forensic_shift_offset = 0; in pm8001_get_gsm_dump()
4885 return direct_data - buf; in pm8001_get_gsm_dump()
4901 return -SAS_QUEUE_FULL; in pm8001_chip_set_dev_state_req()
4903 payload.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_set_dev_state_req()
4904 payload.device_id = cpu_to_le32(pm8001_dev->device_id); in pm8001_chip_set_dev_state_req()
4927 return -SAS_QUEUE_FULL; in pm8001_chip_sas_re_initialization()
4929 payload.tag = cpu_to_le32(ccb->ccb_tag); in pm8001_chip_sas_re_initialization()