From patchwork Thu Nov 2 03:53:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 10037919 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 1760560291 for ; Thu, 2 Nov 2017 03:54:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AC9A286BD for ; Thu, 2 Nov 2017 03:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3F4D287F0; Thu, 2 Nov 2017 03:54:48 +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=unavailable 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 A2C28286BD for ; Thu, 2 Nov 2017 03:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934350AbdKBDyV (ORCPT ); Wed, 1 Nov 2017 23:54:21 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:56114 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934073AbdKBDyT (ORCPT ); Wed, 1 Nov 2017 23:54:19 -0400 Received: by mail-pf0-f194.google.com with SMTP id 17so3581794pfn.12; Wed, 01 Nov 2017 20:54:19 -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:in-reply-to:references; bh=L5l94yF0yE1wu/5vOlDHvM2d56+uG2Acz5mZs4DlHPg=; b=SmpDG+tt6akqfMEcA87anm++M+RcRHNuNondDDWXzkzd1zctIeFmIlAzXF2/iZNqEK l0ggvtKFSijz4DHZbCp3eOlmWnWf1nPFhxI8q2aprcNFQGWFjwXRPCOPQ9I2HWj44P0M 2oW/2T3UdQND6FnAekAOb+FNJWeuvY2fI6KRtSBqdakMEqAcylvv7DnbFSE1+Cma2I4h HYUf+XjW9gbhrPeIm/iwR5FqHnoApTxty7XP2nnDHLyGDpFQ0I3t69LjPnSCxMj/lCgI rYi6l4XCJv5cSeFUJpOBhySqhH0CuMRQNe9csK5tbnQZvuNUzWJa1QIc+SEIpeHHR0KG uZBg== 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 :in-reply-to:references; bh=L5l94yF0yE1wu/5vOlDHvM2d56+uG2Acz5mZs4DlHPg=; b=LeCSbDgTIXztU1iY78H5fa6XISdtm9F4DfsWaWz5j70H/0YUQD++P+hz+GjKqGYqWc n6HN+BAOfQLKkg0DRJBp7ny7JAXKUTFJEk5U8mCWmvb94hmh/zwSBmABQPHlSPMYGcKa K9YscRvSscw58/kj4MQwh7s24wCjc2kiZ9Q5AaX/IIq+vguOwmup81oe+7LLWW2xrkBn 60guY3vby7q5sObbd7xT7kbk9a23n/yRdJX2DcEX+dxJxunJJN2noM+VqePV+9VUZLfR Bik8adY+lYENb2l6ZA5ipnD3hKmbLUeGyNbho0qEPklrNGJq2QsAqAlFpdUfrmV/zLCZ 6lUA== X-Gm-Message-State: AMCzsaU8lj09AAPp6rMDNJsOWk+VXhQAzSM9kmghIBKJeCYK2ilY5Rm3 MlfCxWeksPp841AnCdykZOQ= X-Google-Smtp-Source: ABhQp+Qpr4tqDCFHWrPrsOURzrLdXJuoLaPJrhrS0bpreEjtpZVsYNTwoigbc9SbyVbmG3CPXSpUGw== X-Received: by 10.99.110.196 with SMTP id j187mr2066487pgc.393.1509594858625; Wed, 01 Nov 2017 20:54:18 -0700 (PDT) Received: from aurora.jms.id.au ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id q13sm2867963pgt.73.2017.11.01.20.54.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Nov 2017 20:54:17 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Thu, 02 Nov 2017 14:54:10 +1100 From: Joel Stanley To: Guenter Roeck , Rob Herring Cc: Philipp Zabel , Mykola Kostenok , Jaghathiswari Rankappagounder Natarajan , Patrick Venture , Andrew Jeffery , devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] hwmon: (aspeed-pwm-tacho) Deassert reset in probe Date: Thu, 2 Nov 2017 14:53:48 +1100 Message-Id: <20171102035349.1902-3-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171102035349.1902-1-joel@jms.id.au> References: <20171102035349.1902-1-joel@jms.id.au> 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. Signed-off-by: Joel Stanley --- v2: - Correct horrible mistakes - Boot tested and hwmon sysfs files checked --- drivers/hwmon/aspeed-pwm-tacho.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index 63a95e23ca81..77bb7a4bbed4 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -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_assert(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, + .remove = aspeed_pwm_tacho_remove, .driver = { .name = "aspeed_pwm_tacho", .of_match_table = of_pwm_tacho_match_table,