From patchwork Wed Mar 2 15:32:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 63398 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2449416lbc; Wed, 2 Mar 2016 07:37:00 -0800 (PST) X-Received: by 10.98.74.74 with SMTP id x71mr31458760pfa.135.1456933020591; Wed, 02 Mar 2016 07:37:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hg4si19702067pac.180.2016.03.02.07.37.00; Wed, 02 Mar 2016 07:37:00 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755548AbcCBPg6 (ORCPT + 30 others); Wed, 2 Mar 2016 10:36:58 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38182 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754841AbcCBPeV (ORCPT ); Wed, 2 Mar 2016 10:34:21 -0500 Received: by mail-wm0-f54.google.com with SMTP id l68so83169897wml.1 for ; Wed, 02 Mar 2016 07:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dfJ5O1EWMmkk/0IClp3sm1K3vmJ2ewvlctyjJolSDvo=; b=T+nB+PvegPniRnjHMjfFdhCkDYtM6eTraGlKZBw9yVY69p/x7wGtKDglYI7+LH/3c2 lKhglX998pe89tmcHbtIuu41CJX+uoVU0aYywiqc16Ba6OfIiUaitKYBBwtJUj9DglGj pPzVDcuJhFy2uBFnTdbMmTwA6zcRcnAHGkGR4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dfJ5O1EWMmkk/0IClp3sm1K3vmJ2ewvlctyjJolSDvo=; b=SlSGBSS9J0atuerBGoyV1CoJgmWbDr8fpx92MMwaxlBrm8bzSbv9fXBTUCEZmbdBXw CIxCPA1yJ3lVhAlQkMopAfOe0I3C8KTHqnwWHzO5b0g7zf8cCo6M3J5M5I9OK3u3MR2p V9gHWePJ+74RkH2pXm4NUBnMxmtTYVvr52MbaOmieMlyXMffclQIx8dH6tyhUkgpcG+E xM2e4SmcS3Q0tU+t6rYMEjfCGcR3zGqqM58sZE/sD7XkZS5kEBSe04zlyVb7PEveXANm xJ1YtcjmwUu/YekORvbZN5ZI5jXPNNw0RHQsmmOSSLvcBSvCMU3vfCZaoVLNyPkI+sbQ vqEA== X-Gm-Message-State: AD7BkJJETOmipKxHwxFlJ//pPhMMQP/1Snfz92loy386/xkQWGtkyglT9RWwIWaIbFaZ0SWV X-Received: by 10.194.200.225 with SMTP id jv1mr27353274wjc.49.1456932860282; Wed, 02 Mar 2016 07:34:20 -0800 (PST) Received: from localhost.localdomain (host81-154-142-245.range81-154.btcentralplus.com. [81.154.142.245]) by smtp.gmail.com with ESMTPSA id da6sm26941407wjb.24.2016.03.02.07.34.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 07:34:19 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, maxime.coquelin@st.com, thierry.reding@gmail.com, linux-pwm@vger.kernel.org, ajitpal.singh@st.com, Lee Jones Subject: [RESEND 06/11] pwm: sti: Supply PWM Capture clock handling Date: Wed, 2 Mar 2016 15:32:04 +0000 Message-Id: <1456932729-9667-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456932729-9667-1-git-send-email-lee.jones@linaro.org> References: <1456932729-9667-1-git-send-email-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ST's PWM IP is supplied by 2 different clocks. One for PWM Output and the other for Capture. This patch provides clock handling for the latter. Signed-off-by: Lee Jones --- drivers/pwm/pwm-sti.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 1.9.1 diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index 2336bac..9e6b1c8 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -74,6 +74,7 @@ struct sti_pwm_compat_data { struct sti_pwm_chip { struct device *dev; struct clk *pwm_clk; + struct clk *cpt_clk; struct regmap *regmap; struct sti_pwm_compat_data *cdata; struct regmap_field *prescale_low; @@ -183,6 +184,10 @@ static int sti_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, if (ret) return ret; + ret = clk_enable(pc->cpt_clk); + if (ret) + return ret; + if (!period_same) { ret = sti_pwm_get_prescale(pc, period_ns, &prescale); if (ret) @@ -227,6 +232,7 @@ static int sti_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, clk_dis: clk_disable(pc->pwm_clk); + clk_disable(pc->cpt_clk); return ret; } @@ -246,6 +252,10 @@ static int sti_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) if (ret) goto out; + ret = clk_enable(pc->cpt_clk); + if (ret) + goto out; + ret = regmap_field_write(pc->pwm_out_en, 1); if (ret) { dev_err(dev, "failed to enable PWM device:%d\n", @@ -271,6 +281,7 @@ static void sti_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) regmap_field_write(pc->pwm_out_en, 0); clk_disable(pc->pwm_clk); + clk_disable(pc->cpt_clk); mutex_unlock(&pc->sti_pwm_lock); } @@ -390,6 +401,18 @@ static int sti_pwm_probe(struct platform_device *pdev) return ret; } + pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture"); + if (IS_ERR(pc->cpt_clk)) { + dev_err(dev, "failed to get PWM capture clock\n"); + return PTR_ERR(pc->cpt_clk); + } + + ret = clk_prepare(pc->cpt_clk); + if (ret) { + dev_err(dev, "failed to prepare clock\n"); + return ret; + } + pc->chip.dev = dev; pc->chip.ops = &sti_pwm_ops; pc->chip.base = -1; @@ -399,6 +422,7 @@ static int sti_pwm_probe(struct platform_device *pdev) ret = pwmchip_add(&pc->chip); if (ret < 0) { clk_unprepare(pc->pwm_clk); + clk_unprepare(pc->cpt_clk); return ret; } @@ -416,6 +440,7 @@ static int sti_pwm_remove(struct platform_device *pdev) pwm_disable(&pc->chip.pwms[i]); clk_unprepare(pc->pwm_clk); + clk_unprepare(pc->cpt_clk); return pwmchip_remove(&pc->chip); }