18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * TXx9 SoC AC Link Controller
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __TXX9ACLC_H
78c2ecf20Sopenharmony_ci#define __TXX9ACLC_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
108c2ecf20Sopenharmony_ci#include <asm/txx9/dmac.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define ACCTLEN			0x00	/* control enable */
138c2ecf20Sopenharmony_ci#define ACCTLDIS		0x04	/* control disable */
148c2ecf20Sopenharmony_ci#define   ACCTL_ENLINK		0x00000001	/* enable/disable AC-link */
158c2ecf20Sopenharmony_ci#define   ACCTL_AUDODMA		0x00000100	/* AUDODMA enable/disable */
168c2ecf20Sopenharmony_ci#define   ACCTL_AUDIDMA		0x00001000	/* AUDIDMA enable/disable */
178c2ecf20Sopenharmony_ci#define   ACCTL_AUDOEHLT	0x00010000	/* AUDO error halt
188c2ecf20Sopenharmony_ci						   enable/disable */
198c2ecf20Sopenharmony_ci#define   ACCTL_AUDIEHLT	0x00100000	/* AUDI error halt
208c2ecf20Sopenharmony_ci						   enable/disable */
218c2ecf20Sopenharmony_ci#define ACREGACC		0x08	/* codec register access */
228c2ecf20Sopenharmony_ci#define   ACREGACC_DAT_SHIFT	0	/* data field */
238c2ecf20Sopenharmony_ci#define   ACREGACC_REG_SHIFT	16	/* address field */
248c2ecf20Sopenharmony_ci#define   ACREGACC_CODECID_SHIFT	24	/* CODEC ID field */
258c2ecf20Sopenharmony_ci#define   ACREGACC_READ		0x80000000	/* CODEC read */
268c2ecf20Sopenharmony_ci#define   ACREGACC_WRITE	0x00000000	/* CODEC write */
278c2ecf20Sopenharmony_ci#define ACINTSTS		0x10	/* interrupt status */
288c2ecf20Sopenharmony_ci#define ACINTMSTS		0x14	/* interrupt masked status */
298c2ecf20Sopenharmony_ci#define ACINTEN			0x18	/* interrupt enable */
308c2ecf20Sopenharmony_ci#define ACINTDIS		0x1c	/* interrupt disable */
318c2ecf20Sopenharmony_ci#define   ACINT_CODECRDY(n)	(0x00000001 << (n))	/* CODECn ready */
328c2ecf20Sopenharmony_ci#define   ACINT_REGACCRDY	0x00000010	/* ACREGACC ready */
338c2ecf20Sopenharmony_ci#define   ACINT_AUDOERR		0x00000100	/* AUDO underrun error */
348c2ecf20Sopenharmony_ci#define   ACINT_AUDIERR		0x00001000	/* AUDI overrun error */
358c2ecf20Sopenharmony_ci#define ACDMASTS		0x80	/* DMA request status */
368c2ecf20Sopenharmony_ci#define   ACDMA_AUDO		0x00000001	/* AUDODMA pending */
378c2ecf20Sopenharmony_ci#define   ACDMA_AUDI		0x00000010	/* AUDIDMA pending */
388c2ecf20Sopenharmony_ci#define ACAUDODAT		0xa0	/* audio out data */
398c2ecf20Sopenharmony_ci#define ACAUDIDAT		0xb0	/* audio in data */
408c2ecf20Sopenharmony_ci#define ACREVID			0xfc	/* revision ID */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistruct txx9aclc_dmadata {
438c2ecf20Sopenharmony_ci	struct resource *dma_res;
448c2ecf20Sopenharmony_ci	struct txx9dmac_slave dma_slave;
458c2ecf20Sopenharmony_ci	struct dma_chan *dma_chan;
468c2ecf20Sopenharmony_ci	struct work_struct work;
478c2ecf20Sopenharmony_ci	spinlock_t dma_lock;
488c2ecf20Sopenharmony_ci	int stream; /* SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE */
498c2ecf20Sopenharmony_ci	struct snd_pcm_substream *substream;
508c2ecf20Sopenharmony_ci	unsigned long pos;
518c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
528c2ecf20Sopenharmony_ci	unsigned long buffer_bytes;
538c2ecf20Sopenharmony_ci	unsigned long period_bytes;
548c2ecf20Sopenharmony_ci	unsigned long frag_bytes;
558c2ecf20Sopenharmony_ci	int frags;
568c2ecf20Sopenharmony_ci	int frag_count;
578c2ecf20Sopenharmony_ci	int dmacount;
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistruct txx9aclc_plat_drvdata {
618c2ecf20Sopenharmony_ci	void __iomem *base;
628c2ecf20Sopenharmony_ci	u64 physbase;
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cistatic inline struct txx9aclc_plat_drvdata *txx9aclc_get_plat_drvdata(
668c2ecf20Sopenharmony_ci	struct snd_soc_dai *dai)
678c2ecf20Sopenharmony_ci{
688c2ecf20Sopenharmony_ci	return dev_get_drvdata(dai->dev);
698c2ecf20Sopenharmony_ci}
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#endif /* __TXX9ACLC_H */
72