40 #include <linux/slab.h>
53 pm8001_ha->
main_cfg_tbl.signature = pm8001_mr32(address, 0x00);
54 pm8001_ha->
main_cfg_tbl.interface_rev = pm8001_mr32(address, 0x04);
55 pm8001_ha->
main_cfg_tbl.firmware_rev = pm8001_mr32(address, 0x08);
56 pm8001_ha->
main_cfg_tbl.max_out_io = pm8001_mr32(address, 0x0C);
57 pm8001_ha->
main_cfg_tbl.max_sgl = pm8001_mr32(address, 0x10);
58 pm8001_ha->
main_cfg_tbl.ctrl_cap_flag = pm8001_mr32(address, 0x14);
59 pm8001_ha->
main_cfg_tbl.gst_offset = pm8001_mr32(address, 0x18);
90 pm8001_ha->
gs_tbl.gst_len_mpistate = pm8001_mr32(address, 0x00);
91 pm8001_ha->
gs_tbl.iq_freeze_state0 = pm8001_mr32(address, 0x04);
92 pm8001_ha->
gs_tbl.iq_freeze_state1 = pm8001_mr32(address, 0x08);
93 pm8001_ha->
gs_tbl.msgu_tcnt = pm8001_mr32(address, 0x0C);
94 pm8001_ha->
gs_tbl.iop_tcnt = pm8001_mr32(address, 0x10);
95 pm8001_ha->
gs_tbl.reserved = pm8001_mr32(address, 0x14);
96 pm8001_ha->
gs_tbl.phy_state[0] = pm8001_mr32(address, 0x18);
97 pm8001_ha->
gs_tbl.phy_state[1] = pm8001_mr32(address, 0x1C);
98 pm8001_ha->
gs_tbl.phy_state[2] = pm8001_mr32(address, 0x20);
99 pm8001_ha->
gs_tbl.phy_state[3] = pm8001_mr32(address, 0x24);
100 pm8001_ha->
gs_tbl.phy_state[4] = pm8001_mr32(address, 0x28);
101 pm8001_ha->
gs_tbl.phy_state[5] = pm8001_mr32(address, 0x2C);
102 pm8001_ha->
gs_tbl.phy_state[6] = pm8001_mr32(address, 0x30);
103 pm8001_ha->
gs_tbl.phy_state[7] = pm8001_mr32(address, 0x34);
104 pm8001_ha->
gs_tbl.reserved1 = pm8001_mr32(address, 0x38);
105 pm8001_ha->
gs_tbl.reserved2 = pm8001_mr32(address, 0x3C);
106 pm8001_ha->
gs_tbl.reserved3 = pm8001_mr32(address, 0x40);
107 pm8001_ha->
gs_tbl.recover_err_info[0] = pm8001_mr32(address, 0x44);
108 pm8001_ha->
gs_tbl.recover_err_info[1] = pm8001_mr32(address, 0x48);
109 pm8001_ha->
gs_tbl.recover_err_info[2] = pm8001_mr32(address, 0x4C);
110 pm8001_ha->
gs_tbl.recover_err_info[3] = pm8001_mr32(address, 0x50);
111 pm8001_ha->
gs_tbl.recover_err_info[4] = pm8001_mr32(address, 0x54);
112 pm8001_ha->
gs_tbl.recover_err_info[5] = pm8001_mr32(address, 0x58);
113 pm8001_ha->
gs_tbl.recover_err_info[6] = pm8001_mr32(address, 0x5C);
114 pm8001_ha->
gs_tbl.recover_err_info[7] = pm8001_mr32(address, 0x60);
127 for (i = 0; i < inbQ_num; i++) {
130 get_pci_bar_index(pm8001_mr32(address, (offset + 0x14)));
132 pm8001_mr32(address, (offset + 0x18));
146 for (i = 0; i < outbQ_num; i++) {
147 u32 offset = i * 0x24;
149 get_pci_bar_index(pm8001_mr32(address, (offset + 0x14)));
151 pm8001_mr32(address, (offset + 0x18));
164 u32 offsetib, offsetob;
173 pm8001_ha->
main_cfg_tbl.outbound_tgt_ITNexus_event_pid0_3 = 0;
174 pm8001_ha->
main_cfg_tbl.outbound_tgt_ITNexus_event_pid4_7 = 0;
175 pm8001_ha->
main_cfg_tbl.outbound_tgt_ssp_event_pid0_3 = 0;
176 pm8001_ha->
main_cfg_tbl.outbound_tgt_ssp_event_pid4_7 = 0;
177 pm8001_ha->
main_cfg_tbl.outbound_tgt_smp_event_pid0_3 = 0;
178 pm8001_ha->
main_cfg_tbl.outbound_tgt_smp_event_pid4_7 = 0;
193 for (i = 0; i < qn; i++) {
212 get_pci_bar_index(pm8001_mr32(addressib,
215 pm8001_mr32(addressib, (offsetib + 0x18));
219 for (i = 0; i < qn; i++) {
235 0 | (10 << 16) | (0 << 24);
240 get_pci_bar_index(pm8001_mr32(addressob,
243 pm8001_mr32(addressob, (offsetob + 0x18));
257 pm8001_mw32(address, 0x24,
259 pm8001_mw32(address, 0x28,
261 pm8001_mw32(address, 0x2C,
263 pm8001_mw32(address, 0x30,
265 pm8001_mw32(address, 0x34,
267 pm8001_mw32(address, 0x38,
268 pm8001_ha->
main_cfg_tbl.outbound_tgt_ITNexus_event_pid0_3);
269 pm8001_mw32(address, 0x3C,
270 pm8001_ha->
main_cfg_tbl.outbound_tgt_ITNexus_event_pid4_7);
271 pm8001_mw32(address, 0x40,
273 pm8001_mw32(address, 0x44,
275 pm8001_mw32(address, 0x48,
277 pm8001_mw32(address, 0x4C,
279 pm8001_mw32(address, 0x50,
281 pm8001_mw32(address, 0x54,
283 pm8001_mw32(address, 0x58, pm8001_ha->
main_cfg_tbl.event_log_size);
284 pm8001_mw32(address, 0x5C, pm8001_ha->
main_cfg_tbl.event_log_option);
285 pm8001_mw32(address, 0x60,
287 pm8001_mw32(address, 0x64,
289 pm8001_mw32(address, 0x68, pm8001_ha->
main_cfg_tbl.iop_event_log_size);
290 pm8001_mw32(address, 0x6C,
292 pm8001_mw32(address, 0x70,
301 update_inbnd_queue_table(
struct pm8001_hba_info *pm8001_ha,
int number)
304 u16 offset = number * 0x20;
305 pm8001_mw32(address, offset + 0x00,
306 pm8001_ha->
inbnd_q_tbl[number].element_pri_size_cnt);
307 pm8001_mw32(address, offset + 0x04,
309 pm8001_mw32(address, offset + 0x08,
311 pm8001_mw32(address, offset + 0x0C,
312 pm8001_ha->
inbnd_q_tbl[number].ci_upper_base_addr);
313 pm8001_mw32(address, offset + 0x10,
314 pm8001_ha->
inbnd_q_tbl[number].ci_lower_base_addr);
322 update_outbnd_queue_table(
struct pm8001_hba_info *pm8001_ha,
int number)
325 u16 offset = number * 0x24;
326 pm8001_mw32(address, offset + 0x00,
328 pm8001_mw32(address, offset + 0x04,
330 pm8001_mw32(address, offset + 0x08,
332 pm8001_mw32(address, offset + 0x0C,
334 pm8001_mw32(address, offset + 0x10,
336 pm8001_mw32(address, offset + 0x1C,
337 pm8001_ha->
outbnd_q_tbl[number].interrup_vec_cnt_delay);
359 if (regVal != shiftValue) {
362 " = 0x%x\n", regVal));
379 #define SAS2_SETTINGS_LOCAL_PHY_0_3_SHIFT_ADDR 0x00030000
380 #define SAS2_SETTINGS_LOCAL_PHY_4_7_SHIFT_ADDR 0x00040000
381 #define SAS2_SETTINGS_LOCAL_PHY_0_3_OFFSET 0x1074
382 #define SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET 0x1074
383 #define PHY_G3_WITHOUT_SSC_BIT_SHIFT 12
384 #define PHY_G3_WITH_SSC_BIT_SHIFT 13
385 #define SNW3_PHY_CAPABILITIES_PARITY 31
393 SAS2_SETTINGS_LOCAL_PHY_0_3_SHIFT_ADDR)) {
394 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
398 for (i = 0; i < 4; i++) {
400 pm8001_cw32(pm8001_ha, 2, offset, 0x80001501);
404 SAS2_SETTINGS_LOCAL_PHY_4_7_SHIFT_ADDR)) {
405 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
408 for (i = 4; i < 8; i++) {
410 pm8001_cw32(pm8001_ha, 2, offset, 0x80001501);
427 value = pm8001_cr32(pm8001_ha, 2, 0xd8);
428 pm8001_cw32(pm8001_ha, 2, 0xd8, 0x8000C016);
432 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
450 #define OPEN_RETRY_INTERVAL_PHY_0_3_SHIFT_ADDR 0x00030000
451 #define OPEN_RETRY_INTERVAL_PHY_4_7_SHIFT_ADDR 0x00040000
452 #define OPEN_RETRY_INTERVAL_PHY_0_3_OFFSET 0x30B4
453 #define OPEN_RETRY_INTERVAL_PHY_4_7_OFFSET 0x30B4
454 #define OPEN_RETRY_INTERVAL_REG_MASK 0x0000FFFF
460 OPEN_RETRY_INTERVAL_PHY_0_3_SHIFT_ADDR)) {
461 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
464 for (i = 0; i < 4; i++) {
466 pm8001_cw32(pm8001_ha, 2, offset, value);
470 OPEN_RETRY_INTERVAL_PHY_4_7_SHIFT_ADDR)) {
471 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
474 for (i = 4; i < 8; i++) {
476 pm8001_cw32(pm8001_ha, 2, offset, value);
480 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
492 u32 gst_len_mpistate;
497 max_wait_count = 1 * 1000 * 1000;
502 }
while ((value != 0) && (--max_wait_count));
513 gst_len_mpistate = gst_len_mpistate >> 16;
514 if (0x0000 != gst_len_mpistate)
559 max_wait_count = 1 * 1000 * 1000;
568 if ((--max_wait_count) == 0)
574 static void init_pci_device_addresses(
struct pm8001_hba_info *pm8001_ha)
582 value = pm8001_cr32(pm8001_ha, 0, 0x44);
583 offset = value & 0x03FFFFFF;
586 pcilogic = (value & 0xFC000000) >> 26;
587 pcibar = get_pci_bar_index(pcilogic);
593 base_addr + pm8001_cr32(pm8001_ha, pcibar, offset + 0x18);
595 base_addr + pm8001_cr32(pm8001_ha, pcibar, offset + 0x1C);
597 base_addr + pm8001_cr32(pm8001_ha, pcibar, offset + 0x20);
607 if (-1 == check_fw_ready(pm8001_ha)) {
614 init_pci_device_addresses(pm8001_ha);
615 init_default_table_values(pm8001_ha);
616 read_main_config_table(pm8001_ha);
617 read_general_status_table(pm8001_ha);
618 read_inbnd_queue_table(pm8001_ha);
619 read_outbnd_queue_table(pm8001_ha);
621 update_main_config_table(pm8001_ha);
622 update_inbnd_queue_table(pm8001_ha, 0);
623 update_outbnd_queue_table(pm8001_ha, 0);
624 mpi_set_phys_g3_with_ssc(pm8001_ha, 0);
626 mpi_set_open_retry_interval_reg(pm8001_ha, 119);
628 if (0 == mpi_init_check(pm8001_ha)) {
638 pm8001_cw32(pm8001_ha, 1, 0x0033c0, 0x1);
639 pm8001_cw32(pm8001_ha, 1, 0x0033c4, 0x0);
647 u32 gst_len_mpistate;
648 init_pci_device_addresses(pm8001_ha);
654 max_wait_count = 1 * 1000 * 1000;
659 }
while ((value != 0) && (--max_wait_count));
661 if (!max_wait_count) {
669 max_wait_count = 1 * 1000 * 1000;
676 (gst_len_mpistate & GST_MPI_STATE_MASK))
678 }
while (--max_wait_count);
679 if (!max_wait_count) {
682 gst_len_mpistate & GST_MPI_STATE_MASK));
694 u32 regVal, regVal1, regVal2;
695 if (mpi_uninit_check(pm8001_ha) != 0) {
711 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
729 "=0x%x, MSGU_SCRATCH_PAD2=0x%x\n",
737 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
740 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
754 u32 regVal, toggleVal;
756 u32 regVal1, regVal2, regVal3;
760 if (soft_reset_ready_check(pm8001_ha) != 0) {
770 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
778 pm8001_printk(
"MBIC - NMI Enable VPE0 (IOP)= 0x%x\n", regVal));
782 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
790 pm8001_printk(
"MBIC - NMI Enable VPE0 (AAP1)= 0x%x\n", regVal));
795 pm8001_printk(
"PCIE -Event Interrupt Enable = 0x%x\n", regVal));
805 pm8001_printk(
"PCIE -Error Interrupt Enable = 0x%x\n", regVal));
825 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
846 regVal &= ~(0x00003b00);
851 "Configuration and Reset is set to = 0x%x\n",
859 "Enable = 0x%x\n", regVal1));
862 pm8001_printk(
"GSM 0x700038 - Read Address Parity Check Enable"
863 "is set to = 0x%x\n",
870 " Enable = 0x%x\n", regVal2));
874 "Enable is set to = 0x%x\n",
881 " Enable = 0x%x\n", regVal3));
884 pm8001_printk(
"GSM 0x300048 - Write Data Parity Check Enable"
885 "is set to = 0x%x\n",
892 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
901 " = 0x%x\n", regVal));
903 regVal &= 0xFFFFFFFC;
909 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
918 ":= 0x%x\n", regVal));
926 ": = 0x%x\n", regVal));
937 ":= 0x%x\n", regVal));
947 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
969 " Configuration and Reset is set to = 0x%x\n",
976 pm8001_printk(
"GSM 0x700038 - Read Address Parity Check Enable"
977 " = 0x%x\n", regVal));
981 " Check Enable is set to = 0x%x\n",
988 " Enable is set to = 0x%x\n",
994 pm8001_printk(
"GSM 0x700048 - Write Data Parity Check Enable"
995 "is set to = 0x%x\n",
1001 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1017 max_wait_count = 2 * 1000 * 1000;
1022 }
while ((regVal != toggleVal) && (--max_wait_count));
1024 if (!max_wait_count) {
1025 regVal = pm8001_cr32(pm8001_ha, 0,
1029 "MSGU_SCRATCH_PAD1 = 0x%x\n",
1030 toggleVal, regVal));
1033 pm8001_cr32(pm8001_ha, 0,
1037 pm8001_cr32(pm8001_ha, 0,
1041 pm8001_cr32(pm8001_ha, 0,
1043 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1054 if (check_fw_ready(pm8001_ha) == -1) {
1059 " = 0x%x\n", regVal));
1064 " = 0x%x\n", regVal));
1067 pm8001_cr32(pm8001_ha, 0,
1071 pm8001_cr32(pm8001_ha, 0,
1073 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1078 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1112 }
while ((--i) != 0);
1124 s8 bar, logical = 0;
1125 for (bar = 0; bar < 6; bar++) {
1134 if ((bar == 1) || (bar == 3))
1136 if (pm8001_ha->
io_mem[logical].memvirtaddr) {
1177 value = (1 << int_vec_idx);
1178 pm8001_cw32(pm8001_ha, 0,
MSGU_ODCR, value);
1203 #ifdef PM8001_USE_MSIX
1204 pm8001_chip_msix_interrupt_enable(pm8001_ha, 0);
1207 pm8001_chip_intx_interrupt_enable(pm8001_ha);
1218 #ifdef PM8001_USE_MSIX
1219 pm8001_chip_msix_interrupt_disable(pm8001_ha, 0);
1222 pm8001_chip_intx_interrupt_disable(pm8001_ha);
1233 u16 messageSize,
void **messagePtr)
1240 if (messageSize > 64) {
1246 consumer_index = pm8001_read_32(circularQ->
ci_virt);
1261 *messagePtr = ((
void *)msgHeader) +
sizeof(
struct mpi_msg_hdr);
1278 u32 responseQueue = 0;
1281 if (mpi_msg_free_get(circularQ, 64, &pMessage) < 0) {
1291 Header = ((1 << 31) | (hpriority << 30) | ((
bc & 0x1f) << 24)
1292 | ((responseQueue & 0x3F) << 16)
1293 | ((
category & 0xF) << 12) | (opCode & 0xFFF));
1295 pm8001_write_32((pMessage - 4), 0,
cpu_to_le32(Header));
1297 pm8001_cw32(pm8001_ha, circularQ->
pi_pci_bar,
1315 if (pOutBoundMsgHeader != msgHeader) {
1321 producer_index = pm8001_read_32(circularQ->
pi_virt);
1336 producer_index = pm8001_read_32(circularQ->
pi_virt);
1353 void **messagePtr1,
u8 *pBC)
1367 header_tmp = pm8001_read_32(msgHeader);
1369 if (0 != (
le32_to_cpu(msgHeader_tmp) & 0x80000000)) {
1391 pm8001_write_32(msgHeader, 0, 0);
1393 pm8001_cw32(pm8001_ha,
1402 0x1f)) % PM8001_MPI_QUEUE;
1404 pm8001_write_32(msgHeader, 0, 0);
1406 pm8001_cw32(pm8001_ha, circularQ->
ci_pci_bar,
1413 void *pi_virt = circularQ->
pi_virt;
1415 producer_index = pm8001_read_32(pi_virt);
1437 pm8001_dev = pw->
data;
1438 if ((pm8001_dev ==
NULL)
1463 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1472 if ((tag != 0xFFFFFFFF) && (ccb->
task == t))
1476 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1483 pm8001_dev = ccb->
device;
1493 " done with event 0x%x resp 0x%x stat 0x%x but"
1494 " aborted by upper layer!\n",
1497 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1502 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1541 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1553 if ((tag != 0xFFFFFFFF) && (ccb->
task == t))
1557 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1563 pm8001_dev = ccb->
device;
1569 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1586 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1591 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
1658 unsigned long flags;
1664 struct ssp_response_iu *
iu;
1675 pm8001_dev = ccb->
device;
1689 ",param = %d\n", param));
1712 ",param = %d\n", param));
1742 pm8001_printk(
"IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"));
1768 pm8001_handle_event(pm8001_ha,
1782 "NOT_SUPPORTED\n"));
1838 pm8001_handle_event(pm8001_ha,
1885 " io_status 0x%x resp 0x%x "
1886 "stat 0x%x but aborted by upper layer!\n",
1898 static void mpi_ssp_event(
struct pm8001_hba_info *pm8001_ha ,
void *piomb)
1901 unsigned long flags;
1914 pm8001_dev = ccb->
device;
1974 pm8001_handle_event(pm8001_ha,
1988 "NOT_SUPPORTED\n"));
2038 pm8001_printk(
"IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT\n"));
2073 " event 0x%x resp 0x%x "
2074 "stat 0x%x but aborted by upper layer!\n",
2099 unsigned long flags;
2109 pm8001_dev = ccb->
device;
2130 sata_resp = &psataPayload->
sata_resp[0];
2223 pm8001_handle_event(pm8001_ha,
2230 spin_unlock_irq(&pm8001_ha->
lock);
2232 spin_lock_irq(&pm8001_ha->
lock);
2243 pm8001_handle_event(pm8001_ha,
2250 spin_unlock_irq(&pm8001_ha->
lock);
2252 spin_lock_irq(&pm8001_ha->
lock);
2259 "NOT_SUPPORTED\n"));
2271 pm8001_handle_event(pm8001_ha,
2278 spin_unlock_irq(&pm8001_ha->
lock);
2280 spin_lock_irq(&pm8001_ha->
lock);
2339 pm8001_handle_event(pm8001_ha, pm8001_dev,
2345 spin_unlock_irq(&pm8001_ha->
lock);
2347 spin_lock_irq(&pm8001_ha->
lock);
2363 pm8001_handle_event(pm8001_ha, pm8001_dev,
2369 spin_unlock_irq(&pm8001_ha->
lock);
2371 spin_lock_irq(&pm8001_ha->
lock);
2397 " resp 0x%x stat 0x%x but aborted by upper layer!\n",
2404 spin_unlock_irq(&pm8001_ha->
lock);
2406 spin_lock_irq(&pm8001_ha->
lock);
2411 spin_unlock_irq(&pm8001_ha->
lock);
2413 spin_lock_irq(&pm8001_ha->
lock);
2418 static void mpi_sata_event(
struct pm8001_hba_info *pm8001_ha ,
void *piomb)
2430 unsigned long flags;
2434 pm8001_dev = ccb->
device;
2494 pm8001_handle_event(pm8001_ha,
2501 spin_unlock_irq(&pm8001_ha->
lock);
2503 spin_lock_irq(&pm8001_ha->
lock);
2517 "NOT_SUPPORTED\n"));
2609 " resp 0x%x stat 0x%x but aborted by upper layer!\n",
2616 spin_unlock_irq(&pm8001_ha->
lock);
2618 spin_lock_irq(&pm8001_ha->
lock);
2623 spin_unlock_irq(&pm8001_ha->
lock);
2625 spin_lock_irq(&pm8001_ha->
lock);
2636 unsigned long flags;
2651 pm8001_dev = ccb->
device;
2707 pm8001_printk(
"IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n"));
2732 pm8001_handle_event(pm8001_ha,
2746 "NOT_SUPPORTED\n"));
2819 " io_status 0x%x resp 0x%x "
2820 "stat 0x%x but aborted by upper layer!\n",
2832 mpi_set_dev_state_resp(
struct pm8001_hba_info *pm8001_ha,
void *piomb)
2844 "from 0x%x to 0x%x status = 0x%x!\n",
2845 device_id, pds, nds, status));
2881 u32 ir_tds_bn_dps_das_nvm =
2883 void *virt_addr = pm8001_ha->
memoryMap.region[
NVMD].virt_ptr;
2887 if ((dlen_status & NVMD_STAT) != 0) {
2894 if (ir_tds_bn_dps_das_nvm &
IPMode) {
2899 if (ir_tds_bn_dps_das_nvm == 0x80a80200) {
2901 ((
u8 *)virt_addr + 4),
2905 " from VPD successfully!\n"));
2907 }
else if (((ir_tds_bn_dps_das_nvm & NVMD_TYPE) ==
C_SEEPROM)
2908 || ((ir_tds_bn_dps_das_nvm & NVMD_TYPE) ==
VPD_FLASH) ||
2909 ((ir_tds_bn_dps_das_nvm & NVMD_TYPE) ==
EXPAN_ROM)) {
2911 }
else if (((ir_tds_bn_dps_das_nvm & NVMD_TYPE) ==
AAP1_RDUMP)
2912 || ((ir_tds_bn_dps_das_nvm & NVMD_TYPE) ==
IOP_RDUMP)) {
2918 ir_tds_bn_dps_das_nvm));
2927 fw_control_context->
len);
2934 static int mpi_local_phy_ctl(
struct pm8001_hba_info *pm8001_ha,
void *piomb)
2963 static void pm8001_bytes_dmaed(
struct pm8001_hba_info *pm8001_ha,
int i)
2971 sas_ha = pm8001_ha->
sas;
2973 struct sas_phy *sphy = sas_phy->
phy;
2982 struct sas_identify_frame *
id;
2983 id = (
struct sas_identify_frame *)phy->
frame_rcvd;
2984 id->dev_type = phy->
identify.device_type;
2986 id->target_bits = phy->
identify.target_port_protocols;
2999 struct sas_phy *sas_phy = phy->
sas_phy.phy;
3001 switch (link_rate) {
3034 static void pm8001_get_attached_sas_addr(
struct pm8001_phy *phy,
3037 if (phy->
sas_phy.frame_rcvd[0] == 0x34
3045 struct sas_identify_frame *idframe =
3046 (
void *) phy->
sas_phy.frame_rcvd;
3061 static void pm8001_hw_event_ack_req(
struct pm8001_hba_info *pm8001_ha,
3069 memset((
u8 *)&payload, 0,
sizeof(payload));
3072 payload.sea_phyid_portid =
cpu_to_le32(((SEA & 0xFFFF) << 8) |
3073 ((phyId & 0x0F) << 4) | (port_id & 0x0F));
3076 mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
3095 (
u8)((lr_evt_status_phyid_portid & 0xF0000000) >> 28);
3096 u8 port_id = (
u8)(lr_evt_status_phyid_portid & 0x0000000F);
3098 (
u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
3104 unsigned long flags;
3108 pm8001_printk(
"HW_EVENT_SAS_PHY_UP port id = %d, phy id = %d\n",
3111 switch (deviceType) {
3118 pm8001_chip_phy_ctl_req(pm8001_ha, phy_id,
3121 get_lrate_mode(phy, link_rate);
3127 get_lrate_mode(phy, link_rate);
3133 get_lrate_mode(phy, link_rate);
3141 phy->
identify.device_type = deviceType;
3151 sizeof(
struct sas_identify_frame)-4);
3153 pm8001_get_attached_sas_addr(phy, phy->
sas_phy.attached_sas_addr);
3154 spin_unlock_irqrestore(&phy->
sas_phy.frame_rcvd_lock, flags);
3157 pm8001_bytes_dmaed(pm8001_ha, phy_id);
3170 u32 lr_evt_status_phyid_portid =
3173 (
u8)((lr_evt_status_phyid_portid & 0xF0000000) >> 28);
3174 u8 port_id = (
u8)(lr_evt_status_phyid_portid & 0x0000000F);
3176 (
u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
3178 u8 portstate = (
u8)(npip_portstate & 0x0000000F);
3182 unsigned long flags;
3185 " phy id = %d\n", port_id, phy_id));
3188 get_lrate_mode(phy, link_rate);
3199 pm8001_get_attached_sas_addr(phy, phy->
sas_phy.attached_sas_addr);
3200 spin_unlock_irqrestore(&phy->
sas_phy.frame_rcvd_lock, flags);
3201 pm8001_bytes_dmaed(pm8001_ha, phy_id);
3214 u32 lr_evt_status_phyid_portid =
3216 u8 port_id = (
u8)(lr_evt_status_phyid_portid & 0x0000000F);
3218 (
u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
3220 u8 portstate = (
u8)(npip_portstate & 0x0000000F);
3228 switch (portstate) {
3238 port_id, phy_id, 0, 0);
3256 port_id, phy_id, 0, 0);
3278 static int mpi_reg_resp(
struct pm8001_hba_info *pm8001_ha,
void *piomb)
3290 pm8001_dev = ccb->
device;
3294 pm8001_printk(
" register device is status = %d\n", status));
3306 pm8001_printk(
"DEVREG_FAILURE_DEVICE_ALREADY_REGISTERED\n"));
3314 pm8001_printk(
"DEVREG_FAILURE_PHY_ID_ALREADY_REGISTERED\n"));
3330 pm8001_printk(
"DEVREG_FAILURE_DEVICE_TYPE_NOT_UNSORPORTED\n"));
3340 static int mpi_dereg_resp(
struct pm8001_hba_info *pm8001_ha,
void *piomb)
3352 ", device_id = %x\n", status, device_id));
3357 mpi_fw_flash_update_resp(
struct pm8001_hba_info *pm8001_ha,
void *piomb)
3366 memcpy(&fw_control_context,
3368 sizeof(fw_control_context));
3413 fw_control_context.
len,
3445 unsigned long flags;
3466 "tag = 0x%x, scp= 0x%x\n", status, tag, scp));
3494 static int mpi_hw_event(
struct pm8001_hba_info *pm8001_ha,
void* piomb)
3496 unsigned long flags;
3499 u32 lr_evt_status_phyid_portid =
3501 u8 port_id = (
u8)(lr_evt_status_phyid_portid & 0x0000000F);
3503 (
u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
3505 (
u16)((lr_evt_status_phyid_portid & 0x00FFFF00) >> 8);
3507 (
u8)((lr_evt_status_phyid_portid & 0x0F000000) >> 24);
3513 switch (eventType) {
3517 " status = %x\n", status));
3527 hw_event_sas_phy_up(pm8001_ha, piomb);
3532 hw_event_sata_phy_up(pm8001_ha, piomb);
3537 "status = %x\n", status));
3552 hw_event_phy_down(pm8001_ha, piomb);
3557 sas_phy_disconnected(sas_phy);
3567 port_id, phy_id, 1, 0);
3576 sas_phy_disconnected(&phy->
sas_phy);
3591 pm8001_hw_event_ack_req(pm8001_ha, 0,
3593 sas_phy_disconnected(sas_phy);
3600 pm8001_hw_event_ack_req(pm8001_ha, 0,
3602 port_id, phy_id, 0, 0);
3603 sas_phy_disconnected(sas_phy);
3610 pm8001_hw_event_ack_req(pm8001_ha, 0,
3612 port_id, phy_id, 0, 0);
3613 sas_phy_disconnected(sas_phy);
3620 pm8001_hw_event_ack_req(pm8001_ha, 0,
3622 port_id, phy_id, 0, 0);
3623 sas_phy_disconnected(sas_phy);
3642 pm8001_hw_event_ack_req(pm8001_ha, 0,
3644 port_id, phy_id, 0, 0);
3654 sas_phy_disconnected(sas_phy);
3661 pm8001_hw_event_ack_req(pm8001_ha, 0,
3663 port_id, phy_id, 0, 0);
3664 sas_phy_disconnected(sas_phy);
3671 sas_phy_disconnected(sas_phy);
3678 sas_phy_disconnected(sas_phy);
3707 static void process_one_iomb(
struct pm8001_hba_info *pm8001_ha,
void *piomb)
3721 mpi_hw_event(pm8001_ha, piomb);
3726 mpi_ssp_completion(pm8001_ha, piomb);
3731 mpi_smp_completion(pm8001_ha, piomb);
3736 mpi_local_phy_ctl(pm8001_ha, piomb);
3741 mpi_reg_resp(pm8001_ha, piomb);
3746 mpi_dereg_resp(pm8001_ha, piomb);
3755 mpi_sata_completion(pm8001_ha, piomb);
3760 mpi_sata_event(pm8001_ha, piomb);
3765 mpi_ssp_event(pm8001_ha, piomb);
3784 mpi_fw_flash_update_resp(pm8001_ha, piomb);
3797 mpi_general_event(pm8001_ha, piomb);
3802 mpi_task_abort_resp(pm8001_ha, piomb);
3807 mpi_task_abort_resp(pm8001_ha, piomb);
3832 mpi_task_abort_resp(pm8001_ha, piomb);
3837 mpi_get_nvmd_resp(pm8001_ha, piomb);
3842 mpi_set_nvmd_resp(pm8001_ha, piomb);
3851 mpi_set_dev_state_resp(pm8001_ha, piomb);
3879 unsigned long flags;
3884 ret = mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc);
3887 process_one_iomb(pm8001_ha, (
void *)(pMsg1 - 4));
3889 mpi_msg_free_set(pm8001_ha, pMsg1, circularQ, bc);
3901 spin_unlock_irqrestore(&pm8001_ha->
lock, flags);
3906 static const u8 data_dir_flags[] = {
3927 static void build_smp_cmd(
u32 deviceID,
__le32 hTag,
struct smp_req *psmp_cmd)
3929 psmp_cmd->
tag = hTag;
3952 memset(&smp_cmd, 0,
sizeof(smp_cmd));
3962 sg_resp = &task->
smp_task.smp_resp;
3970 if ((req_len & 0x3) || (resp_len & 0x3)) {
3978 smp_cmd.long_smp_req.long_req_addr =
3980 smp_cmd.long_smp_req.long_req_size =
3982 smp_cmd.long_smp_req.long_resp_addr =
3984 smp_cmd.long_smp_req.long_resp_size =
3986 build_smp_cmd(pm8001_dev->
device_id, smp_cmd.tag, &smp_cmd);
3987 mpi_build_cmd(pm8001_ha, circularQ, opc, (
u32 *)&smp_cmd);
4024 if (task->
ssp_task.enable_first_burst)
4025 ssp_cmd.ssp_iu.efb_prio_attr |= 0x80;
4051 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &
ssp_cmd);
4064 u32 hdr_tag, ncg_tag = 0;
4070 memset(&sata_cmd, 0,
sizeof(sata_cmd));
4091 dir = data_dir_flags[task->
data_dir] << 8;
4095 sata_cmd.ncqtag_atap_dir_m =
4096 cpu_to_le32(((ncg_tag & 0xff)<<16)|((ATAP & 0x3f) << 10) | dir);
4097 sata_cmd.sata_fis = task->
ata_task.fis;
4099 sata_cmd.sata_fis.flags |= 0x80;
4100 sata_cmd.sata_fis.flags &= 0xF0;
4116 sata_cmd.addr_low = 0;
4117 sata_cmd.addr_high = 0;
4121 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd);
4140 memset(&payload, 0,
sizeof(payload));
4153 memcpy(payload.sas_identify.sas_addr,
4155 payload.sas_identify.phy_id =
phy_id;
4156 ret = mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
4166 static int pm8001_chip_phy_stop_req(
struct pm8001_hba_info *pm8001_ha,
4175 memset(&payload, 0,
sizeof(payload));
4178 ret = mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload);
4190 u32 stp_sspsmp_sata = 0x4;
4193 int rc, tag = 0xdeadbeef;
4196 u16 firstBurstSize = 0;
4202 memset(&payload, 0,
sizeof(payload));
4207 ccb->
device = pm8001_dev;
4211 stp_sspsmp_sata = 0x02;
4214 stp_sspsmp_sata = 0x00;
4218 stp_sspsmp_sata = 0x01;
4221 phy_id = parent_dev->
ex_dev.ex_phy->phy_id;
4225 linkrate = (pm8001_dev->
sas_device->linkrate < dev->
port->linkrate) ?
4227 payload.phyid_portid =
4229 ((phy_id & 0x0F) << 4));
4230 payload.dtype_dlr_retry =
cpu_to_le32((retryFlag & 0x01) |
4231 ((linkrate & 0x0F) * 0x1000000) |
4232 ((stp_sspsmp_sata & 0x03) * 0x10000000));
4233 payload.firstburstsize_ITNexustimeout =
4237 rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
4244 static int pm8001_chip_dereg_dev_req(
struct pm8001_hba_info *pm8001_ha,
4253 memset(&payload, 0,
sizeof(payload));
4257 pm8001_printk(
"unregister device device_id = %d\n", device_id));
4258 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
4276 memset(&payload, 0,
sizeof(payload));
4279 payload.phyop_phyid =
4280 cpu_to_le32(((phy_op & 0xff) << 8) | (phyId & 0x0F));
4281 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
4288 #ifdef PM8001_USE_MSIX
4291 value = pm8001_cr32(pm8001_ha, 0,
MSGU_ODR);
4307 pm8001_chip_interrupt_disable(pm8001_ha);
4308 process_oq(pm8001_ha);
4309 pm8001_chip_interrupt_enable(pm8001_ha);
4320 memset(&task_abort, 0,
sizeof(task_abort));
4322 task_abort.abort_all = 0;
4326 }
else if (
ABORT_ALL == (flag & ABORT_MASK)) {
4331 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort);
4346 " = %x", cmd_tag, task_tag));
4354 rc = send_task_abort(pm8001_ha, opc, device_id, flag,
4378 memset(&sspTMCmd, 0,
sizeof(sspTMCmd));
4385 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd);
4389 static int pm8001_chip_get_nvmd_req(
struct pm8001_hba_info *pm8001_ha,
4404 if (!fw_control_context)
4407 fw_control_context->
len = ioctl_payload->
length;
4409 memset(&nvmd_req, 0,
sizeof(nvmd_req));
4412 kfree(fw_control_context);
4420 switch (nvmd_type) {
4422 u32 twi_addr, twi_page_size;
4426 nvmd_req.len_ir_vpdd =
cpu_to_le32(IPMode | twi_addr << 16 |
4429 nvmd_req.resp_addr_hi =
4431 nvmd_req.resp_addr_lo =
4438 nvmd_req.resp_addr_hi =
4440 nvmd_req.resp_addr_lo =
4447 nvmd_req.resp_addr_hi =
4449 nvmd_req.resp_addr_lo =
4456 nvmd_req.resp_addr_hi =
4458 nvmd_req.resp_addr_lo =
4465 rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
4469 static int pm8001_chip_set_nvmd_req(
struct pm8001_hba_info *pm8001_ha,
4484 if (!fw_control_context)
4490 memset(&nvmd_req, 0,
sizeof(nvmd_req));
4493 kfree(fw_control_context);
4500 switch (nvmd_type) {
4502 u32 twi_addr, twi_page_size;
4506 nvmd_req.len_ir_vpdd =
cpu_to_le32(IPMode | twi_addr << 16 |
4509 nvmd_req.resp_addr_hi =
4511 nvmd_req.resp_addr_lo =
4519 nvmd_req.resp_addr_hi =
4521 nvmd_req.resp_addr_lo =
4528 nvmd_req.resp_addr_hi =
4530 nvmd_req.resp_addr_lo =
4537 nvmd_req.resp_addr_hi =
4539 nvmd_req.resp_addr_lo =
4545 rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &nvmd_req);
4559 struct fw_flash_updata_info *
info;
4566 info = fw_flash_updata_info;
4571 payload.len = info->
sgl.im_len.len ;
4572 payload.sgl_addr_lo =
4574 payload.sgl_addr_hi =
4576 ret = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
4584 struct fw_flash_updata_info flash_update_info;
4597 if (!fw_control_context)
4600 if (fw_control->
len != 0) {
4606 fw_control->
len, 0) != 0) {
4609 kfree(fw_control_context);
4614 flash_update_info.sgl.addr =
cpu_to_le64(phys_addr);
4616 flash_update_info.sgl.im_len.e = 0;
4617 flash_update_info.cur_image_offset = fw_control->
offset;
4618 flash_update_info.cur_image_len = fw_control->
len;
4619 flash_update_info.total_image_len = fw_control->
size;
4622 fw_control_context->
len = fw_control->
len;
4625 kfree(fw_control_context);
4631 rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info,
4646 memset(&payload, 0,
sizeof(payload));
4652 ccb->
device = pm8001_dev;
4657 rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
4671 memset(&payload, 0,
sizeof(payload));
4681 payload.open_reject_cmdretries_data_retries =
cpu_to_le32(0xff00ff);
4682 rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
4689 .chip_init = pm8001_chip_init,
4690 .chip_soft_rst = pm8001_chip_soft_rst,
4691 .chip_rst = pm8001_hw_chip_rst,
4692 .chip_iounmap = pm8001_chip_iounmap,
4693 .isr = pm8001_chip_isr,
4694 .is_our_interupt = pm8001_chip_is_our_interupt,
4695 .isr_process_oq = process_oq,
4696 .interrupt_enable = pm8001_chip_interrupt_enable,
4697 .interrupt_disable = pm8001_chip_interrupt_disable,
4698 .make_prd = pm8001_chip_make_sg,
4699 .smp_req = pm8001_chip_smp_req,
4700 .ssp_io_req = pm8001_chip_ssp_io_req,
4701 .sata_req = pm8001_chip_sata_req,
4702 .phy_start_req = pm8001_chip_phy_start_req,
4703 .phy_stop_req = pm8001_chip_phy_stop_req,
4704 .reg_dev_req = pm8001_chip_reg_dev_req,
4705 .dereg_dev_req = pm8001_chip_dereg_dev_req,
4706 .phy_ctl_req = pm8001_chip_phy_ctl_req,
4707 .task_abort = pm8001_chip_abort_task,
4708 .ssp_tm_req = pm8001_chip_ssp_tm_req,
4709 .get_nvmd_req = pm8001_chip_get_nvmd_req,
4710 .set_nvmd_req = pm8001_chip_set_nvmd_req,
4711 .fw_flash_update_req = pm8001_chip_fw_flash_update_req,
4712 .set_dev_state_req = pm8001_chip_set_dev_state_req,
4713 .sas_re_init_req = pm8001_chip_sas_re_initialization,