History log of /linux-master/sound/soc/sh/rcar/ssi.c
Revision Date Author Comments
# 340d79a1 06-Oct-2023 Rob Herring <robh@kernel.org>

ASoC: Explicitly include correct DT includes

The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it was merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> # for at91
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20231006-dt-asoc-header-cleanups-v3-1-13a4f0f7fee6@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2d2998b8 10-Mar-2023 Rob Herring <robh@kernel.org>

ASoC: Use of_property_read_bool() for boolean properties

It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties.
Convert reading boolean properties to to of_property_read_bool().

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230310144733.1546413-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# c12dc0f6 31-Jan-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: indicate necessary error when clock start failed

rsnd_ssi_master_clk_start() indicates error message if it couldn't
handle requested clock/rate, but it is not caring all cases.
This patch cares it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874js66t7g.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 376be51c 01-Sep-2022 Jiasheng Jiang <jiasheng@iscas.ac.cn>

ASoC: rsnd: Add check for rsnd_mod_power_on

As rsnd_mod_power_on() can return negative numbers,
it should be better to check the return value and
deal with the exception.

Fixes: e7d850dd10f4 ("ASoC: rsnd: use mod base common method on SSI-parent")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20220902013030.3691266-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>


# d09a7db4 20-Apr-2022 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: care return value from rsnd_node_fixed_index()

Renesas Sound is very complex, and thus it needs to use
rsnd_node_fixed_index() to know enabled pin index.

It returns error if strange pin was selected,
but some codes didn't check it.

This patch 1) indicates error message, 2) check return
value.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87pmlbgn5t.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6dfeb702 01-Aug-2021 Colin Ian King <colin.king@canonical.com>

ASoC: rsnd: make some arrays static const, makes object smaller

Don't populate arrays on the stack but instead them static const.
Makes the object code smaller by 242 bytes.

Before:
text data bss dec hex filename
23827 8764 0 32591 7f4f ./sound/soc/sh/rcar/ssi.o

After:
text data bss dec hex filename
23361 8988 0 32349 7e5d ./sound/soc/sh/rcar/ssi.o

gcc version 10.2.0)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210801063237.137998-1-colin.king@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# c413983e 30-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: adjust disabled module

In general Renesas SoC's SSI/SRC are all enabled, but some SoC is not.

H2 E2

SRC0 <=
SRC1 SRC1
SRC2 SRC2
... ...

Renesas Sound driver is assuming that *all* modules are
enabled, and thus it is using *data array* to access each modules.
Because of it, we have been using "status = disabled" at DT,
and using *full size* array but avoiding disabled module.

ex)
rcar_sound,src {
src-0 {
=> status = "disabled";
};
src1: src-1 {
...
};
...

But R-Car D3 have many disabled modules (It has SSI3/SSI4, SRC5/SRC6),
and Renesas SoC maintainer don't want above style on DT.

ex)
rcar_sound,src {
=> src0: src-0 { status = "disabled"; };
=> src1: src-1 { status = "disabled"; };
=> src2: src-2 { status = "disabled"; };
=> src3: src-3 { status = "disabled"; };
=> src4: src-4 { status = "disabled"; };
src5: src-5 {
...
};
src6: src-6 {
...
};
};

rcar_sound,ssi {
=> ssi0: ssi-0 { status = "disabled"; };
=> ssi1: ssi-1 { status = "disabled"; };
=> ssi2: ssi-2 { status = "disabled"; };
ssi3: ssi-3 {
...
};
ssi4: ssi-4 {
...
};
};

To adjust it, it needs to care about related for_each_child_of_node()
loop on rsnd driver, and it is used from...

> grep -l for_each_child_of_node sound/soc/sh/rcar/*
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/ctu.c
sound/soc/sh/rcar/dma.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/mix.c
sound/soc/sh/rcar/src.c
sound/soc/sh/rcar/ssi.c
sound/soc/sh/rcar/ssiu.c

This patch adjust to this situation.
By this patch, we can avoid disabled modules on DT

rcar_sound,src {
src5: src-5 {
...
};
src6: src-6 {
...
};
};

rcar_sound,ssi {
ssi3: ssi-3 {
...
};
ssi4: ssi-4 {
...
};
};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875yyzk017.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 73919dbe 30-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup rsnd_parse_connect_xxx()

This patch tidyup rsnd_parse_connect_xxx() style.
Nothing is changed, but is preparation for
next "ASoC: rsnd: adjust disabled module" patch

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877djfk01l.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 039f2ccc 30-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup rsnd_dma_request_channel()

This patch adds "char *name" to rsnd_dma_request_channel().
It is not yet used so far, but is preparation for
next "ASoC: rsnd: adjust disabled module" patch

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878s3vk01q.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 83b220cf 26-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: implement BUSIF related code in ssiu.c

BUSIF is SSIU feature, but its related code is
implemented at ssi.c today.
This patch moves it to ssiu.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Message-Id: <87v974lwy9.wl-kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1f9c82b5 26-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add debugfs support

Current rsnd supports #define DEBUG, but it is not helpful
if issue happen after 4-5 hours.
This patch adds debugfs support for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Message-Id: <87y2c0lwyn.wl-kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1788a152 26-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: incidate irq error message

Current rsnd is using dev_dbg() if irq error happen,
but it makes debug very difficult if some strange things happen.
This patch uses dev_info() for it, and rename the macro name.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Message-Id: <87zgwglwyv.wl-kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 54e81e94 26-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: check BUIF error everytime

Current ssi.c checks BUSIF when TDM mode, but it should be checked
everytime.
This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Message-Id: <8735u8nbjr.wl-kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ab62e8a8 26-May-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: attach SSIU when SSI was DMA mode

SSIU is not needed if SSI was PIO mode.
This patch ignores such case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Message-Id: <874keonbkg.wl-kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 15c57ce0 07-Apr-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_ssi_busif_err_irq_enable/disable()

Current ssi.c has duplicated code to control BUSIF
over/under run interrupt.
This patch adds new rsnd_ssi_busif_err_irq_enable/disable()
and share the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Yongbo Zhang <giraffesnn123@gmail.com>
Cc: Chen Li <licheng0822@thundersoft.com>
Link: https://lore.kernel.org/r/871rbl1jsb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 691b379c 07-Apr-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_ssi_busif_err_status_clear()

Current ssi.c clears BUSIF error status at __rsnd_ssi_interrupt(),
but its code is verbose.
This patch off-load it to rsnd_ssi_busif_err_status_clear().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8735w11jso.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a4856e15 07-Apr-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: check all BUSIF status when error

commit 66c705d07d784 ("SoC: rsnd: add interrupt support for SSI BUSIF
buffer") adds __rsnd_ssi_interrupt() checks for BUSIF status,
but is using "break" at for loop.
This means it is not checking all status. Let's check all BUSIF status.

Fixes: commit 66c705d07d784 ("SoC: rsnd: add interrupt support for SSI BUSIF buffer")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874kgh1jsw.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a122a116 07-Apr-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: call rsnd_ssi_master_clk_start() from rsnd_ssi_init()

Current rsnd needs to call .prepare (P) for clock settings,
.trigger for playback start (S) and stop (E).
It should be called as below from SSI point of view.

P -> S -> E -> P -> S -> E -> ...

But, if you used MIXer, below case might happen

(2)
1: P -> S ---> E -> ...
2: P ----> S -> ...
(1) (3)

P(1) setups clock, but E(2) resets it. and starts playback (3).
In such case, it will reports "SSI parent/child should use same rate".

rsnd_ssi_master_clk_start() which is the main function at (P)
was called from rsnd_ssi_init() (= S) before,
but was moved by below patch to rsnd_soc_dai_prepare() (= P) to avoid
using clk_get_rate() which shouldn't be used under atomic context.

commit 4d230d1271064 ("ASoC: rsnd: fixup not to call clk_get/set
under non-atomic")

Because of above patch, rsnd_ssi_master_clk_start() is now called at (P)
which is for non atomic context. But (P) is assuming that spin lock is
*not* used.
One issue now is rsnd_ssi_master_clk_start() is checking ssi->xxx
which should be protected by spin lock.

After above patch, adg.c had below patch for other reasons.

commit 06e8f5c842f2d ("ASoC: rsnd: don't call clk_get_rate()
under atomic context")

clk_get_rate() is used at probe() timing by this patch.
In other words, rsnd_ssi_master_clk_start() is no longer using
clk_get_rate() any more.

This means we can call it from rsnd_ssi_init() (= S) again which is
protected by spin lock.
This patch re-move it to under spin lock, and solves
1. checking ssi->xxx without spin lock issue.
2. clk setting / device start / device stop race condition.

Reported-by: Linh Phung T. Y. <linh.phung.jy@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875z0x1jt5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0779baa8 24-Feb-2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: cleanup ppcheck warning for ssi.c

This patch cleanups below ppcheck warning.

sound/soc/sh/rcar/ssi.c:170:19: style: The scope of the variable 'mod' can be reduced. [variableScope]
struct rsnd_mod *mod;
^
sound/soc/sh/rcar/ssi.c:535:6: style: The scope of the variable 'i' can be reduced. [variableScope]
int i;
^
sound/soc/sh/rcar/ssi.c:1212:19: style: The scope of the variable 'mod' can be reduced. [variableScope]
struct rsnd_mod *mod;
^
sound/soc/sh/rcar/ssi.c:328:16: portability: Shifting signed 32-bit value by 31 bits is implementation-defined behaviour [shiftTooManyBitsSigned]
ssi->cr_clk = FORCE | rsnd_rdai_width_to_swl(rdai) |
^
sound/soc/sh/rcar/ssi.c:387:12: portability: Shifting signed 32-bit value by 31 bits is implementation-defined behaviour [shiftTooManyBitsSigned]
cr_own |= FORCE | rsnd_rdai_width_to_swl(rdai);
^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0qxro2j.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9946871c 19-Feb-2021 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: sh: rcar: ssi: remove redundant assignment

cppcheck warning:

sound/soc/sh/rcar/ssi.c:403:6: style: Redundant initialization for
'wsr'. The initialized value is overwritten before it is
read. [redundantInitialization]
wsr = ssi->wsr;
^
sound/soc/sh/rcar/ssi.c:372:11: note: wsr is initialized
u32 wsr = ssi->wsr;
^
sound/soc/sh/rcar/ssi.c:403:6: note: wsr is overwritten
wsr = ssi->wsr;
^

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210219231635.5749-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 25b384b8 13-Jul-2020 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use discriminatory terms for function names

rsnd is using discriminatory terms for function names.
This patch changes it to "secondary"

One note here is that it do nothing to DMA related naming
for now, because it needs framework level modification.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ub3qra.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 66c705d0 12-May-2020 Yongbo Zhang <giraffesnn123@gmail.com>

SoC: rsnd: add interrupt support for SSI BUSIF buffer

SSI BUSIF buffer is possible to overflow or underflow, especially in a
hypervisor environment. If there is no interrupt support, it will eventually
lead to errors in pcm data.
This patch adds overflow and underflow interrupt support for SSI BUSIF buffer.

Reported-by: Chen Li <licheng0822@thundersoft.com>
Signed-off-by: Yongbo Zhang <giraffesnn123@gmail.com>
Tested-by: Chen Li <licheng0822@thundersoft.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20200512093003.28332-1-giraffesnn123@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 54cb6221 17-Apr-2020 Matthias Blankertz <matthias.blankertz@cetitec.com>

ASoC: rsnd: Fix "status check failed" spam for multi-SSI

Fix the rsnd_ssi_stop function to skip disabling the individual SSIs of
a multi-SSI setup, as the actual stop is performed by rsnd_ssiu_stop_gen2
- the same logic as in rsnd_ssi_start. The attempt to disable these SSIs
was harmless, but caused a "status check failed" message to be printed
for every SSI in the multi-SSI setup.
The disabling of interrupts is still performed, as they are enabled for
all SSIs in rsnd_ssi_init, but care is taken to not accidentally set the
EN bit for an SSI where it was not set by rsnd_ssi_start.

Signed-off-by: Matthias Blankertz <matthias.blankertz@cetitec.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20200417153017.1744454-3-matthias.blankertz@cetitec.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0c258657 17-Apr-2020 Matthias Blankertz <matthias.blankertz@cetitec.com>

ASoC: rsnd: Don't treat master SSI in multi SSI setup as parent

The master SSI of a multi-SSI setup was attached both to the
RSND_MOD_SSI slot and the RSND_MOD_SSIP slot of the rsnd_dai_stream.
This is not correct wrt. the meaning of being "parent" in the rest of
the SSI code, where it seems to indicate an SSI that provides clock and
word sync but is not transmitting/receiving audio data.

Not treating the multi-SSI master as parent allows removal of various
special cases to the rsnd_ssi_is_parent conditions introduced in commit
a09fb3f28a60 ("ASoC: rsnd: Fix parent SSI start/stop in multi-SSI mode").
It also fixes the issue that operations performed via rsnd_dai_call()
were performed twice for the master SSI. This caused some "status check
failed" spam when stopping a multi-SSI stream as the driver attempted to
stop the master SSI twice.

Signed-off-by: Matthias Blankertz <matthias.blankertz@cetitec.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20200417153017.1744454-2-matthias.blankertz@cetitec.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# a09fb3f2 15-Apr-2020 Matthias Blankertz <matthias.blankertz@cetitec.com>

ASoC: rsnd: Fix parent SSI start/stop in multi-SSI mode

The parent SSI of a multi-SSI setup must be fully setup, started and
stopped since it is also part of the playback/capture setup. So only
skip the SSI (as per commit 203cdf51f288 ("ASoC: rsnd: SSI parent cares
SWSP bit") and commit 597b046f0d99 ("ASoC: rsnd: control SSICR::EN
correctly")) if the SSI is parent outside of a multi-SSI setup.

Signed-off-by: Matthias Blankertz <matthias.blankertz@cetitec.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20200415141017.384017-2-matthias.blankertz@cetitec.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 947ec14c 18-Sep-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: do error check after rsnd_channel_normalization()

SSI need to use rsnd_channel_normalization() for TDM-split mode,
thus, channel check need to do after that.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874l1aw39d.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 526a6d45 25-Jun-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add missing pin sharing with SSI9

When SSI9 is sharing pin with SSI0, we need to care about it,
but is missing. This patch fixup it.

Reported-by: Hien Dang <hien.dang.eb@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Chaoliang Qin <chaoliang.qin.jg@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 66287def 25-Apr-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fixup 6ch settings to 8ch

rsnd need to use 8ch clock settings for 6ch for TDM.
Otherwise, it can't work correctly.
This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d9111d36 04-Feb-2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fixup rsnd_ssi_master_clk_start() user count check

commit 4d230d1271064 ("ASoC: rsnd: fixup not to call clk_get/set
under non-atomic") added new rsnd_ssi_prepare() and moved
rsnd_ssi_master_clk_start() to .prepare.
But, ssi user count (= ssi->usrcnt) is incremented at .init
(= rsnd_ssi_init()).
Because of these timing exchange, ssi->usrcnt check at
rsnd_ssi_master_clk_start() should be adjusted.
Otherwise, 2nd master clock setup will be no check.
This patch fixup this issue.

Fixes: commit 4d230d1271064 ("ASoC: rsnd: fixup not to call clk_get/set under non-atomic")
Reported-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Reported-by: Valentine Barshak <valentine.barshak@cogentembedded.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5d9bb555 04-Dec-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: indicates Channel and Mode for debug

For TDM debug purpose, indicating Channel and Mode is very
useful. This patch indicate it if it has #define DEBUG

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0ade2ccf 21-Nov-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: makes rsnd_ssi_is_dma_mode() static

ssi.c only is using rsnd_ssi_is_dma_mode().
Let's move it as static function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# f69f4522 05-Nov-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add TDM Split mode support

This patch adds TDM Split mode support. rsnd driver is assuming
audio-graph-scu-card is used for Sound Card.

This is very simple sample DT settings to use it.

sound_card: sound {
compatible = "audio-graph-scu-card";
...
convert-channels = <8>; /* TDM Split */

