aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/intel8x0.c120
-rw-r--r--sound/pci/intel8x0m.c118
2 files changed, 83 insertions, 155 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
449static u8 igetbyte(struct intel8x0 *chip, u32 offset) 445static 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
457static u16 igetword(struct intel8x0 *chip, u32 offset) 450static 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
465static u32 igetdword(struct intel8x0 *chip, u32 offset) 455static 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
473static void iputbyte(struct intel8x0 *chip, u32 offset, u8 val) 460static 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
481static void iputword(struct intel8x0 *chip, u32 offset, u16 val) 465static 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
489static void iputdword(struct intel8x0 *chip, u32 offset, u32 val) 470static 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
501static u16 iagetword(struct intel8x0 *chip, u32 offset) 479static 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
509static void iaputword(struct intel8x0 *chip, u32 offset, u16 val) 484static 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);
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 09dcf923b547..936c3cf16936 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
256static u8 igetbyte(struct intel8x0m *chip, u32 offset) 252static 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
264static u16 igetword(struct intel8x0m *chip, u32 offset) 257static 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
272static u32 igetdword(struct intel8x0m *chip, u32 offset) 262static 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
280static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) 267static 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
288static void iputword(struct intel8x0m *chip, u32 offset, u16 val) 272static 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
296static void iputdword(struct intel8x0m *chip, u32 offset, u32 val) 277static 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
308static u16 iagetword(struct intel8x0m *chip, u32 offset) 286static 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
316static void iaputword(struct intel8x0m *chip, u32 offset, u16 val) 291static 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/*
@@ -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);