cregit-Linux how code gets into the kernel

Release 4.7 sound/soc/pxa/pxa-ssp.c

Directory: sound/soc/pxa
/*
 * pxa-ssp.c  --  ALSA Soc Audio Layer
 *
 * Copyright 2005,2008 Wolfson Microelectronics PLC.
 * Author: Liam Girdwood
 *         Mark Brown <broonie@opensource.wolfsonmicro.com>
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the  License, or (at your
 *  option) any later version.
 *
 * TODO:
 *  o Test network mode for > 16bit sample size
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/pxa2xx_ssp.h>
#include <linux/of.h>
#include <linux/dmaengine.h>

#include <asm/irq.h>

#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/initval.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/pxa2xx-lib.h>
#include <sound/dmaengine_pcm.h>

#include "../../arm/pxa2xx-pcm.h"
#include "pxa-ssp.h"

/*
 * SSP audio private data
 */

struct ssp_priv {
	
struct ssp_device *ssp;
	
unsigned int sysclk;
	
int dai_fmt;
#ifdef CONFIG_PM
	
uint32_t	cr0;
	
uint32_t	cr1;
	
uint32_t	to;
	
uint32_t	psp;
#endif
};


static void dump_registers(struct ssp_device *ssp) { dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", pxa_ssp_read_reg(ssp, SSCR0), pxa_ssp_read_reg(ssp, SSCR1), pxa_ssp_read_reg(ssp, SSTO)); dev_dbg(&ssp->pdev->dev, "SSPSP 0x%08x SSSR 0x%08x SSACD 0x%08x\n", pxa_ssp_read_reg(ssp, SSPSP), pxa_ssp_read_reg(ssp, SSSR), pxa_ssp_read_reg(ssp, SSACD)); }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown7192.21%150.00%
haojian zhuanghaojian zhuang67.79%150.00%
Total77100.00%2100.00%


static void pxa_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); }

Contributors

PersonTokensPropCommitsCommitProp
eric miaoeric miao3797.37%150.00%
haojian zhuanghaojian zhuang12.63%150.00%
Total38100.00%2100.00%


static void pxa_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); }

Contributors

PersonTokensPropCommitsCommitProp
eric miaoeric miao3897.44%150.00%
haojian zhuanghaojian zhuang12.56%150.00%
Total39100.00%2100.00%


static void pxa_ssp_set_dma_params(struct ssp_device *ssp, int width4, int out, struct snd_dmaengine_dai_dma_data *dma) { dma->addr_width = width4 ? DMA_SLAVE_BUSWIDTH_4_BYTES : DMA_SLAVE_BUSWIDTH_2_BYTES; dma->maxburst = 16; dma->addr = ssp->phys_base + SSDR; }

Contributors

PersonTokensPropCommitsCommitProp
eric miaoeric miao3062.50%240.00%
daniel mackdaniel mack1225.00%120.00%
guoyhguoyh510.42%120.00%
mark brownmark brown12.08%120.00%
Total48100.00%5100.00%


static int pxa_ssp_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; struct snd_dmaengine_dai_dma_data *dma; int ret = 0; if (!cpu_dai->active) { clk_prepare_enable(ssp->clk); pxa_ssp_disable(ssp); } dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL); if (!dma) return -ENOMEM; dma->filter_data = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? &ssp->drcmr_tx : &ssp->drcmr_rx; snd_soc_dai_set_dma_data(cpu_dai, substream, dma); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown4436.67%216.67%
daniel mackdaniel mack3025.00%325.00%
guoyhguoyh2117.50%18.33%
eric miaoeric miao1512.50%216.67%
liam girdwoodliam girdwood43.33%18.33%
philipp zabelphilipp zabel43.33%18.33%
dmitry eremin-baryshkovdmitry eremin-baryshkov10.83%18.33%
haojian zhuanghaojian zhuang10.83%18.33%
Total120100.00%12100.00%


