Skip to contentSkip to conversation

Additional fixes for the Freescale MPC8610 drivers

PATCH Applied Timur Tabi 2 participants 2 messages May 22, 2008 – May 23, 2008

Subsystems (4)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v2 1/1 Additional fixes for the Freescale MPC8610 drivers

More miscellaneous fixes for the Freescale MPC8610 ASoC V2 drivers.

CS4270 driver: Replace printk() with dev_xxx(). Use snd_soc_add_new_controls(). Report an error if a CS4270 is not found at the given I2C address. Additional initialization of the 'codec' structure.

DMA driver: when an OSS application requests a sync, ASoC calls fsl_dma_hw_params() after calling fsl_dma_prepare(). This caused the DMA controller to be reprogrammed, which made it stop working. So the bulk of DMA programming was moved to fsl_dma_open(). Initialized some more fields in dma_private, so now the ISR won't panic.

SSI driver: The SSI is now enabled only when it starts playback or capture, to prevent premature communication with the DMA controller. Added spinlocks to prevent the SSI from being enabled inadvertently by another stream.

Fabric driver: Turned the driver into a platform driver. Added calls to snd_soc_card_config_codec() and snd_soc_card_init_codec().

---
 sound/soc/codecs/cs4270.c    |   54 +++++++++--------
 sound/soc/fsl/fsl_dma.c      |  139 ++++++++++++++++++++++-------------------
 sound/soc/fsl/fsl_ssi.c      |   79 +++++++++++++++++-------
 sound/soc/fsl/fsl_ssi.h      |    1 +
 sound/soc/fsl/mpc8610_hpcd.c |  130 ++++++++++++++++++++++++---------------
 5 files changed, 240 insertions(+), 163 deletions(-)
sound/soc/codecs/cs4270.c +28 -26
index 13b9d56..6bb4bc7 100644
@@ -223,7 +223,7 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 	rates &= ~SNDRV_PCM_RATE_KNOT;
 
 	if (!rates) {
-		printk(KERN_ERR "cs4270: could not find a valid sample rate\n");
+		dev_err(codec_dai->dev, "could not find a valid sample rate\n");
 		return -EINVAL;
 	}
 
@@ -263,7 +263,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
 		cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
 		break;
 	default:
-		printk(KERN_ERR "cs4270: invalid DAI format\n");
+		dev_err(codec_dai->dev, "invalid DAI format\n");
 		ret = -EINVAL;
 	}
 
@@ -315,7 +315,7 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg,
 		struct i2c_client *client = codec->control_data;
 
 		if (i2c_smbus_write_byte_data(client, reg, value)) {
-			printk(KERN_ERR "cs4270: I2C write failed\n");
+			dev_err(codec->dev, "I2C write failed\n");
 			return -EIO;
 		}
 
@@ -359,7 +359,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
 
 	if (i == NUM_MCLK_RATIOS) {
 		/* We did not find a matching ratio */
-		printk(KERN_ERR "cs4270: could not find matching ratio\n");
+		dev_err(codec->dev, "could not find matching ratio\n");
 		return -EINVAL;
 	}
 
@@ -369,7 +369,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
 		CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC |
 		CS4270_PWRCTL_PDN);
 	if (ret < 0) {
-		printk(KERN_ERR "cs4270: I2C write failed\n");
+		dev_err(codec->dev, "I2C write failed\n");
 		return ret;
 	}
 
@@ -381,7 +381,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
 
 	ret = cs4270_i2c_write(codec, CS4270_MODE, reg);
 	if (ret < 0) {
-		printk(KERN_ERR "cs4270: I2C write failed\n");
+		dev_err(codec->dev, "I2C write failed\n");
 		return ret;
 	}
 
@@ -398,13 +398,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
 		reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ;
 		break;
 	default:
-		printk(KERN_ERR "cs4270: unknown format\n");
+		dev_err(codec->dev, "unknown format\n");
 		return -EINVAL;
 	}
 
 	ret = cs4270_i2c_write(codec, CS4270_FORMAT, reg);
 	if (ret < 0) {
-		printk(KERN_ERR "cs4270: I2C write failed\n");
+		dev_err(codec->dev, "I2C write failed\n");
 		return ret;
 	}
 
@@ -415,7 +415,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
 	reg &= ~CS4270_MUTE_AUTO;
 	ret = cs4270_i2c_write(codec, CS4270_MUTE, reg);
 	if (ret < 0) {
-		printk(KERN_ERR "cs4270: I2C write failed\n");
+		dev_err(codec->dev, "I2C write failed\n");
 		return ret;
 	}
 
