From patchwork Tue Dec 4 13:02:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152804 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8040581ljp; Tue, 4 Dec 2018 05:02:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/XuN7rcTPatlI12Q07OTqK77UcGRVxDGcQwfLZ0RtyA3h37haMzSGt77B/J3A9MhqUm+bst X-Received: by 2002:a63:6445:: with SMTP id y66mr17172406pgb.250.1543928566631; Tue, 04 Dec 2018 05:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543928566; cv=none; d=google.com; s=arc-20160816; b=yyvyttg9tMPOy+dZcZKfU0GJKooOQjHmEzTXMlvv5qRUZLv8mcB2/uK4MTTsCHsqLv 0OCzjLTzw222TxmxIiKDEvg1EnkhKn4LnWviTZ3ddO1S1kWAs5uLKNvaKfx0mx1AmQts N4e42JkyyvyfVYYL1d71bEhYZq4aLCZq7x7KyLqE++CHYRUy5ux1XOY0rWBIKo+a3QHF qMbpt+p2an6/ooV7N6KEQpAbCSjfkYL+HZ04EMFwfAPVHjSroVHDfjkFELFNsRSf3d07 gtXHEt8GWlR9/7dJXy2S6gDdvFOW2Of+X4MHgeNEHyD0hqA4nVd0i6S7esPFY4U5Nmj+ dwfQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=yqLOXfKQca+sJj2qmC5IPQl01/t12NLQ0REyFGsrRAI=; b=XKBHQgA5ybrQQ9J3Fiwgx0W7ftBIUP1DcOO3xWdHZf5v5GSiSeg3zQi7rKosgej+32 9FZ/RgzOuwMrTNBxW7ttmpoDxoj08XrtK5y6jncvhYJ5O+fFt9EQRblEiN88fh5km7Po V7m9YG0d2/VZpWmP3BrwNWHM4wXkiW1Pwv1YtmMY9dRkKvYA6l9ghdm4tKHwGamGSQWK gQCy1xrJTZs7b3xd2S6FgNvskyc/PNsU5Zmj/o1SX6MyZ3u13QdlUjKSyhWTDLdi9k0O 9ooc3zB71uUmEONbZwUaI2aBLivYJCO12YfI+J+lgeGvQ3ljoLyY+gr8FYdvH0wAsz2W wq6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WAi8L0OX; spf=pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a28si16167921pgl.530.2018.12.04.05.02.46 for ; Tue, 04 Dec 2018 05:02:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-watchdog-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 header.s=google header.b=WAi8L0OX; spf=pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726151AbeLDNCq (ORCPT ); Tue, 4 Dec 2018 08:02:46 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34004 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbeLDNCq (ORCPT ); Tue, 4 Dec 2018 08:02:46 -0500 Received: by mail-lj1-f196.google.com with SMTP id u6-v6so14820133ljd.1 for ; Tue, 04 Dec 2018 05:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yqLOXfKQca+sJj2qmC5IPQl01/t12NLQ0REyFGsrRAI=; b=WAi8L0OX08rClzcU4JV4m+6liOXoYrCtiVffDNyLRjuJDLU0Pt5iRWGlPh43cmLCUC 9vAzs3+oCuyRqh3y/IMjCCo+hgz7i5Gc5QOC5c2zLgqlTI7f/UcpdPelRKvdJc/B/9G2 ta/z58PDv8tr1gqMgeNANfoYg7K8oPa86z3tc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yqLOXfKQca+sJj2qmC5IPQl01/t12NLQ0REyFGsrRAI=; b=mmUR6DoLrGOFXkZtdU5sL7miALHKgOJVPAinAaIKzvuDfZrmS4pYxJPcafBfGVcpat /DaN5QtrHGp8MuzZvZFYCGaFYEtK3bsEcclDFBByb0kUPJpbX/vUa7bV0UE5GRUMnd/8 Zfz3GC6n7lx4A1WR535vHxk/SJ6EYtaCGsmxBsFCp6DlDUlW3CsEWbUkK2ffChdP8ZLr pnP8wj6ccZ+1V8rLjipQwLG/3We0ljISoYOUWH0WKeCsLOf2QHZ54C7HStoviLQlOAE9 Wkf/ssY2dWyIUKA110CCLvgS1j3fCEo87aUhiG0CK5UiOIQksEFsDapz2sRHTvtOj3oa mAXQ== X-Gm-Message-State: AA+aEWZIew8PRgEXj72hEoTOdcl4mGSV3zKZxzVVHMxqJ4Q8Wx9EDOtX KoKuVxpAlq/MmJOztvCXNrUOfg== X-Received: by 2002:a2e:99d7:: with SMTP id l23-v6mr12358038ljj.165.1543928562247; Tue, 04 Dec 2018 05:02:42 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r4sm2967281lfe.60.2018.12.04.05.02.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 05:02:41 -0800 (PST) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, Linus Walleij , Florian Fainelli Subject: [PATCH v2] watchdog: mtx-1: Convert to use GPIO descriptor Date: Tue, 4 Dec 2018 14:02:36 +0100 Message-Id: <20181204130236.11504-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This converts the MTX-1 driver to grab a GPIO descriptor associated with the device instead of using a resource with a global GPIO number. The board using this driver appears to be out-of-tree (OpenWRT), but the users can be easily augmented by adding a machine descriptor table before registering the device. Cc: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add the correct descriptor table to the board file and register it. I missed the existing board file in the previous iteration. --- arch/mips/alchemy/board-mtx1.c | 16 +++++++++------- drivers/watchdog/mtx-1_wdt.c | 19 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) -- 2.19.2 diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c index d625e6f99ae7..e263a5d1623f 100644 --- a/arch/mips/alchemy/board-mtx1.c +++ b/arch/mips/alchemy/board-mtx1.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -130,13 +131,13 @@ static struct platform_device mtx1_button = { } }; -static struct resource mtx1_wdt_res[] = { - [0] = { - .start = 215, - .end = 215, - .name = "mtx1-wdt-gpio", - .flags = IORESOURCE_IRQ, - } +static struct gpiod_lookup_table mtx1_wdt_gpio_table = { + .dev_id = "mtx1-wdt.0", + .table = { + /* Global number 215 is offset 15 on Alchemy GPIO 2 */ + GPIO_LOOKUP("alchemy-gpio2", 15, NULL, GPIO_ACTIVE_HIGH), + { }, + }, }; static struct platform_device mtx1_wdt = { @@ -310,6 +311,7 @@ static int __init mtx1_register_devices(void) } gpio_direction_input(mtx1_gpio_button[0].gpio); out: + gpiod_add_lookup_table(&mtx1_wdt_gpio_table); return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); } arch_initcall(mtx1_register_devices); diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 1fa7d2b32494..522a2b98ec16 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include @@ -55,7 +55,7 @@ static struct { int queue; int default_ticks; unsigned long inuse; - unsigned gpio; + struct gpio_desc *gpiod; unsigned int gstate; } mtx1_wdt_device; @@ -67,7 +67,7 @@ static void mtx1_wdt_trigger(struct timer_list *unused) /* toggle wdt gpio */ mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate; - gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate); + gpiod_set_value(mtx1_wdt_device.gpiod, mtx1_wdt_device.gstate); if (mtx1_wdt_device.queue && ticks) mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); @@ -90,7 +90,7 @@ static void mtx1_wdt_start(void) if (!mtx1_wdt_device.queue) { mtx1_wdt_device.queue = 1; mtx1_wdt_device.gstate = 1; - gpio_set_value(mtx1_wdt_device.gpio, 1); + gpiod_set_value(mtx1_wdt_device.gpio, 1); mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); } mtx1_wdt_device.running++; @@ -105,7 +105,7 @@ static int mtx1_wdt_stop(void) if (mtx1_wdt_device.queue) { mtx1_wdt_device.queue = 0; mtx1_wdt_device.gstate = 0; - gpio_set_value(mtx1_wdt_device.gpio, 0); + gpiod_set_value(mtx1_wdt_device.gpio, 0); } ticks = mtx1_wdt_device.default_ticks; spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags); @@ -198,12 +198,11 @@ static int mtx1_wdt_probe(struct platform_device *pdev) { int ret; - mtx1_wdt_device.gpio = pdev->resource[0].start; - ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio, - GPIOF_OUT_INIT_HIGH, "mtx1-wdt"); - if (ret < 0) { + mtx1_wdt_device.gpiod = devm_gpiod_get(&pdev->dev, + NULL, GPIOD_OUT_HIGH); + if (IS_ERR(mtx1_wdt_device.gpiod)) { dev_err(&pdev->dev, "failed to request gpio"); - return ret; + return PTR_ERR(mtx1_wdt_device.gpiod); } spin_lock_init(&mtx1_wdt_device.lock);