2019-05-23 09:14:55 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2006-08-29 22:12:40 +00:00
|
|
|
/*
|
|
|
|
* IDE tuning and bus mastering support for the CS5510/CS5520
|
|
|
|
* chipsets
|
|
|
|
*
|
|
|
|
* The CS5510/CS5520 are slightly unusual devices. Unlike the
|
|
|
|
* typical IDE controllers they do bus mastering with the drive in
|
|
|
|
* PIO mode and smarter silicon.
|
|
|
|
*
|
|
|
|
* The practical upshot of this is that we must always tune the
|
2024-07-26 02:28:37 +00:00
|
|
|
* drive for the right PIO mode and ignore the drive bus mastering DMA
|
|
|
|
* information. Also to confuse matters further we can do DMA on PIO only
|
|
|
|
* drives.
|
2006-08-29 22:12:40 +00:00
|
|
|
*
|
|
|
|
* DMA on the 5510 also requires we disable_hlt() during DMA on early
|
|
|
|
* revisions.
|
|
|
|
*
|
|
|
|
* *** This driver is strictly experimental ***
|
|
|
|
*
|
|
|
|
* (c) Copyright Red Hat Inc 2002
|
|
|
|
*
|
|
|
|
* Documentation:
|
2011-03-31 01:57:33 +00:00
|
|
|
* Not publicly available.
|
2006-08-29 22:12:40 +00:00
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "pata_cs5520"
|
2007-08-31 08:54:06 +00:00
|
|
|
#define DRV_VERSION "0.6.6"
|
2006-08-29 22:12:40 +00:00
|
|
|
|
|
|
|
struct pio_clocks
|
|
|
|
{
|
|
|
|
int address;
|
|
|
|
int assert;
|
|
|
|
int recovery;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pio_clocks cs5520_pio_clocks[]={
|
|
|
|
{3, 6, 11},
|
|
|
|
{2, 5, 6},
|
|
|
|
{1, 4, 3},
|
|
|
|
{1, 3, 2},
|
|
|
|
{1, 2, 1}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cs5520_set_timings - program PIO timings
|
|
|
|
* @ap: ATA port
|
|
|
|
* @adev: ATA device
|
2021-02-01 14:39:35 +00:00
|
|
|
* @pio: PIO ID
|
2006-08-29 22:12:40 +00:00
|
|
|
*
|
|
|
|
* Program the PIO mode timings for the controller according to the pio
|
|
|
|
* clocking table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void cs5520_set_timings(struct ata_port *ap, struct ata_device *adev, int pio)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
|
|
|
int slave = adev->devno;
|
|
|
|
|
|
|
|
pio -= XFER_PIO_0;
|
|
|
|
|
|
|
|
/* Channel command timing */
|
|
|
|
pci_write_config_byte(pdev, 0x62 + ap->port_no,
|
|
|
|
(cs5520_pio_clocks[pio].recovery << 4) |
|
|
|
|
(cs5520_pio_clocks[pio].assert));
|
|
|
|
/* FIXME: should these use address ? */
|
|
|
|
/* Read command timing */
|
|
|
|
pci_write_config_byte(pdev, 0x64 + 4*ap->port_no + slave,
|
|
|
|
(cs5520_pio_clocks[pio].recovery << 4) |
|
|
|
|
(cs5520_pio_clocks[pio].assert));
|
|
|
|
/* Write command timing */
|
|
|
|
pci_write_config_byte(pdev, 0x66 + 4*ap->port_no + slave,
|
|
|
|
(cs5520_pio_clocks[pio].recovery << 4) |
|
|
|
|
(cs5520_pio_clocks[pio].assert));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cs5520_set_piomode - program PIO timings
|
|
|
|
* @ap: ATA port
|
|
|
|
* @adev: ATA device
|
|
|
|
*
|
|
|
|
* Program the PIO mode timings for the controller according to the pio
|
2009-12-03 19:32:09 +00:00
|
|
|
* clocking table.
|
2006-08-29 22:12:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void cs5520_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
cs5520_set_timings(ap, adev, adev->pio_mode);
|
|
|
|
}
|
|
|
|
|
2023-03-22 19:53:59 +00:00
|
|
|
static const struct scsi_host_template cs5520_sht = {
|
2021-05-28 09:04:58 +00:00
|
|
|
ATA_BASE_SHT(DRV_NAME),
|
2007-07-06 23:13:52 +00:00
|
|
|
.sg_tablesize = LIBATA_DUMB_MAX_PRD,
|
2021-05-28 09:04:58 +00:00
|
|
|
.dma_boundary = ATA_DMA_BOUNDARY,
|
2006-08-29 22:12:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations cs5520_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 03:22:49 +00:00
|
|
|
.inherits = &ata_bmdma_port_ops,
|
2010-05-10 19:41:40 +00:00
|
|
|
.qc_prep = ata_bmdma_dumb_qc_prep,
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-25 03:22:49 +00:00
|
|
|
.cable_detect = ata_cable_40wire,
|
2006-08-29 22:12:40 +00:00
|
|
|
.set_piomode = cs5520_set_piomode,
|
|
|
|
};
|
|
|
|
|
2012-12-21 21:19:58 +00:00
|
|
|
static int cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
|
2006-08-29 22:12:40 +00:00
|
|
|
{
|
2007-08-18 04:14:55 +00:00
|
|
|
static const unsigned int cmd_port[] = { 0x1F0, 0x170 };
|
|
|
|
static const unsigned int ctl_port[] = { 0x3F6, 0x376 };
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct ata_port_info pi = {
|
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2009-03-14 20:38:24 +00:00
|
|
|
.pio_mask = ATA_PIO4,
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
.port_ops = &cs5520_port_ops,
|
|
|
|
};
|
|
|
|
const struct ata_port_info *ppi[2];
|
2006-08-29 22:12:40 +00:00
|
|
|
u8 pcicfg;
|
2007-12-30 09:32:22 +00:00
|
|
|
void __iomem *iomap[5];
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
struct ata_host *host;
|
|
|
|
struct ata_ioports *ioaddr;
|
|
|
|
int i, rc;
|
2006-08-29 22:12:40 +00:00
|
|
|
|
2008-03-25 03:22:47 +00:00
|
|
|
rc = pcim_enable_device(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2006-08-29 22:12:40 +00:00
|
|
|
/* IDE port enable bits */
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
pci_read_config_byte(pdev, 0x60, &pcicfg);
|
2006-08-29 22:12:40 +00:00
|
|
|
|
|
|
|
/* Check if the ATA ports are enabled */
|
|
|
|
if ((pcicfg & 3) == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ppi[0] = ppi[1] = &ata_dummy_port_info;
|
|
|
|
if (pcicfg & 1)
|
|
|
|
ppi[0] = π
|
|
|
|
if (pcicfg & 2)
|
|
|
|
ppi[1] = π
|
|
|
|
|
2006-08-29 22:12:40 +00:00
|
|
|
if ((pcicfg & 0x40) == 0) {
|
2011-04-15 22:51:58 +00:00
|
|
|
dev_warn(&pdev->dev, "DMA mode disabled. Enabling.\n");
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
|
2006-08-29 22:12:40 +00:00
|
|
|
}
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
pi.mwdma_mask = id->driver_data;
|
|
|
|
|
|
|
|
host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
|
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2019-08-26 10:57:25 +00:00
|
|
|
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
|
2021-12-21 07:21:13 +00:00
|
|
|
dev_err(&pdev->dev, "unable to configure DMA mask.\n");
|
2006-08-29 22:12:40 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
/* Map IO ports and initialize host accordingly */
|
2007-08-18 04:14:55 +00:00
|
|
|
iomap[0] = devm_ioport_map(&pdev->dev, cmd_port[0], 8);
|
|
|
|
iomap[1] = devm_ioport_map(&pdev->dev, ctl_port[0], 1);
|
|
|
|
iomap[2] = devm_ioport_map(&pdev->dev, cmd_port[1], 8);
|
|
|
|
iomap[3] = devm_ioport_map(&pdev->dev, ctl_port[1], 1);
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
iomap[4] = pcim_iomap(pdev, 2, 0);
|
2007-02-01 06:06:36 +00:00
|
|
|
|
|
|
|
if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4])
|
|
|
|
return -ENOMEM;
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ioaddr = &host->ports[0]->ioaddr;
|
|
|
|
ioaddr->cmd_addr = iomap[0];
|
|
|
|
ioaddr->ctl_addr = iomap[1];
|
|
|
|
ioaddr->altstatus_addr = iomap[1];
|
|
|
|
ioaddr->bmdma_addr = iomap[4];
|
2008-04-07 13:47:16 +00:00
|
|
|
ata_sff_std_ports(ioaddr);
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
|
2007-08-18 04:14:55 +00:00
|
|
|
ata_port_desc(host->ports[0],
|
|
|
|
"cmd 0x%x ctl 0x%x", cmd_port[0], ctl_port[0]);
|
|
|
|
ata_port_pbar_desc(host->ports[0], 4, 0, "bmdma");
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
ioaddr = &host->ports[1]->ioaddr;
|
|
|
|
ioaddr->cmd_addr = iomap[2];
|
|
|
|
ioaddr->ctl_addr = iomap[3];
|
|
|
|
ioaddr->altstatus_addr = iomap[3];
|
|
|
|
ioaddr->bmdma_addr = iomap[4] + 8;
|
2008-04-07 13:47:16 +00:00
|
|
|
ata_sff_std_ports(ioaddr);
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
|
2007-08-18 04:14:55 +00:00
|
|
|
ata_port_desc(host->ports[1],
|
|
|
|
"cmd 0x%x ctl 0x%x", cmd_port[1], ctl_port[1]);
|
|
|
|
ata_port_pbar_desc(host->ports[1], 4, 8, "bmdma");
|
|
|
|
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
/* activate the host */
|
|
|
|
pci_set_master(pdev);
|
|
|
|
rc = ata_host_start(host);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
static const int irq[] = { 14, 15 };
|
2007-07-20 14:36:31 +00:00
|
|
|
struct ata_port *ap = host->ports[i];
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
|
|
|
|
if (ata_port_is_dummy(ap))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rc = devm_request_irq(&pdev->dev, irq[ap->port_no],
|
2010-05-19 20:10:21 +00:00
|
|
|
ata_bmdma_interrupt, 0, DRV_NAME, host);
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2007-07-02 16:38:47 +00:00
|
|
|
|
ata: ahci: print the lpm policy on boot
The target LPM policy can be set using either a Kconfig or a kernel module
parameter.
However, if the board type is set to anything but board_ahci_low_power,
then the LPM policy will overridden and set to ATA_LPM_UNKNOWN.
Additionally, if the default suspend is suspend to idle, depending on the
hardware capabilities of the HBA, ahci_update_initial_lpm_policy() might
override the LPM policy to either ATA_LPM_MIN_POWER_WITH_PARTIAL or
ATA_LPM_MIN_POWER.
All this means that it is very hard to know which LPM policy a user will
actually be using on a given system.
In order to make it easier to debug LPM related issues, print the LPM
policy on boot.
One common LPM related issue is that the device fails to link up.
Because of that, we cannot add this print to ata_dev_configure(), as that
function is only called after a successful link up. Instead, add the info
using ata_port_desc(), with the help of a new ata_port_desc_misc() helper.
The port description is printed once per port during boot.
Before changes:
ata1: SATA max UDMA/133 abar m524288@0xa5780000 port 0xa5780100 irq 170
ata2: SATA max UDMA/133 abar m524288@0xa5780000 port 0xa5780180 irq 170
After changes:
ata1: SATA max UDMA/133 abar m524288@0xa5780000 port 0xa5780100 irq 170 lpm-pol 4
ata2: SATA max UDMA/133 abar m524288@0xa5780000 port 0xa5780180 irq 170 lpm-pol 4
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
2023-09-06 09:22:32 +00:00
|
|
|
ata_port_desc_misc(ap, irq[i]);
|
libata: convert the remaining PATA drivers to new init model
Convert pdc_adma, pata_cs5520, pata_isapnp, pata_ixp4xx_cf,
pata_legacy, pata_mpc52xx, pata_mpiix, pata_pcmcia, pata_pdc2027x,
pata_platform, pata_qdi, pata_scc and pata_winbond to new init model.
* init_one()'s now follow more consistent init order
* cs5520 now registers one host with two ports, not two hosts. If any
of the two ports are disabled, it's made dummy as other drivers do.
Tested pdc_adma and pata_legacy. Both are as broken as before. The
rest are compile tested only.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-04-17 14:44:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ata_host_register(host, &cs5520_sht);
|
2006-08-29 22:12:40 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 15:17:44 +00:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2006-11-22 17:01:06 +00:00
|
|
|
/**
|
|
|
|
* cs5520_reinit_one - device resume
|
|
|
|
* @pdev: PCI device
|
|
|
|
*
|
|
|
|
* Do any reconfiguration work needed by a resume from RAM. We need
|
|
|
|
* to restore DMA mode support on BIOSen which disabled it
|
|
|
|
*/
|
2006-12-11 16:14:06 +00:00
|
|
|
|
2006-11-22 17:01:06 +00:00
|
|
|
static int cs5520_reinit_one(struct pci_dev *pdev)
|
|
|
|
{
|
2013-06-03 05:05:36 +00:00
|
|
|
struct ata_host *host = pci_get_drvdata(pdev);
|
2006-11-22 17:01:06 +00:00
|
|
|
u8 pcicfg;
|
2008-03-25 03:22:47 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = ata_pci_device_do_resume(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2006-11-22 17:01:06 +00:00
|
|
|
pci_read_config_byte(pdev, 0x60, &pcicfg);
|
|
|
|
if ((pcicfg & 0x40) == 0)
|
|
|
|
pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
|
2008-03-25 03:22:47 +00:00
|
|
|
|
|
|
|
ata_host_resume(host);
|
|
|
|
return 0;
|
2006-11-22 17:01:06 +00:00
|
|
|
}
|
2007-02-20 17:44:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cs5520_pci_device_suspend - device suspend
|
|
|
|
* @pdev: PCI device
|
2021-02-01 14:39:35 +00:00
|
|
|
* @mesg: PM event message
|
2007-02-20 17:44:25 +00:00
|
|
|
*
|
|
|
|
* We have to cut and waste bits from the standard method because
|
|
|
|
* the 5520 is a bit odd and not just a pure ATA device. As a result
|
|
|
|
* we must not disable it. The needed code is short and this avoids
|
|
|
|
* chip specific mess in the core code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int cs5520_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
|
|
|
|
{
|
2013-06-03 05:05:36 +00:00
|
|
|
struct ata_host *host = pci_get_drvdata(pdev);
|
2007-02-20 17:44:25 +00:00
|
|
|
|
2022-02-02 20:58:21 +00:00
|
|
|
ata_host_suspend(host, mesg);
|
2007-02-20 17:44:25 +00:00
|
|
|
|
|
|
|
pci_save_state(pdev);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-07 15:17:44 +00:00
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
2007-02-26 10:51:33 +00:00
|
|
|
|
2006-08-29 22:12:40 +00:00
|
|
|
/* For now keep DMA off. We can set it for all but A rev CS5510 once the
|
|
|
|
core ATA code can handle it */
|
|
|
|
|
2006-09-29 00:21:59 +00:00
|
|
|
static const struct pci_device_id pata_cs5520[] = {
|
|
|
|
{ PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5510), },
|
|
|
|
{ PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5520), },
|
|
|
|
|
|
|
|
{ },
|
2006-08-29 22:12:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_driver cs5520_pci_driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.id_table = pata_cs5520,
|
|
|
|
.probe = cs5520_init_one,
|
2007-10-11 21:12:35 +00:00
|
|
|
.remove = ata_pci_remove_one,
|
2014-05-07 15:17:44 +00:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2007-02-20 17:44:25 +00:00
|
|
|
.suspend = cs5520_pci_device_suspend,
|
2006-11-22 17:01:06 +00:00
|
|
|
.resume = cs5520_reinit_one,
|
2007-03-02 08:31:26 +00:00
|
|
|
#endif
|
2006-08-29 22:12:40 +00:00
|
|
|
};
|
|
|
|
|
2012-04-19 05:43:05 +00:00
|
|
|
module_pci_driver(cs5520_pci_driver);
|
2006-08-29 22:12:40 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox");
|
|
|
|
MODULE_DESCRIPTION("low-level driver for Cyrix CS5510/5520");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, pata_cs5520);
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|