Commit e8314d7d authored by Peter Rosin's avatar Peter Rosin Committed by Mark Brown

misc: atmel-ssc: register as sound DAI if #sound-dai-cells is present

The SSC is currently not usable with the ASoC simple-audio-card, as
every SSC audio user has to build a platform driver that may do as
little as calling atmel_ssc_set_audio/atmel_ssc_put_audio (which
allocates the SSC and registers a DAI with the ASoC subsystem).

So, have that happen automatically, if the #sound-dai-cells property
is present in devicetree, which it has to be anyway for simple audio
card to work.
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Acked-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a5de5b74
...@@ -24,6 +24,8 @@ Optional properties: ...@@ -24,6 +24,8 @@ Optional properties:
this parameter to choose where the clock from. this parameter to choose where the clock from.
- By default the clock is from TK pin, if the clock from RK pin, this - By default the clock is from TK pin, if the clock from RK pin, this
property is needed. property is needed.
- #sound-dai-cells: Should contain <0>.
- This property makes the SSC into an automatically registered DAI.
Examples: Examples:
- PDC transfer: - PDC transfer:
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <linux/of.h> #include <linux/of.h>
#include "../../sound/soc/atmel/atmel_ssc_dai.h"
/* Serialize access to ssc_list and user count */ /* Serialize access to ssc_list and user count */
static DEFINE_SPINLOCK(user_lock); static DEFINE_SPINLOCK(user_lock);
static LIST_HEAD(ssc_list); static LIST_HEAD(ssc_list);
...@@ -145,6 +147,49 @@ static inline const struct atmel_ssc_platform_data * __init ...@@ -145,6 +147,49 @@ static inline const struct atmel_ssc_platform_data * __init
platform_get_device_id(pdev)->driver_data; platform_get_device_id(pdev)->driver_data;
} }
#ifdef CONFIG_SND_ATMEL_SOC_SSC
static int ssc_sound_dai_probe(struct ssc_device *ssc)
{
struct device_node *np = ssc->pdev->dev.of_node;
int ret;
int id;
ssc->sound_dai = false;
if (!of_property_read_bool(np, "#sound-dai-cells"))
return 0;
id = of_alias_get_id(np, "ssc");
if (id < 0)
return id;
ret = atmel_ssc_set_audio(id);
ssc->sound_dai = !ret;
return ret;
}
static void ssc_sound_dai_remove(struct ssc_device *ssc)
{
if (!ssc->sound_dai)
return;
atmel_ssc_put_audio(of_alias_get_id(ssc->pdev->dev.of_node, "ssc"));
}
#else
static inline int ssc_sound_dai_probe(struct ssc_device *ssc)
{
if (of_property_read_bool(ssc->pdev->dev.of_node, "#sound-dai-cells"))
return -ENOTSUPP;
return 0;
}
static inline void ssc_sound_dai_remove(struct ssc_device *ssc)
{
}
#endif
static int ssc_probe(struct platform_device *pdev) static int ssc_probe(struct platform_device *pdev)
{ {
struct resource *regs; struct resource *regs;
...@@ -204,6 +249,9 @@ static int ssc_probe(struct platform_device *pdev) ...@@ -204,6 +249,9 @@ static int ssc_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n", dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n",
ssc->regs, ssc->irq); ssc->regs, ssc->irq);
if (ssc_sound_dai_probe(ssc))
dev_err(&pdev->dev, "failed to auto-setup ssc for audio\n");
return 0; return 0;
} }
...@@ -211,6 +259,8 @@ static int ssc_remove(struct platform_device *pdev) ...@@ -211,6 +259,8 @@ static int ssc_remove(struct platform_device *pdev)
{ {
struct ssc_device *ssc = platform_get_drvdata(pdev); struct ssc_device *ssc = platform_get_drvdata(pdev);
ssc_sound_dai_remove(ssc);
spin_lock(&user_lock); spin_lock(&user_lock);
list_del(&ssc->list); list_del(&ssc->list);
spin_unlock(&user_lock); spin_unlock(&user_lock);
......
...@@ -20,6 +20,7 @@ struct ssc_device { ...@@ -20,6 +20,7 @@ struct ssc_device {
int user; int user;
int irq; int irq;
bool clk_from_rk_pin; bool clk_from_rk_pin;
bool sound_dai;
}; };
struct ssc_device * __must_check ssc_request(unsigned int ssc_num); struct ssc_device * __must_check ssc_request(unsigned int ssc_num);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment