11a59d1b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 29b4ffa48SJaya Kumar /* 39ac25594SJaya Kumar * Driver for audio on multifunction CS5535/6 companion device 49b4ffa48SJaya Kumar * Copyright (C) Jaya Kumar 59b4ffa48SJaya Kumar * 69b4ffa48SJaya Kumar * Based on Jaroslav Kysela and Takashi Iwai's examples. 79b4ffa48SJaya Kumar * This work was sponsored by CIS(M) Sdn Bhd. 89b4ffa48SJaya Kumar */ 99b4ffa48SJaya Kumar 109b4ffa48SJaya Kumar #include <linux/delay.h> 119b4ffa48SJaya Kumar #include <linux/interrupt.h> 129b4ffa48SJaya Kumar #include <linux/init.h> 139b4ffa48SJaya Kumar #include <linux/pci.h> 149b4ffa48SJaya Kumar #include <linux/slab.h> 1565a77217SPaul Gortmaker #include <linux/module.h> 166cbbfe1cSTakashi Iwai #include <linux/io.h> 179b4ffa48SJaya Kumar #include <sound/core.h> 189b4ffa48SJaya Kumar #include <sound/control.h> 199b4ffa48SJaya Kumar #include <sound/pcm.h> 209b4ffa48SJaya Kumar #include <sound/rawmidi.h> 219b4ffa48SJaya Kumar #include <sound/ac97_codec.h> 229b4ffa48SJaya Kumar #include <sound/initval.h> 239b4ffa48SJaya Kumar #include <sound/asoundef.h> 249b4ffa48SJaya Kumar #include "cs5535audio.h" 259b4ffa48SJaya Kumar 269b4ffa48SJaya Kumar #define DRIVER_NAME "cs5535audio" 279b4ffa48SJaya Kumar 289ac25594SJaya Kumar static char *ac97_quirk; 299ac25594SJaya Kumar module_param(ac97_quirk, charp, 0444); 309ac25594SJaya Kumar MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds."); 319ac25594SJaya Kumar 32eab0fbfaSJoe Perches static const struct ac97_quirk ac97_quirks[] = { 339ac25594SJaya Kumar #if 0 /* Not yet confirmed if all 5536 boards are HP only */ 349ac25594SJaya Kumar { 359ac25594SJaya Kumar .subvendor = PCI_VENDOR_ID_AMD, 369ac25594SJaya Kumar .subdevice = PCI_DEVICE_ID_AMD_CS5536_AUDIO, 379ac25594SJaya Kumar .name = "AMD RDK", 389ac25594SJaya Kumar .type = AC97_TUNE_HP_ONLY 399ac25594SJaya Kumar }, 409ac25594SJaya Kumar #endif 419ac25594SJaya Kumar {} 429ac25594SJaya Kumar }; 439b4ffa48SJaya Kumar 44302e4c2fSTakashi Iwai static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 45302e4c2fSTakashi Iwai static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 46a67ff6a5SRusty Russell static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 479b4ffa48SJaya Kumar 48302e4c2fSTakashi Iwai module_param_array(index, int, NULL, 0444); 491dbfd8c5STakashi Iwai MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME); 50302e4c2fSTakashi Iwai module_param_array(id, charp, NULL, 0444); 511dbfd8c5STakashi Iwai MODULE_PARM_DESC(id, "ID string for " DRIVER_NAME); 52302e4c2fSTakashi Iwai module_param_array(enable, bool, NULL, 0444); 53302e4c2fSTakashi Iwai MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME); 541dbfd8c5STakashi Iwai 559baa3c34SBenoit Taine static const struct pci_device_id snd_cs5535audio_ids[] = { 569ac25594SJaya Kumar { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) }, 579ac25594SJaya Kumar { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) }, 589b4ffa48SJaya Kumar {} 599b4ffa48SJaya Kumar }; 609b4ffa48SJaya Kumar 619b4ffa48SJaya Kumar MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids); 629b4ffa48SJaya Kumar 6366f8df6bSTakashi Iwai static void wait_till_cmd_acked(struct cs5535audio *cs5535au, unsigned long timeout) 649b4ffa48SJaya Kumar { 653e873174STakashi Iwai unsigned int tmp; 669b4ffa48SJaya Kumar do { 679b4ffa48SJaya Kumar tmp = cs_readl(cs5535au, ACC_CODEC_CNTL); 689b4ffa48SJaya Kumar if (!(tmp & CMD_NEW)) 699b4ffa48SJaya Kumar break; 701037593cSDavid Vrabel udelay(1); 719b4ffa48SJaya Kumar } while (--timeout); 729b4ffa48SJaya Kumar if (!timeout) 7300980aa9STakashi Iwai dev_err(cs5535au->card->dev, 7400980aa9STakashi Iwai "Failure writing to cs5535 codec\n"); 759b4ffa48SJaya Kumar } 769b4ffa48SJaya Kumar 7766f8df6bSTakashi Iwai static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au, 789b4ffa48SJaya Kumar unsigned short reg) 799b4ffa48SJaya Kumar { 803e873174STakashi Iwai unsigned int regdata; 8166f8df6bSTakashi Iwai unsigned int timeout; 823e873174STakashi Iwai unsigned int val; 839b4ffa48SJaya Kumar 843e873174STakashi Iwai regdata = ((unsigned int) reg) << 24; 859b4ffa48SJaya Kumar regdata |= ACC_CODEC_CNTL_RD_CMD; 869b4ffa48SJaya Kumar regdata |= CMD_NEW; 879b4ffa48SJaya Kumar 889b4ffa48SJaya Kumar cs_writel(cs5535au, ACC_CODEC_CNTL, regdata); 891037593cSDavid Vrabel wait_till_cmd_acked(cs5535au, 50); 909b4ffa48SJaya Kumar 919b4ffa48SJaya Kumar timeout = 50; 929b4ffa48SJaya Kumar do { 939b4ffa48SJaya Kumar val = cs_readl(cs5535au, ACC_CODEC_STATUS); 943e873174STakashi Iwai if ((val & STS_NEW) && reg == (val >> 24)) 959b4ffa48SJaya Kumar break; 961037593cSDavid Vrabel udelay(1); 979b4ffa48SJaya Kumar } while (--timeout); 989b4ffa48SJaya Kumar if (!timeout) 9900980aa9STakashi Iwai dev_err(cs5535au->card->dev, 10000980aa9STakashi Iwai "Failure reading codec reg 0x%x, Last value=0x%x\n", 10100980aa9STakashi Iwai reg, val); 1029b4ffa48SJaya Kumar 1033e873174STakashi Iwai return (unsigned short) val; 1049b4ffa48SJaya Kumar } 1059b4ffa48SJaya Kumar 10666f8df6bSTakashi Iwai static void snd_cs5535audio_codec_write(struct cs5535audio *cs5535au, 1079b4ffa48SJaya Kumar unsigned short reg, unsigned short val) 1089b4ffa48SJaya Kumar { 1093e873174STakashi Iwai unsigned int regdata; 1109b4ffa48SJaya Kumar 1113e873174STakashi Iwai regdata = ((unsigned int) reg) << 24; 1123e873174STakashi Iwai regdata |= val; 1139b4ffa48SJaya Kumar regdata &= CMD_MASK; 1149b4ffa48SJaya Kumar regdata |= CMD_NEW; 1159b4ffa48SJaya Kumar regdata &= ACC_CODEC_CNTL_WR_CMD; 1169b4ffa48SJaya Kumar 1179b4ffa48SJaya Kumar cs_writel(cs5535au, ACC_CODEC_CNTL, regdata); 1189b4ffa48SJaya Kumar wait_till_cmd_acked(cs5535au, 50); 1199b4ffa48SJaya Kumar } 1209b4ffa48SJaya Kumar 12166f8df6bSTakashi Iwai static void snd_cs5535audio_ac97_codec_write(struct snd_ac97 *ac97, 1229b4ffa48SJaya Kumar unsigned short reg, unsigned short val) 1239b4ffa48SJaya Kumar { 12466f8df6bSTakashi Iwai struct cs5535audio *cs5535au = ac97->private_data; 1259b4ffa48SJaya Kumar snd_cs5535audio_codec_write(cs5535au, reg, val); 1269b4ffa48SJaya Kumar } 1279b4ffa48SJaya Kumar 12866f8df6bSTakashi Iwai static unsigned short snd_cs5535audio_ac97_codec_read(struct snd_ac97 *ac97, 1299b4ffa48SJaya Kumar unsigned short reg) 1309b4ffa48SJaya Kumar { 13166f8df6bSTakashi Iwai struct cs5535audio *cs5535au = ac97->private_data; 1329b4ffa48SJaya Kumar return snd_cs5535audio_codec_read(cs5535au, reg); 1339b4ffa48SJaya Kumar } 1349b4ffa48SJaya Kumar 135e23e7a14SBill Pemberton static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au) 1369b4ffa48SJaya Kumar { 13766f8df6bSTakashi Iwai struct snd_card *card = cs5535au->card; 13866f8df6bSTakashi Iwai struct snd_ac97_bus *pbus; 13966f8df6bSTakashi Iwai struct snd_ac97_template ac97; 1409b4ffa48SJaya Kumar int err; 14151055da5STakashi Iwai static const struct snd_ac97_bus_ops ops = { 1429b4ffa48SJaya Kumar .write = snd_cs5535audio_ac97_codec_write, 1439b4ffa48SJaya Kumar .read = snd_cs5535audio_ac97_codec_read, 1449b4ffa48SJaya Kumar }; 1459b4ffa48SJaya Kumar 146*164b3ddeSTakashi Iwai err = snd_ac97_bus(card, 0, &ops, NULL, &pbus); 147*164b3ddeSTakashi Iwai if (err < 0) 1489b4ffa48SJaya Kumar return err; 1499b4ffa48SJaya Kumar 1509b4ffa48SJaya Kumar memset(&ac97, 0, sizeof(ac97)); 151b035ce0fSJaya Kumar ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM 152b035ce0fSJaya Kumar | AC97_SCAP_POWER_SAVE; 1539b4ffa48SJaya Kumar ac97.private_data = cs5535au; 1549b4ffa48SJaya Kumar ac97.pci = cs5535au->pci; 1559b4ffa48SJaya Kumar 1563556d184SAndres Salomon /* set any OLPC-specific scaps */ 1573556d184SAndres Salomon olpc_prequirks(card, &ac97); 1583556d184SAndres Salomon 159*164b3ddeSTakashi Iwai err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97); 160*164b3ddeSTakashi Iwai if (err < 0) { 16100980aa9STakashi Iwai dev_err(card->dev, "mixer failed\n"); 1629b4ffa48SJaya Kumar return err; 1639b4ffa48SJaya Kumar } 1649b4ffa48SJaya Kumar 1659ac25594SJaya Kumar snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk); 1669ac25594SJaya Kumar 16757d4bf6dSJaya Kumar err = olpc_quirks(card, cs5535au->ac97); 16857d4bf6dSJaya Kumar if (err < 0) { 16900980aa9STakashi Iwai dev_err(card->dev, "olpc quirks failed\n"); 17057d4bf6dSJaya Kumar return err; 17157d4bf6dSJaya Kumar } 17257d4bf6dSJaya Kumar 1739b4ffa48SJaya Kumar return 0; 1749b4ffa48SJaya Kumar } 1759b4ffa48SJaya Kumar 17666f8df6bSTakashi Iwai static void process_bm0_irq(struct cs5535audio *cs5535au) 1779b4ffa48SJaya Kumar { 1789b4ffa48SJaya Kumar u8 bm_stat; 1799b4ffa48SJaya Kumar spin_lock(&cs5535au->reg_lock); 1809b4ffa48SJaya Kumar bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS); 1819b4ffa48SJaya Kumar spin_unlock(&cs5535au->reg_lock); 1829b4ffa48SJaya Kumar if (bm_stat & EOP) { 1839b4ffa48SJaya Kumar snd_pcm_period_elapsed(cs5535au->playback_substream); 1849b4ffa48SJaya Kumar } else { 18500980aa9STakashi Iwai dev_err(cs5535au->card->dev, 18600980aa9STakashi Iwai "unexpected bm0 irq src, bm_stat=%x\n", 1879b4ffa48SJaya Kumar bm_stat); 1889b4ffa48SJaya Kumar } 1899b4ffa48SJaya Kumar } 1909b4ffa48SJaya Kumar 19166f8df6bSTakashi Iwai static void process_bm1_irq(struct cs5535audio *cs5535au) 1929b4ffa48SJaya Kumar { 1939b4ffa48SJaya Kumar u8 bm_stat; 1949b4ffa48SJaya Kumar spin_lock(&cs5535au->reg_lock); 1959b4ffa48SJaya Kumar bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); 1969b4ffa48SJaya Kumar spin_unlock(&cs5535au->reg_lock); 19745bf4100SColin Ian King if (bm_stat & EOP) 1989b4ffa48SJaya Kumar snd_pcm_period_elapsed(cs5535au->capture_substream); 1999b4ffa48SJaya Kumar } 2009b4ffa48SJaya Kumar 2017d12e780SDavid Howells static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id) 2029b4ffa48SJaya Kumar { 2039b4ffa48SJaya Kumar u16 acc_irq_stat; 2049b4ffa48SJaya Kumar unsigned char count; 20566f8df6bSTakashi Iwai struct cs5535audio *cs5535au = dev_id; 2069b4ffa48SJaya Kumar 2079b4ffa48SJaya Kumar if (cs5535au == NULL) 2089b4ffa48SJaya Kumar return IRQ_NONE; 2099b4ffa48SJaya Kumar 2109b4ffa48SJaya Kumar acc_irq_stat = cs_readw(cs5535au, ACC_IRQ_STATUS); 2119b4ffa48SJaya Kumar 2129b4ffa48SJaya Kumar if (!acc_irq_stat) 2139b4ffa48SJaya Kumar return IRQ_NONE; 2144ea24163SAndres Salomon for (count = 0; count < 4; count++) { 2159b4ffa48SJaya Kumar if (acc_irq_stat & (1 << count)) { 2169b4ffa48SJaya Kumar switch (count) { 2179b4ffa48SJaya Kumar case IRQ_STS: 2189b4ffa48SJaya Kumar cs_readl(cs5535au, ACC_GPIO_STATUS); 2199b4ffa48SJaya Kumar break; 2209b4ffa48SJaya Kumar case WU_IRQ_STS: 2219b4ffa48SJaya Kumar cs_readl(cs5535au, ACC_GPIO_STATUS); 2229b4ffa48SJaya Kumar break; 2239b4ffa48SJaya Kumar case BM0_IRQ_STS: 2249b4ffa48SJaya Kumar process_bm0_irq(cs5535au); 2259b4ffa48SJaya Kumar break; 2269b4ffa48SJaya Kumar case BM1_IRQ_STS: 2279b4ffa48SJaya Kumar process_bm1_irq(cs5535au); 2289b4ffa48SJaya Kumar break; 2299b4ffa48SJaya Kumar default: 23000980aa9STakashi Iwai dev_err(cs5535au->card->dev, 23100980aa9STakashi Iwai "Unexpected irq src: 0x%x\n", 23200980aa9STakashi Iwai acc_irq_stat); 2339b4ffa48SJaya Kumar break; 2349b4ffa48SJaya Kumar } 2359b4ffa48SJaya Kumar } 2369b4ffa48SJaya Kumar } 2379b4ffa48SJaya Kumar return IRQ_HANDLED; 2389b4ffa48SJaya Kumar } 2399b4ffa48SJaya Kumar 24066f8df6bSTakashi Iwai static int snd_cs5535audio_free(struct cs5535audio *cs5535au) 2419b4ffa48SJaya Kumar { 242ec06b2beSJulia Lawall pci_set_power_state(cs5535au->pci, PCI_D3hot); 2439b4ffa48SJaya Kumar 2449b4ffa48SJaya Kumar if (cs5535au->irq >= 0) 2459b4ffa48SJaya Kumar free_irq(cs5535au->irq, cs5535au); 2469b4ffa48SJaya Kumar 2479b4ffa48SJaya Kumar pci_release_regions(cs5535au->pci); 2489b4ffa48SJaya Kumar pci_disable_device(cs5535au->pci); 2499b4ffa48SJaya Kumar kfree(cs5535au); 2509b4ffa48SJaya Kumar return 0; 2519b4ffa48SJaya Kumar } 2529b4ffa48SJaya Kumar 25366f8df6bSTakashi Iwai static int snd_cs5535audio_dev_free(struct snd_device *device) 2549b4ffa48SJaya Kumar { 25566f8df6bSTakashi Iwai struct cs5535audio *cs5535au = device->device_data; 2569b4ffa48SJaya Kumar return snd_cs5535audio_free(cs5535au); 2579b4ffa48SJaya Kumar } 2589b4ffa48SJaya Kumar 259e23e7a14SBill Pemberton static int snd_cs5535audio_create(struct snd_card *card, 2609b4ffa48SJaya Kumar struct pci_dev *pci, 26166f8df6bSTakashi Iwai struct cs5535audio **rcs5535au) 2629b4ffa48SJaya Kumar { 26366f8df6bSTakashi Iwai struct cs5535audio *cs5535au; 2649b4ffa48SJaya Kumar 2659b4ffa48SJaya Kumar int err; 266efb0ad25STakashi Iwai static const struct snd_device_ops ops = { 2679b4ffa48SJaya Kumar .dev_free = snd_cs5535audio_dev_free, 2689b4ffa48SJaya Kumar }; 2699b4ffa48SJaya Kumar 2709b4ffa48SJaya Kumar *rcs5535au = NULL; 271*164b3ddeSTakashi Iwai err = pci_enable_device(pci); 272*164b3ddeSTakashi Iwai if (err < 0) 2739b4ffa48SJaya Kumar return err; 2749b4ffa48SJaya Kumar 275669f65eaSTakashi Iwai if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) { 27600980aa9STakashi Iwai dev_warn(card->dev, "unable to get 32bit dma\n"); 2779b4ffa48SJaya Kumar err = -ENXIO; 2789b4ffa48SJaya Kumar goto pcifail; 2799b4ffa48SJaya Kumar } 2809b4ffa48SJaya Kumar 2819b4ffa48SJaya Kumar cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL); 2829b4ffa48SJaya Kumar if (cs5535au == NULL) { 2839b4ffa48SJaya Kumar err = -ENOMEM; 2849b4ffa48SJaya Kumar goto pcifail; 2859b4ffa48SJaya Kumar } 2869b4ffa48SJaya Kumar 2879b4ffa48SJaya Kumar spin_lock_init(&cs5535au->reg_lock); 2889b4ffa48SJaya Kumar cs5535au->card = card; 2899b4ffa48SJaya Kumar cs5535au->pci = pci; 2909b4ffa48SJaya Kumar cs5535au->irq = -1; 2919b4ffa48SJaya Kumar 292*164b3ddeSTakashi Iwai err = pci_request_regions(pci, "CS5535 Audio"); 293*164b3ddeSTakashi Iwai if (err < 0) { 2949b4ffa48SJaya Kumar kfree(cs5535au); 2959b4ffa48SJaya Kumar goto pcifail; 2969b4ffa48SJaya Kumar } 2979b4ffa48SJaya Kumar 2989b4ffa48SJaya Kumar cs5535au->port = pci_resource_start(pci, 0); 2999b4ffa48SJaya Kumar 3009b4ffa48SJaya Kumar if (request_irq(pci->irq, snd_cs5535audio_interrupt, 301934c2b6dSTakashi Iwai IRQF_SHARED, KBUILD_MODNAME, cs5535au)) { 30200980aa9STakashi Iwai dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 3039b4ffa48SJaya Kumar err = -EBUSY; 3049b4ffa48SJaya Kumar goto sndfail; 3059b4ffa48SJaya Kumar } 3069b4ffa48SJaya Kumar 3079b4ffa48SJaya Kumar cs5535au->irq = pci->irq; 30825ec679bSTakashi Iwai card->sync_irq = cs5535au->irq; 3099b4ffa48SJaya Kumar pci_set_master(pci); 3109b4ffa48SJaya Kumar 311*164b3ddeSTakashi Iwai err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cs5535au, &ops); 312*164b3ddeSTakashi Iwai if (err < 0) 3139b4ffa48SJaya Kumar goto sndfail; 3149b4ffa48SJaya Kumar 3159b4ffa48SJaya Kumar *rcs5535au = cs5535au; 3169b4ffa48SJaya Kumar return 0; 3179b4ffa48SJaya Kumar 3189b4ffa48SJaya Kumar sndfail: /* leave the device alive, just kill the snd */ 3199b4ffa48SJaya Kumar snd_cs5535audio_free(cs5535au); 3209b4ffa48SJaya Kumar return err; 3219b4ffa48SJaya Kumar 3229b4ffa48SJaya Kumar pcifail: 3239b4ffa48SJaya Kumar pci_disable_device(pci); 3249b4ffa48SJaya Kumar return err; 3259b4ffa48SJaya Kumar } 3269b4ffa48SJaya Kumar 327e23e7a14SBill Pemberton static int snd_cs5535audio_probe(struct pci_dev *pci, 3289b4ffa48SJaya Kumar const struct pci_device_id *pci_id) 3299b4ffa48SJaya Kumar { 3309b4ffa48SJaya Kumar static int dev; 33166f8df6bSTakashi Iwai struct snd_card *card; 33266f8df6bSTakashi Iwai struct cs5535audio *cs5535au; 3339b4ffa48SJaya Kumar int err; 3349b4ffa48SJaya Kumar 3359b4ffa48SJaya Kumar if (dev >= SNDRV_CARDS) 3369b4ffa48SJaya Kumar return -ENODEV; 337302e4c2fSTakashi Iwai if (!enable[dev]) { 338302e4c2fSTakashi Iwai dev++; 339302e4c2fSTakashi Iwai return -ENOENT; 340302e4c2fSTakashi Iwai } 3419b4ffa48SJaya Kumar 34260c5772bSTakashi Iwai err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 34360c5772bSTakashi Iwai 0, &card); 344e58de7baSTakashi Iwai if (err < 0) 345e58de7baSTakashi Iwai return err; 3469b4ffa48SJaya Kumar 347*164b3ddeSTakashi Iwai err = snd_cs5535audio_create(card, pci, &cs5535au); 348*164b3ddeSTakashi Iwai if (err < 0) 3499b4ffa48SJaya Kumar goto probefail_out; 3509b4ffa48SJaya Kumar 3519ac25594SJaya Kumar card->private_data = cs5535au; 3529ac25594SJaya Kumar 353*164b3ddeSTakashi Iwai err = snd_cs5535audio_mixer(cs5535au); 354*164b3ddeSTakashi Iwai if (err < 0) 3559b4ffa48SJaya Kumar goto probefail_out; 3569b4ffa48SJaya Kumar 357*164b3ddeSTakashi Iwai err = snd_cs5535audio_pcm(cs5535au); 358*164b3ddeSTakashi Iwai if (err < 0) 3599b4ffa48SJaya Kumar goto probefail_out; 3609b4ffa48SJaya Kumar 3619b4ffa48SJaya Kumar strcpy(card->driver, DRIVER_NAME); 3629b4ffa48SJaya Kumar 3639b4ffa48SJaya Kumar strcpy(card->shortname, "CS5535 Audio"); 3649b4ffa48SJaya Kumar sprintf(card->longname, "%s %s at 0x%lx, irq %i", 3659b4ffa48SJaya Kumar card->shortname, card->driver, 3669b4ffa48SJaya Kumar cs5535au->port, cs5535au->irq); 3679b4ffa48SJaya Kumar 368*164b3ddeSTakashi Iwai err = snd_card_register(card); 369*164b3ddeSTakashi Iwai if (err < 0) 3709b4ffa48SJaya Kumar goto probefail_out; 3719b4ffa48SJaya Kumar 3729b4ffa48SJaya Kumar pci_set_drvdata(pci, card); 3739b4ffa48SJaya Kumar dev++; 3749b4ffa48SJaya Kumar return 0; 3759b4ffa48SJaya Kumar 3769b4ffa48SJaya Kumar probefail_out: 3779b4ffa48SJaya Kumar snd_card_free(card); 3789b4ffa48SJaya Kumar return err; 3799b4ffa48SJaya Kumar } 3809b4ffa48SJaya Kumar 381e23e7a14SBill Pemberton static void snd_cs5535audio_remove(struct pci_dev *pci) 3829b4ffa48SJaya Kumar { 3833c554946SAndres Salomon olpc_quirks_cleanup(); 3849b4ffa48SJaya Kumar snd_card_free(pci_get_drvdata(pci)); 3859b4ffa48SJaya Kumar } 3869b4ffa48SJaya Kumar 387e9f66d9bSTakashi Iwai static struct pci_driver cs5535audio_driver = { 3883733e424STakashi Iwai .name = KBUILD_MODNAME, 3899b4ffa48SJaya Kumar .id_table = snd_cs5535audio_ids, 3909b4ffa48SJaya Kumar .probe = snd_cs5535audio_probe, 391e23e7a14SBill Pemberton .remove = snd_cs5535audio_remove, 392c7561cd8STakashi Iwai #ifdef CONFIG_PM_SLEEP 39368cb2b55STakashi Iwai .driver = { 39468cb2b55STakashi Iwai .pm = &snd_cs5535audio_pm, 39568cb2b55STakashi Iwai }, 3969ac25594SJaya Kumar #endif 3979b4ffa48SJaya Kumar }; 3989b4ffa48SJaya Kumar 399e9f66d9bSTakashi Iwai module_pci_driver(cs5535audio_driver); 4009b4ffa48SJaya Kumar 4019b4ffa48SJaya Kumar MODULE_AUTHOR("Jaya Kumar"); 4029b4ffa48SJaya Kumar MODULE_LICENSE("GPL"); 4039b4ffa48SJaya Kumar MODULE_DESCRIPTION("CS5535 Audio"); 404