2017-12-13 23:18:56

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 00/11] ASoC: fsl_ssi: Clean up - coding style level

==Changelog==
v2->v3
* Added Tested-by and Reviewed-by from Maciej
* Revised PATCH-03 "Refine all comments" by adding Maciej advice
* Revised PATCH-05 "Refine indentations and wrappings"
v1->v2
* Dropped one patch to remove "struct device"
* Revised PATCH-03 "Refine all comments"
* Revised PATCH-05 "Refine indentations and wrappings"
* Rebased all other patches
* Added PATCH-10 "Rename i2smode to i2s_net"
* Added PATCH-11 "Define ternary macros to simplify code"

# Detialed changes are described in each updated patch.

==Background==
The fsl_ssi driver was designed for PPC originally and then it has
been updated to support different modes for i.MX Series, including
SDMA, I2S Master mode, AC97 and older i.MXs with FIQ, by different
contributors for different use cases in different coding styles.

Additionally, in order to fix/work-around hardware bugs and design
flaws, the driver made a lot of compromise so now its program flow
looks very complicated and it's getting hard to maintain or update.

So I am going to clean up the driver on both coding style level and
program flow level.

==Introduction==
This series of patches is the first set to clean up fsl_ssi driver
in the coding style level. Any patch here is not supposed to change
the program flow.

==Verification==
Theoretically, since these patches do not change program flow, they
only need code review, build or sanity tests. I have done build and
sanity tests on an i.MX6SoloX with WM8962 using imx_v6_v7_defconfig
and playback/record tests in I2S Master/Slave modes.

Nicolin Chen (11):
ASoC: fsl_ssi: Rename fsl_ssi_private to fsl_ssi
ASoC: fsl_ssi: Cache pdev->dev pointer
ASoC: fsl_ssi: Refine all comments
ASoC: fsl_ssi: Rename registers and fields macros
ASoC: fsl_ssi: Refine indentations and wrappings
ASoC: fsl_ssi: Refine printk outputs
ASoC: fsl_ssi: Rename cpu_dai parameter to dai
ASoC: fsl_ssi: Rename scr_val to scr
ASoC: fsl_ssi: Replace fsl_ssi_rxtx_reg_val with fsl_ssi_regvals
ASoC: fsl_ssi: Rename i2smode to i2s_net
ASoC: fsl_ssi: Define ternary macros to simplify code

sound/soc/fsl/fsl_ssi.c | 1374 +++++++++++++++++++------------------------
sound/soc/fsl/fsl_ssi.h | 427 ++++++++------
sound/soc/fsl/fsl_ssi_dbg.c | 59 +-
3 files changed, 879 insertions(+), 981 deletions(-)

--
2.1.4


2017-12-13 23:19:04

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 02/11] ASoC: fsl_ssi: Cache pdev->dev pointer

There should be no trouble to understand dev = pdev->dev.
This can save some space to have more print info or save
some wrapped lines.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 64 ++++++++++++++++++++++++-------------------------
1 file changed, 31 insertions(+), 33 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 84d2f7e..e903c92 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1379,23 +1379,24 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
struct fsl_ssi *ssi, void __iomem *iomem)
{
struct device_node *np = pdev->dev.of_node;
+ struct device *dev = &pdev->dev;
u32 dmas[4];
int ret;

if (ssi->has_ipg_clk_name)
- ssi->clk = devm_clk_get(&pdev->dev, "ipg");
+ ssi->clk = devm_clk_get(dev, "ipg");
else
- ssi->clk = devm_clk_get(&pdev->dev, NULL);
+ ssi->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ssi->clk)) {
ret = PTR_ERR(ssi->clk);
- dev_err(&pdev->dev, "could not get clock: %d\n", ret);
+ dev_err(dev, "could not get clock: %d\n", ret);
return ret;
}

if (!ssi->has_ipg_clk_name) {
ret = clk_prepare_enable(ssi->clk);
if (ret) {
- dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n", ret);
+ dev_err(dev, "clk_prepare_enable failed: %d\n", ret);
return ret;
}
}
@@ -1403,9 +1404,9 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
/* For those SLAVE implementations, we ignore non-baudclk cases
* and, instead, abandon MASTER mode that needs baud clock.
*/
- ssi->baudclk = devm_clk_get(&pdev->dev, "baud");
+ ssi->baudclk = devm_clk_get(dev, "baud");
if (IS_ERR(ssi->baudclk))
- dev_dbg(&pdev->dev, "could not get baud clock: %ld\n",
+ dev_dbg(dev, "could not get baud clock: %ld\n",
PTR_ERR(ssi->baudclk));

ssi->dma_params_tx.maxburst = ssi->dma_maxburst;
@@ -1469,6 +1470,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
struct fsl_ssi *ssi;
int ret = 0;
struct device_node *np = pdev->dev.of_node;
+ struct device *dev = &pdev->dev;
const struct of_device_id *of_id;
const char *p, *sprop;
const uint32_t *iprop;
@@ -1477,17 +1479,16 @@ static int fsl_ssi_probe(struct platform_device *pdev)
char name[64];
struct regmap_config regconfig = fsl_ssi_regconfig;

- of_id = of_match_device(fsl_ssi_ids, &pdev->dev);
+ of_id = of_match_device(fsl_ssi_ids, dev);
if (!of_id || !of_id->data)
return -EINVAL;

- ssi = devm_kzalloc(&pdev->dev, sizeof(*ssi),
- GFP_KERNEL);
+ ssi = devm_kzalloc(dev, sizeof(*ssi), GFP_KERNEL);
if (!ssi)
return -ENOMEM;

ssi->soc = of_id->data;
- ssi->dev = &pdev->dev;
+ ssi->dev = dev;

sprop = of_get_property(np, "fsl,mode", NULL);
if (sprop) {
@@ -1507,10 +1508,10 @@ static int fsl_ssi_probe(struct platform_device *pdev)
memcpy(&ssi->cpu_dai_drv, &fsl_ssi_dai_template,
sizeof(fsl_ssi_dai_template));
}
- ssi->cpu_dai_drv.name = dev_name(&pdev->dev);
+ ssi->cpu_dai_drv.name = dev_name(dev);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- iomem = devm_ioremap_resource(&pdev->dev, res);
+ iomem = devm_ioremap_resource(dev, res);
if (IS_ERR(iomem))
return PTR_ERR(iomem);
ssi->ssi_phys = res->start;
@@ -1528,21 +1529,20 @@ static int fsl_ssi_probe(struct platform_device *pdev)
ret = of_property_match_string(np, "clock-names", "ipg");
if (ret < 0) {
ssi->has_ipg_clk_name = false;
- ssi->regs = devm_regmap_init_mmio(&pdev->dev, iomem,
- &regconfig);
+ ssi->regs = devm_regmap_init_mmio(dev, iomem, &regconfig);
} else {
ssi->has_ipg_clk_name = true;
- ssi->regs = devm_regmap_init_mmio_clk(&pdev->dev,
- "ipg", iomem, &regconfig);
+ ssi->regs = devm_regmap_init_mmio_clk(dev, "ipg", iomem,
+ &regconfig);
}
if (IS_ERR(ssi->regs)) {
- dev_err(&pdev->dev, "Failed to init register map\n");
+ dev_err(dev, "Failed to init register map\n");
return PTR_ERR(ssi->regs);
}

ssi->irq = platform_get_irq(pdev, 0);
if (ssi->irq < 0) {
- dev_err(&pdev->dev, "no irq for node %s\n", pdev->name);
+ dev_err(dev, "no irq for node %s\n", pdev->name);
return ssi->irq;
}

@@ -1605,7 +1605,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
break;
}

- dev_set_drvdata(&pdev->dev, ssi);
+ dev_set_drvdata(dev, ssi);

if (ssi->soc->imx) {
ret = fsl_ssi_imx_probe(pdev, ssi, iomem);
@@ -1617,30 +1617,28 @@ static int fsl_ssi_probe(struct platform_device *pdev)
mutex_init(&ssi->ac97_reg_lock);
ret = snd_soc_set_ac97_ops_of_reset(&fsl_ssi_ac97_ops, pdev);
if (ret) {
- dev_err(&pdev->dev, "could not set AC'97 ops\n");
+ dev_err(dev, "could not set AC'97 ops\n");
goto error_ac97_ops;
}
}

- ret = devm_snd_soc_register_component(&pdev->dev, &fsl_ssi_component,
+ ret = devm_snd_soc_register_component(dev, &fsl_ssi_component,
&ssi->cpu_dai_drv, 1);
if (ret) {
- dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
+ dev_err(dev, "failed to register DAI: %d\n", ret);
goto error_asoc_register;
}

if (ssi->use_dma) {
- ret = devm_request_irq(&pdev->dev, ssi->irq,
- fsl_ssi_isr, 0, dev_name(&pdev->dev),
- ssi);
+ ret = devm_request_irq(dev, ssi->irq, fsl_ssi_isr, 0,
+ dev_name(dev), ssi);
if (ret < 0) {
- dev_err(&pdev->dev, "could not claim irq %u\n",
- ssi->irq);
+ dev_err(dev, "could not claim irq %u\n", ssi->irq);
goto error_asoc_register;
}
}

- ret = fsl_ssi_debugfs_create(&ssi->dbg_stats, &pdev->dev);
+ ret = fsl_ssi_debugfs_create(&ssi->dbg_stats, dev);
if (ret)
goto error_asoc_register;

@@ -1665,23 +1663,23 @@ static int fsl_ssi_probe(struct platform_device *pdev)
snprintf(name, sizeof(name), "snd-soc-%s", sprop);
make_lowercase(name);

- ssi->pdev = platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
+ ssi->pdev = platform_device_register_data(dev, name, 0, NULL, 0);
if (IS_ERR(ssi->pdev)) {
ret = PTR_ERR(ssi->pdev);
- dev_err(&pdev->dev, "failed to register platform: %d\n", ret);
+ dev_err(dev, "failed to register platform: %d\n", ret);
goto error_sound_card;
}

done:
if (ssi->dai_fmt)
- _fsl_ssi_set_dai_fmt(&pdev->dev, ssi, ssi->dai_fmt);
+ _fsl_ssi_set_dai_fmt(dev, ssi, ssi->dai_fmt);

if (fsl_ssi_is_ac97(ssi)) {
u32 ssi_idx;

ret = of_property_read_u32(np, "cell-index", &ssi_idx);
if (ret) {
- dev_err(&pdev->dev, "cannot get SSI index property\n");
+ dev_err(dev, "cannot get SSI index property\n");
goto error_sound_card;
}

@@ -1689,7 +1687,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
"ac97-codec", ssi_idx, NULL, 0);
if (IS_ERR(ssi->pdev)) {
ret = PTR_ERR(ssi->pdev);
- dev_err(&pdev->dev,
+ dev_err(dev,
"failed to register AC97 codec platform: %d\n",
ret);
goto error_sound_card;
--
2.1.4

2017-12-13 23:19:07

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 10/11] ASoC: fsl_ssi: Rename i2smode to i2s_net

Since this i2smode also includes the setting of Network mode, it
should have it in the name. This patch also adds its MASK define.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 24 ++++++++++++------------
sound/soc/fsl/fsl_ssi.h | 1 +
2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 1cdc62a..4a2438c 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -201,7 +201,7 @@ struct fsl_ssi_soc_data {
* @cpu_dai_drv: CPU DAI driver for this device
*
* @dai_fmt: DAI configuration this device is currently used with
- * @i2s_mode: I2S and Network mode configuration of SCR register
+ * @i2s_net: I2S and Network mode configurations of SCR register
* @use_dma: DMA is used or FIQ with stream filter
* @use_dual_fifo: DMA with support for dual FIFO mode
* @has_ipg_clk_name: If "ipg" is in the clock name list of device tree
@@ -245,7 +245,7 @@ struct fsl_ssi {
struct snd_soc_dai_driver cpu_dai_drv;

unsigned int dai_fmt;
- u8 i2s_mode;
+ u8 i2s_net;
bool use_dma;
bool use_dual_fifo;
bool has_ipg_clk_name;
@@ -821,16 +821,16 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
}

if (!fsl_ssi_is_ac97(ssi)) {
- u8 i2smode;
+ u8 i2s_net;
/* Normal + Network mode to send 16-bit data in 32-bit frames */
if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
- i2smode = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET;
+ i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET;
else
- i2smode = ssi->i2s_mode;
+ i2s_net = ssi->i2s_net;

regmap_update_bits(regs, REG_SSI_SCR,
- SSI_SCR_NET | SSI_SCR_I2S_MODE_MASK,
- channels == 1 ? 0 : i2smode);
+ SSI_SCR_I2S_NET_MASK,
+ channels == 1 ? 0 : i2s_net);
}

/* In synchronous mode, the SSI uses STCCR for capture */
@@ -887,7 +887,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
srcr &= ~mask;

/* Use Network mode as default */
- ssi->i2s_mode = SSI_SCR_NET;
+ ssi->i2s_net = SSI_SCR_NET;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
regmap_update_bits(regs, REG_SSI_STCCR,
@@ -897,10 +897,10 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFS:
case SND_SOC_DAIFMT_CBS_CFS:
- ssi->i2s_mode |= SSI_SCR_I2S_MODE_MASTER;
+ ssi->i2s_net |= SSI_SCR_I2S_MODE_MASTER;
break;
case SND_SOC_DAIFMT_CBM_CFM:
- ssi->i2s_mode |= SSI_SCR_I2S_MODE_SLAVE;
+ ssi->i2s_net |= SSI_SCR_I2S_MODE_SLAVE;
break;
default:
return -EINVAL;
@@ -925,12 +925,12 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
break;
case SND_SOC_DAIFMT_AC97:
/* Data on falling edge of bclk, frame high, 1clk before data */
- ssi->i2s_mode |= SSI_SCR_I2S_MODE_NORMAL;
+ ssi->i2s_net |= SSI_SCR_I2S_MODE_NORMAL;
break;
default:
return -EINVAL;
}
- scr |= ssi->i2s_mode;
+ scr |= ssi->i2s_net;

/* DAI clock inversion */
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index 52b88f1..b610087 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -95,6 +95,7 @@
#define SSI_SCR_I2S_MODE_SLAVE 0x00000040
#define SSI_SCR_SYN 0x00000010
#define SSI_SCR_NET 0x00000008
+#define SSI_SCR_I2S_NET_MASK (SSI_SCR_NET | SSI_SCR_I2S_MODE_MASK)
#define SSI_SCR_RE 0x00000004
#define SSI_SCR_TE 0x00000002
#define SSI_SCR_SSIEN 0x00000001
--
2.1.4

2017-12-13 23:19:09

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 09/11] ASoC: fsl_ssi: Replace fsl_ssi_rxtx_reg_val with fsl_ssi_regvals

The name fsl_ssi_rxtx_reg_val is too long to read comfortably.
So this patch shortens it by using an array (fsl_ssi_regvals,
renamed from fsl_ssi_reg_val). To do that, it also introduces
two macros (TX and RX) to replace the wrapper structure. This
will also help further cleanups.

Meanwhile, it unifies all local variable with the name "vals"
to get rid of the name "reg" -- could be confusing with "regs"
in the private struct for regmap.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 79 +++++++++++++++++++++++--------------------------
sound/soc/fsl/fsl_ssi.h | 3 ++
2 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 08258c4..1cdc62a 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -106,18 +106,13 @@ enum fsl_ssi_type {
FSL_SSI_MX51,
};

-struct fsl_ssi_reg_val {
+struct fsl_ssi_regvals {
u32 sier;
u32 srcr;
u32 stcr;
u32 scr;
};

-struct fsl_ssi_rxtx_reg_val {
- struct fsl_ssi_reg_val rx;
- struct fsl_ssi_reg_val tx;
-};
-
static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
@@ -213,7 +208,7 @@ struct fsl_ssi_soc_data {
* @fifo_depth: Depth of the SSI FIFOs
* @slot_width: Width of each DAI slot
* @slots: Number of slots
- * @rxtx_reg_val: Specific RX/TX register settings
+ * @regvals: Specific RX/TX register settings
*
* @clk: Clock source to access register
* @baudclk: Clock source to generate bit and frame-sync clocks
@@ -257,7 +252,7 @@ struct fsl_ssi {
unsigned int fifo_depth;
unsigned int slot_width;
unsigned int slots;
- struct fsl_ssi_rxtx_reg_val rxtx_reg_val;
+ struct fsl_ssi_regvals regvals[2];

struct clk *clk;
struct clk *baudclk;
@@ -383,25 +378,25 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
{
struct regmap *regs = ssi->regs;
- struct fsl_ssi_rxtx_reg_val *vals = &ssi->rxtx_reg_val;
+ struct fsl_ssi_regvals *vals = ssi->regvals;

if (enable) {
regmap_update_bits(regs, REG_SSI_SIER,
- vals->rx.sier | vals->tx.sier,
- vals->rx.sier | vals->tx.sier);
+ vals[RX].sier | vals[TX].sier,
+ vals[RX].sier | vals[TX].sier);
regmap_update_bits(regs, REG_SSI_SRCR,
- vals->rx.srcr | vals->tx.srcr,
- vals->rx.srcr | vals->tx.srcr);
+ vals[RX].srcr | vals[TX].srcr,
+ vals[RX].srcr | vals[TX].srcr);
regmap_update_bits(regs, REG_SSI_STCR,
- vals->rx.stcr | vals->tx.stcr,
- vals->rx.stcr | vals->tx.stcr);
+ vals[RX].stcr | vals[TX].stcr,
+ vals[RX].stcr | vals[TX].stcr);
} else {
regmap_update_bits(regs, REG_SSI_SRCR,
- vals->rx.srcr | vals->tx.srcr, 0);
+ vals[RX].srcr | vals[TX].srcr, 0);
regmap_update_bits(regs, REG_SSI_STCR,
- vals->rx.stcr | vals->tx.stcr, 0);
+ vals[RX].stcr | vals[TX].stcr, 0);
regmap_update_bits(regs, REG_SSI_SIER,
- vals->rx.sier | vals->tx.sier, 0);
+ vals[RX].sier | vals[TX].sier, 0);
}
}

@@ -443,10 +438,10 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
* Enable or disable SSI configuration.
*/
static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
- struct fsl_ssi_reg_val *vals)
+ struct fsl_ssi_regvals *vals)
{
struct regmap *regs = ssi->regs;
- struct fsl_ssi_reg_val *avals;
+ struct fsl_ssi_regvals *avals;
int nr_active_streams;
u32 scr;
int keep_active;
@@ -461,10 +456,10 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
keep_active = 0;

/* Get the opposite direction to keep its values untouched */
- if (&ssi->rxtx_reg_val.rx == vals)
- avals = &ssi->rxtx_reg_val.tx;
+ if (&ssi->regvals[RX] == vals)
+ avals = &ssi->regvals[TX];
else
- avals = &ssi->rxtx_reg_val.rx;
+ avals = &ssi->regvals[RX];

if (!enable) {
/* Exclude necessary bits for the opposite stream */
@@ -543,7 +538,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,

static void fsl_ssi_rx_config(struct fsl_ssi *ssi, bool enable)
{
- fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.rx);
+ fsl_ssi_config(ssi, enable, &ssi->regvals[RX]);
}

static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi)
@@ -571,39 +566,39 @@ static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable)
if (enable && fsl_ssi_is_ac97(ssi))
fsl_ssi_tx_ac97_saccst_setup(ssi);

- fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.tx);
+ fsl_ssi_config(ssi, enable, &ssi->regvals[TX]);
}

/**
* Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely
*/
-static void fsl_ssi_setup_reg_vals(struct fsl_ssi *ssi)
+static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi)
{
- struct fsl_ssi_rxtx_reg_val *reg = &ssi->rxtx_reg_val;
+ struct fsl_ssi_regvals *vals = ssi->regvals;

- reg->rx.sier = SSI_SIER_RFF0_EN;
- reg->rx.srcr = SSI_SRCR_RFEN0;
- reg->rx.scr = 0;
- reg->tx.sier = SSI_SIER_TFE0_EN;
- reg->tx.stcr = SSI_STCR_TFEN0;
- reg->tx.scr = 0;
+ vals[RX].sier = SSI_SIER_RFF0_EN;
+ vals[RX].srcr = SSI_SRCR_RFEN0;
+ vals[RX].scr = 0;
+ vals[TX].sier = SSI_SIER_TFE0_EN;
+ vals[TX].stcr = SSI_STCR_TFEN0;
+ vals[TX].scr = 0;

/* AC97 has already enabled SSIEN, RE and TE, so ignore them */
if (!fsl_ssi_is_ac97(ssi)) {
- reg->rx.scr = SSI_SCR_SSIEN | SSI_SCR_RE;
- reg->tx.scr = SSI_SCR_SSIEN | SSI_SCR_TE;
+ vals[RX].scr = SSI_SCR_SSIEN | SSI_SCR_RE;
+ vals[TX].scr = SSI_SCR_SSIEN | SSI_SCR_TE;
}

if (ssi->use_dma) {
- reg->rx.sier |= SSI_SIER_RDMAE;
- reg->tx.sier |= SSI_SIER_TDMAE;
+ vals[RX].sier |= SSI_SIER_RDMAE;
+ vals[TX].sier |= SSI_SIER_TDMAE;
} else {
- reg->rx.sier |= SSI_SIER_RIE;
- reg->tx.sier |= SSI_SIER_TIE;
+ vals[RX].sier |= SSI_SIER_RIE;
+ vals[TX].sier |= SSI_SIER_TIE;
}

- reg->rx.sier |= FSLSSI_SIER_DBG_RX_FLAGS;
- reg->tx.sier |= FSLSSI_SIER_DBG_TX_FLAGS;
+ vals[RX].sier |= FSLSSI_SIER_DBG_RX_FLAGS;
+ vals[TX].sier |= FSLSSI_SIER_DBG_TX_FLAGS;
}

static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi)
@@ -877,7 +872,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
return -EINVAL;
}

- fsl_ssi_setup_reg_vals(ssi);
+ fsl_ssi_setup_regvals(ssi);

regmap_read(regs, REG_SSI_SCR, &scr);
scr &= ~(SSI_SCR_SYN | SSI_SCR_I2S_MODE_MASK);
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index fe38e69..52b88f1 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -12,6 +12,9 @@
#ifndef _MPC8610_I2S_H
#define _MPC8610_I2S_H

+#define RX 0
+#define TX 1
+
/* -- SSI Register Map -- */

/* SSI Transmit Data Register 0 */
--
2.1.4

2017-12-13 23:19:33

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 11/11] ASoC: fsl_ssi: Define ternary macros to simplify code

Some regmap code looks redudant. So simplify it.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 27 +++++++++++----------------
sound/soc/fsl/fsl_ssi.h | 4 ++++
2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 4a2438c..578870f 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -405,13 +405,10 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
*/
static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
{
- if (is_rx) {
- regmap_update_bits(ssi->regs, REG_SSI_SOR,
- SSI_SOR_RX_CLR, SSI_SOR_RX_CLR);
- } else {
- regmap_update_bits(ssi->regs, REG_SSI_SOR,
- SSI_SOR_TX_CLR, SSI_SOR_TX_CLR);
- }
+ bool tx = !is_rx;
+
+ regmap_update_bits(ssi->regs, REG_SSI_SOR,
+ SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx));
}

/**
@@ -666,6 +663,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai,
struct snd_pcm_hw_params *hw_params)
{
+ bool tx2, tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
struct regmap *regs = ssi->regs;
int synchronous = ssi->cpu_dai_drv.symmetric_rates, ret;
@@ -753,10 +751,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
(psr ? SSI_SxCCR_PSR : 0);
mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 | SSI_SxCCR_PSR;

- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || synchronous)
- regmap_update_bits(regs, REG_SSI_STCCR, mask, stccr);
- else
- regmap_update_bits(regs, REG_SSI_SRCCR, mask, stccr);
+ /* STCCR is used for RX in synchronous mode */
+ tx2 = tx || synchronous;
+ regmap_update_bits(regs, REG_SSI_SxCCR(tx2), mask, stccr);

if (!baudclk_is_used) {
ret = clk_set_rate(ssi->baudclk, baudrate);
@@ -784,6 +781,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params,
struct snd_soc_dai *dai)
{
+ bool tx2, tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
struct regmap *regs = ssi->regs;
unsigned int channels = params_channels(hw_params);
@@ -834,11 +832,8 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
}

/* In synchronous mode, the SSI uses STCCR for capture */
- if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
- ssi->cpu_dai_drv.symmetric_rates)
- regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_WL_MASK, wl);
- else
- regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_WL_MASK, wl);
+ tx2 = tx || ssi->cpu_dai_drv.symmetric_rates;
+ regmap_update_bits(regs, REG_SSI_SxCCR(tx2), SSI_SxCCR_WL_MASK, wl);

return 0;
}
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index b610087..de2fdc5 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -35,10 +35,12 @@
#define REG_SSI_STCR 0x1c
/* SSI Receive Configuration Register */
#define REG_SSI_SRCR 0x20
+#define REG_SSI_SxCR(tx) ((tx) ? REG_SSI_STCR : REG_SSI_SRCR)
/* SSI Transmit Clock Control Register */
#define REG_SSI_STCCR 0x24
/* SSI Receive Clock Control Register */
#define REG_SSI_SRCCR 0x28
+#define REG_SSI_SxCCR(tx) ((tx) ? REG_SSI_STCCR : REG_SSI_SRCCR)
/* SSI FIFO Control/Status Register */
#define REG_SSI_SFCSR 0x2c
/*
@@ -67,6 +69,7 @@
#define REG_SSI_STMSK 0x48
/* SSI Receive Time Slot Mask Register */
#define REG_SSI_SRMSK 0x4c
+#define REG_SSI_SxMSK(tx) ((tx) ? REG_SSI_STMSK : REG_SSI_SRMSK)
/*
* SSI AC97 Channel Status Register
*
@@ -249,6 +252,7 @@
#define SSI_SOR_CLKOFF 0x00000040
#define SSI_SOR_RX_CLR 0x00000020
#define SSI_SOR_TX_CLR 0x00000010
+#define SSI_SOR_xX_CLR(tx) ((tx) ? SSI_SOR_TX_CLR : SSI_SOR_RX_CLR)
#define SSI_SOR_INIT 0x00000008
#define SSI_SOR_WAIT_SHIFT 1
#define SSI_SOR_WAIT_MASK 0x00000006
--
2.1.4

2017-12-13 23:19:52

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 08/11] ASoC: fsl_ssi: Rename scr_val to scr

Simplify the variable name. This reduces one over-80-character line.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 83d6e3d..08258c4 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -448,12 +448,12 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
struct regmap *regs = ssi->regs;
struct fsl_ssi_reg_val *avals;
int nr_active_streams;
- u32 scr_val;
+ u32 scr;
int keep_active;

- regmap_read(regs, REG_SSI_SCR, &scr_val);
+ regmap_read(regs, REG_SSI_SCR, &scr);

- nr_active_streams = !!(scr_val & SSI_SCR_TE) + !!(scr_val & SSI_SCR_RE);
+ nr_active_streams = !!(scr & SSI_SCR_TE) + !!(scr & SSI_SCR_RE);

if (nr_active_streams - 1 > 0)
keep_active = 1;
@@ -795,11 +795,11 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
unsigned int sample_size = params_width(hw_params);
u32 wl = SSI_SxCCR_WL(sample_size);
int ret;
- u32 scr_val;
+ u32 scr;
int enabled;

- regmap_read(regs, REG_SSI_SCR, &scr_val);
- enabled = scr_val & SSI_SCR_SSIEN;
+ regmap_read(regs, REG_SSI_SCR, &scr);
+ enabled = scr & SSI_SCR_SSIEN;

/*
* SSI is properly configured if it is enabled and running in
--
2.1.4

2017-12-13 23:20:16

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 07/11] ASoC: fsl_ssi: Rename cpu_dai parameter to dai

Shortens the variable name to save space, useful for dev_err outputs.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 7b6aedd..83d6e3d 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -668,10 +668,10 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
* (In 2-channel I2S Master mode, slot_width is fixed 32)
*/
static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
- struct snd_soc_dai *cpu_dai,
+ struct snd_soc_dai *dai,
struct snd_pcm_hw_params *hw_params)
{
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
struct regmap *regs = ssi->regs;
int synchronous = ssi->cpu_dai_drv.symmetric_rates, ret;
u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i;
@@ -701,7 +701,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
* never greater than 1/5 IPG clock rate
*/
if (freq * 5 > clk_get_rate(ssi->clk)) {
- dev_err(cpu_dai->dev, "bitclk > ipgclk / 5\n");
+ dev_err(dai->dev, "bitclk > ipgclk / 5\n");
return -EINVAL;
}

@@ -750,7 +750,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,

/* No proper pm found if it is still remaining the initial value */
if (pm == 999) {
- dev_err(cpu_dai->dev, "failed to handle the required sysclk\n");
+ dev_err(dai->dev, "failed to handle the required sysclk\n");
return -EINVAL;
}

@@ -766,7 +766,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
if (!baudclk_is_used) {
ret = clk_set_rate(ssi->baudclk, baudrate);
if (ret) {
- dev_err(cpu_dai->dev, "failed to set baudclk rate\n");
+ dev_err(dai->dev, "failed to set baudclk rate\n");
return -EINVAL;
}
}
@@ -787,9 +787,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
*/
static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params,
- struct snd_soc_dai *cpu_dai)
+ struct snd_soc_dai *dai)
{
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
struct regmap *regs = ssi->regs;
unsigned int channels = params_channels(hw_params);
unsigned int sample_size = params_width(hw_params);
@@ -811,7 +811,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
return 0;

if (fsl_ssi_is_i2s_master(ssi)) {
- ret = fsl_ssi_set_bclk(substream, cpu_dai, hw_params);
+ ret = fsl_ssi_set_bclk(substream, dai, hw_params);
if (ret)
return ret;

@@ -849,7 +849,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
}

static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
- struct snd_soc_dai *cpu_dai)
+ struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
@@ -1018,30 +1018,30 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
/**
* Configure Digital Audio Interface (DAI) Format
*/
-static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);

/* AC97 configured DAIFMT earlier in the probe() */
if (fsl_ssi_is_ac97(ssi))
return 0;

- return _fsl_ssi_set_dai_fmt(cpu_dai->dev, ssi, fmt);
+ return _fsl_ssi_set_dai_fmt(dai->dev, ssi, fmt);
}

/**
* Set TDM slot number and slot width
*/
-static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
+static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask,
u32 rx_mask, int slots, int slot_width)
{
- struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);
struct regmap *regs = ssi->regs;
u32 val;

/* The word length should be 8, 10, 12, 16, 18, 20, 22 or 24 */
if (slot_width & 1 || slot_width < 8 || slot_width > 24) {
- dev_err(cpu_dai->dev, "invalid slot width: %d\n", slot_width);
+ dev_err(dai->dev, "invalid slot width: %d\n", slot_width);
return -EINVAL;
}

