From patchwork Wed Feb 19 06:24:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 24929 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EAFAD20468 for ; Wed, 19 Feb 2014 06:30:40 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf67853479obc.7 for ; Tue, 18 Feb 2014 22:30:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=kM4sSSFTg5tBe6y9GN+QUM/Leb9YMF+uLtoV3JGwk1g=; b=mej1FkFTJiB0nnnchr9nrcfkG+PQH5ko8jv7bxV2tHFhpie6TbfFb5LgO5U5DC+0Dy +CcVkiifbcq7H8pG662j1/VXrlvcO4ZpUoUcAnxccPm5XGvtYfHw33mH4HmcJroADX5T oEazWO18sBQUMNhqnkM/aib7l9+yJ7KPYbi/+/9HHMHYvBffVQrN0WWmkG6dxKEpTlJp Y84Au0P6arxeEbJBtIoQOk87g9WPVsMqJlOiytxeJGleJIptsRo48XK9WUWvDWfQx0Ob E054KOKXSzvONvRvwFc0IMmIRpOlyFA7JuJAti7PaPUzeeCSXFAFsVuBB5nqPAlcM3+f d52Q== X-Gm-Message-State: ALoCoQkVxuJPufzTcDuSakUjIw7YvRA3bxyfgdCBUP7ysz7g7ref5jnu0tm0Zw1kjokgFLY63tOm X-Received: by 10.42.82.137 with SMTP id d9mr13405659icl.25.1392791440330; Tue, 18 Feb 2014 22:30:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.71 with SMTP id d65ls1551921qgf.60.gmail; Tue, 18 Feb 2014 22:30:40 -0800 (PST) X-Received: by 10.52.247.231 with SMTP id yh7mr10159754vdc.34.1392791440227; Tue, 18 Feb 2014 22:30:40 -0800 (PST) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id tt2si6394337vdc.152.2014.02.18.22.30.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 22:30:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id ie18so13772702vcb.26 for ; Tue, 18 Feb 2014 22:30:40 -0800 (PST) X-Received: by 10.220.192.71 with SMTP id dp7mr692458vcb.45.1392791440115; Tue, 18 Feb 2014 22:30:40 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp274239vcz; Tue, 18 Feb 2014 22:30:39 -0800 (PST) X-Received: by 10.68.159.228 with SMTP id xf4mr206481pbb.74.1392791439190; Tue, 18 Feb 2014 22:30:39 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pk8si20700512pab.271.2014.02.18.22.30.38; Tue, 18 Feb 2014 22:30:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751932AbaBSGaU (ORCPT + 27 others); Wed, 19 Feb 2014 01:30:20 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:54546 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340AbaBSGaM (ORCPT ); Wed, 19 Feb 2014 01:30:12 -0500 Received: by mail-pa0-f48.google.com with SMTP id kx10so17792479pab.35 for ; Tue, 18 Feb 2014 22:30:11 -0800 (PST) X-Received: by 10.66.26.10 with SMTP id h10mr37391769pag.24.1392791411587; Tue, 18 Feb 2014 22:30:11 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id yd4sm62135719pbc.13.2014.02.18.22.30.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 22:30:10 -0800 (PST) From: Tushar Behera To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: mturquette@linaro.org Subject: [PATCH V2 1/2] clk: clk-s2mps11: Refactor for including support for other MFD clocks Date: Wed, 19 Feb 2014 11:54:35 +0530 Message-Id: <1392791076-28301-2-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392791076-28301-1-git-send-email-tushar.behera@linaro.org> References: <1392791076-28301-1-git-send-email-tushar.behera@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tushar.behera@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The clocks in S2MPS11 and S5M8767 are managed in the same way, baring a difference in the register offset. It would be better to update existing S2MPS11 driver to support the clocks in S5M8767, rather than to create an almost duplicate driver altogether. Signed-off-by: Tushar Behera Reviewed-by: Tomasz Figa Reviewed-by: Yadwinder Singh Brar --- Changes since V1: * Fixed a check patch warning drivers/clk/clk-s2mps11.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c index 00a3abe..6f587bc 100644 --- a/drivers/clk/clk-s2mps11.c +++ b/drivers/clk/clk-s2mps11.c @@ -48,6 +48,7 @@ struct s2mps11_clk { struct clk_lookup *lookup; u32 mask; bool enabled; + unsigned int reg; }; static struct s2mps11_clk *to_s2mps11_clk(struct clk_hw *hw) @@ -61,7 +62,7 @@ static int s2mps11_clk_prepare(struct clk_hw *hw) int ret; ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, - S2MPS11_REG_RTC_CTRL, + s2mps11->reg, s2mps11->mask, s2mps11->mask); if (!ret) s2mps11->enabled = true; @@ -74,7 +75,7 @@ static void s2mps11_clk_unprepare(struct clk_hw *hw) struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); int ret; - ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, S2MPS11_REG_RTC_CTRL, + ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, s2mps11->reg, s2mps11->mask, ~s2mps11->mask); if (!ret) @@ -155,6 +156,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev) struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct s2mps11_clk *s2mps11_clks, *s2mps11_clk; struct device_node *clk_np = NULL; + unsigned int s2mps11_reg; int i, ret = 0; u32 val; @@ -169,13 +171,23 @@ static int s2mps11_clk_probe(struct platform_device *pdev) if (IS_ERR(clk_np)) return PTR_ERR(clk_np); + switch (platform_get_device_id(pdev)->driver_data) { + case S2MPS11X: + s2mps11_reg = S2MPS11_REG_RTC_CTRL; + break; + default: + dev_err(&pdev->dev, "Invalid device type\n"); + return -EINVAL; + }; + for (i = 0; i < S2MPS11_CLKS_NUM; i++, s2mps11_clk++) { s2mps11_clk->iodev = iodev; s2mps11_clk->hw.init = &s2mps11_clks_init[i]; s2mps11_clk->mask = 1 << i; + s2mps11_clk->reg = s2mps11_reg; ret = regmap_read(s2mps11_clk->iodev->regmap_pmic, - S2MPS11_REG_RTC_CTRL, &val); + s2mps11_clk->reg, &val); if (ret < 0) goto err_reg; @@ -241,7 +253,7 @@ static int s2mps11_clk_remove(struct platform_device *pdev) } static const struct platform_device_id s2mps11_clk_id[] = { - { "s2mps11-clk", 0}, + { "s2mps11-clk", S2MPS11X}, { }, }; MODULE_DEVICE_TABLE(platform, s2mps11_clk_id);