X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=sound%2Fpci%2Fintel8x0m.c;h=faf674e671aca3c1432cf4d04860bb69f210d5df;hb=b6c40d68ff6498b7f63ddf97cf0aa818d748dee7;hp=91850281f89b16a7ad3afa9e8487f9d194f9e9b9;hpb=a23f4636c9ae7f1f15c448080f1552864b404136;p=linux-2.6-omap-h63xx.git diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 91850281f89..faf674e671a 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1,7 +1,7 @@ /* * ALSA modem driver for Intel ICH (i8x0) chipsets * - * Copyright (c) 2000 Jaroslav Kysela + * Copyright (c) 2000 Jaroslav Kysela * * This is modified (by Sasha Khapyorsky ) version * of ALSA ICH sound driver intel8x0.c . @@ -23,7 +23,6 @@ * */ -#include #include #include #include @@ -37,7 +36,7 @@ #include #include -MODULE_AUTHOR("Jaroslav Kysela "); +MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; " "SiS 7013; NVidia MCP/2/2S/3 modems"); MODULE_LICENSE("GPL"); @@ -196,12 +195,8 @@ struct intel8x0m { int irq; - unsigned int mmio; - unsigned long addr; - void __iomem *remap_addr; - unsigned int bm_mmio; - unsigned long bmaddr; - void __iomem *remap_bmaddr; + void __iomem *addr; + void __iomem *bmaddr; struct pci_dev *pci; struct snd_card *card; @@ -253,72 +248,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); * Lowlevel I/O - busmaster */ -static u8 igetbyte(struct intel8x0m *chip, u32 offset) +static inline u8 igetbyte(struct intel8x0m *chip, u32 offset) { - if (chip->bm_mmio) - return readb(chip->remap_bmaddr + offset); - else - return inb(chip->bmaddr + offset); + return ioread8(chip->bmaddr + offset); } -static u16 igetword(struct intel8x0m *chip, u32 offset) +static inline u16 igetword(struct intel8x0m *chip, u32 offset) { - if (chip->bm_mmio) - return readw(chip->remap_bmaddr + offset); - else - return inw(chip->bmaddr + offset); + return ioread16(chip->bmaddr + offset); } -static u32 igetdword(struct intel8x0m *chip, u32 offset) +static inline u32 igetdword(struct intel8x0m *chip, u32 offset) { - if (chip->bm_mmio) - return readl(chip->remap_bmaddr + offset); - else - return inl(chip->bmaddr + offset); + return ioread32(chip->bmaddr + offset); } -static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) +static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) { - if (chip->bm_mmio) - writeb(val, chip->remap_bmaddr + offset); - else - outb(val, chip->bmaddr + offset); + iowrite8(val, chip->bmaddr + offset); } -static void iputword(struct intel8x0m *chip, u32 offset, u16 val) +static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val) { - if (chip->bm_mmio) - writew(val, chip->remap_bmaddr + offset); - else - outw(val, chip->bmaddr + offset); + iowrite16(val, chip->bmaddr + offset); } -static void iputdword(struct intel8x0m *chip, u32 offset, u32 val) +static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val) { - if (chip->bm_mmio) - writel(val, chip->remap_bmaddr + offset); - else - outl(val, chip->bmaddr + offset); + iowrite32(val, chip->bmaddr + offset); } /* * Lowlevel I/O - AC'97 registers */ -static u16 iagetword(struct intel8x0m *chip, u32 offset) +static inline u16 iagetword(struct intel8x0m *chip, u32 offset) { - if (chip->mmio) - return readw(chip->remap_addr + offset); - else - return inw(chip->addr + offset); + return ioread16(chip->addr + offset); } -static void iaputword(struct intel8x0m *chip, u32 offset, u16 val) +static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val) { - if (chip->mmio) - writew(val, chip->remap_addr + offset); - else - outw(val, chip->addr + offset); + iowrite16(val, chip->addr + offset); } /* @@ -511,7 +482,7 @@ static inline void snd_intel8x0_update(struct intel8x0m *chip, struct ichdev *ic iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); } -static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id) { struct intel8x0m *chip = dev_id; struct ichdev *ichdev; @@ -858,7 +829,7 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0m *chip, int ac97_clock) memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_intel8x0_mixer_free_ac97; - ac97.scaps = AC97_SCAP_SKIP_AUDIO; + ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; glob_sta = igetdword(chip, ICHREG(GLOB_STA)); @@ -1014,17 +985,15 @@ static int snd_intel8x0_free(struct intel8x0m *chip) /* reset channels */ for (i = 0; i < chip->bdbars_count; i++) iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); - /* --- */ - synchronize_irq(chip->irq); - __hw_end: - if (chip->bdbars.area) - snd_dma_free_pages(&chip->bdbars); - if (chip->remap_addr) - iounmap(chip->remap_addr); - if (chip->remap_bmaddr) - iounmap(chip->remap_bmaddr); + __hw_end: if (chip->irq >= 0) free_irq(chip->irq, chip); + if (chip->bdbars.area) + snd_dma_free_pages(&chip->bdbars); + if (chip->addr) + pci_iounmap(chip->pci, chip->addr); + if (chip->bmaddr) + pci_iounmap(chip->pci, chip->bmaddr); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); @@ -1045,8 +1014,13 @@ static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state) for (i = 0; i < chip->pcm_devs; i++) snd_pcm_suspend_all(chip->pcm[i]); snd_ac97_suspend(chip->ac97); + if (chip->irq >= 0) { + free_irq(chip->irq, chip); + chip->irq = -1; + } pci_disable_device(pci); pci_save_state(pci); + pci_set_power_state(pci, pci_choose_state(pci, state)); return 0; } @@ -1055,9 +1029,23 @@ static int intel8x0m_resume(struct pci_dev *pci) struct snd_card *card = pci_get_drvdata(pci); struct intel8x0m *chip = card->private_data; + pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); - pci_enable_device(pci); + if (pci_enable_device(pci) < 0) { + printk(KERN_ERR "intel8x0m: pci_enable_device failed, " + "disabling device\n"); + snd_card_disconnect(card); + return -EIO; + } pci_set_master(pci); + if (request_irq(pci->irq, snd_intel8x0_interrupt, + IRQF_SHARED, card->shortname, chip)) { + printk(KERN_ERR "intel8x0m: unable to grab IRQ %d, " + "disabling device\n", pci->irq); + snd_card_disconnect(card); + return -EIO; + } + chip->irq = pci->irq; snd_intel8x0_chip_init(chip, 0); snd_ac97_resume(chip->ac97); @@ -1153,39 +1141,31 @@ static int __devinit snd_intel8x0m_create(struct snd_card *card, if (device_type == DEVICE_ALI) { /* ALI5455 has no ac97 region */ - chip->bmaddr = pci_resource_start(pci, 0); + chip->bmaddr = pci_iomap(pci, 0, 0); goto port_inited; } - if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) { /* ICH4 and Nforce */ - chip->mmio = 1; - chip->addr = pci_resource_start(pci, 2); - chip->remap_addr = ioremap_nocache(chip->addr, - pci_resource_len(pci, 2)); - if (chip->remap_addr == NULL) { - snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); - snd_intel8x0_free(chip); - return -EIO; - } - } else { - chip->addr = pci_resource_start(pci, 0); + if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ + chip->addr = pci_iomap(pci, 2, 0); + else + chip->addr = pci_iomap(pci, 0, 0); + if (!chip->addr) { + snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); + snd_intel8x0_free(chip); + return -EIO; } - if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) { /* ICH4 */ - chip->bm_mmio = 1; - chip->bmaddr = pci_resource_start(pci, 3); - chip->remap_bmaddr = ioremap_nocache(chip->bmaddr, - pci_resource_len(pci, 3)); - if (chip->remap_bmaddr == NULL) { - snd_printk(KERN_ERR "Controller space ioremap problem\n"); - snd_intel8x0_free(chip); - return -EIO; - } - } else { - chip->bmaddr = pci_resource_start(pci, 1); + if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ + chip->bmaddr = pci_iomap(pci, 3, 0); + else + chip->bmaddr = pci_iomap(pci, 1, 0); + if (!chip->bmaddr) { + snd_printk(KERN_ERR "Controller space ioremap problem\n"); + snd_intel8x0_free(chip); + return -EIO; } port_inited: - if (request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_DISABLED|IRQF_SHARED, + if (request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_SHARED, card->shortname, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_intel8x0_free(chip); @@ -1319,8 +1299,8 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, snd_intel8x0m_proc_init(chip); - sprintf(card->longname, "%s at 0x%lx, irq %i", - card->shortname, chip->addr, chip->irq); + sprintf(card->longname, "%s at irq %i", + card->shortname, chip->irq); if ((err = snd_card_register(card)) < 0) { snd_card_free(card);