Message ID | 1380224130-11868-2-git-send-email-ezequiel.garcia@free-electrons.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > This commit introduces a new group of clocks present in Armada 370/XP > SoCs (called "Core Divider" clocks) and add a provider for them. > The only clock supported for now is the NAND clock (ndclk), but the > infrastructure to add the rest is already set. > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > --- > drivers/clk/mvebu/Kconfig | 5 + > drivers/clk/mvebu/Makefile | 1 + > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 229 insertions(+) > create mode 100644 drivers/clk/mvebu/clk-corediv.c Acked-by: Jason Cooper <jason@lakedaemon.net> Please let me know once this gets pulled into the clock tree, and I'll pull in the remaining patches. thx, Jason.
On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > This commit introduces a new group of clocks present in Armada 370/XP > > SoCs (called "Core Divider" clocks) and add a provider for them. > > The only clock supported for now is the NAND clock (ndclk), but the > > infrastructure to add the rest is already set. > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > --- > > drivers/clk/mvebu/Kconfig | 5 + > > drivers/clk/mvebu/Makefile | 1 + > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 229 insertions(+) > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > Acked-by: Jason Cooper <jason@lakedaemon.net> > Mike: any comments on this?
On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > This commit introduces a new group of clocks present in Armada 370/XP > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > The only clock supported for now is the NAND clock (ndclk), but the > > > infrastructure to add the rest is already set. > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > --- > > > drivers/clk/mvebu/Kconfig | 5 + > > > drivers/clk/mvebu/Makefile | 1 + > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > 3 files changed, 229 insertions(+) > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > Mike: any comments on this? ping? I'd like to move along with the NAND driver for this controller and -although these are not a hard requirement- it would be nice to have them merged. Thanks!
On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > infrastructure to add the rest is already set. > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > --- > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > drivers/clk/mvebu/Makefile | 1 + > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > 3 files changed, 229 insertions(+) > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > Mike: any comments on this? > > ping? > > I'd like to move along with the NAND driver for this controller and > -although these are not a hard requirement- it would be nice > to have them merged. > Mike? Any chance you pick these soon? It's been almost three-weeks since these patchset has been sent and I'm starting to forget the details of it ;)
On Wed, Oct 16, 2013 at 08:08:19AM -0300, Ezequiel Garcia wrote: > On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > > infrastructure to add the rest is already set. > > > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > > --- > > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > > drivers/clk/mvebu/Makefile | 1 + > > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > > 3 files changed, 229 insertions(+) > > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > > > > Mike: any comments on this? > > > > ping? > > > > I'd like to move along with the NAND driver for this controller and > > -although these are not a hard requirement- it would be nice > > to have them merged. > > > > Mike? Any chance you pick these soon? It's been almost three-weeks since > these patchset has been sent and I'm starting to forget the details of it ;) Jason: It seems Mike went on 'stealth mode' so I'm wondering if you would consider taking this patchset through you (given it's for our SoCs). The patches have been reviewed by Gregory and have your Ack, but unfortunately I don't know if Mike took a look on them. On the other side, this adds a new clock to be used with NAND, so it's completely isolated and innocuous. I hate to re-route patches this way -so feel free to refuse- but other I don't see any way this can be in v3.13. Thanks!
On Thu, Oct 17, 2013 at 04:18:53PM -0300, Ezequiel Garcia wrote: > On Wed, Oct 16, 2013 at 08:08:19AM -0300, Ezequiel Garcia wrote: > > On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > > > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > > > infrastructure to add the rest is already set. > > > > > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > > > --- > > > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > > > drivers/clk/mvebu/Makefile | 1 + > > > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > > > 3 files changed, 229 insertions(+) > > > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > > > > > > > Mike: any comments on this? > > > > > > ping? > > > > > > I'd like to move along with the NAND driver for this controller and > > > -although these are not a hard requirement- it would be nice > > > to have them merged. > > > > > > > Mike? Any chance you pick these soon? It's been almost three-weeks since > > these patchset has been sent and I'm starting to forget the details of it ;) > > Jason: It seems Mike went on 'stealth mode' so I'm wondering if you would > consider taking this patchset through you (given it's for our SoCs). I considered it, and it didn't sit well with me. I don't mind taking a bugfix, everyone wants to see those moved along. However, this is an entirely new driver. Yes, it's scope of use is limited, but I'd prefer to let the maintainer review the driver before agreeing to maintain it. Otherwise, I'd be forcing him to maintain something he hasn't even looked at. :( I know it sucks, but we're going to wait for Mike. thx, Jason.
Quoting Jason Cooper (2013-10-17 12:25:45) > On Thu, Oct 17, 2013 at 04:18:53PM -0300, Ezequiel Garcia wrote: > > On Wed, Oct 16, 2013 at 08:08:19AM -0300, Ezequiel Garcia wrote: > > > On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > > > > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > > > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > > > > infrastructure to add the rest is already set. > > > > > > > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > > > > --- > > > > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > > > > drivers/clk/mvebu/Makefile | 1 + > > > > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > > > > 3 files changed, 229 insertions(+) > > > > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > > > > > > > > > > Mike: any comments on this? > > > > > > > > ping? > > > > > > > > I'd like to move along with the NAND driver for this controller and > > > > -although these are not a hard requirement- it would be nice > > > > to have them merged. > > > > > > > > > > Mike? Any chance you pick these soon? It's been almost three-weeks since > > > these patchset has been sent and I'm starting to forget the details of it ;) > > > > Jason: It seems Mike went on 'stealth mode' so I'm wondering if you would > > consider taking this patchset through you (given it's for our SoCs). > > I considered it, and it didn't sit well with me. I don't mind taking a > bugfix, everyone wants to see those moved along. However, this is an > entirely new driver. Yes, it's scope of use is limited, but I'd prefer > to let the maintainer review the driver before agreeing to maintain it. > Otherwise, I'd be forcing him to maintain something he hasn't even > looked at. :( > > I know it sucks, but we're going to wait for Mike. Sorry for the delay. This driver looks fine and I've taken it into clk-next. Thanks! Mike > > thx, > > Jason.
On Tue, Oct 22, 2013 at 02:53:17AM -0700, Mike Turquette wrote: > Quoting Jason Cooper (2013-10-17 12:25:45) > > On Thu, Oct 17, 2013 at 04:18:53PM -0300, Ezequiel Garcia wrote: > > > On Wed, Oct 16, 2013 at 08:08:19AM -0300, Ezequiel Garcia wrote: > > > > On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > > > > > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > > > > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > > > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > > > > > infrastructure to add the rest is already set. > > > > > > > > > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > > > > > --- > > > > > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > > > > > drivers/clk/mvebu/Makefile | 1 + > > > > > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > > > > > 3 files changed, 229 insertions(+) > > > > > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > > > > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > > > > > > > > > > > > > Mike: any comments on this? > > > > > > > > > > ping? > > > > > > > > > > I'd like to move along with the NAND driver for this controller and > > > > > -although these are not a hard requirement- it would be nice > > > > > to have them merged. > > > > > > > > > > > > > Mike? Any chance you pick these soon? It's been almost three-weeks since > > > > these patchset has been sent and I'm starting to forget the details of it ;) > > > > > > Jason: It seems Mike went on 'stealth mode' so I'm wondering if you would > > > consider taking this patchset through you (given it's for our SoCs). > > > > I considered it, and it didn't sit well with me. I don't mind taking a > > bugfix, everyone wants to see those moved along. However, this is an > > entirely new driver. Yes, it's scope of use is limited, but I'd prefer > > to let the maintainer review the driver before agreeing to maintain it. > > Otherwise, I'd be forcing him to maintain something he hasn't even > > looked at. :( > > > > I know it sucks, but we're going to wait for Mike. > > Sorry for the delay. This driver looks fine and I've taken it into > clk-next. > No problem, thanks Mike!
Hi Mike, On Tue, Oct 22, 2013 at 02:53:17AM -0700, Mike Turquette wrote: > Quoting Jason Cooper (2013-10-17 12:25:45) > > On Thu, Oct 17, 2013 at 04:18:53PM -0300, Ezequiel Garcia wrote: > > > On Wed, Oct 16, 2013 at 08:08:19AM -0300, Ezequiel Garcia wrote: > > > > On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > > > > > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > > > > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > > > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > > > > > infrastructure to add the rest is already set. > > > > > > > > > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > > > > > --- > > > > > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > > > > > drivers/clk/mvebu/Makefile | 1 + > > > > > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > > > > > 3 files changed, 229 insertions(+) > > > > > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > > > > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > > > > > > > > > > > > > Mike: any comments on this? > > > > > > > > > > ping? > > > > > > > > > > I'd like to move along with the NAND driver for this controller and > > > > > -although these are not a hard requirement- it would be nice > > > > > to have them merged. > > > > > > > > > > > > > Mike? Any chance you pick these soon? It's been almost three-weeks since > > > > these patchset has been sent and I'm starting to forget the details of it ;) > > > > > > Jason: It seems Mike went on 'stealth mode' so I'm wondering if you would > > > consider taking this patchset through you (given it's for our SoCs). > > > > I considered it, and it didn't sit well with me. I don't mind taking a > > bugfix, everyone wants to see those moved along. However, this is an > > entirely new driver. Yes, it's scope of use is limited, but I'd prefer > > to let the maintainer review the driver before agreeing to maintain it. > > Otherwise, I'd be forcing him to maintain something he hasn't even > > looked at. :( > > > > I know it sucks, but we're going to wait for Mike. > > Sorry for the delay. This driver looks fine and I've taken it into > clk-next. > This commit doesn't seem to be in clk-next (or in any other place), nearly two months after I submitted it, and after a month I was told it was accepted. What's going on? I really hope I'm missing something or I'm looking at the wrong tree.
On Sun, Nov 17, 2013 at 01:52:52AM -0300, Ezequiel Garcia wrote: > Hi Mike, > > On Tue, Oct 22, 2013 at 02:53:17AM -0700, Mike Turquette wrote: > > Quoting Jason Cooper (2013-10-17 12:25:45) > > > On Thu, Oct 17, 2013 at 04:18:53PM -0300, Ezequiel Garcia wrote: > > > > On Wed, Oct 16, 2013 at 08:08:19AM -0300, Ezequiel Garcia wrote: > > > > > On Tue, Oct 08, 2013 at 04:59:33PM -0300, Ezequiel Garcia wrote: > > > > > > On Wed, Oct 02, 2013 at 03:09:44PM -0300, Ezequiel Garcia wrote: > > > > > > > On Wed, Oct 02, 2013 at 01:43:32PM -0400, Jason Cooper wrote: > > > > > > > > On Thu, Sep 26, 2013 at 04:35:27PM -0300, Ezequiel Garcia wrote: > > > > > > > > > This commit introduces a new group of clocks present in Armada 370/XP > > > > > > > > > SoCs (called "Core Divider" clocks) and add a provider for them. > > > > > > > > > The only clock supported for now is the NAND clock (ndclk), but the > > > > > > > > > infrastructure to add the rest is already set. > > > > > > > > > > > > > > > > > > Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com> > > > > > > > > > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> > > > > > > > > > --- > > > > > > > > > drivers/clk/mvebu/Kconfig | 5 + > > > > > > > > > drivers/clk/mvebu/Makefile | 1 + > > > > > > > > > drivers/clk/mvebu/clk-corediv.c | 223 ++++++++++++++++++++++++++++++++++++++++ > > > > > > > > > 3 files changed, 229 insertions(+) > > > > > > > > > create mode 100644 drivers/clk/mvebu/clk-corediv.c > > > > > > > > > > > > > > > > Acked-by: Jason Cooper <jason@lakedaemon.net> > > > > > > > > > > > > > > > > > > > > > > Mike: any comments on this? > > > > > > > > > > > > ping? > > > > > > > > > > > > I'd like to move along with the NAND driver for this controller and > > > > > > -although these are not a hard requirement- it would be nice > > > > > > to have them merged. > > > > > > > > > > > > > > > > Mike? Any chance you pick these soon? It's been almost three-weeks since > > > > > these patchset has been sent and I'm starting to forget the details of it ;) > > > > > > > > Jason: It seems Mike went on 'stealth mode' so I'm wondering if you would > > > > consider taking this patchset through you (given it's for our SoCs). > > > > > > I considered it, and it didn't sit well with me. I don't mind taking a > > > bugfix, everyone wants to see those moved along. However, this is an > > > entirely new driver. Yes, it's scope of use is limited, but I'd prefer > > > to let the maintainer review the driver before agreeing to maintain it. > > > Otherwise, I'd be forcing him to maintain something he hasn't even > > > looked at. :( > > > > > > I know it sucks, but we're going to wait for Mike. > > > > Sorry for the delay. This driver looks fine and I've taken it into > > clk-next. > > > > This commit doesn't seem to be in clk-next (or in any other place), > nearly two months after I submitted it, and after a month I was told > it was accepted. > > What's going on? > > I really hope I'm missing something or I'm looking at the wrong tree. Hi Mike, This commit seems to be in your clk-next-3.13-fail branch: http://git.linaro.org/gitweb?p=people/mturquette/linux.git;a=shortlog;h=refs/heads/clk-next-3.13-fail What's the purpose of this branch? Why is the commit there and not in clk-next? If there's anything to review on this driver, just let me know so we can have this merged and move forward with the NAND support.
diff --git a/drivers/clk/mvebu/Kconfig b/drivers/clk/mvebu/Kconfig index 0b0f3e7..c339b82 100644 --- a/drivers/clk/mvebu/Kconfig +++ b/drivers/clk/mvebu/Kconfig @@ -4,15 +4,20 @@ config MVEBU_CLK_COMMON config MVEBU_CLK_CPU bool +config MVEBU_CLK_COREDIV + bool + config ARMADA_370_CLK bool select MVEBU_CLK_COMMON select MVEBU_CLK_CPU + select MVEBU_CLK_COREDIV config ARMADA_XP_CLK bool select MVEBU_CLK_COMMON select MVEBU_CLK_CPU + select MVEBU_CLK_COREDIV config DOVE_CLK bool diff --git a/drivers/clk/mvebu/Makefile b/drivers/clk/mvebu/Makefile index 1c7e70c..21bbfb4 100644 --- a/drivers/clk/mvebu/Makefile +++ b/drivers/clk/mvebu/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_MVEBU_CLK_COMMON) += common.o obj-$(CONFIG_MVEBU_CLK_CPU) += clk-cpu.o +obj-$(CONFIG_MVEBU_CLK_COREDIV) += clk-corediv.o obj-$(CONFIG_ARMADA_370_CLK) += armada-370.o obj-$(CONFIG_ARMADA_XP_CLK) += armada-xp.o diff --git a/drivers/clk/mvebu/clk-corediv.c b/drivers/clk/mvebu/clk-corediv.c new file mode 100644 index 0000000..7162615 --- /dev/null +++ b/drivers/clk/mvebu/clk-corediv.c @@ -0,0 +1,223 @@ +/* + * MVEBU Core divider clock + * + * Copyright (C) 2013 Marvell + * + * Ezequiel Garcia <ezequiel.garcia@free-electrons.com> + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include <linux/kernel.h> +#include <linux/clk-provider.h> +#include <linux/of_address.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include "common.h" + +#define CORE_CLK_DIV_RATIO_MASK 0xff +#define CORE_CLK_DIV_RATIO_RELOAD BIT(8) +#define CORE_CLK_DIV_ENABLE_OFFSET 24 +#define CORE_CLK_DIV_RATIO_OFFSET 0x8 + +struct clk_corediv_desc { + unsigned int mask; + unsigned int offset; + unsigned int fieldbit; +}; + +struct clk_corediv { + struct clk_hw hw; + void __iomem *reg; + struct clk_corediv_desc desc; + spinlock_t lock; +}; + +static struct clk_onecell_data clk_data; + +static const struct clk_corediv_desc mvebu_corediv_desc[] __initconst = { + { .mask = 0x3f, .offset = 8, .fieldbit = 1 }, /* NAND clock */ +}; + +#define to_corediv_clk(p) container_of(p, struct clk_corediv, hw) + +static int clk_corediv_is_enabled(struct clk_hw *hwclk) +{ + struct clk_corediv *corediv = to_corediv_clk(hwclk); + struct clk_corediv_desc *desc = &corediv->desc; + u32 enable_mask = BIT(desc->fieldbit) << CORE_CLK_DIV_ENABLE_OFFSET; + + return !!(readl(corediv->reg) & enable_mask); +} + +static int clk_corediv_enable(struct clk_hw *hwclk) +{ + struct clk_corediv *corediv = to_corediv_clk(hwclk); + struct clk_corediv_desc *desc = &corediv->desc; + unsigned long flags = 0; + u32 reg; + + spin_lock_irqsave(&corediv->lock, flags); + + reg = readl(corediv->reg); + reg |= (BIT(desc->fieldbit) << CORE_CLK_DIV_ENABLE_OFFSET); + writel(reg, corediv->reg); + + spin_unlock_irqrestore(&corediv->lock, flags); + + return 0; +} + +static void clk_corediv_disable(struct clk_hw *hwclk) +{ + struct clk_corediv *corediv = to_corediv_clk(hwclk); + struct clk_corediv_desc *desc = &corediv->desc; + unsigned long flags = 0; + u32 reg; + + spin_lock_irqsave(&corediv->lock, flags); + + reg = readl(corediv->reg); + reg &= ~(BIT(desc->fieldbit) << CORE_CLK_DIV_ENABLE_OFFSET); + writel(reg, corediv->reg); + + spin_unlock_irqrestore(&corediv->lock, flags); +} + +static unsigned long clk_corediv_recalc_rate(struct clk_hw *hwclk, + unsigned long parent_rate) +{ + struct clk_corediv *corediv = to_corediv_clk(hwclk); + struct clk_corediv_desc *desc = &corediv->desc; + u32 reg, div; + + reg = readl(corediv->reg + CORE_CLK_DIV_RATIO_OFFSET); + div = (reg >> desc->offset) & desc->mask; + return parent_rate / div; +} + +static long clk_corediv_round_rate(struct clk_hw *hwclk, unsigned long rate, + unsigned long *parent_rate) +{ + /* Valid ratio are 1:4, 1:5, 1:6 and 1:8 */ + u32 div; + + div = *parent_rate / rate; + if (div < 4) + div = 4; + else if (div > 6) + div = 8; + + return *parent_rate / div; +} + +static int clk_corediv_set_rate(struct clk_hw *hwclk, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_corediv *corediv = to_corediv_clk(hwclk); + struct clk_corediv_desc *desc = &corediv->desc; + unsigned long flags = 0; + u32 reg, div; + + div = parent_rate / rate; + + spin_lock_irqsave(&corediv->lock, flags); + + /* Write new divider to the divider ratio register */ + reg = readl(corediv->reg + CORE_CLK_DIV_RATIO_OFFSET); + reg &= ~(desc->mask << desc->offset); + reg |= (div & desc->mask) << desc->offset; + writel(reg, corediv->reg + CORE_CLK_DIV_RATIO_OFFSET); + + /* Set reload-force for this clock */ + reg = readl(corediv->reg) | BIT(desc->fieldbit); + writel(reg, corediv->reg); + + /* Now trigger the clock update */ + reg = readl(corediv->reg) | CORE_CLK_DIV_RATIO_RELOAD; + writel(reg, corediv->reg); + + /* + * Wait for clocks to settle down, and then clear all the + * ratios request and the reload request. + */ + udelay(1000); + reg &= ~(CORE_CLK_DIV_RATIO_MASK | CORE_CLK_DIV_RATIO_RELOAD); + writel(reg, corediv->reg); + udelay(1000); + + spin_unlock_irqrestore(&corediv->lock, flags); + + return 0; +} + +static const struct clk_ops corediv_ops = { + .enable = clk_corediv_enable, + .disable = clk_corediv_disable, + .is_enabled = clk_corediv_is_enabled, + .recalc_rate = clk_corediv_recalc_rate, + .round_rate = clk_corediv_round_rate, + .set_rate = clk_corediv_set_rate, +}; + +static void __init mvebu_corediv_clk_init(struct device_node *node) +{ + struct clk_init_data init; + struct clk_corediv *corediv; + struct clk **clks; + void __iomem *base; + const char *parent_name; + const char *clk_name; + int i; + + base = of_iomap(node, 0); + if (WARN_ON(!base)) + return; + + parent_name = of_clk_get_parent_name(node, 0); + + clk_data.clk_num = ARRAY_SIZE(mvebu_corediv_desc); + + /* clks holds the clock array */ + clks = kcalloc(clk_data.clk_num, sizeof(struct clk *), + GFP_KERNEL); + if (WARN_ON(!clks)) + goto err_unmap; + /* corediv holds the clock specific array */ + corediv = kcalloc(clk_data.clk_num, sizeof(struct clk_corediv), + GFP_KERNEL); + if (WARN_ON(!corediv)) + goto err_free_clks; + + spin_lock_init(&corediv->lock); + + for (i = 0; i < clk_data.clk_num; i++) { + of_property_read_string_index(node, "clock-output-names", + i, &clk_name); + init.num_parents = 1; + init.parent_names = &parent_name; + init.name = clk_name; + init.ops = &corediv_ops; + init.flags = 0; + + corediv[i].desc = mvebu_corediv_desc[i]; + corediv[i].reg = base; + corediv[i].hw.init = &init; + + clks[i] = clk_register(NULL, &corediv[i].hw); + WARN_ON(IS_ERR(clks[i])); + } + + clk_data.clks = clks; + of_clk_add_provider(node, of_clk_src_onecell_get, &clk_data); + return; + +err_free_clks: + kfree(clks); +err_unmap: + iounmap(base); +} +CLK_OF_DECLARE(mvebu_corediv_clk, "marvell,armada-370-corediv-clock", + mvebu_corediv_clk_init);