diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2008-02-01 17:09:29 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:29 -0500 |
commit | 4e5a68aeb6b513ee0adda11642e10e528b7721c0 (patch) | |
tree | 4dfa652522179aec1aca65ad65a158a71e97e71f /drivers/ide | |
parent | f9afd18b5827be93fd9fb3cc84ab9bba38b00db8 (diff) |
trm290: cannot call ide_setup_dma()
The TRM-290 chip is *not* SFF-8038i compatible and therefore can *not* call
ide_setup_dma() -- fix this and also cleanup the code a bit...
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-dma.c | 13 | ||||
-rw-r--r-- | drivers/ide/pci/trm290.c | 64 |
2 files changed, 44 insertions, 33 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 15f8c6abe429..8d668a80adb3 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -933,6 +933,8 @@ static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base, unsigned int por | |||
933 | 933 | ||
934 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) | 934 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) |
935 | { | 935 | { |
936 | u8 dma_stat; | ||
937 | |||
936 | if (ide_dma_iobase(hwif, base, num_ports)) | 938 | if (ide_dma_iobase(hwif, base, num_ports)) |
937 | return; | 939 | return; |
938 | 940 | ||
@@ -971,13 +973,10 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) | |||
971 | if (!hwif->dma_lost_irq) | 973 | if (!hwif->dma_lost_irq) |
972 | hwif->dma_lost_irq = &ide_dma_lost_irq; | 974 | hwif->dma_lost_irq = &ide_dma_lost_irq; |
973 | 975 | ||
974 | if (hwif->chipset != ide_trm290) { | 976 | dma_stat = hwif->INB(hwif->dma_status); |
975 | u8 dma_stat = hwif->INB(hwif->dma_status); | 977 | printk(KERN_CONT ", BIOS settings: %s:%s, %s:%s\n", |
976 | printk(", BIOS settings: %s:%s, %s:%s", | 978 | hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "PIO", |
977 | hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "pio", | 979 | hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "PIO"); |
978 | hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "pio"); | ||
979 | } | ||
980 | printk("\n"); | ||
981 | } | 980 | } |
982 | 981 | ||
983 | EXPORT_SYMBOL_GPL(ide_setup_dma); | 982 | EXPORT_SYMBOL_GPL(ide_setup_dma); |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index 04cd893e1ab0..7b0338890699 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/ide/pci/trm290.c Version 1.05 Dec. 26, 2007 | 2 | * linux/drivers/ide/pci/trm290.c Version 1.05 Dec. 30, 2007 |
3 | * | 3 | * |
4 | * Copyright (c) 1997-1998 Mark Lord | 4 | * Copyright (c) 1997-1998 Mark Lord |
5 | * Copyright (c) 2007 MontaVista Software, Inc. <source@mvista.com> | 5 | * Copyright (c) 2007 MontaVista Software, Inc. <source@mvista.com> |
@@ -209,10 +209,10 @@ static int trm290_dma_setup(ide_drive_t *drive) | |||
209 | } | 209 | } |
210 | /* select DMA xfer */ | 210 | /* select DMA xfer */ |
211 | trm290_prepare_drive(drive, 1); | 211 | trm290_prepare_drive(drive, 1); |
212 | outl(hwif->dmatable_dma | rw, hwif->dma_command); | 212 | outl(hwif->dmatable_dma | rw, hwif->dma_base); |
213 | drive->waiting_for_dma = 1; | 213 | drive->waiting_for_dma = 1; |
214 | /* start DMA */ | 214 | /* start DMA */ |
215 | outw((count * 2) - 1, hwif->dma_status); | 215 | outw(count * 2 - 1, hwif->dma_base + 2); |
216 | return 0; | 216 | return 0; |
217 | } | 217 | } |
218 | 218 | ||
@@ -222,23 +222,21 @@ static void trm290_dma_start(ide_drive_t *drive) | |||
222 | 222 | ||
223 | static int trm290_ide_dma_end (ide_drive_t *drive) | 223 | static int trm290_ide_dma_end (ide_drive_t *drive) |
224 | { | 224 | { |
225 | ide_hwif_t *hwif = HWIF(drive); | 225 | u16 status; |
226 | u16 status = 0; | ||
227 | 226 | ||
228 | drive->waiting_for_dma = 0; | 227 | drive->waiting_for_dma = 0; |
229 | /* purge DMA mappings */ | 228 | /* purge DMA mappings */ |
230 | ide_destroy_dmatable(drive); | 229 | ide_destroy_dmatable(drive); |
231 | status = inw(hwif->dma_status); | 230 | status = inw(HWIF(drive)->dma_base + 2); |
232 | return (status != 0x00ff); | 231 | return status != 0x00ff; |
233 | } | 232 | } |
234 | 233 | ||
235 | static int trm290_ide_dma_test_irq (ide_drive_t *drive) | 234 | static int trm290_ide_dma_test_irq (ide_drive_t *drive) |
236 | { | 235 | { |
237 | ide_hwif_t *hwif = HWIF(drive); | 236 | u16 status; |
238 | u16 status = 0; | ||
239 | 237 | ||
240 | status = inw(hwif->dma_status); | 238 | status = inw(HWIF(drive)->dma_base + 2); |
241 | return (status == 0x00ff); | 239 | return status == 0x00ff; |
242 | } | 240 | } |
243 | 241 | ||
244 | static void trm290_dma_host_set(ide_drive_t *drive, int on) | 242 | static void trm290_dma_host_set(ide_drive_t *drive, int on) |
@@ -247,21 +245,37 @@ static void trm290_dma_host_set(ide_drive_t *drive, int on) | |||
247 | 245 | ||
248 | static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | 246 | static void __devinit init_hwif_trm290(ide_hwif_t *hwif) |
249 | { | 247 | { |
250 | unsigned int cfgbase = 0; | 248 | struct pci_dev *dev = hwif->pci_dev; |
249 | unsigned int cfg_base = pci_resource_start(dev, 4); | ||
251 | unsigned long flags; | 250 | unsigned long flags; |
252 | u8 reg = 0; | 251 | u8 reg = 0; |
253 | struct pci_dev *dev = hwif->pci_dev; | 252 | |
254 | 253 | if ((dev->class & 5) && cfg_base) | |
255 | cfgbase = pci_resource_start(dev, 4); | 254 | printk(KERN_INFO "TRM290: chip"); |
256 | if ((dev->class & 5) && cfgbase) { | 255 | else { |
257 | hwif->config_data = cfgbase; | 256 | cfg_base = 0x3df0; |
258 | printk(KERN_INFO "TRM290: chip config base at 0x%04lx\n", | 257 | printk(KERN_INFO "TRM290: using default"); |
259 | hwif->config_data); | ||
260 | } else { | ||
261 | hwif->config_data = 0x3df0; | ||
262 | printk(KERN_INFO "TRM290: using default config base at 0x%04lx\n", | ||
263 | hwif->config_data); | ||
264 | } | 258 | } |
259 | printk(KERN_CONT " config base at 0x%04x\n", cfg_base); | ||
260 | hwif->config_data = cfg_base; | ||
261 | hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); | ||
262 | |||
263 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | ||
264 | hwif->name, hwif->dma_base, hwif->dma_base + 3); | ||
265 | |||
266 | if (!request_region(hwif->dma_base, 4, hwif->name)) { | ||
267 | printk(KERN_CONT " -- Error, ports in use.\n"); | ||
268 | return; | ||
269 | } | ||
270 | |||
271 | hwif->dmatable_cpu = pci_alloc_consistent(dev, PRD_ENTRIES * PRD_BYTES, | ||
272 | &hwif->dmatable_dma); | ||
273 | if (!hwif->dmatable_cpu) { | ||
274 | printk(KERN_CONT " -- Error, unable to allocate DMA table.\n"); | ||
275 | release_region(hwif->dma_base, 4); | ||
276 | return; | ||
277 | } | ||
278 | printk(KERN_CONT "\n"); | ||
265 | 279 | ||
266 | local_irq_save(flags); | 280 | local_irq_save(flags); |
267 | /* put config reg into first byte of hwif->select_data */ | 281 | /* put config reg into first byte of hwif->select_data */ |
@@ -276,15 +290,13 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
276 | outb(reg, hwif->config_data + 3); | 290 | outb(reg, hwif->config_data + 3); |
277 | local_irq_restore(flags); | 291 | local_irq_restore(flags); |
278 | 292 | ||
279 | if ((reg & 0x10)) | 293 | if (reg & 0x10) |
280 | /* legacy mode */ | 294 | /* legacy mode */ |
281 | hwif->irq = hwif->channel ? 15 : 14; | 295 | hwif->irq = hwif->channel ? 15 : 14; |
282 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | 296 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) |
283 | /* sharing IRQ with mate */ | 297 | /* sharing IRQ with mate */ |
284 | hwif->irq = hwif->mate->irq; | 298 | hwif->irq = hwif->mate->irq; |
285 | 299 | ||
286 | ide_setup_dma(hwif, (hwif->config_data + 4) ^ (hwif->channel ? 0x0080 : 0x0000), 3); | ||
287 | |||
288 | hwif->dma_host_set = &trm290_dma_host_set; | 300 | hwif->dma_host_set = &trm290_dma_host_set; |
289 | hwif->dma_setup = &trm290_dma_setup; | 301 | hwif->dma_setup = &trm290_dma_setup; |
290 | hwif->dma_exec_cmd = &trm290_dma_exec_cmd; | 302 | hwif->dma_exec_cmd = &trm290_dma_exec_cmd; |