Merge series "ASoC: Add new module driver for new ASRC" from Shengjiu Wang <shengjiu.wang@nxp.com>:
Add new module driver for new ASRC in i.MX8MN, several commits are added for new property fsl,asrc-format Shengjiu Wang (7): ASoC: fsl_asrc: rename asrc_priv to asrc ASoC: dt-bindings: fsl_asrc: Add new property fsl,asrc-format ASoC: fsl-asoc-card: Support new property fsl,asrc-format ASoC: fsl_asrc: Support new property fsl,asrc-format ASoC: fsl_asrc: Move common definition to fsl_asrc_common ASoC: dt-bindings: fsl_easrc: Add document for EASRC ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers changes in v9 - use lowercase for dt example. changes in v8 - change get_pair_priv_size to pair_priv_size variable changes in v7 - updated according to Nicoin's comments. - add get_pair_priv_size to replace PAIR_PRIVATE_SIZE changes in v6 - updated according to Nicoin's and Rob's comments. changes in v5 - Add new property fsl,asrc-format, rather than change fsl,asrc-width to fsl,asrc-formt. - code change for above change. changes in v4 - Add several commit for changing DT binding asrc-width to asrc-format - rename asrc_priv to asrc changes in v3 - add new commit "ASoC: fsl_asrc: Change asrc_width to asrc_format" - modify binding doc to yaml format - remove fsl_easrc_dma.c, make fsl_asrc_dma.c useable for easrc. changes in v2 - change i.MX815 to i.MX8MN - Add changes in Kconfig and Makefile .../devicetree/bindings/sound/fsl,asrc.txt | 4 + .../devicetree/bindings/sound/fsl,easrc.yaml | 101 + sound/soc/fsl/Kconfig | 11 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl-asoc-card.c | 24 +- sound/soc/fsl/fsl_asrc.c | 305 +-- sound/soc/fsl/fsl_asrc.h | 74 +- sound/soc/fsl/fsl_asrc_common.h | 106 + sound/soc/fsl/fsl_asrc_dma.c | 54 +- sound/soc/fsl/fsl_easrc.c | 2114 +++++++++++++++++ sound/soc/fsl/fsl_easrc.h | 651 +++++ 11 files changed, 3212 insertions(+), 234 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/fsl,easrc.yaml create mode 100644 sound/soc/fsl/fsl_asrc_common.h create mode 100644 sound/soc/fsl/fsl_easrc.c create mode 100644 sound/soc/fsl/fsl_easrc.h -- 2.21.0
This commit is contained in:
commit
787a46c027
|
@ -51,6 +51,10 @@ Optional properties:
|
|||
will be in use as default. Otherwise, the big endian
|
||||
mode will be in use for all the device registers.
|
||||
|
||||
- fsl,asrc-format : Defines a mutual sample format used by DPCM Back
|
||||
Ends, which can replace the fsl,asrc-width.
|
||||
The value is 2 (S16_LE), or 6 (S24_LE).
|
||||
|
||||
Example:
|
||||
|
||||
asrc: asrc@2034000 {
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/sound/fsl,easrc.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: NXP Asynchronous Sample Rate Converter (ASRC) Controller
|
||||
|
||||
maintainers:
|
||||
- Shengjiu Wang <shengjiu.wang@nxp.com>
|
||||
|
||||
properties:
|
||||
$nodename:
|
||||
pattern: "^easrc@.*"
|
||||
|
||||
compatible:
|
||||
const: fsl,imx8mn-easrc
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
interrupts:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
items:
|
||||
- description: Peripheral clock
|
||||
|
||||
clock-names:
|
||||
items:
|
||||
- const: mem
|
||||
|
||||
dmas:
|
||||
maxItems: 8
|
||||
|
||||
dma-names:
|
||||
items:
|
||||
- const: ctx0_rx
|
||||
- const: ctx0_tx
|
||||
- const: ctx1_rx
|
||||
- const: ctx1_tx
|
||||
- const: ctx2_rx
|
||||
- const: ctx2_tx
|
||||
- const: ctx3_rx
|
||||
- const: ctx3_tx
|
||||
|
||||
firmware-name:
|
||||
allOf:
|
||||
- $ref: /schemas/types.yaml#/definitions/string
|
||||
- const: imx/easrc/easrc-imx8mn.bin
|
||||
description: The coefficient table for the filters
|
||||
|
||||
fsl,asrc-rate:
|
||||
allOf:
|
||||
- $ref: /schemas/types.yaml#/definitions/uint32
|
||||
- minimum: 8000
|
||||
- maximum: 192000
|
||||
description: Defines a mutual sample rate used by DPCM Back Ends
|
||||
|
||||
fsl,asrc-format:
|
||||
allOf:
|
||||
- $ref: /schemas/types.yaml#/definitions/uint32
|
||||
- enum: [2, 6, 10, 32, 36]
|
||||
default: 2
|
||||
description:
|
||||
Defines a mutual sample format used by DPCM Back Ends
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- interrupts
|
||||
- clocks
|
||||
- clock-names
|
||||
- dmas
|
||||
- dma-names
|
||||
- firmware-name
|
||||
- fsl,asrc-rate
|
||||
- fsl,asrc-format
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/clock/imx8mn-clock.h>
|
||||
|
||||
easrc: easrc@300c0000 {
|
||||
compatible = "fsl,imx8mn-easrc";
|
||||
reg = <0x0 0x300c0000 0x0 0x10000>;
|
||||
interrupts = <0x0 122 0x4>;
|
||||
clocks = <&clk IMX8MN_CLK_ASRC_ROOT>;
|
||||
clock-names = "mem";
|
||||
dmas = <&sdma2 16 23 0> , <&sdma2 17 23 0>,
|
||||
<&sdma2 18 23 0> , <&sdma2 19 23 0>,
|
||||
<&sdma2 20 23 0> , <&sdma2 21 23 0>,
|
||||
<&sdma2 22 23 0> , <&sdma2 23 23 0>;
|
||||
dma-names = "ctx0_rx", "ctx0_tx",
|
||||
"ctx1_rx", "ctx1_tx",
|
||||
"ctx2_rx", "ctx2_tx",
|
||||
"ctx3_rx", "ctx3_tx";
|
||||
firmware-name = "imx/easrc/easrc-imx8mn.bin";
|
||||
fsl,asrc-rate = <8000>;
|
||||
fsl,asrc-format = <2>;
|
||||
};
|
|
@ -84,6 +84,17 @@ config SND_SOC_FSL_MICFIL
|
|||
Say Y if you want to add Pulse Density Modulation microphone
|
||||
interface (MICFIL) support for NXP.
|
||||
|
||||
config SND_SOC_FSL_EASRC
|
||||
tristate "Enhanced Asynchronous Sample Rate Converter (EASRC) module support"
|
||||
depends on SND_SOC_FSL_ASRC
|
||||
select REGMAP_MMIO
|
||||
select SND_SOC_GENERIC_DMAENGINE_PCM
|
||||
help
|
||||
Say Y if you want to add Enhanced ASRC support for NXP. The ASRC is
|
||||
a digital module that converts audio from a source sample rate to a
|
||||
destination sample rate. It is a new design module compare with the
|
||||
old ASRC.
|
||||
|
||||
config SND_SOC_FSL_UTILS
|
||||
tristate
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ snd-soc-fsl-micfil-objs := fsl_micfil.o
|
|||
snd-soc-fsl-utils-objs := fsl_utils.o
|
||||
snd-soc-fsl-dma-objs := fsl_dma.o
|
||||
snd-soc-fsl-mqs-objs := fsl_mqs.o
|
||||
snd-soc-fsl-easrc-objs := fsl_easrc.o
|
||||
|
||||
obj-$(CONFIG_SND_SOC_FSL_AUDMIX) += snd-soc-fsl-audmix.o
|
||||
obj-$(CONFIG_SND_SOC_FSL_ASOC_CARD) += snd-soc-fsl-asoc-card.o
|
||||
|
@ -35,6 +36,7 @@ obj-$(CONFIG_SND_SOC_FSL_ESAI) += snd-soc-fsl-esai.o
|
|||
obj-$(CONFIG_SND_SOC_FSL_MICFIL) += snd-soc-fsl-micfil.o
|
||||
obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o
|
||||
obj-$(CONFIG_SND_SOC_FSL_MQS) += snd-soc-fsl-mqs.o
|
||||
obj-$(CONFIG_SND_SOC_FSL_EASRC) += snd-soc-fsl-easrc.o
|
||||
obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o
|
||||
|
||||
# MPC5200 Platform Support
|
||||
|
|
|
@ -680,17 +680,23 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
|
|||
goto asrc_fail;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(asrc_np, "fsl,asrc-width", &width);
|
||||
ret = of_property_read_u32(asrc_np, "fsl,asrc-format",
|
||||
&priv->asrc_format);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to get output rate\n");
|
||||
ret = -EINVAL;
|
||||
goto asrc_fail;
|
||||
}
|
||||
/* Fallback to old binding; translate to asrc_format */
|
||||
ret = of_property_read_u32(asrc_np, "fsl,asrc-width",
|
||||
&width);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"failed to decide output format\n");
|
||||
goto asrc_fail;
|
||||
}
|
||||
|
||||
if (width == 24)
|
||||
priv->asrc_format = SNDRV_PCM_FORMAT_S24_LE;
|
||||
else
|
||||
priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
if (width == 24)
|
||||
priv->asrc_format = SNDRV_PCM_FORMAT_S24_LE;
|
||||
else
|
||||
priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finish card registering */
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#define IDEAL_RATIO_DECIMAL_DEPTH 26
|
||||
|
||||
#define pair_err(fmt, ...) \
|
||||
dev_err(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
|
||||
dev_err(&asrc->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
|
||||
|
||||
#define pair_dbg(fmt, ...) \
|
||||
dev_dbg(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
|
||||
dev_dbg(&asrc->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
|
||||
|
||||
/* Corresponding to process_option */
|
||||
static unsigned int supported_asrc_rate[] = {
|
||||
|
@ -157,15 +157,15 @@ static void fsl_asrc_sel_proc(int inrate, int outrate,
|
|||
int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
|
||||
{
|
||||
enum asrc_pair_index index = ASRC_INVALID_PAIR;
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct device *dev = &asrc_priv->pdev->dev;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
struct device *dev = &asrc->pdev->dev;
|
||||
unsigned long lock_flags;
|
||||
int i, ret = 0;
|
||||
|
||||
spin_lock_irqsave(&asrc_priv->lock, lock_flags);
|
||||
spin_lock_irqsave(&asrc->lock, lock_flags);
|
||||
|
||||
for (i = ASRC_PAIR_A; i < ASRC_PAIR_MAX_NUM; i++) {
|
||||
if (asrc_priv->pair[i] != NULL)
|
||||
if (asrc->pair[i] != NULL)
|
||||
continue;
|
||||
|
||||
index = i;
|
||||
|
@ -177,17 +177,17 @@ int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
|
|||
if (index == ASRC_INVALID_PAIR) {
|
||||
dev_err(dev, "all pairs are busy now\n");
|
||||
ret = -EBUSY;
|
||||
} else if (asrc_priv->channel_avail < channels) {
|
||||
} else if (asrc->channel_avail < channels) {
|
||||
dev_err(dev, "can't afford required channels: %d\n", channels);
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
asrc_priv->channel_avail -= channels;
|
||||
asrc_priv->pair[index] = pair;
|
||||
asrc->channel_avail -= channels;
|
||||
asrc->pair[index] = pair;
|
||||
pair->channels = channels;
|
||||
pair->index = index;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&asrc_priv->lock, lock_flags);
|
||||
spin_unlock_irqrestore(&asrc->lock, lock_flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -195,25 +195,25 @@ int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
|
|||
/**
|
||||
* Release ASRC pair
|
||||
*
|
||||
* It clears the resource from asrc_priv and releases the occupied channels.
|
||||
* It clears the resource from asrc and releases the occupied channels.
|
||||
*/
|
||||
void fsl_asrc_release_pair(struct fsl_asrc_pair *pair)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
unsigned long lock_flags;
|
||||
|
||||
/* Make sure the pair is disabled */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ASRCEi_MASK(index), 0);
|
||||
|
||||
spin_lock_irqsave(&asrc_priv->lock, lock_flags);
|
||||
spin_lock_irqsave(&asrc->lock, lock_flags);
|
||||
|
||||
asrc_priv->channel_avail += pair->channels;
|
||||
asrc_priv->pair[index] = NULL;
|
||||
asrc->channel_avail += pair->channels;
|
||||
asrc->pair[index] = NULL;
|
||||
pair->error = 0;
|
||||
|
||||
spin_unlock_irqrestore(&asrc_priv->lock, lock_flags);
|
||||
spin_unlock_irqrestore(&asrc->lock, lock_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,10 +221,10 @@ void fsl_asrc_release_pair(struct fsl_asrc_pair *pair)
|
|||
*/
|
||||
static void fsl_asrc_set_watermarks(struct fsl_asrc_pair *pair, u32 in, u32 out)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRMCR(index),
|
||||
regmap_update_bits(asrc->regmap, REG_ASRMCR(index),
|
||||
ASRMCRi_EXTTHRSHi_MASK |
|
||||
ASRMCRi_INFIFO_THRESHOLD_MASK |
|
||||
ASRMCRi_OUTFIFO_THRESHOLD_MASK,
|
||||
|
@ -257,7 +257,7 @@ static u32 fsl_asrc_cal_asrck_divisor(struct fsl_asrc_pair *pair, u32 div)
|
|||
static int fsl_asrc_set_ideal_ratio(struct fsl_asrc_pair *pair,
|
||||
int inrate, int outrate)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
unsigned long ratio;
|
||||
int i;
|
||||
|
@ -286,8 +286,8 @@ static int fsl_asrc_set_ideal_ratio(struct fsl_asrc_pair *pair,
|
|||
break;
|
||||
}
|
||||
|
||||
regmap_write(asrc_priv->regmap, REG_ASRIDRL(index), ratio);
|
||||
regmap_write(asrc_priv->regmap, REG_ASRIDRH(index), ratio >> 24);
|
||||
regmap_write(asrc->regmap, REG_ASRIDRL(index), ratio);
|
||||
regmap_write(asrc->regmap, REG_ASRIDRH(index), ratio >> 24);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -308,8 +308,10 @@ static int fsl_asrc_set_ideal_ratio(struct fsl_asrc_pair *pair,
|
|||
*/
|
||||
static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate)
|
||||
{
|
||||
struct asrc_config *config = pair->config;
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc_pair_priv *pair_priv = pair->private;
|
||||
struct asrc_config *config = pair_priv->config;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
struct fsl_asrc_priv *asrc_priv = asrc->private;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
enum asrc_word_width input_word_width;
|
||||
enum asrc_word_width output_word_width;
|
||||
|
@ -441,18 +443,18 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate)
|
|||
channels /= 2;
|
||||
|
||||
/* Update channels for current pair */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCNCR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCNCR,
|
||||
ASRCNCR_ANCi_MASK(index, asrc_priv->soc->channel_bits),
|
||||
ASRCNCR_ANCi(index, channels, asrc_priv->soc->channel_bits));
|
||||
|
||||
/* Default setting: Automatic selection for processing mode */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ATSi_MASK(index), ASRCTR_ATS(index));
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_USRi_MASK(index), 0);
|
||||
|
||||
/* Set the input and output clock sources */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCSR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCSR,
|
||||
ASRCSR_AICSi_MASK(index) | ASRCSR_AOCSi_MASK(index),
|
||||
ASRCSR_AICS(index, clk_index[IN]) |
|
||||
ASRCSR_AOCS(index, clk_index[OUT]));
|
||||
|
@ -462,19 +464,19 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate)
|
|||
outdiv = fsl_asrc_cal_asrck_divisor(pair, div[OUT]);
|
||||
|
||||
/* Suppose indiv and outdiv includes prescaler, so add its MASK too */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCDR(index),
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCDR(index),
|
||||
ASRCDRi_AOCPi_MASK(index) | ASRCDRi_AICPi_MASK(index) |
|
||||
ASRCDRi_AOCDi_MASK(index) | ASRCDRi_AICDi_MASK(index),
|
||||
ASRCDRi_AOCP(index, outdiv) | ASRCDRi_AICP(index, indiv));
|
||||
|
||||
/* Implement word_width configurations */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRMCR1(index),
|
||||
regmap_update_bits(asrc->regmap, REG_ASRMCR1(index),
|
||||
ASRMCR1i_OW16_MASK | ASRMCR1i_IWD_MASK,
|
||||
ASRMCR1i_OW16(output_word_width) |
|
||||
ASRMCR1i_IWD(input_word_width));
|
||||
|
||||
/* Enable BUFFER STALL */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRMCR(index),
|
||||
regmap_update_bits(asrc->regmap, REG_ASRMCR(index),
|
||||
ASRMCRi_BUFSTALLi_MASK, ASRMCRi_BUFSTALLi);
|
||||
|
||||
/* Set default thresholds for input and output FIFO */
|
||||
|
@ -486,18 +488,18 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate)
|
|||
return 0;
|
||||
|
||||
/* Clear ASTSx bit to use Ideal Ratio mode */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ATSi_MASK(index), 0);
|
||||
|
||||
/* Enable Ideal Ratio mode */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_IDRi_MASK(index) | ASRCTR_USRi_MASK(index),
|
||||
ASRCTR_IDR(index) | ASRCTR_USR(index));
|
||||
|
||||
fsl_asrc_sel_proc(inrate, outrate, &pre_proc, &post_proc);
|
||||
|
||||
/* Apply configurations for pre- and post-processing */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCFG,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCFG,
|
||||
ASRCFG_PREMODi_MASK(index) | ASRCFG_POSTMODi_MASK(index),
|
||||
ASRCFG_PREMOD(index, pre_proc) |
|
||||
ASRCFG_POSTMOD(index, post_proc));
|
||||
|
@ -512,28 +514,28 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate)
|
|||
*/
|
||||
static void fsl_asrc_start_pair(struct fsl_asrc_pair *pair)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
int reg, retry = 10, i;
|
||||
|
||||
/* Enable the current pair */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ASRCEi_MASK(index), ASRCTR_ASRCE(index));
|
||||
|
||||
/* Wait for status of initialization */
|
||||
do {
|
||||
udelay(5);
|
||||
regmap_read(asrc_priv->regmap, REG_ASRCFG, ®);
|
||||
regmap_read(asrc->regmap, REG_ASRCFG, ®);
|
||||
reg &= ASRCFG_INIRQi_MASK(index);
|
||||
} while (!reg && --retry);
|
||||
|
||||
/* Make the input fifo to ASRC STALL level */
|
||||
regmap_read(asrc_priv->regmap, REG_ASRCNCR, ®);
|
||||
regmap_read(asrc->regmap, REG_ASRCNCR, ®);
|
||||
for (i = 0; i < pair->channels * 4; i++)
|
||||
regmap_write(asrc_priv->regmap, REG_ASRDI(index), 0);
|
||||
regmap_write(asrc->regmap, REG_ASRDI(index), 0);
|
||||
|
||||
/* Enable overload interrupt */
|
||||
regmap_write(asrc_priv->regmap, REG_ASRIER, ASRIER_AOLIE);
|
||||
regmap_write(asrc->regmap, REG_ASRIER, ASRIER_AOLIE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -541,11 +543,11 @@ static void fsl_asrc_start_pair(struct fsl_asrc_pair *pair)
|
|||
*/
|
||||
static void fsl_asrc_stop_pair(struct fsl_asrc_pair *pair)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
|
||||
/* Stop the current pair */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ASRCEi_MASK(index), 0);
|
||||
}
|
||||
|
||||
|
@ -554,20 +556,21 @@ static void fsl_asrc_stop_pair(struct fsl_asrc_pair *pair)
|
|||
*/
|
||||
struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
char name[4];
|
||||
|
||||
sprintf(name, "%cx%c", dir == IN ? 'r' : 't', index + 'a');
|
||||
|
||||
return dma_request_slave_channel(&asrc_priv->pdev->dev, name);
|
||||
return dma_request_slave_channel(&asrc->pdev->dev, name);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fsl_asrc_get_dma_channel);
|
||||
|
||||
static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai);
|
||||
struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai);
|
||||
struct fsl_asrc_priv *asrc_priv = asrc->private;
|
||||
|
||||
/* Odd channel number is not valid for older ASRC (channel_bits==3) */
|
||||
if (asrc_priv->soc->channel_bits == 3)
|
||||
|
@ -583,13 +586,13 @@ static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
struct snd_pcm_hw_params *params,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai);
|
||||
struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai);
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct fsl_asrc_pair *pair = runtime->private_data;
|
||||
struct fsl_asrc_pair_priv *pair_priv = pair->private;
|
||||
unsigned int channels = params_channels(params);
|
||||
unsigned int rate = params_rate(params);
|
||||
struct asrc_config config;
|
||||
snd_pcm_format_t format;
|
||||
int ret;
|
||||
|
||||
ret = fsl_asrc_request_pair(channels, pair);
|
||||
|
@ -598,12 +601,7 @@ static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
return ret;
|
||||
}
|
||||
|
||||
pair->config = &config;
|
||||
|
||||
if (asrc_priv->asrc_width == 16)
|
||||
format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
else
|
||||
format = SNDRV_PCM_FORMAT_S24_LE;
|
||||
pair_priv->config = &config;
|
||||
|
||||
config.pair = pair->index;
|
||||
config.channel_num = channels;
|
||||
|
@ -612,13 +610,13 @@ static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||
config.input_format = params_format(params);
|
||||
config.output_format = format;
|
||||
config.output_format = asrc->asrc_format;
|
||||
config.input_sample_rate = rate;
|
||||
config.output_sample_rate = asrc_priv->asrc_rate;
|
||||
config.output_sample_rate = asrc->asrc_rate;
|
||||
} else {
|
||||
config.input_format = format;
|
||||
config.input_format = asrc->asrc_format;
|
||||
config.output_format = params_format(params);
|
||||
config.input_sample_rate = asrc_priv->asrc_rate;
|
||||
config.input_sample_rate = asrc->asrc_rate;
|
||||
config.output_sample_rate = rate;
|
||||
}
|
||||
|
||||
|
@ -676,10 +674,10 @@ static const struct snd_soc_dai_ops fsl_asrc_dai_ops = {
|
|||
|
||||
static int fsl_asrc_dai_probe(struct snd_soc_dai *dai)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai);
|
||||
struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai);
|
||||
|
||||
snd_soc_dai_init_dma_data(dai, &asrc_priv->dma_params_tx,
|
||||
&asrc_priv->dma_params_rx);
|
||||
snd_soc_dai_init_dma_data(dai, &asrc->dma_params_tx,
|
||||
&asrc->dma_params_rx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -858,30 +856,30 @@ static const struct regmap_config fsl_asrc_regmap_config = {
|
|||
/**
|
||||
* Initialize ASRC registers with a default configurations
|
||||
*/
|
||||
static int fsl_asrc_init(struct fsl_asrc *asrc_priv)
|
||||
static int fsl_asrc_init(struct fsl_asrc *asrc)
|
||||
{
|
||||
/* Halt ASRC internal FP when input FIFO needs data for pair A, B, C */
|
||||
regmap_write(asrc_priv->regmap, REG_ASRCTR, ASRCTR_ASRCEN);
|
||||
regmap_write(asrc->regmap, REG_ASRCTR, ASRCTR_ASRCEN);
|
||||
|
||||
/* Disable interrupt by default */
|
||||
regmap_write(asrc_priv->regmap, REG_ASRIER, 0x0);
|
||||
regmap_write(asrc->regmap, REG_ASRIER, 0x0);
|
||||
|
||||
/* Apply recommended settings for parameters from Reference Manual */
|
||||
regmap_write(asrc_priv->regmap, REG_ASRPM1, 0x7fffff);
|
||||
regmap_write(asrc_priv->regmap, REG_ASRPM2, 0x255555);
|
||||
regmap_write(asrc_priv->regmap, REG_ASRPM3, 0xff7280);
|
||||
regmap_write(asrc_priv->regmap, REG_ASRPM4, 0xff7280);
|
||||
regmap_write(asrc_priv->regmap, REG_ASRPM5, 0xff7280);
|
||||
regmap_write(asrc->regmap, REG_ASRPM1, 0x7fffff);
|
||||
regmap_write(asrc->regmap, REG_ASRPM2, 0x255555);
|
||||
regmap_write(asrc->regmap, REG_ASRPM3, 0xff7280);
|
||||
regmap_write(asrc->regmap, REG_ASRPM4, 0xff7280);
|
||||
regmap_write(asrc->regmap, REG_ASRPM5, 0xff7280);
|
||||
|
||||
/* Base address for task queue FIFO. Set to 0x7C */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRTFR1,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRTFR1,
|
||||
ASRTFR1_TF_BASE_MASK, ASRTFR1_TF_BASE(0xfc));
|
||||
|
||||
/* Set the processing clock for 76KHz to 133M */
|
||||
regmap_write(asrc_priv->regmap, REG_ASR76K, 0x06D6);
|
||||
regmap_write(asrc->regmap, REG_ASR76K, 0x06D6);
|
||||
|
||||
/* Set the processing clock for 56KHz to 133M */
|
||||
return regmap_write(asrc_priv->regmap, REG_ASR56K, 0x0947);
|
||||
return regmap_write(asrc->regmap, REG_ASR56K, 0x0947);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -889,15 +887,15 @@ static int fsl_asrc_init(struct fsl_asrc *asrc_priv)
|
|||
*/
|
||||
static irqreturn_t fsl_asrc_isr(int irq, void *dev_id)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = (struct fsl_asrc *)dev_id;
|
||||
struct device *dev = &asrc_priv->pdev->dev;
|
||||
struct fsl_asrc *asrc = (struct fsl_asrc *)dev_id;
|
||||
struct device *dev = &asrc->pdev->dev;
|
||||
enum asrc_pair_index index;
|
||||
u32 status;
|
||||
|
||||
regmap_read(asrc_priv->regmap, REG_ASRSTR, &status);
|
||||
regmap_read(asrc->regmap, REG_ASRSTR, &status);
|
||||
|
||||
/* Clean overload error */
|
||||
regmap_write(asrc_priv->regmap, REG_ASRSTR, ASRSTR_AOLE);
|
||||
regmap_write(asrc->regmap, REG_ASRSTR, ASRSTR_AOLE);
|
||||
|
||||
/*
|
||||
* We here use dev_dbg() for all exceptions because ASRC itself does
|
||||
|
@ -905,31 +903,31 @@ static irqreturn_t fsl_asrc_isr(int irq, void *dev_id)
|
|||
* interrupt would result a ridged conversion.
|
||||
*/
|
||||
for (index = ASRC_PAIR_A; index < ASRC_PAIR_MAX_NUM; index++) {
|
||||
if (!asrc_priv->pair[index])
|
||||
if (!asrc->pair[index])
|
||||
continue;
|
||||
|
||||
if (status & ASRSTR_ATQOL) {
|
||||
asrc_priv->pair[index]->error |= ASRC_TASK_Q_OVERLOAD;
|
||||
asrc->pair[index]->error |= ASRC_TASK_Q_OVERLOAD;
|
||||
dev_dbg(dev, "ASRC Task Queue FIFO overload\n");
|
||||
}
|
||||
|
||||
if (status & ASRSTR_AOOL(index)) {
|
||||
asrc_priv->pair[index]->error |= ASRC_OUTPUT_TASK_OVERLOAD;
|
||||
asrc->pair[index]->error |= ASRC_OUTPUT_TASK_OVERLOAD;
|
||||
pair_dbg("Output Task Overload\n");
|
||||
}
|
||||
|
||||
if (status & ASRSTR_AIOL(index)) {
|
||||
asrc_priv->pair[index]->error |= ASRC_INPUT_TASK_OVERLOAD;
|
||||
asrc->pair[index]->error |= ASRC_INPUT_TASK_OVERLOAD;
|
||||
pair_dbg("Input Task Overload\n");
|
||||
}
|
||||
|
||||
if (status & ASRSTR_AODO(index)) {
|
||||
asrc_priv->pair[index]->error |= ASRC_OUTPUT_BUFFER_OVERFLOW;
|
||||
asrc->pair[index]->error |= ASRC_OUTPUT_BUFFER_OVERFLOW;
|
||||
pair_dbg("Output Data Buffer has overflowed\n");
|
||||
}
|
||||
|
||||
if (status & ASRSTR_AIDU(index)) {
|
||||
asrc_priv->pair[index]->error |= ASRC_INPUT_BUFFER_UNDERRUN;
|
||||
asrc->pair[index]->error |= ASRC_INPUT_BUFFER_UNDERRUN;
|
||||
pair_dbg("Input Data Buffer has underflowed\n");
|
||||
}
|
||||
}
|
||||
|
@ -937,21 +935,33 @@ static irqreturn_t fsl_asrc_isr(int irq, void *dev_id)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int fsl_asrc_get_fifo_addr(u8 dir, enum asrc_pair_index index)
|
||||
{
|
||||
return REG_ASRDx(dir, index);
|
||||
}
|
||||
|
||||
static int fsl_asrc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct fsl_asrc *asrc_priv;
|
||||
struct fsl_asrc_priv *asrc_priv;
|
||||
struct fsl_asrc *asrc;
|
||||
struct resource *res;
|
||||
void __iomem *regs;
|
||||
int irq, ret, i;
|
||||
u32 map_idx;
|
||||
char tmp[16];
|
||||
u32 width;
|
||||
|
||||
asrc = devm_kzalloc(&pdev->dev, sizeof(*asrc), GFP_KERNEL);
|
||||
if (!asrc)
|
||||
return -ENOMEM;
|
||||
|
||||
asrc_priv = devm_kzalloc(&pdev->dev, sizeof(*asrc_priv), GFP_KERNEL);
|
||||
if (!asrc_priv)
|
||||
return -ENOMEM;
|
||||
|
||||
asrc_priv->pdev = pdev;
|
||||
asrc->pdev = pdev;
|
||||
asrc->private = asrc_priv;
|
||||
|
||||
/* Get the addresses and IRQ */
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
|
@ -959,13 +969,13 @@ static int fsl_asrc_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(regs))
|
||||
return PTR_ERR(regs);
|
||||
|
||||
asrc_priv->paddr = res->start;
|
||||
asrc->paddr = res->start;
|
||||
|
||||
asrc_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "mem", regs,
|
||||
&fsl_asrc_regmap_config);
|
||||
if (IS_ERR(asrc_priv->regmap)) {
|
||||
asrc->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "mem", regs,
|
||||
&fsl_asrc_regmap_config);
|
||||
if (IS_ERR(asrc->regmap)) {
|
||||
dev_err(&pdev->dev, "failed to init regmap\n");
|
||||
return PTR_ERR(asrc_priv->regmap);
|
||||
return PTR_ERR(asrc->regmap);
|
||||
}
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
|
@ -973,26 +983,26 @@ static int fsl_asrc_probe(struct platform_device *pdev)
|
|||
return irq;
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0,
|
||||
dev_name(&pdev->dev), asrc_priv);
|
||||
dev_name(&pdev->dev), asrc);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to claim irq %u: %d\n", irq, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
asrc_priv->mem_clk = devm_clk_get(&pdev->dev, "mem");
|
||||
if (IS_ERR(asrc_priv->mem_clk)) {
|
||||
asrc->mem_clk = devm_clk_get(&pdev->dev, "mem");
|
||||
if (IS_ERR(asrc->mem_clk)) {
|
||||
dev_err(&pdev->dev, "failed to get mem clock\n");
|
||||
return PTR_ERR(asrc_priv->mem_clk);
|
||||
return PTR_ERR(asrc->mem_clk);
|
||||
}
|
||||
|
||||
asrc_priv->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
|
||||
if (IS_ERR(asrc_priv->ipg_clk)) {
|
||||
asrc->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
|
||||
if (IS_ERR(asrc->ipg_clk)) {
|
||||
dev_err(&pdev->dev, "failed to get ipg clock\n");
|
||||
return PTR_ERR(asrc_priv->ipg_clk);
|
||||
return PTR_ERR(asrc->ipg_clk);
|
||||
}
|
||||
|
||||
asrc_priv->spba_clk = devm_clk_get(&pdev->dev, "spba");
|
||||
if (IS_ERR(asrc_priv->spba_clk))
|
||||
asrc->spba_clk = devm_clk_get(&pdev->dev, "spba");
|
||||
if (IS_ERR(asrc->spba_clk))
|
||||
dev_warn(&pdev->dev, "failed to get spba clock\n");
|
||||
|
||||
for (i = 0; i < ASRC_CLK_MAX_NUM; i++) {
|
||||
|
@ -1010,6 +1020,13 @@ static int fsl_asrc_probe(struct platform_device *pdev)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
asrc->use_edma = asrc_priv->soc->use_edma;
|
||||
asrc->get_dma_channel = fsl_asrc_get_dma_channel;
|
||||
asrc->request_pair = fsl_asrc_request_pair;
|
||||
asrc->release_pair = fsl_asrc_release_pair;
|
||||
asrc->get_fifo_addr = fsl_asrc_get_fifo_addr;
|
||||
asrc->pair_priv_size = sizeof(struct fsl_asrc_pair_priv);
|
||||
|
||||
if (of_device_is_compatible(np, "fsl,imx35-asrc")) {
|
||||
asrc_priv->clk_map[IN] = input_clk_map_imx35;
|
||||
asrc_priv->clk_map[OUT] = output_clk_map_imx35;
|
||||
|
@ -1037,36 +1054,52 @@ static int fsl_asrc_probe(struct platform_device *pdev)
|
|||
}
|
||||
}
|
||||
|
||||
ret = fsl_asrc_init(asrc_priv);
|
||||
ret = fsl_asrc_init(asrc);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to init asrc %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
asrc_priv->channel_avail = 10;
|
||||
asrc->channel_avail = 10;
|
||||
|
||||
ret = of_property_read_u32(np, "fsl,asrc-rate",
|
||||
&asrc_priv->asrc_rate);
|
||||
&asrc->asrc_rate);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to get output rate\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(np, "fsl,asrc-width",
|
||||
&asrc_priv->asrc_width);
|
||||
ret = of_property_read_u32(np, "fsl,asrc-format", &asrc->asrc_format);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to get output width\n");
|
||||
return ret;
|
||||
ret = of_property_read_u32(np, "fsl,asrc-width", &width);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to decide output format\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (width) {
|
||||
case 16:
|
||||
asrc->asrc_format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
break;
|
||||
case 24:
|
||||
asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE;
|
||||
break;
|
||||
default:
|
||||
dev_warn(&pdev->dev,
|
||||
"unsupported width, use default S24_LE\n");
|
||||
asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (asrc_priv->asrc_width != 16 && asrc_priv->asrc_width != 24) {
|
||||
dev_warn(&pdev->dev, "unsupported width, switching to 24bit\n");
|
||||
asrc_priv->asrc_width = 24;
|
||||
if (!(FSL_ASRC_FORMATS & (1ULL << asrc->asrc_format))) {
|
||||
dev_warn(&pdev->dev, "unsupported width, use default S24_LE\n");
|
||||
asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, asrc_priv);
|
||||
platform_set_drvdata(pdev, asrc);
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
spin_lock_init(&asrc_priv->lock);
|
||||
spin_lock_init(&asrc->lock);
|
||||
|
||||
ret = devm_snd_soc_register_component(&pdev->dev, &fsl_asrc_component,
|
||||
&fsl_asrc_dai, 1);
|
||||
|
@ -1081,17 +1114,18 @@ static int fsl_asrc_probe(struct platform_device *pdev)
|
|||
#ifdef CONFIG_PM
|
||||
static int fsl_asrc_runtime_resume(struct device *dev)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = dev_get_drvdata(dev);
|
||||
struct fsl_asrc *asrc = dev_get_drvdata(dev);
|
||||
struct fsl_asrc_priv *asrc_priv = asrc->private;
|
||||
int i, ret;
|
||||
|
||||
ret = clk_prepare_enable(asrc_priv->mem_clk);
|
||||
ret = clk_prepare_enable(asrc->mem_clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = clk_prepare_enable(asrc_priv->ipg_clk);
|
||||
ret = clk_prepare_enable(asrc->ipg_clk);
|
||||
if (ret)
|
||||
goto disable_mem_clk;
|
||||
if (!IS_ERR(asrc_priv->spba_clk)) {
|
||||
ret = clk_prepare_enable(asrc_priv->spba_clk);
|
||||
if (!IS_ERR(asrc->spba_clk)) {
|
||||
ret = clk_prepare_enable(asrc->spba_clk);
|
||||
if (ret)
|
||||
goto disable_ipg_clk;
|
||||
}
|
||||
|
@ -1106,26 +1140,27 @@ static int fsl_asrc_runtime_resume(struct device *dev)
|
|||
disable_asrck_clk:
|
||||
for (i--; i >= 0; i--)
|
||||
clk_disable_unprepare(asrc_priv->asrck_clk[i]);
|
||||
if (!IS_ERR(asrc_priv->spba_clk))
|
||||
clk_disable_unprepare(asrc_priv->spba_clk);
|
||||
if (!IS_ERR(asrc->spba_clk))
|
||||
clk_disable_unprepare(asrc->spba_clk);
|
||||
disable_ipg_clk:
|
||||
clk_disable_unprepare(asrc_priv->ipg_clk);
|
||||
clk_disable_unprepare(asrc->ipg_clk);
|
||||
disable_mem_clk:
|
||||
clk_disable_unprepare(asrc_priv->mem_clk);
|
||||
clk_disable_unprepare(asrc->mem_clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int fsl_asrc_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = dev_get_drvdata(dev);
|
||||
struct fsl_asrc *asrc = dev_get_drvdata(dev);
|
||||
struct fsl_asrc_priv *asrc_priv = asrc->private;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ASRC_CLK_MAX_NUM; i++)
|
||||
clk_disable_unprepare(asrc_priv->asrck_clk[i]);
|
||||
if (!IS_ERR(asrc_priv->spba_clk))
|
||||
clk_disable_unprepare(asrc_priv->spba_clk);
|
||||
clk_disable_unprepare(asrc_priv->ipg_clk);
|
||||
clk_disable_unprepare(asrc_priv->mem_clk);
|
||||
if (!IS_ERR(asrc->spba_clk))
|
||||
clk_disable_unprepare(asrc->spba_clk);
|
||||
clk_disable_unprepare(asrc->ipg_clk);
|
||||
clk_disable_unprepare(asrc->mem_clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1134,37 +1169,39 @@ static int fsl_asrc_runtime_suspend(struct device *dev)
|
|||
#ifdef CONFIG_PM_SLEEP
|
||||
static int fsl_asrc_suspend(struct device *dev)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = dev_get_drvdata(dev);
|
||||
struct fsl_asrc *asrc = dev_get_drvdata(dev);
|
||||
struct fsl_asrc_priv *asrc_priv = asrc->private;
|
||||
|
||||
regmap_read(asrc_priv->regmap, REG_ASRCFG,
|
||||
regmap_read(asrc->regmap, REG_ASRCFG,
|
||||
&asrc_priv->regcache_cfg);
|
||||
|
||||
regcache_cache_only(asrc_priv->regmap, true);
|
||||
regcache_mark_dirty(asrc_priv->regmap);
|
||||
regcache_cache_only(asrc->regmap, true);
|
||||
regcache_mark_dirty(asrc->regmap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fsl_asrc_resume(struct device *dev)
|
||||
{
|
||||
struct fsl_asrc *asrc_priv = dev_get_drvdata(dev);
|
||||
struct fsl_asrc *asrc = dev_get_drvdata(dev);
|
||||
struct fsl_asrc_priv *asrc_priv = asrc->private;
|
||||
u32 asrctr;
|
||||
|
||||
/* Stop all pairs provisionally */
|
||||
regmap_read(asrc_priv->regmap, REG_ASRCTR, &asrctr);
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_read(asrc->regmap, REG_ASRCTR, &asrctr);
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ASRCEi_ALL_MASK, 0);
|
||||
|
||||
/* Restore all registers */
|
||||
regcache_cache_only(asrc_priv->regmap, false);
|
||||
regcache_sync(asrc_priv->regmap);
|
||||
regcache_cache_only(asrc->regmap, false);
|
||||
regcache_sync(asrc->regmap);
|
||||
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCFG,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCFG,
|
||||
ASRCFG_NDPRi_ALL_MASK | ASRCFG_POSTMODi_ALL_MASK |
|
||||
ASRCFG_PREMODi_ALL_MASK, asrc_priv->regcache_cfg);
|
||||
|
||||
/* Restart enabled pairs */
|
||||
regmap_update_bits(asrc_priv->regmap, REG_ASRCTR,
|
||||
regmap_update_bits(asrc->regmap, REG_ASRCTR,
|
||||
ASRCTR_ASRCEi_ALL_MASK, asrctr);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#ifndef _FSL_ASRC_H
|
||||
#define _FSL_ASRC_H
|
||||
|
||||
#define IN 0
|
||||
#define OUT 1
|
||||
#include "fsl_asrc_common.h"
|
||||
|
||||
#define ASRC_DMA_BUFFER_NUM 2
|
||||
#define ASRC_INPUTFIFO_THRESHOLD 32
|
||||
|
@ -283,14 +282,6 @@
|
|||
#define ASRMCR1i_OW16_MASK (1 << ASRMCR1i_OW16_SHIFT)
|
||||
#define ASRMCR1i_OW16(v) ((v) << ASRMCR1i_OW16_SHIFT)
|
||||
|
||||
|
||||
enum asrc_pair_index {
|
||||
ASRC_INVALID_PAIR = -1,
|
||||
ASRC_PAIR_A = 0,
|
||||
ASRC_PAIR_B = 1,
|
||||
ASRC_PAIR_C = 2,
|
||||
};
|
||||
|
||||
#define ASRC_PAIR_MAX_NUM (ASRC_PAIR_C + 1)
|
||||
|
||||
enum asrc_inclk {
|
||||
|
@ -446,83 +437,28 @@ struct fsl_asrc_soc_data {
|
|||
};
|
||||
|
||||
/**
|
||||
* fsl_asrc_pair: ASRC Pair private data
|
||||
* fsl_asrc_pair_priv: ASRC Pair private data
|
||||
*
|
||||
* @asrc_priv: pointer to its parent module
|
||||
* @config: configuration profile
|
||||
* @error: error record
|
||||
* @index: pair index (ASRC_PAIR_A, ASRC_PAIR_B, ASRC_PAIR_C)
|
||||
* @channels: occupied channel number
|
||||
* @desc: input and output dma descriptors
|
||||
* @dma_chan: inputer and output DMA channels
|
||||
* @dma_data: private dma data
|
||||
* @pos: hardware pointer position
|
||||
* @private: pair private area
|
||||
*/
|
||||
struct fsl_asrc_pair {
|
||||
struct fsl_asrc *asrc_priv;
|
||||
struct fsl_asrc_pair_priv {
|
||||
struct asrc_config *config;
|
||||
unsigned int error;
|
||||
|
||||
enum asrc_pair_index index;
|
||||
unsigned int channels;
|
||||
|
||||
struct dma_async_tx_descriptor *desc[2];
|
||||
struct dma_chan *dma_chan[2];
|
||||
struct imx_dma_data dma_data;
|
||||
unsigned int pos;
|
||||
|
||||
void *private;
|
||||
};
|
||||
|
||||
/**
|
||||
* fsl_asrc_pair: ASRC private data
|
||||
* fsl_asrc_priv: ASRC private data
|
||||
*
|
||||
* @dma_params_rx: DMA parameters for receive channel
|
||||
* @dma_params_tx: DMA parameters for transmit channel
|
||||
* @pdev: platform device pointer
|
||||
* @regmap: regmap handler
|
||||
* @paddr: physical address to the base address of registers
|
||||
* @mem_clk: clock source to access register
|
||||
* @ipg_clk: clock source to drive peripheral
|
||||
* @spba_clk: SPBA clock (optional, depending on SoC design)
|
||||
* @asrck_clk: clock sources to driver ASRC internal logic
|
||||
* @lock: spin lock for resource protection
|
||||
* @pair: pair pointers
|
||||
* @soc: soc specific data
|
||||
* @channel_avail: non-occupied channel numbers
|
||||
* @clk_map: clock map for input/output clock
|
||||
* @asrc_rate: default sample rate for ASoC Back-Ends
|
||||
* @asrc_width: default sample width for ASoC Back-Ends
|
||||
* @regcache_cfg: store register value of REG_ASRCFG
|
||||
*/
|
||||
struct fsl_asrc {
|
||||
struct snd_dmaengine_dai_dma_data dma_params_rx;
|
||||
struct snd_dmaengine_dai_dma_data dma_params_tx;
|
||||
struct platform_device *pdev;
|
||||
struct regmap *regmap;
|
||||
unsigned long paddr;
|
||||
struct clk *mem_clk;
|
||||
struct clk *ipg_clk;
|
||||
struct clk *spba_clk;
|
||||
struct fsl_asrc_priv {
|
||||
struct clk *asrck_clk[ASRC_CLK_MAX_NUM];
|
||||
spinlock_t lock;
|
||||
|
||||
struct fsl_asrc_pair *pair[ASRC_PAIR_MAX_NUM];
|
||||
const struct fsl_asrc_soc_data *soc;
|
||||
unsigned int channel_avail;
|
||||
unsigned char *clk_map[2];
|
||||
|
||||
int asrc_rate;
|
||||
int asrc_width;
|
||||
|
||||
u32 regcache_cfg;
|
||||
};
|
||||
|
||||
#define DRV_NAME "fsl-asrc-dai"
|
||||
extern struct snd_soc_component_driver fsl_asrc_component;
|
||||
struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir);
|
||||
int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair);
|
||||
void fsl_asrc_release_pair(struct fsl_asrc_pair *pair);
|
||||
|
||||
#endif /* _FSL_ASRC_H */
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright 2019 NXP
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FSL_ASRC_COMMON_H
|
||||
#define _FSL_ASRC_COMMON_H
|
||||
|
||||
/* directions */
|
||||
#define IN 0
|
||||
#define OUT 1
|
||||
|
||||
enum asrc_pair_index {
|
||||
ASRC_INVALID_PAIR = -1,
|
||||
ASRC_PAIR_A = 0,
|
||||
ASRC_PAIR_B = 1,
|
||||
ASRC_PAIR_C = 2,
|
||||
ASRC_PAIR_D = 3,
|
||||
};
|
||||
|
||||
#define PAIR_CTX_NUM 0x4
|
||||
|
||||
/**
|
||||
* fsl_asrc_pair: ASRC Pair common data
|
||||
*
|
||||
* @asrc: pointer to its parent module
|
||||
* @error: error record
|
||||
* @index: pair index (ASRC_PAIR_A, ASRC_PAIR_B, ASRC_PAIR_C)
|
||||
* @channels: occupied channel number
|
||||
* @desc: input and output dma descriptors
|
||||
* @dma_chan: inputer and output DMA channels
|
||||
* @dma_data: private dma data
|
||||
* @pos: hardware pointer position
|
||||
* @private: pair private area
|
||||
*/
|
||||
struct fsl_asrc_pair {
|
||||
struct fsl_asrc *asrc;
|
||||
unsigned int error;
|
||||
|
||||
enum asrc_pair_index index;
|
||||
unsigned int channels;
|
||||
|
||||
struct dma_async_tx_descriptor *desc[2];
|
||||
struct dma_chan *dma_chan[2];
|
||||
struct imx_dma_data dma_data;
|
||||
unsigned int pos;
|
||||
|
||||
void *private;
|
||||
};
|
||||
|
||||
/**
|
||||
* fsl_asrc: ASRC common data
|
||||
*
|
||||
* @dma_params_rx: DMA parameters for receive channel
|
||||
* @dma_params_tx: DMA parameters for transmit channel
|
||||
* @pdev: platform device pointer
|
||||
* @regmap: regmap handler
|
||||
* @paddr: physical address to the base address of registers
|
||||
* @mem_clk: clock source to access register
|
||||
* @ipg_clk: clock source to drive peripheral
|
||||
* @spba_clk: SPBA clock (optional, depending on SoC design)
|
||||
* @lock: spin lock for resource protection
|
||||
* @pair: pair pointers
|
||||
* @channel_avail: non-occupied channel numbers
|
||||
* @asrc_rate: default sample rate for ASoC Back-Ends
|
||||
* @asrc_format: default sample format for ASoC Back-Ends
|
||||
* @use_edma: edma is used
|
||||
* @get_dma_channel: function pointer
|
||||
* @request_pair: function pointer
|
||||
* @release_pair: function pointer
|
||||
* @get_fifo_addr: function pointer
|
||||
* @pair_priv_size: size of pair private struct.
|
||||
* @private: private data structure
|
||||
*/
|
||||
struct fsl_asrc {
|
||||
struct snd_dmaengine_dai_dma_data dma_params_rx;
|
||||
struct snd_dmaengine_dai_dma_data dma_params_tx;
|
||||
struct platform_device *pdev;
|
||||
struct regmap *regmap;
|
||||
unsigned long paddr;
|
||||
struct clk *mem_clk;
|
||||
struct clk *ipg_clk;
|
||||
struct clk *spba_clk;
|
||||
spinlock_t lock; /* spin lock for resource protection */
|
||||
|
||||
struct fsl_asrc_pair *pair[PAIR_CTX_NUM];
|
||||
unsigned int channel_avail;
|
||||
|
||||
int asrc_rate;
|
||||
snd_pcm_format_t asrc_format;
|
||||
bool use_edma;
|
||||
|
||||
struct dma_chan *(*get_dma_channel)(struct fsl_asrc_pair *pair, bool dir);
|
||||
int (*request_pair)(int channels, struct fsl_asrc_pair *pair);
|
||||
void (*release_pair)(struct fsl_asrc_pair *pair);
|
||||
int (*get_fifo_addr)(u8 dir, enum asrc_pair_index index);
|
||||
size_t pair_priv_size;
|
||||
|
||||
void *private;
|
||||
};
|
||||
|
||||
#define DRV_NAME "fsl-asrc-dai"
|
||||
extern struct snd_soc_component_driver fsl_asrc_component;
|
||||
|
||||
#endif /* _FSL_ASRC_COMMON_H */
|
|
@ -12,7 +12,7 @@
|
|||
#include <sound/dmaengine_pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
|
||||
#include "fsl_asrc.h"
|
||||
#include "fsl_asrc_common.h"
|
||||
|
||||
#define FSL_ASRC_DMABUF_SIZE (256 * 1024)
|
||||
|
||||
|
@ -135,7 +135,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
struct snd_dmaengine_dai_dma_data *dma_params_be = NULL;
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct fsl_asrc_pair *pair = runtime->private_data;
|
||||
struct fsl_asrc *asrc_priv = pair->asrc_priv;
|
||||
struct fsl_asrc *asrc = pair->asrc;
|
||||
struct dma_slave_config config_fe, config_be;
|
||||
enum asrc_pair_index index = pair->index;
|
||||
struct device *dev = component->dev;
|
||||
|
@ -146,7 +146,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
struct device *dev_be;
|
||||
u8 dir = tx ? OUT : IN;
|
||||
dma_cap_mask_t mask;
|
||||
int ret;
|
||||
int ret, width;
|
||||
|
||||
/* Fetch the Back-End dma_data from DPCM */
|
||||
for_each_dpcm_be(rtd, stream, dpcm) {
|
||||
|
@ -170,10 +170,10 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
|
||||
/* Override dma_data of the Front-End and config its dmaengine */
|
||||
dma_params_fe = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream);
|
||||
dma_params_fe->addr = asrc_priv->paddr + REG_ASRDx(!dir, index);
|
||||
dma_params_fe->addr = asrc->paddr + asrc->get_fifo_addr(!dir, index);
|
||||
dma_params_fe->maxburst = dma_params_be->maxburst;
|
||||
|
||||
pair->dma_chan[!dir] = fsl_asrc_get_dma_channel(pair, !dir);
|
||||
pair->dma_chan[!dir] = asrc->get_dma_channel(pair, !dir);
|
||||
if (!pair->dma_chan[!dir]) {
|
||||
dev_err(dev, "failed to request DMA channel\n");
|
||||
return -EINVAL;
|
||||
|
@ -203,7 +203,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
* need to configure dma_request and dma_request2, but get dma_chan via
|
||||
* dma_request_slave_channel directly with dma name of Front-End device
|
||||
*/
|
||||
if (!asrc_priv->soc->use_edma) {
|
||||
if (!asrc->use_edma) {
|
||||
/* Get DMA request of Back-End */
|
||||
tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx");
|
||||
tmp_data = tmp_chan->private;
|
||||
|
@ -211,7 +211,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
dma_release_channel(tmp_chan);
|
||||
|
||||
/* Get DMA request of Front-End */
|
||||
tmp_chan = fsl_asrc_get_dma_channel(pair, dir);
|
||||
tmp_chan = asrc->get_dma_channel(pair, dir);
|
||||
tmp_data = tmp_chan->private;
|
||||
pair->dma_data.dma_request2 = tmp_data->dma_request;
|
||||
pair->dma_data.peripheral_type = tmp_data->peripheral_type;
|
||||
|
@ -222,7 +222,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
dma_request_channel(mask, filter, &pair->dma_data);
|
||||
} else {
|
||||
pair->dma_chan[dir] =
|
||||
fsl_asrc_get_dma_channel(pair, dir);
|
||||
asrc->get_dma_channel(pair, dir);
|
||||
}
|
||||
|
||||
if (!pair->dma_chan[dir]) {
|
||||
|
@ -230,10 +230,19 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (asrc_priv->asrc_width == 16)
|
||||
width = snd_pcm_format_physical_width(asrc->asrc_format);
|
||||
if (width < 8 || width > 64)
|
||||
return -EINVAL;
|
||||
else if (width == 8)
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
|
||||
else if (width == 16)
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
|
||||
else
|
||||
else if (width == 24)
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_3_BYTES;
|
||||
else if (width <= 32)
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
||||
else
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES;
|
||||
|
||||
config_be.direction = DMA_DEV_TO_DEV;
|
||||
config_be.src_addr_width = buswidth;
|
||||
|
@ -242,10 +251,10 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
|
|||
config_be.dst_maxburst = dma_params_be->maxburst;
|
||||
|
||||
if (tx) {
|
||||
config_be.src_addr = asrc_priv->paddr + REG_ASRDO(index);
|
||||
config_be.src_addr = asrc->paddr + asrc->get_fifo_addr(OUT, index);
|
||||
config_be.dst_addr = dma_params_be->addr;
|
||||
} else {
|
||||
config_be.dst_addr = asrc_priv->paddr + REG_ASRDI(index);
|
||||
config_be.dst_addr = asrc->paddr + asrc->get_fifo_addr(IN, index);
|
||||
config_be.src_addr = dma_params_be->addr;
|
||||
}
|
||||
|
||||
|
@ -288,7 +297,7 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,
|
|||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct snd_dmaengine_dai_dma_data *dma_data;
|
||||
struct device *dev = component->dev;
|
||||
struct fsl_asrc *asrc_priv = dev_get_drvdata(dev);
|
||||
struct fsl_asrc *asrc = dev_get_drvdata(dev);
|
||||
struct fsl_asrc_pair *pair;
|
||||
struct dma_chan *tmp_chan = NULL;
|
||||
u8 dir = tx ? OUT : IN;
|
||||
|
@ -302,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,
|
|||
return ret;
|
||||
}
|
||||
|
||||
pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL);
|
||||
pair = kzalloc(sizeof(*pair) + asrc->pair_priv_size, GFP_KERNEL);
|
||||
if (!pair)
|
||||
return -ENOMEM;
|
||||
|
||||
pair->asrc_priv = asrc_priv;
|
||||
pair->asrc = asrc;
|
||||
pair->private = (void *)pair + sizeof(struct fsl_asrc_pair);
|
||||
|
||||
runtime->private_data = pair;
|
||||
|
||||
|
@ -314,14 +324,14 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,
|
|||
* Request pair function needs channel num as input, for this
|
||||
* dummy pair, we just request "1" channel temporarily.
|
||||
*/
|
||||
ret = fsl_asrc_request_pair(1, pair);
|
||||
ret = asrc->request_pair(1, pair);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to request asrc pair\n");
|
||||
goto req_pair_err;
|
||||
}
|
||||
|
||||
/* Request a dummy dma channel, which will be released later. */
|
||||
tmp_chan = fsl_asrc_get_dma_channel(pair, dir);
|
||||
tmp_chan = asrc->get_dma_channel(pair, dir);
|
||||
if (!tmp_chan) {
|
||||
dev_err(dev, "failed to get dma channel\n");
|
||||
ret = -EINVAL;
|
||||
|
@ -347,7 +357,7 @@ out:
|
|||
dma_release_channel(tmp_chan);
|
||||
|
||||
dma_chan_err:
|
||||
fsl_asrc_release_pair(pair);
|
||||
asrc->release_pair(pair);
|
||||
|
||||
req_pair_err:
|
||||
if (release_pair)
|
||||
|
@ -361,15 +371,15 @@ static int fsl_asrc_dma_shutdown(struct snd_soc_component *component,
|
|||
{
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct fsl_asrc_pair *pair = runtime->private_data;
|
||||
struct fsl_asrc *asrc_priv;
|
||||
struct fsl_asrc *asrc;
|
||||
|
||||
if (!pair)
|
||||
return 0;
|
||||
|
||||
asrc_priv = pair->asrc_priv;
|
||||
asrc = pair->asrc;
|
||||
|
||||
if (asrc_priv->pair[pair->index] == pair)
|
||||
asrc_priv->pair[pair->index] = NULL;
|
||||
if (asrc->pair[pair->index] == pair)
|
||||
asrc->pair[pair->index] = NULL;
|
||||
|
||||
kfree(pair);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,651 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2019 NXP
|
||||
*/
|
||||
|
||||
#ifndef _FSL_EASRC_H
|
||||
#define _FSL_EASRC_H
|
||||
|
||||
#include <sound/asound.h>
|
||||
#include <linux/platform_data/dma-imx.h>
|
||||
|
||||
#include "fsl_asrc_common.h"
|
||||
|
||||
/* EASRC Register Map */
|
||||
|
||||
/* ASRC Input Write FIFO */
|
||||
#define REG_EASRC_WRFIFO(ctx) (0x000 + 4 * (ctx))
|
||||
/* ASRC Output Read FIFO */
|
||||
#define REG_EASRC_RDFIFO(ctx) (0x010 + 4 * (ctx))
|
||||
/* ASRC Context Control */
|
||||
#define REG_EASRC_CC(ctx) (0x020 + 4 * (ctx))
|
||||
/* ASRC Context Control Extended 1 */
|
||||
#define REG_EASRC_CCE1(ctx) (0x030 + 4 * (ctx))
|
||||
/* ASRC Context Control Extended 2 */
|
||||
#define REG_EASRC_CCE2(ctx) (0x040 + 4 * (ctx))
|
||||
/* ASRC Control Input Access */
|
||||
#define REG_EASRC_CIA(ctx) (0x050 + 4 * (ctx))
|
||||
/* ASRC Datapath Processor Control Slot0 */
|
||||
#define REG_EASRC_DPCS0R0(ctx) (0x060 + 4 * (ctx))
|
||||
#define REG_EASRC_DPCS0R1(ctx) (0x070 + 4 * (ctx))
|
||||
#define REG_EASRC_DPCS0R2(ctx) (0x080 + 4 * (ctx))
|
||||
#define REG_EASRC_DPCS0R3(ctx) (0x090 + 4 * (ctx))
|
||||
/* ASRC Datapath Processor Control Slot1 */
|
||||
#define REG_EASRC_DPCS1R0(ctx) (0x0A0 + 4 * (ctx))
|
||||
#define REG_EASRC_DPCS1R1(ctx) (0x0B0 + 4 * (ctx))
|
||||
#define REG_EASRC_DPCS1R2(ctx) (0x0C0 + 4 * (ctx))
|
||||
#define REG_EASRC_DPCS1R3(ctx) (0x0D0 + 4 * (ctx))
|
||||
/* ASRC Context Output Control */
|
||||
#define REG_EASRC_COC(ctx) (0x0E0 + 4 * (ctx))
|
||||
/* ASRC Control Output Access */
|
||||
#define REG_EASRC_COA(ctx) (0x0F0 + 4 * (ctx))
|
||||
/* ASRC Sample FIFO Status */
|
||||
#define REG_EASRC_SFS(ctx) (0x100 + 4 * (ctx))
|
||||
/* ASRC Resampling Ratio Low */
|
||||
#define REG_EASRC_RRL(ctx) (0x110 + 8 * (ctx))
|
||||
/* ASRC Resampling Ratio High */
|
||||
#define REG_EASRC_RRH(ctx) (0x114 + 8 * (ctx))
|
||||
/* ASRC Resampling Ratio Update Control */
|
||||
#define REG_EASRC_RUC(ctx) (0x130 + 4 * (ctx))
|
||||
/* ASRC Resampling Ratio Update Rate */
|
||||
#define REG_EASRC_RUR(ctx) (0x140 + 4 * (ctx))
|
||||
/* ASRC Resampling Center Tap Coefficient Low */
|
||||
#define REG_EASRC_RCTCL (0x150)
|
||||
/* ASRC Resampling Center Tap Coefficient High */
|
||||
#define REG_EASRC_RCTCH (0x154)
|
||||
/* ASRC Prefilter Coefficient FIFO */
|
||||
#define REG_EASRC_PCF(ctx) (0x160 + 4 * (ctx))
|
||||
/* ASRC Context Resampling Coefficient Memory */
|
||||
#define REG_EASRC_CRCM 0x170
|
||||
/* ASRC Context Resampling Coefficient Control*/
|
||||
#define REG_EASRC_CRCC 0x174
|
||||
/* ASRC Interrupt Control */
|
||||
#define REG_EASRC_IRQC 0x178
|
||||
/* ASRC Interrupt Status Flags */
|
||||
#define REG_EASRC_IRQF 0x17C
|
||||
/* ASRC Channel Status 0 */
|
||||
#define REG_EASRC_CS0(ctx) (0x180 + 4 * (ctx))
|
||||
/* ASRC Channel Status 1 */
|
||||
#define REG_EASRC_CS1(ctx) (0x190 + 4 * (ctx))
|
||||
/* ASRC Channel Status 2 */
|
||||
#define REG_EASRC_CS2(ctx) (0x1A0 + 4 * (ctx))
|
||||
/* ASRC Channel Status 3 */
|
||||
#define REG_EASRC_CS3(ctx) (0x1B0 + 4 * (ctx))
|
||||
/* ASRC Channel Status 4 */
|
||||
#define REG_EASRC_CS4(ctx) (0x1C0 + 4 * (ctx))
|
||||
/* ASRC Channel Status 5 */
|
||||
#define REG_EASRC_CS5(ctx) (0x1D0 + 4 * (ctx))
|
||||
/* ASRC Debug Control Register */
|
||||
#define REG_EASRC_DBGC 0x1E0
|
||||
/* ASRC Debug Status Register */
|
||||
#define REG_EASRC_DBGS 0x1E4
|
||||
|
||||
#define REG_EASRC_FIFO(x, ctx) (x == IN ? REG_EASRC_WRFIFO(ctx) \
|
||||
: REG_EASRC_RDFIFO(ctx))
|
||||
|
||||
/* ASRC Context Control (CC) */
|
||||
#define EASRC_CC_EN_SHIFT 31
|
||||
#define EASRC_CC_EN_MASK BIT(EASRC_CC_EN_SHIFT)
|
||||
#define EASRC_CC_EN BIT(EASRC_CC_EN_SHIFT)
|
||||
#define EASRC_CC_STOP_SHIFT 29
|
||||
#define EASRC_CC_STOP_MASK BIT(EASRC_CC_STOP_SHIFT)
|
||||
#define EASRC_CC_STOP BIT(EASRC_CC_STOP_SHIFT)
|
||||
#define EASRC_CC_FWMDE_SHIFT 28
|
||||
#define EASRC_CC_FWMDE_MASK BIT(EASRC_CC_FWMDE_SHIFT)
|
||||
#define EASRC_CC_FWMDE BIT(EASRC_CC_FWMDE_SHIFT)
|
||||
#define EASRC_CC_FIFO_WTMK_SHIFT 16
|
||||
#define EASRC_CC_FIFO_WTMK_WIDTH 7
|
||||
#define EASRC_CC_FIFO_WTMK_MASK ((BIT(EASRC_CC_FIFO_WTMK_WIDTH) - 1) \
|
||||
<< EASRC_CC_FIFO_WTMK_SHIFT)
|
||||
#define EASRC_CC_FIFO_WTMK(v) (((v) << EASRC_CC_FIFO_WTMK_SHIFT) \
|
||||
& EASRC_CC_FIFO_WTMK_MASK)
|
||||
#define EASRC_CC_SAMPLE_POS_SHIFT 11
|
||||
#define EASRC_CC_SAMPLE_POS_WIDTH 5
|
||||
#define EASRC_CC_SAMPLE_POS_MASK ((BIT(EASRC_CC_SAMPLE_POS_WIDTH) - 1) \
|
||||
<< EASRC_CC_SAMPLE_POS_SHIFT)
|
||||
#define EASRC_CC_SAMPLE_POS(v) (((v) << EASRC_CC_SAMPLE_POS_SHIFT) \
|
||||
& EASRC_CC_SAMPLE_POS_MASK)
|
||||
#define EASRC_CC_ENDIANNESS_SHIFT 10
|
||||
#define EASRC_CC_ENDIANNESS_MASK BIT(EASRC_CC_ENDIANNESS_SHIFT)
|
||||
#define EASRC_CC_ENDIANNESS BIT(EASRC_CC_ENDIANNESS_SHIFT)
|
||||
#define EASRC_CC_BPS_SHIFT 8
|
||||
#define EASRC_CC_BPS_WIDTH 2
|
||||
#define EASRC_CC_BPS_MASK ((BIT(EASRC_CC_BPS_WIDTH) - 1) \
|
||||
<< EASRC_CC_BPS_SHIFT)
|
||||
#define EASRC_CC_BPS(v) (((v) << EASRC_CC_BPS_SHIFT) \
|
||||
& EASRC_CC_BPS_MASK)
|
||||
#define EASRC_CC_FMT_SHIFT 7
|
||||
#define EASRC_CC_FMT_MASK BIT(EASRC_CC_FMT_SHIFT)
|
||||
#define EASRC_CC_FMT BIT(EASRC_CC_FMT_SHIFT)
|
||||
#define EASRC_CC_INSIGN_SHIFT 6
|
||||
#define EASRC_CC_INSIGN_MASK BIT(EASRC_CC_INSIGN_SHIFT)
|
||||
#define EASRC_CC_INSIGN BIT(EASRC_CC_INSIGN_SHIFT)
|
||||
#define EASRC_CC_CHEN_SHIFT 0
|
||||
#define EASRC_CC_CHEN_WIDTH 5
|
||||
#define EASRC_CC_CHEN_MASK ((BIT(EASRC_CC_CHEN_WIDTH) - 1) \
|
||||
<< EASRC_CC_CHEN_SHIFT)
|
||||
#define EASRC_CC_CHEN(v) (((v) << EASRC_CC_CHEN_SHIFT) \
|
||||
& EASRC_CC_CHEN_MASK)
|
||||
|
||||
/* ASRC Context Control Extended 1 (CCE1) */
|
||||
#define EASRC_CCE1_COEF_WS_SHIFT 25
|
||||
#define EASRC_CCE1_COEF_WS_MASK BIT(EASRC_CCE1_COEF_WS_SHIFT)
|
||||
#define EASRC_CCE1_COEF_WS BIT(EASRC_CCE1_COEF_WS_SHIFT)
|
||||
#define EASRC_CCE1_COEF_MEM_RST_SHIFT 24
|
||||
#define EASRC_CCE1_COEF_MEM_RST_MASK BIT(EASRC_CCE1_COEF_MEM_RST_SHIFT)
|
||||
#define EASRC_CCE1_COEF_MEM_RST BIT(EASRC_CCE1_COEF_MEM_RST_SHIFT)
|
||||
#define EASRC_CCE1_PF_EXP_SHIFT 16
|
||||
#define EASRC_CCE1_PF_EXP_WIDTH 8
|
||||
#define EASRC_CCE1_PF_EXP_MASK ((BIT(EASRC_CCE1_PF_EXP_WIDTH) - 1) \
|
||||
<< EASRC_CCE1_PF_EXP_SHIFT)
|
||||
#define EASRC_CCE1_PF_EXP(v) (((v) << EASRC_CCE1_PF_EXP_SHIFT) \
|
||||
& EASRC_CCE1_PF_EXP_MASK)
|
||||
#define EASRC_CCE1_PF_ST1_WBFP_SHIFT 9
|
||||
#define EASRC_CCE1_PF_ST1_WBFP_MASK BIT(EASRC_CCE1_PF_ST1_WBFP_SHIFT)
|
||||
#define EASRC_CCE1_PF_ST1_WBFP BIT(EASRC_CCE1_PF_ST1_WBFP_SHIFT)
|
||||
#define EASRC_CCE1_PF_TSEN_SHIFT 8
|
||||
#define EASRC_CCE1_PF_TSEN_MASK BIT(EASRC_CCE1_PF_TSEN_SHIFT)
|
||||
#define EASRC_CCE1_PF_TSEN BIT(EASRC_CCE1_PF_TSEN_SHIFT)
|
||||
#define EASRC_CCE1_RS_BYPASS_SHIFT 7
|
||||
#define EASRC_CCE1_RS_BYPASS_MASK BIT(EASRC_CCE1_RS_BYPASS_SHIFT)
|
||||
#define EASRC_CCE1_RS_BYPASS BIT(EASRC_CCE1_RS_BYPASS_SHIFT)
|
||||
#define EASRC_CCE1_PF_BYPASS_SHIFT 6
|
||||
#define EASRC_CCE1_PF_BYPASS_MASK BIT(EASRC_CCE1_PF_BYPASS_SHIFT)
|
||||
#define EASRC_CCE1_PF_BYPASS BIT(EASRC_CCE1_PF_BYPASS_SHIFT)
|
||||
#define EASRC_CCE1_RS_STOP_SHIFT 5
|
||||
#define EASRC_CCE1_RS_STOP_MASK BIT(EASRC_CCE1_RS_STOP_SHIFT)
|
||||
#define EASRC_CCE1_RS_STOP BIT(EASRC_CCE1_RS_STOP_SHIFT)
|
||||
#define EASRC_CCE1_PF_STOP_SHIFT 4
|
||||
#define EASRC_CCE1_PF_STOP_MASK BIT(EASRC_CCE1_PF_STOP_SHIFT)
|
||||
#define EASRC_CCE1_PF_STOP BIT(EASRC_CCE1_PF_STOP_SHIFT)
|
||||
#define EASRC_CCE1_RS_INIT_SHIFT 2
|
||||
#define EASRC_CCE1_RS_INIT_WIDTH 2
|
||||
#define EASRC_CCE1_RS_INIT_MASK ((BIT(EASRC_CCE1_RS_INIT_WIDTH) - 1) \
|
||||
<< EASRC_CCE1_RS_INIT_SHIFT)
|
||||
#define EASRC_CCE1_RS_INIT(v) (((v) << EASRC_CCE1_RS_INIT_SHIFT) \
|
||||
& EASRC_CCE1_RS_INIT_MASK)
|
||||
#define EASRC_CCE1_PF_INIT_SHIFT 0
|
||||
#define EASRC_CCE1_PF_INIT_WIDTH 2
|
||||
#define EASRC_CCE1_PF_INIT_MASK ((BIT(EASRC_CCE1_PF_INIT_WIDTH) - 1) \
|
||||
<< EASRC_CCE1_PF_INIT_SHIFT)
|
||||
#define EASRC_CCE1_PF_INIT(v) (((v) << EASRC_CCE1_PF_INIT_SHIFT) \
|
||||
& EASRC_CCE1_PF_INIT_MASK)
|
||||
|
||||
/* ASRC Context Control Extended 2 (CCE2) */
|
||||
#define EASRC_CCE2_ST2_TAPS_SHIFT 16
|
||||
#define EASRC_CCE2_ST2_TAPS_WIDTH 9
|
||||
#define EASRC_CCE2_ST2_TAPS_MASK ((BIT(EASRC_CCE2_ST2_TAPS_WIDTH) - 1) \
|
||||
<< EASRC_CCE2_ST2_TAPS_SHIFT)
|
||||
#define EASRC_CCE2_ST2_TAPS(v) (((v) << EASRC_CCE2_ST2_TAPS_SHIFT) \
|
||||
& EASRC_CCE2_ST2_TAPS_MASK)
|
||||
#define EASRC_CCE2_ST1_TAPS_SHIFT 0
|
||||
#define EASRC_CCE2_ST1_TAPS_WIDTH 9
|
||||
#define EASRC_CCE2_ST1_TAPS_MASK ((BIT(EASRC_CCE2_ST1_TAPS_WIDTH) - 1) \
|
||||
<< EASRC_CCE2_ST1_TAPS_SHIFT)
|
||||
#define EASRC_CCE2_ST1_TAPS(v) (((v) << EASRC_CCE2_ST1_TAPS_SHIFT) \
|
||||
& EASRC_CCE2_ST1_TAPS_MASK)
|
||||
|
||||
/* ASRC Control Input Access (CIA) */
|
||||
#define EASRC_CIA_ITER_SHIFT 16
|
||||
#define EASRC_CIA_ITER_WIDTH 6
|
||||
#define EASRC_CIA_ITER_MASK ((BIT(EASRC_CIA_ITER_WIDTH) - 1) \
|
||||
<< EASRC_CIA_ITER_SHIFT)
|
||||
#define EASRC_CIA_ITER(v) (((v) << EASRC_CIA_ITER_SHIFT) \
|
||||
& EASRC_CIA_ITER_MASK)
|
||||
#define EASRC_CIA_GRLEN_SHIFT 8
|
||||
#define EASRC_CIA_GRLEN_WIDTH 6
|
||||
#define EASRC_CIA_GRLEN_MASK ((BIT(EASRC_CIA_GRLEN_WIDTH) - 1) \
|
||||
<< EASRC_CIA_GRLEN_SHIFT)
|
||||
#define EASRC_CIA_GRLEN(v) (((v) << EASRC_CIA_GRLEN_SHIFT) \
|
||||
& EASRC_CIA_GRLEN_MASK)
|
||||
#define EASRC_CIA_ACCLEN_SHIFT 0
|
||||
#define EASRC_CIA_ACCLEN_WIDTH 6
|
||||
#define EASRC_CIA_ACCLEN_MASK ((BIT(EASRC_CIA_ACCLEN_WIDTH) - 1) \
|
||||
<< EASRC_CIA_ACCLEN_SHIFT)
|
||||
#define EASRC_CIA_ACCLEN(v) (((v) << EASRC_CIA_ACCLEN_SHIFT) \
|
||||
& EASRC_CIA_ACCLEN_MASK)
|
||||
|
||||
/* ASRC Datapath Processor Control Slot0 Register0 (DPCS0R0) */
|
||||
#define EASRC_DPCS0R0_MAXCH_SHIFT 24
|
||||
#define EASRC_DPCS0R0_MAXCH_WIDTH 5
|
||||
#define EASRC_DPCS0R0_MAXCH_MASK ((BIT(EASRC_DPCS0R0_MAXCH_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R0_MAXCH_SHIFT)
|
||||
#define EASRC_DPCS0R0_MAXCH(v) (((v) << EASRC_DPCS0R0_MAXCH_SHIFT) \
|
||||
& EASRC_DPCS0R0_MAXCH_MASK)
|
||||
#define EASRC_DPCS0R0_MINCH_SHIFT 16
|
||||
#define EASRC_DPCS0R0_MINCH_WIDTH 5
|
||||
#define EASRC_DPCS0R0_MINCH_MASK ((BIT(EASRC_DPCS0R0_MINCH_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R0_MINCH_SHIFT)
|
||||
#define EASRC_DPCS0R0_MINCH(v) (((v) << EASRC_DPCS0R0_MINCH_SHIFT) \
|
||||
& EASRC_DPCS0R0_MINCH_MASK)
|
||||
#define EASRC_DPCS0R0_NUMCH_SHIFT 8
|
||||
#define EASRC_DPCS0R0_NUMCH_WIDTH 5
|
||||
#define EASRC_DPCS0R0_NUMCH_MASK ((BIT(EASRC_DPCS0R0_NUMCH_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R0_NUMCH_SHIFT)
|
||||
#define EASRC_DPCS0R0_NUMCH(v) (((v) << EASRC_DPCS0R0_NUMCH_SHIFT) \
|
||||
& EASRC_DPCS0R0_NUMCH_MASK)
|
||||
#define EASRC_DPCS0R0_CTXNUM_SHIFT 1
|
||||
#define EASRC_DPCS0R0_CTXNUM_WIDTH 2
|
||||
#define EASRC_DPCS0R0_CTXNUM_MASK ((BIT(EASRC_DPCS0R0_CTXNUM_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R0_CTXNUM_SHIFT)
|
||||
#define EASRC_DPCS0R0_CTXNUM(v) (((v) << EASRC_DPCS0R0_CTXNUM_SHIFT) \
|
||||
& EASRC_DPCS0R0_CTXNUM_MASK)
|
||||
#define EASRC_DPCS0R0_EN_SHIFT 0
|
||||
#define EASRC_DPCS0R0_EN_MASK BIT(EASRC_DPCS0R0_EN_SHIFT)
|
||||
#define EASRC_DPCS0R0_EN BIT(EASRC_DPCS0R0_EN_SHIFT)
|
||||
|
||||
/* ASRC Datapath Processor Control Slot0 Register1 (DPCS0R1) */
|
||||
#define EASRC_DPCS0R1_ST1_EXP_SHIFT 0
|
||||
#define EASRC_DPCS0R1_ST1_EXP_WIDTH 13
|
||||
#define EASRC_DPCS0R1_ST1_EXP_MASK ((BIT(EASRC_DPCS0R1_ST1_EXP_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R1_ST1_EXP_SHIFT)
|
||||
#define EASRC_DPCS0R1_ST1_EXP(v) (((v) << EASRC_DPCS0R1_ST1_EXP_SHIFT) \
|
||||
& EASRC_DPCS0R1_ST1_EXP_MASK)
|
||||
|
||||
/* ASRC Datapath Processor Control Slot0 Register2 (DPCS0R2) */
|
||||
#define EASRC_DPCS0R2_ST1_MA_SHIFT 16
|
||||
#define EASRC_DPCS0R2_ST1_MA_WIDTH 13
|
||||
#define EASRC_DPCS0R2_ST1_MA_MASK ((BIT(EASRC_DPCS0R2_ST1_MA_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R2_ST1_MA_SHIFT)
|
||||
#define EASRC_DPCS0R2_ST1_MA(v) (((v) << EASRC_DPCS0R2_ST1_MA_SHIFT) \
|
||||
& EASRC_DPCS0R2_ST1_MA_MASK)
|
||||
#define EASRC_DPCS0R2_ST1_SA_SHIFT 0
|
||||
#define EASRC_DPCS0R2_ST1_SA_WIDTH 13
|
||||
#define EASRC_DPCS0R2_ST1_SA_MASK ((BIT(EASRC_DPCS0R2_ST1_SA_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R2_ST1_SA_SHIFT)
|
||||
#define EASRC_DPCS0R2_ST1_SA(v) (((v) << EASRC_DPCS0R2_ST1_SA_SHIFT) \
|
||||
& EASRC_DPCS0R2_ST1_SA_MASK)
|
||||
|
||||
/* ASRC Datapath Processor Control Slot0 Register3 (DPCS0R3) */
|
||||
#define EASRC_DPCS0R3_ST2_MA_SHIFT 16
|
||||
#define EASRC_DPCS0R3_ST2_MA_WIDTH 13
|
||||
#define EASRC_DPCS0R3_ST2_MA_MASK ((BIT(EASRC_DPCS0R3_ST2_MA_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R3_ST2_MA_SHIFT)
|
||||
#define EASRC_DPCS0R3_ST2_MA(v) (((v) << EASRC_DPCS0R3_ST2_MA_SHIFT) \
|
||||
& EASRC_DPCS0R3_ST2_MA_MASK)
|
||||
#define EASRC_DPCS0R3_ST2_SA_SHIFT 0
|
||||
#define EASRC_DPCS0R3_ST2_SA_WIDTH 13
|
||||
#define EASRC_DPCS0R3_ST2_SA_MASK ((BIT(EASRC_DPCS0R3_ST2_SA_WIDTH) - 1) \
|
||||
<< EASRC_DPCS0R3_ST2_SA_SHIFT)
|
||||
#define EASRC_DPCS0R3_ST2_SA(v) (((v) << EASRC_DPCS0R3_ST2_SA_SHIFT) \
|
||||
& EASRC_DPCS0R3_ST2_SA_MASK)
|
||||
|
||||
/* ASRC Context Output Control (COC) */
|
||||
#define EASRC_COC_FWMDE_SHIFT 28
|
||||
#define EASRC_COC_FWMDE_MASK BIT(EASRC_COC_FWMDE_SHIFT)
|
||||
#define EASRC_COC_FWMDE BIT(EASRC_COC_FWMDE_SHIFT)
|
||||
#define EASRC_COC_FIFO_WTMK_SHIFT 16
|
||||
#define EASRC_COC_FIFO_WTMK_WIDTH 7
|
||||
#define EASRC_COC_FIFO_WTMK_MASK ((BIT(EASRC_COC_FIFO_WTMK_WIDTH) - 1) \
|
||||
<< EASRC_COC_FIFO_WTMK_SHIFT)
|
||||
#define EASRC_COC_FIFO_WTMK(v) (((v) << EASRC_COC_FIFO_WTMK_SHIFT) \
|
||||
& EASRC_COC_FIFO_WTMK_MASK)
|
||||
#define EASRC_COC_SAMPLE_POS_SHIFT 11
|
||||
#define EASRC_COC_SAMPLE_POS_WIDTH 5
|
||||
#define EASRC_COC_SAMPLE_POS_MASK ((BIT(EASRC_COC_SAMPLE_POS_WIDTH) - 1) \
|
||||
<< EASRC_COC_SAMPLE_POS_SHIFT)
|
||||
#define EASRC_COC_SAMPLE_POS(v) (((v) << EASRC_COC_SAMPLE_POS_SHIFT) \
|
||||
& EASRC_COC_SAMPLE_POS_MASK)
|
||||
#define EASRC_COC_ENDIANNESS_SHIFT 10
|
||||
#define EASRC_COC_ENDIANNESS_MASK BIT(EASRC_COC_ENDIANNESS_SHIFT)
|
||||
#define EASRC_COC_ENDIANNESS BIT(EASRC_COC_ENDIANNESS_SHIFT)
|
||||
#define EASRC_COC_BPS_SHIFT 8
|
||||
#define EASRC_COC_BPS_WIDTH 2
|
||||
#define EASRC_COC_BPS_MASK ((BIT(EASRC_COC_BPS_WIDTH) - 1) \
|
||||
<< EASRC_COC_BPS_SHIFT)
|
||||
#define EASRC_COC_BPS(v) (((v) << EASRC_COC_BPS_SHIFT) \
|
||||
& EASRC_COC_BPS_MASK)
|
||||
#define EASRC_COC_FMT_SHIFT 7
|
||||
#define EASRC_COC_FMT_MASK BIT(EASRC_COC_FMT_SHIFT)
|
||||
#define EASRC_COC_FMT BIT(EASRC_COC_FMT_SHIFT)
|
||||
#define EASRC_COC_OUTSIGN_SHIFT 6
|
||||
#define EASRC_COC_OUTSIGN_MASK BIT(EASRC_COC_OUTSIGN_SHIFT)
|
||||
#define EASRC_COC_OUTSIGN_OUT BIT(EASRC_COC_OUTSIGN_SHIFT)
|
||||
#define EASRC_COC_IEC_VDATA_SHIFT 2
|
||||
#define EASRC_COC_IEC_VDATA_MASK BIT(EASRC_COC_IEC_VDATA_SHIFT)
|
||||
#define EASRC_COC_IEC_VDATA BIT(EASRC_COC_IEC_VDATA_SHIFT)
|
||||
#define EASRC_COC_IEC_EN_SHIFT 1
|
||||
#define EASRC_COC_IEC_EN_MASK BIT(EASRC_COC_IEC_EN_SHIFT)
|
||||
#define EASRC_COC_IEC_EN BIT(EASRC_COC_IEC_EN_SHIFT)
|
||||
#define EASRC_COC_DITHER_EN_SHIFT 0
|
||||
#define EASRC_COC_DITHER_EN_MASK BIT(EASRC_COC_DITHER_EN_SHIFT)
|
||||
#define EASRC_COC_DITHER_EN BIT(EASRC_COC_DITHER_EN_SHIFT)
|
||||
|
||||
/* ASRC Control Output Access (COA) */
|
||||
#define EASRC_COA_ITER_SHIFT 16
|
||||
#define EASRC_COA_ITER_WIDTH 6
|
||||
#define EASRC_COA_ITER_MASK ((BIT(EASRC_COA_ITER_WIDTH) - 1) \
|
||||
<< EASRC_COA_ITER_SHIFT)
|
||||
#define EASRC_COA_ITER(v) (((v) << EASRC_COA_ITER_SHIFT) \
|
||||
& EASRC_COA_ITER_MASK)
|
||||
#define EASRC_COA_GRLEN_SHIFT 8
|
||||
#define EASRC_COA_GRLEN_WIDTH 6
|
||||
#define EASRC_COA_GRLEN_MASK ((BIT(EASRC_COA_GRLEN_WIDTH) - 1) \
|
||||
<< EASRC_COA_GRLEN_SHIFT)
|
||||
#define EASRC_COA_GRLEN(v) (((v) << EASRC_COA_GRLEN_SHIFT) \
|
||||
& EASRC_COA_GRLEN_MASK)
|
||||
#define EASRC_COA_ACCLEN_SHIFT 0
|
||||
#define EASRC_COA_ACCLEN_WIDTH 6
|
||||
#define EASRC_COA_ACCLEN_MASK ((BIT(EASRC_COA_ACCLEN_WIDTH) - 1) \
|
||||
<< EASRC_COA_ACCLEN_SHIFT)
|
||||
#define EASRC_COA_ACCLEN(v) (((v) << EASRC_COA_ACCLEN_SHIFT) \
|
||||
& EASRC_COA_ACCLEN_MASK)
|
||||
|
||||
/* ASRC Sample FIFO Status (SFS) */
|
||||
#define EASRC_SFS_IWTMK_SHIFT 23
|
||||
#define EASRC_SFS_IWTMK_MASK BIT(EASRC_SFS_IWTMK_SHIFT)
|
||||
#define EASRC_SFS_IWTMK BIT(EASRC_SFS_IWTMK_SHIFT)
|
||||
#define EASRC_SFS_NSGI_SHIFT 16
|
||||
#define EASRC_SFS_NSGI_WIDTH 7
|
||||
#define EASRC_SFS_NSGI_MASK ((BIT(EASRC_SFS_NSGI_WIDTH) - 1) \
|
||||
<< EASRC_SFS_NSGI_SHIFT)
|
||||
#define EASRC_SFS_NSGI(v) (((v) << EASRC_SFS_NSGI_SHIFT) \
|
||||
& EASRC_SFS_NSGI_MASK)
|
||||
#define EASRC_SFS_OWTMK_SHIFT 7
|
||||
#define EASRC_SFS_OWTMK_MASK BIT(EASRC_SFS_OWTMK_SHIFT)
|
||||
#define EASRC_SFS_OWTMK BIT(EASRC_SFS_OWTMK_SHIFT)
|
||||
#define EASRC_SFS_NSGO_SHIFT 0
|
||||
#define EASRC_SFS_NSGO_WIDTH 7
|
||||
#define EASRC_SFS_NSGO_MASK ((BIT(EASRC_SFS_NSGO_WIDTH) - 1) \
|
||||
<< EASRC_SFS_NSGO_SHIFT)
|
||||
#define EASRC_SFS_NSGO(v) (((v) << EASRC_SFS_NSGO_SHIFT) \
|
||||
& EASRC_SFS_NSGO_MASK)
|
||||
|
||||
/* ASRC Resampling Ratio Low (RRL) */
|
||||
#define EASRC_RRL_RS_RL_SHIFT 0
|
||||
#define EASRC_RRL_RS_RL_WIDTH 32
|
||||
#define EASRC_RRL_RS_RL(v) ((v) << EASRC_RRL_RS_RL_SHIFT)
|
||||
|
||||
/* ASRC Resampling Ratio High (RRH) */
|
||||
#define EASRC_RRH_RS_VLD_SHIFT 31
|
||||
#define EASRC_RRH_RS_VLD_MASK BIT(EASRC_RRH_RS_VLD_SHIFT)
|
||||
#define EASRC_RRH_RS_VLD BIT(EASRC_RRH_RS_VLD_SHIFT)
|
||||
#define EASRC_RRH_RS_RH_SHIFT 0
|
||||
#define EASRC_RRH_RS_RH_WIDTH 12
|
||||
#define EASRC_RRH_RS_RH_MASK ((BIT(EASRC_RRH_RS_RH_WIDTH) - 1) \
|
||||
<< EASRC_RRH_RS_RH_SHIFT)
|
||||
#define EASRC_RRH_RS_RH(v) (((v) << EASRC_RRH_RS_RH_SHIFT) \
|
||||
& EASRC_RRH_RS_RH_MASK)
|
||||
|
||||
/* ASRC Resampling Ratio Update Control (RSUC) */
|
||||
#define EASRC_RSUC_RS_RM_SHIFT 0
|
||||
#define EASRC_RSUC_RS_RM_WIDTH 32
|
||||
#define EASRC_RSUC_RS_RM(v) ((v) << EASRC_RSUC_RS_RM_SHIFT)
|
||||
|
||||
/* ASRC Resampling Ratio Update Rate (RRUR) */
|
||||
#define EASRC_RRUR_RRR_SHIFT 0
|
||||
#define EASRC_RRUR_RRR_WIDTH 31
|
||||
#define EASRC_RRUR_RRR_MASK ((BIT(EASRC_RRUR_RRR_WIDTH) - 1) \
|
||||
<< EASRC_RRUR_RRR_SHIFT)
|
||||
#define EASRC_RRUR_RRR(v) (((v) << EASRC_RRUR_RRR_SHIFT) \
|
||||
& EASRC_RRUR_RRR_MASK)
|
||||
|
||||
/* ASRC Resampling Center Tap Coefficient Low (RCTCL) */
|
||||
#define EASRC_RCTCL_RS_CL_SHIFT 0
|
||||
#define EASRC_RCTCL_RS_CL_WIDTH 32
|
||||
#define EASRC_RCTCL_RS_CL(v) ((v) << EASRC_RCTCL_RS_CL_SHIFT)
|
||||
|
||||
/* ASRC Resampling Center Tap Coefficient High (RCTCH) */
|
||||
#define EASRC_RCTCH_RS_CH_SHIFT 0
|
||||
#define EASRC_RCTCH_RS_CH_WIDTH 32
|
||||
#define EASRC_RCTCH_RS_CH(v) ((v) << EASRC_RCTCH_RS_CH_SHIFT)
|
||||
|
||||
/* ASRC Prefilter Coefficient FIFO (PCF) */
|
||||
#define EASRC_PCF_CD_SHIFT 0
|
||||
#define EASRC_PCF_CD_WIDTH 32
|
||||
#define EASRC_PCF_CD(v) ((v) << EASRC_PCF_CD_SHIFT)
|
||||
|
||||
/* ASRC Context Resampling Coefficient Memory (CRCM) */
|
||||
#define EASRC_CRCM_RS_CWD_SHIFT 0
|
||||
#define EASRC_CRCM_RS_CWD_WIDTH 32
|
||||
#define EASRC_CRCM_RS_CWD(v) ((v) << EASRC_CRCM_RS_CWD_SHIFT)
|
||||
|
||||
/* ASRC Context Resampling Coefficient Control (CRCC) */
|
||||
#define EASRC_CRCC_RS_CA_SHIFT 16
|
||||
#define EASRC_CRCC_RS_CA_WIDTH 11
|
||||
#define EASRC_CRCC_RS_CA_MASK ((BIT(EASRC_CRCC_RS_CA_WIDTH) - 1) \
|
||||
<< EASRC_CRCC_RS_CA_SHIFT)
|
||||
#define EASRC_CRCC_RS_CA(v) (((v) << EASRC_CRCC_RS_CA_SHIFT) \
|
||||
& EASRC_CRCC_RS_CA_MASK)
|
||||
#define EASRC_CRCC_RS_TAPS_SHIFT 1
|
||||
#define EASRC_CRCC_RS_TAPS_WIDTH 2
|
||||
#define EASRC_CRCC_RS_TAPS_MASK ((BIT(EASRC_CRCC_RS_TAPS_WIDTH) - 1) \
|
||||
<< EASRC_CRCC_RS_TAPS_SHIFT)
|
||||
#define EASRC_CRCC_RS_TAPS(v) (((v) << EASRC_CRCC_RS_TAPS_SHIFT) \
|
||||
& EASRC_CRCC_RS_TAPS_MASK)
|
||||
#define EASRC_CRCC_RS_CPR_SHIFT 0
|
||||
#define EASRC_CRCC_RS_CPR_MASK BIT(EASRC_CRCC_RS_CPR_SHIFT)
|
||||
#define EASRC_CRCC_RS_CPR BIT(EASRC_CRCC_RS_CPR_SHIFT)
|
||||
|
||||
/* ASRC Interrupt_Control (IC) */
|
||||
#define EASRC_IRQC_RSDM_SHIFT 8
|
||||
#define EASRC_IRQC_RSDM_WIDTH 4
|
||||
#define EASRC_IRQC_RSDM_MASK ((BIT(EASRC_IRQC_RSDM_WIDTH) - 1) \
|
||||
<< EASRC_IRQC_RSDM_SHIFT)
|
||||
#define EASRC_IRQC_RSDM(v) (((v) << EASRC_IRQC_RSDM_SHIFT) \
|
||||
& EASRC_IRQC_RSDM_MASK)
|
||||
#define EASRC_IRQC_OERM_SHIFT 4
|
||||
#define EASRC_IRQC_OERM_WIDTH 4
|
||||
#define EASRC_IRQC_OERM_MASK ((BIT(EASRC_IRQC_OERM_WIDTH) - 1) \
|
||||
<< EASRC_IRQC_OERM_SHIFT)
|
||||
#define EASRC_IRQC_OERM(v) (((v) << EASRC_IRQC_OERM_SHIFT) \
|
||||
& EASRC_IEQC_OERM_MASK)
|
||||
#define EASRC_IRQC_IOM_SHIFT 0
|
||||
#define EASRC_IRQC_IOM_WIDTH 4
|
||||
#define EASRC_IRQC_IOM_MASK ((BIT(EASRC_IRQC_IOM_WIDTH) - 1) \
|
||||
<< EASRC_IRQC_IOM_SHIFT)
|
||||
#define EASRC_IRQC_IOM(v) (((v) << EASRC_IRQC_IOM_SHIFT) \
|
||||
& EASRC_IRQC_IOM_MASK)
|
||||
|
||||
/* ASRC Interrupt Status Flags (ISF) */
|
||||
#define EASRC_IRQF_RSD_SHIFT 8
|
||||
#define EASRC_IRQF_RSD_WIDTH 4
|
||||
#define EASRC_IRQF_RSD_MASK ((BIT(EASRC_IRQF_RSD_WIDTH) - 1) \
|
||||
<< EASRC_IRQF_RSD_SHIFT)
|
||||
#define EASRC_IRQF_RSD(v) (((v) << EASRC_IRQF_RSD_SHIFT) \
|
||||
& EASRC_IRQF_RSD_MASK)
|
||||
#define EASRC_IRQF_OER_SHIFT 4
|
||||
#define EASRC_IRQF_OER_WIDTH 4
|
||||
#define EASRC_IRQF_OER_MASK ((BIT(EASRC_IRQF_OER_WIDTH) - 1) \
|
||||
<< EASRC_IRQF_OER_SHIFT)
|
||||
#define EASRC_IRQF_OER(v) (((v) << EASRC_IRQF_OER_SHIFT) \
|
||||
& EASRC_IRQF_OER_MASK)
|
||||
#define EASRC_IRQF_IFO_SHIFT 0
|
||||
#define EASRC_IRQF_IFO_WIDTH 4
|
||||
#define EASRC_IRQF_IFO_MASK ((BIT(EASRC_IRQF_IFO_WIDTH) - 1) \
|
||||
<< EASRC_IRQF_IFO_SHIFT)
|
||||
#define EASRC_IRQF_IFO(v) (((v) << EASRC_IRQF_IFO_SHIFT) \
|
||||
& EASRC_IRQF_IFO_MASK)
|
||||
|
||||
/* ASRC Context Channel STAT */
|
||||
#define EASRC_CSx_CSx_SHIFT 0
|
||||
#define EASRC_CSx_CSx_WIDTH 32
|
||||
#define EASRC_CSx_CSx(v) ((v) << EASRC_CSx_CSx_SHIFT)
|
||||
|
||||
/* ASRC Debug Control Register */
|
||||
#define EASRC_DBGC_DMS_SHIFT 0
|
||||
#define EASRC_DBGC_DMS_WIDTH 6
|
||||
#define EASRC_DBGC_DMS_MASK ((BIT(EASRC_DBGC_DMS_WIDTH) - 1) \
|
||||
<< EASRC_DBGC_DMS_SHIFT)
|
||||
#define EASRC_DBGC_DMS(v) (((v) << EASRC_DBGC_DMS_SHIFT) \
|
||||
& EASRC_DBGC_DMS_MASK)
|
||||
|
||||
/* ASRC Debug Status Register */
|
||||
#define EASRC_DBGS_DS_SHIFT 0
|
||||
#define EASRC_DBGS_DS_WIDTH 32
|
||||
#define EASRC_DBGS_DS(v) ((v) << EASRC_DBGS_DS_SHIFT)
|
||||
|
||||
/* General Constants */
|
||||
#define EASRC_CTX_MAX_NUM 4
|
||||
#define EASRC_RS_COEFF_MEM 0
|
||||
#define EASRC_PF_COEFF_MEM 1
|
||||
|
||||
/* Prefilter constants */
|
||||
#define EASRC_PF_ST1_ONLY 0
|
||||
#define EASRC_PF_TWO_STAGE_MODE 1
|
||||
#define EASRC_PF_ST1_COEFF_WR 0
|
||||
#define EASRC_PF_ST2_COEFF_WR 1
|
||||
#define EASRC_MAX_PF_TAPS 384
|
||||
|
||||
/* Resampling constants */
|
||||
#define EASRC_RS_32_TAPS 0
|
||||
#define EASRC_RS_64_TAPS 1
|
||||
#define EASRC_RS_128_TAPS 2
|
||||
|
||||
/* Initialization mode */
|
||||
#define EASRC_INIT_MODE_SW_CONTROL 0
|
||||
#define EASRC_INIT_MODE_REPLICATE 1
|
||||
#define EASRC_INIT_MODE_ZERO_FILL 2
|
||||
|
||||
/* FIFO watermarks */
|
||||
#define FSL_EASRC_INPUTFIFO_WML 0x4
|
||||
#define FSL_EASRC_OUTPUTFIFO_WML 0x1
|
||||
|
||||
#define EASRC_INPUTFIFO_THRESHOLD_MIN 0
|
||||
#define EASRC_INPUTFIFO_THRESHOLD_MAX 127
|
||||
#define EASRC_OUTPUTFIFO_THRESHOLD_MIN 0
|
||||
#define EASRC_OUTPUTFIFO_THRESHOLD_MAX 63
|
||||
|
||||
#define EASRC_DMA_BUFFER_SIZE (1024 * 48 * 9)
|
||||
#define EASRC_MAX_BUFFER_SIZE (1024 * 48)
|
||||
|
||||
#define FIRMWARE_MAGIC 0xDEAD
|
||||
#define FIRMWARE_VERSION 1
|
||||
|
||||
#define PREFILTER_MEM_LEN 0x1800
|
||||
|
||||
enum easrc_word_width {
|
||||
EASRC_WIDTH_16_BIT = 0,
|
||||
EASRC_WIDTH_20_BIT = 1,
|
||||
EASRC_WIDTH_24_BIT = 2,
|
||||
EASRC_WIDTH_32_BIT = 3,
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) asrc_firmware_hdr {
|
||||
u32 magic;
|
||||
u32 interp_scen;
|
||||
u32 prefil_scen;
|
||||
u32 firmware_version;
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) interp_params {
|
||||
u32 magic;
|
||||
u32 num_taps;
|
||||
u32 num_phases;
|
||||
u64 center_tap;
|
||||
u64 coeff[8192];
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) prefil_params {
|
||||
u32 magic;
|
||||
u32 insr;
|
||||
u32 outsr;
|
||||
u32 st1_taps;
|
||||
u32 st2_taps;
|
||||
u32 st1_exp;
|
||||
u64 coeff[256];
|
||||
};
|
||||
|
||||
struct dma_block {
|
||||
void *dma_vaddr;
|
||||
unsigned int length;
|
||||
unsigned int max_buf_size;
|
||||
};
|
||||
|
||||
struct fsl_easrc_data_fmt {
|
||||
unsigned int width : 2;
|
||||
unsigned int endianness : 1;
|
||||
unsigned int unsign : 1;
|
||||
unsigned int floating_point : 1;
|
||||
unsigned int iec958: 1;
|
||||
unsigned int sample_pos: 5;
|
||||
unsigned int addexp;
|
||||
};
|
||||
|
||||
struct fsl_easrc_io_params {
|
||||
struct fsl_easrc_data_fmt fmt;
|
||||
unsigned int group_len;
|
||||
unsigned int iterations;
|
||||
unsigned int access_len;
|
||||
unsigned int fifo_wtmk;
|
||||
unsigned int sample_rate;
|
||||
unsigned int sample_format;
|
||||
unsigned int norm_rate;
|
||||
};
|
||||
|
||||
struct fsl_easrc_slot {
|
||||
bool busy;
|
||||
int ctx_index;
|
||||
int slot_index;
|
||||
int num_channel; /* maximum is 8 */
|
||||
int min_channel;
|
||||
int max_channel;
|
||||
int pf_mem_used;
|
||||
};
|
||||
|
||||
/**
|
||||
* fsl_easrc_ctx_priv: EASRC context private data
|
||||
*
|
||||
* @in_params: input parameter
|
||||
* @out_params: output parameter
|
||||
* @st1_num_taps: tap number of stage 1
|
||||
* @st2_num_taps: tap number of stage 2
|
||||
* @st1_num_exp: exponent number of stage 1
|
||||
* @pf_init_mode: prefilter init mode
|
||||
* @rs_init_mode: resample filter init mode
|
||||
* @ctx_streams: stream flag of ctx
|
||||
* @rs_ratio: resampler ratio
|
||||
* @st1_coeff: pointer of stage 1 coeff
|
||||
* @st2_coeff: pointer of stage 2 coeff
|
||||
* @in_filled_sample: input filled sample
|
||||
* @out_missed_sample: sample missed in output
|
||||
* @st1_addexp: exponent added for stage1
|
||||
* @st2_addexp: exponent added for stage2
|
||||
*/
|
||||
struct fsl_easrc_ctx_priv {
|
||||
struct fsl_easrc_io_params in_params;
|
||||
struct fsl_easrc_io_params out_params;
|
||||
unsigned int st1_num_taps;
|
||||
unsigned int st2_num_taps;
|
||||
unsigned int st1_num_exp;
|
||||
unsigned int pf_init_mode;
|
||||
unsigned int rs_init_mode;
|
||||
unsigned int ctx_streams;
|
||||
u64 rs_ratio;
|
||||
u64 *st1_coeff;
|
||||
u64 *st2_coeff;
|
||||
int in_filled_sample;
|
||||
int out_missed_sample;
|
||||
int st1_addexp;
|
||||
int st2_addexp;
|
||||
};
|
||||
|
||||
/**
|
||||
* fsl_easrc_priv: EASRC private data
|
||||
*
|
||||
* @slot: slot setting
|
||||
* @firmware_hdr: the header of firmware
|
||||
* @interp: pointer to interpolation filter coeff
|
||||
* @prefil: pointer to prefilter coeff
|
||||
* @fw: firmware of coeff table
|
||||
* @fw_name: firmware name
|
||||
* @rs_num_taps: resample filter taps, 32, 64, or 128
|
||||
* @bps_iec958: bits per sample of iec958
|
||||
* @rs_coeff: resampler coefficient
|
||||
* @const_coeff: one tap prefilter coefficient
|
||||
* @firmware_loaded: firmware is loaded
|
||||
*/
|
||||
struct fsl_easrc_priv {
|
||||
struct fsl_easrc_slot slot[EASRC_CTX_MAX_NUM][2];
|
||||
struct asrc_firmware_hdr *firmware_hdr;
|
||||
struct interp_params *interp;
|
||||
struct prefil_params *prefil;
|
||||
const struct firmware *fw;
|
||||
const char *fw_name;
|
||||
unsigned int rs_num_taps;
|
||||
unsigned int bps_iec958[EASRC_CTX_MAX_NUM];
|
||||
u64 *rs_coeff;
|
||||
u64 const_coeff;
|
||||
int firmware_loaded;
|
||||
};
|
||||
#endif /* _FSL_EASRC_H */
|
Loading…
Reference in New Issue