X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/a7f49cd3e861f1c192081a543a711fde8d7c1f08..2da5dcf199f77603afb654d9127910cda5e225ac:/target/linux/adm5120/files/drivers/ata/pata_rb153_cf.c diff --git a/target/linux/adm5120/files/drivers/ata/pata_rb153_cf.c b/target/linux/adm5120/files/drivers/ata/pata_rb153_cf.c index 16ec6762f..fbbf313d9 100644 --- a/target/linux/adm5120/files/drivers/ata/pata_rb153_cf.c +++ b/target/linux/adm5120/files/drivers/ata/pata_rb153_cf.c @@ -32,7 +32,7 @@ #include #define DRV_NAME "pata-rb153-cf" -#define DRV_VERSION "0.1" +#define DRV_VERSION "0.2.2" #define DRV_DESC "PATA driver for RouterBOARD 153 Compact Flash" #define RB153_CF_MAXPORTS 1 @@ -45,7 +45,7 @@ struct rb153_cf_info { void __iomem *iobase; unsigned int gpio_line; - int error; + int frozen; }; /* ------------------------------------------------------------------------ */ @@ -70,25 +70,31 @@ static void rb153_pata_exec_command(struct ata_port *ap, static void rb153_pata_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data) { - struct ata_port *ap = adev->ap; - unsigned int i; + void __iomem *ioaddr = adev->ap->ioaddr.data_addr; if (write_data) { - for (i = 0; i < buflen; i++) - writeb(buf[i], ap->ioaddr.data_addr); + for (; buflen > 0; buflen--, buf++) + writeb(*buf, ioaddr); } else { - for (; buflen > 0; buflen--) - buf[i] = readb(ap->ioaddr.data_addr); + for (; buflen > 0; buflen--, buf++) + *buf = readb(ioaddr); } - rb153_pata_finish_io(ap); + rb153_pata_finish_io(adev->ap); +} + +static void rb153_pata_freeze(struct ata_port *ap) +{ + struct rb153_cf_info *info = ap->host->private_data; + + info->frozen = 1; } static void rb153_pata_thaw(struct ata_port *ap) { struct rb153_cf_info *info = ap->host->private_data; - info->error = 0; + info->frozen = 0; } static irqreturn_t rb153_pata_irq_handler(int irq, void *dev_instance) @@ -98,7 +104,7 @@ static irqreturn_t rb153_pata_irq_handler(int irq, void *dev_instance) if (gpio_get_value(info->gpio_line)) { set_irq_type(ah->irq, IRQ_TYPE_LEVEL_LOW); - if (!info->error) + if (!info->frozen) ata_interrupt(irq, dev_instance); } else { set_irq_type(ah->irq, IRQ_TYPE_LEVEL_HIGH); @@ -131,6 +137,7 @@ static struct ata_port_operations rb153_pata_port_ops = { .qc_prep = ata_qc_prep, .qc_issue = ata_qc_issue_prot, + .freeze = rb153_pata_freeze, .thaw = rb153_pata_thaw, .error_handler = ata_bmdma_error_handler, @@ -168,21 +175,20 @@ static void rb153_pata_setup_ports(struct ata_host *ah) { struct rb153_cf_info *info = ah->private_data; struct ata_port *ap; - struct ata_ioports *iop; ap = ah->ports[0]; - iop = &ap->ioaddr; ap->ops = &rb153_pata_port_ops; ap->pio_mask = 0x1f; /* PIO4 */ - ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY; + ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO; + + ap->ioaddr.cmd_addr = info->iobase + RB153_CF_REG_CMD; + ap->ioaddr.ctl_addr = info->iobase + RB153_CF_REG_CTRL; + ap->ioaddr.altstatus_addr = info->iobase + RB153_CF_REG_CTRL; - iop->cmd_addr = info->iobase + RB153_CF_REG_CMD; - iop->ctl_addr = info->iobase + RB153_CF_REG_CTRL; - iop->altstatus_addr = info->iobase + RB153_CF_REG_CTRL; - iop->data_addr = info->iobase + RB153_CF_REG_DATA; + ata_std_ports(&ap->ioaddr); - ata_std_ports(iop); + ap->ioaddr.data_addr = info->iobase + RB153_CF_REG_DATA; } static __devinit int rb153_pata_driver_probe(struct platform_device *pdev) @@ -230,6 +236,7 @@ static __devinit int rb153_pata_driver_probe(struct platform_device *pdev) return -ENOMEM; ah->private_data = info; + info->gpio_line = gpio; info->iobase = devm_ioremap_nocache(&pdev->dev, res->start, res->end - res->start + 1); @@ -245,8 +252,8 @@ static __devinit int rb153_pata_driver_probe(struct platform_device *pdev) rb153_pata_setup_ports(ah); - ret = ata_host_activate(ah, irq, ata_interrupt, IRQF_TRIGGER_HIGH, - &rb153_pata_sht); + ret = ata_host_activate(ah, irq, rb153_pata_irq_handler, + IRQF_TRIGGER_LOW, &rb153_pata_sht); if (ret) goto err_free_gpio;