clk: samsung: add infrastructure to add separate aliases
authorHeiko Stuebner <heiko@sntech.de>
Mon, 18 Mar 2013 04:43:56 +0000 (13:43 +0900)
committerKukjin Kim <kgene.kim@samsung.com>
Thu, 28 Mar 2013 05:46:33 +0000 (14:46 +0900)
The current code adds aliases, if necessary, directly when adding
the clock, limiting the number of possible aliases to one.

Some platforms need more than one alias, like the hsmmc pclocks on
s3c2416 which need a "hsmmc" and "mmc_busclk.0" alias for the s3c-
sdhci driver.

Therefore add the possibility to separately add clock aliases for
previously created clocks.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
drivers/clk/samsung/clk.c
drivers/clk/samsung/clk.h

index 1ed571606395cef04987232612861453ad9d5a91..82f27f644dae584eeb51cddbebb2c224ff4bc288 100644 (file)
@@ -97,6 +97,39 @@ 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;
+               }
+
+               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)
index 26a752b18f88c27092ceced42f3ee70b58dd67b8..6bacd6fa0200752e6461998bb967122fef370dc6 100644 (file)
 
 #include <mach/map.h>
 
+/**
+ * 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.
@@ -251,6 +270,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(