Skip to content

Commit 2ba14a0

Browse files
committed
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (67 commits) fix drivers/ata/sata_fsl.c double-decl [libata] Prefer SCSI_SENSE_BUFFERSIZE to sizeof() pata_legacy: Merge winbond support ata_generic: Cenatek support pata_winbond: error return pata_serverworks: Fix cable types and cosmetics pata_mpc52xx: remove un-needed assignment libata: fix off-by-one in error categorization ahci: factor out AHCI enabling and enable AHCI before reading CAP ata_piix: implement SIDPR SCR access ata_piix: convert to prepare - activate initialization libata: factor out ata_pci_activate_sff_host() from ata_pci_one() [libata] Prefer SCSI_SENSE_BUFFERSIZE to sizeof() pata_legacy: resychronize with upstream changes and resubmit [libata] pata_legacy: typo fix [libata] pata_winbond: update for new ->data_xfer hook pata_pcmcia: convert to new data_xfer prototype libata annotations and fixes libata: use dev_driver_string() instead of "libata" in libata-sff.c ata_piix: kill unused constants and flags ...
2 parents 99f1c97 + a984f58 commit 2ba14a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2851
-1323
lines changed

drivers/ata/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,15 @@ config PATA_NETCELL
459459

460460
If unsure, say N.
461461

462+
config PATA_NINJA32
463+
tristate "Ninja32/Delkin Cardbus ATA support (Experimental)"
464+
depends on PCI && EXPERIMENTAL
465+
help
466+
This option enables support for the Ninja32, Delkin and
467+
possibly other brands of Cardbus ATA adapter
468+
469+
If unsure, say N.
470+
462471
config PATA_NS87410
463472
tristate "Nat Semi NS87410 PATA support (Experimental)"
464473
depends on PCI && EXPERIMENTAL

drivers/ata/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ obj-$(CONFIG_PATA_IT821X) += pata_it821x.o
4141
obj-$(CONFIG_PATA_IT8213) += pata_it8213.o
4242
obj-$(CONFIG_PATA_JMICRON) += pata_jmicron.o
4343
obj-$(CONFIG_PATA_NETCELL) += pata_netcell.o
44+
obj-$(CONFIG_PATA_NINJA32) += pata_ninja32.o
4445
obj-$(CONFIG_PATA_NS87410) += pata_ns87410.o
4546
obj-$(CONFIG_PATA_NS87415) += pata_ns87415.o
4647
obj-$(CONFIG_PATA_OPTI) += pata_opti.o

drivers/ata/ahci.c

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,18 @@ enum {
198198
};
199199

200200
struct ahci_cmd_hdr {
201-
u32 opts;
202-
u32 status;
203-
u32 tbl_addr;
204-
u32 tbl_addr_hi;
205-
u32 reserved[4];
201+
__le32 opts;
202+
__le32 status;
203+
__le32 tbl_addr;
204+
__le32 tbl_addr_hi;
205+
__le32 reserved[4];
206206
};
207207

208208
struct ahci_sg {
209-
u32 addr;
210-
u32 addr_hi;
211-
u32 reserved;
212-
u32 flags_size;
209+
__le32 addr;
210+
__le32 addr_hi;
211+
__le32 reserved;
212+
__le32 flags_size;
213213
};
214214

215215
struct ahci_host_priv {
@@ -597,6 +597,20 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap)
597597
return __ahci_port_base(ap->host, ap->port_no);
598598
}
599599

