All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, alsa-devel@alsa-project.org,
	robh+dt@kernel.org, devicetree@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org, krzk@kernel.org,
	jcsing.lee@samsung.com, sbkim73@samsung.com,
	linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com,
	m.szyprowski@samsung.com,
	Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: [PATCH 2/8] ASoC: samsung: i2s: Ensure names of supplied clocks are unique
Date: Mon, 05 Feb 2018 16:43:57 +0100	[thread overview]
Message-ID: <20180205154403.13520-3-s.nawrocki@samsung.com> (raw)
In-Reply-To: <20180205154403.13520-1-s.nawrocki@samsung.com>

In order to support multiple instances of the I2S IP block the platform
device name is prepended to each clock registered by the driver.
The clock-output-names property is now not used, this should not cause
any issues as, for example, CDCLK clock is referenced through DT 'clocks'
property, not by name.

This change allows to have both I2S0 and I2S1 enabled simultaneously
on exynos5433 and working properly when #clock-cells property is specified
in respective DT nodes.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 sound/soc/samsung/i2s.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index aeba0ae890ea..b7d25a63da8b 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -1193,11 +1193,13 @@ static void i2s_unregister_clock_provider(struct platform_device *pdev)
 
 static int i2s_register_clock_provider(struct platform_device *pdev)
 {
-	struct device *dev = &pdev->dev;
-	struct i2s_dai *i2s = dev_get_drvdata(dev);
+	const char * const i2s_clk_desc[] = { "cdclk", "rclk_src", "prescaler" };
 	const char *clk_name[2] = { "i2s_opclk0", "i2s_opclk1" };
 	const char *p_names[2] = { NULL };
+	struct device *dev = &pdev->dev;
+	struct i2s_dai *i2s = dev_get_drvdata(dev);
 	const struct samsung_i2s_variant_regs *reg_info = i2s->variant_regs;
+	const char *i2s_clk_name[ARRAY_SIZE(i2s_clk_desc)];
 	struct clk *rclksrc;
 	int ret, i;
 
@@ -1214,30 +1216,35 @@ static int i2s_register_clock_provider(struct platform_device *pdev)
 		clk_put(rclksrc);
 	}
 
+	for (i = 0; i < ARRAY_SIZE(i2s_clk_desc); i++)
+		i2s_clk_name[i] = devm_kasprintf(dev, GFP_KERNEL, "%s_%s",
+						dev_name(dev), i2s_clk_desc[i]);
+
 	if (!(i2s->quirks & QUIRK_NO_MUXPSR)) {
 		/* Activate the prescaler */
 		u32 val = readl(i2s->addr + I2SPSR);
 		writel(val | PSR_PSREN, i2s->addr + I2SPSR);
 
 		i2s->clk_table[CLK_I2S_RCLK_SRC] = clk_register_mux(dev,
-				"i2s_rclksrc", p_names, ARRAY_SIZE(p_names),
+				i2s_clk_name[CLK_I2S_RCLK_SRC], p_names,
+				ARRAY_SIZE(p_names),
 				CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT,
 				i2s->addr + I2SMOD, reg_info->rclksrc_off,
 				1, 0, i2s->lock);
 
 		i2s->clk_table[CLK_I2S_RCLK_PSR] = clk_register_divider(dev,
-				"i2s_presc", "i2s_rclksrc",
+				i2s_clk_name[CLK_I2S_RCLK_PSR],
+				i2s_clk_name[CLK_I2S_RCLK_SRC],
 				CLK_SET_RATE_PARENT,
 				i2s->addr + I2SPSR, 8, 6, 0, i2s->lock);
 
-		p_names[0] = "i2s_presc";
+		p_names[0] = i2s_clk_name[CLK_I2S_RCLK_PSR];
 		i2s->clk_data.clk_num = 2;
 	}
-	of_property_read_string_index(dev->of_node,
-				"clock-output-names", 0, &clk_name[0]);
 
