0001
0002
0003
0004
0005
0006
0007
0008 #ifndef SIU_H
0009 #define SIU_H
0010
0011
0012
0013 #define YRAM0_SIZE (0x0040 / 4)
0014 #define YRAM1_SIZE (0x0080 / 4)
0015 #define YRAM2_SIZE (0x0040 / 4)
0016 #define YRAM3_SIZE (0x0080 / 4)
0017 #define YRAM4_SIZE (0x0080 / 4)
0018 #define YRAM_DEF_SIZE (YRAM0_SIZE + YRAM1_SIZE + YRAM2_SIZE + \
0019 YRAM3_SIZE + YRAM4_SIZE)
0020 #define YRAM_FIR_SIZE (0x0400 / 4)
0021 #define YRAM_IIR_SIZE (0x0200 / 4)
0022
0023 #define XRAM0_SIZE (0x0400 / 4)
0024 #define XRAM1_SIZE (0x0200 / 4)
0025 #define XRAM2_SIZE (0x0200 / 4)
0026
0027
0028 #define PRAM0_SIZE (0x0100 / 4)
0029 #define PRAM1_SIZE ((0x2000 - 0x0100) / 4)
0030
0031 #include <linux/types.h>
0032
0033 struct siu_spb_param {
0034 __u32 ab1a;
0035 __u32 ab0a;
0036 __u32 dir;
0037 __u32 event;
0038 __u32 stfifo;
0039 __u32 trdat;
0040 };
0041
0042 struct siu_firmware {
0043 __u32 yram_fir_coeff[YRAM_FIR_SIZE];
0044 __u32 pram0[PRAM0_SIZE];
0045 __u32 pram1[PRAM1_SIZE];
0046 __u32 yram0[YRAM0_SIZE];
0047 __u32 yram1[YRAM1_SIZE];
0048 __u32 yram2[YRAM2_SIZE];
0049 __u32 yram3[YRAM3_SIZE];
0050 __u32 yram4[YRAM4_SIZE];
0051 __u32 spbpar_num;
0052 struct siu_spb_param spbpar[32];
0053 };
0054
0055 #ifdef __KERNEL__
0056
0057 #include <linux/dmaengine.h>
0058 #include <linux/interrupt.h>
0059 #include <linux/io.h>
0060 #include <linux/sh_dma.h>
0061
0062 #include <sound/core.h>
0063 #include <sound/pcm.h>
0064 #include <sound/soc.h>
0065
0066 #define SIU_PERIOD_BYTES_MAX 8192
0067 #define SIU_PERIOD_BYTES_MIN 256
0068 #define SIU_PERIODS_MAX 64
0069 #define SIU_PERIODS_MIN 4
0070 #define SIU_BUFFER_BYTES_MAX (SIU_PERIOD_BYTES_MAX * SIU_PERIODS_MAX)
0071
0072
0073 enum {
0074 SIU_PORT_A,
0075 SIU_PORT_B,
0076 SIU_PORT_NUM,
0077 };
0078
0079
0080 enum {
0081 SIU_CLKA_PLL,
0082 SIU_CLKA_EXT,
0083 SIU_CLKB_PLL,
0084 SIU_CLKB_EXT
0085 };
0086
0087 struct device;
0088 struct siu_info {
0089 struct device *dev;
0090 int port_id;
0091 u32 __iomem *pram;
0092 u32 __iomem *xram;
0093 u32 __iomem *yram;
0094 u32 __iomem *reg;
0095 struct siu_firmware fw;
0096 };
0097
0098 struct siu_stream {
0099 struct work_struct work;
0100 struct snd_pcm_substream *substream;
0101 snd_pcm_format_t format;
0102 size_t buf_bytes;
0103 size_t period_bytes;
0104 int cur_period;
0105 u32 volume;
0106 snd_pcm_sframes_t xfer_cnt;
0107 u8 rw_flg;
0108
0109 struct dma_chan *chan;
0110 struct dma_async_tx_descriptor *tx_desc;
0111 dma_cookie_t cookie;
0112 struct sh_dmae_slave param;
0113 };
0114
0115 struct siu_port {
0116 unsigned long play_cap;
0117 struct snd_pcm *pcm;
0118 struct siu_stream playback;
0119 struct siu_stream capture;
0120 u32 stfifo;
0121 u32 trdat;
0122 };
0123
0124 extern struct siu_port *siu_ports[SIU_PORT_NUM];
0125
0126 static inline struct siu_port *siu_port_info(struct snd_pcm_substream *substream)
0127 {
0128 struct platform_device *pdev =
0129 to_platform_device(substream->pcm->card->dev);
0130 return siu_ports[pdev->id];
0131 }
0132
0133
0134 static inline void siu_write32(u32 __iomem *addr, u32 val)
0135 {
0136 __raw_writel(val, addr);
0137 }
0138
0139 static inline u32 siu_read32(u32 __iomem *addr)
0140 {
0141 return __raw_readl(addr);
0142 }
0143
0144
0145 #define SIU_IFCTL (0x000 / sizeof(u32))
0146 #define SIU_SRCTL (0x004 / sizeof(u32))
0147 #define SIU_SFORM (0x008 / sizeof(u32))
0148 #define SIU_CKCTL (0x00c / sizeof(u32))
0149 #define SIU_TRDAT (0x010 / sizeof(u32))
0150 #define SIU_STFIFO (0x014 / sizeof(u32))
0151 #define SIU_DPAK (0x01c / sizeof(u32))
0152 #define SIU_CKREV (0x020 / sizeof(u32))
0153 #define SIU_EVNTC (0x028 / sizeof(u32))
0154 #define SIU_SBCTL (0x040 / sizeof(u32))
0155 #define SIU_SBPSET (0x044 / sizeof(u32))
0156 #define SIU_SBFSTS (0x068 / sizeof(u32))
0157 #define SIU_SBDVCA (0x06c / sizeof(u32))
0158 #define SIU_SBDVCB (0x070 / sizeof(u32))
0159 #define SIU_SBACTIV (0x074 / sizeof(u32))
0160 #define SIU_DMAIA (0x090 / sizeof(u32))
0161 #define SIU_DMAIB (0x094 / sizeof(u32))
0162 #define SIU_DMAOA (0x098 / sizeof(u32))
0163 #define SIU_DMAOB (0x09c / sizeof(u32))
0164 #define SIU_DMAML (0x0a0 / sizeof(u32))
0165 #define SIU_SPSTS (0x0cc / sizeof(u32))
0166 #define SIU_SPCTL (0x0d0 / sizeof(u32))
0167 #define SIU_BRGASEL (0x100 / sizeof(u32))
0168 #define SIU_BRRA (0x104 / sizeof(u32))
0169 #define SIU_BRGBSEL (0x108 / sizeof(u32))
0170 #define SIU_BRRB (0x10c / sizeof(u32))
0171
0172 extern const struct snd_soc_component_driver siu_component;
0173 extern struct siu_info *siu_i2s_data;
0174
0175 int siu_init_port(int port, struct siu_port **port_info, struct snd_card *card);
0176 void siu_free_port(struct siu_port *port_info);
0177
0178 #endif
0179
0180 #endif