From patchwork Thu Dec 12 16:07:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3332951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D84E0C0D4A for ; Thu, 12 Dec 2013 16:11:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 323F8207CC for ; Thu, 12 Dec 2013 16:11:47 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E193207CB for ; Thu, 12 Dec 2013 16:11:41 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vr8pb-00024j-3W; Thu, 12 Dec 2013 16:09:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vr8oz-0001CQ-0n; Thu, 12 Dec 2013 16:09:05 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vr8o9-00015z-8W for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2013 16:08:15 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MXP00ACXBGYBF60@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2013 16:07:46 +0000 (GMT) X-AuditID: cbfec7f4-b7f966d0000003d9-4f-52a9df522afd Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 5B.EC.00985.25FD9A25; Thu, 12 Dec 2013 16:07:46 +0000 (GMT) Received: from amdc1227.digital.local ([106.116.147.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0MXP00BIHBGQS260@eusync3.samsung.com>; Thu, 12 Dec 2013 16:07:46 +0000 (GMT) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 7/8] clk: max77686: Register OF clock provider Date: Thu, 12 Dec 2013 17:07:20 +0100 Message-id: <1386864441-19561-8-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.8.4.3 In-reply-to: <1386864441-19561-1-git-send-email-t.figa@samsung.com> References: <1386864441-19561-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDJMWRmVeSWpSXmKPExsVy+t/xq7pB91cGGTT/kraYf+Qcq8XZpjfs Fve/HmW02PT4GqvFjPP7mCyeTrjIZnHyTy+jxeluVov1M16zOHB63Lm2h81j3slAj81L6j36 tqxi9Pi8SS6ANYrLJiU1J7MstUjfLoErY9PCY6wF6+QrPm+9xd7A+Fyyi5GTQ0LARGLawTWM ELaYxIV769m6GLk4hASWMkqs/f6HCcLpY5K48uAcE0gVm4CaxOeGR2wgtoiAhsSUrsfsIEXM AmuYJHo3T2XtYuTgEBZwlOh57ABisgioSuy4mwJSzivgJHFr5Vx2iGUKEp1r/oMt5hRwlrhx eDaYLQRUs23xJPYJjLwLGBlWMYqmliYXFCel5xrqFSfmFpfmpesl5+duYoSE2JcdjIuPWR1i FOBgVOLhfXFwRZAQa2JZcWXuIUYJDmYlEd57W1YGCfGmJFZWpRblxxeV5qQWH2Jk4uCUamAU NCtK+H1FepEe53PNtX92stmvbd1gn5vtYNqQKbrCTmaX0LFgfis7Lb4LWeu4NHe+/OXof8bA v2RHEq89o9dydo29WX/Wbjp3hD1O0XGKb+P+dcfe/uKRbpfiX++8s2bRorxc39N3i/X13j9n nR3QvGpNr/1lY+7XnhevhB/Ynyp648eDtllKLMUZiYZazEXFiQDSBwmxDwIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131212_110813_547286_F37B7633 X-CRM114-Status: GOOD ( 12.40 ) X-Spam-Score: -6.9 (------) Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Mike Turquette , Samuel Ortiz , Sachin Kamat , Tomasz Figa , Kyungmin Park , Lee Jones X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If max77686 chip is instantiated from device tree, it is desirable to have an OF clock provider to allow device tree based look-up of clocks. This patch adds OF clock provider registration to the clk-max77686 driver. Signed-off-by: Tomasz Figa Acked-by: Kyungmin Park --- .../devicetree/bindings/clock/maxim,max77686.txt | 38 ++++++++++++++++++++++ Documentation/devicetree/bindings/mfd/max77686.txt | 3 ++ drivers/clk/clk-max77686.c | 24 ++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/maxim,max77686.txt diff --git a/Documentation/devicetree/bindings/clock/maxim,max77686.txt b/Documentation/devicetree/bindings/clock/maxim,max77686.txt new file mode 100644 index 0000000..96ce71b --- /dev/null +++ b/Documentation/devicetree/bindings/clock/maxim,max77686.txt @@ -0,0 +1,38 @@ +Binding for Maxim MAX77686 32k clock generator block + +This is a part of device tree bindings of MAX77686 multi-function device. +More information can be found in bindings/mfd/max77686.txt file. + +The MAX77686 contains three 32.768khz clock outputs that can be controlled +(gated/ungated) over I2C. + +Following properties should be presend in main device node of the MFD chip. + +Required properties: +- #clock-cells: simple one-cell clock specifier format is used, where the + only cell is used as an index of the clock inside the provider. Following + indices are allowed: + - 0: 32khz_ap clock, + - 1: 32khz_cp clock, + - 2: 32khz_pmic clock. + +Example: Node of the MFD chip + + max77686: max77686@09 { + compatible = "maxim,max77686"; + interrupt-parent = <&wakeup_eint>; + interrupts = <26 0>; + reg = <0x09>; + #clock-cells = <1>; + + /* ... */ + }; + +Example: Clock consumer node + + foo@0 { + compatible = "bar,foo"; + /* ... */ + clock-names = "my-clock"; + clocks = <&max77686 2>; + }; diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt b/Documentation/devicetree/bindings/mfd/max77686.txt index c6a3469..678f3cf 100644 --- a/Documentation/devicetree/bindings/mfd/max77686.txt +++ b/Documentation/devicetree/bindings/mfd/max77686.txt @@ -7,6 +7,9 @@ different i2c slave address,presently for which we are statically creating i2c client while probing.This document describes the binding for mfd device and PMIC submodule. +Binding for the built-in 32k clock generator block is defined separately +in bindings/clk/maxim,max77686.txt file. + Required properties: - compatible : Must be "maxim,max77686"; - reg : Specifies the i2c slave address of PMIC block. diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 3cf38dc..3d7e8dd 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -169,6 +169,26 @@ static int max77686_clk_probe(struct platform_device *pdev) platform_set_drvdata(pdev, clocks); + if (iodev->dev->of_node) { + struct clk_onecell_data *of_data; + + of_data = devm_kzalloc(&pdev->dev, + sizeof(*of_data), GFP_KERNEL); + if (!of_data) { + ret = -ENOMEM; + goto err_clocks; + } + + of_data->clks = clocks; + of_data->clk_num = MAX77686_CLKS_NUM; + ret = of_clk_add_provider(iodev->dev->of_node, + of_clk_src_onecell_get, of_data); + if (ret) { + dev_err(&pdev->dev, "failed to register OF clock provider\n"); + goto err_clocks; + } + } + return 0; err_clocks: @@ -182,9 +202,13 @@ err_clocks: static int max77686_clk_remove(struct platform_device *pdev) { + struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct clk **clocks = platform_get_drvdata(pdev); int i; + if (iodev->dev->of_node) + of_clk_del_provider(iodev->dev->of_node); + for (i = 0; i < MAX77686_CLKS_NUM; i++) { struct clk_hw *hw = __clk_get_hw(clocks[i]); struct max77686_clk *max77686 = to_max77686_clk(hw);