dais = <&rsnd_port0 /* playback ch1/ch2 */
&rsnd_port1 /* playback ch3/ch4 */
&rsnd_port2 /* playback ch5/ch6 */
&rsnd_port3 /* playback ch7/ch8 */
>;
};

audio-codec {
...
port {
codec_0: endpoint@1 {
remote-endpoint = <&rsnd_ep0>;
};
codec_1: endpoint@2 {
remote-endpoint = <&rsnd_ep1>;
};
codec_2: endpoint@3 {
remote-endpoint = <&rsnd_ep2>;
};
codec_3: endpoint@4 {
remote-endpoint = <&rsnd_ep3>;
};
};
};

&rcar_sound {
...
ports {
rsnd_port0: port@0 {
rsnd_ep0: endpoint {
remote-endpoint = <&codec_0>;
...
playback = <&ssiu30 &ssi3>;
};
};
rsnd_port1: port@1 {
rsnd_ep1: endpoint {
remote-endpoint = <&codec_1>;
...
playback = <&ssiu31 &ssi3>;
};
};
rsnd_port2: port@2 {
rsnd_ep2: endpoint {
remote-endpoint = <&codec_2>;
...
playback = <&ssiu32 &ssi3>;
};
};
rsnd_port3: port@3 {
rsnd_ep3: endpoint {
remote-endpoint = <&codec_3>;
...
playback = <&ssiu33 &ssi3>;
};
};
};
};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4e7788fb 05-Nov-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add SSIU BUSIF support

Gen2 has BUSIF0-3, Gen3 has BUSIF0-7 on some SSIU.
Current driver is assuming it is using BUSIF0 as default.
Thus, SSI is attaching SSIU (with BUSIF0) by using rsnd_ssiu_attach().
But, TDM split mode also needs other BUSIF to use it.
This patch adds missing SSIU BUSIFx support.

BUSIF is handled by SSIU instead of SSI anymore.
Thus, its settings no longer needed on SSI node on DT.
This patch removes its settings from Document, but driver is still
keeping compatibility. Thus, old DT style is still working.
But, to avoid confusing, it doesn't indicate old compatibility things on
Document. New SoC should have SSIU on DT from this patch.

1) old style DT is still supported (= no rcar_sound,ssiu node on DT)
2) If ssiu is not indicated on playback/capture,
BUSIF0 will be used as default
playback = <&ssi3>; /* ssiu30 will be selected */
3) you can select own ssiu
playback = <&ssi32 &ssi3>; /* ssiu32 will be selected */

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# beed78ae 05-Nov-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: move HDMI information from ssi.c to core.c

Current driver is supporting HDMI output, and its information
are handled under ssi.c. But, it is stream information.
Let's move it from ssi.c to core.c.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a6072802 05-Nov-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename rsnd_runtime_is_ssi_xxx()

Current rsnd driver has rsnd_runtime_is_ssi_xxx() functions,
but it is not only related to SSI, thus, it is misunderstandable.
This patch renames it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c8b222bf 05-Nov-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove endpoint bidirectional check