@@ -1049,7 +1049,7 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
regmap_read(regs, REG_SSI_SCR, &val);
val &= SSI_SCR_I2S_MODE_MASK | SSI_SCR_NET;
if (val && slots < 2) {
- dev_err(cpu_dai->dev, "slot number should be >= 2 in I2S or NET\n");
+ dev_err(dai->dev, "slot number should be >= 2 in I2S or NET\n");
return -EINVAL;
}

--
2.1.4

2017-12-13 23:19:02

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 01/11] ASoC: fsl_ssi: Rename fsl_ssi_private to fsl_ssi

Shorten the private data structure to save some wrapped lines.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 456 +++++++++++++++++++++++-------------------------
1 file changed, 220 insertions(+), 236 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index c350117..84d2f7e 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -185,7 +185,7 @@ struct fsl_ssi_soc_data {
};

/**
- * fsl_ssi_private: per-SSI private data
+ * fsl_ssi: per-SSI private data
*
* @reg: Pointer to the regmap registers
* @irq: IRQ of this SSI
@@ -224,7 +224,7 @@ struct fsl_ssi_soc_data {
* @dma_maxburst: max number of words to transfer in one go. So far,
* this is always the same as fifo_watermark.
*/
-struct fsl_ssi_private {
+struct fsl_ssi {
struct regmap *regs;
int irq;
struct snd_soc_dai_driver cpu_dai_drv;
@@ -325,21 +325,21 @@ static const struct of_device_id fsl_ssi_ids[] = {
};
MODULE_DEVICE_TABLE(of, fsl_ssi_ids);

-static bool fsl_ssi_is_ac97(struct fsl_ssi_private *ssi_private)
+static bool fsl_ssi_is_ac97(struct fsl_ssi *ssi)
{
- return (ssi_private->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) ==
+ return (ssi->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) ==
SND_SOC_DAIFMT_AC97;
}

-static bool fsl_ssi_is_i2s_master(struct fsl_ssi_private *ssi_private)
+static bool fsl_ssi_is_i2s_master(struct fsl_ssi *ssi)
{
- return (ssi_private->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
+ return (ssi->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
SND_SOC_DAIFMT_CBS_CFS;
}

-static bool fsl_ssi_is_i2s_cbm_cfs(struct fsl_ssi_private *ssi_private)
+static bool fsl_ssi_is_i2s_cbm_cfs(struct fsl_ssi *ssi)
{
- return (ssi_private->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
+ return (ssi->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
SND_SOC_DAIFMT_CBM_CFS;
}
/**
@@ -352,12 +352,12 @@ static bool fsl_ssi_is_i2s_cbm_cfs(struct fsl_ssi_private *ssi_private)
* This interrupt handler is used only to gather statistics.
*
* @irq: IRQ of the SSI device
- * @dev_id: pointer to the ssi_private structure for this SSI device
+ * @dev_id: pointer to the fsl_ssi structure for this SSI device
*/
static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
{
- struct fsl_ssi_private *ssi_private = dev_id;
- struct regmap *regs = ssi_private->regs;
+ struct fsl_ssi *ssi = dev_id;
+ struct regmap *regs = ssi->regs;
__be32 sisr;
__be32 sisr2;

@@ -367,12 +367,12 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
*/
regmap_read(regs, CCSR_SSI_SISR, &sisr);

- sisr2 = sisr & ssi_private->soc->sisr_write_mask;
+ sisr2 = sisr & ssi->soc->sisr_write_mask;
/* Clear the bits that we set */
if (sisr2)
regmap_write(regs, CCSR_SSI_SISR, sisr2);

- fsl_ssi_dbg_isr(&ssi_private->dbg_stats, sisr);
+ fsl_ssi_dbg_isr(&ssi->dbg_stats, sisr);

return IRQ_HANDLED;
}
@@ -380,11 +380,10 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
/*
* Enable/Disable all rx/tx config flags at once.
*/
-static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private,
- bool enable)
+static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
{
- struct regmap *regs = ssi_private->regs;
- struct fsl_ssi_rxtx_reg_val *vals = &ssi_private->rxtx_reg_val;
+ struct regmap *regs = ssi->regs;
+ struct fsl_ssi_rxtx_reg_val *vals = &ssi->rxtx_reg_val;

if (enable) {
regmap_update_bits(regs, CCSR_SSI_SIER,
@@ -414,14 +413,13 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private,
* Note: The SOR is not documented in recent IMX datasheet, but
* is described in IMX51 reference manual at section 56.3.3.15.
*/
-static void fsl_ssi_fifo_clear(struct fsl_ssi_private *ssi_private,
- bool is_rx)
+static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
{
if (is_rx) {
- regmap_update_bits(ssi_private->regs, CCSR_SSI_SOR,
+ regmap_update_bits(ssi->regs, CCSR_SSI_SOR,
CCSR_SSI_SOR_RX_CLR, CCSR_SSI_SOR_RX_CLR);
} else {
- regmap_update_bits(ssi_private->regs, CCSR_SSI_SOR,
+ regmap_update_bits(ssi->regs, CCSR_SSI_SOR,
CCSR_SSI_SOR_TX_CLR, CCSR_SSI_SOR_TX_CLR);
}
}
@@ -448,12 +446,12 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi_private *ssi_private,

/*
* Enable/Disable a ssi configuration. You have to pass either
- * ssi_private->rxtx_reg_val.rx or tx as vals parameter.
+ * ssi->rxtx_reg_val.rx or tx as vals parameter.
*/
-static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
+static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
struct fsl_ssi_reg_val *vals)
{
- struct regmap *regs = ssi_private->regs;
+ struct regmap *regs = ssi->regs;
struct fsl_ssi_reg_val *avals;
int nr_active_streams;
u32 scr_val;
@@ -471,10 +469,10 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,

/* Find the other direction values rx or tx which we do not want to
* modify */
- if (&ssi_private->rxtx_reg_val.rx == vals)
- avals = &ssi_private->rxtx_reg_val.tx;
+ if (&ssi->rxtx_reg_val.rx == vals)
+ avals = &ssi->rxtx_reg_val.tx;
else
- avals = &ssi_private->rxtx_reg_val.rx;
+ avals = &ssi->rxtx_reg_val.rx;

/* If vals should be disabled, start with disabling the unit */
if (!enable) {
@@ -488,10 +486,10 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
* reconfiguration, so we have to enable all necessary flags at once
* even if we do not use them later (capture and playback configuration)
*/
- if (ssi_private->soc->offline_config) {
+ if (ssi->soc->offline_config) {
if ((enable && !nr_active_streams) ||
(!enable && !keep_active))
- fsl_ssi_rxtx_config(ssi_private, enable);
+ fsl_ssi_rxtx_config(ssi, enable);

goto config_done;
}
@@ -501,7 +499,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
* (online configuration)
*/
if (enable) {
- fsl_ssi_fifo_clear(ssi_private, vals->scr & CCSR_SSI_SCR_RE);
+ fsl_ssi_fifo_clear(ssi, vals->scr & CCSR_SSI_SCR_RE);

regmap_update_bits(regs, CCSR_SSI_SRCR, vals->srcr, vals->srcr);
regmap_update_bits(regs, CCSR_SSI_STCR, vals->stcr, vals->stcr);
@@ -536,7 +534,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
config_done:
/* Enabling of subunits is done after configuration */
if (enable) {
- if (ssi_private->use_dma && (vals->scr & CCSR_SSI_SCR_TE)) {
+ if (ssi->use_dma && (vals->scr & CCSR_SSI_SCR_TE)) {
/*
* Be sure the Tx FIFO is filled when TE is set.
* Otherwise, there are some chances to start the
@@ -563,7 +561,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
break;
}
if (i == max_loop) {
- dev_err(ssi_private->dev,
+ dev_err(ssi->dev,
"Timeout waiting TX FIFO filling\n");
}
}
@@ -572,17 +570,17 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,
}


-static void fsl_ssi_rx_config(struct fsl_ssi_private *ssi_private, bool enable)
+static void fsl_ssi_rx_config(struct fsl_ssi *ssi, bool enable)
{
- fsl_ssi_config(ssi_private, enable, &ssi_private->rxtx_reg_val.rx);
+ fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.rx);
}

-static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi_private *ssi_private)
+static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi)
{
- struct regmap *regs = ssi_private->regs;
+ struct regmap *regs = ssi->regs;

/* no SACC{ST,EN,DIS} regs on imx21-class SSI */
- if (!ssi_private->soc->imx21regs) {
+ if (!ssi->soc->imx21regs) {
/*
* Note that these below aren't just normal registers.
* They are a way to disable or enable bits in SACCST
@@ -601,7 +599,7 @@ static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi_private *ssi_private)
}
}

-static void fsl_ssi_tx_config(struct fsl_ssi_private *ssi_private, bool enable)
+static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable)
{
/*
* Why are we setting up SACCST everytime we are starting a
@@ -622,10 +620,10 @@ static void fsl_ssi_tx_config(struct fsl_ssi_private *ssi_private, bool enable)
* untrustworthy let's play safe here and make sure that no extra
* slots are enabled every time a playback is started.
*/
- if (enable && fsl_ssi_is_ac97(ssi_private))
- fsl_ssi_tx_ac97_saccst_setup(ssi_private);
+ if (enable && fsl_ssi_is_ac97(ssi))
+ fsl_ssi_tx_ac97_saccst_setup(ssi);

- fsl_ssi_config(ssi_private, enable, &ssi_private->rxtx_reg_val.tx);
+ fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.tx);
}

/*
@@ -633,9 +631,9 @@ static void fsl_ssi_tx_config(struct fsl_ssi_private *ssi_private, bool enable)
* be used later in fsl_ssi_config to setup the streams without the need to
* check for all different SSI modes.
*/
-static void fsl_ssi_setup_reg_vals(struct fsl_ssi_private *ssi_private)
+static void fsl_ssi_setup_reg_vals(struct fsl_ssi *ssi)
{
- struct fsl_ssi_rxtx_reg_val *reg = &ssi_private->rxtx_reg_val;
+ struct fsl_ssi_rxtx_reg_val *reg = &ssi->rxtx_reg_val;

reg->rx.sier = CCSR_SSI_SIER_RFF0_EN;
reg->rx.srcr = CCSR_SSI_SRCR_RFEN0;
@@ -644,12 +642,12 @@ static void fsl_ssi_setup_reg_vals(struct fsl_ssi_private *ssi_private)
reg->tx.stcr = CCSR_SSI_STCR_TFEN0;
reg->tx.scr = 0;

- if (!fsl_ssi_is_ac97(ssi_private)) {
+ if (!fsl_ssi_is_ac97(ssi)) {
reg->rx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE;
reg->tx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE;
}

- if (ssi_private->use_dma) {
+ if (ssi->use_dma) {
reg->rx.sier |= CCSR_SSI_SIER_RDMAE;
reg->tx.sier |= CCSR_SSI_SIER_TDMAE;
} else {
@@ -661,9 +659,9 @@ static void fsl_ssi_setup_reg_vals(struct fsl_ssi_private *ssi_private)
reg->tx.sier |= FSLSSI_SIER_DBG_TX_FLAGS;
}

-static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private)
+static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi)
{
- struct regmap *regs = ssi_private->regs;
+ struct regmap *regs = ssi->regs;

/*
* Setup the clock control register
@@ -702,11 +700,10 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct fsl_ssi_private *ssi_private =
- snd_soc_dai_get_drvdata(rtd->cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
int ret;

- ret = clk_prepare_enable(ssi_private->clk);
+ ret = clk_prepare_enable(ssi->clk);
if (ret)
return ret;

@@ -715,7 +712,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
* task from fifo0, fifo1 would be neglected at the end of each
* period. But SSI would still access fifo1 with an invalid data.
*/
- if (ssi_private->use_dual_fifo)
+ if (ssi->use_dual_fifo)
snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2);

@@ -730,10 +727,9 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct fsl_ssi_private *ssi_private =
- snd_soc_dai_get_drvdata(rtd->cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);

- clk_disable_unprepare(ssi_private->clk);
+ clk_disable_unprepare(ssi->clk);

}

@@ -750,9 +746,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai,
struct snd_pcm_hw_params *hw_params)
{
- struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
- struct regmap *regs = ssi_private->regs;
- int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret;
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct regmap *regs = ssi->regs;
+ int synchronous = ssi->cpu_dai_drv.symmetric_rates, ret;
u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i;
unsigned long clkrate, baudrate, tmprate;
unsigned int slots = params_channels(hw_params);
@@ -762,29 +758,29 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
bool baudclk_is_used;

/* Override slots and slot_width if being specifically set... */
- if (ssi_private->slots)
- slots = ssi_private->slots;
+ if (ssi->slots)
+ slots = ssi->slots;
/* ...but keep 32 bits if slots is 2 -- I2S Master mode */
- if (ssi_private->slot_width && slots != 2)
- slot_width = ssi_private->slot_width;
+ if (ssi->slot_width && slots != 2)
+ slot_width = ssi->slot_width;

/* Generate bit clock based on the slot number and slot width */
freq = slots * slot_width * params_rate(hw_params);

/* Don't apply it to any non-baudclk circumstance */
- if (IS_ERR(ssi_private->baudclk))
+ if (IS_ERR(ssi->baudclk))
return -EINVAL;

/*
* Hardware limitation: The bclk rate must be
* never greater than 1/5 IPG clock rate
*/
- if (freq * 5 > clk_get_rate(ssi_private->clk)) {
+ if (freq * 5 > clk_get_rate(ssi->clk)) {
dev_err(cpu_dai->dev, "bitclk > ipgclk/5\n");
return -EINVAL;
}

- baudclk_is_used = ssi_private->baudclk_streams & ~(BIT(substream->stream));
+ baudclk_is_used = ssi->baudclk_streams & ~(BIT(substream->stream));

/* It should be already enough to divide clock by setting pm alone */
psr = 0;
@@ -796,9 +792,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
tmprate = freq * factor * (i + 1);

if (baudclk_is_used)
- clkrate = clk_get_rate(ssi_private->baudclk);
+ clkrate = clk_get_rate(ssi->baudclk);
else
- clkrate = clk_round_rate(ssi_private->baudclk, tmprate);
+ clkrate = clk_round_rate(ssi->baudclk, tmprate);

clkrate /= factor;
afreq = clkrate / (i + 1);
@@ -844,7 +840,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
regmap_update_bits(regs, CCSR_SSI_SRCCR, mask, stccr);

if (!baudclk_is_used) {
- ret = clk_set_rate(ssi_private->baudclk, baudrate);
+ ret = clk_set_rate(ssi->baudclk, baudrate);
if (ret) {
dev_err(cpu_dai->dev, "failed to set baudclk rate\n");
return -EINVAL;
@@ -870,8 +866,8 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
{
- struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
- struct regmap *regs = ssi_private->regs;
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct regmap *regs = ssi->regs;
unsigned int channels = params_channels(hw_params);
unsigned int sample_size = params_width(hw_params);
u32 wl = CCSR_SSI_SxCCR_WL(sample_size);
@@ -886,35 +882,35 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
* If we're in synchronous mode, and the SSI is already enabled,
* then STCCR is already set properly.
*/
- if (enabled && ssi_private->cpu_dai_drv.symmetric_rates)
+ if (enabled && ssi->cpu_dai_drv.symmetric_rates)
return 0;

- if (fsl_ssi_is_i2s_master(ssi_private)) {
+ if (fsl_ssi_is_i2s_master(ssi)) {
ret = fsl_ssi_set_bclk(substream, cpu_dai, hw_params);
if (ret)
return ret;

/* Do not enable the clock if it is already enabled */
- if (!(ssi_private->baudclk_streams & BIT(substream->stream))) {
- ret = clk_prepare_enable(ssi_private->baudclk);
+ if (!(ssi->baudclk_streams & BIT(substream->stream))) {
+ ret = clk_prepare_enable(ssi->baudclk);
if (ret)
return ret;

- ssi_private->baudclk_streams |= BIT(substream->stream);
+ ssi->baudclk_streams |= BIT(substream->stream);
}
}

- if (!fsl_ssi_is_ac97(ssi_private)) {
+ if (!fsl_ssi_is_ac97(ssi)) {
u8 i2smode;
/*
* Switch to normal net mode in order to have a frame sync
* signal every 32 bits instead of 16 bits
*/
- if (fsl_ssi_is_i2s_cbm_cfs(ssi_private) && sample_size == 16)
+ if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
i2smode = CCSR_SSI_SCR_I2S_MODE_NORMAL |
CCSR_SSI_SCR_NET;
else
- i2smode = ssi_private->i2s_mode;
+ i2smode = ssi->i2s_mode;

regmap_update_bits(regs, CCSR_SSI_SCR,
CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK,
@@ -933,7 +929,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,

/* In synchronous mode, the SSI uses STCCR for capture */
if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
- ssi_private->cpu_dai_drv.symmetric_rates)
+ ssi->cpu_dai_drv.symmetric_rates)
regmap_update_bits(regs, CCSR_SSI_STCCR, CCSR_SSI_SxCCR_WL_MASK,
wl);
else
@@ -947,34 +943,32 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct fsl_ssi_private *ssi_private =
- snd_soc_dai_get_drvdata(rtd->cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);

- if (fsl_ssi_is_i2s_master(ssi_private) &&
- ssi_private->baudclk_streams & BIT(substream->stream)) {
- clk_disable_unprepare(ssi_private->baudclk);
- ssi_private->baudclk_streams &= ~BIT(substream->stream);
+ if (fsl_ssi_is_i2s_master(ssi) &&
+ ssi->baudclk_streams & BIT(substream->stream)) {
+ clk_disable_unprepare(ssi->baudclk);
+ ssi->baudclk_streams &= ~BIT(substream->stream);
}

return 0;
}

static int _fsl_ssi_set_dai_fmt(struct device *dev,
- struct fsl_ssi_private *ssi_private,
- unsigned int fmt)
+ struct fsl_ssi *ssi, unsigned int fmt)
{
- struct regmap *regs = ssi_private->regs;
+ struct regmap *regs = ssi->regs;
u32 strcr = 0, stcr, srcr, scr, mask;
u8 wm;

- ssi_private->dai_fmt = fmt;
+ ssi->dai_fmt = fmt;

- if (fsl_ssi_is_i2s_master(ssi_private) && IS_ERR(ssi_private->baudclk)) {
+ if (fsl_ssi_is_i2s_master(ssi) && IS_ERR(ssi->baudclk)) {
dev_err(dev, "baudclk is missing which is necessary for master mode\n");
return -EINVAL;
}

- fsl_ssi_setup_reg_vals(ssi_private);
+ fsl_ssi_setup_reg_vals(ssi);

regmap_read(regs, CCSR_SSI_SCR, &scr);
scr &= ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK);
@@ -988,7 +982,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
stcr &= ~mask;
srcr &= ~mask;

- ssi_private->i2s_mode = CCSR_SSI_SCR_NET;
+ ssi->i2s_mode = CCSR_SSI_SCR_NET;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
regmap_update_bits(regs, CCSR_SSI_STCCR,
@@ -1000,10 +994,10 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFS:
case SND_SOC_DAIFMT_CBS_CFS:
- ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_MASTER;
+ ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_MASTER;
break;
case SND_SOC_DAIFMT_CBM_CFM:
- ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_SLAVE;
+ ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_SLAVE;
break;
default:
return -EINVAL;
@@ -1028,12 +1022,12 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
CCSR_SSI_STCR_TXBIT0;
break;
case SND_SOC_DAIFMT_AC97:
- ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_NORMAL;
+ ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_NORMAL;
break;
default:
return -EINVAL;
}
- scr |= ssi_private->i2s_mode;
+ scr |= ssi->i2s_mode;

/* DAI clock inversion */
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -1072,15 +1066,14 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr &= ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
default:
- if (!fsl_ssi_is_ac97(ssi_private))
+ if (!fsl_ssi_is_ac97(ssi))
return -EINVAL;
}

stcr |= strcr;
srcr |= strcr;

- if (ssi_private->cpu_dai_drv.symmetric_rates
- || fsl_ssi_is_ac97(ssi_private)) {
+ if (ssi->cpu_dai_drv.symmetric_rates || fsl_ssi_is_ac97(ssi)) {
/* Need to clear RXDIR when using SYNC or AC97 mode */
srcr &= ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
@@ -1090,13 +1083,13 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
regmap_write(regs, CCSR_SSI_SRCR, srcr);
regmap_write(regs, CCSR_SSI_SCR, scr);

- wm = ssi_private->fifo_watermark;
+ wm = ssi->fifo_watermark;

regmap_write(regs, CCSR_SSI_SFCSR,
CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm));

- if (ssi_private->use_dual_fifo) {
+ if (ssi->use_dual_fifo) {
regmap_update_bits(regs, CCSR_SSI_SRCR, CCSR_SSI_SRCR_RFEN1,
CCSR_SSI_SRCR_RFEN1);
regmap_update_bits(regs, CCSR_SSI_STCR, CCSR_SSI_STCR_TFEN1,
@@ -1106,7 +1099,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
}

if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97)
- fsl_ssi_setup_ac97(ssi_private);
+ fsl_ssi_setup_ac97(ssi);

return 0;

@@ -1117,12 +1110,12 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
*/
static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
{
- struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);

- if (fsl_ssi_is_ac97(ssi_private))
+ if (fsl_ssi_is_ac97(ssi))
return 0;

- return _fsl_ssi_set_dai_fmt(cpu_dai->dev, ssi_private, fmt);
+ return _fsl_ssi_set_dai_fmt(cpu_dai->dev, ssi, fmt);
}

/**
@@ -1133,8 +1126,8 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
u32 rx_mask, int slots, int slot_width)
{
- struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
- struct regmap *regs = ssi_private->regs;
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
+ struct regmap *regs = ssi->regs;
u32 val;

/* The word length should be 8, 10, 12, 16, 18, 20, 22 or 24 */
@@ -1169,8 +1162,8 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,

regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val);

- ssi_private->slot_width = slot_width;
- ssi_private->slots = slots;
+ ssi->slot_width = slot_width;
+ ssi->slots = slots;

return 0;
}
@@ -1188,33 +1181,33 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai);
- struct regmap *regs = ssi_private->regs;
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+ struct regmap *regs = ssi->regs;

switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- fsl_ssi_tx_config(ssi_private, true);
+ fsl_ssi_tx_config(ssi, true);
else
- fsl_ssi_rx_config(ssi_private, true);
+ fsl_ssi_rx_config(ssi, true);
break;

case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- fsl_ssi_tx_config(ssi_private, false);
+ fsl_ssi_tx_config(ssi, false);
else
- fsl_ssi_rx_config(ssi_private, false);
+ fsl_ssi_rx_config(ssi, false);
break;

default:
return -EINVAL;
}

- if (fsl_ssi_is_ac97(ssi_private)) {
+ if (fsl_ssi_is_ac97(ssi)) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_TX_CLR);
else
@@ -1226,11 +1219,11 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,

static int fsl_ssi_dai_probe(struct snd_soc_dai *dai)
{
- struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai);
+ struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai);

- if (ssi_private->soc->imx && ssi_private->use_dma) {
- dai->playback_dma_data = &ssi_private->dma_params_tx;
- dai->capture_dma_data = &ssi_private->dma_params_rx;
+ if (ssi->soc->imx && ssi->use_dma) {
+ dai->playback_dma_data = &ssi->dma_params_tx;
+ dai->capture_dma_data = &ssi->dma_params_rx;
}

return 0;
@@ -1292,7 +1285,7 @@ static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
};


-static struct fsl_ssi_private *fsl_ac97_data;
+static struct fsl_ssi *fsl_ac97_data;

static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
unsigned short val)
@@ -1383,24 +1376,24 @@ static void make_lowercase(char *s)
}

static int fsl_ssi_imx_probe(struct platform_device *pdev,
- struct fsl_ssi_private *ssi_private, void __iomem *iomem)
+ struct fsl_ssi *ssi, void __iomem *iomem)
{
struct device_node *np = pdev->dev.of_node;
u32 dmas[4];
int ret;

- if (ssi_private->has_ipg_clk_name)
- ssi_private->clk = devm_clk_get(&pdev->dev, "ipg");
+ if (ssi->has_ipg_clk_name)
+ ssi->clk = devm_clk_get(&pdev->dev, "ipg");
else
- ssi_private->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(ssi_private->clk)) {
- ret = PTR_ERR(ssi_private->clk);
+ ssi->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(ssi->clk)) {
+ ret = PTR_ERR(ssi->clk);
dev_err(&pdev->dev, "could not get clock: %d\n", ret);
return ret;
}

- if (!ssi_private->has_ipg_clk_name) {
- ret = clk_prepare_enable(ssi_private->clk);
+ if (!ssi->has_ipg_clk_name) {
+ ret = clk_prepare_enable(ssi->clk);
if (ret) {
dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n", ret);
return ret;
@@ -1410,27 +1403,27 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
/* For those SLAVE implementations, we ignore non-baudclk cases
* and, instead, abandon MASTER mode that needs baud clock.
*/
- ssi_private->baudclk = devm_clk_get(&pdev->dev, "baud");
- if (IS_ERR(ssi_private->baudclk))
+ ssi->baudclk = devm_clk_get(&pdev->dev, "baud");
+ if (IS_ERR(ssi->baudclk))
dev_dbg(&pdev->dev, "could not get baud clock: %ld\n",
- PTR_ERR(ssi_private->baudclk));
+ PTR_ERR(ssi->baudclk));

- ssi_private->dma_params_tx.maxburst = ssi_private->dma_maxburst;
- ssi_private->dma_params_rx.maxburst = ssi_private->dma_maxburst;
- ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0;
- ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0;
+ ssi->dma_params_tx.maxburst = ssi->dma_maxburst;
+ ssi->dma_params_rx.maxburst = ssi->dma_maxburst;
+ ssi->dma_params_tx.addr = ssi->ssi_phys + CCSR_SSI_STX0;
+ ssi->dma_params_rx.addr = ssi->ssi_phys + CCSR_SSI_SRX0;

ret = of_property_read_u32_array(np, "dmas", dmas, 4);
- if (ssi_private->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) {
- ssi_private->use_dual_fifo = true;
+ if (ssi->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) {
+ ssi->use_dual_fifo = true;
/* When using dual fifo mode, we need to keep watermark
* as even numbers due to dma script limitation.
*/
- ssi_private->dma_params_tx.maxburst &= ~0x1;
- ssi_private->dma_params_rx.maxburst &= ~0x1;
+ ssi->dma_params_tx.maxburst &= ~0x1;
+ ssi->dma_params_rx.maxburst &= ~0x1;
}

- if (!ssi_private->use_dma) {
+ if (!ssi->use_dma) {

/*
* Some boards use an incompatible codec. To get it
@@ -1439,14 +1432,12 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
* situation.
*/

- ssi_private->fiq_params.irq = ssi_private->irq;
- ssi_private->fiq_params.base = iomem;
- ssi_private->fiq_params.dma_params_rx =
- &ssi_private->dma_params_rx;
- ssi_private->fiq_params.dma_params_tx =
- &ssi_private->dma_params_tx;
+ ssi->fiq_params.irq = ssi->irq;
+ ssi->fiq_params.base = iomem;
+ ssi->fiq_params.dma_params_rx = &ssi->dma_params_rx;
+ ssi->fiq_params.dma_params_tx = &ssi->dma_params_tx;

- ret = imx_pcm_fiq_init(pdev, &ssi_private->fiq_params);
+ ret = imx_pcm_fiq_init(pdev, &ssi->fiq_params);
if (ret)
goto error_pcm;
} else {
@@ -1459,23 +1450,23 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,

error_pcm:

- if (!ssi_private->has_ipg_clk_name)
- clk_disable_unprepare(ssi_private->clk);
+ if (!ssi->has_ipg_clk_name)
+ clk_disable_unprepare(ssi->clk);
return ret;
}

static void fsl_ssi_imx_clean(struct platform_device *pdev,
- struct fsl_ssi_private *ssi_private)
+ struct fsl_ssi *ssi)
{
- if (!ssi_private->use_dma)
+ if (!ssi->use_dma)
imx_pcm_fiq_exit(pdev);
- if (!ssi_private->has_ipg_clk_name)
- clk_disable_unprepare(ssi_private->clk);
+ if (!ssi->has_ipg_clk_name)
+ clk_disable_unprepare(ssi->clk);
}

static int fsl_ssi_probe(struct platform_device *pdev)
{
- struct fsl_ssi_private *ssi_private;
+ struct fsl_ssi *ssi;
int ret = 0;
struct device_node *np = pdev->dev.of_node;
const struct of_device_id *of_id;
@@ -1490,42 +1481,41 @@ static int fsl_ssi_probe(struct platform_device *pdev)
if (!of_id || !of_id->data)
return -EINVAL;

- ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private),
+ ssi = devm_kzalloc(&pdev->dev, sizeof(*ssi),
GFP_KERNEL);
- if (!ssi_private)
+ if (!ssi)
return -ENOMEM;

- ssi_private->soc = of_id->data;
- ssi_private->dev = &pdev->dev;
+ ssi->soc = of_id->data;
+ ssi->dev = &pdev->dev;

sprop = of_get_property(np, "fsl,mode", NULL);
if (sprop) {
if (!strcmp(sprop, "ac97-slave"))
- ssi_private->dai_fmt = SND_SOC_DAIFMT_AC97;
+ ssi->dai_fmt = SND_SOC_DAIFMT_AC97;
}

- ssi_private->use_dma = !of_property_read_bool(np,
- "fsl,fiq-stream-filter");
+ ssi->use_dma = !of_property_read_bool(np, "fsl,fiq-stream-filter");

- if (fsl_ssi_is_ac97(ssi_private)) {
- memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai,
+ if (fsl_ssi_is_ac97(ssi)) {
+ memcpy(&ssi->cpu_dai_drv, &fsl_ssi_ac97_dai,
sizeof(fsl_ssi_ac97_dai));

- fsl_ac97_data = ssi_private;
+ fsl_ac97_data = ssi;
} else {
/* Initialize this copy of the CPU DAI driver structure */
- memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template,
+ memcpy(&ssi->cpu_dai_drv, &fsl_ssi_dai_template,
sizeof(fsl_ssi_dai_template));
}
- ssi_private->cpu_dai_drv.name = dev_name(&pdev->dev);
+ ssi->cpu_dai_drv.name = dev_name(&pdev->dev);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
iomem = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(iomem))
return PTR_ERR(iomem);
- ssi_private->ssi_phys = res->start;
+ ssi->ssi_phys = res->start;

- if (ssi_private->soc->imx21regs) {
+ if (ssi->soc->imx21regs) {
/*
* According to datasheet imx21-class SSI
* don't have SACC{ST,EN,DIS} regs.
@@ -1537,42 +1527,42 @@ static int fsl_ssi_probe(struct platform_device *pdev)

ret = of_property_match_string(np, "clock-names", "ipg");
if (ret < 0) {
- ssi_private->has_ipg_clk_name = false;
- ssi_private->regs = devm_regmap_init_mmio(&pdev->dev, iomem,
+ ssi->has_ipg_clk_name = false;
+ ssi->regs = devm_regmap_init_mmio(&pdev->dev, iomem,
&regconfig);
} else {
- ssi_private->has_ipg_clk_name = true;
- ssi_private->regs = devm_regmap_init_mmio_clk(&pdev->dev,
+ ssi->has_ipg_clk_name = true;
+ ssi->regs = devm_regmap_init_mmio_clk(&pdev->dev,
"ipg", iomem, &regconfig);
}
- if (IS_ERR(ssi_private->regs)) {
+ if (IS_ERR(ssi->regs)) {
dev_err(&pdev->dev, "Failed to init register map\n");
- return PTR_ERR(ssi_private->regs);
+ return PTR_ERR(ssi->regs);
}

- ssi_private->irq = platform_get_irq(pdev, 0);
- if (ssi_private->irq < 0) {
+ ssi->irq = platform_get_irq(pdev, 0);
+ if (ssi->irq < 0) {
dev_err(&pdev->dev, "no irq for node %s\n", pdev->name);
- return ssi_private->irq;
+ return ssi->irq;
}

/* Are the RX and the TX clocks locked? */
if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) {
- if (!fsl_ssi_is_ac97(ssi_private)) {
- ssi_private->cpu_dai_drv.symmetric_rates = 1;
- ssi_private->cpu_dai_drv.symmetric_samplebits = 1;
+ if (!fsl_ssi_is_ac97(ssi)) {
+ ssi->cpu_dai_drv.symmetric_rates = 1;
+ ssi->cpu_dai_drv.symmetric_samplebits = 1;
}

- ssi_private->cpu_dai_drv.symmetric_channels = 1;
+ ssi->cpu_dai_drv.symmetric_channels = 1;
}

/* Determine the FIFO depth. */
iprop = of_get_property(np, "fsl,fifo-depth", NULL);
if (iprop)
- ssi_private->fifo_depth = be32_to_cpup(iprop);
+ ssi->fifo_depth = be32_to_cpup(iprop);
else
/* Older 8610 DTs didn't have the fifo-depth property */
- ssi_private->fifo_depth = 8;
+ ssi->fifo_depth = 8;

/*
* Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
@@ -1589,7 +1579,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
* fiq it is probably better to use the biggest possible watermark
* size.
*/
- switch (ssi_private->fifo_depth) {
+ switch (ssi->fifo_depth) {
case 15:
/*
* 2 samples is not enough when running at high data
@@ -1598,8 +1588,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
* for the DMA to fill the FIFO before it's over/under
* run.
*/
- ssi_private->fifo_watermark = 8;
- ssi_private->dma_maxburst = 8;
+ ssi->fifo_watermark = 8;
+ ssi->dma_maxburst = 8;
break;
case 8:
default:
@@ -1610,21 +1600,21 @@ static int fsl_ssi_probe(struct platform_device *pdev)
* I suspect this could be changed to be something to
* leave some more space in the fifo.
*/
- ssi_private->fifo_watermark = ssi_private->fifo_depth - 2;
- ssi_private->dma_maxburst = ssi_private->fifo_depth - 2;
+ ssi->fifo_watermark = ssi->fifo_depth - 2;
+ ssi->dma_maxburst = ssi->fifo_depth - 2;
break;
}

- dev_set_drvdata(&pdev->dev, ssi_private);
+ dev_set_drvdata(&pdev->dev, ssi);

- if (ssi_private->soc->imx) {
- ret = fsl_ssi_imx_probe(pdev, ssi_private, iomem);
+ if (ssi->soc->imx) {
+ ret = fsl_ssi_imx_probe(pdev, ssi, iomem);
if (ret)
return ret;
}

- if (fsl_ssi_is_ac97(ssi_private)) {
- mutex_init(&ssi_private->ac97_reg_lock);
+ if (fsl_ssi_is_ac97(ssi)) {
+ mutex_init(&ssi->ac97_reg_lock);
ret = snd_soc_set_ac97_ops_of_reset(&fsl_ssi_ac97_ops, pdev);
if (ret) {
dev_err(&pdev->dev, "could not set AC'97 ops\n");
@@ -1633,24 +1623,24 @@ static int fsl_ssi_probe(struct platform_device *pdev)
}

ret = devm_snd_soc_register_component(&pdev->dev, &fsl_ssi_component,
- &ssi_private->cpu_dai_drv, 1);
+ &ssi->cpu_dai_drv, 1);
if (ret) {
dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
goto error_asoc_register;
}

- if (ssi_private->use_dma) {
- ret = devm_request_irq(&pdev->dev, ssi_private->irq,
+ if (ssi->use_dma) {
+ ret = devm_request_irq(&pdev->dev, ssi->irq,
fsl_ssi_isr, 0, dev_name(&pdev->dev),
- ssi_private);
+ ssi);
if (ret < 0) {
dev_err(&pdev->dev, "could not claim irq %u\n",
- ssi_private->irq);
+ ssi->irq);
goto error_asoc_register;
}
}

- ret = fsl_ssi_debugfs_create(&ssi_private->dbg_stats, &pdev->dev);
+ ret = fsl_ssi_debugfs_create(&ssi->dbg_stats, &pdev->dev);
if (ret)
goto error_asoc_register;

@@ -1675,20 +1665,18 @@ static int fsl_ssi_probe(struct platform_device *pdev)
snprintf(name, sizeof(name), "snd-soc-%s", sprop);
make_lowercase(name);

- ssi_private->pdev =
- platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
- if (IS_ERR(ssi_private->pdev)) {
- ret = PTR_ERR(ssi_private->pdev);
+ ssi->pdev = platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
+ if (IS_ERR(ssi->pdev)) {
+ ret = PTR_ERR(ssi->pdev);
dev_err(&pdev->dev, "failed to register platform: %d\n", ret);
goto error_sound_card;
}

done:
- if (ssi_private->dai_fmt)
- _fsl_ssi_set_dai_fmt(&pdev->dev, ssi_private,
- ssi_private->dai_fmt);
+ if (ssi->dai_fmt)
+ _fsl_ssi_set_dai_fmt(&pdev->dev, ssi, ssi->dai_fmt);

- if (fsl_ssi_is_ac97(ssi_private)) {
+ if (fsl_ssi_is_ac97(ssi)) {
u32 ssi_idx;

ret = of_property_read_u32(np, "cell-index", &ssi_idx);
@@ -1697,11 +1685,10 @@ static int fsl_ssi_probe(struct platform_device *pdev)
goto error_sound_card;
}

- ssi_private->pdev =
- platform_device_register_data(NULL,
+ ssi->pdev = platform_device_register_data(NULL,
"ac97-codec", ssi_idx, NULL, 0);
- if (IS_ERR(ssi_private->pdev)) {
- ret = PTR_ERR(ssi_private->pdev);
+ if (IS_ERR(ssi->pdev)) {
+ ret = PTR_ERR(ssi->pdev);
dev_err(&pdev->dev,
"failed to register AC97 codec platform: %d\n",
ret);
@@ -1712,37 +1699,37 @@ static int fsl_ssi_probe(struct platform_device *pdev)
return 0;

error_sound_card:
- fsl_ssi_debugfs_remove(&ssi_private->dbg_stats);
+ fsl_ssi_debugfs_remove(&ssi->dbg_stats);

error_asoc_register:
- if (fsl_ssi_is_ac97(ssi_private))
+ if (fsl_ssi_is_ac97(ssi))
snd_soc_set_ac97_ops(NULL);

error_ac97_ops:
- if (fsl_ssi_is_ac97(ssi_private))
- mutex_destroy(&ssi_private->ac97_reg_lock);
+ if (fsl_ssi_is_ac97(ssi))
+ mutex_destroy(&ssi->ac97_reg_lock);

- if (ssi_private->soc->imx)
- fsl_ssi_imx_clean(pdev, ssi_private);
+ if (ssi->soc->imx)
+ fsl_ssi_imx_clean(pdev, ssi);

return ret;
}

static int fsl_ssi_remove(struct platform_device *pdev)
{
- struct fsl_ssi_private *ssi_private = dev_get_drvdata(&pdev->dev);
+ struct fsl_ssi *ssi = dev_get_drvdata(&pdev->dev);

- fsl_ssi_debugfs_remove(&ssi_private->dbg_stats);
+ fsl_ssi_debugfs_remove(&ssi->dbg_stats);

- if (ssi_private->pdev)
- platform_device_unregister(ssi_private->pdev);
+ if (ssi->pdev)
+ platform_device_unregister(ssi->pdev);

- if (ssi_private->soc->imx)
- fsl_ssi_imx_clean(pdev, ssi_private);
+ if (ssi->soc->imx)
+ fsl_ssi_imx_clean(pdev, ssi);

- if (fsl_ssi_is_ac97(ssi_private)) {
+ if (fsl_ssi_is_ac97(ssi)) {
snd_soc_set_ac97_ops(NULL);
- mutex_destroy(&ssi_private->ac97_reg_lock);
+ mutex_destroy(&ssi->ac97_reg_lock);
}

return 0;
@@ -1751,13 +1738,11 @@ static int fsl_ssi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP
static int fsl_ssi_suspend(struct device *dev)
{
- struct fsl_ssi_private *ssi_private = dev_get_drvdata(dev);
- struct regmap *regs = ssi_private->regs;
+ struct fsl_ssi *ssi = dev_get_drvdata(dev);
+ struct regmap *regs = ssi->regs;

- regmap_read(regs, CCSR_SSI_SFCSR,
- &ssi_private->regcache_sfcsr);
- regmap_read(regs, CCSR_SSI_SACNT,
- &ssi_private->regcache_sacnt);
+ regmap_read(regs, CCSR_SSI_SFCSR, &ssi->regcache_sfcsr);
+ regmap_read(regs, CCSR_SSI_SACNT, &ssi->regcache_sacnt);

regcache_cache_only(regs, true);
regcache_mark_dirty(regs);
@@ -1767,17 +1752,16 @@ static int fsl_ssi_suspend(struct device *dev)

static int fsl_ssi_resume(struct device *dev)
{
- struct fsl_ssi_private *ssi_private = dev_get_drvdata(dev);
- struct regmap *regs = ssi_private->regs;
+ struct fsl_ssi *ssi = dev_get_drvdata(dev);
+ struct regmap *regs = ssi->regs;

regcache_cache_only(regs, false);

regmap_update_bits(regs, CCSR_SSI_SFCSR,
CCSR_SSI_SFCSR_RFWM1_MASK | CCSR_SSI_SFCSR_TFWM1_MASK |
CCSR_SSI_SFCSR_RFWM0_MASK | CCSR_SSI_SFCSR_TFWM0_MASK,
- ssi_private->regcache_sfcsr);
- regmap_write(regs, CCSR_SSI_SACNT,
- ssi_private->regcache_sacnt);
+ ssi->regcache_sfcsr);
+ regmap_write(regs, CCSR_SSI_SACNT, ssi->regcache_sacnt);

return regcache_sync(regs);
}
--
2.1.4

2017-12-13 23:20:54

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 05/11] ASoC: fsl_ssi: Refine indentations and wrappings

This patch just simply unifies the coding style.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 239 +++++++++++++++++++++-----------------------
sound/soc/fsl/fsl_ssi.h | 2 +-
sound/soc/fsl/fsl_ssi_dbg.c | 3 +-
3 files changed, 118 insertions(+), 126 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index ce6c945..a3b9116 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -69,21 +69,35 @@
* samples will be written to STX properly.
*/
#ifdef __BIG_ENDIAN
-#define FSLSSI_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | \
- SNDRV_PCM_FMTBIT_S18_3BE | SNDRV_PCM_FMTBIT_S20_3BE | \
- SNDRV_PCM_FMTBIT_S24_3BE | SNDRV_PCM_FMTBIT_S24_BE)
+#define FSLSSI_I2S_FORMATS \
+ (SNDRV_PCM_FMTBIT_S8 | \
+ SNDRV_PCM_FMTBIT_S16_BE | \
+ SNDRV_PCM_FMTBIT_S18_3BE | \
+ SNDRV_PCM_FMTBIT_S20_3BE | \
+ SNDRV_PCM_FMTBIT_S24_3BE | \
+ SNDRV_PCM_FMTBIT_S24_BE)
#else
-#define FSLSSI_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \
- SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S20_3LE | \
- SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE)
+#define FSLSSI_I2S_FORMATS \
+ (SNDRV_PCM_FMTBIT_S8 | \
+ SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_S18_3LE | \
+ SNDRV_PCM_FMTBIT_S20_3LE | \
+ SNDRV_PCM_FMTBIT_S24_3LE | \
+ SNDRV_PCM_FMTBIT_S24_LE)
#endif

-#define FSLSSI_SIER_DBG_RX_FLAGS (SSI_SIER_RFF0_EN | \
- SSI_SIER_RLS_EN | SSI_SIER_RFS_EN | \
- SSI_SIER_ROE0_EN | SSI_SIER_RFRC_EN)
-#define FSLSSI_SIER_DBG_TX_FLAGS (SSI_SIER_TFE0_EN | \
- SSI_SIER_TLS_EN | SSI_SIER_TFS_EN | \
- SSI_SIER_TUE0_EN | SSI_SIER_TFRC_EN)
+#define FSLSSI_SIER_DBG_RX_FLAGS \
+ (SSI_SIER_RFF0_EN | \
+ SSI_SIER_RLS_EN | \
+ SSI_SIER_RFS_EN | \
+ SSI_SIER_ROE0_EN | \
+ SSI_SIER_RFRC_EN)
+#define FSLSSI_SIER_DBG_TX_FLAGS \
+ (SSI_SIER_TFE0_EN | \
+ SSI_SIER_TLS_EN | \
+ SSI_SIER_TFS_EN | \
+ SSI_SIER_TUE0_EN | \
+ SSI_SIER_TFRC_EN)

enum fsl_ssi_type {
FSL_SSI_MCP8610,
@@ -291,8 +305,8 @@ static struct fsl_ssi_soc_data fsl_ssi_mpc8610 = {
.imx = false,
.offline_config = true,
.sisr_write_mask = SSI_SISR_RFRC | SSI_SISR_TFRC |
- SSI_SISR_ROE0 | SSI_SISR_ROE1 |
- SSI_SISR_TUE0 | SSI_SISR_TUE1,
+ SSI_SISR_ROE0 | SSI_SISR_ROE1 |
+ SSI_SISR_TUE0 | SSI_SISR_TUE1,
};

static struct fsl_ssi_soc_data fsl_ssi_imx21 = {
@@ -306,15 +320,15 @@ static struct fsl_ssi_soc_data fsl_ssi_imx35 = {
.imx = true,
.offline_config = true,
.sisr_write_mask = SSI_SISR_RFRC | SSI_SISR_TFRC |
- SSI_SISR_ROE0 | SSI_SISR_ROE1 |
- SSI_SISR_TUE0 | SSI_SISR_TUE1,
+ SSI_SISR_ROE0 | SSI_SISR_ROE1 |
+ SSI_SISR_TUE0 | SSI_SISR_TUE1,
};

static struct fsl_ssi_soc_data fsl_ssi_imx51 = {
.imx = true,
.offline_config = false,
.sisr_write_mask = SSI_SISR_ROE0 | SSI_SISR_ROE1 |
- SSI_SISR_TUE0 | SSI_SISR_TUE1,
+ SSI_SISR_TUE0 | SSI_SISR_TUE1,
};

static const struct of_device_id fsl_ssi_ids[] = {
@@ -373,21 +387,21 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)

if (enable) {
regmap_update_bits(regs, REG_SSI_SIER,
- vals->rx.sier | vals->tx.sier,
- vals->rx.sier | vals->tx.sier);
+ vals->rx.sier | vals->tx.sier,
+ vals->rx.sier | vals->tx.sier);
regmap_update_bits(regs, REG_SSI_SRCR,
- vals->rx.srcr | vals->tx.srcr,
- vals->rx.srcr | vals->tx.srcr);
+ vals->rx.srcr | vals->tx.srcr,
+ vals->rx.srcr | vals->tx.srcr);
regmap_update_bits(regs, REG_SSI_STCR,
- vals->rx.stcr | vals->tx.stcr,
- vals->rx.stcr | vals->tx.stcr);
+ vals->rx.stcr | vals->tx.stcr,
+ vals->rx.stcr | vals->tx.stcr);
} else {
regmap_update_bits(regs, REG_SSI_SRCR,
- vals->rx.srcr | vals->tx.srcr, 0);
+ vals->rx.srcr | vals->tx.srcr, 0);
regmap_update_bits(regs, REG_SSI_STCR,
- vals->rx.stcr | vals->tx.stcr, 0);
+ vals->rx.stcr | vals->tx.stcr, 0);
regmap_update_bits(regs, REG_SSI_SIER,
- vals->rx.sier | vals->tx.sier, 0);
+ vals->rx.sier | vals->tx.sier, 0);
}
}

@@ -398,10 +412,10 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
{
if (is_rx) {
regmap_update_bits(ssi->regs, REG_SSI_SOR,
- SSI_SOR_RX_CLR, SSI_SOR_RX_CLR);
+ SSI_SOR_RX_CLR, SSI_SOR_RX_CLR);
} else {
regmap_update_bits(ssi->regs, REG_SSI_SOR,
- SSI_SOR_TX_CLR, SSI_SOR_TX_CLR);
+ SSI_SOR_TX_CLR, SSI_SOR_TX_CLR);
}
}

@@ -429,7 +443,7 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
* Enable or disable SSI configuration.
*/
static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
- struct fsl_ssi_reg_val *vals)
+ struct fsl_ssi_reg_val *vals)
{
struct regmap *regs = ssi->regs;
struct fsl_ssi_reg_val *avals;
@@ -439,8 +453,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,

regmap_read(regs, REG_SSI_SCR, &scr_val);

- nr_active_streams = !!(scr_val & SSI_SCR_TE) +
- !!(scr_val & SSI_SCR_RE);
+ nr_active_streams = !!(scr_val & SSI_SCR_TE) + !!(scr_val & SSI_SCR_RE);

if (nr_active_streams - 1 > 0)
keep_active = 1;
@@ -456,7 +469,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
if (!enable) {
/* Exclude necessary bits for the opposite stream */
u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr,
- keep_active);
+ keep_active);
/* Safely disable SCR register for the stream */
regmap_update_bits(regs, REG_SSI_SCR, scr, 0);
}
@@ -466,8 +479,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
* Enable or Disable all necessary bits at once
*/
if (ssi->soc->offline_config) {
- if ((enable && !nr_active_streams) ||
- (!enable && !keep_active))
+ if ((enable && !nr_active_streams) || (!enable && !keep_active))
fsl_ssi_rxtx_config(ssi, enable);

goto config_done;
@@ -487,11 +499,11 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,

/* Exclude necessary bits for the opposite stream */
sier = fsl_ssi_disable_val(vals->sier, avals->sier,
- keep_active);
+ keep_active);
srcr = fsl_ssi_disable_val(vals->srcr, avals->srcr,
- keep_active);
+ keep_active);
stcr = fsl_ssi_disable_val(vals->stcr, avals->stcr,
- keep_active);
+ keep_active);

/* Safely disable other control registers for the stream */
regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0);
@@ -510,7 +522,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,

/* Enable SSI first to send TX DMA request */
regmap_update_bits(regs, REG_SSI_SCR,
- SSI_SCR_SSIEN, SSI_SCR_SSIEN);
+ SSI_SCR_SSIEN, SSI_SCR_SSIEN);

/* Wait until TX FIFO not empty -- DMA working */
for (i = 0; i < max_loop; i++) {
@@ -529,7 +541,6 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
}
}

-
static void fsl_ssi_rx_config(struct fsl_ssi *ssi, bool enable)
{
fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.rx);
@@ -600,19 +611,16 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi)
struct regmap *regs = ssi->regs;

/* Setup the clock control register */
- regmap_write(regs, REG_SSI_STCCR,
- SSI_SxCCR_WL(17) | SSI_SxCCR_DC(13));
- regmap_write(regs, REG_SSI_SRCCR,
- SSI_SxCCR_WL(17) | SSI_SxCCR_DC(13));
+ regmap_write(regs, REG_SSI_STCCR, SSI_SxCCR_WL(17) | SSI_SxCCR_DC(13));
+ regmap_write(regs, REG_SSI_SRCCR, SSI_SxCCR_WL(17) | SSI_SxCCR_DC(13));

/* Enable AC97 mode and startup the SSI */
- regmap_write(regs, REG_SSI_SACNT,
- SSI_SACNT_AC97EN | SSI_SACNT_FV);
+ regmap_write(regs, REG_SSI_SACNT, SSI_SACNT_AC97EN | SSI_SACNT_FV);

/* AC97 has to communicate with codec before starting a stream */
regmap_update_bits(regs, REG_SSI_SCR,
- SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE,
- SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE);
+ SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE,
+ SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE);

regmap_write(regs, REG_SSI_SOR, SSI_SOR_WAIT(3));
}
@@ -636,19 +644,18 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
*/
if (ssi->use_dual_fifo)
snd_pcm_hw_constraint_step(substream->runtime, 0,
- SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2);
+ SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2);

return 0;
}

static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
+ struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);

clk_disable_unprepare(ssi->clk);
-
}

/**
@@ -661,8 +668,8 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
* (In 2-channel I2S Master mode, slot_width is fixed 32)
*/
static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
- struct snd_soc_dai *cpu_dai,
- struct snd_pcm_hw_params *hw_params)
+ struct snd_soc_dai *cpu_dai,
+ struct snd_pcm_hw_params *hw_params)
{
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
struct regmap *regs = ssi->regs;
@@ -749,8 +756,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,

stccr = SSI_SxCCR_PM(pm + 1) | (div2 ? SSI_SxCCR_DIV2 : 0) |
(psr ? SSI_SxCCR_PSR : 0);
- mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 |
- SSI_SxCCR_PSR;
+ mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 | SSI_SxCCR_PSR;

if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || synchronous)
regmap_update_bits(regs, REG_SSI_STCCR, mask, stccr);
@@ -780,7 +786,8 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
* fsl_ssi_set_bclk() if SSI is the DAI clock master.
*/
static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
+ struct snd_pcm_hw_params *hw_params,
+ struct snd_soc_dai *cpu_dai)
{
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
struct regmap *regs = ssi->regs;
@@ -822,36 +829,33 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
u8 i2smode;
/* Normal + Network mode to send 16-bit data in 32-bit frames */
if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
- i2smode = SSI_SCR_I2S_MODE_NORMAL |
- SSI_SCR_NET;
+ i2smode = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET;
else
i2smode = ssi->i2s_mode;

regmap_update_bits(regs, REG_SSI_SCR,
- SSI_SCR_NET | SSI_SCR_I2S_MODE_MASK,
- channels == 1 ? 0 : i2smode);
+ SSI_SCR_NET | SSI_SCR_I2S_MODE_MASK,
+ channels == 1 ? 0 : i2smode);
}

