61 #include <linux/module.h>
62 #include <linux/errno.h>
65 #include <linux/pci.h>
69 #include <linux/kernel.h>
70 #include <linux/string.h>
77 #include <scsi/scsi.h>
90 static u8 default_nvram[64] =
119 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
120 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
130 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
131 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8,
143 for (i = 0; i < 10; i++) {
151 static u8 wait_firmware_ready(
struct orc_host * host)
155 for (i = 0; i < 10; i++) {
164 static u8 wait_scsi_reset_done(
struct orc_host * host)
168 for (i = 0; i < 10; i++) {
177 static u8 wait_HDO_off(
struct orc_host * host)
181 for (i = 0; i < 10; i++) {
194 for (i = 0; i < 10; i++) {
203 static unsigned short orc_read_fwrev(
struct orc_host * host)
210 if (wait_HDO_off(host) == 0)
213 if (wait_hdi_set(host, &data) == 0)
218 if (wait_hdi_set(host, &data) == 0)
231 if (wait_HDO_off(host) == 0)
236 if (wait_HDO_off(host) == 0)
241 if (wait_HDO_off(host) == 0)
254 if (wait_HDO_off(host) == 0)
259 if (wait_HDO_off(host) == 0)
262 if (wait_hdi_set(host, &data) == 0)
291 static int se2_rd_all(
struct orc_host * host)
297 for (i = 0; i < 64; i++, np++) {
298 if (orc_nv_read(host, (
u8) i, np) == 0)
304 for (i = 0; i < 63; i++)
319 static void se2_update_all(
struct orc_host * host)
322 u8 *np, *np1, chksum = 0;
325 np = (
u8 *) default_nvram;
326 for (i = 0; i < 63; i++)
330 np = (
u8 *) default_nvram;
332 for (i = 0; i < 64; i++, np++, np1++) {
334 orc_nv_write(host, (
u8) i, *np);
348 if (se2_rd_all(host) != 1) {
349 se2_update_all(host);
365 static u8 orc_load_firmware(
struct orc_host * host)
390 data32_ptr = (
u8 *) & data32;
405 for (i = 0, data32_ptr = (
u8 *) & data32;
412 data32_ptr = (
u8 *) & data32;
420 for (i = 0, data32_ptr = (
u8 *) & data32;
431 data32_ptr = (
u8 *) & data32;
442 static void setup_SCBs(
struct orc_host * host)
479 static void init_alloc_map(
struct orc_host * host)
484 for (j = 0; j < 8; j++) {
499 static int init_orchid(
struct orc_host * host)
505 init_alloc_map(host);
509 revision = orc_read_fwrev(host);
510 if (revision == 0xFFFF) {
512 if (wait_chip_ready(host) == 0)
514 orc_load_firmware(host);
517 if (wait_firmware_ready(host) == 0)
525 if (wait_chip_ready(host) == 0)
527 orc_load_firmware(host);
532 if (wait_firmware_ready(host) == 0)
547 for (i = 0; i < 16; ptr++, i++) {
565 static int orc_reset_scsi_bus(
struct orc_host * host)
571 init_alloc_map(host);
576 if (wait_scsi_reset_done(host) == 0) {
612 init_alloc_map(host);
616 escb = host_scb->
escb;
617 if (host_scb->
status && escb->
srb == cmd)
622 if (i == ORC_MAXQUEUE) {
629 if ((scb = __orc_alloc_scb(host)) ==
NULL) {
650 orc_exec_scb(host, scb);
672 channel = host->
index;
673 for (i = 0; i < 8; i++) {
674 for (index = 0; index < 32; index++) {
677 idx = index + 32 *
i;
702 scb = __orc_alloc_scb(host);
716 static void orc_release_scb(
struct orc_host *host,
struct orc_scb *scb)
722 channel = host->
index;
738 static int orchid_abort_scb(
struct orc_host * host,
struct orc_scb * scb)
744 if (wait_HDO_off(host) == 0)
749 if (wait_HDO_off(host) == 0)
752 if (wait_hdi_set(host, &data) == 0)
784 if (orchid_abort_scb(host, scb)) {
828 inia100_scb_handler(host, scb);
895 if (cmd->
device->tagged_supported) {
922 if ((scb = orc_alloc_scb(host)) ==
NULL)
925 if (inia100_build_scb(host, scb, cmd)) {
926 orc_release_scb(host, scb);
929 orc_exec_scb(host, scb);
947 host = (
struct orc_host *) cmd->device->host->hostdata;
948 return inia100_abort_cmd(host, cmd);
959 static int inia100_bus_reset(
struct scsi_cmnd * cmd)
963 return orc_reset_scsi_bus(host);
973 static int inia100_device_reset(
struct scsi_cmnd * cmd)
977 return orc_device_reset(host, cmd,
scmd_id(cmd));
991 static void inia100_scb_handler(
struct orc_host *host,
struct orc_scb *scb)
999 orc_release_scb(host, scb);
1046 orc_release_scb(host, scb);
1061 unsigned long flags;
1065 res = orc_interrupt(host);
1066 spin_unlock_irqrestore(shost->
host_lock, flags);
1072 .proc_name =
"inia100",
1074 .queuecommand = inia100_queue,
1075 .eh_abort_handler = inia100_abort,
1076 .eh_bus_reset_handler = inia100_bus_reset,
1077 .eh_device_reset_handler = inia100_device_reset,
1093 unsigned long biosaddr;
1100 "on inia100 adapter, ignoring.\n");
1101 goto out_disable_device;
1109 goto out_disable_device;
1113 bios =
inw(port + 0x50);
1118 goto out_release_region;
1120 host = (
struct orc_host *)shost->hostdata;
1127 sz = ORC_MAXQUEUE *
sizeof(
struct orc_scb);
1131 printk(
"inia100: SCB memory allocation error\n");
1141 printk(
"inia100: ESCB memory allocation error\n");
1142 goto out_free_scb_array;
1147 biosaddr = (biosaddr << 4);
1149 if (init_orchid(host)) {
1150 printk(
"inia100: initial orchid fail!!\n");
1151 goto out_free_escb_array;
1170 goto out_free_escb_array;
1173 pci_set_drvdata(pdev, shost);
1175 error = scsi_add_host(shost, &pdev->
dev);
1184 out_free_escb_array:
1202 struct Scsi_Host *shost = pci_get_drvdata(pdev);
1223 static struct pci_driver inia100_pci_driver = {
1225 .id_table = inia100_pci_tbl,
1226 .probe = inia100_probe_one,
1230 static int __init inia100_init(
void)
1232 return pci_register_driver(&inia100_pci_driver);
1235 static void __exit inia100_exit(
void)