|
8 | 8 |
|
9 | 9 | #include <linux/device.h>
|
10 | 10 | #include <linux/interrupt.h>
|
| 11 | +#include <linux/io.h> |
11 | 12 | #include <linux/pm_runtime.h>
|
12 | 13 | #include <linux/timecounter.h>
|
13 | 14 | #include <sound/core.h>
|
@@ -330,6 +331,7 @@ struct hdac_bus {
|
330 | 331 | bool chip_init:1; /* h/w initialized */
|
331 | 332 |
|
332 | 333 | /* behavior flags */
|
| 334 | + bool aligned_mmio:1; /* aligned MMIO access */ |
333 | 335 | bool sync_write:1; /* sync after verb write */
|
334 | 336 | bool use_posbuf:1; /* use position buffer */
|
335 | 337 | bool snoop:1; /* enable snooping */
|
@@ -405,34 +407,61 @@ void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus);
|
405 | 407 | unsigned int snd_hdac_aligned_read(void __iomem *addr, unsigned int mask);
|
406 | 408 | void snd_hdac_aligned_write(unsigned int val, void __iomem *addr,
|
407 | 409 | unsigned int mask);
|
408 |
| -#define snd_hdac_reg_writeb(v, addr) snd_hdac_aligned_write(v, addr, 0xff) |
409 |
| -#define snd_hdac_reg_writew(v, addr) snd_hdac_aligned_write(v, addr, 0xffff) |
410 |
| -#define snd_hdac_reg_readb(addr) snd_hdac_aligned_read(addr, 0xff) |
411 |
| -#define snd_hdac_reg_readw(addr) snd_hdac_aligned_read(addr, 0xffff) |
412 |
| -#else /* CONFIG_SND_HDA_ALIGNED_MMIO */ |
413 |
| -#define snd_hdac_reg_writeb(val, addr) writeb(val, addr) |
414 |
| -#define snd_hdac_reg_writew(val, addr) writew(val, addr) |
415 |
| -#define snd_hdac_reg_readb(addr) readb(addr) |
416 |
| -#define snd_hdac_reg_readw(addr) readw(addr) |
417 |
| -#endif /* CONFIG_SND_HDA_ALIGNED_MMIO */ |
418 |
| -#define snd_hdac_reg_writel(val, addr) writel(val, addr) |
419 |
| -#define snd_hdac_reg_readl(addr) readl(addr) |
| 410 | +#define snd_hdac_aligned_mmio(bus) (bus)->aligned_mmio |
| 411 | +#else |
| 412 | +#define snd_hdac_aligned_mmio(bus) false |
| 413 | +#define snd_hdac_aligned_read(addr, mask) 0 |
| 414 | +#define snd_hdac_aligned_write(val, addr, mask) do {} while (0) |
| 415 | +#endif |
| 416 | + |
| 417 | +static inline void snd_hdac_reg_writeb(struct hdac_bus *bus, void __iomem *addr, |
| 418 | + u8 val) |
| 419 | +{ |
| 420 | + if (snd_hdac_aligned_mmio(bus)) |
| 421 | + snd_hdac_aligned_write(val, addr, 0xff); |
| 422 | + else |
| 423 | + writeb(val, addr); |
| 424 | +} |
| 425 | + |
| 426 | +static inline void snd_hdac_reg_writew(struct hdac_bus *bus, void __iomem *addr, |
| 427 | + u16 val) |
| 428 | +{ |
| 429 | + if (snd_hdac_aligned_mmio(bus)) |
| 430 | + snd_hdac_aligned_write(val, addr, 0xffff); |
| 431 | + else |
| 432 | + writew(val, addr); |
| 433 | +} |
| 434 | + |
| 435 | +static inline u8 snd_hdac_reg_readb(struct hdac_bus *bus, void __iomem *addr) |
| 436 | +{ |
| 437 | + return snd_hdac_aligned_mmio(bus) ? |
| 438 | + snd_hdac_aligned_read(addr, 0xff) : readb(addr); |
| 439 | +} |
| 440 | + |
| 441 | +static inline u16 snd_hdac_reg_readw(struct hdac_bus *bus, void __iomem *addr) |
| 442 | +{ |
| 443 | + return snd_hdac_aligned_mmio(bus) ? |
| 444 | + snd_hdac_aligned_read(addr, 0xffff) : readw(addr); |
| 445 | +} |
| 446 | + |
| 447 | +#define snd_hdac_reg_writel(bus, addr, val) writel(val, addr) |
| 448 | +#define snd_hdac_reg_readl(bus, addr) readl(addr) |
420 | 449 |
|
421 | 450 | /*
|
422 | 451 | * macros for easy use
|
423 | 452 | */
|
424 | 453 | #define _snd_hdac_chip_writeb(chip, reg, value) \
|
425 |
| - snd_hdac_reg_writeb(value, (chip)->remap_addr + (reg)) |
| 454 | + snd_hdac_reg_writeb(chip, (chip)->remap_addr + (reg), value) |
426 | 455 | #define _snd_hdac_chip_readb(chip, reg) \
|
427 |
| - snd_hdac_reg_readb((chip)->remap_addr + (reg)) |
| 456 | + snd_hdac_reg_readb(chip, (chip)->remap_addr + (reg)) |
428 | 457 | #define _snd_hdac_chip_writew(chip, reg, value) \
|
429 |
| - snd_hdac_reg_writew(value, (chip)->remap_addr + (reg)) |
| 458 | + snd_hdac_reg_writew(chip, (chip)->remap_addr + (reg), value) |
430 | 459 | #define _snd_hdac_chip_readw(chip, reg) \
|
431 |
| - snd_hdac_reg_readw((chip)->remap_addr + (reg)) |
| 460 | + snd_hdac_reg_readw(chip, (chip)->remap_addr + (reg)) |
432 | 461 | #define _snd_hdac_chip_writel(chip, reg, value) \
|
433 |
| - snd_hdac_reg_writel(value, (chip)->remap_addr + (reg)) |
| 462 | + snd_hdac_reg_writel(chip, (chip)->remap_addr + (reg), value) |
434 | 463 | #define _snd_hdac_chip_readl(chip, reg) \
|
435 |
| - snd_hdac_reg_readl((chip)->remap_addr + (reg)) |
| 464 | + snd_hdac_reg_readl(chip, (chip)->remap_addr + (reg)) |
436 | 465 |
|
437 | 466 | /* read/write a register, pass without AZX_REG_ prefix */
|
438 | 467 | #define snd_hdac_chip_writel(chip, reg, value) \
|
@@ -540,17 +569,17 @@ int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus,
|
540 | 569 | */
|
541 | 570 | /* read/write a register, pass without AZX_REG_ prefix */
|
542 | 571 | #define snd_hdac_stream_writel(dev, reg, value) \
|
543 |
| - snd_hdac_reg_writel(value, (dev)->sd_addr + AZX_REG_ ## reg) |
| 572 | + snd_hdac_reg_writel((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) |
544 | 573 | #define snd_hdac_stream_writew(dev, reg, value) \
|
545 |
| - snd_hdac_reg_writew(value, (dev)->sd_addr + AZX_REG_ ## reg) |
| 574 | + snd_hdac_reg_writew((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) |
546 | 575 | #define snd_hdac_stream_writeb(dev, reg, value) \
|
547 |
| - snd_hdac_reg_writeb(value, (dev)->sd_addr + AZX_REG_ ## reg) |
| 576 | + snd_hdac_reg_writeb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) |
548 | 577 | #define snd_hdac_stream_readl(dev, reg) \
|
549 |
| - snd_hdac_reg_readl((dev)->sd_addr + AZX_REG_ ## reg) |
| 578 | + snd_hdac_reg_readl((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) |
550 | 579 | #define snd_hdac_stream_readw(dev, reg) \
|
551 |
| - snd_hdac_reg_readw((dev)->sd_addr + AZX_REG_ ## reg) |
| 580 | + snd_hdac_reg_readw((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) |
552 | 581 | #define snd_hdac_stream_readb(dev, reg) \
|
553 |
| - snd_hdac_reg_readb((dev)->sd_addr + AZX_REG_ ## reg) |
| 582 | + snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) |
554 | 583 |
|
555 | 584 | /* update a register, pass without AZX_REG_ prefix */
|
556 | 585 | #define snd_hdac_stream_updatel(dev, reg, mask, val) \
|
|
0 commit comments