600+
static void ahci_enable_ahci(void __iomem *mmio)
601+
{
602+
u32 tmp;
603+
604+
/* turn on AHCI_EN */
605+
tmp = readl(mmio + HOST_CTL);
606+
if (!(tmp & HOST_AHCI_EN)) {
607+
tmp |= HOST_AHCI_EN;
608+
writel(tmp, mmio + HOST_CTL);
609+
tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
610+
WARN_ON(!(tmp & HOST_AHCI_EN));
611+
}
612+
}
613+
600614
/**
601615
* ahci_save_initial_config - Save and fixup initial config values
602616
* @pdev: target PCI device
@@ -619,6 +633,9 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
619633
u32 cap, port_map;
620634
int i;
621635

636+
/* make sure AHCI mode is enabled before accessing CAP */
637+
ahci_enable_ahci(mmio);
638+
622639
/* Values prefixed with saved_ are written back to host after
623640
* reset. Values without are used for driver operation.
624641
*/
@@ -1036,19 +1053,17 @@ static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
10361053
static int ahci_reset_controller(struct ata_host *host)
10371054
{
10381055
struct pci_dev *pdev = to_pci_dev(host->dev);
1056+
struct ahci_host_priv *hpriv = host->private_data;
10391057
void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
10401058
u32 tmp;
10411059

10421060
/* we must be in AHCI mode, before using anything
10431061
* AHCI-specific, such as HOST_RESET.
10441062
*/
1045-
tmp = readl(mmio + HOST_CTL);
1046-
if (!(tmp & HOST_AHCI_EN)) {
1047-
tmp |= HOST_AHCI_EN;
1048-
writel(tmp, mmio + HOST_CTL);
1049-
}
1063+
ahci_enable_ahci(mmio);
10501064

10511065
/* global controller reset */
1066+
tmp = readl(mmio + HOST_CTL);
10521067
if ((tmp & HOST_RESET) == 0) {
10531068
writel(tmp | HOST_RESET, mmio + HOST_CTL);
10541069
readl(mmio + HOST_CTL); /* flush */
@@ -1067,8 +1082,7 @@ static int ahci_reset_controller(struct ata_host *host)
10671082
}
10681083

10691084
/* turn on AHCI mode */
1070-
writel(HOST_AHCI_EN, mmio + HOST_CTL);
1071-
(void) readl(mmio + HOST_CTL); /* flush */
1085+
ahci_enable_ahci(mmio);
10721086

10731087
/* some registers might be cleared on reset. restore initial values */
10741088
ahci_restore_initial_config(host);
@@ -1078,8 +1092,10 @@ static int ahci_reset_controller(struct ata_host *host)
10781092

10791093
/* configure PCS */
10801094
pci_read_config_word(pdev, 0x92, &tmp16);
1081-
tmp16 |= 0xf;
1082-
pci_write_config_word(pdev, 0x92, tmp16);
1095+
if ((tmp16 & hpriv->port_map) != hpriv->port_map) {
1096+
tmp16 |= hpriv->port_map;
1097+
pci_write_config_word(pdev, 0x92, tmp16);
1098+
}
10831099
}
10841100

10851101
return 0;
@@ -1480,35 +1496,31 @@ static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
14801496
static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
14811497
{
14821498
struct scatterlist *sg;
1483-
struct ahci_sg *ahci_sg;
1484-
unsigned int n_sg = 0;
1499+
struct ahci_sg *ahci_sg = cmd_tbl + AHCI_CMD_TBL_HDR_SZ;
1500+
unsigned int si;
14851501

14861502
VPRINTK("ENTER\n");
14871503

14881504
/*
14891505
* Next, the S/G list.
14901506
*/
1491-
ahci_sg = cmd_tbl + AHCI_CMD_TBL_HDR_SZ;
1492-
ata_for_each_sg(sg, qc) {
1507+
for_each_sg(qc->sg, sg, qc->n_elem, si) {
14931508
dma_addr_t addr = sg_dma_address(sg);
14941509
u32 sg_len = sg_dma_len(sg);
14951510

1496-
ahci_sg->addr = cpu_to_le32(addr & 0xffffffff);
1497-
ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16);
1498-
ahci_sg->flags_size = cpu_to_le32(sg_len - 1);
1499-
1500-
ahci_sg++;
1501-
n_sg++;
1511+
ahci_sg[si].addr = cpu_to_le32(addr & 0xffffffff);
1512+
ahci_sg[si].addr_hi = cpu_to_le32((addr >> 16) >> 16);
1513+
ahci_sg[si].flags_size = cpu_to_le32(sg_len - 1);
15021514
}
15031515

1504-
return n_sg;
1516+
return si;
15051517
}
15061518

