Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: clk_set_parent() by name ?
On Mon, Mar 19, 2018 at 03:02:09PM +0100, Manuel Bouyer wrote:
> Hello
> right now, at last in the arm/sunxi port, for clocks with MUXes we never
> explicitely set the parent: we use whatever is there at boot.
> For the display drivers I need to set the parent, as this is not setup
> (or not completely setup) by u-boot.
>
> Looking at what we have now, I see 2 ways for doing this:
> - clk_set_parent(). But this one takes a "struct clk*" as parent,
> and I don't have this handy in the driver. There is clk_get(), but it
> need the ckock domain, which I also don't have it in the driver.
> There is no clk_get_domain()
> - clk->set_parent(), which takes a clock name. But for this I need to
> use a struct sunxi_ccu_clk * instead of struct clk *.
>
> So what should I do to solve this ? Introduce clk_get_domain() or
> clk_set_parent_byname() in sys/dev/clk/, or use struct sunxi_ccu_clk in
> the sunxi drivers ?
Attachted is an implementation of clk_set_parent_byname(), which is working
for my purpose.
--
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
NetBSD: 26 ans d'experience feront toujours la difference
--
Index: clk.c
===================================================================
RCS file: /cvsroot/src/sys/dev/clk/clk.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 clk.c
--- clk.c 16 Apr 2017 12:28:21 -0000 1.2
+++ clk.c 19 Mar 2018 16:05:24 -0000
@@ -93,6 +93,16 @@ clk_set_parent(struct clk *clk, struct c
return EINVAL;
}
+int
+clk_set_parent_byname(struct clk *clk, const char *name)
+{
+ struct clk *pclk;
+ pclk = clk_get(clk->domain, name);
+ if (pclk == NULL)
+ return EINVAL;
+ return clk_set_parent(clk, pclk);
+}
+
struct clk *
clk_get_parent(struct clk *clk)
{
Index: clk.h
===================================================================
RCS file: /cvsroot/src/sys/dev/clk/clk.h,v
retrieving revision 1.2
diff -u -p -u -r1.2 clk.h
--- clk.h 16 Apr 2017 12:28:21 -0000 1.2
+++ clk.h 19 Mar 2018 16:05:24 -0000
@@ -39,6 +39,7 @@ int clk_set_rate(struct clk *, u_int);
int clk_enable(struct clk *);
int clk_disable(struct clk *);
int clk_set_parent(struct clk *, struct clk *);
+int clk_set_parent_byname(struct clk *, const char *);
struct clk * clk_get_parent(struct clk *);
#endif /* _DEV_CLK_CLK_H */
Home |
Main Index |
Thread Index |
Old Index