@@ -39,7 +39,10 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
clks[i].clk = NULL;
for (i = 0; i < num_clks; i++) {
- clks[i].clk = clk_get(dev, clks[i].id);
+ if (clks->flags & CLK_BULK_CLK_GET_OF)
+ clks[i].clk = of_clk_get(dev->of_node, i);
+ else
+ clks[i].clk = clk_get(dev, clks[i].id);
if (IS_ERR(clks[i].clk)) {
ret = PTR_ERR(clks[i].clk);
dev_err(dev, "Failed to get clk '%s': %d\n",
@@ -82,16 +82,24 @@ struct clk_notifier_data {
*
* @id: clock consumer ID
* @clk: struct clk * to store the associated clock
+ * @flags: bulk clk operation flags
*
* The CLK APIs provide a series of clk_bulk_() API calls as
* a convenience to consumers which require multiple clks. This
* structure is used to manage data for these calls.
+ *
+ * Flags:
+ * CLK_BULK_CLK_GET_OF - Instead of calling clk_get() to retrieve clock by id,
+ * clk_bulk_get() API will call of_clk_get() to find clock by index.
*/
struct clk_bulk_data {
const char *id;
struct clk *clk;
+ unsigned long flags;
};
+#define CLK_BULK_CLK_GET_OF BIT(0)
+
#ifdef CONFIG_COMMON_CLK
/**
@@ -270,7 +278,9 @@ static inline void clk_bulk_unprepare(int num_clks, struct clk_bulk_data *clks)
* Returns 0 if all clocks specified in clk_bulk_data table are obtained
* successfully, or valid IS_ERR() condition containing errno.
* The implementation uses @dev and @clk_bulk_data.id to determine the
- * clock consumer, and thereby the clock producer.
+ * clock consumer, and thereby the clock producer. If flag CLK_BULK_CLK_GET_OF
+ * is set in @clk_bulk_data.flags, @clk_bulk_data.id will be ignored and the API
+ * will look up clock by calling of_clk_get() with clock index.
* The clock returned is stored in each @clk_bulk_data.clk field.
*
* Drivers must assume that the clock source is not enabled.