DTC commit df536831d02c ("checks: add graph binding checks")
is checking endpoint bidirectional, and it is upstreamed to linux by
commit 50aafd60898a ("scripts/dtc: Update to upstream version
v1.4.6-21-g84e414b0b5bc").
Let's remove own bidirectional check

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c0ea089d 30-Oct-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_mod_name() handles both name and ID

Current rsnd driver is using "%s[%d]" for mod name and ID,
but, this ID portion might confusable.
For example currently, CTU ID is 0 to 7, but using 00 to 13
(= 00, 01, 02, 03, 10, 11, 12, 13) is very best matching to datasheet.

In the future, we will support BUSIFn, but it will be more complicated
numbering. To avoid future confusable code, this patch modify
rsnd_mod_name() to return understandable name.

To avoid using pointless memory, it uses static char and snprintf,
thus, rsnd_mod_name() user should use it immediately, and shouldn't keep
its pointer.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7e7fe06d 30-Oct-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: move .get_status under rsnd_mod_ops

Each mod needs to have .get_status, but current driver is handling it
under rsnd_mod, instead of rsnd_mod_ops.
It is not any make sence. This patch moves it to rsnd_mod_ops, and
tidyup its parameter order to align to other callback functions.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3ee9a76a 30-Oct-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fixup clock start checker

commit 4d230d12710646 ("ASoC: rsnd: fixup not to call clk_get/set under
non-atomic") fixuped clock start timing. But it exchanged clock start
checker from ssi->usrcnt to ssi->rate.

Current rsnd_ssi_master_clk_start() is called from .prepare,
but some player (for example GStreamer) might calls it many times.
In such case, the checker might returns error even though it was not
error. It should check ssi->usrcnt instead of ssi->rate.
This patch fixup it. Without this patch, GStreamer can't switch
48kHz / 44.1kHz.

Reported-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2eaa6e23 16-Oct-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup SSICR::SWSP for TDM

R-Car datasheet is indicating that WS output settings of SSICR::SWSP
is inverted on TDM mode from non TDM mode settings.
But, it is meaning that TDM should use 0 here.
Without this patch, sound input/output 1ch will be 2ch, 2ch will be 3ch
..., be jumbled on I2S + TDM settings. This patch fixup it.
This patch is tested on R-Car H3 ulcb-kf board, SSI3/4 TDM sound.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6817d759 16-Oct-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: enable TDM settings for SSI parent

Some SSIs are sharing each pins (= WS/CLK pin for playback/capture).
Then, SSI parent needs control WS/CLK setting for SSI slave.
In such case, SSI parent needs TDM settings if SSI slave is working as
TDM mode. But it is not cared in current driver.
It can't capture TDM sound without this patch if SSIs were pin sharing.
This patch is tested on R-Car H3 ulcb-kf board, SSI3/4 with TDM sound.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5e45a6fa 03-Sep-2018 Jiada Wang <jiada_wang@mentor.com>

ASoc: rsnd: dma: Calculate dma address with consider of BUSIF

DMA address calculated by rsnd_dma_addr() only considers BUSIF0 so far.
But BUSIF1 ~ BUSIF7 also maybe used, in the future.

This patch updates DMA address calculations, to also consider
BUSIF number used by SSI.

One note is that we can't support SSI9-4/5/6/7 so far,
because its address is out of calculation rule.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[kuninori: adjust to upstreaming]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 599da084 03-Sep-2018 Jiada Wang <jiada_wang@mentor.com>

ASoC: rsnd: ssi: Check runtime channel number rather than hw_params

The number of channel handled by SSI maybe differs from the one set
in hw_params, currently SSI checks hw_params's channel number,
and constrains to use same channel number, when it is being
used by multiple clients.

This patch corrects to check runtime channel number rather
than channel number set in hw_params.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[kuninori: adjust to upstreaming]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0e289012 03-Sep-2018 Jiada Wang <jiada_wang@mentor.com>

ASoC: rsnd: ssi: Fix issue in dma data address assignment

Same SSI device may be used in different dai links,
by only having one dma struct in rsnd_ssi, after the first
instance's dma config be initilized, the following instances
can no longer configure dma, this causes issue, when their
dma data address are different from the first instance.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[Kuninori: tidyup for upstream]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ba5d553b 03-Sep-2018 Dragos Tarcatu <dragos_tarcatu@mentor.com>

ASoC: rsnd: add support for 8 bit S8 format

This patch adds support for SNDRV_PCM_FMTBIT_S8 format.

Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[Kuninori: tidyup for upstream]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# fb2815f4 03-Sep-2018 Dragos Tarcatu <dragos_tarcatu@mentor.com>

ASoC: rsnd: add support for 16/24 bit slot widths

The slot width (system word length) was fixed at 32 bits.
This patch allows also setting it to 16 or 24 bits.

Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[Kuninori: tidyup for upstream]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4d230d12 03-Sep-2018 Jiada Wang <jiada_wang@mentor.com>

ASoC: rsnd: fixup not to call clk_get/set under non-atomic

Clocking operations clk_get/set_rate, are non-atomic,
they shouldn't be called in soc_pcm_trigger() which is atomic.

Following issue was found due to execution of clk_get_rate() causes
sleep in soc_pcm_trigger(), which shouldn't be blocked.

We can reproduce this issue by following
> enable CONFIG_DEBUG_ATOMIC_SLEEP=y
> compile, and boot
> mount -t debugfs none /sys/kernel/debug
> while true; do cat /sys/kernel/debug/clk/clk_summary > /dev/null; done &
> while true; do aplay xxx; done

This patch adds support to .prepare callback, and moves non-atomic
clocking operations to it. As .prepare is non-atomic, it is always
called before trigger_start/trigger_stop.

BUG: sleeping function called from invalid context at kernel/locking/mutex.c:620
in_atomic(): 1, irqs_disabled(): 128, pid: 2242, name: aplay
INFO: lockdep is turned off.
irq event stamp: 5964
hardirqs last enabled at (5963): [<ffff200008e59e40>] mutex_lock_nested+0x6e8/0x6f0
hardirqs last disabled at (5964): [<ffff200008e623f0>] _raw_spin_lock_irqsave+0x24/0x68
softirqs last enabled at (5502): [<ffff200008081838>] __do_softirq+0x560/0x10c0
softirqs last disabled at (5495): [<ffff2000080c2e78>] irq_exit+0x160/0x25c
Preemption disabled at:[ 62.904063] [<ffff200008be4d48>] snd_pcm_stream_lock+0xb4/0xc0
CPU: 2 PID: 2242 Comm: aplay Tainted: G B C 4.9.54+ #186
Hardware name: Renesas Salvator-X board based on r8a7795 (DT)
Call trace:
[<ffff20000808fe48>] dump_backtrace+0x0/0x37c
[<ffff2000080901d8>] show_stack+0x14/0x1c
[<ffff2000086f4458>] dump_stack+0xfc/0x154
[<ffff2000081134a0>] ___might_sleep+0x57c/0x58c
[<ffff2000081136b8>] __might_sleep+0x208/0x21c
[<ffff200008e5980c>] mutex_lock_nested+0xb4/0x6f0
[<ffff2000087cac74>] clk_prepare_lock+0xb0/0x184
[<ffff2000087cb094>] clk_core_get_rate+0x14/0x54
[<ffff2000087cb0f4>] clk_get_rate+0x20/0x34
[<ffff20000113aa00>] rsnd_adg_ssi_clk_try_start+0x158/0x4f8 [snd_soc_rcar]
[<ffff20000113da00>] rsnd_ssi_init+0x668/0x7a0 [snd_soc_rcar]
[<ffff200001133ff4>] rsnd_soc_dai_trigger+0x4bc/0xcf8 [snd_soc_rcar]
[<ffff200008c1af24>] soc_pcm_trigger+0x2a4/0x2d4

Fixes: e7d850dd10f4 ("ASoC: rsnd: use mod base common method on SSI-parent")
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
[Kuninori: tidyup for upstream]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org


# 203cdf51 11-Jun-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI parent cares SWSP bit

SSICR has SWSP bit (= Serial WS Polarity) which decides WS pin 1st
channel polarity (low or hi). This bit shouldn't exchange after running.

Current SSI "parent" doesn't care SSICR, just controls clock only.
Because of this behavior, if platform uses SSI0 as playback,
SSI1 as capture, and if user starts capture -> playback order,
SSI0 SSICR::SWSP bit exchanged 0 -> 1 during captureing, and it makes
capture noise.
This patch cares SSICR on SSI parent, too.
Special thanks to Yokoyama-san

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7cc90a5c 11-Jun-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: has .symmetric_rates if SSIs are sharing WS pin

If SSIs are sharing WS pin, it should has .symmetric_rates.
This patch sets it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1e0edd4d 11-Jun-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: convert to SPDX identifiers

Tidyup incoherence between MODULE_LICENSE and header license, too

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a86854d0 12-Jun-2018 Kees Cook <keescook@chromium.org>

treewide: devm_kzalloc() -> devm_kcalloc()

The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

devm_kzalloc(handle, a * b, gfp)

with:
devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

devm_kzalloc(handle, a * b * c, gfp)

with:

devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
devm_kzalloc(HANDLE,
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
devm_kzalloc(HANDLE,
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
devm_kzalloc(HANDLE,
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(char) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- SIZE * COUNT
+ COUNT, SIZE
, ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
devm_kzalloc(HANDLE,
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- (E1) * E2
+ E1, E2
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- (E1) * (E2)
+ E1, E2
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- E1 * E2
+ E1, E2
, ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>


# 3fd391fb 15-Apr-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: ssi: wait maximum 5ms for status check

It is waiting udelay(50) x 1024 (= 50ms) for status check
in worst case, but it is overkill.
And we shouldn't use udelay() for 50us
(linux/Documentation/timers/timers-howto.txt)

Waiting maximum udelay(5) x 1024 (= 5ms) is very enough
for status check.
This patch fixes these issue.

Reported-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9ff73866 10-Apr-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't assume node full path name for HDMI probing

Current ssi.c is assuming below 2 things to probing HDMI node.
1) remote node is including "hdmi0" or "hdmi1" in node name
2) remote_ep->full_name is including full path name

But, these assumptions are broken by below
1) Node names should not use numerical suffixes
commit 6b5ac2f1cb11 ("arm64: dts: renesas: r8a7795: Drop bogus HDMI
node names suffixes")
2) node full_name no longer include full path name
commit a7e4cfb0a7ca ("of/fdt: only store the device node basename
in full_name")

Because of these reasons, ssi.c can't probe HDMI on current kernel.
This patch probes HDMI0/1 by using its address.
Note is that we need to keep updating for this address for future
generation chip.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2b627869 12-Feb-2018 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: indicate IRQ error status for debug

SSI/SRC have under/over flow error handling, and its status is useful
for debuging. But sometimes it might be too much message,
and it might blocks necessity other information.

To avoid such situation, basically this patch indicates interrupt
status debug message if DEBUG was defined, but it will be suppressed
if RSND_DEBUG_NO_IRQ_STATUS was defined.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d8d9b973 10-Dec-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: PIO related function cleanup

SSI had shared counting pointer position method between PIO/DMA mode
before. But now DMA mode is using DMAEngine feature to get it.
Thus, this counting pointer position method is needed for only PIO mode.
We don't need to share code anymore.
This patch names PIO related functions as rsnd_ssi_pio_xxx(), and
merged/cleanuped each feature.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 41acc8ec 10-Dec-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use runtime->sample_bits

Current rsnd driver is judging 16bit/24bit data by using
runtime->sample_bits, but it is indicating physical size,
not format size. This is confusable code.
This patch uses snd_pcm_format_width() to be more correct code.

Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2e2d53da 07-Dec-2017 Jiada Wang <jiada_wang@mentor.com>

ASoC: rsnd: ssi: remove unnesessary period_pos

period_pos can always be calculated by byte_pos and
byte_per_period, there is no reason to maintain this
variable in rsnd_dai_stream.

This patch removes period_pos from rsnd_ssi and calculates
next_period_byte with consideration of actual byte_pos value.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 33f80136 07-Dec-2017 Jiada Wang <jiada_wang@mentor.com>

ASoC: rsnd: ssi: fix race condition in rsnd_ssi_pointer_update

Currently there is race condition between set of byte_pos and wrap
it around when new buffer starts. If .pointer is called in-between
it will result in inconsistent pointer position be returned
from .pointer callback.

This patch increments buffer pointer atomically to avoid this issue.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Reviewed-by: Takashi Sakamoto <takashi.sakamoto@miraclelinux.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 21781e87 01-Nov-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_ssi_run_mods() needs to care ssi_parent_mod

SSI parent mod might be NULL. ssi_parent_mod() needs to care
about it. Otherwise, it uses negative shift.
This patch fixes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ce548931 30-Oct-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: Don't check SSISR::DIRQ when Capture

When stop case, it was Playback, it need to check all data were
completely sent. But in Capture case, it might not receive data
anymore. SSISR::DIRQ check is not need for Capture case.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 42991989 01-Oct-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add generic rsnd_flags_xxx() macro

SSI is using rsnd_ssi_flags_xxx() macro to control flags.
But it is useful macro not only for SSI. This patch replace it
to more generic rsnd_flags_xxx().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9e9e95df 02-Oct-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rcar: skip disabled-SSI nodes

The current device tree representation of the R-Car SSI assumes that they
are numbered consecutively, starting from 0. Alas, this is not the case
with the R8A77995 (D3) SoC which SSI1/SSI2 aren't present. In order to
keep the existing device trees working, I'm suggesting to use a disabled
node for SSI0/SSI1. Teach the SSI probe to just skip disabled nodes.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c1629356 21-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unused rsnd_xxx_to_dma()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b6e58fca 09-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: call request_irq/free_irq once in MIX case

Each module's dai callback function availability is controlled
by mod->status. For example "always called", "call once".
In .probe/.remove case, it needs to be called always, because
.probe will call xxx_attach() function on .probe, especially
if platform is using MIXer.
For example, below case, MIX0/DVC0/SSI0 needs to be called twice.

playback = <&src0 &ctu02 &mix0 &dvc0 &ssi0>;
playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;

But in this case, SSI0 will call request_irq() twice.
This patch add new RSND_SSI_PROBED flag and control it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# bf9b29c7 09-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_ssi_flags_has/add() macro

Current rsnd_ssi_mode_flags() is not useful. This patch adds
new rsnd_ssi_flags_has/add() macro for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 213691c7 09-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: call free_irq() both DMA/PIO mode

commit 701172dca15b ("ASoC: rsnd: don't use devm_request_irq() for SSI")
exchanged devm_request_irq() to request_irq() for SSI, because SSI will
fallback into PIO mode if DMA doesn't work.
But, because of it, PIO mode needed to call free_irq() when removing,
not only DMA mode.
This patch call free_irq() both PIO/DMA. Otherwise, rsnd IRQ handler
will be increased if user tried many unbind/bind.

Fixes: 701172dca15b ("ASoC: rsnd: don't use devm_request_irq() for SSI")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e0936c34 08-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: avoid duplicate free_irq()

commit 1f8754d4daea5f ("ASoC: rsnd: don't call free_irq() on
Parent SSI") fixed Parent SSI duplicate free_irq().
But on Renesas Sound, not only Parent SSI but also Multi SSI
have same issue.
This patch avoid duplicate free_irq() if it was not pure SSI.

Fixes: 1f8754d4daea5f ("ASoC: rsnd: don't call free_irq() on Parent SSI")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 597b046f 07-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: control SSICR::EN correctly

In case of SSI0 playback, SSI1 capture, SSI0 might be shared for
clock output if clock master mode.

Current rsnd driver had been assumed that SSI clock contiguous
output which is needed for SSI parent needs SSICR::EN (SSI module
enable) bit.
But, this bit controls data input/output, not for clock.
Clock contiguous output needs SSICR : FORCE, SCKD, SWSD,
and SSIWSR : CONT. Not SSICR : EN.

Because of this wrong assumption, and insufficient control, on current
code, for example, if it starts SSI0(playback) -> SSI1(capture) order,
SSI0 SSICR::EN bit will temporarily be 0.
It causes playback side underrun error. This is bug.
We can reproduce this issue with SSI+SRC (without DVC), and capture
during playback operation.

This patch fixup current (wrong) assumption, and control SSICR::EN bit
correctly.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# bb002f92 07-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_ssi_can_output_clk() macro

For example SSI0/SSI1 case, SSI1 can share pin with SSI0.
And then, SSI1 needs SSI0's clock.
This clock controlling is very picky and difficult to understand
in current code.

This patch adds new rsnd_ssi_can_output_clk() macro,
the code will be more understandable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# bf23c6a3 07-Aug-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: move rsnd_ssi_config_init() execute condition into it.

Make it the same style as other functions

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 53ba2aa3 15-Jul-2017 Julia Lawall <Julia.Lawall@lip6.fr>

ASoC: rsnd: add missing of_node_put

for_each_child_of_node performs an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression n;
expression e,e1;
identifier l;
@@

for_each_child_of_node(e1,n) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? goto l;
)
...
}
...
l: ... when != n
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 947f4eb5 15-Jun-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fixup unsigned expression compared with zero: main_rate

This patch fixes this WARNING

sound/soc/sh/rcar/ssi.c:285:5-14: WARNING: Unsigned expression\
compared with zero: main_rate < 0

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# ef4cf5d6 14-Jun-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_ssi_clk_query()

Current Renesas sound driver is assuming that all Sampling rate and
channles are possible to use, but these are depends on inputed clock
and SSI connection situation.
For example, if it is using 1 SSI, enabled TDM mode and has 12288000
input clock, 2ch output can support until 192000Hz, but 6ch output can
support until 64000Hz, 8ch can support 48000Hz.
To control these situation correctly, it needs to support
hw_constraints / refine feature.

To support such feature, this patch adds new rsnd_ssi_clk_query().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1ff9593d 14-Jun-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename "slots" related variable

Current Renesas sound driver has slots and slots_num in
struct rsnd_dai, but these are very un-understandable naming
(It had named from TDM slots).
In this driver, the "slots" means total usable channels, and
"stot_num" means SSI lane number if Multi SSI was used.
To more understandable code, this patch renames "slots" to
"max_channels", and "slots_num" to "ssi_lane", and replaces related
functions name.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8cd8a186 15-May-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't call free_irq() on Parent SSI

If SSI uses shared pin, some SSI will be used as parent SSI.
Then, normal SSI's remove and Parent SSI's remove
(these are same SSI) will be called when unbind or remove timing.
In this case, free_irq() will be called twice.
This patch solve this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a97a06c7 06-Jun-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: cleanup pointer related code

Current rsnd driver is sharing pointer related code between
PIO / DMA. But, it is used only PIO mode now, no longer needed.
This patch cleanup these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 07b7acb5 06-Jun-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: update pointer more accurate

Current rsnd driver updates pointer when DMA transfer was finished
in DMA transfer mode. But PulseAudio requests more accurate
pointer update when timer mode.
This patch consider about DMA transfer residue and update more
accurate pointer.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# f07b38e5 05-Jun-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unused rsnd_ssi_non_ops

rsnd_ssi_non_ops is never used. Let's remove it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7819a942 23-May-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI PIO adjust to 24bit mode

commit 90431eb49bff ("ASoC: rsnd: don't use PDTA bit for 24bit on SSI")
fixups 24bit mode data alignment, but PIO was not cared.
This patch fixes PIO mode 24bit data alignment

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7fa72cca 17-May-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add HDMI output support

Renesas R-Car Gen3 can output HDMI sound if SSIU/SSI are connected to
R-Car built-in HDMI device (R-Car Gen3 built-in HDMI device will be
controlled by DRM/KMS driver).
If SSIx was connected to HDMI0/1 on DT, SSI driver will detect it
automatically by this patch.
Note is that now Renesas R-Car sound driver is assuming that it is
using OF-graph base simple card for HDMI sound.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1f8754d4 15-May-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't call free_irq() on Parent SSI

If SSI uses shared pin, some SSI will be used as parent SSI.
Then, normal SSI's remove and Parent SSI's remove
(these are same SSI) will be called when unbind or remove timing.
In this case, free_irq() will be called twice.
This patch solve this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 90431eb4 15-May-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use PDTA bit for 24bit on SSI

Current SSI uses PDTA bit which indicates data that Input/Output
data are Right-Aligned. But, 24bit sound should be Left-Aligned
in this HW. Because Linux is using Right-Aligned data, and HW uses
Left-Aligned data, current 24bit data is missing lower 8bit.
To fix this issue, this patch removes PDTA bit, and shift 8bit
in necessary module

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6b8530cc 21-Mar-2017 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rcar: ssi: don't set SSICR.CKDV = 000 with SSIWSR.CONT

R-Car Datasheet is indicating "SSICR.CKDV = 000 is invalid when
SSIWSR.WS_MODE = 1 or SSIWSR.CONT = 1".
Current driver will set CONT, thus, we shouldn't use CKDV = 000.
This patch fixup it.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6bf66b1c 06-Dec-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup ssi->usrcnt counter check in hw_params

ssi->usrcnt will be updated on snd_soc_dai_ops::trigger,
but snd_pcm_ops::hw_params will be called *before* it.
Thus, ssi->usrcnt is still 0 when 1st call.
rsnd_ssi_hw_params() needs to check its called count, this means
trigger should be if (ssi->usrcnt) instead of if (ssi->usrcnt > 1).

Reported-by: Nguyen Viet Dung <nv-dung@jinso.co.jp>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# dae4b832 24-Oct-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove rsnd_dma_detach()

DMA mod is now connected to stream via rsnd_dai_connect().
This means DMA mod can use .remove for its clearance.
rsnd_dma_detach() is no longer needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 701172dc 24-Oct-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use devm_request_irq() for SSI

SSI will use DMA mode, and migh be fallback to PIO mode.
Using devm_request_irq() makes its operation more complex when
it fallbacks to PIO mode.
Let's use manual request_irq()/free_irq()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b99305d2 24-Oct-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove non DT support for DMA

Current Renesas Sound driver is based on DeviceTree, and no one is
using this driver from non DT. Non-DT support is no longer needed.
Let's remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0af5c01a 18-Oct-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: amend .probe/.remove call for DPCM

commit 1a5658c2131 ("ASoC: rsnd: count .probe/.remove for
rsnd_mod_call()") solved multi-resource-free issue, by putting
.probe/.remove under count control. But,it breaks sound mixing case
(if it was used under DPCM). In such case, it uses MIXn/DVCn/SSIn,
and these should be always probed.
This patch reverted above patch, and solved the same issue by
modifing _rsnd_kctrl_remove() function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 51930295 05-Aug-2016 Julia Lawall <Julia.Lawall@lip6.fr>

ASoC: use of_property_read_bool

Use of_property_read_bool to check for the existence of a property.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e1,e2;
statement S2,S1;
@@
- if (of_get_property(e1,e2,NULL))
+ if (of_property_read_bool(e1,e2))
S1 else S2
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>


# cbf1494f 06-Mar-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_src_get_in/out_rate()

SRC will convert rate, and then, CMD and SSI want to know its
rate (= SRC.in / SRC.out) for each purpose.
Current driver is supporting only Playback, but SRC+Capture support
needs more flexibility.
This patch adds rsnd_src_get_in/out_rate() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# eed76bb8 24-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_runtime_channel_xxx()

Current SSI is supporting Normal SSI/Multi mode SSI/TDM mode SSI
and its behavior is based on input channels.
This input channel might be converted by CTU,
and SSI needs to be Multi SSI mode / TDM SSI mode if 6ch input

EX) 6ch input, CTU for 2ch, playback

6ch 6ch 2ch 2ch 2ch 2ch
-> SRC -> CTU -> MIX -> DVC -> SSIU -> SSI

EX) 6ch input, no CTU, Multi SSI, playback

6ch 6ch 6ch 6ch 6ch 2ch
-> SRC -> CTU -> MIX -> DVC -> SSIU -> SSI0/SSI1/SSI2

Current driver is using rsnd_get_adinr_chan() / rsnd_get_slot_width()
for this purpose, but it is complicated enough without meaning.
This patch adds new rsnd_runtime_channel_xxx() which is caring
CTU/Multi SSI.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# fd9adcfd 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: judge work SSI in runtime

Current rsnd supports multi SSI (maximum 4 SSI for 8ch),
and, it should determine whether using each SSI or not in runtime.
All SSIs are not used even if there are 4 SSI in case of stereo.

Current driver setups un-used SSI in such case. It is no problem,
but not needed. This patch judges it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4f5c634d 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: judge multi SSI in runtime

Current rsnd supports multi SSI (maximum 4 SSI for 8ch),
and, it should determine whether using each SSI or not in runtime.
Current judgement is vague, and had broken by
c308abe45e2("ASoC: rsnd: rsnd_ssi_is_multi_slave() macro uses
rsnd_ssi_multi_slaves()")
This patch makes clean it, and solve this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 615fb6c7 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: move rsnd_ssi_irq() position

prepare for runtime judging for SSI work

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 098bd891 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: Parent SSI attach is not needed if not clock master

Parent SSI is needed if it is PIN sharing and clock master,
otherwise, not needed. But, whether clockk master is judged on
.set_fmt, thus, it can't call rsnd_ssi_parent_attach() on .probe.

Now, .pcm_new will be called after .set_fmt, so this patch reuses it
at this point.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 0dc6bf75 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup SSI init/start sequence

SSI want to have SSIWSR settings and SSICR settings without EN bit
when init, and SSICR EN bit only when start timing.
Otherwise, SSI output signal might be unstable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c8e969a8 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add missing .irq callback for DMA

commit b5b442abd9d5 ("ASoC: rsnd: add .irq callback") added .irq callback
but SSI DMA is missing it. This patch adds it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5bf5d8fc 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fixup forever loop bug on SSI

commit b5b442abd9 ("ASoC: rsnd: add .irq callback")
added .irq support, and it cares both parent SSI and normal SSI.
But it should care only normal SSI. Otherwise SSI might be
forever loop if SSI is used as both parent SSI and normal SSI
(= 2 users), and if under/over run error happen. Because irq disable
do nothing in such case. This patch solve this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 26d34b11 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI function parameter uses "mod" instead of "ssi"

To reduce confusion, SSI uses "mod" instead of "ssi"
as function parameter

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1120dbff 18-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: indicates status failed SSI

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c308abe4 09-Feb-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_ssi_is_multi_slave() macro uses rsnd_ssi_multi_slaves()

b4c83b171 ("ASoC: rsnd: add Multi channel support") added
Multi channel support, and current rsnd_ssi_is_multi_slave()'s check
method is !SSI equals SSIM1/2/3. But, SSI parent also hit to this macro.
Because of this reason, some stream which needs SSI parent clock
can't work correctly. This patch uses rsnd_ssi_multi_slaves() to
solve this issue. This issue was reported by Dung.

Reported-by: Nguyen Viet Dung <nv-dung@jinso.co.jp>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b5b442ab 25-Jan-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add .irq callback

Current rsnd driver has .init/.start/.stop/.quit callbacks,
and it needs many IPs (SRC/CTU/MUX/DVC/CMD/SSIU/SSI).
Because of these relationship, it might get unnecessary
error IRQ when start/stop.
This patch adds new .irq callback and control IRQ enable/disable
timing to avoid it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6a25c8da 25-Jan-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't auto-recover when under/over run error

Renesas R-Car sound needs recovery (= restart) when under/over run
error occurred, and current driver tries it on under/over run error
handler automatically. But this recovery should be handled by userland,
not kernel. This patch stops XRUN when under/over run error occur, and
will leave the recovery of HW in userland.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 355cb84fb 20-Jan-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: attach Audio-DMAC-periperi correctly

SSI/SRC will try to attach DMAC as Audio-DMAC or Audio-DMAC-periperi.
It is fixed IP, but will be attached to each streams as different module
in case of MUX (= multi sound path will be merged).
This patch solves this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5ba17b42 20-Jan-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: each mod has status again for CTU/MUX support

SSI will be used as normal SSI or as clock parent SSI. Therefor,
rsnd driver wants to control SSI and parent SSI separately. Otherwise it
can't use Playback/Capture in the same time.
And it has been done by c2dc47d5cf("ASoC: rsnd: rsnd_dai_stream has each
mod's status insted of rsnd_mod") before.

OTOH, rsnd driver doesn't want to control CTU/MUX/DVC/SSIU/SSI in
separately. Otherwise, these will be re-initialized during playing if
MUX merges 2 sounds.
Because of these picky reasons, this patch re-defines status on each mod,
and add new parent_ssi_status on rsnd_dai_stream.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 678ea003 20-Jan-2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unsed *parent

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e5d9cfc6 24-Dec-2015 Andrzej Hajda <a.hajda@samsung.com>

ASoC: rsnd: fix usrcnt decrementing bug

Field usrcnt is unsigned so it cannot be lesser than zero.
The patch fixes the check, moves it to the beginning of the function
and changes return value to -EIO in case of usercnt error.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b4c83b17 16-Dec-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add Multi channel support

This patch adds Multi channel support on Renesas R-Car sound.
This patch is tested on Salvator-X board, but it can't use
Multi channel, because supported format is different between
codec chip and R-Car.
Thus, it was tested on board which doesn't mount codec chip,
with oscilloscope.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c140284b 16-Dec-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup rsnd_get_slot_xxx() naming

rsnd_get_slot_rdai() returns total slots (it returns 6 if total 6
channels) , and rsnd_get_slot_extend() returns extended SSI width
(it returns 8 if total 6 channels). This will be used on SSI multi
channel support too (It will return 2 if total 6 channels with 3 SSI).
But, it is using confusable naming.
This patch changes rsnd_get_slot_rdai() -> rsnd_get_slot(),
rsnd_get_slot_extend() -> rsnd_get_slot_width()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 49ee73b4 16-Dec-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI/SSIU use rsnd_get_slot_extend() to check TDM

Current SSI/SSIU are using rsnd_get_slot_runtime() to check TDM,
but using rsnd_get_slot_extend() is more sane.
This patch fix it up

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# f98ed119 02-Dec-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: care SWSP bit for TDM/non-TDM

SSICR::SWSP bit controls WS signal low/high, but in case of TDM
it is inverted. This patch solves this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 186fadc1 30-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add TDM Extend Mode support

Renesas R-Car can out TDM by
1) 6ch x 1 DAI as TDM Extend Mode
2) 2ch x 4 x 1 DAI as TDM split Mode
3) 2ch x 3 DAI or
2ch x 4 DAI as TDM Multichannel Mode

This patch adds 1) TDM Extend Mode. Because of HW design,
this 6ch data will be outputed via 8ch data width.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8ec85e7f 30-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: ssi enables non-stereo sound

