mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>,
	Krystian Garbaciak <krystian.garbaciak@diasemi.com>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH v3 6/6] mfd: da9063: add 32 kHz output clock to clock tree
Date: Mon, 29 Jul 2013 19:00:47 +0200	[thread overview]
Message-ID: <1375117247-6376-7-git-send-email-p.zabel@pengutronix.de> (raw)
In-Reply-To: <1375117247-6376-1-git-send-email-p.zabel@pengutronix.de>

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/mfd/da9063-core.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index c9cf8d9..adcdc50 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -14,6 +14,7 @@
  *
  */
 
+#include <linux/clk-provider.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -107,10 +108,68 @@ static struct mfd_cell da9063_devs[] = {
 	},
 };
 
+struct da9063_out_32k_clk {
+	struct clk_hw clk_hw;
+	struct regmap *regmap;
+};
+
+static int da9063_out_32k_prepare(struct clk_hw *hw)
+{
+	struct da9063_out_32k_clk *out_32k =
+			container_of(hw, struct da9063_out_32k_clk, clk_hw);
+
+	return regmap_update_bits(out_32k->regmap, DA9063_REG_EN_32K,
+				  DA9063_OUT_32K_EN, DA9063_OUT_32K_EN);
+}
+
+static void da9063_out_32k_unprepare(struct clk_hw *hw)
+{
+	struct da9063_out_32k_clk *out_32k =
+			container_of(hw, struct da9063_out_32k_clk, clk_hw);
+
+	regmap_update_bits(out_32k->regmap, DA9063_REG_EN_32K,
+			   DA9063_OUT_32K_EN, 0);
+}
+
+static int da9063_out_32k_is_prepared(struct clk_hw *hw)
+{
+	struct da9063_out_32k_clk *out_32k =
+			container_of(hw, struct da9063_out_32k_clk, clk_hw);
+	int val;
+
+	regmap_read(out_32k->regmap, DA9063_REG_EN_32K, &val);
+
+	return val & DA9063_OUT_32K_EN;
+}
+
+static unsigned long da9063_out_32k_recalc_rate(struct clk_hw *hw,
+						unsigned long parent_rate)
+{
+	return 32000;
+}
+
+static long da9063_out_32k_round_rate(struct clk_hw *hw,
+				      unsigned long rate,
+				      unsigned long *prate)
+{
+	return 32000;
+}
+
+static const struct clk_ops da9063_out_32k_ops = {
+	.prepare = da9063_out_32k_prepare,
+	.unprepare = da9063_out_32k_unprepare,
+	.is_prepared = da9063_out_32k_is_prepared,
+	.recalc_rate = da9063_out_32k_recalc_rate,
+	.round_rate = da9063_out_32k_round_rate,
+};
+
 int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 {
 	struct da9063_pdata *pdata = da9063->dev->platform_data;
+	struct da9063_out_32k_clk *out_32k;
+	struct clk_init_data init;
 	int model, revision;
+	struct clk *clk;
 	int ret;
 
 	if (pdata) {
@@ -165,6 +224,23 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 		return ret;
 	}
 
+	out_32k = devm_kzalloc(da9063->dev, sizeof(*out_32k), GFP_KERNEL);
+	if (!out_32k)
+		return -ENOMEM;
+
+	init.name = "da9063_out_32k";
+	init.ops = &da9063_out_32k_ops;
+	init.flags = CLK_IS_BASIC | CLK_IS_ROOT;
+	init.parent_names = NULL;
+	init.num_parents = 0;
+
+	out_32k->clk_hw.init = &init;
+	out_32k->regmap = da9063->regmap;
+
+	clk = devm_clk_register(da9063->dev, &out_32k->clk_hw);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
 	ret = mfd_add_devices(da9063->dev, -1, da9063_devs,
 			      ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base,
 			      NULL);
-- 
1.8.3.2


  parent reply	other threads:[~2013-07-29 17:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 17:00 [PATCH v3 0/6] Add Dialog DA9063 core and regulator drivers Philipp Zabel
2013-07-29 17:00 ` [PATCH v3 1/6] mfd: da9063: Add register definitions for DA9063 driver Philipp Zabel
2013-07-29 17:00 ` [PATCH v3 2/6] mfd: da9063: Add Dialog DA9063 core driver Philipp Zabel
2013-07-29 17:00 ` [PATCH v3 3/6] mfd: da9063: Add IRQ support Philipp Zabel
2013-07-29 17:00 ` [PATCH v3 4/6] regulator: da9063: Add Dialog DA9063 voltage regulators support Philipp Zabel
2013-08-29 18:35   ` Mark Brown
2013-07-29 17:00 ` [PATCH v3 5/6] Documentation: Add device tree bindings for DA9063 PMIC Philipp Zabel
2013-07-29 17:00 ` Philipp Zabel [this message]
2013-07-29 18:15   ` [PATCH v3 6/6] mfd: da9063: add 32 kHz output clock to clock tree Mark Brown
2013-08-02 11:50     ` Philipp Zabel
2013-08-20  1:18 ` [PATCH v3 0/6] Add Dialog DA9063 core and regulator drivers Samuel Ortiz

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=1375117247-6376-7-git-send-email-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=broonie@kernel.org \
    --cc=krystian.garbaciak@diasemi.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.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

all inboxes | Powered by JetHome®