Lines Matching +full:chip +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * This is modified (by Sasha Khapyorsky <sashak@alsa-project.org>) version
29 static int index = -2; /* Exclude the first card */
38 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
53 ICH_REG_##name##_BDBAR = base + 0x0, /* dword - buffer descriptor list base address */ \
54 ICH_REG_##name##_CIV = base + 0x04, /* byte - current index value */ \
55 ICH_REG_##name##_LVI = base + 0x05, /* byte - last valid index */ \
56 ICH_REG_##name##_SR = base + 0x06, /* byte - status register */ \
57 ICH_REG_##name##_PICB = base + 0x08, /* word - position in current buffer */ \
58 ICH_REG_##name##_PIV = base + 0x0a, /* byte - prefetched index value */ \
59 ICH_REG_##name##_CR = base + 0x0b, /* byte - control register */ \
84 #define ICH_RESETREGS 0x02 /* reset busmaster registers */
89 #define ICH_REG_GLOB_CNT 0x3c /* dword - global control */
94 #define ICH_AC97WARM 0x00000004 /* AC'97 warm reset */
95 #define ICH_AC97COLD 0x00000002 /* AC'97 cold reset */
97 #define ICH_REG_GLOB_STA 0x40 /* dword - global status */
102 #define ICH_P2INT 0x02000000 /* ICH4: PCM2-In interrupt */
103 #define ICH_M2INT 0x01000000 /* ICH4: Mic2-In interrupt */
105 #define ICH_MULTICHAN_CAP 0x00300000 /* ICH4: multi-channel capability bits (RO) */
123 #define ICH_REG_ACC_SEMA 0x44 /* byte - codec write semaphore */
136 #define get_ichdev(substream) (substream->runtime->private_data)
218 * Lowlevel I/O - busmaster
221 static inline u8 igetbyte(struct intel8x0m *chip, u32 offset) in igetbyte() argument
223 return ioread8(chip->bmaddr + offset); in igetbyte()
226 static inline u16 igetword(struct intel8x0m *chip, u32 offset) in igetword() argument
228 return ioread16(chip->bmaddr + offset); in igetword()
231 static inline u32 igetdword(struct intel8x0m *chip, u32 offset) in igetdword() argument
233 return ioread32(chip->bmaddr + offset); in igetdword()
236 static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) in iputbyte() argument
238 iowrite8(val, chip->bmaddr + offset); in iputbyte()
241 static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val) in iputword() argument
243 iowrite16(val, chip->bmaddr + offset); in iputword()
246 static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val) in iputdword() argument
248 iowrite32(val, chip->bmaddr + offset); in iputdword()
252 * Lowlevel I/O - AC'97 registers
255 static inline u16 iagetword(struct intel8x0m *chip, u32 offset) in iagetword() argument
257 return ioread16(chip->addr + offset); in iagetword()
260 static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val) in iaputword() argument
262 iowrite16(val, chip->addr + offset); in iaputword()
274 static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec) in get_ich_codec_bit() argument
284 static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int codec) in snd_intel8x0m_codec_semaphore() argument
289 return -EIO; in snd_intel8x0m_codec_semaphore()
290 codec = get_ich_codec_bit(chip, codec); in snd_intel8x0m_codec_semaphore()
293 if ((igetdword(chip, ICHREG(GLOB_STA)) & codec) == 0) in snd_intel8x0m_codec_semaphore()
294 return -EIO; in snd_intel8x0m_codec_semaphore()
299 if (!(igetbyte(chip, ICHREG(ACC_SEMA)) & ICH_CAS)) in snd_intel8x0m_codec_semaphore()
302 } while (time--); in snd_intel8x0m_codec_semaphore()
305 * reset the semaphore. So even if you don't get the semaphore, still in snd_intel8x0m_codec_semaphore()
307 dev_err(chip->card->dev, in snd_intel8x0m_codec_semaphore()
309 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA))); in snd_intel8x0m_codec_semaphore()
310 iagetword(chip, 0); /* clear semaphore flag */ in snd_intel8x0m_codec_semaphore()
312 return -EBUSY; in snd_intel8x0m_codec_semaphore()
319 struct intel8x0m *chip = ac97->private_data; in snd_intel8x0m_codec_write() local
321 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { in snd_intel8x0m_codec_write()
322 if (! chip->in_ac97_init) in snd_intel8x0m_codec_write()
323 dev_err(chip->card->dev, in snd_intel8x0m_codec_write()
325 ac97->num, reg); in snd_intel8x0m_codec_write()
327 iaputword(chip, reg + ac97->num * 0x80, val); in snd_intel8x0m_codec_write()
333 struct intel8x0m *chip = ac97->private_data; in snd_intel8x0m_codec_read() local
337 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { in snd_intel8x0m_codec_read()
338 if (! chip->in_ac97_init) in snd_intel8x0m_codec_read()
339 dev_err(chip->card->dev, in snd_intel8x0m_codec_read()
341 ac97->num, reg); in snd_intel8x0m_codec_read()
344 res = iagetword(chip, reg + ac97->num * 0x80); in snd_intel8x0m_codec_read()
345 tmp = igetdword(chip, ICHREG(GLOB_STA)); in snd_intel8x0m_codec_read()
347 /* reset RCS and preserve other R/WC bits */ in snd_intel8x0m_codec_read()
348 iputdword(chip, ICHREG(GLOB_STA), in snd_intel8x0m_codec_read()
350 if (! chip->in_ac97_init) in snd_intel8x0m_codec_read()
351 dev_err(chip->card->dev, in snd_intel8x0m_codec_read()
353 ac97->num, reg); in snd_intel8x0m_codec_read()
358 iagetword(chip, 0); /* clear semaphore */ in snd_intel8x0m_codec_read()
366 static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *ichdev) in snd_intel8x0m_setup_periods() argument
369 __le32 *bdbar = ichdev->bdbar; in snd_intel8x0m_setup_periods()
370 unsigned long port = ichdev->reg_offset; in snd_intel8x0m_setup_periods()
372 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr); in snd_intel8x0m_setup_periods()
373 if (ichdev->size == ichdev->fragsize) { in snd_intel8x0m_setup_periods()
374 ichdev->ack_reload = ichdev->ack = 2; in snd_intel8x0m_setup_periods()
375 ichdev->fragsize1 = ichdev->fragsize >> 1; in snd_intel8x0m_setup_periods()
377 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf); in snd_intel8x0m_setup_periods()
379 ichdev->fragsize1 >> chip->pcm_pos_shift); in snd_intel8x0m_setup_periods()
380 bdbar[idx + 2] = cpu_to_le32(ichdev->physbuf + (ichdev->size >> 1)); in snd_intel8x0m_setup_periods()
382 ichdev->fragsize1 >> chip->pcm_pos_shift); in snd_intel8x0m_setup_periods()
384 ichdev->frags = 2; in snd_intel8x0m_setup_periods()
386 ichdev->ack_reload = ichdev->ack = 1; in snd_intel8x0m_setup_periods()
387 ichdev->fragsize1 = ichdev->fragsize; in snd_intel8x0m_setup_periods()
389 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size)); in snd_intel8x0m_setup_periods()
391 ichdev->fragsize >> chip->pcm_pos_shift); in snd_intel8x0m_setup_periods()
393 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n", in snd_intel8x0m_setup_periods()
397 ichdev->frags = ichdev->size / ichdev->fragsize; in snd_intel8x0m_setup_periods()
399 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK); in snd_intel8x0m_setup_periods()
400 ichdev->civ = 0; in snd_intel8x0m_setup_periods()
401 iputbyte(chip, port + ICH_REG_OFF_CIV, 0); in snd_intel8x0m_setup_periods()
402 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; in snd_intel8x0m_setup_periods()
403 ichdev->position = 0; in snd_intel8x0m_setup_periods()
405 dev_dbg(chip->card->dev, in snd_intel8x0m_setup_periods()
407 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, in snd_intel8x0m_setup_periods()
408 ichdev->fragsize1); in snd_intel8x0m_setup_periods()
411 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in snd_intel8x0m_setup_periods()
418 static inline void snd_intel8x0m_update(struct intel8x0m *chip, struct ichdev *ichdev) in snd_intel8x0m_update() argument
420 unsigned long port = ichdev->reg_offset; in snd_intel8x0m_update()
424 civ = igetbyte(chip, port + ICH_REG_OFF_CIV); in snd_intel8x0m_update()
425 if (civ == ichdev->civ) { in snd_intel8x0m_update()
427 ichdev->civ++; in snd_intel8x0m_update()
428 ichdev->civ &= ICH_REG_LVI_MASK; in snd_intel8x0m_update()
430 step = civ - ichdev->civ; in snd_intel8x0m_update()
433 ichdev->civ = civ; in snd_intel8x0m_update()
436 ichdev->position += step * ichdev->fragsize1; in snd_intel8x0m_update()
437 ichdev->position %= ichdev->size; in snd_intel8x0m_update()
438 ichdev->lvi += step; in snd_intel8x0m_update()
439 ichdev->lvi &= ICH_REG_LVI_MASK; in snd_intel8x0m_update()
440 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi); in snd_intel8x0m_update()
442 ichdev->lvi_frag++; in snd_intel8x0m_update()
443 ichdev->lvi_frag %= ichdev->frags; in snd_intel8x0m_update()
444 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + in snd_intel8x0m_update()
445 ichdev->lvi_frag * in snd_intel8x0m_update()
446 ichdev->fragsize1); in snd_intel8x0m_update()
448 dev_dbg(chip->card->dev, in snd_intel8x0m_update()
450 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], in snd_intel8x0m_update()
451 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), in snd_intel8x0m_update()
454 if (--ichdev->ack == 0) { in snd_intel8x0m_update()
455 ichdev->ack = ichdev->ack_reload; in snd_intel8x0m_update()
459 if (ack && ichdev->substream) { in snd_intel8x0m_update()
460 spin_unlock(&chip->reg_lock); in snd_intel8x0m_update()
461 snd_pcm_period_elapsed(ichdev->substream); in snd_intel8x0m_update()
462 spin_lock(&chip->reg_lock); in snd_intel8x0m_update()
464 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); in snd_intel8x0m_update()
469 struct intel8x0m *chip = dev_id; in snd_intel8x0m_interrupt() local
474 spin_lock(&chip->reg_lock); in snd_intel8x0m_interrupt()
475 status = igetdword(chip, chip->int_sta_reg); in snd_intel8x0m_interrupt()
477 spin_unlock(&chip->reg_lock); in snd_intel8x0m_interrupt()
480 if ((status & chip->int_sta_mask) == 0) { in snd_intel8x0m_interrupt()
482 iputdword(chip, chip->int_sta_reg, status); in snd_intel8x0m_interrupt()
483 spin_unlock(&chip->reg_lock); in snd_intel8x0m_interrupt()
487 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0m_interrupt()
488 ichdev = &chip->ichd[i]; in snd_intel8x0m_interrupt()
489 if (status & ichdev->int_sta_mask) in snd_intel8x0m_interrupt()
490 snd_intel8x0m_update(chip, ichdev); in snd_intel8x0m_interrupt()
494 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask); in snd_intel8x0m_interrupt()
495 spin_unlock(&chip->reg_lock); in snd_intel8x0m_interrupt()
506 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_pcm_trigger() local
509 unsigned long port = ichdev->reg_offset; in snd_intel8x0m_pcm_trigger()
527 return -EINVAL; in snd_intel8x0m_pcm_trigger()
529 iputbyte(chip, port + ICH_REG_OFF_CR, val); in snd_intel8x0m_pcm_trigger()
532 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ; in snd_intel8x0m_pcm_trigger()
533 /* reset whole DMA things */ in snd_intel8x0m_pcm_trigger()
534 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); in snd_intel8x0m_pcm_trigger()
541 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_pcm_pointer() local
545 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << chip->pcm_pos_shift; in snd_intel8x0m_pcm_pointer()
547 ptr = ichdev->fragsize1 - ptr1; in snd_intel8x0m_pcm_pointer()
550 ptr += ichdev->position; in snd_intel8x0m_pcm_pointer()
551 if (ptr >= ichdev->size) in snd_intel8x0m_pcm_pointer()
553 return bytes_to_frames(substream->runtime, ptr); in snd_intel8x0m_pcm_pointer()
558 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_pcm_prepare() local
559 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0m_pcm_prepare()
562 ichdev->physbuf = runtime->dma_addr; in snd_intel8x0m_pcm_prepare()
563 ichdev->size = snd_pcm_lib_buffer_bytes(substream); in snd_intel8x0m_pcm_prepare()
564 ichdev->fragsize = snd_pcm_lib_period_bytes(substream); in snd_intel8x0m_pcm_prepare()
565 snd_ac97_write(ichdev->ac97, AC97_LINE1_RATE, runtime->rate); in snd_intel8x0m_pcm_prepare()
566 snd_ac97_write(ichdev->ac97, AC97_LINE1_LEVEL, 0); in snd_intel8x0m_pcm_prepare()
567 snd_intel8x0m_setup_periods(chip, ichdev); in snd_intel8x0m_pcm_prepare()
601 struct snd_pcm_runtime *runtime = substream->runtime; in snd_intel8x0m_pcm_open()
604 ichdev->substream = substream; in snd_intel8x0m_pcm_open()
605 runtime->hw = snd_intel8x0m_stream; in snd_intel8x0m_pcm_open()
610 runtime->private_data = ichdev; in snd_intel8x0m_pcm_open()
616 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_playback_open() local
618 return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMOUT]); in snd_intel8x0m_playback_open()
623 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_playback_close() local
625 chip->ichd[ICHD_MDMOUT].substream = NULL; in snd_intel8x0m_playback_close()
631 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_capture_open() local
633 return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMIN]); in snd_intel8x0m_capture_open()
638 struct intel8x0m *chip = snd_pcm_substream_chip(substream); in snd_intel8x0m_capture_close() local
640 chip->ichd[ICHD_MDMIN].substream = NULL; in snd_intel8x0m_capture_close()
671 static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device, in snd_intel8x0m_pcm1() argument
678 if (rec->suffix) in snd_intel8x0m_pcm1()
679 sprintf(name, "Intel ICH - %s", rec->suffix); in snd_intel8x0m_pcm1()
682 err = snd_pcm_new(chip->card, name, device, in snd_intel8x0m_pcm1()
683 rec->playback_ops ? 1 : 0, in snd_intel8x0m_pcm1()
684 rec->capture_ops ? 1 : 0, &pcm); in snd_intel8x0m_pcm1()
688 if (rec->playback_ops) in snd_intel8x0m_pcm1()
689 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, rec->playback_ops); in snd_intel8x0m_pcm1()
690 if (rec->capture_ops) in snd_intel8x0m_pcm1()
691 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, rec->capture_ops); in snd_intel8x0m_pcm1()
693 pcm->private_data = chip; in snd_intel8x0m_pcm1()
694 pcm->info_flags = 0; in snd_intel8x0m_pcm1()
695 pcm->dev_class = SNDRV_PCM_CLASS_MODEM; in snd_intel8x0m_pcm1()
696 if (rec->suffix) in snd_intel8x0m_pcm1()
697 sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix); in snd_intel8x0m_pcm1()
699 strcpy(pcm->name, chip->card->shortname); in snd_intel8x0m_pcm1()
700 chip->pcm[device] = pcm; in snd_intel8x0m_pcm1()
703 &chip->pci->dev, in snd_intel8x0m_pcm1()
704 rec->prealloc_size, in snd_intel8x0m_pcm1()
705 rec->prealloc_max_size); in snd_intel8x0m_pcm1()
720 static int snd_intel8x0m_pcm(struct intel8x0m *chip) in snd_intel8x0m_pcm() argument
729 switch (chip->device_type) { in snd_intel8x0m_pcm()
747 if (i > 0 && rec->ac97_idx) { in snd_intel8x0m_pcm()
749 if (! chip->ichd[rec->ac97_idx].ac97) in snd_intel8x0m_pcm()
752 err = snd_intel8x0m_pcm1(chip, device, rec); in snd_intel8x0m_pcm()
758 chip->pcm_devs = device; in snd_intel8x0m_pcm()
769 struct intel8x0m *chip = bus->private_data; in snd_intel8x0m_mixer_free_ac97_bus() local
770 chip->ac97_bus = NULL; in snd_intel8x0m_mixer_free_ac97_bus()
775 struct intel8x0m *chip = ac97->private_data; in snd_intel8x0m_mixer_free_ac97() local
776 chip->ac97 = NULL; in snd_intel8x0m_mixer_free_ac97()
780 static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock) in snd_intel8x0m_mixer() argument
792 chip->in_ac97_init = 1; in snd_intel8x0m_mixer()
795 ac97.private_data = chip; in snd_intel8x0m_mixer()
799 glob_sta = igetdword(chip, ICHREG(GLOB_STA)); in snd_intel8x0m_mixer()
801 err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus); in snd_intel8x0m_mixer()
804 pbus->private_free = snd_intel8x0m_mixer_free_ac97_bus; in snd_intel8x0m_mixer()
806 pbus->clock = ac97_clock; in snd_intel8x0m_mixer()
807 chip->ac97_bus = pbus; in snd_intel8x0m_mixer()
809 ac97.pci = chip->pci; in snd_intel8x0m_mixer()
813 dev_err(chip->card->dev, in snd_intel8x0m_mixer()
819 chip->ac97 = x97; in snd_intel8x0m_mixer()
820 if(ac97_is_modem(x97) && !chip->ichd[ICHD_MDMIN].ac97) { in snd_intel8x0m_mixer()
821 chip->ichd[ICHD_MDMIN].ac97 = x97; in snd_intel8x0m_mixer()
822 chip->ichd[ICHD_MDMOUT].ac97 = x97; in snd_intel8x0m_mixer()
825 chip->in_ac97_init = 0; in snd_intel8x0m_mixer()
829 /* clear the cold-reset bit for the next chance */ in snd_intel8x0m_mixer()
830 if (chip->device_type != DEVICE_ALI) in snd_intel8x0m_mixer()
831 iputdword(chip, ICHREG(GLOB_CNT), in snd_intel8x0m_mixer()
832 igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD); in snd_intel8x0m_mixer()
841 static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing) in snd_intel8x0m_ich_chip_init() argument
849 cnt = igetdword(chip, ICHREG(GLOB_STA)); in snd_intel8x0m_ich_chip_init()
850 iputdword(chip, ICHREG(GLOB_STA), cnt & status); in snd_intel8x0m_ich_chip_init()
853 cnt = igetdword(chip, ICHREG(GLOB_CNT)); in snd_intel8x0m_ich_chip_init()
855 /* finish cold or do warm reset */ in snd_intel8x0m_ich_chip_init()
857 iputdword(chip, ICHREG(GLOB_CNT), cnt); in snd_intel8x0m_ich_chip_init()
858 usleep_range(500, 1000); /* give warm reset some time */ in snd_intel8x0m_ich_chip_init()
861 if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0) in snd_intel8x0m_ich_chip_init()
865 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n", in snd_intel8x0m_ich_chip_init()
866 igetdword(chip, ICHREG(GLOB_CNT))); in snd_intel8x0m_ich_chip_init()
867 return -EIO; in snd_intel8x0m_ich_chip_init()
877 status = igetdword(chip, ICHREG(GLOB_STA)) & in snd_intel8x0m_ich_chip_init()
885 dev_err(chip->card->dev, in snd_intel8x0m_ich_chip_init()
887 igetdword(chip, ICHREG(GLOB_STA))); in snd_intel8x0m_ich_chip_init()
888 return -EIO; in snd_intel8x0m_ich_chip_init()
898 status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus; in snd_intel8x0m_ich_chip_init()
904 if (chip->ac97) in snd_intel8x0m_ich_chip_init()
905 status |= get_ich_codec_bit(chip, chip->ac97->num); in snd_intel8x0m_ich_chip_init()
909 nstatus = igetdword(chip, ICHREG(GLOB_STA)) & in snd_intel8x0m_ich_chip_init()
917 if (chip->device_type == DEVICE_SIS) { in snd_intel8x0m_ich_chip_init()
919 iputword(chip, 0x4c, igetword(chip, 0x4c) | 1); in snd_intel8x0m_ich_chip_init()
925 static int snd_intel8x0m_chip_init(struct intel8x0m *chip, int probing) in snd_intel8x0m_chip_init() argument
930 err = snd_intel8x0m_ich_chip_init(chip, probing); in snd_intel8x0m_chip_init()
933 iagetword(chip, 0); /* clear semaphore flag */ in snd_intel8x0m_chip_init()
936 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0m_chip_init()
937 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); in snd_intel8x0m_chip_init()
938 /* reset channels */ in snd_intel8x0m_chip_init()
939 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0m_chip_init()
940 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); in snd_intel8x0m_chip_init()
942 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0m_chip_init()
943 iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, chip->ichd[i].bdbar_addr); in snd_intel8x0m_chip_init()
949 struct intel8x0m *chip = card->private_data; in snd_intel8x0m_free() local
952 if (chip->irq < 0) in snd_intel8x0m_free()
955 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0m_free()
956 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00); in snd_intel8x0m_free()
957 /* reset channels */ in snd_intel8x0m_free()
958 for (i = 0; i < chip->bdbars_count; i++) in snd_intel8x0m_free()
959 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); in snd_intel8x0m_free()
961 if (chip->irq >= 0) in snd_intel8x0m_free()
962 free_irq(chip->irq, chip); in snd_intel8x0m_free()
971 struct intel8x0m *chip = card->private_data; in intel8x0m_suspend() local
974 snd_ac97_suspend(chip->ac97); in intel8x0m_suspend()
975 if (chip->irq >= 0) { in intel8x0m_suspend()
976 free_irq(chip->irq, chip); in intel8x0m_suspend()
977 chip->irq = -1; in intel8x0m_suspend()
978 card->sync_irq = -1; in intel8x0m_suspend()
987 struct intel8x0m *chip = card->private_data; in intel8x0m_resume() local
989 if (request_irq(pci->irq, snd_intel8x0m_interrupt, in intel8x0m_resume()
990 IRQF_SHARED, KBUILD_MODNAME, chip)) { in intel8x0m_resume()
992 pci->irq); in intel8x0m_resume()
994 return -EIO; in intel8x0m_resume()
996 chip->irq = pci->irq; in intel8x0m_resume()
997 card->sync_irq = chip->irq; in intel8x0m_resume()
998 snd_intel8x0m_chip_init(chip, 0); in intel8x0m_resume()
999 snd_ac97_resume(chip->ac97); in intel8x0m_resume()
1010 struct intel8x0m *chip = entry->private_data; in snd_intel8x0m_proc_read() local
1014 if (chip->device_type == DEVICE_ALI) in snd_intel8x0m_proc_read()
1016 tmp = igetdword(chip, ICHREG(GLOB_STA)); in snd_intel8x0m_proc_read()
1018 igetdword(chip, ICHREG(GLOB_CNT))); in snd_intel8x0m_proc_read()
1027 static void snd_intel8x0m_proc_init(struct intel8x0m *chip) in snd_intel8x0m_proc_init() argument
1029 snd_card_ro_proc_new(chip->card, "intel8x0m", chip, in snd_intel8x0m_proc_init()
1042 struct intel8x0m *chip = card->private_data; in snd_intel8x0m_init() local
1057 spin_lock_init(&chip->reg_lock); in snd_intel8x0m_init()
1058 chip->device_type = device_type; in snd_intel8x0m_init()
1059 chip->card = card; in snd_intel8x0m_init()
1060 chip->pci = pci; in snd_intel8x0m_init()
1061 chip->irq = -1; in snd_intel8x0m_init()
1063 err = pci_request_regions(pci, card->shortname); in snd_intel8x0m_init()
1069 chip->bmaddr = pcim_iomap(pci, 0, 0); in snd_intel8x0m_init()
1072 chip->addr = pcim_iomap(pci, 2, 0); in snd_intel8x0m_init()
1074 chip->addr = pcim_iomap(pci, 0, 0); in snd_intel8x0m_init()
1076 chip->bmaddr = pcim_iomap(pci, 3, 0); in snd_intel8x0m_init()
1078 chip->bmaddr = pcim_iomap(pci, 1, 0); in snd_intel8x0m_init()
1082 chip->bdbars_count = 2; in snd_intel8x0m_init()
1085 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0m_init()
1086 ichdev = &chip->ichd[i]; in snd_intel8x0m_init()
1087 ichdev->ichd = i; in snd_intel8x0m_init()
1088 ichdev->reg_offset = tbl[i].offset; in snd_intel8x0m_init()
1089 ichdev->int_sta_mask = tbl[i].int_sta_mask; in snd_intel8x0m_init()
1092 ichdev->roff_sr = ICH_REG_OFF_PICB; in snd_intel8x0m_init()
1093 ichdev->roff_picb = ICH_REG_OFF_SR; in snd_intel8x0m_init()
1095 ichdev->roff_sr = ICH_REG_OFF_SR; in snd_intel8x0m_init()
1096 ichdev->roff_picb = ICH_REG_OFF_PICB; in snd_intel8x0m_init()
1099 ichdev->ali_slot = (ichdev->reg_offset - 0x40) / 0x10; in snd_intel8x0m_init()
1102 chip->pcm_pos_shift = (device_type == DEVICE_SIS) ? 0 : 1; in snd_intel8x0m_init()
1106 chip->bdbars = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, in snd_intel8x0m_init()
1107 chip->bdbars_count * sizeof(u32) * in snd_intel8x0m_init()
1109 if (!chip->bdbars) in snd_intel8x0m_init()
1110 return -ENOMEM; in snd_intel8x0m_init()
1115 for (i = 0; i < chip->bdbars_count; i++) { in snd_intel8x0m_init()
1116 ichdev = &chip->ichd[i]; in snd_intel8x0m_init()
1117 ichdev->bdbar = ((__le32 *)chip->bdbars->area) + (i * ICH_MAX_FRAGS * 2); in snd_intel8x0m_init()
1118 ichdev->bdbar_addr = chip->bdbars->addr + (i * sizeof(u32) * ICH_MAX_FRAGS * 2); in snd_intel8x0m_init()
1119 int_sta_masks |= ichdev->int_sta_mask; in snd_intel8x0m_init()
1121 chip->int_sta_reg = ICH_REG_GLOB_STA; in snd_intel8x0m_init()
1122 chip->int_sta_mask = int_sta_masks; in snd_intel8x0m_init()
1126 err = snd_intel8x0m_chip_init(chip, 1); in snd_intel8x0m_init()
1131 * re-acquired in PM callbacks. in snd_intel8x0m_init()
1134 if (request_irq(pci->irq, snd_intel8x0m_interrupt, IRQF_SHARED, in snd_intel8x0m_init()
1135 KBUILD_MODNAME, chip)) { in snd_intel8x0m_init()
1136 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_intel8x0m_init()
1137 return -EBUSY; in snd_intel8x0m_init()
1139 chip->irq = pci->irq; in snd_intel8x0m_init()
1140 card->sync_irq = chip->irq; in snd_intel8x0m_init()
1142 card->private_free = snd_intel8x0m_free; in snd_intel8x0m_init()
1151 { PCI_DEVICE_ID_INTEL_82801AA_6, "Intel 82801AA-ICH" },
1152 { PCI_DEVICE_ID_INTEL_82801AB_6, "Intel 82901AB-ICH0" },
1153 { PCI_DEVICE_ID_INTEL_82801BA_6, "Intel 82801BA-ICH2" },
1155 { PCI_DEVICE_ID_INTEL_82801CA_6, "Intel 82801CA-ICH3" },
1156 { PCI_DEVICE_ID_INTEL_82801DB_6, "Intel 82801DB-ICH4" },
1177 struct intel8x0m *chip; in __snd_intel8x0m_probe() local
1181 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, in __snd_intel8x0m_probe()
1182 sizeof(*chip), &card); in __snd_intel8x0m_probe()
1185 chip = card->private_data; in __snd_intel8x0m_probe()
1187 strcpy(card->driver, "ICH-MODEM"); in __snd_intel8x0m_probe()
1188 strcpy(card->shortname, "Intel ICH"); in __snd_intel8x0m_probe()
1189 for (name = shortnames; name->id; name++) { in __snd_intel8x0m_probe()
1190 if (pci->device == name->id) { in __snd_intel8x0m_probe()
1191 strcpy(card->shortname, name->s); in __snd_intel8x0m_probe()
1195 strcat(card->shortname," Modem"); in __snd_intel8x0m_probe()
1197 err = snd_intel8x0m_init(card, pci, pci_id->driver_data); in __snd_intel8x0m_probe()
1201 err = snd_intel8x0m_mixer(chip, ac97_clock); in __snd_intel8x0m_probe()
1204 err = snd_intel8x0m_pcm(chip); in __snd_intel8x0m_probe()
1208 snd_intel8x0m_proc_init(chip); in __snd_intel8x0m_probe()
1210 sprintf(card->longname, "%s at irq %i", in __snd_intel8x0m_probe()
1211 card->shortname, chip->irq); in __snd_intel8x0m_probe()
1223 return snd_card_free_on_error(&pci->dev, __snd_intel8x0m_probe(pci, pci_id)); in snd_intel8x0m_probe()