39 #include <linux/kernel.h>
40 #include <linux/module.h>
41 #include <linux/pci.h>
46 #include <linux/device.h>
49 #include <scsi/scsi.h>
54 #include <asm/pci-bridge.h>
57 #define DRV_NAME "sata_svw"
58 #define DRV_VERSION "2.3"
100 static u8 k2_stat_check_status(
struct ata_port *ap);
127 unsigned int sc_reg,
u32 *
val)
131 *val =
readl(link->
ap->ioaddr.scr_addr + (sc_reg * 4));
136 static int k2_sata_scr_write(
struct ata_link *link,
137 unsigned int sc_reg,
u32 val)
141 writel(val, link->
ap->ioaddr.scr_addr + (sc_reg * 4));
145 static int k2_sata_softreset(
struct ata_link *link,
146 unsigned int *
class,
unsigned long deadline)
149 void __iomem *mmio = link->
ap->ioaddr.bmdma_addr;
155 dmactl &= ~ATA_DMA_START;
162 static int k2_sata_hardreset(
struct ata_link *link,
163 unsigned int *
class,
unsigned long deadline)
166 void __iomem *mmio = link->
ap->ioaddr.bmdma_addr;
172 dmactl &= ~ATA_DMA_START;
181 struct ata_ioports *ioaddr = &ap->ioaddr;
184 if (tf->
ctl != ap->last_ctl) {
186 ap->last_ctl = tf->
ctl;
191 ioaddr->feature_addr);
200 }
else if (is_addr) {
217 struct ata_ioports *ioaddr = &ap->ioaddr;
220 tf->
command = k2_stat_check_status(ap);
222 feature =
readw(ioaddr->error_addr);
223 nsect =
readw(ioaddr->nsect_addr);
224 lbal =
readw(ioaddr->lbal_addr);
225 lbam =
readw(ioaddr->lbam_addr);
226 lbah =
readw(ioaddr->lbah_addr);
256 void __iomem *mmio = ap->ioaddr.bmdma_addr;
271 ap->
ops->sff_exec_command(ap, &qc->
tf);
285 void __iomem *mmio = ap->ioaddr.bmdma_addr;
315 ap->
ops->sff_exec_command(ap, &qc->
tf);
319 static u8 k2_stat_check_status(
struct ata_port *ap)
321 return readl(ap->ioaddr.status_addr);
344 ap = ata_shost_to_port(shost);
354 index = (ap == ap->
host->ports[0]) ? 0 : 1;
375 .proc_info = k2_sata_proc_info,
381 .inherits = &ata_bmdma_port_ops,
382 .softreset = k2_sata_softreset,
383 .hardreset = k2_sata_hardreset,
384 .sff_tf_load = k2_sata_tf_load,
385 .sff_tf_read = k2_sata_tf_read,
386 .sff_check_status = k2_stat_check_status,
387 .check_atapi_dma = k2_sata_check_atapi_dma,
388 .bmdma_setup = k2_bmdma_setup_mmio,
389 .bmdma_start = k2_bmdma_start_mmio,
390 .scr_read = k2_sata_scr_read,
391 .scr_write = k2_sata_scr_write,
401 .port_ops = &k2_sata_ops,
410 .port_ops = &k2_sata_ops,
418 .port_ops = &k2_sata_ops,
426 .port_ops = &k2_sata_ops,
430 static void k2_sata_setup_port(
struct ata_ioports *
port,
void __iomem *base)
443 port->altstatus_addr =
500 mmio_base = host->
iomap[bar_pos];
505 for (i = 0; i < host->
n_ports; i++) {
509 k2_sata_setup_port(&ap->ioaddr, mmio_base + offset);
511 ata_port_pbar_desc(ap, 5, -1,
"mmio");
512 ata_port_pbar_desc(ap, 5, offset,
"port");
556 static struct pci_driver k2_sata_pci_driver = {
558 .id_table = k2_sata_pci_tbl,
559 .probe = k2_sata_init_one,
560 .remove = ata_pci_remove_one,