18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci#ifndef __HAL2_H 38c2ecf20Sopenharmony_ci#define __HAL2_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Driver for HAL2 sound processors 78c2ecf20Sopenharmony_ci * Copyright (c) 1999 Ulf Carlsson <ulfc@bun.falkenberg.se> 88c2ecf20Sopenharmony_ci * Copyright (c) 2001, 2002, 2003 Ladislav Michl <ladis@linux-mips.org> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* Indirect status register */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define H2_ISR_TSTATUS 0x01 /* RO: transaction status 1=busy */ 168c2ecf20Sopenharmony_ci#define H2_ISR_USTATUS 0x02 /* RO: utime status bit 1=armed */ 178c2ecf20Sopenharmony_ci#define H2_ISR_QUAD_MODE 0x04 /* codec mode 0=indigo 1=quad */ 188c2ecf20Sopenharmony_ci#define H2_ISR_GLOBAL_RESET_N 0x08 /* chip global reset 0=reset */ 198c2ecf20Sopenharmony_ci#define H2_ISR_CODEC_RESET_N 0x10 /* codec/synth reset 0=reset */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* Revision register */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define H2_REV_AUDIO_PRESENT 0x8000 /* RO: audio present 0=present */ 248c2ecf20Sopenharmony_ci#define H2_REV_BOARD_M 0x7000 /* RO: bits 14:12, board revision */ 258c2ecf20Sopenharmony_ci#define H2_REV_MAJOR_CHIP_M 0x00F0 /* RO: bits 7:4, major chip revision */ 268c2ecf20Sopenharmony_ci#define H2_REV_MINOR_CHIP_M 0x000F /* RO: bits 3:0, minor chip revision */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Indirect address register */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* 318c2ecf20Sopenharmony_ci * Address of indirect internal register to be accessed. A write to this 328c2ecf20Sopenharmony_ci * register initiates read or write access to the indirect registers in the 338c2ecf20Sopenharmony_ci * HAL2. Note that there af four indirect data registers for write access to 348c2ecf20Sopenharmony_ci * registers larger than 16 byte. 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define H2_IAR_TYPE_M 0xF000 /* bits 15:12, type of functional */ 388c2ecf20Sopenharmony_ci /* block the register resides in */ 398c2ecf20Sopenharmony_ci /* 1=DMA Port */ 408c2ecf20Sopenharmony_ci /* 9=Global DMA Control */ 418c2ecf20Sopenharmony_ci /* 2=Bresenham */ 428c2ecf20Sopenharmony_ci /* 3=Unix Timer */ 438c2ecf20Sopenharmony_ci#define H2_IAR_NUM_M 0x0F00 /* bits 11:8 instance of the */ 448c2ecf20Sopenharmony_ci /* blockin which the indirect */ 458c2ecf20Sopenharmony_ci /* register resides */ 468c2ecf20Sopenharmony_ci /* If IAR_TYPE_M=DMA Port: */ 478c2ecf20Sopenharmony_ci /* 1=Synth In */ 488c2ecf20Sopenharmony_ci /* 2=AES In */ 498c2ecf20Sopenharmony_ci /* 3=AES Out */ 508c2ecf20Sopenharmony_ci /* 4=DAC Out */ 518c2ecf20Sopenharmony_ci /* 5=ADC Out */ 528c2ecf20Sopenharmony_ci /* 6=Synth Control */ 538c2ecf20Sopenharmony_ci /* If IAR_TYPE_M=Global DMA Control: */ 548c2ecf20Sopenharmony_ci /* 1=Control */ 558c2ecf20Sopenharmony_ci /* If IAR_TYPE_M=Bresenham: */ 568c2ecf20Sopenharmony_ci /* 1=Bresenham Clock Gen 1 */ 578c2ecf20Sopenharmony_ci /* 2=Bresenham Clock Gen 2 */ 588c2ecf20Sopenharmony_ci /* 3=Bresenham Clock Gen 3 */ 598c2ecf20Sopenharmony_ci /* If IAR_TYPE_M=Unix Timer: */ 608c2ecf20Sopenharmony_ci /* 1=Unix Timer */ 618c2ecf20Sopenharmony_ci#define H2_IAR_ACCESS_SELECT 0x0080 /* 1=read 0=write */ 628c2ecf20Sopenharmony_ci#define H2_IAR_PARAM 0x000C /* Parameter Select */ 638c2ecf20Sopenharmony_ci#define H2_IAR_RB_INDEX_M 0x0003 /* Read Back Index */ 648c2ecf20Sopenharmony_ci /* 00:word0 */ 658c2ecf20Sopenharmony_ci /* 01:word1 */ 668c2ecf20Sopenharmony_ci /* 10:word2 */ 678c2ecf20Sopenharmony_ci /* 11:word3 */ 688c2ecf20Sopenharmony_ci/* 698c2ecf20Sopenharmony_ci * HAL2 internal addressing 708c2ecf20Sopenharmony_ci * 718c2ecf20Sopenharmony_ci * The HAL2 has "indirect registers" (idr) which are accessed by writing to the 728c2ecf20Sopenharmony_ci * Indirect Data registers. Write the address to the Indirect Address register 738c2ecf20Sopenharmony_ci * to transfer the data. 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * We define the H2IR_* to the read address and H2IW_* to the write address and 768c2ecf20Sopenharmony_ci * H2I_* to be fields in whatever register is referred to. 778c2ecf20Sopenharmony_ci * 788c2ecf20Sopenharmony_ci * When we write to indirect registers which are larger than one word (16 bit) 798c2ecf20Sopenharmony_ci * we have to fill more than one indirect register before writing. When we read 808c2ecf20Sopenharmony_ci * back however we have to read several times, each time with different Read 818c2ecf20Sopenharmony_ci * Back Indexes (there are defs for doing this easily). 828c2ecf20Sopenharmony_ci */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* 858c2ecf20Sopenharmony_ci * Relay Control 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_ci#define H2I_RELAY_C 0x9100 888c2ecf20Sopenharmony_ci#define H2I_RELAY_C_STATE 0x01 /* state of RELAY pin signal */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* DMA port enable */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define H2I_DMA_PORT_EN 0x9104 938c2ecf20Sopenharmony_ci#define H2I_DMA_PORT_EN_SY_IN 0x01 /* Synth_in DMA port */ 948c2ecf20Sopenharmony_ci#define H2I_DMA_PORT_EN_AESRX 0x02 /* AES receiver DMA port */ 958c2ecf20Sopenharmony_ci#define H2I_DMA_PORT_EN_AESTX 0x04 /* AES transmitter DMA port */ 968c2ecf20Sopenharmony_ci#define H2I_DMA_PORT_EN_CODECTX 0x08 /* CODEC transmit DMA port */ 978c2ecf20Sopenharmony_ci#define H2I_DMA_PORT_EN_CODECR 0x10 /* CODEC receive DMA port */ 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define H2I_DMA_END 0x9108 /* global dma endian select */ 1008c2ecf20Sopenharmony_ci#define H2I_DMA_END_SY_IN 0x01 /* Synth_in DMA port */ 1018c2ecf20Sopenharmony_ci#define H2I_DMA_END_AESRX 0x02 /* AES receiver DMA port */ 1028c2ecf20Sopenharmony_ci#define H2I_DMA_END_AESTX 0x04 /* AES transmitter DMA port */ 1038c2ecf20Sopenharmony_ci#define H2I_DMA_END_CODECTX 0x08 /* CODEC transmit DMA port */ 1048c2ecf20Sopenharmony_ci#define H2I_DMA_END_CODECR 0x10 /* CODEC receive DMA port */ 1058c2ecf20Sopenharmony_ci /* 0=b_end 1=l_end */ 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define H2I_DMA_DRV 0x910C /* global PBUS DMA enable */ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define H2I_SYNTH_C 0x1104 /* Synth DMA control */ 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define H2I_AESRX_C 0x1204 /* AES RX dma control */ 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define H2I_C_TS_EN 0x20 /* Timestamp enable */ 1148c2ecf20Sopenharmony_ci#define H2I_C_TS_FRMT 0x40 /* Timestamp format */ 1158c2ecf20Sopenharmony_ci#define H2I_C_NAUDIO 0x80 /* Sign extend */ 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* AESRX CTL, 16 bit */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define H2I_AESTX_C 0x1304 /* AES TX DMA control */ 1208c2ecf20Sopenharmony_ci#define H2I_AESTX_C_CLKID_SHIFT 3 /* Bresenham Clock Gen 1-3 */ 1218c2ecf20Sopenharmony_ci#define H2I_AESTX_C_CLKID_M 0x18 1228c2ecf20Sopenharmony_ci#define H2I_AESTX_C_DATAT_SHIFT 8 /* 1=mono 2=stereo (3=quad) */ 1238c2ecf20Sopenharmony_ci#define H2I_AESTX_C_DATAT_M 0x300 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* CODEC registers */ 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define H2I_DAC_C1 0x1404 /* DAC DMA control, 16 bit */ 1288c2ecf20Sopenharmony_ci#define H2I_DAC_C2 0x1408 /* DAC DMA control, 32 bit */ 1298c2ecf20Sopenharmony_ci#define H2I_ADC_C1 0x1504 /* ADC DMA control, 16 bit */ 1308c2ecf20Sopenharmony_ci#define H2I_ADC_C2 0x1508 /* ADC DMA control, 32 bit */ 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* Bits in CTL1 register */ 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define H2I_C1_DMA_SHIFT 0 /* DMA channel */ 1358c2ecf20Sopenharmony_ci#define H2I_C1_DMA_M 0x7 1368c2ecf20Sopenharmony_ci#define H2I_C1_CLKID_SHIFT 3 /* Bresenham Clock Gen 1-3 */ 1378c2ecf20Sopenharmony_ci#define H2I_C1_CLKID_M 0x18 1388c2ecf20Sopenharmony_ci#define H2I_C1_DATAT_SHIFT 8 /* 1=mono 2=stereo (3=quad) */ 1398c2ecf20Sopenharmony_ci#define H2I_C1_DATAT_M 0x300 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* Bits in CTL2 register */ 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define H2I_C2_R_GAIN_SHIFT 0 /* right a/d input gain */ 1448c2ecf20Sopenharmony_ci#define H2I_C2_R_GAIN_M 0xf 1458c2ecf20Sopenharmony_ci#define H2I_C2_L_GAIN_SHIFT 4 /* left a/d input gain */ 1468c2ecf20Sopenharmony_ci#define H2I_C2_L_GAIN_M 0xf0 1478c2ecf20Sopenharmony_ci#define H2I_C2_R_SEL 0x100 /* right input select */ 1488c2ecf20Sopenharmony_ci#define H2I_C2_L_SEL 0x200 /* left input select */ 1498c2ecf20Sopenharmony_ci#define H2I_C2_MUTE 0x400 /* mute */ 1508c2ecf20Sopenharmony_ci#define H2I_C2_DO1 0x00010000 /* digital output port bit 0 */ 1518c2ecf20Sopenharmony_ci#define H2I_C2_DO2 0x00020000 /* digital output port bit 1 */ 1528c2ecf20Sopenharmony_ci#define H2I_C2_R_ATT_SHIFT 18 /* right d/a output - */ 1538c2ecf20Sopenharmony_ci#define H2I_C2_R_ATT_M 0x007c0000 /* attenuation */ 1548c2ecf20Sopenharmony_ci#define H2I_C2_L_ATT_SHIFT 23 /* left d/a output - */ 1558c2ecf20Sopenharmony_ci#define H2I_C2_L_ATT_M 0x0f800000 /* attenuation */ 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#define H2I_SYNTH_MAP_C 0x1104 /* synth dma handshake ctrl */ 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* Clock generator CTL 1, 16 bit */ 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci#define H2I_BRES1_C1 0x2104 1628c2ecf20Sopenharmony_ci#define H2I_BRES2_C1 0x2204 1638c2ecf20Sopenharmony_ci#define H2I_BRES3_C1 0x2304 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci#define H2I_BRES_C1_SHIFT 0 /* 0=48.0 1=44.1 2=aes_rx */ 1668c2ecf20Sopenharmony_ci#define H2I_BRES_C1_M 0x03 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci/* Clock generator CTL 2, 32 bit */ 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define H2I_BRES1_C2 0x2108 1718c2ecf20Sopenharmony_ci#define H2I_BRES2_C2 0x2208 1728c2ecf20Sopenharmony_ci#define H2I_BRES3_C2 0x2308 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci#define H2I_BRES_C2_INC_SHIFT 0 /* increment value */ 1758c2ecf20Sopenharmony_ci#define H2I_BRES_C2_INC_M 0xffff 1768c2ecf20Sopenharmony_ci#define H2I_BRES_C2_MOD_SHIFT 16 /* modcontrol value */ 1778c2ecf20Sopenharmony_ci#define H2I_BRES_C2_MOD_M 0xffff0000 /* modctrl=0xffff&(modinc-1) */ 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* Unix timer, 64 bit */ 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci#define H2I_UTIME 0x3104 1828c2ecf20Sopenharmony_ci#define H2I_UTIME_0_LD 0xffff /* microseconds, LSB's */ 1838c2ecf20Sopenharmony_ci#define H2I_UTIME_1_LD0 0x0f /* microseconds, MSB's */ 1848c2ecf20Sopenharmony_ci#define H2I_UTIME_1_LD1 0xf0 /* tenths of microseconds */ 1858c2ecf20Sopenharmony_ci#define H2I_UTIME_2_LD 0xffff /* seconds, LSB's */ 1868c2ecf20Sopenharmony_ci#define H2I_UTIME_3_LD 0xffff /* seconds, MSB's */ 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_cistruct hal2_ctl_regs { 1898c2ecf20Sopenharmony_ci u32 _unused0[4]; 1908c2ecf20Sopenharmony_ci u32 isr; /* 0x10 Status Register */ 1918c2ecf20Sopenharmony_ci u32 _unused1[3]; 1928c2ecf20Sopenharmony_ci u32 rev; /* 0x20 Revision Register */ 1938c2ecf20Sopenharmony_ci u32 _unused2[3]; 1948c2ecf20Sopenharmony_ci u32 iar; /* 0x30 Indirect Address Register */ 1958c2ecf20Sopenharmony_ci u32 _unused3[3]; 1968c2ecf20Sopenharmony_ci u32 idr0; /* 0x40 Indirect Data Register 0 */ 1978c2ecf20Sopenharmony_ci u32 _unused4[3]; 1988c2ecf20Sopenharmony_ci u32 idr1; /* 0x50 Indirect Data Register 1 */ 1998c2ecf20Sopenharmony_ci u32 _unused5[3]; 2008c2ecf20Sopenharmony_ci u32 idr2; /* 0x60 Indirect Data Register 2 */ 2018c2ecf20Sopenharmony_ci u32 _unused6[3]; 2028c2ecf20Sopenharmony_ci u32 idr3; /* 0x70 Indirect Data Register 3 */ 2038c2ecf20Sopenharmony_ci}; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_cistruct hal2_aes_regs { 2068c2ecf20Sopenharmony_ci u32 rx_stat[2]; /* Status registers */ 2078c2ecf20Sopenharmony_ci u32 rx_cr[2]; /* Control registers */ 2088c2ecf20Sopenharmony_ci u32 rx_ud[4]; /* User data window */ 2098c2ecf20Sopenharmony_ci u32 rx_st[24]; /* Channel status data */ 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci u32 tx_stat[1]; /* Status register */ 2128c2ecf20Sopenharmony_ci u32 tx_cr[3]; /* Control registers */ 2138c2ecf20Sopenharmony_ci u32 tx_ud[4]; /* User data window */ 2148c2ecf20Sopenharmony_ci u32 tx_st[24]; /* Channel status data */ 2158c2ecf20Sopenharmony_ci}; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_cistruct hal2_vol_regs { 2188c2ecf20Sopenharmony_ci u32 right; /* Right volume */ 2198c2ecf20Sopenharmony_ci u32 left; /* Left volume */ 2208c2ecf20Sopenharmony_ci}; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_cistruct hal2_syn_regs { 2238c2ecf20Sopenharmony_ci u32 _unused0[2]; 2248c2ecf20Sopenharmony_ci u32 page; /* DOC Page register */ 2258c2ecf20Sopenharmony_ci u32 regsel; /* DOC Register selection */ 2268c2ecf20Sopenharmony_ci u32 dlow; /* DOC Data low */ 2278c2ecf20Sopenharmony_ci u32 dhigh; /* DOC Data high */ 2288c2ecf20Sopenharmony_ci u32 irq; /* IRQ Status */ 2298c2ecf20Sopenharmony_ci u32 dram; /* DRAM Access */ 2308c2ecf20Sopenharmony_ci}; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci#endif /* __HAL2_H */ 233