diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-10-06 11:06:39 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:00:14 -0500 |
commit | 3388c37e04ec0e35ebc1b4c732fdefc9ea938f3b (patch) | |
tree | 07dbc35af342077af1cee71ede6902e4a4d14130 /sound/pci/intel8x0.c | |
parent | c7132aeb72ad1106dc76279de4d005f9e1c5815c (diff) |
[ALSA] intel8x0 - Use pci_iomap
Use pci_iomap and ioread*/iowrite*() functions for accessing
hardwares. pci_iomap is suitable for hardwares like ICH and
compatible that have both PIO and MMIO.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/intel8x0.c')
-rw-r--r-- | sound/pci/intel8x0.c | 120 |
1 files changed, 42 insertions, 78 deletions
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 30aaa6092a84..28d5d9deb892 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -368,12 +368,8 @@ struct intel8x0 { | |||
368 | 368 | ||
369 | int irq; | 369 | int irq; |
370 | 370 | ||
371 | unsigned int mmio; | 371 | void __iomem *addr; |
372 | unsigned long addr; | 372 | void __iomem *bmaddr; |
373 | void __iomem *remap_addr; | ||
374 | unsigned int bm_mmio; | ||
375 | unsigned long bmaddr; | ||
376 | void __iomem *remap_bmaddr; | ||
377 | 373 | ||
378 | struct pci_dev *pci; | 374 | struct pci_dev *pci; |
379 | struct snd_card *card; | 375 | struct snd_card *card; |
@@ -446,72 +442,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0_ids); | |||
446 | * Lowlevel I/O - busmaster | 442 | * Lowlevel I/O - busmaster |
447 | */ | 443 | */ |
448 | 444 | ||
449 | static u8 igetbyte(struct intel8x0 *chip, u32 offset) | 445 | static inline u8 igetbyte(struct intel8x0 *chip, u32 offset) |
450 | { | 446 | { |
451 | if (chip->bm_mmio) | 447 | return ioread8(chip->bmaddr + offset); |
452 | return readb(chip->remap_bmaddr + offset); | ||
453 | else | ||
454 | return inb(chip->bmaddr + offset); | ||
455 | } | 448 | } |
456 | 449 | ||
457 | static u16 igetword(struct intel8x0 *chip, u32 offset) | 450 | static inline u16 igetword(struct intel8x0 *chip, u32 offset) |
458 | { | 451 | { |
459 | if (chip->bm_mmio) | 452 | return ioread16(chip->bmaddr + offset); |
460 | return readw(chip->remap_bmaddr + offset); | ||
461 | else | ||
462 | return inw(chip->bmaddr + offset); | ||
463 | } | 453 | } |
464 | 454 | ||
465 | static u32 igetdword(struct intel8x0 *chip, u32 offset) | 455 | static inline u32 igetdword(struct intel8x0 *chip, u32 offset) |
466 | { | 456 | { |
467 | if (chip->bm_mmio) | 457 | return ioread32(chip->bmaddr + offset); |
468 | return readl(chip->remap_bmaddr + offset); | ||
469 | else | ||
470 | return inl(chip->bmaddr + offset); | ||
471 | } | 458 | } |
472 | 459 | ||
473 | static void iputbyte(struct intel8x0 *chip, u32 offset, u8 val) | 460 | static inline void iputbyte(struct intel8x0 *chip, u32 offset, u8 val) |
474 | { | 461 | { |
475 | if (chip->bm_mmio) | 462 | iowrite8(val, chip->bmaddr + offset); |
476 | writeb(val, chip->remap_bmaddr + offset); | ||
477 | else | ||
478 | outb(val, chip->bmaddr + offset); | ||
479 | } | 463 | } |
480 | 464 | ||
481 | static void iputword(struct intel8x0 *chip, u32 offset, u16 val) | 465 | static inline void iputword(struct intel8x0 *chip, u32 offset, u16 val) |
482 | { | 466 | { |
483 | if (chip->bm_mmio) | 467 | iowrite16(val, chip->bmaddr + offset); |
484 | writew(val, chip->remap_bmaddr + offset); | ||
485 | else | ||
486 | outw(val, chip->bmaddr + offset); | ||
487 | } | 468 | } |
488 | 469 | ||
489 | static void iputdword(struct intel8x0 *chip, u32 offset, u32 val) | 470 | static inline void iputdword(struct intel8x0 *chip, u32 offset, u32 val) |
490 | { | 471 | { |
491 | if (chip->bm_mmio) | 472 | iowrite32(val, chip->bmaddr + offset); |
492 | writel(val, chip->remap_bmaddr + offset); | ||
493 | else | ||
494 | outl(val, chip->bmaddr + offset); | ||
495 | } | 473 | } |
496 | 474 | ||
497 | /* | 475 | /* |
498 | * Lowlevel I/O - AC'97 registers | 476 | * Lowlevel I/O - AC'97 registers |
499 | */ | 477 | */ |
500 | 478 | ||
501 | static u16 iagetword(struct intel8x0 *chip, u32 offset) | 479 | static inline u16 iagetword(struct intel8x0 *chip, u32 offset) |
502 | { | 480 | { |
503 | if (chip->mmio) | 481 | return ioread16(chip->addr + offset); |
504 | return readw(chip->remap_addr + offset); | ||
505 | else | ||
506 | return inw(chip->addr + offset); | ||
507 | } | 482 | } |
508 | 483 | ||
509 | static void iaputword(struct intel8x0 *chip, u32 offset, u16 val) | 484 | static inline void iaputword(struct intel8x0 *chip, u32 offset, u16 val) |
510 | { | 485 | { |
511 | if (chip->mmio) | 486 | iowrite16(val, chip->addr + offset); |
512 | writew(val, chip->remap_addr + offset); | ||
513 | else | ||
514 | outw(val, chip->addr + offset); | ||
515 | } | 487 | } |
516 | 488 | ||
517 | /* | 489 | /* |
@@ -2443,10 +2415,10 @@ static int snd_intel8x0_free(struct intel8x0 *chip) | |||
2443 | fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0); | 2415 | fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0); |
2444 | snd_dma_free_pages(&chip->bdbars); | 2416 | snd_dma_free_pages(&chip->bdbars); |
2445 | } | 2417 | } |
2446 | if (chip->remap_addr) | 2418 | if (chip->addr) |
2447 | iounmap(chip->remap_addr); | 2419 | pci_iounmap(chip->pci, chip->addr); |
2448 | if (chip->remap_bmaddr) | 2420 | if (chip->bmaddr) |
2449 | iounmap(chip->remap_bmaddr); | 2421 | pci_iounmap(chip->pci, chip->bmaddr); |
2450 | pci_release_regions(chip->pci); | 2422 | pci_release_regions(chip->pci); |
2451 | pci_disable_device(chip->pci); | 2423 | pci_disable_device(chip->pci); |
2452 | kfree(chip); | 2424 | kfree(chip); |
@@ -2793,35 +2765,27 @@ static int __devinit snd_intel8x0_create(struct snd_card *card, | |||
2793 | 2765 | ||
2794 | if (device_type == DEVICE_ALI) { | 2766 | if (device_type == DEVICE_ALI) { |
2795 | /* ALI5455 has no ac97 region */ | 2767 | /* ALI5455 has no ac97 region */ |
2796 | chip->bmaddr = pci_resource_start(pci, 0); | 2768 | chip->bmaddr = pci_iomap(pci, 0, 0); |
2797 | goto port_inited; | 2769 | goto port_inited; |
2798 | } | 2770 | } |
2799 | 2771 | ||
2800 | if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) { /* ICH4 and Nforce */ | 2772 | if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ |
2801 | chip->mmio = 1; | 2773 | chip->addr = pci_iomap(pci, 2, 0); |
2802 | chip->addr = pci_resource_start(pci, 2); | 2774 | else |
2803 | chip->remap_addr = ioremap_nocache(chip->addr, | 2775 | chip->addr = pci_iomap(pci, 0, 0); |
2804 | pci_resource_len(pci, 2)); | 2776 | if (!chip->addr) { |
2805 | if (chip->remap_addr == NULL) { | 2777 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); |
2806 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); | 2778 | snd_intel8x0_free(chip); |
2807 | snd_intel8x0_free(chip); | 2779 | return -EIO; |
2808 | return -EIO; | 2780 | } |
2809 | } | 2781 | if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ |
2810 | } else { | 2782 | chip->bmaddr = pci_iomap(pci, 3, 0); |
2811 | chip->addr = pci_resource_start(pci, 0); | 2783 | else |
2812 | } | 2784 | chip->bmaddr = pci_iomap(pci, 1, 0); |
2813 | if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) { /* ICH4 */ | 2785 | if (!chip->bmaddr) { |
2814 | chip->bm_mmio = 1; | 2786 | snd_printk(KERN_ERR "Controller space ioremap problem\n"); |
2815 | chip->bmaddr = pci_resource_start(pci, 3); | 2787 | snd_intel8x0_free(chip); |
2816 | chip->remap_bmaddr = ioremap_nocache(chip->bmaddr, | 2788 | return -EIO; |
2817 | pci_resource_len(pci, 3)); | ||
2818 | if (chip->remap_bmaddr == NULL) { | ||
2819 | snd_printk(KERN_ERR "Controller space ioremap problem\n"); | ||
2820 | snd_intel8x0_free(chip); | ||
2821 | return -EIO; | ||
2822 | } | ||
2823 | } else { | ||
2824 | chip->bmaddr = pci_resource_start(pci, 1); | ||
2825 | } | 2789 | } |
2826 | 2790 | ||
2827 | port_inited: | 2791 | port_inited: |
@@ -3025,8 +2989,8 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, | |||
3025 | snd_intel8x0_proc_init(chip); | 2989 | snd_intel8x0_proc_init(chip); |
3026 | 2990 | ||
3027 | snprintf(card->longname, sizeof(card->longname), | 2991 | snprintf(card->longname, sizeof(card->longname), |
3028 | "%s with %s at %#lx, irq %i", card->shortname, | 2992 | "%s with %s at irq %i", card->shortname, |
3029 | snd_ac97_get_short_name(chip->ac97[0]), chip->addr, chip->irq); | 2993 | snd_ac97_get_short_name(chip->ac97[0]), chip->irq); |
3030 | 2994 | ||
3031 | if (! ac97_clock) | 2995 | if (! ac97_clock) |
3032 | intel8x0_measure_ac97_clock(chip); | 2996 | intel8x0_measure_ac97_clock(chip); |