19b4ffa48SJaya Kumar /* 29ac25594SJaya Kumar * Driver for audio on multifunction CS5535/6 companion device 39b4ffa48SJaya Kumar * Copyright (C) Jaya Kumar 49b4ffa48SJaya Kumar * 59b4ffa48SJaya Kumar * Based on Jaroslav Kysela and Takashi Iwai's examples. 69b4ffa48SJaya Kumar * This work was sponsored by CIS(M) Sdn Bhd. 79b4ffa48SJaya Kumar * 89b4ffa48SJaya Kumar * This program is free software; you can redistribute it and/or modify 99b4ffa48SJaya Kumar * it under the terms of the GNU General Public License as published by 109b4ffa48SJaya Kumar * the Free Software Foundation; either version 2 of the License, or 119b4ffa48SJaya Kumar * (at your option) any later version. 129b4ffa48SJaya Kumar * 139b4ffa48SJaya Kumar * This program is distributed in the hope that it will be useful, 149b4ffa48SJaya Kumar * but WITHOUT ANY WARRANTY; without even the implied warranty of 159b4ffa48SJaya Kumar * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 169b4ffa48SJaya Kumar * GNU General Public License for more details. 179b4ffa48SJaya Kumar * 189b4ffa48SJaya Kumar * You should have received a copy of the GNU General Public License 199b4ffa48SJaya Kumar * along with this program; if not, write to the Free Software 209b4ffa48SJaya Kumar * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 219b4ffa48SJaya Kumar * 229b4ffa48SJaya Kumar */ 239b4ffa48SJaya Kumar 249b4ffa48SJaya Kumar #include <linux/delay.h> 259b4ffa48SJaya Kumar #include <linux/interrupt.h> 269b4ffa48SJaya Kumar #include <linux/init.h> 279b4ffa48SJaya Kumar #include <linux/pci.h> 289b4ffa48SJaya Kumar #include <linux/slab.h> 2965a77217SPaul Gortmaker #include <linux/module.h> 309b4ffa48SJaya Kumar #include <asm/io.h> 319b4ffa48SJaya Kumar #include <sound/core.h> 329b4ffa48SJaya Kumar #include <sound/control.h> 339b4ffa48SJaya Kumar #include <sound/pcm.h> 349b4ffa48SJaya Kumar #include <sound/rawmidi.h> 359b4ffa48SJaya Kumar #include <sound/ac97_codec.h> 369b4ffa48SJaya Kumar #include <sound/initval.h> 379b4ffa48SJaya Kumar #include <sound/asoundef.h> 389b4ffa48SJaya Kumar #include "cs5535audio.h" 399b4ffa48SJaya Kumar 409b4ffa48SJaya Kumar #define DRIVER_NAME "cs5535audio" 419b4ffa48SJaya Kumar 429ac25594SJaya Kumar static char *ac97_quirk; 439ac25594SJaya Kumar module_param(ac97_quirk, charp, 0444); 449ac25594SJaya Kumar MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds."); 459ac25594SJaya Kumar 46e23e7a14SBill Pemberton static struct ac97_quirk ac97_quirks[] = { 479ac25594SJaya Kumar #if 0 /* Not yet confirmed if all 5536 boards are HP only */ 489ac25594SJaya Kumar { 499ac25594SJaya Kumar .subvendor = PCI_VENDOR_ID_AMD, 509ac25594SJaya Kumar .subdevice = PCI_DEVICE_ID_AMD_CS5536_AUDIO, 519ac25594SJaya Kumar .name = "AMD RDK", 529ac25594SJaya Kumar .type = AC97_TUNE_HP_ONLY 539ac25594SJaya Kumar }, 549ac25594SJaya Kumar #endif 559ac25594SJaya Kumar {} 569ac25594SJaya Kumar }; 579b4ffa48SJaya Kumar 58302e4c2fSTakashi Iwai static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 59302e4c2fSTakashi Iwai static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 60a67ff6a5SRusty Russell static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 619b4ffa48SJaya Kumar 62302e4c2fSTakashi Iwai module_param_array(index, int, NULL, 0444); 631dbfd8c5STakashi Iwai MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME); 64302e4c2fSTakashi Iwai module_param_array(id, charp, NULL, 0444); 651dbfd8c5STakashi Iwai MODULE_PARM_DESC(id, "ID string for " DRIVER_NAME); 66302e4c2fSTakashi Iwai module_param_array(enable, bool, NULL, 0444); 67302e4c2fSTakashi Iwai MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME); 681dbfd8c5STakashi Iwai 69cebe41d4SAlexey Dobriyan static DEFINE_PCI_DEVICE_TABLE(snd_cs5535audio_ids) = { 709ac25594SJaya Kumar { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) }, 719ac25594SJaya Kumar { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) }, 729b4ffa48SJaya Kumar {} 739b4ffa48SJaya Kumar }; 749b4ffa48SJaya Kumar 759b4ffa48SJaya Kumar MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids); 769b4ffa48SJaya Kumar 7766f8df6bSTakashi Iwai static void wait_till_cmd_acked(struct cs5535audio *cs5535au, unsigned long timeout) 789b4ffa48SJaya Kumar { 793e873174STakashi Iwai unsigned int tmp; 809b4ffa48SJaya Kumar do { 819b4ffa48SJaya Kumar tmp = cs_readl(cs5535au, ACC_CODEC_CNTL); 829b4ffa48SJaya Kumar if (!(tmp & CMD_NEW)) 839b4ffa48SJaya Kumar break; 841037593cSDavid Vrabel udelay(1); 859b4ffa48SJaya Kumar } while (--timeout); 869b4ffa48SJaya Kumar if (!timeout) 879b4ffa48SJaya Kumar snd_printk(KERN_ERR "Failure writing to cs5535 codec\n"); 889b4ffa48SJaya Kumar } 899b4ffa48SJaya Kumar 9066f8df6bSTakashi Iwai static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au, 919b4ffa48SJaya Kumar unsigned short reg) 929b4ffa48SJaya Kumar { 933e873174STakashi Iwai unsigned int regdata; 9466f8df6bSTakashi Iwai unsigned int timeout; 953e873174STakashi Iwai unsigned int val; 969b4ffa48SJaya Kumar 973e873174STakashi Iwai regdata = ((unsigned int) reg) << 24; 989b4ffa48SJaya Kumar regdata |= ACC_CODEC_CNTL_RD_CMD; 999b4ffa48SJaya Kumar regdata |= CMD_NEW; 1009b4ffa48SJaya Kumar 1019b4ffa48SJaya Kumar cs_writel(cs5535au, ACC_CODEC_CNTL, regdata); 1021037593cSDavid Vrabel wait_till_cmd_acked(cs5535au, 50); 1039b4ffa48SJaya Kumar 1049b4ffa48SJaya Kumar timeout = 50; 1059b4ffa48SJaya Kumar do { 1069b4ffa48SJaya Kumar val = cs_readl(cs5535au, ACC_CODEC_STATUS); 1073e873174STakashi Iwai if ((val & STS_NEW) && reg == (val >> 24)) 1089b4ffa48SJaya Kumar break; 1091037593cSDavid Vrabel udelay(1); 1109b4ffa48SJaya Kumar } while (--timeout); 1119b4ffa48SJaya Kumar if (!timeout) 11240a4f7a0SJaya Kumar snd_printk(KERN_ERR "Failure reading codec reg 0x%x," 11340a4f7a0SJaya Kumar "Last value=0x%x\n", reg, val); 1149b4ffa48SJaya Kumar 1153e873174STakashi Iwai return (unsigned short) val; 1169b4ffa48SJaya Kumar } 1179b4ffa48SJaya Kumar 11866f8df6bSTakashi Iwai static void snd_cs5535audio_codec_write(struct cs5535audio *cs5535au, 1199b4ffa48SJaya Kumar unsigned short reg, unsigned short val) 1209b4ffa48SJaya Kumar { 1213e873174STakashi Iwai unsigned int regdata; 1229b4ffa48SJaya Kumar 1233e873174STakashi Iwai regdata = ((unsigned int) reg) << 24; 1243e873174STakashi Iwai regdata |= val; 1259b4ffa48SJaya Kumar regdata &= CMD_MASK; 1269b4ffa48SJaya Kumar regdata |= CMD_NEW; 1279b4ffa48SJaya Kumar regdata &= ACC_CODEC_CNTL_WR_CMD; 1289b4ffa48SJaya Kumar 1299b4ffa48SJaya Kumar cs_writel(cs5535au, ACC_CODEC_CNTL, regdata); 1309b4ffa48SJaya Kumar wait_till_cmd_acked(cs5535au, 50); 1319b4ffa48SJaya Kumar } 1329b4ffa48SJaya Kumar 13366f8df6bSTakashi Iwai static void snd_cs5535audio_ac97_codec_write(struct snd_ac97 *ac97, 1349b4ffa48SJaya Kumar unsigned short reg, unsigned short val) 1359b4ffa48SJaya Kumar { 13666f8df6bSTakashi Iwai struct cs5535audio *cs5535au = ac97->private_data; 1379b4ffa48SJaya Kumar snd_cs5535audio_codec_write(cs5535au, reg, val); 1389b4ffa48SJaya Kumar } 1399b4ffa48SJaya Kumar 14066f8df6bSTakashi Iwai static unsigned short snd_cs5535audio_ac97_codec_read(struct snd_ac97 *ac97, 1419b4ffa48SJaya Kumar unsigned short reg) 1429b4ffa48SJaya Kumar { 14366f8df6bSTakashi Iwai struct cs5535audio *cs5535au = ac97->private_data; 1449b4ffa48SJaya Kumar return snd_cs5535audio_codec_read(cs5535au, reg); 1459b4ffa48SJaya Kumar } 1469b4ffa48SJaya Kumar 147e23e7a14SBill Pemberton static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au) 1489b4ffa48SJaya Kumar { 14966f8df6bSTakashi Iwai struct snd_card *card = cs5535au->card; 15066f8df6bSTakashi Iwai struct snd_ac97_bus *pbus; 15166f8df6bSTakashi Iwai struct snd_ac97_template ac97; 1529b4ffa48SJaya Kumar int err; 15366f8df6bSTakashi Iwai static struct snd_ac97_bus_ops ops = { 1549b4ffa48SJaya Kumar .write = snd_cs5535audio_ac97_codec_write, 1559b4ffa48SJaya Kumar .read = snd_cs5535audio_ac97_codec_read, 1569b4ffa48SJaya Kumar }; 1579b4ffa48SJaya Kumar 1589b4ffa48SJaya Kumar if ((err = snd_ac97_bus(card, 0, &ops, NULL, &pbus)) < 0) 1599b4ffa48SJaya Kumar return err; 1609b4ffa48SJaya Kumar 1619b4ffa48SJaya Kumar memset(&ac97, 0, sizeof(ac97)); 162b035ce0fSJaya Kumar ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM 163b035ce0fSJaya Kumar | AC97_SCAP_POWER_SAVE; 1649b4ffa48SJaya Kumar ac97.private_data = cs5535au; 1659b4ffa48SJaya Kumar ac97.pci = cs5535au->pci; 1669b4ffa48SJaya Kumar 1673556d184SAndres Salomon /* set any OLPC-specific scaps */ 1683556d184SAndres Salomon olpc_prequirks(card, &ac97); 1693556d184SAndres Salomon 1709b4ffa48SJaya Kumar if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { 1713e873174STakashi Iwai snd_printk(KERN_ERR "mixer failed\n"); 1729b4ffa48SJaya Kumar return err; 1739b4ffa48SJaya Kumar } 1749b4ffa48SJaya Kumar 1759ac25594SJaya Kumar snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk); 1769ac25594SJaya Kumar 17757d4bf6dSJaya Kumar err = olpc_quirks(card, cs5535au->ac97); 17857d4bf6dSJaya Kumar if (err < 0) { 17957d4bf6dSJaya Kumar snd_printk(KERN_ERR "olpc quirks failed\n"); 18057d4bf6dSJaya Kumar return err; 18157d4bf6dSJaya Kumar } 18257d4bf6dSJaya Kumar 1839b4ffa48SJaya Kumar return 0; 1849b4ffa48SJaya Kumar } 1859b4ffa48SJaya Kumar 18666f8df6bSTakashi Iwai static void process_bm0_irq(struct cs5535audio *cs5535au) 1879b4ffa48SJaya Kumar { 1889b4ffa48SJaya Kumar u8 bm_stat; 1899b4ffa48SJaya Kumar spin_lock(&cs5535au->reg_lock); 1909b4ffa48SJaya Kumar bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS); 1919b4ffa48SJaya Kumar spin_unlock(&cs5535au->reg_lock); 1929b4ffa48SJaya Kumar if (bm_stat & EOP) { 19366f8df6bSTakashi Iwai struct cs5535audio_dma *dma; 1949b4ffa48SJaya Kumar dma = cs5535au->playback_substream->runtime->private_data; 1959b4ffa48SJaya Kumar snd_pcm_period_elapsed(cs5535au->playback_substream); 1969b4ffa48SJaya Kumar } else { 1979b4ffa48SJaya Kumar snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n", 1989b4ffa48SJaya Kumar bm_stat); 1999b4ffa48SJaya Kumar } 2009b4ffa48SJaya Kumar } 2019b4ffa48SJaya Kumar 20266f8df6bSTakashi Iwai static void process_bm1_irq(struct cs5535audio *cs5535au) 2039b4ffa48SJaya Kumar { 2049b4ffa48SJaya Kumar u8 bm_stat; 2059b4ffa48SJaya Kumar spin_lock(&cs5535au->reg_lock); 2069b4ffa48SJaya Kumar bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); 2079b4ffa48SJaya Kumar spin_unlock(&cs5535au->reg_lock); 2089b4ffa48SJaya Kumar if (bm_stat & EOP) { 20966f8df6bSTakashi Iwai struct cs5535audio_dma *dma; 2109b4ffa48SJaya Kumar dma = cs5535au->capture_substream->runtime->private_data; 2119b4ffa48SJaya Kumar snd_pcm_period_elapsed(cs5535au->capture_substream); 2129b4ffa48SJaya Kumar } 2139b4ffa48SJaya Kumar } 2149b4ffa48SJaya Kumar 2157d12e780SDavid Howells static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id) 2169b4ffa48SJaya Kumar { 2179b4ffa48SJaya Kumar u16 acc_irq_stat; 2189b4ffa48SJaya Kumar unsigned char count; 21966f8df6bSTakashi Iwai struct cs5535audio *cs5535au = dev_id; 2209b4ffa48SJaya Kumar 2219b4ffa48SJaya Kumar if (cs5535au == NULL) 2229b4ffa48SJaya Kumar return IRQ_NONE; 2239b4ffa48SJaya Kumar 2249b4ffa48SJaya Kumar acc_irq_stat = cs_readw(cs5535au, ACC_IRQ_STATUS); 2259b4ffa48SJaya Kumar 2269b4ffa48SJaya Kumar if (!acc_irq_stat) 2279b4ffa48SJaya Kumar return IRQ_NONE; 2284ea24163SAndres Salomon for (count = 0; count < 4; count++) { 2299b4ffa48SJaya Kumar if (acc_irq_stat & (1 << count)) { 2309b4ffa48SJaya Kumar switch (count) { 2319b4ffa48SJaya Kumar case IRQ_STS: 2329b4ffa48SJaya Kumar cs_readl(cs5535au, ACC_GPIO_STATUS); 2339b4ffa48SJaya Kumar break; 2349b4ffa48SJaya Kumar case WU_IRQ_STS: 2359b4ffa48SJaya Kumar cs_readl(cs5535au, ACC_GPIO_STATUS); 2369b4ffa48SJaya Kumar break; 2379b4ffa48SJaya Kumar case BM0_IRQ_STS: 2389b4ffa48SJaya Kumar process_bm0_irq(cs5535au); 2399b4ffa48SJaya Kumar break; 2409b4ffa48SJaya Kumar case BM1_IRQ_STS: 2419b4ffa48SJaya Kumar process_bm1_irq(cs5535au); 2429b4ffa48SJaya Kumar break; 2439b4ffa48SJaya Kumar default: 2444ea24163SAndres Salomon snd_printk(KERN_ERR "Unexpected irq src: " 2454ea24163SAndres Salomon "0x%x\n", acc_irq_stat); 2469b4ffa48SJaya Kumar break; 2479b4ffa48SJaya Kumar } 2489b4ffa48SJaya Kumar } 2499b4ffa48SJaya Kumar } 2509b4ffa48SJaya Kumar return IRQ_HANDLED; 2519b4ffa48SJaya Kumar } 2529b4ffa48SJaya Kumar 25366f8df6bSTakashi Iwai static int snd_cs5535audio_free(struct cs5535audio *cs5535au) 2549b4ffa48SJaya Kumar { 2559b4ffa48SJaya Kumar synchronize_irq(cs5535au->irq); 256*ec06b2beSJulia Lawall pci_set_power_state(cs5535au->pci, PCI_D3hot); 2579b4ffa48SJaya Kumar 2589b4ffa48SJaya Kumar if (cs5535au->irq >= 0) 2599b4ffa48SJaya Kumar free_irq(cs5535au->irq, cs5535au); 2609b4ffa48SJaya Kumar 2619b4ffa48SJaya Kumar pci_release_regions(cs5535au->pci); 2629b4ffa48SJaya Kumar pci_disable_device(cs5535au->pci); 2639b4ffa48SJaya Kumar kfree(cs5535au); 2649b4ffa48SJaya Kumar return 0; 2659b4ffa48SJaya Kumar } 2669b4ffa48SJaya Kumar 26766f8df6bSTakashi Iwai static int snd_cs5535audio_dev_free(struct snd_device *device) 2689b4ffa48SJaya Kumar { 26966f8df6bSTakashi Iwai struct cs5535audio *cs5535au = device->device_data; 2709b4ffa48SJaya Kumar return snd_cs5535audio_free(cs5535au); 2719b4ffa48SJaya Kumar } 2729b4ffa48SJaya Kumar 273e23e7a14SBill Pemberton static int snd_cs5535audio_create(struct snd_card *card, 2749b4ffa48SJaya Kumar struct pci_dev *pci, 27566f8df6bSTakashi Iwai struct cs5535audio **rcs5535au) 2769b4ffa48SJaya Kumar { 27766f8df6bSTakashi Iwai struct cs5535audio *cs5535au; 2789b4ffa48SJaya Kumar 2799b4ffa48SJaya Kumar int err; 28066f8df6bSTakashi Iwai static struct snd_device_ops ops = { 2819b4ffa48SJaya Kumar .dev_free = snd_cs5535audio_dev_free, 2829b4ffa48SJaya Kumar }; 2839b4ffa48SJaya Kumar 2849b4ffa48SJaya Kumar *rcs5535au = NULL; 2859b4ffa48SJaya Kumar if ((err = pci_enable_device(pci)) < 0) 2869b4ffa48SJaya Kumar return err; 2879b4ffa48SJaya Kumar 288284901a9SYang Hongyang if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 || 289284901a9SYang Hongyang pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) { 2909b4ffa48SJaya Kumar printk(KERN_WARNING "unable to get 32bit dma\n"); 2919b4ffa48SJaya Kumar err = -ENXIO; 2929b4ffa48SJaya Kumar goto pcifail; 2939b4ffa48SJaya Kumar } 2949b4ffa48SJaya Kumar 2959b4ffa48SJaya Kumar cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL); 2969b4ffa48SJaya Kumar if (cs5535au == NULL) { 2979b4ffa48SJaya Kumar err = -ENOMEM; 2989b4ffa48SJaya Kumar goto pcifail; 2999b4ffa48SJaya Kumar } 3009b4ffa48SJaya Kumar 3019b4ffa48SJaya Kumar spin_lock_init(&cs5535au->reg_lock); 3029b4ffa48SJaya Kumar cs5535au->card = card; 3039b4ffa48SJaya Kumar cs5535au->pci = pci; 3049b4ffa48SJaya Kumar cs5535au->irq = -1; 3059b4ffa48SJaya Kumar 3069b4ffa48SJaya Kumar if ((err = pci_request_regions(pci, "CS5535 Audio")) < 0) { 3079b4ffa48SJaya Kumar kfree(cs5535au); 3089b4ffa48SJaya Kumar goto pcifail; 3099b4ffa48SJaya Kumar } 3109b4ffa48SJaya Kumar 3119b4ffa48SJaya Kumar cs5535au->port = pci_resource_start(pci, 0); 3129b4ffa48SJaya Kumar 3139b4ffa48SJaya Kumar if (request_irq(pci->irq, snd_cs5535audio_interrupt, 314934c2b6dSTakashi Iwai IRQF_SHARED, KBUILD_MODNAME, cs5535au)) { 315ee419653STakashi Iwai snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 3169b4ffa48SJaya Kumar err = -EBUSY; 3179b4ffa48SJaya Kumar goto sndfail; 3189b4ffa48SJaya Kumar } 3199b4ffa48SJaya Kumar 3209b4ffa48SJaya Kumar cs5535au->irq = pci->irq; 3219b4ffa48SJaya Kumar pci_set_master(pci); 3229b4ffa48SJaya Kumar 3239b4ffa48SJaya Kumar if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, 3249b4ffa48SJaya Kumar cs5535au, &ops)) < 0) 3259b4ffa48SJaya Kumar goto sndfail; 3269b4ffa48SJaya Kumar 3279b4ffa48SJaya Kumar snd_card_set_dev(card, &pci->dev); 3289b4ffa48SJaya Kumar 3299b4ffa48SJaya Kumar *rcs5535au = cs5535au; 3309b4ffa48SJaya Kumar return 0; 3319b4ffa48SJaya Kumar 3329b4ffa48SJaya Kumar sndfail: /* leave the device alive, just kill the snd */ 3339b4ffa48SJaya Kumar snd_cs5535audio_free(cs5535au); 3349b4ffa48SJaya Kumar return err; 3359b4ffa48SJaya Kumar 3369b4ffa48SJaya Kumar pcifail: 3379b4ffa48SJaya Kumar pci_disable_device(pci); 3389b4ffa48SJaya Kumar return err; 3399b4ffa48SJaya Kumar } 3409b4ffa48SJaya Kumar 341e23e7a14SBill Pemberton static int snd_cs5535audio_probe(struct pci_dev *pci, 3429b4ffa48SJaya Kumar const struct pci_device_id *pci_id) 3439b4ffa48SJaya Kumar { 3449b4ffa48SJaya Kumar static int dev; 34566f8df6bSTakashi Iwai struct snd_card *card; 34666f8df6bSTakashi Iwai struct cs5535audio *cs5535au; 3479b4ffa48SJaya Kumar int err; 3489b4ffa48SJaya Kumar 3499b4ffa48SJaya Kumar if (dev >= SNDRV_CARDS) 3509b4ffa48SJaya Kumar return -ENODEV; 351302e4c2fSTakashi Iwai if (!enable[dev]) { 352302e4c2fSTakashi Iwai dev++; 353302e4c2fSTakashi Iwai return -ENOENT; 354302e4c2fSTakashi Iwai } 3559b4ffa48SJaya Kumar 356e58de7baSTakashi Iwai err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 357e58de7baSTakashi Iwai if (err < 0) 358e58de7baSTakashi Iwai return err; 3599b4ffa48SJaya Kumar 3609b4ffa48SJaya Kumar if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0) 3619b4ffa48SJaya Kumar goto probefail_out; 3629b4ffa48SJaya Kumar 3639ac25594SJaya Kumar card->private_data = cs5535au; 3649ac25594SJaya Kumar 3659b4ffa48SJaya Kumar if ((err = snd_cs5535audio_mixer(cs5535au)) < 0) 3669b4ffa48SJaya Kumar goto probefail_out; 3679b4ffa48SJaya Kumar 3689b4ffa48SJaya Kumar if ((err = snd_cs5535audio_pcm(cs5535au)) < 0) 3699b4ffa48SJaya Kumar goto probefail_out; 3709b4ffa48SJaya Kumar 3719b4ffa48SJaya Kumar strcpy(card->driver, DRIVER_NAME); 3729b4ffa48SJaya Kumar 3739b4ffa48SJaya Kumar strcpy(card->shortname, "CS5535 Audio"); 3749b4ffa48SJaya Kumar sprintf(card->longname, "%s %s at 0x%lx, irq %i", 3759b4ffa48SJaya Kumar card->shortname, card->driver, 3769b4ffa48SJaya Kumar cs5535au->port, cs5535au->irq); 3779b4ffa48SJaya Kumar 3789b4ffa48SJaya Kumar if ((err = snd_card_register(card)) < 0) 3799b4ffa48SJaya Kumar goto probefail_out; 3809b4ffa48SJaya Kumar 3819b4ffa48SJaya Kumar pci_set_drvdata(pci, card); 3829b4ffa48SJaya Kumar dev++; 3839b4ffa48SJaya Kumar return 0; 3849b4ffa48SJaya Kumar 3859b4ffa48SJaya Kumar probefail_out: 3869b4ffa48SJaya Kumar snd_card_free(card); 3879b4ffa48SJaya Kumar return err; 3889b4ffa48SJaya Kumar } 3899b4ffa48SJaya Kumar 390e23e7a14SBill Pemberton static void snd_cs5535audio_remove(struct pci_dev *pci) 3919b4ffa48SJaya Kumar { 3923c554946SAndres Salomon olpc_quirks_cleanup(); 3939b4ffa48SJaya Kumar snd_card_free(pci_get_drvdata(pci)); 3949b4ffa48SJaya Kumar } 3959b4ffa48SJaya Kumar 396e9f66d9bSTakashi Iwai static struct pci_driver cs5535audio_driver = { 3973733e424STakashi Iwai .name = KBUILD_MODNAME, 3989b4ffa48SJaya Kumar .id_table = snd_cs5535audio_ids, 3999b4ffa48SJaya Kumar .probe = snd_cs5535audio_probe, 400e23e7a14SBill Pemberton .remove = snd_cs5535audio_remove, 401c7561cd8STakashi Iwai #ifdef CONFIG_PM_SLEEP 40268cb2b55STakashi Iwai .driver = { 40368cb2b55STakashi Iwai .pm = &snd_cs5535audio_pm, 40468cb2b55STakashi Iwai }, 4059ac25594SJaya Kumar #endif 4069b4ffa48SJaya Kumar }; 4079b4ffa48SJaya Kumar 408e9f66d9bSTakashi Iwai module_pci_driver(cs5535audio_driver); 4099b4ffa48SJaya Kumar 4109b4ffa48SJaya Kumar MODULE_AUTHOR("Jaya Kumar"); 4119b4ffa48SJaya Kumar MODULE_LICENSE("GPL"); 4129b4ffa48SJaya Kumar MODULE_DESCRIPTION("CS5535 Audio"); 4139b4ffa48SJaya Kumar MODULE_SUPPORTED_DEVICE("CS5535 Audio"); 414