162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * kirkwood.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * (c) 2010 Arnaud Patard <apatard@mandriva.com> 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _KIRKWOOD_AUDIO_H 962306a36Sopenharmony_ci#define _KIRKWOOD_AUDIO_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define DRV_NAME "mvebu-audio" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define KIRKWOOD_RECORD_WIN 0 1462306a36Sopenharmony_ci#define KIRKWOOD_PLAYBACK_WIN 1 1562306a36Sopenharmony_ci#define KIRKWOOD_MAX_AUDIO_WIN 2 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#define KIRKWOOD_AUDIO_WIN_BASE_REG(win) (0xA00 + ((win)<<3)) 1862306a36Sopenharmony_ci#define KIRKWOOD_AUDIO_WIN_CTRL_REG(win) (0xA04 + ((win)<<3)) 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define KIRKWOOD_RECCTL 0x1000 2262306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SPDIF_EN (1<<11) 2362306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_I2S_EN (1<<10) 2462306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_PAUSE (1<<9) 2562306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_MUTE (1<<8) 2662306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_BURST_MASK (3<<5) 2762306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_BURST_128 (2<<5) 2862306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_BURST_32 (1<<5) 2962306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_MONO (1<<4) 3062306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_MONO_CHAN_RIGHT (1<<3) 3162306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_MONO_CHAN_LEFT (0<<3) 3262306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_MASK (7<<0) 3362306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_16 (7<<0) 3462306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_16_C (3<<0) 3562306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_20 (2<<0) 3662306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_24 (1<<0) 3762306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_32 (0<<0) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define KIRKWOOD_RECCTL_ENABLE_MASK (KIRKWOOD_RECCTL_SPDIF_EN | \ 4062306a36Sopenharmony_ci KIRKWOOD_RECCTL_I2S_EN) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define KIRKWOOD_REC_BUF_ADDR 0x1004 4362306a36Sopenharmony_ci#define KIRKWOOD_REC_BUF_SIZE 0x1008 4462306a36Sopenharmony_ci#define KIRKWOOD_REC_BYTE_COUNT 0x100C 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL 0x1100 4762306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_PLAY_BUSY (1<<16) 4862306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_BURST_MASK (3<<11) 4962306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_BURST_128 (2<<11) 5062306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_BURST_32 (1<<11) 5162306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_PAUSE (1<<9) 5262306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SPDIF_MUTE (1<<8) 5362306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_MONO_MASK (3<<5) 5462306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_MONO_BOTH (3<<5) 5562306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_MONO_OFF (0<<5) 5662306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_I2S_MUTE (1<<7) 5762306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SPDIF_EN (1<<4) 5862306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_I2S_EN (1<<3) 5962306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_MASK (7<<0) 6062306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_16 (7<<0) 6162306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_16_C (3<<0) 6262306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_20 (2<<0) 6362306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_24 (1<<0) 6462306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_32 (0<<0) 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define KIRKWOOD_PLAYCTL_ENABLE_MASK (KIRKWOOD_PLAYCTL_SPDIF_EN | \ 6762306a36Sopenharmony_ci KIRKWOOD_PLAYCTL_I2S_EN) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define KIRKWOOD_PLAY_BUF_ADDR 0x1104 7062306a36Sopenharmony_ci#define KIRKWOOD_PLAY_BUF_SIZE 0x1108 7162306a36Sopenharmony_ci#define KIRKWOOD_PLAY_BYTE_COUNT 0x110C 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL 0x1204 7462306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL_OFFSET_MASK (0xFFF<<2) 7562306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL_OFFSET_0 (0x800<<2) 7662306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_MASK (3<<0) 7762306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_11 (0<<0) 7862306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_12 (1<<0) 7962306a36Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_24 (2<<0) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define KIRKWOOD_DCO_SPCR_STATUS 0x120c 8262306a36Sopenharmony_ci#define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK (1<<16) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define KIRKWOOD_CLOCKS_CTRL 0x1230 8562306a36Sopenharmony_ci#define KIRKWOOD_MCLK_SOURCE_MASK (3<<0) 8662306a36Sopenharmony_ci#define KIRKWOOD_MCLK_SOURCE_DCO (0<<0) 8762306a36Sopenharmony_ci#define KIRKWOOD_MCLK_SOURCE_EXTCLK (3<<0) 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#define KIRKWOOD_ERR_CAUSE 0x1300 9062306a36Sopenharmony_ci#define KIRKWOOD_ERR_MASK 0x1304 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE 0x1308 9362306a36Sopenharmony_ci#define KIRKWOOD_INT_MASK 0x130C 9462306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_PLAY_BYTES (1<<14) 9562306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_REC_BYTES (1<<13) 9662306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_END (1<<7) 9762306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_3Q (1<<6) 9862306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_HALF (1<<5) 9962306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_1Q (1<<4) 10062306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_END (1<<3) 10162306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_3Q (1<<2) 10262306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_HALF (1<<1) 10362306a36Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_1Q (1<<0) 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define KIRKWOOD_REC_BYTE_INT_COUNT 0x1310 10662306a36Sopenharmony_ci#define KIRKWOOD_PLAY_BYTE_INT_COUNT 0x1314 10762306a36Sopenharmony_ci#define KIRKWOOD_BYTE_INT_COUNT_MASK 0xffffff 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define KIRKWOOD_I2S_PLAYCTL 0x2508 11062306a36Sopenharmony_ci#define KIRKWOOD_I2S_RECCTL 0x2408 11162306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_JUST_MASK (0xf<<26) 11262306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_LJ (0<<26) 11362306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_I2S (5<<26) 11462306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_RJ (8<<26) 11562306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_MASK (3<<30) 11662306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_16 (3<<30) 11762306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_20 (2<<30) 11862306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_24 (1<<30) 11962306a36Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_32 (0<<30) 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci#define KIRKWOOD_AUDIO_BUF_MAX (16*1024*1024) 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci/* Theses values come from the marvell alsa driver */ 12462306a36Sopenharmony_ci/* need to find where they come from */ 12562306a36Sopenharmony_ci#define KIRKWOOD_SND_MIN_PERIODS 2 12662306a36Sopenharmony_ci#define KIRKWOOD_SND_MAX_PERIODS 16 12762306a36Sopenharmony_ci#define KIRKWOOD_SND_MIN_PERIOD_BYTES 256 12862306a36Sopenharmony_ci#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x8000 12962306a36Sopenharmony_ci#define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \ 13062306a36Sopenharmony_ci * KIRKWOOD_SND_MAX_PERIODS) 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_cistruct kirkwood_dma_data { 13362306a36Sopenharmony_ci void __iomem *io; 13462306a36Sopenharmony_ci void __iomem *pll_config; 13562306a36Sopenharmony_ci void __iomem *soc_control; 13662306a36Sopenharmony_ci struct clk *clk; 13762306a36Sopenharmony_ci struct clk *extclk; 13862306a36Sopenharmony_ci uint32_t ctl_play; 13962306a36Sopenharmony_ci uint32_t ctl_rec; 14062306a36Sopenharmony_ci struct snd_pcm_substream *substream_play; 14162306a36Sopenharmony_ci struct snd_pcm_substream *substream_rec; 14262306a36Sopenharmony_ci int irq; 14362306a36Sopenharmony_ci int burst; 14462306a36Sopenharmony_ci}; 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ciextern const struct snd_soc_component_driver kirkwood_soc_component; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#endif 149