/* In synchronous mode, the SSI uses STCCR for capture */
if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
ssi->cpu_dai_drv.symmetric_rates)
- regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_WL_MASK,
- wl);
+ regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_WL_MASK, wl);
else
- regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_WL_MASK,
- wl);
+ regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_WL_MASK, wl);

return 0;
}

static int fsl_ssi_hw_free(struct snd_pcm_substream *substream,
- struct snd_soc_dai *cpu_dai)
+ struct snd_soc_dai *cpu_dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai);

if (fsl_ssi_is_i2s_master(ssi) &&
- ssi->baudclk_streams & BIT(substream->stream)) {
+ ssi->baudclk_streams & BIT(substream->stream)) {
clk_disable_unprepare(ssi->baudclk);
ssi->baudclk_streams &= ~BIT(substream->stream);
}
@@ -881,8 +885,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr |= SSI_SCR_SYNC_TX_FS;

mask = SSI_STCR_TXBIT0 | SSI_STCR_TFDIR | SSI_STCR_TXDIR |
- SSI_STCR_TSCKP | SSI_STCR_TFSI | SSI_STCR_TFSL |
- SSI_STCR_TEFS;
+ SSI_STCR_TSCKP | SSI_STCR_TFSI | SSI_STCR_TFSL | SSI_STCR_TEFS;
regmap_read(regs, REG_SSI_STCR, &stcr);
regmap_read(regs, REG_SSI_SRCR, &srcr);
stcr &= ~mask;
@@ -893,11 +896,9 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
regmap_update_bits(regs, REG_SSI_STCCR,
- SSI_SxCCR_DC_MASK,
- SSI_SxCCR_DC(2));
+ SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2));
regmap_update_bits(regs, REG_SSI_SRCCR,
- SSI_SxCCR_DC_MASK,
- SSI_SxCCR_DC(2));
+ SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2));
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFS:
case SND_SOC_DAIFMT_CBS_CFS:
@@ -912,7 +913,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,

/* Data on rising edge of bclk, frame low, 1clk before data */
strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP |
- SSI_STCR_TXBIT0 | SSI_STCR_TEFS;
+ SSI_STCR_TXBIT0 | SSI_STCR_TEFS;
break;
case SND_SOC_DAIFMT_LEFT_J:
/* Data on rising edge of bclk, frame high */
@@ -921,12 +922,11 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
case SND_SOC_DAIFMT_DSP_A:
/* Data on rising edge of bclk, frame high, 1clk before data */
strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP |
- SSI_STCR_TXBIT0 | SSI_STCR_TEFS;
+ SSI_STCR_TXBIT0 | SSI_STCR_TEFS;
break;
case SND_SOC_DAIFMT_DSP_B:
/* Data on rising edge of bclk, frame high */
- strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP |
- SSI_STCR_TXBIT0;
+ strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP | SSI_STCR_TXBIT0;
break;
case SND_SOC_DAIFMT_AC97:
/* Data on falling edge of bclk, frame high, 1clk before data */
@@ -997,23 +997,22 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
wm = ssi->fifo_watermark;

regmap_write(regs, REG_SSI_SFCSR,
- SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) |
- SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm));
+ SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) |
+ SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm));

if (ssi->use_dual_fifo) {
- regmap_update_bits(regs, REG_SSI_SRCR, SSI_SRCR_RFEN1,
- SSI_SRCR_RFEN1);
- regmap_update_bits(regs, REG_SSI_STCR, SSI_STCR_TFEN1,
- SSI_STCR_TFEN1);
- regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_TCH_EN,
- SSI_SCR_TCH_EN);
+ regmap_update_bits(regs, REG_SSI_SRCR,
+ SSI_SRCR_RFEN1, SSI_SRCR_RFEN1);
+ regmap_update_bits(regs, REG_SSI_STCR,
+ SSI_STCR_TFEN1, SSI_STCR_TFEN1);
+ regmap_update_bits(regs, REG_SSI_SCR,
+ SSI_SCR_TCH_EN, SSI_SCR_TCH_EN);
}

if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97)
fsl_ssi_setup_ac97(ssi);

return 0;
-
}

/**
@@ -1034,7 +1033,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
* Set TDM slot number and slot width
*/
static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
- u32 rx_mask, int slots, int slot_width)
+ u32 rx_mask, int slots, int slot_width)
{
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);
struct regmap *regs = ssi->regs;
@@ -1054,17 +1053,16 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
return -EINVAL;
}

- regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_DC_MASK,
- SSI_SxCCR_DC(slots));
- regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_DC_MASK,
- SSI_SxCCR_DC(slots));
+ regmap_update_bits(regs, REG_SSI_STCCR,
+ SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots));
+ regmap_update_bits(regs, REG_SSI_SRCCR,
+ SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots));

/* Save SSIEN bit of the SCR register */
regmap_read(regs, REG_SSI_SCR, &val);
val &= SSI_SCR_SSIEN;
/* Temporarily enable SSI to allow SxMSKs to be configurable */
- regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_SSIEN,
- SSI_SCR_SSIEN);
+ regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_SSIEN, SSI_SCR_SSIEN);

regmap_write(regs, REG_SSI_STMSK, ~tx_mask);
regmap_write(regs, REG_SSI_SRMSK, ~rx_mask);
@@ -1135,13 +1133,13 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai)
}

static const struct snd_soc_dai_ops fsl_ssi_dai_ops = {
- .startup = fsl_ssi_startup,
- .shutdown = fsl_ssi_shutdown,
- .hw_params = fsl_ssi_hw_params,
- .hw_free = fsl_ssi_hw_free,
- .set_fmt = fsl_ssi_set_dai_fmt,
- .set_tdm_slot = fsl_ssi_set_dai_tdm_slot,
- .trigger = fsl_ssi_trigger,
+ .startup = fsl_ssi_startup,
+ .shutdown = fsl_ssi_shutdown,
+ .hw_params = fsl_ssi_hw_params,
+ .hw_free = fsl_ssi_hw_free,
+ .set_fmt = fsl_ssi_set_dai_fmt,
+ .set_tdm_slot = fsl_ssi_set_dai_tdm_slot,
+ .trigger = fsl_ssi_trigger,
};

static struct snd_soc_dai_driver fsl_ssi_dai_template = {
@@ -1164,7 +1162,7 @@ static struct snd_soc_dai_driver fsl_ssi_dai_template = {
};

static const struct snd_soc_component_driver fsl_ssi_component = {
- .name = "fsl-ssi",
+ .name = "fsl-ssi",
};

static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
@@ -1188,11 +1186,10 @@ static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
.ops = &fsl_ssi_dai_ops,
};

-
static struct fsl_ssi *fsl_ac97_data;

static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
- unsigned short val)
+ unsigned short val)
{
struct regmap *regs = fsl_ac97_data->regs;
unsigned int lreg;
@@ -1217,8 +1214,8 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
lval = val << 4;
regmap_write(regs, REG_SSI_SACDAT, lval);

- regmap_update_bits(regs, REG_SSI_SACNT, SSI_SACNT_RDWR_MASK,
- SSI_SACNT_WR);
+ regmap_update_bits(regs, REG_SSI_SACNT,
+ SSI_SACNT_RDWR_MASK, SSI_SACNT_WR);
udelay(100);

clk_disable_unprepare(fsl_ac97_data->clk);
@@ -1228,10 +1225,9 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
}

static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
- unsigned short reg)
+ unsigned short reg)
{
struct regmap *regs = fsl_ac97_data->regs;
-
unsigned short val = 0;
u32 reg_val;
unsigned int lreg;
@@ -1241,15 +1237,14 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,

ret = clk_prepare_enable(fsl_ac97_data->clk);
if (ret) {
- pr_err("ac97 read clk_prepare_enable failed: %d\n",
- ret);
+ pr_err("ac97 read clk_prepare_enable failed: %d\n", ret);
goto ret_unlock;
}

lreg = (reg & 0x7f) << 12;
regmap_write(regs, REG_SSI_SACADD, lreg);
- regmap_update_bits(regs, REG_SSI_SACNT, SSI_SACNT_RDWR_MASK,
- SSI_SACNT_RD);
+ regmap_update_bits(regs, REG_SSI_SACNT,
+ SSI_SACNT_RDWR_MASK, SSI_SACNT_RD);

udelay(100);

@@ -1264,8 +1259,8 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
}