-	i2s->clk_table[CLK_I2S_CDCLK] = clk_register_gate(dev, clk_name[0],
-				p_names[0], CLK_SET_RATE_PARENT,
+	i2s->clk_table[CLK_I2S_CDCLK] = clk_register_gate(dev,
+				i2s_clk_name[CLK_I2S_CDCLK], p_names[0],
+				CLK_SET_RATE_PARENT,
 				i2s->addr + I2SMOD, reg_info->cdclkcon_off,
 				CLK_GATE_SET_TO_DISABLE, i2s->lock);
 
-- 
2.14.2

  parent reply	other threads:[~2018-02-05 15:45 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180205154421epcas2p16072f713ea81f72b3f8230f6a9d412cf@epcas2p1.samsung.com>
2018-02-05 15:43 ` [PATCH 0/8] ASoC: samsung: Add HDMI sound support for tm2 board Sylwester Nawrocki
     [not found]   ` <CGME20180205154453epcas1p10046e1103497692c86c0899a5ef11781@epcas1p1.samsung.com>
2018-02-05 15:43     ` [PATCH 1/8] ASoC: samsung: i2s: Ensure the RCLK rate is properly determined Sylwester Nawrocki
2018-02-05 15:43       ` Sylwester Nawrocki
2018-02-06 12:15       ` Krzysztof Kozlowski
2018-02-06 12:15         ` Krzysztof Kozlowski
2018-02-12 12:52       ` Applied "ASoC: samsung: i2s: Ensure the RCLK rate is properly determined" to the asoc tree Mark Brown
2018-02-12 12:52         ` Mark Brown
     [not found]   ` <CGME20180205154511epcas1p14dccb00b68fdb688f2c427c56e01c052@epcas1p1.samsung.com>
2018-02-05 15:43     ` Sylwester Nawrocki [this message]
2018-02-06 12:20       ` [PATCH 2/8] ASoC: samsung: i2s: Ensure names of supplied clocks are unique Krzysztof Kozlowski
2018-02-07 15:20         ` Sylwester Nawrocki
     [not found]   ` <CGME20180205154516epcas1p39c5977145e7b32879b935087ee3865f8@epcas1p3.samsung.com>
2018-02-05 15:43     ` [PATCH 3/8] ASoC: samsung: i2s: Prevent external abort on exynos5433 I2S1 access Sylwester Nawrocki
2018-02-06 12:22       ` Krzysztof Kozlowski
2018-02-06 12:22         ` Krzysztof Kozlowski
     [not found]   ` <CGME20180205154520epcas1p4132421a187a4d767a2f75badfef5eec4@epcas1p4.samsung.com>
2018-02-05 15:43     ` [PATCH 4/8] ASoC: samsung: i2s: Define the parameters list for SAMSUNG_I2S_OPCLK Sylwester Nawrocki
2018-02-05 15:43       ` Sylwester Nawrocki
2018-02-06 12:26       ` Krzysztof Kozlowski
2018-02-06 12:26         ` Krzysztof Kozlowski
2018-02-07 16:23         ` Sylwester Nawrocki
2018-02-12 10:00           ` Krzysztof Kozlowski
2018-02-14 13:29       ` Applied "ASoC: samsung: i2s: Define the parameters list for SAMSUNG_I2S_OPCLK" to the asoc tree Mark Brown
2018-02-14 13:29         ` Mark Brown
     [not found]   ` <CGME20180205154524epcas1p35874552d9056837a162dc59d847d1930@epcas1p3.samsung.com>
2018-02-05 15:44     ` [PATCH 5/8] ASoC: samsung: Add support for HDMI audio on TM2 board Sylwester Nawrocki
2018-02-06 12:57       ` Krzysztof Kozlowski
2018-02-06 12:57         ` Krzysztof Kozlowski
     [not found]   ` <CGME20180205154529epcas2p3478546ef61294ac06cd9d8ed3d7e12c9@epcas2p3.samsung.com>
2018-02-05 15:44     ` [PATCH 6/8] ASoC: samsung: i2s: Update clock-output-names property documentation Sylwester Nawrocki
2018-02-06 12:59       ` Krzysztof Kozlowski
2018-02-06 12:59         ` Krzysztof Kozlowski
2018-02-06 12:59         ` Krzysztof Kozlowski
2018-02-06 12:59           ` Krzysztof Kozlowski
2018-02-09  2:36       ` Rob Herring
     [not found]   ` <CGME20180205154533epcas2p2d0ed58188cf7f29751c08cd804f6fb0d@epcas2p2.samsung.com>
2018-02-05 15:44     ` [PATCH 7/8] ASoC: samsung: Add missing #sound-dai-cells " Sylwester Nawrocki
2018-02-06 13:02       ` Krzysztof Kozlowski
2018-02-07 16:37         ` Sylwester Nawrocki
     [not found]   ` <CGME20180205154537epcas1p10a9a30a574e3f472358e7dacf3cb0489@epcas1p1.samsung.com>
2018-02-05 15:44     ` [PATCH 8/8] ASoC: samsung,tm2-audio DT binding documentation update Sylwester Nawrocki
2018-02-06 13:05       ` Krzysztof Kozlowski
2018-02-07 16:31         ` Sylwester Nawrocki
2018-02-07 16:31           ` Sylwester Nawrocki
2018-02-12  9:19           ` Krzysztof Kozlowski
2018-02-12  9:19             ` Krzysztof Kozlowski
2018-02-09  2:39       ` Rob Herring
2018-02-14 13:29       ` Applied "ASoC: samsung,tm2-audio DT binding documentation update" to the asoc tree Mark Brown
2018-02-14 13:29         ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180205154403.13520-3-s.nawrocki@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jcsing.lee@samsung.com \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=sbkim73@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.