diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clk.h | 24 | ||||
-rw-r--r-- | include/linux/clk-provider.h | 9 |
2 files changed, 32 insertions, 1 deletions
diff --git a/include/clk.h b/include/clk.h index a6ef4e02692..f94135ff778 100644 --- a/include/clk.h +++ b/include/clk.h @@ -13,6 +13,15 @@ #include <linux/errno.h> #include <linux/types.h> +#ifdef CONFIG_CLK_AUTO_ID +#define CLK_ID_SZ 24 +#define CLK_ID_MSK GENMASK(23, 0) +#define CLK_ID(dev, id) (((dev_seq(dev) + 1) << CLK_ID_SZ) | ((id) & CLK_ID_MSK)) +#else +#define CLK_ID_MSK (~0UL) +#define CLK_ID(dev, id) id +#endif + /** * DOC: Overview * @@ -570,6 +579,16 @@ int clk_get_by_id(ulong id, struct clk **clkp); */ bool clk_dev_binded(struct clk *clk); +/** + * clk_get_id - get clk id + * + * @clk: A clock struct + * + * Return: the clock identifier as it is defined by the clock provider in + * device tree or in platdata + */ +ulong clk_get_id(const struct clk *clk); + #else /* CONFIG_IS_ENABLED(CLK) */ static inline int clk_request(struct udevice *dev, struct clk *clk) @@ -641,6 +660,11 @@ static inline bool clk_dev_binded(struct clk *clk) { return false; } + +static inline ulong clk_get_id(const struct clk *clk) +{ + return 0; +} #endif /* CONFIG_IS_ENABLED(CLK) */ /** diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 267757939e0..2d754fa4287 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -15,10 +15,17 @@ struct udevice; +/* update clock ID for the dev = clock provider, compatible with CLK_AUTO_ID */ +static inline void dev_clk_dm(const struct udevice *dev, ulong id, struct clk *clk) +{ + if (!IS_ERR(clk)) + clk->id = CLK_ID(dev, id); +} + static inline void clk_dm(ulong id, struct clk *clk) { if (!IS_ERR(clk)) - clk->id = id; + clk->id = CLK_ID(clk->dev, id); } /* |