Lines Matching refs:chip
219 void (*enable_dma)(struct atiixp *chip, int on);
221 void (*enable_transfer)(struct atiixp *chip, int on);
223 void (*flush_dma)(struct atiixp *chip);
244 * ATI IXP chip
298 static int snd_atiixp_update_bits(struct atiixp *chip, unsigned int reg,
301 void __iomem *addr = chip->remap_addr + reg;
315 #define atiixp_write(chip,reg,value) \
316 writel(value, chip->remap_addr + ATI_REG_##reg)
317 #define atiixp_read(chip,reg) \
318 readl(chip->remap_addr + ATI_REG_##reg)
319 #define atiixp_update(chip,reg,mask,val) \
320 snd_atiixp_update_bits(chip, ATI_REG_##reg, mask, val)
341 static int atiixp_build_dma_packets(struct atiixp *chip, struct atiixp_dma *dma,
355 &chip->pci->dev,
366 spin_lock_irqsave(&chip->reg_lock, flags);
367 writel(0, chip->remap_addr + dma->ops->llp_offset);
368 dma->ops->enable_dma(chip, 0);
369 dma->ops->enable_dma(chip, 1);
370 spin_unlock_irqrestore(&chip->reg_lock, flags);
390 chip->remap_addr + dma->ops->llp_offset);
401 static void atiixp_clear_dma_packets(struct atiixp *chip, struct atiixp_dma *dma,
405 writel(0, chip->remap_addr + dma->ops->llp_offset);
414 static int snd_atiixp_acquire_codec(struct atiixp *chip)
418 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) {
420 dev_warn(chip->card->dev, "codec acquire timeout\n");
428 static unsigned short snd_atiixp_codec_read(struct atiixp *chip, unsigned short codec, unsigned short reg)
433 if (snd_atiixp_acquire_codec(chip) < 0)
439 atiixp_write(chip, PHYS_OUT_ADDR, data);
440 if (snd_atiixp_acquire_codec(chip) < 0)
444 data = atiixp_read(chip, PHYS_IN_ADDR);
451 dev_warn(chip->card->dev, "codec read timeout (reg %x)\n", reg);
456 static void snd_atiixp_codec_write(struct atiixp *chip, unsigned short codec,
461 if (snd_atiixp_acquire_codec(chip) < 0)
466 atiixp_write(chip, PHYS_OUT_ADDR, data);
473 struct atiixp *chip = ac97->private_data;
474 return snd_atiixp_codec_read(chip, ac97->num, reg);
481 struct atiixp *chip = ac97->private_data;
482 snd_atiixp_codec_write(chip, ac97->num, reg, val);
488 static int snd_atiixp_aclink_reset(struct atiixp *chip)
493 if (atiixp_update(chip, CMD, ATI_REG_CMD_POWERDOWN, 0))
497 atiixp_update(chip, CMD, ATI_REG_CMD_AC_SOFT_RESET, ATI_REG_CMD_AC_SOFT_RESET);
498 atiixp_read(chip, CMD);
500 atiixp_update(chip, CMD, ATI_REG_CMD_AC_SOFT_RESET, 0);
503 while (! (atiixp_read(chip, CMD) & ATI_REG_CMD_ACLINK_ACTIVE)) {
505 atiixp_update(chip, CMD, ATI_REG_CMD_AC_SYNC|ATI_REG_CMD_AC_RESET,
507 atiixp_read(chip, CMD);
509 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
511 dev_err(chip->card->dev, "codec reset timeout\n");
517 atiixp_update(chip, CMD, ATI_REG_CMD_AC_SYNC|ATI_REG_CMD_AC_RESET,
524 static int snd_atiixp_aclink_down(struct atiixp *chip)
526 // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */
528 atiixp_update(chip, CMD,
538 * the IXP chip can generate interrupts for the non-existing codecs.
563 static int snd_atiixp_codec_detect(struct atiixp *chip)
567 chip->codec_not_ready_bits = 0;
569 ac97_codec = ac97_probing_bugs(chip->pci);
571 chip->codec_not_ready_bits |=
576 atiixp_write(chip, IER, CODEC_CHECK_BITS);
581 if (chip->codec_not_ready_bits)
584 atiixp_write(chip, IER, 0); /* disable irqs */
586 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) {
587 dev_err(chip->card->dev, "no codec detected!\n");
597 static int snd_atiixp_chip_start(struct atiixp *chip)
602 reg = atiixp_read(chip, CMD);
605 atiixp_write(chip, CMD, reg);
607 reg = atiixp_read(chip, SPDF_CMD);
609 atiixp_write(chip, SPDF_CMD, reg);
612 atiixp_write(chip, ISR, 0xffffffff);
614 atiixp_write(chip, IER,
627 static int snd_atiixp_chip_stop(struct atiixp *chip)
630 atiixp_write(chip, ISR, atiixp_read(chip, ISR));
632 atiixp_write(chip, IER, 0);
648 struct atiixp *chip = snd_pcm_substream_chip(substream);
655 curptr = readl(chip->remap_addr + dma->ops->dt_cur);
663 dev_dbg(chip->card->dev, "invalid DMA pointer read 0x%x (buf=%x)\n",
664 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
671 static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
675 dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
682 static void snd_atiixp_update_dma(struct atiixp *chip, struct atiixp_dma *dma)
691 static void snd_atiixp_check_bus_busy(struct atiixp *chip)
694 if (atiixp_read(chip, CMD) & (ATI_REG_CMD_SEND_EN |
700 atiixp_update(chip, IER, ATI_REG_IER_SET_BUS_BUSY, bus_busy);
708 struct atiixp *chip = snd_pcm_substream_chip(substream);
716 spin_lock(&chip->reg_lock);
723 writel(dma->saved_curptr, chip->remap_addr +
725 dma->ops->enable_transfer(chip, 1);
734 dma->saved_curptr = readl(chip->remap_addr +
736 dma->ops->enable_transfer(chip, 0);
744 snd_atiixp_check_bus_busy(chip);
746 dma->ops->flush_dma(chip);
747 snd_atiixp_check_bus_busy(chip);
750 spin_unlock(&chip->reg_lock);
758 * every callback is supposed to be called in chip->reg_lock spinlock
762 static void atiixp_out_flush_dma(struct atiixp *chip)
764 atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_OUT_FLUSH);
768 static void atiixp_out_enable_dma(struct atiixp *chip, int on)
771 data = atiixp_read(chip, CMD);
775 atiixp_out_flush_dma(chip);
779 atiixp_write(chip, CMD, data);
783 static void atiixp_out_enable_transfer(struct atiixp *chip, int on)
785 atiixp_update(chip, CMD, ATI_REG_CMD_SEND_EN,
790 static void atiixp_in_enable_dma(struct atiixp *chip, int on)
792 atiixp_update(chip, CMD, ATI_REG_CMD_IN_DMA_EN,
797 static void atiixp_in_enable_transfer(struct atiixp *chip, int on)
800 unsigned int data = atiixp_read(chip, CMD);
805 while ((atiixp_read(chip, COUNTER) &
809 atiixp_write(chip, CMD, data);
812 atiixp_update(chip, CMD, ATI_REG_CMD_RECEIVE_EN, 0);
816 static void atiixp_in_flush_dma(struct atiixp *chip)
818 atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_IN_FLUSH);
822 static void atiixp_spdif_enable_dma(struct atiixp *chip, int on)
824 atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_DMA_EN,
829 static void atiixp_spdif_enable_transfer(struct atiixp *chip, int on)
832 data = atiixp_read(chip, CMD);
837 atiixp_write(chip, CMD, data);
841 static void atiixp_spdif_flush_dma(struct atiixp *chip)
846 atiixp_spdif_enable_dma(chip, 0);
847 atiixp_spdif_enable_transfer(chip, 1);
851 if (! (atiixp_read(chip, SPDF_DMA_DT_SIZE) & ATI_REG_DMA_FIFO_USED))
856 atiixp_spdif_enable_transfer(chip, 0);
862 struct atiixp *chip = snd_pcm_substream_chip(substream);
864 spin_lock_irq(&chip->reg_lock);
865 if (chip->spdif_over_aclink) {
868 atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_CONFIG_MASK,
870 data = atiixp_read(chip, OUT_DMA_SLOT) & ~ATI_REG_OUT_DMA_SLOT_MASK;
874 atiixp_write(chip, OUT_DMA_SLOT, data);
875 atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_OUT,
879 atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_CONFIG_MASK, 0);
880 atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_SPDF, 0);
882 spin_unlock_irq(&chip->reg_lock);
889 struct atiixp *chip = snd_pcm_substream_chip(substream);
892 spin_lock_irq(&chip->reg_lock);
893 data = atiixp_read(chip, OUT_DMA_SLOT) & ~ATI_REG_OUT_DMA_SLOT_MASK;
915 atiixp_write(chip, OUT_DMA_SLOT, data);
917 atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_OUT,
924 atiixp_update(chip, 6CH_REORDER, ATI_REG_6CH_REORDER_EN,
927 spin_unlock_irq(&chip->reg_lock);
934 struct atiixp *chip = snd_pcm_substream_chip(substream);
936 spin_lock_irq(&chip->reg_lock);
937 atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_IN,
940 spin_unlock_irq(&chip->reg_lock);
950 struct atiixp *chip = snd_pcm_substream_chip(substream);
957 err = atiixp_build_dma_packets(chip, dma, substream,
964 struct ac97_pcm *pcm = chip->pcms[dma->ac97_pcm_type];
984 struct atiixp *chip = snd_pcm_substream_chip(substream);
988 struct ac97_pcm *pcm = chip->pcms[dma->ac97_pcm_type];
992 atiixp_clear_dma_packets(chip, dma, substream);
1023 struct atiixp *chip = snd_pcm_substream_chip(substream);
1036 runtime->hw.rates = chip->pcms[pcm_type]->rates;
1048 spin_lock_irq(&chip->reg_lock);
1049 dma->ops->enable_dma(chip, 1);
1050 spin_unlock_irq(&chip->reg_lock);
1059 struct atiixp *chip = snd_pcm_substream_chip(substream);
1063 spin_lock_irq(&chip->reg_lock);
1064 dma->ops->enable_dma(chip, 0);
1065 spin_unlock_irq(&chip->reg_lock);
1075 struct atiixp *chip = snd_pcm_substream_chip(substream);
1078 mutex_lock(&chip->open_mutex);
1079 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
1080 mutex_unlock(&chip->open_mutex);
1083 substream->runtime->hw.channels_max = chip->max_channels;
1084 if (chip->max_channels > 2)
1093 struct atiixp *chip = snd_pcm_substream_chip(substream);
1095 mutex_lock(&chip->open_mutex);
1096 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
1097 mutex_unlock(&chip->open_mutex);
1103 struct atiixp *chip = snd_pcm_substream_chip(substream);
1104 return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_CAPTURE], 1);
1109 struct atiixp *chip = snd_pcm_substream_chip(substream);
1110 return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_CAPTURE]);
1115 struct atiixp *chip = snd_pcm_substream_chip(substream);
1117 mutex_lock(&chip->open_mutex);
1118 if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */
1119 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2);
1121 err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1);
1122 mutex_unlock(&chip->open_mutex);
1128 struct atiixp *chip = snd_pcm_substream_chip(substream);
1130 mutex_lock(&chip->open_mutex);
1131 if (chip->spdif_over_aclink)
1132 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
1134 err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]);
1135 mutex_unlock(&chip->open_mutex);
1236 static int snd_atiixp_pcm_new(struct atiixp *chip)
1240 struct snd_ac97_bus *pbus = chip->ac97_bus;
1244 chip->dmas[ATI_DMA_PLAYBACK].ops = &snd_atiixp_playback_dma_ops;
1245 chip->dmas[ATI_DMA_CAPTURE].ops = &snd_atiixp_capture_dma_ops;
1246 if (! chip->spdif_over_aclink)
1247 chip->dmas[ATI_DMA_SPDIF].ops = &snd_atiixp_spdif_dma_ops;
1250 if (chip->spdif_over_aclink)
1258 chip->pcms[i] = &pbus->pcms[i];
1260 chip->max_channels = 2;
1263 chip->max_channels = 6;
1265 chip->max_channels = 4;
1269 err = snd_pcm_new(chip->card, "ATI IXP AC97",
1275 pcm->private_data = chip;
1277 chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm;
1280 &chip->pci->dev, 64*1024, 128*1024);
1283 snd_pcm_alt_chmaps, chip->max_channels, 0,
1288 chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap;
1291 if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates)
1295 if (chip->pcms[ATI_PCM_SPDIF])
1296 chip->pcms[ATI_PCM_SPDIF]->rates = SNDRV_PCM_RATE_48000;
1299 err = snd_pcm_new(chip->card, "ATI IXP IEC958",
1304 pcm->private_data = chip;
1305 if (chip->spdif_over_aclink)
1309 chip->pcmdevs[ATI_PCMDEV_DIGITAL] = pcm;
1312 &chip->pci->dev, 64*1024, 128*1024);
1316 if (chip->ac97[i])
1317 snd_ac97_update_bits(chip->ac97[i],
1332 struct atiixp *chip = dev_id;
1335 status = atiixp_read(chip, ISR);
1342 snd_atiixp_xrun_dma(chip, &chip->dmas[ATI_DMA_PLAYBACK]);
1344 snd_atiixp_update_dma(chip, &chip->dmas[ATI_DMA_PLAYBACK]);
1346 snd_atiixp_xrun_dma(chip, &chip->dmas[ATI_DMA_CAPTURE]);
1348 snd_atiixp_update_dma(chip, &chip->dmas[ATI_DMA_CAPTURE]);
1349 if (! chip->spdif_over_aclink) {
1351 snd_atiixp_xrun_dma(chip, &chip->dmas[ATI_DMA_SPDIF]);
1353 snd_atiixp_update_dma(chip, &chip->dmas[ATI_DMA_SPDIF]);
1360 spin_lock(&chip->reg_lock);
1361 chip->codec_not_ready_bits |= detected;
1362 atiixp_update(chip, IER, detected, 0); /* disable the detected irqs */
1363 spin_unlock(&chip->reg_lock);
1367 atiixp_write(chip, ISR, status);
1399 static int snd_atiixp_mixer_new(struct atiixp *chip, int clock,
1416 if (snd_atiixp_codec_detect(chip) < 0)
1419 err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus);
1423 chip->ac97_bus = pbus;
1427 if (chip->codec_not_ready_bits & codec_skip[i])
1430 ac97.private_data = chip;
1431 ac97.pci = chip->pci;
1434 if (! chip->spdif_over_aclink)
1436 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i]);
1438 chip->ac97[i] = NULL; /* to be sure */
1439 dev_dbg(chip->card->dev,
1447 dev_err(chip->card->dev, "no codec available\n");
1451 snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override);
1464 struct atiixp *chip = card->private_data;
1469 snd_ac97_suspend(chip->ac97[i]);
1470 snd_atiixp_aclink_down(chip);
1471 snd_atiixp_chip_stop(chip);
1478 struct atiixp *chip = card->private_data;
1481 snd_atiixp_aclink_reset(chip);
1482 snd_atiixp_chip_start(chip);
1485 snd_ac97_resume(chip->ac97[i]);
1488 if (chip->pcmdevs[i]) {
1489 struct atiixp_dma *dma = &chip->dmas[i];
1491 dma->ops->enable_dma(chip, 1);
1494 chip->remap_addr + dma->ops->llp_offset);
1516 struct atiixp *chip = entry->private_data;
1520 snd_iprintf(buffer, "%02x: %08x\n", i, readl(chip->remap_addr + i));
1523 static void snd_atiixp_proc_init(struct atiixp *chip)
1525 snd_card_ro_proc_new(chip->card, "atiixp", chip, snd_atiixp_proc_read);
1539 * constructor for chip instance
1543 struct atiixp *chip = card->private_data;
1550 spin_lock_init(&chip->reg_lock);
1551 mutex_init(&chip->open_mutex);
1552 chip->card = card;
1553 chip->pci = pci;
1554 chip->irq = -1;
1558 chip->addr = pci_resource_start(pci, 0);
1559 chip->remap_addr = pcim_iomap_table(pci)[0];
1562 IRQF_SHARED, KBUILD_MODNAME, chip)) {
1566 chip->irq = pci->irq;
1567 card->sync_irq = chip->irq;
1579 struct atiixp *chip;
1583 sizeof(*chip), &card);
1586 chip = card->private_data;
1594 err = snd_atiixp_aclink_reset(chip);
1598 chip->spdif_over_aclink = spdif_aclink;
1600 err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk);
1604 err = snd_atiixp_pcm_new(chip);
1608 snd_atiixp_proc_init(chip);
1610 snd_atiixp_chip_start(chip);
1615 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
1616 chip->addr, chip->irq);