aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2017-08-04 06:58:17 -0400
committerMark Brown <broonie@kernel.org>2017-08-08 07:02:51 -0400
commita8ad0c85fbfa56c44161829f6433e59dcd84b731 (patch)
treea79cd7ac2ebe836ef4f46b776e5a0d991a2cbed4
parent6f187f7ef1c15dca9f720b18a7e928718fd1a8b3 (diff)
ASoC: samsung: odroid: Drop requirement of clocks in the sound node
As suggested in reviews the requirement of clocks in the 'sound' node is dropped and instead a leaf clock is used to configure frequency of the audio root clock PLL. This can work now after the clock tree definitions have been updated to allow clock rate setting propagation on the path from the I2S controller up to the EPLL. This patch also lowers the CODEC master clock frequency so as to not exceed the maximum allowed 60 MHz at maximum audio sampling rates. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/sound/samsung,odroid.txt6
-rw-r--r--sound/soc/samsung/odroid.c44
2 files changed, 30 insertions, 20 deletions
diff --git a/Documentation/devicetree/bindings/sound/samsung,odroid.txt b/Documentation/devicetree/bindings/sound/samsung,odroid.txt
index c30934dd975b..625b1b18fd02 100644
--- a/Documentation/devicetree/bindings/sound/samsung,odroid.txt
+++ b/Documentation/devicetree/bindings/sound/samsung,odroid.txt
@@ -7,9 +7,6 @@ Required properties:
7 - model - the user-visible name of this sound complex 7 - model - the user-visible name of this sound complex
8 - clocks - should contain entries matching clock names in the clock-names 8 - clocks - should contain entries matching clock names in the clock-names
9 property 9 property
10 - clock-names - should contain following entries:
11 - "epll" - indicating the EPLL output clock
12 - "i2s_rclk" - indicating the RCLK (root) clock of the I2S0 controller
13 - samsung,audio-widgets - this property specifies off-codec audio elements 10 - samsung,audio-widgets - this property specifies off-codec audio elements
14 like headphones or speakers, for details see widgets.txt 11 like headphones or speakers, for details see widgets.txt
15 - samsung,audio-routing - a list of the connections between audio 12 - samsung,audio-routing - a list of the connections between audio
@@ -46,9 +43,6 @@ sound {
46 "IN1", "Mic Jack", 43 "IN1", "Mic Jack",
47 "Mic Jack", "MICBIAS"; 44 "Mic Jack", "MICBIAS";
48 45
49 clocks = <&clock CLK_FOUT_EPLL>, <&i2s0 CLK_I2S_RCLK_SRC>;
50 clock-names = "epll", "sclk_i2s";
51
52 cpu { 46 cpu {
53 sound-dai = <&i2s0 0>; 47 sound-dai = <&i2s0 0>;
54 }; 48 };
diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index 0c0b00e40646..00b7f455a472 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -19,8 +19,8 @@ struct odroid_priv {
19 struct snd_soc_card card; 19 struct snd_soc_card card;
20 struct snd_soc_dai_link dai_link; 20 struct snd_soc_dai_link dai_link;
21 21
22 struct clk *pll; 22 struct clk *clk_i2s_bus;
23 struct clk *rclk; 23 struct clk *sclk_i2s;
24}; 24};
25 25
26static int odroid_card_startup(struct snd_pcm_substream *substream) 26static int odroid_card_startup(struct snd_pcm_substream *substream)
@@ -58,13 +58,18 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream,
58 return -EINVAL; 58 return -EINVAL;
59 } 59 }
60 60
61 ret = clk_set_rate(priv->pll, pll_freq + 1); 61 ret = clk_set_rate(priv->clk_i2s_bus, pll_freq / 2 + 1);
62 if (ret < 0) 62 if (ret < 0)
63 return ret; 63 return ret;
64 64
65 rclk_freq = params_rate(params) * 256 * 4; 65 /*
66 * We add 1 to the rclk_freq value in order to avoid too low clock
67 * frequency values due to the EPLL output frequency not being exact
68 * multiple of the audio sampling rate.
69 */
70 rclk_freq = params_rate(params) * 256 + 1;
66 71
67 ret = clk_set_rate(priv->rclk, rclk_freq); 72 ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
68 if (ret < 0) 73 if (ret < 0)
69 return ret; 74 return ret;
70 75
@@ -118,14 +123,6 @@ static int odroid_audio_probe(struct platform_device *pdev)
118 123
119 snd_soc_card_set_drvdata(card, priv); 124 snd_soc_card_set_drvdata(card, priv);
120 125
121 priv->pll = devm_clk_get(dev, "epll");
122 if (IS_ERR(priv->pll))
123 return PTR_ERR(priv->pll);
124
125 priv->rclk = devm_clk_get(dev, "i2s_rclk");
126 if (IS_ERR(priv->rclk))
127 return PTR_ERR(priv->rclk);
128
129 ret = snd_soc_of_parse_card_name(card, "model"); 126 ret = snd_soc_of_parse_card_name(card, "model");
130 if (ret < 0) 127 if (ret < 0)
131 return ret; 128 return ret;
@@ -171,14 +168,31 @@ static int odroid_audio_probe(struct platform_device *pdev)
171 link->name = "Primary"; 168 link->name = "Primary";
172 link->stream_name = link->name; 169 link->stream_name = link->name;
173 170
171
172 priv->sclk_i2s = of_clk_get_by_name(link->cpu_of_node, "i2s_opclk1");
173 if (IS_ERR(priv->sclk_i2s)) {
174 ret = PTR_ERR(priv->sclk_i2s);
175 goto err_put_i2s_n;
176 }
177
178 priv->clk_i2s_bus = of_clk_get_by_name(link->cpu_of_node, "iis");
179 if (IS_ERR(priv->clk_i2s_bus)) {
180 ret = PTR_ERR(priv->clk_i2s_bus);
181 goto err_put_sclk;
182 }
183
174 ret = devm_snd_soc_register_card(dev, card); 184 ret = devm_snd_soc_register_card(dev, card);
175 if (ret < 0) { 185 if (ret < 0) {
176 dev_err(dev, "snd_soc_register_card() failed: %d\n", ret); 186 dev_err(dev, "snd_soc_register_card() failed: %d\n", ret);
177 goto err_put_i2s_n; 187 goto err_put_clk_i2s;
178 } 188 }
179 189
180 return 0; 190 return 0;
181 191
192err_put_clk_i2s:
193 clk_put(priv->clk_i2s_bus);
194err_put_sclk:
195 clk_put(priv->sclk_i2s);
182err_put_i2s_n: 196err_put_i2s_n:
183 of_node_put(link->cpu_of_node); 197 of_node_put(link->cpu_of_node);
184err_put_codec_n: 198err_put_codec_n:
@@ -192,6 +206,8 @@ static int odroid_audio_remove(struct platform_device *pdev)
192 206
193 of_node_put(priv->dai_link.cpu_of_node); 207 of_node_put(priv->dai_link.cpu_of_node);
194 odroid_put_codec_of_nodes(&priv->dai_link); 208 odroid_put_codec_of_nodes(&priv->dai_link);
209 clk_put(priv->sclk_i2s);
210 clk_put(priv->clk_i2s_bus);
195 211
196 return 0; 212 return 0;
197} 213}