Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1428821ybl; Sun, 19 Jan 2020 03:03:56 -0800 (PST) X-Google-Smtp-Source: APXvYqw0WDAvQ4BDSfczdXe5kpZNg5HxOytmll5sYIi8cCzEpulRxEwskybCXGu7y+D64jEFqx9V X-Received: by 2002:aca:b808:: with SMTP id i8mr9412445oif.66.1579431835938; Sun, 19 Jan 2020 03:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579431835; cv=none; d=google.com; s=arc-20160816; b=Tl3g2ZBOlDoTLfk7w/67acjNtBkKfed0YByQQrXQgKv0cdIhiR+kBr4/XdaYSNMOI7 kJMPz63kOpJLJzy1AvcjJHZgyNkJORXTymtR6EG9amyioUjtcTaSFrDLaAzDquUJe/c7 PBXWYdK7bzwikH6JVo+zEv4ZKwGORhjWh5o3z6+76UJqOXHc0Pv4dOPJSPSUtdMfKOl8 VzFdTzVkXVHXnTJ41qCO/eVSXTyhOcA/TRiP2cwZsSxeRCck3puuV8jRooXj6XEt/RKz jSjoDccNlkTvOfAQe7MNyxlZV655W2OC0e19mQwbYuLz9PRZvrInL+JNgdm2zhb+uaLz obvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NaoUgR6N8k9Ku/W31jsGDAikgNH5XPbbXcgbaXhSLTE=; b=fa0KGxt1fOOabSJ3IDuT95jcHI15QtuidtZyxOyp5+dHh2+1HdzJBjRlUPCMjJ+5/N wYqzc4bai+4PvexiFVHmD/KpE8DBxV6VWNpQ0Vg2IDTW6gfOHvsr/2t8cYNrgvxlcpXg p3MrdbppmLtOPnrutp0QxvybSJ2uBobGsK+vErNVc0b+5aTOpsy95z2DYxLIrNnmtM7r SeNqmK6+LguA1zghyqEQWkAGteitKYFgCxfU6dYaOKgba3V9XP+sHihBhOCDzzr6k4ar f9Fw3VIpHWPN5alraBVDYyn0og4whrUzDy9QTJvfxfGICGZQ275fP0hLrO2Wral1ajcX RS8w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l204si4512124oif.261.2020.01.19.03.03.32; Sun, 19 Jan 2020 03:03:55 -0800 (PST) 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; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbgASLBr (ORCPT + 99 others); Sun, 19 Jan 2020 06:01:47 -0500 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:39088 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726744AbgASLBq (ORCPT ); Sun, 19 Jan 2020 06:01:46 -0500 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 00JB0bDq001026; Sun, 19 Jan 2020 13:00:37 +0200 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id E2DBD6032E; Sun, 19 Jan 2020 13:00:37 +0200 (IST) From: Tomer Maimon To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, avifishman70@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, joel@jms.id.au Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Tomer Maimon Subject: [PATCH v1 2/2] iio: adc: modify NPCM reset support Date: Sun, 19 Jan 2020 13:00:32 +0200 Message-Id: <20200119110032.124745-2-tmaimon77@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200119110032.124745-1-tmaimon77@gmail.com> References: <20200119110032.124745-1-tmaimon77@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Modify NPCM ADC reset support from direct register access to reset controller support. Signed-off-by: Tomer Maimon --- drivers/iio/adc/npcm_adc.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c index a6170a37ebe8..83bad2d5575d 100644 --- a/drivers/iio/adc/npcm_adc.c +++ b/drivers/iio/adc/npcm_adc.c @@ -14,6 +14,7 @@ #include #include #include +#include struct npcm_adc { bool int_status; @@ -23,13 +24,9 @@ struct npcm_adc { struct clk *adc_clk; wait_queue_head_t wq; struct regulator *vref; - struct regmap *rst_regmap; + struct reset_control *reset; }; -/* NPCM7xx reset module */ -#define NPCM7XX_IPSRST1_OFFSET 0x020 -#define NPCM7XX_IPSRST1_ADC_RST BIT(27) - /* ADC registers */ #define NPCM_ADCCON 0x00 #define NPCM_ADCDATA 0x04 @@ -106,13 +103,11 @@ static int npcm_adc_read(struct npcm_adc *info, int *val, u8 channel) msecs_to_jiffies(10)); if (ret == 0) { regtemp = ioread32(info->regs + NPCM_ADCCON); - if ((regtemp & NPCM_ADCCON_ADC_CONV) && info->rst_regmap) { + if (regtemp & NPCM_ADCCON_ADC_CONV) { /* if conversion failed - reset ADC module */ - regmap_write(info->rst_regmap, NPCM7XX_IPSRST1_OFFSET, - NPCM7XX_IPSRST1_ADC_RST); + reset_control_assert(info->reset); msleep(100); - regmap_write(info->rst_regmap, NPCM7XX_IPSRST1_OFFSET, - 0x0); + reset_control_deassert(info->reset); msleep(100); /* Enable ADC and start conversion module */ @@ -186,7 +181,6 @@ static int npcm_adc_probe(struct platform_device *pdev) struct npcm_adc *info; struct iio_dev *indio_dev; struct device *dev = &pdev->dev; - struct device_node *np = pdev->dev.of_node; indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info)); if (!indio_dev) @@ -199,6 +193,10 @@ static int npcm_adc_probe(struct platform_device *pdev) if (IS_ERR(info->regs)) return PTR_ERR(info->regs); + info->reset = devm_reset_control_get(&pdev->dev, NULL); + if (IS_ERR(info->reset)) + return PTR_ERR(info->reset); + info->adc_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(info->adc_clk)) { dev_warn(&pdev->dev, "ADC clock failed: can't read clk\n"); @@ -211,16 +209,6 @@ static int npcm_adc_probe(struct platform_device *pdev) div = div >> NPCM_ADCCON_DIV_SHIFT; info->adc_sample_hz = clk_get_rate(info->adc_clk) / ((div + 1) * 2); - if (of_device_is_compatible(np, "nuvoton,npcm750-adc")) { - info->rst_regmap = syscon_regmap_lookup_by_compatible - ("nuvoton,npcm750-rst"); - if (IS_ERR(info->rst_regmap)) { - dev_err(&pdev->dev, "Failed to find nuvoton,npcm750-rst\n"); - ret = PTR_ERR(info->rst_regmap); - goto err_disable_clk; - } - } - irq = platform_get_irq(pdev, 0); if (irq <= 0) { ret = -EINVAL; -- 2.22.0