Current SSI is assuming that the sound is always stereo. But, SSI needs
to calculate its frequency when master mode. Then This frequency depends
on each SSI's slots, and TDM mode (= TDM Extend Mode, TDM split Mode,
TDM Multichannel Mode).
This patch enables to use non-stereo sound.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 08bada26 30-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: set SSIWSR setting on rsnd_ssi_config_init()

It will have TDM settings on SSIWSR. Actually, we would like to set
it on rsnd_ssi_config_init(), but we can't. Because SSI might be used
as clock master (It doesn't need to call rsnd_ssi_config_init() when
clock master mode).
This patch adds new ssi->wsr and set it on rsnd_ssi_start().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 840ada3b 30-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_ssi_config_init()

In order to enhance code readability, this patch adds
rsnd_ssi_config_init() and moves SSICR register settings to it.
This is prepare patch for TDM support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 5342dff2 26-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup semantics of rsnd_ssi_record_error()

rsnd_ssi_record_error() should recorde error, but it clears error too.
this patch fixes up semantic of rsnd_ssi_record_error that it records
error but doesn't clear error.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2ea6b074 09-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove struct platform_device from probe/remove parameter

Current Renesas sound driver requests struct platform_device on
probe/remove for each modules. But driver can get it by
rsnd_priv_to_pdev(). This patch removes unnecessary parameter

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e797f58e 09-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove struct rsnd_of_data