static void pxa_ssp_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; if (!cpu_dai->active) { pxa_ssp_disable(ssp); clk_disable_unprepare(ssp->clk); } kfree(snd_soc_dai_get_dma_data(cpu_dai, substream)); snd_soc_dai_set_dma_data(cpu_dai, substream, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown3648.00%222.22%
eric miaoeric miao1925.33%222.22%
daniel mackdaniel mack1114.67%111.11%
liam girdwoodliam girdwood45.33%111.11%
philipp zabelphilipp zabel34.00%111.11%
haojian zhuanghaojian zhuang11.33%111.11%
dmitry eremin-baryshkovdmitry eremin-baryshkov11.33%111.11%
Total75100.00%9100.00%

#ifdef CONFIG_PM
static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; if (!cpu_dai->active) clk_prepare_enable(ssp->clk); priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0); priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1); priv->to = __raw_readl(ssp->mmio_base + SSTO); priv->psp = __raw_readl(ssp->mmio_base + SSPSP); pxa_ssp_disable(ssp); clk_disable_unprepare(ssp->clk); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
eric miaoeric miao5751.35%114.29%
mark brownmark brown4237.84%114.29%
russell kingrussell king54.50%114.29%
liam girdwoodliam girdwood32.70%114.29%
dmitry eremin-baryshkovdmitry eremin-baryshkov21.80%114.29%
haojian zhuanghaojian zhuang10.90%114.29%
daniel mackdaniel mack10.90%114.29%
Total111100.00%7100.00%


static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE; clk_prepare_enable(ssp->clk); __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); if (cpu_dai->active) pxa_ssp_enable(ssp); else clk_disable_unprepare(ssp->clk); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
eric miaoeric miao7555.97%114.29%
mark brownmark brown4432.84%114.29%
daniel mackdaniel mack85.97%114.29%
liam girdwoodliam girdwood32.24%114.29%
dmitry eremin-baryshkovdmitry eremin-baryshkov21.49%114.29%
russell kingrussell king10.75%114.29%
haojian zhuanghaojian zhuang10.75%114.29%
Total134100.00%7100.00%

#else #define pxa_ssp_suspend NULL #define pxa_ssp_resume NULL #endif /** * ssp_set_clkdiv - set SSP clock divider * @div: serial clock rate divider */
static void pxa_ssp_set_scr(struct ssp_device *ssp, u32 div) { u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0); if (ssp->type == PXA25x_SSP) { sscr0 &= ~0x0000ff00; sscr0 |= ((div - 2)/2) << 8; /* 2..512 */ } else { sscr0 &= ~0x000fff00; sscr0 |= (div - 1) << 8; /* 1..4096 */ } pxa_ssp_write_reg(ssp, SSCR0, sscr0); }

Contributors

PersonTokensPropCommitsCommitProp
philipp zabelphilipp zabel5465.85%133.33%
mark brownmark brown2530.49%133.33%
haojian zhuanghaojian zhuang33.66%133.33%
Total82100.00%3100.00%

/** * pxa_ssp_get_clkdiv - get SSP clock divider */
static u32 pxa_ssp_get_scr(struct ssp_device *ssp) { u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0); u32 div; if (ssp->type == PXA25x_SSP) div = ((sscr0 >> 8) & 0xff) * 2 + 2; else div = ((sscr0 >> 8) & 0xfff) + 1; return div; }

Contributors

PersonTokensPropCommitsCommitProp
philipp zabelphilipp zabel5989.39%133.33%
mark brownmark brown57.58%133.33%
haojian zhuanghaojian zhuang23.03%133.33%
Total66100.00%3100.00%

