From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 --- sound/soc/sh/rcar/rsnd.h | 1 + sound/soc/sh/rcar/ssi.c | 98 +------------------------------ sound/soc/sh/rcar/ssiu.c | 121 ++++++++++++++++++++++++++++++++++----- 3 files changed, 108 insertions(+), 112 deletions(-)
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index b76dfa93d362..75db25b8cd03 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -810,6 +810,7 @@ void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai, struct device_node *playback, struct device_node *capture); #define rsnd_ssiu_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_SSIU) +bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod);
/* * R-Car SRC diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index aa1da2978dc6..19fbafcc0d92 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -357,96 +357,6 @@ static void rsnd_ssi_master_clk_stop(struct rsnd_mod *mod, rsnd_adg_ssi_clk_stop(mod); }
-/* enable busif buffer over/under run interrupt. */ -#define rsnd_ssi_busif_err_irq_enable(mod) rsnd_ssi_busif_err_irq_ctrl(mod, 1) -#define rsnd_ssi_busif_err_irq_disable(mod) rsnd_ssi_busif_err_irq_ctrl(mod, 0) -static void rsnd_ssi_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable) -{ - u32 sys_int_enable = 0; - int id = rsnd_mod_id(mod); - int i; - - switch (id) { - case 0: - case 1: - case 2: - case 3: - case 4: - for (i = 0; i < 4; i++) { - sys_int_enable = rsnd_mod_read(mod, SSI_SYS_INT_ENABLE(i * 2)); - if (enable) - sys_int_enable |= 0xf << (id * 4); - else - sys_int_enable &= ~(0xf << (id * 4)); - rsnd_mod_write(mod, - SSI_SYS_INT_ENABLE(i * 2), - sys_int_enable); - } - break; - case 9: - for (i = 0; i < 4; i++) { - sys_int_enable = rsnd_mod_read(mod, SSI_SYS_INT_ENABLE((i * 2) + 1)); - if (enable) - sys_int_enable |= 0xf << 4; - else - sys_int_enable &= ~(0xf << 4); - rsnd_mod_write(mod, - SSI_SYS_INT_ENABLE((i * 2) + 1), - sys_int_enable); - } - break; - } -} - -static bool rsnd_ssi_busif_err_status_clear(struct rsnd_mod *mod) -{ - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); - struct device *dev = rsnd_priv_to_dev(priv); - u32 status; - bool stop = false; - int id = rsnd_mod_id(mod); - int i; - - switch (id) { - case 0: - case 1: - case 2: - case 3: - case 4: - for (i = 0; i < 4; i++) { - status = rsnd_mod_read(mod, SSI_SYS_STATUS(i * 2)); - status &= 0xf << (id * 4); - - if (status) { - rsnd_print_irq_status(dev, "%s err status : 0x%08x\n", - rsnd_mod_name(mod), status); - rsnd_mod_write(mod, - SSI_SYS_STATUS(i * 2), - 0xf << (id * 4)); - stop = true; - } - } - break; - case 9: - for (i = 0; i < 4; i++) { - status = rsnd_mod_read(mod, SSI_SYS_STATUS((i * 2) + 1)); - status &= 0xf << 4; - - if (status) { - rsnd_print_irq_status(dev, "%s err status : 0x%08x\n", - rsnd_mod_name(mod), status); - rsnd_mod_write(mod, - SSI_SYS_STATUS((i * 2) + 1), - 0xf << 4); - stop = true; - } - } - break; - } - - return stop; -} - static void rsnd_ssi_config_init(struct rsnd_mod *mod, struct rsnd_dai_stream *io) { @@ -534,9 +444,6 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod, cr_mode = DIEN; /* PIO : enable Data interrupt */ }
- /* enable busif buffer over/under run interrupt. */ - rsnd_ssi_busif_err_irq_enable(mod); - init_end: ssi->cr_own = cr_own; ssi->cr_mode = cr_mode; @@ -612,9 +519,6 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod, ssi->wsr = 0; }
- /* disable busif buffer over/under run interrupt. */ - rsnd_ssi_busif_err_irq_disable(mod); - return 0; }
@@ -788,7 +692,7 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod, stop = true; }
- stop |= rsnd_ssi_busif_err_status_clear(mod); + stop |= rsnd_ssiu_busif_err_status_clear(mod);
rsnd_ssi_status_clear(mod); rsnd_ssi_interrupt_out: diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index cb2071cbe3c6..3a98ec2066bc 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c @@ -45,6 +45,92 @@ struct rsnd_ssiu { 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 };
+/* enable busif buffer over/under run interrupt. */ +#define rsnd_ssiu_busif_err_irq_enable(mod) rsnd_ssiu_busif_err_irq_ctrl(mod, 1) +#define rsnd_ssiu_busif_err_irq_disable(mod) rsnd_ssiu_busif_err_irq_ctrl(mod, 0) +static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable) +{ + u32 sys_int_enable = 0; + int id = rsnd_mod_id(mod); + int i; + + switch (id) { + case 0: + case 1: + case 2: + case 3: + case 4: + for (i = 0; i < 4; i++) { + sys_int_enable = rsnd_mod_read(mod, SSI_SYS_INT_ENABLE(i * 2)); + if (enable) + sys_int_enable |= 0xf << (id * 4); + else + sys_int_enable &= ~(0xf << (id * 4)); + rsnd_mod_write(mod, + SSI_SYS_INT_ENABLE(i * 2), + sys_int_enable); + } + break; + case 9: + for (i = 0; i < 4; i++) { + sys_int_enable = rsnd_mod_read(mod, SSI_SYS_INT_ENABLE((i * 2) + 1)); + if (enable) + sys_int_enable |= 0xf << 4; + else + sys_int_enable &= ~(0xf << 4); + rsnd_mod_write(mod, + SSI_SYS_INT_ENABLE((i * 2) + 1), + sys_int_enable); + } + break; + } +} + +bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod) +{ + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); + u32 status; + bool error = false; + int id = rsnd_mod_id(mod); + int i; + + switch (id) { + case 0: + case 1: + case 2: + case 3: + case 4: + for (i = 0; i < 4; i++) { + status = rsnd_mod_read(mod, SSI_SYS_STATUS(i * 2)); + status &= 0xf << (id * 4); + + if (status) { + rsnd_print_irq_status(dev, "%s err status : 0x%08x\n", + rsnd_mod_name(mod), status); + error = true; + } + rsnd_mod_write(mod, SSI_SYS_STATUS(i * 2), 0xf << (id * 4)); + } + break; + case 9: + for (i = 0; i < 4; i++) { + status = rsnd_mod_read(mod, SSI_SYS_STATUS((i * 2) + 1)); + status &= 0xf << 4; + + if (status) { + rsnd_print_irq_status(dev, "%s err status : 0x%08x\n", + rsnd_mod_name(mod), status); + error = true; + } + rsnd_mod_write(mod, SSI_SYS_STATUS((i * 2) + 1), 0xf << 4); + } + break; + } + + return error; +} + static u32 *rsnd_ssiu_get_status(struct rsnd_mod *mod, struct rsnd_dai_stream *io, enum rsnd_mod_type type) @@ -65,23 +151,9 @@ static int rsnd_ssiu_init(struct rsnd_mod *mod, int id = rsnd_mod_id(mod); int is_clk_master = rsnd_rdai_is_clk_master(rdai); u32 val1, val2; - int i;
/* clear status */ - switch (id) { - case 0: - case 1: - case 2: - case 3: - case 4: - for (i = 0; i < 4; i++) - rsnd_mod_write(mod, SSI_SYS_STATUS(i * 2), 0xf << (id * 4)); - break; - case 9: - for (i = 0; i < 4; i++) - rsnd_mod_write(mod, SSI_SYS_STATUS((i * 2) + 1), 0xf << 4); - break; - } + rsnd_ssiu_busif_err_status_clear(mod);
/* * SSI_MODE0 @@ -137,12 +209,31 @@ static int rsnd_ssiu_init(struct rsnd_mod *mod, rsnd_mod_bset(mod, SSI_MODE1, 0x0013001f, val1); rsnd_mod_bset(mod, SSI_MODE2, 0x00000017, val2);
+ /* + * Enable busif buffer over/under run interrupt. + * It will be handled from ssi.c + * see + * __rsnd_ssi_interrupt() + */ + rsnd_ssiu_busif_err_irq_enable(mod); + + return 0; +} + +static int rsnd_ssiu_quit(struct rsnd_mod *mod, + struct rsnd_dai_stream *io, + struct rsnd_priv *priv) +{ + /* disable busif buffer over/under run interrupt. */ + rsnd_ssiu_busif_err_irq_disable(mod); + return 0; }
static struct rsnd_mod_ops rsnd_ssiu_ops_gen1 = { .name = SSIU_NAME, .init = rsnd_ssiu_init, + .quit = rsnd_ssiu_quit, .get_status = rsnd_ssiu_get_status, };