From patchwork Tue Aug 16 09:35:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 73977 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1897102qga; Tue, 16 Aug 2016 02:38:19 -0700 (PDT) X-Received: by 10.66.221.229 with SMTP id qh5mr62101699pac.66.1471340293810; Tue, 16 Aug 2016 02:38:13 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si31413413pao.78.2016.08.16.02.38.13; Tue, 16 Aug 2016 02:38:13 -0700 (PDT) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859AbcHPJhx (ORCPT + 27 others); Tue, 16 Aug 2016 05:37:53 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:37483 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753562AbcHPJfu (ORCPT ); Tue, 16 Aug 2016 05:35:50 -0400 Received: by mail-wm0-f44.google.com with SMTP id i5so154555694wmg.0 for ; Tue, 16 Aug 2016 02:35:50 -0700 (PDT) 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=m7NeSU5Zyhx1DCzdb1vcvMkOxQIY2+CzLN7Yt3qGKTg=; b=FuQo3zpNM77x+pxJx1KoS9V5w8M40nXWchb/OvmD1iEon4ZUs9QI3vZjltT9fn+bbG 9/EDNCppbMcj1SLd9TEB/dHHB2SwBFgvuJwoYb0maHFyWRB23EdGMT5fyGVFm8ZbylW2 o3sXTcr+lCT9r7VdkFDgo2et6KbfSdMdQAZTA= 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=m7NeSU5Zyhx1DCzdb1vcvMkOxQIY2+CzLN7Yt3qGKTg=; b=ZFpqHY/1M11IoHvT9VdeXvOSwCasLj1+09Eb973U3sL9wA0OBuf1GwWjZFhG4UCLtS 6QVO2OM+Jk2O/nTwwrfTTffL7uRGUo18GPdqVVPZD2ZSq9qYRTJlmklKUnsRQ/uYIUug aQs5xix5tquX8ULpUdfZxRHbBP40pjAZVR9ZYQJ9BvfSkCGAs930ubeTiq/+3PZNPojy 7gZloxEd0hMphzgIBoWTzG4oMge8cyKOPOFLJhOFY4uhNz6KWRDWe+hBWrzULLEl4vKl Cg1axIrTtgHL/VRY10SkMN+55KNnriAK1cdKuQit3GG5Whk9hIWt5L+MOUhggHh4PMbV Kirg== X-Gm-Message-State: AEkoouvtVOAJPhlNa04LCSdqjIUxJN0ilIaq8JSNtnUnDoU4sMOTKv0O7d6sOel3FU4xY0CI X-Received: by 10.194.38.166 with SMTP id h6mr36747836wjk.101.1471340149296; Tue, 16 Aug 2016 02:35:49 -0700 (PDT) Received: from localhost.localdomain (host81-129-169-93.range81-129.btcentralplus.com. [81.129.169.93]) by smtp.gmail.com with ESMTPSA id g1sm16614889wjy.5.2016.08.16.02.35.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 02:35:48 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: kernel@stlinux.com, patrice.chotard@st.com, thierry.reding@gmail.com, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH v4 11/17] pwm: sti: Supply PWM Capture clock handling Date: Tue, 16 Aug 2016 10:35:02 +0100 Message-Id: <20160816093508.28307-12-lee.jones@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160816093508.28307-1-lee.jones@linaro.org> References: <20160816093508.28307-1-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(+) -- 2.9.0 diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index f2090c0..b596783 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); }