/* * Set the SSP ports SYSCLK. */
static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; int val; u32 sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); dev_dbg(&ssp->pdev->dev, "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n", cpu_dai->id, clk_id, freq); switch (clk_id) { case PXA_SSP_CLK_NET_PLL: sscr0 |= SSCR0_MOD; break; case PXA_SSP_CLK_PLL: /* Internal PLL is fixed */ if (ssp->type == PXA25x_SSP) priv->sysclk = 1843200; else priv->sysclk = 13000000; break; case PXA_SSP_CLK_EXT: priv->sysclk = freq; sscr0 |= SSCR0_ECS; break; case PXA_SSP_CLK_NET: priv->sysclk = freq; sscr0 |= SSCR0_NCS | SSCR0_MOD; break; case PXA_SSP_CLK_AUDIO: priv->sysclk = 0; pxa_ssp_set_scr(ssp, 1); sscr0 |= SSCR0_ACS; break; default: return -ENODEV; } /* The SSP clock must be disabled when changing SSP clock mode * on PXA2xx. On PXA3xx it must be enabled when doing so. */ if (ssp->type != PXA3xx_SSP) clk_disable_unprepare(ssp->clk); val = pxa_ssp_read_reg(ssp, SSCR0) | sscr0; pxa_ssp_write_reg(ssp, SSCR0, val); if (ssp->type != PXA3xx_SSP) clk_prepare_enable(ssp->clk); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown20688.03%112.50%
qiao zhouqiao zhou156.41%112.50%
haojian zhuanghaojian zhuang41.71%112.50%
liam girdwoodliam girdwood31.28%112.50%
daniel mackdaniel mack20.85%112.50%
dmitry eremin-baryshkovdmitry eremin-baryshkov20.85%112.50%
roel kluinroel kluin10.43%112.50%
philipp zabelphilipp zabel10.43%112.50%
Total234100.00%8100.00%

/* * Set the SSP clock dividers. */
static int pxa_ssp_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, int div_id, int div) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; int val; switch (div_id) { case PXA_SSP_AUDIO_DIV_ACDS: val = (pxa_ssp_read_reg(ssp, SSACD) & ~0x7) | SSACD_ACDS(div); pxa_ssp_write_reg(ssp, SSACD, val); break; case PXA_SSP_AUDIO_DIV_SCDB: val = pxa_ssp_read_reg(ssp, SSACD); val &= ~SSACD_SCDB; if (ssp->type == PXA3xx_SSP) val &= ~SSACD_SCDX8; switch (div) { case PXA_SSP_CLK_SCDB_1: val |= SSACD_SCDB; break; case PXA_SSP_CLK_SCDB_4: break; case PXA_SSP_CLK_SCDB_8: if (ssp->type == PXA3xx_SSP) val |= SSACD_SCDX8; else return -EINVAL; break; default: return -EINVAL; } pxa_ssp_write_reg(ssp, SSACD, val); break; case PXA_SSP_DIV_SCR: pxa_ssp_set_scr(ssp, div); break; default: return -ENODEV; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown16189.44%120.00%
qiao zhouqiao zhou105.56%120.00%
haojian zhuanghaojian zhuang52.78%120.00%
liam girdwoodliam girdwood31.67%120.00%
philipp zabelphilipp zabel10.56%120.00%
Total180100.00%5100.00%

/* * Configure the PLL frequency pxa27x and (afaik - pxa320 only) */
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) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; u32 ssacd = pxa_ssp_read_reg(ssp, SSACD) & ~0x70; if (ssp->type == PXA3xx_SSP) pxa_ssp_write_reg(ssp, SSACDD, 0); switch (freq_out) { case 5622000: break; case 11345000: ssacd |= (0x1 << 4); break; case 12235000: ssacd |= (0x2 << 4); break; case 14857000: ssacd |= (0x3 << 4); break; case 32842000: ssacd |= (0x4 << 4); break; case 48000000: ssacd |= (0x5 << 4); break; case 0: /* Disable */ break; default: /* PXA3xx has a clock ditherer which can be used to generate * a wider range of frequencies - calculate a value for it. */ if (ssp->type == PXA3xx_SSP) { u32 val; u64 tmp = 19968; tmp *= 1000000; do_div(tmp, freq_out); val = tmp; val = (val << 16) | 64; pxa_ssp_write_reg(ssp, SSACDD, val); ssacd |= (0x6 << 4); dev_dbg(&ssp->pdev->dev, "Using SSACDD %x to supply %uHz\n", val, freq_out); break; } return -EINVAL; } pxa_ssp_write_reg(ssp, SSACD, ssacd); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown22692.62%233.33%
qiao zhouqiao zhou104.10%116.67%
haojian zhuanghaojian zhuang41.64%116.67%
liam girdwoodliam girdwood31.23%116.67%
roel kluinroel kluin10.41%116.67%
Total244100.00%6100.00%

