blob: a1733a6aace5a86d2f49d8849cc646a5e94d383c [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
apatard@mandriva.comf9b95982010-05-31 13:49:14 +02002/*
3 * kirkwood.h
4 *
5 * (c) 2010 Arnaud Patard <apatard@mandriva.com>
apatard@mandriva.comf9b95982010-05-31 13:49:14 +02006 */
7
8#ifndef _KIRKWOOD_AUDIO_H
9#define _KIRKWOOD_AUDIO_H
10
Kuninori Morimotof98fc0f2018-01-29 02:48:03 +000011#define DRV_NAME "mvebu-audio"
12
apatard@mandriva.comf9b95982010-05-31 13:49:14 +020013#define KIRKWOOD_RECORD_WIN 0
14#define KIRKWOOD_PLAYBACK_WIN 1
15#define KIRKWOOD_MAX_AUDIO_WIN 2
16
17#define KIRKWOOD_AUDIO_WIN_BASE_REG(win) (0xA00 + ((win)<<3))
18#define KIRKWOOD_AUDIO_WIN_CTRL_REG(win) (0xA04 + ((win)<<3))
19
20
21#define KIRKWOOD_RECCTL 0x1000
22#define KIRKWOOD_RECCTL_SPDIF_EN (1<<11)
23#define KIRKWOOD_RECCTL_I2S_EN (1<<10)
24#define KIRKWOOD_RECCTL_PAUSE (1<<9)
25#define KIRKWOOD_RECCTL_MUTE (1<<8)
26#define KIRKWOOD_RECCTL_BURST_MASK (3<<5)
27#define KIRKWOOD_RECCTL_BURST_128 (2<<5)
28#define KIRKWOOD_RECCTL_BURST_32 (1<<5)
29#define KIRKWOOD_RECCTL_MONO (1<<4)
30#define KIRKWOOD_RECCTL_MONO_CHAN_RIGHT (1<<3)
31#define KIRKWOOD_RECCTL_MONO_CHAN_LEFT (0<<3)
32#define KIRKWOOD_RECCTL_SIZE_MASK (7<<0)
33#define KIRKWOOD_RECCTL_SIZE_16 (7<<0)
34#define KIRKWOOD_RECCTL_SIZE_16_C (3<<0)
35#define KIRKWOOD_RECCTL_SIZE_20 (2<<0)
36#define KIRKWOOD_RECCTL_SIZE_24 (1<<0)
37#define KIRKWOOD_RECCTL_SIZE_32 (0<<0)
38
Russell King52b896c2014-06-26 15:22:55 +010039#define KIRKWOOD_RECCTL_ENABLE_MASK (KIRKWOOD_RECCTL_SPDIF_EN | \
40 KIRKWOOD_RECCTL_I2S_EN)
41
apatard@mandriva.comf9b95982010-05-31 13:49:14 +020042#define KIRKWOOD_REC_BUF_ADDR 0x1004
43#define KIRKWOOD_REC_BUF_SIZE 0x1008
44#define KIRKWOOD_REC_BYTE_COUNT 0x100C
45
46#define KIRKWOOD_PLAYCTL 0x1100
47#define KIRKWOOD_PLAYCTL_PLAY_BUSY (1<<16)
48#define KIRKWOOD_PLAYCTL_BURST_MASK (3<<11)
49#define KIRKWOOD_PLAYCTL_BURST_128 (2<<11)
50#define KIRKWOOD_PLAYCTL_BURST_32 (1<<11)
51#define KIRKWOOD_PLAYCTL_PAUSE (1<<9)
52#define KIRKWOOD_PLAYCTL_SPDIF_MUTE (1<<8)
arnaud.patard@rtp-net.orgdfe4c932010-07-11 23:28:31 +020053#define KIRKWOOD_PLAYCTL_MONO_MASK (3<<5)
54#define KIRKWOOD_PLAYCTL_MONO_BOTH (3<<5)
55#define KIRKWOOD_PLAYCTL_MONO_OFF (0<<5)
apatard@mandriva.comf9b95982010-05-31 13:49:14 +020056#define KIRKWOOD_PLAYCTL_I2S_MUTE (1<<7)
57#define KIRKWOOD_PLAYCTL_SPDIF_EN (1<<4)
Russell Kingdb43b162013-08-04 20:26:03 +010058#define KIRKWOOD_PLAYCTL_I2S_EN (1<<3)
apatard@mandriva.comf9b95982010-05-31 13:49:14 +020059#define KIRKWOOD_PLAYCTL_SIZE_MASK (7<<0)
60#define KIRKWOOD_PLAYCTL_SIZE_16 (7<<0)
61#define KIRKWOOD_PLAYCTL_SIZE_16_C (3<<0)
62#define KIRKWOOD_PLAYCTL_SIZE_20 (2<<0)
63#define KIRKWOOD_PLAYCTL_SIZE_24 (1<<0)
64#define KIRKWOOD_PLAYCTL_SIZE_32 (0<<0)
65
Russell Kingdb43b162013-08-04 20:26:03 +010066#define KIRKWOOD_PLAYCTL_ENABLE_MASK (KIRKWOOD_PLAYCTL_SPDIF_EN | \
67 KIRKWOOD_PLAYCTL_I2S_EN)
68
apatard@mandriva.comf9b95982010-05-31 13:49:14 +020069#define KIRKWOOD_PLAY_BUF_ADDR 0x1104
70#define KIRKWOOD_PLAY_BUF_SIZE 0x1108
71#define KIRKWOOD_PLAY_BYTE_COUNT 0x110C
72
73#define KIRKWOOD_DCO_CTL 0x1204
74#define KIRKWOOD_DCO_CTL_OFFSET_MASK (0xFFF<<2)
75#define KIRKWOOD_DCO_CTL_OFFSET_0 (0x800<<2)
76#define KIRKWOOD_DCO_CTL_FREQ_MASK (3<<0)
77#define KIRKWOOD_DCO_CTL_FREQ_11 (0<<0)
78#define KIRKWOOD_DCO_CTL_FREQ_12 (1<<0)
79#define KIRKWOOD_DCO_CTL_FREQ_24 (2<<0)
80
81#define KIRKWOOD_DCO_SPCR_STATUS 0x120c
82#define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK (1<<16)
83
Russell King363589b2012-11-20 12:20:34 +000084#define KIRKWOOD_CLOCKS_CTRL 0x1230
85#define KIRKWOOD_MCLK_SOURCE_MASK (3<<0)
86#define KIRKWOOD_MCLK_SOURCE_DCO (0<<0)
87#define KIRKWOOD_MCLK_SOURCE_EXTCLK (3<<0)
88
apatard@mandriva.comf9b95982010-05-31 13:49:14 +020089#define KIRKWOOD_ERR_CAUSE 0x1300
90#define KIRKWOOD_ERR_MASK 0x1304
91
92#define KIRKWOOD_INT_CAUSE 0x1308
93#define KIRKWOOD_INT_MASK 0x130C
94#define KIRKWOOD_INT_CAUSE_PLAY_BYTES (1<<14)
95#define KIRKWOOD_INT_CAUSE_REC_BYTES (1<<13)
96#define KIRKWOOD_INT_CAUSE_DMA_PLAY_END (1<<7)
97#define KIRKWOOD_INT_CAUSE_DMA_PLAY_3Q (1<<6)
98#define KIRKWOOD_INT_CAUSE_DMA_PLAY_HALF (1<<5)
99#define KIRKWOOD_INT_CAUSE_DMA_PLAY_1Q (1<<4)
100#define KIRKWOOD_INT_CAUSE_DMA_REC_END (1<<3)
101#define KIRKWOOD_INT_CAUSE_DMA_REC_3Q (1<<2)
102#define KIRKWOOD_INT_CAUSE_DMA_REC_HALF (1<<1)
103#define KIRKWOOD_INT_CAUSE_DMA_REC_1Q (1<<0)
104
105#define KIRKWOOD_REC_BYTE_INT_COUNT 0x1310
106#define KIRKWOOD_PLAY_BYTE_INT_COUNT 0x1314
107#define KIRKWOOD_BYTE_INT_COUNT_MASK 0xffffff
108
109#define KIRKWOOD_I2S_PLAYCTL 0x2508
110#define KIRKWOOD_I2S_RECCTL 0x2408
111#define KIRKWOOD_I2S_CTL_JUST_MASK (0xf<<26)
112#define KIRKWOOD_I2S_CTL_LJ (0<<26)
113#define KIRKWOOD_I2S_CTL_I2S (5<<26)
114#define KIRKWOOD_I2S_CTL_RJ (8<<26)
115#define KIRKWOOD_I2S_CTL_SIZE_MASK (3<<30)
116#define KIRKWOOD_I2S_CTL_SIZE_16 (3<<30)
117#define KIRKWOOD_I2S_CTL_SIZE_20 (2<<30)
118#define KIRKWOOD_I2S_CTL_SIZE_24 (1<<30)
119#define KIRKWOOD_I2S_CTL_SIZE_32 (0<<30)
120
121#define KIRKWOOD_AUDIO_BUF_MAX (16*1024*1024)
122
123/* Theses values come from the marvell alsa driver */
124/* need to find where they come from */
Russell Kinga6222512014-06-26 15:23:15 +0100125#define KIRKWOOD_SND_MIN_PERIODS 2
apatard@mandriva.comf9b95982010-05-31 13:49:14 +0200126#define KIRKWOOD_SND_MAX_PERIODS 16
Russell Kinga6222512014-06-26 15:23:15 +0100127#define KIRKWOOD_SND_MIN_PERIOD_BYTES 256
Jean-Francois Moinece3d0602013-09-19 11:20:43 +0200128#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x8000
Russell Kinge4065f32013-08-04 20:28:04 +0100129#define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \
130 * KIRKWOOD_SND_MAX_PERIODS)
apatard@mandriva.comf9b95982010-05-31 13:49:14 +0200131
132struct kirkwood_dma_data {
apatard@mandriva.comf9b95982010-05-31 13:49:14 +0200133 void __iomem *io;
Russell King363589b2012-11-20 12:20:34 +0000134 struct clk *clk;
135 struct clk *extclk;
Russell Kingd8d11ba2012-11-20 12:19:53 +0000136 uint32_t ctl_play;
137 uint32_t ctl_rec;
Russell Kinga7d09422013-08-04 20:22:03 +0100138 struct snd_pcm_substream *substream_play;
139 struct snd_pcm_substream *substream_rec;
apatard@mandriva.comf9b95982010-05-31 13:49:14 +0200140 int irq;
141 int burst;
apatard@mandriva.comf9b95982010-05-31 13:49:14 +0200142};
143
Kuninori Morimotof98fc0f2018-01-29 02:48:03 +0000144extern const struct snd_soc_component_driver kirkwood_soc_component;
Russell King64ddf1f2013-08-04 20:27:03 +0100145
apatard@mandriva.comf9b95982010-05-31 13:49:14 +0200146#endif