From patchwork Sat Dec 22 10:12:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 154432 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2198621ljp; Sat, 22 Dec 2018 08:56:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN70oi6xfoKFGoiMZjsZ0HT86+ngoTNJDBkq/3Sbfk17cz3q3P/FlUN4JUxRyJoeI2UCO0OY X-Received: by 2002:a17:902:112c:: with SMTP id d41mr6847325pla.144.1545497791353; Sat, 22 Dec 2018 08:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545497791; cv=none; d=google.com; s=arc-20160816; b=KxEpiC3+NVZg8WZSlqvo8aIAmvgNotDIvcelTUpF33Lwb9EeV4/uOOB/41pehmN12P D5qFxsQ+5Y57dWmkvnMkI2iW41iqYuH6ItgpIxUt/E3Fh6qXGF6Mz0VGJLDB8TifFDxU HxQ/0qOEvijoTNfkaNPQ121ZRZg8+d1ssO5nTycI/S6H0emw1IfOqrTWtfP6sm0WU3zt LqivcF2VTatyaAb/L/A1u6pVvBgQvLIJV0R3JX+PRepL/6dsrV9hArjlPPdcvrT6nZrX ZqMpA4wrWBUxRL4GFKTVVOPEeQOlNPhqw/mUk6nutZgakeAz+bqyNRoS3R8R5fclG/f9 nTDQ== 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=pzvgCR5woup59n5zQupxHPUJp3XfYJCLF7eRdT69RtQ=; b=WI5S4CzsB/Fdq7abeDl1dW8vg/hxQYCc/4aNLX+Cz1+3fkb7R7+BTHc/SBfDEGsDoT 3C1FoZW7xsUtdC4uKNWs2oAW61n8Tx8uu+po4+F403tPw5DYix5a42vhKPil4p+jnY2l Brl8h4olRTNA+g8H641iUDz0QeQpY79iscd8WqvF7VI/YlPavhaufHtPbFXX+yh23IDF Eov+Jw6JCUeajpzNVxb0fOpVzVwMOb/EhAuzJcbQ2sNR/mC4oukbdp+sGAP8jOHzj8kJ e3fevczIEYEJQJ0Rse9J9GwbRuJ84NMBMVXrogFlXj21tQl8tsXF4W/wKpZ6R3pB4ls6 ujUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j5faRq+d; 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 b9si22907913pgt.293.2018.12.22.08.56.31 for ; Sat, 22 Dec 2018 08:56:31 -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=j5faRq+d; 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 S2388358AbeLVQ4a (ORCPT ); Sat, 22 Dec 2018 11:56:30 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:44214 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726511AbeLVQ4a (ORCPT ); Sat, 22 Dec 2018 11:56:30 -0500 Received: by mail-lj1-f196.google.com with SMTP id k19-v6so7360331lji.11 for ; Sat, 22 Dec 2018 08:56:28 -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=pzvgCR5woup59n5zQupxHPUJp3XfYJCLF7eRdT69RtQ=; b=j5faRq+dE+g2OGMwa1JkCw6Lp1tG7kQOkAC3ysu0J2+N1vFuClz+5wk7jeMIoN0RCa 4+hjHp5q3IOVExkwB2tM0rEJqeR2C8PGz0kjt5CDtQs7b1j/LeoWU0Rt994+pDXqP3qI b6bpmu6KiAXOHEii8k2AohUMOmBqJ6pPC20ak= 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=pzvgCR5woup59n5zQupxHPUJp3XfYJCLF7eRdT69RtQ=; b=ZmB2/kf5bY4gFZio9mKpuDRg0fEyqdMrPSgrMaEwzWnNdh3LNlRFBKMpn5QgS74oTt QmFrl4TKBacJF4e6iKDWXnW0Inx+sgQePa6VSVwck/nHfLMLn75rfjrjgO362SBX81JD Ms3urNjllJ2LcrxmjlVvcP7eI0/+/REPfnR857JIi5h+cv+IK5cmFyFro9tT6yzgtKvk n4khSV6jJGiHbysdXCyNPCbUTiZgMO7XC4+f8qZ2zl9jCETRZH3CkT+pFT+muaJAy5pk gmhKL8RMt0EbF2RqdO0nW4WQjv1FpfbdJqyP1OCENYZ81wQ0qVahSK+xol3DbOAC2fFp zvlg== X-Gm-Message-State: AJcUukdP4+Kk6HNzitc0U1SwrcRXceOLAbM7XXQYmo2Othz8kHsHbJog QqBFRfxfuHJzrKzyuMBXWhmCLmV3J4l7fg== X-Received: by 2002:a2e:1603:: with SMTP id w3-v6mr3653715ljd.33.1545473674768; Sat, 22 Dec 2018 02:14:34 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 85-v6sm5228014lja.16.2018.12.22.02.14.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Dec 2018 02:14:33 -0800 (PST) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, Linus Walleij , Ralf Baechle , Paul Burton , James Hogan , linux-mips@linux-mips.org, Florian Fainelli Subject: [PATCH v4] watchdog: mtx-1: Convert to use GPIO descriptor Date: Sat, 22 Dec 2018 11:12:31 +0100 Message-Id: <20181222101231.19092-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. Augment the driver and the boardfile. Cc: Ralf Baechle Cc: Paul Burton Cc: James Hogan Cc: linux-mips@linux-mips.org Cc: Florian Fainelli Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Collect Florian's Review-tag. - Cc MIPS maintainers. Please provide an ACK so that Guenther can merge this into the watchdog tree! ChangeLog v2->v3: - Fix to acces .gpiod rather than .gpio - Drop resource assignment in boardfile: no resources left to pass. 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 | 18 +++++++++--------- drivers/watchdog/mtx-1_wdt.c | 19 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) -- 2.19.2 Acked-by: Paul Burton diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c index d625e6f99ae7..9d9d4ee31605 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,20 +131,18 @@ 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 = { .name = "mtx1-wdt", .id = 0, - .num_resources = ARRAY_SIZE(mtx1_wdt_res), - .resource = mtx1_wdt_res, }; static const struct gpio_led default_leds[] = { @@ -310,6 +309,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..e028e0a2eca0 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.gpiod, 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.gpiod, 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);