Lines Matching defs:host

50  *          - Fix allocation of scsi host structs and private data
85 static struct orc_scb *__orc_alloc_scb(struct orc_host * host);
86 static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb);
139 static u8 wait_chip_ready(struct orc_host * host)
144 if (inb(host->base + ORC_HCTRL) & HOSTSTOP) /* Wait HOSTSTOP set */
151 static u8 wait_firmware_ready(struct orc_host * host)
156 if (inb(host->base + ORC_HSTUS) & RREADY) /* Wait READY set */
164 static u8 wait_scsi_reset_done(struct orc_host * host)
169 if (!(inb(host->base + ORC_HCTRL) & SCSIRST)) /* Wait SCSIRST done */
177 static u8 wait_HDO_off(struct orc_host * host)
182 if (!(inb(host->base + ORC_HCTRL) & HDO)) /* Wait HDO off */
190 static u8 wait_hdi_set(struct orc_host * host, u8 * data)
195 if ((*data = inb(host->base + ORC_HSTUS)) & HDI)
203 static unsigned short orc_read_fwrev(struct orc_host * host)
208 outb(ORC_CMD_VERSION, host->base + ORC_HDATA);
209 outb(HDO, host->base + ORC_HCTRL);
210 if (wait_HDO_off(host) == 0) /* Wait HDO off */
213 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */
215 version = inb(host->base + ORC_HDATA);
216 outb(data, host->base + ORC_HSTUS); /* Clear HDI */
218 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */
220 version |= inb(host->base + ORC_HDATA) << 8;
221 outb(data, host->base + ORC_HSTUS); /* Clear HDI */
227 static u8 orc_nv_write(struct orc_host * host, unsigned char address, unsigned char value)
229 outb(ORC_CMD_SET_NVM, host->base + ORC_HDATA); /* Write command */
230 outb(HDO, host->base + ORC_HCTRL);
231 if (wait_HDO_off(host) == 0) /* Wait HDO off */
234 outb(address, host->base + ORC_HDATA); /* Write address */
235 outb(HDO, host->base + ORC_HCTRL);
236 if (wait_HDO_off(host) == 0) /* Wait HDO off */
239 outb(value, host->base + ORC_HDATA); /* Write value */
240 outb(HDO, host->base + ORC_HCTRL);
241 if (wait_HDO_off(host) == 0) /* Wait HDO off */
248 static u8 orc_nv_read(struct orc_host * host, u8 address, u8 *ptr)
252 outb(ORC_CMD_GET_NVM, host->base + ORC_HDATA); /* Write command */
253 outb(HDO, host->base + ORC_HCTRL);
254 if (wait_HDO_off(host) == 0) /* Wait HDO off */
257 outb(address, host->base + ORC_HDATA); /* Write address */
258 outb(HDO, host->base + ORC_HCTRL);
259 if (wait_HDO_off(host) == 0) /* Wait HDO off */
262 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */
264 *ptr = inb(host->base + ORC_HDATA);
265 outb(data, host->base + ORC_HSTUS); /* Clear HDI */
273 * @host: host adapter the SCB belongs to
277 static void orc_exec_scb(struct orc_host * host, struct orc_scb * scb)
280 outb(scb->scbidx, host->base + ORC_PQUEUE);
286 * @host: Host whose EEPROM is being loaded
291 static int se2_rd_all(struct orc_host * host)
298 if (orc_nv_read(host, (u8) i, np) == 0)
314 * @host: Host whose EEPROM is being updated
319 static void se2_update_all(struct orc_host * host)
334 orc_nv_write(host, (u8) i, *np);
340 * @host: Host EEPROM to read
342 * Read the EEPROM for a given host. If it is invalid or fails
346 static void read_eeprom(struct orc_host * host)
348 if (se2_rd_all(host) != 1) {
349 se2_update_all(host); /* setup default pattern */
350 se2_rd_all(host); /* load again */
357 * @host: Host to set up
365 static u8 orc_load_firmware(struct orc_host * host)
375 data = inb(host->base + ORC_GCFG);
376 outb(data | EEPRG, host->base + ORC_GCFG); /* Enable EEPROM programming */
377 outb(0x00, host->base + ORC_EBIOSADR2);
378 outw(0x0000, host->base + ORC_EBIOSADR0);
379 if (inb(host->base + ORC_EBIOSDATA) != 0x55) {
380 outb(data, host->base + ORC_GCFG); /* Disable EEPROM programming */
383 outw(0x0001, host->base + ORC_EBIOSADR0);
384 if (inb(host->base + ORC_EBIOSDATA) != 0xAA) {
385 outb(data, host->base + ORC_GCFG); /* Disable EEPROM programming */
389 outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL); /* Enable SRAM programming */
392 outw(0x0010, host->base + ORC_EBIOSADR0);
393 *data32_ptr = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
394 outw(0x0011, host->base + ORC_EBIOSADR0);
395 *(data32_ptr + 1) = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
396 outw(0x0012, host->base + ORC_EBIOSADR0);
397 *(data32_ptr + 2) = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
398 outw(*(data32_ptr + 2), host->base + ORC_EBIOSADR2);
399 outl(le32_to_cpu(data32), host->base + ORC_FWBASEADR); /* Write FW address */
408 outw(bios_addr, host->base + ORC_EBIOSADR0);
409 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
411 outl(le32_to_cpu(data32), host->base + ORC_RISCRAM); /* Write every 4 bytes */
418 outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL); /* Reset program count 0 */
423 outw(bios_addr, host->base + ORC_EBIOSADR0);
424 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
426 if (inl(host->base + ORC_RISCRAM) != le32_to_cpu(data32)) {
427 outb(PRGMRST, host->base + ORC_RISCCTL); /* Reset program to 0 */
428 outb(data, host->base + ORC_GCFG); /*Disable EEPROM programming */
436 outb(PRGMRST, host->base + ORC_RISCCTL); /* Reset program to 0 */
437 outb(data, host->base + ORC_GCFG); /* Disable EEPROM programming */
442 static void setup_SCBs(struct orc_host * host)
450 outb(ORC_MAXQUEUE, host->base + ORC_SCBSIZE); /* Total number of SCBs */
452 outl(host->scb_phys, host->base + ORC_SCBBASE0);
454 outl(host->scb_phys, host->base + ORC_SCBBASE1);
457 scb = host->scb_virt;
458 escb = host->escb_virt;
461 escb_phys = (host->escb_phys + (sizeof(struct orc_extended_scb) * i));
473 * @host: host map to configure
479 static void init_alloc_map(struct orc_host * host)
485 host->allocation_map[i][j] = 0xffffffff;
491 * init_orchid - initialise the host adapter
492 * @host:host adapter to initialise
499 static int init_orchid(struct orc_host * host)
505 init_alloc_map(host);
506 outb(0xFF, host->base + ORC_GIMSK); /* Disable all interrupts */
508 if (inb(host->base + ORC_HSTUS) & RREADY) { /* Orchid is ready */
509 revision = orc_read_fwrev(host);
511 outb(DEVRST, host->base + ORC_HCTRL); /* Reset Host Adapter */
512 if (wait_chip_ready(host) == 0)
514 orc_load_firmware(host); /* Download FW */
515 setup_SCBs(host); /* Setup SCB base and SCB Size registers */
516 outb(0x00, host->base + ORC_HCTRL); /* clear HOSTSTOP */
517 if (wait_firmware_ready(host) == 0)
521 setup_SCBs(host); /* Setup SCB base and SCB Size registers */
524 outb(DEVRST, host->base + ORC_HCTRL); /* Reset Host Adapter */
525 if (wait_chip_ready(host) == 0)
527 orc_load_firmware(host); /* Download FW */
528 setup_SCBs(host); /* Setup SCB base and SCB Size registers */
529 outb(HDO, host->base + ORC_HCTRL); /* Do Hardware Reset & */
532 if (wait_firmware_ready(host) == 0) /* Wait for firmware ready */
538 read_eeprom(host);
543 host->scsi_id = nvramp->scsi_id;
544 host->BIOScfg = nvramp->BIOSConfig1;
545 host->max_targets = MAX_TARGETS;
548 host->target_flag[i] = *ptr;
549 host->max_tags[i] = ORC_MAXTAGS;
553 host->flags |= HCF_SCSI_RESET;
554 outb(0xFB, host->base + ORC_GIMSK); /* enable RP FIFO interrupt */
560 * @host: host being reset
565 static int orc_reset_scsi_bus(struct orc_host * host)
569 spin_lock_irqsave(&host->allocation_lock, flags);
571 init_alloc_map(host);
573 outb(SCSIRST, host->base + ORC_HCTRL);
576 if (wait_scsi_reset_done(host) == 0) {
577 spin_unlock_irqrestore(&host->allocation_lock, flags);
580 spin_unlock_irqrestore(&host->allocation_lock, flags);
587 * @host: host to reset
595 static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsigned int target)
603 spin_lock_irqsave(&(host->allocation_lock), flags);
608 host_scb = host->scb_virt;
612 init_alloc_map(host);
624 spin_unlock_irqrestore(&(host->allocation_lock), flags);
629 if ((scb = __orc_alloc_scb(host)) == NULL) {
631 spin_unlock_irqrestore(&(host->allocation_lock), flags);
650 orc_exec_scb(host, scb); /* Start execute SCB */
651 spin_unlock_irqrestore(&host->allocation_lock, flags);
657 * @host: host to allocate from
665 static struct orc_scb *__orc_alloc_scb(struct orc_host * host)
672 channel = host->index;
675 if ((host->allocation_map[channel][i] >> index) & 0x01) {
676 host->allocation_map[channel][i] &= ~(1 << index);
681 return host->scb_virt + idx;
690 * @host: host to allocate from
696 static struct orc_scb *orc_alloc_scb(struct orc_host * host)
701 spin_lock_irqsave(&host->allocation_lock, flags);
702 scb = __orc_alloc_scb(host);
703 spin_unlock_irqrestore(&host->allocation_lock, flags);
709 * @host: host owning the SCB
713 * calling the SCB must be out of use on both the host and the HA.
716 static void orc_release_scb(struct orc_host *host, struct orc_scb *scb)
721 spin_lock_irqsave(&(host->allocation_lock), flags);
722 channel = host->index; /* Channel */
726 host->allocation_map[channel][i] |= (1 << index);
727 spin_unlock_irqrestore(&(host->allocation_lock), flags);
738 static int orchid_abort_scb(struct orc_host * host, struct orc_scb * scb)
742 outb(ORC_CMD_ABORT_SCB, host->base + ORC_HDATA); /* Write command */
743 outb(HDO, host->base + ORC_HCTRL);
744 if (wait_HDO_off(host) == 0) /* Wait HDO off */
747 outb(scb->scbidx, host->base + ORC_HDATA); /* Write address */
748 outb(HDO, host->base + ORC_HCTRL);
749 if (wait_HDO_off(host) == 0) /* Wait HDO off */
752 if (wait_hdi_set(host, &data) == 0) /* Wait HDI set */
754 status = inb(host->base + ORC_HDATA);
755 outb(data, host->base + ORC_HSTUS); /* Clear HDI */
762 static int inia100_abort_cmd(struct orc_host * host, struct scsi_cmnd *cmd)
769 spin_lock_irqsave(&(host->allocation_lock), flags);
771 scb = host->scb_virt;
784 if (orchid_abort_scb(host, scb)) {
786 spin_unlock_irqrestore(&host->allocation_lock, flags);
794 spin_unlock_irqrestore(&host->allocation_lock, flags);
800 * @host: Host causing the interrupt
803 * by the host lock. While the controller reports that there are
805 * index into a host address pointer to the scb and call the scb
811 static irqreturn_t orc_interrupt(struct orc_host * host)
817 if (inb(host->base + ORC_RQUEUECNT) == 0)
822 scb_index = inb(host->base + ORC_RQUEUE);
824 /* Translate it back to a host pointer */
825 scb = (struct orc_scb *) ((unsigned long) host->scb_virt + (unsigned long) (sizeof(struct orc_scb) * scb_index));
828 inia100_scb_handler(host, scb);
829 } while (inb(host->base + ORC_RQUEUECNT));
835 * @host: host owing the control block
839 * Build a host adapter control block from the SCSI mid layer command
842 static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struct scsi_cmnd * cmd)
905 * inia100_queue_lck - queue command with host
909 * block, build the host specific scb structures and if there is room
915 struct orc_host *host; /* Point to Host adapter control block */
917 host = (struct orc_host *) cmd->device->host->hostdata;
919 if ((scb = orc_alloc_scb(host)) == NULL)
922 if (inia100_build_scb(host, scb, cmd)) {
923 orc_release_scb(host, scb);
926 orc_exec_scb(host, scb); /* Start execute SCB */
936 Input : host - Pointer to host adapter structure
942 struct orc_host *host;
944 host = (struct orc_host *) cmd->device->host->hostdata;
945 return inia100_abort_cmd(host, cmd);
952 Input : host - Pointer to host adapter structure
958 struct orc_host *host;
959 host = (struct orc_host *) cmd->device->host->hostdata;
960 return orc_reset_scsi_bus(host);
966 Input : host - Pointer to host adapter structure
972 struct orc_host *host;
973 host = (struct orc_host *) cmd->device->host->hostdata;
974 return orc_device_reset(host, cmd, scmd_id(cmd));
980 * @host: Host causing the interrupt
984 * from host to SCSI midlayer error coding, save any sense data and
988 static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb)
996 orc_release_scb(host, scb); /* Release SCB for current channel */
1014 phase sequence was requested by the target. The host adapter
1015 will generate a SCSI Reset Condition, notifying the host with
1043 orc_release_scb(host, scb); /* Release SCB for current channel */
1057 struct orc_host *host = (struct orc_host *)shost->hostdata;
1062 res = orc_interrupt(host);
1084 struct orc_host *host;
1113 host = (struct orc_host *)shost->hostdata;
1114 host->pdev = pdev;
1115 host->base = port;
1116 host->BIOScfg = bios;
1117 spin_lock_init(&host->allocation_lock);
1121 host->scb_virt = dma_alloc_coherent(&pdev->dev, sz, &host->scb_phys,
1123 if (!host->scb_virt) {
1130 host->escb_virt = dma_alloc_coherent(&pdev->dev, sz, &host->escb_phys,
1132 if (!host->escb_virt) {
1137 if (init_orchid(host)) { /* Initialize orchid chip */
1142 shost->io_port = host->base;
1146 shost->max_id = host->max_targets;
1149 shost->this_id = host->scsi_id; /* Assign HCS index */
1175 host->escb_virt, host->escb_phys);
1179 host->scb_virt, host->scb_phys);
1193 struct orc_host *host = (struct orc_host *)shost->hostdata;
1200 host->escb_virt, host->escb_phys);
1203 host->scb_virt, host->scb_phys);