From patchwork Sun Mar 3 12:08:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 2208281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 886EC3FCF2 for ; Sun, 3 Mar 2013 12:12:15 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UC7jG-0001D5-Cp; Sun, 03 Mar 2013 12:09:22 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UC7j7-0001Cc-87 for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2013 12:09:19 +0000 Received: from 146-52-45-75-dynip.superkabel.de ([146.52.45.75] helo=marty.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1UC7iw-0006Dq-O6; Sun, 03 Mar 2013 13:09:02 +0100 From: Heiko =?iso-8859-1?q?St=FCbner?= To: Tomasz Figa Subject: Re: [PATCH v6 01/16] clk: samsung: add common clock framework helper functions for Samsung platforms Date: Sun, 3 Mar 2013 13:08:59 +0100 User-Agent: KMail/1.13.7 (Linux/3.2.0-3-686-pae; KDE/4.8.4; i686; ; ) References: <1361175686-19400-1-git-send-email-thomas.abraham@linaro.org> <51333149.1060105@gmail.com> <2984153.Xctncej7hL@flatron> In-Reply-To: <2984153.Xctncej7hL@flatron> MIME-Version: 1.0 Message-Id: <201303031309.01118.heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130303_070913_481964_3CDC8037 X-CRM114-Status: GOOD ( 29.33 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, mturquette@linaro.org, devicetree-discuss@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org, Thomas Abraham , Sylwester Nawrocki , t.figa@samsung.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Am Sonntag, 3. März 2013, 12:45:01 schrieb Tomasz Figa: > Hi, > > On Sunday 03 of March 2013 12:17:29 Sylwester Nawrocki wrote: > > Hi, > > > > On 03/03/2013 02:08 AM, Heiko Stübner wrote: > > > But is there an easy way to define more than one alias? On the s3c2416 > > > for example the hsmmc hclk is the "hsmmc" io-clock, as well as the > > > source for the "mmc_busclk.0". Same for the "uart" pclk, that is also > > > a baud clock source. > > > > This driver currently provides for only one additional clkdev lookup > > entry per a platform clock. I pointed out this desing issue in the > > early version of the patch set. It's because a machine clock definition > > is coupled with a clock consumer definition. And IMO various > > samsung_clock_register_* functions should not have > > clk_register_clkdev() inside them. I.e. first step could be registering > > all machine clocks and in the second one clkdev lookup entries could be > > created. This is how most (all?) existing SoC clock drivers are > > working. > > > > But those multiple aliases are important only for machines with device > > tree support, aren't they ? > > I suppose you meant _without_ device tree support, right? The aliases are only needed for the non-dt case. But as I think common clk support will be a requirement for dt support in the future, similar to pinctrl, without the correct handling of the aliases it will be hard to incrementally convert the other platforms (i.e. s3c24xx before s3c2443, etc). For the time being I've added my own register_alias function to Thomas' core code, hijacking the clk_table for this - attached for reference below. > > I hope this patch series gets merged early to linux-next in the 3.10 > > cycle so the multiple accumulated fixup patches for this clock driver > > can be merged as well and issues like that you pointed out can be > > resolved with incremental patches. > > Yes, I hope so too. me too. Following all this still out-of-tree stuff makes me dizzy :-) Heiko diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index d36cdd5..7f1b5bc 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -57,14 +57,15 @@ void __init samsung_clk_init(struct device_node *np, void __iomem *base, unsigned long nr_rdump) { reg_base = base; - if (!np) - return; -#ifdef CONFIG_OF clk_table = kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL); if (!clk_table) panic("could not allocate clock lookup table\n"); + if (!np) + return; + +#ifdef CONFIG_OF clk_data.clks = clk_table; clk_data.clk_num = nr_clks; of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); @@ -96,6 +97,46 @@ void samsung_clk_add_lookup(struct clk *clk, unsigned int id) clk_table[id] = clk; } +/* register a list of aliases */ +void __init samsung_clk_register_alias(struct samsung_clock_alias *list, + unsigned int nr_clk) +{ + struct clk *clk; + unsigned int idx, ret; + + if (!clk_table) { + pr_err("%s: clock table missing\n", __func__); + return; + } + + for (idx = 0; idx < nr_clk; idx++, list++) { + if (!list->id) { + pr_err("%s: clock id missing for index %d\n", __func__, + idx); + continue; + } + + clk = clk_table[list->id]; + if (!clk) { + pr_err("%s: failed to find clock %d\n", __func__, + list->id); + continue; + } + + /* register a clock lookup only if a clock alias is specified */ + if (!list->alias) { + pr_err("%s: no alias defined for clock %d\n", __func__, + list->id); + continue; + } + + ret = clk_register_clkdev(clk, list->alias, list->dev_name); + if (ret) + pr_err("%s: failed to register lookup %s\n", + __func__, list->alias); + } +} + /* register a list of fixed clocks */ void __init samsung_clk_register_fixed_rate( struct samsung_fixed_rate_clock *list, unsigned int nr_clk) diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index 175a9d0..8be9248 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -23,6 +23,25 @@ #include /** + * struct samsung_clock_alias: information about mux clock + * @id: platform specific id of the clock. + * @dev_name: name of the device to which this clock belongs. + * @alias: optional clock alias name to be assigned to this clock. + */ +struct samsung_clock_alias { + unsigned int id; + const char *dev_name; + const char *alias; +}; + +#define ALIAS(_id, dname, a) \ + { \ + .id = _id, \ + .dev_name = dname, \ + .alias = a, \ + } + +/** * struct samsung_fixed_rate_clock: information about fixed-rate clock * @id: platform specific id of the clock. * @name: name of this fixed-rate clock. @@ -260,6 +282,8 @@ extern void __init samsung_clk_of_register_fixed_ext( extern void samsung_clk_add_lookup(struct clk *clk, unsigned int id); +extern void samsung_clk_register_alias(struct samsung_clock_alias *list, + unsigned int nr_clk); extern void __init samsung_clk_register_fixed_rate( struct samsung_fixed_rate_clock *clk_list, unsigned int nr_clk); extern void __init samsung_clk_register_fixed_factor(