dma->ops->quit(io, dma);
}
-int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id)
+struct rsnd_dma *rsnd_dma_init(struct rsnd_dai_stream *io,
+ struct rsnd_mod *mod, int id)
{
struct rsnd_mod *mod_from = NULL;
struct rsnd_mod *mod_to = NULL;
struct rsnd_priv *priv = rsnd_io_to_priv(io);
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
+ struct rsnd_dma *dma;
struct device *dev = rsnd_priv_to_dev(priv);
int is_play = rsnd_io_is_play(io);
+ int ret;
/*
* DMA failed. try to PIO mode
* rsnd_rdai_continuance_probe()
*/
if (!dmac)
- return -EAGAIN;
+ return ERR_PTR(-EAGAIN);
+
+ dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
+ if (!dma)
+ return ERR_PTR(-ENOMEM);
+
+ dma->mod = mod;
rsnd_dma_of_path(dma, io, is_play, &mod_from, &mod_to);
rsnd_mod_name(mod_from), rsnd_mod_id(mod_from),
rsnd_mod_name(mod_to), rsnd_mod_id(mod_to));
- return dma->ops->init(io, dma, id, mod_from, mod_to);
+ ret = dma->ops->init(io, dma, id, mod_from, mod_to);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ return dma;
}
int rsnd_dma_probe(struct platform_device *pdev,
struct rsnd_dma {
struct rsnd_dma_ops *ops;
+ struct rsnd_mod *mod;
dma_addr_t src_addr;
dma_addr_t dst_addr;
union {
};
#define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en)
#define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp)
-#define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma)
+#define rsnd_dma_to_mod(_dma) ((dma)->mod)
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
-int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id);
+struct rsnd_dma *rsnd_dma_init(struct rsnd_dai_stream *io,
+ struct rsnd_mod *mod, int id);
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
int rsnd_dma_probe(struct platform_device *pdev,
const struct rsnd_of_data *of_data,
int id;
enum rsnd_mod_type type;
struct rsnd_mod_ops *ops;
- struct rsnd_dma dma;
struct rsnd_priv *priv;
struct clk *clk;
u32 status;
#define __rsnd_mod_call_hw_params 0
#define rsnd_mod_to_priv(mod) ((mod)->priv)
-#define rsnd_mod_to_dma(mod) (&(mod)->dma)
#define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1)
#define rsnd_mod_power_on(mod) clk_enable((mod)->clk)
#define rsnd_mod_power_off(mod) clk_disable((mod)->clk)
struct rsnd_src {
struct rsnd_src_platform_info *info; /* rcar_snd.h */
struct rsnd_mod mod;
+ struct rsnd_dma *dma;
struct rsnd_kctrl_cfg_s sen; /* sync convert enable */
struct rsnd_kctrl_cfg_s sync; /* sync convert */
u32 convert_rate; /* sampling rate convert */
#define RSND_SRC_NAME_SIZE 16
+#define rsnd_src_to_dma(src) ((src)->dma)
#define rsnd_src_nr(priv) ((priv)->src_nr)
#define rsnd_enable_sync_convert(src) ((src)->sen.val)
#define rsnd_src_of_node(priv) \
return ret;
}
- ret = rsnd_dma_init(io,
- rsnd_mod_to_dma(mod),
- src->info->dma_id);
+ src->dma = rsnd_dma_init(io, mod, src->info->dma_id);
+ if (IS_ERR(src->dma))
+ return PTR_ERR(src->dma);
return ret;
}
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
- rsnd_dma_quit(io, rsnd_mod_to_dma(mod));
+ struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+ rsnd_dma_quit(io, rsnd_src_to_dma(src));
return 0;
}
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
- rsnd_dma_start(io, rsnd_mod_to_dma(mod));
+ struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+ rsnd_dma_start(io, rsnd_src_to_dma(src));
return _rsnd_src_start_gen2(mod, io);
}
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
+ struct rsnd_src *src = rsnd_mod_to_src(mod);
int ret;
ret = _rsnd_src_stop_gen2(mod);
- rsnd_dma_stop(io, rsnd_mod_to_dma(mod));
+ rsnd_dma_stop(io, rsnd_src_to_dma(src));
return ret;
}
struct rsnd_ssi_platform_info *info; /* rcar_snd.h */
struct rsnd_ssi *parent;
struct rsnd_mod mod;
+ struct rsnd_dma *dma;
u32 cr_own;
u32 cr_clk;
((pos) = ((struct rsnd_ssi *)(priv)->ssi + i)); \
i++)
+#define rsnd_ssi_to_dma(mod) ((ssi)->dma)
#define rsnd_ssi_nr(priv) ((priv)->ssi_nr)
#define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod)
#define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0)
if (ret)
return ret;
- ret = rsnd_dma_init(
- io, rsnd_mod_to_dma(mod),
- dma_id);
+ ssi->dma = rsnd_dma_init(io, mod, dma_id);
+ if (IS_ERR(ssi->dma))
+ return PTR_ERR(ssi->dma);
return ret;
}
struct device *dev = rsnd_priv_to_dev(priv);
int irq = ssi->info->irq;
- rsnd_dma_quit(io, rsnd_mod_to_dma(mod));
+ rsnd_dma_quit(io, rsnd_ssi_to_dma(ssi));
/* PIO will request IRQ again */
devm_free_irq(dev, irq, mod);
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
- struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
+ struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
+ struct rsnd_dma *dma = rsnd_ssi_to_dma(ssi);
rsnd_dma_start(io, dma);
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
- struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
+ struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
+ struct rsnd_dma *dma = rsnd_ssi_to_dma(ssi);
rsnd_ssi_stop(mod, io, priv);