18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * kirkwood.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * (c) 2010 Arnaud Patard <apatard@mandriva.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _KIRKWOOD_AUDIO_H
98c2ecf20Sopenharmony_ci#define _KIRKWOOD_AUDIO_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define DRV_NAME	"mvebu-audio"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define KIRKWOOD_RECORD_WIN			0
148c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYBACK_WIN			1
158c2ecf20Sopenharmony_ci#define KIRKWOOD_MAX_AUDIO_WIN			2
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define KIRKWOOD_AUDIO_WIN_BASE_REG(win)	(0xA00 + ((win)<<3))
188c2ecf20Sopenharmony_ci#define KIRKWOOD_AUDIO_WIN_CTRL_REG(win)	(0xA04 + ((win)<<3))
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL			0x1000
228c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SPDIF_EN		(1<<11)
238c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_I2S_EN			(1<<10)
248c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_PAUSE			(1<<9)
258c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_MUTE			(1<<8)
268c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_BURST_MASK		(3<<5)
278c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_BURST_128		(2<<5)
288c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_BURST_32		(1<<5)
298c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_MONO			(1<<4)
308c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_MONO_CHAN_RIGHT	(1<<3)
318c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_MONO_CHAN_LEFT		(0<<3)
328c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_MASK		(7<<0)
338c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_16		(7<<0)
348c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_16_C		(3<<0)
358c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_20		(2<<0)
368c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_24		(1<<0)
378c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_SIZE_32		(0<<0)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define KIRKWOOD_RECCTL_ENABLE_MASK		(KIRKWOOD_RECCTL_SPDIF_EN | \
408c2ecf20Sopenharmony_ci						 KIRKWOOD_RECCTL_I2S_EN)
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define KIRKWOOD_REC_BUF_ADDR			0x1004
438c2ecf20Sopenharmony_ci#define KIRKWOOD_REC_BUF_SIZE			0x1008
448c2ecf20Sopenharmony_ci#define KIRKWOOD_REC_BYTE_COUNT			0x100C
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL			0x1100
478c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_PLAY_BUSY		(1<<16)
488c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_BURST_MASK		(3<<11)
498c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_BURST_128		(2<<11)
508c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_BURST_32		(1<<11)
518c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_PAUSE			(1<<9)
528c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SPDIF_MUTE		(1<<8)
538c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_MONO_MASK		(3<<5)
548c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_MONO_BOTH		(3<<5)
558c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_MONO_OFF		(0<<5)
568c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_I2S_MUTE		(1<<7)
578c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SPDIF_EN		(1<<4)
588c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_I2S_EN			(1<<3)
598c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_MASK		(7<<0)
608c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_16		(7<<0)
618c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_16_C		(3<<0)
628c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_20		(2<<0)
638c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_24		(1<<0)
648c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_SIZE_32		(0<<0)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAYCTL_ENABLE_MASK		(KIRKWOOD_PLAYCTL_SPDIF_EN | \
678c2ecf20Sopenharmony_ci						 KIRKWOOD_PLAYCTL_I2S_EN)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAY_BUF_ADDR			0x1104
708c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAY_BUF_SIZE			0x1108
718c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAY_BYTE_COUNT		0x110C
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL			0x1204
748c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL_OFFSET_MASK		(0xFFF<<2)
758c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL_OFFSET_0		(0x800<<2)
768c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_MASK		(3<<0)
778c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_11		(0<<0)
788c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_12		(1<<0)
798c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_CTL_FREQ_24		(2<<0)
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_SPCR_STATUS		0x120c
828c2ecf20Sopenharmony_ci#define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK	(1<<16)
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define KIRKWOOD_CLOCKS_CTRL			0x1230
858c2ecf20Sopenharmony_ci#define KIRKWOOD_MCLK_SOURCE_MASK		(3<<0)
868c2ecf20Sopenharmony_ci#define KIRKWOOD_MCLK_SOURCE_DCO		(0<<0)
878c2ecf20Sopenharmony_ci#define KIRKWOOD_MCLK_SOURCE_EXTCLK		(3<<0)
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define KIRKWOOD_ERR_CAUSE			0x1300
908c2ecf20Sopenharmony_ci#define KIRKWOOD_ERR_MASK			0x1304
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE			0x1308
938c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_MASK			0x130C
948c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_PLAY_BYTES		(1<<14)
958c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_REC_BYTES		(1<<13)
968c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_END	(1<<7)
978c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_3Q		(1<<6)
988c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_HALF	(1<<5)
998c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_PLAY_1Q		(1<<4)
1008c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_END		(1<<3)
1018c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_3Q		(1<<2)
1028c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_HALF	(1<<1)
1038c2ecf20Sopenharmony_ci#define KIRKWOOD_INT_CAUSE_DMA_REC_1Q		(1<<0)
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci#define KIRKWOOD_REC_BYTE_INT_COUNT		0x1310
1068c2ecf20Sopenharmony_ci#define KIRKWOOD_PLAY_BYTE_INT_COUNT		0x1314
1078c2ecf20Sopenharmony_ci#define KIRKWOOD_BYTE_INT_COUNT_MASK		0xffffff
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_PLAYCTL			0x2508
1108c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_RECCTL			0x2408
1118c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_JUST_MASK		(0xf<<26)
1128c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_LJ			(0<<26)
1138c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_I2S			(5<<26)
1148c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_RJ			(8<<26)
1158c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_MASK		(3<<30)
1168c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_16		(3<<30)
1178c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_20		(2<<30)
1188c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_24		(1<<30)
1198c2ecf20Sopenharmony_ci#define KIRKWOOD_I2S_CTL_SIZE_32		(0<<30)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define KIRKWOOD_AUDIO_BUF_MAX			(16*1024*1024)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/* Theses values come from the marvell alsa driver */
1248c2ecf20Sopenharmony_ci/* need to find where they come from               */
1258c2ecf20Sopenharmony_ci#define KIRKWOOD_SND_MIN_PERIODS		2
1268c2ecf20Sopenharmony_ci#define KIRKWOOD_SND_MAX_PERIODS		16
1278c2ecf20Sopenharmony_ci#define KIRKWOOD_SND_MIN_PERIOD_BYTES		256
1288c2ecf20Sopenharmony_ci#define KIRKWOOD_SND_MAX_PERIOD_BYTES		0x8000
1298c2ecf20Sopenharmony_ci#define KIRKWOOD_SND_MAX_BUFFER_BYTES		(KIRKWOOD_SND_MAX_PERIOD_BYTES \
1308c2ecf20Sopenharmony_ci						 * KIRKWOOD_SND_MAX_PERIODS)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistruct kirkwood_dma_data {
1338c2ecf20Sopenharmony_ci	void __iomem *io;
1348c2ecf20Sopenharmony_ci	struct clk *clk;
1358c2ecf20Sopenharmony_ci	struct clk *extclk;
1368c2ecf20Sopenharmony_ci	uint32_t ctl_play;
1378c2ecf20Sopenharmony_ci	uint32_t ctl_rec;
1388c2ecf20Sopenharmony_ci	struct snd_pcm_substream *substream_play;
1398c2ecf20Sopenharmony_ci	struct snd_pcm_substream *substream_rec;
1408c2ecf20Sopenharmony_ci	int irq;
1418c2ecf20Sopenharmony_ci	int burst;
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ciextern const struct snd_soc_component_driver kirkwood_soc_component;
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#endif
147