Lines Matching refs:chip
221 static inline u8 igetbyte(struct intel8x0m *chip, u32 offset)
223 return ioread8(chip->bmaddr + offset);
226 static inline u16 igetword(struct intel8x0m *chip, u32 offset)
228 return ioread16(chip->bmaddr + offset);
231 static inline u32 igetdword(struct intel8x0m *chip, u32 offset)
233 return ioread32(chip->bmaddr + offset);
236 static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val)
238 iowrite8(val, chip->bmaddr + offset);
241 static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val)
243 iowrite16(val, chip->bmaddr + offset);
246 static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val)
248 iowrite32(val, chip->bmaddr + offset);
255 static inline u16 iagetword(struct intel8x0m *chip, u32 offset)
257 return ioread16(chip->addr + offset);
260 static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val)
262 iowrite16(val, chip->addr + offset);
274 static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec)
284 static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int codec)
290 codec = get_ich_codec_bit(chip, codec);
293 if ((igetdword(chip, ICHREG(GLOB_STA)) & codec) == 0)
299 if (!(igetbyte(chip, ICHREG(ACC_SEMA)) & ICH_CAS))
307 dev_err(chip->card->dev,
309 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
310 iagetword(chip, 0); /* clear semaphore flag */
319 struct intel8x0m *chip = ac97->private_data;
321 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
322 if (! chip->in_ac97_init)
323 dev_err(chip->card->dev,
327 iaputword(chip, reg + ac97->num * 0x80, val);
333 struct intel8x0m *chip = ac97->private_data;
337 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
338 if (! chip->in_ac97_init)
339 dev_err(chip->card->dev,
344 res = iagetword(chip, reg + ac97->num * 0x80);
345 tmp = igetdword(chip, ICHREG(GLOB_STA));
348 iputdword(chip, ICHREG(GLOB_STA),
350 if (! chip->in_ac97_init)
351 dev_err(chip->card->dev,
358 iagetword(chip, 0); /* clear semaphore */
366 static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *ichdev)
372 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
379 ichdev->fragsize1 >> chip->pcm_pos_shift);
382 ichdev->fragsize1 >> chip->pcm_pos_shift);
391 ichdev->fragsize >> chip->pcm_pos_shift);
393 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
399 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK);
401 iputbyte(chip, port + ICH_REG_OFF_CIV, 0);
405 dev_dbg(chip->card->dev,
411 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
418 static inline void snd_intel8x0m_update(struct intel8x0m *chip, struct ichdev *ichdev)
424 civ = igetbyte(chip, port + ICH_REG_OFF_CIV);
443 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
451 dev_dbg(chip->card->dev,
463 spin_unlock(&chip->reg_lock);
465 spin_lock(&chip->reg_lock);
467 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
472 struct intel8x0m *chip = dev_id;
477 spin_lock(&chip->reg_lock);
478 status = igetdword(chip, chip->int_sta_reg);
480 spin_unlock(&chip->reg_lock);
483 if ((status & chip->int_sta_mask) == 0) {
485 iputdword(chip, chip->int_sta_reg, status);
486 spin_unlock(&chip->reg_lock);
490 for (i = 0; i < chip->bdbars_count; i++) {
491 ichdev = &chip->ichd[i];
493 snd_intel8x0m_update(chip, ichdev);
497 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask);
498 spin_unlock(&chip->reg_lock);
509 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
532 iputbyte(chip, port + ICH_REG_OFF_CR, val);
535 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ;
537 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS);
544 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
548 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << chip->pcm_pos_shift;
561 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
570 snd_intel8x0m_setup_periods(chip, ichdev);
619 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
621 return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMOUT]);
626 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
628 chip->ichd[ICHD_MDMOUT].substream = NULL;
634 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
636 return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMIN]);
641 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
643 chip->ichd[ICHD_MDMIN].substream = NULL;
674 static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device,
685 err = snd_pcm_new(chip->card, name, device,
696 pcm->private_data = chip;
700 sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix);
702 strcpy(pcm->name, chip->card->shortname);
703 chip->pcm[device] = pcm;
706 &chip->pci->dev,
723 static int snd_intel8x0m_pcm(struct intel8x0m *chip)
732 switch (chip->device_type) {
752 if (! chip->ichd[rec->ac97_idx].ac97)
755 err = snd_intel8x0m_pcm1(chip, device, rec);
761 chip->pcm_devs = device;
772 struct intel8x0m *chip = bus->private_data;
773 chip->ac97_bus = NULL;
778 struct intel8x0m *chip = ac97->private_data;
779 chip->ac97 = NULL;
783 static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock)
795 chip->in_ac97_init = 1;
798 ac97.private_data = chip;
802 glob_sta = igetdword(chip, ICHREG(GLOB_STA));
804 err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus);
810 chip->ac97_bus = pbus;
812 ac97.pci = chip->pci;
816 dev_err(chip->card->dev,
822 chip->ac97 = x97;
823 if(ac97_is_modem(x97) && !chip->ichd[ICHD_MDMIN].ac97) {
824 chip->ichd[ICHD_MDMIN].ac97 = x97;
825 chip->ichd[ICHD_MDMOUT].ac97 = x97;
828 chip->in_ac97_init = 0;
833 if (chip->device_type != DEVICE_ALI)
834 iputdword(chip, ICHREG(GLOB_CNT),
835 igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD);
844 static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
852 cnt = igetdword(chip, ICHREG(GLOB_STA));
853 iputdword(chip, ICHREG(GLOB_STA), cnt & status);
856 cnt = igetdword(chip, ICHREG(GLOB_CNT));
860 iputdword(chip, ICHREG(GLOB_CNT), cnt);
864 if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
868 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
869 igetdword(chip, ICHREG(GLOB_CNT)));
880 status = igetdword(chip, ICHREG(GLOB_STA)) &
888 dev_err(chip->card->dev,
890 igetdword(chip, ICHREG(GLOB_STA)));
901 status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus;
907 if (chip->ac97)
908 status |= get_ich_codec_bit(chip, chip->ac97->num);
912 nstatus = igetdword(chip, ICHREG(GLOB_STA)) &
920 if (chip->device_type == DEVICE_SIS) {
922 iputword(chip, 0x4c, igetword(chip, 0x4c) | 1);
928 static int snd_intel8x0m_chip_init(struct intel8x0m *chip, int probing)
933 err = snd_intel8x0m_ich_chip_init(chip, probing);
936 iagetword(chip, 0); /* clear semaphore flag */
939 for (i = 0; i < chip->bdbars_count; i++)
940 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00);
942 for (i = 0; i < chip->bdbars_count; i++)
943 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
945 for (i = 0; i < chip->bdbars_count; i++)
946 iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, chip->ichd[i].bdbar_addr);
952 struct intel8x0m *chip = card->private_data;
955 if (chip->irq < 0)
958 for (i = 0; i < chip->bdbars_count; i++)
959 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00);
961 for (i = 0; i < chip->bdbars_count; i++)
962 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
964 if (chip->irq >= 0)
965 free_irq(chip->irq, chip);
975 struct intel8x0m *chip = card->private_data;
978 snd_ac97_suspend(chip->ac97);
979 if (chip->irq >= 0) {
980 free_irq(chip->irq, chip);
981 chip->irq = -1;
991 struct intel8x0m *chip = card->private_data;
994 IRQF_SHARED, KBUILD_MODNAME, chip)) {
1000 chip->irq = pci->irq;
1001 card->sync_irq = chip->irq;
1002 snd_intel8x0m_chip_init(chip, 0);
1003 snd_ac97_resume(chip->ac97);
1018 struct intel8x0m *chip = entry->private_data;
1022 if (chip->device_type == DEVICE_ALI)
1024 tmp = igetdword(chip, ICHREG(GLOB_STA));
1026 igetdword(chip, ICHREG(GLOB_CNT)));
1035 static void snd_intel8x0m_proc_init(struct intel8x0m *chip)
1037 snd_card_ro_proc_new(chip->card, "intel8x0m", chip,
1050 struct intel8x0m *chip = card->private_data;
1065 spin_lock_init(&chip->reg_lock);
1066 chip->device_type = device_type;
1067 chip->card = card;
1068 chip->pci = pci;
1069 chip->irq = -1;
1077 chip->bmaddr = pcim_iomap(pci, 0, 0);
1080 chip->addr = pcim_iomap(pci, 2, 0);
1082 chip->addr = pcim_iomap(pci, 0, 0);
1084 chip->bmaddr = pcim_iomap(pci, 3, 0);
1086 chip->bmaddr = pcim_iomap(pci, 1, 0);
1090 chip->bdbars_count = 2;
1093 for (i = 0; i < chip->bdbars_count; i++) {
1094 ichdev = &chip->ichd[i];
1110 chip->pcm_pos_shift = (device_type == DEVICE_SIS) ? 0 : 1;
1114 chip->bdbars = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV,
1115 chip->bdbars_count * sizeof(u32) *
1117 if (!chip->bdbars)
1123 for (i = 0; i < chip->bdbars_count; i++) {
1124 ichdev = &chip->ichd[i];
1125 ichdev->bdbar = ((__le32 *)chip->bdbars->area) + (i * ICH_MAX_FRAGS * 2);
1126 ichdev->bdbar_addr = chip->bdbars->addr + (i * sizeof(u32) * ICH_MAX_FRAGS * 2);
1129 chip->int_sta_reg = ICH_REG_GLOB_STA;
1130 chip->int_sta_mask = int_sta_masks;
1134 err = snd_intel8x0m_chip_init(chip, 1);
1143 KBUILD_MODNAME, chip)) {
1147 chip->irq = pci->irq;
1148 card->sync_irq = chip->irq;
1185 struct intel8x0m *chip;
1190 sizeof(*chip), &card);
1193 chip = card->private_data;
1209 err = snd_intel8x0m_mixer(chip, ac97_clock);
1212 err = snd_intel8x0m_pcm(chip);
1216 snd_intel8x0m_proc_init(chip);
1219 card->shortname, chip->irq);