Ejemplo n.º 1
0
static inline int mac_esp_wait_for_dreq(struct esp *esp)
{
    struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp);
    int i = 500000;

    do {
        if (mep->pdma_regs == NULL) {
            if (via2_scsi_drq_pending())
                return 0;
        } else {
            if (nubus_readl(mep->pdma_regs) & 0x200)
                return 0;
        }

        if (esp_read8(ESP_STATUS) & ESP_STAT_INTR)
            return 1;

        udelay(2);
    } while (--i);

    printk(KERN_ERR PFX "PDMA timeout (sreg %02x)\n",
           esp_read8(ESP_STATUS));
    mep->error = 1;
    return 1;
}
Ejemplo n.º 2
0
static inline int mac_esp_wait_for_fifo(struct esp *esp)
{
	int i = 500000;

	do {
		if (esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES)
			return 0;

		udelay(2);
	} while (--i);

	printk(KERN_ERR PFX "FIFO is empty (sreg %02x)\n",
	       esp_read8(ESP_STATUS));
	return 1;
}
Ejemplo n.º 3
0
static void mac_esp_send_pdma_cmd(struct esp *esp, u32 addr, u32 esp_count,
				  u32 dma_count, int write, u8 cmd)
{
	struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp);
	unsigned long flags;

	local_irq_save(flags);

	mep->error = 0;

	if (!write)
		scsi_esp_cmd(esp, ESP_CMD_FLUSH);

	esp_write8((esp_count >> 0) & 0xFF, ESP_TCLOW);
	esp_write8((esp_count >> 8) & 0xFF, ESP_TCMED);

	scsi_esp_cmd(esp, cmd);

	do {
		unsigned int count32 = esp_count >> 5;
		unsigned int count2 = (esp_count & 0x1F) >> 1;
		unsigned int count1 = esp_count & 1;
		unsigned int start_addr = addr;

		if (mac_esp_wait_for_dreq(esp))
			break;

		if (write) {
			MAC_ESP_PDMA_LOOP("%4@,%0@+");

			esp_count -= addr - start_addr;
		} else {
			unsigned int n;

			MAC_ESP_PDMA_LOOP("%0@+,%4@");

			if (mac_esp_wait_for_empty_fifo(esp))
				break;

			n = (esp_read8(ESP_TCMED) << 8) + esp_read8(ESP_TCLOW);
			addr = start_addr + esp_count - n;
			esp_count = n;
		}
	} while (esp_count);

	local_irq_restore(flags);
}
Ejemplo n.º 4
0
static inline unsigned int mac_esp_wait_for_fifo(struct esp *esp)
{
    int i = 500000;

    do {
        unsigned int fbytes = esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES;

        if (fbytes)
            return fbytes;

        udelay(2);
    } while (--i);

    printk(KERN_ERR PFX "FIFO is empty (sreg %02x)\n",
           esp_read8(ESP_STATUS));
    return 0;
}
Ejemplo n.º 5
0
static inline int mac_esp_wait_for_empty_fifo(struct esp *esp)
{
    struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp);
    int i = 500000;

    do {
        if (!(esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES))
            return 0;

        if (esp_read8(ESP_STATUS) & ESP_STAT_INTR)
            return 1;

        udelay(2);
    } while (--i);

    printk(KERN_ERR PFX "FIFO is not empty (sreg %02x)\n",
           esp_read8(ESP_STATUS));
    mep->error = 1;
    return 1;
}
Ejemplo n.º 6
0
static inline int mac_esp_wait_for_intr(struct esp *esp)
{
	int i = 500000;

	do {
		esp->sreg = esp_read8(ESP_STATUS);
		if (esp->sreg & ESP_STAT_INTR)
			return 0;

		udelay(2);
	} while (--i);

	printk(KERN_ERR PFX "IRQ timeout (sreg %02x)\n", esp->sreg);
	return 1;
}
Ejemplo n.º 7
0
static int mac_esp_irq_pending(struct esp *esp)
{
    if (esp_read8(ESP_STATUS) & ESP_STAT_INTR)
        return 1;
    return 0;
}
Ejemplo n.º 8
0
static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
                                 u32 dma_count, int write, u8 cmd)
{
    struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp);
    u8 *fifo = esp->regs + ESP_FDATA * 16;

    cmd &= ~ESP_CMD_DMA;
    mep->error = 0;

    if (write) {
        scsi_esp_cmd(esp, cmd);

        while (1) {
            unsigned int n;

            n = mac_esp_wait_for_fifo(esp);
            if (!n)
                break;

            if (n > esp_count)
                n = esp_count;
            esp_count -= n;

            MAC_ESP_PIO_LOOP("%2@,%0@+", n);

            if (!esp_count)
                break;

            if (mac_esp_wait_for_intr(esp))
                break;

            if (((esp->sreg & ESP_STAT_PMASK) != ESP_DIP) &&
                    ((esp->sreg & ESP_STAT_PMASK) != ESP_MIP))
                break;

            esp->ireg = esp_read8(ESP_INTRPT);
            if ((esp->ireg & (ESP_INTR_DC | ESP_INTR_BSERV)) !=
                    ESP_INTR_BSERV)
                break;

            scsi_esp_cmd(esp, ESP_CMD_TI);
        }
    } else {
        scsi_esp_cmd(esp, ESP_CMD_FLUSH);

        if (esp_count >= MAC_ESP_FIFO_SIZE)
            MAC_ESP_PIO_FILL("%0@+,%2@", esp_count);
        else
            MAC_ESP_PIO_LOOP("%0@+,%2@", esp_count);

        scsi_esp_cmd(esp, cmd);

        while (esp_count) {
            unsigned int n;

            if (mac_esp_wait_for_intr(esp))
                break;

            if (((esp->sreg & ESP_STAT_PMASK) != ESP_DOP) &&
                    ((esp->sreg & ESP_STAT_PMASK) != ESP_MOP))
                break;

            esp->ireg = esp_read8(ESP_INTRPT);
            if ((esp->ireg & (ESP_INTR_DC | ESP_INTR_BSERV)) !=
                    ESP_INTR_BSERV)
                break;

            n = MAC_ESP_FIFO_SIZE -
                (esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES);
            if (n > esp_count)
                n = esp_count;

            if (n == MAC_ESP_FIFO_SIZE) {
                MAC_ESP_PIO_FILL("%0@+,%2@", esp_count);
            } else {
                esp_count -= n;
                MAC_ESP_PIO_LOOP("%0@+,%2@", n);
            }

            scsi_esp_cmd(esp, ESP_CMD_TI);
        }
    }
}
Ejemplo n.º 9
0
static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
				 u32 dma_count, int write, u8 cmd)
{
	unsigned long flags;
	struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp);
	u8 *fifo = esp->regs + ESP_FDATA * 16;

	local_irq_save(flags);

	cmd &= ~ESP_CMD_DMA;
	mep->error = 0;

	if (write) {
		scsi_esp_cmd(esp, cmd);

		if (!mac_esp_wait_for_intr(esp)) {
			if (mac_esp_wait_for_fifo(esp))
				esp_count = 0;
		} else {
			esp_count = 0;
		}
	} else {
		scsi_esp_cmd(esp, ESP_CMD_FLUSH);

		if (esp_count >= MAC_ESP_FIFO_SIZE)
			MAC_ESP_PIO_FILL("%0@+,%2@", esp_count);
		else
			MAC_ESP_PIO_LOOP("%0@+,%2@", esp_count);

		scsi_esp_cmd(esp, cmd);
	}

	while (esp_count) {
		unsigned int n;

		if (mac_esp_wait_for_intr(esp)) {
			mep->error = 1;
			break;
		}

		if (esp->sreg & ESP_STAT_SPAM) {
			printk(KERN_ERR PFX "gross error\n");
			mep->error = 1;
			break;
		}

		n = esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES;

		if (write) {
			if (n > esp_count)
				n = esp_count;
			esp_count -= n;

			MAC_ESP_PIO_LOOP("%2@,%0@+", n);

			if ((esp->sreg & ESP_STAT_PMASK) == ESP_STATP)
				break;

			if (esp_count) {
				esp->ireg = esp_read8(ESP_INTRPT);
				if (esp->ireg & ESP_INTR_DC)
					break;

				scsi_esp_cmd(esp, ESP_CMD_TI);
			}
		} else {
			esp->ireg = esp_read8(ESP_INTRPT);
			if (esp->ireg & ESP_INTR_DC)
				break;

			n = MAC_ESP_FIFO_SIZE - n;
			if (n > esp_count)
				n = esp_count;

			if (n == MAC_ESP_FIFO_SIZE) {
				MAC_ESP_PIO_FILL("%0@+,%2@", esp_count);
			} else {
				esp_count -= n;
				MAC_ESP_PIO_LOOP("%0@+,%2@", n);
			}

			scsi_esp_cmd(esp, ESP_CMD_TI);
		}
	}

	local_irq_restore(flags);
}