drivers/sh/clk: add support for CLK_SET_TO_ENABLE flag
PATCH 1/5 drivers/sh/clk: add support for CLK_SET_TO_ENABLE flag
The current sh_clk_mstp_{enable,disable} functions assume that enable_bit must be cleared to enable the clock, and set to disable the clock.
However, this clock type is used for the PHY of the SH7786 PCIe controller, which has the opposite polarity: set to enable, clear to disable. In order to properly support this clock, we introduce a CLK_SET_TO_ENABLE flag.
--- drivers/sh/clk/cpg.c | 10 ++++++++-- include/linux/sh_clk.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/sh/clk/cpg.c +8 -2
@@ -53,7 +53,10 @@ static unsigned int r32(const void __iomem *addr)static int sh_clk_mstp_enable (struct clk *clk) { -sh_clk_write (sh_clk_read (clk) & ~(1 << clk->enable_bit), clk); +if (clk->flags &CLK_SET_TO_ENABLE ) +sh_clk_write (sh_clk_read (clk) | (1 << clk->enable_bit), clk); +else +sh_clk_write (sh_clk_read (clk) & ~(1 << clk->enable_bit), clk);if (clk->status_reg) {unsigned int (*read)(const void __iomem *addr);int i;
@@ -82,7 +85,10 @@ static int sh_clk_mstp_enable(struct clk *clk)static void sh_clk_mstp_disable (struct clk *clk) { -sh_clk_write (sh_clk_read (clk) | (1 << clk->enable_bit), clk); +if (clk->flags &CLK_SET_TO_ENABLE ) +sh_clk_write (sh_clk_read (clk) & ~(1 << clk->enable_bit), clk); +else +sh_clk_write (sh_clk_read (clk) | (1 << clk->enable_bit), clk); }static struct sh_clk_ops sh_clk_mstp_clk_ops = {
include/linux/sh_clk.h +2 -0
@@ -73,6 +73,8 @@ struct clk {#define CLK_MASK_DIV_ON_DISABLE BIT(4) +#define CLK_SET_TO_ENABLE BIT(5) +#define CLK_ENABLE_REG_MASK (CLK_ENABLE_REG_32BIT | \ CLK_ENABLE_REG_16BIT | \ CLK_ENABLE_REG_8BIT)
Signature · 1 line
2.14.3
Hi Thomas,
Thanks for your patch!
Quoted 3 lines · Thomas Petazzoni
The current sh_clk_mstp_{enable,disable} functions assume that
enable_bitmust be cleared to enable the clock, and set to disable the clock.
Correct, mstp stands for "Module SToP".
Quoted 4 lines
However, this clock type is used for the PHY of the SH7786 PCIe controller, which has the opposite polarity: set to enable, clear to disable. In order to properly support this clock, we introduce a
CLK_SET_TO_ENABLEflag.
I think the correct solution is to not model the PHY clock as an MSTP clock, so you don't need to pollute the MSTP clock driver with foreign clock support.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds