* [PATCH] clk: sunxi: gmac-tx-clk mux is not a CLK_MUX_INDEX_BIT mux
@ 2014-11-16 12:56 Hans de Goede
[not found] ` <1416142617-4094-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2014-11-16 12:56 UTC (permalink / raw)
To: Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Grant Likely,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Hans de Goede
A CLK_MUX_INDEX_BIT mux has one bit per parent, but the sun7i-a20-gmac-clk
has 2 bits selecting between 3 possible parents using values of 0, 1, 2,
which makes it a regular mux which should not have CLK_MUX_INDEX_BIT set in
its flag.
However we do not support parent 1 (an external clock), so use a table to
select parent 0 or 2, which are the 2 parents we support.
Note this has not been causing any issues sofar, because we start with a
parent setting of parent 0, and only ever re-parent to parent 2 (for which
we use an index of 1 as we skip parent 1) and with CLK_MUX_INDEX_BIT set
we write a value of 2 for index 1.
Tested on both a cubietruck (which uses rgmii mode) as well as a cs908
(an a31s board which uses mii mode).
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
drivers/clk/sunxi/clk-a20-gmac.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/sunxi/clk-a20-gmac.c b/drivers/clk/sunxi/clk-a20-gmac.c
index 5296fd6..0dcf4f2 100644
--- a/drivers/clk/sunxi/clk-a20-gmac.c
+++ b/drivers/clk/sunxi/clk-a20-gmac.c
@@ -53,6 +53,11 @@ static DEFINE_SPINLOCK(gmac_lock);
#define SUN7I_A20_GMAC_MASK 0x3
#define SUN7I_A20_GMAC_PARENTS 2
+static u32 sun7i_a20_gmac_mux_table[SUN7I_A20_GMAC_PARENTS] = {
+ 0x00, /* Select mii_phy_tx_clk */
+ 0x02, /* Select gmac_int_tx_clk */
+};
+
static void __init sun7i_a20_gmac_clk_setup(struct device_node *node)
{
struct clk *clk;
@@ -90,7 +95,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct device_node *node)
gate->lock = &gmac_lock;
mux->reg = reg;
mux->mask = SUN7I_A20_GMAC_MASK;
- mux->flags = CLK_MUX_INDEX_BIT;
+ mux->table = sun7i_a20_gmac_mux_table;
mux->lock = &gmac_lock;
clk = clk_register_composite(NULL, clk_name,
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1416142617-4094-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] clk: sunxi: gmac-tx-clk mux is not a CLK_MUX_INDEX_BIT mux [not found] ` <1416142617-4094-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2014-11-16 17:13 ` Maxime Ripard 2014-11-18 5:51 ` Chen-Yu Tsai 1 sibling, 0 replies; 3+ messages in thread From: Maxime Ripard @ 2014-11-16 17:13 UTC (permalink / raw) To: Hans de Goede Cc: Emilio Lopez, Mike Turquette, Chen-Yu Tsai, Philipp Zabel, Grant Likely, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw [-- Attachment #1: Type: text/plain, Size: 1044 bytes --] On Sun, Nov 16, 2014 at 01:56:57PM +0100, Hans de Goede wrote: > A CLK_MUX_INDEX_BIT mux has one bit per parent, but the sun7i-a20-gmac-clk > has 2 bits selecting between 3 possible parents using values of 0, 1, 2, > which makes it a regular mux which should not have CLK_MUX_INDEX_BIT set in > its flag. > > However we do not support parent 1 (an external clock), so use a table to > select parent 0 or 2, which are the 2 parents we support. > > Note this has not been causing any issues sofar, because we start with a > parent setting of parent 0, and only ever re-parent to parent 2 (for which > we use an index of 1 as we skip parent 1) and with CLK_MUX_INDEX_BIT set > we write a value of 2 for index 1. > > Tested on both a cubietruck (which uses rgmii mode) as well as a cs908 > (an a31s board which uses mii mode). > > Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Applied, thanks. Maxime -- Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: sunxi: gmac-tx-clk mux is not a CLK_MUX_INDEX_BIT mux [not found] ` <1416142617-4094-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2014-11-16 17:13 ` Maxime Ripard @ 2014-11-18 5:51 ` Chen-Yu Tsai 1 sibling, 0 replies; 3+ messages in thread From: Chen-Yu Tsai @ 2014-11-18 5:51 UTC (permalink / raw) To: Hans de Goede Cc: Emilio Lopez, Mike Turquette, Maxime Ripard, Philipp Zabel, Grant Likely, linux-arm-kernel, devicetree, linux-sunxi Hi, On Sun, Nov 16, 2014 at 4:56 AM, Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > A CLK_MUX_INDEX_BIT mux has one bit per parent, but the sun7i-a20-gmac-clk > has 2 bits selecting between 3 possible parents using values of 0, 1, 2, > which makes it a regular mux which should not have CLK_MUX_INDEX_BIT set in > its flag. > > However we do not support parent 1 (an external clock), so use a table to > select parent 0 or 2, which are the 2 parents we support. > > Note this has not been causing any issues sofar, because we start with a > parent setting of parent 0, and only ever re-parent to parent 2 (for which > we use an index of 1 as we skip parent 1) and with CLK_MUX_INDEX_BIT set > we write a value of 2 for index 1. We never use parent 1, and some hardware doesn't even have it. So back then I went for CLK_MUX_INDEX_BIT to simplify it. Guess it's not the best way to do it. > Tested on both a cubietruck (which uses rgmii mode) as well as a cs908 > (an a31s board which uses mii mode). > > Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > drivers/clk/sunxi/clk-a20-gmac.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/sunxi/clk-a20-gmac.c b/drivers/clk/sunxi/clk-a20-gmac.c > index 5296fd6..0dcf4f2 100644 > --- a/drivers/clk/sunxi/clk-a20-gmac.c > +++ b/drivers/clk/sunxi/clk-a20-gmac.c > @@ -53,6 +53,11 @@ static DEFINE_SPINLOCK(gmac_lock); > #define SUN7I_A20_GMAC_MASK 0x3 > #define SUN7I_A20_GMAC_PARENTS 2 > > +static u32 sun7i_a20_gmac_mux_table[SUN7I_A20_GMAC_PARENTS] = { > + 0x00, /* Select mii_phy_tx_clk */ > + 0x02, /* Select gmac_int_tx_clk */ > +}; > + > static void __init sun7i_a20_gmac_clk_setup(struct device_node *node) > { > struct clk *clk; > @@ -90,7 +95,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct device_node *node) > gate->lock = &gmac_lock; > mux->reg = reg; > mux->mask = SUN7I_A20_GMAC_MASK; > - mux->flags = CLK_MUX_INDEX_BIT; > + mux->table = sun7i_a20_gmac_mux_table; > mux->lock = &gmac_lock; > > clk = clk_register_composite(NULL, clk_name, > -- > 2.1.0 > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-18 5:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-16 12:56 [PATCH] clk: sunxi: gmac-tx-clk mux is not a CLK_MUX_INDEX_BIT mux Hans de Goede
[not found] ` <1416142617-4094-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-16 17:13 ` Maxime Ripard
2014-11-18 5:51 ` Chen-Yu Tsai
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).