1 --- a/sound/soc/Kconfig
2 +++ b/sound/soc/Kconfig
3 @@ -45,6 +45,7 @@ source "sound/soc/s6000/Kconfig"
4 source "sound/soc/sh/Kconfig"
5 source "sound/soc/tegra/Kconfig"
6 source "sound/soc/txx9/Kconfig"
7 +source "sound/soc/gw-avila/Kconfig"
10 source "sound/soc/codecs/Kconfig"
11 --- a/sound/soc/Makefile
12 +++ b/sound/soc/Makefile
13 @@ -22,3 +22,4 @@ obj-$(CONFIG_SND_SOC) += s6000/
14 obj-$(CONFIG_SND_SOC) += sh/
15 obj-$(CONFIG_SND_SOC) += tegra/
16 obj-$(CONFIG_SND_SOC) += txx9/
17 +obj-$(CONFIG_SND_SOC) += gw-avila/
19 +++ b/sound/soc/gw-avila/Kconfig
21 +config SND_GW_AVILA_SOC_PCM
24 +config SND_GW_AVILA_SOC_HSS
27 +config SND_GW_AVILA_SOC
28 + tristate "SoC Audio for the Gateworks AVILA Family"
29 + depends on ARCH_IXP4XX && SND_SOC
30 + select SND_GW_AVILA_SOC_PCM
31 + select SND_GW_AVILA_SOC_HSS
32 + select SND_SOC_TLV320AIC3X
34 + Say Y or M if you want to add support for codecs attached to
35 + the Gateworks HSS interface. You will also need
36 + to select the audio interfaces to support below.
39 +++ b/sound/soc/gw-avila/Makefile
41 +# Gateworks Avila HSS Platform Support
42 +snd-soc-gw-avila-objs := gw-avila.o ixp4xx_hss.o
43 +snd-soc-gw-avila-pcm-objs := gw-avila-pcm.o
44 +snd-soc-gw-avila-hss-objs := gw-avila-hss.o
46 +obj-$(CONFIG_SND_GW_AVILA_SOC) += snd-soc-gw-avila.o
47 +obj-$(CONFIG_SND_GW_AVILA_SOC_PCM) += snd-soc-gw-avila-pcm.o
48 +obj-$(CONFIG_SND_GW_AVILA_SOC_HSS) += snd-soc-gw-avila-hss.o
50 +++ b/sound/soc/gw-avila/gw-avila-hss.c
53 + * gw-avila-hss.c -- HSS Audio Support for Gateworks Avila
55 + * Author: Chris Lang <clang@gateworks.com>
57 + * This program is free software; you can redistribute it and/or modify
58 + * it under the terms of the GNU General Public License version 2 as
59 + * published by the Free Software Foundation.
62 +#include <linux/init.h>
63 +#include <linux/module.h>
64 +#include <linux/platform_device.h>
65 +#include <linux/interrupt.h>
66 +#include <linux/wait.h>
67 +#include <linux/delay.h>
69 +#include <sound/core.h>
70 +#include <sound/pcm.h>
71 +#include <sound/ac97_codec.h>
72 +#include <sound/initval.h>
73 +#include <sound/soc.h>
76 +#include <linux/mutex.h>
77 +#include <linux/gpio.h>
79 +#include "ixp4xx_hss.h"
80 +#include "gw-avila-hss.h"
82 +#define gw_avila_hss_suspend NULL
83 +#define gw_avila_hss_resume NULL
85 +struct snd_soc_dai_driver gw_avila_hss_dai = {
89 + .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
90 + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
91 + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
92 + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
93 + SNDRV_PCM_RATE_KNOT),
94 + .formats = SNDRV_PCM_FMTBIT_S16_LE, },
98 + .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
99 + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
100 + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
101 + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
102 + SNDRV_PCM_RATE_KNOT),
103 + .formats = SNDRV_PCM_FMTBIT_S16_LE, },
106 +static int gw_avila_hss_probe(struct platform_device *pdev)
108 + int port = (pdev->id < 2) ? 0 : 1;
109 + int channel = (pdev->id % 2);
111 + hss_handle[pdev->id] = hss_init(port, channel);
112 + if (!hss_handle[pdev->id]) {
116 + return snd_soc_register_dai(&pdev->dev, &gw_avila_hss_dai);
119 +static int gw_avila_hss_remove(struct platform_device *pdev)
121 + snd_soc_unregister_dai(&pdev->dev);
126 +static struct platform_driver gw_avila_hss_driver = {
127 + .probe = gw_avila_hss_probe,
128 + .remove = gw_avila_hss_remove,
130 + .name = "gw_avila_hss",
131 + .owner = THIS_MODULE,
135 +static int __init gw_avila_hss_init(void)
137 + return platform_driver_register(&gw_avila_hss_driver);
139 +module_init(gw_avila_hss_init);
141 +static void __exit gw_avila_hss_exit(void)
143 + platform_driver_unregister(&gw_avila_hss_driver);
145 +module_exit(gw_avila_hss_exit);
147 +MODULE_AUTHOR("Chris Lang");
148 +MODULE_DESCRIPTION("HSS Audio Driver for Gateworks Avila");
149 +MODULE_LICENSE("GPL");
151 +++ b/sound/soc/gw-avila/gw-avila-hss.h
154 + * Author: Chris Lang <clang@gateworks.com>
156 + * This program is free software; you can redistribute it and/or modify
157 + * it under the terms of the GNU General Public License version 2 as
158 + * published by the Free Software Foundation.
161 +#ifndef _GW_AVILA_HSS_H
162 +#define _GW_AVILA_HSS_H
166 +++ b/sound/soc/gw-avila/gw-avila-pcm.c
169 + * ALSA PCM interface for the TI DAVINCI processor
171 + * Author: Chris Lang, <clang@gateworks.com>
172 + * Copyright: (C) 2009 Gateworks Corporation
174 + * Based On: davinci-evm.c, Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
176 + * This program is free software; you can redistribute it and/or modify
177 + * it under the terms of the GNU General Public License version 2 as
178 + * published by the Free Software Foundation.
181 +#include <linux/module.h>
182 +#include <linux/init.h>
183 +#include <linux/platform_device.h>
184 +#include <linux/slab.h>
185 +#include <linux/dma-mapping.h>
187 +#include <sound/core.h>
188 +#include <sound/pcm.h>
189 +#include <sound/pcm_params.h>
190 +#include <sound/soc.h>
192 +#include <asm/dma.h>
194 +#include "gw-avila-pcm.h"
195 +#include "gw-avila-hss.h"
196 +#include "ixp4xx_hss.h"
198 +#define GW_AVILA_PCM_DEBUG 0
199 +#if GW_AVILA_PCM_DEBUG
200 +#define DPRINTK(x...) printk(KERN_DEBUG x)
202 +#define DPRINTK(x...)
205 +static struct snd_pcm_hardware gw_avila_pcm_hardware = {
206 + .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
207 + SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID),
208 +/* SNDRV_PCM_INFO_PAUSE),*/
209 + .formats = (SNDRV_PCM_FMTBIT_S16_LE),
210 + .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
211 + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
212 + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
213 + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
214 + SNDRV_PCM_RATE_KNOT),
219 + .buffer_bytes_max = 64 * 1024, // All of the lines below may need to be changed
220 + .period_bytes_min = 128,
221 + .period_bytes_max = 4 * 1024,
227 +struct gw_avila_runtime_data {
229 + int period; /* current DMA period */
230 + int master_lch; /* Master DMA channel */
231 + int slave_lch; /* Slave DMA channel */
232 + struct gw_avila_pcm_dma_params *params; /* DMA params */
235 +static void gw_avila_dma_irq(void *data)
237 + struct snd_pcm_substream *substream = data;
238 + snd_pcm_period_elapsed(substream);
241 +static int gw_avila_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
243 + struct snd_pcm_runtime *runtime = substream->runtime;
244 + struct hss_device *hdev = runtime->private_data;
248 + case SNDRV_PCM_TRIGGER_START:
249 + case SNDRV_PCM_TRIGGER_RESUME:
250 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
251 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
252 + hss_tx_start(hdev);
254 + hss_rx_start(hdev);
256 + case SNDRV_PCM_TRIGGER_STOP:
257 + case SNDRV_PCM_TRIGGER_SUSPEND:
258 + case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
259 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
271 +static int gw_avila_pcm_prepare(struct snd_pcm_substream *substream)
273 + struct snd_pcm_runtime *runtime = substream->runtime;
274 + struct hss_device *hdev = runtime->private_data;
276 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
277 + hss_set_tx_callback(hdev, gw_avila_dma_irq, substream);
278 + hss_config_tx_dma(hdev, runtime->dma_area, runtime->buffer_size, runtime->period_size);
280 + hss_set_rx_callback(hdev, gw_avila_dma_irq, substream);
281 + hss_config_rx_dma(hdev, runtime->dma_area, runtime->buffer_size, runtime->period_size);
287 +static snd_pcm_uframes_t
288 +gw_avila_pcm_pointer(struct snd_pcm_substream *substream)
290 + struct snd_pcm_runtime *runtime = substream->runtime;
291 + struct hss_device *hdev = runtime->private_data;
293 + unsigned int curr = 0;
294 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
295 + curr = hss_curr_offset_tx(hdev);
297 + curr = hss_curr_offset_rx(hdev);
301 +static int gw_avila_pcm_open(struct snd_pcm_substream *substream)
303 + struct snd_pcm_runtime *runtime = substream->runtime;
304 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
305 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
307 + snd_soc_set_runtime_hwparams(substream, &gw_avila_pcm_hardware);
309 + if (hss_handle[cpu_dai->id] != NULL)
310 + runtime->private_data = hss_handle[cpu_dai->id];
312 + pr_err("hss_handle is NULL\n");
316 + hss_chan_open(hss_handle[cpu_dai->id]);
321 +static int gw_avila_pcm_close(struct snd_pcm_substream *substream)
323 + struct snd_pcm_runtime *runtime = substream->runtime;
324 + struct hss_device *hdev = runtime->private_data;
326 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
327 + memset(hdev->tx_buf, 0, runtime->buffer_size);
329 + memset(hdev->rx_buf, 0, runtime->buffer_size);
331 + hss_chan_close(hdev);
336 +static int gw_avila_pcm_hw_params(struct snd_pcm_substream *substream,
337 + struct snd_pcm_hw_params *hw_params)
339 + return snd_pcm_lib_malloc_pages(substream,
340 + params_buffer_bytes(hw_params));
343 +static int gw_avila_pcm_hw_free(struct snd_pcm_substream *substream)
345 + struct snd_pcm_runtime *runtime = substream->runtime;
347 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
348 + memset(runtime->dma_area, 0, runtime->buffer_size);
350 + return snd_pcm_lib_free_pages(substream);
353 +static int gw_avila_pcm_mmap(struct snd_pcm_substream *substream,
354 + struct vm_area_struct *vma)
356 + struct snd_pcm_runtime *runtime = substream->runtime;
358 + return dma_mmap_writecombine(substream->pcm->card->dev, vma,
361 + runtime->dma_bytes);
364 +struct snd_pcm_ops gw_avila_pcm_ops = {
365 + .open = gw_avila_pcm_open,
366 + .close = gw_avila_pcm_close,
367 + .ioctl = snd_pcm_lib_ioctl,
368 + .hw_params = gw_avila_pcm_hw_params,
369 + .hw_free = gw_avila_pcm_hw_free,
370 + .prepare = gw_avila_pcm_prepare,
371 + .trigger = gw_avila_pcm_trigger,
372 + .pointer = gw_avila_pcm_pointer,
373 + .mmap = gw_avila_pcm_mmap,
376 +static int gw_avila_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
378 + struct snd_pcm_substream *substream = pcm->streams[stream].substream;
379 + struct snd_dma_buffer *buf = &substream->dma_buffer;
380 + size_t size = gw_avila_pcm_hardware.buffer_bytes_max;
382 + buf->dev.type = SNDRV_DMA_TYPE_DEV;
383 + buf->dev.dev = pcm->card->dev;
384 + buf->private_data = NULL;
386 + buf->area = dma_alloc_coherent(pcm->card->dev, size,
387 + &buf->addr, GFP_KERNEL);
393 + memset(buf->area, 0xff, size);
395 + DPRINTK("preallocate_dma_buffer: area=%p, addr=%p, size=%d\n",
396 + (void *) buf->area, (void *) buf->addr, size);
403 +static void gw_avila_pcm_free(struct snd_pcm *pcm)
405 + struct snd_pcm_substream *substream;
406 + struct snd_dma_buffer *buf;
409 + for (stream = 0; stream < 2; stream++) {
410 + substream = pcm->streams[stream].substream;
414 + buf = &substream->dma_buffer;
418 + dma_free_coherent(NULL, buf->bytes, buf->area, 0);
423 +static u64 gw_avila_pcm_dmamask = 0xFFFFFFFF;
425 +static int gw_avila_pcm_new(struct snd_soc_pcm_runtime *rtd)
427 + struct snd_card *card = rtd->card->snd_card;
428 + struct snd_pcm *pcm = rtd->pcm;
429 + struct snd_soc_dai *dai = rtd->codec_dai;
432 + if (!card->dev->dma_mask)
433 + card->dev->dma_mask = &gw_avila_pcm_dmamask;
434 + if (!card->dev->coherent_dma_mask)
435 + card->dev->coherent_dma_mask = 0xFFFFFFFF;
437 + if (dai->driver->playback.channels_min) {
438 + ret = gw_avila_pcm_preallocate_dma_buffer(pcm,
439 + SNDRV_PCM_STREAM_PLAYBACK);
444 + if (dai->driver->capture.channels_min) {
445 + ret = gw_avila_pcm_preallocate_dma_buffer(pcm,
446 + SNDRV_PCM_STREAM_CAPTURE);
454 +struct snd_soc_platform_driver gw_avila_soc_platform = {
455 + .ops = &gw_avila_pcm_ops,
456 + .pcm_new = gw_avila_pcm_new,
457 + .pcm_free = gw_avila_pcm_free,
460 +static int __devinit gw_avila_pcm_platform_probe(struct platform_device *pdev)
462 + return snd_soc_register_platform(&pdev->dev, &gw_avila_soc_platform);
465 +static int __devexit gw_avila_pcm_platform_remove(struct platform_device *pdev)
467 + snd_soc_unregister_platform(&pdev->dev);
471 +static struct platform_driver gw_avila_pcm_driver = {
473 + .name = "gw_avila-audio",
474 + .owner = THIS_MODULE,
476 + .probe = gw_avila_pcm_platform_probe,
477 + .remove = __devexit_p(gw_avila_pcm_platform_remove),
480 +static int __init gw_avila_soc_platform_init(void)
482 + return platform_driver_register(&gw_avila_pcm_driver);
484 +module_init(gw_avila_soc_platform_init);
486 +static void __exit gw_avila_soc_platform_exit(void)
488 + platform_driver_unregister(&gw_avila_pcm_driver);
490 +module_exit(gw_avila_soc_platform_exit);
492 +MODULE_AUTHOR("Chris Lang");
493 +MODULE_DESCRIPTION("Gateworks Avila PCM DMA module");
494 +MODULE_LICENSE("GPL");
496 +++ b/sound/soc/gw-avila/gw-avila-pcm.h
499 + * ALSA PCM interface for the Gateworks Avila platform
501 + * Author: Chris Lang, <clang@gateworks.com>
502 + * Copyright: (C) 2009 Gateworks Corporation
504 + * Based On: davinci-evm.c, Author: Vladimir Barinov, <vbarinov@ru.mvista.com>
506 + * This program is free software; you can redistribute it and/or modify
507 + * it under the terms of the GNU General Public License version 2 as
508 + * published by the Free Software Foundation.
511 +#ifndef _GW_AVILA_PCM_H
512 +#define _GW_AVILA_PCM_H
515 +struct gw_avila_pcm_dma_params {
516 + char *name; /* stream identifier */
517 + int channel; /* sync dma channel ID */
518 + dma_addr_t dma_addr; /* device physical address for DMA */
519 + unsigned int data_type; /* xfer data type */
522 +struct gw_avila_snd_platform_data {
523 + int tx_dma_ch; // XXX Do we need this?
524 + int rx_dma_ch; // XXX Do we need this
526 +extern struct snd_soc_platform gw_avila_soc_platform[];
531 +++ b/sound/soc/gw-avila/gw-avila.c
534 + * File: sound/soc/gw-avila/gw_avila.c
535 + * Author: Chris Lang <clang@gateworks.com>
537 + * Created: Tue June 06 2008
538 + * Description: Board driver for Gateworks Avila
541 + * Copyright 2009 Gateworks Corporation
545 + * This program is free software; you can redistribute it and/or modify
546 + * it under the terms of the GNU General Public License as published by
547 + * the Free Software Foundation; either version 2 of the License, or
548 + * (at your option) any later version.
550 + * This program is distributed in the hope that it will be useful,
551 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
552 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
553 + * GNU General Public License for more details.
555 + * You should have received a copy of the GNU General Public License
556 + * along with this program; if not, see the file COPYING, or write
557 + * to the Free Software Foundation, Inc.,
558 + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
561 +#include <linux/module.h>
562 +#include <linux/moduleparam.h>
563 +#include <linux/device.h>
564 +#include <asm/dma.h>
565 +#include <linux/platform_device.h>
566 +#include <sound/core.h>
567 +#include <sound/pcm.h>
568 +#include <sound/soc.h>
569 +#include <linux/slab.h>
570 +#include <linux/gpio.h>
572 +#include "ixp4xx_hss.h"
573 +#include "gw-avila-hss.h"
574 +#include "gw-avila-pcm.h"
576 +#define CODEC_FREQ 33333000
578 +static int gw_avila_board_startup(struct snd_pcm_substream *substream)
580 + pr_debug("%s enter\n", __func__);
584 +static int gw_avila_hw_params(struct snd_pcm_substream *substream,
585 + struct snd_pcm_hw_params *params)
587 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
588 + struct snd_soc_dai *codec_dai = rtd->codec_dai;
589 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
593 + /* set codec DAI configuration */
594 + if (cpu_dai->id % 2) {
595 + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS);
596 + snd_soc_dai_set_tdm_slot(codec_dai, 0, 0, 1, 32);
598 + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBM_CFM);
599 + snd_soc_dai_set_tdm_slot(codec_dai, 0, 0, 0, 32);
605 + /* set the codec system clock */
606 + ret = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_FREQ, SND_SOC_CLOCK_OUT);
613 +static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
614 + SND_SOC_DAPM_HP("Headphone Jack", NULL),
615 + SND_SOC_DAPM_LINE("Line Out", NULL),
616 + SND_SOC_DAPM_LINE("Line In", NULL),
619 +static const struct snd_soc_dapm_route audio_map[] = {
620 + {"Headphone Jack", NULL, "HPLOUT"},
621 + {"Headphone Jack", NULL, "HPROUT"},
623 + /* Line Out connected to LLOUT, RLOUT */
624 + {"Line Out", NULL, "LLOUT"},
625 + {"Line Out", NULL, "RLOUT"},
627 + /* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
628 + {"LINE1L", NULL, "Line In"},
629 + {"LINE1R", NULL, "Line In"},
632 +/* Logic for a aic3x as connected on a davinci-evm */
633 +static int avila_aic3x_init(struct snd_soc_pcm_runtime *rtd)
635 + struct snd_soc_codec *codec = rtd->codec;
636 + struct snd_soc_dapm_context *dapm = &codec->dapm;
638 + /* Add davinci-evm specific widgets */
639 + snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
640 + ARRAY_SIZE(aic3x_dapm_widgets));
642 + /* Set up davinci-evm specific audio path audio_map */
643 + snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
645 + /* not connected */
646 + snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
647 + //snd_soc_dapm_disable_pin(dapm, "HPLCOM");
648 + //snd_soc_dapm_disable_pin(dapm, "HPRCOM");
649 + snd_soc_dapm_disable_pin(dapm, "MIC3L");
650 + snd_soc_dapm_disable_pin(dapm, "MIC3R");
651 + snd_soc_dapm_disable_pin(dapm, "LINE2L");
652 + snd_soc_dapm_disable_pin(dapm, "LINE2R");
654 + /* always connected */
655 + snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
656 + snd_soc_dapm_enable_pin(dapm, "Line Out");
657 + snd_soc_dapm_enable_pin(dapm, "Line In");
659 + snd_soc_dapm_sync(dapm);
664 +static struct snd_soc_ops gw_avila_board_ops = {
665 + .startup = gw_avila_board_startup,
666 + .hw_params = gw_avila_hw_params,
669 +static struct snd_soc_dai_link gw_avila_board_dai[] = {
672 + .stream_name = "HSS-0",
673 + .cpu_dai_name = "gw_avila_hss.0",
674 + .codec_dai_name = "tlv320aic3x-hifi",
675 + .codec_name = "tlv320aic3x-codec.0-001b",
676 + .platform_name = "gw_avila-audio.0",
677 + .init = avila_aic3x_init,
678 + .ops = &gw_avila_board_ops,
681 + .stream_name = "HSS-1",
682 + .cpu_dai_name = "gw_avila_hss.1",
683 + .codec_dai_name = "tlv320aic3x-hifi",
684 + .codec_name = "tlv320aic3x-codec.0-001a",
685 + .platform_name = "gw_avila-audio.1",
686 + .init = avila_aic3x_init,
687 + .ops = &gw_avila_board_ops,
690 + .stream_name = "HSS-2",
691 + .cpu_dai_name = "gw_avila_hss.2",
692 + .codec_dai_name = "tlv320aic3x-hifi",
693 + .codec_name = "tlv320aic3x-codec.0-0019",
694 + .platform_name = "gw_avila-audio.2",
695 + .init = avila_aic3x_init,
696 + .ops = &gw_avila_board_ops,
699 + .stream_name = "HSS-3",
700 + .cpu_dai_name = "gw_avila_hss.3",
701 + .codec_dai_name = "tlv320aic3x-hifi",
702 + .codec_name = "tlv320aic3x-codec.0-0018",
703 + .platform_name = "gw_avila-audio.3",
704 + .init = avila_aic3x_init,
705 + .ops = &gw_avila_board_ops,
709 +static struct snd_soc_card gw_avila_board[] = {
711 + .name = "gw_avila-board.0",
712 + .owner = THIS_MODULE,
713 + .dai_link = &gw_avila_board_dai[0],
716 + .name = "gw_avila-board.1",
717 + .owner = THIS_MODULE,
718 + .dai_link = &gw_avila_board_dai[1],
721 + .name = "gw_avila-board.2",
722 + .owner = THIS_MODULE,
723 + .dai_link = &gw_avila_board_dai[2],
726 + .name = "gw_avila-board.3",
727 + .owner = THIS_MODULE,
728 + .dai_link = &gw_avila_board_dai[3],
733 +static struct platform_device *gw_avila_board_snd_device[4];
735 +static int __init gw_avila_board_init(void)
741 + if ((hss_port[0] = kzalloc(sizeof(*port), GFP_KERNEL)) == NULL)
744 + if ((hss_port[1] = kzalloc(sizeof(*port), GFP_KERNEL)) == NULL)
747 + for (i = 0; i < 4; i++) {
748 + gw_avila_board_snd_device[i] = platform_device_alloc("soc-audio", i);
749 + if (!gw_avila_board_snd_device[i]) {
753 + platform_set_drvdata(gw_avila_board_snd_device[i], &gw_avila_board[i]);
754 + ret = platform_device_add(gw_avila_board_snd_device[i]);
757 + platform_device_put(gw_avila_board_snd_device[i]);
763 +static void __exit gw_avila_board_exit(void)
766 + for (i = 0; i < 4; i++)
767 + platform_device_unregister(gw_avila_board_snd_device[i]);
770 +module_init(gw_avila_board_init);
771 +module_exit(gw_avila_board_exit);
773 +/* Module information */
774 +MODULE_AUTHOR("Chris Lang");
775 +MODULE_DESCRIPTION("ALSA SoC HSS Audio gw_avila board");
776 +MODULE_LICENSE("GPL");
778 +++ b/sound/soc/gw-avila/ixp4xx_hss.c
781 + * Intel IXP4xx HSS (synchronous serial port) driver for Linux
783 + * Copyright (C) 2009 Chris Lang <clang@gateworks.com>
785 + * This program is free software; you can redistribute it and/or modify it
786 + * under the terms of version 2 of the GNU General Public License
787 + * as published by the Free Software Foundation.
790 +#include <linux/module.h>
791 +#include <linux/bitops.h>
792 +#include <linux/cdev.h>
793 +#include <linux/dma-mapping.h>
794 +#include <linux/dmapool.h>
795 +#include <linux/fs.h>
796 +#include <linux/io.h>
797 +#include <linux/kernel.h>
798 +#include <linux/platform_device.h>
799 +#include <linux/poll.h>
800 +#include <linux/slab.h>
801 +#include <linux/delay.h>
803 +#include <mach/npe.h>
804 +#include <mach/qmgr.h>
806 +#include "ixp4xx_hss.h"
808 +/*****************************************************************************
810 + ****************************************************************************/
812 +void hss_chan_read(unsigned long data);
813 +static char lock_init = 0;
814 +static spinlock_t npe_lock;
815 +static struct npe *npe;
817 +static const struct {
818 + int tx, txdone, rx, rxfree, chan;
819 +}queue_ids[2] = {{HSS0_PKT_TX0_QUEUE, HSS0_PKT_TXDONE_QUEUE, HSS0_PKT_RX_QUEUE,
820 + HSS0_PKT_RXFREE0_QUEUE, HSS0_CHL_RXTRIG_QUEUE},
821 + {HSS1_PKT_TX0_QUEUE, HSS1_PKT_TXDONE_QUEUE, HSS1_PKT_RX_QUEUE,
822 + HSS1_PKT_RXFREE0_QUEUE, HSS1_CHL_RXTRIG_QUEUE},
825 +struct port *hss_port[2];
826 +struct hss_device *hss_handle[32];
827 +EXPORT_SYMBOL(hss_handle);
829 +/*****************************************************************************
830 + * utility functions
831 + ****************************************************************************/
834 +static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt)
837 + for (i = 0; i < cnt; i++)
838 + dest[i] = swab32(src[i]);
842 +static inline unsigned int sub_offset(unsigned int a, unsigned int b,
843 + unsigned int modulo)
845 + return (modulo /* make sure the result >= 0 */ + a - b) % modulo;
848 +/*****************************************************************************
850 + ****************************************************************************/
852 +static void hss_config_load(struct port *port)
857 + memset(&msg, 0, sizeof(msg));
858 + msg.cmd = PORT_CONFIG_LOAD;
859 + msg.hss_port = port->id;
860 + if (npe_send_message(npe, &msg, "HSS_LOAD_CONFIG"))
862 + if (npe_recv_message(npe, &msg, "HSS_LOAD_CONFIG"))
865 + /* HSS_LOAD_CONFIG for port #1 returns port_id = #4 */
866 + if (msg.cmd != PORT_CONFIG_LOAD || msg.data32)
869 + /* HDLC may stop working without this */
870 + npe_recv_message(npe, &msg, "FLUSH_IT");
874 + printk(KERN_CRIT "HSS-%i: unable to reload HSS configuration\n",
879 +static void hss_config_set_pcr(struct port *port)
884 + memset(&msg, 0, sizeof(msg));
885 + msg.cmd = PORT_CONFIG_WRITE;
886 + msg.hss_port = port->id;
887 + msg.index = HSS_CONFIG_TX_PCR;
889 + msg.data32 = PCR_FRM_SYNC_RISINGEDGE | PCR_MSB_ENDIAN |
890 + PCR_TX_DATA_ENABLE | PCR_TX_UNASS_HIGH_IMP | PCR_TX_V56K_HIGH_IMP | PCR_TX_FB_HIGH_IMP;
892 + msg.data32 = PCR_FRM_SYNC_RISINGEDGE | PCR_MSB_ENDIAN |
893 + PCR_TX_DATA_ENABLE | PCR_TX_FB_HIGH_IMP | PCR_DCLK_EDGE_RISING;
895 + if (port->frame_size % 8 == 0)
896 + msg.data32 |= PCR_SOF_NO_FBIT;
898 + if (npe_send_message(npe, &msg, "HSS_SET_TX_PCR"))
901 + msg.index = HSS_CONFIG_RX_PCR;
902 + msg.data32 &= ~ (PCR_DCLK_EDGE_RISING | PCR_FCLK_EDGE_RISING | PCR_TX_DATA_ENABLE);
904 + if (npe_send_message(npe, &msg, "HSS_SET_RX_PCR"))
909 + printk(KERN_CRIT "HSS-%i: unable to set HSS PCR registers\n", port->id);
913 +static void hss_config_set_core(struct port *port)
917 + memset(&msg, 0, sizeof(msg));
918 + msg.cmd = PORT_CONFIG_WRITE;
919 + msg.hss_port = port->id;
920 + msg.index = HSS_CONFIG_CORE_CR;
922 + msg.data32 = 0 | CCR_LOOPBACK |
923 + (port->id ? CCR_SECOND_HSS : 0);
926 + (port->id ? CCR_SECOND_HSS : 0);
928 + if (npe_send_message(npe, &msg, "HSS_SET_CORE_CR")) {
929 + printk(KERN_CRIT "HSS-%i: unable to set HSS core control"
930 + " register\n", port->id);
935 +static void hss_config_set_line(struct port *port)
939 + hss_config_set_pcr(port);
940 + hss_config_set_core(port);
942 + memset(&msg, 0, sizeof(msg));
943 + msg.cmd = PORT_CONFIG_WRITE;
944 + msg.hss_port = port->id;
945 + msg.index = HSS_CONFIG_CLOCK_CR;
946 + msg.data32 = CLK42X_SPEED_8192KHZ /* FIXME */;
947 + if (npe_send_message(npe, &msg, "HSS_SET_CLOCK_CR")) {
948 + printk(KERN_CRIT "HSS-%i: unable to set HSS clock control"
949 + " register\n", port->id);
954 +static void hss_config_set_rx_frame(struct port *port)
958 + memset(&msg, 0, sizeof(msg));
959 + msg.cmd = PORT_CONFIG_WRITE;
960 + msg.hss_port = port->id;
961 + msg.index = HSS_CONFIG_RX_FCR;
962 + msg.data16a = port->frame_sync_offset;
963 + msg.data16b = port->frame_size - 1;
964 + if (npe_send_message(npe, &msg, "HSS_SET_RX_FCR")) {
965 + printk(KERN_CRIT "HSS-%i: unable to set HSS RX frame size"
966 + " and offset\n", port->id);
971 +static void hss_config_set_frame(struct port *port)
975 + memset(&msg, 0, sizeof(msg));
976 + msg.cmd = PORT_CONFIG_WRITE;
977 + msg.hss_port = port->id;
978 + msg.index = HSS_CONFIG_TX_FCR;
979 + msg.data16a = TX_FRAME_SYNC_OFFSET;
980 + msg.data16b = port->frame_size - 1;
981 + if (npe_send_message(npe, &msg, "HSS_SET_TX_FCR")) {
982 + printk(KERN_CRIT "HSS-%i: unable to set HSS TX frame size"
983 + " and offset\n", port->id);
986 + hss_config_set_rx_frame(port);
989 +static void hss_config_set_lut(struct port *port)
992 + int chan_count = 32;
994 + memset(&msg, 0, sizeof(msg));
995 + msg.cmd = PORT_CONFIG_WRITE;
996 + msg.hss_port = port->id;
998 + msg.index = HSS_CONFIG_TX_LUT;
999 + msg.data32 = 0xffffffff;
1000 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1002 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1005 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1007 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1009 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1011 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1013 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1015 + npe_send_message(npe, &msg, "HSS_SET_TX_LUT");
1017 + msg.index = HSS_CONFIG_RX_LUT;
1018 + msg.data32 = 0xffffffff;
1019 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1021 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1024 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1026 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1028 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1030 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1032 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1034 + npe_send_message(npe, &msg, "HSS_SET_RX_LUT");
1036 + hss_config_set_frame(port);
1038 + memset(&msg, 0, sizeof(msg));
1039 + msg.cmd = CHAN_NUM_CHANS_WRITE;
1040 + msg.hss_port = port->id;
1041 + msg.data8a = chan_count;
1042 + if (npe_send_message(npe, &msg, "CHAN_NUM_CHANS_WRITE")) {
1043 + printk(KERN_CRIT "HSS-%i: unable to set HSS channel count\n",
1049 +static u32 hss_config_get_status(struct port *port)
1054 + memset(&msg, 0, sizeof(msg));
1055 + msg.cmd = PORT_ERROR_READ;
1056 + msg.hss_port = port->id;
1057 + if (npe_send_message(npe, &msg, "PORT_ERROR_READ"))
1059 + if (npe_recv_message(npe, &msg, "PORT_ERROR_READ"))
1062 + return msg.data32;
1065 + printk(KERN_CRIT "HSS-%i: unable to read HSS status\n", port->id);
1069 +static void hss_config_start_chan(struct port *port)
1073 + port->chan_last_tx = 0;
1074 + port->chan_last_rx = 0;
1077 + memset(&msg, 0, sizeof(msg));
1078 + msg.cmd = CHAN_RX_BUF_ADDR_WRITE;
1079 + msg.hss_port = port->id;
1080 + msg.data32 = port->chan_rx_buf_phys;
1081 + if (npe_send_message(npe, &msg, "CHAN_RX_BUF_ADDR_WRITE"))
1084 + memset(&msg, 0, sizeof(msg));
1085 + msg.cmd = CHAN_TX_BUF_ADDR_WRITE;
1086 + msg.hss_port = port->id;
1087 + msg.data32 = port->chan_tx_pointers_phys;
1088 + if (npe_send_message(npe, &msg, "CHAN_TX_BUF_ADDR_WRITE"))
1091 + memset(&msg, 0, sizeof(msg));
1092 + msg.cmd = CHAN_FLOW_ENABLE;
1093 + msg.hss_port = port->id;
1094 + if (npe_send_message(npe, &msg, "CHAN_FLOW_ENABLE"))
1096 + port->chan_started = 1;
1100 + printk(KERN_CRIT "HSS-%i: unable to start channelized flow\n",
1105 +static void hss_config_stop_chan(struct port *port)
1109 + if (!port->chan_started)
1112 + memset(&msg, 0, sizeof(msg));
1113 + msg.cmd = CHAN_FLOW_DISABLE;
1114 + msg.hss_port = port->id;
1115 + if (npe_send_message(npe, &msg, "CHAN_FLOW_DISABLE")) {
1116 + printk(KERN_CRIT "HSS-%i: unable to stop channelized flow\n",
1120 + hss_config_get_status(port); /* make sure it's halted */
1121 + port->chan_started = 0;
1124 +static int hss_config_load_firmware(struct port *port)
1128 + if (port->initialized)
1131 + if (!npe_running(npe)) {
1133 + if ((err = npe_load_firmware(npe, "NPE-A-HSS",
1139 + /* HSS main configuration */
1140 + hss_config_set_line(port);
1142 + hss_config_set_frame(port);
1144 + /* Channelized operation settings */
1145 + memset(&msg, 0, sizeof(msg));
1146 + msg.cmd = CHAN_TX_BLK_CFG_WRITE;
1147 + msg.hss_port = port->id;
1148 + msg.data8b = (CHAN_TX_LIST_FRAMES & ~7) / 2;
1149 + msg.data8a = msg.data8b / 4;
1150 + msg.data8d = CHAN_TX_LIST_FRAMES - msg.data8b;
1151 + msg.data8c = msg.data8d / 4;
1152 + if (npe_send_message(npe, &msg, "CHAN_TX_BLK_CFG_WRITE"))
1155 + memset(&msg, 0, sizeof(msg));
1156 + msg.cmd = CHAN_RX_BUF_CFG_WRITE;
1157 + msg.hss_port = port->id;
1158 + msg.data8a = CHAN_RX_TRIGGER / 8;
1159 + msg.data8b = CHAN_RX_FRAMES;
1160 + if (npe_send_message(npe, &msg, "CHAN_RX_BUF_CFG_WRITE"))
1163 + memset(&msg, 0, sizeof(msg));
1164 + msg.cmd = CHAN_TX_BUF_SIZE_WRITE;
1165 + msg.hss_port = port->id;
1166 + msg.data8a = CHAN_TX_LISTS;
1167 + if (npe_send_message(npe, &msg, "CHAN_TX_BUF_SIZE_WRITE"))
1170 + port->initialized = 1;
1174 + printk(KERN_CRIT "HSS-%i: unable to start HSS operation\n", port->id);
1178 +void hss_chan_irq(void *pdev)
1180 + struct port *port = pdev;
1182 + qmgr_disable_irq(queue_ids[port->id].chan);
1184 + tasklet_hi_schedule(&port->task);
1188 +int hss_prepare_chan(struct port *port)
1195 + if (port->initialized)
1198 + if ((err = hss_config_load_firmware(port)))
1201 + if ((err = qmgr_request_queue(queue_ids[port->id].chan,
1202 + CHAN_QUEUE_LEN, 0, 0, "%s:hss", "hss")))
1205 + port->chan_tx_buf = dma_alloc_coherent(port->dev, chan_tx_buf_len(port), &port->chan_tx_buf_phys, GFP_DMA);
1206 + memset(port->chan_tx_buf, 0, chan_tx_buf_len(port));
1208 + port->chan_tx_pointers = dma_alloc_coherent(port->dev, chan_tx_buf_len(port) / CHAN_TX_LIST_FRAMES * 4, &port->chan_tx_pointers_phys, GFP_DMA);
1210 + temp3 = port->chan_tx_buf;
1211 + for (i = 0; i < CHAN_TX_LISTS; i++) {
1212 + for (j = 0; j < 8; j++) {
1213 + port->tx_lists[i][j] = temp3;
1214 + temp3 += CHAN_TX_LIST_FRAMES * 4;
1218 + temp = port->chan_tx_pointers;
1219 + temp2 = port->chan_tx_buf_phys;
1220 + for (i = 0; i < CHAN_TX_LISTS; i++)
1222 + for (j = 0; j < 32; j++)
1225 + temp2 += CHAN_TX_LIST_FRAMES;
1230 + port->chan_rx_buf = dma_alloc_coherent(port->dev, chan_rx_buf_len(port), &port->chan_rx_buf_phys, GFP_DMA);
1232 + for (i = 0; i < 8; i++) {
1233 + temp3 = port->chan_rx_buf + (i * 4 * 128);
1234 + for (j = 0; j < 8; j++) {
1235 + port->rx_frames[i][j] = temp3;
1236 + temp3 += CHAN_RX_TRIGGER;
1240 + qmgr_set_irq(queue_ids[port->id].chan, QUEUE_IRQ_SRC_NOT_EMPTY,
1241 + hss_chan_irq, port);
1247 +int hss_tx_start(struct hss_device *hdev)
1249 + unsigned long flags;
1250 + struct port *port = hdev->port;
1253 + hdev->tx_frame = 0;
1255 + set_bit((1 << hdev->id), &port->chan_tx_bitmap);
1257 + if (!port->chan_started)
1259 + qmgr_enable_irq(queue_ids[port->id].chan);
1260 + spin_lock_irqsave(&npe_lock, flags);
1261 + hss_config_start_chan(port);
1262 + spin_unlock_irqrestore(&npe_lock, flags);
1263 + hss_chan_irq(port);
1268 +EXPORT_SYMBOL(hss_tx_start);
1270 +int hss_rx_start(struct hss_device *hdev)
1272 + unsigned long flags;
1273 + struct port *port = hdev->port;
1276 + hdev->rx_frame = 0;
1278 + set_bit((1 << hdev->id), &port->chan_rx_bitmap);
1280 + if (!port->chan_started)
1282 + qmgr_enable_irq(queue_ids[port->id].chan);
1283 + spin_lock_irqsave(&npe_lock, flags);
1284 + hss_config_start_chan(port);
1285 + spin_unlock_irqrestore(&npe_lock, flags);
1286 + hss_chan_irq(port);
1291 +EXPORT_SYMBOL(hss_rx_start);
1293 +int hss_tx_stop(struct hss_device *hdev)
1295 + struct port *port = hdev->port;
1297 + clear_bit((1 << hdev->id), &port->chan_tx_bitmap);
1301 +EXPORT_SYMBOL(hss_tx_stop);
1303 +int hss_rx_stop(struct hss_device *hdev)
1305 + struct port *port = hdev->port;
1307 + clear_bit((1 << hdev->id), &port->chan_rx_bitmap);
1311 +EXPORT_SYMBOL(hss_rx_stop);
1313 +int hss_chan_open(struct hss_device *hdev)
1315 + struct port *port = hdev->port;
1318 + if (port->chan_open)
1321 + if (port->mode == MODE_HDLC) {
1326 + if (port->mode == MODE_G704 && port->channels[0] == hdev->id) {
1327 + err = -EBUSY; /* channel #0 is used for G.704 signaling */
1331 + for (i = MAX_CHANNELS; i > port->frame_size / 8; i--)
1332 + if (port->channels[i - 1] == hdev->id) {
1333 + err = -ECHRNG; /* frame too short */
1337 + hdev->rx_loc = hdev->tx_loc = 0;
1338 + hdev->rx_frame = hdev->tx_frame = 0;
1340 + //clear_bit((1 << hdev->id), &port->chan_rx_bitmap);
1341 + //clear_bit((1 << hdev->id), &port->chan_tx_bitmap);
1343 + if (!port->initialized) {
1344 + hss_prepare_chan(port);
1346 + hss_config_stop_chan(port);
1347 + hdev->open_count++;
1348 + port->chan_open_count++;
1350 + hss_config_set_lut(port);
1351 + hss_config_load(port);
1354 + port->chan_open = 1;
1359 +EXPORT_SYMBOL(hss_chan_open);
1361 +int hss_chan_close(struct hss_device *hdev)
1365 +EXPORT_SYMBOL(hss_chan_close);
1367 +void hss_chan_read(unsigned long data)
1369 + struct port *port = (void *)data;
1370 + struct hss_device *hdev;
1371 + u8 *hw_buf, *save_buf;
1374 + unsigned int tx_list, rx_frame;
1375 + int i, j, channel;
1379 + My Data in the hardware buffer is scattered by channels into 4 trunks
1382 + channel 0 channel 1 channel 2 channel 3
1383 +Trunk 1 = 0 -> 127 128 -> 255 256 -> 383 384 -> 512
1384 +Trunk 2 = 513 -> 639 640 -> 768 769 -> 895 896 -> 1023
1385 +Trunk 3 = 1024 -> 1151 1152 -> 1207 1208 -> 1407 1408 -> 1535
1386 +Trunk 4 = 1535 -> 1663 1664 -> 1791 1792 -> 1920 1921 -> 2047
1388 + I will get CHAN_RX_TRIGGER worth of bytes out of each channel on each trunk
1391 + For TX Data, it is split into 8 lists with each list containing 16 bytes per
1394 +Trunk 1 = 0 -> 16 17 -> 32 33 -> 48 49 -> 64
1395 +Trunk 2 = 65 -> 80 81 -> 96 97 -> 112 113 -> 128
1396 +Trunk 3 = 129 -> 144 145 -> 160 161 -> 176 177 -> 192
1397 +Trunk 4 = 193 -> 208 209 -> 224 225 -> 240 241 -> 256
1402 + while ((v = qmgr_get_entry(queue_ids[port->id].chan)))
1404 + tx_list = (v >> 8) & 0xFF;
1405 + rx_frame = v & 0xFF;
1411 + for (channel = 0; channel < 8; channel++) {
1413 + hdev = port->chan_devices[channel];
1417 + if (test_bit(1 << channel, &port->chan_tx_bitmap)) {
1418 + buf = (u8 *)hdev->tx_buf + hdev->tx_loc;
1420 + hw_buf = (u8 *)port->chan_tx_buf;
1421 + hw_buf += (tx_list * CHAN_TX_LIST_FRAMES * 32);
1422 + hw_buf += (4 * CHAN_TX_LIST_FRAMES * channel);
1423 + save_buf = hw_buf;
1425 + save_buf = port->tx_lists[tx_list][channel];
1427 + for (i = 0; i < CHAN_TX_LIST_FRAMES; i++) {
1428 + hw_buf = save_buf + i;
1429 + for (j = 0; j < 4; j++) {
1430 + *hw_buf = *(buf++);
1431 + hw_buf += CHAN_TX_LIST_FRAMES;
1434 + hdev->tx_loc += 4;
1436 + if (hdev->tx_loc >= hdev->tx_buffer_size) {
1438 + buf = (u8 *)hdev->tx_buf;
1443 + hw_buf = (u8 *)port->chan_tx_buf;
1444 + hw_buf += (tx_list * CHAN_TX_LIST_FRAMES * 32);
1445 + hw_buf += (4 * CHAN_TX_LIST_FRAMES * channel);
1447 + hw_buf = port->tx_lists[tx_list][channel];
1449 + memset(hw_buf, 0, 64);
1452 + if (hdev->tx_frame >= hdev->tx_period_size && test_bit(1 << channel, &port->chan_tx_bitmap))
1454 + hdev->tx_frame %= hdev->tx_period_size;
1455 + if (hdev->tx_callback)
1456 + hdev->tx_callback(hdev->tx_data);
1460 + if (test_bit(1 << channel, &port->chan_rx_bitmap)) {
1461 + buf = (u8 *)hdev->rx_buf + hdev->rx_loc;
1463 + hw_buf = (u8 *)port->chan_rx_buf;
1464 + hw_buf += (4 * CHAN_RX_FRAMES * channel);
1465 + hw_buf += rx_frame;
1466 + save_buf = hw_buf;
1468 + save_buf = port->rx_frames[channel][rx_frame >> 4];
1470 + for (i = 0; i < CHAN_RX_TRIGGER; i++) {
1471 + hw_buf = save_buf + i;
1472 + for (j = 0; j < 4; j++) {
1473 + *(buf++) = *hw_buf;
1474 + hw_buf += CHAN_RX_FRAMES;
1476 + hdev->rx_loc += 4;
1478 + if (hdev->rx_loc >= hdev->rx_buffer_size) {
1480 + buf = (u8 *)hdev->rx_buf;
1485 + if (hdev->rx_frame >= hdev->rx_period_size && test_bit(1 << channel, &port->chan_rx_bitmap))
1487 + hdev->rx_frame %= hdev->rx_period_size;
1488 + if (hdev->rx_callback)
1489 + hdev->rx_callback(hdev->rx_data);
1496 + tasklet_hi_schedule(&port->task);
1502 + qmgr_enable_irq(queue_ids[port->id].chan);
1508 +struct hss_device *hss_chan_create(struct port *port, unsigned int channel)
1510 + struct hss_device *chan_dev;
1511 + unsigned long flags;
1513 + chan_dev = kzalloc(sizeof(struct hss_device), GFP_KERNEL);
1515 + spin_lock_irqsave(&npe_lock, flags);
1517 + chan_dev->id = channel;
1518 + chan_dev->port = port;
1520 + port->channels[channel] = channel;
1522 + port->chan_devices[channel] = chan_dev;
1524 + spin_unlock_irqrestore(&npe_lock, flags);
1529 +/*****************************************************************************
1531 + ****************************************************************************/
1533 +static struct platform_device gw_avila_hss_device_0 = {
1534 + .name = "ixp4xx_hss",
1538 +static struct platform_device gw_avila_hss_device_1 = {
1539 + .name = "ixp4xx_hss",
1543 +static struct platform_device *gw_avila_hss_port_0;
1544 +static struct platform_device *gw_avila_hss_port_1;
1545 +static u64 hss_dmamask = 0xFFFFFFFF;
1547 +struct hss_device *hss_init(int id, int channel)
1549 + struct port *port = hss_port[id];
1550 + struct hss_device *hdev;
1555 + spin_lock_init(&npe_lock);
1557 + npe = npe_request(0);
1560 + if (!port->init) {
1562 + gw_avila_hss_port_0 = platform_device_alloc("hss-port", 0);
1564 + platform_set_drvdata(gw_avila_hss_port_0, &gw_avila_hss_device_0);
1565 + port->dev = &gw_avila_hss_port_0->dev;
1567 + if (!port->dev->dma_mask)
1568 + port->dev->dma_mask = &hss_dmamask;
1569 + if (!port->dev->coherent_dma_mask)
1570 + port->dev->coherent_dma_mask = 0xFFFFFFFF;
1572 + ret = platform_device_add(gw_avila_hss_port_0);
1575 + platform_device_put(gw_avila_hss_port_0);
1577 + tasklet_init(&port->task, hss_chan_read, (unsigned long) port);
1581 + gw_avila_hss_port_1 = platform_device_alloc("hss-port", 1);
1583 + platform_set_drvdata(gw_avila_hss_port_1, &gw_avila_hss_device_1);
1584 + port->dev = &gw_avila_hss_port_1->dev;
1586 + if (!port->dev->dma_mask)
1587 + port->dev->dma_mask = &hss_dmamask;
1588 + if (!port->dev->coherent_dma_mask)
1589 + port->dev->coherent_dma_mask = 0xFFFFFFFF;
1591 + ret = platform_device_add(gw_avila_hss_port_1);
1594 + platform_device_put(gw_avila_hss_port_1);
1596 + tasklet_init(&port->task, hss_chan_read, (unsigned long) port);
1601 + port->clock_type = CLOCK_EXT;
1602 + port->clock_rate = 8192000;
1603 + port->frame_size = 256; /* E1 */
1604 + port->mode = MODE_RAW;
1605 + port->next_rx_frame = 0;
1606 + memset(port->channels, CHANNEL_UNUSED, sizeof(port->channels));
1609 + hdev = hss_chan_create(port, channel);
1613 +EXPORT_SYMBOL(hss_init);
1615 +int hss_set_tx_callback(struct hss_device *hdev, void (*tx_callback)(void *), void *tx_data)
1617 + BUG_ON(tx_callback == NULL);
1618 + hdev->tx_callback = tx_callback;
1619 + hdev->tx_data = tx_data;
1623 +EXPORT_SYMBOL(hss_set_tx_callback);
1625 +int hss_set_rx_callback(struct hss_device *hdev, void (*rx_callback)(void *), void *rx_data)
1627 + BUG_ON(rx_callback == NULL);
1628 + hdev->rx_callback = rx_callback;
1629 + hdev->rx_data = rx_data;
1633 +EXPORT_SYMBOL(hss_set_rx_callback);
1635 +int hss_config_rx_dma(struct hss_device *hdev, void *buf, size_t buffer_size, size_t period_size)
1638 + * Period Size and Buffer Size are in Frames which are u32
1639 + * We convert the u32 *buf to u8 in order to make channel reads
1640 + * and rx_loc easier
1643 + hdev->rx_buf = (u8 *)buf;
1644 + hdev->rx_buffer_size = buffer_size << 2;
1645 + hdev->rx_period_size = period_size;
1649 +EXPORT_SYMBOL(hss_config_rx_dma);
1651 +int hss_config_tx_dma(struct hss_device *hdev, void *buf, size_t buffer_size, size_t period_size)
1654 + * Period Size and Buffer Size are in Frames which are u32
1655 + * We convert the u32 *buf to u8 in order to make channel reads
1656 + * and rx_loc easier
1659 + hdev->tx_buf = (u8 *)buf;
1660 + hdev->tx_buffer_size = buffer_size << 2;
1661 + hdev->tx_period_size = period_size;
1665 +EXPORT_SYMBOL(hss_config_tx_dma);
1667 +unsigned long hss_curr_offset_rx(struct hss_device *hdev)
1669 + return hdev->rx_loc >> 2;
1671 +EXPORT_SYMBOL(hss_curr_offset_rx);
1673 +unsigned long hss_curr_offset_tx(struct hss_device *hdev)
1675 + return hdev->tx_loc >> 2;
1677 +EXPORT_SYMBOL(hss_curr_offset_tx);
1679 +MODULE_AUTHOR("Chris Lang");
1680 +MODULE_DESCRIPTION("Intel IXP4xx HSS Audio driver");
1681 +MODULE_LICENSE("GPL v2");
1683 +++ b/sound/soc/gw-avila/ixp4xx_hss.h
1688 + * Copyright (C) 2009 Gateworks Corporation
1690 + * This program is free software; you can redistribute it and/or modify it
1691 + * under the terms of version 2 of the GNU General Public License
1692 + * as published by the Free Software Foundation.
1695 +#include <linux/types.h>
1696 +#include <linux/bitops.h>
1697 +#include <linux/dma-mapping.h>
1698 +#include <linux/dmapool.h>
1699 +#include <linux/fs.h>
1700 +#include <linux/io.h>
1701 +#include <linux/kernel.h>
1702 +#include <linux/platform_device.h>
1703 +#include <linux/poll.h>
1704 +#include <mach/npe.h>
1705 +#include <mach/qmgr.h>
1706 +#include <linux/interrupt.h>
1708 +//#include <linux/hdlc.h> XXX We aren't HDLC
1710 +#define DEBUG_QUEUES 0
1711 +#define DEBUG_DESC 0
1714 +#define DEBUG_PKT_BYTES 0
1715 +#define DEBUG_CLOSE 0
1716 +#define DEBUG_FRAMER 0
1718 +#define DRV_NAME "ixp4xx_hss"
1720 +#define PKT_EXTRA_FLAGS 0 /* orig 1 */
1721 +#define TX_FRAME_SYNC_OFFSET 0 /* channelized */
1722 +#define PKT_NUM_PIPES 1 /* 1, 2 or 4 */
1723 +#define PKT_PIPE_FIFO_SIZEW 4 /* total 4 dwords per HSS */
1725 +#define RX_DESCS 512 /* also length of all RX queues */
1726 +#define TX_DESCS 512 /* also length of all TX queues */
1728 +//#define POOL_ALLOC_SIZE (sizeof(struct desc) * (RX_DESCS + TX_DESCS))
1729 +#define RX_SIZE (HDLC_MAX_MRU + 4) /* NPE needs more space */
1730 +#define MAX_CLOSE_WAIT 1000 /* microseconds */
1731 +#define HSS_COUNT 2
1732 +#define MIN_FRAME_SIZE 16 /* bits */
1733 +#define MAX_FRAME_SIZE 257 /* 256 bits + framing bit */
1734 +#define MAX_CHANNELS (MAX_FRAME_SIZE / 8)
1735 +#define MAX_CHAN_DEVICES 32
1736 +#define CHANNEL_HDLC 0xFE
1737 +#define CHANNEL_UNUSED 0xFF
1739 +#define NAPI_WEIGHT 16
1740 +#define CHAN_RX_TRIGGER 16 /* 8 RX frames = 1 ms @ E1 */
1741 +#define CHAN_RX_FRAMES 128
1742 +#define CHAN_RX_TRUNKS 1
1743 +#define MAX_CHAN_RX_BAD_SYNC (CHAN_RX_TRIGGER / 2 /* pairs */ - 3)
1745 +#define CHAN_TX_LIST_FRAMES CHAN_RX_TRIGGER /* bytes/channel per list, 16 - 48 */
1746 +#define CHAN_TX_LISTS 8
1747 +#define CHAN_TX_TRUNKS CHAN_RX_TRUNKS
1748 +#define CHAN_TX_FRAMES (CHAN_TX_LIST_FRAMES * CHAN_TX_LISTS)
1750 +#define CHAN_QUEUE_LEN 32 /* minimum possible */
1752 +#define chan_rx_buf_len(port) (port->frame_size / 8 * CHAN_RX_FRAMES * CHAN_RX_TRUNKS)
1753 +#define chan_tx_buf_len(port) (port->frame_size / 8 * CHAN_TX_FRAMES * CHAN_TX_TRUNKS)
1756 +#define HSS0_CHL_RXTRIG_QUEUE 12 /* orig size = 32 dwords */
1757 +#define HSS0_PKT_RX_QUEUE 13 /* orig size = 32 dwords */
1758 +#define HSS0_PKT_TX0_QUEUE 14 /* orig size = 16 dwords */
1759 +#define HSS0_PKT_TX1_QUEUE 15
1760 +#define HSS0_PKT_TX2_QUEUE 16
1761 +#define HSS0_PKT_TX3_QUEUE 17
1762 +#define HSS0_PKT_RXFREE0_QUEUE 18 /* orig size = 16 dwords */
1763 +#define HSS0_PKT_RXFREE1_QUEUE 19
1764 +#define HSS0_PKT_RXFREE2_QUEUE 20
1765 +#define HSS0_PKT_RXFREE3_QUEUE 21
1766 +#define HSS0_PKT_TXDONE_QUEUE 22 /* orig size = 64 dwords */
1768 +#define HSS1_CHL_RXTRIG_QUEUE 10
1769 +#define HSS1_PKT_RX_QUEUE 0
1770 +#define HSS1_PKT_TX0_QUEUE 5
1771 +#define HSS1_PKT_TX1_QUEUE 6
1772 +#define HSS1_PKT_TX2_QUEUE 7
1773 +#define HSS1_PKT_TX3_QUEUE 8
1774 +#define HSS1_PKT_RXFREE0_QUEUE 1
1775 +#define HSS1_PKT_RXFREE1_QUEUE 2
1776 +#define HSS1_PKT_RXFREE2_QUEUE 3
1777 +#define HSS1_PKT_RXFREE3_QUEUE 4
1778 +#define HSS1_PKT_TXDONE_QUEUE 9
1780 +#define NPE_PKT_MODE_HDLC 0
1781 +#define NPE_PKT_MODE_RAW 1
1782 +#define NPE_PKT_MODE_56KMODE 2
1783 +#define NPE_PKT_MODE_56KENDIAN_MSB 4
1785 +/* PKT_PIPE_HDLC_CFG_WRITE flags */
1786 +#define PKT_HDLC_IDLE_ONES 0x1 /* default = flags */
1787 +#define PKT_HDLC_CRC_32 0x2 /* default = CRC-16 */
1788 +#define PKT_HDLC_MSB_ENDIAN 0x4 /* default = LE */
1791 +/* hss_config, PCRs */
1792 +/* Frame sync sampling, default = active low */
1793 +#define PCR_FRM_SYNC_ACTIVE_HIGH 0x40000000
1794 +#define PCR_FRM_SYNC_FALLINGEDGE 0x80000000
1795 +#define PCR_FRM_SYNC_RISINGEDGE 0xC0000000
1797 +/* Frame sync pin: input (default) or output generated off a given clk edge */
1798 +#define PCR_FRM_SYNC_OUTPUT_FALLING 0x20000000
1799 +#define PCR_FRM_SYNC_OUTPUT_RISING 0x30000000
1801 +/* Frame and data clock sampling on edge, default = falling */
1802 +#define PCR_FCLK_EDGE_RISING 0x08000000
1803 +#define PCR_DCLK_EDGE_RISING 0x04000000
1805 +/* Clock direction, default = input */
1806 +#define PCR_SYNC_CLK_DIR_OUTPUT 0x02000000
1808 +/* Generate/Receive frame pulses, default = enabled */
1809 +#define PCR_FRM_PULSE_DISABLED 0x01000000
1811 + /* Data rate is full (default) or half the configured clk speed */
1812 +#define PCR_HALF_CLK_RATE 0x00200000
1814 +/* Invert data between NPE and HSS FIFOs? (default = no) */
1815 +#define PCR_DATA_POLARITY_INVERT 0x00100000
1817 +/* TX/RX endianness, default = LSB */
1818 +#define PCR_MSB_ENDIAN 0x00080000
1820 +/* Normal (default) / open drain mode (TX only) */
1821 +#define PCR_TX_PINS_OPEN_DRAIN 0x00040000
1823 +/* No framing bit transmitted and expected on RX? (default = framing bit) */
1824 +#define PCR_SOF_NO_FBIT 0x00020000
1826 +/* Drive data pins? */
1827 +#define PCR_TX_DATA_ENABLE 0x00010000
1829 +/* Voice 56k type: drive the data pins low (default), high, high Z */
1830 +#define PCR_TX_V56K_HIGH 0x00002000
1831 +#define PCR_TX_V56K_HIGH_IMP 0x00004000
1833 +/* Unassigned type: drive the data pins low (default), high, high Z */
1834 +#define PCR_TX_UNASS_HIGH 0x00000800
1835 +#define PCR_TX_UNASS_HIGH_IMP 0x00001000
1837 +/* T1 @ 1.544MHz only: Fbit dictated in FIFO (default) or high Z */
1838 +#define PCR_TX_FB_HIGH_IMP 0x00000400
1840 +/* 56k data endiannes - which bit unused: high (default) or low */
1841 +#define PCR_TX_56KE_BIT_0_UNUSED 0x00000200
1843 +/* 56k data transmission type: 32/8 bit data (default) or 56K data */
1844 +#define PCR_TX_56KS_56K_DATA 0x00000100
1846 +/* hss_config, cCR */
1847 +/* Number of packetized clients, default = 1 */
1848 +#define CCR_NPE_HFIFO_2_HDLC 0x04000000
1849 +#define CCR_NPE_HFIFO_3_OR_4HDLC 0x08000000
1851 +/* default = no loopback */
1852 +#define CCR_LOOPBACK 0x02000000
1854 +/* HSS number, default = 0 (first) */
1855 +#define CCR_SECOND_HSS 0x01000000
1858 +/* hss_config, clkCR: main:10, num:10, denom:12 */
1859 +#define CLK42X_SPEED_EXP ((0x3FF << 22) | ( 2 << 12) | 15) /*65 KHz*/
1861 +#define CLK42X_SPEED_512KHZ (( 130 << 22) | ( 2 << 12) | 15)
1862 +#define CLK42X_SPEED_1536KHZ (( 43 << 22) | ( 18 << 12) | 47)
1863 +#define CLK42X_SPEED_1544KHZ (( 43 << 22) | ( 33 << 12) | 192)
1864 +#define CLK42X_SPEED_2048KHZ (( 32 << 22) | ( 34 << 12) | 63)
1865 +#define CLK42X_SPEED_4096KHZ (( 16 << 22) | ( 34 << 12) | 127)
1866 +#define CLK42X_SPEED_8192KHZ (( 8 << 22) | ( 34 << 12) | 255)
1868 +#define CLK46X_SPEED_512KHZ (( 130 << 22) | ( 24 << 12) | 127)
1869 +#define CLK46X_SPEED_1536KHZ (( 43 << 22) | (152 << 12) | 383)
1870 +#define CLK46X_SPEED_1544KHZ (( 43 << 22) | ( 66 << 12) | 385)
1871 +#define CLK46X_SPEED_2048KHZ (( 32 << 22) | (280 << 12) | 511)
1872 +#define CLK46X_SPEED_4096KHZ (( 16 << 22) | (280 << 12) | 1023)
1873 +#define CLK46X_SPEED_8192KHZ (( 8 << 22) | (280 << 12) | 2047)
1876 +/* hss_config, LUT entries */
1877 +#define TDMMAP_UNASSIGNED 0
1878 +#define TDMMAP_HDLC 1 /* HDLC - packetized */
1879 +#define TDMMAP_VOICE56K 2 /* Voice56K - 7-bit channelized */
1880 +#define TDMMAP_VOICE64K 3 /* Voice64K - 8-bit channelized */
1882 +/* offsets into HSS config */
1883 +#define HSS_CONFIG_TX_PCR 0x00 /* port configuration registers */
1884 +#define HSS_CONFIG_RX_PCR 0x04
1885 +#define HSS_CONFIG_CORE_CR 0x08 /* loopback control, HSS# */
1886 +#define HSS_CONFIG_CLOCK_CR 0x0C /* clock generator control */
1887 +#define HSS_CONFIG_TX_FCR 0x10 /* frame configuration registers */
1888 +#define HSS_CONFIG_RX_FCR 0x14
1889 +#define HSS_CONFIG_TX_LUT 0x18 /* channel look-up tables */
1890 +#define HSS_CONFIG_RX_LUT 0x38
1893 +/* NPE command codes */
1894 +/* writes the ConfigWord value to the location specified by offset */
1895 +#define PORT_CONFIG_WRITE 0x40
1897 +/* triggers the NPE to load the contents of the configuration table */
1898 +#define PORT_CONFIG_LOAD 0x41
1900 +/* triggers the NPE to return an HssErrorReadResponse message */
1901 +#define PORT_ERROR_READ 0x42
1903 +/* reset NPE internal status and enable the HssChannelized operation */
1904 +#define CHAN_FLOW_ENABLE 0x43
1905 +#define CHAN_FLOW_DISABLE 0x44
1906 +#define CHAN_IDLE_PATTERN_WRITE 0x45
1907 +#define CHAN_NUM_CHANS_WRITE 0x46
1908 +#define CHAN_RX_BUF_ADDR_WRITE 0x47
1909 +#define CHAN_RX_BUF_CFG_WRITE 0x48
1910 +#define CHAN_TX_BLK_CFG_WRITE 0x49
1911 +#define CHAN_TX_BUF_ADDR_WRITE 0x4A
1912 +#define CHAN_TX_BUF_SIZE_WRITE 0x4B
1913 +#define CHAN_TSLOTSWITCH_ENABLE 0x4C
1914 +#define CHAN_TSLOTSWITCH_DISABLE 0x4D
1916 +/* downloads the gainWord value for a timeslot switching channel associated
1918 +#define CHAN_TSLOTSWITCH_GCT_DOWNLOAD 0x4E
1920 +/* triggers the NPE to reset internal status and enable the HssPacketized
1921 + operation for the flow specified by pPipe */
1922 +#define PKT_PIPE_FLOW_ENABLE 0x50
1923 +#define PKT_PIPE_FLOW_DISABLE 0x51
1924 +#define PKT_NUM_PIPES_WRITE 0x52
1925 +#define PKT_PIPE_FIFO_SIZEW_WRITE 0x53
1926 +#define PKT_PIPE_HDLC_CFG_WRITE 0x54
1927 +#define PKT_PIPE_IDLE_PATTERN_WRITE 0x55
1928 +#define PKT_PIPE_RX_SIZE_WRITE 0x56
1929 +#define PKT_PIPE_MODE_WRITE 0x57
1931 +/* HDLC packet status values - desc->status */
1932 +#define ERR_SHUTDOWN 1 /* stop or shutdown occurrance */
1933 +#define ERR_HDLC_ALIGN 2 /* HDLC alignment error */
1934 +#define ERR_HDLC_FCS 3 /* HDLC Frame Check Sum error */
1935 +#define ERR_RXFREE_Q_EMPTY 4 /* RX-free queue became empty while receiving
1936 + this packet (if buf_len < pkt_len) */
1937 +#define ERR_HDLC_TOO_LONG 5 /* HDLC frame size too long */
1938 +#define ERR_HDLC_ABORT 6 /* abort sequence received */
1939 +#define ERR_DISCONNECTING 7 /* disconnect is in progress */
1941 +#define CLOCK_EXT 0
1942 +#define CLOCK_INT 1
1944 +enum mode {MODE_HDLC = 0, MODE_RAW, MODE_G704};
1950 + CHAN_0 = (1 << 0),
1951 + CHAN_1 = (1 << 1),
1952 + CHAN_2 = (1 << 2),
1953 + CHAN_3 = (1 << 3),
1954 + CHAN_4 = (1 << 4),
1955 + CHAN_5 = (1 << 5),
1956 + CHAN_6 = (1 << 6),
1957 + CHAN_7 = (1 << 7),
1958 + CHAN_8 = (1 << 8),
1959 + CHAN_9 = (1 << 9),
1960 + CHAN_10 = (1 << 10),
1961 + CHAN_11 = (1 << 11),
1962 + CHAN_12 = (1 << 12),
1963 + CHAN_13 = (1 << 13),
1964 + CHAN_14 = (1 << 14),
1965 + CHAN_15 = (1 << 15)
1968 +enum alignment { NOT_ALIGNED = 0, EVEN_FIRST, ODD_FIRST };
1971 +typedef struct sk_buff buffer_t;
1972 +#define free_buffer dev_kfree_skb
1973 +#define free_buffer_irq dev_kfree_skb_irq
1975 +typedef void buffer_t;
1976 +#define free_buffer kfree
1977 +#define free_buffer_irq kfree
1980 +struct hss_device {
1981 + struct port *port;
1982 + unsigned int open_count, excl_open;
1983 + unsigned long tx_loc, rx_loc; /* bytes */
1984 + unsigned long tx_frame, rx_frame; /* Frames */
1985 + u8 id, chan_count;
1986 + u8 log_channels[MAX_CHANNELS];
1991 + size_t rx_buffer_size;
1992 + size_t rx_period_size;
1993 + size_t tx_buffer_size;
1994 + size_t tx_period_size;
1996 + void (*rx_callback)(void *data);
1998 + void (*tx_callback)(void *data);
2000 + void *private_data;
2003 +extern struct hss_device *hss_handle[32];
2004 +extern struct port *hss_port[2];
2007 + unsigned char init;
2009 + struct device *dev;
2011 + struct tasklet_struct task;
2013 + unsigned long chan_rx_bitmap;
2014 + unsigned long chan_tx_bitmap;
2015 + unsigned char chan_open;
2017 + /* the following fields must be protected by npe_lock */
2019 + unsigned int clock_type, clock_rate, loopback;
2020 + unsigned int frame_size, frame_sync_offset;
2021 + unsigned int next_rx_frame;
2023 + struct hss_device *chan_devices[MAX_CHAN_DEVICES];
2024 + u32 chan_tx_buf_phys, chan_rx_buf_phys;
2025 + u32 chan_tx_pointers_phys;
2026 + u32 *chan_tx_pointers;
2029 + u8 *tx_lists[CHAN_TX_LISTS][8];
2030 + u8 *rx_frames[8][CHAN_TX_LISTS];
2031 + unsigned int chan_open_count, hdlc_open;
2032 + unsigned int chan_started, initialized, just_set_offset;
2033 + unsigned int chan_last_rx, chan_last_tx;
2035 + /* assigned channels, may be invalid with given frame length or mode */
2036 + u8 channels[MAX_CHANNELS];
2040 +/* NPE message structure */
2043 + u8 cmd, unused, hss_port, index;
2045 + struct { u8 data8a, data8b, data8c, data8d; };
2046 + struct { u16 data16a, data16b; };
2047 + struct { u32 data32; };
2050 + u8 index, hss_port, unused, cmd;
2052 + struct { u8 data8d, data8c, data8b, data8a; };
2053 + struct { u16 data16b, data16a; };
2054 + struct { u32 data32; };
2059 +#define rx_desc_phys(port, n) ((port)->desc_tab_phys + \
2060 + (n) * sizeof(struct desc))
2061 +#define rx_desc_ptr(port, n) (&(port)->desc_tab[n])
2063 +#define tx_desc_phys(port, n) ((port)->desc_tab_phys + \
2064 + ((n) + RX_DESCS) * sizeof(struct desc))
2065 +#define tx_desc_ptr(port, n) (&(port)->desc_tab[(n) + RX_DESCS])
2067 +int hss_prepare_chan(struct port *port);
2068 +void hss_chan_stop(struct port *port);
2070 +struct hss_device *hss_init(int id, int channel);
2071 +int hss_chan_open(struct hss_device *hdev);
2072 +int hss_chan_close(struct hss_device *hdev);
2074 +int hss_set_tx_callback(struct hss_device *hdev, void (*tx_callback)(void *), void *tx_data);
2075 +int hss_set_rx_callback(struct hss_device *hdev, void (*rx_callback)(void *), void *rx_data);
2076 +int hss_tx_start(struct hss_device *hdev);
2077 +int hss_tx_stop(struct hss_device *hdev);
2078 +int hss_rx_start(struct hss_device *hdev);
2079 +int hss_rx_stop(struct hss_device *hdev);
2081 +int hss_config_rx_dma(struct hss_device *hdev, void *buf, size_t buffer_size, size_t period_size);
2082 +int hss_config_tx_dma(struct hss_device *hdev, void *buf, size_t buffer_size, size_t period_size);
2083 +unsigned long hss_curr_offset_rx(struct hss_device *hdev);
2084 +unsigned long hss_curr_offset_tx(struct hss_device *hdev);