No board is using Renesas sound driver via platform boot now.
This means all user is using DT boot. Platform boot support is
no longer needed. But, it strongly depends on platform boot style.
Now, platform boot style was removed from driver.
This is cleanup patch, and remove pointless struct rsnd_of_data

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 02534f2f 09-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove platform boot support from ssi.c

No board is using Renesas sound driver via platform boot now.
This means all user is using DT boot. Platform boot support is
no longer needed. But, it strongly depends on platform boot style.
This patch removes platform boot support from ssi.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 94e2710c 09-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove platform boot support from core.c

No board is using Renesas sound driver via platform boot now.
This means all user is using DT boot. Platform boot support is
no longer needed. But, it strongly depends on platform boot style.
This patch removes platform boot support from core.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# f46a93b8 17-Nov-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: ssi: 24bit data needs right-aligned settings

Data left/right aligned is controlled by PDTA bit on SSICR.
But default is left-aligned. Thus 24bit sound will be very small sound
without this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e7d850dd 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod base common method on SSI-parent

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

This patch makes SSI parent mod base common method

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c7f69ab5 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod base common method on SSIU

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

This patch makes SSIU mod base common method

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 497debaa 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod base common method on DMA phase3

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

This patch makes DMA mod bse common method

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 76c80b5b 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod base common method on DMA phase2

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