static struct snd_ac97_bus_ops fsl_ssi_ac97_ops = {
- .read = fsl_ssi_ac97_read,
- .write = fsl_ssi_ac97_write,
+ .read = fsl_ssi_ac97_read,
+ .write = fsl_ssi_ac97_write,
};

/**
@@ -1280,7 +1275,7 @@ static void make_lowercase(char *s)
}

static int fsl_ssi_imx_probe(struct platform_device *pdev,
- struct fsl_ssi *ssi, void __iomem *iomem)
+ struct fsl_ssi *ssi, void __iomem *iomem)
{
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
@@ -1349,14 +1344,13 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
return 0;

error_pcm:
-
if (!ssi->has_ipg_clk_name)
clk_disable_unprepare(ssi->clk);
+
return ret;
}

-static void fsl_ssi_imx_clean(struct platform_device *pdev,
- struct fsl_ssi *ssi)
+static void fsl_ssi_imx_clean(struct platform_device *pdev, struct fsl_ssi *ssi)
{
if (!ssi->use_dma)
imx_pcm_fiq_exit(pdev);
@@ -1401,8 +1395,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)

if (fsl_ssi_is_ac97(ssi)) {
memcpy(&ssi->cpu_dai_drv, &fsl_ssi_ac97_dai,
- sizeof(fsl_ssi_ac97_dai));
-
+ sizeof(fsl_ssi_ac97_dai));
fsl_ac97_data = ssi;
} else {
memcpy(&ssi->cpu_dai_drv, &fsl_ssi_dai_template,
@@ -1554,8 +1547,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
goto error_sound_card;
}

- ssi->pdev = platform_device_register_data(NULL,
- "ac97-codec", ssi_idx, NULL, 0);
+ ssi->pdev = platform_device_register_data(NULL, "ac97-codec",
+ ssi_idx, NULL, 0);
if (IS_ERR(ssi->pdev)) {
ret = PTR_ERR(ssi->pdev);
dev_err(dev,
@@ -1569,11 +1562,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)

error_sound_card:
fsl_ssi_debugfs_remove(&ssi->dbg_stats);
-
error_asoc_register:
if (fsl_ssi_is_ac97(ssi))
snd_soc_set_ac97_ops(NULL);
-
error_ac97_ops:
if (fsl_ssi_is_ac97(ssi))
mutex_destroy(&ssi->ac97_reg_lock);
@@ -1627,9 +1618,9 @@ static int fsl_ssi_resume(struct device *dev)
regcache_cache_only(regs, false);

regmap_update_bits(regs, REG_SSI_SFCSR,
- SSI_SFCSR_RFWM1_MASK | SSI_SFCSR_TFWM1_MASK |
- SSI_SFCSR_RFWM0_MASK | SSI_SFCSR_TFWM0_MASK,
- ssi->regcache_sfcsr);
+ SSI_SFCSR_RFWM1_MASK | SSI_SFCSR_TFWM1_MASK |
+ SSI_SFCSR_RFWM0_MASK | SSI_SFCSR_TFWM0_MASK,
+ ssi->regcache_sfcsr);
regmap_write(regs, REG_SSI_SACNT, ssi->regcache_sacnt);

return regcache_sync(regs);
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index cdcf3d2..fe38e69 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -310,7 +310,7 @@ static inline void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *stats, u32 sisr)
}

static inline int fsl_ssi_debugfs_create(struct fsl_ssi_dbg *ssi_dbg,
- struct device *dev)
+ struct device *dev)
{
return 0;
}
diff --git a/sound/soc/fsl/fsl_ssi_dbg.c b/sound/soc/fsl/fsl_ssi_dbg.c
index 50b0cab..0dc71df 100644
--- a/sound/soc/fsl/fsl_ssi_dbg.c
+++ b/sound/soc/fsl/fsl_ssi_dbg.c
@@ -147,7 +147,8 @@ int fsl_ssi_debugfs_create(struct fsl_ssi_dbg *ssi_dbg, struct device *dev)
return -ENOMEM;

ssi_dbg->dbg_stats = debugfs_create_file("stats", S_IRUGO,
- ssi_dbg->dbg_dir, ssi_dbg, &fsl_ssi_stats_ops);
+ ssi_dbg->dbg_dir, ssi_dbg,
+ &fsl_ssi_stats_ops);
if (!ssi_dbg->dbg_stats) {
debugfs_remove(ssi_dbg->dbg_dir);
return -ENOMEM;
--
2.1.4

2017-12-13 23:20:53

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 06/11] ASoC: fsl_ssi: Refine printk outputs

This patches unifies the error message in the "failed to xxxx" format.

It also reduces the length of one line and adds spaces to an operator.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index a3b9116..7b6aedd 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -701,7 +701,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
* never greater than 1/5 IPG clock rate
*/
if (freq * 5 > clk_get_rate(ssi->clk)) {
- dev_err(cpu_dai->dev, "bitclk > ipgclk/5\n");
+ dev_err(cpu_dai->dev, "bitclk > ipgclk / 5\n");
return -EINVAL;
}

@@ -873,7 +873,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
ssi->dai_fmt = fmt;

if (fsl_ssi_is_i2s_master(ssi) && IS_ERR(ssi->baudclk)) {
- dev_err(dev, "baudclk is missing which is necessary for master mode\n");
+ dev_err(dev, "missing baudclk for master mode\n");
return -EINVAL;
}

@@ -1289,7 +1289,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
ssi->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ssi->clk)) {
ret = PTR_ERR(ssi->clk);
- dev_err(dev, "could not get clock: %d\n", ret);
+ dev_err(dev, "failed to get clock: %d\n", ret);
return ret;
}

@@ -1305,7 +1305,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
/* Do not error out for slave cases that live without a baud clock */
ssi->baudclk = devm_clk_get(dev, "baud");
if (IS_ERR(ssi->baudclk))
- dev_dbg(dev, "could not get baud clock: %ld\n",
+ dev_dbg(dev, "failed to get baud clock: %ld\n",
PTR_ERR(ssi->baudclk));

ssi->dma_params_tx.maxburst = ssi->dma_maxburst;
@@ -1426,7 +1426,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
&regconfig);
}
if (IS_ERR(ssi->regs)) {
- dev_err(dev, "Failed to init register map\n");
+ dev_err(dev, "failed to init register map\n");
return PTR_ERR(ssi->regs);
}

@@ -1485,7 +1485,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
mutex_init(&ssi->ac97_reg_lock);
ret = snd_soc_set_ac97_ops_of_reset(&fsl_ssi_ac97_ops, pdev);
if (ret) {
- dev_err(dev, "could not set AC'97 ops\n");
+ dev_err(dev, "failed to set AC'97 ops\n");
goto error_ac97_ops;
}
}
@@ -1501,7 +1501,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
ret = devm_request_irq(dev, ssi->irq, fsl_ssi_isr, 0,
dev_name(dev), ssi);
if (ret < 0) {
- dev_err(dev, "could not claim irq %u\n", ssi->irq);
+ dev_err(dev, "failed to claim irq %u\n", ssi->irq);
goto error_asoc_register;
}
}
@@ -1543,7 +1543,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)

ret = of_property_read_u32(np, "cell-index", &ssi_idx);
if (ret) {
- dev_err(dev, "cannot get SSI index property\n");
+ dev_err(dev, "failed to get SSI index property\n");
goto error_sound_card;
}

--
2.1.4

2017-12-13 23:21:23

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

This patch refines the comments by:
1) Removing all out-of-date comments
2) Removing all not-so-useful comments
3) Unifying the styles of all comments
4) Simplifying over-descriptive comments
5) Adding comments to improve code readablity
6) Moving all register related comments to fsl_ssi.h
7) Adding comments to all register and field defines

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---

Changelog
v2->v3
* Revised a comment in hw_params() by taking Maciej's advice
v1->v2
* Added some new comments at "SoC specific data" to be more precise
* Revised one comment in fsl_ssi_config()
* Revised the comment of fsl_ssi_setup_reg_vals()
* Added one comment for AC97 in fsl_ssi_setup_reg_vals()
* Revised the comment of fsl_ssi_hw_params() to be more precise
* Added some comments in _fsl_ssi_set_dai_fmt() to help understand
the formats
* Added one comment in fsl_ssi_set_dai_fmt() to explain why AC97
needs to bypass it
* Revised comments in fsl_ssi_set_dai_tdm_slot() to be more precise
* Revised comments around dual FIFO code in fsl_ssi_imx_probe() to
be more precise

sound/soc/fsl/fsl_ssi.c | 377 +++++++++++++++-----------------------------
sound/soc/fsl/fsl_ssi.h | 67 +++++++-
sound/soc/fsl/fsl_ssi_dbg.c | 12 +-
3 files changed, 191 insertions(+), 265 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index e903c92..fe11a23 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -187,42 +187,48 @@ struct fsl_ssi_soc_data {
/**
* fsl_ssi: per-SSI private data
*
- * @reg: Pointer to the regmap registers
+ * @regs: Pointer to the regmap registers
* @irq: IRQ of this SSI
* @cpu_dai_drv: CPU DAI driver for this device
*
* @dai_fmt: DAI configuration this device is currently used with
- * @i2s_mode: i2s and network mode configuration of the device. Is used to
- * switch between normal and i2s/network mode
- * mode depending on the number of channels
+ * @i2s_mode: I2S and Network mode configuration of SCR register
* @use_dma: DMA is used or FIQ with stream filter
- * @use_dual_fifo: DMA with support for both FIFOs used
- * @fifo_deph: Depth of the SSI FIFOs
- * @slot_width: width of each DAI slot
- * @slots: number of slots
- * @rxtx_reg_val: Specific register settings for receive/transmit configuration
+ * @use_dual_fifo: DMA with support for dual FIFO mode
+ * @has_ipg_clk_name: If "ipg" is in the clock name list of device tree
+ * @fifo_depth: Depth of the SSI FIFOs
+ * @slot_width: Width of each DAI slot
+ * @slots: Number of slots
+ * @rxtx_reg_val: Specific RX/TX register settings
*
- * @clk: SSI clock
- * @baudclk: SSI baud clock for master mode
+ * @clk: Clock source to access register
+ * @baudclk: Clock source to generate bit and frame-sync clocks
* @baudclk_streams: Active streams that are using baudclk
*
+ * @regcache_sfcsr: Cache sfcsr register value during suspend and resume
+ * @regcache_sacnt: Cache sacnt register value during suspend and resume
+ *
* @dma_params_tx: DMA transmit parameters
* @dma_params_rx: DMA receive parameters
* @ssi_phys: physical address of the SSI registers
*
* @fiq_params: FIQ stream filtering parameters
*
- * @pdev: Pointer to pdev used for deprecated fsl-ssi sound card
+ * @pdev: Pointer to pdev when using fsl-ssi as sound card (ppc only)
+ * TODO: Should be replaced with simple-sound-card
*
* @dbg_stats: Debugging statistics
*
* @soc: SoC specific data
+ * @dev: Pointer to &pdev->dev
+ *
+ * @fifo_watermark: The FIFO watermark setting. Notifies DMA when there are
+ * @fifo_watermark or fewer words in TX fifo or
+ * @fifo_watermark or more empty words in RX fifo.
+ * @dma_maxburst: Max number of words to transfer in one go. So far,
+ * this is always the same as fifo_watermark.
*
- * @fifo_watermark: the FIFO watermark setting. Notifies DMA when
- * there are @fifo_watermark or fewer words in TX fifo or
- * @fifo_watermark or more empty words in RX fifo.
- * @dma_maxburst: max number of words to transfer in one go. So far,
- * this is always the same as fifo_watermark.
+ * @ac97_reg_lock: Mutex lock to serialize AC97 register access operations
*/
struct fsl_ssi {
struct regmap *regs;
@@ -243,20 +249,15 @@ struct fsl_ssi {
struct clk *baudclk;
unsigned int baudclk_streams;

- /* regcache for volatile regs */
u32 regcache_sfcsr;
u32 regcache_sacnt;

- /* DMA params */
struct snd_dmaengine_dai_dma_data dma_params_tx;
struct snd_dmaengine_dai_dma_data dma_params_rx;
dma_addr_t ssi_phys;

- /* params for non-dma FIQ stream filtered mode */
struct imx_pcm_fiq_params fiq_params;

- /* Used when using fsl-ssi as sound-card. This is only used by ppc and
- * should be replaced with simple-sound-card. */
struct platform_device *pdev;

struct fsl_ssi_dbg dbg_stats;
@@ -271,19 +272,19 @@ struct fsl_ssi {
};

/*
- * imx51 and later SoCs have a slightly different IP that allows the
- * SSI configuration while the SSI unit is running.
- *
- * More important, it is necessary on those SoCs to configure the
- * sperate TX/RX DMA bits just before starting the stream
- * (fsl_ssi_trigger). The SDMA unit has to be configured before fsl_ssi
- * sends any DMA requests to the SDMA unit, otherwise it is not defined
- * how the SDMA unit handles the DMA request.
+ * SoC specific data
*
- * SDMA units are present on devices starting at imx35 but the imx35
- * reference manual states that the DMA bits should not be changed
- * while the SSI unit is running (SSIEN). So we support the necessary
- * online configuration of fsl-ssi starting at imx51.
+ * Notes:
+ * 1) SSI in earlier SoCS has crtical bits in control registers that
+ * cannot be changed after SSI starts running -- a software reset
+ * (set SSIEN to 0) is required to change their values. So adding
+ * an offline_config flag for these SoCs.
+ * 2) SDMA is available since imx35. However, imx35 does not support
+ * DMA bits changing when SSI is running, so set offline_config.
+ * 3) imx51 and later versions support register configurations when
+ * SSI is running (SSIEN); For these versions, DMA needs to be
+ * configured before SSI sends DMA request to avoid an undefined
+ * DMA request on the SDMA side.
*/

static struct fsl_ssi_soc_data fsl_ssi_mpc8610 = {
@@ -342,18 +343,7 @@ static bool fsl_ssi_is_i2s_cbm_cfs(struct fsl_ssi *ssi)
return (ssi->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
SND_SOC_DAIFMT_CBM_CFS;
}
-/**
- * fsl_ssi_isr: SSI interrupt handler
- *
- * Although it's possible to use the interrupt handler to send and receive
- * data to/from the SSI, we use the DMA instead. Programming is more
- * complicated, but the performance is much better.
- *
- * This interrupt handler is used only to gather statistics.
- *
- * @irq: IRQ of the SSI device
- * @dev_id: pointer to the fsl_ssi structure for this SSI device
- */
+
static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
{
struct fsl_ssi *ssi = dev_id;
@@ -361,10 +351,6 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
__be32 sisr;
__be32 sisr2;

- /* We got an interrupt, so read the status register to see what we
- were interrupted for. We mask it with the Interrupt Enable register
- so that we only check for events that we're interested in.
- */
regmap_read(regs, CCSR_SSI_SISR, &sisr);

sisr2 = sisr & ssi->soc->sisr_write_mask;
@@ -377,8 +363,8 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}

-/*
- * Enable/Disable all rx/tx config flags at once.
+/**
+ * Enable or disable all rx/tx config flags at once
*/
static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
{
@@ -405,13 +391,8 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
}
}

-/*
- * Clear RX or TX FIFO to remove samples from the previous
- * stream session which may be still present in the FIFO and
- * may introduce bad samples and/or channel slipping.
- *
- * Note: The SOR is not documented in recent IMX datasheet, but
- * is described in IMX51 reference manual at section 56.3.3.15.
+/**
+ * Clear remaining data in the FIFO to avoid dirty data or channel slipping
*/
static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
{
@@ -424,7 +405,7 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
}
}

-/*
+/**
* Calculate the bits that have to be disabled for the current stream that is
* getting disabled. This keeps the bits enabled that are necessary for the
* second stream to work if 'stream_active' is true.
@@ -444,9 +425,8 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
((vals_disable) & \
((vals_disable) ^ ((vals_stream) * (u32)!!(stream_active))))

-/*
- * Enable/Disable a ssi configuration. You have to pass either
- * ssi->rxtx_reg_val.rx or tx as vals parameter.
+/**
+ * Enable or disable SSI configuration.
*/
static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
struct fsl_ssi_reg_val *vals)
@@ -467,24 +447,23 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
else
keep_active = 0;

- /* Find the other direction values rx or tx which we do not want to
- * modify */
+ /* Get the opposite direction to keep its values untouched */
if (&ssi->rxtx_reg_val.rx == vals)
avals = &ssi->rxtx_reg_val.tx;
else
avals = &ssi->rxtx_reg_val.rx;

- /* If vals should be disabled, start with disabling the unit */
if (!enable) {
+ /* Exclude necessary bits for the opposite stream */
u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr,
keep_active);
+ /* Safely disable SCR register for the stream */
regmap_update_bits(regs, CCSR_SSI_SCR, scr, 0);
}

/*
- * We are running on a SoC which does not support online SSI
- * reconfiguration, so we have to enable all necessary flags at once
- * even if we do not use them later (capture and playback configuration)
+ * Online configuration is not supported
+ * Enable or Disable all necessary bits at once
*/
if (ssi->soc->offline_config) {
if ((enable && !nr_active_streams) ||
@@ -494,10 +473,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
goto config_done;
}

- /*
- * Configure single direction units while the SSI unit is running
- * (online configuration)
- */
+ /* Online configure single direction while SSI is running */
if (enable) {
fsl_ssi_fifo_clear(ssi, vals->scr & CCSR_SSI_SCR_RE);

@@ -509,16 +485,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
u32 srcr;
u32 stcr;

- /*
- * Disabling the necessary flags for one of rx/tx while the
- * other stream is active is a little bit more difficult. We
- * have to disable only those flags that differ between both
- * streams (rx XOR tx) and that are set in the stream that is
- * disabled now. Otherwise we could alter flags of the other
- * stream
- */
-
- /* These assignments are simply vals without bits set in avals*/
+ /* Exclude necessary bits for the opposite stream */
sier = fsl_ssi_disable_val(vals->sier, avals->sier,
keep_active);
srcr = fsl_ssi_disable_val(vals->srcr, avals->srcr,
@@ -526,6 +493,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
stcr = fsl_ssi_disable_val(vals->stcr, avals->stcr,
keep_active);

+ /* Safely disable other control registers for the stream */
regmap_update_bits(regs, CCSR_SSI_SRCR, srcr, 0);
regmap_update_bits(regs, CCSR_SSI_STCR, stcr, 0);
regmap_update_bits(regs, CCSR_SSI_SIER, sier, 0);
@@ -534,26 +502,17 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
config_done:
/* Enabling of subunits is done after configuration */
if (enable) {
+ /* Start DMA before setting TE to avoid underrun */
+ /* TODO: FIQ cases might also need this upon testing */
if (ssi->use_dma && (vals->scr & CCSR_SSI_SCR_TE)) {
- /*
- * Be sure the Tx FIFO is filled when TE is set.
- * Otherwise, there are some chances to start the
- * playback with some void samples inserted first,
- * generating a channel slip.
- *
- * First, SSIEN must be set, to let the FIFO be filled.
- *
- * Notes:
- * - Limit this fix to the DMA case until FIQ cases can
- * be tested.
- * - Limit the length of the busy loop to not lock the
- * system too long, even if 1-2 loops are sufficient
- * in general.
- */
int i;
int max_loop = 100;
+
+ /* Enable SSI first to send TX DMA request */
regmap_update_bits(regs, CCSR_SSI_SCR,
CCSR_SSI_SCR_SSIEN, CCSR_SSI_SCR_SSIEN);
+
+ /* Wait until TX FIFO not empty -- DMA working */
for (i = 0; i < max_loop; i++) {
u32 sfcsr;
regmap_read(regs, CCSR_SSI_SFCSR, &sfcsr);
@@ -565,6 +524,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
"Timeout waiting TX FIFO filling\n");
}
}
+ /* Enable all remaining bits */
regmap_update_bits(regs, CCSR_SSI_SCR, vals->scr, vals->scr);
}
}
@@ -581,20 +541,9 @@ static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi)

/* no SACC{ST,EN,DIS} regs on imx21-class SSI */
if (!ssi->soc->imx21regs) {
- /*
- * Note that these below aren't just normal registers.
- * They are a way to disable or enable bits in SACCST
- * register:
- * - writing a '1' bit at some position in SACCEN sets the
- * relevant bit in SACCST,
- * - writing a '1' bit at some position in SACCDIS unsets
- * the relevant bit in SACCST register.
- *
- * The two writes below first disable all channels slots,
- * then enable just slots 3 & 4 ("PCM Playback Left Channel"
- * and "PCM Playback Right Channel").
- */
+ /* Disable all channel slots */
regmap_write(regs, CCSR_SSI_SACCDIS, 0xff);
+ /* Enable slots 3 & 4 -- PCM Playback Left & Right channels */
regmap_write(regs, CCSR_SSI_SACCEN, 0x300);
}
}
@@ -602,23 +551,11 @@ static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi)
static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable)
{
/*
- * Why are we setting up SACCST everytime we are starting a
- * playback?
- * Some CODECs (like VT1613 CODEC on UDOO board) like to
- * (sometimes) set extra bits in their SLOTREQ requests.
- * When a bit is set in a SLOTREQ request then SSI sets the
- * relevant bit in SACCST automatically (it is enough if a bit was
- * set in a SLOTREQ just once, bits in SACCST are 'sticky').
- * If an extra slot gets enabled that's a disaster for playback
- * because some of normal left or right channel samples are
- * redirected instead to this extra slot.
+ * SACCST might be modified via AC Link by a CODEC if it sends
+ * extra bits in their SLOTREQ requests, which'll accidentally
+ * send valid data to slots other than normal playback slots.
*
- * A workaround implemented in fsl-asoc-card of setting an
- * appropriate CODEC register so that slots 3 & 4 (the normal
- * stereo playback slots) are used for S/PDIF seems to mostly fix
- * this issue on the UDOO board but since this CODEC is so
- * untrustworthy let's play safe here and make sure that no extra
- * slots are enabled every time a playback is started.
+ * To be safe, configure SACCST right before TX starts.
*/
if (enable && fsl_ssi_is_ac97(ssi))
fsl_ssi_tx_ac97_saccst_setup(ssi);
@@ -626,10 +563,8 @@ static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable)
fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.tx);
}

-/*
- * Setup rx/tx register values used to enable/disable the streams. These will
- * be used later in fsl_ssi_config to setup the streams without the need to
- * check for all different SSI modes.
+/**
+ * Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely
*/
static void fsl_ssi_setup_reg_vals(struct fsl_ssi *ssi)
{
@@ -642,6 +577,7 @@ static void fsl_ssi_setup_reg_vals(struct fsl_ssi *ssi)
reg->tx.stcr = CCSR_SSI_STCR_TFEN0;
reg->tx.scr = 0;

+ /* AC97 has already enabled SSIEN, RE and TE, so ignore them */
if (!fsl_ssi_is_ac97(ssi)) {
reg->rx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE;
reg->tx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE;
@@ -663,24 +599,17 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi)
{
struct regmap *regs = ssi->regs;

- /*
- * Setup the clock control register
- */
+ /* Setup the clock control register */
regmap_write(regs, CCSR_SSI_STCCR,
CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13));
regmap_write(regs, CCSR_SSI_SRCCR,
CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13));

- /*
- * Enable AC97 mode and startup the SSI
- */
+ /* Enable AC97 mode and startup the SSI */
regmap_write(regs, CCSR_SSI_SACNT,
CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV);

- /*
- * Enable SSI, Transmit and Receive. AC97 has to communicate with the
- * codec before a stream is started.
- */
+ /* AC97 has to communicate with codec before starting a stream */
regmap_update_bits(regs, CCSR_SSI_SCR,
CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE,
CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE);
@@ -688,14 +617,6 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi)
regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_WAIT(3));
}

-/**
- * fsl_ssi_startup: create a new substream
- *
- * This is the first function called when a stream is opened.
- *
- * If this is the first stream open, then grab the IRQ and program most of
- * the SSI registers.
- */
static int fsl_ssi_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -707,7 +628,8 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
if (ret)
return ret;

- /* When using dual fifo mode, it is safer to ensure an even period
+ /*
+ * When using dual fifo mode, it is safer to ensure an even period
* size. If appearing to an odd number while DMA always starts its
* task from fifo0, fifo1 would be neglected at the end of each
* period. But SSI would still access fifo1 with an invalid data.
@@ -719,10 +641,6 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
return 0;
}

-/**
- * fsl_ssi_shutdown: shutdown the SSI
- *
- */
static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -734,7 +652,7 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
}

/**
- * fsl_ssi_set_bclk - configure Digital Audio Interface bit clock
+ * Configure Digital Audio Interface bit clock
*
* Note: This function can be only called when using SSI as DAI master
*
@@ -851,17 +769,15 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
}

/**
- * fsl_ssi_hw_params - program the sample size
+ * Configure SSI based on PCM hardware parameters
*
- * Most of the SSI registers have been programmed in the startup function,
- * but the word length must be programmed here. Unfortunately, programming
- * the SxCCR.WL bits requires the SSI to be temporarily disabled. This can
- * cause a problem with supporting simultaneous playback and capture. If
- * the SSI is already playing a stream, then that stream may be temporarily
- * stopped when you start capture.
- *
- * Note: The SxCCR.DC and SxCCR.PM bits are only used if the SSI is the
- * clock master.
+ * Notes:
+ * 1) SxCCR.WL bits are critical bits that require SSI to be temporarily
+ * disabled on offline_config SoCs. Even for online configurable SoCs
+ * running in synchronous mode (both TX and RX use STCCR), it is not
+ * safe to re-configure them when both two streams start running.
+ * 2) SxCCR.PM, SxCCR.DIV2 and SxCCR.PSR bits will be configured in the
+ * fsl_ssi_set_bclk() if SSI is the DAI clock master.
*/
static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
@@ -879,8 +795,10 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
enabled = scr_val & CCSR_SSI_SCR_SSIEN;

/*
- * If we're in synchronous mode, and the SSI is already enabled,
- * then STCCR is already set properly.
+ * SSI is properly configured if it is enabled and running in
+ * the synchronous mode; Note that AC97 mode is an exception
+ * that should set separate configurations for STCCR and SRCCR
+ * despite running in the synchronous mode.
*/
if (enabled && ssi->cpu_dai_drv.symmetric_rates)
return 0;
@@ -902,10 +820,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,

if (!fsl_ssi_is_ac97(ssi)) {
u8 i2smode;
- /*
- * Switch to normal net mode in order to have a frame sync
- * signal every 32 bits instead of 16 bits
- */
+ /* Normal + Network mode to send 16-bit data in 32-bit frames */
if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
i2smode = CCSR_SSI_SCR_I2S_MODE_NORMAL |
CCSR_SSI_SCR_NET;
@@ -917,16 +832,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
channels == 1 ? 0 : i2smode);
}

- /*
- * FIXME: The documentation says that SxCCR[WL] should not be
- * modified while the SSI is enabled. The only time this can
- * happen is if we're trying to do simultaneous playback and
- * capture in asynchronous mode. Unfortunately, I have been enable
- * to get that to work at all on the P1022DS. Therefore, we don't
- * bother to disable/enable the SSI when setting SxCCR[WL], because
- * the SSI will stop anyway. Maybe one day, this will get fixed.
- */
-
/* In synchronous mode, the SSI uses STCCR for capture */
if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
ssi->cpu_dai_drv.symmetric_rates)
@@ -972,6 +877,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,

regmap_read(regs, CCSR_SSI_SCR, &scr);
scr &= ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK);
+ /* Synchronize frame sync clock for TE to avoid data slipping */
scr |= CCSR_SSI_SCR_SYNC_TX_FS;

mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR |
@@ -982,6 +888,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
stcr &= ~mask;
srcr &= ~mask;

+ /* Use Network mode as default */
ssi->i2s_mode = CCSR_SSI_SCR_NET;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
@@ -1022,6 +929,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
CCSR_SSI_STCR_TXBIT0;
break;
case SND_SOC_DAIFMT_AC97:
+ /* Data on falling edge of bclk, frame high, 1clk before data */
ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_NORMAL;
break;
default:
@@ -1054,13 +962,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
/* DAI clock master masks */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
+ /* Output bit and frame sync clocks */
strcr |= CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR;
scr |= CCSR_SSI_SCR_SYS_CLK_EN;
break;
case SND_SOC_DAIFMT_CBM_CFM:
+ /* Input bit or frame sync clocks */
scr &= ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
case SND_SOC_DAIFMT_CBM_CFS:
+ /* Input bit clock but output frame sync clock */
strcr &= ~CCSR_SSI_STCR_TXDIR;
strcr |= CCSR_SSI_STCR_TFDIR;
scr &= ~CCSR_SSI_SCR_SYS_CLK_EN;
@@ -1073,8 +984,8 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
stcr |= strcr;
srcr |= strcr;

+ /* Set SYN mode and clear RXDIR bit when using SYN or AC97 mode */
if (ssi->cpu_dai_drv.symmetric_rates || fsl_ssi_is_ac97(ssi)) {
- /* Need to clear RXDIR when using SYNC or AC97 mode */
srcr &= ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
}
@@ -1106,12 +1017,13 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
}

/**
- * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
+ * Configure Digital Audio Interface (DAI) Format
*/
static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
{
struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(cpu_dai);

+ /* AC97 configured DAIFMT earlier in the probe() */
if (fsl_ssi_is_ac97(ssi))
return 0;

@@ -1119,9 +1031,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
}

/**
- * fsl_ssi_set_dai_tdm_slot - set TDM slot number
- *
- * Note: This function can be only called when using SSI as DAI master
+ * Set TDM slot number and slot width
*/
static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
u32 rx_mask, int slots, int slot_width)
@@ -1149,17 +1059,17 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
regmap_update_bits(regs, CCSR_SSI_SRCCR, CCSR_SSI_SxCCR_DC_MASK,
CCSR_SSI_SxCCR_DC(slots));

- /* The register SxMSKs needs SSI to provide essential clock due to
- * hardware design. So we here temporarily enable SSI to set them.
- */
+ /* Save SSIEN bit of the SCR register */
regmap_read(regs, CCSR_SSI_SCR, &val);
val &= CCSR_SSI_SCR_SSIEN;
+ /* Temporarily enable SSI to allow SxMSKs to be configurable */
regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN,
CCSR_SSI_SCR_SSIEN);

regmap_write(regs, CCSR_SSI_STMSK, ~tx_mask);
regmap_write(regs, CCSR_SSI_SRMSK, ~rx_mask);

