sunxi clock fixes
Emilio López
maintainercover sunxi clock fixes
Hi,
This small series contains two bug fixes and a patch to solve the issue of accidental clock gating, as discussed earlier on my RFC patch, "of:
add a basic memory driver".
I believe the two first patches should go into -rcN, although I have not noticed any issues so far coming from the bugs themselves.
The third patch should be a no-op for now, and I'd like to have it merged before these clocks actually appear on the driver; in this way they will never be gated accidentally, and it remains bisectable. I will be sending PLL5/6 support patches in short order.
Cheers,
Emilio
Emilio L?pez (3):
clk: sunxi: factors: fix off-by-one masks
clk: sunxi: factors: clear variables before using them
clk: sunxi: protect core clocks from accidental shutdown
drivers/clk/sunxi/clk-factors.c | 4 ++-- drivers/clk/sunxi/clk-sunxi.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.4
Emilio López
maintainerPATCH 1/3 clk: sunxi: factors: fix off-by-one masks
The previous code would generate one bit too long masks, and was needlessly complicated. This patch replaces it by simpler code that can generate the masks correctly.
--- drivers/clk/sunxi/clk-factors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-factors.c +1 -1
@@ -40,7 +40,7 @@ struct clk_factors {#define to_clk_factors (_hw) container_of(_hw, struct clk_factors, hw) -#define SETMASK (len, pos) (((-1U) >> (31-len)) << (pos)) +#define SETMASK (len, pos) (((1U << (len)) - 1) << (pos))#define CLRMASK (len, pos) (~(SETMASK(len, pos)))#define FACTOR_GET (bit, len, reg) (((reg) & SETMASK(len, bit)) >> (bit))
Signature · 1 line
1.8.4
PATCH 1/3 clk: sunxi: factors: fix off-by-one masks
Quoted 5 lines · Emilio L?pez
The previous code would generate one bit too long masks, and was needlessly complicated. This patch replaces it by simpler code that can generate the masks correctly.
Signed-off-by Emilio L?pez <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130923/73614c4b/attachment.sig>
Emilio López
maintainerPATCH 2/3 clk: sunxi: factors: clear variables before using them
In reply to Emilio LópezRandom bits may get into our factors if we don't clear n, k, m and p.
--- drivers/clk/sunxi/clk-factors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-factors.c +1 -1
@@ -88,7 +88,7 @@ static long clk_factors_round_rate(struct clk_hw *hw, unsigned long rate,static int clk_factors_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) { -u8 n, k, m, p; +u8 n =0 , k =0 , m =0 , p =0 ;u32 reg;struct clk_factors *factors =to_clk_factors (hw);struct clk_factors_config *config = factors->config;
Signature · 1 line
1.8.4
PATCH 2/3 clk: sunxi: factors: clear variables before using them
Quoted 3 lines · Emilio L?pez
Random bits may get into our factors if we don't clear n, k, m and p.
Signed-off-by Emilio L?pez <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130923/b34eb042/attachment.sig>
Emilio López
maintainerPATCH 3/3 clk: sunxi: protect core clocks from accidental shutdown
In reply to Emilio LópezSome important clocks may get disabled as a side effect of another clock being disabled, because they have no consumers. This patch implements a mechanism so those clocks can be claimed by the driver and therefore remain enabled at all times.
--- drivers/clk/sunxi/clk-sunxi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/clk/sunxi/clk-sunxi.c +28 -0
@@ -617,6 +617,31 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat } } +/** +* System clock protection +* +* By enabling these critical clocks, we prevent their accidental gating +* by the framework +*/ +static void __init sunxi_clock_protect (void ) +{ +struct clk *clk; + +/* memory bus clock - sun5i+ */ + clk =clk_get (NULL ,"mbus" ); +if (!IS_ERR (clk)) { +clk_prepare_enable (clk); +clk_put (clk); + } + +/* DDR clock - sun4i+ */ + clk =clk_get (NULL ,"pll5_ddr" ); +if (!IS_ERR (clk)) { +clk_prepare_enable (clk); +clk_put (clk); + } +} +void __init sunxi_init_clocks (void ) {/* Register all the simple and basic clocks on DT */
@@ -633,4 +658,7 @@ void __init sunxi_init_clocks(void)/* Register gate clocks */ of_sunxi_table_clock_setup (clk_gates_match, sunxi_gates_clk_setup); + +/* Enable core system clocks */ +sunxi_clock_protect (); }
Signature · 1 line
1.8.4
PATCH 3/3 clk: sunxi: protect core clocks from accidental shutdown
Quoted 6 lines · Emilio L?pez
Some important clocks may get disabled as a side effect of another clock being disabled, because they have no consumers. This patch implements a mechanism so those clocks can be claimed by the driver and therefore remain enabled at all times.
Signed-off-by Emilio L?pez <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130923/878c7f57/attachment.sig>
Emilio López
maintainercover sunxi clock fixes
In reply to Emilio LópezHi Mike,
El 20/09/13 22:03, Emilio L?pez escribi?:
Quoted 18 lines
Hi,
This small series contains two bug fixes and a patch to solve the issue of accidental clock gating, as discussed earlier on my RFC patch, "of:
add a basic memory driver".I believe the two first patches should go into -rcN, although I have not noticed any issues so far coming from the bugs themselves.
The third patch should be a no-op for now, and I'd like to have it merged before these clocks actually appear on the driver; in this way they will never be gated accidentally, and it remains bisectable. I will be sending PLL5/6 support patches in short order.
Cheers,
Emilio
Quoted 9 lines
Emilio L?pez (3):
clk: sunxi: factors: fix off-by-one masks
clk: sunxi: factors: clear variables before using them
clk: sunxi: protect core clocks from accidental shutdowndrivers/clk/sunxi/clk-factors.c | 4 ++-- drivers/clk/sunxi/clk-sunxi.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-)
Can you please take a look at this series and pick the patches if you are ok with them? It would be nice to see the first two fixes on -rcN by the way.
Thanks!
Emilio
Emilio López
maintainercover sunxi clock fixes
El 09/10/13 09:51, Emilio L?pez escribi?:
Quoted 26 lines
Hi Mike,
El 20/09/13 22:03, Emilio L?pez escribi?:
Quoted 23 lines
Hi,
This small series contains two bug fixes and a patch to solve the issue of accidental clock gating, as discussed earlier on my RFC patch, "of:
add a basic memory driver".I believe the two first patches should go into -rcN, although I have not noticed any issues so far coming from the bugs themselves.
The third patch should be a no-op for now, and I'd like to have it merged before these clocks actually appear on the driver; in this way they will never be gated accidentally, and it remains bisectable. I will be sending PLL5/6 support patches in short order.
Cheers,
Emilio
Emilio L?pez (3):
clk: sunxi: factors: fix off-by-one masks
clk: sunxi: factors: clear variables before using them
clk: sunxi: protect core clocks from accidental shutdown
Quoted 8 lines
Quoted 4 lines
drivers/clk/sunxi/clk-factors.c | 4 ++-- drivers/clk/sunxi/clk-sunxi.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-)Can you please take a look at this series and pick the patches if you are ok with them? It would be nice to see the first two fixes on -rcN by the way.
$ ping Mike