diff options
Diffstat (limited to 'drivers/scsi/aic7xxx/aic7xxx_osm_pci.c')
-rw-r--r-- | drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 73 |
1 files changed, 62 insertions, 11 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index 3d3eaef65fb..0d7628f1f1e 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | |||
@@ -46,7 +46,7 @@ | |||
46 | */ | 46 | */ |
47 | #define ID(x) ID_C(x, PCI_CLASS_STORAGE_SCSI) | 47 | #define ID(x) ID_C(x, PCI_CLASS_STORAGE_SCSI) |
48 | 48 | ||
49 | static struct pci_device_id ahc_linux_pci_id_table[] = { | 49 | static const struct pci_device_id ahc_linux_pci_id_table[] = { |
50 | /* aic7850 based controllers */ | 50 | /* aic7850 based controllers */ |
51 | ID(ID_AHA_2902_04_10_15_20C_30C), | 51 | ID(ID_AHA_2902_04_10_15_20C_30C), |
52 | /* aic7860 based controllers */ | 52 | /* aic7860 based controllers */ |
@@ -206,7 +206,7 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
206 | const uint64_t mask_39bit = 0x7FFFFFFFFFULL; | 206 | const uint64_t mask_39bit = 0x7FFFFFFFFFULL; |
207 | struct ahc_softc *ahc; | 207 | struct ahc_softc *ahc; |
208 | ahc_dev_softc_t pci; | 208 | ahc_dev_softc_t pci; |
209 | struct ahc_pci_identity *entry; | 209 | const struct ahc_pci_identity *entry; |
210 | char *name; | 210 | char *name; |
211 | int error; | 211 | int error; |
212 | struct device *dev = &pdev->dev; | 212 | struct device *dev = &pdev->dev; |
@@ -269,6 +269,57 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
269 | return (0); | 269 | return (0); |
270 | } | 270 | } |
271 | 271 | ||
272 | /******************************* PCI Routines *********************************/ | ||
273 | uint32_t | ||
274 | ahc_pci_read_config(ahc_dev_softc_t pci, int reg, int width) | ||
275 | { | ||
276 | switch (width) { | ||
277 | case 1: | ||
278 | { | ||
279 | uint8_t retval; | ||
280 | |||
281 | pci_read_config_byte(pci, reg, &retval); | ||
282 | return (retval); | ||
283 | } | ||
284 | case 2: | ||
285 | { | ||
286 | uint16_t retval; | ||
287 | pci_read_config_word(pci, reg, &retval); | ||
288 | return (retval); | ||
289 | } | ||
290 | case 4: | ||
291 | { | ||
292 | uint32_t retval; | ||
293 | pci_read_config_dword(pci, reg, &retval); | ||
294 | return (retval); | ||
295 | } | ||
296 | default: | ||
297 | panic("ahc_pci_read_config: Read size too big"); | ||
298 | /* NOTREACHED */ | ||
299 | return (0); | ||
300 | } | ||
301 | } | ||
302 | |||
303 | void | ||
304 | ahc_pci_write_config(ahc_dev_softc_t pci, int reg, uint32_t value, int width) | ||
305 | { | ||
306 | switch (width) { | ||
307 | case 1: | ||
308 | pci_write_config_byte(pci, reg, value); | ||
309 | break; | ||
310 | case 2: | ||
311 | pci_write_config_word(pci, reg, value); | ||
312 | break; | ||
313 | case 4: | ||
314 | pci_write_config_dword(pci, reg, value); | ||
315 | break; | ||
316 | default: | ||
317 | panic("ahc_pci_write_config: Write size too big"); | ||
318 | /* NOTREACHED */ | ||
319 | } | ||
320 | } | ||
321 | |||
322 | |||
272 | static struct pci_driver aic7xxx_pci_driver = { | 323 | static struct pci_driver aic7xxx_pci_driver = { |
273 | .name = "aic7xxx", | 324 | .name = "aic7xxx", |
274 | .probe = ahc_linux_pci_dev_probe, | 325 | .probe = ahc_linux_pci_dev_probe, |
@@ -293,7 +344,7 @@ ahc_linux_pci_exit(void) | |||
293 | } | 344 | } |
294 | 345 | ||
295 | static int | 346 | static int |
296 | ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, u_long *base) | 347 | ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, resource_size_t *base) |
297 | { | 348 | { |
298 | if (aic7xxx_allow_memio == 0) | 349 | if (aic7xxx_allow_memio == 0) |
299 | return (ENOMEM); | 350 | return (ENOMEM); |
@@ -308,10 +359,10 @@ ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, u_long *base) | |||
308 | 359 | ||
309 | static int | 360 | static int |
310 | ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc, | 361 | ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc, |
311 | u_long *bus_addr, | 362 | resource_size_t *bus_addr, |
312 | uint8_t __iomem **maddr) | 363 | uint8_t __iomem **maddr) |
313 | { | 364 | { |
314 | u_long start; | 365 | resource_size_t start; |
315 | int error; | 366 | int error; |
316 | 367 | ||
317 | error = 0; | 368 | error = 0; |
@@ -336,7 +387,7 @@ int | |||
336 | ahc_pci_map_registers(struct ahc_softc *ahc) | 387 | ahc_pci_map_registers(struct ahc_softc *ahc) |
337 | { | 388 | { |
338 | uint32_t command; | 389 | uint32_t command; |
339 | u_long base; | 390 | resource_size_t base; |
340 | uint8_t __iomem *maddr; | 391 | uint8_t __iomem *maddr; |
341 | int error; | 392 | int error; |
342 | 393 | ||
@@ -374,12 +425,12 @@ ahc_pci_map_registers(struct ahc_softc *ahc) | |||
374 | } else | 425 | } else |
375 | command |= PCIM_CMD_MEMEN; | 426 | command |= PCIM_CMD_MEMEN; |
376 | } else { | 427 | } else { |
377 | printf("aic7xxx: PCI%d:%d:%d MEM region 0x%lx " | 428 | printf("aic7xxx: PCI%d:%d:%d MEM region 0x%llx " |
378 | "unavailable. Cannot memory map device.\n", | 429 | "unavailable. Cannot memory map device.\n", |
379 | ahc_get_pci_bus(ahc->dev_softc), | 430 | ahc_get_pci_bus(ahc->dev_softc), |
380 | ahc_get_pci_slot(ahc->dev_softc), | 431 | ahc_get_pci_slot(ahc->dev_softc), |
381 | ahc_get_pci_function(ahc->dev_softc), | 432 | ahc_get_pci_function(ahc->dev_softc), |
382 | base); | 433 | (unsigned long long)base); |
383 | } | 434 | } |
384 | 435 | ||
385 | /* | 436 | /* |
@@ -390,15 +441,15 @@ ahc_pci_map_registers(struct ahc_softc *ahc) | |||
390 | error = ahc_linux_pci_reserve_io_region(ahc, &base); | 441 | error = ahc_linux_pci_reserve_io_region(ahc, &base); |
391 | if (error == 0) { | 442 | if (error == 0) { |
392 | ahc->tag = BUS_SPACE_PIO; | 443 | ahc->tag = BUS_SPACE_PIO; |
393 | ahc->bsh.ioport = base; | 444 | ahc->bsh.ioport = (u_long)base; |
394 | command |= PCIM_CMD_PORTEN; | 445 | command |= PCIM_CMD_PORTEN; |
395 | } else { | 446 | } else { |
396 | printf("aic7xxx: PCI%d:%d:%d IO region 0x%lx[0..255] " | 447 | printf("aic7xxx: PCI%d:%d:%d IO region 0x%llx[0..255] " |
397 | "unavailable. Cannot map device.\n", | 448 | "unavailable. Cannot map device.\n", |
398 | ahc_get_pci_bus(ahc->dev_softc), | 449 | ahc_get_pci_bus(ahc->dev_softc), |
399 | ahc_get_pci_slot(ahc->dev_softc), | 450 | ahc_get_pci_slot(ahc->dev_softc), |
400 | ahc_get_pci_function(ahc->dev_softc), | 451 | ahc_get_pci_function(ahc->dev_softc), |
401 | base); | 452 | (unsigned long long)base); |
402 | } | 453 | } |
403 | } | 454 | } |
404 | ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, 4); | 455 | ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, command, 4); |