linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Turquette <mturquette@baylibre.com>
To: Gregory CLEMENT <gregory.clement@free-electrons.com>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Rob Herring" <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, "Jason Cooper" <jason@lakedaemon.net>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Sebastian Hesselbarth" <sebastian.hesselbarth@gmail.com>,
	"Gregory CLEMENT" <gregory.clement@free-electrons.com>,
	"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
	linux-arm-kernel@lists.infradead.org,
	"Nadav Haklai" <nadavh@marvell.com>,
	"Victor Gu" <xigu@marvell.com>,
	"Romain Perier" <romain.perier@free-electrons.com>,
	"Omri Itach" <omrii@marvell.com>,
	"Marcin Wojtas" <mw@semihalf.com>,
	"Wilson Ding" <dingwei@marvell.com>,
	"Hua Jing" <jinghua@marvell.com>,
	"Terry Zhou" <bjzhou@marvell.com>
Subject: Re: [PATCH v2 2/6] clk: mvebu: Add the xtal clock for Armada 3700 SoC
Date: Fri, 08 Jul 2016 10:32:40 -0700	[thread overview]
Message-ID: <146799916006.73491.13586762303347604368@resonance> (raw)
In-Reply-To: <1467931071-31004-3-git-send-email-gregory.clement@free-electrons.com>

Quoting Gregory CLEMENT (2016-07-07 15:37:47)
> This clock is the parent of all the Armada 3700 clocks. It is a fixed
> rate clock which depends on the gpio configuration read when resetting
> the SoC.
> =

> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
> ---
>  drivers/clk/mvebu/Kconfig            |  3 ++
>  drivers/clk/mvebu/Makefile           |  1 +
>  drivers/clk/mvebu/armada-37xx-xtal.c | 98 ++++++++++++++++++++++++++++++=
++++++
>  3 files changed, 102 insertions(+)
>  create mode 100644 drivers/clk/mvebu/armada-37xx-xtal.c
> =

> diff --git a/drivers/clk/mvebu/Kconfig b/drivers/clk/mvebu/Kconfig
> index 3165da77d525..fddc8ac5faff 100644
> --- a/drivers/clk/mvebu/Kconfig
> +++ b/drivers/clk/mvebu/Kconfig
> @@ -24,6 +24,9 @@ config ARMADA_39X_CLK
>         bool
>         select MVEBU_CLK_COMMON
>  =

