2018-06-12 12:58:38 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//
|
|
|
|
// Renesas R-Car SSIU support
|
|
|
|
//
|
|
|
|
// Copyright (c) 2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
#include "rsnd.h"
|
|
|
|
|
|
|
|
#define SSIU_NAME "ssiu"
|
|
|
|
|
|
|
|
struct rsnd_ssiu {
|
|
|
|
struct rsnd_mod mod;
|
2018-09-03 14:08:37 +07:00
|
|
|
u32 busif_status[8]; /* for BUSIF0 - BUSIF7 */
|
|
|
|
unsigned int usrcnt;
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
int id;
|
|
|
|
int id_sub;
|
2015-10-26 15:43:41 +07:00
|
|
|
};
|
|
|
|
|
2018-11-06 12:21:46 +07:00
|
|
|
/* SSI_MODE */
|
|
|
|
#define TDM_EXT (1 << 0)
|
|
|
|
#define TDM_SPLIT (1 << 8)
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
#define rsnd_ssiu_nr(priv) ((priv)->ssiu_nr)
|
2018-09-03 14:08:37 +07:00
|
|
|
#define rsnd_mod_to_ssiu(_mod) container_of((_mod), struct rsnd_ssiu, mod)
|
2015-10-26 15:43:41 +07:00
|
|
|
#define for_each_rsnd_ssiu(pos, priv, i) \
|
|
|
|
for (i = 0; \
|
|
|
|
(i < rsnd_ssiu_nr(priv)) && \
|
|
|
|
((pos) = ((struct rsnd_ssiu *)(priv)->ssiu + i)); \
|
|
|
|
i++)
|
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
/*
|
|
|
|
* SSI Gen2 Gen3
|
|
|
|
* 0 BUSIF0-3 BUSIF0-7
|
|
|
|
* 1 BUSIF0-3 BUSIF0-7
|
|
|
|
* 2 BUSIF0-3 BUSIF0-7
|
|
|
|
* 3 BUSIF0 BUSIF0-7
|
|
|
|
* 4 BUSIF0 BUSIF0-7
|
|
|
|
* 5 BUSIF0 BUSIF0
|
|
|
|
* 6 BUSIF0 BUSIF0
|
|
|
|
* 7 BUSIF0 BUSIF0
|
|
|
|
* 8 BUSIF0 BUSIF0
|
|
|
|
* 9 BUSIF0-3 BUSIF0-7
|
|
|
|
* total 22 52
|
|
|
|
*/
|
|
|
|
static const int gen2_id[] = { 0, 4, 8, 12, 13, 14, 15, 16, 17, 18 };
|
|
|
|
static const int gen3_id[] = { 0, 8, 16, 24, 32, 40, 41, 42, 43, 44 };
|
|
|
|
|
2018-10-30 14:46:05 +07:00
|
|
|
static u32 *rsnd_ssiu_get_status(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
enum rsnd_mod_type type)
|
|
|
|
{
|
|
|
|
struct rsnd_ssiu *ssiu = rsnd_mod_to_ssiu(mod);
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
int busif = rsnd_mod_id_sub(mod);
|
2018-10-30 14:46:05 +07:00
|
|
|
|
|
|
|
return &ssiu->busif_status[busif];
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
static int rsnd_ssiu_init(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
|
|
|
{
|
|
|
|
struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
|
2019-06-26 08:58:56 +07:00
|
|
|
u32 ssis = rsnd_ssi_multi_slaves_runtime(io);
|
2015-10-26 15:43:41 +07:00
|
|
|
int use_busif = rsnd_ssi_use_busif(io);
|
|
|
|
int id = rsnd_mod_id(mod);
|
2019-06-26 08:58:56 +07:00
|
|
|
int is_clk_master = rsnd_rdai_is_clk_master(rdai);
|
|
|
|
u32 val1, val2;
|
2018-12-12 14:03:58 +07:00
|
|
|
int i;
|
2015-10-26 15:43:41 +07:00
|
|
|
|
2016-10-26 11:29:21 +07:00
|
|
|
/* clear status */
|
|
|
|
switch (id) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
2018-12-12 14:03:58 +07:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
rsnd_mod_write(mod, SSI_SYS_STATUS(i * 2), 0xf << (id * 4));
|
2016-10-26 11:29:21 +07:00
|
|
|
break;
|
|
|
|
case 9:
|
2018-12-12 14:03:58 +07:00
|
|
|
for (i = 0; i < 4; i++)
|
2019-02-04 20:41:05 +07:00
|
|
|
rsnd_mod_write(mod, SSI_SYS_STATUS((i * 2) + 1), 0xf << 4);
|
2016-10-26 11:29:21 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
/*
|
|
|
|
* SSI_MODE0
|
|
|
|
*/
|
|
|
|
rsnd_mod_bset(mod, SSI_MODE0, (1 << id), !use_busif << id);
|
|
|
|
|
|
|
|
/*
|
2019-06-26 08:58:56 +07:00
|
|
|
* SSI_MODE1 / SSI_MODE2
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* sharing/multi with SSI0 are mainly supported
|
2015-10-26 15:43:41 +07:00
|
|
|
*/
|
2019-06-26 08:58:56 +07:00
|
|
|
val1 = rsnd_mod_read(mod, SSI_MODE1);
|
|
|
|
val2 = rsnd_mod_read(mod, SSI_MODE2);
|
|
|
|
if (rsnd_ssi_is_pin_sharing(io)) {
|
|
|
|
|
|
|
|
ssis |= (1 << id);
|
|
|
|
|
|
|
|
} else if (ssis) {
|
2017-03-03 11:25:09 +07:00
|
|
|
/*
|
2019-06-26 08:58:56 +07:00
|
|
|
* Multi SSI
|
|
|
|
*
|
|
|
|
* set synchronized bit here
|
2017-03-03 11:25:09 +07:00
|
|
|
*/
|
2019-06-26 08:58:56 +07:00
|
|
|
|
|
|
|
/* SSI4 is synchronized with SSI3 */
|
|
|
|
if (ssis & (1 << 4))
|
|
|
|
val1 |= (1 << 20);
|
|
|
|
/* SSI012 are synchronized */
|
|
|
|
if (ssis == 0x0006)
|
|
|
|
val1 |= (1 << 4);
|
|
|
|
/* SSI0129 are synchronized */
|
|
|
|
if (ssis == 0x0206)
|
|
|
|
val2 |= (1 << 4);
|
2015-10-26 15:43:41 +07:00
|
|
|
}
|
|
|
|
|
2019-06-26 08:58:56 +07:00
|
|
|
/* SSI1 is sharing pin with SSI0 */
|
|
|
|
if (ssis & (1 << 1))
|
|
|
|
val1 |= is_clk_master ? 0x2 : 0x1;
|
|
|
|
|
|
|
|
/* SSI2 is sharing pin with SSI0 */
|
|
|
|
if (ssis & (1 << 2))
|
|
|
|
val1 |= is_clk_master ? 0x2 << 2 :
|
|
|
|
0x1 << 2;
|
|
|
|
/* SSI4 is sharing pin with SSI3 */
|
|
|
|
if (ssis & (1 << 4))
|
|
|
|
val1 |= is_clk_master ? 0x2 << 16 :
|
|
|
|
0x1 << 16;
|
|
|
|
/* SSI9 is sharing pin with SSI0 */
|
|
|
|
if (ssis & (1 << 9))
|
|
|
|
val2 |= is_clk_master ? 0x2 : 0x1;
|
|
|
|
|
|
|
|
rsnd_mod_bset(mod, SSI_MODE1, 0x0013001f, val1);
|
|
|
|
rsnd_mod_bset(mod, SSI_MODE2, 0x00000017, val2);
|
2015-12-17 10:00:10 +07:00
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct rsnd_mod_ops rsnd_ssiu_ops_gen1 = {
|
2018-10-30 14:46:05 +07:00
|
|
|
.name = SSIU_NAME,
|
|
|
|
.init = rsnd_ssiu_init,
|
|
|
|
.get_status = rsnd_ssiu_get_status,
|
2015-10-26 15:43:41 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int rsnd_ssiu_init_gen2(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
|
|
|
{
|
2018-09-03 14:08:37 +07:00
|
|
|
struct rsnd_ssiu *ssiu = rsnd_mod_to_ssiu(mod);
|
2018-11-06 12:19:48 +07:00
|
|
|
u32 has_hdmi0 = rsnd_flags_has(io, RSND_STREAM_HDMI0);
|
|
|
|
u32 has_hdmi1 = rsnd_flags_has(io, RSND_STREAM_HDMI1);
|
2015-10-26 15:43:41 +07:00
|
|
|
int ret;
|
2017-11-28 14:05:13 +07:00
|
|
|
u32 mode = 0;
|
2015-10-26 15:43:41 +07:00
|
|
|
|
|
|
|
ret = rsnd_ssiu_init(mod, io, priv);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2018-09-03 14:08:37 +07:00
|
|
|
ssiu->usrcnt++;
|
|
|
|
|
2018-11-06 12:21:46 +07:00
|
|
|
/*
|
|
|
|
* TDM Extend/Split Mode
|
|
|
|
* see
|
|
|
|
* rsnd_ssi_config_init()
|
|
|
|
*/
|
|
|
|
if (rsnd_runtime_is_tdm(io))
|
|
|
|
mode = TDM_EXT;
|
|
|
|
else if (rsnd_runtime_is_tdm_split(io))
|
|
|
|
mode = TDM_SPLIT;
|
2015-11-30 15:54:03 +07:00
|
|
|
|
2017-11-28 14:05:13 +07:00
|
|
|
rsnd_mod_write(mod, SSI_MODE, mode);
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
if (rsnd_ssi_use_busif(io)) {
|
2018-09-03 14:08:20 +07:00
|
|
|
int id = rsnd_mod_id(mod);
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
int busif = rsnd_mod_id_sub(mod);
|
2019-02-25 18:14:20 +07:00
|
|
|
enum rsnd_reg adinr_reg, mode_reg, dalign_reg;
|
2018-09-03 14:08:20 +07:00
|
|
|
|
|
|
|
if ((id == 9) && (busif >= 4)) {
|
2019-02-25 18:14:20 +07:00
|
|
|
adinr_reg = SSI9_BUSIF_ADINR(busif);
|
|
|
|
mode_reg = SSI9_BUSIF_MODE(busif);
|
|
|
|
dalign_reg = SSI9_BUSIF_DALIGN(busif);
|
|
|
|
} else {
|
|
|
|
adinr_reg = SSI_BUSIF_ADINR(busif);
|
|
|
|
mode_reg = SSI_BUSIF_MODE(busif);
|
|
|
|
dalign_reg = SSI_BUSIF_DALIGN(busif);
|
2018-09-03 14:08:20 +07:00
|
|
|
}
|
|
|
|
|
2019-02-25 18:14:20 +07:00
|
|
|
rsnd_mod_write(mod, adinr_reg,
|
2018-12-12 14:03:58 +07:00
|
|
|
rsnd_get_adinr_bit(mod, io) |
|
|
|
|
(rsnd_io_is_play(io) ?
|
|
|
|
rsnd_runtime_channel_after_ctu(io) :
|
|
|
|
rsnd_runtime_channel_original(io)));
|
2019-02-25 18:14:20 +07:00
|
|
|
rsnd_mod_write(mod, mode_reg,
|
2018-12-12 14:03:58 +07:00
|
|
|
rsnd_get_busif_shift(io, mod) | 1);
|
2019-02-25 18:14:20 +07:00
|
|
|
rsnd_mod_write(mod, dalign_reg,
|
2018-12-12 14:03:58 +07:00
|
|
|
rsnd_get_dalign(mod, io));
|
2015-10-26 15:43:41 +07:00
|
|
|
}
|
|
|
|
|
2018-11-06 12:19:48 +07:00
|
|
|
if (has_hdmi0 || has_hdmi1) {
|
2017-05-18 08:28:22 +07:00
|
|
|
enum rsnd_mod_type rsnd_ssi_array[] = {
|
|
|
|
RSND_MOD_SSIM1,
|
|
|
|
RSND_MOD_SSIM2,
|
|
|
|
RSND_MOD_SSIM3,
|
|
|
|
};
|
|
|
|
struct rsnd_mod *ssi_mod = rsnd_io_to_mod_ssi(io);
|
|
|
|
struct rsnd_mod *pos;
|
|
|
|
u32 val;
|
|
|
|
int i, shift;
|
|
|
|
|
|
|
|
i = rsnd_mod_id(ssi_mod);
|
|
|
|
|
|
|
|
/* output all same SSI as default */
|
|
|
|
val = i << 16 |
|
|
|
|
i << 20 |
|
|
|
|
i << 24 |
|
|
|
|
i << 28 |
|
|
|
|
i;
|
|
|
|
|
|
|
|
for_each_rsnd_mod_array(i, pos, io, rsnd_ssi_array) {
|
|
|
|
shift = (i * 4) + 16;
|
|
|
|
val = (val & ~(0xF << shift)) |
|
|
|
|
rsnd_mod_id(pos) << shift;
|
|
|
|
}
|
|
|
|
|
2018-11-06 12:19:48 +07:00
|
|
|
if (has_hdmi0)
|
2017-05-18 08:28:22 +07:00
|
|
|
rsnd_mod_write(mod, HDMI0_SEL, val);
|
2018-11-06 12:19:48 +07:00
|
|
|
if (has_hdmi1)
|
2017-05-18 08:28:22 +07:00
|
|
|
rsnd_mod_write(mod, HDMI1_SEL, val);
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rsnd_ssiu_start_gen2(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
|
|
|
{
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
int busif = rsnd_mod_id_sub(mod);
|
2018-09-03 14:08:20 +07:00
|
|
|
|
2015-12-17 10:00:10 +07:00
|
|
|
if (!rsnd_ssi_use_busif(io))
|
|
|
|
return 0;
|
|
|
|
|
2018-09-03 14:08:20 +07:00
|
|
|
rsnd_mod_bset(mod, SSI_CTRL, 1 << (busif * 4), 1 << (busif * 4));
|
2015-12-17 10:00:10 +07:00
|
|
|
|
2016-02-18 15:18:54 +07:00
|
|
|
if (rsnd_ssi_multi_slaves_runtime(io))
|
2015-12-17 10:00:10 +07:00
|
|
|
rsnd_mod_write(mod, SSI_CONTROL, 0x1);
|
2015-10-26 15:43:41 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rsnd_ssiu_stop_gen2(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
|
|
|
{
|
2018-09-03 14:08:37 +07:00
|
|
|
struct rsnd_ssiu *ssiu = rsnd_mod_to_ssiu(mod);
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
int busif = rsnd_mod_id_sub(mod);
|
2018-09-03 14:08:20 +07:00
|
|
|
|
2015-12-17 10:00:10 +07:00
|
|
|
if (!rsnd_ssi_use_busif(io))
|
|
|
|
return 0;
|
|
|
|
|
2018-09-03 14:08:20 +07:00
|
|
|
rsnd_mod_bset(mod, SSI_CTRL, 1 << (busif * 4), 0);
|
2015-12-17 10:00:10 +07:00
|
|
|
|
2018-09-03 14:08:37 +07:00
|
|
|
if (--ssiu->usrcnt)
|
|
|
|
return 0;
|
|
|
|
|
2016-02-18 15:18:54 +07:00
|
|
|
if (rsnd_ssi_multi_slaves_runtime(io))
|
2015-12-17 10:00:10 +07:00
|
|
|
rsnd_mod_write(mod, SSI_CONTROL, 0);
|
2015-10-26 15:43:41 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
static int rsnd_ssiu_id(struct rsnd_mod *mod)
|
|
|
|
{
|
|
|
|
struct rsnd_ssiu *ssiu = rsnd_mod_to_ssiu(mod);
|
|
|
|
|
|
|
|
/* see rsnd_ssiu_probe() */
|
|
|
|
return ssiu->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rsnd_ssiu_id_sub(struct rsnd_mod *mod)
|
|
|
|
{
|
|
|
|
struct rsnd_ssiu *ssiu = rsnd_mod_to_ssiu(mod);
|
|
|
|
|
|
|
|
/* see rsnd_ssiu_probe() */
|
|
|
|
return ssiu->id_sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct dma_chan *rsnd_ssiu_dma_req(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod)
|
|
|
|
{
|
|
|
|
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
|
|
|
int is_play = rsnd_io_is_play(io);
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It should use "rcar_sound,ssiu" on DT.
|
|
|
|
* But, we need to keep compatibility for old version.
|
|
|
|
*
|
|
|
|
* If it has "rcar_sound.ssiu", it will be used.
|
|
|
|
* If not, "rcar_sound.ssi" will be used.
|
|
|
|
* see
|
|
|
|
* rsnd_ssi_dma_req()
|
|
|
|
* rsnd_dma_of_path()
|
|
|
|
*/
|
|
|
|
|
|
|
|
name = is_play ? "rx" : "tx";
|
|
|
|
|
|
|
|
return rsnd_dma_request_channel(rsnd_ssiu_of_node(priv),
|
|
|
|
mod, name);
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
static struct rsnd_mod_ops rsnd_ssiu_ops_gen2 = {
|
2018-10-30 14:46:05 +07:00
|
|
|
.name = SSIU_NAME,
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
.dma_req = rsnd_ssiu_dma_req,
|
2018-10-30 14:46:05 +07:00
|
|
|
.init = rsnd_ssiu_init_gen2,
|
|
|
|
.start = rsnd_ssiu_start_gen2,
|
|
|
|
.stop = rsnd_ssiu_stop_gen2,
|
|
|
|
.get_status = rsnd_ssiu_get_status,
|
2015-10-26 15:43:41 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct rsnd_mod *rsnd_ssiu_mod_get(struct rsnd_priv *priv, int id)
|
|
|
|
{
|
|
|
|
if (WARN_ON(id < 0 || id >= rsnd_ssiu_nr(priv)))
|
|
|
|
id = 0;
|
|
|
|
|
|
|
|
return rsnd_mod_get((struct rsnd_ssiu *)(priv->ssiu) + id);
|
|
|
|
}
|
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
static void rsnd_parse_connect_ssiu_compatible(struct rsnd_priv *priv,
|
|
|
|
struct rsnd_dai_stream *io)
|
|
|
|
{
|
|
|
|
struct rsnd_mod *ssi_mod = rsnd_io_to_mod_ssi(io);
|
|
|
|
struct rsnd_mod *mod;
|
|
|
|
struct rsnd_ssiu *ssiu;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!ssi_mod)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* select BUSIF0 */
|
|
|
|
for_each_rsnd_ssiu(ssiu, priv, i) {
|
|
|
|
mod = rsnd_mod_get(ssiu);
|
|
|
|
|
2018-11-21 08:58:30 +07:00
|
|
|
if ((rsnd_mod_id(ssi_mod) == rsnd_mod_id(mod)) &&
|
|
|
|
(rsnd_mod_id_sub(mod) == 0)) {
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
rsnd_dai_connect(mod, io, mod->type);
|
2018-11-21 08:58:30 +07:00
|
|
|
return;
|
|
|
|
}
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai,
|
|
|
|
struct device_node *playback,
|
|
|
|
struct device_node *capture)
|
2015-10-26 15:43:41 +07:00
|
|
|
{
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
|
|
|
|
struct device_node *node = rsnd_ssiu_of_node(priv);
|
|
|
|
struct device_node *np;
|
|
|
|
struct rsnd_mod *mod;
|
|
|
|
struct rsnd_dai_stream *io_p = &rdai->playback;
|
|
|
|
struct rsnd_dai_stream *io_c = &rdai->capture;
|
|
|
|
int i;
|
2015-10-26 15:43:41 +07:00
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
/* use rcar_sound,ssiu if exist */
|
|
|
|
if (node) {
|
|
|
|
i = 0;
|
|
|
|
for_each_child_of_node(node, np) {
|
|
|
|
mod = rsnd_ssiu_mod_get(priv, i);
|
|
|
|
if (np == playback)
|
|
|
|
rsnd_dai_connect(mod, io_p, mod->type);
|
|
|
|
if (np == capture)
|
|
|
|
rsnd_dai_connect(mod, io_c, mod->type);
|
|
|
|
i++;
|
|
|
|
}
|
2015-10-26 15:43:41 +07:00
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
of_node_put(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Keep DT compatibility */
|
|
|
|
if (!rsnd_io_to_mod_ssiu(io_p))
|
|
|
|
rsnd_parse_connect_ssiu_compatible(priv, io_p);
|
|
|
|
if (!rsnd_io_to_mod_ssiu(io_c))
|
|
|
|
rsnd_parse_connect_ssiu_compatible(priv, io_c);
|
2015-10-26 15:43:41 +07:00
|
|
|
}
|
|
|
|
|
2015-11-10 12:14:12 +07:00
|
|
|
int rsnd_ssiu_probe(struct rsnd_priv *priv)
|
2015-10-26 15:43:41 +07:00
|
|
|
{
|
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
struct device_node *node;
|
2015-10-26 15:43:41 +07:00
|
|
|
struct rsnd_ssiu *ssiu;
|
2017-07-17 22:30:20 +07:00
|
|
|
struct rsnd_mod_ops *ops;
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
const int *list = NULL;
|
2015-10-26 15:43:41 +07:00
|
|
|
int i, nr, ret;
|
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
/*
|
|
|
|
* Keep DT compatibility.
|
|
|
|
* if it has "rcar_sound,ssiu", use it.
|
|
|
|
* if not, use "rcar_sound,ssi"
|
|
|
|
* see
|
|
|
|
* rsnd_ssiu_bufsif_to_id()
|
|
|
|
*/
|
|
|
|
node = rsnd_ssiu_of_node(priv);
|
|
|
|
if (node)
|
|
|
|
nr = of_get_child_count(node);
|
|
|
|
else
|
|
|
|
nr = priv->ssi_nr;
|
|
|
|
|
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>
2018-06-13 04:07:58 +07:00
|
|
|
ssiu = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL);
|
2015-10-26 15:43:41 +07:00
|
|
|
if (!ssiu)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
priv->ssiu = ssiu;
|
|
|
|
priv->ssiu_nr = nr;
|
|
|
|
|
|
|
|
if (rsnd_is_gen1(priv))
|
|
|
|
ops = &rsnd_ssiu_ops_gen1;
|
|
|
|
else
|
|
|
|
ops = &rsnd_ssiu_ops_gen2;
|
|
|
|
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
/* Keep compatibility */
|
|
|
|
nr = 0;
|
|
|
|
if ((node) &&
|
|
|
|
(ops == &rsnd_ssiu_ops_gen2)) {
|
|
|
|
ops->id = rsnd_ssiu_id;
|
|
|
|
ops->id_sub = rsnd_ssiu_id_sub;
|
|
|
|
|
|
|
|
if (rsnd_is_gen2(priv)) {
|
|
|
|
list = gen2_id;
|
|
|
|
nr = ARRAY_SIZE(gen2_id);
|
|
|
|
} else if (rsnd_is_gen3(priv)) {
|
|
|
|
list = gen3_id;
|
|
|
|
nr = ARRAY_SIZE(gen3_id);
|
|
|
|
} else {
|
|
|
|
dev_err(dev, "unknown SSIU\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
for_each_rsnd_ssiu(ssiu, priv, i) {
|
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>
2018-11-06 12:21:08 +07:00
|
|
|
if (node) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* see
|
|
|
|
* rsnd_ssiu_get_id()
|
|
|
|
* rsnd_ssiu_get_id_sub()
|
|
|
|
*/
|
|
|
|
for (j = 0; j < nr; j++) {
|
|
|
|
if (list[j] > i)
|
|
|
|
break;
|
|
|
|
ssiu->id = j;
|
|
|
|
ssiu->id_sub = i - list[ssiu->id];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ssiu->id = i;
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:41 +07:00
|
|
|
ret = rsnd_mod_init(priv, rsnd_mod_get(ssiu),
|
2018-10-30 14:46:05 +07:00
|
|
|
ops, NULL, RSND_MOD_SSIU, i);
|
2015-10-26 15:43:41 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-10 12:14:12 +07:00
|
|
|
void rsnd_ssiu_remove(struct rsnd_priv *priv)
|
2015-10-26 15:43:41 +07:00
|
|
|
{
|
|
|
|
struct rsnd_ssiu *ssiu;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for_each_rsnd_ssiu(ssiu, priv, i) {
|
|
|
|
rsnd_mod_quit(rsnd_mod_get(ssiu));
|
|
|
|
}
|
|
|
|
}
|