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

Commit f9efc9df authored by Eric Miao's avatar Eric Miao
Browse files

ASoC: Remove legacy SSP API usage from pxa-ssp.c

parent a056bef4
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ config SND_PXA2XX_SOC_I2S


config SND_PXA_SOC_SSP
config SND_PXA_SOC_SSP
	tristate
	tristate
	select PXA_SSP_LEGACY


config SND_PXA2XX_SOC_CORGI
config SND_PXA2XX_SOC_CORGI
	tristate "SoC Audio support for Sharp Zaurus SL-C7x0"
	tristate "SoC Audio support for Sharp Zaurus SL-C7x0"
+61 −29
Original line number Original line Diff line number Diff line
@@ -42,11 +42,14 @@
 * SSP audio private data
 * SSP audio private data
 */
 */
struct ssp_priv {
struct ssp_priv {
	struct ssp_dev dev;
	struct ssp_device *ssp;
	unsigned int sysclk;
	unsigned int sysclk;
	int dai_fmt;
	int dai_fmt;
#ifdef CONFIG_PM
#ifdef CONFIG_PM
	struct ssp_state state;
	uint32_t	cr0;
	uint32_t	cr1;
	uint32_t	to;
	uint32_t	psp;
#endif
#endif
};
};


@@ -61,6 +64,22 @@ static void dump_registers(struct ssp_device *ssp)
		 ssp_read_reg(ssp, SSACD));
		 ssp_read_reg(ssp, SSACD));
}
}


static void ssp_enable(struct ssp_device *ssp)
{
	uint32_t sscr0;

	sscr0 = __raw_readl(ssp->mmio_base + SSCR0) | SSCR0_SSE;
	__raw_writel(sscr0, ssp->mmio_base + SSCR0);
}

static void ssp_disable(struct ssp_device *ssp)
{
	uint32_t sscr0;

	sscr0 = __raw_readl(ssp->mmio_base + SSCR0) & ~SSCR0_SSE;
	__raw_writel(sscr0, ssp->mmio_base + SSCR0);
}

struct pxa2xx_pcm_dma_data {
struct pxa2xx_pcm_dma_data {
	struct pxa2xx_pcm_dma_params params;
	struct pxa2xx_pcm_dma_params params;
	char name[20];
	char name[20];
@@ -94,13 +113,12 @@ static int pxa_ssp_startup(struct snd_pcm_substream *substream,
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->ssp;
	int ret = 0;
	int ret = 0;


	if (!cpu_dai->active) {
	if (!cpu_dai->active) {
		priv->dev.port = cpu_dai->id + 1;
		clk_enable(ssp->clk);
		priv->dev.irq = NO_IRQ;
		ssp_disable(ssp);
		clk_enable(priv->dev.ssp->clk);
		ssp_disable(&priv->dev);
	}
	}


	if (cpu_dai->dma_data) {
	if (cpu_dai->dma_data) {
@@ -116,10 +134,11 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->ssp;


	if (!cpu_dai->active) {
	if (!cpu_dai->active) {
		ssp_disable(&priv->dev);
		ssp_disable(ssp);
		clk_disable(priv->dev.ssp->clk);
		clk_disable(ssp->clk);
	}
	}


	if (cpu_dai->dma_data) {
	if (cpu_dai->dma_data) {
@@ -133,26 +152,39 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->ssp;


	if (!cpu_dai->active)
	if (!cpu_dai->active)
		return 0;
		return 0;


	ssp_save_state(&priv->dev, &priv->state);
	priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0);
	clk_disable(priv->dev.ssp->clk);
	priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1);
	priv->to  = __raw_readl(ssp->mmio_base + SSTO);
	priv->psp = __raw_readl(ssp->mmio_base + SSPSP);

	ssp_disable(ssp);
	clk_disable(ssp->clk);
	return 0;
	return 0;
}
}


static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->ssp;
	uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE;


	if (!cpu_dai->active)
	if (!cpu_dai->active)
		return 0;
		return 0;


	clk_enable(priv->dev.ssp->clk);
	clk_enable(ssp->clk);
	ssp_restore_state(&priv->dev, &priv->state);

	ssp_enable(&priv->dev);
	__raw_writel(sssr, ssp->mmio_base + SSSR);


	__raw_writel(priv->cr0 & ~SSCR0_SSE, ssp->mmio_base + SSCR0);
	__raw_writel(priv->cr1, ssp->mmio_base + SSCR1);
	__raw_writel(priv->to,  ssp->mmio_base + SSTO);
	__raw_writel(priv->psp, ssp->mmio_base + SSPSP);
	__raw_writel(priv->cr0 | SSCR0_SSE, ssp->mmio_base + SSCR0);
	return 0;
	return 0;
}
}


@@ -201,7 +233,7 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
	int clk_id, unsigned int freq, int dir)
	int clk_id, unsigned int freq, int dir)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	int val;
	int val;


	u32 sscr0 = ssp_read_reg(ssp, SSCR0) &
	u32 sscr0 = ssp_read_reg(ssp, SSCR0) &
