diff options
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 101 |
1 files changed, 63 insertions, 38 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 6302010fd8e2..5171601fb255 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -72,16 +72,16 @@ static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | |||
72 | } | 72 | } |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * ide_get_or_set_dma_base - setup BMIBA | 75 | * ide_pci_dma_base - setup BMIBA |
76 | * @d: IDE port info | ||
77 | * @hwif: IDE interface | 76 | * @hwif: IDE interface |
77 | * @d: IDE port info | ||
78 | * | 78 | * |
79 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. | 79 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
80 | * Where a device has a partner that is already in DMA mode we check | 80 | * Where a device has a partner that is already in DMA mode we check |
81 | * and enforce IDE simplex rules. | 81 | * and enforce IDE simplex rules. |
82 | */ | 82 | */ |
83 | 83 | ||
84 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) | 84 | unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) |
85 | { | 85 | { |
86 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 86 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
87 | unsigned long dma_base = 0; | 87 | unsigned long dma_base = 0; |
@@ -132,6 +132,31 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
132 | out: | 132 | out: |
133 | return dma_base; | 133 | return dma_base; |
134 | } | 134 | } |
135 | EXPORT_SYMBOL_GPL(ide_pci_dma_base); | ||
136 | |||
137 | /* | ||
138 | * Set up BM-DMA capability (PnP BIOS should have done this) | ||
139 | */ | ||
140 | int ide_pci_set_master(struct pci_dev *dev, const char *name) | ||
141 | { | ||
142 | u16 pcicmd; | ||
143 | |||
144 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
145 | |||
146 | if ((pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
147 | pci_set_master(dev); | ||
148 | |||
149 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || | ||
150 | (pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
151 | printk(KERN_ERR "%s: error updating PCICMD on %s\n", | ||
152 | name, pci_name(dev)); | ||
153 | return -EIO; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(ide_pci_set_master); | ||
135 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 160 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
136 | 161 | ||
137 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) | 162 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
@@ -158,7 +183,7 @@ EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | |||
158 | 183 | ||
159 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | 184 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) |
160 | { | 185 | { |
161 | int ret; | 186 | int ret, bars; |
162 | 187 | ||
163 | if (pci_enable_device(dev)) { | 188 | if (pci_enable_device(dev)) { |
164 | ret = pci_enable_device_io(dev); | 189 | ret = pci_enable_device_io(dev); |
@@ -181,13 +206,21 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | |||
181 | goto out; | 206 | goto out; |
182 | } | 207 | } |
183 | 208 | ||
184 | /* FIXME: Temporary - until we put in the hotplug interface logic | 209 | if (d->host_flags & IDE_HFLAG_SINGLE) |
185 | Check that the bits we want are not in use by someone else. */ | 210 | bars = (1 << 2) - 1; |
186 | ret = pci_request_region(dev, 4, "ide_tmp"); | 211 | else |
187 | if (ret < 0) | 212 | bars = (1 << 4) - 1; |
188 | goto out; | ||
189 | 213 | ||
190 | pci_release_region(dev, 4); | 214 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { |
215 | if (d->host_flags & IDE_HFLAG_CS5520) | ||
216 | bars |= (1 << 2); | ||
217 | else | ||
218 | bars |= (1 << 4); | ||
219 | } | ||
220 | |||
221 | ret = pci_request_selected_regions(dev, bars, d->name); | ||
222 | if (ret < 0) | ||
223 | printk(KERN_ERR "%s: can't reserve resources\n", d->name); | ||
191 | out: | 224 | out: |
192 | return ret; | 225 | return ret; |
193 | } | 226 | } |
@@ -314,7 +347,6 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
314 | ide_init_port_hw(hwif, &hw); | 347 | ide_init_port_hw(hwif, &hw); |
315 | 348 | ||
316 | hwif->dev = &dev->dev; | 349 | hwif->dev = &dev->dev; |
317 | hwif->cds = d; | ||
318 | 350 | ||
319 | return hwif; | 351 | return hwif; |
320 | } | 352 | } |
@@ -330,40 +362,33 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
330 | * state | 362 | * state |
331 | */ | 363 | */ |
332 | 364 | ||
333 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | 365 | int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) |
334 | { | 366 | { |
335 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 367 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
336 | u16 pcicmd; | ||
337 | |||
338 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
339 | 368 | ||
340 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || | 369 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
341 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 370 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
342 | (dev->class & 0x80))) { | 371 | (dev->class & 0x80))) { |
343 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); | 372 | unsigned long base = ide_pci_dma_base(hwif, d); |
344 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { | 373 | |
345 | /* | 374 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
346 | * Set up BM-DMA capability | 375 | return -1; |
347 | * (PnP BIOS should have done this) | 376 | |
348 | */ | 377 | if (hwif->mmio) |
349 | pci_set_master(dev); | 378 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
350 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { | 379 | else |
351 | printk(KERN_ERR "%s: %s error updating PCICMD\n", | 380 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
352 | hwif->name, d->name); | 381 | hwif->name, base, base + 7); |
353 | dma_base = 0; | 382 | |
354 | } | 383 | hwif->extra_base = base + (hwif->channel ? 8 : 16); |
355 | } | 384 | |
356 | if (dma_base) { | 385 | if (ide_allocate_dma_engine(hwif)) |
357 | if (d->init_dma) { | 386 | return -1; |
358 | d->init_dma(hwif, dma_base); | 387 | |
359 | } else { | 388 | ide_setup_dma(hwif, base); |
360 | ide_setup_dma(hwif, dma_base); | ||
361 | } | ||
362 | } else { | ||
363 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " | ||
364 | "(BIOS)\n", hwif->name, d->name); | ||
365 | } | ||
366 | } | 389 | } |
390 | |||
391 | return 0; | ||
367 | } | 392 | } |
368 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 393 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
369 | 394 | ||