18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2018 BayLibre, SAS.
48c2ecf20Sopenharmony_ci * Author: Jerome Brunet <jbrunet@baylibre.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _MESON_AIU_H
88c2ecf20Sopenharmony_ci#define _MESON_AIU_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistruct clk;
118c2ecf20Sopenharmony_cistruct clk_bulk_data;
128c2ecf20Sopenharmony_cistruct device;
138c2ecf20Sopenharmony_cistruct of_phandle_args;
148c2ecf20Sopenharmony_cistruct snd_soc_dai;
158c2ecf20Sopenharmony_cistruct snd_soc_dai_ops;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum aiu_clk_ids {
188c2ecf20Sopenharmony_ci	PCLK = 0,
198c2ecf20Sopenharmony_ci	AOCLK,
208c2ecf20Sopenharmony_ci	MCLK,
218c2ecf20Sopenharmony_ci	MIXER
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct aiu_interface {
258c2ecf20Sopenharmony_ci	struct clk_bulk_data *clks;
268c2ecf20Sopenharmony_ci	unsigned int clk_num;
278c2ecf20Sopenharmony_ci	int irq;
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistruct aiu_platform_data {
318c2ecf20Sopenharmony_ci	bool has_acodec;
328c2ecf20Sopenharmony_ci	bool has_clk_ctrl_more_i2s_div;
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct aiu {
368c2ecf20Sopenharmony_ci	struct clk *pclk;
378c2ecf20Sopenharmony_ci	struct clk *spdif_mclk;
388c2ecf20Sopenharmony_ci	struct aiu_interface i2s;
398c2ecf20Sopenharmony_ci	struct aiu_interface spdif;
408c2ecf20Sopenharmony_ci	const struct aiu_platform_data *platform;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define AIU_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |	\
448c2ecf20Sopenharmony_ci		     SNDRV_PCM_FMTBIT_S20_LE |	\
458c2ecf20Sopenharmony_ci		     SNDRV_PCM_FMTBIT_S24_LE)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciint aiu_of_xlate_dai_name(struct snd_soc_component *component,
488c2ecf20Sopenharmony_ci			  struct of_phandle_args *args,
498c2ecf20Sopenharmony_ci			  const char **dai_name,
508c2ecf20Sopenharmony_ci			  unsigned int component_id);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciint aiu_hdmi_ctrl_register_component(struct device *dev);
538c2ecf20Sopenharmony_ciint aiu_acodec_ctrl_register_component(struct device *dev);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciint aiu_fifo_i2s_dai_probe(struct snd_soc_dai *dai);
568c2ecf20Sopenharmony_ciint aiu_fifo_spdif_dai_probe(struct snd_soc_dai *dai);
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ciextern const struct snd_soc_dai_ops aiu_fifo_i2s_dai_ops;
598c2ecf20Sopenharmony_ciextern const struct snd_soc_dai_ops aiu_fifo_spdif_dai_ops;
608c2ecf20Sopenharmony_ciextern const struct snd_soc_dai_ops aiu_encoder_i2s_dai_ops;
618c2ecf20Sopenharmony_ciextern const struct snd_soc_dai_ops aiu_encoder_spdif_dai_ops;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define AIU_IEC958_BPF			0x000
648c2ecf20Sopenharmony_ci#define AIU_958_MISC			0x010
658c2ecf20Sopenharmony_ci#define AIU_IEC958_DCU_FF_CTRL		0x01c
668c2ecf20Sopenharmony_ci#define AIU_958_CHSTAT_L0		0x020
678c2ecf20Sopenharmony_ci#define AIU_958_CHSTAT_L1		0x024
688c2ecf20Sopenharmony_ci#define AIU_958_CTRL			0x028
698c2ecf20Sopenharmony_ci#define AIU_I2S_SOURCE_DESC		0x034
708c2ecf20Sopenharmony_ci#define AIU_I2S_DAC_CFG			0x040
718c2ecf20Sopenharmony_ci#define AIU_I2S_SYNC			0x044
728c2ecf20Sopenharmony_ci#define AIU_I2S_MISC			0x048
738c2ecf20Sopenharmony_ci#define AIU_RST_SOFT			0x054
748c2ecf20Sopenharmony_ci#define AIU_CLK_CTRL			0x058
758c2ecf20Sopenharmony_ci#define AIU_CLK_CTRL_MORE		0x064
768c2ecf20Sopenharmony_ci#define AIU_CODEC_DAC_LRCLK_CTRL	0x0a0
778c2ecf20Sopenharmony_ci#define AIU_HDMI_CLK_DATA_CTRL		0x0a8
788c2ecf20Sopenharmony_ci#define AIU_ACODEC_CTRL			0x0b0
798c2ecf20Sopenharmony_ci#define AIU_958_CHSTAT_R0		0x0c0
808c2ecf20Sopenharmony_ci#define AIU_958_CHSTAT_R1		0x0c4
818c2ecf20Sopenharmony_ci#define AIU_MEM_I2S_START		0x180
828c2ecf20Sopenharmony_ci#define AIU_MEM_I2S_MASKS		0x18c
838c2ecf20Sopenharmony_ci#define AIU_MEM_I2S_CONTROL		0x190
848c2ecf20Sopenharmony_ci#define AIU_MEM_IEC958_START		0x194
858c2ecf20Sopenharmony_ci#define AIU_MEM_IEC958_CONTROL		0x1a4
868c2ecf20Sopenharmony_ci#define AIU_MEM_I2S_BUF_CNTL		0x1d8
878c2ecf20Sopenharmony_ci#define AIU_MEM_IEC958_BUF_CNTL		0x1fc
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#endif /* _MESON_AIU_H */
90