/* * Set the active slots in TDM/Network mode */
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) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; u32 sscr0; sscr0 = pxa_ssp_read_reg(ssp, SSCR0); sscr0 &= ~(SSCR0_MOD | SSCR0_SlotsPerFrm(8) | SSCR0_EDSS | SSCR0_DSS); /* set slot width */ if (slot_width > 16) sscr0 |= SSCR0_EDSS | SSCR0_DataSize(slot_width - 16); else sscr0 |= SSCR0_DataSize(slot_width); if (slots > 1) { /* enable network mode */ sscr0 |= SSCR0_MOD; /* set number of active slots */ sscr0 |= SSCR0_SlotsPerFrm(slots); /* set active slot mask */ pxa_ssp_write_reg(ssp, SSTSA, tx_mask); pxa_ssp_write_reg(ssp, SSRSA, rx_mask); } pxa_ssp_write_reg(ssp, SSCR0, sscr0); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown7751.33%125.00%
daniel ribeirodaniel ribeiro6644.00%125.00%
haojian zhuanghaojian zhuang42.67%125.00%
liam girdwoodliam girdwood32.00%125.00%
Total150100.00%4100.00%

/* * Tristate the SSP DAI lines */
static int pxa_ssp_set_dai_tristate(struct snd_soc_dai *cpu_dai, int tristate) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; u32 sscr1; sscr1 = pxa_ssp_read_reg(ssp, SSCR1); if (tristate) sscr1 &= ~SSCR1_TTE; else sscr1 |= SSCR1_TTE; pxa_ssp_write_reg(ssp, SSCR1, sscr1); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown6692.96%133.33%
liam girdwoodliam girdwood34.23%133.33%
haojian zhuanghaojian zhuang22.82%133.33%
Total71100.00%3100.00%

/* * Set up the SSP DAI format. * The SSP Port must be inactive before calling this function as the * physical interface format is changed. */
static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; u32 sscr0, sscr1, sspsp, scfr; /* check if we need to change anything at all */ if (priv->dai_fmt == fmt) return 0; /* we can only change the settings if the port is not in use */ if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) { dev_err(&ssp->pdev->dev, "can't change hardware dai format: stream is in use"); return -EINVAL; } /* reset port settings */ sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); sscr1 = SSCR1_RxTresh(8) | SSCR1_TxTresh(7); sspsp = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: sscr1 |= SSCR1_SCLKDIR | SSCR1_SFRMDIR | SSCR1_SCFR; break; case SND_SOC_DAIFMT_CBM_CFS: sscr1 |= SSCR1_SCLKDIR | SSCR1_SCFR; break; case SND_SOC_DAIFMT_CBS_CFS: break; default: return -EINVAL; } switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: sspsp |= SSPSP_SFRMP; break; case SND_SOC_DAIFMT_NB_IF: break; case SND_SOC_DAIFMT_IB_IF: sspsp |= SSPSP_SCMODE(2); break; case SND_SOC_DAIFMT_IB_NF: sspsp |= SSPSP_SCMODE(2) | SSPSP_SFRMP; break; default: return -EINVAL; } switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: sscr0 |= SSCR0_PSP; sscr1 |= SSCR1_RWOT | SSCR1_TRAIL; /* See hw_params() */ break; case SND_SOC_DAIFMT_DSP_A: sspsp |= SSPSP_FSRT; case SND_SOC_DAIFMT_DSP_B: sscr0 |= SSCR0_MOD | SSCR0_PSP; sscr1 |= SSCR1_TRAIL | SSCR1_RWOT; break; default: return -EINVAL; } pxa_ssp_write_reg(ssp, SSCR0, sscr0); pxa_ssp_write_reg(ssp, SSCR1, sscr1); pxa_ssp_write_reg(ssp, SSPSP, sspsp); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFS: scfr = pxa_ssp_read_reg(ssp, SSCR1) | SSCR1_SCFR; pxa_ssp_write_reg(ssp, SSCR1, scfr); while (pxa_ssp_read_reg(ssp, SSSR) & SSSR_BSY) cpu_relax(); break; } dump_registers(ssp); /* Since we are configuring the timings for the format by hand * we have to defer some things until hw_params() where we * know parameters like the sample size. */ priv->dai_fmt = fmt; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown20658.52%220.00%
haojian zhuanghaojian zhuang6317.90%220.00%
daniel mackdaniel mack4512.78%330.00%
daniel ribeirodaniel ribeiro359.94%220.00%
liam girdwoodliam girdwood30.85%110.00%
Total352100.00%10100.00%

