Lines Matching +full:gemini +full:- +full:pata
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Includes portions of the SL2312/SL3516/Gemini PATA driver
25 * struct ftide010 - state container for the Faraday FTIDE010
32 * @sg: Gemini SATA bridge pointer, if running on the Gemini
33 * @master_to_sata0: Gemini SATA bridge: the ATA master is connected
35 * @slave_to_sata0: Gemini SATA bridge: the ATA slave is connected
37 * @master_to_sata1: Gemini SATA bridge: the ATA master is connected
39 * @slave_to_sata1: Gemini SATA bridge: the ATA slave is connected
49 /* Gemini-specific properties */
143 struct ftide010 *ftide = ap->host->private_data; in ftide010_set_dmamode()
144 u8 speed = adev->dma_mode; in ftide010_set_dmamode()
145 u8 devno = adev->devno & 1; in ftide010_set_dmamode()
161 clkreg = readb(ftide->base + FTIDE010_CLK_MOD); in ftide010_set_dmamode()
167 dev_dbg(ftide->dev, "set UDMA mode %02x, index %d\n", in ftide010_set_dmamode()
184 dev_dbg(ftide->dev, "UDMA write clkreg = %02x, timreg = %02x\n", in ftide010_set_dmamode()
187 writeb(clkreg, ftide->base + FTIDE010_CLK_MOD); in ftide010_set_dmamode()
188 writeb(timreg, ftide->base + FTIDE010_UDMA_TIMING0 + devno); in ftide010_set_dmamode()
191 dev_dbg(ftide->dev, "set MWDMA mode %02x, index %d\n", in ftide010_set_dmamode()
202 dev_dbg(ftide->dev, in ftide010_set_dmamode()
206 writeb(clkreg, ftide->base + FTIDE010_CLK_MOD); in ftide010_set_dmamode()
207 writeb(timreg, ftide->base + FTIDE010_MWDMA_TIMING); in ftide010_set_dmamode()
211 * Store the current device (master or slave) in ap->private_data in ftide010_set_dmamode()
215 ap->private_data = adev; in ftide010_set_dmamode()
222 struct ftide010 *ftide = ap->host->private_data; in ftide010_set_piomode()
223 u8 pio = adev->pio_mode - XFER_PIO_0; in ftide010_set_piomode()
225 dev_dbg(ftide->dev, "set PIO mode %02x, index %d\n", in ftide010_set_piomode()
226 adev->pio_mode, pio); in ftide010_set_piomode()
228 ftide->base + FTIDE010_PIO_TIMING); in ftide010_set_piomode()
239 struct ata_port *ap = qc->ap; in ftide010_qc_issue()
240 struct ata_device *adev = qc->dev; in ftide010_qc_issue()
243 * If the device changed, i.e. slave->master, master->slave, in ftide010_qc_issue()
247 if (adev != ap->private_data && ata_dma_enabled(adev)) in ftide010_qc_issue()
272 struct ftide010 *ftide = ap->host->private_data; in pata_ftide010_gemini_port_start()
273 struct device *dev = ftide->dev; in pata_ftide010_gemini_port_start()
274 struct sata_gemini *sg = ftide->sg; in pata_ftide010_gemini_port_start()
282 if (ftide->master_to_sata0) { in pata_ftide010_gemini_port_start()
288 if (ftide->master_to_sata1) { in pata_ftide010_gemini_port_start()
294 /* Avoid double-starting */ in pata_ftide010_gemini_port_start()
295 if (ftide->slave_to_sata0 && !ftide->master_to_sata0) { in pata_ftide010_gemini_port_start()
301 /* Avoid double-starting */ in pata_ftide010_gemini_port_start()
302 if (ftide->slave_to_sata1 && !ftide->master_to_sata1) { in pata_ftide010_gemini_port_start()
310 return (bridges > 0) ? 0 : -EINVAL; // -ENODEV; in pata_ftide010_gemini_port_start()
315 struct ftide010 *ftide = ap->host->private_data; in pata_ftide010_gemini_port_stop()
316 struct device *dev = ftide->dev; in pata_ftide010_gemini_port_stop()
317 struct sata_gemini *sg = ftide->sg; in pata_ftide010_gemini_port_stop()
319 if (ftide->master_to_sata0) { in pata_ftide010_gemini_port_stop()
323 if (ftide->master_to_sata1) { in pata_ftide010_gemini_port_stop()
327 /* Avoid double-stopping */ in pata_ftide010_gemini_port_stop()
328 if (ftide->slave_to_sata0 && !ftide->master_to_sata0) { in pata_ftide010_gemini_port_stop()
332 /* Avoid double-stopping */ in pata_ftide010_gemini_port_stop()
333 if (ftide->slave_to_sata1 && !ftide->master_to_sata1) { in pata_ftide010_gemini_port_stop()
341 struct ftide010 *ftide = ap->host->private_data; in pata_ftide010_gemini_cable_detect()
347 return ftide->master_cbl; in pata_ftide010_gemini_cable_detect()
354 struct device *dev = ftide->dev; in pata_ftide010_gemini_init()
362 ftide->sg = sg; in pata_ftide010_gemini_init()
374 /* Flag port as SATA-capable */ in pata_ftide010_gemini_init()
376 pi->flags |= ATA_FLAG_SATA; in pata_ftide010_gemini_init()
380 pi->mwdma_mask = 0; in pata_ftide010_gemini_init()
381 pi->udma_mask = 0; in pata_ftide010_gemini_init()
385 * We assume that a simple 40-wire cable is used in the PATA mode. in pata_ftide010_gemini_init()
386 * if you're adding a system using the PATA interface, make sure in pata_ftide010_gemini_init()
394 ftide->master_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
395 ftide->slave_cbl = ATA_CBL_PATA40; in pata_ftide010_gemini_init()
396 ftide->master_to_sata0 = true; in pata_ftide010_gemini_init()
399 ftide->master_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
400 ftide->slave_cbl = ATA_CBL_NONE; in pata_ftide010_gemini_init()
401 ftide->master_to_sata0 = true; in pata_ftide010_gemini_init()
404 ftide->master_cbl = ATA_CBL_PATA40; in pata_ftide010_gemini_init()
405 ftide->slave_cbl = ATA_CBL_PATA40; in pata_ftide010_gemini_init()
408 ftide->master_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
409 ftide->slave_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
410 ftide->master_to_sata0 = true; in pata_ftide010_gemini_init()
411 ftide->slave_to_sata1 = true; in pata_ftide010_gemini_init()
417 ftide->master_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
418 ftide->slave_cbl = ATA_CBL_NONE; in pata_ftide010_gemini_init()
419 ftide->master_to_sata1 = true; in pata_ftide010_gemini_init()
422 ftide->master_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
423 ftide->slave_cbl = ATA_CBL_PATA40; in pata_ftide010_gemini_init()
424 ftide->master_to_sata1 = true; in pata_ftide010_gemini_init()
427 ftide->master_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
428 ftide->slave_cbl = ATA_CBL_SATA; in pata_ftide010_gemini_init()
429 ftide->slave_to_sata0 = true; in pata_ftide010_gemini_init()
430 ftide->master_to_sata1 = true; in pata_ftide010_gemini_init()
433 ftide->master_cbl = ATA_CBL_PATA40; in pata_ftide010_gemini_init()
434 ftide->slave_cbl = ATA_CBL_PATA40; in pata_ftide010_gemini_init()
438 dev_info(dev, "set up Gemini PATA%d\n", is_ata1); in pata_ftide010_gemini_init()
447 return -ENOTSUPP; in pata_ftide010_gemini_init()
454 struct device *dev = &pdev->dev; in pata_ftide010_probe()
455 struct device_node *np = dev->of_node; in pata_ftide010_probe()
466 return -ENOMEM; in pata_ftide010_probe()
467 ftide->dev = dev; in pata_ftide010_probe()
475 return -ENODEV; in pata_ftide010_probe()
477 ftide->base = devm_ioremap_resource(dev, res); in pata_ftide010_probe()
478 if (IS_ERR(ftide->base)) in pata_ftide010_probe()
479 return PTR_ERR(ftide->base); in pata_ftide010_probe()
481 ftide->pclk = devm_clk_get(dev, "PCLK"); in pata_ftide010_probe()
482 if (!IS_ERR(ftide->pclk)) { in pata_ftide010_probe()
483 ret = clk_prepare_enable(ftide->pclk); in pata_ftide010_probe()
490 /* Some special Cortina Gemini init, if needed */ in pata_ftide010_probe()
491 if (of_device_is_compatible(np, "cortina,gemini-pata")) { in pata_ftide010_probe()
494 * Gemini has two instances of FTIDE010) and we do in pata_ftide010_probe()
501 (res->start == 0x63400000)); in pata_ftide010_probe()
506 ftide->master_cbl = ATA_CBL_PATA40; in pata_ftide010_probe()
507 ftide->slave_cbl = ATA_CBL_PATA40; in pata_ftide010_probe()
510 ftide->host = ata_host_alloc_pinfo(dev, ppi, 1); in pata_ftide010_probe()
511 if (!ftide->host) { in pata_ftide010_probe()
512 ret = -ENOMEM; in pata_ftide010_probe()
515 ftide->host->private_data = ftide; in pata_ftide010_probe()
517 for (i = 0; i < ftide->host->n_ports; i++) { in pata_ftide010_probe()
518 struct ata_port *ap = ftide->host->ports[i]; in pata_ftide010_probe()
519 struct ata_ioports *ioaddr = &ap->ioaddr; in pata_ftide010_probe()
521 ioaddr->bmdma_addr = ftide->base + FTIDE010_DMA_REG; in pata_ftide010_probe()
522 ioaddr->cmd_addr = ftide->base + FTIDE010_CMD_DATA; in pata_ftide010_probe()
523 ioaddr->ctl_addr = ftide->base + FTIDE010_ALTSTAT_CTRL; in pata_ftide010_probe()
524 ioaddr->altstatus_addr = ftide->base + FTIDE010_ALTSTAT_CTRL; in pata_ftide010_probe()
529 readl(ftide->base + FTIDE010_IDE_DEVICE_ID), irq, res); in pata_ftide010_probe()
531 ret = ata_host_activate(ftide->host, irq, ata_bmdma_interrupt, in pata_ftide010_probe()
539 if (!IS_ERR(ftide->pclk)) in pata_ftide010_probe()
540 clk_disable_unprepare(ftide->pclk); in pata_ftide010_probe()
547 struct ftide010 *ftide = host->private_data; in pata_ftide010_remove()
549 ata_host_detach(ftide->host); in pata_ftide010_remove()
550 if (!IS_ERR(ftide->pclk)) in pata_ftide010_remove()
551 clk_disable_unprepare(ftide->pclk); in pata_ftide010_remove()