/*
* ALSA driver for ATI IXP 150/200/250 AC97 modem controllers
*
* Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
*
* 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
*
*/
#include <asm/io.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/info.h>
#include <sound/ac97_codec.h>
#include <sound/initval.h>
MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
MODULE_DESCRIPTION("ATI IXP MC97 controller");
MODULE_LICENSE("GPL");
MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250}}");
static int index = -2; /* Exclude the first card */
static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
static int ac97_clock = 48000;
module_param(index, int, 0444);
MODULE_PARM_DESC(index, "Index value for ATI IXP controller.");
module_param(id, charp, 0444);
MODULE_PARM_DESC(id, "ID string for ATI IXP controller.");
module_param(ac97_clock, int, 0444);
MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
/* just for backward compatibility */
static int enable;
module_param(enable, bool, 0444);
/*
*/
#define ATI_REG_ISR 0x00 /* interrupt source */
#define ATI_REG_ISR_MODEM_IN_XRUN (1U<<0)
#define ATI_REG_ISR_MODEM_IN_STATUS (1U<<1)
#define ATI_REG_ISR_MODEM_OUT1_XRUN (1U<<2)
#define ATI_REG_ISR_MODEM_OUT1_STATUS (1U<<3)
#define ATI_REG_ISR_MODEM_OUT2_XRUN (1U<<4)
#define ATI_REG_ISR_MODEM_OUT2_STATUS (1U<<5)
#define ATI_REG_ISR_MODEM_OUT3_XRUN (1U<<6)
#define ATI_REG_ISR_MODEM_OUT3_STATUS (1U<<7)
#define ATI_REG_ISR_PHYS_INTR (1U<<8)
#define ATI_REG_ISR_PHYS_MISMATCH (1U<<9)
#define ATI_REG_ISR_CODEC0_NOT_READY (1U<<10)
#define ATI_REG_ISR_CODEC1_NOT_READY (1U<<11)
#define ATI_REG_ISR_CODEC2_NOT_READY (1U<<12)
#define ATI_REG_ISR_NEW_FRAME (1U<<13)
#define ATI_REG_ISR_MODEM_GPIO_DATA (1U<<14)
#define ATI_REG_IER 0x04 /* interrupt enable */
#define ATI_REG_IER_MODEM_IN_XRUN_EN (1U<<0)
#define ATI_REG_IER_MODEM_STATUS_EN (1U<<1)
#define ATI_REG_IER_MODEM_OUT1_XRUN_EN (1U<<2)
#define ATI_REG_IER_MODEM_OUT2_XRUN_EN (1U<<4)
#define ATI_REG_IER_MODEM_OUT3_XRUN_EN (1U<<6)
#define ATI_REG_IER_PHYS_INTR_EN (1U<<8)
#define ATI_REG_IER_PHYS_MISMATCH_EN (1U<<9)
#define ATI_REG_IER_CODEC0_INTR_EN (1U<<10)
#define ATI_REG_IER_CODEC1_INTR_EN (1U<<11)
#define ATI_REG_IER_CODEC2_INTR_EN (1U<<12)
#define ATI_REG_IER_NEW_FRAME_EN (1U<<13) /* (RO */
#define ATI_REG_IER_MODEM_GPIO_DATA_EN (1U<<14) /* (WO) modem is running */
#define ATI_REG_IER_MODEM_SET_BUS_BUSY (1U<<15)
#define ATI_REG_CMD 0x08 /* command */
#define ATI_REG_CMD_POWERDOWN (1U<<0)
#define ATI_REG_CMD_MODEM_RECEIVE_EN (1U<<1) /* modem only */
#define ATI_REG_CMD_MODEM_SEND1_EN (1U<<2) /* modem only */
#define ATI_REG_CMD_MODEM_SEND2_EN (1U<<3) /* modem only */
#define ATI_REG_CMD_MODEM_SEND3_EN (1U<<4) /* modem only */
#define ATI_REG_CMD_MODEM_STATUS_MEM (1U<<5) /* modem only */
#define ATI_REG_CMD_MODEM_IN_DMA_EN (1U<<8) /* modem only */
#define ATI_REG_CMD_MODEM_OUT_DMA1_EN (1U<<9) /* modem only */
#define ATI_REG_CMD_MODEM_OUT_DMA2_EN (1U<<10) /* modem only */
#define ATI_REG_CMD_MODEM_OUT_DMA3_EN (1U<<11) /* modem only */
#define ATI_REG_CMD_AUDIO_PRESENT (1U<<20)
#define ATI_REG_CMD_MODEM_GPIO_THRU_DMA (1U<<22)