/* * Set the SSP audio DMA parameters and sample size. * Can be called multiple times by oss emulation. */
static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; int chn = params_channels(params); u32 sscr0; u32 sspsp; int width = snd_pcm_format_physical_width(params_format(params)); int ttsa = pxa_ssp_read_reg(ssp, SSTSA) & 0xf; struct snd_dmaengine_dai_dma_data *dma_data; dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream); /* Network mode with one active slot (ttsa == 1) can be used * to force 16-bit frame width on the wire (for S16_LE), even * with two channels. Use 16-bit DMA transfers for this case. */ pxa_ssp_set_dma_params(ssp, ((chn == 2) && (ttsa != 1)) || (width == 32), substream->stream == SNDRV_PCM_STREAM_PLAYBACK, dma_data); /* we can only change the settings if the port is not in use */ if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) return 0; /* clear selected SSP bits */ sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & ~(SSCR0_DSS | SSCR0_EDSS); /* bit size */ switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: if (ssp->type == PXA3xx_SSP) sscr0 |= SSCR0_FPCKE; sscr0 |= SSCR0_DataSize(16); break; case SNDRV_PCM_FORMAT_S24_LE: sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8)); break; case SNDRV_PCM_FORMAT_S32_LE: sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(16)); break; } pxa_ssp_write_reg(ssp, SSCR0, sscr0); switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: sspsp = pxa_ssp_read_reg(ssp, SSPSP); if ((pxa_ssp_get_scr(ssp) == 4) && (width == 16)) { /* This is a special case where the bitclk is 64fs * and we're not dealing with 2*32 bits of audio * samples. * * The SSP values used for that are all found out by * trying and failing a lot; some of the registers * needed for that mode are only available on PXA3xx. */ if (ssp->type != PXA3xx_SSP) return -EINVAL; sspsp |= SSPSP_SFRMWDTH(width * 2); sspsp |= SSPSP_SFRMDLY(width * 4); sspsp |= SSPSP_EDMYSTOP(3); sspsp |= SSPSP_DMYSTOP(3); sspsp |= SSPSP_DMYSTRT(1); } else { /* The frame width is the width the LRCLK is * asserted for; the delay is expressed in * half cycle units. We need the extra cycle * because the data starts clocking out one BCLK * after LRCLK changes polarity. */ sspsp |= SSPSP_SFRMWDTH(width + 1); sspsp |= SSPSP_SFRMDLY((width + 1) * 2); sspsp |= SSPSP_DMYSTRT(1); } pxa_ssp_write_reg(ssp, SSPSP, sspsp); break; default: break; } /* When we use a network mode, we always require TDM slots * - complain loudly and fail if they've not been set up yet. */ if ((sscr0 & SSCR0_MOD) && !ttsa) { dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); return -EINVAL; } dump_registers(ssp); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown25262.22%323.08%
daniel mackdaniel mack8921.98%323.08%
philipp zabelphilipp zabel327.90%215.38%
qiao zhouqiao zhou102.47%17.69%
eric miaoeric miao92.22%17.69%
haojian zhuanghaojian zhuang71.73%17.69%
liam girdwoodliam girdwood51.23%17.69%
guoyhguoyh10.25%17.69%
Total405100.00%13100.00%