DMA will be implemented as module. Then rsnd_dma_ops will be rebased
to rsnd_mod_ops, but these are similar, but different function.
This patch modify rsnd_dma_ops same style as rsnd_mod_ops.
This is prepare for final merge

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 940e9479 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod base common method on DMA phase1

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

DMA will be implemented as module. Then rsnd_dma will be mod base.
This patch makes rsnd_dma mod base, but still not yet completely
finished. This mod is not yet installed to system at this point.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e10369d8 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use common rsnd_ssi_status_xxx()

Current ssi.c driver has random access to SSISR register. Let's use
common rsnd_ssi_status_xxx() function

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 69e32a58 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: Don't stop HW even if a large number of errors occur

Current SSI/SRC restarts HW if under/over flow happened to avoid L/R
invert issue. But it will stop HW if too many error happen.
But if it stops on HW, other side under/over flow happen. OTHA, it will
be forever loop interrupt if something strange error happen on
HW/driver without escape route of large number error.

To avoid this issue, it indicates error message if large number error
occur, and disables error interrupt.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 37447b46 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: move rsnd_src_ssi_irq_enable/disable() to ssi.c

Part of SSI IRQ enable/disable was controlled by SRU (on Gen1)
or CMD (on Gen2). Because of this reason SSI IRQ function was
implemented under src.c. but it is not understandable.
Let's move it to ssi.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 81ecbb65 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename rsnd_dma_init() to rsnd_dma_attach()

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

DMA will be implemented as module. Then each rsnd_dma_ops will be
rsnd_mod_ops. But current rsnd_dma_ops::init means "DMA attach".
This patch removes .init from rsnd_dma_ops, and renames
rsnd_dma_init() to rsnd_dma_attach()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 232c00b6 26-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: DMA become SSI/SRC member

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

Current rsnd_mod is member of rsnd_mod. But the DMA user is only
SSI/SRC. This DMA will be implemented as module. As 1st step, DMA
become SSI/SRC member by this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b415b4d3 21-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove duplicate parameter from rsnd_ssi_xxx()

rsnd_ssi_use_busif() and rsnd_ssi_is_pin_sharing() are the function
which returns current SSI status. But these requests duplicated parameter.
This patch removes duplicated parameter.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 69819f52 21-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unused rsnd_dma_to_ssi() macro

rsnd_dma_to_ssi() is no longer used, let's remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c9929345 21-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename rsnd_mod_hw_start/stop to rsnd_mod_power_on/off

rsnd_mod_hw_start/stop were unclear naming.
It became rsnd_mod_power_on/off by this patch

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b05ce4c0 21-Oct-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fixup devm_request_irq() option on ssi.c

bfc0cfe("ASoC: rsnd: don't use rsnd_mod_to_io() on rsnd_ssi_xxx()")
tidyuped devm_request_irq() option from ssi to mod, but devm_free_irq()
on rsnd_ssi_dma_remove() didn't modified. This patch fixups this issue.
Otherwise kernel will output WARNING message.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# dcc448e6 06-Oct-2015 Geert Uytterhoeven <geert+renesas@glider.be>

ASoC: rsnd: Remove obsolete platform data support

Since commit 3d7608e4c169af03 ("ARM: shmobile: bockw: remove legacy
board file and config"), Renesas R-Car SoCs are only supported in
generic DT-only ARM multi-platform builds. The driver doesn't need to
use platform data anymore, hence remove platform data configuration.

Move <sound/rcar_snd.h> to sound/soc/sh/rcar/, as it's no longer needed
by platform code.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>


# eae6fff4 10-Sep-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup ADG clock calculate method

Current ADG clock calculation needs ADG and SSI settings.
Thus, SSI side clock request function depends on ADG settings.
After reconsideration, we can close this method inside ADG.
This function uses new method. And it becomes preparation for
AUDIO_CLKOUT support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b76e218a 10-Sep-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_mod_get() macro and use it

Renesas sound driver has SSI/SRC/DVC/CTU/MIX, and these are controlled
as modules. And these module are member of each modules's private data.
It used own method to get module pointer, but Let's use common method

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# afa70072 15-Jul-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unnecessary 'out of memory' message from SSI

Current checkpatch.pl indicates 'out of memory' message is unnecessary.
Let's remove it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d5bbe7de 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: move rsnd_mod_is_working() to rsnd_io_is_working()

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. In such case, mod <-> io is no longer 1:1
relationship.
This patch checks module working status via io instead of mod

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# bfc0cfe6 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use rsnd_mod_to_io() on rsnd_ssi_xxx()

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. In such case, mod <-> io is no longer 1:1
relationship. This patch removes rsnd_mod_to_io() from rsnd_ssi_xxx()
and related function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9b99e9a7 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use rsnd_mod_to_io() on rsnd_dma_xxx()

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. In such case, mod <-> io is no longer 1:1
relationship. This patch removes rsnd_mod_to_io() from rsnd_dma_xxx()
and related function

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4e2639ff 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't use rsnd_mod_to_io() on rsnd_get_adinr()

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. In such case, mod <-> io is no longer 1:1
relationship. This patch removes rsnd_mod_to_io() from rsnd_get_adinr()
and its related function

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2c0fac19 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: adds struct rsnd_dai_stream as on each fuction as parameter

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. In such case, mod <-> io is no longer 1:1
relationship. This means we can't call rsnd_mod_to_io() any more.
This patch adds struct rsnd_dai_stream to each function as parameter.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2099bc8e 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_mod has rsnd_priv

Each Renesas sound mod (= SSI/SRC/DVC) might be called from many paths
if it supports MIXer. In such case, mod <-> io is no longer 1:1
relationship. This means we can't use rsnd_mod_to_io() in SSI/SRC/DMA
interrupt handler. In such case, we need to check all io in interrupt
handler, and then, "priv" is needed.
This patch adds rsnd_priv pointer in rsnd_mod for prepare it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 75defee0 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't call snd_pcm_period_elapsed() under spin lock

'a9e1ac1a9e4585b5("ASoC: rsnd: spin lock for interrupt handler")'
added spin lock under interrupt handler to solve HW restart issue.

OTOH, current rsnd driver calls snd_pcm_period_elapsed() from
rsnd_dai_pointer_update(). but, it will be called under spin lock
if SSI was PIO mode.

If it was called under spin lock, it will call
snd_pcm_update_state() -> snd_pcm_drain_done().
Then, it calls rsnd_soc_dai_trigger() and will be dead-lock.
This patch doesn't call rsnd_dai_pointer_update() under spin lock

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 12927a8f 15-Jun-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: don't care under/over run error when PIO

PIO is used only for checking data path / codec settings. And underrun
is very normal when PIO mode. Let's don't care about under/over run
error when PIO case. Otherwise, 1) too many HW restart happens, 2) some
sounds which need much data transfer can't play since it falls into
error detection method which was created for DMA transfer

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 02299d98 20-May-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: spin lock for interrupt handler

Renesas R-Car driver interrupt handler was not locked before.
But now, SSI/SRC interrupt handler calls restart function
which should be called under spin lock.
Below error might happen witout this patch.

Unable to handle kernel NULL pointer dereference at virtual address 00000048
pgd = edfac000
[00000048] *pgd=6e0f0831, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] SMP ARM
CPU: 0 PID: 2009 Comm: aplay Not tainted 4.1.0-rc2-dirty #4
Hardware name: Generic R8A7790 (Flattened Device Tree)
task: eeac9040 ti: eebe8000 task.ti: eebe8000
PC is at rsnd_get_adinr+0x28/0x60
LR is at rsnd_src_ssiu_start+0xdc/0x19c
pc : [<c0409790>] lr : [<c040c068>] psr: a0000193
sp : eebe9e58 ip : eebe9e68 fp : eebe9e64
r10: c06ed9d0 r9 : ee919d10 r8 : 00000001
r7 : 00000001 r6 : ee1cb090 r5 : 00000000 r4 : edcaa418
r3 : 00000000 r2 : eea8ce00 r1 : 80000193 r0 : edcaa418
...