@@ -423,7 +423,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
 
 	ret = cs4270_i2c_write(codec, CS4270_PWRCTL, 0);
 	if (ret < 0) {
-		printk(KERN_ERR "cs4270: I2C write failed\n");
+		dev_err(codec->dev, "I2C write failed\n");
 		return ret;
 	}
 
@@ -469,23 +469,16 @@ static int cs4270_codec_init(struct snd_soc_codec *codec,
 	struct snd_soc_card *soc_card)
 {
 	int ret;
-	unsigned int i;
 
 	/* Add the non-DAPM controls */
 
-	for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) {
-		struct snd_kcontrol *kctrl;
-
-		kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
+	ret = snd_soc_add_new_controls(soc_card, cs4270_snd_controls, codec,
+		ARRAY_SIZE(cs4270_snd_controls));
 
-		ret = snd_ctl_add(soc_card->card, kctrl);
-		if (ret < 0) {
-			dev_err(soc_card->card->dev, "could not add control\n");
-			return ret;
-		}
-	}
+	if (ret < 0)
+		dev_err(soc_card->card->dev, "could not add control\n");
 
-	return 0;
+	return ret;
 }
 
 /*
@@ -513,9 +506,14 @@ static int cs4270_i2c_probe(struct i2c_client *client,
 		return ret;
 	}
 	/* The top four bits of the chip ID should be 1100. */
-	if ((ret & 0xF0) != 0xC0)
-		/* The device at this address is not a CS4270 codec */
+	if ((ret & 0xF0) != 0xC0) {
+		/* This is a new-style I2C driver, which means we're supposed
+		 * to be given the actual I2C address that the chip is on.  If
+		 * this device is not a CS4270, then that's a bug.
+		 */
+		dev_err(&client->dev, "device is not a CS4270\n");
 		return -ENODEV;
+	}
 
 	dev_info(&client->dev, "found device at address %X\n", client->addr);
 	dev_info(&client->dev, "hardware revision %X\n", ret & 0xF);
@@ -567,10 +565,13 @@ static int cs4270_i2c_probe(struct i2c_client *client,
 
 	codec->control_data = client;
 	codec->init = cs4270_codec_init;
+	codec->reg_cache = cs4270->reg_cache;
+	codec->codec_read = cs4270_read_reg_cache;
+	codec->codec_write = cs4270_i2c_write;
 
 	ret = snd_soc_register_codec(codec, &client->dev);
 	if (ret < 0) {
-		printk(KERN_ERR "cs4270: failed to register card\n");
+		dev_err(&client->dev, "failed to register card\n");
 		goto error;
 	}
 	registered = 1;
@@ -583,6 +584,7 @@ static int cs4270_i2c_probe(struct i2c_client *client,
 	cs4270->dai =
 		snd_soc_register_codec_dai(&cs4270->dai_new, &client->dev);
 	if (!cs4270->dai) {
+		dev_err(&client->dev, "failed to register DAI\n");
 		ret = -EINVAL;
 		goto error;
 	}
@@ -650,7 +652,7 @@ static int __init cs4270_init(void)
 	ret = i2c_add_driver(&cs4270_i2c_driver);
 
 	if (ret)
-		printk(KERN_ERR "cs4270: failed to register I2C driver\n");
+		pr_err("cs4270: failed to register I2C driver\n");
 
 	return ret;
 }
sound/soc/fsl/fsl_dma.c +75 -64

223 lines not on this page · raw message

sound/soc/fsl/fsl_ssi.c +55 -24

148 lines not on this page · raw message

sound/soc/fsl/fsl_ssi.h +1 -0
index 05fd84d..9a22b04 100644
@@ -219,6 +219,7 @@ struct fsl_ssi_info {
 	struct device *dev;
 	unsigned int playback;
 	unsigned int capture;
+	spinlock_t lock;
 	struct snd_soc_dai *dai;
 	struct device_attribute dev_attr;
 
sound/soc/fsl/mpc8610_hpcd.c +81 -49

254 lines not on this page · raw message

Signature · 1 line
1.5.5
Applied
#1 lore raw
Quoted 1 line · Timur Tabi

More miscellaneous fixes for the Freescale MPC8610 ASoC V2 drivers.

Applied, thanks.