Lines Matching +full:tf +full:- +full:a
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * sata_svw.c - ServerWorks / Apple K2 SATA
7 * Please ALWAYS copy linux-ide@vger.kernel.org
14 * This driver probably works with non-Apple versions of the
18 * as Documentation/driver-api/libata.rst
41 /* ap->flags bits */
85 u8 cmnd = qc->scsicmd->cmnd[0]; in k2_sata_check_atapi_dma()
87 if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA) in k2_sata_check_atapi_dma()
88 return -1; /* ATAPI DMA not supported */ in k2_sata_check_atapi_dma()
100 return -1; in k2_sata_check_atapi_dma()
110 return -EINVAL; in k2_sata_scr_read()
111 *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4)); in k2_sata_scr_read()
120 return -EINVAL; in k2_sata_scr_write()
121 writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); in k2_sata_scr_write()
129 void __iomem *mmio = link->ap->ioaddr.bmdma_addr; in k2_sata_softreset()
146 void __iomem *mmio = link->ap->ioaddr.bmdma_addr; in k2_sata_hardreset()
159 static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) in k2_sata_tf_load() argument
161 struct ata_ioports *ioaddr = &ap->ioaddr; in k2_sata_tf_load()
162 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; in k2_sata_tf_load()
164 if (tf->ctl != ap->last_ctl) { in k2_sata_tf_load()
165 writeb(tf->ctl, ioaddr->ctl_addr); in k2_sata_tf_load()
166 ap->last_ctl = tf->ctl; in k2_sata_tf_load()
169 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { in k2_sata_tf_load()
170 writew(tf->feature | (((u16)tf->hob_feature) << 8), in k2_sata_tf_load()
171 ioaddr->feature_addr); in k2_sata_tf_load()
172 writew(tf->nsect | (((u16)tf->hob_nsect) << 8), in k2_sata_tf_load()
173 ioaddr->nsect_addr); in k2_sata_tf_load()
174 writew(tf->lbal | (((u16)tf->hob_lbal) << 8), in k2_sata_tf_load()
175 ioaddr->lbal_addr); in k2_sata_tf_load()
176 writew(tf->lbam | (((u16)tf->hob_lbam) << 8), in k2_sata_tf_load()
177 ioaddr->lbam_addr); in k2_sata_tf_load()
178 writew(tf->lbah | (((u16)tf->hob_lbah) << 8), in k2_sata_tf_load()
179 ioaddr->lbah_addr); in k2_sata_tf_load()
181 writew(tf->feature, ioaddr->feature_addr); in k2_sata_tf_load()
182 writew(tf->nsect, ioaddr->nsect_addr); in k2_sata_tf_load()
183 writew(tf->lbal, ioaddr->lbal_addr); in k2_sata_tf_load()
184 writew(tf->lbam, ioaddr->lbam_addr); in k2_sata_tf_load()
185 writew(tf->lbah, ioaddr->lbah_addr); in k2_sata_tf_load()
188 if (tf->flags & ATA_TFLAG_DEVICE) in k2_sata_tf_load()
189 writeb(tf->device, ioaddr->device_addr); in k2_sata_tf_load()
195 static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in k2_sata_tf_read() argument
197 struct ata_ioports *ioaddr = &ap->ioaddr; in k2_sata_tf_read()
200 tf->status = k2_stat_check_status(ap); in k2_sata_tf_read()
201 tf->device = readw(ioaddr->device_addr); in k2_sata_tf_read()
202 error = readw(ioaddr->error_addr); in k2_sata_tf_read()
203 nsect = readw(ioaddr->nsect_addr); in k2_sata_tf_read()
204 lbal = readw(ioaddr->lbal_addr); in k2_sata_tf_read()
205 lbam = readw(ioaddr->lbam_addr); in k2_sata_tf_read()
206 lbah = readw(ioaddr->lbah_addr); in k2_sata_tf_read()
208 tf->error = error; in k2_sata_tf_read()
209 tf->nsect = nsect; in k2_sata_tf_read()
210 tf->lbal = lbal; in k2_sata_tf_read()
211 tf->lbam = lbam; in k2_sata_tf_read()
212 tf->lbah = lbah; in k2_sata_tf_read()
214 if (tf->flags & ATA_TFLAG_LBA48) { in k2_sata_tf_read()
215 tf->hob_feature = error >> 8; in k2_sata_tf_read()
216 tf->hob_nsect = nsect >> 8; in k2_sata_tf_read()
217 tf->hob_lbal = lbal >> 8; in k2_sata_tf_read()
218 tf->hob_lbam = lbam >> 8; in k2_sata_tf_read()
219 tf->hob_lbah = lbah >> 8; in k2_sata_tf_read()
224 * k2_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction (MMIO)
233 struct ata_port *ap = qc->ap; in k2_bmdma_setup_mmio()
234 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); in k2_bmdma_setup_mmio()
236 void __iomem *mmio = ap->ioaddr.bmdma_addr; in k2_bmdma_setup_mmio()
240 writel(ap->bmdma_prd_dma, mmio + ATA_DMA_TABLE_OFS); in k2_bmdma_setup_mmio()
242 /* specify data direction, triple-check start bit is clear */ in k2_bmdma_setup_mmio()
249 /* issue r/w command if this is not a ATA DMA command*/ in k2_bmdma_setup_mmio()
250 if (qc->tf.protocol != ATA_PROT_DMA) in k2_bmdma_setup_mmio()
251 ap->ops->sff_exec_command(ap, &qc->tf); in k2_bmdma_setup_mmio()
255 * k2_bmdma_start_mmio - Start a PCI IDE BMDMA transaction (MMIO)
264 struct ata_port *ap = qc->ap; in k2_bmdma_start_mmio()
265 void __iomem *mmio = ap->ioaddr.bmdma_addr; in k2_bmdma_start_mmio()
277 On a Read command, the controller would initiate the in k2_bmdma_start_mmio()
281 cache, there is the possibility that the drive returns a in k2_bmdma_start_mmio()
290 the SATA controller is sitting behind a number of bridges, in k2_bmdma_start_mmio()
294 if (qc->tf.protocol == ATA_PROT_DMA) in k2_bmdma_start_mmio()
295 ap->ops->sff_exec_command(ap, &qc->tf); in k2_bmdma_start_mmio()
301 return readl(ap->ioaddr.status_addr); in k2_stat_check_status()
316 np = pci_device_to_OF_node(to_pci_dev(ap->host->dev)); in k2_sata_show_info()
320 /* Match it to a port node */ in k2_sata_show_info()
321 index = (ap == ap->host->ports[0]) ? 0 : 1; in k2_sata_show_info()
322 for (np = np->child; np != NULL; np = np->sibling) { in k2_sata_show_info()
393 port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET; in k2_sata_setup_port()
394 port->data_addr = base + K2_SATA_TF_DATA_OFFSET; in k2_sata_setup_port()
395 port->feature_addr = in k2_sata_setup_port()
396 port->error_addr = base + K2_SATA_TF_ERROR_OFFSET; in k2_sata_setup_port()
397 port->nsect_addr = base + K2_SATA_TF_NSECT_OFFSET; in k2_sata_setup_port()
398 port->lbal_addr = base + K2_SATA_TF_LBAL_OFFSET; in k2_sata_setup_port()
399 port->lbam_addr = base + K2_SATA_TF_LBAM_OFFSET; in k2_sata_setup_port()
400 port->lbah_addr = base + K2_SATA_TF_LBAH_OFFSET; in k2_sata_setup_port()
401 port->device_addr = base + K2_SATA_TF_DEVICE_OFFSET; in k2_sata_setup_port()
402 port->command_addr = in k2_sata_setup_port()
403 port->status_addr = base + K2_SATA_TF_CMDSTAT_OFFSET; in k2_sata_setup_port()
404 port->altstatus_addr = in k2_sata_setup_port()
405 port->ctl_addr = base + K2_SATA_TF_CTL_OFFSET; in k2_sata_setup_port()
406 port->bmdma_addr = base + K2_SATA_DMA_CMD_OFFSET; in k2_sata_setup_port()
407 port->scr_addr = base + K2_SATA_SCR_STATUS_OFFSET; in k2_sata_setup_port()
414 { &k2_port_info[ent->driver_data], NULL }; in k2_sata_init_one()
419 ata_print_version_once(&pdev->dev, DRV_VERSION); in k2_sata_init_one()
423 if (ppi[0]->flags & K2_FLAG_SATA_8_PORTS) in k2_sata_init_one()
426 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); in k2_sata_init_one()
428 return -ENOMEM; in k2_sata_init_one()
431 if (ppi[0]->flags & K2_FLAG_BAR_POS_3) in k2_sata_init_one()
435 * we should check that here as it has a normal Serverworks ID in k2_sata_init_one()
451 return -ENODEV; in k2_sata_init_one()
456 if (rc == -EBUSY) in k2_sata_init_one()
460 host->iomap = pcim_iomap_table(pdev); in k2_sata_init_one()
461 mmio_base = host->iomap[bar_pos]; in k2_sata_init_one()
463 /* different controllers have different number of ports - currently 4 or 8 */ in k2_sata_init_one()
464 /* All ports are on the same function. Multi-function device is no in k2_sata_init_one()
466 for (i = 0; i < host->n_ports; i++) { in k2_sata_init_one()
467 struct ata_port *ap = host->ports[i]; in k2_sata_init_one()
470 k2_sata_setup_port(&ap->ioaddr, mmio_base + offset); in k2_sata_init_one()
472 ata_port_pbar_desc(ap, 5, -1, "mmio"); in k2_sata_init_one()
476 rc = dma_set_mask_and_coherent(&pdev->dev, ATA_DMA_MASK); in k2_sata_init_one()
480 /* Clear a magic bit in SCR1 according to Darwin, those help in k2_sata_init_one()
492 return ata_host_activate(host, pdev->irq, ata_bmdma_interrupt, in k2_sata_init_one()
524 MODULE_DESCRIPTION("low-level driver for K2 SATA controller");