1*1a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * Driver for PowerMac AWACS onboard soundchips 41da177e4SLinus Torvalds * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de> 51da177e4SLinus Torvalds * based on dmasound.c. 61da177e4SLinus Torvalds */ 71da177e4SLinus Torvalds 81da177e4SLinus Torvalds 91da177e4SLinus Torvalds #ifndef __AWACS_H 101da177e4SLinus Torvalds #define __AWACS_H 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds /*******************************/ 131da177e4SLinus Torvalds /* AWACs Audio Register Layout */ 141da177e4SLinus Torvalds /*******************************/ 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds struct awacs_regs { 171da177e4SLinus Torvalds unsigned control; /* Audio control register */ 181da177e4SLinus Torvalds unsigned pad0[3]; 191da177e4SLinus Torvalds unsigned codec_ctrl; /* Codec control register */ 201da177e4SLinus Torvalds unsigned pad1[3]; 211da177e4SLinus Torvalds unsigned codec_stat; /* Codec status register */ 221da177e4SLinus Torvalds unsigned pad2[3]; 231da177e4SLinus Torvalds unsigned clip_count; /* Clipping count register */ 241da177e4SLinus Torvalds unsigned pad3[3]; 251da177e4SLinus Torvalds unsigned byteswap; /* Data is little-endian if 1 */ 261da177e4SLinus Torvalds }; 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds /*******************/ 291da177e4SLinus Torvalds /* Audio Bit Masks */ 301da177e4SLinus Torvalds /*******************/ 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds /* Audio Control Reg Bit Masks */ 331da177e4SLinus Torvalds /* ----- ------- --- --- ----- */ 341da177e4SLinus Torvalds #define MASK_ISFSEL (0xf) /* Input SubFrame Select */ 351da177e4SLinus Torvalds #define MASK_OSFSEL (0xf << 4) /* Output SubFrame Select */ 361da177e4SLinus Torvalds #define MASK_RATE (0x7 << 8) /* Sound Rate */ 371da177e4SLinus Torvalds #define MASK_CNTLERR (0x1 << 11) /* Error */ 381da177e4SLinus Torvalds #define MASK_PORTCHG (0x1 << 12) /* Port Change */ 391da177e4SLinus Torvalds #define MASK_IEE (0x1 << 13) /* Enable Interrupt on Error */ 401da177e4SLinus Torvalds #define MASK_IEPC (0x1 << 14) /* Enable Interrupt on Port Change */ 411da177e4SLinus Torvalds #define MASK_SSFSEL (0x3 << 15) /* Status SubFrame Select */ 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds /* Audio Codec Control Reg Bit Masks */ 441da177e4SLinus Torvalds /* ----- ----- ------- --- --- ----- */ 451da177e4SLinus Torvalds #define MASK_NEWECMD (0x1 << 24) /* Lock: don't write to reg when 1 */ 461da177e4SLinus Torvalds #define MASK_EMODESEL (0x3 << 22) /* Send info out on which frame? */ 471da177e4SLinus Torvalds #define MASK_EXMODEADDR (0x3ff << 12) /* Extended Mode Address -- 10 bits */ 481da177e4SLinus Torvalds #define MASK_EXMODEDATA (0xfff) /* Extended Mode Data -- 12 bits */ 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds /* Audio Codec Control Address Values / Masks */ 511da177e4SLinus Torvalds /* ----- ----- ------- ------- ------ - ----- */ 521da177e4SLinus Torvalds #define MASK_ADDR0 (0x0 << 12) /* Expanded Data Mode Address 0 */ 531da177e4SLinus Torvalds #define MASK_ADDR_MUX MASK_ADDR0 /* Mux Control */ 541da177e4SLinus Torvalds #define MASK_ADDR_GAIN MASK_ADDR0 551da177e4SLinus Torvalds 561da177e4SLinus Torvalds #define MASK_ADDR1 (0x1 << 12) /* Expanded Data Mode Address 1 */ 571da177e4SLinus Torvalds #define MASK_ADDR_MUTE MASK_ADDR1 581da177e4SLinus Torvalds #define MASK_ADDR_RATE MASK_ADDR1 591da177e4SLinus Torvalds 601da177e4SLinus Torvalds #define MASK_ADDR2 (0x2 << 12) /* Expanded Data Mode Address 2 */ 611da177e4SLinus Torvalds #define MASK_ADDR_VOLA MASK_ADDR2 /* Volume Control A -- Headphones */ 621da177e4SLinus Torvalds #define MASK_ADDR_VOLHD MASK_ADDR2 631da177e4SLinus Torvalds 641da177e4SLinus Torvalds #define MASK_ADDR4 (0x4 << 12) /* Expanded Data Mode Address 4 */ 651da177e4SLinus Torvalds #define MASK_ADDR_VOLC MASK_ADDR4 /* Volume Control C -- Speaker */ 661da177e4SLinus Torvalds #define MASK_ADDR_VOLSPK MASK_ADDR4 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds /* additional registers of screamer */ 691da177e4SLinus Torvalds #define MASK_ADDR5 (0x5 << 12) /* Expanded Data Mode Address 5 */ 701da177e4SLinus Torvalds #define MASK_ADDR6 (0x6 << 12) /* Expanded Data Mode Address 6 */ 711da177e4SLinus Torvalds #define MASK_ADDR7 (0x7 << 12) /* Expanded Data Mode Address 7 */ 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds /* Address 0 Bit Masks & Macros */ 741da177e4SLinus Torvalds /* ------- - --- ----- - ------ */ 751da177e4SLinus Torvalds #define MASK_GAINRIGHT (0xf) /* Gain Right Mask */ 761da177e4SLinus Torvalds #define MASK_GAINLEFT (0xf << 4) /* Gain Left Mask */ 771da177e4SLinus Torvalds #define MASK_GAINLINE (0x1 << 8) /* Disable Mic preamp */ 781da177e4SLinus Torvalds #define MASK_GAINMIC (0x0 << 8) /* Enable Mic preamp */ 791da177e4SLinus Torvalds #define MASK_MUX_CD (0x1 << 9) /* Select CD in MUX */ 801da177e4SLinus Torvalds #define MASK_MUX_MIC (0x1 << 10) /* Select Mic in MUX */ 811da177e4SLinus Torvalds #define MASK_MUX_AUDIN (0x1 << 11) /* Select Audio In in MUX */ 821da177e4SLinus Torvalds #define MASK_MUX_LINE MASK_MUX_AUDIN 831da177e4SLinus Torvalds #define SHIFT_GAINLINE 8 841da177e4SLinus Torvalds #define SHIFT_MUX_CD 9 851da177e4SLinus Torvalds #define SHIFT_MUX_MIC 10 861da177e4SLinus Torvalds #define SHIFT_MUX_LINE 11 871da177e4SLinus Torvalds 881da177e4SLinus Torvalds #define GAINRIGHT(x) ((x) & MASK_GAINRIGHT) 891da177e4SLinus Torvalds #define GAINLEFT(x) (((x) << 4) & MASK_GAINLEFT) 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds /* Address 1 Bit Masks */ 921da177e4SLinus Torvalds /* ------- - --- ----- */ 931da177e4SLinus Torvalds #define MASK_ADDR1RES1 (0x3) /* Reserved */ 941da177e4SLinus Torvalds #define MASK_RECALIBRATE (0x1 << 2) /* Recalibrate */ 951da177e4SLinus Torvalds #define MASK_SAMPLERATE (0x7 << 3) /* Sample Rate: */ 961da177e4SLinus Torvalds #define MASK_LOOPTHRU (0x1 << 6) /* Loopthrough Enable */ 971da177e4SLinus Torvalds #define SHIFT_LOOPTHRU 6 981da177e4SLinus Torvalds #define MASK_CMUTE (0x1 << 7) /* Output C (Speaker) Mute when 1 */ 991da177e4SLinus Torvalds #define MASK_SPKMUTE MASK_CMUTE 1001da177e4SLinus Torvalds #define SHIFT_SPKMUTE 7 1011da177e4SLinus Torvalds #define MASK_ADDR1RES2 (0x1 << 8) /* Reserved */ 1021da177e4SLinus Torvalds #define MASK_AMUTE (0x1 << 9) /* Output A (Headphone) Mute when 1 */ 1031da177e4SLinus Torvalds #define MASK_HDMUTE MASK_AMUTE 1041da177e4SLinus Torvalds #define SHIFT_HDMUTE 9 1051da177e4SLinus Torvalds #define MASK_PAROUT (0x3 << 10) /* Parallel Out (???) */ 106a8c2a6bfSRisto Suominen #define MASK_PAROUT0 (0x1 << 10) /* Parallel Out (???) */ 107a8c2a6bfSRisto Suominen #define MASK_PAROUT1 (0x1 << 11) /* Parallel Out (enable speaker) */ 108a8c2a6bfSRisto Suominen #define SHIFT_PAROUT 10 109a8c2a6bfSRisto Suominen #define SHIFT_PAROUT0 10 110a8c2a6bfSRisto Suominen #define SHIFT_PAROUT1 11 1111da177e4SLinus Torvalds 1121da177e4SLinus Torvalds #define SAMPLERATE_48000 (0x0 << 3) /* 48 or 44.1 kHz */ 1131da177e4SLinus Torvalds #define SAMPLERATE_32000 (0x1 << 3) /* 32 or 29.4 kHz */ 1141da177e4SLinus Torvalds #define SAMPLERATE_24000 (0x2 << 3) /* 24 or 22.05 kHz */ 1151da177e4SLinus Torvalds #define SAMPLERATE_19200 (0x3 << 3) /* 19.2 or 17.64 kHz */ 1161da177e4SLinus Torvalds #define SAMPLERATE_16000 (0x4 << 3) /* 16 or 14.7 kHz */ 1171da177e4SLinus Torvalds #define SAMPLERATE_12000 (0x5 << 3) /* 12 or 11.025 kHz */ 1181da177e4SLinus Torvalds #define SAMPLERATE_9600 (0x6 << 3) /* 9.6 or 8.82 kHz */ 1191da177e4SLinus Torvalds #define SAMPLERATE_8000 (0x7 << 3) /* 8 or 7.35 kHz */ 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds /* Address 2 & 4 Bit Masks & Macros */ 1221da177e4SLinus Torvalds /* ------- - - - --- ----- - ------ */ 1231da177e4SLinus Torvalds #define MASK_OUTVOLRIGHT (0xf) /* Output Right Volume */ 1241da177e4SLinus Torvalds #define MASK_ADDR2RES1 (0x2 << 4) /* Reserved */ 1251da177e4SLinus Torvalds #define MASK_ADDR4RES1 MASK_ADDR2RES1 1261da177e4SLinus Torvalds #define MASK_OUTVOLLEFT (0xf << 6) /* Output Left Volume */ 1271da177e4SLinus Torvalds #define MASK_ADDR2RES2 (0x2 << 10) /* Reserved */ 1281da177e4SLinus Torvalds #define MASK_ADDR4RES2 MASK_ADDR2RES2 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds #define VOLRIGHT(x) (((~(x)) & MASK_OUTVOLRIGHT)) 1311da177e4SLinus Torvalds #define VOLLEFT(x) (((~(x)) << 6) & MASK_OUTVOLLEFT) 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds /* address 6 */ 1341da177e4SLinus Torvalds #define MASK_MIC_BOOST (0x4) /* screamer mic boost */ 1351da177e4SLinus Torvalds #define SHIFT_MIC_BOOST 2 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds /* Audio Codec Status Reg Bit Masks */ 1381da177e4SLinus Torvalds /* ----- ----- ------ --- --- ----- */ 1391da177e4SLinus Torvalds #define MASK_EXTEND (0x1 << 23) /* Extend */ 1401da177e4SLinus Torvalds #define MASK_VALID (0x1 << 22) /* Valid Data? */ 1411da177e4SLinus Torvalds #define MASK_OFLEFT (0x1 << 21) /* Overflow Left */ 1421da177e4SLinus Torvalds #define MASK_OFRIGHT (0x1 << 20) /* Overflow Right */ 1431da177e4SLinus Torvalds #define MASK_ERRCODE (0xf << 16) /* Error Code */ 1441da177e4SLinus Torvalds #define MASK_REVISION (0xf << 12) /* Revision Number */ 1451da177e4SLinus Torvalds #define MASK_MFGID (0xf << 8) /* Mfg. ID */ 1461da177e4SLinus Torvalds #define MASK_CODSTATRES (0xf << 4) /* bits 4 - 7 reserved */ 147a8c2a6bfSRisto Suominen #define MASK_INSENSE (0xf) /* port sense bits: */ 1481da177e4SLinus Torvalds #define MASK_HDPCONN 8 /* headphone plugged in */ 149a8c2a6bfSRisto Suominen #define MASK_LOCONN 4 /* line-out plugged in */ 150a8c2a6bfSRisto Suominen #define MASK_LICONN 2 /* line-in plugged in */ 151a8c2a6bfSRisto Suominen #define MASK_MICCONN 1 /* microphone plugged in */ 152a8c2a6bfSRisto Suominen #define MASK_LICONN_IMAC 8 /* line-in plugged in */ 153a8c2a6bfSRisto Suominen #define MASK_HDPRCONN_IMAC 4 /* headphone right plugged in */ 154a8c2a6bfSRisto Suominen #define MASK_HDPLCONN_IMAC 2 /* headphone left plugged in */ 155a8c2a6bfSRisto Suominen #define MASK_LOCONN_IMAC 1 /* line-out plugged in */ 1561da177e4SLinus Torvalds 1571da177e4SLinus Torvalds /* Clipping Count Reg Bit Masks */ 1581da177e4SLinus Torvalds /* -------- ----- --- --- ----- */ 1591da177e4SLinus Torvalds #define MASK_CLIPLEFT (0xff << 7) /* Clipping Count, Left Channel */ 1601da177e4SLinus Torvalds #define MASK_CLIPRIGHT (0xff) /* Clipping Count, Right Channel */ 1611da177e4SLinus Torvalds 1621da177e4SLinus Torvalds /* DBDMA ChannelStatus Bit Masks */ 1631da177e4SLinus Torvalds /* ----- ------------- --- ----- */ 1641da177e4SLinus Torvalds #define MASK_CSERR (0x1 << 7) /* Error */ 1657ae44cfaSRisto Suominen #define MASK_EOI (0x1 << 6) /* End of Input -- 1667ae44cfaSRisto Suominen only for Input Channel */ 1671da177e4SLinus Torvalds #define MASK_CSUNUSED (0x1f << 1) /* bits 1-5 not used */ 1681da177e4SLinus Torvalds #define MASK_WAIT (0x1) /* Wait */ 1691da177e4SLinus Torvalds 1701da177e4SLinus Torvalds /* Various Rates */ 1711da177e4SLinus Torvalds /* ------- ----- */ 1721da177e4SLinus Torvalds #define RATE_48000 (0x0 << 8) /* 48 kHz */ 1731da177e4SLinus Torvalds #define RATE_44100 (0x0 << 8) /* 44.1 kHz */ 1741da177e4SLinus Torvalds #define RATE_32000 (0x1 << 8) /* 32 kHz */ 1751da177e4SLinus Torvalds #define RATE_29400 (0x1 << 8) /* 29.4 kHz */ 1761da177e4SLinus Torvalds #define RATE_24000 (0x2 << 8) /* 24 kHz */ 1771da177e4SLinus Torvalds #define RATE_22050 (0x2 << 8) /* 22.05 kHz */ 1781da177e4SLinus Torvalds #define RATE_19200 (0x3 << 8) /* 19.2 kHz */ 1791da177e4SLinus Torvalds #define RATE_17640 (0x3 << 8) /* 17.64 kHz */ 1801da177e4SLinus Torvalds #define RATE_16000 (0x4 << 8) /* 16 kHz */ 1811da177e4SLinus Torvalds #define RATE_14700 (0x4 << 8) /* 14.7 kHz */ 1821da177e4SLinus Torvalds #define RATE_12000 (0x5 << 8) /* 12 kHz */ 1831da177e4SLinus Torvalds #define RATE_11025 (0x5 << 8) /* 11.025 kHz */ 1841da177e4SLinus Torvalds #define RATE_9600 (0x6 << 8) /* 9.6 kHz */ 1851da177e4SLinus Torvalds #define RATE_8820 (0x6 << 8) /* 8.82 kHz */ 1861da177e4SLinus Torvalds #define RATE_8000 (0x7 << 8) /* 8 kHz */ 1871da177e4SLinus Torvalds #define RATE_7350 (0x7 << 8) /* 7.35 kHz */ 1881da177e4SLinus Torvalds 1891da177e4SLinus Torvalds #define RATE_LOW 1 /* HIGH = 48kHz, etc; LOW = 44.1kHz, etc. */ 1901da177e4SLinus Torvalds 1911da177e4SLinus Torvalds 1921da177e4SLinus Torvalds #endif /* __AWACS_H */ 193