Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] hptiop: Support HighPoint RR4520/RR4522 HBA

Support IOP RR4520/RR4522 which are based on Marvell frey.

Signed-off-by: HighPoint Linux Team <linux@highpoint-tech.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

HighPoint Linux Team and committed by
James Bottomley
286aa031 b83908ce

+530 -24
+65 -4
Documentation/scsi/hptiop.txt
··· 37 37 0x40 Inbound Queue Port 38 38 0x44 Outbound Queue Port 39 39 40 - For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1: 40 + For Marvell not Frey IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1: 41 41 42 42 BAR0 offset Register 43 43 0x20400 Inbound Doorbell Register ··· 55 55 0x40-0x1040 Inbound Queue 56 56 0x1040-0x2040 Outbound Queue 57 57 58 + For Marvell Frey IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1: 58 59 59 - I/O Request Workflow 60 - ---------------------- 60 + BAR0 offset Register 61 + 0x0 IOP configuration information. 62 + 63 + BAR1 offset Register 64 + 0x4000 Inbound List Base Address Low 65 + 0x4004 Inbound List Base Address High 66 + 0x4018 Inbound List Write Pointer 67 + 0x402C Inbound List Configuration and Control 68 + 0x4050 Outbound List Base Address Low 69 + 0x4054 Outbound List Base Address High 70 + 0x4058 Outbound List Copy Pointer Shadow Base Address Low 71 + 0x405C Outbound List Copy Pointer Shadow Base Address High 72 + 0x4088 Outbound List Interrupt Cause 73 + 0x408C Outbound List Interrupt Enable 74 + 0x1020C PCIe Function 0 Interrupt Enable 75 + 0x10400 PCIe Function 0 to CPU Message A 76 + 0x10420 CPU to PCIe Function 0 Message A 77 + 0x10480 CPU to PCIe Function 0 Doorbell 78 + 0x10484 CPU to PCIe Function 0 Doorbell Enable 79 + 80 + 81 + I/O Request Workflow of Not Marvell Frey 82 + ------------------------------------------ 61 83 62 84 All queued requests are handled via inbound/outbound queue port. 63 85 A request packet can be allocated in either IOP or host memory. ··· 123 101 of an inbound message. 124 102 125 103 104 + I/O Request Workflow of Marvell Frey 105 + -------------------------------------- 106 + 107 + All queued requests are handled via inbound/outbound list. 108 + 109 + To send a request to the controller: 110 + 111 + - Allocate a free request in host DMA coherent memory. 112 + 113 + Requests allocated in host memory must be aligned on 32-bytes boundary. 114 + 115 + - Fill the request with index of the request in the flag. 116 + 117 + Fill a free inbound list unit with the physical address and the size of 118 + the request. 119 + 120 + Set up the inbound list write pointer with the index of previous unit, 121 + round to 0 if the index reaches the supported count of requests. 122 + 123 + - Post the inbound list writer pointer to IOP. 124 + 125 + - The IOP process the request. When the request is completed, the flag of 126 + the request with or-ed IOPMU_QUEUE_MASK_HOST_BITS will be put into a 127 + free outbound list unit and the index of the outbound list unit will be 128 + put into the copy pointer shadow register. An outbound interrupt will be 129 + generated. 130 + 131 + - The host read the outbound list copy pointer shadow register and compare 132 + with previous saved read ponter N. If they are different, the host will 133 + read the (N+1)th outbound list unit. 134 + 135 + The host get the index of the request from the (N+1)th outbound list 136 + unit and complete the request. 137 + 138 + Non-queued requests (reset communication/reset/flush etc) can be sent via PCIe 139 + Function 0 to CPU Message A register. The CPU to PCIe Function 0 Message register 140 + with the same value indicates the completion of message. 141 + 142 + 126 143 User-level Interface 127 144 --------------------- 128 145 ··· 173 112 174 113 175 114 ----------------------------------------------------------------------------- 176 - Copyright (C) 2006-2009 HighPoint Technologies, Inc. All Rights Reserved. 115 + Copyright (C) 2006-2012 HighPoint Technologies, Inc. All Rights Reserved. 177 116 178 117 This file is distributed in the hope that it will be useful, 179 118 but WITHOUT ANY WARRANTY; without even the implied warranty of
+394 -19
drivers/scsi/hptiop.c
··· 1 1 /* 2 2 * HighPoint RR3xxx/4xxx controller driver for Linux 3 - * Copyright (C) 2006-2009 HighPoint Technologies, Inc. All Rights Reserved. 3 + * Copyright (C) 2006-2012 HighPoint Technologies, Inc. All Rights Reserved. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify 6 6 * it under the terms of the GNU General Public License as published by ··· 42 42 43 43 static char driver_name[] = "hptiop"; 44 44 static const char driver_name_long[] = "RocketRAID 3xxx/4xxx Controller driver"; 45 - static const char driver_ver[] = "v1.6 (091225)"; 45 + static const char driver_ver[] = "v1.8"; 46 46 47 47 static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec); 48 48 static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag, ··· 73 73 } 74 74 75 75 static int iop_wait_ready_mv(struct hptiop_hba *hba, u32 millisec) 76 + { 77 + return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec); 78 + } 79 + 80 + static int iop_wait_ready_mvfrey(struct hptiop_hba *hba, u32 millisec) 76 81 { 77 82 return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec); 78 83 } ··· 235 230 return ret; 236 231 } 237 232 233 + static void hptiop_request_callback_mvfrey(struct hptiop_hba *hba, u32 _tag) 234 + { 235 + u32 req_type = _tag & 0xf; 236 + struct hpt_iop_request_scsi_command *req; 237 + 238 + switch (req_type) { 239 + case IOP_REQUEST_TYPE_GET_CONFIG: 240 + case IOP_REQUEST_TYPE_SET_CONFIG: 241 + hba->msg_done = 1; 242 + break; 243 + 244 + case IOP_REQUEST_TYPE_SCSI_COMMAND: 245 + req = hba->reqs[(_tag >> 4) & 0xff].req_virt; 246 + if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT)) 247 + req->header.result = IOP_RESULT_SUCCESS; 248 + hptiop_finish_scsi_req(hba, (_tag >> 4) & 0xff, req); 249 + break; 250 + 251 + default: 252 + break; 253 + } 254 + } 255 + 256 + static int iop_intr_mvfrey(struct hptiop_hba *hba) 257 + { 258 + u32 _tag, status, cptr, cur_rptr; 259 + int ret = 0; 260 + 261 + if (hba->initialized) 262 + writel(0, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); 263 + 264 + status = readl(&(hba->u.mvfrey.mu->f0_doorbell)); 265 + if (status) { 266 + writel(status, &(hba->u.mvfrey.mu->f0_doorbell)); 267 + if (status & CPU_TO_F0_DRBL_MSG_BIT) { 268 + u32 msg = readl(&(hba->u.mvfrey.mu->cpu_to_f0_msg_a)); 269 + dprintk("received outbound msg %x\n", msg); 270 + hptiop_message_callback(hba, msg); 271 + } 272 + ret = 1; 273 + } 274 + 275 + status = readl(&(hba->u.mvfrey.mu->isr_cause)); 276 + if (status) { 277 + writel(status, &(hba->u.mvfrey.mu->isr_cause)); 278 + do { 279 + cptr = *hba->u.mvfrey.outlist_cptr & 0xff; 280 + cur_rptr = hba->u.mvfrey.outlist_rptr; 281 + while (cur_rptr != cptr) { 282 + cur_rptr++; 283 + if (cur_rptr == hba->u.mvfrey.list_count) 284 + cur_rptr = 0; 285 + 286 + _tag = hba->u.mvfrey.outlist[cur_rptr].val; 287 + BUG_ON(!(_tag & IOPMU_QUEUE_MASK_HOST_BITS)); 288 + hptiop_request_callback_mvfrey(hba, _tag); 289 + ret = 1; 290 + } 291 + hba->u.mvfrey.outlist_rptr = cur_rptr; 292 + } while (cptr != (*hba->u.mvfrey.outlist_cptr & 0xff)); 293 + } 294 + 295 + if (hba->initialized) 296 + writel(0x1010, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); 297 + 298 + return ret; 299 + } 300 + 238 301 static int iop_send_sync_request_itl(struct hptiop_hba *hba, 239 302 void __iomem *_req, u32 millisec) 240 303 { ··· 345 272 return -1; 346 273 } 347 274 275 + static int iop_send_sync_request_mvfrey(struct hptiop_hba *hba, 276 + u32 size_bits, u32 millisec) 277 + { 278 + struct hpt_iop_request_header *reqhdr = 279 + hba->u.mvfrey.internal_req.req_virt; 280 + u32 i; 281 + 282 + hba->msg_done = 0; 283 + reqhdr->flags |= cpu_to_le32(IOP_REQUEST_FLAG_SYNC_REQUEST); 284 + hba->ops->post_req(hba, &(hba->u.mvfrey.internal_req)); 285 + 286 + for (i = 0; i < millisec; i++) { 287 + iop_intr_mvfrey(hba); 288 + if (hba->msg_done) 289 + break; 290 + msleep(1); 291 + } 292 + return hba->msg_done ? 0 : -1; 293 + } 294 + 348 295 static void hptiop_post_msg_itl(struct hptiop_hba *hba, u32 msg) 349 296 { 350 297 writel(msg, &hba->u.itl.iop->inbound_msgaddr0); ··· 378 285 readl(&hba->u.mv.regs->inbound_doorbell); 379 286 } 380 287 288 + static void hptiop_post_msg_mvfrey(struct hptiop_hba *hba, u32 msg) 289 + { 290 + writel(msg, &(hba->u.mvfrey.mu->f0_to_cpu_msg_a)); 291 + readl(&(hba->u.mvfrey.mu->f0_to_cpu_msg_a)); 292 + } 293 + 381 294 static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec) 382 295 { 383 296 u32 i; 384 297 385 298 hba->msg_done = 0; 299 + hba->ops->disable_intr(hba); 386 300 hba->ops->post_msg(hba, msg); 387 301 388 302 for (i = 0; i < millisec; i++) { ··· 401 301 msleep(1); 402 302 } 403 303 304 + hba->ops->enable_intr(hba); 404 305 return hba->msg_done? 0 : -1; 405 306 } 406 307 ··· 452 351 } 453 352 454 353 memcpy(config, req, sizeof(struct hpt_iop_request_get_config)); 354 + return 0; 355 + } 356 + 357 + static int iop_get_config_mvfrey(struct hptiop_hba *hba, 358 + struct hpt_iop_request_get_config *config) 359 + { 360 + struct hpt_iop_request_get_config *info = hba->u.mvfrey.config; 361 + 362 + if (info->header.size != sizeof(struct hpt_iop_request_get_config) || 363 + info->header.type != IOP_REQUEST_TYPE_GET_CONFIG) 364 + return -1; 365 + 366 + config->interface_version = info->interface_version; 367 + config->firmware_version = info->firmware_version; 368 + config->max_requests = info->max_requests; 369 + config->request_size = info->request_size; 370 + config->max_sg_count = info->max_sg_count; 371 + config->data_transfer_length = info->data_transfer_length; 372 + config->alignment_mask = info->alignment_mask; 373 + config->max_devices = info->max_devices; 374 + config->sdram_size = info->sdram_size; 375 + 455 376 return 0; 456 377 } 457 378 ··· 531 408 return 0; 532 409 } 533 410 411 + static int iop_set_config_mvfrey(struct hptiop_hba *hba, 412 + struct hpt_iop_request_set_config *config) 413 + { 414 + struct hpt_iop_request_set_config *req = 415 + hba->u.mvfrey.internal_req.req_virt; 416 + 417 + memcpy(req, config, sizeof(struct hpt_iop_request_set_config)); 418 + req->header.flags = cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT); 419 + req->header.type = cpu_to_le32(IOP_REQUEST_TYPE_SET_CONFIG); 420 + req->header.size = 421 + cpu_to_le32(sizeof(struct hpt_iop_request_set_config)); 422 + req->header.result = cpu_to_le32(IOP_RESULT_PENDING); 423 + req->header.context = cpu_to_le32(IOP_REQUEST_TYPE_SET_CONFIG<<5); 424 + req->header.context_hi32 = 0; 425 + 426 + if (iop_send_sync_request_mvfrey(hba, 0, 20000)) { 427 + dprintk("Set config send cmd failed\n"); 428 + return -1; 429 + } 430 + 431 + return 0; 432 + } 433 + 534 434 static void hptiop_enable_intr_itl(struct hptiop_hba *hba) 535 435 { 536 436 writel(~(IOPMU_OUTBOUND_INT_POSTQUEUE | IOPMU_OUTBOUND_INT_MSG0), ··· 564 418 { 565 419 writel(MVIOP_MU_OUTBOUND_INT_POSTQUEUE | MVIOP_MU_OUTBOUND_INT_MSG, 566 420 &hba->u.mv.regs->outbound_intmask); 421 + } 422 + 423 + static void hptiop_enable_intr_mvfrey(struct hptiop_hba *hba) 424 + { 425 + writel(CPU_TO_F0_DRBL_MSG_BIT, &(hba->u.mvfrey.mu->f0_doorbell_enable)); 426 + writel(0x1, &(hba->u.mvfrey.mu->isr_enable)); 427 + writel(0x1010, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); 567 428 } 568 429 569 430 static int hptiop_initialize_iop(struct hptiop_hba *hba) ··· 655 502 return 0; 656 503 } 657 504 505 + static int hptiop_map_pci_bar_mvfrey(struct hptiop_hba *hba) 506 + { 507 + hba->u.mvfrey.config = hptiop_map_pci_bar(hba, 0); 508 + if (hba->u.mvfrey.config == NULL) 509 + return -1; 510 + 511 + hba->u.mvfrey.mu = hptiop_map_pci_bar(hba, 2); 512 + if (hba->u.mvfrey.mu == NULL) { 513 + iounmap(hba->u.mvfrey.config); 514 + return -1; 515 + } 516 + 517 + return 0; 518 + } 519 + 658 520 static void hptiop_unmap_pci_bar_mv(struct hptiop_hba *hba) 659 521 { 660 522 iounmap(hba->u.mv.regs); 661 523 iounmap(hba->u.mv.mu); 662 524 } 663 525 526 + static void hptiop_unmap_pci_bar_mvfrey(struct hptiop_hba *hba) 527 + { 528 + iounmap(hba->u.mvfrey.config); 529 + iounmap(hba->u.mvfrey.mu); 530 + } 531 + 664 532 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg) 665 533 { 666 534 dprintk("iop message 0x%x\n", msg); 667 535 668 - if (msg == IOPMU_INBOUND_MSG0_NOP) 536 + if (msg == IOPMU_INBOUND_MSG0_NOP || 537 + msg == IOPMU_INBOUND_MSG0_RESET_COMM) 669 538 hba->msg_done = 1; 670 539 671 540 if (!hba->initialized) ··· 767 592 memcpy(scp->sense_buffer, &req->sg_list, 768 593 min_t(size_t, SCSI_SENSE_BUFFERSIZE, 769 594 le32_to_cpu(req->dataxfer_length))); 595 + goto skip_resid; 770 596 break; 771 597 772 598 default: ··· 775 599 break; 776 600 } 777 601 602 + scsi_set_resid(scp, 603 + scsi_bufflen(scp) - le32_to_cpu(req->dataxfer_length)); 604 + 605 + skip_resid: 778 606 dprintk("scsi_done(%p)\n", scp); 779 607 scp->scsi_done(scp); 780 608 free_req(hba, &hba->reqs[tag]); ··· 872 692 BUG_ON(HPT_SCP(scp)->sgcnt > hba->max_sg_descriptors); 873 693 874 694 scsi_for_each_sg(scp, sg, HPT_SCP(scp)->sgcnt, idx) { 875 - psg[idx].pci_address = cpu_to_le64(sg_dma_address(sg)); 695 + psg[idx].pci_address = cpu_to_le64(sg_dma_address(sg)) | 696 + hba->ops->host_phy_flag; 876 697 psg[idx].size = cpu_to_le32(sg_dma_len(sg)); 877 698 psg[idx].eot = (idx == HPT_SCP(scp)->sgcnt - 1) ? 878 699 cpu_to_le32(1) : 0; ··· 932 751 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba); 933 752 } 934 753 754 + static void hptiop_post_req_mvfrey(struct hptiop_hba *hba, 755 + struct hptiop_request *_req) 756 + { 757 + struct hpt_iop_request_header *reqhdr = _req->req_virt; 758 + u32 index; 759 + 760 + reqhdr->flags |= cpu_to_le32(IOP_REQUEST_FLAG_OUTPUT_CONTEXT | 761 + IOP_REQUEST_FLAG_ADDR_BITS | 762 + ((_req->req_shifted_phy >> 11) & 0xffff0000)); 763 + reqhdr->context = cpu_to_le32(IOPMU_QUEUE_ADDR_HOST_BIT | 764 + (_req->index << 4) | reqhdr->type); 765 + reqhdr->context_hi32 = cpu_to_le32((_req->req_shifted_phy << 5) & 766 + 0xffffffff); 767 + 768 + hba->u.mvfrey.inlist_wptr++; 769 + index = hba->u.mvfrey.inlist_wptr & 0x3fff; 770 + 771 + if (index == hba->u.mvfrey.list_count) { 772 + index = 0; 773 + hba->u.mvfrey.inlist_wptr &= ~0x3fff; 774 + hba->u.mvfrey.inlist_wptr ^= CL_POINTER_TOGGLE; 775 + } 776 + 777 + hba->u.mvfrey.inlist[index].addr = 778 + (dma_addr_t)_req->req_shifted_phy << 5; 779 + hba->u.mvfrey.inlist[index].intrfc_len = (reqhdr->size + 3) / 4; 780 + writel(hba->u.mvfrey.inlist_wptr, 781 + &(hba->u.mvfrey.mu->inbound_write_ptr)); 782 + readl(&(hba->u.mvfrey.mu->inbound_write_ptr)); 783 + } 784 + 785 + static int hptiop_reset_comm_itl(struct hptiop_hba *hba) 786 + { 787 + return 0; 788 + } 789 + 790 + static int hptiop_reset_comm_mv(struct hptiop_hba *hba) 791 + { 792 + return 0; 793 + } 794 + 795 + static int hptiop_reset_comm_mvfrey(struct hptiop_hba *hba) 796 + { 797 + u32 list_count = hba->u.mvfrey.list_count; 798 + 799 + if (iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET_COMM, 3000)) 800 + return -1; 801 + 802 + /* wait 100ms for MCU ready */ 803 + msleep(100); 804 + 805 + writel(cpu_to_le32(hba->u.mvfrey.inlist_phy & 0xffffffff), 806 + &(hba->u.mvfrey.mu->inbound_base)); 807 + writel(cpu_to_le32((hba->u.mvfrey.inlist_phy >> 16) >> 16), 808 + &(hba->u.mvfrey.mu->inbound_base_high)); 809 + 810 + writel(cpu_to_le32(hba->u.mvfrey.outlist_phy & 0xffffffff), 811 + &(hba->u.mvfrey.mu->outbound_base)); 812 + writel(cpu_to_le32((hba->u.mvfrey.outlist_phy >> 16) >> 16), 813 + &(hba->u.mvfrey.mu->outbound_base_high)); 814 + 815 + writel(cpu_to_le32(hba->u.mvfrey.outlist_cptr_phy & 0xffffffff), 816 + &(hba->u.mvfrey.mu->outbound_shadow_base)); 817 + writel(cpu_to_le32((hba->u.mvfrey.outlist_cptr_phy >> 16) >> 16), 818 + &(hba->u.mvfrey.mu->outbound_shadow_base_high)); 819 + 820 + hba->u.mvfrey.inlist_wptr = (list_count - 1) | CL_POINTER_TOGGLE; 821 + *hba->u.mvfrey.outlist_cptr = (list_count - 1) | CL_POINTER_TOGGLE; 822 + hba->u.mvfrey.outlist_rptr = list_count - 1; 823 + return 0; 824 + } 825 + 935 826 static int hptiop_queuecommand_lck(struct scsi_cmnd *scp, 936 827 void (*done)(struct scsi_cmnd *)) 937 828 { ··· 1024 771 1025 772 _req->scp = scp; 1026 773 1027 - dprintk("hptiop_queuecmd(scp=%p) %d/%d/%d/%d cdb=(%x-%x-%x) " 774 + dprintk("hptiop_queuecmd(scp=%p) %d/%d/%d/%d cdb=(%08x-%08x-%08x-%08x) " 1028 775 "req_index=%d, req=%p\n", 1029 776 scp, 1030 777 host->host_no, scp->device->channel, 1031 778 scp->device->id, scp->device->lun, 1032 - ((u32 *)scp->cmnd)[0], 1033 - ((u32 *)scp->cmnd)[1], 1034 - ((u32 *)scp->cmnd)[2], 779 + cpu_to_be32(((u32 *)scp->cmnd)[0]), 780 + cpu_to_be32(((u32 *)scp->cmnd)[1]), 781 + cpu_to_be32(((u32 *)scp->cmnd)[2]), 782 + cpu_to_be32(((u32 *)scp->cmnd)[3]), 1035 783 _req->index, _req->req_virt); 1036 784 1037 785 scp->result = 0; ··· 1187 933 .change_queue_depth = hptiop_adjust_disk_queue_depth, 1188 934 }; 1189 935 936 + static int hptiop_internal_memalloc_itl(struct hptiop_hba *hba) 937 + { 938 + return 0; 939 + } 940 + 1190 941 static int hptiop_internal_memalloc_mv(struct hptiop_hba *hba) 1191 942 { 1192 943 hba->u.mv.internal_req = dma_alloc_coherent(&hba->pcidev->dev, ··· 1202 943 return -1; 1203 944 } 1204 945 946 + static int hptiop_internal_memalloc_mvfrey(struct hptiop_hba *hba) 947 + { 948 + u32 list_count = readl(&hba->u.mvfrey.mu->inbound_conf_ctl); 949 + char *p; 950 + dma_addr_t phy; 951 + 952 + BUG_ON(hba->max_request_size == 0); 953 + 954 + if (list_count == 0) { 955 + BUG_ON(1); 956 + return -1; 957 + } 958 + 959 + list_count >>= 16; 960 + 961 + hba->u.mvfrey.list_count = list_count; 962 + hba->u.mvfrey.internal_mem_size = 0x800 + 963 + list_count * sizeof(struct mvfrey_inlist_entry) + 964 + list_count * sizeof(struct mvfrey_outlist_entry) + 965 + sizeof(int); 966 + 967 + p = dma_alloc_coherent(&hba->pcidev->dev, 968 + hba->u.mvfrey.internal_mem_size, &phy, GFP_KERNEL); 969 + if (!p) 970 + return -1; 971 + 972 + hba->u.mvfrey.internal_req.req_virt = p; 973 + hba->u.mvfrey.internal_req.req_shifted_phy = phy >> 5; 974 + hba->u.mvfrey.internal_req.scp = NULL; 975 + hba->u.mvfrey.internal_req.next = NULL; 976 + 977 + p += 0x800; 978 + phy += 0x800; 979 + 980 + hba->u.mvfrey.inlist = (struct mvfrey_inlist_entry *)p; 981 + hba->u.mvfrey.inlist_phy = phy; 982 + 983 + p += list_count * sizeof(struct mvfrey_inlist_entry); 984 + phy += list_count * sizeof(struct mvfrey_inlist_entry); 985 + 986 + hba->u.mvfrey.outlist = (struct mvfrey_outlist_entry *)p; 987 + hba->u.mvfrey.outlist_phy = phy; 988 + 989 + p += list_count * sizeof(struct mvfrey_outlist_entry); 990 + phy += list_count * sizeof(struct mvfrey_outlist_entry); 991 + 992 + hba->u.mvfrey.outlist_cptr = (__le32 *)p; 993 + hba->u.mvfrey.outlist_cptr_phy = phy; 994 + 995 + return 0; 996 + } 997 + 998 + static int hptiop_internal_memfree_itl(struct hptiop_hba *hba) 999 + { 1000 + return 0; 1001 + } 1002 + 1205 1003 static int hptiop_internal_memfree_mv(struct hptiop_hba *hba) 1206 1004 { 1207 1005 if (hba->u.mv.internal_req) { 1208 1006 dma_free_coherent(&hba->pcidev->dev, 0x800, 1209 1007 hba->u.mv.internal_req, hba->u.mv.internal_req_phy); 1008 + return 0; 1009 + } else 1010 + return -1; 1011 + } 1012 + 1013 + static int hptiop_internal_memfree_mvfrey(struct hptiop_hba *hba) 1014 + { 1015 + if (hba->u.mvfrey.internal_req.req_virt) { 1016 + dma_free_coherent(&hba->pcidev->dev, 1017 + hba->u.mvfrey.internal_mem_size, 1018 + hba->u.mvfrey.internal_req.req_virt, 1019 + (dma_addr_t) 1020 + hba->u.mvfrey.internal_req.req_shifted_phy << 5); 1210 1021 return 0; 1211 1022 } else 1212 1023 return -1; ··· 1356 1027 goto unmap_pci_bar; 1357 1028 } 1358 1029 1359 - if (hba->ops->internal_memalloc) { 1030 + if (hba->ops->family == MV_BASED_IOP) { 1360 1031 if (hba->ops->internal_memalloc(hba)) { 1361 1032 printk(KERN_ERR "scsi%d: internal_memalloc failed\n", 1362 1033 hba->host->host_no); ··· 1378 1049 hba->firmware_version = le32_to_cpu(iop_config.firmware_version); 1379 1050 hba->interface_version = le32_to_cpu(iop_config.interface_version); 1380 1051 hba->sdram_size = le32_to_cpu(iop_config.sdram_size); 1052 + 1053 + if (hba->ops->family == MVFREY_BASED_IOP) { 1054 + if (hba->ops->internal_memalloc(hba)) { 1055 + printk(KERN_ERR "scsi%d: internal_memalloc failed\n", 1056 + hba->host->host_no); 1057 + goto unmap_pci_bar; 1058 + } 1059 + if (hba->ops->reset_comm(hba)) { 1060 + printk(KERN_ERR "scsi%d: reset comm failed\n", 1061 + hba->host->host_no); 1062 + goto unmap_pci_bar; 1063 + } 1064 + } 1381 1065 1382 1066 if (hba->firmware_version > 0x01020000 || 1383 1067 hba->interface_version > 0x01020000) ··· 1446 1104 hba->dma_coherent = start_virt; 1447 1105 hba->dma_coherent_handle = start_phy; 1448 1106 1449 - if ((start_phy & 0x1f) != 0) 1450 - { 1107 + if ((start_phy & 0x1f) != 0) { 1451 1108 offset = ((start_phy + 0x1f) & ~0x1f) - start_phy; 1452 1109 start_phy += offset; 1453 1110 start_virt += offset; 1454 1111 } 1455 1112 1456 - hba->req_list = start_virt; 1113 + hba->req_list = NULL; 1457 1114 for (i = 0; i < hba->max_requests; i++) { 1458 1115 hba->reqs[i].next = NULL; 1459 1116 hba->reqs[i].req_virt = start_virt; ··· 1473 1132 goto free_request_mem; 1474 1133 } 1475 1134 1476 - 1477 1135 scsi_scan_host(host); 1478 1136 1479 1137 dprintk("scsi%d: hptiop_probe successfully\n", hba->host->host_no); ··· 1487 1147 free_irq(hba->pcidev->irq, hba); 1488 1148 1489 1149 unmap_pci_bar: 1490 - if (hba->ops->internal_memfree) 1491 - hba->ops->internal_memfree(hba); 1150 + hba->ops->internal_memfree(hba); 1492 1151 1493 1152 hba->ops->unmap_pci_bar(hba); 1494 1153 ··· 1537 1198 readl(&hba->u.mv.regs->outbound_intmask); 1538 1199 } 1539 1200 1201 + static void hptiop_disable_intr_mvfrey(struct hptiop_hba *hba) 1202 + { 1203 + writel(0, &(hba->u.mvfrey.mu->f0_doorbell_enable)); 1204 + readl(&(hba->u.mvfrey.mu->f0_doorbell_enable)); 1205 + writel(0, &(hba->u.mvfrey.mu->isr_enable)); 1206 + readl(&(hba->u.mvfrey.mu->isr_enable)); 1207 + writel(0, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); 1208 + readl(&(hba->u.mvfrey.mu->pcie_f0_int_enable)); 1209 + } 1210 + 1540 1211 static void hptiop_remove(struct pci_dev *pcidev) 1541 1212 { 1542 1213 struct Scsi_Host *host = pci_get_drvdata(pcidev); ··· 1565 1216 hba->dma_coherent, 1566 1217 hba->dma_coherent_handle); 1567 1218 1568 - if (hba->ops->internal_memfree) 1569 - hba->ops->internal_memfree(hba); 1219 + hba->ops->internal_memfree(hba); 1570 1220 1571 1221 hba->ops->unmap_pci_bar(hba); 1572 1222 ··· 1577 1229 } 1578 1230 1579 1231 static struct hptiop_adapter_ops hptiop_itl_ops = { 1232 + .family = INTEL_BASED_IOP, 1580 1233 .iop_wait_ready = iop_wait_ready_itl, 1581 - .internal_memalloc = NULL, 1582 - .internal_memfree = NULL, 1234 + .internal_memalloc = hptiop_internal_memalloc_itl, 1235 + .internal_memfree = hptiop_internal_memfree_itl, 1583 1236 .map_pci_bar = hptiop_map_pci_bar_itl, 1584 1237 .unmap_pci_bar = hptiop_unmap_pci_bar_itl, 1585 1238 .enable_intr = hptiop_enable_intr_itl, ··· 1591 1242 .post_msg = hptiop_post_msg_itl, 1592 1243 .post_req = hptiop_post_req_itl, 1593 1244 .hw_dma_bit_mask = 64, 1245 + .reset_comm = hptiop_reset_comm_itl, 1246 + .host_phy_flag = cpu_to_le64(0), 1594 1247 }; 1595 1248 1596 1249 static struct hptiop_adapter_ops hptiop_mv_ops = { 1250 + .family = MV_BASED_IOP, 1597 1251 .iop_wait_ready = iop_wait_ready_mv, 1598 1252 .internal_memalloc = hptiop_internal_memalloc_mv, 1599 1253 .internal_memfree = hptiop_internal_memfree_mv, ··· 1610 1258 .post_msg = hptiop_post_msg_mv, 1611 1259 .post_req = hptiop_post_req_mv, 1612 1260 .hw_dma_bit_mask = 33, 1261 + .reset_comm = hptiop_reset_comm_mv, 1262 + .host_phy_flag = cpu_to_le64(0), 1263 + }; 1264 + 1265 + static struct hptiop_adapter_ops hptiop_mvfrey_ops = { 1266 + .family = MVFREY_BASED_IOP, 1267 + .iop_wait_ready = iop_wait_ready_mvfrey, 1268 + .internal_memalloc = hptiop_internal_memalloc_mvfrey, 1269 + .internal_memfree = hptiop_internal_memfree_mvfrey, 1270 + .map_pci_bar = hptiop_map_pci_bar_mvfrey, 1271 + .unmap_pci_bar = hptiop_unmap_pci_bar_mvfrey, 1272 + .enable_intr = hptiop_enable_intr_mvfrey, 1273 + .disable_intr = hptiop_disable_intr_mvfrey, 1274 + .get_config = iop_get_config_mvfrey, 1275 + .set_config = iop_set_config_mvfrey, 1276 + .iop_intr = iop_intr_mvfrey, 1277 + .post_msg = hptiop_post_msg_mvfrey, 1278 + .post_req = hptiop_post_req_mvfrey, 1279 + .hw_dma_bit_mask = 64, 1280 + .reset_comm = hptiop_reset_comm_mvfrey, 1281 + .host_phy_flag = cpu_to_le64(1), 1613 1282 }; 1614 1283 1615 1284 static struct pci_device_id hptiop_id_table[] = { ··· 1656 1283 { PCI_VDEVICE(TTI, 0x3120), (kernel_ulong_t)&hptiop_mv_ops }, 1657 1284 { PCI_VDEVICE(TTI, 0x3122), (kernel_ulong_t)&hptiop_mv_ops }, 1658 1285 { PCI_VDEVICE(TTI, 0x3020), (kernel_ulong_t)&hptiop_mv_ops }, 1286 + { PCI_VDEVICE(TTI, 0x4520), (kernel_ulong_t)&hptiop_mvfrey_ops }, 1287 + { PCI_VDEVICE(TTI, 0x4522), (kernel_ulong_t)&hptiop_mvfrey_ops }, 1659 1288 {}, 1660 1289 }; 1661 1290
+71 -1
drivers/scsi/hptiop.h
··· 1 1 /* 2 2 * HighPoint RR3xxx/4xxx controller driver for Linux 3 - * Copyright (C) 2006-2009 HighPoint Technologies, Inc. All Rights Reserved. 3 + * Copyright (C) 2006-2012 HighPoint Technologies, Inc. All Rights Reserved. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify 6 6 * it under the terms of the GNU General Public License as published by ··· 75 75 __le32 outbound_intmask; 76 76 }; 77 77 78 + #pragma pack(1) 79 + struct hpt_iopmu_mvfrey { 80 + __le32 reserved0[(0x4000 - 0) / 4]; 81 + __le32 inbound_base; 82 + __le32 inbound_base_high; 83 + __le32 reserved1[(0x4018 - 0x4008) / 4]; 84 + __le32 inbound_write_ptr; 85 + __le32 reserved2[(0x402c - 0x401c) / 4]; 86 + __le32 inbound_conf_ctl; 87 + __le32 reserved3[(0x4050 - 0x4030) / 4]; 88 + __le32 outbound_base; 89 + __le32 outbound_base_high; 90 + __le32 outbound_shadow_base; 91 + __le32 outbound_shadow_base_high; 92 + __le32 reserved4[(0x4088 - 0x4060) / 4]; 93 + __le32 isr_cause; 94 + __le32 isr_enable; 95 + __le32 reserved5[(0x1020c - 0x4090) / 4]; 96 + __le32 pcie_f0_int_enable; 97 + __le32 reserved6[(0x10400 - 0x10210) / 4]; 98 + __le32 f0_to_cpu_msg_a; 99 + __le32 reserved7[(0x10420 - 0x10404) / 4]; 100 + __le32 cpu_to_f0_msg_a; 101 + __le32 reserved8[(0x10480 - 0x10424) / 4]; 102 + __le32 f0_doorbell; 103 + __le32 f0_doorbell_enable; 104 + }; 105 + 106 + struct mvfrey_inlist_entry { 107 + dma_addr_t addr; 108 + __le32 intrfc_len; 109 + __le32 reserved; 110 + }; 111 + 112 + struct mvfrey_outlist_entry { 113 + __le32 val; 114 + }; 115 + #pragma pack() 116 + 78 117 #define MVIOP_MU_QUEUE_ADDR_HOST_MASK (~(0x1full)) 79 118 #define MVIOP_MU_QUEUE_ADDR_HOST_BIT 4 80 119 ··· 126 87 #define MVIOP_MU_OUTBOUND_INT_MSG 1 127 88 #define MVIOP_MU_OUTBOUND_INT_POSTQUEUE 2 128 89 90 + #define CL_POINTER_TOGGLE 0x00004000 91 + #define CPU_TO_F0_DRBL_MSG_BIT 0x02000000 92 + 129 93 enum hpt_iopmu_message { 130 94 /* host-to-iop messages */ 131 95 IOPMU_INBOUND_MSG0_NOP = 0, ··· 137 95 IOPMU_INBOUND_MSG0_SHUTDOWN, 138 96 IOPMU_INBOUND_MSG0_STOP_BACKGROUND_TASK, 139 97 IOPMU_INBOUND_MSG0_START_BACKGROUND_TASK, 98 + IOPMU_INBOUND_MSG0_RESET_COMM, 140 99 IOPMU_INBOUND_MSG0_MAX = 0xff, 141 100 /* iop-to-host messages */ 142 101 IOPMU_OUTBOUND_MSG0_REGISTER_DEVICE_0 = 0x100, ··· 161 118 #define IOP_REQUEST_FLAG_BIST_REQUEST 2 162 119 #define IOP_REQUEST_FLAG_REMAPPED 4 163 120 #define IOP_REQUEST_FLAG_OUTPUT_CONTEXT 8 121 + #define IOP_REQUEST_FLAG_ADDR_BITS 0x40 /* flags[31:16] is phy_addr[47:32] */ 164 122 165 123 enum hpt_iop_request_type { 166 124 IOP_REQUEST_TYPE_GET_CONFIG = 0, ··· 267 223 268 224 #define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp) 269 225 226 + enum hptiop_family { 227 + UNKNOWN_BASED_IOP, 228 + INTEL_BASED_IOP, 229 + MV_BASED_IOP, 230 + MVFREY_BASED_IOP 231 + } ; 232 + 270 233 struct hptiop_hba { 271 234 struct hptiop_adapter_ops *ops; 272 235 union { ··· 287 236 void *internal_req; 288 237 dma_addr_t internal_req_phy; 289 238 } mv; 239 + struct { 240 + struct hpt_iop_request_get_config __iomem *config; 241 + struct hpt_iopmu_mvfrey __iomem *mu; 242 + 243 + int internal_mem_size; 244 + struct hptiop_request internal_req; 245 + int list_count; 246 + struct mvfrey_inlist_entry *inlist; 247 + dma_addr_t inlist_phy; 248 + __le32 inlist_wptr; 249 + struct mvfrey_outlist_entry *outlist; 250 + dma_addr_t outlist_phy; 251 + __le32 *outlist_cptr; /* copy pointer shadow */ 252 + dma_addr_t outlist_cptr_phy; 253 + __le32 outlist_rptr; 254 + } mvfrey; 290 255 } u; 291 256 292 257 struct Scsi_Host *host; ··· 350 283 }; 351 284 352 285 struct hptiop_adapter_ops { 286 + enum hptiop_family family; 353 287 int (*iop_wait_ready)(struct hptiop_hba *hba, u32 millisec); 354 288 int (*internal_memalloc)(struct hptiop_hba *hba); 355 289 int (*internal_memfree)(struct hptiop_hba *hba); ··· 366 298 void (*post_msg)(struct hptiop_hba *hba, u32 msg); 367 299 void (*post_req)(struct hptiop_hba *hba, struct hptiop_request *_req); 368 300 int hw_dma_bit_mask; 301 + int (*reset_comm)(struct hptiop_hba *hba); 302 + __le64 host_phy_flag; 369 303 }; 370 304 371 305 #define HPT_IOCTL_RESULT_OK 0