From patchwork Tue Aug 16 09:35:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 73969 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1896506qga; Tue, 16 Aug 2016 02:36:57 -0700 (PDT) X-Received: by 10.66.43.7 with SMTP id s7mr63114356pal.27.1471340217620; Tue, 16 Aug 2016 02:36:57 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pe4si31374525pac.256.2016.08.16.02.36.57; Tue, 16 Aug 2016 02:36:57 -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 S1753743AbcHPJgo (ORCPT + 27 others); Tue, 16 Aug 2016 05:36:44 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:34258 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257AbcHPJfy (ORCPT ); Tue, 16 Aug 2016 05:35:54 -0400 Received: by mail-wm0-f49.google.com with SMTP id q128so27441044wma.1 for ; Tue, 16 Aug 2016 02:35:53 -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=esO6qS+dkYWesLBuwCIXynnm9aBzrA5rw24e0nQWIDk=; b=aJKDrwRK6urnJKJFkfehF4K/U3NE3T2uARgdQ4WvrCcJ+S2ugfOM+rPYj3mUDXOh8f R8ISqQR+KqS1nc3CW1vFjNCLqYVpKriJLkszr1lZCfMI76ga3uLy41w0bO74BKe1B4+s xcLvbEzvRZU5Jm0HH9xiWfh5bv47JRKrdL0es= 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=esO6qS+dkYWesLBuwCIXynnm9aBzrA5rw24e0nQWIDk=; b=dAGSJUfXVnZlY2hboSlyeSVyCyGWc7Zr4Yc4UCZgWQyRKLQ07MxDczBbMa20eDDHrI KqBU4pwR+UOT7+RKQeFg9UpiG5BSHIAehPIG5a0OChk+ODvDJhnO/iZNhOyIzyTFIlAh XrH5+RVAznpwPfnmxd81+cIJcAIu0whcM6VXlIJyKAjH4rWf4orytUrUMkyivkOxY2xs SHHvb/HhVU32Wrv4F2QrXopqtGFCYZEpOmkM7mltwV9T8fUULR8CPtDn1ffCJ8bp+iiR vOV8lpnQK3zw9yBuCtcTfAtBhFBjqgwxpJiSf9DPVso+FqGnyNuFoMO9uErHFfeFfjEJ gX2Q== X-Gm-Message-State: AEkooutBHOORE/1U6YK7glzW0BILxTmL5hz5tg3TCpPZcWFM8loKD7OaDVQFiXIPcX0IhCnf X-Received: by 10.28.40.133 with SMTP id o127mr21661964wmo.46.1471340152953; Tue, 16 Aug 2016 02:35:52 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 02:35:52 -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 15/17] pwm: sti: It's now valid for number of PWM channels to be zero Date: Tue, 16 Aug 2016 10:35:06 +0100 Message-Id: <20160816093508.28307-16-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 Setting up the STI PWM IP as capture only, with zero PWM-out devices is a perfectly valued configuration. It is no longer okay to assume that there must be at least 1 PWM-out devices. In this patch we make the default number of PWM-out devices zero and only configure channels explicitly requested. Reported-by: Peter Griffin Signed-off-by: Lee Jones --- drivers/pwm/pwm-sti.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index fcc80eb..a1319c0 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -483,6 +483,11 @@ static int sti_pwm_probe_dt(struct sti_pwm_chip *pc) if (!ret) cdata->cpt_num_devs = num_devs; + if (cdata->pwm_num_devs && !cdata->cpt_num_devs) { + dev_err(dev, "No channels configured\n"); + return -EINVAL; + } + reg_fields = cdata->reg_fields; pc->prescale_low = devm_regmap_field_alloc(dev, pc->regmap, @@ -573,7 +578,7 @@ static int sti_pwm_probe(struct platform_device *pdev) cdata->reg_fields = &sti_pwm_regfields[0]; cdata->max_prescale = 0xff; cdata->max_pwm_cnt = 255; - cdata->pwm_num_devs = 1; + cdata->pwm_num_devs = 0; cdata->cpt_num_devs = 0; pc->cdata = cdata; @@ -585,6 +590,9 @@ static int sti_pwm_probe(struct platform_device *pdev) if (ret) return ret; + if (!cdata->pwm_num_devs) + goto skip_pwm; + pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm"); if (IS_ERR(pc->pwm_clk)) { dev_err(dev, "failed to get PWM clock\n"); @@ -597,6 +605,10 @@ static int sti_pwm_probe(struct platform_device *pdev) return ret; } +skip_pwm: + if (!cdata->cpt_num_devs) + goto skip_cpt; + 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"); @@ -609,6 +621,7 @@ static int sti_pwm_probe(struct platform_device *pdev) return ret; } +skip_cpt: pc->chip.dev = dev; pc->chip.ops = &sti_pwm_ops; pc->chip.base = -1;