1 --- a/drivers/ata/pata_ixp4xx_cf.c
2 +++ b/drivers/ata/pata_ixp4xx_cf.c
4 #include <scsi/scsi_host.h>
6 #define DRV_NAME "pata_ixp4xx_cf"
7 -#define DRV_VERSION "0.2"
8 +#define DRV_VERSION "0.3"
10 static int ixp4xx_set_mode(struct ata_link *link, struct ata_device **error)
12 struct ata_device *dev;
13 + struct ixp4xx_pata_data *data = link->ap->host->dev->platform_data;
14 + unsigned int pio_mask;
16 ata_for_each_dev(dev, link, ENABLED) {
17 - ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
18 - dev->pio_mode = XFER_PIO_0;
19 - dev->xfer_mode = XFER_PIO_0;
20 + if (dev->id[ATA_ID_FIELD_VALID] & (1 << 1)) {
21 + pio_mask = dev->id[ATA_ID_PIO_MODES] & 0x03;
22 + if (pio_mask & (1 << 1)) {
28 + pio_mask = (dev->id[ATA_ID_OLD_PIO_MODES] >> 8);
33 + ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
34 + dev->pio_mode = XFER_PIO_0;
35 + dev->xfer_mode = XFER_PIO_0;
36 + *data->cs0_cfg = 0x8a473c03;
39 + ata_dev_printk(dev, KERN_INFO, "configured for PIO1\n");
40 + dev->pio_mode = XFER_PIO_1;
41 + dev->xfer_mode = XFER_PIO_1;
42 + *data->cs0_cfg = 0x86433c03;
45 + ata_dev_printk(dev, KERN_INFO, "configured for PIO2\n");
46 + dev->pio_mode = XFER_PIO_2;
47 + dev->xfer_mode = XFER_PIO_2;
48 + *data->cs0_cfg = 0x82413c03;
51 + ata_dev_printk(dev, KERN_INFO, "configured for PIO3\n");
52 + dev->pio_mode = XFER_PIO_3;
53 + dev->xfer_mode = XFER_PIO_3;
54 + *data->cs0_cfg = 0x80823c03;
57 + ata_dev_printk(dev, KERN_INFO, "configured for PIO4\n");
58 + dev->pio_mode = XFER_PIO_4;
59 + dev->xfer_mode = XFER_PIO_4;
60 + *data->cs0_cfg = 0x80403c03;
63 dev->xfer_shift = ATA_SHIFT_PIO;
64 dev->flags |= ATA_DFLAG_PIO;
66 @@ -46,6 +88,7 @@ static unsigned int ixp4xx_mmio_data_xfe
68 unsigned int words = buflen >> 1;
69 u16 *buf16 = (u16 *) buf;
70 + unsigned int pio_mask;
71 struct ata_port *ap = dev->link->ap;
72 void __iomem *mmio = ap->ioaddr.data_addr;
73 struct ixp4xx_pata_data *data = ap->host->dev->platform_data;
74 @@ -53,8 +96,34 @@ static unsigned int ixp4xx_mmio_data_xfe
75 /* set the expansion bus in 16bit mode and restore
76 * 8 bit mode after the transaction.
78 - *data->cs0_cfg &= ~(0x01);
80 + if (dev->id[ATA_ID_FIELD_VALID] & (1 << 1)){
81 + pio_mask = dev->id[ATA_ID_PIO_MODES] & 0x03;
82 + if (pio_mask & (1 << 1)){
88 + pio_mask = (dev->id[ATA_ID_OLD_PIO_MODES] >> 8);
92 + *data->cs0_cfg = 0xa9643c42;
95 + *data->cs0_cfg = 0x85033c42;
98 + *data->cs0_cfg = 0x80b23c42;
101 + *data->cs0_cfg = 0x80823c42;
104 + *data->cs0_cfg = 0x80403c42;
109 /* Transfer multiple of 2 bytes */
111 @@ -79,8 +148,24 @@ static unsigned int ixp4xx_mmio_data_xfe
116 - *data->cs0_cfg |= 0x01;
120 + *data->cs0_cfg = 0x8a473c03;
123 + *data->cs0_cfg = 0x86433c03;
126 + *data->cs0_cfg = 0x82413c03;
129 + *data->cs0_cfg = 0x80823c03;
132 + *data->cs0_cfg = 0x80403c03;