diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/ide | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/ide')
69 files changed, 707 insertions, 955 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 9a5d0aaac9d0..98ccfeb3f5aa 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -7,50 +7,25 @@ config HAVE_IDE | |||
7 | bool | 7 | bool |
8 | 8 | ||
9 | menuconfig IDE | 9 | menuconfig IDE |
10 | tristate "ATA/ATAPI/MFM/RLL support" | 10 | tristate "ATA/ATAPI/MFM/RLL support (DEPRECATED)" |
11 | depends on HAVE_IDE | 11 | depends on HAVE_IDE |
12 | depends on BLOCK | 12 | depends on BLOCK |
13 | ---help--- | 13 | ---help--- |
14 | If you say Y here, your kernel will be able to manage low cost mass | 14 | If you say Y here, your kernel will be able to manage ATA/(E)IDE and |
15 | storage units such as ATA/(E)IDE and ATAPI units. The most common | 15 | ATAPI units. The most common cases are IDE hard drives and ATAPI |
16 | cases are IDE hard drives and ATAPI CD-ROM drives. | 16 | CD-ROM drives. |
17 | 17 | ||
18 | If your system is pure SCSI and doesn't use these interfaces, you | 18 | This subsystem is currently in maintenance mode with only bug fix |
19 | can say N here. | 19 | changes applied. Users of ATA hardware are encouraged to migrate to |
20 | 20 | the newer ATA subsystem ("Serial ATA (prod) and Parallel ATA | |
21 | Integrated Disk Electronics (IDE aka ATA-1) is a connecting standard | 21 | (experimental) drivers") which is more actively maintained. |
22 | for mass storage units such as hard disks. It was designed by | ||
23 | Western Digital and Compaq Computer in 1984. It was then named | ||
24 | ST506. Quite a number of disks use the IDE interface. | ||
25 | |||
26 | AT Attachment (ATA) is the superset of the IDE specifications. | ||
27 | ST506 was also called ATA-1. | ||
28 | |||
29 | Fast-IDE is ATA-2 (also named Fast ATA), Enhanced IDE (EIDE) is | ||
30 | ATA-3. It provides support for larger disks (up to 8.4GB by means of | ||
31 | the LBA standard), more disks (4 instead of 2) and for other mass | ||
32 | storage units such as tapes and cdrom. UDMA/33 (aka UltraDMA/33) is | ||
33 | ATA-4 and provides faster (and more CPU friendly) transfer modes | ||
34 | than previous PIO (Programmed processor Input/Output) from previous | ||
35 | ATA/IDE standards by means of fast DMA controllers. | ||
36 | |||
37 | ATA Packet Interface (ATAPI) is a protocol used by EIDE tape and | ||
38 | CD-ROM drives, similar in many respects to the SCSI protocol. | ||
39 | |||
40 | SMART IDE (Self Monitoring, Analysis and Reporting Technology) was | ||
41 | designed in order to prevent data corruption and disk crash by | ||
42 | detecting pre hardware failure conditions (heat, access time, and | ||
43 | the like...). Disks built since June 1995 may follow this standard. | ||
44 | The kernel itself doesn't manage this; however there are quite a | ||
45 | number of user programs such as smart that can query the status of | ||
46 | SMART parameters from disk drives. | ||
47 | 22 | ||
48 | To compile this driver as a module, choose M here: the | 23 | To compile this driver as a module, choose M here: the |
49 | module will be called ide-core. | 24 | module will be called ide-core. |
50 | 25 | ||
51 | For further information, please read <file:Documentation/ide/ide.txt>. | 26 | For further information, please read <file:Documentation/ide/ide.txt>. |
52 | 27 | ||
53 | If unsure, say Y. | 28 | If unsure, say N. |
54 | 29 | ||
55 | if IDE | 30 | if IDE |
56 | 31 | ||
diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c index 878f8ec6dbe1..57d00caefc86 100644 --- a/drivers/ide/aec62xx.c +++ b/drivers/ide/aec62xx.c | |||
@@ -81,15 +81,15 @@ static u8 pci_bus_clock_list_ultra (u8 speed, struct chipset_bus_clock_list_entr | |||
81 | return chipset_table->ultra_settings; | 81 | return chipset_table->ultra_settings; |
82 | } | 82 | } |
83 | 83 | ||
84 | static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | 84 | static void aec6210_set_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
85 | { | 85 | { |
86 | ide_hwif_t *hwif = drive->hwif; | ||
87 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 86 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
88 | struct ide_host *host = pci_get_drvdata(dev); | 87 | struct ide_host *host = pci_get_drvdata(dev); |
89 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; | 88 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; |
90 | u16 d_conf = 0; | 89 | u16 d_conf = 0; |
91 | u8 ultra = 0, ultra_conf = 0; | 90 | u8 ultra = 0, ultra_conf = 0; |
92 | u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; | 91 | u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; |
92 | const u8 speed = drive->dma_mode; | ||
93 | unsigned long flags; | 93 | unsigned long flags; |
94 | 94 | ||
95 | local_irq_save(flags); | 95 | local_irq_save(flags); |
@@ -109,15 +109,15 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | |||
109 | local_irq_restore(flags); | 109 | local_irq_restore(flags); |
110 | } | 110 | } |
111 | 111 | ||
112 | static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | 112 | static void aec6260_set_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
113 | { | 113 | { |
114 | ide_hwif_t *hwif = drive->hwif; | ||
115 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 114 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
116 | struct ide_host *host = pci_get_drvdata(dev); | 115 | struct ide_host *host = pci_get_drvdata(dev); |
117 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; | 116 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; |
118 | u8 unit = drive->dn & 1; | 117 | u8 unit = drive->dn & 1; |
119 | u8 tmp1 = 0, tmp2 = 0; | 118 | u8 tmp1 = 0, tmp2 = 0; |
120 | u8 ultra = 0, drive_conf = 0, ultra_conf = 0; | 119 | u8 ultra = 0, drive_conf = 0, ultra_conf = 0; |
120 | const u8 speed = drive->dma_mode; | ||
121 | unsigned long flags; | 121 | unsigned long flags; |
122 | 122 | ||
123 | local_irq_save(flags); | 123 | local_irq_save(flags); |
@@ -134,9 +134,10 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | |||
134 | local_irq_restore(flags); | 134 | local_irq_restore(flags); |
135 | } | 135 | } |
136 | 136 | ||
137 | static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | 137 | static void aec_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
138 | { | 138 | { |
139 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); | 139 | drive->dma_mode = drive->pio_mode; |
140 | hwif->port_ops->set_dma_mode(hwif, drive); | ||
140 | } | 141 | } |
141 | 142 | ||
142 | static int init_chipset_aec62xx(struct pci_dev *dev) | 143 | static int init_chipset_aec62xx(struct pci_dev *dev) |
diff --git a/drivers/ide/ali14xx.c b/drivers/ide/ali14xx.c index 90da1f953ed0..25b9fe3a9f8e 100644 --- a/drivers/ide/ali14xx.c +++ b/drivers/ide/ali14xx.c | |||
@@ -109,13 +109,14 @@ static DEFINE_SPINLOCK(ali14xx_lock); | |||
109 | * This function computes timing parameters | 109 | * This function computes timing parameters |
110 | * and sets controller registers accordingly. | 110 | * and sets controller registers accordingly. |
111 | */ | 111 | */ |
112 | static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | 112 | static void ali14xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
113 | { | 113 | { |
114 | int driveNum; | 114 | int driveNum; |
115 | int time1, time2; | 115 | int time1, time2; |
116 | u8 param1, param2, param3, param4; | 116 | u8 param1, param2, param3, param4; |
117 | unsigned long flags; | 117 | unsigned long flags; |
118 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; | 118 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
119 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
119 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | 120 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
120 | 121 | ||
121 | /* calculate timing, according to PIO mode */ | 122 | /* calculate timing, according to PIO mode */ |
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index e59b6dee9ae2..2c8016ad0e26 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Copyright (C) 2002 Alan Cox | 8 | * Copyright (C) 2002 Alan Cox |
9 | * ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw> | 9 | * ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw> |
10 | * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> | 10 | * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> |
11 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 11 | * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz |
12 | * | 12 | * |
13 | * (U)DMA capable version of ali 1533/1543(C), 1535(D) | 13 | * (U)DMA capable version of ali 1533/1543(C), 1535(D) |
14 | * | 14 | * |
@@ -40,16 +40,6 @@ | |||
40 | #define DRV_NAME "alim15x3" | 40 | #define DRV_NAME "alim15x3" |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking | ||
44 | * (this is DANGEROUS and could result in data corruption). | ||
45 | */ | ||
46 | static int wdc_udma; | ||
47 | |||
48 | module_param(wdc_udma, bool, 0); | ||
49 | MODULE_PARM_DESC(wdc_udma, | ||
50 | "allow UDMA on M1543C-E chipset for WDC disks (DANGEROUS)"); | ||
51 | |||
52 | /* | ||
53 | * ALi devices are not plug in. Otherwise these static values would | 43 | * ALi devices are not plug in. Otherwise these static values would |
54 | * need to go. They ought to go away anyway | 44 | * need to go. They ought to go away anyway |
55 | */ | 45 | */ |
@@ -58,61 +48,84 @@ static u8 m5229_revision; | |||
58 | static u8 chip_is_1543c_e; | 48 | static u8 chip_is_1543c_e; |
59 | static struct pci_dev *isa_dev; | 49 | static struct pci_dev *isa_dev; |
60 | 50 | ||
51 | static void ali_fifo_control(ide_hwif_t *hwif, ide_drive_t *drive, int on) | ||
52 | { | ||
53 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | ||
54 | int pio_fifo = 0x54 + hwif->channel; | ||
55 | u8 fifo; | ||
56 | int shift = 4 * (drive->dn & 1); | ||
57 | |||
58 | pci_read_config_byte(pdev, pio_fifo, &fifo); | ||
59 | fifo &= ~(0x0F << shift); | ||
60 | fifo |= (on << shift); | ||
61 | pci_write_config_byte(pdev, pio_fifo, fifo); | ||
62 | } | ||
63 | |||
64 | static void ali_program_timings(ide_hwif_t *hwif, ide_drive_t *drive, | ||
65 | struct ide_timing *t, u8 ultra) | ||
66 | { | ||
67 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
68 | int port = hwif->channel ? 0x5c : 0x58; | ||
69 | int udmat = 0x56 + hwif->channel; | ||
70 | u8 unit = drive->dn & 1, udma; | ||
71 | int shift = 4 * unit; | ||
72 | |||
73 | /* Set up the UDMA */ | ||
74 | pci_read_config_byte(dev, udmat, &udma); | ||
75 | udma &= ~(0x0F << shift); | ||
76 | udma |= ultra << shift; | ||
77 | pci_write_config_byte(dev, udmat, udma); | ||
78 | |||
79 | if (t == NULL) | ||
80 | return; | ||
81 | |||
82 | t->setup = clamp_val(t->setup, 1, 8) & 7; | ||
83 | t->act8b = clamp_val(t->act8b, 1, 8) & 7; | ||
84 | t->rec8b = clamp_val(t->rec8b, 1, 16) & 15; | ||
85 | t->active = clamp_val(t->active, 1, 8) & 7; | ||
86 | t->recover = clamp_val(t->recover, 1, 16) & 15; | ||
87 | |||
88 | pci_write_config_byte(dev, port, t->setup); | ||
89 | pci_write_config_byte(dev, port + 1, (t->act8b << 4) | t->rec8b); | ||
90 | pci_write_config_byte(dev, port + unit + 2, | ||
91 | (t->active << 4) | t->recover); | ||
92 | } | ||
93 | |||
61 | /** | 94 | /** |
62 | * ali_set_pio_mode - set host controller for PIO mode | 95 | * ali_set_pio_mode - set host controller for PIO mode |
96 | * @hwif: port | ||
63 | * @drive: drive | 97 | * @drive: drive |
64 | * @pio: PIO mode number | ||
65 | * | 98 | * |
66 | * Program the controller for the given PIO mode. | 99 | * Program the controller for the given PIO mode. |
67 | */ | 100 | */ |
68 | 101 | ||
69 | static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) | 102 | static void ali_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
70 | { | 103 | { |
71 | ide_hwif_t *hwif = drive->hwif; | 104 | ide_drive_t *pair = ide_get_pair_dev(drive); |
72 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
73 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | ||
74 | int s_time = t->setup, a_time = t->active, c_time = t->cycle; | ||
75 | u8 s_clc, a_clc, r_clc; | ||
76 | unsigned long flags; | ||
77 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; | 105 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
78 | int port = hwif->channel ? 0x5c : 0x58; | 106 | unsigned long T = 1000000 / bus_speed; /* PCI clock based */ |
79 | int portFIFO = hwif->channel ? 0x55 : 0x54; | 107 | struct ide_timing t; |
80 | u8 cd_dma_fifo = 0, unit = drive->dn & 1; | 108 | |
81 | 109 | ide_timing_compute(drive, drive->pio_mode, &t, T, 1); | |
82 | if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) | 110 | if (pair) { |
83 | s_clc = 0; | 111 | struct ide_timing p; |
84 | if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8) | 112 | |
85 | a_clc = 0; | 113 | ide_timing_compute(pair, pair->pio_mode, &p, T, 1); |
86 | 114 | ide_timing_merge(&p, &t, &t, | |
87 | if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) { | 115 | IDE_TIMING_SETUP | IDE_TIMING_8BIT); |
88 | r_clc = 1; | 116 | if (pair->dma_mode) { |
89 | } else { | 117 | ide_timing_compute(pair, pair->dma_mode, &p, T, 1); |
90 | if (r_clc >= 16) | 118 | ide_timing_merge(&p, &t, &t, |
91 | r_clc = 0; | 119 | IDE_TIMING_SETUP | IDE_TIMING_8BIT); |
120 | } | ||
92 | } | 121 | } |
93 | local_irq_save(flags); | 122 | |
94 | |||
95 | /* | 123 | /* |
96 | * PIO mode => ATA FIFO on, ATAPI FIFO off | 124 | * PIO mode => ATA FIFO on, ATAPI FIFO off |
97 | */ | 125 | */ |
98 | pci_read_config_byte(dev, portFIFO, &cd_dma_fifo); | 126 | ali_fifo_control(hwif, drive, (drive->media == ide_disk) ? 0x05 : 0x00); |
99 | if (drive->media==ide_disk) { | 127 | |
100 | if (unit) { | 128 | ali_program_timings(hwif, drive, &t, 0); |
101 | pci_write_config_byte(dev, portFIFO, (cd_dma_fifo & 0x0F) | 0x50); | ||
102 | } else { | ||
103 | pci_write_config_byte(dev, portFIFO, (cd_dma_fifo & 0xF0) | 0x05); | ||
104 | } | ||
105 | } else { | ||
106 | if (unit) { | ||
107 | pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0x0F); | ||
108 | } else { | ||
109 | pci_write_config_byte(dev, portFIFO, cd_dma_fifo & 0xF0); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | pci_write_config_byte(dev, port, s_clc); | ||
114 | pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc); | ||
115 | local_irq_restore(flags); | ||
116 | } | 129 | } |
117 | 130 | ||
118 | /** | 131 | /** |
@@ -132,7 +145,7 @@ static u8 ali_udma_filter(ide_drive_t *drive) | |||
132 | if (m5229_revision > 0x20 && m5229_revision < 0xC2) { | 145 | if (m5229_revision > 0x20 && m5229_revision < 0xC2) { |
133 | if (drive->media != ide_disk) | 146 | if (drive->media != ide_disk) |
134 | return 0; | 147 | return 0; |
135 | if (wdc_udma == 0 && chip_is_1543c_e && | 148 | if (chip_is_1543c_e && |
136 | strstr((char *)&drive->id[ATA_ID_PROD], "WDC ")) | 149 | strstr((char *)&drive->id[ATA_ID_PROD], "WDC ")) |
137 | return 0; | 150 | return 0; |
138 | } | 151 | } |
@@ -142,44 +155,42 @@ static u8 ali_udma_filter(ide_drive_t *drive) | |||
142 | 155 | ||
143 | /** | 156 | /** |
144 | * ali_set_dma_mode - set host controller for DMA mode | 157 | * ali_set_dma_mode - set host controller for DMA mode |
158 | * @hwif: port | ||
145 | * @drive: drive | 159 | * @drive: drive |
146 | * @speed: DMA mode | ||
147 | * | 160 | * |
148 | * Configure the hardware for the desired IDE transfer mode. | 161 | * Configure the hardware for the desired IDE transfer mode. |
149 | */ | 162 | */ |
150 | 163 | ||
151 | static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) | 164 | static void ali_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
152 | { | 165 | { |
153 | ide_hwif_t *hwif = drive->hwif; | 166 | static u8 udma_timing[7] = { 0xC, 0xB, 0xA, 0x9, 0x8, 0xF, 0xD }; |
154 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 167 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
155 | u8 speed1 = speed; | 168 | ide_drive_t *pair = ide_get_pair_dev(drive); |
156 | u8 unit = drive->dn & 1; | 169 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
170 | unsigned long T = 1000000 / bus_speed; /* PCI clock based */ | ||
171 | const u8 speed = drive->dma_mode; | ||
157 | u8 tmpbyte = 0x00; | 172 | u8 tmpbyte = 0x00; |
158 | int m5229_udma = (hwif->channel) ? 0x57 : 0x56; | 173 | struct ide_timing t; |
159 | |||
160 | if (speed == XFER_UDMA_6) | ||
161 | speed1 = 0x47; | ||
162 | 174 | ||
163 | if (speed < XFER_UDMA_0) { | 175 | if (speed < XFER_UDMA_0) { |
164 | u8 ultra_enable = (unit) ? 0x7f : 0xf7; | 176 | ide_timing_compute(drive, drive->dma_mode, &t, T, 1); |
165 | /* | 177 | if (pair) { |
166 | * clear "ultra enable" bit | 178 | struct ide_timing p; |
167 | */ | 179 | |
168 | pci_read_config_byte(dev, m5229_udma, &tmpbyte); | 180 | ide_timing_compute(pair, pair->pio_mode, &p, T, 1); |
169 | tmpbyte &= ultra_enable; | 181 | ide_timing_merge(&p, &t, &t, |
170 | pci_write_config_byte(dev, m5229_udma, tmpbyte); | 182 | IDE_TIMING_SETUP | IDE_TIMING_8BIT); |
171 | 183 | if (pair->dma_mode) { | |
172 | /* | 184 | ide_timing_compute(pair, pair->dma_mode, |
173 | * FIXME: Oh, my... DMA timings are never set. | 185 | &p, T, 1); |
174 | */ | 186 | ide_timing_merge(&p, &t, &t, |
187 | IDE_TIMING_SETUP | IDE_TIMING_8BIT); | ||
188 | } | ||
189 | } | ||
190 | ali_program_timings(hwif, drive, &t, 0); | ||
175 | } else { | 191 | } else { |
176 | pci_read_config_byte(dev, m5229_udma, &tmpbyte); | 192 | ali_program_timings(hwif, drive, NULL, |
177 | tmpbyte &= (0x0f << ((1-unit) << 2)); | 193 | udma_timing[speed - XFER_UDMA_0]); |
178 | /* | ||
179 | * enable ultra dma and set timing | ||
180 | */ | ||
181 | tmpbyte |= ((0x08 | ((4-speed1)&0x07)) << (unit << 2)); | ||
182 | pci_write_config_byte(dev, m5229_udma, tmpbyte); | ||
183 | if (speed >= XFER_UDMA_3) { | 194 | if (speed >= XFER_UDMA_3) { |
184 | pci_read_config_byte(dev, 0x4b, &tmpbyte); | 195 | pci_read_config_byte(dev, 0x4b, &tmpbyte); |
185 | tmpbyte |= 1; | 196 | tmpbyte |= 1; |
@@ -365,19 +376,13 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
365 | * | 376 | * |
366 | * This checks if the controller and the cable are capable | 377 | * This checks if the controller and the cable are capable |
367 | * of UDMA66 transfers. It doesn't check the drives. | 378 | * of UDMA66 transfers. It doesn't check the drives. |
368 | * But see note 2 below! | ||
369 | * | ||
370 | * FIXME: frobs bits that are not defined on newer ALi devicea | ||
371 | */ | 379 | */ |
372 | 380 | ||
373 | static u8 ali_cable_detect(ide_hwif_t *hwif) | 381 | static u8 ali_cable_detect(ide_hwif_t *hwif) |
374 | { | 382 | { |
375 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 383 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
376 | unsigned long flags; | ||
377 | u8 cbl = ATA_CBL_PATA40, tmpbyte; | 384 | u8 cbl = ATA_CBL_PATA40, tmpbyte; |
378 | 385 | ||
379 | local_irq_save(flags); | ||
380 | |||
381 | if (m5229_revision >= 0xC2) { | 386 | if (m5229_revision >= 0xC2) { |
382 | /* | 387 | /* |
383 | * m5229 80-pin cable detection (from Host View) | 388 | * m5229 80-pin cable detection (from Host View) |
@@ -397,8 +402,6 @@ static u8 ali_cable_detect(ide_hwif_t *hwif) | |||
397 | } | 402 | } |
398 | } | 403 | } |
399 | 404 | ||
400 | local_irq_restore(flags); | ||
401 | |||
402 | return cbl; | 405 | return cbl; |
403 | } | 406 | } |
404 | 407 | ||
@@ -594,6 +597,6 @@ static void __exit ali15x3_ide_exit(void) | |||
594 | module_init(ali15x3_ide_init); | 597 | module_init(ali15x3_ide_init); |
595 | module_exit(ali15x3_ide_exit); | 598 | module_exit(ali15x3_ide_exit); |
596 | 599 | ||
597 | MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox"); | 600 | MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox, Bartlomiej Zolnierkiewicz"); |
598 | MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE"); | 601 | MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE"); |
599 | MODULE_LICENSE("GPL"); | 602 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c index 628cd2e5fed8..3747b2561f09 100644 --- a/drivers/ide/amd74xx.c +++ b/drivers/ide/amd74xx.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * IDE driver for Linux. | 3 | * IDE driver for Linux. |
4 | * | 4 | * |
5 | * Copyright (c) 2000-2002 Vojtech Pavlik | 5 | * Copyright (c) 2000-2002 Vojtech Pavlik |
6 | * Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz | 6 | * Copyright (c) 2007-2010 Bartlomiej Zolnierkiewicz |
7 | * | 7 | * |
8 | * Based on the work of: | 8 | * Based on the work of: |
9 | * Andre Hedrick | 9 | * Andre Hedrick |
@@ -70,7 +70,8 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask, | |||
70 | default: return; | 70 | default: return; |
71 | } | 71 | } |
72 | 72 | ||
73 | pci_write_config_byte(dev, AMD_UDMA_TIMING + offset + (3 - dn), t); | 73 | if (timing->udma) |
74 | pci_write_config_byte(dev, AMD_UDMA_TIMING + offset + 3 - dn, t); | ||
74 | } | 75 | } |
75 | 76 | ||
76 | /* | 77 | /* |
@@ -78,14 +79,14 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask, | |||
78 | * to a desired transfer mode. It also can be called by upper layers. | 79 | * to a desired transfer mode. It also can be called by upper layers. |
79 | */ | 80 | */ |
80 | 81 | ||
81 | static void amd_set_drive(ide_drive_t *drive, const u8 speed) | 82 | static void amd_set_drive(ide_hwif_t *hwif, ide_drive_t *drive) |
82 | { | 83 | { |
83 | ide_hwif_t *hwif = drive->hwif; | ||
84 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 84 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
85 | ide_drive_t *peer = ide_get_pair_dev(drive); | 85 | ide_drive_t *peer = ide_get_pair_dev(drive); |
86 | struct ide_timing t, p; | 86 | struct ide_timing t, p; |
87 | int T, UT; | 87 | int T, UT; |
88 | u8 udma_mask = hwif->ultra_mask; | 88 | u8 udma_mask = hwif->ultra_mask; |
89 | const u8 speed = drive->dma_mode; | ||
89 | 90 | ||
90 | T = 1000000000 / amd_clock; | 91 | T = 1000000000 / amd_clock; |
91 | UT = (udma_mask == ATA_UDMA2) ? T : (T / 2); | 92 | UT = (udma_mask == ATA_UDMA2) ? T : (T / 2); |
@@ -93,7 +94,7 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed) | |||
93 | ide_timing_compute(drive, speed, &t, T, UT); | 94 | ide_timing_compute(drive, speed, &t, T, UT); |
94 | 95 | ||
95 | if (peer) { | 96 | if (peer) { |
96 | ide_timing_compute(peer, peer->current_speed, &p, T, UT); | 97 | ide_timing_compute(peer, peer->pio_mode, &p, T, UT); |
97 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); | 98 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); |
98 | } | 99 | } |
99 | 100 | ||
@@ -107,9 +108,10 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed) | |||
107 | * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning. | 108 | * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning. |
108 | */ | 109 | */ |
109 | 110 | ||
110 | static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) | 111 | static void amd_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
111 | { | 112 | { |
112 | amd_set_drive(drive, XFER_PIO_0 + pio); | 113 | drive->dma_mode = drive->pio_mode; |
114 | amd_set_drive(hwif, drive); | ||
113 | } | 115 | } |
114 | 116 | ||
115 | static void amd7409_cable_detect(struct pci_dev *dev) | 117 | static void amd7409_cable_detect(struct pci_dev *dev) |
@@ -340,6 +342,6 @@ static void __exit amd74xx_ide_exit(void) | |||
340 | module_init(amd74xx_ide_init); | 342 | module_init(amd74xx_ide_init); |
341 | module_exit(amd74xx_ide_exit); | 343 | module_exit(amd74xx_ide_exit); |
342 | 344 | ||
343 | MODULE_AUTHOR("Vojtech Pavlik"); | 345 | MODULE_AUTHOR("Vojtech Pavlik, Bartlomiej Zolnierkiewicz"); |
344 | MODULE_DESCRIPTION("AMD PCI IDE driver"); | 346 | MODULE_DESCRIPTION("AMD PCI IDE driver"); |
345 | MODULE_LICENSE("GPL"); | 347 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c index 248219a89a68..000a78e5246c 100644 --- a/drivers/ide/at91_ide.c +++ b/drivers/ide/at91_ide.c | |||
@@ -172,11 +172,12 @@ static void at91_ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd, | |||
172 | leave_16bit(chipselect, mode); | 172 | leave_16bit(chipselect, mode); |
173 | } | 173 | } |
174 | 174 | ||
175 | static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | 175 | static void at91_ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
176 | { | 176 | { |
177 | struct ide_timing *timing; | 177 | struct ide_timing *timing; |
178 | u8 chipselect = drive->hwif->select_data; | 178 | u8 chipselect = hwif->select_data; |
179 | int use_iordy = 0; | 179 | int use_iordy = 0; |
180 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
180 | 181 | ||
181 | pdbg("chipselect %u pio %u\n", chipselect, pio); | 182 | pdbg("chipselect %u pio %u\n", chipselect, pio); |
182 | 183 | ||
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c index 837322b10a4c..15f0ead89f5c 100644 --- a/drivers/ide/atiixp.c +++ b/drivers/ide/atiixp.c | |||
@@ -42,19 +42,20 @@ static DEFINE_SPINLOCK(atiixp_lock); | |||
42 | 42 | ||
43 | /** | 43 | /** |
44 | * atiixp_set_pio_mode - set host controller for PIO mode | 44 | * atiixp_set_pio_mode - set host controller for PIO mode |
45 | * @hwif: port | ||
45 | * @drive: drive | 46 | * @drive: drive |
46 | * @pio: PIO mode number | ||
47 | * | 47 | * |
48 | * Set the interface PIO mode. | 48 | * Set the interface PIO mode. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) | 51 | static void atiixp_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
52 | { | 52 | { |
53 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 53 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
54 | unsigned long flags; | 54 | unsigned long flags; |
55 | int timing_shift = (drive->dn ^ 1) * 8; | 55 | int timing_shift = (drive->dn ^ 1) * 8; |
56 | u32 pio_timing_data; | 56 | u32 pio_timing_data; |
57 | u16 pio_mode_data; | 57 | u16 pio_mode_data; |
58 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
58 | 59 | ||
59 | spin_lock_irqsave(&atiixp_lock, flags); | 60 | spin_lock_irqsave(&atiixp_lock, flags); |
60 | 61 | ||
@@ -74,21 +75,22 @@ static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
74 | 75 | ||
75 | /** | 76 | /** |
76 | * atiixp_set_dma_mode - set host controller for DMA mode | 77 | * atiixp_set_dma_mode - set host controller for DMA mode |
78 | * @hwif: port | ||
77 | * @drive: drive | 79 | * @drive: drive |
78 | * @speed: DMA mode | ||
79 | * | 80 | * |
80 | * Set a ATIIXP host controller to the desired DMA mode. This involves | 81 | * Set a ATIIXP host controller to the desired DMA mode. This involves |
81 | * programming the right timing data into the PCI configuration space. | 82 | * programming the right timing data into the PCI configuration space. |
82 | */ | 83 | */ |
83 | 84 | ||
84 | static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) | 85 | static void atiixp_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
85 | { | 86 | { |
86 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 87 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
87 | unsigned long flags; | 88 | unsigned long flags; |
88 | int timing_shift = (drive->dn ^ 1) * 8; | 89 | int timing_shift = (drive->dn ^ 1) * 8; |
89 | u32 tmp32; | 90 | u32 tmp32; |
90 | u16 tmp16; | 91 | u16 tmp16; |
91 | u16 udma_ctl = 0; | 92 | u16 udma_ctl = 0; |
93 | const u8 speed = drive->dma_mode; | ||
92 | 94 | ||
93 | spin_lock_irqsave(&atiixp_lock, flags); | 95 | spin_lock_irqsave(&atiixp_lock, flags); |
94 | 96 | ||
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c index 58121bd6c115..b26c23416fa7 100644 --- a/drivers/ide/au1xxx-ide.c +++ b/drivers/ide/au1xxx-ide.c | |||
@@ -56,8 +56,8 @@ static inline void auide_insw(unsigned long port, void *addr, u32 count) | |||
56 | chan_tab_t *ctp; | 56 | chan_tab_t *ctp; |
57 | au1x_ddma_desc_t *dp; | 57 | au1x_ddma_desc_t *dp; |
58 | 58 | ||
59 | if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1, | 59 | if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, virt_to_phys(addr), |
60 | DDMA_FLAGS_NOIE)) { | 60 | count << 1, DDMA_FLAGS_NOIE)) { |
61 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); | 61 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
62 | return; | 62 | return; |
63 | } | 63 | } |
@@ -74,8 +74,8 @@ static inline void auide_outsw(unsigned long port, void *addr, u32 count) | |||
74 | chan_tab_t *ctp; | 74 | chan_tab_t *ctp; |
75 | au1x_ddma_desc_t *dp; | 75 | au1x_ddma_desc_t *dp; |
76 | 76 | ||
77 | if(!put_source_flags(ahwif->tx_chan, (void*)addr, | 77 | if (!au1xxx_dbdma_put_source(ahwif->tx_chan, virt_to_phys(addr), |
78 | count << 1, DDMA_FLAGS_NOIE)) { | 78 | count << 1, DDMA_FLAGS_NOIE)) { |
79 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); | 79 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
80 | return; | 80 | return; |
81 | } | 81 | } |
@@ -99,12 +99,11 @@ static void au1xxx_output_data(ide_drive_t *drive, struct ide_cmd *cmd, | |||
99 | } | 99 | } |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | static void au1xxx_set_pio_mode(ide_drive_t *drive, const u8 pio) | 102 | static void au1xxx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
103 | { | 103 | { |
104 | int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2); | 104 | int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2); |
105 | 105 | ||
106 | /* set pio mode! */ | 106 | switch (drive->pio_mode - XFER_PIO_0) { |
107 | switch(pio) { | ||
108 | case 0: | 107 | case 0: |
109 | mem_sttime = SBC_IDE_TIMING(PIO0); | 108 | mem_sttime = SBC_IDE_TIMING(PIO0); |
110 | 109 | ||
@@ -161,11 +160,11 @@ static void au1xxx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
161 | au_writel(mem_stcfg,MEM_STCFG2); | 160 | au_writel(mem_stcfg,MEM_STCFG2); |
162 | } | 161 | } |
163 | 162 | ||
164 | static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed) | 163 | static void auide_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
165 | { | 164 | { |
166 | int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2); | 165 | int mem_sttime = 0, mem_stcfg = au_readl(MEM_STCFG2); |
167 | 166 | ||
168 | switch(speed) { | 167 | switch (drive->dma_mode) { |
169 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 168 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
170 | case XFER_MW_DMA_2: | 169 | case XFER_MW_DMA_2: |
171 | mem_sttime = SBC_IDE_TIMING(MDMA2); | 170 | mem_sttime = SBC_IDE_TIMING(MDMA2); |
@@ -246,17 +245,14 @@ static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd) | |||
246 | flags = DDMA_FLAGS_NOIE; | 245 | flags = DDMA_FLAGS_NOIE; |
247 | 246 | ||
248 | if (iswrite) { | 247 | if (iswrite) { |
249 | if(!put_source_flags(ahwif->tx_chan, | 248 | if (!au1xxx_dbdma_put_source(ahwif->tx_chan, |
250 | (void*) sg_virt(sg), | 249 | sg_phys(sg), tc, flags)) { |
251 | tc, flags)) { | ||
252 | printk(KERN_ERR "%s failed %d\n", | 250 | printk(KERN_ERR "%s failed %d\n", |
253 | __func__, __LINE__); | 251 | __func__, __LINE__); |
254 | } | 252 | } |
255 | } else | 253 | } else { |
256 | { | 254 | if (!au1xxx_dbdma_put_dest(ahwif->rx_chan, |
257 | if(!put_dest_flags(ahwif->rx_chan, | 255 | sg_phys(sg), tc, flags)) { |
258 | (void*) sg_virt(sg), | ||
259 | tc, flags)) { | ||
260 | printk(KERN_ERR "%s failed %d\n", | 256 | printk(KERN_ERR "%s failed %d\n", |
261 | __func__, __LINE__); | 257 | __func__, __LINE__); |
262 | } | 258 | } |
@@ -300,8 +296,8 @@ static int auide_dma_test_irq(ide_drive_t *drive) | |||
300 | */ | 296 | */ |
301 | drive->waiting_for_dma++; | 297 | drive->waiting_for_dma++; |
302 | if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) { | 298 | if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) { |
303 | printk(KERN_WARNING "%s: timeout waiting for ddma to \ | 299 | printk(KERN_WARNING "%s: timeout waiting for ddma to complete\n", |
304 | complete\n", drive->name); | 300 | drive->name); |
305 | return 1; | 301 | return 1; |
306 | } | 302 | } |
307 | udelay(10); | 303 | udelay(10); |
@@ -532,14 +528,13 @@ static int au_ide_probe(struct platform_device *dev) | |||
532 | goto out; | 528 | goto out; |
533 | } | 529 | } |
534 | 530 | ||
535 | if (!request_mem_region(res->start, res->end - res->start + 1, | 531 | if (!request_mem_region(res->start, resource_size(res), dev->name)) { |
536 | dev->name)) { | ||
537 | pr_debug("%s: request_mem_region failed\n", DRV_NAME); | 532 | pr_debug("%s: request_mem_region failed\n", DRV_NAME); |
538 | ret = -EBUSY; | 533 | ret = -EBUSY; |
539 | goto out; | 534 | goto out; |
540 | } | 535 | } |
541 | 536 | ||
542 | ahwif->regbase = (u32)ioremap(res->start, res->end - res->start + 1); | 537 | ahwif->regbase = (u32)ioremap(res->start, resource_size(res)); |
543 | if (ahwif->regbase == 0) { | 538 | if (ahwif->regbase == 0) { |
544 | ret = -ENOMEM; | 539 | ret = -ENOMEM; |
545 | goto out; | 540 | goto out; |
@@ -575,7 +570,7 @@ static int au_ide_remove(struct platform_device *dev) | |||
575 | iounmap((void *)ahwif->regbase); | 570 | iounmap((void *)ahwif->regbase); |
576 | 571 | ||
577 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 572 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
578 | release_mem_region(res->start, res->end - res->start + 1); | 573 | release_mem_region(res->start, resource_size(res)); |
579 | 574 | ||
580 | return 0; | 575 | return 0; |
581 | } | 576 | } |
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c index 1a32d62ed86b..d2b8b272bc27 100644 --- a/drivers/ide/cmd640.c +++ b/drivers/ide/cmd640.c | |||
@@ -572,9 +572,10 @@ static void cmd640_set_mode(ide_drive_t *drive, unsigned int index, | |||
572 | program_drive_counts(drive, index); | 572 | program_drive_counts(drive, index); |
573 | } | 573 | } |
574 | 574 | ||
575 | static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | 575 | static void cmd640_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
576 | { | 576 | { |
577 | unsigned int index = 0, cycle_time; | 577 | unsigned int index = 0, cycle_time; |
578 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
578 | u8 b; | 579 | u8 b; |
579 | 580 | ||
580 | switch (pio) { | 581 | switch (pio) { |
@@ -605,7 +606,7 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
605 | } | 606 | } |
606 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 607 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
607 | 608 | ||
608 | static void cmd640_init_dev(ide_drive_t *drive) | 609 | static void __init cmd640_init_dev(ide_drive_t *drive) |
609 | { | 610 | { |
610 | unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1); | 611 | unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1); |
611 | 612 | ||
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index ca0c46f6580a..5f80312e636b 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * Copyright (C) 1998 David S. Miller (davem@redhat.com) | 7 | * Copyright (C) 1998 David S. Miller (davem@redhat.com) |
8 | * | 8 | * |
9 | * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> | 9 | * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> |
10 | * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz | ||
10 | * Copyright (C) 2007,2009 MontaVista Software, Inc. <source@mvista.com> | 11 | * Copyright (C) 2007,2009 MontaVista Software, Inc. <source@mvista.com> |
11 | */ | 12 | */ |
12 | 13 | ||
@@ -20,14 +21,6 @@ | |||
20 | 21 | ||
21 | #define DRV_NAME "cmd64x" | 22 | #define DRV_NAME "cmd64x" |
22 | 23 | ||
23 | #define CMD_DEBUG 0 | ||
24 | |||
25 | #if CMD_DEBUG | ||
26 | #define cmdprintk(x...) printk(x) | ||
27 | #else | ||
28 | #define cmdprintk(x...) | ||
29 | #endif | ||
30 | |||
31 | /* | 24 | /* |
32 | * CMD64x specific registers definition. | 25 | * CMD64x specific registers definition. |
33 | */ | 26 | */ |
@@ -58,79 +51,42 @@ | |||
58 | #define UDIDETCR1 0x7B | 51 | #define UDIDETCR1 0x7B |
59 | #define DTPR1 0x7C | 52 | #define DTPR1 0x7C |
60 | 53 | ||
61 | static u8 quantize_timing(int timing, int quant) | 54 | static void cmd64x_program_timings(ide_drive_t *drive, u8 mode) |
62 | { | ||
63 | return (timing + quant - 1) / quant; | ||
64 | } | ||
65 | |||
66 | /* | ||
67 | * This routine calculates active/recovery counts and then writes them into | ||
68 | * the chipset registers. | ||
69 | */ | ||
70 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) | ||
71 | { | 55 | { |
56 | ide_hwif_t *hwif = drive->hwif; | ||
72 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 57 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
73 | int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : 33); | 58 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
74 | u8 cycle_count, active_count, recovery_count, drwtim; | 59 | const unsigned long T = 1000000 / bus_speed; |
75 | static const u8 recovery_values[] = | 60 | static const u8 recovery_values[] = |
76 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; | 61 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; |
62 | static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; | ||
63 | static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; | ||
77 | static const u8 drwtim_regs[4] = {DRWTIM0, DRWTIM1, DRWTIM2, DRWTIM3}; | 64 | static const u8 drwtim_regs[4] = {DRWTIM0, DRWTIM1, DRWTIM2, DRWTIM3}; |
65 | struct ide_timing t; | ||
66 | u8 arttim = 0; | ||
78 | 67 | ||
79 | cmdprintk("program_cycle_times parameters: total=%d, active=%d\n", | 68 | ide_timing_compute(drive, mode, &t, T, 0); |
80 | cycle_time, active_time); | ||
81 | |||
82 | cycle_count = quantize_timing( cycle_time, clock_time); | ||
83 | active_count = quantize_timing(active_time, clock_time); | ||
84 | recovery_count = cycle_count - active_count; | ||
85 | 69 | ||
86 | /* | 70 | /* |
87 | * In case we've got too long recovery phase, try to lengthen | 71 | * In case we've got too long recovery phase, try to lengthen |
88 | * the active phase | 72 | * the active phase |
89 | */ | 73 | */ |
90 | if (recovery_count > 16) { | 74 | if (t.recover > 16) { |
91 | active_count += recovery_count - 16; | 75 | t.active += t.recover - 16; |
92 | recovery_count = 16; | 76 | t.recover = 16; |
93 | } | 77 | } |
94 | if (active_count > 16) /* shouldn't actually happen... */ | 78 | if (t.active > 16) /* shouldn't actually happen... */ |
95 | active_count = 16; | 79 | t.active = 16; |
96 | |||
97 | cmdprintk("Final counts: total=%d, active=%d, recovery=%d\n", | ||
98 | cycle_count, active_count, recovery_count); | ||
99 | 80 | ||
100 | /* | 81 | /* |
101 | * Convert values to internal chipset representation | 82 | * Convert values to internal chipset representation |
102 | */ | 83 | */ |
103 | recovery_count = recovery_values[recovery_count]; | 84 | t.recover = recovery_values[t.recover]; |
104 | active_count &= 0x0f; | 85 | t.active &= 0x0f; |
105 | 86 | ||
106 | /* Program the active/recovery counts into the DRWTIM register */ | 87 | /* Program the active/recovery counts into the DRWTIM register */ |
107 | drwtim = (active_count << 4) | recovery_count; | 88 | pci_write_config_byte(dev, drwtim_regs[drive->dn], |
108 | (void) pci_write_config_byte(dev, drwtim_regs[drive->dn], drwtim); | 89 | (t.active << 4) | t.recover); |
109 | cmdprintk("Write 0x%02x to reg 0x%x\n", drwtim, drwtim_regs[drive->dn]); | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * This routine writes into the chipset registers | ||
114 | * PIO setup/active/recovery timings. | ||
115 | */ | ||
116 | static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | ||
117 | { | ||
118 | ide_hwif_t *hwif = drive->hwif; | ||
119 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
120 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | ||
121 | unsigned long setup_count; | ||
122 | unsigned int cycle_time; | ||
123 | u8 arttim = 0; | ||
124 | |||
125 | static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; | ||
126 | static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; | ||
127 | |||
128 | cycle_time = ide_pio_cycle_time(drive, pio); | ||
129 | |||
130 | program_cycle_times(drive, cycle_time, t->active); | ||
131 | |||
132 | setup_count = quantize_timing(t->setup, | ||
133 | 1000 / (ide_pci_clk ? ide_pci_clk : 33)); | ||
134 | 90 | ||
135 | /* | 91 | /* |
136 | * The primary channel has individual address setup timing registers | 92 | * The primary channel has individual address setup timing registers |
@@ -141,16 +97,21 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | |||
141 | if (hwif->channel) { | 97 | if (hwif->channel) { |
142 | ide_drive_t *pair = ide_get_pair_dev(drive); | 98 | ide_drive_t *pair = ide_get_pair_dev(drive); |
143 | 99 | ||
144 | ide_set_drivedata(drive, (void *)setup_count); | 100 | if (pair) { |
101 | struct ide_timing tp; | ||
145 | 102 | ||
146 | if (pair) | 103 | ide_timing_compute(pair, pair->pio_mode, &tp, T, 0); |
147 | setup_count = max_t(u8, setup_count, | 104 | ide_timing_merge(&t, &tp, &t, IDE_TIMING_SETUP); |
148 | (unsigned long)ide_get_drivedata(pair)); | 105 | if (pair->dma_mode) { |
106 | ide_timing_compute(pair, pair->dma_mode, | ||
107 | &tp, T, 0); | ||
108 | ide_timing_merge(&tp, &t, &t, IDE_TIMING_SETUP); | ||
109 | } | ||
110 | } | ||
149 | } | 111 | } |
150 | 112 | ||
151 | if (setup_count > 5) /* shouldn't actually happen... */ | 113 | if (t.setup > 5) /* shouldn't actually happen... */ |
152 | setup_count = 5; | 114 | t.setup = 5; |
153 | cmdprintk("Final address setup count: %d\n", setup_count); | ||
154 | 115 | ||
155 | /* | 116 | /* |
156 | * Program the address setup clocks into the ARTTIM registers. | 117 | * Program the address setup clocks into the ARTTIM registers. |
@@ -160,9 +121,8 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | |||
160 | if (hwif->channel) | 121 | if (hwif->channel) |
161 | arttim &= ~ARTTIM23_INTR_CH1; | 122 | arttim &= ~ARTTIM23_INTR_CH1; |
162 | arttim &= ~0xc0; | 123 | arttim &= ~0xc0; |
163 | arttim |= setup_values[setup_count]; | 124 | arttim |= setup_values[t.setup]; |
164 | (void) pci_write_config_byte(dev, arttim_regs[drive->dn], arttim); | 125 | (void) pci_write_config_byte(dev, arttim_regs[drive->dn], arttim); |
165 | cmdprintk("Write 0x%02x to reg 0x%x\n", arttim, arttim_regs[drive->dn]); | ||
166 | } | 126 | } |
167 | 127 | ||
168 | /* | 128 | /* |
@@ -170,8 +130,10 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | |||
170 | * Special cases are 8: prefetch off, 9: prefetch on (both never worked) | 130 | * Special cases are 8: prefetch off, 9: prefetch on (both never worked) |
171 | */ | 131 | */ |
172 | 132 | ||
173 | static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio) | 133 | static void cmd64x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
174 | { | 134 | { |
135 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
136 | |||
175 | /* | 137 | /* |
176 | * Filter out the prefetch control values | 138 | * Filter out the prefetch control values |
177 | * to prevent PIO5 from being programmed | 139 | * to prevent PIO5 from being programmed |
@@ -179,20 +141,18 @@ static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
179 | if (pio == 8 || pio == 9) | 141 | if (pio == 8 || pio == 9) |
180 | return; | 142 | return; |
181 | 143 | ||
182 | cmd64x_tune_pio(drive, pio); | 144 | cmd64x_program_timings(drive, XFER_PIO_0 + pio); |
183 | } | 145 | } |
184 | 146 | ||
185 | static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | 147 | static void cmd64x_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
186 | { | 148 | { |
187 | ide_hwif_t *hwif = drive->hwif; | ||
188 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 149 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
189 | u8 unit = drive->dn & 0x01; | 150 | u8 unit = drive->dn & 0x01; |
190 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; | 151 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; |
152 | const u8 speed = drive->dma_mode; | ||
191 | 153 | ||
192 | if (speed >= XFER_SW_DMA_0) { | 154 | pci_read_config_byte(dev, pciU, ®U); |
193 | (void) pci_read_config_byte(dev, pciU, ®U); | 155 | regU &= ~(unit ? 0xCA : 0x35); |
194 | regU &= ~(unit ? 0xCA : 0x35); | ||
195 | } | ||
196 | 156 | ||
197 | switch(speed) { | 157 | switch(speed) { |
198 | case XFER_UDMA_5: | 158 | case XFER_UDMA_5: |
@@ -214,18 +174,13 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
214 | regU |= unit ? 0xC2 : 0x31; | 174 | regU |= unit ? 0xC2 : 0x31; |
215 | break; | 175 | break; |
216 | case XFER_MW_DMA_2: | 176 | case XFER_MW_DMA_2: |
217 | program_cycle_times(drive, 120, 70); | ||
218 | break; | ||
219 | case XFER_MW_DMA_1: | 177 | case XFER_MW_DMA_1: |
220 | program_cycle_times(drive, 150, 80); | ||
221 | break; | ||
222 | case XFER_MW_DMA_0: | 178 | case XFER_MW_DMA_0: |
223 | program_cycle_times(drive, 480, 215); | 179 | cmd64x_program_timings(drive, speed); |
224 | break; | 180 | break; |
225 | } | 181 | } |
226 | 182 | ||
227 | if (speed >= XFER_SW_DMA_0) | 183 | pci_write_config_byte(dev, pciU, regU); |
228 | (void) pci_write_config_byte(dev, pciU, regU); | ||
229 | } | 184 | } |
230 | 185 | ||
231 | static void cmd648_clear_irq(ide_drive_t *drive) | 186 | static void cmd648_clear_irq(ide_drive_t *drive) |
@@ -488,6 +443,6 @@ static void __exit cmd64x_ide_exit(void) | |||
488 | module_init(cmd64x_ide_init); | 443 | module_init(cmd64x_ide_init); |
489 | module_exit(cmd64x_ide_exit); | 444 | module_exit(cmd64x_ide_exit); |
490 | 445 | ||
491 | MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick"); | 446 | MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick, Bartlomiej Zolnierkiewicz"); |
492 | MODULE_DESCRIPTION("PCI driver module for CMD64x IDE"); | 447 | MODULE_DESCRIPTION("PCI driver module for CMD64x IDE"); |
493 | MODULE_LICENSE("GPL"); | 448 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c index 09f98ed0731f..2c1e5f7cd261 100644 --- a/drivers/ide/cs5520.c +++ b/drivers/ide/cs5520.c | |||
@@ -57,11 +57,11 @@ static struct pio_clocks cs5520_pio_clocks[]={ | |||
57 | {1, 2, 1} | 57 | {1, 2, 1} |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) | 60 | static void cs5520_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
61 | { | 61 | { |
62 | ide_hwif_t *hwif = drive->hwif; | ||
63 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 62 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
64 | int controller = drive->dn > 1 ? 1 : 0; | 63 | int controller = drive->dn > 1 ? 1 : 0; |
64 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
65 | 65 | ||
66 | /* 8bit CAT/CRT - 8bit command timing for channel */ | 66 | /* 8bit CAT/CRT - 8bit command timing for channel */ |
67 | pci_write_config_byte(pdev, 0x62 + controller, | 67 | pci_write_config_byte(pdev, 0x62 + controller, |
@@ -81,11 +81,12 @@ static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
81 | (cs5520_pio_clocks[pio].assert)); | 81 | (cs5520_pio_clocks[pio].assert)); |
82 | } | 82 | } |
83 | 83 | ||
84 | static void cs5520_set_dma_mode(ide_drive_t *drive, const u8 speed) | 84 | static void cs5520_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
85 | { | 85 | { |
86 | printk(KERN_ERR "cs55x0: bad ide timing.\n"); | 86 | printk(KERN_ERR "cs55x0: bad ide timing.\n"); |
87 | 87 | ||
88 | cs5520_set_pio_mode(drive, 0); | 88 | drive->pio_mode = XFER_PIO_0 + 0; |
89 | cs5520_set_pio_mode(hwif, drive); | ||
89 | } | 90 | } |
90 | 91 | ||
91 | static const struct ide_port_ops cs5520_port_ops = { | 92 | static const struct ide_port_ops cs5520_port_ops = { |
diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c index 40bf05eddf6e..4dc4eb92b076 100644 --- a/drivers/ide/cs5530.c +++ b/drivers/ide/cs5530.c | |||
@@ -41,8 +41,8 @@ static unsigned int cs5530_pio_timings[2][5] = { | |||
41 | 41 | ||
42 | /** | 42 | /** |
43 | * cs5530_set_pio_mode - set host controller for PIO mode | 43 | * cs5530_set_pio_mode - set host controller for PIO mode |
44 | * @hwif: port | ||
44 | * @drive: drive | 45 | * @drive: drive |
45 | * @pio: PIO mode number | ||
46 | * | 46 | * |
47 | * Handles setting of PIO mode for the chipset. | 47 | * Handles setting of PIO mode for the chipset. |
48 | * | 48 | * |
@@ -50,10 +50,11 @@ static unsigned int cs5530_pio_timings[2][5] = { | |||
50 | * will have valid default PIO timings set up before we get here. | 50 | * will have valid default PIO timings set up before we get here. |
51 | */ | 51 | */ |
52 | 52 | ||
53 | static void cs5530_set_pio_mode(ide_drive_t *drive, const u8 pio) | 53 | static void cs5530_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
54 | { | 54 | { |
55 | unsigned long basereg = CS5530_BASEREG(drive->hwif); | 55 | unsigned long basereg = CS5530_BASEREG(hwif); |
56 | unsigned int format = (inl(basereg + 4) >> 31) & 1; | 56 | unsigned int format = (inl(basereg + 4) >> 31) & 1; |
57 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
57 | 58 | ||
58 | outl(cs5530_pio_timings[format][pio], basereg + ((drive->dn & 1)<<3)); | 59 | outl(cs5530_pio_timings[format][pio], basereg + ((drive->dn & 1)<<3)); |
59 | } | 60 | } |
@@ -99,12 +100,12 @@ out: | |||
99 | return mask; | 100 | return mask; |
100 | } | 101 | } |
101 | 102 | ||
102 | static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) | 103 | static void cs5530_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
103 | { | 104 | { |
104 | unsigned long basereg; | 105 | unsigned long basereg; |
105 | unsigned int reg, timings = 0; | 106 | unsigned int reg, timings = 0; |
106 | 107 | ||
107 | switch (mode) { | 108 | switch (drive->dma_mode) { |
108 | case XFER_UDMA_0: timings = 0x00921250; break; | 109 | case XFER_UDMA_0: timings = 0x00921250; break; |
109 | case XFER_UDMA_1: timings = 0x00911140; break; | 110 | case XFER_UDMA_1: timings = 0x00911140; break; |
110 | case XFER_UDMA_2: timings = 0x00911030; break; | 111 | case XFER_UDMA_2: timings = 0x00911030; break; |
@@ -112,7 +113,7 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
112 | case XFER_MW_DMA_1: timings = 0x00012121; break; | 113 | case XFER_MW_DMA_1: timings = 0x00012121; break; |
113 | case XFER_MW_DMA_2: timings = 0x00002020; break; | 114 | case XFER_MW_DMA_2: timings = 0x00002020; break; |
114 | } | 115 | } |
115 | basereg = CS5530_BASEREG(drive->hwif); | 116 | basereg = CS5530_BASEREG(hwif); |
116 | reg = inl(basereg + 4); /* get drive0 config register */ | 117 | reg = inl(basereg + 4); /* get drive0 config register */ |
117 | timings |= reg & 0x80000000; /* preserve PIO format bit */ | 118 | timings |= reg & 0x80000000; /* preserve PIO format bit */ |
118 | if ((drive-> dn & 1) == 0) { /* are we configuring drive0? */ | 119 | if ((drive-> dn & 1) == 0) { /* are we configuring drive0? */ |
diff --git a/drivers/ide/cs5535.c b/drivers/ide/cs5535.c index 983d957a0189..5059fafadf29 100644 --- a/drivers/ide/cs5535.c +++ b/drivers/ide/cs5535.c | |||
@@ -86,7 +86,7 @@ static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) | |||
86 | cmd = pioa = speed - XFER_PIO_0; | 86 | cmd = pioa = speed - XFER_PIO_0; |
87 | 87 | ||
88 | if (pair) { | 88 | if (pair) { |
89 | u8 piob = ide_get_best_pio_mode(pair, 255, 4); | 89 | u8 piob = pair->pio_mode - XFER_PIO_0; |
90 | 90 | ||
91 | if (piob < cmd) | 91 | if (piob < cmd) |
92 | cmd = piob; | 92 | cmd = piob; |
@@ -129,28 +129,28 @@ static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) | |||
129 | 129 | ||
130 | /** | 130 | /** |
131 | * cs5535_set_dma_mode - set host controller for DMA mode | 131 | * cs5535_set_dma_mode - set host controller for DMA mode |
132 | * @hwif: port | ||
132 | * @drive: drive | 133 | * @drive: drive |
133 | * @speed: DMA mode | ||
134 | * | 134 | * |
135 | * Programs the chipset for DMA mode. | 135 | * Programs the chipset for DMA mode. |
136 | */ | 136 | */ |
137 | 137 | ||
138 | static void cs5535_set_dma_mode(ide_drive_t *drive, const u8 speed) | 138 | static void cs5535_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
139 | { | 139 | { |
140 | cs5535_set_speed(drive, speed); | 140 | cs5535_set_speed(drive, drive->dma_mode); |
141 | } | 141 | } |
142 | 142 | ||
143 | /** | 143 | /** |
144 | * cs5535_set_pio_mode - set host controller for PIO mode | 144 | * cs5535_set_pio_mode - set host controller for PIO mode |
145 | * @hwif: port | ||
145 | * @drive: drive | 146 | * @drive: drive |
146 | * @pio: PIO mode number | ||
147 | * | 147 | * |
148 | * A callback from the upper layers for PIO-only tuning. | 148 | * A callback from the upper layers for PIO-only tuning. |
149 | */ | 149 | */ |
150 | 150 | ||
151 | static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio) | 151 | static void cs5535_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
152 | { | 152 | { |
153 | cs5535_set_speed(drive, XFER_PIO_0 + pio); | 153 | cs5535_set_speed(drive, drive->pio_mode); |
154 | } | 154 | } |
155 | 155 | ||
156 | static u8 cs5535_cable_detect(ide_hwif_t *hwif) | 156 | static u8 cs5535_cable_detect(ide_hwif_t *hwif) |
@@ -187,6 +187,7 @@ static int __devinit cs5535_init_one(struct pci_dev *dev, | |||
187 | 187 | ||
188 | static const struct pci_device_id cs5535_pci_tbl[] = { | 188 | static const struct pci_device_id cs5535_pci_tbl[] = { |
189 | { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_CS5535_IDE), 0 }, | 189 | { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_CS5535_IDE), 0 }, |
190 | { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5535_IDE), }, | ||
190 | { 0, }, | 191 | { 0, }, |
191 | }; | 192 | }; |
192 | 193 | ||
diff --git a/drivers/ide/cs5536.c b/drivers/ide/cs5536.c index 9623b852c616..24214ab60ac0 100644 --- a/drivers/ide/cs5536.c +++ b/drivers/ide/cs5536.c | |||
@@ -125,11 +125,11 @@ static u8 cs5536_cable_detect(ide_hwif_t *hwif) | |||
125 | 125 | ||
126 | /** | 126 | /** |
127 | * cs5536_set_pio_mode - PIO timing setup | 127 | * cs5536_set_pio_mode - PIO timing setup |
128 | * @hwif: ATA port | ||
128 | * @drive: ATA device | 129 | * @drive: ATA device |
129 | * @pio: PIO mode number | ||
130 | */ | 130 | */ |
131 | 131 | ||
132 | static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio) | 132 | static void cs5536_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
133 | { | 133 | { |
134 | static const u8 drv_timings[5] = { | 134 | static const u8 drv_timings[5] = { |
135 | 0x98, 0x55, 0x32, 0x21, 0x20, | 135 | 0x98, 0x55, 0x32, 0x21, 0x20, |
@@ -143,15 +143,16 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
143 | 0x99, 0x92, 0x90, 0x22, 0x20, | 143 | 0x99, 0x92, 0x90, 0x22, 0x20, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); | 146 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
147 | ide_drive_t *pair = ide_get_pair_dev(drive); | 147 | ide_drive_t *pair = ide_get_pair_dev(drive); |
148 | int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; | 148 | int cshift = (drive->dn & 1) ? IDE_CAST_D1_SHIFT : IDE_CAST_D0_SHIFT; |
149 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); | 149 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); |
150 | u32 cast; | 150 | u32 cast; |
151 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
151 | u8 cmd_pio = pio; | 152 | u8 cmd_pio = pio; |
152 | 153 | ||
153 | if (pair) | 154 | if (pair) |
154 | cmd_pio = min(pio, ide_get_best_pio_mode(pair, 255, 4)); | 155 | cmd_pio = min_t(u8, pio, pair->pio_mode - XFER_PIO_0); |
155 | 156 | ||
156 | timings &= (IDE_DRV_MASK << 8); | 157 | timings &= (IDE_DRV_MASK << 8); |
157 | timings |= drv_timings[pio]; | 158 | timings |= drv_timings[pio]; |
@@ -172,11 +173,11 @@ static void cs5536_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
172 | 173 | ||
173 | /** | 174 | /** |
174 | * cs5536_set_dma_mode - DMA timing setup | 175 | * cs5536_set_dma_mode - DMA timing setup |
176 | * @hwif: ATA port | ||
175 | * @drive: ATA device | 177 | * @drive: ATA device |
176 | * @mode: DMA mode | ||
177 | */ | 178 | */ |
178 | 179 | ||
179 | static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode) | 180 | static void cs5536_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
180 | { | 181 | { |
181 | static const u8 udma_timings[6] = { | 182 | static const u8 udma_timings[6] = { |
182 | 0xc2, 0xc1, 0xc0, 0xc4, 0xc5, 0xc6, | 183 | 0xc2, 0xc1, 0xc0, 0xc4, 0xc5, 0xc6, |
@@ -186,10 +187,11 @@ static void cs5536_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
186 | 0x67, 0x21, 0x20, | 187 | 0x67, 0x21, 0x20, |
187 | }; | 188 | }; |
188 | 189 | ||
189 | struct pci_dev *pdev = to_pci_dev(drive->hwif->dev); | 190 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
190 | int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT; | 191 | int dshift = (drive->dn & 1) ? IDE_D1_SHIFT : IDE_D0_SHIFT; |
191 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); | 192 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); |
192 | u32 etc; | 193 | u32 etc; |
194 | const u8 mode = drive->dma_mode; | ||
193 | 195 | ||
194 | cs5536_read(pdev, ETC, &etc); | 196 | cs5536_read(pdev, ETC, &etc); |
195 | 197 | ||
diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c index 74fc5401f407..9383f67deae1 100644 --- a/drivers/ide/cy82c693.c +++ b/drivers/ide/cy82c693.c | |||
@@ -1,43 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer | 2 | * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer |
3 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator | 3 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator |
4 | * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz | ||
4 | * | 5 | * |
5 | * CYPRESS CY82C693 chipset IDE controller | 6 | * CYPRESS CY82C693 chipset IDE controller |
6 | * | 7 | * |
7 | * The CY82C693 chipset is used on Digital's PC-Alpha 164SX boards. | 8 | * The CY82C693 chipset is used on Digital's PC-Alpha 164SX boards. |
8 | * Writing the driver was quite simple, since most of the job is | ||
9 | * done by the generic pci-ide support. | ||
10 | * The hard part was finding the CY82C693's datasheet on Cypress's | ||
11 | * web page :-(. But Altavista solved this problem :-). | ||
12 | * | ||
13 | * | ||
14 | * Notes: | ||
15 | * - I recently got a 16.8G IBM DTTA, so I was able to test it with | ||
16 | * a large and fast disk - the results look great, so I'd say the | ||
17 | * driver is working fine :-) | ||
18 | * hdparm -t reports 8.17 MB/sec at about 6% CPU usage for the DTTA | ||
19 | * - this is my first linux driver, so there's probably a lot of room | ||
20 | * for optimizations and bug fixing, so feel free to do it. | ||
21 | * - if using PIO mode it's a good idea to set the PIO mode and | ||
22 | * 32-bit I/O support (if possible), e.g. hdparm -p2 -c1 /dev/hda | ||
23 | * - I had some problems with my IBM DHEA with PIO modes < 2 | ||
24 | * (lost interrupts) ????? | ||
25 | * - first tests with DMA look okay, they seem to work, but there is a | ||
26 | * problem with sound - the BusMaster IDE TimeOut should fixed this | ||
27 | * | ||
28 | * Ancient History: | ||
29 | * AMH@1999-08-24: v0.34 init_cy82c693_chip moved to pci_init_cy82c693 | ||
30 | * ASK@1999-01-23: v0.33 made a few minor code clean ups | ||
31 | * removed DMA clock speed setting by default | ||
32 | * added boot message | ||
33 | * ASK@1998-11-01: v0.32 added support to set BusMaster IDE TimeOut | ||
34 | * added support to set DMA Controller Clock Speed | ||
35 | * ASK@1998-10-31: v0.31 fixed problem with setting to high DMA modes | ||
36 | * on some drives. | ||
37 | * ASK@1998-10-29: v0.3 added support to set DMA modes | ||
38 | * ASK@1998-10-28: v0.2 added support to set PIO modes | ||
39 | * ASK@1998-10-27: v0.1 first version - chipset detection | ||
40 | * | ||
41 | */ | 9 | */ |
42 | 10 | ||
43 | #include <linux/module.h> | 11 | #include <linux/module.h> |
@@ -51,11 +19,6 @@ | |||
51 | #define DRV_NAME "cy82c693" | 19 | #define DRV_NAME "cy82c693" |
52 | 20 | ||
53 | /* | 21 | /* |
54 | * The following are used to debug the driver. | ||
55 | */ | ||
56 | #define CY82C693_DEBUG_INFO 0 | ||
57 | |||
58 | /* | ||
59 | * NOTE: the value for busmaster timeout is tricky and I got it by | 22 | * NOTE: the value for busmaster timeout is tricky and I got it by |
60 | * trial and error! By using a to low value will cause DMA timeouts | 23 | * trial and error! By using a to low value will cause DMA timeouts |
61 | * and drop IDE performance, and by using a to high value will cause | 24 | * and drop IDE performance, and by using a to high value will cause |
@@ -86,87 +49,13 @@ | |||
86 | #define CY82_INDEX_CHANNEL1 0x31 | 49 | #define CY82_INDEX_CHANNEL1 0x31 |
87 | #define CY82_INDEX_TIMEOUT 0x32 | 50 | #define CY82_INDEX_TIMEOUT 0x32 |
88 | 51 | ||
89 | /* the min and max PCI bus speed in MHz - from datasheet */ | ||
90 | #define CY82C963_MIN_BUS_SPEED 25 | ||
91 | #define CY82C963_MAX_BUS_SPEED 33 | ||
92 | |||
93 | /* the struct for the PIO mode timings */ | ||
94 | typedef struct pio_clocks_s { | ||
95 | u8 address_time; /* Address setup (clocks) */ | ||
96 | u8 time_16r; /* clocks for 16bit IOR (0xF0=Active/data, 0x0F=Recovery) */ | ||
97 | u8 time_16w; /* clocks for 16bit IOW (0xF0=Active/data, 0x0F=Recovery) */ | ||
98 | u8 time_8; /* clocks for 8bit (0xF0=Active/data, 0x0F=Recovery) */ | ||
99 | } pio_clocks_t; | ||
100 | |||
101 | /* | ||
102 | * calc clocks using bus_speed | ||
103 | * returns (rounded up) time in bus clocks for time in ns | ||
104 | */ | ||
105 | static int calc_clk(int time, int bus_speed) | ||
106 | { | ||
107 | int clocks; | ||
108 | |||
109 | clocks = (time*bus_speed+999)/1000 - 1; | ||
110 | |||
111 | if (clocks < 0) | ||
112 | clocks = 0; | ||
113 | |||
114 | if (clocks > 0x0F) | ||
115 | clocks = 0x0F; | ||
116 | |||
117 | return clocks; | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | * compute the values for the clock registers for PIO | ||
122 | * mode and pci_clk [MHz] speed | ||
123 | * | ||
124 | * NOTE: for mode 0,1 and 2 drives 8-bit IDE command control registers are used | ||
125 | * for mode 3 and 4 drives 8 and 16-bit timings are the same | ||
126 | * | ||
127 | */ | ||
128 | static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) | ||
129 | { | ||
130 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | ||
131 | int clk1, clk2; | ||
132 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; | ||
133 | |||
134 | /* we don't check against CY82C693's min and max speed, | ||
135 | * so you can play with the idebus=xx parameter | ||
136 | */ | ||
137 | |||
138 | /* let's calc the address setup time clocks */ | ||
139 | p_pclk->address_time = (u8)calc_clk(t->setup, bus_speed); | ||
140 | |||
141 | /* let's calc the active and recovery time clocks */ | ||
142 | clk1 = calc_clk(t->active, bus_speed); | ||
143 | |||
144 | /* calc recovery timing */ | ||
145 | clk2 = t->cycle - t->active - t->setup; | ||
146 | |||
147 | clk2 = calc_clk(clk2, bus_speed); | ||
148 | |||
149 | clk1 = (clk1<<4)|clk2; /* combine active and recovery clocks */ | ||
150 | |||
151 | /* note: we use the same values for 16bit IOR and IOW | ||
152 | * those are all the same, since I don't have other | ||
153 | * timings than those from ide-lib.c | ||
154 | */ | ||
155 | |||
156 | p_pclk->time_16r = (u8)clk1; | ||
157 | p_pclk->time_16w = (u8)clk1; | ||
158 | |||
159 | /* what are good values for 8bit ?? */ | ||
160 | p_pclk->time_8 = (u8)clk1; | ||
161 | } | ||
162 | |||
163 | /* | 52 | /* |
164 | * set DMA mode a specific channel for CY82C693 | 53 | * set DMA mode a specific channel for CY82C693 |
165 | */ | 54 | */ |
166 | 55 | ||
167 | static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | 56 | static void cy82c693_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
168 | { | 57 | { |
169 | ide_hwif_t *hwif = drive->hwif; | 58 | const u8 mode = drive->dma_mode; |
170 | u8 single = (mode & 0x10) >> 4, index = 0, data = 0; | 59 | u8 single = (mode & 0x10) >> 4, index = 0, data = 0; |
171 | 60 | ||
172 | index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0; | 61 | index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0; |
@@ -176,11 +65,6 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
176 | outb(index, CY82_INDEX_PORT); | 65 | outb(index, CY82_INDEX_PORT); |
177 | outb(data, CY82_DATA_PORT); | 66 | outb(data, CY82_DATA_PORT); |
178 | 67 | ||
179 | #if CY82C693_DEBUG_INFO | ||
180 | printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n", | ||
181 | drive->name, hwif->channel, drive->dn & 1, mode & 3, single); | ||
182 | #endif /* CY82C693_DEBUG_INFO */ | ||
183 | |||
184 | /* | 68 | /* |
185 | * note: below we set the value for Bus Master IDE TimeOut Register | 69 | * note: below we set the value for Bus Master IDE TimeOut Register |
186 | * I'm not absolutly sure what this does, but it solved my problem | 70 | * I'm not absolutly sure what this does, but it solved my problem |
@@ -194,19 +78,16 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
194 | data = BUSMASTER_TIMEOUT; | 78 | data = BUSMASTER_TIMEOUT; |
195 | outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT); | 79 | outb(CY82_INDEX_TIMEOUT, CY82_INDEX_PORT); |
196 | outb(data, CY82_DATA_PORT); | 80 | outb(data, CY82_DATA_PORT); |
197 | |||
198 | #if CY82C693_DEBUG_INFO | ||
199 | printk(KERN_INFO "%s: Set IDE Bus Master TimeOut Register to 0x%X\n", | ||
200 | drive->name, data); | ||
201 | #endif /* CY82C693_DEBUG_INFO */ | ||
202 | } | 81 | } |
203 | 82 | ||
204 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | 83 | static void cy82c693_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
205 | { | 84 | { |
206 | ide_hwif_t *hwif = drive->hwif; | ||
207 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 85 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
208 | pio_clocks_t pclk; | 86 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
87 | const unsigned long T = 1000000 / bus_speed; | ||
209 | unsigned int addrCtrl; | 88 | unsigned int addrCtrl; |
89 | struct ide_timing t; | ||
90 | u8 time_16, time_8; | ||
210 | 91 | ||
211 | /* select primary or secondary channel */ | 92 | /* select primary or secondary channel */ |
212 | if (hwif->index > 0) { /* drive is on the secondary channel */ | 93 | if (hwif->index > 0) { /* drive is on the secondary channel */ |
@@ -219,8 +100,12 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
219 | } | 100 | } |
220 | } | 101 | } |
221 | 102 | ||
222 | /* let's calc the values for this PIO mode */ | 103 | ide_timing_compute(drive, drive->pio_mode, &t, T, 1); |
223 | compute_clocks(pio, &pclk); | 104 | |
105 | time_16 = clamp_val(t.recover - 1, 0, 15) | | ||
106 | (clamp_val(t.active - 1, 0, 15) << 4); | ||
107 | time_8 = clamp_val(t.act8b - 1, 0, 15) | | ||
108 | (clamp_val(t.rec8b - 1, 0, 15) << 4); | ||
224 | 109 | ||
225 | /* now let's write the clocks registers */ | 110 | /* now let's write the clocks registers */ |
226 | if ((drive->dn & 1) == 0) { | 111 | if ((drive->dn & 1) == 0) { |
@@ -232,15 +117,13 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
232 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); | 117 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
233 | 118 | ||
234 | addrCtrl &= (~0xF); | 119 | addrCtrl &= (~0xF); |
235 | addrCtrl |= (unsigned int)pclk.address_time; | 120 | addrCtrl |= clamp_val(t.setup - 1, 0, 15); |
236 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); | 121 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); |
237 | 122 | ||
238 | /* now let's set the remaining registers */ | 123 | /* now let's set the remaining registers */ |
239 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, pclk.time_16r); | 124 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOR, time_16); |
240 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, pclk.time_16w); | 125 | pci_write_config_byte(dev, CY82_IDE_MASTER_IOW, time_16); |
241 | pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, pclk.time_8); | 126 | pci_write_config_byte(dev, CY82_IDE_MASTER_8BIT, time_8); |
242 | |||
243 | addrCtrl &= 0xF; | ||
244 | } else { | 127 | } else { |
245 | /* | 128 | /* |
246 | * set slave drive | 129 | * set slave drive |
@@ -250,24 +133,14 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
250 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); | 133 | pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); |
251 | 134 | ||
252 | addrCtrl &= (~0xF0); | 135 | addrCtrl &= (~0xF0); |
253 | addrCtrl |= ((unsigned int)pclk.address_time<<4); | 136 | addrCtrl |= (clamp_val(t.setup - 1, 0, 15) << 4); |
254 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); | 137 | pci_write_config_dword(dev, CY82_IDE_ADDRSETUP, addrCtrl); |
255 | 138 | ||
256 | /* now let's set the remaining registers */ | 139 | /* now let's set the remaining registers */ |
257 | pci_write_config_byte(dev, CY82_IDE_SLAVE_IOR, pclk.time_16r); | 140 | pci_write_config_byte(dev, CY82_IDE_SLAVE_IOR, time_16); |
258 | pci_write_config_byte(dev, CY82_IDE_SLAVE_IOW, pclk.time_16w); | 141 | pci_write_config_byte(dev, CY82_IDE_SLAVE_IOW, time_16); |
259 | pci_write_config_byte(dev, CY82_IDE_SLAVE_8BIT, pclk.time_8); | 142 | pci_write_config_byte(dev, CY82_IDE_SLAVE_8BIT, time_8); |
260 | |||
261 | addrCtrl >>= 4; | ||
262 | addrCtrl &= 0xF; | ||
263 | } | 143 | } |
264 | |||
265 | #if CY82C693_DEBUG_INFO | ||
266 | printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " | ||
267 | "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n", | ||
268 | drive->name, hwif->channel, drive->dn & 1, | ||
269 | addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); | ||
270 | #endif /* CY82C693_DEBUG_INFO */ | ||
271 | } | 144 | } |
272 | 145 | ||
273 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | 146 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
@@ -352,6 +225,6 @@ static void __exit cy82c693_ide_exit(void) | |||
352 | module_init(cy82c693_ide_init); | 225 | module_init(cy82c693_ide_init); |
353 | module_exit(cy82c693_ide_exit); | 226 | module_exit(cy82c693_ide_exit); |
354 | 227 | ||
355 | MODULE_AUTHOR("Andreas Krebs, Andre Hedrick"); | 228 | MODULE_AUTHOR("Andreas Krebs, Andre Hedrick, Bartlomiej Zolnierkiewicz"); |
356 | MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE"); | 229 | MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE"); |
357 | MODULE_LICENSE("GPL"); | 230 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/dtc2278.c b/drivers/ide/dtc2278.c index c6b138122981..6929f7fce93a 100644 --- a/drivers/ide/dtc2278.c +++ b/drivers/ide/dtc2278.c | |||
@@ -68,11 +68,11 @@ static void sub22 (char b, char c) | |||
68 | 68 | ||
69 | static DEFINE_SPINLOCK(dtc2278_lock); | 69 | static DEFINE_SPINLOCK(dtc2278_lock); |
70 | 70 | ||
71 | static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) | 71 | static void dtc2278_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
72 | { | 72 | { |
73 | unsigned long flags; | 73 | unsigned long flags; |
74 | 74 | ||
75 | if (pio >= 3) { | 75 | if (drive->pio_mode >= XFER_PIO_3) { |
76 | spin_lock_irqsave(&dtc2278_lock, flags); | 76 | spin_lock_irqsave(&dtc2278_lock, flags); |
77 | /* | 77 | /* |
78 | * This enables PIO mode4 (3?) on the first interface | 78 | * This enables PIO mode4 (3?) on the first interface |
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index 7ce68ef6b904..45163693f737 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c | |||
@@ -128,6 +128,7 @@ | |||
128 | #include <linux/pci.h> | 128 | #include <linux/pci.h> |
129 | #include <linux/init.h> | 129 | #include <linux/init.h> |
130 | #include <linux/ide.h> | 130 | #include <linux/ide.h> |
131 | #include <linux/slab.h> | ||
131 | 132 | ||
132 | #include <asm/uaccess.h> | 133 | #include <asm/uaccess.h> |
133 | #include <asm/io.h> | 134 | #include <asm/io.h> |
@@ -297,68 +298,6 @@ static u32 twenty_five_base_hpt36x[] = { | |||
297 | /* XFER_PIO_0 */ 0xc0d08585 | 298 | /* XFER_PIO_0 */ 0xc0d08585 |
298 | }; | 299 | }; |
299 | 300 | ||
300 | #if 0 | ||
301 | /* These are the timing tables from the HighPoint open source drivers... */ | ||
302 | static u32 thirty_three_base_hpt37x[] = { | ||
303 | /* XFER_UDMA_6 */ 0x12446231, /* 0x12646231 ?? */ | ||
304 | /* XFER_UDMA_5 */ 0x12446231, | ||
305 | /* XFER_UDMA_4 */ 0x12446231, | ||
306 | /* XFER_UDMA_3 */ 0x126c6231, | ||
307 | /* XFER_UDMA_2 */ 0x12486231, | ||
308 | /* XFER_UDMA_1 */ 0x124c6233, | ||
309 | /* XFER_UDMA_0 */ 0x12506297, | ||
310 | |||
311 | /* XFER_MW_DMA_2 */ 0x22406c31, | ||
312 | /* XFER_MW_DMA_1 */ 0x22406c33, | ||
313 | /* XFER_MW_DMA_0 */ 0x22406c97, | ||
314 | |||
315 | /* XFER_PIO_4 */ 0x06414e31, | ||
316 | /* XFER_PIO_3 */ 0x06414e42, | ||
317 | /* XFER_PIO_2 */ 0x06414e53, | ||
318 | /* XFER_PIO_1 */ 0x06814e93, | ||
319 | /* XFER_PIO_0 */ 0x06814ea7 | ||
320 | }; | ||
321 | |||
322 | static u32 fifty_base_hpt37x[] = { | ||
323 | /* XFER_UDMA_6 */ 0x12848242, | ||
324 | /* XFER_UDMA_5 */ 0x12848242, | ||
325 | /* XFER_UDMA_4 */ 0x12ac8242, | ||
326 | /* XFER_UDMA_3 */ 0x128c8242, | ||
327 | /* XFER_UDMA_2 */ 0x120c8242, | ||
328 | /* XFER_UDMA_1 */ 0x12148254, | ||
329 | /* XFER_UDMA_0 */ 0x121882ea, | ||
330 | |||
331 | /* XFER_MW_DMA_2 */ 0x22808242, | ||
332 | /* XFER_MW_DMA_1 */ 0x22808254, | ||
333 | /* XFER_MW_DMA_0 */ 0x228082ea, | ||
334 | |||
335 | /* XFER_PIO_4 */ 0x0a81f442, | ||
336 | /* XFER_PIO_3 */ 0x0a81f443, | ||
337 | /* XFER_PIO_2 */ 0x0a81f454, | ||
338 | /* XFER_PIO_1 */ 0x0ac1f465, | ||
339 | /* XFER_PIO_0 */ 0x0ac1f48a | ||
340 | }; | ||
341 | |||
342 | static u32 sixty_six_base_hpt37x[] = { | ||
343 | /* XFER_UDMA_6 */ 0x1c869c62, | ||
344 | /* XFER_UDMA_5 */ 0x1cae9c62, /* 0x1c8a9c62 */ | ||
345 | /* XFER_UDMA_4 */ 0x1c8a9c62, | ||
346 | /* XFER_UDMA_3 */ 0x1c8e9c62, | ||
347 | /* XFER_UDMA_2 */ 0x1c929c62, | ||
348 | /* XFER_UDMA_1 */ 0x1c9a9c62, | ||
349 | /* XFER_UDMA_0 */ 0x1c829c62, | ||
350 | |||
351 | /* XFER_MW_DMA_2 */ 0x2c829c62, | ||
352 | /* XFER_MW_DMA_1 */ 0x2c829c66, | ||
353 | /* XFER_MW_DMA_0 */ 0x2c829d2e, | ||
354 | |||
355 | /* XFER_PIO_4 */ 0x0c829c62, | ||
356 | /* XFER_PIO_3 */ 0x0c829c84, | ||
357 | /* XFER_PIO_2 */ 0x0c829ca6, | ||
358 | /* XFER_PIO_1 */ 0x0d029d26, | ||
359 | /* XFER_PIO_0 */ 0x0d029d5e | ||
360 | }; | ||
361 | #else | ||
362 | /* | 301 | /* |
363 | * The following are the new timing tables with PIO mode data/taskfile transfer | 302 | * The following are the new timing tables with PIO mode data/taskfile transfer |
364 | * overclocking fixed... | 303 | * overclocking fixed... |
@@ -424,16 +363,13 @@ static u32 sixty_six_base_hpt37x[] = { | |||
424 | /* XFER_PIO_1 */ 0x0d02ff26, | 363 | /* XFER_PIO_1 */ 0x0d02ff26, |
425 | /* XFER_PIO_0 */ 0x0d42ff7f | 364 | /* XFER_PIO_0 */ 0x0d42ff7f |
426 | }; | 365 | }; |
427 | #endif | ||
428 | 366 | ||
429 | #define HPT366_DEBUG_DRIVE_INFO 0 | ||
430 | #define HPT371_ALLOW_ATA133_6 1 | 367 | #define HPT371_ALLOW_ATA133_6 1 |
431 | #define HPT302_ALLOW_ATA133_6 1 | 368 | #define HPT302_ALLOW_ATA133_6 1 |
432 | #define HPT372_ALLOW_ATA133_6 1 | 369 | #define HPT372_ALLOW_ATA133_6 1 |
433 | #define HPT370_ALLOW_ATA100_5 0 | 370 | #define HPT370_ALLOW_ATA100_5 0 |
434 | #define HPT366_ALLOW_ATA66_4 1 | 371 | #define HPT366_ALLOW_ATA66_4 1 |
435 | #define HPT366_ALLOW_ATA66_3 1 | 372 | #define HPT366_ALLOW_ATA66_3 1 |
436 | #define HPT366_MAX_DEVS 8 | ||
437 | 373 | ||
438 | /* Supported ATA clock frequencies */ | 374 | /* Supported ATA clock frequencies */ |
439 | enum ata_clock { | 375 | enum ata_clock { |
@@ -692,14 +628,14 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info) | |||
692 | return info->timings->clock_table[info->clock][i]; | 628 | return info->timings->clock_table[info->clock][i]; |
693 | } | 629 | } |
694 | 630 | ||
695 | static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) | 631 | static void hpt3xx_set_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
696 | { | 632 | { |
697 | ide_hwif_t *hwif = drive->hwif; | ||
698 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 633 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
699 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); | 634 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); |
700 | struct hpt_timings *t = info->timings; | 635 | struct hpt_timings *t = info->timings; |
701 | u8 itr_addr = 0x40 + (drive->dn * 4); | 636 | u8 itr_addr = 0x40 + (drive->dn * 4); |
702 | u32 old_itr = 0; | 637 | u32 old_itr = 0; |
638 | const u8 speed = drive->dma_mode; | ||
703 | u32 new_itr = get_speed_setting(speed, info); | 639 | u32 new_itr = get_speed_setting(speed, info); |
704 | u32 itr_mask = speed < XFER_MW_DMA_0 ? t->pio_mask : | 640 | u32 itr_mask = speed < XFER_MW_DMA_0 ? t->pio_mask : |
705 | (speed < XFER_UDMA_0 ? t->dma_mask : | 641 | (speed < XFER_UDMA_0 ? t->dma_mask : |
@@ -716,9 +652,10 @@ static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) | |||
716 | pci_write_config_dword(dev, itr_addr, new_itr); | 652 | pci_write_config_dword(dev, itr_addr, new_itr); |
717 | } | 653 | } |
718 | 654 | ||
719 | static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | 655 | static void hpt3xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
720 | { | 656 | { |
721 | hpt3xx_set_mode(drive, XFER_PIO_0 + pio); | 657 | drive->dma_mode = drive->pio_mode; |
658 | hpt3xx_set_mode(hwif, drive); | ||
722 | } | 659 | } |
723 | 660 | ||
724 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | 661 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) |
diff --git a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c index aafed8060e17..d81e49680c3f 100644 --- a/drivers/ide/ht6560b.c +++ b/drivers/ide/ht6560b.c | |||
@@ -279,9 +279,10 @@ static void ht_set_prefetch(ide_drive_t *drive, u8 state) | |||
279 | #endif | 279 | #endif |
280 | } | 280 | } |
281 | 281 | ||
282 | static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) | 282 | static void ht6560b_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
283 | { | 283 | { |
284 | unsigned long flags, config; | 284 | unsigned long flags, config; |
285 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
285 | u8 timing; | 286 | u8 timing; |
286 | 287 | ||
287 | switch (pio) { | 288 | switch (pio) { |
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c index 0f67f1abbbd3..4a697a238e28 100644 --- a/drivers/ide/icside.c +++ b/drivers/ide/icside.c | |||
@@ -65,6 +65,8 @@ static struct cardinfo icside_cardinfo_v6_2 = { | |||
65 | }; | 65 | }; |
66 | 66 | ||
67 | struct icside_state { | 67 | struct icside_state { |
68 | unsigned int channel; | ||
69 | unsigned int enabled; | ||
68 | void __iomem *irq_port; | 70 | void __iomem *irq_port; |
69 | void __iomem *ioc_base; | 71 | void __iomem *ioc_base; |
70 | unsigned int sel; | 72 | unsigned int sel; |
@@ -114,11 +116,18 @@ static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr) | |||
114 | struct icside_state *state = ec->irq_data; | 116 | struct icside_state *state = ec->irq_data; |
115 | void __iomem *base = state->irq_port; | 117 | void __iomem *base = state->irq_port; |
116 | 118 | ||
117 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1); | 119 | state->enabled = 1; |
118 | readb(base + ICS_ARCIN_V6_INTROFFSET_2); | ||
119 | 120 | ||
120 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2); | 121 | switch (state->channel) { |
121 | readb(base + ICS_ARCIN_V6_INTROFFSET_1); | 122 | case 0: |
123 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1); | ||
124 | readb(base + ICS_ARCIN_V6_INTROFFSET_2); | ||
125 | break; | ||
126 | case 1: | ||
127 | writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2); | ||
128 | readb(base + ICS_ARCIN_V6_INTROFFSET_1); | ||
129 | break; | ||
130 | } | ||
122 | } | 131 | } |
123 | 132 | ||
124 | /* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) | 133 | /* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) |
@@ -128,6 +137,8 @@ static void icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr) | |||
128 | { | 137 | { |
129 | struct icside_state *state = ec->irq_data; | 138 | struct icside_state *state = ec->irq_data; |
130 | 139 | ||
140 | state->enabled = 0; | ||
141 | |||
131 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | 142 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); |
132 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | 143 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); |
133 | } | 144 | } |
@@ -149,6 +160,44 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = { | |||
149 | .irqpending = icside_irqpending_arcin_v6, | 160 | .irqpending = icside_irqpending_arcin_v6, |
150 | }; | 161 | }; |
151 | 162 | ||
163 | /* | ||
164 | * Handle routing of interrupts. This is called before | ||
165 | * we write the command to the drive. | ||
166 | */ | ||
167 | static void icside_maskproc(ide_drive_t *drive, int mask) | ||
168 | { | ||
169 | ide_hwif_t *hwif = drive->hwif; | ||
170 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | ||
171 | struct icside_state *state = ecard_get_drvdata(ec); | ||
172 | unsigned long flags; | ||
173 | |||
174 | local_irq_save(flags); | ||
175 | |||
176 | state->channel = hwif->channel; | ||
177 | |||
178 | if (state->enabled && !mask) { | ||
179 | switch (hwif->channel) { | ||
180 | case 0: | ||
181 | writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | ||
182 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | ||
183 | break; | ||
184 | case 1: | ||
185 | writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | ||
186 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | ||
187 | break; | ||
188 | } | ||
189 | } else { | ||
190 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2); | ||
191 | readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1); | ||
192 | } | ||
193 | |||
194 | local_irq_restore(flags); | ||
195 | } | ||
196 | |||
197 | static const struct ide_port_ops icside_v6_no_dma_port_ops = { | ||
198 | .maskproc = icside_maskproc, | ||
199 | }; | ||
200 | |||
152 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS | 201 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS |
153 | /* | 202 | /* |
154 | * SG-DMA support. | 203 | * SG-DMA support. |
@@ -185,10 +234,11 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = { | |||
185 | * MW1 80 50 50 150 C | 234 | * MW1 80 50 50 150 C |
186 | * MW2 70 25 25 120 C | 235 | * MW2 70 25 25 120 C |
187 | */ | 236 | */ |
188 | static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) | 237 | static void icside_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
189 | { | 238 | { |
190 | unsigned long cycle_time; | 239 | unsigned long cycle_time; |
191 | int use_dma_info = 0; | 240 | int use_dma_info = 0; |
241 | const u8 xfer_mode = drive->dma_mode; | ||
192 | 242 | ||
193 | switch (xfer_mode) { | 243 | switch (xfer_mode) { |
194 | case XFER_MW_DMA_2: | 244 | case XFER_MW_DMA_2: |
@@ -228,6 +278,7 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) | |||
228 | 278 | ||
229 | static const struct ide_port_ops icside_v6_port_ops = { | 279 | static const struct ide_port_ops icside_v6_port_ops = { |
230 | .set_dma_mode = icside_set_dma_mode, | 280 | .set_dma_mode = icside_set_dma_mode, |
281 | .maskproc = icside_maskproc, | ||
231 | }; | 282 | }; |
232 | 283 | ||
233 | static void icside_dma_host_set(ide_drive_t *drive, int on) | 284 | static void icside_dma_host_set(ide_drive_t *drive, int on) |
@@ -272,6 +323,11 @@ static int icside_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd) | |||
272 | BUG_ON(dma_channel_active(ec->dma)); | 323 | BUG_ON(dma_channel_active(ec->dma)); |
273 | 324 | ||
274 | /* | 325 | /* |
326 | * Ensure that we have the right interrupt routed. | ||
327 | */ | ||
328 | icside_maskproc(drive, 0); | ||
329 | |||
330 | /* | ||
275 | * Route the DMA signals to the correct interface. | 331 | * Route the DMA signals to the correct interface. |
276 | */ | 332 | */ |
277 | writeb(state->sel | hwif->channel, state->ioc_base); | 333 | writeb(state->sel | hwif->channel, state->ioc_base); |
@@ -399,6 +455,7 @@ err_free: | |||
399 | 455 | ||
400 | static const struct ide_port_info icside_v6_port_info __initdata = { | 456 | static const struct ide_port_info icside_v6_port_info __initdata = { |
401 | .init_dma = icside_dma_off_init, | 457 | .init_dma = icside_dma_off_init, |
458 | .port_ops = &icside_v6_no_dma_port_ops, | ||
402 | .dma_ops = &icside_v6_dma_ops, | 459 | .dma_ops = &icside_v6_dma_ops, |
403 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO, | 460 | .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO, |
404 | .mwdma_mask = ATA_MWDMA2, | 461 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index c0cf45a11b93..c26c11905ffe 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/device.h> | 12 | #include <linux/device.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | ||
15 | #include <acpi/acpi.h> | 16 | #include <acpi/acpi.h> |
16 | #include <linux/ide.h> | 17 | #include <linux/ide.h> |
17 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
@@ -108,11 +109,11 @@ bool ide_port_acpi(ide_hwif_t *hwif) | |||
108 | * Returns 0 on success, <0 on error. | 109 | * Returns 0 on success, <0 on error. |
109 | */ | 110 | */ |
110 | static int ide_get_dev_handle(struct device *dev, acpi_handle *handle, | 111 | static int ide_get_dev_handle(struct device *dev, acpi_handle *handle, |
111 | acpi_integer *pcidevfn) | 112 | u64 *pcidevfn) |
112 | { | 113 | { |
113 | struct pci_dev *pdev = to_pci_dev(dev); | 114 | struct pci_dev *pdev = to_pci_dev(dev); |
114 | unsigned int bus, devnum, func; | 115 | unsigned int bus, devnum, func; |
115 | acpi_integer addr; | 116 | u64 addr; |
116 | acpi_handle dev_handle; | 117 | acpi_handle dev_handle; |
117 | acpi_status status; | 118 | acpi_status status; |
118 | struct acpi_device_info *dinfo = NULL; | 119 | struct acpi_device_info *dinfo = NULL; |
@@ -122,7 +123,7 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle, | |||
122 | devnum = PCI_SLOT(pdev->devfn); | 123 | devnum = PCI_SLOT(pdev->devfn); |
123 | func = PCI_FUNC(pdev->devfn); | 124 | func = PCI_FUNC(pdev->devfn); |
124 | /* ACPI _ADR encoding for PCI bus: */ | 125 | /* ACPI _ADR encoding for PCI bus: */ |
125 | addr = (acpi_integer)(devnum << 16 | func); | 126 | addr = (u64)(devnum << 16 | func); |
126 | 127 | ||
127 | DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func); | 128 | DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func); |
128 | 129 | ||
@@ -169,7 +170,7 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif) | |||
169 | { | 170 | { |
170 | struct device *dev = hwif->gendev.parent; | 171 | struct device *dev = hwif->gendev.parent; |
171 | acpi_handle uninitialized_var(dev_handle); | 172 | acpi_handle uninitialized_var(dev_handle); |
172 | acpi_integer pcidevfn; | 173 | u64 pcidevfn; |
173 | acpi_handle chan_handle; | 174 | acpi_handle chan_handle; |
174 | int err; | 175 | int err; |
175 | 176 | ||
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index eb2181a6a11c..f9daffd7d0e3 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/delay.h> | 7 | #include <linux/delay.h> |
8 | #include <linux/ide.h> | 8 | #include <linux/ide.h> |
9 | #include <linux/scatterlist.h> | 9 | #include <linux/scatterlist.h> |
10 | #include <linux/gfp.h> | ||
10 | 11 | ||
11 | #include <scsi/scsi.h> | 12 | #include <scsi/scsi.h> |
12 | 13 | ||
@@ -263,8 +264,8 @@ void ide_retry_pc(ide_drive_t *drive) | |||
263 | * of it. The failed command will be retried after sense data | 264 | * of it. The failed command will be retried after sense data |
264 | * is acquired. | 265 | * is acquired. |
265 | */ | 266 | */ |
266 | blk_requeue_request(failed_rq->q, failed_rq); | ||
267 | drive->hwif->rq = NULL; | 267 | drive->hwif->rq = NULL; |
268 | ide_requeue_and_plug(drive, failed_rq); | ||
268 | if (ide_queue_sense_rq(drive, pc)) { | 269 | if (ide_queue_sense_rq(drive, pc)) { |
269 | blk_start_request(failed_rq); | 270 | blk_start_request(failed_rq); |
270 | ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq)); | 271 | ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq)); |
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c index df3df0041eb6..02712bf045c1 100644 --- a/drivers/ide/ide-cd_ioctl.c +++ b/drivers/ide/ide-cd_ioctl.c | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/cdrom.h> | 10 | #include <linux/cdrom.h> |
11 | #include <linux/gfp.h> | ||
11 | #include <linux/ide.h> | 12 | #include <linux/ide.h> |
12 | #include <scsi/scsi.h> | 13 | #include <scsi/scsi.h> |
13 | 14 | ||
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c index 063b933d864a..b85450865ff0 100644 --- a/drivers/ide/ide-cs.c +++ b/drivers/ide/ide-cs.c | |||
@@ -60,15 +60,6 @@ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); | |||
60 | MODULE_DESCRIPTION("PCMCIA ATA/IDE card driver"); | 60 | MODULE_DESCRIPTION("PCMCIA ATA/IDE card driver"); |
61 | MODULE_LICENSE("Dual MPL/GPL"); | 61 | MODULE_LICENSE("Dual MPL/GPL"); |
62 | 62 | ||
63 | #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0) | ||
64 | |||
65 | #ifdef CONFIG_PCMCIA_DEBUG | ||
66 | INT_MODULE_PARM(pc_debug, 0); | ||
67 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | ||
68 | #else | ||
69 | #define DEBUG(n, args...) | ||
70 | #endif | ||
71 | |||
72 | /*====================================================================*/ | 63 | /*====================================================================*/ |
73 | 64 | ||
74 | typedef struct ide_info_t { | 65 | typedef struct ide_info_t { |
@@ -98,7 +89,7 @@ static int ide_probe(struct pcmcia_device *link) | |||
98 | { | 89 | { |
99 | ide_info_t *info; | 90 | ide_info_t *info; |
100 | 91 | ||
101 | DEBUG(0, "ide_attach()\n"); | 92 | dev_dbg(&link->dev, "ide_attach()\n"); |
102 | 93 | ||
103 | /* Create new ide device */ | 94 | /* Create new ide device */ |
104 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 95 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
@@ -112,7 +103,6 @@ static int ide_probe(struct pcmcia_device *link) | |||
112 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 103 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
113 | link->io.IOAddrLines = 3; | 104 | link->io.IOAddrLines = 3; |
114 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; | 105 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
115 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | ||
116 | link->conf.Attributes = CONF_ENABLE_IRQ; | 106 | link->conf.Attributes = CONF_ENABLE_IRQ; |
117 | link->conf.IntType = INT_MEMORY_AND_IO; | 107 | link->conf.IntType = INT_MEMORY_AND_IO; |
118 | 108 | ||
@@ -131,19 +121,11 @@ static int ide_probe(struct pcmcia_device *link) | |||
131 | static void ide_detach(struct pcmcia_device *link) | 121 | static void ide_detach(struct pcmcia_device *link) |
132 | { | 122 | { |
133 | ide_info_t *info = link->priv; | 123 | ide_info_t *info = link->priv; |
134 | ide_hwif_t *hwif = info->host->ports[0]; | ||
135 | unsigned long data_addr, ctl_addr; | ||
136 | 124 | ||
137 | DEBUG(0, "ide_detach(0x%p)\n", link); | 125 | dev_dbg(&link->dev, "ide_detach(0x%p)\n", link); |
138 | |||
139 | data_addr = hwif->io_ports.data_addr; | ||
140 | ctl_addr = hwif->io_ports.ctl_addr; | ||
141 | 126 | ||
142 | ide_release(link); | 127 | ide_release(link); |
143 | 128 | ||
144 | release_region(ctl_addr, 1); | ||
145 | release_region(data_addr, 8); | ||
146 | |||
147 | kfree(info); | 129 | kfree(info); |
148 | } /* ide_detach */ | 130 | } /* ide_detach */ |
149 | 131 | ||
@@ -217,9 +199,6 @@ out_release: | |||
217 | 199 | ||
218 | ======================================================================*/ | 200 | ======================================================================*/ |
219 | 201 | ||
220 | #define CS_CHECK(fn, ret) \ | ||
221 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | ||
222 | |||
223 | struct pcmcia_config_check { | 202 | struct pcmcia_config_check { |
224 | unsigned long ctl_base; | 203 | unsigned long ctl_base; |
225 | int skip_vcc; | 204 | int skip_vcc; |
@@ -282,11 +261,11 @@ static int ide_config(struct pcmcia_device *link) | |||
282 | { | 261 | { |
283 | ide_info_t *info = link->priv; | 262 | ide_info_t *info = link->priv; |
284 | struct pcmcia_config_check *stk = NULL; | 263 | struct pcmcia_config_check *stk = NULL; |
285 | int last_ret = 0, last_fn = 0, is_kme = 0; | 264 | int ret = 0, is_kme = 0; |
286 | unsigned long io_base, ctl_base; | 265 | unsigned long io_base, ctl_base; |
287 | struct ide_host *host; | 266 | struct ide_host *host; |
288 | 267 | ||
289 | DEBUG(0, "ide_config(0x%p)\n", link); | 268 | dev_dbg(&link->dev, "ide_config(0x%p)\n", link); |
290 | 269 | ||
291 | is_kme = ((link->manf_id == MANFID_KME) && | 270 | is_kme = ((link->manf_id == MANFID_KME) && |
292 | ((link->card_id == PRODID_KME_KXLC005_A) || | 271 | ((link->card_id == PRODID_KME_KXLC005_A) || |
@@ -306,8 +285,12 @@ static int ide_config(struct pcmcia_device *link) | |||
306 | io_base = link->io.BasePort1; | 285 | io_base = link->io.BasePort1; |
307 | ctl_base = stk->ctl_base; | 286 | ctl_base = stk->ctl_base; |
308 | 287 | ||
309 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 288 | ret = pcmcia_request_irq(link, &link->irq); |
310 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 289 | if (ret) |
290 | goto failed; | ||
291 | ret = pcmcia_request_configuration(link, &link->conf); | ||
292 | if (ret) | ||
293 | goto failed; | ||
311 | 294 | ||
312 | /* disable drive interrupts during IDE probe */ | 295 | /* disable drive interrupts during IDE probe */ |
313 | outb(0x02, ctl_base); | 296 | outb(0x02, ctl_base); |
@@ -342,8 +325,6 @@ err_mem: | |||
342 | printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n"); | 325 | printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n"); |
343 | goto failed; | 326 | goto failed; |
344 | 327 | ||
345 | cs_failed: | ||
346 | cs_error(link, last_fn, last_ret); | ||
347 | failed: | 328 | failed: |
348 | kfree(stk); | 329 | kfree(stk); |
349 | ide_release(link); | 330 | ide_release(link); |
@@ -363,14 +344,21 @@ static void ide_release(struct pcmcia_device *link) | |||
363 | ide_info_t *info = link->priv; | 344 | ide_info_t *info = link->priv; |
364 | struct ide_host *host = info->host; | 345 | struct ide_host *host = info->host; |
365 | 346 | ||
366 | DEBUG(0, "ide_release(0x%p)\n", link); | 347 | dev_dbg(&link->dev, "ide_release(0x%p)\n", link); |
348 | |||
349 | if (info->ndev) { | ||
350 | ide_hwif_t *hwif = host->ports[0]; | ||
351 | unsigned long data_addr, ctl_addr; | ||
352 | |||
353 | data_addr = hwif->io_ports.data_addr; | ||
354 | ctl_addr = hwif->io_ports.ctl_addr; | ||
367 | 355 | ||
368 | if (info->ndev) | ||
369 | /* FIXME: if this fails we need to queue the cleanup somehow | ||
370 | -- need to investigate the required PCMCIA magic */ | ||
371 | ide_host_remove(host); | 356 | ide_host_remove(host); |
357 | info->ndev = 0; | ||
372 | 358 | ||
373 | info->ndev = 0; | 359 | release_region(ctl_addr, 1); |
360 | release_region(data_addr, 8); | ||
361 | } | ||
374 | 362 | ||
375 | pcmcia_disable_device(link); | 363 | pcmcia_disable_device(link); |
376 | } /* ide_release */ | 364 | } /* ide_release */ |
@@ -421,6 +409,8 @@ static struct pcmcia_device_id ide_ids[] = { | |||
421 | PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), | 409 | PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), |
422 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), | 410 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), |
423 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), | 411 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), |
412 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF CARD 1GB", 0x2e6d1829, 0x55d5bffb), | ||
413 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF CARD 4GB", 0x2e6d1829, 0x531e7d10), | ||
424 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), | 414 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), |
425 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), | 415 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), |
426 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), | 416 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), |
@@ -441,6 +431,8 @@ static struct pcmcia_device_id ide_ids[] = { | |||
441 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), | 431 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), |
442 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), | 432 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), |
443 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), | 433 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), |
434 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF133", 0x709b1bf1, 0x7558f133), | ||
435 | PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS8GCF133", 0x709b1bf1, 0xb2f89b47), | ||
444 | PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), | 436 | PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), |
445 | PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), | 437 | PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), |
446 | PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), | 438 | PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), |
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c index 1099bf7cf968..9e98122f646e 100644 --- a/drivers/ide/ide-devsets.c +++ b/drivers/ide/ide-devsets.c | |||
@@ -1,5 +1,6 @@ | |||
1 | 1 | ||
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <linux/gfp.h> | ||
3 | #include <linux/ide.h> | 4 | #include <linux/ide.h> |
4 | 5 | ||
5 | DEFINE_MUTEX(ide_setting_mtx); | 6 | DEFINE_MUTEX(ide_setting_mtx); |
@@ -105,15 +106,17 @@ static int set_pio_mode(ide_drive_t *drive, int arg) | |||
105 | return -ENOSYS; | 106 | return -ENOSYS; |
106 | 107 | ||
107 | if (set_pio_mode_abuse(drive->hwif, arg)) { | 108 | if (set_pio_mode_abuse(drive->hwif, arg)) { |
109 | drive->pio_mode = arg + XFER_PIO_0; | ||
110 | |||
108 | if (arg == 8 || arg == 9) { | 111 | if (arg == 8 || arg == 9) { |
109 | unsigned long flags; | 112 | unsigned long flags; |
110 | 113 | ||
111 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ | 114 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ |
112 | spin_lock_irqsave(&hwif->lock, flags); | 115 | spin_lock_irqsave(&hwif->lock, flags); |
113 | port_ops->set_pio_mode(drive, arg); | 116 | port_ops->set_pio_mode(hwif, drive); |
114 | spin_unlock_irqrestore(&hwif->lock, flags); | 117 | spin_unlock_irqrestore(&hwif->lock, flags); |
115 | } else | 118 | } else |
116 | port_ops->set_pio_mode(drive, arg); | 119 | port_ops->set_pio_mode(hwif, drive); |
117 | } else { | 120 | } else { |
118 | int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | 121 | int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); |
119 | 122 | ||
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 7f878017b736..3b128dce9c3a 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -679,7 +679,7 @@ static void ide_disk_setup(ide_drive_t *drive) | |||
679 | if (max_s > hwif->rqsize) | 679 | if (max_s > hwif->rqsize) |
680 | max_s = hwif->rqsize; | 680 | max_s = hwif->rqsize; |
681 | 681 | ||
682 | blk_queue_max_sectors(q, max_s); | 682 | blk_queue_max_hw_sectors(q, max_s); |
683 | } | 683 | } |
684 | 684 | ||
685 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, | 685 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, |
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c index 60b0590ccc9c..f9bbd904eae7 100644 --- a/drivers/ide/ide-disk_proc.c +++ b/drivers/ide/ide-disk_proc.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/ide.h> | 2 | #include <linux/ide.h> |
3 | #include <linux/slab.h> | ||
3 | #include <linux/seq_file.h> | 4 | #include <linux/seq_file.h> |
4 | 5 | ||
5 | #include "ide-disk.h" | 6 | #include "ide-disk.h" |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index ee58c88dee5a..06b14bc9a1d4 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -29,6 +29,7 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/gfp.h> | ||
32 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
33 | #include <linux/ide.h> | 34 | #include <linux/ide.h> |
34 | #include <linux/scatterlist.h> | 35 | #include <linux/scatterlist.h> |
@@ -492,6 +493,7 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | |||
492 | if (rq) { | 493 | if (rq) { |
493 | hwif->rq = NULL; | 494 | hwif->rq = NULL; |
494 | rq->errors = 0; | 495 | rq->errors = 0; |
496 | ide_requeue_and_plug(drive, rq); | ||
495 | } | 497 | } |
496 | return ret; | 498 | return ret; |
497 | } | 499 | } |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index fefbdfc8db06..4713bdca20b6 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/major.h> | 25 | #include <linux/major.h> |
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/genhd.h> | 27 | #include <linux/genhd.h> |
28 | #include <linux/slab.h> | ||
29 | #include <linux/cdrom.h> | 28 | #include <linux/cdrom.h> |
30 | #include <linux/ide.h> | 29 | #include <linux/ide.h> |
31 | #include <linux/hdreg.h> | 30 | #include <linux/hdreg.h> |
@@ -486,7 +485,7 @@ static void ide_floppy_setup(ide_drive_t *drive) | |||
486 | drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; | 485 | drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; |
487 | /* This value will be visible in the /proc/ide/hdx/settings */ | 486 | /* This value will be visible in the /proc/ide/hdx/settings */ |
488 | drive->pc_delay = IDEFLOPPY_PC_DELAY; | 487 | drive->pc_delay = IDEFLOPPY_PC_DELAY; |
489 | blk_queue_max_sectors(drive->queue, 64); | 488 | blk_queue_max_hw_sectors(drive->queue, 64); |
490 | } | 489 | } |
491 | 490 | ||
492 | /* | 491 | /* |
@@ -494,7 +493,7 @@ static void ide_floppy_setup(ide_drive_t *drive) | |||
494 | * nasty clicking noises without it, so please don't remove this. | 493 | * nasty clicking noises without it, so please don't remove this. |
495 | */ | 494 | */ |
496 | if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) { | 495 | if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) { |
497 | blk_queue_max_sectors(drive->queue, 64); | 496 | blk_queue_max_hw_sectors(drive->queue, 64); |
498 | drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; | 497 | drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; |
499 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 498 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
500 | drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; | 499 | drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; |
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 753241429c26..c32d83996ae1 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/ide.h> | 8 | #include <linux/ide.h> |
9 | #include <linux/hdreg.h> | 9 | #include <linux/hdreg.h> |
10 | #include <linux/dmi.h> | 10 | #include <linux/dmi.h> |
11 | #include <linux/slab.h> | ||
11 | 12 | ||
12 | #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) | 13 | #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) |
13 | #define IDE_DISK_MINORS (1 << PARTN_BITS) | 14 | #define IDE_DISK_MINORS (1 << PARTN_BITS) |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index db96138fefcd..172ac9218154 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -566,7 +566,7 @@ plug_device_2: | |||
566 | blk_plug_device(q); | 566 | blk_plug_device(q); |
567 | } | 567 | } |
568 | 568 | ||
569 | static void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) | 569 | void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) |
570 | { | 570 | { |
571 | struct request_queue *q = drive->queue; | 571 | struct request_queue *q = drive->queue; |
572 | unsigned long flags; | 572 | unsigned long flags; |
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c index 6e7ae2b6cfc6..9965ecd5078c 100644 --- a/drivers/ide/ide-ioctls.c +++ b/drivers/ide/ide-ioctls.c | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | #include <linux/hdreg.h> | 5 | #include <linux/hdreg.h> |
6 | #include <linux/ide.h> | 6 | #include <linux/ide.h> |
7 | #include <linux/slab.h> | ||
7 | 8 | ||
8 | static const struct ide_ioctl_devset ide_ioctl_settings[] = { | 9 | static const struct ide_ioctl_devset ide_ioctl_settings[] = { |
9 | { HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit }, | 10 | { HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit }, |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 222c1ef65fb9..376f2dc410c5 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -231,7 +231,7 @@ u8 eighty_ninty_three(ide_drive_t *drive) | |||
231 | u16 *id = drive->id; | 231 | u16 *id = drive->id; |
232 | int ivb = ide_in_drive_list(id, ivb_list); | 232 | int ivb = ide_in_drive_list(id, ivb_list); |
233 | 233 | ||
234 | if (hwif->cbl == ATA_CBL_PATA40_SHORT) | 234 | if (hwif->cbl == ATA_CBL_SATA || hwif->cbl == ATA_CBL_PATA40_SHORT) |
235 | return 1; | 235 | return 1; |
236 | 236 | ||
237 | if (ivb) | 237 | if (ivb) |
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c index a914023d6d03..88a380c5a470 100644 --- a/drivers/ide/ide-park.c +++ b/drivers/ide/ide-park.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/gfp.h> | ||
2 | #include <linux/ide.h> | 3 | #include <linux/ide.h> |
3 | #include <linux/jiffies.h> | 4 | #include <linux/jiffies.h> |
4 | #include <linux/blkdev.h> | 5 | #include <linux/blkdev.h> |
diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c index 39d4e01f5c9c..a743e68a8903 100644 --- a/drivers/ide/ide-pci-generic.c +++ b/drivers/ide/ide-pci-generic.c | |||
@@ -162,9 +162,10 @@ static const struct pci_device_id generic_pci_tbl[] = { | |||
162 | #ifdef CONFIG_BLK_DEV_IDE_SATA | 162 | #ifdef CONFIG_BLK_DEV_IDE_SATA |
163 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 5 }, | 163 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 5 }, |
164 | #endif | 164 | #endif |
165 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 4 }, | ||
166 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 4 }, | 165 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 4 }, |
167 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 4 }, | 166 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 4 }, |
167 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), 4 }, | ||
168 | { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), 4 }, | ||
168 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 6 }, | 169 | { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 6 }, |
169 | /* | 170 | /* |
170 | * Must come last. If you add entries adjust | 171 | * Must come last. If you add entries adjust |
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c index ad7be2669dcb..1c08311b0a0e 100644 --- a/drivers/ide/ide-pm.c +++ b/drivers/ide/ide-pm.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/gfp.h> | ||
2 | #include <linux/ide.h> | 3 | #include <linux/ide.h> |
3 | 4 | ||
4 | int generic_ide_suspend(struct device *dev, pm_message_t mesg) | 5 | int generic_ide_suspend(struct device *dev, pm_message_t mesg) |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 4d76ba473097..4c3d1bfec0c5 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -695,14 +695,8 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
695 | if (irqd) | 695 | if (irqd) |
696 | disable_irq(hwif->irq); | 696 | disable_irq(hwif->irq); |
697 | 697 | ||
698 | rc = ide_port_wait_ready(hwif); | 698 | if (ide_port_wait_ready(hwif) == -EBUSY) |
699 | if (rc == -ENODEV) { | 699 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); |
700 | printk(KERN_INFO "%s: no devices on the port\n", hwif->name); | ||
701 | goto out; | ||
702 | } else if (rc == -EBUSY) | ||
703 | printk(KERN_ERR "%s: not ready before the probe\n", hwif->name); | ||
704 | else | ||
705 | rc = -ENODEV; | ||
706 | 700 | ||
707 | /* | 701 | /* |
708 | * Second drive should only exist if first drive was found, | 702 | * Second drive should only exist if first drive was found, |
@@ -713,7 +707,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
713 | if (drive->dev_flags & IDE_DFLAG_PRESENT) | 707 | if (drive->dev_flags & IDE_DFLAG_PRESENT) |
714 | rc = 0; | 708 | rc = 0; |
715 | } | 709 | } |
716 | out: | 710 | |
717 | /* | 711 | /* |
718 | * Use cached IRQ number. It might be (and is...) changed by probe | 712 | * Use cached IRQ number. It might be (and is...) changed by probe |
719 | * code above | 713 | * code above |
@@ -774,7 +768,7 @@ static int ide_init_queue(ide_drive_t *drive) | |||
774 | 768 | ||
775 | if (hwif->rqsize < max_sectors) | 769 | if (hwif->rqsize < max_sectors) |
776 | max_sectors = hwif->rqsize; | 770 | max_sectors = hwif->rqsize; |
777 | blk_queue_max_sectors(q, max_sectors); | 771 | blk_queue_max_hw_sectors(q, max_sectors); |
778 | 772 | ||
779 | #ifdef CONFIG_PCI | 773 | #ifdef CONFIG_PCI |
780 | /* When we have an IOMMU, we may have a problem where pci_map_sg() | 774 | /* When we have an IOMMU, we may have a problem where pci_map_sg() |
@@ -790,8 +784,7 @@ static int ide_init_queue(ide_drive_t *drive) | |||
790 | max_sg_entries >>= 1; | 784 | max_sg_entries >>= 1; |
791 | #endif /* CONFIG_PCI */ | 785 | #endif /* CONFIG_PCI */ |
792 | 786 | ||
793 | blk_queue_max_hw_segments(q, max_sg_entries); | 787 | blk_queue_max_segments(q, max_sg_entries); |
794 | blk_queue_max_phys_segments(q, max_sg_entries); | ||
795 | 788 | ||
796 | /* assign drive queue */ | 789 | /* assign drive queue */ |
797 | drive->queue = q; | 790 | drive->queue = q; |
@@ -1043,6 +1036,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1043 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | 1036 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) |
1044 | drive->dev_flags |= IDE_DFLAG_NO_UNMASK; | 1037 | drive->dev_flags |= IDE_DFLAG_NO_UNMASK; |
1045 | 1038 | ||
1039 | drive->pio_mode = XFER_PIO_0; | ||
1040 | |||
1046 | if (port_ops && port_ops->init_dev) | 1041 | if (port_ops && port_ops->init_dev) |
1047 | port_ops->init_dev(drive); | 1042 | port_ops->init_dev(drive); |
1048 | } | 1043 | } |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 017c09540c2f..a3133d7b2a0c 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/ctype.h> | 25 | #include <linux/ctype.h> |
26 | #include <linux/ide.h> | 26 | #include <linux/ide.h> |
27 | #include <linux/seq_file.h> | 27 | #include <linux/seq_file.h> |
28 | #include <linux/slab.h> | ||
28 | 29 | ||
29 | #include <asm/io.h> | 30 | #include <asm/io.h> |
30 | 31 | ||
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 58fc920d5c32..b07232880ec9 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -221,6 +221,8 @@ typedef struct ide_tape_obj { | |||
221 | 221 | ||
222 | static DEFINE_MUTEX(idetape_ref_mutex); | 222 | static DEFINE_MUTEX(idetape_ref_mutex); |
223 | 223 | ||
224 | static DEFINE_MUTEX(idetape_chrdev_mutex); | ||
225 | |||
224 | static struct class *idetape_sysfs_class; | 226 | static struct class *idetape_sysfs_class; |
225 | 227 | ||
226 | static void ide_tape_release(struct device *); | 228 | static void ide_tape_release(struct device *); |
@@ -1363,7 +1365,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1363 | * supported here, and not in the corresponding block interface. Our own | 1365 | * supported here, and not in the corresponding block interface. Our own |
1364 | * ide-tape ioctls are supported on both interfaces. | 1366 | * ide-tape ioctls are supported on both interfaces. |
1365 | */ | 1367 | */ |
1366 | static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | 1368 | static long do_idetape_chrdev_ioctl(struct file *file, |
1367 | unsigned int cmd, unsigned long arg) | 1369 | unsigned int cmd, unsigned long arg) |
1368 | { | 1370 | { |
1369 | struct ide_tape_obj *tape = file->private_data; | 1371 | struct ide_tape_obj *tape = file->private_data; |
@@ -1418,6 +1420,16 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
1418 | } | 1420 | } |
1419 | } | 1421 | } |
1420 | 1422 | ||
1423 | static long idetape_chrdev_ioctl(struct file *file, | ||
1424 | unsigned int cmd, unsigned long arg) | ||
1425 | { | ||
1426 | long ret; | ||
1427 | lock_kernel(); | ||
1428 | ret = do_idetape_chrdev_ioctl(file, cmd, arg); | ||
1429 | unlock_kernel(); | ||
1430 | return ret; | ||
1431 | } | ||
1432 | |||
1421 | /* | 1433 | /* |
1422 | * Do a mode sense page 0 with block descriptor and if it succeeds set the tape | 1434 | * Do a mode sense page 0 with block descriptor and if it succeeds set the tape |
1423 | * block size with the reported value. | 1435 | * block size with the reported value. |
@@ -1457,10 +1469,11 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1457 | if (i >= MAX_HWIFS * MAX_DRIVES) | 1469 | if (i >= MAX_HWIFS * MAX_DRIVES) |
1458 | return -ENXIO; | 1470 | return -ENXIO; |
1459 | 1471 | ||
1460 | lock_kernel(); | 1472 | mutex_lock(&idetape_chrdev_mutex); |
1473 | |||
1461 | tape = ide_tape_get(NULL, true, i); | 1474 | tape = ide_tape_get(NULL, true, i); |
1462 | if (!tape) { | 1475 | if (!tape) { |
1463 | unlock_kernel(); | 1476 | mutex_unlock(&idetape_chrdev_mutex); |
1464 | return -ENXIO; | 1477 | return -ENXIO; |
1465 | } | 1478 | } |
1466 | 1479 | ||
@@ -1519,12 +1532,15 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
1519 | tape->door_locked = DOOR_LOCKED; | 1532 | tape->door_locked = DOOR_LOCKED; |
1520 | } | 1533 | } |
1521 | } | 1534 | } |
1522 | unlock_kernel(); | 1535 | mutex_unlock(&idetape_chrdev_mutex); |
1536 | |||
1523 | return 0; | 1537 | return 0; |
1524 | 1538 | ||
1525 | out_put_tape: | 1539 | out_put_tape: |
1526 | ide_tape_put(tape); | 1540 | ide_tape_put(tape); |
1527 | unlock_kernel(); | 1541 | |
1542 | mutex_unlock(&idetape_chrdev_mutex); | ||
1543 | |||
1528 | return retval; | 1544 | return retval; |
1529 | } | 1545 | } |
1530 | 1546 | ||
@@ -1551,7 +1567,8 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1551 | ide_drive_t *drive = tape->drive; | 1567 | ide_drive_t *drive = tape->drive; |
1552 | unsigned int minor = iminor(inode); | 1568 | unsigned int minor = iminor(inode); |
1553 | 1569 | ||
1554 | lock_kernel(); | 1570 | mutex_lock(&idetape_chrdev_mutex); |
1571 | |||
1555 | tape = drive->driver_data; | 1572 | tape = drive->driver_data; |
1556 | 1573 | ||
1557 | ide_debug_log(IDE_DBG_FUNC, "enter"); | 1574 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
@@ -1575,7 +1592,9 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
1575 | } | 1592 | } |
1576 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); | 1593 | clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); |
1577 | ide_tape_put(tape); | 1594 | ide_tape_put(tape); |
1578 | unlock_kernel(); | 1595 | |
1596 | mutex_unlock(&idetape_chrdev_mutex); | ||
1597 | |||
1579 | return 0; | 1598 | return 0; |
1580 | } | 1599 | } |
1581 | 1600 | ||
@@ -1879,7 +1898,7 @@ static const struct file_operations idetape_fops = { | |||
1879 | .owner = THIS_MODULE, | 1898 | .owner = THIS_MODULE, |
1880 | .read = idetape_chrdev_read, | 1899 | .read = idetape_chrdev_read, |
1881 | .write = idetape_chrdev_write, | 1900 | .write = idetape_chrdev_write, |
1882 | .ioctl = idetape_chrdev_ioctl, | 1901 | .unlocked_ioctl = idetape_chrdev_ioctl, |
1883 | .open = idetape_chrdev_open, | 1902 | .open = idetape_chrdev_open, |
1884 | .release = idetape_chrdev_release, | 1903 | .release = idetape_chrdev_release, |
1885 | }; | 1904 | }; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index cc8633cbe133..67fb73559fd5 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -428,13 +428,11 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, | |||
428 | { | 428 | { |
429 | struct request *rq; | 429 | struct request *rq; |
430 | int error; | 430 | int error; |
431 | int rw = !(cmd->tf_flags & IDE_TFLAG_WRITE) ? READ : WRITE; | ||
431 | 432 | ||
432 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 433 | rq = blk_get_request(drive->queue, rw, __GFP_WAIT); |
433 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; | 434 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
434 | 435 | ||
435 | if (cmd->tf_flags & IDE_TFLAG_WRITE) | ||
436 | rq->cmd_flags |= REQ_RW; | ||
437 | |||
438 | /* | 436 | /* |
439 | * (ks) We transfer currently only whole sectors. | 437 | * (ks) We transfer currently only whole sectors. |
440 | * This is suffient for now. But, it would be great, | 438 | * This is suffient for now. But, it would be great, |
diff --git a/drivers/ide/ide-timings.c b/drivers/ide/ide-timings.c index 001a56365be5..0e05f75934c9 100644 --- a/drivers/ide/ide-timings.c +++ b/drivers/ide/ide-timings.c | |||
@@ -166,12 +166,13 @@ int ide_timing_compute(ide_drive_t *drive, u8 speed, | |||
166 | if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ | 166 | if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ |
167 | memset(&p, 0, sizeof(p)); | 167 | memset(&p, 0, sizeof(p)); |
168 | 168 | ||
169 | if (speed <= XFER_PIO_2) | 169 | if (speed >= XFER_PIO_0 && speed < XFER_SW_DMA_0) { |
170 | p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO]; | 170 | if (speed <= XFER_PIO_2) |
171 | else if ((speed <= XFER_PIO_4) || | 171 | p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO]; |
172 | (speed == XFER_PIO_5 && !ata_id_is_cfa(id))) | 172 | else if ((speed <= XFER_PIO_4) || |
173 | p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY]; | 173 | (speed == XFER_PIO_5 && !ata_id_is_cfa(id))) |
174 | else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) | 174 | p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY]; |
175 | } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) | ||
175 | p.cycle = id[ATA_ID_EIDE_DMA_MIN]; | 176 | p.cycle = id[ATA_ID_EIDE_DMA_MIN]; |
176 | 177 | ||
177 | ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B); | 178 | ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B); |
@@ -185,11 +186,10 @@ int ide_timing_compute(ide_drive_t *drive, u8 speed, | |||
185 | /* | 186 | /* |
186 | * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, | 187 | * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, |
187 | * S.M.A.R.T and some other commands. We have to ensure that the | 188 | * S.M.A.R.T and some other commands. We have to ensure that the |
188 | * DMA cycle timing is slower/equal than the fastest PIO timing. | 189 | * DMA cycle timing is slower/equal than the current PIO timing. |
189 | */ | 190 | */ |
190 | if (speed >= XFER_SW_DMA_0) { | 191 | if (speed >= XFER_SW_DMA_0) { |
191 | u8 pio = ide_get_best_pio_mode(drive, 255, 5); | 192 | ide_timing_compute(drive, drive->pio_mode, &p, T, UT); |
192 | ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT); | ||
193 | ide_timing_merge(&p, t, t, IDE_TIMING_ALL); | 193 | ide_timing_merge(&p, t, t, IDE_TIMING_ALL); |
194 | } | 194 | } |
195 | 195 | ||
diff --git a/drivers/ide/ide-xfer-mode.c b/drivers/ide/ide-xfer-mode.c index 46d203ce60cc..5fc8d5c17de9 100644 --- a/drivers/ide/ide-xfer-mode.c +++ b/drivers/ide/ide-xfer-mode.c | |||
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(ide_xfer_verbose); | |||
58 | * This is used by most chipset support modules when "auto-tuning". | 58 | * This is used by most chipset support modules when "auto-tuning". |
59 | */ | 59 | */ |
60 | 60 | ||
61 | u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode) | 61 | static u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode) |
62 | { | 62 | { |
63 | u16 *id = drive->id; | 63 | u16 *id = drive->id; |
64 | int pio_mode = -1, overridden = 0; | 64 | int pio_mode = -1, overridden = 0; |
@@ -105,7 +105,6 @@ u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode) | |||
105 | 105 | ||
106 | return pio_mode; | 106 | return pio_mode; |
107 | } | 107 | } |
108 | EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); | ||
109 | 108 | ||
110 | int ide_pio_need_iordy(ide_drive_t *drive, const u8 pio) | 109 | int ide_pio_need_iordy(ide_drive_t *drive, const u8 pio) |
111 | { | 110 | { |
@@ -135,17 +134,20 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | |||
135 | * set transfer mode on the device in ->set_pio_mode method... | 134 | * set transfer mode on the device in ->set_pio_mode method... |
136 | */ | 135 | */ |
137 | if (port_ops->set_dma_mode == NULL) { | 136 | if (port_ops->set_dma_mode == NULL) { |
138 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | 137 | drive->pio_mode = mode; |
138 | port_ops->set_pio_mode(hwif, drive); | ||
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | 142 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { |
143 | if (ide_config_drive_speed(drive, mode)) | 143 | if (ide_config_drive_speed(drive, mode)) |
144 | return -1; | 144 | return -1; |
145 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | 145 | drive->pio_mode = mode; |
146 | port_ops->set_pio_mode(hwif, drive); | ||
146 | return 0; | 147 | return 0; |
147 | } else { | 148 | } else { |
148 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); | 149 | drive->pio_mode = mode; |
150 | port_ops->set_pio_mode(hwif, drive); | ||
149 | return ide_config_drive_speed(drive, mode); | 151 | return ide_config_drive_speed(drive, mode); |
150 | } | 152 | } |
151 | } | 153 | } |
@@ -164,10 +166,12 @@ int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
164 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | 166 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { |
165 | if (ide_config_drive_speed(drive, mode)) | 167 | if (ide_config_drive_speed(drive, mode)) |
166 | return -1; | 168 | return -1; |
167 | port_ops->set_dma_mode(drive, mode); | 169 | drive->dma_mode = mode; |
170 | port_ops->set_dma_mode(hwif, drive); | ||
168 | return 0; | 171 | return 0; |
169 | } else { | 172 | } else { |
170 | port_ops->set_dma_mode(drive, mode); | 173 | drive->dma_mode = mode; |
174 | port_ops->set_dma_mode(hwif, drive); | ||
171 | return ide_config_drive_speed(drive, mode); | 175 | return ide_config_drive_speed(drive, mode); |
172 | } | 176 | } |
173 | } | 177 | } |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 16d056939f9f..3cb9c4e056ff 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -52,7 +52,6 @@ | |||
52 | #include <linux/major.h> | 52 | #include <linux/major.h> |
53 | #include <linux/errno.h> | 53 | #include <linux/errno.h> |
54 | #include <linux/genhd.h> | 54 | #include <linux/genhd.h> |
55 | #include <linux/slab.h> | ||
56 | #include <linux/init.h> | 55 | #include <linux/init.h> |
57 | #include <linux/pci.h> | 56 | #include <linux/pci.h> |
58 | #include <linux/ide.h> | 57 | #include <linux/ide.h> |
diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c index b579fbe88370..42965b3e30b9 100644 --- a/drivers/ide/ide_platform.c +++ b/drivers/ide/ide_platform.c | |||
@@ -81,14 +81,14 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
81 | 81 | ||
82 | if (mmio) { | 82 | if (mmio) { |
83 | base = devm_ioremap(&pdev->dev, | 83 | base = devm_ioremap(&pdev->dev, |
84 | res_base->start, res_base->end - res_base->start + 1); | 84 | res_base->start, resource_size(res_base)); |
85 | alt_base = devm_ioremap(&pdev->dev, | 85 | alt_base = devm_ioremap(&pdev->dev, |
86 | res_alt->start, res_alt->end - res_alt->start + 1); | 86 | res_alt->start, resource_size(res_alt)); |
87 | } else { | 87 | } else { |
88 | base = devm_ioport_map(&pdev->dev, | 88 | base = devm_ioport_map(&pdev->dev, |
89 | res_base->start, res_base->end - res_base->start + 1); | 89 | res_base->start, resource_size(res_base)); |
90 | alt_base = devm_ioport_map(&pdev->dev, | 90 | alt_base = devm_ioport_map(&pdev->dev, |
91 | res_alt->start, res_alt->end - res_alt->start + 1); | 91 | res_alt->start, resource_size(res_alt)); |
92 | } | 92 | } |
93 | 93 | ||
94 | memset(&hw, 0, sizeof(hw)); | 94 | memset(&hw, 0, sizeof(hw)); |
diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c index 0d266a5b524d..560e66d07659 100644 --- a/drivers/ide/it8172.c +++ b/drivers/ide/it8172.c | |||
@@ -37,12 +37,12 @@ | |||
37 | 37 | ||
38 | #define DRV_NAME "IT8172" | 38 | #define DRV_NAME "IT8172" |
39 | 39 | ||
40 | static void it8172_set_pio_mode(ide_drive_t *drive, const u8 pio) | 40 | static void it8172_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
41 | { | 41 | { |
42 | ide_hwif_t *hwif = drive->hwif; | ||
43 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 42 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
44 | u16 drive_enables; | 43 | u16 drive_enables; |
45 | u32 drive_timing; | 44 | u32 drive_timing; |
45 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
46 | 46 | ||
47 | /* | 47 | /* |
48 | * The highest value of DIOR/DIOW pulse width and recovery time | 48 | * The highest value of DIOR/DIOW pulse width and recovery time |
@@ -77,14 +77,14 @@ static void it8172_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
77 | pci_write_config_dword(dev, 0x44, drive_timing); | 77 | pci_write_config_dword(dev, 0x44, drive_timing); |
78 | } | 78 | } |
79 | 79 | ||
80 | static void it8172_set_dma_mode(ide_drive_t *drive, const u8 speed) | 80 | static void it8172_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
81 | { | 81 | { |
82 | ide_hwif_t *hwif = drive->hwif; | ||
83 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 82 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
84 | int a_speed = 3 << (drive->dn * 4); | 83 | int a_speed = 3 << (drive->dn * 4); |
85 | int u_flag = 1 << drive->dn; | 84 | int u_flag = 1 << drive->dn; |
86 | int u_speed = 0; | 85 | int u_speed = 0; |
87 | u8 reg48, reg4a; | 86 | u8 reg48, reg4a; |
87 | const u8 speed = drive->dma_mode; | ||
88 | 88 | ||
89 | pci_read_config_byte(dev, 0x48, ®48); | 89 | pci_read_config_byte(dev, 0x48, ®48); |
90 | pci_read_config_byte(dev, 0x4a, ®4a); | 90 | pci_read_config_byte(dev, 0x4a, ®4a); |
@@ -98,14 +98,14 @@ static void it8172_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
98 | pci_write_config_byte(dev, 0x4a, reg4a | u_speed); | 98 | pci_write_config_byte(dev, 0x4a, reg4a | u_speed); |
99 | } else { | 99 | } else { |
100 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | 100 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; |
101 | u8 pio; | ||
102 | 101 | ||
103 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | 102 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); |
104 | pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed); | 103 | pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed); |
105 | 104 | ||
106 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | 105 | drive->pio_mode = |
106 | mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0; | ||
107 | 107 | ||
108 | it8172_set_pio_mode(drive, pio); | 108 | it8172_set_pio_mode(hwif, drive); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/drivers/ide/it8213.c b/drivers/ide/it8213.c index 47976167796a..46816ba26416 100644 --- a/drivers/ide/it8213.c +++ b/drivers/ide/it8213.c | |||
@@ -17,15 +17,14 @@ | |||
17 | 17 | ||
18 | /** | 18 | /** |
19 | * it8213_set_pio_mode - set host controller for PIO mode | 19 | * it8213_set_pio_mode - set host controller for PIO mode |
20 | * @hwif: port | ||
20 | * @drive: drive | 21 | * @drive: drive |
21 | * @pio: PIO mode number | ||
22 | * | 22 | * |
23 | * Set the interface PIO mode. | 23 | * Set the interface PIO mode. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | 26 | static void it8213_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
27 | { | 27 | { |
28 | ide_hwif_t *hwif = drive->hwif; | ||
29 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 28 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
30 | int is_slave = drive->dn & 1; | 29 | int is_slave = drive->dn & 1; |
31 | int master_port = 0x40; | 30 | int master_port = 0x40; |
@@ -35,6 +34,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
35 | u8 slave_data; | 34 | u8 slave_data; |
36 | static DEFINE_SPINLOCK(tune_lock); | 35 | static DEFINE_SPINLOCK(tune_lock); |
37 | int control = 0; | 36 | int control = 0; |
37 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
38 | 38 | ||
39 | static const u8 timings[][2] = { | 39 | static const u8 timings[][2] = { |
40 | { 0, 0 }, | 40 | { 0, 0 }, |
@@ -74,15 +74,14 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
74 | 74 | ||
75 | /** | 75 | /** |
76 | * it8213_set_dma_mode - set host controller for DMA mode | 76 | * it8213_set_dma_mode - set host controller for DMA mode |
77 | * @hwif: port | ||
77 | * @drive: drive | 78 | * @drive: drive |
78 | * @speed: DMA mode | ||
79 | * | 79 | * |
80 | * Tune the ITE chipset for the DMA mode. | 80 | * Tune the ITE chipset for the DMA mode. |
81 | */ | 81 | */ |
82 | 82 | ||
83 | static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | 83 | static void it8213_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
84 | { | 84 | { |
85 | ide_hwif_t *hwif = drive->hwif; | ||
86 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 85 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
87 | u8 maslave = 0x40; | 86 | u8 maslave = 0x40; |
88 | int a_speed = 3 << (drive->dn * 4); | 87 | int a_speed = 3 << (drive->dn * 4); |
@@ -92,6 +91,7 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
92 | int u_speed = 0; | 91 | int u_speed = 0; |
93 | u16 reg4042, reg4a; | 92 | u16 reg4042, reg4a; |
94 | u8 reg48, reg54, reg55; | 93 | u8 reg48, reg54, reg55; |
94 | const u8 speed = drive->dma_mode; | ||
95 | 95 | ||
96 | pci_read_config_word(dev, maslave, ®4042); | 96 | pci_read_config_word(dev, maslave, ®4042); |
97 | pci_read_config_byte(dev, 0x48, ®48); | 97 | pci_read_config_byte(dev, 0x48, ®48); |
@@ -120,7 +120,6 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
120 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 120 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
121 | } else { | 121 | } else { |
122 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | 122 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; |
123 | u8 pio; | ||
124 | 123 | ||
125 | if (reg48 & u_flag) | 124 | if (reg48 & u_flag) |
126 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | 125 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); |
@@ -132,11 +131,12 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
132 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); | 131 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); |
133 | 132 | ||
134 | if (speed >= XFER_MW_DMA_0) | 133 | if (speed >= XFER_MW_DMA_0) |
135 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | 134 | drive->pio_mode = |
135 | mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0; | ||
136 | else | 136 | else |
137 | pio = 2; /* only SWDMA2 is allowed */ | 137 | drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */ |
138 | 138 | ||
139 | it8213_set_pio_mode(drive, pio); | 139 | it8213_set_pio_mode(hwif, drive); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c index 51aa745246dc..2e3169f2acda 100644 --- a/drivers/ide/it821x.c +++ b/drivers/ide/it821x.c | |||
@@ -61,6 +61,7 @@ | |||
61 | 61 | ||
62 | #include <linux/types.h> | 62 | #include <linux/types.h> |
63 | #include <linux/module.h> | 63 | #include <linux/module.h> |
64 | #include <linux/slab.h> | ||
64 | #include <linux/pci.h> | 65 | #include <linux/pci.h> |
65 | #include <linux/ide.h> | 66 | #include <linux/ide.h> |
66 | #include <linux/init.h> | 67 | #include <linux/init.h> |
@@ -228,18 +229,18 @@ static void it821x_clock_strategy(ide_drive_t *drive) | |||
228 | 229 | ||
229 | /** | 230 | /** |
230 | * it821x_set_pio_mode - set host controller for PIO mode | 231 | * it821x_set_pio_mode - set host controller for PIO mode |
232 | * @hwif: port | ||
231 | * @drive: drive | 233 | * @drive: drive |
232 | * @pio: PIO mode number | ||
233 | * | 234 | * |
234 | * Tune the host to the desired PIO mode taking into the consideration | 235 | * Tune the host to the desired PIO mode taking into the consideration |
235 | * the maximum PIO mode supported by the other device on the cable. | 236 | * the maximum PIO mode supported by the other device on the cable. |
236 | */ | 237 | */ |
237 | 238 | ||
238 | static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) | 239 | static void it821x_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
239 | { | 240 | { |
240 | ide_hwif_t *hwif = drive->hwif; | ||
241 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 241 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
242 | ide_drive_t *pair = ide_get_pair_dev(drive); | 242 | ide_drive_t *pair = ide_get_pair_dev(drive); |
243 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
243 | u8 unit = drive->dn & 1, set_pio = pio; | 244 | u8 unit = drive->dn & 1, set_pio = pio; |
244 | 245 | ||
245 | /* Spec says 89 ref driver uses 88 */ | 246 | /* Spec says 89 ref driver uses 88 */ |
@@ -252,7 +253,7 @@ static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
252 | * on the cable. | 253 | * on the cable. |
253 | */ | 254 | */ |
254 | if (pair) { | 255 | if (pair) { |
255 | u8 pair_pio = ide_get_best_pio_mode(pair, 255, 4); | 256 | u8 pair_pio = pair->pio_mode - XFER_PIO_0; |
256 | /* trim PIO to the slowest of the master/slave */ | 257 | /* trim PIO to the slowest of the master/slave */ |
257 | if (pair_pio < set_pio) | 258 | if (pair_pio < set_pio) |
258 | set_pio = pair_pio; | 259 | set_pio = pair_pio; |
@@ -393,14 +394,16 @@ static int it821x_dma_end(ide_drive_t *drive) | |||
393 | 394 | ||
394 | /** | 395 | /** |
395 | * it821x_set_dma_mode - set host controller for DMA mode | 396 | * it821x_set_dma_mode - set host controller for DMA mode |
397 | * @hwif: port | ||
396 | * @drive: drive | 398 | * @drive: drive |
397 | * @speed: DMA mode | ||
398 | * | 399 | * |
399 | * Tune the ITE chipset for the desired DMA mode. | 400 | * Tune the ITE chipset for the desired DMA mode. |
400 | */ | 401 | */ |
401 | 402 | ||
402 | static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed) | 403 | static void it821x_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
403 | { | 404 | { |
405 | const u8 speed = drive->dma_mode; | ||
406 | |||
404 | /* | 407 | /* |
405 | * MWDMA tuning is really hard because our MWDMA and PIO | 408 | * MWDMA tuning is really hard because our MWDMA and PIO |
406 | * timings are kept in the same place. We can switch in the | 409 | * timings are kept in the same place. We can switch in the |
diff --git a/drivers/ide/jmicron.c b/drivers/ide/jmicron.c index bf2be6431b20..74c2c4a6d909 100644 --- a/drivers/ide/jmicron.c +++ b/drivers/ide/jmicron.c | |||
@@ -80,19 +80,19 @@ static u8 jmicron_cable_detect(ide_hwif_t *hwif) | |||
80 | return ATA_CBL_PATA80; | 80 | return ATA_CBL_PATA80; |
81 | } | 81 | } |
82 | 82 | ||
83 | static void jmicron_set_pio_mode(ide_drive_t *drive, const u8 pio) | 83 | static void jmicron_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * jmicron_set_dma_mode - set host controller for DMA mode | 88 | * jmicron_set_dma_mode - set host controller for DMA mode |
89 | * @hwif: port | ||
89 | * @drive: drive | 90 | * @drive: drive |
90 | * @mode: DMA mode | ||
91 | * | 91 | * |
92 | * As the JMicron snoops for timings we don't need to do anything here. | 92 | * As the JMicron snoops for timings we don't need to do anything here. |
93 | */ | 93 | */ |
94 | 94 | ||
95 | static void jmicron_set_dma_mode(ide_drive_t *drive, const u8 mode) | 95 | static void jmicron_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c index f1d70d6630fe..1a53a4c375ed 100644 --- a/drivers/ide/opti621.c +++ b/drivers/ide/opti621.c | |||
@@ -8,77 +8,6 @@ | |||
8 | * Jan Harkes <jaharkes@cwi.nl>, | 8 | * Jan Harkes <jaharkes@cwi.nl>, |
9 | * Mark Lord <mlord@pobox.com> | 9 | * Mark Lord <mlord@pobox.com> |
10 | * Some parts of code are from ali14xx.c and from rz1000.c. | 10 | * Some parts of code are from ali14xx.c and from rz1000.c. |
11 | * | ||
12 | * OPTi is trademark of OPTi, Octek is trademark of Octek. | ||
13 | * | ||
14 | * I used docs from OPTi databook, from ftp.opti.com, file 9123-0002.ps | ||
15 | * and disassembled/traced setupvic.exe (DOS program). | ||
16 | * It increases kernel code about 2 kB. | ||
17 | * I don't have this card no more, but I hope I can get some in case | ||
18 | * of needed development. | ||
19 | * My card is Octek PIDE 1.01 (on card) or OPTiViC (program). | ||
20 | * It has a place for a secondary connector in circuit, but nothing | ||
21 | * is there. Also BIOS says no address for | ||
22 | * secondary controller (see bellow in ide_init_opti621). | ||
23 | * I've only tested this on my system, which only has one disk. | ||
24 | * It's Western Digital WDAC2850, with PIO mode 3. The PCI bus | ||
25 | * is at 20 MHz (I have DX2/80, I tried PCI at 40, but I got random | ||
26 | * lockups). I tried the OCTEK double speed CD-ROM and | ||
27 | * it does not work! But I can't boot DOS also, so it's probably | ||
28 | * hardware fault. I have connected Conner 80MB, the Seagate 850MB (no | ||
29 | * problems) and Seagate 1GB (as slave, WD as master). My experiences | ||
30 | * with the third, 1GB drive: I got 3MB/s (hdparm), but sometimes | ||
31 | * it slows to about 100kB/s! I don't know why and I have | ||
32 | * not this drive now, so I can't try it again. | ||
33 | * I write this driver because I lost the paper ("manual") with | ||
34 | * settings of jumpers on the card and I have to boot Linux with | ||
35 | * Loadlin except LILO, cause I have to run the setupvic.exe program | ||
36 | * already or I get disk errors (my test: rpm -Vf | ||
37 | * /usr/X11R6/bin/XF86_SVGA - or any big file). | ||
38 | * Some numbers from hdparm -t /dev/hda: | ||
39 | * Timing buffer-cache reads: 32 MB in 3.02 seconds =10.60 MB/sec | ||
40 | * Timing buffered disk reads: 16 MB in 5.52 seconds = 2.90 MB/sec | ||
41 | * I have 4 Megs/s before, but I don't know why (maybe changes | ||
42 | * in hdparm test). | ||
43 | * After release of 0.1, I got some successful reports, so it might work. | ||
44 | * | ||
45 | * The main problem with OPTi is that some timings for master | ||
46 | * and slave must be the same. For example, if you have master | ||
47 | * PIO 3 and slave PIO 0, driver have to set some timings of | ||
48 | * master for PIO 0. Second problem is that opti621_set_pio_mode | ||
49 | * got only one drive to set, but have to set both drives. | ||
50 | * This is solved in compute_pios. If you don't set | ||
51 | * the second drive, compute_pios use ide_get_best_pio_mode | ||
52 | * for autoselect mode (you can change it to PIO 0, if you want). | ||
53 | * If you then set the second drive to another PIO, the old value | ||
54 | * (automatically selected) will be overrided by yours. | ||
55 | * There is a 25/33MHz switch in configuration | ||
56 | * register, but driver is written for use at any frequency. | ||
57 | * | ||
58 | * Version 0.1, Nov 8, 1996 | ||
59 | * by Jaromir Koutek, for 2.1.8. | ||
60 | * Initial version of driver. | ||
61 | * | ||
62 | * Version 0.2 | ||
63 | * Number 0.2 skipped. | ||
64 | * | ||
65 | * Version 0.3, Nov 29, 1997 | ||
66 | * by Mark Lord (probably), for 2.1.68 | ||
67 | * Updates for use with new IDE block driver. | ||
68 | * | ||
69 | * Version 0.4, Dec 14, 1997 | ||
70 | * by Jan Harkes | ||
71 | * Fixed some errors and cleaned the code. | ||
72 | * | ||
73 | * Version 0.5, Jan 2, 1998 | ||
74 | * by Jaromir Koutek | ||
75 | * Updates for use with (again) new IDE block driver. | ||
76 | * Update of documentation. | ||
77 | * | ||
78 | * Version 0.6, Jan 2, 1999 | ||
79 | * by Jaromir Koutek | ||
80 | * Reversed to version 0.3 of the driver, because | ||
81 | * 0.5 doesn't work. | ||
82 | */ | 11 | */ |
83 | 12 | ||
84 | #include <linux/types.h> | 13 | #include <linux/types.h> |
@@ -133,12 +62,12 @@ static u8 read_reg(int reg) | |||
133 | return ret; | 62 | return ret; |
134 | } | 63 | } |
135 | 64 | ||
136 | static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | 65 | static void opti621_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
137 | { | 66 | { |
138 | ide_hwif_t *hwif = drive->hwif; | ||
139 | ide_drive_t *pair = ide_get_pair_dev(drive); | 67 | ide_drive_t *pair = ide_get_pair_dev(drive); |
140 | unsigned long flags; | 68 | unsigned long flags; |
141 | unsigned long mode = XFER_PIO_0 + pio, pair_mode; | 69 | unsigned long mode = drive->pio_mode, pair_mode; |
70 | const u8 pio = mode - XFER_PIO_0; | ||
142 | u8 tim, misc, addr_pio = pio, clk; | 71 | u8 tim, misc, addr_pio = pio, clk; |
143 | 72 | ||
144 | /* DRDY is default 2 (by OPTi Databook) */ | 73 | /* DRDY is default 2 (by OPTi Databook) */ |
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c index f8eddf05ecb8..9e8f4e1b0cc9 100644 --- a/drivers/ide/palm_bk3710.c +++ b/drivers/ide/palm_bk3710.c | |||
@@ -166,7 +166,7 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
166 | writel(val32, base + BK3710_DATRCVR); | 166 | writel(val32, base + BK3710_DATRCVR); |
167 | 167 | ||
168 | if (mate) { | 168 | if (mate) { |
169 | u8 mode2 = ide_get_best_pio_mode(mate, 255, 4); | 169 | u8 mode2 = mate->pio_mode - XFER_PIO_0; |
170 | 170 | ||
171 | if (mode2 < mode) | 171 | if (mode2 < mode) |
172 | mode = mode2; | 172 | mode = mode2; |
@@ -188,10 +188,11 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
188 | writel(val32, base + BK3710_REGRCVR); | 188 | writel(val32, base + BK3710_REGRCVR); |
189 | } | 189 | } |
190 | 190 | ||
191 | static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed) | 191 | static void palm_bk3710_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
192 | { | 192 | { |
193 | int is_slave = drive->dn & 1; | 193 | int is_slave = drive->dn & 1; |
194 | void __iomem *base = (void *)drive->hwif->dma_base; | 194 | void __iomem *base = (void *)hwif->dma_base; |
195 | const u8 xferspeed = drive->dma_mode; | ||
195 | 196 | ||
196 | if (xferspeed >= XFER_UDMA_0) { | 197 | if (xferspeed >= XFER_UDMA_0) { |
197 | palm_bk3710_setudmamode(base, is_slave, | 198 | palm_bk3710_setudmamode(base, is_slave, |
@@ -203,12 +204,13 @@ static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed) | |||
203 | } | 204 | } |
204 | } | 205 | } |
205 | 206 | ||
206 | static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio) | 207 | static void palm_bk3710_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
207 | { | 208 | { |
208 | unsigned int cycle_time; | 209 | unsigned int cycle_time; |
209 | int is_slave = drive->dn & 1; | 210 | int is_slave = drive->dn & 1; |
210 | ide_drive_t *mate; | 211 | ide_drive_t *mate; |
211 | void __iomem *base = (void *)drive->hwif->dma_base; | 212 | void __iomem *base = (void *)hwif->dma_base; |
213 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
212 | 214 | ||
213 | /* | 215 | /* |
214 | * Obtain the drive PIO data for tuning the Palm Chip registers | 216 | * Obtain the drive PIO data for tuning the Palm Chip registers |
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c index 65ba8239e7b5..9546fe2a93f7 100644 --- a/drivers/ide/pdc202xx_new.c +++ b/drivers/ide/pdc202xx_new.c | |||
@@ -129,11 +129,11 @@ static struct udma_timing { | |||
129 | { 0x1a, 0x01, 0xcb }, /* UDMA mode 6 */ | 129 | { 0x1a, 0x01, 0xcb }, /* UDMA mode 6 */ |
130 | }; | 130 | }; |
131 | 131 | ||
132 | static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) | 132 | static void pdcnew_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
133 | { | 133 | { |
134 | ide_hwif_t *hwif = drive->hwif; | ||
135 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 134 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
136 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; | 135 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; |
136 | const u8 speed = drive->dma_mode; | ||
137 | 137 | ||
138 | /* | 138 | /* |
139 | * IDE core issues SETFEATURES_XFER to the drive first (thanks to | 139 | * IDE core issues SETFEATURES_XFER to the drive first (thanks to |
@@ -167,11 +167,11 @@ static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) | 170 | static void pdcnew_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
171 | { | 171 | { |
172 | ide_hwif_t *hwif = drive->hwif; | ||
173 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 172 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
174 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; | 173 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; |
174 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
175 | 175 | ||
176 | if (max_dma_rate(dev) == 4) { | 176 | if (max_dma_rate(dev) == 4) { |
177 | set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); | 177 | set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); |
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c index cb812f3700e8..c5f3841af360 100644 --- a/drivers/ide/pdc202xx_old.c +++ b/drivers/ide/pdc202xx_old.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> | 2 | * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> |
3 | * Copyright (C) 2006-2007, 2009 MontaVista Software, Inc. | 3 | * Copyright (C) 2006-2007, 2009 MontaVista Software, Inc. |
4 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 4 | * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz |
5 | * | 5 | * |
6 | * Portions Copyright (C) 1999 Promise Technology, Inc. | 6 | * Portions Copyright (C) 1999 Promise Technology, Inc. |
7 | * Author: Frank Tiernan (frankt@promise.com) | 7 | * Author: Frank Tiernan (frankt@promise.com) |
@@ -21,30 +21,15 @@ | |||
21 | 21 | ||
22 | #define DRV_NAME "pdc202xx_old" | 22 | #define DRV_NAME "pdc202xx_old" |
23 | 23 | ||
24 | #define PDC202XX_DEBUG_DRIVE_INFO 0 | 24 | static void pdc202xx_set_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
25 | |||
26 | static void pdc_old_disable_66MHz_clock(ide_hwif_t *); | ||
27 | |||
28 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) | ||
29 | { | 25 | { |
30 | ide_hwif_t *hwif = drive->hwif; | ||
31 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 26 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
32 | u8 drive_pci = 0x60 + (drive->dn << 2); | 27 | u8 drive_pci = 0x60 + (drive->dn << 2); |
28 | const u8 speed = drive->dma_mode; | ||
33 | 29 | ||
34 | u8 AP = 0, BP = 0, CP = 0; | 30 | u8 AP = 0, BP = 0, CP = 0; |
35 | u8 TA = 0, TB = 0, TC = 0; | 31 | u8 TA = 0, TB = 0, TC = 0; |
36 | 32 | ||
37 | #if PDC202XX_DEBUG_DRIVE_INFO | ||
38 | u32 drive_conf = 0; | ||
39 | pci_read_config_dword(dev, drive_pci, &drive_conf); | ||
40 | #endif | ||
41 | |||
42 | /* | ||
43 | * TODO: do this once per channel | ||
44 | */ | ||
45 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) | ||
46 | pdc_old_disable_66MHz_clock(hwif); | ||
47 | |||
48 | pci_read_config_byte(dev, drive_pci, &AP); | 33 | pci_read_config_byte(dev, drive_pci, &AP); |
49 | pci_read_config_byte(dev, drive_pci + 1, &BP); | 34 | pci_read_config_byte(dev, drive_pci + 1, &BP); |
50 | pci_read_config_byte(dev, drive_pci + 2, &CP); | 35 | pci_read_config_byte(dev, drive_pci + 2, &CP); |
@@ -89,19 +74,12 @@ static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) | |||
89 | pci_write_config_byte(dev, drive_pci + 1, BP | TB); | 74 | pci_write_config_byte(dev, drive_pci + 1, BP | TB); |
90 | pci_write_config_byte(dev, drive_pci + 2, CP | TC); | 75 | pci_write_config_byte(dev, drive_pci + 2, CP | TC); |
91 | } | 76 | } |
92 | |||
93 | #if PDC202XX_DEBUG_DRIVE_INFO | ||
94 | printk(KERN_DEBUG "%s: %s drive%d 0x%08x ", | ||
95 | drive->name, ide_xfer_verbose(speed), | ||
96 | drive->dn, drive_conf); | ||
97 | pci_read_config_dword(dev, drive_pci, &drive_conf); | ||
98 | printk("0x%08x\n", drive_conf); | ||
99 | #endif | ||
100 | } | 77 | } |
101 | 78 | ||
102 | static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | 79 | static void pdc202xx_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
103 | { | 80 | { |
104 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); | 81 | drive->dma_mode = drive->pio_mode; |
82 | pdc202xx_set_mode(hwif, drive); | ||
105 | } | 83 | } |
106 | 84 | ||
107 | static int pdc202xx_test_irq(ide_hwif_t *hwif) | 85 | static int pdc202xx_test_irq(ide_hwif_t *hwif) |
@@ -115,13 +93,13 @@ static int pdc202xx_test_irq(ide_hwif_t *hwif) | |||
115 | * bit 7: error, bit 6: interrupting, | 93 | * bit 7: error, bit 6: interrupting, |
116 | * bit 5: FIFO full, bit 4: FIFO empty | 94 | * bit 5: FIFO full, bit 4: FIFO empty |
117 | */ | 95 | */ |
118 | return ((sc1d & 0x50) == 0x40) ? 1 : 0; | 96 | return ((sc1d & 0x50) == 0x50) ? 1 : 0; |
119 | } else { | 97 | } else { |
120 | /* | 98 | /* |
121 | * bit 3: error, bit 2: interrupting, | 99 | * bit 3: error, bit 2: interrupting, |
122 | * bit 1: FIFO full, bit 0: FIFO empty | 100 | * bit 1: FIFO full, bit 0: FIFO empty |
123 | */ | 101 | */ |
124 | return ((sc1d & 0x05) == 0x04) ? 1 : 0; | 102 | return ((sc1d & 0x05) == 0x05) ? 1 : 0; |
125 | } | 103 | } |
126 | } | 104 | } |
127 | 105 | ||
@@ -160,6 +138,11 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif) | |||
160 | outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); | 138 | outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); |
161 | } | 139 | } |
162 | 140 | ||
141 | static void pdc2026x_init_hwif(ide_hwif_t *hwif) | ||
142 | { | ||
143 | pdc_old_disable_66MHz_clock(hwif); | ||
144 | } | ||
145 | |||
163 | static void pdc202xx_dma_start(ide_drive_t *drive) | 146 | static void pdc202xx_dma_start(ide_drive_t *drive) |
164 | { | 147 | { |
165 | if (drive->current_speed > XFER_UDMA_2) | 148 | if (drive->current_speed > XFER_UDMA_2) |
@@ -276,6 +259,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = { | |||
276 | { \ | 259 | { \ |
277 | .name = DRV_NAME, \ | 260 | .name = DRV_NAME, \ |
278 | .init_chipset = init_chipset_pdc202xx, \ | 261 | .init_chipset = init_chipset_pdc202xx, \ |
262 | .init_hwif = pdc2026x_init_hwif, \ | ||
279 | .port_ops = &pdc2026x_port_ops, \ | 263 | .port_ops = &pdc2026x_port_ops, \ |
280 | .dma_ops = &pdc2026x_dma_ops, \ | 264 | .dma_ops = &pdc2026x_dma_ops, \ |
281 | .host_flags = IDE_HFLAGS_PDC202XX, \ | 265 | .host_flags = IDE_HFLAGS_PDC202XX, \ |
@@ -371,6 +355,6 @@ static void __exit pdc202xx_ide_exit(void) | |||
371 | module_init(pdc202xx_ide_init); | 355 | module_init(pdc202xx_ide_init); |
372 | module_exit(pdc202xx_ide_exit); | 356 | module_exit(pdc202xx_ide_exit); |
373 | 357 | ||
374 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); | 358 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan, Bartlomiej Zolnierkiewicz"); |
375 | MODULE_DESCRIPTION("PCI driver module for older Promise IDE"); | 359 | MODULE_DESCRIPTION("PCI driver module for older Promise IDE"); |
376 | MODULE_LICENSE("GPL"); | 360 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c index bf14f39bd3a7..1bdca49e5a03 100644 --- a/drivers/ide/piix.c +++ b/drivers/ide/piix.c | |||
@@ -59,15 +59,14 @@ static int no_piix_dma; | |||
59 | 59 | ||
60 | /** | 60 | /** |
61 | * piix_set_pio_mode - set host controller for PIO mode | 61 | * piix_set_pio_mode - set host controller for PIO mode |
62 | * @port: port | ||
62 | * @drive: drive | 63 | * @drive: drive |
63 | * @pio: PIO mode number | ||
64 | * | 64 | * |
65 | * Set the interface PIO mode based upon the settings done by AMI BIOS. | 65 | * Set the interface PIO mode based upon the settings done by AMI BIOS. |
66 | */ | 66 | */ |
67 | 67 | ||
68 | static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | 68 | static void piix_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
69 | { | 69 | { |
70 | ide_hwif_t *hwif = drive->hwif; | ||
71 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 70 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
72 | int is_slave = drive->dn & 1; | 71 | int is_slave = drive->dn & 1; |
73 | int master_port = hwif->channel ? 0x42 : 0x40; | 72 | int master_port = hwif->channel ? 0x42 : 0x40; |
@@ -77,6 +76,7 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
77 | u8 slave_data; | 76 | u8 slave_data; |
78 | static DEFINE_SPINLOCK(tune_lock); | 77 | static DEFINE_SPINLOCK(tune_lock); |
79 | int control = 0; | 78 | int control = 0; |
79 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
80 | 80 | ||
81 | /* ISP RTC */ | 81 | /* ISP RTC */ |
82 | static const u8 timings[][2]= { | 82 | static const u8 timings[][2]= { |
@@ -127,16 +127,15 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
127 | 127 | ||
128 | /** | 128 | /** |
129 | * piix_set_dma_mode - set host controller for DMA mode | 129 | * piix_set_dma_mode - set host controller for DMA mode |
130 | * @hwif: port | ||
130 | * @drive: drive | 131 | * @drive: drive |
131 | * @speed: DMA mode | ||
132 | * | 132 | * |
133 | * Set a PIIX host controller to the desired DMA mode. This involves | 133 | * Set a PIIX host controller to the desired DMA mode. This involves |
134 | * programming the right timing data into the PCI configuration space. | 134 | * programming the right timing data into the PCI configuration space. |
135 | */ | 135 | */ |
136 | 136 | ||
137 | static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | 137 | static void piix_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
138 | { | 138 | { |
139 | ide_hwif_t *hwif = drive->hwif; | ||
140 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 139 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
141 | u8 maslave = hwif->channel ? 0x42 : 0x40; | 140 | u8 maslave = hwif->channel ? 0x42 : 0x40; |
142 | int a_speed = 3 << (drive->dn * 4); | 141 | int a_speed = 3 << (drive->dn * 4); |
@@ -147,6 +146,7 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
147 | int sitre; | 146 | int sitre; |
148 | u16 reg4042, reg4a; | 147 | u16 reg4042, reg4a; |
149 | u8 reg48, reg54, reg55; | 148 | u8 reg48, reg54, reg55; |
149 | const u8 speed = drive->dma_mode; | ||
150 | 150 | ||
151 | pci_read_config_word(dev, maslave, ®4042); | 151 | pci_read_config_word(dev, maslave, ®4042); |
152 | sitre = (reg4042 & 0x4000) ? 1 : 0; | 152 | sitre = (reg4042 & 0x4000) ? 1 : 0; |
@@ -176,7 +176,6 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
176 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); | 176 | pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); |
177 | } else { | 177 | } else { |
178 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | 178 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; |
179 | u8 pio; | ||
180 | 179 | ||
181 | if (reg48 & u_flag) | 180 | if (reg48 & u_flag) |
182 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | 181 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); |
@@ -188,11 +187,12 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
188 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); | 187 | pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); |
189 | 188 | ||
190 | if (speed >= XFER_MW_DMA_0) | 189 | if (speed >= XFER_MW_DMA_0) |
191 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | 190 | drive->pio_mode = |
191 | mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0; | ||
192 | else | 192 | else |
193 | pio = 2; /* only SWDMA2 is allowed */ | 193 | drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */ |
194 | 194 | ||
195 | piix_set_pio_mode(drive, pio); | 195 | piix_set_pio_mode(hwif, drive); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c index 97642a7a79c4..159955d16c47 100644 --- a/drivers/ide/pmac.c +++ b/drivers/ide/pmac.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/adb.h> | 33 | #include <linux/adb.h> |
34 | #include <linux/pmu.h> | 34 | #include <linux/pmu.h> |
35 | #include <linux/scatterlist.h> | 35 | #include <linux/scatterlist.h> |
36 | #include <linux/slab.h> | ||
36 | 37 | ||
37 | #include <asm/prom.h> | 38 | #include <asm/prom.h> |
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
@@ -43,10 +44,7 @@ | |||
43 | #include <asm/pmac_feature.h> | 44 | #include <asm/pmac_feature.h> |
44 | #include <asm/sections.h> | 45 | #include <asm/sections.h> |
45 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
46 | |||
47 | #ifndef CONFIG_PPC64 | ||
48 | #include <asm/mediabay.h> | 47 | #include <asm/mediabay.h> |
49 | #endif | ||
50 | 48 | ||
51 | #define DRV_NAME "ide-pmac" | 49 | #define DRV_NAME "ide-pmac" |
52 | 50 | ||
@@ -59,13 +57,14 @@ typedef struct pmac_ide_hwif { | |||
59 | int irq; | 57 | int irq; |
60 | int kind; | 58 | int kind; |
61 | int aapl_bus_id; | 59 | int aapl_bus_id; |
62 | unsigned mediabay : 1; | ||
63 | unsigned broken_dma : 1; | 60 | unsigned broken_dma : 1; |
64 | unsigned broken_dma_warn : 1; | 61 | unsigned broken_dma_warn : 1; |
65 | struct device_node* node; | 62 | struct device_node* node; |
66 | struct macio_dev *mdev; | 63 | struct macio_dev *mdev; |
67 | u32 timings[4]; | 64 | u32 timings[4]; |
68 | volatile u32 __iomem * *kauai_fcr; | 65 | volatile u32 __iomem * *kauai_fcr; |
66 | ide_hwif_t *hwif; | ||
67 | |||
69 | /* Those fields are duplicating what is in hwif. We currently | 68 | /* Those fields are duplicating what is in hwif. We currently |
70 | * can't use the hwif ones because of some assumptions that are | 69 | * can't use the hwif ones because of some assumptions that are |
71 | * beeing done by the generic code about the kind of dma controller | 70 | * beeing done by the generic code about the kind of dma controller |
@@ -498,12 +497,11 @@ static void pmac_write_devctl(ide_hwif_t *hwif, u8 ctl) | |||
498 | /* | 497 | /* |
499 | * Old tuning functions (called on hdparm -p), sets up drive PIO timings | 498 | * Old tuning functions (called on hdparm -p), sets up drive PIO timings |
500 | */ | 499 | */ |
501 | static void | 500 | static void pmac_ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
502 | pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
503 | { | 501 | { |
504 | ide_hwif_t *hwif = drive->hwif; | ||
505 | pmac_ide_hwif_t *pmif = | 502 | pmac_ide_hwif_t *pmif = |
506 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | 503 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); |
504 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
507 | struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio); | 505 | struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio); |
508 | u32 *timings, t; | 506 | u32 *timings, t; |
509 | unsigned accessTicks, recTicks; | 507 | unsigned accessTicks, recTicks; |
@@ -780,14 +778,14 @@ set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, | |||
780 | #endif | 778 | #endif |
781 | } | 779 | } |
782 | 780 | ||
783 | static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) | 781 | static void pmac_ide_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
784 | { | 782 | { |
785 | ide_hwif_t *hwif = drive->hwif; | ||
786 | pmac_ide_hwif_t *pmif = | 783 | pmac_ide_hwif_t *pmif = |
787 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | 784 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); |
788 | int ret = 0; | 785 | int ret = 0; |
789 | u32 *timings, *timings2, tl[2]; | 786 | u32 *timings, *timings2, tl[2]; |
790 | u8 unit = drive->dn & 1; | 787 | u8 unit = drive->dn & 1; |
788 | const u8 speed = drive->dma_mode; | ||
791 | 789 | ||
792 | timings = &pmif->timings[unit]; | 790 | timings = &pmif->timings[unit]; |
793 | timings2 = &pmif->timings[unit+2]; | 791 | timings2 = &pmif->timings[unit+2]; |
@@ -854,6 +852,11 @@ sanitize_timings(pmac_ide_hwif_t *pmif) | |||
854 | pmif->timings[2] = pmif->timings[3] = value2; | 852 | pmif->timings[2] = pmif->timings[3] = value2; |
855 | } | 853 | } |
856 | 854 | ||
855 | static int on_media_bay(pmac_ide_hwif_t *pmif) | ||
856 | { | ||
857 | return pmif->mdev && pmif->mdev->media_bay != NULL; | ||
858 | } | ||
859 | |||
857 | /* Suspend call back, should be called after the child devices | 860 | /* Suspend call back, should be called after the child devices |
858 | * have actually been suspended | 861 | * have actually been suspended |
859 | */ | 862 | */ |
@@ -866,7 +869,7 @@ static int pmac_ide_do_suspend(pmac_ide_hwif_t *pmif) | |||
866 | disable_irq(pmif->irq); | 869 | disable_irq(pmif->irq); |
867 | 870 | ||
868 | /* The media bay will handle itself just fine */ | 871 | /* The media bay will handle itself just fine */ |
869 | if (pmif->mediabay) | 872 | if (on_media_bay(pmif)) |
870 | return 0; | 873 | return 0; |
871 | 874 | ||
872 | /* Kauai has bus control FCRs directly here */ | 875 | /* Kauai has bus control FCRs directly here */ |
@@ -889,7 +892,7 @@ static int pmac_ide_do_suspend(pmac_ide_hwif_t *pmif) | |||
889 | static int pmac_ide_do_resume(pmac_ide_hwif_t *pmif) | 892 | static int pmac_ide_do_resume(pmac_ide_hwif_t *pmif) |
890 | { | 893 | { |
891 | /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ | 894 | /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ |
892 | if (!pmif->mediabay) { | 895 | if (!on_media_bay(pmif)) { |
893 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); | 896 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); |
894 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1); | 897 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1); |
895 | msleep(10); | 898 | msleep(10); |
@@ -950,13 +953,11 @@ static void pmac_ide_init_dev(ide_drive_t *drive) | |||
950 | pmac_ide_hwif_t *pmif = | 953 | pmac_ide_hwif_t *pmif = |
951 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | 954 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); |
952 | 955 | ||
953 | if (pmif->mediabay) { | 956 | if (on_media_bay(pmif)) { |
954 | #ifdef CONFIG_PMAC_MEDIABAY | 957 | if (check_media_bay(pmif->mdev->media_bay) == MB_CD) { |
955 | if (check_media_bay_by_base(pmif->regbase, MB_CD) == 0) { | ||
956 | drive->dev_flags &= ~IDE_DFLAG_NOPROBE; | 958 | drive->dev_flags &= ~IDE_DFLAG_NOPROBE; |
957 | return; | 959 | return; |
958 | } | 960 | } |
959 | #endif | ||
960 | drive->dev_flags |= IDE_DFLAG_NOPROBE; | 961 | drive->dev_flags |= IDE_DFLAG_NOPROBE; |
961 | } | 962 | } |
962 | } | 963 | } |
@@ -1072,26 +1073,23 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, | |||
1072 | writel(KAUAI_FCR_UATA_MAGIC | | 1073 | writel(KAUAI_FCR_UATA_MAGIC | |
1073 | KAUAI_FCR_UATA_RESET_N | | 1074 | KAUAI_FCR_UATA_RESET_N | |
1074 | KAUAI_FCR_UATA_ENABLE, pmif->kauai_fcr); | 1075 | KAUAI_FCR_UATA_ENABLE, pmif->kauai_fcr); |
1075 | |||
1076 | pmif->mediabay = 0; | ||
1077 | 1076 | ||
1078 | /* Make sure we have sane timings */ | 1077 | /* Make sure we have sane timings */ |
1079 | sanitize_timings(pmif); | 1078 | sanitize_timings(pmif); |
1080 | 1079 | ||
1080 | /* If we are on a media bay, wait for it to settle and lock it */ | ||
1081 | if (pmif->mdev) | ||
1082 | lock_media_bay(pmif->mdev->media_bay); | ||
1083 | |||
1081 | host = ide_host_alloc(&d, hws, 1); | 1084 | host = ide_host_alloc(&d, hws, 1); |
1082 | if (host == NULL) | 1085 | if (host == NULL) { |
1083 | return -ENOMEM; | 1086 | rc = -ENOMEM; |
1084 | hwif = host->ports[0]; | 1087 | goto bail; |
1088 | } | ||
1089 | hwif = pmif->hwif = host->ports[0]; | ||
1085 | 1090 | ||
1086 | #ifndef CONFIG_PPC64 | 1091 | if (on_media_bay(pmif)) { |
1087 | /* XXX FIXME: Media bay stuff need re-organizing */ | 1092 | /* Fixup bus ID for media bay */ |
1088 | if (np->parent && np->parent->name | ||
1089 | && strcasecmp(np->parent->name, "media-bay") == 0) { | ||
1090 | #ifdef CONFIG_PMAC_MEDIABAY | ||
1091 | media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, | ||
1092 | hwif); | ||
1093 | #endif /* CONFIG_PMAC_MEDIABAY */ | ||
1094 | pmif->mediabay = 1; | ||
1095 | if (!bidp) | 1093 | if (!bidp) |
1096 | pmif->aapl_bus_id = 1; | 1094 | pmif->aapl_bus_id = 1; |
1097 | } else if (pmif->kind == controller_ohare) { | 1095 | } else if (pmif->kind == controller_ohare) { |
@@ -1100,9 +1098,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, | |||
1100 | * units, I keep the old way | 1098 | * units, I keep the old way |
1101 | */ | 1099 | */ |
1102 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1); | 1100 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1); |
1103 | } else | 1101 | } else { |
1104 | #endif | ||
1105 | { | ||
1106 | /* This is necessary to enable IDE when net-booting */ | 1102 | /* This is necessary to enable IDE when net-booting */ |
1107 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1); | 1103 | ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1); |
1108 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1); | 1104 | ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1); |
@@ -1112,17 +1108,21 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, | |||
1112 | } | 1108 | } |
1113 | 1109 | ||
1114 | printk(KERN_INFO DRV_NAME ": Found Apple %s controller (%s), " | 1110 | printk(KERN_INFO DRV_NAME ": Found Apple %s controller (%s), " |
1115 | "bus ID %d%s, irq %d\n", model_name[pmif->kind], | 1111 | "bus ID %d%s, irq %d\n", model_name[pmif->kind], |
1116 | pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, | 1112 | pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, |
1117 | pmif->mediabay ? " (mediabay)" : "", hw->irq); | 1113 | on_media_bay(pmif) ? " (mediabay)" : "", hw->irq); |
1118 | 1114 | ||
1119 | rc = ide_host_register(host, &d, hws); | 1115 | rc = ide_host_register(host, &d, hws); |
1120 | if (rc) { | 1116 | if (rc) |
1121 | ide_host_free(host); | 1117 | pmif->hwif = NULL; |
1122 | return rc; | ||
1123 | } | ||
1124 | 1118 | ||
1125 | return 0; | 1119 | if (pmif->mdev) |
1120 | unlock_media_bay(pmif->mdev->media_bay); | ||
1121 | |||
1122 | bail: | ||
1123 | if (rc && host) | ||
1124 | ide_host_free(host); | ||
1125 | return rc; | ||
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | static void __devinit pmac_ide_init_ports(struct ide_hw *hw, unsigned long base) | 1128 | static void __devinit pmac_ide_init_ports(struct ide_hw *hw, unsigned long base) |
@@ -1362,6 +1362,25 @@ pmac_ide_pci_resume(struct pci_dev *pdev) | |||
1362 | return rc; | 1362 | return rc; |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | #ifdef CONFIG_PMAC_MEDIABAY | ||
1366 | static void pmac_ide_macio_mb_event(struct macio_dev* mdev, int mb_state) | ||
1367 | { | ||
1368 | pmac_ide_hwif_t *pmif = | ||
1369 | (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); | ||
1370 | |||
1371 | switch(mb_state) { | ||
1372 | case MB_CD: | ||
1373 | if (!pmif->hwif->present) | ||
1374 | ide_port_scan(pmif->hwif); | ||
1375 | break; | ||
1376 | default: | ||
1377 | if (pmif->hwif->present) | ||
1378 | ide_port_unregister_devices(pmif->hwif); | ||
1379 | } | ||
1380 | } | ||
1381 | #endif /* CONFIG_PMAC_MEDIABAY */ | ||
1382 | |||
1383 | |||
1365 | static struct of_device_id pmac_ide_macio_match[] = | 1384 | static struct of_device_id pmac_ide_macio_match[] = |
1366 | { | 1385 | { |
1367 | { | 1386 | { |
@@ -1386,6 +1405,9 @@ static struct macio_driver pmac_ide_macio_driver = | |||
1386 | .probe = pmac_ide_macio_attach, | 1405 | .probe = pmac_ide_macio_attach, |
1387 | .suspend = pmac_ide_macio_suspend, | 1406 | .suspend = pmac_ide_macio_suspend, |
1388 | .resume = pmac_ide_macio_resume, | 1407 | .resume = pmac_ide_macio_resume, |
1408 | #ifdef CONFIG_PMAC_MEDIABAY | ||
1409 | .mediabay_event = pmac_ide_macio_mb_event, | ||
1410 | #endif | ||
1389 | }; | 1411 | }; |
1390 | 1412 | ||
1391 | static const struct pci_device_id pmac_ide_pci_match[] = { | 1413 | static const struct pci_device_id pmac_ide_pci_match[] = { |
@@ -1629,8 +1651,8 @@ pmac_ide_dma_test_irq (ide_drive_t *drive) | |||
1629 | if ((status & FLUSH) == 0) | 1651 | if ((status & FLUSH) == 0) |
1630 | break; | 1652 | break; |
1631 | if (++timeout > 100) { | 1653 | if (++timeout > 100) { |
1632 | printk(KERN_WARNING "ide%d, ide_dma_test_irq \ | 1654 | printk(KERN_WARNING "ide%d, ide_dma_test_irq timeout flushing channel\n", |
1633 | timeout flushing channel\n", hwif->index); | 1655 | hwif->index); |
1634 | break; | 1656 | break; |
1635 | } | 1657 | } |
1636 | } | 1658 | } |
diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c index 74696edc8d1d..3f0244fd8e62 100644 --- a/drivers/ide/qd65xx.c +++ b/drivers/ide/qd65xx.c | |||
@@ -189,15 +189,13 @@ static void qd_set_timing (ide_drive_t *drive, u8 timing) | |||
189 | printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); | 189 | printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); |
190 | } | 190 | } |
191 | 191 | ||
192 | static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) | 192 | static void qd6500_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
193 | { | 193 | { |
194 | u16 *id = drive->id; | 194 | u16 *id = drive->id; |
195 | int active_time = 175; | 195 | int active_time = 175; |
196 | int recovery_time = 415; /* worst case values from the dos driver */ | 196 | int recovery_time = 415; /* worst case values from the dos driver */ |
197 | 197 | ||
198 | /* | 198 | /* FIXME: use drive->pio_mode value */ |
199 | * FIXME: use "pio" value | ||
200 | */ | ||
201 | if (!qd_find_disk_type(drive, &active_time, &recovery_time) && | 199 | if (!qd_find_disk_type(drive, &active_time, &recovery_time) && |
202 | (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) && | 200 | (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) && |
203 | id[ATA_ID_EIDE_PIO] >= 240) { | 201 | id[ATA_ID_EIDE_PIO] >= 240) { |
@@ -211,9 +209,9 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
211 | active_time, recovery_time)); | 209 | active_time, recovery_time)); |
212 | } | 210 | } |
213 | 211 | ||
214 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | 212 | static void qd6580_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
215 | { | 213 | { |
216 | ide_hwif_t *hwif = drive->hwif; | 214 | const u8 pio = drive->pio_mode - XFER_PIO_0; |
217 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | 215 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
218 | unsigned int cycle_time; | 216 | unsigned int cycle_time; |
219 | int active_time = 175; | 217 | int active_time = 175; |
diff --git a/drivers/ide/rapide.c b/drivers/ide/rapide.c index 00f54248f41f..48d976aad7ab 100644 --- a/drivers/ide/rapide.c +++ b/drivers/ide/rapide.c | |||
@@ -3,7 +3,6 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <linux/slab.h> | ||
7 | #include <linux/blkdev.h> | 6 | #include <linux/blkdev.h> |
8 | #include <linux/errno.h> | 7 | #include <linux/errno.h> |
9 | #include <linux/ide.h> | 8 | #include <linux/ide.h> |
diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c index d467478d68da..356b9b504ffd 100644 --- a/drivers/ide/sc1200.c +++ b/drivers/ide/sc1200.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/slab.h> | ||
17 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
19 | #include <linux/ide.h> | 20 | #include <linux/ide.h> |
@@ -122,13 +123,13 @@ out: | |||
122 | return mask; | 123 | return mask; |
123 | } | 124 | } |
124 | 125 | ||
125 | static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | 126 | static void sc1200_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
126 | { | 127 | { |
127 | ide_hwif_t *hwif = drive->hwif; | ||
128 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 128 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
129 | unsigned int reg, timings; | 129 | unsigned int reg, timings; |
130 | unsigned short pci_clock; | 130 | unsigned short pci_clock; |
131 | unsigned int basereg = hwif->channel ? 0x50 : 0x40; | 131 | unsigned int basereg = hwif->channel ? 0x50 : 0x40; |
132 | const u8 mode = drive->dma_mode; | ||
132 | 133 | ||
133 | static const u32 udma_timing[3][3] = { | 134 | static const u32 udma_timing[3][3] = { |
134 | { 0x00921250, 0x00911140, 0x00911030 }, | 135 | { 0x00921250, 0x00911140, 0x00911030 }, |
@@ -193,10 +194,10 @@ static int sc1200_dma_end(ide_drive_t *drive) | |||
193 | * will have valid default PIO timings set up before we get here. | 194 | * will have valid default PIO timings set up before we get here. |
194 | */ | 195 | */ |
195 | 196 | ||
196 | static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) | 197 | static void sc1200_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
197 | { | 198 | { |
198 | ide_hwif_t *hwif = drive->hwif; | ||
199 | int mode = -1; | 199 | int mode = -1; |
200 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
200 | 201 | ||
201 | /* | 202 | /* |
202 | * bad abuse of ->set_pio_mode interface | 203 | * bad abuse of ->set_pio_mode interface |
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 1104bb301eb9..b7f5b0c4310c 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c | |||
@@ -199,16 +199,15 @@ scc_ide_outsl(unsigned long port, void *addr, u32 count) | |||
199 | 199 | ||
200 | /** | 200 | /** |
201 | * scc_set_pio_mode - set host controller for PIO mode | 201 | * scc_set_pio_mode - set host controller for PIO mode |
202 | * @hwif: port | ||
202 | * @drive: drive | 203 | * @drive: drive |
203 | * @pio: PIO mode number | ||
204 | * | 204 | * |
205 | * Load the timing settings for this device mode into the | 205 | * Load the timing settings for this device mode into the |
206 | * controller. | 206 | * controller. |
207 | */ | 207 | */ |
208 | 208 | ||
209 | static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) | 209 | static void scc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
210 | { | 210 | { |
211 | ide_hwif_t *hwif = drive->hwif; | ||
212 | struct scc_ports *ports = ide_get_hwifdata(hwif); | 211 | struct scc_ports *ports = ide_get_hwifdata(hwif); |
213 | unsigned long ctl_base = ports->ctl; | 212 | unsigned long ctl_base = ports->ctl; |
214 | unsigned long cckctrl_port = ctl_base + 0xff0; | 213 | unsigned long cckctrl_port = ctl_base + 0xff0; |
@@ -216,6 +215,7 @@ static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
216 | unsigned long pioct_port = ctl_base + 0x004; | 215 | unsigned long pioct_port = ctl_base + 0x004; |
217 | unsigned long reg; | 216 | unsigned long reg; |
218 | int offset; | 217 | int offset; |
218 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
219 | 219 | ||
220 | reg = in_be32((void __iomem *)cckctrl_port); | 220 | reg = in_be32((void __iomem *)cckctrl_port); |
221 | if (reg & CCKCTRL_ATACLKOEN) { | 221 | if (reg & CCKCTRL_ATACLKOEN) { |
@@ -231,16 +231,15 @@ static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
231 | 231 | ||
232 | /** | 232 | /** |
233 | * scc_set_dma_mode - set host controller for DMA mode | 233 | * scc_set_dma_mode - set host controller for DMA mode |
234 | * @hwif: port | ||
234 | * @drive: drive | 235 | * @drive: drive |
235 | * @speed: DMA mode | ||
236 | * | 236 | * |
237 | * Load the timing settings for this device mode into the | 237 | * Load the timing settings for this device mode into the |
238 | * controller. | 238 | * controller. |
239 | */ | 239 | */ |
240 | 240 | ||
241 | static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) | 241 | static void scc_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
242 | { | 242 | { |
243 | ide_hwif_t *hwif = drive->hwif; | ||
244 | struct scc_ports *ports = ide_get_hwifdata(hwif); | 243 | struct scc_ports *ports = ide_get_hwifdata(hwif); |
245 | unsigned long ctl_base = ports->ctl; | 244 | unsigned long ctl_base = ports->ctl; |
246 | unsigned long cckctrl_port = ctl_base + 0xff0; | 245 | unsigned long cckctrl_port = ctl_base + 0xff0; |
@@ -254,6 +253,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
254 | int offset, idx; | 253 | int offset, idx; |
255 | unsigned long reg; | 254 | unsigned long reg; |
256 | unsigned long jcactsel; | 255 | unsigned long jcactsel; |
256 | const u8 speed = drive->dma_mode; | ||
257 | 257 | ||
258 | reg = in_be32((void __iomem *)cckctrl_port); | 258 | reg = in_be32((void __iomem *)cckctrl_port); |
259 | if (reg & CCKCTRL_ATACLKOEN) { | 259 | if (reg & CCKCTRL_ATACLKOEN) { |
@@ -872,20 +872,18 @@ static struct pci_driver scc_pci_driver = { | |||
872 | .remove = __devexit_p(scc_remove), | 872 | .remove = __devexit_p(scc_remove), |
873 | }; | 873 | }; |
874 | 874 | ||
875 | static int scc_ide_init(void) | 875 | static int __init scc_ide_init(void) |
876 | { | 876 | { |
877 | return ide_pci_register_driver(&scc_pci_driver); | 877 | return ide_pci_register_driver(&scc_pci_driver); |
878 | } | 878 | } |
879 | 879 | ||
880 | module_init(scc_ide_init); | 880 | static void __exit scc_ide_exit(void) |
881 | /* -- No exit code? | ||
882 | static void scc_ide_exit(void) | ||
883 | { | 881 | { |
884 | ide_pci_unregister_driver(&scc_pci_driver); | 882 | pci_unregister_driver(&scc_pci_driver); |
885 | } | 883 | } |
886 | module_exit(scc_ide_exit); | ||
887 | */ | ||
888 | 884 | ||
885 | module_init(scc_ide_init); | ||
886 | module_exit(scc_ide_exit); | ||
889 | 887 | ||
890 | MODULE_DESCRIPTION("PCI driver module for Toshiba SCC IDE"); | 888 | MODULE_DESCRIPTION("PCI driver module for Toshiba SCC IDE"); |
891 | MODULE_LICENSE("GPL"); | 889 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c index b6554ef92716..35fb8dabb55d 100644 --- a/drivers/ide/serverworks.c +++ b/drivers/ide/serverworks.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Copyright (C) 1998-2000 Michel Aubry | 2 | * Copyright (C) 1998-2000 Michel Aubry |
3 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz | 3 | * Copyright (C) 1998-2000 Andrzej Krzysztofowicz |
4 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | 4 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
5 | * Copyright (C) 2007 Bartlomiej Zolnierkiewicz | 5 | * Copyright (C) 2007-2010 Bartlomiej Zolnierkiewicz |
6 | * Portions copyright (c) 2001 Sun Microsystems | 6 | * Portions copyright (c) 2001 Sun Microsystems |
7 | * | 7 | * |
8 | * | 8 | * |
@@ -52,8 +52,6 @@ static const char *svwks_bad_ata100[] = { | |||
52 | NULL | 52 | NULL |
53 | }; | 53 | }; |
54 | 54 | ||
55 | static struct pci_dev *isa_dev; | ||
56 | |||
57 | static int check_in_drive_lists (ide_drive_t *drive, const char **list) | 55 | static int check_in_drive_lists (ide_drive_t *drive, const char **list) |
58 | { | 56 | { |
59 | char *m = (char *)&drive->id[ATA_ID_PROD]; | 57 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
@@ -67,26 +65,14 @@ static int check_in_drive_lists (ide_drive_t *drive, const char **list) | |||
67 | static u8 svwks_udma_filter(ide_drive_t *drive) | 65 | static u8 svwks_udma_filter(ide_drive_t *drive) |
68 | { | 66 | { |
69 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 67 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
70 | u8 mask = 0; | ||
71 | 68 | ||
72 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) | 69 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) { |
73 | return 0x1f; | 70 | return 0x1f; |
74 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { | ||
75 | u32 reg = 0; | ||
76 | if (isa_dev) | ||
77 | pci_read_config_dword(isa_dev, 0x64, ®); | ||
78 | |||
79 | /* | ||
80 | * Don't enable UDMA on disk devices for the moment | ||
81 | */ | ||
82 | if(drive->media == ide_disk) | ||
83 | return 0; | ||
84 | /* Check the OSB4 DMA33 enable bit */ | ||
85 | return ((reg & 0x00004000) == 0x00004000) ? 0x07 : 0; | ||
86 | } else if (dev->revision < SVWKS_CSB5_REVISION_NEW) { | 71 | } else if (dev->revision < SVWKS_CSB5_REVISION_NEW) { |
87 | return 0x07; | 72 | return 0x07; |
88 | } else if (dev->revision >= SVWKS_CSB5_REVISION_NEW) { | 73 | } else { |
89 | u8 btr = 0, mode; | 74 | u8 btr = 0, mode, mask; |
75 | |||
90 | pci_read_config_byte(dev, 0x5A, &btr); | 76 | pci_read_config_byte(dev, 0x5A, &btr); |
91 | mode = btr & 0x3; | 77 | mode = btr & 0x3; |
92 | 78 | ||
@@ -101,13 +87,9 @@ static u8 svwks_udma_filter(ide_drive_t *drive) | |||
101 | case 1: mask = 0x07; break; | 87 | case 1: mask = 0x07; break; |
102 | default: mask = 0x00; break; | 88 | default: mask = 0x00; break; |
103 | } | 89 | } |
104 | } | ||
105 | if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) || | ||
106 | (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) && | ||
107 | (!(PCI_FUNC(dev->devfn) & 1))) | ||
108 | mask = 0x1f; | ||
109 | 90 | ||
110 | return mask; | 91 | return mask; |
92 | } | ||
111 | } | 93 | } |
112 | 94 | ||
113 | static u8 svwks_csb_check (struct pci_dev *dev) | 95 | static u8 svwks_csb_check (struct pci_dev *dev) |
@@ -124,12 +106,13 @@ static u8 svwks_csb_check (struct pci_dev *dev) | |||
124 | return 0; | 106 | return 0; |
125 | } | 107 | } |
126 | 108 | ||
127 | static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio) | 109 | static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
128 | { | 110 | { |
129 | static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; | 111 | static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; |
130 | static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; | 112 | static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; |
131 | 113 | ||
132 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 114 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
115 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
133 | 116 | ||
134 | pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); | 117 | pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); |
135 | 118 | ||
@@ -145,14 +128,14 @@ static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
145 | } | 128 | } |
146 | } | 129 | } |
147 | 130 | ||
148 | static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | 131 | static void svwks_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
149 | { | 132 | { |
150 | static const u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; | 133 | static const u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; |
151 | static const u8 dma_modes[] = { 0x77, 0x21, 0x20 }; | 134 | static const u8 dma_modes[] = { 0x77, 0x21, 0x20 }; |
152 | static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; | 135 | static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; |
153 | 136 | ||
154 | ide_hwif_t *hwif = drive->hwif; | ||
155 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 137 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
138 | const u8 speed = drive->dma_mode; | ||
156 | u8 unit = drive->dn & 1; | 139 | u8 unit = drive->dn & 1; |
157 | 140 | ||
158 | u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; | 141 | u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; |
@@ -185,8 +168,9 @@ static int init_chipset_svwks(struct pci_dev *dev) | |||
185 | 168 | ||
186 | /* OSB4 : South Bridge and IDE */ | 169 | /* OSB4 : South Bridge and IDE */ |
187 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { | 170 | if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { |
188 | isa_dev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS, | 171 | struct pci_dev *isa_dev = |
189 | PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL); | 172 | pci_get_device(PCI_VENDOR_ID_SERVERWORKS, |
173 | PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL); | ||
190 | if (isa_dev) { | 174 | if (isa_dev) { |
191 | pci_read_config_dword(isa_dev, 0x64, ®); | 175 | pci_read_config_dword(isa_dev, 0x64, ®); |
192 | reg &= ~0x00002000; /* disable 600ns interrupt mask */ | 176 | reg &= ~0x00002000; /* disable 600ns interrupt mask */ |
@@ -195,6 +179,7 @@ static int init_chipset_svwks(struct pci_dev *dev) | |||
195 | "enabled.\n", pci_name(dev)); | 179 | "enabled.\n", pci_name(dev)); |
196 | reg |= 0x00004000; /* enable UDMA/33 support */ | 180 | reg |= 0x00004000; /* enable UDMA/33 support */ |
197 | pci_write_config_dword(isa_dev, 0x64, reg); | 181 | pci_write_config_dword(isa_dev, 0x64, reg); |
182 | pci_dev_put(isa_dev); | ||
198 | } | 183 | } |
199 | } | 184 | } |
200 | 185 | ||
@@ -343,7 +328,6 @@ static u8 svwks_cable_detect(ide_hwif_t *hwif) | |||
343 | static const struct ide_port_ops osb4_port_ops = { | 328 | static const struct ide_port_ops osb4_port_ops = { |
344 | .set_pio_mode = svwks_set_pio_mode, | 329 | .set_pio_mode = svwks_set_pio_mode, |
345 | .set_dma_mode = svwks_set_dma_mode, | 330 | .set_dma_mode = svwks_set_dma_mode, |
346 | .udma_filter = svwks_udma_filter, | ||
347 | }; | 331 | }; |
348 | 332 | ||
349 | static const struct ide_port_ops svwks_port_ops = { | 333 | static const struct ide_port_ops svwks_port_ops = { |
@@ -460,6 +444,6 @@ static void __exit svwks_ide_exit(void) | |||
460 | module_init(svwks_ide_init); | 444 | module_init(svwks_ide_init); |
461 | module_exit(svwks_ide_exit); | 445 | module_exit(svwks_ide_exit); |
462 | 446 | ||
463 | MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick"); | 447 | MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick, Bartlomiej Zolnierkiewicz"); |
464 | MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE"); | 448 | MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE"); |
465 | MODULE_LICENSE("GPL"); | 449 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c index b7d61dc64096..e3ea591f66d3 100644 --- a/drivers/ide/sgiioc4.c +++ b/drivers/ide/sgiioc4.c | |||
@@ -255,7 +255,7 @@ static int sgiioc4_dma_end(ide_drive_t *drive) | |||
255 | return dma_stat; | 255 | return dma_stat; |
256 | } | 256 | } |
257 | 257 | ||
258 | static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed) | 258 | static void sgiioc4_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
259 | { | 259 | { |
260 | } | 260 | } |
261 | 261 | ||
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c index d95df528562f..ddeda444a27a 100644 --- a/drivers/ide/siimage.c +++ b/drivers/ide/siimage.c | |||
@@ -229,19 +229,18 @@ static u8 sil_sata_udma_filter(ide_drive_t *drive) | |||
229 | 229 | ||
230 | /** | 230 | /** |
231 | * sil_set_pio_mode - set host controller for PIO mode | 231 | * sil_set_pio_mode - set host controller for PIO mode |
232 | * @hwif: port | ||
232 | * @drive: drive | 233 | * @drive: drive |
233 | * @pio: PIO mode number | ||
234 | * | 234 | * |
235 | * Load the timing settings for this device mode into the | 235 | * Load the timing settings for this device mode into the |
236 | * controller. | 236 | * controller. |
237 | */ | 237 | */ |
238 | 238 | ||
239 | static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | 239 | static void sil_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
240 | { | 240 | { |
241 | static const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 }; | 241 | static const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 }; |
242 | static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 }; | 242 | static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 }; |
243 | 243 | ||
244 | ide_hwif_t *hwif = drive->hwif; | ||
245 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 244 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
246 | ide_drive_t *pair = ide_get_pair_dev(drive); | 245 | ide_drive_t *pair = ide_get_pair_dev(drive); |
247 | u32 speedt = 0; | 246 | u32 speedt = 0; |
@@ -249,6 +248,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
249 | unsigned long addr = siimage_seldev(drive, 0x04); | 248 | unsigned long addr = siimage_seldev(drive, 0x04); |
250 | unsigned long tfaddr = siimage_selreg(hwif, 0x02); | 249 | unsigned long tfaddr = siimage_selreg(hwif, 0x02); |
251 | unsigned long base = (unsigned long)hwif->hwif_data; | 250 | unsigned long base = (unsigned long)hwif->hwif_data; |
251 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
252 | u8 tf_pio = pio; | 252 | u8 tf_pio = pio; |
253 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | 253 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
254 | u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) | 254 | u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) |
@@ -258,7 +258,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
258 | 258 | ||
259 | /* trim *taskfile* PIO to the slowest of the master/slave */ | 259 | /* trim *taskfile* PIO to the slowest of the master/slave */ |
260 | if (pair) { | 260 | if (pair) { |
261 | u8 pair_pio = ide_get_best_pio_mode(pair, 255, 4); | 261 | u8 pair_pio = pair->pio_mode - XFER_PIO_0; |
262 | 262 | ||
263 | if (pair_pio < tf_pio) | 263 | if (pair_pio < tf_pio) |
264 | tf_pio = pair_pio; | 264 | tf_pio = pair_pio; |
@@ -289,19 +289,18 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
289 | 289 | ||
290 | /** | 290 | /** |
291 | * sil_set_dma_mode - set host controller for DMA mode | 291 | * sil_set_dma_mode - set host controller for DMA mode |
292 | * @hwif: port | ||
292 | * @drive: drive | 293 | * @drive: drive |
293 | * @speed: DMA mode | ||
294 | * | 294 | * |
295 | * Tune the SiI chipset for the desired DMA mode. | 295 | * Tune the SiI chipset for the desired DMA mode. |
296 | */ | 296 | */ |
297 | 297 | ||
298 | static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | 298 | static void sil_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
299 | { | 299 | { |
300 | static const u8 ultra6[] = { 0x0F, 0x0B, 0x07, 0x05, 0x03, 0x02, 0x01 }; | 300 | static const u8 ultra6[] = { 0x0F, 0x0B, 0x07, 0x05, 0x03, 0x02, 0x01 }; |
301 | static const u8 ultra5[] = { 0x0C, 0x07, 0x05, 0x04, 0x02, 0x01 }; | 301 | static const u8 ultra5[] = { 0x0C, 0x07, 0x05, 0x04, 0x02, 0x01 }; |
302 | static const u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; | 302 | static const u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; |
303 | 303 | ||
304 | ide_hwif_t *hwif = drive->hwif; | ||
305 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 304 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
306 | unsigned long base = (unsigned long)hwif->hwif_data; | 305 | unsigned long base = (unsigned long)hwif->hwif_data; |
307 | u16 ultra = 0, multi = 0; | 306 | u16 ultra = 0, multi = 0; |
@@ -311,6 +310,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
311 | : (mmio ? 0xB4 : 0x80); | 310 | : (mmio ? 0xB4 : 0x80); |
312 | unsigned long ma = siimage_seldev(drive, 0x08); | 311 | unsigned long ma = siimage_seldev(drive, 0x08); |
313 | unsigned long ua = siimage_seldev(drive, 0x0C); | 312 | unsigned long ua = siimage_seldev(drive, 0x0C); |
313 | const u8 speed = drive->dma_mode; | ||
314 | 314 | ||
315 | scsc = sil_ioread8 (dev, base + (mmio ? 0x4A : 0x8A)); | 315 | scsc = sil_ioread8 (dev, base + (mmio ? 0x4A : 0x8A)); |
316 | mode = sil_ioread8 (dev, base + addr_mask); | 316 | mode = sil_ioread8 (dev, base + addr_mask); |
diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c index 3b88eba04c9c..db7f4e761dbc 100644 --- a/drivers/ide/sis5513.c +++ b/drivers/ide/sis5513.c | |||
@@ -290,10 +290,10 @@ static void config_drive_art_rwp(ide_drive_t *drive) | |||
290 | pci_write_config_byte(dev, 0x4b, rw_prefetch); | 290 | pci_write_config_byte(dev, 0x4b, rw_prefetch); |
291 | } | 291 | } |
292 | 292 | ||
293 | static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) | 293 | static void sis_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
294 | { | 294 | { |
295 | config_drive_art_rwp(drive); | 295 | config_drive_art_rwp(drive); |
296 | sis_program_timings(drive, XFER_PIO_0 + pio); | 296 | sis_program_timings(drive, drive->pio_mode); |
297 | } | 297 | } |
298 | 298 | ||
299 | static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) | 299 | static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) |
@@ -340,8 +340,10 @@ static void sis_program_udma_timings(ide_drive_t *drive, const u8 mode) | |||
340 | sis_ata33_program_udma_timings(drive, mode); | 340 | sis_ata33_program_udma_timings(drive, mode); |
341 | } | 341 | } |
342 | 342 | ||
343 | static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) | 343 | static void sis_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
344 | { | 344 | { |
345 | const u8 speed = drive->dma_mode; | ||
346 | |||
345 | if (speed >= XFER_UDMA_0) | 347 | if (speed >= XFER_UDMA_0) |
346 | sis_program_udma_timings(drive, speed); | 348 | sis_program_udma_timings(drive, speed); |
347 | else | 349 | else |
@@ -632,12 +634,3 @@ module_exit(sis5513_ide_exit); | |||
632 | MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik"); | 634 | MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik"); |
633 | MODULE_DESCRIPTION("PCI driver module for SIS IDE"); | 635 | MODULE_DESCRIPTION("PCI driver module for SIS IDE"); |
634 | MODULE_LICENSE("GPL"); | 636 | MODULE_LICENSE("GPL"); |
635 | |||
636 | /* | ||
637 | * TODO: | ||
638 | * - CLEANUP | ||
639 | * - More checks in the config registers (force values instead of | ||
640 | * relying on the BIOS setting them correctly). | ||
641 | * - Further optimisations ? | ||
642 | * . for example ATA66+ regs 0x48 & 0x4A | ||
643 | */ | ||
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c index d698da470d6f..f21dc2ad7682 100644 --- a/drivers/ide/sl82c105.c +++ b/drivers/ide/sl82c105.c | |||
@@ -24,13 +24,6 @@ | |||
24 | 24 | ||
25 | #define DRV_NAME "sl82c105" | 25 | #define DRV_NAME "sl82c105" |
26 | 26 | ||
27 | #undef DEBUG | ||
28 | |||
29 | #ifdef DEBUG | ||
30 | #define DBG(arg) printk arg | ||
31 | #else | ||
32 | #define DBG(fmt,...) | ||
33 | #endif | ||
34 | /* | 27 | /* |
35 | * SL82C105 PCI config register 0x40 bits. | 28 | * SL82C105 PCI config register 0x40 bits. |
36 | */ | 29 | */ |
@@ -70,12 +63,13 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | |||
70 | /* | 63 | /* |
71 | * Configure the chipset for PIO mode. | 64 | * Configure the chipset for PIO mode. |
72 | */ | 65 | */ |
73 | static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) | 66 | static void sl82c105_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
74 | { | 67 | { |
75 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 68 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
76 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); | 69 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); |
77 | int reg = 0x44 + drive->dn * 4; | 70 | int reg = 0x44 + drive->dn * 4; |
78 | u16 drv_ctrl; | 71 | u16 drv_ctrl; |
72 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
79 | 73 | ||
80 | drv_ctrl = get_pio_timings(drive, pio); | 74 | drv_ctrl = get_pio_timings(drive, pio); |
81 | 75 | ||
@@ -98,14 +92,12 @@ static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
98 | /* | 92 | /* |
99 | * Configure the chipset for DMA mode. | 93 | * Configure the chipset for DMA mode. |
100 | */ | 94 | */ |
101 | static void sl82c105_set_dma_mode(ide_drive_t *drive, const u8 speed) | 95 | static void sl82c105_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
102 | { | 96 | { |
103 | static u16 mwdma_timings[] = {0x0707, 0x0201, 0x0200}; | 97 | static u16 mwdma_timings[] = {0x0707, 0x0201, 0x0200}; |
104 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); | 98 | unsigned long timings = (unsigned long)ide_get_drivedata(drive); |
105 | u16 drv_ctrl; | 99 | u16 drv_ctrl; |
106 | 100 | const u8 speed = drive->dma_mode; | |
107 | DBG(("sl82c105_tune_chipset(drive:%s, speed:%s)\n", | ||
108 | drive->name, ide_xfer_verbose(speed))); | ||
109 | 101 | ||
110 | drv_ctrl = mwdma_timings[speed - XFER_MW_DMA_0]; | 102 | drv_ctrl = mwdma_timings[speed - XFER_MW_DMA_0]; |
111 | 103 | ||
@@ -196,8 +188,6 @@ static void sl82c105_dma_start(ide_drive_t *drive) | |||
196 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 188 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
197 | int reg = 0x44 + drive->dn * 4; | 189 | int reg = 0x44 + drive->dn * 4; |
198 | 190 | ||
199 | DBG(("%s(drive:%s)\n", __func__, drive->name)); | ||
200 | |||
201 | pci_write_config_word(dev, reg, | 191 | pci_write_config_word(dev, reg, |
202 | (unsigned long)ide_get_drivedata(drive) >> 16); | 192 | (unsigned long)ide_get_drivedata(drive) >> 16); |
203 | 193 | ||
@@ -209,8 +199,6 @@ static void sl82c105_dma_clear(ide_drive_t *drive) | |||
209 | { | 199 | { |
210 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 200 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
211 | 201 | ||
212 | DBG(("sl82c105_dma_clear(drive:%s)\n", drive->name)); | ||
213 | |||
214 | sl82c105_reset_host(dev); | 202 | sl82c105_reset_host(dev); |
215 | } | 203 | } |
216 | 204 | ||
@@ -218,11 +206,7 @@ static int sl82c105_dma_end(ide_drive_t *drive) | |||
218 | { | 206 | { |
219 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 207 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
220 | int reg = 0x44 + drive->dn * 4; | 208 | int reg = 0x44 + drive->dn * 4; |
221 | int ret; | 209 | int ret = ide_dma_end(drive); |
222 | |||
223 | DBG(("%s(drive:%s)\n", __func__, drive->name)); | ||
224 | |||
225 | ret = ide_dma_end(drive); | ||
226 | 210 | ||
227 | pci_write_config_word(dev, reg, | 211 | pci_write_config_word(dev, reg, |
228 | (unsigned long)ide_get_drivedata(drive)); | 212 | (unsigned long)ide_get_drivedata(drive)); |
@@ -239,8 +223,6 @@ static void sl82c105_resetproc(ide_drive_t *drive) | |||
239 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 223 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
240 | u32 val; | 224 | u32 val; |
241 | 225 | ||
242 | DBG(("sl82c105_resetproc(drive:%s)\n", drive->name)); | ||
243 | |||
244 | pci_read_config_dword(dev, 0x40, &val); | 226 | pci_read_config_dword(dev, 0x40, &val); |
245 | val |= (CTRL_P1F16 | CTRL_P0F16); | 227 | val |= (CTRL_P1F16 | CTRL_P0F16); |
246 | pci_write_config_dword(dev, 0x40, val); | 228 | pci_write_config_dword(dev, 0x40, val); |
@@ -291,8 +273,6 @@ static int init_chipset_sl82c105(struct pci_dev *dev) | |||
291 | { | 273 | { |
292 | u32 val; | 274 | u32 val; |
293 | 275 | ||
294 | DBG(("init_chipset_sl82c105()\n")); | ||
295 | |||
296 | pci_read_config_dword(dev, 0x40, &val); | 276 | pci_read_config_dword(dev, 0x40, &val); |
297 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; | 277 | val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; |
298 | pci_write_config_dword(dev, 0x40, val); | 278 | pci_write_config_dword(dev, 0x40, val); |
diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c index 9aec78d3bcff..864ffe0e26d9 100644 --- a/drivers/ide/slc90e66.c +++ b/drivers/ide/slc90e66.c | |||
@@ -18,9 +18,8 @@ | |||
18 | 18 | ||
19 | static DEFINE_SPINLOCK(slc90e66_lock); | 19 | static DEFINE_SPINLOCK(slc90e66_lock); |
20 | 20 | ||
21 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | 21 | static void slc90e66_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
22 | { | 22 | { |
23 | ide_hwif_t *hwif = drive->hwif; | ||
24 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 23 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
25 | int is_slave = drive->dn & 1; | 24 | int is_slave = drive->dn & 1; |
26 | int master_port = hwif->channel ? 0x42 : 0x40; | 25 | int master_port = hwif->channel ? 0x42 : 0x40; |
@@ -29,6 +28,8 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
29 | u16 master_data; | 28 | u16 master_data; |
30 | u8 slave_data; | 29 | u8 slave_data; |
31 | int control = 0; | 30 | int control = 0; |
31 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
32 | |||
32 | /* ISP RTC */ | 33 | /* ISP RTC */ |
33 | static const u8 timings[][2] = { | 34 | static const u8 timings[][2] = { |
34 | { 0, 0 }, | 35 | { 0, 0 }, |
@@ -71,14 +72,14 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
71 | spin_unlock_irqrestore(&slc90e66_lock, flags); | 72 | spin_unlock_irqrestore(&slc90e66_lock, flags); |
72 | } | 73 | } |
73 | 74 | ||
74 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | 75 | static void slc90e66_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
75 | { | 76 | { |
76 | ide_hwif_t *hwif = drive->hwif; | ||
77 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 77 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
78 | u8 maslave = hwif->channel ? 0x42 : 0x40; | 78 | u8 maslave = hwif->channel ? 0x42 : 0x40; |
79 | int sitre = 0, a_speed = 7 << (drive->dn * 4); | 79 | int sitre = 0, a_speed = 7 << (drive->dn * 4); |
80 | int u_speed = 0, u_flag = 1 << drive->dn; | 80 | int u_speed = 0, u_flag = 1 << drive->dn; |
81 | u16 reg4042, reg44, reg48, reg4a; | 81 | u16 reg4042, reg44, reg48, reg4a; |
82 | const u8 speed = drive->dma_mode; | ||
82 | 83 | ||
83 | pci_read_config_word(dev, maslave, ®4042); | 84 | pci_read_config_word(dev, maslave, ®4042); |
84 | sitre = (reg4042 & 0x4000) ? 1 : 0; | 85 | sitre = (reg4042 & 0x4000) ? 1 : 0; |
@@ -91,15 +92,13 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
91 | 92 | ||
92 | if (!(reg48 & u_flag)) | 93 | if (!(reg48 & u_flag)) |
93 | pci_write_config_word(dev, 0x48, reg48|u_flag); | 94 | pci_write_config_word(dev, 0x48, reg48|u_flag); |
94 | /* FIXME: (reg4a & a_speed) ? */ | 95 | if ((reg4a & a_speed) != u_speed) { |
95 | if ((reg4a & u_speed) != u_speed) { | ||
96 | pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); | 96 | pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); |
97 | pci_read_config_word(dev, 0x4a, ®4a); | 97 | pci_read_config_word(dev, 0x4a, ®4a); |
98 | pci_write_config_word(dev, 0x4a, reg4a|u_speed); | 98 | pci_write_config_word(dev, 0x4a, reg4a|u_speed); |
99 | } | 99 | } |
100 | } else { | 100 | } else { |
101 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | 101 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; |
102 | u8 pio; | ||
103 | 102 | ||
104 | if (reg48 & u_flag) | 103 | if (reg48 & u_flag) |
105 | pci_write_config_word(dev, 0x48, reg48 & ~u_flag); | 104 | pci_write_config_word(dev, 0x48, reg48 & ~u_flag); |
@@ -107,11 +106,12 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
107 | pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); | 106 | pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); |
108 | 107 | ||
109 | if (speed >= XFER_MW_DMA_0) | 108 | if (speed >= XFER_MW_DMA_0) |
110 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | 109 | drive->pio_mode = |
110 | mwdma_to_pio[speed - XFER_MW_DMA_0] + XFER_PIO_0; | ||
111 | else | 111 | else |
112 | pio = 2; /* only SWDMA2 is allowed */ | 112 | drive->pio_mode = XFER_PIO_2; /* for SWDMA2 */ |
113 | 113 | ||
114 | slc90e66_set_pio_mode(drive, pio); | 114 | slc90e66_set_pio_mode(hwif, drive); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c index 05a93d6baecc..e444d24934b3 100644 --- a/drivers/ide/tc86c001.c +++ b/drivers/ide/tc86c001.c | |||
@@ -13,11 +13,11 @@ | |||
13 | 13 | ||
14 | #define DRV_NAME "tc86c001" | 14 | #define DRV_NAME "tc86c001" |
15 | 15 | ||
16 | static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) | 16 | static void tc86c001_set_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
17 | { | 17 | { |
18 | ide_hwif_t *hwif = drive->hwif; | ||
19 | unsigned long scr_port = hwif->config_data + (drive->dn ? 0x02 : 0x00); | 18 | unsigned long scr_port = hwif->config_data + (drive->dn ? 0x02 : 0x00); |
20 | u16 mode, scr = inw(scr_port); | 19 | u16 mode, scr = inw(scr_port); |
20 | const u8 speed = drive->dma_mode; | ||
21 | 21 | ||
22 | switch (speed) { | 22 | switch (speed) { |
23 | case XFER_UDMA_4: mode = 0x00c0; break; | 23 | case XFER_UDMA_4: mode = 0x00c0; break; |
@@ -41,9 +41,10 @@ static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) | |||
41 | outw(scr, scr_port); | 41 | outw(scr, scr_port); |
42 | } | 42 | } |
43 | 43 | ||
44 | static void tc86c001_set_pio_mode(ide_drive_t *drive, const u8 pio) | 44 | static void tc86c001_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
45 | { | 45 | { |
46 | tc86c001_set_mode(drive, XFER_PIO_0 + pio); | 46 | drive->dma_mode = drive->pio_mode; |
47 | tc86c001_set_mode(hwif, drive); | ||
47 | } | 48 | } |
48 | 49 | ||
49 | /* | 50 | /* |
diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c index 8773c3ba7462..7953447eae0f 100644 --- a/drivers/ide/triflex.c +++ b/drivers/ide/triflex.c | |||
@@ -34,9 +34,8 @@ | |||
34 | 34 | ||
35 | #define DRV_NAME "triflex" | 35 | #define DRV_NAME "triflex" |
36 | 36 | ||
37 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) | 37 | static void triflex_set_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
38 | { | 38 | { |
39 | ide_hwif_t *hwif = drive->hwif; | ||
40 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 39 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
41 | u32 triflex_timings = 0; | 40 | u32 triflex_timings = 0; |
42 | u16 timing = 0; | 41 | u16 timing = 0; |
@@ -44,7 +43,7 @@ static void triflex_set_mode(ide_drive_t *drive, const u8 speed) | |||
44 | 43 | ||
45 | pci_read_config_dword(dev, channel_offset, &triflex_timings); | 44 | pci_read_config_dword(dev, channel_offset, &triflex_timings); |
46 | 45 | ||
47 | switch(speed) { | 46 | switch (drive->dma_mode) { |
48 | case XFER_MW_DMA_2: | 47 | case XFER_MW_DMA_2: |
49 | timing = 0x0103; | 48 | timing = 0x0103; |
50 | break; | 49 | break; |
@@ -82,9 +81,10 @@ static void triflex_set_mode(ide_drive_t *drive, const u8 speed) | |||
82 | pci_write_config_dword(dev, channel_offset, triflex_timings); | 81 | pci_write_config_dword(dev, channel_offset, triflex_timings); |
83 | } | 82 | } |
84 | 83 | ||
85 | static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio) | 84 | static void triflex_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
86 | { | 85 | { |
87 | triflex_set_mode(drive, XFER_PIO_0 + pio); | 86 | drive->dma_mode = drive->pio_mode; |
87 | triflex_set_mode(hwif, drive); | ||
88 | } | 88 | } |
89 | 89 | ||
90 | static const struct ide_port_ops triflex_port_ops = { | 90 | static const struct ide_port_ops triflex_port_ops = { |
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c index ea89fddeed91..1d80f1fdbc97 100644 --- a/drivers/ide/tx4938ide.c +++ b/drivers/ide/tx4938ide.c | |||
@@ -56,16 +56,15 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch, | |||
56 | &tx4938_ebuscptr->cr[ebus_ch]); | 56 | &tx4938_ebuscptr->cr[ebus_ch]); |
57 | } | 57 | } |
58 | 58 | ||
59 | static void tx4938ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | 59 | static void tx4938ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
60 | { | 60 | { |
61 | ide_hwif_t *hwif = drive->hwif; | ||
62 | struct tx4938ide_platform_info *pdata = hwif->dev->platform_data; | 61 | struct tx4938ide_platform_info *pdata = hwif->dev->platform_data; |
63 | u8 safe = pio; | 62 | u8 safe = drive->pio_mode - XFER_PIO_0; |
64 | ide_drive_t *pair; | 63 | ide_drive_t *pair; |
65 | 64 | ||
66 | pair = ide_get_pair_dev(drive); | 65 | pair = ide_get_pair_dev(drive); |
67 | if (pair) | 66 | if (pair) |
68 | safe = min(safe, ide_get_best_pio_mode(pair, 255, 5)); | 67 | safe = min(safe, pair->pio_mode - XFER_PIO_0); |
69 | tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, safe); | 68 | tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, safe); |
70 | } | 69 | } |
71 | 70 | ||
@@ -146,7 +145,7 @@ static int __init tx4938ide_probe(struct platform_device *pdev) | |||
146 | return -ENODEV; | 145 | return -ENODEV; |
147 | 146 | ||
148 | if (!devm_request_mem_region(&pdev->dev, res->start, | 147 | if (!devm_request_mem_region(&pdev->dev, res->start, |
149 | res->end - res->start + 1, "tx4938ide")) | 148 | resource_size(res), "tx4938ide")) |
150 | return -EBUSY; | 149 | return -EBUSY; |
151 | mapbase = (unsigned long)devm_ioremap(&pdev->dev, res->start, | 150 | mapbase = (unsigned long)devm_ioremap(&pdev->dev, res->start, |
152 | 8 << pdata->ioport_shift); | 151 | 8 << pdata->ioport_shift); |
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c index 64b58ecc3f0e..3c7367751873 100644 --- a/drivers/ide/tx4939ide.c +++ b/drivers/ide/tx4939ide.c | |||
@@ -104,17 +104,17 @@ static void tx4939ide_writeb(u8 val, void __iomem *base, u32 reg) | |||
104 | 104 | ||
105 | #define TX4939IDE_BASE(hwif) ((void __iomem *)(hwif)->extra_base) | 105 | #define TX4939IDE_BASE(hwif) ((void __iomem *)(hwif)->extra_base) |
106 | 106 | ||
107 | static void tx4939ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | 107 | static void tx4939ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
108 | { | 108 | { |
109 | ide_hwif_t *hwif = drive->hwif; | ||
110 | int is_slave = drive->dn; | 109 | int is_slave = drive->dn; |
111 | u32 mask, val; | 110 | u32 mask, val; |
111 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
112 | u8 safe = pio; | 112 | u8 safe = pio; |
113 | ide_drive_t *pair; | 113 | ide_drive_t *pair; |
114 | 114 | ||
115 | pair = ide_get_pair_dev(drive); | 115 | pair = ide_get_pair_dev(drive); |
116 | if (pair) | 116 | if (pair) |
117 | safe = min(safe, ide_get_best_pio_mode(pair, 255, 4)); | 117 | safe = min(safe, pair->pio_mode - XFER_PIO_0); |
118 | /* | 118 | /* |
119 | * Update Command Transfer Mode for master/slave and Data | 119 | * Update Command Transfer Mode for master/slave and Data |
120 | * Transfer Mode for this drive. | 120 | * Transfer Mode for this drive. |
@@ -125,10 +125,10 @@ static void tx4939ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
125 | /* tx4939ide_tf_load_fixup() will set the Sys_Ctl register */ | 125 | /* tx4939ide_tf_load_fixup() will set the Sys_Ctl register */ |
126 | } | 126 | } |
127 | 127 | ||
128 | static void tx4939ide_set_dma_mode(ide_drive_t *drive, const u8 mode) | 128 | static void tx4939ide_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
129 | { | 129 | { |
130 | ide_hwif_t *hwif = drive->hwif; | ||
131 | u32 mask, val; | 130 | u32 mask, val; |
131 | const u8 mode = drive->dma_mode; | ||
132 | 132 | ||
133 | /* Update Data Transfer Mode for this drive. */ | 133 | /* Update Data Transfer Mode for this drive. */ |
134 | if (mode >= XFER_UDMA_0) | 134 | if (mode >= XFER_UDMA_0) |
diff --git a/drivers/ide/umc8672.c b/drivers/ide/umc8672.c index 60f936e2319c..47adcd09cb26 100644 --- a/drivers/ide/umc8672.c +++ b/drivers/ide/umc8672.c | |||
@@ -104,10 +104,11 @@ static void umc_set_speeds(u8 speeds[]) | |||
104 | speeds[0], speeds[1], speeds[2], speeds[3]); | 104 | speeds[0], speeds[1], speeds[2], speeds[3]); |
105 | } | 105 | } |
106 | 106 | ||
107 | static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) | 107 | static void umc_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
108 | { | 108 | { |
109 | ide_hwif_t *hwif = drive->hwif, *mate = hwif->mate; | 109 | ide_hwif_t *mate = hwif->mate; |
110 | unsigned long uninitialized_var(flags); | 110 | unsigned long uninitialized_var(flags); |
111 | const u8 pio = drive->pio_mode - XFER_PIO_0; | ||
111 | 112 | ||
112 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", | 113 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", |
113 | drive->name, pio, pio_to_umc[pio]); | 114 | drive->name, pio, pio_to_umc[pio]); |
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c index 028de26a25fe..101f40022386 100644 --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * vt8235, vt8237, vt8237a | 6 | * vt8235, vt8237, vt8237a |
7 | * | 7 | * |
8 | * Copyright (c) 2000-2002 Vojtech Pavlik | 8 | * Copyright (c) 2000-2002 Vojtech Pavlik |
9 | * Copyright (c) 2007 Bartlomiej Zolnierkiewicz | 9 | * Copyright (c) 2007-2010 Bartlomiej Zolnierkiewicz |
10 | * | 10 | * |
11 | * Based on the work of: | 11 | * Based on the work of: |
12 | * Michel Aubry | 12 | * Michel Aubry |
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/slab.h> | ||
29 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
30 | #include <linux/init.h> | 31 | #include <linux/init.h> |
31 | #include <linux/ide.h> | 32 | #include <linux/ide.h> |
@@ -54,6 +55,11 @@ | |||
54 | #define VIA_NO_UNMASK 0x08 /* Doesn't work with IRQ unmasking on */ | 55 | #define VIA_NO_UNMASK 0x08 /* Doesn't work with IRQ unmasking on */ |
55 | #define VIA_BAD_ID 0x10 /* Has wrong vendor ID (0x1107) */ | 56 | #define VIA_BAD_ID 0x10 /* Has wrong vendor ID (0x1107) */ |
56 | #define VIA_BAD_AST 0x20 /* Don't touch Address Setup Timing */ | 57 | #define VIA_BAD_AST 0x20 /* Don't touch Address Setup Timing */ |
58 | #define VIA_SATA_PATA 0x80 /* SATA/PATA combined configuration */ | ||
59 | |||
60 | enum { | ||
61 | VIA_IDFLAG_SINGLE = (1 << 1), /* single channel controller */ | ||
62 | }; | ||
57 | 63 | ||
58 | /* | 64 | /* |
59 | * VIA SouthBridge chips. | 65 | * VIA SouthBridge chips. |
@@ -67,11 +73,13 @@ static struct via_isa_bridge { | |||
67 | u8 udma_mask; | 73 | u8 udma_mask; |
68 | u8 flags; | 74 | u8 flags; |
69 | } via_isa_bridges[] = { | 75 | } via_isa_bridges[] = { |
70 | { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 76 | { "vx855", PCI_DEVICE_ID_VIA_VX855, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_SATA_PATA }, |
71 | { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 77 | { "vx800", PCI_DEVICE_ID_VIA_VX800, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_SATA_PATA }, |
72 | { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 78 | { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST | VIA_SATA_PATA }, |
79 | { "vt8261", PCI_DEVICE_ID_VIA_8261, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | ||
73 | { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 80 | { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
74 | { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 81 | { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
82 | { "vt6415", PCI_DEVICE_ID_VIA_6410, 0x00, 0xff, ATA_UDMA6, VIA_BAD_AST }, | ||
75 | { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 83 | { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
76 | { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 84 | { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
77 | { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | 85 | { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, |
@@ -92,6 +100,7 @@ static struct via_isa_bridge { | |||
92 | { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, 0x00, VIA_SET_FIFO }, | 100 | { "vt82c586", PCI_DEVICE_ID_VIA_82C586_0, 0x00, 0x0f, 0x00, VIA_SET_FIFO }, |
93 | { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, 0x00, VIA_SET_FIFO | VIA_NO_UNMASK }, | 101 | { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, 0x00, VIA_SET_FIFO | VIA_NO_UNMASK }, |
94 | { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, 0x00, VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID }, | 102 | { "vt82c576", PCI_DEVICE_ID_VIA_82C576, 0x00, 0x2f, 0x00, VIA_SET_FIFO | VIA_NO_UNMASK | VIA_BAD_ID }, |
103 | { "vtxxxx", PCI_DEVICE_ID_VIA_ANON, 0x00, 0x2f, ATA_UDMA6, VIA_BAD_AST }, | ||
95 | { NULL } | 104 | { NULL } |
96 | }; | 105 | }; |
97 | 106 | ||
@@ -137,30 +146,45 @@ static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | |||
137 | case ATA_UDMA4: t = timing->udma ? (0xe8 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x0f; break; | 146 | case ATA_UDMA4: t = timing->udma ? (0xe8 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x0f; break; |
138 | case ATA_UDMA5: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; | 147 | case ATA_UDMA5: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; |
139 | case ATA_UDMA6: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; | 148 | case ATA_UDMA6: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; |
140 | default: return; | ||
141 | } | 149 | } |
142 | 150 | ||
143 | pci_write_config_byte(dev, VIA_UDMA_TIMING + (3 - dn), t); | 151 | /* Set UDMA unless device is not UDMA capable */ |
152 | if (vdev->via_config->udma_mask) { | ||
153 | u8 udma_etc; | ||
154 | |||
155 | pci_read_config_byte(dev, VIA_UDMA_TIMING + 3 - dn, &udma_etc); | ||
156 | |||
157 | /* clear transfer mode bit */ | ||
158 | udma_etc &= ~0x20; | ||
159 | |||
160 | if (timing->udma) { | ||
161 | /* preserve 80-wire cable detection bit */ | ||
162 | udma_etc &= 0x10; | ||
163 | udma_etc |= t; | ||
164 | } | ||
165 | |||
166 | pci_write_config_byte(dev, VIA_UDMA_TIMING + 3 - dn, udma_etc); | ||
167 | } | ||
144 | } | 168 | } |
145 | 169 | ||
146 | /** | 170 | /** |
147 | * via_set_drive - configure transfer mode | 171 | * via_set_drive - configure transfer mode |
172 | * @hwif: port | ||
148 | * @drive: Drive to set up | 173 | * @drive: Drive to set up |
149 | * @speed: desired speed | ||
150 | * | 174 | * |
151 | * via_set_drive() computes timing values configures the chipset to | 175 | * via_set_drive() computes timing values configures the chipset to |
152 | * a desired transfer mode. It also can be called by upper layers. | 176 | * a desired transfer mode. It also can be called by upper layers. |
153 | */ | 177 | */ |
154 | 178 | ||
155 | static void via_set_drive(ide_drive_t *drive, const u8 speed) | 179 | static void via_set_drive(ide_hwif_t *hwif, ide_drive_t *drive) |
156 | { | 180 | { |
157 | ide_hwif_t *hwif = drive->hwif; | ||
158 | ide_drive_t *peer = ide_get_pair_dev(drive); | 181 | ide_drive_t *peer = ide_get_pair_dev(drive); |
159 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 182 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
160 | struct ide_host *host = pci_get_drvdata(dev); | 183 | struct ide_host *host = pci_get_drvdata(dev); |
161 | struct via82cxxx_dev *vdev = host->host_priv; | 184 | struct via82cxxx_dev *vdev = host->host_priv; |
162 | struct ide_timing t, p; | 185 | struct ide_timing t, p; |
163 | unsigned int T, UT; | 186 | unsigned int T, UT; |
187 | const u8 speed = drive->dma_mode; | ||
164 | 188 | ||
165 | T = 1000000000 / via_clock; | 189 | T = 1000000000 / via_clock; |
166 | 190 | ||
@@ -175,7 +199,7 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed) | |||
175 | ide_timing_compute(drive, speed, &t, T, UT); | 199 | ide_timing_compute(drive, speed, &t, T, UT); |
176 | 200 | ||
177 | if (peer) { | 201 | if (peer) { |
178 | ide_timing_compute(peer, peer->current_speed, &p, T, UT); | 202 | ide_timing_compute(peer, peer->pio_mode, &p, T, UT); |
179 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); | 203 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); |
180 | } | 204 | } |
181 | 205 | ||
@@ -184,22 +208,24 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed) | |||
184 | 208 | ||
185 | /** | 209 | /** |
186 | * via_set_pio_mode - set host controller for PIO mode | 210 | * via_set_pio_mode - set host controller for PIO mode |
211 | * @hwif: port | ||
187 | * @drive: drive | 212 | * @drive: drive |
188 | * @pio: PIO mode number | ||
189 | * | 213 | * |
190 | * A callback from the upper layers for PIO-only tuning. | 214 | * A callback from the upper layers for PIO-only tuning. |
191 | */ | 215 | */ |
192 | 216 | ||
193 | static void via_set_pio_mode(ide_drive_t *drive, const u8 pio) | 217 | static void via_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) |
194 | { | 218 | { |
195 | via_set_drive(drive, XFER_PIO_0 + pio); | 219 | drive->dma_mode = drive->pio_mode; |
220 | via_set_drive(hwif, drive); | ||
196 | } | 221 | } |
197 | 222 | ||
198 | static struct via_isa_bridge *via_config_find(struct pci_dev **isa) | 223 | static struct via_isa_bridge *via_config_find(struct pci_dev **isa) |
199 | { | 224 | { |
200 | struct via_isa_bridge *via_config; | 225 | struct via_isa_bridge *via_config; |
201 | 226 | ||
202 | for (via_config = via_isa_bridges; via_config->id; via_config++) | 227 | for (via_config = via_isa_bridges; |
228 | via_config->id != PCI_DEVICE_ID_VIA_ANON; via_config++) | ||
203 | if ((*isa = pci_get_device(PCI_VENDOR_ID_VIA + | 229 | if ((*isa = pci_get_device(PCI_VENDOR_ID_VIA + |
204 | !!(via_config->flags & VIA_BAD_ID), | 230 | !!(via_config->flags & VIA_BAD_ID), |
205 | via_config->id, NULL))) { | 231 | via_config->id, NULL))) { |
@@ -362,6 +388,9 @@ static u8 via82cxxx_cable_detect(ide_hwif_t *hwif) | |||
362 | if (via_cable_override(pdev)) | 388 | if (via_cable_override(pdev)) |
363 | return ATA_CBL_PATA40_SHORT; | 389 | return ATA_CBL_PATA40_SHORT; |
364 | 390 | ||
391 | if ((vdev->via_config->flags & VIA_SATA_PATA) && hwif->channel == 0) | ||
392 | return ATA_CBL_SATA; | ||
393 | |||
365 | if ((vdev->via_80w >> hwif->channel) & 1) | 394 | if ((vdev->via_80w >> hwif->channel) & 1) |
366 | return ATA_CBL_PATA80; | 395 | return ATA_CBL_PATA80; |
367 | else | 396 | else |
@@ -402,11 +431,6 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
402 | * Find the ISA bridge and check we know what it is. | 431 | * Find the ISA bridge and check we know what it is. |
403 | */ | 432 | */ |
404 | via_config = via_config_find(&isa); | 433 | via_config = via_config_find(&isa); |
405 | if (!via_config->id) { | ||
406 | printk(KERN_WARNING DRV_NAME " %s: unknown chipset, skipping\n", | ||
407 | pci_name(dev)); | ||
408 | return -ENODEV; | ||
409 | } | ||
410 | 434 | ||
411 | /* | 435 | /* |
412 | * Print the boot message. | 436 | * Print the boot message. |
@@ -436,10 +460,13 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i | |||
436 | via_clock = 33333; | 460 | via_clock = 33333; |
437 | } | 461 | } |
438 | 462 | ||
439 | if (idx == 0) | 463 | if (idx == 1) |
440 | d.host_flags |= IDE_HFLAG_NO_AUTODMA; | ||
441 | else | ||
442 | d.enablebits[1].reg = d.enablebits[0].reg = 0; | 464 | d.enablebits[1].reg = d.enablebits[0].reg = 0; |
465 | else | ||
466 | d.host_flags |= IDE_HFLAG_NO_AUTODMA; | ||
467 | |||
468 | if (idx == VIA_IDFLAG_SINGLE) | ||
469 | d.host_flags |= IDE_HFLAG_SINGLE; | ||
443 | 470 | ||
444 | if ((via_config->flags & VIA_NO_UNMASK) == 0) | 471 | if ((via_config->flags & VIA_NO_UNMASK) == 0) |
445 | d.host_flags |= IDE_HFLAG_UNMASK_IRQS; | 472 | d.host_flags |= IDE_HFLAG_UNMASK_IRQS; |
@@ -475,8 +502,9 @@ static const struct pci_device_id via_pci_tbl[] = { | |||
475 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 }, | 502 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 }, |
476 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 }, | 503 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 }, |
477 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 }, | 504 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_CX700_IDE), 0 }, |
478 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_VX855_IDE), 0 }, | 505 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_VX855_IDE), VIA_IDFLAG_SINGLE }, |
479 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 }, | 506 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 }, |
507 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6415), 1 }, | ||
480 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 }, | 508 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 }, |
481 | { 0, }, | 509 | { 0, }, |
482 | }; | 510 | }; |
@@ -504,6 +532,6 @@ static void __exit via_ide_exit(void) | |||
504 | module_init(via_ide_init); | 532 | module_init(via_ide_init); |
505 | module_exit(via_ide_exit); | 533 | module_exit(via_ide_exit); |
506 | 534 | ||
507 | MODULE_AUTHOR("Vojtech Pavlik, Michel Aubry, Jeff Garzik, Andre Hedrick"); | 535 | MODULE_AUTHOR("Vojtech Pavlik, Bartlomiej Zolnierkiewicz, Michel Aubry, Jeff Garzik, Andre Hedrick"); |
508 | MODULE_DESCRIPTION("PCI driver module for VIA IDE"); | 536 | MODULE_DESCRIPTION("PCI driver module for VIA IDE"); |
509 | MODULE_LICENSE("GPL"); | 537 | MODULE_LICENSE("GPL"); |