From nobody Mon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Date: Fri Apr 28 15:30:44 2006 +0200
Subject: [PATCH] at73c213 ALSA driver
This driver uses the SSC and SPI modules to communicate with an at73c213
sound chip on the AT32STK1000.
---
sound/avr32/Kconfig | 20
sound/avr32/Makefile | 3
sound/avr32/at73c213.c | 1296 +++++++++++++++++++++++++++++++++++++++++++++++++
sound/avr32/at73c213.h | 120 ++++
4 files changed, 1439 insertions(+)
create mode 100644 sound/avr32/at73c213.c
create mode 100644 sound/avr32/at73c213.h
859730d5cbe00b7935c4e30d179c5c5b096deb3c
Index: linux-2.6.18-avr32/sound/avr32/Kconfig
===================================================================
--- linux-2.6.18-avr32.orig/sound/avr32/Kconfig 2006-11-02 15:56:20.000000000 +0100
+++ linux-2.6.18-avr32/sound/avr32/Kconfig 2006-11-02 15:56:20.000000000 +0100
@@ -28,4 +28,24 @@ config SND_ATMEL_AC97C_USE_PDC
Say Y if PDC (Peripheral DMA Controller) is used for DMA transfers
to/from the Atmel AC97C instead of using the generic DMA framework.
+config SND_AT73C213
+ tristate "Atmel AT73C213 DAC driver"
+ depends on SND && SPI_ATMEL
+ select SND_PCM
+ help
+ Say Y here if you want to use the Atmel AT73C213 external
+ DAC on the ATSTK1000 development board.
+
+ To compile this driver as a module, choose M here: the
+ module will be called snd-at73c213.
+
+config SND_AT73C213_USE_ALSA_MALLOC_CALLS
+ bool "Use the built-in malloc calls in the alsa driver"
+ default n
+ depends on SND_AT73C213
+ help
+ Say Y if the built-in malloc calls in the alsa driver should be
+ used instead of the native dma_alloc_coherent and dma_free_coherent
+ function calls. Enabling this feature may brake the rmmod feature.
+
endmenu
Index: linux-2.6.18-avr32/sound/avr32/Makefile
===================================================================
--- linux-2.6.18-avr32.orig/sound/avr32/Makefile 2006-11-02 15:56:20.000000000 +0100
+++ linux-2.6.18-avr32/sound/avr32/Makefile 2006-11-02 15:56:20.000000000 +0100
@@ -4,3 +4,6 @@
snd-atmel-ac97-objs := ac97c.o
obj-$(CONFIG_SND_ATMEL_AC97) += snd-atmel-ac97.o
+
+snd-at73c213-objs := at73c213.o
+obj-$(CONFIG_SND_AT73C213) += snd-at73c213.o
Index: linux-2.6.18-avr32/sound/avr32/at73c213.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.18-avr32/sound/avr32/at73c213.c 2006-11-02 16:01:55.000000000 +0100
@@ -0,0 +1,1296 @@
+/*
+ * Driver for the at73c213 16-bit stereo DAC on Atmel ATSTK1000
+ *
+ * Copyright (C) 2006 Atmel Norway
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this
+ * distribution in the file called COPYING.
+ */
+#undef DEBUG
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kmod.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <sound/initval.h>
+#include <sound/driver.h>
+#include <sound/control.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#ifndef SND_AT73C213_USE_ALSA_MALLOC_CALLS
+#include <sound/memalloc.h>
+#endif
+
+#include <linux/spi/spi.h>
+
+#include <asm/io.h>
+#include <asm/processor.h>
+
+#include "at73c213.h"
+
+/* module parameters */
+static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
+static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
+static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
+
+/* Register defines */
+#define PIOA_BASE 0xFFE02800
+#define SSC0_BASE 0xFFE01C00
+#define PM_BASE 0xFFF00000
+
+#define PM_CKSEL 0x04
+#define PM_APBAMASK 0x10
+#define PM_GCCTRL 0x60
+
+#define PIO_PER 0x00
+#define PIO_PDR 0x04
+#define PIO_PUER 0x64
+#define PIO_ASR 0x70
+#define PIO_BSR 0x74
+
+#define SSC_CMR 0x04
+#define SSC_CR 0x00
+#define SSC_TCMR 0x18
+#define SSC_TFMR 0x1C
+
+/* SSC register definitions */
+#define SSC_CR 0x00
+#define SSC_CMR 0x04
+#define SSC_TCMR 0x18
+#define SSC_TFMR 0x1C
+#define SSC_THR 0x24
+#define SSC_SR 0x40
+#define SSC_IER 0x44
+#define SSC_IDR 0x48
+#define SSC_IMR 0x4C
+
+/* SSC fields definitions */
+#define SSC_CR_TXEN 0x00000100
+#define SSC_CR_TXDIS 0x00000200
+#define SSC_CR_SWRST 0x00008000
+
+/* SSC interrupt definitions */
+#define SSC0_IRQ 10
+#define SSC_INT_ENDTX 0x00000004
+#define SSC_INT_TXBUFE 0x00000008
+
+/* PDC register definitions */
+#define PDC_RPR 0x100
+#define PDC_RCR 0x104
+#define PDC_TPR 0x108
+#define PDC_TCR 0x10c
+#define PDC_RNPR 0x110
+#define PDC_RNCR 0x114
+#define PDC_TNPR 0x118
+#define PDC_TNCR 0x11c
+#define PDC_PTCR 0x120
+#define PDC_PTSR 0x124
+
+/* PDC fields definitions */
+#define PDC_PTCR_RXTEN 0x0001
+#define PDC_PTCR_RXTDIS 0x0002
+#define PDC_PTCR_TXTEN 0x0100
+#
|