Skip to content

Commit 80f43c5

Browse files
John Madieubroonie
authored andcommitted
ASoC: rsnd: ssiu: Add RZ/G3E BUSIF support
Add support for the SSIU found on the Renesas RZ/G3E SoC, which provides a different BUSIF layout compared to earlier generations: - SSI0-SSI4: 4 BUSIF instances each (BUSIF0-3) - SSI5-SSI8: 1 BUSIF instance each (BUSIF0 only) - SSI9: 4 BUSIF instances (BUSIF0-3) - Total: 28 BUSIFs The RZ/G3E also has only two pairs of BUSIF error-status registers instead of four, and the SSI always operates in BUSIF mode: the SSI_MODE0 BUSIF/PIO select bit is not implemented and must not be written. While at it, add RSND_SSIU_BUSIF_STATUS_COUNT_2 as a capability flag in the match data, consumed via struct rsnd_ssiu_ctrl, to parametrise the two BUSIF error-status loops. Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://patch.msgid.link/20260525110230.4014435-11-john.madieu.xa@bp.renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b4ef837 commit 80f43c5

3 files changed

Lines changed: 41 additions & 19 deletions

File tree

sound/soc/renesas/rcar/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ static const struct of_device_id rsnd_of_match[] = {
106106
{ .compatible = "renesas,rcar_sound-gen4", .data = (void *)RSND_GEN4 },
107107
/* Special Handling */
108108
{ .compatible = "renesas,rcar_sound-r8a77990", .data = (void *)(RSND_GEN3 | RSND_SOC_E) },
109-
{ .compatible = "renesas,r9a09g047-sound", .data = (void *)(RSND_RZ3 | RSND_RZG3E) },
109+
{ .compatible = "renesas,r9a09g047-sound",
110+
.data = (void *)(RSND_RZ3 | RSND_RZG3E | RSND_SSIU_BUSIF_STATUS_COUNT_2) },
110111
{},
111112
};
112113
MODULE_DEVICE_TABLE(of, rsnd_of_match);

