Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f371f12f authored by Takashi Iwai's avatar Takashi Iwai
Browse files

Merge branch 'fix/asoc' into for-linus

* fix/asoc:
  ASoC: Fix wm8753 register cache size and initialization
  ASoC: add locking to mpc5200-psc-ac97 driver
  ASoC: Fix mpc5200-psc-ac97 to ensure the data ready bit is cleared
  ASoC: Fix register cache initialisation for WM8753
parents 7ce1695c 637a935a
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -79,7 +79,7 @@ static const u16 wm8753_reg[] = {
	0x0097, 0x0097, 0x0000, 0x0004,
	0x0097, 0x0097, 0x0000, 0x0004,
	0x0000, 0x0083, 0x0024, 0x01ba,
	0x0000, 0x0083, 0x0024, 0x01ba,
	0x0000, 0x0083, 0x0024, 0x01ba,
	0x0000, 0x0083, 0x0024, 0x01ba,
	0x0000, 0x0000
	0x0000, 0x0000, 0x0000
};
};


/* codec private data */
/* codec private data */
@@ -1660,11 +1660,11 @@ static int wm8753_register(struct wm8753_priv *wm8753)
	codec->set_bias_level = wm8753_set_bias_level;
	codec->set_bias_level = wm8753_set_bias_level;
	codec->dai = wm8753_dai;
	codec->dai = wm8753_dai;
	codec->num_dai = 2;
	codec->num_dai = 2;
	codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache);
	codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache) + 1;
	codec->reg_cache = &wm8753->reg_cache;
	codec->reg_cache = &wm8753->reg_cache;
	codec->private_data = wm8753;
	codec->private_data = wm8753;


	memcpy(codec->reg_cache, wm8753_reg, sizeof(codec->reg_cache));
	memcpy(codec->reg_cache, wm8753_reg, sizeof(wm8753->reg_cache));
	INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
	INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);


	ret = wm8753_reset(codec);
	ret = wm8753_reset(codec);
+1 −0
Original line number Original line Diff line number Diff line
@@ -456,6 +456,7 @@ int mpc5200_audio_dma_create(struct of_device *op)
		return -ENODEV;
		return -ENODEV;


	spin_lock_init(&psc_dma->lock);
	spin_lock_init(&psc_dma->lock);
	mutex_init(&psc_dma->mutex);
	psc_dma->id = be32_to_cpu(*prop);
	psc_dma->id = be32_to_cpu(*prop);
	psc_dma->irq = irq;
	psc_dma->irq = irq;
	psc_dma->psc_regs = regs;
	psc_dma->psc_regs = regs;
+1 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@ struct psc_dma {
	unsigned int irq;
	unsigned int irq;
	struct device *dev;
	struct device *dev;
	spinlock_t lock;
	spinlock_t lock;
	struct mutex mutex;
	u32 sicr;
	u32 sicr;
	uint sysclk;
	uint sysclk;
	int imr;
	int imr;
+16 −1
Original line number Original line Diff line number Diff line
@@ -34,13 +34,20 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
	int status;
	int status;
	unsigned int val;
	unsigned int val;


	mutex_lock(&psc_dma->mutex);

	/* Wait for command send status zero = ready */
	/* Wait for command send status zero = ready */
	status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
	status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
				MPC52xx_PSC_SR_CMDSEND), 100, 0);
				MPC52xx_PSC_SR_CMDSEND), 100, 0);
	if (status == 0) {
	if (status == 0) {
		pr_err("timeout on ac97 bus (rdy)\n");
		pr_err("timeout on ac97 bus (rdy)\n");
		mutex_unlock(&psc_dma->mutex);
		return -ENODEV;
		return -ENODEV;
	}
	}

	/* Force clear the data valid bit */
	in_be32(&psc_dma->psc_regs->ac97_data);

	/* Send the read */
	/* Send the read */
	out_be32(&psc_dma->psc_regs->ac97_cmd, (1<<31) | ((reg & 0x7f) << 24));
	out_be32(&psc_dma->psc_regs->ac97_cmd, (1<<31) | ((reg & 0x7f) << 24));


@@ -50,16 +57,19 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
	if (status == 0) {
	if (status == 0) {
		pr_err("timeout on ac97 read (val) %x\n",
		pr_err("timeout on ac97 read (val) %x\n",
				in_be16(&psc_dma->psc_regs->sr_csr.status));
				in_be16(&psc_dma->psc_regs->sr_csr.status));
		mutex_unlock(&psc_dma->mutex);
		return -ENODEV;
		return -ENODEV;
	}
	}
	/* Get the data */
	/* Get the data */
	val = in_be32(&psc_dma->psc_regs->ac97_data);
	val = in_be32(&psc_dma->psc_regs->ac97_data);
	if (((val >> 24) & 0x7f) != reg) {
	if (((val >> 24) & 0x7f) != reg) {
		pr_err("reg echo error on ac97 read\n");
		pr_err("reg echo error on ac97 read\n");
		mutex_unlock(&psc_dma->mutex);
		return -ENODEV;
		return -ENODEV;
	}
	}
	val = (val >> 8) & 0xffff;
	val = (val >> 8) & 0xffff;


	mutex_unlock(&psc_dma->mutex);
	return (unsigned short) val;
	return (unsigned short) val;
}
}


@@ -68,16 +78,21 @@ static void psc_ac97_write(struct snd_ac97 *ac97,
{
{
	int status;
	int status;


	mutex_lock(&psc_dma->mutex);

	/* Wait for command status zero = ready */
	/* Wait for command status zero = ready */
	status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
	status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
				MPC52xx_PSC_SR_CMDSEND), 100, 0);
				MPC52xx_PSC_SR_CMDSEND), 100, 0);
	if (status == 0) {
	if (status == 0) {
		pr_err("timeout on ac97 bus (write)\n");
		pr_err("timeout on ac97 bus (write)\n");
		return;
		goto out;
	}
	}
	/* Write data */
	/* Write data */
	out_be32(&psc_dma->psc_regs->ac97_cmd,
	out_be32(&psc_dma->psc_regs->ac97_cmd,
			((reg & 0x7f) << 24) | (val << 8));
			((reg & 0x7f) << 24) | (val << 8));

 out:
	mutex_unlock(&psc_dma->mutex);
}
}


static void psc_ac97_warm_reset(struct snd_ac97 *ac97)
static void psc_ac97_warm_reset(struct snd_ac97 *ac97)