+ /* Restore the value of SSIEN bit */
regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val);

ssi->slot_width = slot_width;
@@ -1169,13 +1079,7 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
}

/**
- * fsl_ssi_trigger: start and stop the DMA transfer.
- *
- * This function is called by ALSA to start, stop, pause, and resume the DMA
- * transfer of data.
- *
- * The DMA channel is in external master start and pause mode, which
- * means the SSI completely controls the flow of data.
+ * Start or stop SSI and corresponding DMA transaction.
*/
static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
@@ -1207,6 +1111,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
return -EINVAL;
}

+ /* Clear corresponding FIFO */
if (fsl_ssi_is_ac97(ssi)) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_TX_CLR);
@@ -1239,7 +1144,6 @@ static const struct snd_soc_dai_ops fsl_ssi_dai_ops = {
.trigger = fsl_ssi_trigger,
};

-/* Template for the CPU dai driver structure */
static struct snd_soc_dai_driver fsl_ssi_dai_template = {
.probe = fsl_ssi_dai_probe,
.playback = {
@@ -1383,6 +1287,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
u32 dmas[4];
int ret;

+ /* Backward compatible for a DT without ipg clock name assigned */
if (ssi->has_ipg_clk_name)
ssi->clk = devm_clk_get(dev, "ipg");
else
@@ -1393,6 +1298,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
return ret;
}

+ /* Enable the clock since regmap will not handle it in this case */
if (!ssi->has_ipg_clk_name) {
ret = clk_prepare_enable(ssi->clk);
if (ret) {
@@ -1401,9 +1307,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
}
}

- /* For those SLAVE implementations, we ignore non-baudclk cases
- * and, instead, abandon MASTER mode that needs baud clock.
- */
+ /* Do not error out for slave cases that live without a baud clock */
ssi->baudclk = devm_clk_get(dev, "baud");
if (IS_ERR(ssi->baudclk))
dev_dbg(dev, "could not get baud clock: %ld\n",
@@ -1414,25 +1318,20 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
ssi->dma_params_tx.addr = ssi->ssi_phys + CCSR_SSI_STX0;
ssi->dma_params_rx.addr = ssi->ssi_phys + CCSR_SSI_SRX0;

+ /* Set to dual FIFO mode according to the SDMA sciprt */
ret = of_property_read_u32_array(np, "dmas", dmas, 4);
if (ssi->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) {
ssi->use_dual_fifo = true;
- /* When using dual fifo mode, we need to keep watermark
- * as even numbers due to dma script limitation.
+ /*
+ * Use even numbers to avoid channel swap due to SDMA
+ * script design
*/
ssi->dma_params_tx.maxburst &= ~0x1;
ssi->dma_params_rx.maxburst &= ~0x1;
}

if (!ssi->use_dma) {
-
- /*
- * Some boards use an incompatible codec. To get it
- * working, we are using imx-fiq-pcm-audio, that
- * can handle those codecs. DMA is not possible in this
- * situation.
- */
-
+ /* Use imx-fiq-pcm-audio for codec incompatible with DMA */
ssi->fiq_params.irq = ssi->irq;
ssi->fiq_params.base = iomem;
ssi->fiq_params.dma_params_rx = &ssi->dma_params_rx;
@@ -1490,12 +1389,14 @@ static int fsl_ssi_probe(struct platform_device *pdev)
ssi->soc = of_id->data;
ssi->dev = dev;

+ /* Check if being used in AC97 mode */
sprop = of_get_property(np, "fsl,mode", NULL);
if (sprop) {
if (!strcmp(sprop, "ac97-slave"))
ssi->dai_fmt = SND_SOC_DAIFMT_AC97;
}

+ /* Select DMA or FIQ */
ssi->use_dma = !of_property_read_bool(np, "fsl,fiq-stream-filter");

if (fsl_ssi_is_ac97(ssi)) {
@@ -1504,7 +1405,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)

fsl_ac97_data = ssi;
} else {
- /* Initialize this copy of the CPU DAI driver structure */
memcpy(&ssi->cpu_dai_drv, &fsl_ssi_dai_template,
sizeof(fsl_ssi_dai_template));
}
@@ -1517,10 +1417,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
ssi->ssi_phys = res->start;

if (ssi->soc->imx21regs) {
- /*
- * According to datasheet imx21-class SSI
- * don't have SACC{ST,EN,DIS} regs.
- */
+ /* No SACC{ST,EN,DIS} regs in imx21-class SSI */
regconfig.max_register = CCSR_SSI_SRMSK;
regconfig.num_reg_defaults_raw =
CCSR_SSI_SRMSK / sizeof(uint32_t) + 1;
@@ -1546,7 +1443,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
return ssi->irq;
}

- /* Are the RX and the TX clocks locked? */
+ /* Set software limitations for synchronous mode */
if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) {
if (!fsl_ssi_is_ac97(ssi)) {
ssi->cpu_dai_drv.symmetric_rates = 1;
@@ -1556,50 +1453,28 @@ static int fsl_ssi_probe(struct platform_device *pdev)
ssi->cpu_dai_drv.symmetric_channels = 1;
}

- /* Determine the FIFO depth. */
+ /* Fetch FIFO depth; Set to 8 for older DT without this property */
iprop = of_get_property(np, "fsl,fifo-depth", NULL);
if (iprop)
ssi->fifo_depth = be32_to_cpup(iprop);
else
- /* Older 8610 DTs didn't have the fifo-depth property */
ssi->fifo_depth = 8;

/*
- * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
- * use FIFO 1 but set the watermark appropriately nontheless.
- * We program the transmit water to signal a DMA transfer
- * if there are N elements left in the FIFO. For chips with 15-deep
- * FIFOs, set watermark to 8. This allows the SSI to operate at a
- * high data rate without channel slipping. Behavior is unchanged
- * for the older chips with a fifo depth of only 8. A value of 4
- * might be appropriate for the older chips, but is left at
- * fifo_depth-2 until sombody has a chance to test.
+ * Configure TX and RX DMA watermarks.
*
- * We set the watermark on the same level as the DMA burstsize. For
- * fiq it is probably better to use the biggest possible watermark
- * size.
+ * Values should be tested to avoid FIFO under/over run. Set maxburst
+ * to fifo_watermark to maxiumize DMA transaction to reduce overhead.
*/
switch (ssi->fifo_depth) {
case 15:
- /*
- * 2 samples is not enough when running at high data
- * rates (like 48kHz @ 16 bits/channel, 16 channels)
- * 8 seems to split things evenly and leave enough time
- * for the DMA to fill the FIFO before it's over/under
- * run.
- */
+ /* Tested with cases running at 48kHz @ 16 bits x 16 channels */
ssi->fifo_watermark = 8;
ssi->dma_maxburst = 8;
break;
case 8:
default:
- /*
- * maintain old behavior for older chips.
- * Keeping it the same because I don't have an older
- * board to test with.
- * I suspect this could be changed to be something to
- * leave some more space in the fifo.
- */
+ /* Use old watermark configurations for older chips */
ssi->fifo_watermark = ssi->fifo_depth - 2;
ssi->dma_maxburst = ssi->fifo_depth - 2;
break;
@@ -1642,18 +1517,14 @@ static int fsl_ssi_probe(struct platform_device *pdev)
if (ret)
goto error_asoc_register;

- /*
- * If codec-handle property is missing from SSI node, we assume
- * that the machine driver uses new binding which does not require
- * SSI driver to trigger machine driver's probe.
- */
+ /* Bypass it if using newer DT bindings of ASoC machine drivers */
if (!of_get_property(np, "codec-handle", NULL))
goto done;

- /* Trigger the machine driver's probe function. The platform driver
- * name of the machine driver is taken from /compatible property of the
- * device tree. We also pass the address of the CPU DAI driver
- * structure.
+ /*
+ * Backward compatible for older bindings by manually triggering the
+ * machine driver's probe(). Use /compatible property, including the
+ * address of CPU DAI driver structure, as the name of machine driver.
*/
sprop = of_get_property(of_find_node_by_path("/"), "compatible", NULL);
/* Sometimes the compatible name has a "fsl," prefix, so we strip it. */
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index 5065105..1ad3bde 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -1,5 +1,5 @@
/*
- * fsl_ssi.h - ALSA SSI interface for the Freescale MPC8610 SoC
+ * fsl_ssi.h - ALSA SSI interface for the Freescale MPC8610 and i.MX SoC
*
* Author: Timur Tabi <[email protected]>
*
@@ -12,31 +12,75 @@
#ifndef _MPC8610_I2S_H
#define _MPC8610_I2S_H

-/* SSI registers */
+/* -- SSI Register Map -- */
+
+/* SSI Transmit Data Register 0 */
#define CCSR_SSI_STX0 0x00
+/* SSI Transmit Data Register 1 */
#define CCSR_SSI_STX1 0x04
+/* SSI Receive Data Register 0 */
#define CCSR_SSI_SRX0 0x08
+/* SSI Receive Data Register 1 */
#define CCSR_SSI_SRX1 0x0c
+/* SSI Control Register */
#define CCSR_SSI_SCR 0x10
+/* SSI Interrupt Status Register */
#define CCSR_SSI_SISR 0x14
+/* SSI Interrupt Enable Register */
#define CCSR_SSI_SIER 0x18
+/* SSI Transmit Configuration Register */
#define CCSR_SSI_STCR 0x1c
+/* SSI Receive Configuration Register */
#define CCSR_SSI_SRCR 0x20
+/* SSI Transmit Clock Control Register */
#define CCSR_SSI_STCCR 0x24
+/* SSI Receive Clock Control Register */
#define CCSR_SSI_SRCCR 0x28
+/* SSI FIFO Control/Status Register */
#define CCSR_SSI_SFCSR 0x2c
+/*
+ * SSI Test Register (Intended for debugging purposes only)
+ *
+ * Note: STR is not documented in recent IMX datasheet, but
+ * is described in IMX51 reference manual at section 56.3.3.14
+ */
#define CCSR_SSI_STR 0x30
+/*
+ * SSI Option Register (Intended for internal use only)
+ *
+ * Note: SOR is not documented in recent IMX datasheet, but
+ * is described in IMX51 reference manual at section 56.3.3.15
+ */
#define CCSR_SSI_SOR 0x34
+/* SSI AC97 Control Register */
#define CCSR_SSI_SACNT 0x38
+/* SSI AC97 Command Address Register */
#define CCSR_SSI_SACADD 0x3c
+/* SSI AC97 Command Data Register */
#define CCSR_SSI_SACDAT 0x40
+/* SSI AC97 Tag Register */
#define CCSR_SSI_SATAG 0x44
+/* SSI Transmit Time Slot Mask Register */
#define CCSR_SSI_STMSK 0x48
+/* SSI Receive Time Slot Mask Register */
#define CCSR_SSI_SRMSK 0x4c
+/*
+ * SSI AC97 Channel Status Register
+ *
+ * The status could be changed by:
+ * 1) Writing a '1' bit at some position in SACCEN sets relevant bit in SACCST
+ * 2) Writing a '1' bit at some position in SACCDIS unsets the relevant bit
+ * 3) Receivng a '1' in SLOTREQ bit from external CODEC via AC Link
+ */
#define CCSR_SSI_SACCST 0x50
+/* SSI AC97 Channel Enable Register -- Set bits in SACCST */
#define CCSR_SSI_SACCEN 0x54
+/* SSI AC97 Channel Disable Register -- Clear bits in SACCST */
#define CCSR_SSI_SACCDIS 0x58

+/* -- SSI Register Field Maps -- */
+
+/* SSI Control Register -- CCSR_SSI_SCR 0x10 */
#define CCSR_SSI_SCR_SYNC_TX_FS 0x00001000
#define CCSR_SSI_SCR_RFR_CLK_DIS 0x00000800
#define CCSR_SSI_SCR_TFR_CLK_DIS 0x00000400
@@ -52,6 +96,7 @@
#define CCSR_SSI_SCR_TE 0x00000002
#define CCSR_SSI_SCR_SSIEN 0x00000001

+/* SSI Interrupt Status Register -- CCSR_SSI_SISR 0x14 */
#define CCSR_SSI_SISR_RFRC 0x01000000
#define CCSR_SSI_SISR_TFRC 0x00800000
#define CCSR_SSI_SISR_CMDAU 0x00040000
@@ -74,6 +119,7 @@
#define CCSR_SSI_SISR_TFE1 0x00000002
#define CCSR_SSI_SISR_TFE0 0x00000001

+/* SSI Interrupt Enable Register -- CCSR_SSI_SIER 0x18 */
#define CCSR_SSI_SIER_RFRC_EN 0x01000000
#define CCSR_SSI_SIER_TFRC_EN 0x00800000
#define CCSR_SSI_SIER_RDMAE 0x00400000
@@ -100,6 +146,7 @@
#define CCSR_SSI_SIER_TFE1_EN 0x00000002
#define CCSR_SSI_SIER_TFE0_EN 0x00000001

+/* SSI Transmit Configuration Register -- CCSR_SSI_STCR 0x1C */
#define CCSR_SSI_STCR_TXBIT0 0x00000200
#define CCSR_SSI_STCR_TFEN1 0x00000100
#define CCSR_SSI_STCR_TFEN0 0x00000080
@@ -111,6 +158,7 @@
#define CCSR_SSI_STCR_TFSL 0x00000002
#define CCSR_SSI_STCR_TEFS 0x00000001

+/* SSI Receive Configuration Register -- CCSR_SSI_SRCR 0x20 */
#define CCSR_SSI_SRCR_RXEXT 0x00000400
#define CCSR_SSI_SRCR_RXBIT0 0x00000200
#define CCSR_SSI_SRCR_RFEN1 0x00000100
@@ -123,7 +171,10 @@
#define CCSR_SSI_SRCR_RFSL 0x00000002
#define CCSR_SSI_SRCR_REFS 0x00000001

-/* STCCR and SRCCR */
+/*
+ * SSI Transmit Clock Control Register -- CCSR_SSI_STCCR 0x24
+ * SSI Receive Clock Control Register -- CCSR_SSI_SRCCR 0x28
+ */
#define CCSR_SSI_SxCCR_DIV2_SHIFT 18
#define CCSR_SSI_SxCCR_DIV2 0x00040000
#define CCSR_SSI_SxCCR_PSR_SHIFT 17
@@ -142,9 +193,10 @@
((((x) - 1) << CCSR_SSI_SxCCR_PM_SHIFT) & CCSR_SSI_SxCCR_PM_MASK)

/*
- * The xFCNT bits are read-only, and the xFWM bits are read/write. Use the
- * CCSR_SSI_SFCSR_xFCNTy() macros to read the FIFO counters, and use the
- * CCSR_SSI_SFCSR_xFWMy() macros to set the watermarks.
+ * SSI FIFO Control/Status Register -- CCSR_SSI_SFCSR 0x2c
+ *
+ * Tx or Rx FIFO Counter -- CCSR_SSI_SFCSR_xFCNTy Read-Only
+ * Tx or Rx FIFO Watermarks -- CCSR_SSI_SFCSR_xFWMy Read/Write
*/
#define CCSR_SSI_SFCSR_RFCNT1_SHIFT 28
#define CCSR_SSI_SFCSR_RFCNT1_MASK 0xF0000000
@@ -179,6 +231,7 @@
#define CCSR_SSI_SFCSR_TFWM0(x) \
(((x) << CCSR_SSI_SFCSR_TFWM0_SHIFT) & CCSR_SSI_SFCSR_TFWM0_MASK)

+/* SSI Test Register -- CCSR_SSI_STR 0x30 */
#define CCSR_SSI_STR_TEST 0x00008000
#define CCSR_SSI_STR_RCK2TCK 0x00004000
#define CCSR_SSI_STR_RFS2TFS 0x00002000
@@ -188,6 +241,7 @@
#define CCSR_SSI_STR_TFS2RFS 0x00000020
#define CCSR_SSI_STR_TXSTATE(x) ((x) & 0x1F)

+/* SSI Option Register -- CCSR_SSI_SOR 0x34 */
#define CCSR_SSI_SOR_CLKOFF 0x00000040
#define CCSR_SSI_SOR_RX_CLR 0x00000020
#define CCSR_SSI_SOR_TX_CLR 0x00000010
@@ -197,6 +251,7 @@
#define CCSR_SSI_SOR_WAIT(x) (((x) & 3) << CCSR_SSI_SOR_WAIT_SHIFT)
#define CCSR_SSI_SOR_SYNRST 0x00000001

+/* SSI AC97 Control Register -- CCSR_SSI_SACNT 0x38 */
#define CCSR_SSI_SACNT_FRDIV(x) (((x) & 0x3f) << 5)
#define CCSR_SSI_SACNT_WR 0x00000010
#define CCSR_SSI_SACNT_RD 0x00000008
diff --git a/sound/soc/fsl/fsl_ssi_dbg.c b/sound/soc/fsl/fsl_ssi_dbg.c
index 5469ffb..9c7fa6c 100644
--- a/sound/soc/fsl/fsl_ssi_dbg.c
+++ b/sound/soc/fsl/fsl_ssi_dbg.c
@@ -82,9 +82,10 @@ void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *dbg, u32 sisr)
dbg->stats.tfe0++;
}

-/* Show the statistics of a flag only if its interrupt is enabled. The
- * compiler will optimze this code to a no-op if the interrupt is not
- * enabled.
+/**
+ * Show the statistics of a flag only if its interrupt is enabled
+ *
+ * Compilers will optimze it to a no-op if the interrupt is disabled
*/
#define SIER_SHOW(flag, name) \
do { \
@@ -94,10 +95,9 @@ void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *dbg, u32 sisr)


/**
- * fsl_sysfs_ssi_show: display SSI statistics
+ * Display the statistics for the current SSI device
*
- * Display the statistics for the current SSI device. To avoid confusion,
- * we only show those counts that are enabled.
+ * To avoid confusion, only show those counts that are enabled
*/
static int fsl_ssi_stats_show(struct seq_file *s, void *unused)
{
--
2.1.4

2017-12-13 23:21:21

by Nicolin Chen

[permalink] [raw]
Subject: [PATCH v3 04/11] ASoC: fsl_ssi: Rename registers and fields macros

This patch renames CCSR_SSI_xxx to REG_SSI_xxx and SSI_xxx_yyy style.
It also slightly reduces the length of them to save some space.

Signed-off-by: Nicolin Chen <[email protected]>
Tested-by: Maciej S. Szmigiero <[email protected]>
Reviewed-by: Maciej S. Szmigiero <[email protected]>
---
sound/soc/fsl/fsl_ssi.c | 374 +++++++++++++++++++++----------------------
sound/soc/fsl/fsl_ssi.h | 376 ++++++++++++++++++++++----------------------
sound/soc/fsl/fsl_ssi_dbg.c | 44 +++---
3 files changed, 397 insertions(+), 397 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index fe11a23..ce6c945 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -78,12 +78,12 @@
SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE)
#endif

-#define FSLSSI_SIER_DBG_RX_FLAGS (CCSR_SSI_SIER_RFF0_EN | \
- CCSR_SSI_SIER_RLS_EN | CCSR_SSI_SIER_RFS_EN | \
- CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_RFRC_EN)
-#define FSLSSI_SIER_DBG_TX_FLAGS (CCSR_SSI_SIER_TFE0_EN | \
- CCSR_SSI_SIER_TLS_EN | CCSR_SSI_SIER_TFS_EN | \
- CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TFRC_EN)
+#define FSLSSI_SIER_DBG_RX_FLAGS (SSI_SIER_RFF0_EN | \
+ SSI_SIER_RLS_EN | SSI_SIER_RFS_EN | \
+ SSI_SIER_ROE0_EN | SSI_SIER_RFRC_EN)
+#define FSLSSI_SIER_DBG_TX_FLAGS (SSI_SIER_TFE0_EN | \
+ SSI_SIER_TLS_EN | SSI_SIER_TFS_EN | \
+ SSI_SIER_TUE0_EN | SSI_SIER_TFRC_EN)

enum fsl_ssi_type {
FSL_SSI_MCP8610,
@@ -107,8 +107,8 @@ struct fsl_ssi_rxtx_reg_val {
static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
- case CCSR_SSI_SACCEN:
- case CCSR_SSI_SACCDIS:
+ case REG_SSI_SACCEN:
+ case REG_SSI_SACCDIS:
return false;
default:
return true;
@@ -118,18 +118,18 @@ static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg)
static bool fsl_ssi_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
- case CCSR_SSI_STX0:
- case CCSR_SSI_STX1:
- case CCSR_SSI_SRX0:
- case CCSR_SSI_SRX1:
- case CCSR_SSI_SISR:
- case CCSR_SSI_SFCSR:
- case CCSR_SSI_SACNT:
- case CCSR_SSI_SACADD:
- case CCSR_SSI_SACDAT:
- case CCSR_SSI_SATAG:
- case CCSR_SSI_SACCST:
- case CCSR_SSI_SOR:
+ case REG_SSI_STX0:
+ case REG_SSI_STX1:
+ case REG_SSI_SRX0:
+ case REG_SSI_SRX1:
+ case REG_SSI_SISR:
+ case REG_SSI_SFCSR:
+ case REG_SSI_SACNT:
+ case REG_SSI_SACADD:
+ case REG_SSI_SACDAT:
+ case REG_SSI_SATAG:
+ case REG_SSI_SACCST:
+ case REG_SSI_SOR:
return true;
default:
return false;
@@ -139,12 +139,12 @@ static bool fsl_ssi_volatile_reg(struct device *dev, unsigned int reg)
static bool fsl_ssi_precious_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
- case CCSR_SSI_SRX0:
- case CCSR_SSI_SRX1:
- case CCSR_SSI_SISR:
- case CCSR_SSI_SACADD:
- case CCSR_SSI_SACDAT:
- case CCSR_SSI_SATAG:
+ case REG_SSI_SRX0:
+ case REG_SSI_SRX1:
+ case REG_SSI_SISR:
+ case REG_SSI_SACADD:
+ case REG_SSI_SACDAT:
+ case REG_SSI_SATAG:
return true;
default:
return false;
@@ -154,9 +154,9 @@ static bool fsl_ssi_precious_reg(struct device *dev, unsigned int reg)
static bool fsl_ssi_writeable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
- case CCSR_SSI_SRX0:
- case CCSR_SSI_SRX1:
- case CCSR_SSI_SACCST:
+ case REG_SSI_SRX0:
+ case REG_SSI_SRX1:
+ case REG_SSI_SACCST:
return false;
default:
return true;
@@ -164,12 +164,12 @@ static bool fsl_ssi_writeable_reg(struct device *dev, unsigned int reg)
}

static const struct regmap_config fsl_ssi_regconfig = {
- .max_register = CCSR_SSI_SACCDIS,
+ .max_register = REG_SSI_SACCDIS,
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
.val_format_endian = REGMAP_ENDIAN_NATIVE,
- .num_reg_defaults_raw = CCSR_SSI_SACCDIS / sizeof(uint32_t) + 1,
+ .num_reg_defaults_raw = REG_SSI_SACCDIS / sizeof(uint32_t) + 1,
.readable_reg = fsl_ssi_readable_reg,
.volatile_reg = fsl_ssi_volatile_reg,
.precious_reg = fsl_ssi_precious_reg,
@@ -290,9 +290,9 @@ struct fsl_ssi {
static struct fsl_ssi_soc_data fsl_ssi_mpc8610 = {
.imx = false,
.offline_config = true,
- .sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC |
- CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 |
- CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1,
+ .sisr_write_mask = SSI_SISR_RFRC | SSI_SISR_TFRC |
+ SSI_SISR_ROE0 | SSI_SISR_ROE1 |
+ SSI_SISR_TUE0 | SSI_SISR_TUE1,
};

static struct fsl_ssi_soc_data fsl_ssi_imx21 = {
@@ -305,16 +305,16 @@ static struct fsl_ssi_soc_data fsl_ssi_imx21 = {
static struct fsl_ssi_soc_data fsl_ssi_imx35 = {
.imx = true,
.offline_config = true,
- .sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC |
- CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 |
- CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1,
+ .sisr_write_mask = SSI_SISR_RFRC | SSI_SISR_TFRC |
+ SSI_SISR_ROE0 | SSI_SISR_ROE1 |
+ SSI_SISR_TUE0 | SSI_SISR_TUE1,
};

static struct fsl_ssi_soc_data fsl_ssi_imx51 = {
.imx = true,
.offline_config = false,
- .sisr_write_mask = CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 |
- CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1,
+ .sisr_write_mask = SSI_SISR_ROE0 | SSI_SISR_ROE1 |
+ SSI_SISR_TUE0 | SSI_SISR_TUE1,
};

static const struct of_device_id fsl_ssi_ids[] = {
@@ -351,12 +351,12 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
__be32 sisr;
__be32 sisr2;

- regmap_read(regs, CCSR_SSI_SISR, &sisr);
+ regmap_read(regs, REG_SSI_SISR, &sisr);

sisr2 = sisr & ssi->soc->sisr_write_mask;
/* Clear the bits that we set */
if (sisr2)
- regmap_write(regs, CCSR_SSI_SISR, sisr2);
+ regmap_write(regs, REG_SSI_SISR, sisr2);

fsl_ssi_dbg_isr(&ssi->dbg_stats, sisr);

@@ -372,21 +372,21 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
struct fsl_ssi_rxtx_reg_val *vals = &ssi->rxtx_reg_val;

if (enable) {
- regmap_update_bits(regs, CCSR_SSI_SIER,
+ regmap_update_bits(regs, REG_SSI_SIER,
vals->rx.sier | vals->tx.sier,
vals->rx.sier | vals->tx.sier);
- regmap_update_bits(regs, CCSR_SSI_SRCR,
+ regmap_update_bits(regs, REG_SSI_SRCR,
vals->rx.srcr | vals->tx.srcr,
vals->rx.srcr | vals->tx.srcr);
- regmap_update_bits(regs, CCSR_SSI_STCR,
+ regmap_update_bits(regs, REG_SSI_STCR,
vals->rx.stcr | vals->tx.stcr,
vals->rx.stcr | vals->tx.stcr);
} else {
- regmap_update_bits(regs, CCSR_SSI_SRCR,
+ regmap_update_bits(regs, REG_SSI_SRCR,
vals->rx.srcr | vals->tx.srcr, 0);
- regmap_update_bits(regs, CCSR_SSI_STCR,
+ regmap_update_bits(regs, REG_SSI_STCR,
vals->rx.stcr | vals->tx.stcr, 0);
- regmap_update_bits(regs, CCSR_SSI_SIER,
+ regmap_update_bits(regs, REG_SSI_SIER,
vals->rx.sier | vals->tx.sier, 0);
}
}
@@ -397,11 +397,11 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable)
static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx)
{
if (is_rx) {
- regmap_update_bits(ssi->regs, CCSR_SSI_SOR,
- CCSR_SSI_SOR_RX_CLR, CCSR_SSI_SOR_RX_CLR);
+ regmap_update_bits(ssi->regs, REG_SSI_SOR,
+ SSI_SOR_RX_CLR, SSI_SOR_RX_CLR);
} else {
- regmap_update_bits(ssi->regs, CCSR_SSI_SOR,
- CCSR_SSI_SOR_TX_CLR, CCSR_SSI_SOR_TX_CLR);
+ regmap_update_bits(ssi->regs, REG_SSI_SOR,
+ SSI_SOR_TX_CLR, SSI_SOR_TX_CLR);
}
}

@@ -437,10 +437,10 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
u32 scr_val;
int keep_active;

- regmap_read(regs, CCSR_SSI_SCR, &scr_val);
+ regmap_read(regs, REG_SSI_SCR, &scr_val);

- nr_active_streams = !!(scr_val & CCSR_SSI_SCR_TE) +
- !!(scr_val & CCSR_SSI_SCR_RE);
+ nr_active_streams = !!(scr_val & SSI_SCR_TE) +
+ !!(scr_val & SSI_SCR_RE);

if (nr_active_streams - 1 > 0)
keep_active = 1;
@@ -458,7 +458,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr,
keep_active);
/* Safely disable SCR register for the stream */
- regmap_update_bits(regs, CCSR_SSI_SCR, scr, 0);
+ regmap_update_bits(regs, REG_SSI_SCR, scr, 0);
}

/*
@@ -475,11 +475,11 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,

/* Online configure single direction while SSI is running */
if (enable) {
- fsl_ssi_fifo_clear(ssi, vals->scr & CCSR_SSI_SCR_RE);
+ fsl_ssi_fifo_clear(ssi, vals->scr & SSI_SCR_RE);

- regmap_update_bits(regs, CCSR_SSI_SRCR, vals->srcr, vals->srcr);
- regmap_update_bits(regs, CCSR_SSI_STCR, vals->stcr, vals->stcr);
- regmap_update_bits(regs, CCSR_SSI_SIER, vals->sier, vals->sier);
+ regmap_update_bits(regs, REG_SSI_SRCR, vals->srcr, vals->srcr);
+ regmap_update_bits(regs, REG_SSI_STCR, vals->stcr, vals->stcr);
+ regmap_update_bits(regs, REG_SSI_SIER, vals->sier, vals->sier);
} else {
u32 sier;
u32 srcr;
@@ -494,9 +494,9 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
keep_active);

/* Safely disable other control registers for the stream */
- regmap_update_bits(regs, CCSR_SSI_SRCR, srcr, 0);
- regmap_update_bits(regs, CCSR_SSI_STCR, stcr, 0);
- regmap_update_bits(regs, CCSR_SSI_SIER, sier, 0);
+ regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0);
+ regmap_update_bits(regs, REG_SSI_STCR, stcr, 0);
+ regmap_update_bits(regs, REG_SSI_SIER, sier, 0);
}

config_done:
@@ -504,19 +504,19 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
if (enable) {
/* Start DMA before setting TE to avoid underrun */
/* TODO: FIQ cases might also need this upon testing */
- if (ssi->use_dma && (vals->scr & CCSR_SSI_SCR_TE)) {
+ if (ssi->use_dma && (vals->scr & SSI_SCR_TE)) {
int i;
int max_loop = 100;

/* Enable SSI first to send TX DMA request */
- regmap_update_bits(regs, CCSR_SSI_SCR,
- CCSR_SSI_SCR_SSIEN, CCSR_SSI_SCR_SSIEN);
+ regmap_update_bits(regs, REG_SSI_SCR,
+ SSI_SCR_SSIEN, SSI_SCR_SSIEN);

/* Wait until TX FIFO not empty -- DMA working */
for (i = 0; i < max_loop; i++) {
u32 sfcsr;
- regmap_read(regs, CCSR_SSI_SFCSR, &sfcsr);
- if (CCSR_SSI_SFCSR_TFCNT0(sfcsr))
+ regmap_read(regs, REG_SSI_SFCSR, &sfcsr);
+ if (SSI_SFCSR_TFCNT0(sfcsr))
break;
}
if (i == max_loop) {
@@ -525,7 +525,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable,
}
}
/* Enable all remaining bits */
- regmap_update_bits(regs, CCSR_SSI_SCR, vals->scr, vals->scr);
+ regmap_update_bits(regs, REG_SSI_SCR, vals->scr, vals->scr);
}
}

@@ -542,9 +542,9 @@ static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi)
/* no SACC{ST,EN,DIS} regs on imx21-class SSI */
if (!ssi->soc->imx21regs) {
/* Disable all channel slots */
- regmap_write(regs, CCSR_SSI_SACCDIS, 0xff);
+ regmap_write(regs, REG_SSI_SACCDIS, 0xff);
/* Enable slots 3 & 4 -- PCM Playback Left & Right channels */
- regmap_write(regs, CCSR_SSI_SACCEN, 0x300);
+ regmap_write(regs, REG_SSI_SACCEN, 0x300);
}
}

@@ -570,25 +570,25 @@ static void fsl_ssi_setup_reg_vals(struct fsl_ssi *ssi)
{
struct fsl_ssi_rxtx_reg_val *reg = &ssi->rxtx_reg_val;

- reg->rx.sier = CCSR_SSI_SIER_RFF0_EN;
- reg->rx.srcr = CCSR_SSI_SRCR_RFEN0;
+ reg->rx.sier = SSI_SIER_RFF0_EN;
+ reg->rx.srcr = SSI_SRCR_RFEN0;
reg->rx.scr = 0;
- reg->tx.sier = CCSR_SSI_SIER_TFE0_EN;
- reg->tx.stcr = CCSR_SSI_STCR_TFEN0;
+ reg->tx.sier = SSI_SIER_TFE0_EN;
+ reg->tx.stcr = SSI_STCR_TFEN0;
reg->tx.scr = 0;

/* AC97 has already enabled SSIEN, RE and TE, so ignore them */
if (!fsl_ssi_is_ac97(ssi)) {
- reg->rx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE;
- reg->tx.scr = CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE;
+ reg->rx.scr = SSI_SCR_SSIEN | SSI_SCR_RE;
+ reg->tx.scr = SSI_SCR_SSIEN | SSI_SCR_TE;
}

if (ssi->use_dma) {
- reg->rx.sier |= CCSR_SSI_SIER_RDMAE;
- reg->tx.sier |= CCSR_SSI_SIER_TDMAE;
+ reg->rx.sier |= SSI_SIER_RDMAE;
+ reg->tx.sier |= SSI_SIER_TDMAE;
} else {
- reg->rx.sier |= CCSR_SSI_SIER_RIE;
- reg->tx.sier |= CCSR_SSI_SIER_TIE;
+ reg->rx.sier |= SSI_SIER_RIE;
+ reg->tx.sier |= SSI_SIER_TIE;
}

reg->rx.sier |= FSLSSI_SIER_DBG_RX_FLAGS;
@@ -600,21 +600,21 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi)
struct regmap *regs = ssi->regs;

/* Setup the clock control register */
- regmap_write(regs, CCSR_SSI_STCCR,
- CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13));
- regmap_write(regs, CCSR_SSI_SRCCR,
- CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13));
+ regmap_write(regs, REG_SSI_STCCR,
+ SSI_SxCCR_WL(17) | SSI_SxCCR_DC(13));
+ regmap_write(regs, REG_SSI_SRCCR,
+ SSI_SxCCR_WL(17) | SSI_SxCCR_DC(13));