Reported-by: Cao Minh Hiep <cm-hiep@jinso.co.jp>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Tested by: Cao Minh Hiep <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b8473579 20-May-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: indicate unknown HW start

rsnd_ssi_hw_stop() should be called after rsnd_ssi_hw_start().
This patch indicates unknown hw_stop as error

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Tested by: Cao Minh Hiep <cm-hiep@jinso.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 919567d9 10-Apr-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: make sure SSI parent/child uses same number of sound channel.

SSI parent/child need to use same number of sound data channel
if these are sharing clock/ws pin. this patch makes it sure.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8c5c79a1 10-Apr-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup SSI parent related function/macro names

Current rsnd driver is using SSI parent related function/macro as
"clock" related. but it is not only clock related.
tidyup function/macro naming.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b543b52a 25-Mar-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove useless debug message

This patch removes useless debug message. especially some kind of
"probed" message will be printed from core.c if it has #define DEBUG

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2f78dd7f 25-Mar-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: call clk_prepare/unprepare() in probe/remove

clk_prepare_enable()/clk_disable_unprepare() uses mutex inside,
in concretely clk_prepare()/clk_unprepare().And it uses __schedule().
Then, raw_spin_lock/unlock_irq() is called, and it breaks Renesas
sound driver's spin lock irq.
This patch separates thesse into clk_prepare()/clk_unprepare() and
clk_enable/clk_disable. And call clk_prepare()/clk_unprepare() from
probe/remove function. Special thanks to Das Biju.

Reported-by: Das Biju <biju.das@bp.renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 044930b4 18-Mar-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: no more SSI restart when unusual situation

It will be SSI interrupt endless loop f unusual situation happen.
This patch adds restart limit for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 72adc61f 20-Feb-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: 1st DMAC dma-names cares subnode

Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.

dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.

And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.

In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.

This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...

rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...

rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 04e627ba 20-Feb-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: ssi: add rsnd_ssi_of_node()

This patch adds rsnd_ssi_of_node() to get SSI subnode from DT.
This is prepare for new DT bindings for 1st DMAC

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# e879a9dd 20-Feb-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: enable rsnd_ssi_use_busif() for DMA

Renesas R-Car sound driver uses SSI, but the DMA interfaces are
SSI/SSIU. This interface is based on SSI/SRC/DVC connection.
And DMA function needs to know which interface is used somehow.
This patch enables rsnd_ssi_use_busif() for DMA.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8a2ff426 20-Feb-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove un-needed parameter from rsnd_dma_quit()

priv is not used on rsnd_dma_quit()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 9c706ab2 20-Feb-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unused rsnd_dma_available()

rsnd_dma_available() is not used. Let's remove it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4715219e 20-Feb-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove un-needed parameter from rsnd_dma_init()

It can get DMA direction via rsnd_dai_stream.
Remove un-needed is_play from rsnd_dma_init().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1ceeab26 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup DMA start/stop timing on SSI

Current DMA starts after SSI, and stops before SSI. but we need
to reverse these order. Otherwise, under/over run error might happen.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 765ae7c8 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: ignore DIRQ when DMA transfer

SSI interrupt handler of R-Car sound driver will be called
when DIRQ (= Data read/write timing for PIO) or
UIRQ / OIRQ (= under/over run error).
DIRQ "interrupt" doesn't occur when DMA transfer, but then,
DIRQ "status bit" might occur. we need to ignore this DIRQ
operation when DMA. Otherwise, driver will push/pop as PIO.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 337b0b4c 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: error meesage indicates its port

Current SRC/SSI output its error, but it desn't indicate
port number. it is un-understandable.
Let's indicate port number for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1b13d118 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: save priv in struct rsnd_dai

Current rsnd driver has rsnd_mod_to_priv() macro, and struct rsnd_mod
has struct rsnd_priv pointer. But, it is waste of memory from data
structure point of view.
Today we can link mod <-> io <-> rdai each other, so saving priv in
rdai is very reasonable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 690602fc 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: replace rdai to priv in each function

Current rsnd driver's function requests rdai, but it is not used.
Adding priv is more reasonable. Let's replace it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# f708d944 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unsed rdai parameter from each function

Current rsnd driver's many functions requests struct rsnd_dai (= rdai),
but, 1) we can get rdai from rsnd_io_to_rsnd(), 2) almost all rdai
is not used. Let's remove these rdai.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 985a4f6e 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: replace rsnd_dai_is_play() to rsnd_io_is_play()

Current rsnd driver can use rsnd_io_to_rdai()
we can get play/capture direction via io now.
Let's replace rsnd_dai_is_play() to rsnd_io_is_play()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3ed6448c 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename rsnd_dai_is_clk_master() to rsnd_rdai_is_clk_master()

struct rsnd_dai is called as "rdai", and struct snd_soc_dai is called
as "dai" on this driver. but macro/function have confusable naming.
This patch rename rsnd_dai_is_clk_master() to rsnd_rdai_is_clk_master()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 85642952 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_mod controls clock

Current rsnd driver's mod (= ssi/src/dvc) have each own clk,
but, these are needed to start/stop each mod.
This patch adds struct clk in rsnd_mod, and start/stop these
via rsnd_mod_hw_start/stop() macro

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 798cbb40 15-Jan-2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove unsed .rate

rsnd_ssi::rate is not used. Let's remove it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6cfad789 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename SSI function name of PIO

Current R-Car sound SSI PIO/DMA mode are using interrupt.
it is no longer "xxx_pio_xxx", rename it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4e7d606c 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add salvage support for under/over flow error on SSI

L/R channel will be switched if under/over flow error happen on
Renesas R-Car sound device by the HW bugs. Then, HW restart is required
for salvage. This patch add salvage support for SSI.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 49229850 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: share SSI starting method between PIO/DMA mode

Basically, SSI starting method is same between PIO/DMA mode.
Let's share it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7b466fc6 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: synchronize SSI start/stop sequence between PIO/DMA mode

Current SSI start/stop sequence is different between PIO/DMA mode,
but, almost all are same. this patch synchronize it.
It will be shared in the future.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3ba84f45 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: clear status register when HW start

Let's clear SSI status when HW start

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d1b64056 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: care SSIWSR register in rsnd_ssi_hw_start()

Current SSI is careing SSIWSR which controls WS continue mode when
DMA mode, but, it should be cared when PIO mode too.
This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# c17dba8b 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup SSI interrupt enable/disable method

Current SSI doesn't care interrupt "disable" method. And, it is used
when PIO mode only at this point. SSI interrupt will be used for
sound R/L issue workaround when DMA mode too.
This patch tidyup SSI interrupt enable/disable method.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 05795411 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup PIO/DMA mode settings method

Current ssi.c has .cr_etc which is used for SSICR's
etc settings. but, it is used as PIO/DMA switching purpose now.
This patch tidyup this method. This is prepare for
under/over run issue handling

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 660cdce2 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_src_ssiu_stop() stops SSIU compulsorily

rsnd_src_ssiu_stop() is used to stop SSIU,
but it shouldn't depend on whether it is using SSIU.
This patch stops SSIU compulsorily.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 97463e19 27-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add .fallback callback

Current R-Car sound has PIO fallback support if it couldn't use DMA.
This fallback is done in .remove callback, but, it should have
.fallback callback. Otherwise, normal .remove callback will have
strange behavior. This patch adds .fallback callback.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d3a76823 09-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: fallback to PIO mode if DMA mode was failed

Current Renesas R-Car sound driver probe will be failed
if it try to use DMA mode and it couldn't use for some reasons.
But PIO mode works even though in such case.
This patch try to fallback to PIO mode if DMA mode probing was failed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 30cc4faf 09-Nov-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup debug message format and timing

Current Renesas R-Car sound driver debug message
is using random format
(ex "ssi0: xxx" / "SSI0 xxx" / "ssi[0]: xxx")
and confusable timing
("xxx probe failed" and "xxx probed" are shown in same time)
This patch fixes these

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# d9288d0b 22-Jun-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI + DMA can select BUSIF

Sound data needs to be sent to R-Car sound SSI when playback.
But, there are 2 interfaces for it.
1st is SSITDR/SSIRDR which are mapped on SSI.
2nd is SSIn_BUSIF which are mapped on SSIU.

2nd SSIn_BUSIF is used when DMA transfer,
and it is always used if sound data came from via SRC.
But, we can use it when SSI+DMA case too.
(Current driver is assuming 1st SSITDR/SSIRDR for it)

2nd SSIn_BUSIF can be used as FIFO.
This is very helpful/useful for SSI+DMA.

But DMA address / DMA ID are not same between 1st/2nd cases.
This patch care about these settings.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 199e7688 23-May-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: care DMA slave channel name for DT

Renesas sound driver is supporting to use DMAEngine.
But, DMA slave channel name "tx", "rx" is not enough
in DT case.
Becuase, it has many ports and path combination.

This patch adds rsnd_dma_of_name() to find
DMA channel name, for example
memory to SSI0 is "mem_ssi0",
SSI0 to memory is "ssi0_mem",
SSI0 to SRC0 is "ssi0_src0",
SRC0 to SSI0 is "src0_ssi0",
SRC0 to DVC0 is "src0_dvc0"...

Renesas sound want to use PIO transfer mode for some reasons.
It will be PIO tranfer mode if device node doesn't have
DMA settings.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8aefda50 23-May-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: module name is unified

Renesas sound driver uses many modules (= SSI/SRC/DVC),
and each module had own name.
But, each module name can be used as several purpose,
like clock name, DMA name etc...
This patch uses common name for each module.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# f451e48d 23-May-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: DT node clean up by using the of_node_put()

Driver needs to call of_node_put() after of_get_chile_by_name()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# b42fccf6 08-May-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove duplicate parameter from rsnd_mod_ops

