From patchwork Wed Nov 1 01:34:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 117666 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp279133qgn; Tue, 31 Oct 2017 18:34:41 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SSyTm/x7N9UYkjGwqzXYtrPzm5G7py6EPZbZ74XBD+ua2ozhSuPq8XuCKyi/ut0DfffV01 X-Received: by 10.99.111.5 with SMTP id k5mr3819079pgc.364.1509500081003; Tue, 31 Oct 2017 18:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509500080; cv=none; d=google.com; s=arc-20160816; b=DLN7K1YZasMEUnu4snPJOOjj+H01Tm1p8XBMc4QRJoqCJ+R59mQT8HRhuykdAzLqwe iaeImdkdm95Ma10YIgFl6rFBQBKY4DlicdcriTFM3BwjZbbIgn/jxtgzWPKIAVVduxKF chOyaIOM+y/3IN9j0gQP4Kk162svswzMiE5ykAAbfAjV2WcroGLqMQellCvBYiucHNtx AFdlKD3JXUhSq9GtboKn8nhvQNsXtZUAJeEdY57moWxHbNx4IsLiwyThbkEDimh7jkFG RF8qBkmBWUtgKQtJBtrPvHnaMxbOK3WUUiHUx2DnXtpw60zd2U3LSC1kmUP4KDP9PiGK /RyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Yh+mwGomLFVoi+akmxrzvmFVtLgBjyP+X3NIFvQaF34=; b=vKbwEomQOb8P9EtUKIWJaf4KF0bnVGSPPtQt//k/Bui4GCW3gBY4kDgr5Z2MXHrhKX LZ6TlM7z0zIYSNrJzx8I+ngftBdMNed+MCbVDP+pkLsT3JUCJfiJzk87Mv9bOHuFAQg8 4tIO4Ggc56HBVQkAjN0MoMj3eDUrtHTXTfT8NN5JQUA+1I4S1SR9sqGMPVbfxNcf7tj+ RM27E5oWBBIQqUKHMwh2CyHzDEQRaofbQjRzDvWElThHb5CEYFKfRV9IfD0lQOwjx8Ds 957wWwoEm8XAwOEAMyfP+A88lg1Zz4X8V400QVwt9G915yOPAX/YAc6szL/DW6fiYo0U dVTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LfuLmVrT; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w28si3079677pfi.452.2017.10.31.18.34.40; Tue, 31 Oct 2017 18:34:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=LfuLmVrT; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753100AbdKABej (ORCPT + 6 others); Tue, 31 Oct 2017 21:34:39 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:48160 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbdKABeh (ORCPT ); Tue, 31 Oct 2017 21:34:37 -0400 Received: by mail-pf0-f193.google.com with SMTP id b79so699391pfk.5; Tue, 31 Oct 2017 18:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=CIMxrq66lYU9ctO06Cyq8zOOW0xhI3YyNpmrGvS2xDY=; b=LfuLmVrTmPrH6/z8ztCYer9F0lKYXrgHZnIjbvexlVVRahTXUmuMDro9WkXuB480bX 1G9wycsB4os99A60eqYHhv35A52eSfrQNt1DF0Kg2Hm6YYgt5NmPwEj43JrngzQwuNqt mR/4oEfuEwGU1Fv53zxfephMkKnWguYoBuOnQiszTo36teK6D8Z4HcUkyqh6JCmb0j9z 6fEq1zXqtc5TvZ5Prb1aDcU1f5zxjJRIVrtzoQoslP6UmKiR3nx12i3zh6izH309m57o bzG6ojojewjCEPUvEiGkc2pKsCM2GMnEpp/Iw+lg6FC7PteO8H/LfF9jYnH+Qeh3UYrp VTjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=CIMxrq66lYU9ctO06Cyq8zOOW0xhI3YyNpmrGvS2xDY=; b=WO1VKG6vcWmilVl+hsVt6hPUn6aTX/v/2RHczp1tiCnT5j3ov1LqVbtlhsM9Qka4u9 c4Vn+Rz6d1T5NNY0+OHr4qWB8Rm31H9agpuxXt0eGsHpvobn0+HkiXA1I0hEGP2yiSXV hf1mzhRc/B3AYxokK1tne6NZdtMgbIGSijoFhTXtXKHH7VaJ9oTXue0w809xuo5+1Rn+ lGE4CLyUoB2e/lNxT6vWsS893rXptSVEt1dKIllyyggWf+aiqttiFMb+tcsd2oqutH77 a4srXaMzwTEnbZZChNLI4DryqQtUkdLl7sZ4ndUW8U0BP40CFteCQgzCcheDQoAEjUvw laIA== X-Gm-Message-State: AMCzsaXaROic9NGqgwQ8RaaN7GkRc0QIF85/P+s/9TCnHC86LCwDeovs KKGZGYyIE6MOd+lxtN4OhSs= X-Received: by 10.98.57.220 with SMTP id u89mr4354627pfj.104.1509500077219; Tue, 31 Oct 2017 18:34:37 -0700 (PDT) Received: from aurora.jms.id.au (bh02i525f01.au.ibm.com. [202.81.18.30]) by smtp.gmail.com with ESMTPSA id i8sm4130611pgq.67.2017.10.31.18.34.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Oct 2017 18:34:36 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Wed, 01 Nov 2017 12:04:26 +1030 From: Joel Stanley To: Guenter Roeck , Rob Herring Cc: Philipp Zabel , Mykola Kostenok , Jaghathiswari Rankappagounder Natarajan , devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (aspeed-pwm-tacho) Deassert reset in probe Date: Wed, 1 Nov 2017 12:04:21 +1030 Message-Id: <20171101013421.8488-1-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The ASPEED SoC must deassert a reset in order to use the PWM/tach peripheral. The device tree bindings are updated to document the resets phandle, and the example is updated to match what is expected for both the reset and clock phandle. Note that the bindings should have always had the reset controller, as the hardware is unusable without it. Signed-off-by: Joel Stanley --- .../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt | 14 ++++------- drivers/hwmon/aspeed-pwm-tacho.c | 27 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt b/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt index 367c8203213b..3ac02988a1a5 100644 --- a/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt +++ b/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt @@ -22,8 +22,9 @@ Required properties for pwm-tacho node: - compatible : should be "aspeed,ast2400-pwm-tacho" for AST2400 and "aspeed,ast2500-pwm-tacho" for AST2500. -- clocks : a fixed clock providing input clock frequency(PWM - and Fan Tach clock) +- clocks : phandle to clock provider with the clock number in the second cell + +- resets : phandle to reset controller with the reset number in the second cell fan subnode format: =================== @@ -48,19 +49,14 @@ Required properties for each child node: Examples: -pwm_tacho_fixed_clk: fixedclk { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <24000000>; -}; - pwm_tacho: pwmtachocontroller@1e786000 { #address-cells = <1>; #size-cells = <1>; #cooling-cells = <2>; reg = <0x1E786000 0x1000>; compatible = "aspeed,ast2500-pwm-tacho"; - clocks = <&pwm_tacho_fixed_clk>; + clocks = <&syscon ASPEED_CLK_APB>; + resets = <&syscon ASPEED_RESET_PWM>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default>; diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index f914e5f41048..346a4c5952a3 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -7,19 +7,20 @@ */ #include +#include #include #include -#include #include #include #include #include #include -#include #include +#include #include -#include #include +#include +#include #include /* ASPEED PWM & FAN Tach Register Definition */ @@ -181,6 +182,7 @@ struct aspeed_cooling_device { struct aspeed_pwm_tacho_data { struct regmap *regmap; + struct reset_control *rst; unsigned long clk_freq; bool pwm_present[8]; bool fan_tach_present[16]; @@ -931,6 +933,15 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) &aspeed_pwm_tacho_regmap_config); if (IS_ERR(priv->regmap)) return PTR_ERR(priv->regmap); + + priv->rst = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(priv->rst)) { + dev_err(dev, + "missing or invalid reset controller device tree entry"); + return PTR_ERR(priv->rst); + } + reset_control_deassert(priv->rst); + regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE, 0); regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE_EXT, 0); @@ -960,6 +971,15 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) return PTR_ERR_OR_ZERO(hwmon); } +static int aspeed_pwm_tacho_remove(struct platform_device *pdev) +{ + struct aspeed_pwm_tacho_data *priv = platform_get_drvdata(pdev); + + reset_control_deassert(priv->rst); + + return 0; +} + static const struct of_device_id of_pwm_tacho_match_table[] = { { .compatible = "aspeed,ast2400-pwm-tacho", }, { .compatible = "aspeed,ast2500-pwm-tacho", }, @@ -969,6 +989,7 @@ MODULE_DEVICE_TABLE(of, of_pwm_tacho_match_table); static struct platform_driver aspeed_pwm_tacho_driver = { .probe = aspeed_pwm_tacho_probe, + .probe = aspeed_pwm_tacho_remove, .driver = { .name = "aspeed_pwm_tacho", .of_match_table = of_pwm_tacho_match_table,