/* Enable AC97 mode and startup the SSI */
- regmap_write(regs, CCSR_SSI_SACNT,
- CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV);
+ regmap_write(regs, REG_SSI_SACNT,
+ SSI_SACNT_AC97EN | SSI_SACNT_FV);

/* AC97 has to communicate with codec before starting a stream */
- regmap_update_bits(regs, CCSR_SSI_SCR,
- CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE,
- CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE);
+ regmap_update_bits(regs, REG_SSI_SCR,
+ SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE,
+ SSI_SCR_SSIEN | SSI_SCR_TE | SSI_SCR_RE);

- regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_WAIT(3));
+ regmap_write(regs, REG_SSI_SOR, SSI_SOR_WAIT(3));
}

static int fsl_ssi_startup(struct snd_pcm_substream *substream,
@@ -747,15 +747,15 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
return -EINVAL;
}

- stccr = CCSR_SSI_SxCCR_PM(pm + 1) | (div2 ? CCSR_SSI_SxCCR_DIV2 : 0) |
- (psr ? CCSR_SSI_SxCCR_PSR : 0);
- mask = CCSR_SSI_SxCCR_PM_MASK | CCSR_SSI_SxCCR_DIV2 |
- CCSR_SSI_SxCCR_PSR;
+ stccr = SSI_SxCCR_PM(pm + 1) | (div2 ? SSI_SxCCR_DIV2 : 0) |
+ (psr ? SSI_SxCCR_PSR : 0);
+ mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 |
+ SSI_SxCCR_PSR;

if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || synchronous)
- regmap_update_bits(regs, CCSR_SSI_STCCR, mask, stccr);
+ regmap_update_bits(regs, REG_SSI_STCCR, mask, stccr);
else
- regmap_update_bits(regs, CCSR_SSI_SRCCR, mask, stccr);
+ regmap_update_bits(regs, REG_SSI_SRCCR, mask, stccr);

if (!baudclk_is_used) {
ret = clk_set_rate(ssi->baudclk, baudrate);
@@ -786,13 +786,13 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
struct regmap *regs = ssi->regs;
unsigned int channels = params_channels(hw_params);
unsigned int sample_size = params_width(hw_params);
- u32 wl = CCSR_SSI_SxCCR_WL(sample_size);
+ u32 wl = SSI_SxCCR_WL(sample_size);
int ret;
u32 scr_val;
int enabled;

- regmap_read(regs, CCSR_SSI_SCR, &scr_val);
- enabled = scr_val & CCSR_SSI_SCR_SSIEN;
+ regmap_read(regs, REG_SSI_SCR, &scr_val);
+ enabled = scr_val & SSI_SCR_SSIEN;

/*
* SSI is properly configured if it is enabled and running in
@@ -822,23 +822,23 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
u8 i2smode;
/* Normal + Network mode to send 16-bit data in 32-bit frames */
if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
- i2smode = CCSR_SSI_SCR_I2S_MODE_NORMAL |
- CCSR_SSI_SCR_NET;
+ i2smode = SSI_SCR_I2S_MODE_NORMAL |
+ SSI_SCR_NET;
else
i2smode = ssi->i2s_mode;

- regmap_update_bits(regs, CCSR_SSI_SCR,
- CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK,
+ regmap_update_bits(regs, REG_SSI_SCR,
+ SSI_SCR_NET | SSI_SCR_I2S_MODE_MASK,
channels == 1 ? 0 : i2smode);
}

/* In synchronous mode, the SSI uses STCCR for capture */
if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
ssi->cpu_dai_drv.symmetric_rates)
- regmap_update_bits(regs, CCSR_SSI_STCCR, CCSR_SSI_SxCCR_WL_MASK,
+ regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_WL_MASK,
wl);
else
- regmap_update_bits(regs, CCSR_SSI_SRCCR, CCSR_SSI_SxCCR_WL_MASK,
+ regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_WL_MASK,
wl);

return 0;
@@ -875,62 +875,62 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,

fsl_ssi_setup_reg_vals(ssi);

- regmap_read(regs, CCSR_SSI_SCR, &scr);
- scr &= ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK);
+ regmap_read(regs, REG_SSI_SCR, &scr);
+ scr &= ~(SSI_SCR_SYN | SSI_SCR_I2S_MODE_MASK);
/* Synchronize frame sync clock for TE to avoid data slipping */
- scr |= CCSR_SSI_SCR_SYNC_TX_FS;
+ scr |= SSI_SCR_SYNC_TX_FS;

- mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR |
- CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TFSL |
- CCSR_SSI_STCR_TEFS;
- regmap_read(regs, CCSR_SSI_STCR, &stcr);
- regmap_read(regs, CCSR_SSI_SRCR, &srcr);
+ mask = SSI_STCR_TXBIT0 | SSI_STCR_TFDIR | SSI_STCR_TXDIR |
+ SSI_STCR_TSCKP | SSI_STCR_TFSI | SSI_STCR_TFSL |
+ SSI_STCR_TEFS;
+ regmap_read(regs, REG_SSI_STCR, &stcr);
+ regmap_read(regs, REG_SSI_SRCR, &srcr);
stcr &= ~mask;
srcr &= ~mask;

/* Use Network mode as default */
- ssi->i2s_mode = CCSR_SSI_SCR_NET;
+ ssi->i2s_mode = SSI_SCR_NET;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
- regmap_update_bits(regs, CCSR_SSI_STCCR,
- CCSR_SSI_SxCCR_DC_MASK,
- CCSR_SSI_SxCCR_DC(2));
- regmap_update_bits(regs, CCSR_SSI_SRCCR,
- CCSR_SSI_SxCCR_DC_MASK,
- CCSR_SSI_SxCCR_DC(2));
+ regmap_update_bits(regs, REG_SSI_STCCR,
+ SSI_SxCCR_DC_MASK,
+ SSI_SxCCR_DC(2));
+ regmap_update_bits(regs, REG_SSI_SRCCR,
+ SSI_SxCCR_DC_MASK,
+ SSI_SxCCR_DC(2));
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFS:
case SND_SOC_DAIFMT_CBS_CFS:
- ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_MASTER;
+ ssi->i2s_mode |= SSI_SCR_I2S_MODE_MASTER;
break;
case SND_SOC_DAIFMT_CBM_CFM:
- ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_SLAVE;
+ ssi->i2s_mode |= SSI_SCR_I2S_MODE_SLAVE;
break;
default:
return -EINVAL;
}

/* Data on rising edge of bclk, frame low, 1clk before data */
- strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP |
- CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TEFS;
+ strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP |
+ SSI_STCR_TXBIT0 | SSI_STCR_TEFS;
break;
case SND_SOC_DAIFMT_LEFT_J:
/* Data on rising edge of bclk, frame high */
- strcr |= CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TSCKP;
+ strcr |= SSI_STCR_TXBIT0 | SSI_STCR_TSCKP;
break;
case SND_SOC_DAIFMT_DSP_A:
/* Data on rising edge of bclk, frame high, 1clk before data */
- strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP |
- CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TEFS;
+ strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP |
+ SSI_STCR_TXBIT0 | SSI_STCR_TEFS;
break;
case SND_SOC_DAIFMT_DSP_B:
/* Data on rising edge of bclk, frame high */
- strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP |
- CCSR_SSI_STCR_TXBIT0;
+ strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP |
+ SSI_STCR_TXBIT0;
break;
case SND_SOC_DAIFMT_AC97:
/* Data on falling edge of bclk, frame high, 1clk before data */
- ssi->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_NORMAL;
+ ssi->i2s_mode |= SSI_SCR_I2S_MODE_NORMAL;
break;
default:
return -EINVAL;
@@ -944,16 +944,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
break;
case SND_SOC_DAIFMT_IB_NF:
/* Invert bit clock */
- strcr ^= CCSR_SSI_STCR_TSCKP;
+ strcr ^= SSI_STCR_TSCKP;
break;
case SND_SOC_DAIFMT_NB_IF:
/* Invert frame clock */
- strcr ^= CCSR_SSI_STCR_TFSI;
+ strcr ^= SSI_STCR_TFSI;
break;
case SND_SOC_DAIFMT_IB_IF:
/* Invert both clocks */
- strcr ^= CCSR_SSI_STCR_TSCKP;
- strcr ^= CCSR_SSI_STCR_TFSI;
+ strcr ^= SSI_STCR_TSCKP;
+ strcr ^= SSI_STCR_TFSI;
break;
default:
return -EINVAL;
@@ -963,18 +963,18 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
/* Output bit and frame sync clocks */
- strcr |= CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR;
- scr |= CCSR_SSI_SCR_SYS_CLK_EN;
+ strcr |= SSI_STCR_TFDIR | SSI_STCR_TXDIR;
+ scr |= SSI_SCR_SYS_CLK_EN;
break;
case SND_SOC_DAIFMT_CBM_CFM:
/* Input bit or frame sync clocks */
- scr &= ~CCSR_SSI_SCR_SYS_CLK_EN;
+ scr &= ~SSI_SCR_SYS_CLK_EN;
break;
case SND_SOC_DAIFMT_CBM_CFS:
/* Input bit clock but output frame sync clock */
- strcr &= ~CCSR_SSI_STCR_TXDIR;
- strcr |= CCSR_SSI_STCR_TFDIR;
- scr &= ~CCSR_SSI_SCR_SYS_CLK_EN;
+ strcr &= ~SSI_STCR_TXDIR;
+ strcr |= SSI_STCR_TFDIR;
+ scr &= ~SSI_SCR_SYS_CLK_EN;
break;
default:
if (!fsl_ssi_is_ac97(ssi))
@@ -986,27 +986,27 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,

/* Set SYN mode and clear RXDIR bit when using SYN or AC97 mode */
if (ssi->cpu_dai_drv.symmetric_rates || fsl_ssi_is_ac97(ssi)) {
- srcr &= ~CCSR_SSI_SRCR_RXDIR;
- scr |= CCSR_SSI_SCR_SYN;
+ srcr &= ~SSI_SRCR_RXDIR;
+ scr |= SSI_SCR_SYN;
}

- regmap_write(regs, CCSR_SSI_STCR, stcr);
- regmap_write(regs, CCSR_SSI_SRCR, srcr);
- regmap_write(regs, CCSR_SSI_SCR, scr);
+ regmap_write(regs, REG_SSI_STCR, stcr);
+ regmap_write(regs, REG_SSI_SRCR, srcr);
+ regmap_write(regs, REG_SSI_SCR, scr);

wm = ssi->fifo_watermark;

- regmap_write(regs, CCSR_SSI_SFCSR,
- CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
- CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm));
+ regmap_write(regs, REG_SSI_SFCSR,
+ SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) |
+ SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm));

if (ssi->use_dual_fifo) {
- regmap_update_bits(regs, CCSR_SSI_SRCR, CCSR_SSI_SRCR_RFEN1,
- CCSR_SSI_SRCR_RFEN1);
- regmap_update_bits(regs, CCSR_SSI_STCR, CCSR_SSI_STCR_TFEN1,
- CCSR_SSI_STCR_TFEN1);
- regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_TCH_EN,
- CCSR_SSI_SCR_TCH_EN);
+ regmap_update_bits(regs, REG_SSI_SRCR, SSI_SRCR_RFEN1,
+ SSI_SRCR_RFEN1);
+ regmap_update_bits(regs, REG_SSI_STCR, SSI_STCR_TFEN1,
+ SSI_STCR_TFEN1);
+ regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_TCH_EN,
+ SSI_SCR_TCH_EN);
}

if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97)
@@ -1047,30 +1047,30 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
}

/* The slot number should be >= 2 if using Network mode or I2S mode */
- regmap_read(regs, CCSR_SSI_SCR, &val);
- val &= CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_NET;
+ regmap_read(regs, REG_SSI_SCR, &val);
+ val &= SSI_SCR_I2S_MODE_MASK | SSI_SCR_NET;
if (val && slots < 2) {
dev_err(cpu_dai->dev, "slot number should be >= 2 in I2S or NET\n");
return -EINVAL;
}

- regmap_update_bits(regs, CCSR_SSI_STCCR, CCSR_SSI_SxCCR_DC_MASK,
- CCSR_SSI_SxCCR_DC(slots));
- regmap_update_bits(regs, CCSR_SSI_SRCCR, CCSR_SSI_SxCCR_DC_MASK,
- CCSR_SSI_SxCCR_DC(slots));
+ regmap_update_bits(regs, REG_SSI_STCCR, SSI_SxCCR_DC_MASK,
+ SSI_SxCCR_DC(slots));
+ regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_DC_MASK,
+ SSI_SxCCR_DC(slots));

/* Save SSIEN bit of the SCR register */
- regmap_read(regs, CCSR_SSI_SCR, &val);
- val &= CCSR_SSI_SCR_SSIEN;
+ regmap_read(regs, REG_SSI_SCR, &val);
+ val &= SSI_SCR_SSIEN;
/* Temporarily enable SSI to allow SxMSKs to be configurable */
- regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN,
- CCSR_SSI_SCR_SSIEN);
+ regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_SSIEN,
+ SSI_SCR_SSIEN);

- regmap_write(regs, CCSR_SSI_STMSK, ~tx_mask);
- regmap_write(regs, CCSR_SSI_SRMSK, ~rx_mask);
+ regmap_write(regs, REG_SSI_STMSK, ~tx_mask);
+ regmap_write(regs, REG_SSI_SRMSK, ~rx_mask);

/* Restore the value of SSIEN bit */
- regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val);
+ regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_SSIEN, val);

ssi->slot_width = slot_width;
ssi->slots = slots;
@@ -1114,9 +1114,9 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
/* Clear corresponding FIFO */
if (fsl_ssi_is_ac97(ssi)) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_TX_CLR);
+ regmap_write(regs, REG_SSI_SOR, SSI_SOR_TX_CLR);
else
- regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_RX_CLR);
+ regmap_write(regs, REG_SSI_SOR, SSI_SOR_RX_CLR);
}

return 0;
@@ -1212,13 +1212,13 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
}

lreg = reg << 12;
- regmap_write(regs, CCSR_SSI_SACADD, lreg);
+ regmap_write(regs, REG_SSI_SACADD, lreg);

lval = val << 4;
- regmap_write(regs, CCSR_SSI_SACDAT, lval);
+ regmap_write(regs, REG_SSI_SACDAT, lval);

- regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK,
- CCSR_SSI_SACNT_WR);
+ regmap_update_bits(regs, REG_SSI_SACNT, SSI_SACNT_RDWR_MASK,
+ SSI_SACNT_WR);
udelay(100);

clk_disable_unprepare(fsl_ac97_data->clk);
@@ -1247,13 +1247,13 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
}

lreg = (reg & 0x7f) << 12;
- regmap_write(regs, CCSR_SSI_SACADD, lreg);
- regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK,
- CCSR_SSI_SACNT_RD);
+ regmap_write(regs, REG_SSI_SACADD, lreg);
+ regmap_update_bits(regs, REG_SSI_SACNT, SSI_SACNT_RDWR_MASK,
+ SSI_SACNT_RD);

udelay(100);

- regmap_read(regs, CCSR_SSI_SACDAT, &reg_val);
+ regmap_read(regs, REG_SSI_SACDAT, &reg_val);
val = (reg_val >> 4) & 0xffff;

clk_disable_unprepare(fsl_ac97_data->clk);
@@ -1315,8 +1315,8 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,

ssi->dma_params_tx.maxburst = ssi->dma_maxburst;
ssi->dma_params_rx.maxburst = ssi->dma_maxburst;
- ssi->dma_params_tx.addr = ssi->ssi_phys + CCSR_SSI_STX0;
- ssi->dma_params_rx.addr = ssi->ssi_phys + CCSR_SSI_SRX0;
+ ssi->dma_params_tx.addr = ssi->ssi_phys + REG_SSI_STX0;
+ ssi->dma_params_rx.addr = ssi->ssi_phys + REG_SSI_SRX0;

/* Set to dual FIFO mode according to the SDMA sciprt */
ret = of_property_read_u32_array(np, "dmas", dmas, 4);
@@ -1418,9 +1418,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)

if (ssi->soc->imx21regs) {
/* No SACC{ST,EN,DIS} regs in imx21-class SSI */
- regconfig.max_register = CCSR_SSI_SRMSK;
+ regconfig.max_register = REG_SSI_SRMSK;
regconfig.num_reg_defaults_raw =
- CCSR_SSI_SRMSK / sizeof(uint32_t) + 1;
+ REG_SSI_SRMSK / sizeof(uint32_t) + 1;
}

ret = of_property_match_string(np, "clock-names", "ipg");
@@ -1610,8 +1610,8 @@ static int fsl_ssi_suspend(struct device *dev)
struct fsl_ssi *ssi = dev_get_drvdata(dev);
struct regmap *regs = ssi->regs;

- regmap_read(regs, CCSR_SSI_SFCSR, &ssi->regcache_sfcsr);
- regmap_read(regs, CCSR_SSI_SACNT, &ssi->regcache_sacnt);
+ regmap_read(regs, REG_SSI_SFCSR, &ssi->regcache_sfcsr);
+ regmap_read(regs, REG_SSI_SACNT, &ssi->regcache_sacnt);

regcache_cache_only(regs, true);
regcache_mark_dirty(regs);
@@ -1626,11 +1626,11 @@ static int fsl_ssi_resume(struct device *dev)

regcache_cache_only(regs, false);

- regmap_update_bits(regs, CCSR_SSI_SFCSR,
- CCSR_SSI_SFCSR_RFWM1_MASK | CCSR_SSI_SFCSR_TFWM1_MASK |
- CCSR_SSI_SFCSR_RFWM0_MASK | CCSR_SSI_SFCSR_TFWM0_MASK,
+ regmap_update_bits(regs, REG_SSI_SFCSR,
+ SSI_SFCSR_RFWM1_MASK | SSI_SFCSR_TFWM1_MASK |
+ SSI_SFCSR_RFWM0_MASK | SSI_SFCSR_TFWM0_MASK,
ssi->regcache_sfcsr);
- regmap_write(regs, CCSR_SSI_SACNT, ssi->regcache_sacnt);
+ regmap_write(regs, REG_SSI_SACNT, ssi->regcache_sacnt);

return regcache_sync(regs);
}
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h
index 1ad3bde..cdcf3d2 100644
--- a/sound/soc/fsl/fsl_ssi.h
+++ b/sound/soc/fsl/fsl_ssi.h
@@ -15,55 +15,55 @@
/* -- SSI Register Map -- */

/* SSI Transmit Data Register 0 */
-#define CCSR_SSI_STX0 0x00
+#define REG_SSI_STX0 0x00
/* SSI Transmit Data Register 1 */
-#define CCSR_SSI_STX1 0x04
+#define REG_SSI_STX1 0x04
/* SSI Receive Data Register 0 */
-#define CCSR_SSI_SRX0 0x08
+#define REG_SSI_SRX0 0x08
/* SSI Receive Data Register 1 */
-#define CCSR_SSI_SRX1 0x0c
+#define REG_SSI_SRX1 0x0c
/* SSI Control Register */
-#define CCSR_SSI_SCR 0x10
+#define REG_SSI_SCR 0x10
/* SSI Interrupt Status Register */
-#define CCSR_SSI_SISR 0x14
+#define REG_SSI_SISR 0x14
/* SSI Interrupt Enable Register */
-#define CCSR_SSI_SIER 0x18
+#define REG_SSI_SIER 0x18
/* SSI Transmit Configuration Register */
-#define CCSR_SSI_STCR 0x1c
+#define REG_SSI_STCR 0x1c
/* SSI Receive Configuration Register */
-#define CCSR_SSI_SRCR 0x20
+#define REG_SSI_SRCR 0x20
/* SSI Transmit Clock Control Register */
-#define CCSR_SSI_STCCR 0x24
+#define REG_SSI_STCCR 0x24
/* SSI Receive Clock Control Register */
-#define CCSR_SSI_SRCCR 0x28
+#define REG_SSI_SRCCR 0x28
/* SSI FIFO Control/Status Register */
-#define CCSR_SSI_SFCSR 0x2c
+#define REG_SSI_SFCSR 0x2c
/*
* SSI Test Register (Intended for debugging purposes only)
*
* Note: STR is not documented in recent IMX datasheet, but
* is described in IMX51 reference manual at section 56.3.3.14
*/
-#define CCSR_SSI_STR 0x30
+#define REG_SSI_STR 0x30
/*
* SSI Option Register (Intended for internal use only)
*
* Note: SOR is not documented in recent IMX datasheet, but
* is described in IMX51 reference manual at section 56.3.3.15
*/
-#define CCSR_SSI_SOR 0x34
+#define REG_SSI_SOR 0x34
/* SSI AC97 Control Register */
-#define CCSR_SSI_SACNT 0x38
+#define REG_SSI_SACNT 0x38
/* SSI AC97 Command Address Register */
-#define CCSR_SSI_SACADD 0x3c
+#define REG_SSI_SACADD 0x3c
/* SSI AC97 Command Data Register */
-#define CCSR_SSI_SACDAT 0x40
+#define REG_SSI_SACDAT 0x40
/* SSI AC97 Tag Register */
-#define CCSR_SSI_SATAG 0x44
+#define REG_SSI_SATAG 0x44
/* SSI Transmit Time Slot Mask Register */
-#define CCSR_SSI_STMSK 0x48
+#define REG_SSI_STMSK 0x48
/* SSI Receive Time Slot Mask Register */
-#define CCSR_SSI_SRMSK 0x4c
+#define REG_SSI_SRMSK 0x4c
/*
* SSI AC97 Channel Status Register
*
@@ -72,193 +72,193 @@
* 2) Writing a '1' bit at some position in SACCDIS unsets the relevant bit
* 3) Receivng a '1' in SLOTREQ bit from external CODEC via AC Link
*/
-#define CCSR_SSI_SACCST 0x50
+#define REG_SSI_SACCST 0x50
/* SSI AC97 Channel Enable Register -- Set bits in SACCST */
-#define CCSR_SSI_SACCEN 0x54
+#define REG_SSI_SACCEN 0x54
/* SSI AC97 Channel Disable Register -- Clear bits in SACCST */
-#define CCSR_SSI_SACCDIS 0x58
+#define REG_SSI_SACCDIS 0x58

/* -- SSI Register Field Maps -- */

-/* SSI Control Register -- CCSR_SSI_SCR 0x10 */
-#define CCSR_SSI_SCR_SYNC_TX_FS 0x00001000
-#define CCSR_SSI_SCR_RFR_CLK_DIS 0x00000800
-#define CCSR_SSI_SCR_TFR_CLK_DIS 0x00000400
-#define CCSR_SSI_SCR_TCH_EN 0x00000100
-#define CCSR_SSI_SCR_SYS_CLK_EN 0x00000080
-#define CCSR_SSI_SCR_I2S_MODE_MASK 0x00000060
-#define CCSR_SSI_SCR_I2S_MODE_NORMAL 0x00000000
-#define CCSR_SSI_SCR_I2S_MODE_MASTER 0x00000020
-#define CCSR_SSI_SCR_I2S_MODE_SLAVE 0x00000040
-#define CCSR_SSI_SCR_SYN 0x00000010
-#define CCSR_SSI_SCR_NET 0x00000008
-#define CCSR_SSI_SCR_RE 0x00000004
-#define CCSR_SSI_SCR_TE 0x00000002
-#define CCSR_SSI_SCR_SSIEN 0x00000001
+/* SSI Control Register -- REG_SSI_SCR 0x10 */
+#define SSI_SCR_SYNC_TX_FS 0x00001000
+#define SSI_SCR_RFR_CLK_DIS 0x00000800
+#define SSI_SCR_TFR_CLK_DIS 0x00000400
+#define SSI_SCR_TCH_EN 0x00000100
+#define SSI_SCR_SYS_CLK_EN 0x00000080
+#define SSI_SCR_I2S_MODE_MASK 0x00000060
+#define SSI_SCR_I2S_MODE_NORMAL 0x00000000
+#define SSI_SCR_I2S_MODE_MASTER 0x00000020
+#define SSI_SCR_I2S_MODE_SLAVE 0x00000040
+#define SSI_SCR_SYN 0x00000010
+#define SSI_SCR_NET 0x00000008
+#define SSI_SCR_RE 0x00000004
+#define SSI_SCR_TE 0x00000002
+#define SSI_SCR_SSIEN 0x00000001

-/* SSI Interrupt Status Register -- CCSR_SSI_SISR 0x14 */
-#define CCSR_SSI_SISR_RFRC 0x01000000
-#define CCSR_SSI_SISR_TFRC 0x00800000
-#define CCSR_SSI_SISR_CMDAU 0x00040000
-#define CCSR_SSI_SISR_CMDDU 0x00020000
-#define CCSR_SSI_SISR_RXT 0x00010000
-#define CCSR_SSI_SISR_RDR1 0x00008000
-#define CCSR_SSI_SISR_RDR0 0x00004000
-#define CCSR_SSI_SISR_TDE1 0x00002000
-#define CCSR_SSI_SISR_TDE0 0x00001000
-#define CCSR_SSI_SISR_ROE1 0x00000800
-#define CCSR_SSI_SISR_ROE0 0x00000400
-#define CCSR_SSI_SISR_TUE1 0x00000200
-#define CCSR_SSI_SISR_TUE0 0x00000100
-#define CCSR_SSI_SISR_TFS 0x00000080
-#define CCSR_SSI_SISR_RFS 0x00000040
-#define CCSR_SSI_SISR_TLS 0x00000020
-#define CCSR_SSI_SISR_RLS 0x00000010
-#define CCSR_SSI_SISR_RFF1 0x00000008
-#define CCSR_SSI_SISR_RFF0 0x00000004
-#define CCSR_SSI_SISR_TFE1 0x00000002
-#define CCSR_SSI_SISR_TFE0 0x00000001
+/* SSI Interrupt Status Register -- REG_SSI_SISR 0x14 */
+#define SSI_SISR_RFRC 0x01000000
+#define SSI_SISR_TFRC 0x00800000
+#define SSI_SISR_CMDAU 0x00040000
+#define SSI_SISR_CMDDU 0x00020000
+#define SSI_SISR_RXT 0x00010000
+#define SSI_SISR_RDR1 0x00008000
+#define SSI_SISR_RDR0 0x00004000
+#define SSI_SISR_TDE1 0x00002000
+#define SSI_SISR_TDE0 0x00001000
+#define SSI_SISR_ROE1 0x00000800
+#define SSI_SISR_ROE0 0x00000400
+#define SSI_SISR_TUE1 0x00000200
+#define SSI_SISR_TUE0 0x00000100
+#define SSI_SISR_TFS 0x00000080
+#define SSI_SISR_RFS 0x00000040
+#define SSI_SISR_TLS 0x00000020
+#define SSI_SISR_RLS 0x00000010
+#define SSI_SISR_RFF1 0x00000008
+#define SSI_SISR_RFF0 0x00000004
+#define SSI_SISR_TFE1 0x00000002
+#define SSI_SISR_TFE0 0x00000001

