Lines Matching +full:host +full:- +full:port

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * sata_vsc.c - Vitesse VSC7174 4 port DPA SATA
6 * Please ALWAYS copy linux-ide@vger.kernel.org
14 * as Documentation/driver-api/libata.rst
27 #include <linux/dma-mapping.h>
67 /* Port stride */
88 return -EINVAL; in vsc_sata_scr_read()
89 *val = readl(link->ap->ioaddr.scr_addr + (sc_reg * 4)); in vsc_sata_scr_read()
98 return -EINVAL; in vsc_sata_scr_write()
99 writel(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); in vsc_sata_scr_write()
108 mask_addr = ap->host->iomap[VSC_MMIO_BAR] + in vsc_freeze()
109 VSC_SATA_INT_MASK_OFFSET + ap->port_no; in vsc_freeze()
119 mask_addr = ap->host->iomap[VSC_MMIO_BAR] + in vsc_thaw()
120 VSC_SATA_INT_MASK_OFFSET + ap->port_no; in vsc_thaw()
131 mask_addr = ap->host->iomap[VSC_MMIO_BAR] + in vsc_intr_mask_update()
132 VSC_SATA_INT_MASK_OFFSET + ap->port_no; in vsc_intr_mask_update()
144 struct ata_ioports *ioaddr = &ap->ioaddr; in vsc_sata_tf_load()
145 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; in vsc_sata_tf_load()
153 if ((tf->ctl & ATA_NIEN) != (ap->last_ctl & ATA_NIEN)) { in vsc_sata_tf_load()
154 ap->last_ctl = tf->ctl; in vsc_sata_tf_load()
155 vsc_intr_mask_update(ap, tf->ctl & ATA_NIEN); in vsc_sata_tf_load()
157 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { in vsc_sata_tf_load()
158 writew(tf->feature | (((u16)tf->hob_feature) << 8), in vsc_sata_tf_load()
159 ioaddr->feature_addr); in vsc_sata_tf_load()
160 writew(tf->nsect | (((u16)tf->hob_nsect) << 8), in vsc_sata_tf_load()
161 ioaddr->nsect_addr); in vsc_sata_tf_load()
162 writew(tf->lbal | (((u16)tf->hob_lbal) << 8), in vsc_sata_tf_load()
163 ioaddr->lbal_addr); in vsc_sata_tf_load()
164 writew(tf->lbam | (((u16)tf->hob_lbam) << 8), in vsc_sata_tf_load()
165 ioaddr->lbam_addr); in vsc_sata_tf_load()
166 writew(tf->lbah | (((u16)tf->hob_lbah) << 8), in vsc_sata_tf_load()
167 ioaddr->lbah_addr); in vsc_sata_tf_load()
169 writew(tf->feature, ioaddr->feature_addr); in vsc_sata_tf_load()
170 writew(tf->nsect, ioaddr->nsect_addr); in vsc_sata_tf_load()
171 writew(tf->lbal, ioaddr->lbal_addr); in vsc_sata_tf_load()
172 writew(tf->lbam, ioaddr->lbam_addr); in vsc_sata_tf_load()
173 writew(tf->lbah, ioaddr->lbah_addr); in vsc_sata_tf_load()
176 if (tf->flags & ATA_TFLAG_DEVICE) in vsc_sata_tf_load()
177 writeb(tf->device, ioaddr->device_addr); in vsc_sata_tf_load()
185 struct ata_ioports *ioaddr = &ap->ioaddr; in vsc_sata_tf_read()
188 tf->status = ata_sff_check_status(ap); in vsc_sata_tf_read()
189 tf->device = readw(ioaddr->device_addr); in vsc_sata_tf_read()
190 error = readw(ioaddr->error_addr); in vsc_sata_tf_read()
191 nsect = readw(ioaddr->nsect_addr); in vsc_sata_tf_read()
192 lbal = readw(ioaddr->lbal_addr); in vsc_sata_tf_read()
193 lbam = readw(ioaddr->lbam_addr); in vsc_sata_tf_read()
194 lbah = readw(ioaddr->lbah_addr); in vsc_sata_tf_read()
196 tf->error = error; in vsc_sata_tf_read()
197 tf->nsect = nsect; in vsc_sata_tf_read()
198 tf->lbal = lbal; in vsc_sata_tf_read()
199 tf->lbam = lbam; in vsc_sata_tf_read()
200 tf->lbah = lbah; in vsc_sata_tf_read()
202 if (tf->flags & ATA_TFLAG_LBA48) { in vsc_sata_tf_read()
203 tf->hob_feature = error >> 8; in vsc_sata_tf_read()
204 tf->hob_nsect = nsect >> 8; in vsc_sata_tf_read()
205 tf->hob_lbal = lbal >> 8; in vsc_sata_tf_read()
206 tf->hob_lbam = lbam >> 8; in vsc_sata_tf_read()
207 tf->hob_lbah = lbah >> 8; in vsc_sata_tf_read()
229 qc = ata_qc_from_tag(ap, ap->link.active_tag); in vsc_port_intr()
230 if (qc && likely(!(qc->tf.flags & ATA_TFLAG_POLLING))) in vsc_port_intr()
239 ap->ops->sff_check_status(ap); in vsc_port_intr()
250 struct ata_host *host = dev_instance; in vsc_sata_interrupt() local
255 status = readl(host->iomap[VSC_MMIO_BAR] + VSC_SATA_INT_STAT_OFFSET); in vsc_sata_interrupt()
259 dev_err(host->dev, in vsc_sata_interrupt()
264 spin_lock(&host->lock); in vsc_sata_interrupt()
266 for (i = 0; i < host->n_ports; i++) { in vsc_sata_interrupt()
269 vsc_port_intr(port_status, host->ports[i]); in vsc_sata_interrupt()
274 spin_unlock(&host->lock); in vsc_sata_interrupt()
298 static void vsc_sata_setup_port(struct ata_ioports *port, void __iomem *base) in vsc_sata_setup_port() argument
300 port->cmd_addr = base + VSC_SATA_TF_CMD_OFFSET; in vsc_sata_setup_port()
301 port->data_addr = base + VSC_SATA_TF_DATA_OFFSET; in vsc_sata_setup_port()
302 port->error_addr = base + VSC_SATA_TF_ERROR_OFFSET; in vsc_sata_setup_port()
303 port->feature_addr = base + VSC_SATA_TF_FEATURE_OFFSET; in vsc_sata_setup_port()
304 port->nsect_addr = base + VSC_SATA_TF_NSECT_OFFSET; in vsc_sata_setup_port()
305 port->lbal_addr = base + VSC_SATA_TF_LBAL_OFFSET; in vsc_sata_setup_port()
306 port->lbam_addr = base + VSC_SATA_TF_LBAM_OFFSET; in vsc_sata_setup_port()
307 port->lbah_addr = base + VSC_SATA_TF_LBAH_OFFSET; in vsc_sata_setup_port()
308 port->device_addr = base + VSC_SATA_TF_DEVICE_OFFSET; in vsc_sata_setup_port()
309 port->status_addr = base + VSC_SATA_TF_STATUS_OFFSET; in vsc_sata_setup_port()
310 port->command_addr = base + VSC_SATA_TF_COMMAND_OFFSET; in vsc_sata_setup_port()
311 port->altstatus_addr = base + VSC_SATA_TF_ALTSTATUS_OFFSET; in vsc_sata_setup_port()
312 port->ctl_addr = base + VSC_SATA_TF_CTL_OFFSET; in vsc_sata_setup_port()
313 port->bmdma_addr = base + VSC_SATA_DMA_CMD_OFFSET; in vsc_sata_setup_port()
314 port->scr_addr = base + VSC_SATA_SCR_STATUS_OFFSET; in vsc_sata_setup_port()
331 struct ata_host *host; in vsc_sata_init_one() local
336 ata_print_version_once(&pdev->dev, DRV_VERSION); in vsc_sata_init_one()
338 /* allocate host */ in vsc_sata_init_one()
339 host = ata_host_alloc_pinfo(&pdev->dev, ppi, 4); in vsc_sata_init_one()
340 if (!host) in vsc_sata_init_one()
341 return -ENOMEM; in vsc_sata_init_one()
349 return -ENODEV; in vsc_sata_init_one()
351 /* map IO regions and initialize host accordingly */ in vsc_sata_init_one()
353 if (rc == -EBUSY) in vsc_sata_init_one()
357 host->iomap = pcim_iomap_table(pdev); in vsc_sata_init_one()
359 mmio_base = host->iomap[VSC_MMIO_BAR]; in vsc_sata_init_one()
361 for (i = 0; i < host->n_ports; i++) { in vsc_sata_init_one()
362 struct ata_port *ap = host->ports[i]; in vsc_sata_init_one()
365 vsc_sata_setup_port(&ap->ioaddr, mmio_base + offset); in vsc_sata_init_one()
367 ata_port_pbar_desc(ap, VSC_MMIO_BAR, -1, "mmio"); in vsc_sata_init_one()
368 ata_port_pbar_desc(ap, VSC_MMIO_BAR, offset, "port"); in vsc_sata_init_one()
374 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in vsc_sata_init_one()
380 * used (unless the default is non-zero). in vsc_sata_init_one()
393 * If bit 28 is clear, each port has its own LED. in vsc_sata_init_one()
398 return ata_host_activate(host, pdev->irq, vsc_sata_interrupt, in vsc_sata_init_one()
421 MODULE_DESCRIPTION("low-level driver for Vitesse VSC7174 SATA controller");