static void pxa_ssp_set_running_bit(struct snd_pcm_substream *substream, struct ssp_device *ssp, int value) { uint32_t sscr0 = pxa_ssp_read_reg(ssp, SSCR0); uint32_t sscr1 = pxa_ssp_read_reg(ssp, SSCR1); uint32_t sspsp = pxa_ssp_read_reg(ssp, SSPSP); uint32_t sssr = pxa_ssp_read_reg(ssp, SSSR); if (value && (sscr0 & SSCR0_SSE)) pxa_ssp_write_reg(ssp, SSCR0, sscr0 & ~SSCR0_SSE); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (value) sscr1 |= SSCR1_TSRE; else sscr1 &= ~SSCR1_TSRE; } else { if (value) sscr1 |= SSCR1_RSRE; else sscr1 &= ~SSCR1_RSRE; } pxa_ssp_write_reg(ssp, SSCR1, sscr1); if (value) { pxa_ssp_write_reg(ssp, SSSR, sssr); pxa_ssp_write_reg(ssp, SSPSP, sspsp); pxa_ssp_write_reg(ssp, SSCR0, sscr0 | SSCR0_SSE); } }

Contributors

PersonTokensPropCommitsCommitProp
daniel mackdaniel mack166100.00%1100.00%
Total166100.00%1100.00%