> +config ARMADA_37XX_CLK
> +       bool
> +
>  config ARMADA_XP_CLK
>         bool
>         select MVEBU_CLK_COMMON
> diff --git a/drivers/clk/mvebu/Makefile b/drivers/clk/mvebu/Makefile
> index 7172ef65693d..4257a36d0219 100644
> --- a/drivers/clk/mvebu/Makefile
> +++ b/drivers/clk/mvebu/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_ARMADA_370_CLK)    +=3D armada-370.o
>  obj-$(CONFIG_ARMADA_375_CLK)   +=3D armada-375.o
>  obj-$(CONFIG_ARMADA_38X_CLK)   +=3D armada-38x.o
>  obj-$(CONFIG_ARMADA_39X_CLK)   +=3D armada-39x.o
> +obj-$(CONFIG_ARMADA_37XX_CLK)  +=3D armada-37xx-xtal.o
>  obj-$(CONFIG_ARMADA_XP_CLK)    +=3D armada-xp.o
>  obj-$(CONFIG_ARMADA_AP806_SYSCON) +=3D ap806-system-controller.o
>  obj-$(CONFIG_ARMADA_CP110_SYSCON) +=3D cp110-system-controller.o
> diff --git a/drivers/clk/mvebu/armada-37xx-xtal.c b/drivers/clk/mvebu/arm=
ada-37xx-xtal.c
> new file mode 100644
> index 000000000000..f832c219420f
> --- /dev/null
> +++ b/drivers/clk/mvebu/armada-37xx-xtal.c
> @@ -0,0 +1,98 @@
> +/*
> + * Marvell Armada 37xx SoC xtal clocks
> + *
> + * Copyright (C) 2016 Marvell
> + *
> + * Gregory CLEMENT <gregory.clement@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/clk.h>

Is clk.h necessary? Is this driver also a clock consumer?

Regards,
Mike

> +#include <linux/clk-provider.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +#define NB_GPIO1_LATCH 0xC
> +#define XTAL_MODE          BIT(31)
> +
> +static int armada_3700_xtal_clock_probe(struct platform_device *pdev)
> +{
> +       struct device_node *np =3D pdev->dev.of_node;
> +       const char *xtal_name =3D "xtal";
> +       struct device_node *parent;
> +       struct regmap *regmap;
> +       struct clk_hw *xtal_hw;
> +       unsigned int rate;
> +       u32 reg;
> +       int ret;
> +
> +       xtal_hw =3D devm_kzalloc(&pdev->dev, sizeof(*xtal_hw), GFP_KERNEL=
);
> +       if (!xtal_hw)
> +               return -ENOMEM;
> +
> +       platform_set_drvdata(pdev, xtal_hw);
> +
> +       parent =3D np->parent;
> +       if (!parent) {
> +               dev_err(&pdev->dev, "no parent\n");
> +               return -ENODEV;
> +       }
> +
> +       regmap =3D syscon_node_to_regmap(parent);
> +       if (IS_ERR(regmap)) {
> +               dev_err(&pdev->dev, "cannot get regmap\n");
> +               return PTR_ERR(regmap);
> +       }
> +
> +       ret =3D regmap_read(regmap, NB_GPIO1_LATCH, &reg);
> +       if (ret) {
> +               dev_err(&pdev->dev, "cannot read from regmap\n");
> +               return ret;
> +       }
> +
> +       if (reg & XTAL_MODE)
> +               rate =3D 40000000;
> +       else
> +               rate =3D 25000000;
> +
> +       of_property_read_string_index(np, "clock-output-names", 0, &xtal_=
name);
> +       xtal_hw =3D clk_hw_register_fixed_rate(NULL, xtal_name, NULL, 0, =
rate);
> +       if (IS_ERR(xtal_hw))
> +               return PTR_ERR(xtal_hw);
> +       ret =3D of_clk_add_hw_provider(np, of_clk_hw_simple_get, xtal_hw);
> +
> +       return ret;
> +}
> +
> +static int armada_3700_xtal_clock_remove(struct platform_device *pdev)
> +{
> +       of_clk_del_provider(pdev->dev.of_node);
> +
> +       return 0;
> +}
> +
> +static const struct of_device_id armada_3700_xtal_clock_of_match[] =3D {
> +       { .compatible =3D "marvell,armada-3700-xtal-clock", },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, armada_3700_xtal_clock_of_match);
> +
> +static struct platform_driver armada_3700_xtal_clock_driver =3D {
> +       .probe =3D armada_3700_xtal_clock_probe,
> +       .remove =3D armada_3700_xtal_clock_remove,
> +       .driver         =3D {
> +               .name   =3D "marvell-armada-3700-xtal-clock",
> +               .of_match_table =3D armada_3700_xtal_clock_of_match,
> +       },
> +};
> +
> +module_platform_driver(armada_3700_xtal_clock_driver);
> +
> +MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
> +MODULE_DESCRIPTION("Marvell Armada 37xx SoC xtal clocks driver");
> +MODULE_LICENSE("GPL v2");
> -- =

> 2.5.0
>=20

  reply	other threads:[~2016-07-08 17:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07 22:37 [PATCH v2 0/6] Add clock support for Armada 37xx SoCs Gregory CLEMENT
2016-07-07 22:37 ` [PATCH v2 1/6] dt-bindings: clock: add DT binding for the Xtal clock on Armada 3700 Gregory CLEMENT
2016-07-08  7:31   ` Thomas Petazzoni
2016-07-11 16:12     ` Gregory CLEMENT
2016-07-07 22:37 ` [PATCH v2 2/6] clk: mvebu: Add the xtal clock for Armada 3700 SoC Gregory CLEMENT
2016-07-08 17:32   ` Michael Turquette [this message]
2016-07-12 10:42     ` Gregory CLEMENT
2016-07-09 23:34   ` Paul Gortmaker
2016-07-12 10:43     ` Gregory CLEMENT
2016-07-07 22:37 ` [PATCH v2 3/6] dt-bindings: clock: add DT binding for the TBG clocks on Armada 3700 Gregory CLEMENT
2016-07-07 22:37 ` [PATCH v2 4/6] clk: mvebu Add the time base generator clocks for " Gregory CLEMENT
2016-07-07 22:37 ` [PATCH v2 5/6] dt-bindings: clock: add DT binding for the peripheral clocks on " Gregory CLEMENT
2016-07-07 22:37 ` [PATCH v2 6/6] clk: mvebu: Add the peripheral clock driver for " Gregory CLEMENT
2016-07-08 18:27   ` Michael Turquette
2016-07-12 16:30     ` Gregory CLEMENT
2016-07-12 17:28       ` Michael Turquette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=146799916006.73491.13586762303347604368@resonance \
    --to=mturquette@baylibre.com \
    --cc=andrew@lunn.ch \
    --cc=bjzhou@marvell.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dingwei@marvell.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=jinghua@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=omrii@marvell.com \
    --cc=robh+dt@kernel.org \
    --cc=romain.perier@free-electrons.com \
    --cc=sboyd@codeaurora.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=xigu@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).