-/* SSI Interrupt Enable Register -- CCSR_SSI_SIER 0x18 */
-#define CCSR_SSI_SIER_RFRC_EN 0x01000000
-#define CCSR_SSI_SIER_TFRC_EN 0x00800000
-#define CCSR_SSI_SIER_RDMAE 0x00400000
-#define CCSR_SSI_SIER_RIE 0x00200000
-#define CCSR_SSI_SIER_TDMAE 0x00100000
-#define CCSR_SSI_SIER_TIE 0x00080000
-#define CCSR_SSI_SIER_CMDAU_EN 0x00040000
-#define CCSR_SSI_SIER_CMDDU_EN 0x00020000
-#define CCSR_SSI_SIER_RXT_EN 0x00010000
-#define CCSR_SSI_SIER_RDR1_EN 0x00008000
-#define CCSR_SSI_SIER_RDR0_EN 0x00004000
-#define CCSR_SSI_SIER_TDE1_EN 0x00002000
-#define CCSR_SSI_SIER_TDE0_EN 0x00001000
-#define CCSR_SSI_SIER_ROE1_EN 0x00000800
-#define CCSR_SSI_SIER_ROE0_EN 0x00000400
-#define CCSR_SSI_SIER_TUE1_EN 0x00000200
-#define CCSR_SSI_SIER_TUE0_EN 0x00000100
-#define CCSR_SSI_SIER_TFS_EN 0x00000080
-#define CCSR_SSI_SIER_RFS_EN 0x00000040
-#define CCSR_SSI_SIER_TLS_EN 0x00000020
-#define CCSR_SSI_SIER_RLS_EN 0x00000010
-#define CCSR_SSI_SIER_RFF1_EN 0x00000008
-#define CCSR_SSI_SIER_RFF0_EN 0x00000004
-#define CCSR_SSI_SIER_TFE1_EN 0x00000002
-#define CCSR_SSI_SIER_TFE0_EN 0x00000001
+/* SSI Interrupt Enable Register -- REG_SSI_SIER 0x18 */
+#define SSI_SIER_RFRC_EN 0x01000000
+#define SSI_SIER_TFRC_EN 0x00800000
+#define SSI_SIER_RDMAE 0x00400000
+#define SSI_SIER_RIE 0x00200000
+#define SSI_SIER_TDMAE 0x00100000
+#define SSI_SIER_TIE 0x00080000
+#define SSI_SIER_CMDAU_EN 0x00040000
+#define SSI_SIER_CMDDU_EN 0x00020000
+#define SSI_SIER_RXT_EN 0x00010000
+#define SSI_SIER_RDR1_EN 0x00008000
+#define SSI_SIER_RDR0_EN 0x00004000
+#define SSI_SIER_TDE1_EN 0x00002000
+#define SSI_SIER_TDE0_EN 0x00001000
+#define SSI_SIER_ROE1_EN 0x00000800
+#define SSI_SIER_ROE0_EN 0x00000400
+#define SSI_SIER_TUE1_EN 0x00000200
+#define SSI_SIER_TUE0_EN 0x00000100
+#define SSI_SIER_TFS_EN 0x00000080
+#define SSI_SIER_RFS_EN 0x00000040
+#define SSI_SIER_TLS_EN 0x00000020
+#define SSI_SIER_RLS_EN 0x00000010
+#define SSI_SIER_RFF1_EN 0x00000008
+#define SSI_SIER_RFF0_EN 0x00000004
+#define SSI_SIER_TFE1_EN 0x00000002
+#define SSI_SIER_TFE0_EN 0x00000001

-/* SSI Transmit Configuration Register -- CCSR_SSI_STCR 0x1C */
-#define CCSR_SSI_STCR_TXBIT0 0x00000200
-#define CCSR_SSI_STCR_TFEN1 0x00000100
-#define CCSR_SSI_STCR_TFEN0 0x00000080
-#define CCSR_SSI_STCR_TFDIR 0x00000040
-#define CCSR_SSI_STCR_TXDIR 0x00000020
-#define CCSR_SSI_STCR_TSHFD 0x00000010
-#define CCSR_SSI_STCR_TSCKP 0x00000008
-#define CCSR_SSI_STCR_TFSI 0x00000004
-#define CCSR_SSI_STCR_TFSL 0x00000002
-#define CCSR_SSI_STCR_TEFS 0x00000001
+/* SSI Transmit Configuration Register -- REG_SSI_STCR 0x1C */
+#define SSI_STCR_TXBIT0 0x00000200
+#define SSI_STCR_TFEN1 0x00000100
+#define SSI_STCR_TFEN0 0x00000080
+#define SSI_STCR_TFDIR 0x00000040
+#define SSI_STCR_TXDIR 0x00000020
+#define SSI_STCR_TSHFD 0x00000010
+#define SSI_STCR_TSCKP 0x00000008
+#define SSI_STCR_TFSI 0x00000004
+#define SSI_STCR_TFSL 0x00000002
+#define SSI_STCR_TEFS 0x00000001

-/* SSI Receive Configuration Register -- CCSR_SSI_SRCR 0x20 */
-#define CCSR_SSI_SRCR_RXEXT 0x00000400
-#define CCSR_SSI_SRCR_RXBIT0 0x00000200
-#define CCSR_SSI_SRCR_RFEN1 0x00000100
-#define CCSR_SSI_SRCR_RFEN0 0x00000080
-#define CCSR_SSI_SRCR_RFDIR 0x00000040
-#define CCSR_SSI_SRCR_RXDIR 0x00000020
-#define CCSR_SSI_SRCR_RSHFD 0x00000010
-#define CCSR_SSI_SRCR_RSCKP 0x00000008
-#define CCSR_SSI_SRCR_RFSI 0x00000004
-#define CCSR_SSI_SRCR_RFSL 0x00000002
-#define CCSR_SSI_SRCR_REFS 0x00000001
+/* SSI Receive Configuration Register -- REG_SSI_SRCR 0x20 */
+#define SSI_SRCR_RXEXT 0x00000400
+#define SSI_SRCR_RXBIT0 0x00000200
+#define SSI_SRCR_RFEN1 0x00000100
+#define SSI_SRCR_RFEN0 0x00000080
+#define SSI_SRCR_RFDIR 0x00000040
+#define SSI_SRCR_RXDIR 0x00000020
+#define SSI_SRCR_RSHFD 0x00000010
+#define SSI_SRCR_RSCKP 0x00000008
+#define SSI_SRCR_RFSI 0x00000004
+#define SSI_SRCR_RFSL 0x00000002
+#define SSI_SRCR_REFS 0x00000001

/*
- * SSI Transmit Clock Control Register -- CCSR_SSI_STCCR 0x24
- * SSI Receive Clock Control Register -- CCSR_SSI_SRCCR 0x28
+ * SSI Transmit Clock Control Register -- REG_SSI_STCCR 0x24
+ * SSI Receive Clock Control Register -- REG_SSI_SRCCR 0x28
*/
-#define CCSR_SSI_SxCCR_DIV2_SHIFT 18
-#define CCSR_SSI_SxCCR_DIV2 0x00040000
-#define CCSR_SSI_SxCCR_PSR_SHIFT 17
-#define CCSR_SSI_SxCCR_PSR 0x00020000
-#define CCSR_SSI_SxCCR_WL_SHIFT 13
-#define CCSR_SSI_SxCCR_WL_MASK 0x0001E000
-#define CCSR_SSI_SxCCR_WL(x) \
- (((((x) / 2) - 1) << CCSR_SSI_SxCCR_WL_SHIFT) & CCSR_SSI_SxCCR_WL_MASK)
-#define CCSR_SSI_SxCCR_DC_SHIFT 8
-#define CCSR_SSI_SxCCR_DC_MASK 0x00001F00
-#define CCSR_SSI_SxCCR_DC(x) \
- ((((x) - 1) << CCSR_SSI_SxCCR_DC_SHIFT) & CCSR_SSI_SxCCR_DC_MASK)
-#define CCSR_SSI_SxCCR_PM_SHIFT 0
-#define CCSR_SSI_SxCCR_PM_MASK 0x000000FF
-#define CCSR_SSI_SxCCR_PM(x) \
- ((((x) - 1) << CCSR_SSI_SxCCR_PM_SHIFT) & CCSR_SSI_SxCCR_PM_MASK)
+#define SSI_SxCCR_DIV2_SHIFT 18
+#define SSI_SxCCR_DIV2 0x00040000
+#define SSI_SxCCR_PSR_SHIFT 17
+#define SSI_SxCCR_PSR 0x00020000
+#define SSI_SxCCR_WL_SHIFT 13
+#define SSI_SxCCR_WL_MASK 0x0001E000
+#define SSI_SxCCR_WL(x) \
+ (((((x) / 2) - 1) << SSI_SxCCR_WL_SHIFT) & SSI_SxCCR_WL_MASK)
+#define SSI_SxCCR_DC_SHIFT 8
+#define SSI_SxCCR_DC_MASK 0x00001F00
+#define SSI_SxCCR_DC(x) \
+ ((((x) - 1) << SSI_SxCCR_DC_SHIFT) & SSI_SxCCR_DC_MASK)
+#define SSI_SxCCR_PM_SHIFT 0
+#define SSI_SxCCR_PM_MASK 0x000000FF
+#define SSI_SxCCR_PM(x) \
+ ((((x) - 1) << SSI_SxCCR_PM_SHIFT) & SSI_SxCCR_PM_MASK)

/*
- * SSI FIFO Control/Status Register -- CCSR_SSI_SFCSR 0x2c
+ * SSI FIFO Control/Status Register -- REG_SSI_SFCSR 0x2c
*
- * Tx or Rx FIFO Counter -- CCSR_SSI_SFCSR_xFCNTy Read-Only
- * Tx or Rx FIFO Watermarks -- CCSR_SSI_SFCSR_xFWMy Read/Write
+ * Tx or Rx FIFO Counter -- SSI_SFCSR_xFCNTy Read-Only
+ * Tx or Rx FIFO Watermarks -- SSI_SFCSR_xFWMy Read/Write
*/
-#define CCSR_SSI_SFCSR_RFCNT1_SHIFT 28
-#define CCSR_SSI_SFCSR_RFCNT1_MASK 0xF0000000
-#define CCSR_SSI_SFCSR_RFCNT1(x) \
- (((x) & CCSR_SSI_SFCSR_RFCNT1_MASK) >> CCSR_SSI_SFCSR_RFCNT1_SHIFT)
-#define CCSR_SSI_SFCSR_TFCNT1_SHIFT 24
-#define CCSR_SSI_SFCSR_TFCNT1_MASK 0x0F000000
-#define CCSR_SSI_SFCSR_TFCNT1(x) \
- (((x) & CCSR_SSI_SFCSR_TFCNT1_MASK) >> CCSR_SSI_SFCSR_TFCNT1_SHIFT)
-#define CCSR_SSI_SFCSR_RFWM1_SHIFT 20
-#define CCSR_SSI_SFCSR_RFWM1_MASK 0x00F00000
-#define CCSR_SSI_SFCSR_RFWM1(x) \
- (((x) << CCSR_SSI_SFCSR_RFWM1_SHIFT) & CCSR_SSI_SFCSR_RFWM1_MASK)
-#define CCSR_SSI_SFCSR_TFWM1_SHIFT 16
-#define CCSR_SSI_SFCSR_TFWM1_MASK 0x000F0000
-#define CCSR_SSI_SFCSR_TFWM1(x) \
- (((x) << CCSR_SSI_SFCSR_TFWM1_SHIFT) & CCSR_SSI_SFCSR_TFWM1_MASK)
-#define CCSR_SSI_SFCSR_RFCNT0_SHIFT 12
-#define CCSR_SSI_SFCSR_RFCNT0_MASK 0x0000F000
-#define CCSR_SSI_SFCSR_RFCNT0(x) \
- (((x) & CCSR_SSI_SFCSR_RFCNT0_MASK) >> CCSR_SSI_SFCSR_RFCNT0_SHIFT)
-#define CCSR_SSI_SFCSR_TFCNT0_SHIFT 8
-#define CCSR_SSI_SFCSR_TFCNT0_MASK 0x00000F00
-#define CCSR_SSI_SFCSR_TFCNT0(x) \
- (((x) & CCSR_SSI_SFCSR_TFCNT0_MASK) >> CCSR_SSI_SFCSR_TFCNT0_SHIFT)
-#define CCSR_SSI_SFCSR_RFWM0_SHIFT 4
-#define CCSR_SSI_SFCSR_RFWM0_MASK 0x000000F0
-#define CCSR_SSI_SFCSR_RFWM0(x) \
- (((x) << CCSR_SSI_SFCSR_RFWM0_SHIFT) & CCSR_SSI_SFCSR_RFWM0_MASK)
-#define CCSR_SSI_SFCSR_TFWM0_SHIFT 0
-#define CCSR_SSI_SFCSR_TFWM0_MASK 0x0000000F
-#define CCSR_SSI_SFCSR_TFWM0(x) \
- (((x) << CCSR_SSI_SFCSR_TFWM0_SHIFT) & CCSR_SSI_SFCSR_TFWM0_MASK)
+#define SSI_SFCSR_RFCNT1_SHIFT 28
+#define SSI_SFCSR_RFCNT1_MASK 0xF0000000
+#define SSI_SFCSR_RFCNT1(x) \
+ (((x) & SSI_SFCSR_RFCNT1_MASK) >> SSI_SFCSR_RFCNT1_SHIFT)
+#define SSI_SFCSR_TFCNT1_SHIFT 24
+#define SSI_SFCSR_TFCNT1_MASK 0x0F000000
+#define SSI_SFCSR_TFCNT1(x) \
+ (((x) & SSI_SFCSR_TFCNT1_MASK) >> SSI_SFCSR_TFCNT1_SHIFT)
+#define SSI_SFCSR_RFWM1_SHIFT 20
+#define SSI_SFCSR_RFWM1_MASK 0x00F00000
+#define SSI_SFCSR_RFWM1(x) \
+ (((x) << SSI_SFCSR_RFWM1_SHIFT) & SSI_SFCSR_RFWM1_MASK)
+#define SSI_SFCSR_TFWM1_SHIFT 16
+#define SSI_SFCSR_TFWM1_MASK 0x000F0000
+#define SSI_SFCSR_TFWM1(x) \
+ (((x) << SSI_SFCSR_TFWM1_SHIFT) & SSI_SFCSR_TFWM1_MASK)
+#define SSI_SFCSR_RFCNT0_SHIFT 12
+#define SSI_SFCSR_RFCNT0_MASK 0x0000F000
+#define SSI_SFCSR_RFCNT0(x) \
+ (((x) & SSI_SFCSR_RFCNT0_MASK) >> SSI_SFCSR_RFCNT0_SHIFT)
+#define SSI_SFCSR_TFCNT0_SHIFT 8
+#define SSI_SFCSR_TFCNT0_MASK 0x00000F00
+#define SSI_SFCSR_TFCNT0(x) \
+ (((x) & SSI_SFCSR_TFCNT0_MASK) >> SSI_SFCSR_TFCNT0_SHIFT)
+#define SSI_SFCSR_RFWM0_SHIFT 4
+#define SSI_SFCSR_RFWM0_MASK 0x000000F0
+#define SSI_SFCSR_RFWM0(x) \
+ (((x) << SSI_SFCSR_RFWM0_SHIFT) & SSI_SFCSR_RFWM0_MASK)
+#define SSI_SFCSR_TFWM0_SHIFT 0
+#define SSI_SFCSR_TFWM0_MASK 0x0000000F
+#define SSI_SFCSR_TFWM0(x) \
+ (((x) << SSI_SFCSR_TFWM0_SHIFT) & SSI_SFCSR_TFWM0_MASK)

-/* SSI Test Register -- CCSR_SSI_STR 0x30 */
-#define CCSR_SSI_STR_TEST 0x00008000
-#define CCSR_SSI_STR_RCK2TCK 0x00004000
-#define CCSR_SSI_STR_RFS2TFS 0x00002000
-#define CCSR_SSI_STR_RXSTATE(x) (((x) >> 8) & 0x1F)
-#define CCSR_SSI_STR_TXD2RXD 0x00000080
-#define CCSR_SSI_STR_TCK2RCK 0x00000040
-#define CCSR_SSI_STR_TFS2RFS 0x00000020
-#define CCSR_SSI_STR_TXSTATE(x) ((x) & 0x1F)
+/* SSI Test Register -- REG_SSI_STR 0x30 */
+#define SSI_STR_TEST 0x00008000
+#define SSI_STR_RCK2TCK 0x00004000
+#define SSI_STR_RFS2TFS 0x00002000
+#define SSI_STR_RXSTATE(x) (((x) >> 8) & 0x1F)
+#define SSI_STR_TXD2RXD 0x00000080
+#define SSI_STR_TCK2RCK 0x00000040
+#define SSI_STR_TFS2RFS 0x00000020
+#define SSI_STR_TXSTATE(x) ((x) & 0x1F)

-/* SSI Option Register -- CCSR_SSI_SOR 0x34 */
-#define CCSR_SSI_SOR_CLKOFF 0x00000040
-#define CCSR_SSI_SOR_RX_CLR 0x00000020
-#define CCSR_SSI_SOR_TX_CLR 0x00000010
-#define CCSR_SSI_SOR_INIT 0x00000008
-#define CCSR_SSI_SOR_WAIT_SHIFT 1
-#define CCSR_SSI_SOR_WAIT_MASK 0x00000006
-#define CCSR_SSI_SOR_WAIT(x) (((x) & 3) << CCSR_SSI_SOR_WAIT_SHIFT)
-#define CCSR_SSI_SOR_SYNRST 0x00000001
+/* SSI Option Register -- REG_SSI_SOR 0x34 */
+#define SSI_SOR_CLKOFF 0x00000040
+#define SSI_SOR_RX_CLR 0x00000020
+#define SSI_SOR_TX_CLR 0x00000010
+#define SSI_SOR_INIT 0x00000008
+#define SSI_SOR_WAIT_SHIFT 1
+#define SSI_SOR_WAIT_MASK 0x00000006
+#define SSI_SOR_WAIT(x) (((x) & 3) << SSI_SOR_WAIT_SHIFT)
+#define SSI_SOR_SYNRST 0x00000001

-/* SSI AC97 Control Register -- CCSR_SSI_SACNT 0x38 */
-#define CCSR_SSI_SACNT_FRDIV(x) (((x) & 0x3f) << 5)
-#define CCSR_SSI_SACNT_WR 0x00000010
-#define CCSR_SSI_SACNT_RD 0x00000008
-#define CCSR_SSI_SACNT_RDWR_MASK 0x00000018
-#define CCSR_SSI_SACNT_TIF 0x00000004
-#define CCSR_SSI_SACNT_FV 0x00000002
-#define CCSR_SSI_SACNT_AC97EN 0x00000001
+/* SSI AC97 Control Register -- REG_SSI_SACNT 0x38 */
+#define SSI_SACNT_FRDIV(x) (((x) & 0x3f) << 5)
+#define SSI_SACNT_WR 0x00000010
+#define SSI_SACNT_RD 0x00000008
+#define SSI_SACNT_RDWR_MASK 0x00000018
+#define SSI_SACNT_TIF 0x00000004
+#define SSI_SACNT_FV 0x00000002
+#define SSI_SACNT_AC97EN 0x00000001


struct device;
diff --git a/sound/soc/fsl/fsl_ssi_dbg.c b/sound/soc/fsl/fsl_ssi_dbg.c
index 9c7fa6c..50b0cab 100644
--- a/sound/soc/fsl/fsl_ssi_dbg.c
+++ b/sound/soc/fsl/fsl_ssi_dbg.c
@@ -18,67 +18,67 @@

void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *dbg, u32 sisr)
{
- if (sisr & CCSR_SSI_SISR_RFRC)
+ if (sisr & SSI_SISR_RFRC)
dbg->stats.rfrc++;

- if (sisr & CCSR_SSI_SISR_TFRC)
+ if (sisr & SSI_SISR_TFRC)
dbg->stats.tfrc++;

- if (sisr & CCSR_SSI_SISR_CMDAU)
+ if (sisr & SSI_SISR_CMDAU)
dbg->stats.cmdau++;

- if (sisr & CCSR_SSI_SISR_CMDDU)
+ if (sisr & SSI_SISR_CMDDU)
dbg->stats.cmddu++;

- if (sisr & CCSR_SSI_SISR_RXT)
+ if (sisr & SSI_SISR_RXT)
dbg->stats.rxt++;

- if (sisr & CCSR_SSI_SISR_RDR1)
+ if (sisr & SSI_SISR_RDR1)
dbg->stats.rdr1++;

- if (sisr & CCSR_SSI_SISR_RDR0)
+ if (sisr & SSI_SISR_RDR0)
dbg->stats.rdr0++;

- if (sisr & CCSR_SSI_SISR_TDE1)
+ if (sisr & SSI_SISR_TDE1)
dbg->stats.tde1++;

- if (sisr & CCSR_SSI_SISR_TDE0)
+ if (sisr & SSI_SISR_TDE0)
dbg->stats.tde0++;

- if (sisr & CCSR_SSI_SISR_ROE1)
+ if (sisr & SSI_SISR_ROE1)
dbg->stats.roe1++;

- if (sisr & CCSR_SSI_SISR_ROE0)
+ if (sisr & SSI_SISR_ROE0)
dbg->stats.roe0++;

- if (sisr & CCSR_SSI_SISR_TUE1)
+ if (sisr & SSI_SISR_TUE1)
dbg->stats.tue1++;

- if (sisr & CCSR_SSI_SISR_TUE0)
+ if (sisr & SSI_SISR_TUE0)
dbg->stats.tue0++;

- if (sisr & CCSR_SSI_SISR_TFS)
+ if (sisr & SSI_SISR_TFS)
dbg->stats.tfs++;

- if (sisr & CCSR_SSI_SISR_RFS)
+ if (sisr & SSI_SISR_RFS)
dbg->stats.rfs++;

- if (sisr & CCSR_SSI_SISR_TLS)
+ if (sisr & SSI_SISR_TLS)
dbg->stats.tls++;

- if (sisr & CCSR_SSI_SISR_RLS)
+ if (sisr & SSI_SISR_RLS)
dbg->stats.rls++;

- if (sisr & CCSR_SSI_SISR_RFF1)
+ if (sisr & SSI_SISR_RFF1)
dbg->stats.rff1++;

- if (sisr & CCSR_SSI_SISR_RFF0)
+ if (sisr & SSI_SISR_RFF0)
dbg->stats.rff0++;

- if (sisr & CCSR_SSI_SISR_TFE1)
+ if (sisr & SSI_SISR_TFE1)
dbg->stats.tfe1++;

- if (sisr & CCSR_SSI_SISR_TFE0)
+ if (sisr & SSI_SISR_TFE0)
dbg->stats.tfe0++;
}

@@ -89,7 +89,7 @@ void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *dbg, u32 sisr)
*/
#define SIER_SHOW(flag, name) \
do { \
- if (CCSR_SSI_SIER_##flag) \
+ if (SSI_SIER_##flag) \
seq_printf(s, #name "=%u\n", ssi_dbg->stats.name); \
} while (0)

--
2.1.4

2017-12-16 04:43:20

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On 12/13/17 5:18 PM, Nicolin Chen wrote:
> - * We are running on a SoC which does not support online SSI
> - * reconfiguration, so we have to enable all necessary flags at once
> - * even if we do not use them later (capture and playback configuration)
> + * Online configuration is not supported
> + * Enable or Disable all necessary bits at once

This is an example of a bad change, IMHO. The original was written in
elegant prose. The new version is just two short sentences.

2017-12-16 04:53:19

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH v3 00/11] ASoC: fsl_ssi: Clean up - coding style level

On 12/13/17 5:18 PM, Nicolin Chen wrote:
> Additionally, in order to fix/work-around hardware bugs and design
> flaws, the driver made a lot of compromise so now its program flow
> looks very complicated and it's getting hard to maintain or update.
>
> So I am going to clean up the driver on both coding style level and
> program flow level.

I'm okay with everything except patch #3.

2017-12-16 16:27:14

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On 12/16/17 12:10 AM, Nicolin Chen wrote:
> Hi,
>
> I am outside so can't use mutt. Sorry for that.
>
> This comment is going to be replaced in the 2nd set anyway because the
> whole function will be replaced.

So you're asking me to review comment changes that will soon be deleted?
Can you send out a new patch without changes to comments, so that I
can focus on the ones that matter?

> And please point out all comments that you think I need to rework. I am
> totally fine to do that. I don't think every single one is bad. And this
> patch has to go in as it also adds a lot of new comments.

Ok.

2017-12-16 17:15:49

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On 12/13/17 5:18 PM, Nicolin Chen wrote:

> - /* Used when using fsl-ssi as sound-card. This is only used by ppc and
> - * should be replaced with simple-sound-card. */
> struct platform_device *pdev;

Is this comment no longer true?

> + * 1) SSI in earlier SoCS has crtical bits in control registers that

critical

> -/**
> - * fsl_ssi_isr: SSI interrupt handler
> - *
> - * Although it's possible to use the interrupt handler to send and receive
> - * data to/from the SSI, we use the DMA instead. Programming is more
> - * complicated, but the performance is much better.
> - *
> - * This interrupt handler is used only to gather statistics.
> - *
> - * @irq: IRQ of the SSI device
> - * @dev_id: pointer to the fsl_ssi structure for this SSI device
> - */

What's wrong with this comment?

> -/*
> - * Clear RX or TX FIFO to remove samples from the previous
> - * stream session which may be still present in the FIFO and
> - * may introduce bad samples and/or channel slipping.
> - *
> - * Note: The SOR is not documented in recent IMX datasheet, but
> - * is described in IMX51 reference manual at section 56.3.3.15.
> +/**
> + * Clear remaining data in the FIFO to avoid dirty data or channel slipping

I think the original is better, unless there's something untrue about it.

> - * We are running on a SoC which does not support online SSI
> - * reconfiguration, so we have to enable all necessary flags at once
> - * even if we do not use them later (capture and playback configuration)
> + * Online configuration is not supported
> + * Enable or Disable all necessary bits at once

Ditto

> - /*
> - * Configure single direction units while the SSI unit is running
> - * (online configuration)
> - */
> + /* Online configure single direction while SSI is running */

Ditto

> - /*
> - * Disabling the necessary flags for one of rx/tx while the
> - * other stream is active is a little bit more difficult. We
> - * have to disable only those flags that differ between both
> - * streams (rx XOR tx) and that are set in the stream that is
> - * disabled now. Otherwise we could alter flags of the other
> - * stream
> - */
> -
> - /* These assignments are simply vals without bits set in avals*/
> + /* Exclude necessary bits for the opposite stream */

Ditto

> - /*
> - * Be sure the Tx FIFO is filled when TE is set.
> - * Otherwise, there are some chances to start the
> - * playback with some void samples inserted first,
> - * generating a channel slip.
> - *
> - * First, SSIEN must be set, to let the FIFO be filled.
> - *
> - * Notes:
> - * - Limit this fix to the DMA case until FIQ cases can
> - * be tested.
> - * - Limit the length of the busy loop to not lock the
> - * system too long, even if 1-2 loops are sufficient
> - * in general.
> - */

What's wrong with this comment?

> - /*
> - * Note that these below aren't just normal registers.
> - * They are a way to disable or enable bits in SACCST
> - * register:
> - * - writing a '1' bit at some position in SACCEN sets the
> - * relevant bit in SACCST,
> - * - writing a '1' bit at some position in SACCDIS unsets
> - * the relevant bit in SACCST register.
> - *
> - * The two writes below first disable all channels slots,
> - * then enable just slots 3 & 4 ("PCM Playback Left Channel"
> - * and "PCM Playback Right Channel").
> - */
> + /* Disable all channel slots */

Ditto.


> - * Why are we setting up SACCST everytime we are starting a
> - * playback?
> - * Some CODECs (like VT1613 CODEC on UDOO board) like to
> - * (sometimes) set extra bits in their SLOTREQ requests.
> - * When a bit is set in a SLOTREQ request then SSI sets the
> - * relevant bit in SACCST automatically (it is enough if a bit was
> - * set in a SLOTREQ just once, bits in SACCST are 'sticky').
> - * If an extra slot gets enabled that's a disaster for playback
> - * because some of normal left or right channel samples are
> - * redirected instead to this extra slot.
> + * SACCST might be modified via AC Link by a CODEC if it sends
> + * extra bits in their SLOTREQ requests, which'll accidentally
> + * send valid data to slots other than normal playback slots.
> *
> - * A workaround implemented in fsl-asoc-card of setting an
> - * appropriate CODEC register so that slots 3 & 4 (the normal
> - * stereo playback slots) are used for S/PDIF seems to mostly fix
> - * this issue on the UDOO board but since this CODEC is so
> - * untrustworthy let's play safe here and make sure that no extra
> - * slots are enabled every time a playback is started.
> + * To be safe, configure SACCST right before TX starts.

I think the original is better, unless there's something untrue about it.

> */
> if (enable && fsl_ssi_is_ac97(ssi))
> fsl_ssi_tx_ac97_saccst_setup(ssi);
> @@ -626,10 +563,8 @@ static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable)
> fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.tx);
> }
>
> -/*
> - * Setup rx/tx register values used to enable/disable the streams. These will
> - * be used later in fsl_ssi_config to setup the streams without the need to
> - * check for all different SSI modes.
> +/**
> + * Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely

This is different comment altogether. Is the original wrong?

> -/**
> - * fsl_ssi_startup: create a new substream
> - *
> - * This is the first function called when a stream is opened.
> - *
> - * If this is the first stream open, then grab the IRQ and program most of
> - * the SSI registers.
> - */

What's wrong with this?

> - * fsl_ssi_hw_params - program the sample size
> + * Configure SSI based on PCM hardware parameters
> *
> - * Most of the SSI registers have been programmed in the startup function,
> - * but the word length must be programmed here. Unfortunately, programming
> - * the SxCCR.WL bits requires the SSI to be temporarily disabled. This can
> - * cause a problem with supporting simultaneous playback and capture. If
> - * the SSI is already playing a stream, then that stream may be temporarily
> - * stopped when you start capture.
> - *
> - * Note: The SxCCR.DC and SxCCR.PM bits are only used if the SSI is the
> - * clock master.
> + * Notes:
> + * 1) SxCCR.WL bits are critical bits that require SSI to be temporarily
> + * disabled on offline_config SoCs. Even for online configurable SoCs
> + * running in synchronous mode (both TX and RX use STCCR), it is not
> + * safe to re-configure them when both two streams start running.
> + * 2) SxCCR.PM, SxCCR.DIV2 and SxCCR.PSR bits will be configured in the
> + * fsl_ssi_set_bclk() if SSI is the DAI clock master.

I think the comment about the stream being temporarily stopped should be
kept, since it was a real issue I spent a lot of time trying to debug.
Unless it's been fixed, of course.