15071519
static void ahci_qc_prep(struct ata_queued_cmd *qc)
15081520
{
15091521
struct ata_port *ap = qc->ap;
15101522
struct ahci_port_priv *pp = ap->private_data;
1511-
int is_atapi = is_atapi_taskfile(&qc->tf);
1523+
int is_atapi = ata_is_atapi(qc->tf.protocol);
15121524
void *cmd_tbl;
15131525
u32 opts;
15141526
const u32 cmd_fis_len = 5; /* five dwords */

drivers/ata/ata_generic.c

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <linux/libata.h>
2727

2828
#define DRV_NAME "ata_generic"
29-
#define DRV_VERSION "0.2.13"
29+
#define DRV_VERSION "0.2.15"
3030

3131
/*
3232
* A generic parallel ATA driver using libata
@@ -48,27 +48,47 @@ static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
4848
struct ata_port *ap = link->ap;
4949
int dma_enabled = 0;
5050
struct ata_device *dev;
51+
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
5152

5253
/* Bits 5 and 6 indicate if DMA is active on master/slave */
5354
if (ap->ioaddr.bmdma_addr)
5455
dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
5556

57+
if (pdev->vendor == PCI_VENDOR_ID_CENATEK)
58+
dma_enabled = 0xFF;
59+
5660
ata_link_for_each_dev(dev, link) {
57-
if (ata_dev_enabled(dev)) {
58-
/* We don't really care */
59-
dev->pio_mode = XFER_PIO_0;
60-
dev->dma_mode = XFER_MW_DMA_0;
61-
/* We do need the right mode information for DMA or PIO
62-
and this comes from the current configuration flags */
63-
if (dma_enabled & (1 << (5 + dev->devno))) {
64-
ata_id_to_dma_mode(dev, XFER_MW_DMA_0);
65-
dev->flags &= ~ATA_DFLAG_PIO;
66-
} else {
67-
ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
68-
dev->xfer_mode = XFER_PIO_0;
69-
dev->xfer_shift = ATA_SHIFT_PIO;
70-
dev->flags |= ATA_DFLAG_PIO;
61+
if (!ata_dev_enabled(dev))
62+
continue;
63+
64+
/* We don't really care */
65+
dev->pio_mode = XFER_PIO_0;
66+
dev->dma_mode = XFER_MW_DMA_0;
67+
/* We do need the right mode information for DMA or PIO
68+
and this comes from the current configuration flags */
69+
if (dma_enabled & (1 << (5 + dev->devno))) {
70+
unsigned int xfer_mask = ata_id_xfermask(dev->id);
71+
const char *name;
72+
73+
if (xfer_mask & (ATA_MASK_MWDMA | ATA_MASK_UDMA))
74+
name = ata_mode_string(xfer_mask);
75+
else {
76+
/* SWDMA perhaps? */
77+
name = "DMA";
78+
xfer_mask |= ata_xfer_mode2mask(XFER_MW_DMA_0);
7179
}
80+
81+
ata_dev_printk(dev, KERN_INFO, "configured for %s\n",
82+
name);
83+
84+
dev->xfer_mode = ata_xfer_mask2mode(xfer_mask);
85+
dev->xfer_shift = ata_xfer_mode2shift(dev->xfer_mode);
86+
dev->flags &= ~ATA_DFLAG_PIO;
87+
} else {
88+
ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
89+
dev->xfer_mode = XFER_PIO_0;
90+
dev->xfer_shift = ATA_SHIFT_PIO;
91+
dev->flags |= ATA_DFLAG_PIO;
7292
}
7393
}
7494
return 0;
@@ -185,6 +205,7 @@ static struct pci_device_id ata_generic[] = {
185205
{ PCI_DEVICE(PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), },
186206
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561), },
187207
{ PCI_DEVICE(PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558), },
208+
{ PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE), },
188209
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO), },
189210
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
190211
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },

0 commit comments

Comments
 (0)