@@ -242,11 +274,11 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
	/* The SSP clock must be disabled when changing SSP clock mode
	/* The SSP clock must be disabled when changing SSP clock mode
	 * on PXA2xx.  On PXA3xx it must be enabled when doing so. */
	 * on PXA2xx.  On PXA3xx it must be enabled when doing so. */
	if (!cpu_is_pxa3xx())
	if (!cpu_is_pxa3xx())
		clk_disable(priv->dev.ssp->clk);
		clk_disable(ssp->clk);
	val = ssp_read_reg(ssp, SSCR0) | sscr0;
	val = ssp_read_reg(ssp, SSCR0) | sscr0;
	ssp_write_reg(ssp, SSCR0, val);
	ssp_write_reg(ssp, SSCR0, val);
	if (!cpu_is_pxa3xx())
	if (!cpu_is_pxa3xx())
		clk_enable(priv->dev.ssp->clk);
		clk_enable(ssp->clk);


	return 0;
	return 0;
}
}
@@ -258,7 +290,7 @@ static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai *cpu_dai,
	int div_id, int div)
	int div_id, int div)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	int val;
	int val;


	switch (div_id) {
	switch (div_id) {
@@ -309,7 +341,7 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id,
	int source, unsigned int freq_in, unsigned int freq_out)
	int source, unsigned int freq_in, unsigned int freq_out)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	u32 ssacd = ssp_read_reg(ssp, SSACD) & ~0x70;
	u32 ssacd = ssp_read_reg(ssp, SSACD) & ~0x70;


#if defined(CONFIG_PXA3xx)
#if defined(CONFIG_PXA3xx)
@@ -378,7 +410,7 @@ static int pxa_ssp_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai,
	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	u32 sscr0;
	u32 sscr0;


	sscr0 = ssp_read_reg(ssp, SSCR0);
	sscr0 = ssp_read_reg(ssp, SSCR0);
@@ -413,7 +445,7 @@ static int pxa_ssp_set_dai_tristate(struct snd_soc_dai *cpu_dai,
	int tristate)
	int tristate)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	u32 sscr1;
	u32 sscr1;


	sscr1 = ssp_read_reg(ssp, SSCR1);
	sscr1 = ssp_read_reg(ssp, SSCR1);
@@ -435,7 +467,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
		unsigned int fmt)
		unsigned int fmt)
{
{
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	u32 sscr0;
	u32 sscr0;
	u32 sscr1;
	u32 sscr1;
	u32 sspsp;
	u32 sspsp;
@@ -530,7 +562,7 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	int chn = params_channels(params);
	int chn = params_channels(params);
	u32 sscr0;
	u32 sscr0;
	u32 sspsp;
	u32 sspsp;
@@ -640,12 +672,12 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	int ret = 0;
	int ret = 0;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_priv *priv = cpu_dai->private_data;
	struct ssp_device *ssp = priv->dev.ssp;
	struct ssp_device *ssp = priv->ssp;
	int val;
	int val;


	switch (cmd) {
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_RESUME:
		ssp_enable(&priv->dev);
		ssp_enable(ssp);
		break;
		break;
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		val = ssp_read_reg(ssp, SSCR1);
		val = ssp_read_reg(ssp, SSCR1);
@@ -664,7 +696,7 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
		else
		else
			val |= SSCR1_RSRE;
			val |= SSCR1_RSRE;
		ssp_write_reg(ssp, SSCR1, val);
		ssp_write_reg(ssp, SSCR1, val);
		ssp_enable(&priv->dev);
		ssp_enable(ssp);
		break;
		break;
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_STOP:
		val = ssp_read_reg(ssp, SSCR1);
		val = ssp_read_reg(ssp, SSCR1);
@@ -675,7 +707,7 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
		ssp_write_reg(ssp, SSCR1, val);
		ssp_write_reg(ssp, SSCR1, val);
		break;
		break;
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_SUSPEND:
		ssp_disable(&priv->dev);
		ssp_disable(ssp);
		break;
		break;
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
		val = ssp_read_reg(ssp, SSCR1);
		val = ssp_read_reg(ssp, SSCR1);
@@ -705,8 +737,8 @@ static int pxa_ssp_probe(struct platform_device *pdev,
	if (!priv)
	if (!priv)
		return -ENOMEM;
		return -ENOMEM;


	priv->dev.ssp = ssp_request(dai->id + 1, "SoC audio");
	priv->ssp = ssp_request(dai->id + 1, "SoC audio");
	if (priv->dev.ssp == NULL) {
	if (priv->ssp == NULL) {
		ret = -ENODEV;
		ret = -ENODEV;
		goto err_priv;
		goto err_priv;
	}
	}
@@ -725,7 +757,7 @@ static void pxa_ssp_remove(struct platform_device *pdev,
			      struct snd_soc_dai *dai)
			      struct snd_soc_dai *dai)
{
{
	struct ssp_priv *priv = dai->private_data;
	struct ssp_priv *priv = dai->private_data;
	ssp_free(priv->dev.ssp);
	ssp_free(priv->ssp);
}
}


#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\