> */
> static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
> @@ -879,8 +795,10 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> enabled = scr_val & CCSR_SSI_SCR_SSIEN;
>
> /*
> - * If we're in synchronous mode, and the SSI is already enabled,
> - * then STCCR is already set properly.
> + * SSI is properly configured if it is enabled and running in
> + * the synchronous mode; Note that AC97 mode is an exception
> + * that should set separate configurations for STCCR and SRCCR
> + * despite running in the synchronous mode.
> */
> if (enabled && ssi->cpu_dai_drv.symmetric_rates)
> return 0;
> @@ -902,10 +820,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
>
> if (!fsl_ssi_is_ac97(ssi)) {
> u8 i2smode;
> - /*
> - * Switch to normal net mode in order to have a frame sync
> - * signal every 32 bits instead of 16 bits
> - */
> + /* Normal + Network mode to send 16-bit data in 32-bit frames */
> if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
> i2smode = CCSR_SSI_SCR_I2S_MODE_NORMAL |
> CCSR_SSI_SCR_NET;
> @@ -917,16 +832,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> channels == 1 ? 0 : i2smode);
> }
>
> - /*
> - * FIXME: The documentation says that SxCCR[WL] should not be
> - * modified while the SSI is enabled. The only time this can
> - * happen is if we're trying to do simultaneous playback and
> - * capture in asynchronous mode. Unfortunately, I have been enable
> - * to get that to work at all on the P1022DS. Therefore, we don't
> - * bother to disable/enable the SSI when setting SxCCR[WL], because
> - * the SSI will stop anyway. Maybe one day, this will get fixed.
> - */

Has this been fixed? If not, then don't delete the comment.

> /**
> - * fsl_ssi_trigger: start and stop the DMA transfer.
> - *
> - * This function is called by ALSA to start, stop, pause, and resume the DMA
> - * transfer of data.
> - *
> - * The DMA channel is in external master start and pause mode, which
> - * means the SSI completely controls the flow of data.

This last paragraph is important.

> -
> - /*
> - * Some boards use an incompatible codec. To get it
> - * working, we are using imx-fiq-pcm-audio, that
> - * can handle those codecs. DMA is not possible in this
> - * situation.
> - */
> -
> + /* Use imx-fiq-pcm-audio for codec incompatible with DMA */

Original is clearer.

> - * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
> - * use FIFO 1 but set the watermark appropriately nontheless.
> - * We program the transmit water to signal a DMA transfer
> - * if there are N elements left in the FIFO. For chips with 15-deep
> - * FIFOs, set watermark to 8. This allows the SSI to operate at a
> - * high data rate without channel slipping. Behavior is unchanged
> - * for the older chips with a fifo depth of only 8. A value of 4
> - * might be appropriate for the older chips, but is left at
> - * fifo_depth-2 until sombody has a chance to test.
> + * Configure TX and RX DMA watermarks.
> *
> - * We set the watermark on the same level as the DMA burstsize. For
> - * fiq it is probably better to use the biggest possible watermark
> - * size.
> + * Values should be tested to avoid FIFO under/over run. Set maxburst
> + * to fifo_watermark to maxiumize DMA transaction to reduce overhead.

Why in the world would you delete all this good info?

> */
> switch (ssi->fifo_depth) {
> case 15:
> - /*
> - * 2 samples is not enough when running at high data
> - * rates (like 48kHz @ 16 bits/channel, 16 channels)
> - * 8 seems to split things evenly and leave enough time
> - * for the DMA to fill the FIFO before it's over/under
> - * run.
> - */
> + /* Tested with cases running at 48kHz @ 16 bits x 16 channels */

Same here.

> - /*
> - * If codec-handle property is missing from SSI node, we assume
> - * that the machine driver uses new binding which does not require
> - * SSI driver to trigger machine driver's probe.
> - */
> + /* Bypass it if using newer DT bindings of ASoC machine drivers */

Not an improvement.

> -/* Show the statistics of a flag only if its interrupt is enabled. The
> - * compiler will optimze this code to a no-op if the interrupt is not
> - * enabled.
> +/**
> + * Show the statistics of a flag only if its interrupt is enabled
> + *
> + * Compilers will optimze it to a no-op if the interrupt is disabled

optimize

2017-12-16 17:30:38

by Caleb Crome

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On Sat, Dec 16, 2017 at 9:15 AM, Timur Tabi <[email protected]> wrote:
>
> On 12/13/17 5:18 PM, Nicolin Chen wrote:
>
>> - /* Used when using fsl-ssi as sound-card. This is only used by ppc and
>> - * should be replaced with simple-sound-card. */
>> struct platform_device *pdev;
>
>
> Is this comment no longer true?
>
>> + * 1) SSI in earlier SoCS has crtical bits in control registers that
>
>
> critical
>
>> -/**
>> - * fsl_ssi_isr: SSI interrupt handler
>> - *
>> - * Although it's possible to use the interrupt handler to send and receive
>> - * data to/from the SSI, we use the DMA instead. Programming is more
>> - * complicated, but the performance is much better.
>> - *
>> - * This interrupt handler is used only to gather statistics.
>> - *
>> - * @irq: IRQ of the SSI device
>> - * @dev_id: pointer to the fsl_ssi structure for this SSI device
>> - */
>
>
> What's wrong with this comment?
>
>> -/*
>> - * Clear RX or TX FIFO to remove samples from the previous
>> - * stream session which may be still present in the FIFO and
>> - * may introduce bad samples and/or channel slipping.
>> - *
>> - * Note: The SOR is not documented in recent IMX datasheet, but
>> - * is described in IMX51 reference manual at section 56.3.3.15.
>> +/**
>> + * Clear remaining data in the FIFO to avoid dirty data or channel slipping
>
>
> I think the original is better, unless there's something untrue about it.
>
>> - * We are running on a SoC which does not support online SSI
>> - * reconfiguration, so we have to enable all necessary flags at once
>> - * even if we do not use them later (capture and playback configuration)
>> + * Online configuration is not supported
>> + * Enable or Disable all necessary bits at once
>
>
> Ditto
>
>> - /*
>> - * Configure single direction units while the SSI unit is running
>> - * (online configuration)
>> - */
>> + /* Online configure single direction while SSI is running */
>
>
> Ditto
>
>> - /*
>> - * Disabling the necessary flags for one of rx/tx while the
>> - * other stream is active is a little bit more difficult. We
>> - * have to disable only those flags that differ between both
>> - * streams (rx XOR tx) and that are set in the stream that is
>> - * disabled now. Otherwise we could alter flags of the other
>> - * stream
>> - */
>> -
>> - /* These assignments are simply vals without bits set in avals*/
>> + /* Exclude necessary bits for the opposite stream */
>
>
> Ditto
>
>> - /*
>> - * Be sure the Tx FIFO is filled when TE is set.
>> - * Otherwise, there are some chances to start the
>> - * playback with some void samples inserted first,
>> - * generating a channel slip.
>> - *
>> - * First, SSIEN must be set, to let the FIFO be filled.
>> - *
>> - * Notes:
>> - * - Limit this fix to the DMA case until FIQ cases can
>> - * be tested.
>> - * - Limit the length of the busy loop to not lock the
>> - * system too long, even if 1-2 loops are sufficient
>> - * in general.
>> - */
>
>
> What's wrong with this comment?
>
>> - /*
>> - * Note that these below aren't just normal registers.
>> - * They are a way to disable or enable bits in SACCST
>> - * register:
>> - * - writing a '1' bit at some position in SACCEN sets the
>> - * relevant bit in SACCST,
>> - * - writing a '1' bit at some position in SACCDIS unsets
>> - * the relevant bit in SACCST register.
>> - *
>> - * The two writes below first disable all channels slots,
>> - * then enable just slots 3 & 4 ("PCM Playback Left Channel"
>> - * and "PCM Playback Right Channel").
>> - */
>> + /* Disable all channel slots */
>
>
> Ditto.
>
>
>> - * Why are we setting up SACCST everytime we are starting a
>> - * playback?
>> - * Some CODECs (like VT1613 CODEC on UDOO board) like to
>> - * (sometimes) set extra bits in their SLOTREQ requests.
>> - * When a bit is set in a SLOTREQ request then SSI sets the
>> - * relevant bit in SACCST automatically (it is enough if a bit was
>> - * set in a SLOTREQ just once, bits in SACCST are 'sticky').
>> - * If an extra slot gets enabled that's a disaster for playback
>> - * because some of normal left or right channel samples are
>> - * redirected instead to this extra slot.
>> + * SACCST might be modified via AC Link by a CODEC if it sends
>> + * extra bits in their SLOTREQ requests, which'll accidentally
>> + * send valid data to slots other than normal playback slots.
>> *
>> - * A workaround implemented in fsl-asoc-card of setting an
>> - * appropriate CODEC register so that slots 3 & 4 (the normal
>> - * stereo playback slots) are used for S/PDIF seems to mostly fix
>> - * this issue on the UDOO board but since this CODEC is so
>> - * untrustworthy let's play safe here and make sure that no extra
>> - * slots are enabled every time a playback is started.
>> + * To be safe, configure SACCST right before TX starts.
>
>
> I think the original is better, unless there's something untrue about it.
>
>> */
>> if (enable && fsl_ssi_is_ac97(ssi))
>> fsl_ssi_tx_ac97_saccst_setup(ssi);
>> @@ -626,10 +563,8 @@ static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable)
>> fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.tx);
>> }
>> -/*
>> - * Setup rx/tx register values used to enable/disable the streams. These will
>> - * be used later in fsl_ssi_config to setup the streams without the need to
>> - * check for all different SSI modes.
>> +/**
>> + * Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely
>
>
> This is different comment altogether. Is the original wrong?
>
>> -/**
>> - * fsl_ssi_startup: create a new substream
>> - *
>> - * This is the first function called when a stream is opened.
>> - *
>> - * If this is the first stream open, then grab the IRQ and program most of
>> - * the SSI registers.
>> - */
>
>
> What's wrong with this?
>
>> - * fsl_ssi_hw_params - program the sample size
>> + * Configure SSI based on PCM hardware parameters
>> *
>> - * Most of the SSI registers have been programmed in the startup function,
>> - * but the word length must be programmed here. Unfortunately, programming
>> - * the SxCCR.WL bits requires the SSI to be temporarily disabled. This can
>> - * cause a problem with supporting simultaneous playback and capture. If
>> - * the SSI is already playing a stream, then that stream may be temporarily
>> - * stopped when you start capture.
>> - *
>> - * Note: The SxCCR.DC and SxCCR.PM bits are only used if the SSI is the
>> - * clock master.
>> + * Notes:
>> + * 1) SxCCR.WL bits are critical bits that require SSI to be temporarily
>> + * disabled on offline_config SoCs. Even for online configurable SoCs
>> + * running in synchronous mode (both TX and RX use STCCR), it is not
>> + * safe to re-configure them when both two streams start running.
>> + * 2) SxCCR.PM, SxCCR.DIV2 and SxCCR.PSR bits will be configured in the
>> + * fsl_ssi_set_bclk() if SSI is the DAI clock master.
>
>
> I think the comment about the stream being temporarily stopped should be kept, since it was a real issue I spent a lot of time trying to debug. Unless it's been fixed, of course.
>
>
>> */
>> static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
>> struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
>> @@ -879,8 +795,10 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
>> enabled = scr_val & CCSR_SSI_SCR_SSIEN;
>> /*
>> - * If we're in synchronous mode, and the SSI is already enabled,
>> - * then STCCR is already set properly.
>> + * SSI is properly configured if it is enabled and running in
>> + * the synchronous mode; Note that AC97 mode is an exception
>> + * that should set separate configurations for STCCR and SRCCR
>> + * despite running in the synchronous mode.
>> */
>> if (enabled && ssi->cpu_dai_drv.symmetric_rates)
>> return 0;
>> @@ -902,10 +820,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
>> if (!fsl_ssi_is_ac97(ssi)) {
>> u8 i2smode;
>> - /*
>> - * Switch to normal net mode in order to have a frame sync
>> - * signal every 32 bits instead of 16 bits
>> - */
>> + /* Normal + Network mode to send 16-bit data in 32-bit frames */
>> if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
>> i2smode = CCSR_SSI_SCR_I2S_MODE_NORMAL |
>> CCSR_SSI_SCR_NET;
>> @@ -917,16 +832,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
>> channels == 1 ? 0 : i2smode);
>> }
>> - /*
>> - * FIXME: The documentation says that SxCCR[WL] should not be
>> - * modified while the SSI is enabled. The only time this can
>> - * happen is if we're trying to do simultaneous playback and
>> - * capture in asynchronous mode. Unfortunately, I have been enable
>> - * to get that to work at all on the P1022DS. Therefore, we don't
>> - * bother to disable/enable the SSI when setting SxCCR[WL], because
>> - * the SSI will stop anyway. Maybe one day, this will get fixed.
>> - */
>
>
> Has this been fixed? If not, then don't delete the comment.
>
>> /**
>> - * fsl_ssi_trigger: start and stop the DMA transfer.
>> - *
>> - * This function is called by ALSA to start, stop, pause, and resume the DMA
>> - * transfer of data.
>> - *
>> - * The DMA channel is in external master start and pause mode, which
>> - * means the SSI completely controls the flow of data.
>
>
> This last paragraph is important.
>
>> -
>> - /*
>> - * Some boards use an incompatible codec. To get it
>> - * working, we are using imx-fiq-pcm-audio, that
>> - * can handle those codecs. DMA is not possible in this
>> - * situation.
>> - */
>> -
>> + /* Use imx-fiq-pcm-audio for codec incompatible with DMA */
>
>
> Original is clearer.
>
>> - * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
>> - * use FIFO 1 but set the watermark appropriately nontheless.
>> - * We program the transmit water to signal a DMA transfer
>> - * if there are N elements left in the FIFO. For chips with 15-deep
>> - * FIFOs, set watermark to 8. This allows the SSI to operate at a
>> - * high data rate without channel slipping. Behavior is unchanged
>> - * for the older chips with a fifo depth of only 8. A value of 4
>> - * might be appropriate for the older chips, but is left at
>> - * fifo_depth-2 until sombody has a chance to test.
>> + * Configure TX and RX DMA watermarks.
>> *
>> - * We set the watermark on the same level as the DMA burstsize. For
>> - * fiq it is probably better to use the biggest possible watermark
>> - * size.
>> + * Values should be tested to avoid FIFO under/over run. Set maxburst
>> + * to fifo_watermark to maxiumize DMA transaction to reduce overhead.
>
>
> Why in the world would you delete all this good info?
>
>> */
>> switch (ssi->fifo_depth) {
>> case 15:
>> - /*
>> - * 2 samples is not enough when running at high data
>> - * rates (like 48kHz @ 16 bits/channel, 16 channels)
>> - * 8 seems to split things evenly and leave enough time
>> - * for the DMA to fill the FIFO before it's over/under
>> - * run.
>> - */
>> + /* Tested with cases running at 48kHz @ 16 bits x 16 channels */
>
>
> Same here.
>
>> - /*
>> - * If codec-handle property is missing from SSI node, we assume
>> - * that the machine driver uses new binding which does not require
>> - * SSI driver to trigger machine driver's probe.
>> - */
>> + /* Bypass it if using newer DT bindings of ASoC machine drivers */
>
>
> Not an improvement.
>
>> -/* Show the statistics of a flag only if its interrupt is enabled. The
>> - * compiler will optimze this code to a no-op if the interrupt is not
>> - * enabled.
>> +/**
>> + * Show the statistics of a flag only if its interrupt is enabled
>> + *
>> + * Compilers will optimze it to a no-op if the interrupt is disabled
>
>
> optimize

Having come to work on this driver with very little knowledge about
kernel programming, and i.MX, I have to agree with Timur. It's an
amazingly complex driver (with support of so many variants). By
eliminating verbose commentary, it's also wiping away a lot of
knowledge. The more sparse commentary makes things harder to
understand for newcomers, or really anybody who isn't already steeped
in knowledge about the SSI port and linux, and it's interaction with
DMA.

(IMO, the hardware design is fundamentally flawed, which makes this
thing such a bear to program -- interrupts & DMA requests are based on
numbers of samples rather than frames -- but that's a discussion for a
different mailing list ;-) )

-Caleb

2017-12-16 17:34:38

by Nicolin Chen

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

Hi,

On Sat, Dec 16, 2017 at 10:27:06AM -0600, Timur Tabi wrote:
> On 12/16/17 12:10 AM, Nicolin Chen wrote:
> >Hi,
> >
> >I am outside so can't use mutt. Sorry for that.
> >
> >This comment is going to be replaced in the 2nd set anyway because the
> >whole function will be replaced.
>
> So you're asking me to review comment changes that will soon be deleted?

I never said "deleted".

> Can you send out a new patch without changes to comments, so that I can
> focus on the ones that matter?

Please don't make any assumption. I am trying my best to do that.
And that's the reason why I have this patch here. I have already
done as much as I can to integrate all comments here.

Thanks
Nicolin

2017-12-16 17:47:28

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On 12/16/17 11:30 AM, Caleb Crome wrote:
> Having come to work on this driver with very little knowledge about
> kernel programming, and i.MX, I have to agree with Timur. It's an
> amazingly complex driver (with support of so many variants). By
> eliminating verbose commentary, it's also wiping away a lot of
> knowledge. The more sparse commentary makes things harder to
> understand for newcomers, or really anybody who isn't already steeped
> in knowledge about the SSI port and linux, and it's interaction with
> DMA.

This is exactly why I wrote the comments the way I did. As I was
learning about the hardware and ASoC drivers, whenever I was confused
about something and then figured it out, I would add a comment about
that. I figured if it wasn't obvious to me, it wouldn't be obvious to
anyone else. And since this was one of the first ASoC drivers, and the
first to use device tree, it would become a reference driver for years
to come. That made it even more important that I document everything I
learned.

I am pleased that other developers kept up that commenting style. This
patch destroys all of that.

2017-12-16 17:49:38

by Nicolin Chen

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On Sat, Dec 16, 2017 at 09:30:14AM -0800, Caleb Crome wrote:

> Having come to work on this driver with very little knowledge about
> kernel programming, and i.MX, I have to agree with Timur. It's an
> amazingly complex driver (with support of so many variants). By
> eliminating verbose commentary, it's also wiping away a lot of
> knowledge. The more sparse commentary makes things harder to
> understand for newcomers, or really anybody who isn't already steeped
> in knowledge about the SSI port and linux, and it's interaction with
> DMA.

I never said that I don't agree with Timur. Every change here is
to simplify things. As long as Timur or any reviewer feels one of
new comments is harder to understand, I am totally fine to rework.
I respect everyone's opinion, but I hope everyone can respect my
effort too by telling me which one needs to rework and why?

Thanks
Nicolin

2017-12-16 18:31:40

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On 12/16/17 11:49 AM, Nicolin Chen wrote:
> I never said that I don't agree with Timur. Every change here is
> to simplify things. As long as Timur or any reviewer feels one of
> new comments is harder to understand, I am totally fine to rework.
> I respect everyone's opinion, but I hope everyone can respect my
> effort too by telling me which one needs to rework and why?

I do respect it. I apologize if I came across as unduly harsh.

2017-12-16 19:17:17

by Nicolin Chen

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

First of all, thanks a lot for the review. And I will send a v4
after I refine these comments.

But please please don't think in the way like "you can touch it
unless it's untrue." I never said anything or anyone is wrong
here. As the other patches that shortens variable names, this
patch just does something similar.

The point here is just to make the driver necessarily explained
while being brief. I am totally fine if you feel some of my new
comments are worse. I will refine it until you get satisfied.

And I hope you (or anyone else) can tell me more about what is
wrong with my new comments instead of asking me to drop them all.
I locally have more than 20 patches based on this one. Any change
I make to this one will give me a lot of trouble to rebase them.
So I am more willing to refine those that people really feel hard
to understand.

On Sat, Dec 16, 2017 at 11:15:43AM -0600, Timur Tabi wrote:
> On 12/13/17 5:18 PM, Nicolin Chen wrote:
>
> >- /* Used when using fsl-ssi as sound-card. This is only used by ppc and
> >- * should be replaced with simple-sound-card. */
> > struct platform_device *pdev;
>
> Is this comment no longer true?

It's moved to the comments of structure fsl_ssi. Since we defined
a pdev at the first place, we should have explained it along with
the definition.

> >-/**
> >- * fsl_ssi_isr: SSI interrupt handler
> >- *
> >- * Although it's possible to use the interrupt handler to send and receive
> >- * data to/from the SSI, we use the DMA instead. Programming is more
> >- * complicated, but the performance is much better.
> >- *
> >- * This interrupt handler is used only to gather statistics.
> >- *
> >- * @irq: IRQ of the SSI device
> >- * @dev_id: pointer to the fsl_ssi structure for this SSI device
> >- */
>
> What's wrong with this comment?

Nothing wrong. An interrupt handler is way too common sense in
a driver code. I am okay to retain it if you strongly feel it's
that necessary. But I would feel more plausible to clean it away.

> >- * Clear RX or TX FIFO to remove samples from the previous
> >- * stream session which may be still present in the FIFO and
> >- * may introduce bad samples and/or channel slipping.
> >- *
> >- * Note: The SOR is not documented in recent IMX datasheet, but
> >- * is described in IMX51 reference manual at section 56.3.3.15.
> >+/**
> >+ * Clear remaining data in the FIFO to avoid dirty data or channel slipping
>
> I think the original is better, unless there's something untrue about it.

It's literally stating the same thing. And SOR register comments
are moved to the header file.

> >- * We are running on a SoC which does not support online SSI
> >- * reconfiguration, so we have to enable all necessary flags at once
> >- * even if we do not use them later (capture and playback configuration)
> >+ * Online configuration is not supported
> >+ * Enable or Disable all necessary bits at once
>
> Ditto

The code also does disabling as well however it doesn't mention
at all. Just like you might have hard time to understand my new
comments, I also had a hard time to understand this one. So I'll
have to change it. My new comments are shorter but covers both
enable and disable. I could make it more descriptive if necessary.

> >- /*
> >- * Configure single direction units while the SSI unit is running
> >- * (online configuration)
> >- */
> >+ /* Online configure single direction while SSI is running */
>
> Ditto

It's literally the same but shorter. I don't think anyone would
have trouble to understand mine...

> >- /*
> >- * Be sure the Tx FIFO is filled when TE is set.
> >- * Otherwise, there are some chances to start the
> >- * playback with some void samples inserted first,
> >- * generating a channel slip.
> >- *
> >- * First, SSIEN must be set, to let the FIFO be filled.
> >- *
> >- * Notes:
> >- * - Limit this fix to the DMA case until FIQ cases can
> >- * be tested.
> >- * - Limit the length of the busy loop to not lock the
> >- * system too long, even if 1-2 loops are sufficient
> >- * in general.
> >- */
>
> What's wrong with this comment?

I have new comments covering necessary steps. But I could bring
some parts back if that makes you happy.

> >- /*
> >- * Note that these below aren't just normal registers.
> >- * They are a way to disable or enable bits in SACCST
> >- * register:
> >- * - writing a '1' bit at some position in SACCEN sets the
> >- * relevant bit in SACCST,
> >- * - writing a '1' bit at some position in SACCDIS unsets
> >- * the relevant bit in SACCST register.
> >- *
> >- * The two writes below first disable all channels slots,
> >- * then enable just slots 3 & 4 ("PCM Playback Left Channel"
> >- * and "PCM Playback Right Channel").
> >- */
> >+ /* Disable all channel slots */
>
> Ditto.

All register related comments are moved to the header file. And
I have new comments covering the 2nd part of original one.

> >- * Why are we setting up SACCST everytime we are starting a
> >- * playback?
> >- * Some CODECs (like VT1613 CODEC on UDOO board) like to
> >- * (sometimes) set extra bits in their SLOTREQ requests.
> >- * When a bit is set in a SLOTREQ request then SSI sets the
> >- * relevant bit in SACCST automatically (it is enough if a bit was
> >- * set in a SLOTREQ just once, bits in SACCST are 'sticky').
> >- * If an extra slot gets enabled that's a disaster for playback
> >- * because some of normal left or right channel samples are
> >- * redirected instead to this extra slot.
> >+ * SACCST might be modified via AC Link by a CODEC if it sends
> >+ * extra bits in their SLOTREQ requests, which'll accidentally
> >+ * send valid data to slots other than normal playback slots.
> > *
> >- * A workaround implemented in fsl-asoc-card of setting an
> >- * appropriate CODEC register so that slots 3 & 4 (the normal
> >- * stereo playback slots) are used for S/PDIF seems to mostly fix
> >- * this issue on the UDOO board but since this CODEC is so
> >- * untrustworthy let's play safe here and make sure that no extra
> >- * slots are enabled every time a playback is started.
> >+ * To be safe, configure SACCST right before TX starts.
>
> I think the original is better, unless there's something untrue about it.

The 1st part is saying the same thing as mine, the 2nd part is not
that necessary to mention some work in the machine driver since we
have already applied the safest way here.

> >-/*
> >- * Setup rx/tx register values used to enable/disable the streams. These will
> >- * be used later in fsl_ssi_config to setup the streams without the need to
> >- * check for all different SSI modes.
> >+/**
> >+ * Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely
>
> This is different comment altogether. Is the original wrong?

"Setup register values" sounds more like touching the registers.
But the function just caches them into a structure which will be
used later. I think mine is more accurate.

> >-/**
> >- * fsl_ssi_startup: create a new substream
> >- *
> >- * This is the first function called when a stream is opened.
> >- *
> >- * If this is the first stream open, then grab the IRQ and program most of
> >- * the SSI registers.
> >- */
>
> What's wrong with this?

* If this is the first stream open, then grab the IRQ and program most of
* the SSI registers.

There is no corresponding code in this function any more.

> >- * fsl_ssi_hw_params - program the sample size
> >+ * Configure SSI based on PCM hardware parameters
> > *
> >- * Most of the SSI registers have been programmed in the startup function,
> >- * but the word length must be programmed here. Unfortunately, programming
> >- * the SxCCR.WL bits requires the SSI to be temporarily disabled. This can
> >- * cause a problem with supporting simultaneous playback and capture. If
> >- * the SSI is already playing a stream, then that stream may be temporarily
> >- * stopped when you start capture.
> >- *
> >- * Note: The SxCCR.DC and SxCCR.PM bits are only used if the SSI is the
> >- * clock master.
> >+ * Notes:
> >+ * 1) SxCCR.WL bits are critical bits that require SSI to be temporarily
> >+ * disabled on offline_config SoCs. Even for online configurable SoCs
> >+ * running in synchronous mode (both TX and RX use STCCR), it is not
> >+ * safe to re-configure them when both two streams start running.
> >+ * 2) SxCCR.PM, SxCCR.DIV2 and SxCCR.PSR bits will be configured in the
> >+ * fsl_ssi_set_bclk() if SSI is the DAI clock master.
>
> I think the comment about the stream being temporarily stopped should be
> kept, since it was a real issue I spent a lot of time trying to debug.
> Unless it's been fixed, of course.

Mine also has "require SSI to be temporarily disabled".

> > */
> > static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> > struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
> >@@ -879,8 +795,10 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> > enabled = scr_val & CCSR_SSI_SCR_SSIEN;
> > /*
> >- * If we're in synchronous mode, and the SSI is already enabled,
> >- * then STCCR is already set properly.
> >+ * SSI is properly configured if it is enabled and running in
> >+ * the synchronous mode; Note that AC97 mode is an exception
> >+ * that should set separate configurations for STCCR and SRCCR
> >+ * despite running in the synchronous mode.
> > */
> > if (enabled && ssi->cpu_dai_drv.symmetric_rates)
> > return 0;
> >@@ -902,10 +820,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> > if (!fsl_ssi_is_ac97(ssi)) {
> > u8 i2smode;
> >- /*
> >- * Switch to normal net mode in order to have a frame sync
> >- * signal every 32 bits instead of 16 bits
> >- */
> >+ /* Normal + Network mode to send 16-bit data in 32-bit frames */
> > if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
> > i2smode = CCSR_SSI_SCR_I2S_MODE_NORMAL |
> > CCSR_SSI_SCR_NET;
> >@@ -917,16 +832,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
> > channels == 1 ? 0 : i2smode);
> > }
> >- /*
> >- * FIXME: The documentation says that SxCCR[WL] should not be
> >- * modified while the SSI is enabled. The only time this can
> >- * happen is if we're trying to do simultaneous playback and
> >- * capture in asynchronous mode. Unfortunately, I have been enable
> >- * to get that to work at all on the P1022DS. Therefore, we don't
> >- * bother to disable/enable the SSI when setting SxCCR[WL], because
> >- * the SSI will stop anyway. Maybe one day, this will get fixed.
> >- */
>
> Has this been fixed? If not, then don't delete the comment.

The comments about WL is moved to the previous one that you just
reviewed. Besides, this is fixed since hw_params() returns the
2nd stream when running in the synchronous mode (you may take a
quick look at the driver code.)

> >- * Set the watermark for transmit FIFO 0 and receive FIFO 0. We don't
> >- * use FIFO 1 but set the watermark appropriately nontheless.
> >- * We program the transmit water to signal a DMA transfer
> >- * if there are N elements left in the FIFO. For chips with 15-deep
> >- * FIFOs, set watermark to 8. This allows the SSI to operate at a
> >- * high data rate without channel slipping. Behavior is unchanged
> >- * for the older chips with a fifo depth of only 8. A value of 4
> >- * might be appropriate for the older chips, but is left at
> >- * fifo_depth-2 until sombody has a chance to test.
> >+ * Configure TX and RX DMA watermarks.
> > *
> >- * We set the watermark on the same level as the DMA burstsize. For
> >- * fiq it is probably better to use the biggest possible watermark
> >- * size.
> >+ * Values should be tested to avoid FIFO under/over run. Set maxburst
> >+ * to fifo_watermark to maxiumize DMA transaction to reduce overhead.
>
> Why in the world would you delete all this good info?

Firstly, FIFO 1 is now being used on i.MX. Secondly, I have some
comments covering important part in my opinion. You may tell me
which part that I am missing here..

> >- /*
> >- * If codec-handle property is missing from SSI node, we assume
> >- * that the machine driver uses new binding which does not require
> >- * SSI driver to trigger machine driver's probe.
> >- */
> >+ /* Bypass it if using newer DT bindings of ASoC machine drivers */
>
> Not an improvement.

Simplification is an improvement in my opinion. And this is the
purpose of the whole set. Touching comments is a sensitive step
and I realized it before sending this patch. But I am willing to
take it as there probably won't be any second chance to do this
kinda cleanup again. If some of the changes made things worse or
even *destroyed* something, I'll definitely change it. Otherwise,
I would like to take this aggressive step.

Thanks
Nicolin

2017-12-16 19:19:24

by Nicolin Chen

[permalink] [raw]
Subject: Re: [PATCH v3 03/11] ASoC: fsl_ssi: Refine all comments

On Sat, Dec 16, 2017 at 12:31:34PM -0600, Timur Tabi wrote:
> On 12/16/17 11:49 AM, Nicolin Chen wrote:
> >I never said that I don't agree with Timur. Every change here is
> >to simplify things. As long as Timur or any reviewer feels one of
> >new comments is harder to understand, I am totally fine to rework.
> >I respect everyone's opinion, but I hope everyone can respect my
> >effort too by telling me which one needs to rework and why?
>
> I do respect it. I apologize if I came across as unduly harsh.

I believe everyone here has a good heart to make things better.
So I am not and won't take it personally. Let's just act more
cooperative. Thanks.