diff options
Diffstat (limited to 'sound/pci/intel8x0m.c')
-rw-r--r-- | sound/pci/intel8x0m.c | 120 |
1 files changed, 42 insertions, 78 deletions
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 09dcf923b54..c155e1f3a0e 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c | |||
@@ -196,12 +196,8 @@ struct intel8x0m { | |||
196 | 196 | ||
197 | int irq; | 197 | int irq; |
198 | 198 | ||
199 | unsigned int mmio; | 199 | void __iomem *addr; |
200 | unsigned long addr; | 200 | void __iomem *bmaddr; |
201 | void __iomem *remap_addr; | ||
202 | unsigned int bm_mmio; | ||
203 | unsigned long bmaddr; | ||
204 | void __iomem *remap_bmaddr; | ||
205 | 201 | ||
206 | struct pci_dev *pci; | 202 | struct pci_dev *pci; |
207 | struct snd_card *card; | 203 | struct snd_card *card; |
@@ -253,72 +249,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); | |||
253 | * Lowlevel I/O - busmaster | 249 | * Lowlevel I/O - busmaster |
254 | */ | 250 | */ |
255 | 251 | ||
256 | static u8 igetbyte(struct intel8x0m *chip, u32 offset) | 252 | static inline u8 igetbyte(struct intel8x0m *chip, u32 offset) |
257 | { | 253 | { |
258 | if (chip->bm_mmio) | 254 | return ioread8(chip->bmaddr + offset); |
259 | return readb(chip->remap_bmaddr + offset); | ||
260 | else | ||
261 | return inb(chip->bmaddr + offset); | ||
262 | } | 255 | } |
263 | 256 | ||
264 | static u16 igetword(struct intel8x0m *chip, u32 offset) | 257 | static inline u16 igetword(struct intel8x0m *chip, u32 offset) |
265 | { | 258 | { |
266 | if (chip->bm_mmio) | 259 | return ioread16(chip->bmaddr + offset); |
267 | return readw(chip->remap_bmaddr + offset); | ||
268 | else | ||
269 | return inw(chip->bmaddr + offset); | ||
270 | } | 260 | } |
271 | 261 | ||
272 | static u32 igetdword(struct intel8x0m *chip, u32 offset) | 262 | static inline u32 igetdword(struct intel8x0m *chip, u32 offset) |
273 | { | 263 | { |
274 | if (chip->bm_mmio) | 264 | return ioread32(chip->bmaddr + offset); |
275 | return readl(chip->remap_bmaddr + offset); | ||
276 | else | ||
277 | return inl(chip->bmaddr + offset); | ||
278 | } | 265 | } |
279 | 266 | ||
280 | static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) | 267 | static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) |
281 | { | 268 | { |
282 | if (chip->bm_mmio) | 269 | iowrite8(val, chip->bmaddr + offset); |
283 | writeb(val, chip->remap_bmaddr + offset); | ||
284 | else | ||
285 | outb(val, chip->bmaddr + offset); | ||
286 | } | 270 | } |
287 | 271 | ||
288 | static void iputword(struct intel8x0m *chip, u32 offset, u16 val) | 272 | static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val) |
289 | { | 273 | { |
290 | if (chip->bm_mmio) | 274 | iowrite16(val, chip->bmaddr + offset); |
291 | writew(val, chip->remap_bmaddr + offset); | ||
292 | else | ||
293 | outw(val, chip->bmaddr + offset); | ||
294 | } | 275 | } |
295 | 276 | ||
296 | static void iputdword(struct intel8x0m *chip, u32 offset, u32 val) | 277 | static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val) |
297 | { | 278 | { |
298 | if (chip->bm_mmio) | 279 | iowrite32(val, chip->bmaddr + offset); |
299 | writel(val, chip->remap_bmaddr + offset); | ||
300 | else | ||
301 | outl(val, chip->bmaddr + offset); | ||
302 | } | 280 | } |
303 | 281 | ||
304 | /* | 282 | /* |
305 | * Lowlevel I/O - AC'97 registers | 283 | * Lowlevel I/O - AC'97 registers |
306 | */ | 284 | */ |
307 | 285 | ||
308 | static u16 iagetword(struct intel8x0m *chip, u32 offset) | 286 | static inline u16 iagetword(struct intel8x0m *chip, u32 offset) |
309 | { | 287 | { |
310 | if (chip->mmio) | 288 | return ioread16(chip->addr + offset); |
311 | return readw(chip->remap_addr + offset); | ||
312 | else | ||
313 | return inw(chip->addr + offset); | ||
314 | } | 289 | } |
315 | 290 | ||
316 | static void iaputword(struct intel8x0m *chip, u32 offset, u16 val) | 291 | static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val) |
317 | { | 292 | { |
318 | if (chip->mmio) | 293 | iowrite16(val, chip->addr + offset); |
319 | writew(val, chip->remap_addr + offset); | ||
320 | else | ||
321 | outw(val, chip->addr + offset); | ||
322 | } | 294 | } |
323 | 295 | ||
324 | /* | 296 | /* |
@@ -858,7 +830,7 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0m *chip, int ac97_clock) | |||
858 | memset(&ac97, 0, sizeof(ac97)); | 830 | memset(&ac97, 0, sizeof(ac97)); |
859 | ac97.private_data = chip; | 831 | ac97.private_data = chip; |
860 | ac97.private_free = snd_intel8x0_mixer_free_ac97; | 832 | ac97.private_free = snd_intel8x0_mixer_free_ac97; |
861 | ac97.scaps = AC97_SCAP_SKIP_AUDIO; | 833 | ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; |
862 | 834 | ||
863 | glob_sta = igetdword(chip, ICHREG(GLOB_STA)); | 835 | glob_sta = igetdword(chip, ICHREG(GLOB_STA)); |
864 | 836 | ||
@@ -1019,10 +991,10 @@ static int snd_intel8x0_free(struct intel8x0m *chip) | |||
1019 | __hw_end: | 991 | __hw_end: |
1020 | if (chip->bdbars.area) | 992 | if (chip->bdbars.area) |
1021 | snd_dma_free_pages(&chip->bdbars); | 993 | snd_dma_free_pages(&chip->bdbars); |
1022 | if (chip->remap_addr) | 994 | if (chip->addr) |
1023 | iounmap(chip->remap_addr); | 995 | pci_iounmap(chip->pci, chip->addr); |
1024 | if (chip->remap_bmaddr) | 996 | if (chip->bmaddr) |
1025 | iounmap(chip->remap_bmaddr); | 997 | pci_iounmap(chip->pci, chip->bmaddr); |
1026 | if (chip->irq >= 0) | 998 | if (chip->irq >= 0) |
1027 | free_irq(chip->irq, chip); | 999 | free_irq(chip->irq, chip); |
1028 | pci_release_regions(chip->pci); | 1000 | pci_release_regions(chip->pci); |
@@ -1173,35 +1145,27 @@ static int __devinit snd_intel8x0m_create(struct snd_card *card, | |||
1173 | 1145 | ||
1174 | if (device_type == DEVICE_ALI) { | 1146 | if (device_type == DEVICE_ALI) { |
1175 | /* ALI5455 has no ac97 region */ | 1147 | /* ALI5455 has no ac97 region */ |
1176 | chip->bmaddr = pci_resource_start(pci, 0); | 1148 | chip->bmaddr = pci_iomap(pci, 0, 0); |
1177 | goto port_inited; | 1149 | goto port_inited; |
1178 | } | 1150 | } |
1179 | 1151 | ||
1180 | if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) { /* ICH4 and Nforce */ | 1152 | if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ |
1181 | chip->mmio = 1; | 1153 | chip->addr = pci_iomap(pci, 2, 0); |
1182 | chip->addr = pci_resource_start(pci, 2); | 1154 | else |
1183 | chip->remap_addr = ioremap_nocache(chip->addr, | 1155 | chip->addr = pci_iomap(pci, 0, 0); |
1184 | pci_resource_len(pci, 2)); | 1156 | if (!chip->addr) { |
1185 | if (chip->remap_addr == NULL) { | 1157 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); |
1186 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); | 1158 | snd_intel8x0_free(chip); |
1187 | snd_intel8x0_free(chip); | 1159 | return -EIO; |
1188 | return -EIO; | ||
1189 | } | ||
1190 | } else { | ||
1191 | chip->addr = pci_resource_start(pci, 0); | ||
1192 | } | 1160 | } |
1193 | if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) { /* ICH4 */ | 1161 | if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ |
1194 | chip->bm_mmio = 1; | 1162 | chip->bmaddr = pci_iomap(pci, 3, 0); |
1195 | chip->bmaddr = pci_resource_start(pci, 3); | 1163 | else |
1196 | chip->remap_bmaddr = ioremap_nocache(chip->bmaddr, | 1164 | chip->bmaddr = pci_iomap(pci, 1, 0); |
1197 | pci_resource_len(pci, 3)); | 1165 | if (!chip->bmaddr) { |
1198 | if (chip->remap_bmaddr == NULL) { | 1166 | snd_printk(KERN_ERR "Controller space ioremap problem\n"); |
1199 | snd_printk(KERN_ERR "Controller space ioremap problem\n"); | 1167 | snd_intel8x0_free(chip); |
1200 | snd_intel8x0_free(chip); | 1168 | return -EIO; |
1201 | return -EIO; | ||
1202 | } | ||
1203 | } else { | ||
1204 | chip->bmaddr = pci_resource_start(pci, 1); | ||
1205 | } | 1169 | } |
1206 | 1170 | ||
1207 | port_inited: | 1171 | port_inited: |
@@ -1339,8 +1303,8 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, | |||
1339 | 1303 | ||
1340 | snd_intel8x0m_proc_init(chip); | 1304 | snd_intel8x0m_proc_init(chip); |
1341 | 1305 | ||
1342 | sprintf(card->longname, "%s at 0x%lx, irq %i", | 1306 | sprintf(card->longname, "%s at irq %i", |
1343 | card->shortname, chip->addr, chip->irq); | 1307 | card->shortname, chip->irq); |
1344 | 1308 | ||
1345 | if ((err = snd_card_register(card)) < 0) { | 1309 | if ((err = snd_card_register(card)) < 0) { |
1346 | snd_card_free(card); | 1310 | snd_card_free(card); |