sound/soc/renesas/rcar/rsnd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ struct rsnd_priv {
666666
#define RSND_RZ3 (3 << 8)
667667
#define RSND_RZ_ID_MASK (0xF << 12) /* nibble D */
668668
#define RSND_RZG3E (1 << 12)
669+
#define RSND_SSIU_BUSIF_STATUS_COUNT_2 BIT(16) /* Only 2 BUSIF error-status register pairs */
669670
/*
670671
* below value will be filled on rsnd_gen_probe()
671672
*/
@@ -690,6 +691,7 @@ struct rsnd_priv {
690691
/*
691692
* below value will be filled on rsnd_ssiu_probe()
692693
*/
694+
void *ssiu_ctrl;
693695
void *ssiu;
694696
int ssiu_nr;
695697

sound/soc/renesas/rcar/ssiu.c

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,39 @@ struct rsnd_ssiu {
2929
i++)
3030

3131
/*
32-
* SSI Gen2 Gen3 Gen4
33-
* 0 BUSIF0-3 BUSIF0-7 BUSIF0-7
34-
* 1 BUSIF0-3 BUSIF0-7
35-
* 2 BUSIF0-3 BUSIF0-7
36-
* 3 BUSIF0 BUSIF0-7
37-
* 4 BUSIF0 BUSIF0-7
38-
* 5 BUSIF0 BUSIF0
39-
* 6 BUSIF0 BUSIF0
40-
* 7 BUSIF0 BUSIF0
41-
* 8 BUSIF0 BUSIF0
42-
* 9 BUSIF0-3 BUSIF0-7
43-
* total 22 52 8
32+
* SSI Gen2 Gen3 Gen4 RZ/G3E
33+
* 0 BUSIF0-3 BUSIF0-7 BUSIF0-7 BUSIF0-3
34+
* 1 BUSIF0-3 BUSIF0-7 BUSIF0-3
35+
* 2 BUSIF0-3 BUSIF0-7 BUSIF0-3
36+
* 3 BUSIF0 BUSIF0-7 BUSIF0-3
37+
* 4 BUSIF0 BUSIF0-7 BUSIF0-3
38+
* 5 BUSIF0 BUSIF0 BUSIF0
39+
* 6 BUSIF0 BUSIF0 BUSIF0
40+
* 7 BUSIF0 BUSIF0 BUSIF0
41+
* 8 BUSIF0 BUSIF0 BUSIF0
42+
* 9 BUSIF0-3 BUSIF0-7 BUSIF0-3
43+
* total 22 52 8 28
4444
*/
4545
static const int gen2_id[] = { 0, 4, 8, 12, 13, 14, 15, 16, 17, 18 };
4646
static const int gen3_id[] = { 0, 8, 16, 24, 32, 40, 41, 42, 43, 44 };
4747
static const int gen4_id[] = { 0 };
48+
static const int rzg3e_id[] = { 0, 4, 8, 12, 16, 20, 21, 22, 23, 24 };
49+
50+
struct rsnd_ssiu_ctrl {
51+
unsigned int busif_status_count;
52+
};
53+
54+
#define rsnd_priv_to_ssiu_ctrl(priv) \
55+
((struct rsnd_ssiu_ctrl *)(priv)->ssiu_ctrl)
4856

4957
/* enable busif buffer over/under run interrupt. */
5058
#define rsnd_ssiu_busif_err_irq_enable(mod) rsnd_ssiu_busif_err_irq_ctrl(mod, 1)
5159
#define rsnd_ssiu_busif_err_irq_disable(mod) rsnd_ssiu_busif_err_irq_ctrl(mod, 0)
5260
static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable)
5361
{
62+
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
5463
int id = rsnd_mod_id(mod);
5564
int shift, offset;
56-
int i;
5765

5866
switch (id) {
5967
case 0:
@@ -72,7 +80,7 @@ static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable)
7280
return;
7381
}
7482

75-
for (i = 0; i < 4; i++) {
83+
for (unsigned int i = 0; i < rsnd_priv_to_ssiu_ctrl(priv)->busif_status_count; i++) {
7684
enum rsnd_reg reg = SSI_SYS_INT_ENABLE((i * 2) + offset);
7785
u32 val = 0xf << (shift * 4);
7886
u32 sys_int_enable = rsnd_mod_read(mod, reg);
@@ -87,10 +95,10 @@ static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable)
8795

8896
bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod)
8997
{
98+
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
9099
bool error = false;
91100
int id = rsnd_mod_id(mod);
92101
int shift, offset;
93-
int i;
94102

95103
switch (id) {
96104
case 0:
@@ -109,14 +117,13 @@ bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod)
109117
goto out;
110118
}
111119

112-
for (i = 0; i < 4; i++) {
120+
for (unsigned int i = 0; i < rsnd_priv_to_ssiu_ctrl(priv)->busif_status_count; i++) {
113121
u32 reg = SSI_SYS_STATUS(i * 2) + offset;
114122
u32 status = rsnd_mod_read(mod, reg);
115123
u32 val = 0xf << (shift * 4);
116124

117125
status &= val;
118126
if (status) {
119-
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
120127
struct device *dev = rsnd_priv_to_dev(priv);
121128

122129
rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
@@ -160,7 +167,8 @@ static int rsnd_ssiu_init(struct rsnd_mod *mod,
160167
/*
161168
* SSI_MODE0
162169
*/
163-
rsnd_mod_bset(mod, SSI_MODE0, (1 << id), !use_busif << id);
170+
if (!rsnd_is_rzg3e(priv))
171+
rsnd_mod_bset(mod, SSI_MODE0, (1 << id), !use_busif << id);
164172

165173
/*
166174
* SSI_MODE1 / SSI_MODE2
@@ -511,6 +519,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
511519
struct device *dev = rsnd_priv_to_dev(priv);
512520
struct device_node *node __free(device_node) = rsnd_ssiu_of_node(priv);
513521
struct reset_control *rstc;
522+
struct rsnd_ssiu_ctrl *ctrl;
514523
struct rsnd_ssiu *ssiu;
515524
struct rsnd_mod_ops *ops;
516525
const int *list = NULL;
@@ -535,8 +544,15 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
535544
if (!ssiu)
536545
return -ENOMEM;
537546

547+
ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
548+
if (!ctrl)
549+
return -ENOMEM;
550+
551+
ctrl->busif_status_count = rsnd_flags_has(priv, RSND_SSIU_BUSIF_STATUS_COUNT_2) ? 2 : 4;
552+
538553
priv->ssiu = ssiu;
539554
priv->ssiu_nr = nr;
555+
priv->ssiu_ctrl = ctrl;
540556

541557
if (rsnd_is_gen1(priv))
542558
ops = &rsnd_ssiu_ops_gen1;
@@ -559,6 +575,9 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
559575
} else if (rsnd_is_gen4(priv)) {
560576
list = gen4_id;
561577
nr = ARRAY_SIZE(gen4_id);
578+
} else if (rsnd_is_rzg3e(priv)) {
579+
list = rzg3e_id;
580+
nr = ARRAY_SIZE(rzg3e_id);
562581
} else {
563582
dev_err(dev, "unknown SSIU\n");
564583
return -ENODEV;

0 commit comments

Comments
 (0)