Lines Matching refs:chip

236 static inline u8 igetbyte(struct intel8x0m *chip, u32 offset)
238 return ioread8(chip->bmaddr + offset);
241 static inline u16 igetword(struct intel8x0m *chip, u32 offset)
243 return ioread16(chip->bmaddr + offset);
246 static inline u32 igetdword(struct intel8x0m *chip, u32 offset)
248 return ioread32(chip->bmaddr + offset);
251 static inline void iputbyte(struct intel8x0m *chip, u32 offset, u8 val)
253 iowrite8(val, chip->bmaddr + offset);
256 static inline void iputword(struct intel8x0m *chip, u32 offset, u16 val)
258 iowrite16(val, chip->bmaddr + offset);
261 static inline void iputdword(struct intel8x0m *chip, u32 offset, u32 val)
263 iowrite32(val, chip->bmaddr + offset);
270 static inline u16 iagetword(struct intel8x0m *chip, u32 offset)
272 return ioread16(chip->addr + offset);
275 static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val)
277 iowrite16(val, chip->addr + offset);
289 static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec)
299 static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int codec)
305 codec = get_ich_codec_bit(chip, codec);
308 if ((igetdword(chip, ICHREG(GLOB_STA)) & codec) == 0)
314 if (!(igetbyte(chip, ICHREG(ACC_SEMA)) & ICH_CAS))
322 dev_err(chip->card->dev,
324 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
325 iagetword(chip, 0); /* clear semaphore flag */
334 struct intel8x0m *chip = ac97->private_data;
336 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
337 if (! chip->in_ac97_init)
338 dev_err(chip->card->dev,
342 iaputword(chip, reg + ac97->num * 0x80, val);
348 struct intel8x0m *chip = ac97->private_data;
352 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
353 if (! chip->in_ac97_init)
354 dev_err(chip->card->dev,
359 res = iagetword(chip, reg + ac97->num * 0x80);
360 if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) {
362 iputdword(chip, ICHREG(GLOB_STA),
364 if (! chip->in_ac97_init)
365 dev_err(chip->card->dev,
372 iagetword(chip, 0); /* clear semaphore */
380 static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *ichdev)
386 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
393 ichdev->fragsize1 >> chip->pcm_pos_shift);
396 ichdev->fragsize1 >> chip->pcm_pos_shift);
405 ichdev->fragsize >> chip->pcm_pos_shift);
407 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
413 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK);
415 iputbyte(chip, port + ICH_REG_OFF_CIV, 0);
419 dev_dbg(chip->card->dev,
425 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
432 static inline void snd_intel8x0m_update(struct intel8x0m *chip, struct ichdev *ichdev)
438 civ = igetbyte(chip, port + ICH_REG_OFF_CIV);
457 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
465 dev_dbg(chip->card->dev,
477 spin_unlock(&chip->reg_lock);
479 spin_lock(&chip->reg_lock);
481 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
486 struct intel8x0m *chip = dev_id;
491 spin_lock(&chip->reg_lock);
492 status = igetdword(chip, chip->int_sta_reg);
494 spin_unlock(&chip->reg_lock);
497 if ((status & chip->int_sta_mask) == 0) {
499 iputdword(chip, chip->int_sta_reg, status);
500 spin_unlock(&chip->reg_lock);
504 for (i = 0; i < chip->bdbars_count; i++) {
505 ichdev = &chip->ichd[i];
507 snd_intel8x0m_update(chip, ichdev);
511 iputdword(chip, chip->int_sta_reg, status & chip->int_sta_mask);
512 spin_unlock(&chip->reg_lock);
523 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
546 iputbyte(chip, port + ICH_REG_OFF_CR, val);
549 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ;
551 iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS);
558 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
562 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << chip->pcm_pos_shift;
575 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
584 snd_intel8x0m_setup_periods(chip, ichdev);
633 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
635 return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMOUT]);
640 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
642 chip->ichd[ICHD_MDMOUT].substream = NULL;
648 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
650 return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMIN]);
655 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
657 chip->ichd[ICHD_MDMIN].substream = NULL;
688 static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device,
699 err = snd_pcm_new(chip->card, name, device,
710 pcm->private_data = chip;
714 sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix);
716 strcpy(pcm->name, chip->card->shortname);
717 chip->pcm[device] = pcm;
720 &chip->pci->dev,
737 static int snd_intel8x0m_pcm(struct intel8x0m *chip)
746 switch (chip->device_type) {
766 if (! chip->ichd[rec->ac97_idx].ac97)
769 err = snd_intel8x0m_pcm1(chip, device, rec);
775 chip->pcm_devs = device;
786 struct intel8x0m *chip = bus->private_data;
787 chip->ac97_bus = NULL;
792 struct intel8x0m *chip = ac97->private_data;
793 chip->ac97 = NULL;
797 static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock)
809 chip->in_ac97_init = 1;
812 ac97.private_data = chip;
816 glob_sta = igetdword(chip, ICHREG(GLOB_STA));
818 if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0)
823 chip->ac97_bus = pbus;
825 ac97.pci = chip->pci;
828 dev_err(chip->card->dev,
834 chip->ac97 = x97;
835 if(ac97_is_modem(x97) && !chip->ichd[ICHD_MDMIN].ac97) {
836 chip->ichd[ICHD_MDMIN].ac97 = x97;
837 chip->ichd[ICHD_MDMOUT].ac97 = x97;
840 chip->in_ac97_init = 0;
845 if (chip->device_type != DEVICE_ALI)
846 iputdword(chip, ICHREG(GLOB_CNT),
847 igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD);
856 static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
864 cnt = igetdword(chip, ICHREG(GLOB_STA));
865 iputdword(chip, ICHREG(GLOB_STA), cnt & status);
868 cnt = igetdword(chip, ICHREG(GLOB_CNT));
872 iputdword(chip, ICHREG(GLOB_CNT), cnt);
876 if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
880 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
881 igetdword(chip, ICHREG(GLOB_CNT)));
892 status = igetdword(chip, ICHREG(GLOB_STA)) &
900 dev_err(chip->card->dev,
902 igetdword(chip, ICHREG(GLOB_STA)));
913 status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus;
919 if (chip->ac97)
920 status |= get_ich_codec_bit(chip, chip->ac97->num);
924 nstatus = igetdword(chip, ICHREG(GLOB_STA)) &
932 if (chip->device_type == DEVICE_SIS) {
934 iputword(chip, 0x4c, igetword(chip, 0x4c) | 1);
940 static int snd_intel8x0m_chip_init(struct intel8x0m *chip, int probing)
945 if ((err = snd_intel8x0m_ich_chip_init(chip, probing)) < 0)
947 iagetword(chip, 0); /* clear semaphore flag */
950 for (i = 0; i < chip->bdbars_count; i++)
951 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00);
953 for (i = 0; i < chip->bdbars_count; i++)
954 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
956 for (i = 0; i < chip->bdbars_count; i++)
957 iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, chip->ichd[i].bdbar_addr);
961 static int snd_intel8x0m_free(struct intel8x0m *chip)
965 if (chip->irq < 0)
968 for (i = 0; i < chip->bdbars_count; i++)
969 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, 0x00);
971 for (i = 0; i < chip->bdbars_count; i++)
972 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
974 if (chip->irq >= 0)
975 free_irq(chip->irq, chip);
976 if (chip->bdbars.area)
977 snd_dma_free_pages(&chip->bdbars);
978 if (chip->addr)
979 pci_iounmap(chip->pci, chip->addr);
980 if (chip->bmaddr)
981 pci_iounmap(chip->pci, chip->bmaddr);
982 pci_release_regions(chip->pci);
983 pci_disable_device(chip->pci);
984 kfree(chip);
995 struct intel8x0m *chip = card->private_data;
998 snd_ac97_suspend(chip->ac97);
999 if (chip->irq >= 0) {
1000 free_irq(chip->irq, chip);
1001 chip->irq = -1;
1011 struct intel8x0m *chip = card->private_data;
1014 IRQF_SHARED, KBUILD_MODNAME, chip)) {
1020 chip->irq = pci->irq;
1021 card->sync_irq = chip->irq;
1022 snd_intel8x0m_chip_init(chip, 0);
1023 snd_ac97_resume(chip->ac97);
1038 struct intel8x0m *chip = entry->private_data;
1042 if (chip->device_type == DEVICE_ALI)
1044 tmp = igetdword(chip, ICHREG(GLOB_STA));
1046 igetdword(chip, ICHREG(GLOB_CNT)));
1055 static void snd_intel8x0m_proc_init(struct intel8x0m *chip)
1057 snd_card_ro_proc_new(chip->card, "intel8x0m", chip,
1063 struct intel8x0m *chip = device->device_data;
1064 return snd_intel8x0m_free(chip);
1077 struct intel8x0m *chip;
1096 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1097 if (chip == NULL) {
1101 spin_lock_init(&chip->reg_lock);
1102 chip->device_type = device_type;
1103 chip->card = card;
1104 chip->pci = pci;
1105 chip->irq = -1;
1108 kfree(chip);
1115 chip->bmaddr = pci_iomap(pci, 0, 0);
1120 chip->addr = pci_iomap(pci, 2, 0);
1122 chip->addr = pci_iomap(pci, 0, 0);
1123 if (!chip->addr) {
1125 snd_intel8x0m_free(chip);
1129 chip->bmaddr = pci_iomap(pci, 3, 0);
1131 chip->bmaddr = pci_iomap(pci, 1, 0);
1132 if (!chip->bmaddr) {
1134 snd_intel8x0m_free(chip);
1140 chip->bdbars_count = 2;
1143 for (i = 0; i < chip->bdbars_count; i++) {
1144 ichdev = &chip->ichd[i];
1160 chip->pcm_pos_shift = (device_type == DEVICE_SIS) ? 0 : 1;
1165 chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2,
1166 &chip->bdbars) < 0) {
1167 snd_intel8x0m_free(chip);
1173 for (i = 0; i < chip->bdbars_count; i++) {
1174 ichdev = &chip->ichd[i];
1175 ichdev->bdbar = ((__le32 *)chip->bdbars.area) + (i * ICH_MAX_FRAGS * 2);
1176 ichdev->bdbar_addr = chip->bdbars.addr + (i * sizeof(u32) * ICH_MAX_FRAGS * 2);
1179 chip->int_sta_reg = ICH_REG_GLOB_STA;
1180 chip->int_sta_mask = int_sta_masks;
1184 if ((err = snd_intel8x0m_chip_init(chip, 1)) < 0) {
1185 snd_intel8x0m_free(chip);
1190 KBUILD_MODNAME, chip)) {
1192 snd_intel8x0m_free(chip);
1195 chip->irq = pci->irq;
1196 card->sync_irq = chip->irq;
1198 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
1199 snd_intel8x0m_free(chip);
1203 *r_intel8x0m = chip;
1237 struct intel8x0m *chip;
1255 if ((err = snd_intel8x0m_create(card, pci, pci_id->driver_data, &chip)) < 0) {
1259 card->private_data = chip;
1261 if ((err = snd_intel8x0m_mixer(chip, ac97_clock)) < 0) {
1265 if ((err = snd_intel8x0m_pcm(chip)) < 0) {
1270 snd_intel8x0m_proc_init(chip);
1273 card->shortname, chip->irq);