162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci#ifndef __HAL2_H
362306a36Sopenharmony_ci#define __HAL2_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci *  Driver for HAL2 sound processors
762306a36Sopenharmony_ci *  Copyright (c) 1999 Ulf Carlsson <ulfc@bun.falkenberg.se>
862306a36Sopenharmony_ci *  Copyright (c) 2001, 2002, 2003 Ladislav Michl <ladis@linux-mips.org>
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/types.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* Indirect status register */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define H2_ISR_TSTATUS		0x01	/* RO: transaction status 1=busy */
1662306a36Sopenharmony_ci#define H2_ISR_USTATUS		0x02	/* RO: utime status bit 1=armed */
1762306a36Sopenharmony_ci#define H2_ISR_QUAD_MODE	0x04	/* codec mode 0=indigo 1=quad */
1862306a36Sopenharmony_ci#define H2_ISR_GLOBAL_RESET_N	0x08	/* chip global reset 0=reset */
1962306a36Sopenharmony_ci#define H2_ISR_CODEC_RESET_N	0x10	/* codec/synth reset 0=reset  */
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/* Revision register */
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define H2_REV_AUDIO_PRESENT	0x8000	/* RO: audio present 0=present */
2462306a36Sopenharmony_ci#define H2_REV_BOARD_M		0x7000	/* RO: bits 14:12, board revision */
2562306a36Sopenharmony_ci#define H2_REV_MAJOR_CHIP_M	0x00F0	/* RO: bits 7:4, major chip revision */
2662306a36Sopenharmony_ci#define H2_REV_MINOR_CHIP_M	0x000F	/* RO: bits 3:0, minor chip revision */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/* Indirect address register */
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/*
3162306a36Sopenharmony_ci * Address of indirect internal register to be accessed. A write to this
3262306a36Sopenharmony_ci * register initiates read or write access to the indirect registers in the
3362306a36Sopenharmony_ci * HAL2. Note that there af four indirect data registers for write access to
3462306a36Sopenharmony_ci * registers larger than 16 byte.
3562306a36Sopenharmony_ci */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define H2_IAR_TYPE_M		0xF000	/* bits 15:12, type of functional */
3862306a36Sopenharmony_ci					/* block the register resides in */
3962306a36Sopenharmony_ci					/* 1=DMA Port */
4062306a36Sopenharmony_ci					/* 9=Global DMA Control */
4162306a36Sopenharmony_ci					/* 2=Bresenham */
4262306a36Sopenharmony_ci					/* 3=Unix Timer */
4362306a36Sopenharmony_ci#define H2_IAR_NUM_M		0x0F00	/* bits 11:8 instance of the */
4462306a36Sopenharmony_ci					/* blockin which the indirect */
4562306a36Sopenharmony_ci					/* register resides */
4662306a36Sopenharmony_ci					/* If IAR_TYPE_M=DMA Port: */
4762306a36Sopenharmony_ci					/* 1=Synth In */
4862306a36Sopenharmony_ci					/* 2=AES In */
4962306a36Sopenharmony_ci					/* 3=AES Out */
5062306a36Sopenharmony_ci					/* 4=DAC Out */
5162306a36Sopenharmony_ci					/* 5=ADC Out */
5262306a36Sopenharmony_ci					/* 6=Synth Control */
5362306a36Sopenharmony_ci					/* If IAR_TYPE_M=Global DMA Control: */
5462306a36Sopenharmony_ci					/* 1=Control */
5562306a36Sopenharmony_ci					/* If IAR_TYPE_M=Bresenham: */
5662306a36Sopenharmony_ci					/* 1=Bresenham Clock Gen 1 */
5762306a36Sopenharmony_ci					/* 2=Bresenham Clock Gen 2 */
5862306a36Sopenharmony_ci					/* 3=Bresenham Clock Gen 3 */
5962306a36Sopenharmony_ci					/* If IAR_TYPE_M=Unix Timer: */
6062306a36Sopenharmony_ci					/* 1=Unix Timer */
6162306a36Sopenharmony_ci#define H2_IAR_ACCESS_SELECT	0x0080	/* 1=read 0=write */
6262306a36Sopenharmony_ci#define H2_IAR_PARAM		0x000C	/* Parameter Select */
6362306a36Sopenharmony_ci#define H2_IAR_RB_INDEX_M	0x0003	/* Read Back Index */
6462306a36Sopenharmony_ci					/* 00:word0 */
6562306a36Sopenharmony_ci					/* 01:word1 */
6662306a36Sopenharmony_ci					/* 10:word2 */
6762306a36Sopenharmony_ci					/* 11:word3 */
6862306a36Sopenharmony_ci/*
6962306a36Sopenharmony_ci * HAL2 internal addressing
7062306a36Sopenharmony_ci *
7162306a36Sopenharmony_ci * The HAL2 has "indirect registers" (idr) which are accessed by writing to the
7262306a36Sopenharmony_ci * Indirect Data registers. Write the address to the Indirect Address register
7362306a36Sopenharmony_ci * to transfer the data.
7462306a36Sopenharmony_ci *
7562306a36Sopenharmony_ci * We define the H2IR_* to the read address and H2IW_* to the write address and
7662306a36Sopenharmony_ci * H2I_* to be fields in whatever register is referred to.
7762306a36Sopenharmony_ci *
7862306a36Sopenharmony_ci * When we write to indirect registers which are larger than one word (16 bit)
7962306a36Sopenharmony_ci * we have to fill more than one indirect register before writing. When we read
8062306a36Sopenharmony_ci * back however we have to read several times, each time with different Read
8162306a36Sopenharmony_ci * Back Indexes (there are defs for doing this easily).
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/*
8562306a36Sopenharmony_ci * Relay Control
8662306a36Sopenharmony_ci */
8762306a36Sopenharmony_ci#define H2I_RELAY_C		0x9100
8862306a36Sopenharmony_ci#define H2I_RELAY_C_STATE	0x01		/* state of RELAY pin signal */
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci/* DMA port enable */
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#define H2I_DMA_PORT_EN		0x9104
9362306a36Sopenharmony_ci#define H2I_DMA_PORT_EN_SY_IN	0x01		/* Synth_in DMA port */
9462306a36Sopenharmony_ci#define H2I_DMA_PORT_EN_AESRX	0x02		/* AES receiver DMA port */
9562306a36Sopenharmony_ci#define H2I_DMA_PORT_EN_AESTX	0x04		/* AES transmitter DMA port */
9662306a36Sopenharmony_ci#define H2I_DMA_PORT_EN_CODECTX	0x08		/* CODEC transmit DMA port */
9762306a36Sopenharmony_ci#define H2I_DMA_PORT_EN_CODECR	0x10		/* CODEC receive DMA port */
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define H2I_DMA_END		0x9108 		/* global dma endian select */
10062306a36Sopenharmony_ci#define H2I_DMA_END_SY_IN	0x01		/* Synth_in DMA port */
10162306a36Sopenharmony_ci#define H2I_DMA_END_AESRX	0x02		/* AES receiver DMA port */
10262306a36Sopenharmony_ci#define H2I_DMA_END_AESTX	0x04		/* AES transmitter DMA port */
10362306a36Sopenharmony_ci#define H2I_DMA_END_CODECTX	0x08		/* CODEC transmit DMA port */
10462306a36Sopenharmony_ci#define H2I_DMA_END_CODECR	0x10		/* CODEC receive DMA port */
10562306a36Sopenharmony_ci						/* 0=b_end 1=l_end */
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci#define H2I_DMA_DRV		0x910C  	/* global PBUS DMA enable */
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#define H2I_SYNTH_C		0x1104		/* Synth DMA control */
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#define H2I_AESRX_C		0x1204	 	/* AES RX dma control */
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci#define H2I_C_TS_EN		0x20		/* Timestamp enable */
11462306a36Sopenharmony_ci#define H2I_C_TS_FRMT		0x40		/* Timestamp format */
11562306a36Sopenharmony_ci#define H2I_C_NAUDIO		0x80		/* Sign extend */
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci/* AESRX CTL, 16 bit */
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#define H2I_AESTX_C		0x1304		/* AES TX DMA control */
12062306a36Sopenharmony_ci#define H2I_AESTX_C_CLKID_SHIFT	3		/* Bresenham Clock Gen 1-3 */
12162306a36Sopenharmony_ci#define H2I_AESTX_C_CLKID_M	0x18
12262306a36Sopenharmony_ci#define H2I_AESTX_C_DATAT_SHIFT	8		/* 1=mono 2=stereo (3=quad) */
12362306a36Sopenharmony_ci#define H2I_AESTX_C_DATAT_M	0x300
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/* CODEC registers */
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#define H2I_DAC_C1		0x1404 		/* DAC DMA control, 16 bit */
12862306a36Sopenharmony_ci#define H2I_DAC_C2		0x1408		/* DAC DMA control, 32 bit */
12962306a36Sopenharmony_ci#define H2I_ADC_C1		0x1504 		/* ADC DMA control, 16 bit */
13062306a36Sopenharmony_ci#define H2I_ADC_C2		0x1508		/* ADC DMA control, 32 bit */
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci/* Bits in CTL1 register */
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define H2I_C1_DMA_SHIFT	0		/* DMA channel */
13562306a36Sopenharmony_ci#define H2I_C1_DMA_M		0x7
13662306a36Sopenharmony_ci#define H2I_C1_CLKID_SHIFT	3		/* Bresenham Clock Gen 1-3 */
13762306a36Sopenharmony_ci#define H2I_C1_CLKID_M		0x18
13862306a36Sopenharmony_ci#define H2I_C1_DATAT_SHIFT	8		/* 1=mono 2=stereo (3=quad) */
13962306a36Sopenharmony_ci#define H2I_C1_DATAT_M		0x300
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci/* Bits in CTL2 register */
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#define H2I_C2_R_GAIN_SHIFT	0		/* right a/d input gain */
14462306a36Sopenharmony_ci#define H2I_C2_R_GAIN_M		0xf
14562306a36Sopenharmony_ci#define H2I_C2_L_GAIN_SHIFT	4		/* left a/d input gain */
14662306a36Sopenharmony_ci#define H2I_C2_L_GAIN_M		0xf0
14762306a36Sopenharmony_ci#define H2I_C2_R_SEL		0x100		/* right input select */
14862306a36Sopenharmony_ci#define H2I_C2_L_SEL		0x200		/* left input select */
14962306a36Sopenharmony_ci#define H2I_C2_MUTE		0x400		/* mute */
15062306a36Sopenharmony_ci#define H2I_C2_DO1		0x00010000	/* digital output port bit 0 */
15162306a36Sopenharmony_ci#define H2I_C2_DO2		0x00020000	/* digital output port bit 1 */
15262306a36Sopenharmony_ci#define H2I_C2_R_ATT_SHIFT	18		/* right d/a output - */
15362306a36Sopenharmony_ci#define H2I_C2_R_ATT_M		0x007c0000	/* attenuation */
15462306a36Sopenharmony_ci#define H2I_C2_L_ATT_SHIFT	23		/* left d/a output - */
15562306a36Sopenharmony_ci#define H2I_C2_L_ATT_M		0x0f800000	/* attenuation */
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci#define H2I_SYNTH_MAP_C		0x1104		/* synth dma handshake ctrl */
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/* Clock generator CTL 1, 16 bit */
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci#define H2I_BRES1_C1		0x2104
16262306a36Sopenharmony_ci#define H2I_BRES2_C1		0x2204
16362306a36Sopenharmony_ci#define H2I_BRES3_C1		0x2304
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#define H2I_BRES_C1_SHIFT	0		/* 0=48.0 1=44.1 2=aes_rx */
16662306a36Sopenharmony_ci#define H2I_BRES_C1_M		0x03
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci/* Clock generator CTL 2, 32 bit */
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define H2I_BRES1_C2		0x2108
17162306a36Sopenharmony_ci#define H2I_BRES2_C2		0x2208
17262306a36Sopenharmony_ci#define H2I_BRES3_C2		0x2308
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#define H2I_BRES_C2_INC_SHIFT	0		/* increment value */
17562306a36Sopenharmony_ci#define H2I_BRES_C2_INC_M	0xffff
17662306a36Sopenharmony_ci#define H2I_BRES_C2_MOD_SHIFT	16		/* modcontrol value */
17762306a36Sopenharmony_ci#define H2I_BRES_C2_MOD_M	0xffff0000	/* modctrl=0xffff&(modinc-1) */
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci/* Unix timer, 64 bit */
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci#define H2I_UTIME		0x3104
18262306a36Sopenharmony_ci#define H2I_UTIME_0_LD		0xffff		/* microseconds, LSB's */
18362306a36Sopenharmony_ci#define H2I_UTIME_1_LD0		0x0f		/* microseconds, MSB's */
18462306a36Sopenharmony_ci#define H2I_UTIME_1_LD1		0xf0		/* tenths of microseconds */
18562306a36Sopenharmony_ci#define H2I_UTIME_2_LD		0xffff		/* seconds, LSB's */
18662306a36Sopenharmony_ci#define H2I_UTIME_3_LD		0xffff		/* seconds, MSB's */
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_cistruct hal2_ctl_regs {
18962306a36Sopenharmony_ci	u32 _unused0[4];
19062306a36Sopenharmony_ci	u32 isr;		/* 0x10 Status Register */
19162306a36Sopenharmony_ci	u32 _unused1[3];
19262306a36Sopenharmony_ci	u32 rev;		/* 0x20 Revision Register */
19362306a36Sopenharmony_ci	u32 _unused2[3];
19462306a36Sopenharmony_ci	u32 iar;		/* 0x30 Indirect Address Register */
19562306a36Sopenharmony_ci	u32 _unused3[3];
19662306a36Sopenharmony_ci	u32 idr0;		/* 0x40 Indirect Data Register 0 */
19762306a36Sopenharmony_ci	u32 _unused4[3];
19862306a36Sopenharmony_ci	u32 idr1;		/* 0x50 Indirect Data Register 1 */
19962306a36Sopenharmony_ci	u32 _unused5[3];
20062306a36Sopenharmony_ci	u32 idr2;		/* 0x60 Indirect Data Register 2 */
20162306a36Sopenharmony_ci	u32 _unused6[3];
20262306a36Sopenharmony_ci	u32 idr3;		/* 0x70 Indirect Data Register 3 */
20362306a36Sopenharmony_ci};
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_cistruct hal2_aes_regs {
20662306a36Sopenharmony_ci	u32 rx_stat[2];	/* Status registers */
20762306a36Sopenharmony_ci	u32 rx_cr[2];		/* Control registers */
20862306a36Sopenharmony_ci	u32 rx_ud[4];		/* User data window */
20962306a36Sopenharmony_ci	u32 rx_st[24];		/* Channel status data */
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci	u32 tx_stat[1];	/* Status register */
21262306a36Sopenharmony_ci	u32 tx_cr[3];		/* Control registers */
21362306a36Sopenharmony_ci	u32 tx_ud[4];		/* User data window */
21462306a36Sopenharmony_ci	u32 tx_st[24];		/* Channel status data */
21562306a36Sopenharmony_ci};
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_cistruct hal2_vol_regs {
21862306a36Sopenharmony_ci	u32 right;		/* Right volume */
21962306a36Sopenharmony_ci	u32 left;		/* Left volume */
22062306a36Sopenharmony_ci};
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_cistruct hal2_syn_regs {
22362306a36Sopenharmony_ci	u32 _unused0[2];
22462306a36Sopenharmony_ci	u32 page;		/* DOC Page register */
22562306a36Sopenharmony_ci	u32 regsel;		/* DOC Register selection */
22662306a36Sopenharmony_ci	u32 dlow;		/* DOC Data low */
22762306a36Sopenharmony_ci	u32 dhigh;		/* DOC Data high */
22862306a36Sopenharmony_ci	u32 irq;		/* IRQ Status */
22962306a36Sopenharmony_ci	u32 dram;		/* DRAM Access */
23062306a36Sopenharmony_ci};
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci#endif	/* __HAL2_H */
233