18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * tegra20_ac97.h - Definitions for the Tegra20 AC97 controller driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2012 Lucas Stach <dev@lynxeye.de>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Partly based on code copyright/by:
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (c) 2011,2012 Toradex Inc.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __TEGRA20_AC97_H__
138c2ecf20Sopenharmony_ci#define __TEGRA20_AC97_H__
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "tegra_pcm.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL				0x00
188c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD				0x04
198c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1				0x08
208c2ecf20Sopenharmony_ci/* ... */
218c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO1_SCR				0x1c
228c2ecf20Sopenharmony_ci/* ... */
238c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_TX1				0x40
248c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_RX1				0x80
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* TEGRA20_AC97_CTRL */
278c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_STM2_EN			(1 << 16)
288c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_DOUBLE_SAMPLING_EN		(1 << 11)
298c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_IO_CNTRL_EN			(1 << 10)
308c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_HSET_DAC_EN			(1 << 9)
318c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_LINE2_DAC_EN			(1 << 8)
328c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_PCM_LFE_EN			(1 << 7)
338c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_PCM_SUR_EN			(1 << 6)
348c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_PCM_CEN_DAC_EN		(1 << 5)
358c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_LINE1_DAC_EN			(1 << 4)
368c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_PCM_DAC_EN			(1 << 3)
378c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_COLD_RESET			(1 << 2)
388c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_WARM_RESET			(1 << 1)
398c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CTRL_STM_EN			(1 << 0)
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* TEGRA20_AC97_CMD */
428c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_CMD_ADDR_SHIFT			24
438c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_CMD_ADDR_MASK			(0xff << TEGRA20_AC97_CMD_CMD_ADDR_SHIFT)
448c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_CMD_DATA_SHIFT			8
458c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_CMD_DATA_MASK			(0xffff << TEGRA20_AC97_CMD_CMD_DATA_SHIFT)
468c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_CMD_ID_SHIFT			2
478c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_CMD_ID_MASK			(0x3 << TEGRA20_AC97_CMD_CMD_ID_SHIFT)
488c2ecf20Sopenharmony_ci#define TEGRA20_AC97_CMD_BUSY				(1 << 0)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* TEGRA20_AC97_STATUS1 */
518c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_STA_ADDR1_SHIFT		24
528c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_STA_ADDR1_MASK		(0xff << TEGRA20_AC97_STATUS1_STA_ADDR1_SHIFT)
538c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_STA_DATA1_SHIFT		8
548c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_STA_DATA1_MASK		(0xffff << TEGRA20_AC97_STATUS1_STA_DATA1_SHIFT)
558c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_STA_VALID1			(1 << 2)
568c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_STANDBY1			(1 << 1)
578c2ecf20Sopenharmony_ci#define TEGRA20_AC97_STATUS1_CODEC1_RDY			(1 << 0)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* TEGRA20_AC97_FIFO1_SCR */
608c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_MT_CNT_SHIFT		27
618c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_MT_CNT_MASK		(0x1f << TEGRA20_AC97_FIFO_SCR_REC_MT_CNT_SHIFT)
628c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_MT_CNT_SHIFT		22
638c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_MT_CNT_MASK		(0x1f << TEGRA20_AC97_FIFO_SCR_PB_MT_CNT_SHIFT)
648c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_OVERRUN_INT_STA	(1 << 19)
658c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_UNDERRUN_INT_STA	(1 << 18)
668c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_FORCE_MT		(1 << 17)
678c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_FORCE_MT		(1 << 16)
688c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_FULL_EN		(1 << 15)
698c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_3QRT_FULL_EN		(1 << 14)
708c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_QRT_FULL_EN		(1 << 13)
718c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_REC_EMPTY_EN		(1 << 12)
728c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_NOT_FULL_EN		(1 << 11)
738c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_QRT_MT_EN		(1 << 10)
748c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_3QRT_MT_EN		(1 << 9)
758c2ecf20Sopenharmony_ci#define TEGRA20_AC97_FIFO_SCR_PB_EMPTY_MT_EN		(1 << 8)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistruct tegra20_ac97 {
788c2ecf20Sopenharmony_ci	struct clk *clk_ac97;
798c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data capture_dma_data;
808c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data playback_dma_data;
818c2ecf20Sopenharmony_ci	struct regmap *regmap;
828c2ecf20Sopenharmony_ci	int reset_gpio;
838c2ecf20Sopenharmony_ci	int sync_gpio;
848c2ecf20Sopenharmony_ci};
858c2ecf20Sopenharmony_ci#endif /* __TEGRA20_AC97_H__ */
86