Skip to content

Commit

Permalink
ASoC: make clock direction configurable in asoc-simple
Browse files Browse the repository at this point in the history
Some CPU drivers (e. g. davinci-mcasp) may require the system clock to
be configured as OUT, while there's no good way currently to set
SND_SOC_CLK_OUT in simple-soc driver if the clock is fixed-rate.

This patch makes asoc_simple_card_init_dai() initialize clock to
SND_SOCK_CLK_OUT if explicitly stated in the relevant dts file. This
change is transparent and doesn't change the default behavior.

Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Vitaly Wool authored and Mark Brown committed Sep 1, 2017
1 parent 0995fb7 commit a728f56
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/sound/simple-card.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Optional CPU/CODEC subnodes properties:
in dai startup() and disabled with
clk_disable_unprepare() in dai
shutdown().
- system-clock-direction-out : specifies clock direction as 'out' on
initialization. It is useful for some aCPUs with
fixed clocks.

Example 1 - single DAI link:

Expand Down
1 change: 1 addition & 0 deletions include/sound/simple_card_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
struct asoc_simple_dai {
const char *name;
unsigned int sysclk;
int clk_direction;
int slots;
int slot_width;
unsigned int tx_slot_mask;
Expand Down
9 changes: 7 additions & 2 deletions sound/soc/generic/simple-card-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ int asoc_simple_card_parse_clk(struct device *dev,
simple_dai->sysclk = clk_get_rate(clk);
}

dev_dbg(dev, "%s : sysclk = %d\n", name, simple_dai->sysclk);
if (of_property_read_bool(node, "system-clock-direction-out"))
simple_dai->clk_direction = SND_SOC_CLOCK_OUT;

dev_dbg(dev, "%s : sysclk = %d, direction %d\n", name,
simple_dai->sysclk, simple_dai->clk_direction);

return 0;
}
Expand Down Expand Up @@ -310,7 +314,8 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
int ret;

if (simple_dai->sysclk) {
ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, 0);
ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk,
simple_dai->clk_direction);
if (ret && ret != -ENOTSUPP) {
dev_err(dai->dev, "simple-card: set_sysclk error\n");
return ret;
Expand Down

0 comments on commit a728f56

Please sign in to comment.