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: 10035817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 31AF7603B5 for ; Wed, 1 Nov 2017 01:34:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B59E268AE for ; Wed, 1 Nov 2017 01:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DA45281E1; Wed, 1 Nov 2017 01:34:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4B7427F60 for ; Wed, 1 Nov 2017 01:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752319AbdKABej (ORCPT ); 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-Google-Smtp-Source: ABhQp+QMhjEHFw74j6B5/VewEWOHvnuqa8FMWnXRM0tu178rGvCmYBv1UfToPD7M/IHz+3R+aqtDRA== 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: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,