static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *cpu_dai) { int ret = 0; struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; int val; switch (cmd) { case SNDRV_PCM_TRIGGER_RESUME: pxa_ssp_enable(ssp); break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: pxa_ssp_set_running_bit(substream, ssp, 1); val = pxa_ssp_read_reg(ssp, SSSR); pxa_ssp_write_reg(ssp, SSSR, val); break; case SNDRV_PCM_TRIGGER_START: pxa_ssp_set_running_bit(substream, ssp, 1); break; case SNDRV_PCM_TRIGGER_STOP: pxa_ssp_set_running_bit(substream, ssp, 0); break; case SNDRV_PCM_TRIGGER_SUSPEND: pxa_ssp_disable(ssp); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: pxa_ssp_set_running_bit(substream, ssp, 0); break; default: ret = -EINVAL; } dump_registers(ssp); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown13185.06%233.33%
daniel mackdaniel mack127.79%116.67%
haojian zhuanghaojian zhuang42.60%116.67%
liam girdwoodliam girdwood42.60%116.67%
eric miaoeric miao31.95%116.67%
Total154100.00%6100.00%


static int pxa_ssp_probe(struct snd_soc_dai *dai) { struct device *dev = dai->dev; struct ssp_priv *priv; int ret; priv = kzalloc(sizeof(struct ssp_priv), GFP_KERNEL); if (!priv) return -ENOMEM; if (dev->of_node) { struct device_node *ssp_handle; ssp_handle = of_parse_phandle(dev->of_node, "port", 0); if (!ssp_handle) { dev_err(dev, "unable to get 'port' phandle\n"); ret = -ENODEV; goto err_priv; } priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio"); if (priv->ssp == NULL) { ret = -ENODEV; goto err_priv; } } else { priv->ssp = pxa_ssp_request(dai->id + 1, "SoC audio"); if (priv->ssp == NULL) { ret = -ENODEV; goto err_priv; } } priv->dai_fmt = (unsigned int) -1; snd_soc_dai_set_drvdata(dai, priv); return 0; err_priv: kfree(priv); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
daniel mackdaniel mack9448.45%228.57%
mark brownmark brown8744.85%114.29%
dan carpenterdan carpenter63.09%114.29%
liam girdwoodliam girdwood42.06%114.29%
philipp zabelphilipp zabel21.03%114.29%
haojian zhuanghaojian zhuang10.52%114.29%
Total194100.00%7100.00%


static int pxa_ssp_remove(struct snd_soc_dai *dai) { struct ssp_priv *priv = snd_soc_dai_get_drvdata(dai); pxa_ssp_free(priv->ssp); kfree(priv); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown2363.89%125.00%
liam girdwoodliam girdwood719.44%125.00%
axel linaxel lin513.89%125.00%
haojian zhuanghaojian zhuang12.78%125.00%
Total36100.00%4100.00%

#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \ SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \ SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) #define PXA_SSP_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) static const struct snd_soc_dai_ops pxa_ssp_dai_ops = { .startup = pxa_ssp_startup, .shutdown = pxa_ssp_shutdown, .trigger = pxa_ssp_trigger, .hw_params = pxa_ssp_hw_params, .set_sysclk = pxa_ssp_set_dai_sysclk, .set_clkdiv = pxa_ssp_set_dai_clkdiv, .set_pll = pxa_ssp_set_dai_pll, .set_fmt = pxa_ssp_set_dai_fmt, .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, .set_tristate = pxa_ssp_set_dai_tristate, }; static struct snd_soc_dai_driver pxa_ssp_dai = { .probe = pxa_ssp_probe, .remove = pxa_ssp_remove, .suspend = pxa_ssp_suspend, .resume = pxa_ssp_resume, .playback = { .channels_min = 1, .channels_max = 8, .rates = PXA_SSP_RATES, .formats = PXA_SSP_FORMATS, }, .capture = { .channels_min = 1, .channels_max = 8, .rates = PXA_SSP_RATES, .formats = PXA_SSP_FORMATS, }, .ops = &pxa_ssp_dai_ops, }; static const struct snd_soc_component_driver pxa_ssp_component = { .name = "pxa-ssp", }; #ifdef CONFIG_OF static const struct of_device_id pxa_ssp_of_ids[] = { { .compatible = "mrvl,pxa-ssp-dai" }, {} }; MODULE_DEVICE_TABLE(of, pxa_ssp_of_ids); #endif
static int asoc_ssp_probe(struct platform_device *pdev) { return devm_snd_soc_register_component(&pdev->dev, &pxa_ssp_component, &pxa_ssp_dai, 1); }

Contributors

PersonTokensPropCommitsCommitProp
liam girdwoodliam girdwood2071.43%120.00%
kuninori morimotokuninori morimoto517.86%120.00%
mark brownmark brown13.57%120.00%
axel linaxel lin13.57%120.00%
eric miaoeric miao13.57%120.00%
Total28100.00%5100.00%

static struct platform_driver asoc_ssp_driver = { .driver = { .name = "pxa-ssp-dai", .of_match_table = of_match_ptr(pxa_ssp_of_ids), }, .probe = asoc_ssp_probe, }; module_platform_driver(asoc_ssp_driver); /* Module information */ MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); MODULE_DESCRIPTION("PXA SSP/PCM SoC Interface"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:pxa-ssp-dai");

Overall Contributors

PersonTokensPropCommitsCommitProp
mark brownmark brown190456.52%510.42%
daniel mackdaniel mack50414.96%1122.92%
eric miaoeric miao35710.60%48.33%
philipp zabelphilipp zabel1594.72%36.25%
haojian zhuanghaojian zhuang1143.38%36.25%
daniel ribeirodaniel ribeiro1013.00%36.25%
liam girdwoodliam girdwood862.55%12.08%
qiao zhouqiao zhou461.37%24.17%
guoyhguoyh270.80%12.08%
kuninori morimotokuninori morimoto180.53%12.08%
dmitry eremin-baryshkovdmitry eremin-baryshkov80.24%12.08%
axel linaxel lin70.21%36.25%
luis de bethencourtluis de bethencourt70.21%12.08%
dan carpenterdan carpenter60.18%12.08%
russell kingrussell king60.18%12.08%
andrea adamiandrea adami50.15%12.08%
tejun heotejun heo30.09%12.08%
stephen boydstephen boyd30.09%12.08%
sebastian andrzej siewiorsebastian andrzej siewior30.09%12.08%
roel kluinroel kluin20.06%12.08%
graeme gregorygraeme gregory20.06%12.08%
lars-peter clausenlars-peter clausen10.03%12.08%
Total3369100.00%48100.00%
Directory: sound/soc/pxa
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}