Now, it can get rsnd_dai_stream pointer from rsnd_mod.
Remove duplicate parameter from rsnd_mod_ops

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 29e69fd2 08-May-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove compatibility code

Now, all platform is using new style rsnd_dai_platform_info.
Keeping compatibility is no longer needed.
We can cleanup code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 79861bbb 10-Apr-2014 Ben Dooks <ben.dooks@codethink.co.uk>

ASoC: rsnd: fix clock prepare/unprepare

As with the previous commit, before a clock can be used it must be prepared
for use. Change from clk_enable() and clk_disable() to the versions of the
calls which also prepare and un-prepare the clocks.

Will fix warnings from the clock code when this is used.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 90e8e50f 17-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add DeviceTree support

Support for loading the Renesas R-Car sound driver via DeviceTree.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# ba9c949f 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rename scu to src

R-Car sound has SCU unit which has SRC/CTU/MIX/DVC,
and current rsnd driver has scu.c and scu module.
Current scu.c has SRC support only.
My first concept was control these feature on scu.c
but, it become difficult and un-understandable now.
This patch rename scu to src

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 9524be0e 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove all rsnd_xxx_remove()

Now, rsnd_xxx_remove() do nothing.
remove these

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# ff8f30e6 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod probe method on SSI

Now, it can use .probe

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 221bf523 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: call rsnd_scu_ssi_mode_init() from SSI

Current R-Car sound driver is assuming that
SCU mod is used even though it is not needed.
Because scu.c is controlling SSIU too.
(it is Gen1 compatibility)
But, SCU mod will be really not used if new platform dai
feature was added.
Thus, rsnd_scu_ssi_mode_init() is called from SSI
directory by this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# b8cc41e9 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_scu_enable_ssi_irq()

Current R-Car sound driver is assuming that
SCU mod is used even though it is not needed.
Because scu.c is controlling SSIU too.
(it is Gen1 compatibility)
But, SCU mod will be really not used if new platform dai
feature was used.
Thus, SSIU irq setting is called from SSI
directory by this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 389933d9 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: Get correct SCU ID

Current rsnd driver is assuming that SCU/SRU ID is
same as SSIU/SSI ID, because Gen1 can't select it.
But, Gen2 can select it.
The SCU/SRU/SSIU/SSI pair depends on the platform.
This patch get correct SCU ID from platform info.
To keep compatible, it still assuming SCU ID = SSI ID
if platform doesn't have info

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 78f13d0c 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add struct rsnd_dai_platform_info

R-Car sound DAI consists from SSI/SCU/SSIU/SRU...
Current R-Car sound DAI is decided from these settings,
but it is intuitively unclear, and is not good design for DT support.
This patch adds new rsnd_dai_platform_info to solve this issue.

But now, many platform is using this driver without
rsnd_dai_platform_info.
So, this patch still supports DAI settings via SSI to keep compatible.
It will be removed in next Linux version.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 374e5426 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: get ssi/scu from rsnd_dai_stream

Current driver is assuming that SSI id = SCU id.
But, now, it can get correct SSI/SCU from
rsnd_dai_stream. use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# a126021d 03-Mar-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: use mod array instead of list on rdai

struct rsnd_dai_stream used list for mod list.
It added only odd flexibility to current driver, and
it is a factor which makes extendibility difficult.
rsnd use mod array instead of list from now.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 98455ed5 24-Feb-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove verbose debug message from scu/ssi

scu/ssi probe() already have more detail debug message.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 5da39cf3 24-Feb-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove verbose function parameter

priv has rcar_snd_info pointer.
having priv and info in same time is verbose.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 4686a0ad 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove SSI dependent DMAEngine callback

Renesas Gen2 sound will use 2 DMAC
which are Audio-DMAC, and Audio-DMAC-peri-peri.
Current driver has callback function for each DMAC,
because it assumed each DMAC needs special settings.
But it became clear that these can share settings.
This patch removes unnecessary callback

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 1b7b08ef 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: extracts Gen1/Gen2 common parts

Renesas sound IP Gen1/Gen2 are similar, but different.
This patch extracts Gen1/Gen2 common and dependency parts,
and create Gen1/Gen2 ops to control it.

According to this structure, SSIU setup which
has been implemented on ssi.c can be moved to scu.c
(SRU/SSIU/SCU should be implemented on scu.c)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 32f27ebf 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add rsnd_ssi_is_play()

SCU needs SSI direction if Gen2.
Add rsnd_ssi_is_play() function for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# dd27d808 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove ssiu from ssi.c

Now, SSI_MODE0/1 are controlled under scu.c
ssiu is no longer needed on ssi.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 7b5ce975 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI_MODE0/1 settings goes to scu.c

SRU (Gen1) / SCU (Gen2) / SSIU (Gen2) are controlled under scu.c.
(SCU + SSIU (Gen2) was SRU (Gen1))
And register of SSI_MODE0/1 are mapped on these IP.
But these have been implemented under ssi.c on this driver.
The naming is very confusable,
but it should be implemented under scu.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 6f3ab6c1 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove pin sync option

Renesas Chip is supporting multi pin sound,
but the HW setting is very difficult and confusable.
But driver is supporting it halfway.
Remove SYNC option at this point.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# e779a20d 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: rsnd_dai_is_clk_master() can be shared

Current rsnd driver is using ssi local
rsnd_rdai_is_clk_master() for checking clock master.
But it can be rsnd_dai_is_clk_master(), and share in each file

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 6acef172 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove meaningless rsnd_ssi_non()

rsnd_ssi_non_ops callback functions are never called.
remove these meaningless callback

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 92d9587e 23-Jan-2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: cleanup debug information method

rsnd_mod debug information is implemented
in each callback functions now.
But, it can be implemented in rsnd_mod_call(),
and share this code.
This patch adds it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# ef749400 19-Dec-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: add SRC (Sampling Rate Converter) support

This patch adds SRC support to Renesas sound driver.
SRC converts sampling rate between codec <-> cpu.
It needs special codec chip,
or very simple DA/AD converter to use it.
This patch was tested via ak4554 codec,
and supports Gen1 only at this point.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# adcf7d5e 19-Dec-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup rsnd_ssi_master_clk_start() parameter

Renesas sound has SRC (= Sampling Rate Converter),
but, the HW implementation depends on its generation.
It was part of SRU on Gen1, and SCU on Gen2.
This SCU needs DMA transfer to use it.
Current rsnd driver is using it as DMA transfer buffer
(= no rate convert), and Gen1 is only supported at this point.

This patch cleanup it with focusing about SRC and Gen2 part.

ssi clock which is calculated from rsnd_ssi_master_clk_start()
should have flexibility since Renesas sound has
SRC (= Sampling Rate Converter).
But current implementation is using runtime->rate directly.
This patch tidyup rsnd_ssi_master_clk_start() parameter
as preparation of future SRC support

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 52ea2a79 19-Dec-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: INT_ENABLE is needed only Gen2

INT_ENABLE is needed only Gen2.
rsnd_mod_write() do nothing on Gen1, but it is confusable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 729aca51 19-Dec-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: tidyup ssi comment

we can check rsnd_ssi_init(), not, rsnd_ssi_start()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 60dbb4f1 03-Dec-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rcar: use devm_clk_get() instead of clk_get()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 507d466c 28-Nov-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rcar: add Gen2 sound support

This patch adds Gen2 sound support for Renesas R-Car.
But, it is supporting PIO transfer only at this point

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 8b14719b 05-Nov-2013 Takashi Iwai <tiwai@suse.de>

ASoC: rcar: Use WARN_ON() instead of BUG_ON()

Use WARN_ON() and handle the error cases accordingly.

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 92eba04e 17-Oct-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rcar: remove RSND_SSI_CLK_FROM_ADG

R-Car sound has clock pin for each SSI, and sometimes,
these pins are shared with paired SSI.
It may sometimes become "SSI-A clock pin is master" and
"SSI-B clock pin is slave", but "SSI-A/B clock pins are shared".
SSI-B needs SSI-A clock in this case.

Current R-Car sound driver is using RSND_SSI_xxx flag
to control this kind of shared pin behavior.

But, this information, especially clock master setting,
can be got from ASoC set_fmt settings.
This patch removes rsnd_ssi_mode_init() and extend rsnd_ssi_mode_set()
to controlling pin settings via .set_fmt.

This patch doesn't removes RSND_SSI_CLK_FROM_ADG flag at this point
to avoid conflict branch merging between ASoC <-> SH-ARM.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# cdcfcac9 17-Oct-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rcar: add rsnd_scu_hpbif_is_enable()

Current SSI needs RSND_SSI_DEPENDENT flag to
decide dependent/independent mode.
And SCU needs RSND_SCU_USE_HPBIF flag
to decide HPBIF is enable/disable.
But these 2 means same things.

This patch adds new rsnd_scu_hpbif_is_enable()
function, and merges above methods.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 374a5281 28-Jul-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI supports DMA transfer via BUSIF

This patch adds BUSIF support for R-Car sound DMAEngine transfer.
The sound data will be transferred via FIFO which can cover blank time
which will happen when DMA channel is switching.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 849fc82a 28-Jul-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: SSI supports DMA transfer

This patch adds DMAEngine transfer on SSI.
But, it transfers sound data from memory to SSI directly
without using HPBIF at this time.
It will be updated soon

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# 4b4dab82 28-Jul-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: rsnd: remove platform dai and add dai_id on platform setting

Current rsnd driver is using struct rsnd_dai_platform_info
so that indicate sound DAI information (playback/capture SSI ID).
But, SSI settings were also required separately.
Thus, platform settings was very un-understandable.
This patch adds dai_id to SSI
settings, and removed rsnd_dai_platform_info.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>


# ae5c3223 21-Jul-2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: add Renesas R-Car SSI feature

Renesas R-Car series sound circuit consists of SSI and its peripheral.
But this peripheral circuit is different between
R-Car Generation1 (E1/M1/H1) and Generation2 (E2/M2/H2)
(Actually, there are many difference in Generation1 chips)

As 1st protype, this patch adds SSI feature on this driver.
But, it is PIO sound playback support only at this point.
The DMA transfer, and capture feature will be supported in the future

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>