From patchwork Tue Nov 12 05:54:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11238595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AE6E17E6 for ; Tue, 12 Nov 2019 05:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A9F821783 for ; Tue, 12 Nov 2019 05:54:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GW4XPSBu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726965AbfKLFyR (ORCPT ); Tue, 12 Nov 2019 00:54:17 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34584 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbfKLFyR (ORCPT ); Tue, 12 Nov 2019 00:54:17 -0500 Received: by mail-pg1-f195.google.com with SMTP id z188so5180324pgb.1; Mon, 11 Nov 2019 21:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RNUXeUQ2he9yGQNHJeu0ueH2/ESMsrmnicZwkmOdB+k=; b=GW4XPSBudhcmTSVwBxMyFjzIWM2FsIKdPr6SSTaRlyet8RhDmQiIVYqEJpEFWFcLm7 XX5WTaJ9h4fgkVFaWc38tpXJKJTFDlDqWgcXTDt+lalFs/CX4prBGpF0+c3DWxJRIi/e DKYd5yYKRsEglGBgERR5fyQMcvQdV6isFOzPcFT688PfOvQFMgLwtcFYzvcCHA4gBnR6 aq+jmerRh6Ss3zjJ0l4iYW7F1lR+mydnIt6+K4t14CyaQVPqNuoxEhCGyvhPfhUPt92s Hl3GoX+x8TM6wjZZYzTjqCWDpa7t8Su77y/1r7GtT+DZSwEfxB791o+eBGcorwK7p9sK vppA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RNUXeUQ2he9yGQNHJeu0ueH2/ESMsrmnicZwkmOdB+k=; b=QUovztiR3T4qa0PD1/kLNzY8E5kKnK1gShS5FAQ8ZhitOmvZV+AKn5xdLeOHCCbcp0 siZDzdvdipfgj17gOFyBPnXPKNyE9qp7JACWSDmwAVjGpR9fVTbDqM2mxAnIzgfQR6Nv yYsiNWU81hvm5SXUvyujIQwJ7DpBSkUerw43hrMNIcg0RoYkU7tr0hGptBo92nI49Yp7 urNMDWwzZU/sT2uiH7hnizz8qKpeDVPDp3/X1TDq+gWVsokoYT96rSJa+/bfTZWjyTg6 CyxkT8kgi4lixn0bdgPCWjiFAQBOD8osz6JATZ9ssotJdgs3IkVfAWwWzg8BgVivMtF/ P4Pg== X-Gm-Message-State: APjAAAWVIZSIxxqXGvLIb02yUgcznA6ef4JVzuXV2ruTSWORBnvRDHBS PaJigaGHWamOaO3qT7Vr3lk= X-Google-Smtp-Source: APXvYqzU0C+BWuw3Ec2o2cnt5pc8T768D2XbYVOUzZfj0x1BLbP3fOUEtaqf2ctwzdSnAJv40qXrvw== X-Received: by 2002:a63:ff65:: with SMTP id s37mr32689085pgk.331.1573538056221; Mon, 11 Nov 2019 21:54:16 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id d139sm23160178pfd.162.2019.11.11.21.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 21:54:15 -0800 (PST) From: Dmitry Torokhov To: Mark Brown Cc: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Mark Rutland , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 1/2] spi: dt-bindings: spi-controller: add wakeup-source and interrupts Date: Mon, 11 Nov 2019 21:54:10 -0800 Message-Id: <20191112055412.192675-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191112055412.192675-1-dmitry.torokhov@gmail.com> References: <20191112055412.192675-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This change adds bindings for wakeup-source and interrupts/interrupt-names properties that can be used to configure device as wakeup source on the system. Signed-off-by: Dmitry Torokhov --- .../bindings/spi/spi-controller.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-controller.yaml b/Documentation/devicetree/bindings/spi/spi-controller.yaml index 732339275848c..4e31a4bf6851c 100644 --- a/Documentation/devicetree/bindings/spi/spi-controller.yaml +++ b/Documentation/devicetree/bindings/spi/spi-controller.yaml @@ -78,6 +78,29 @@ patternProperties: description: Chip select used by the device. + interrupts: + items: + - description: main interrupt (attention) line. + - description: dedicated wakeup interrupt. + minItems: 1 # The wakeup interrupt is optional. + description: + Specifies interrupt lines a device is connected to. Typically a + device is wired to a single interrupt line that is used as + "attention" signal and also to wake up system when device is + set up as wakeup source. However on some systems a dedicated + wakeup line might be used. + + interrupt-names: + items: + - const: irq + - const: wakeup + minItems: 1 + + wakeup-source: + description: + Device is capable of waking up the system. + type: boolean + spi-3wire: $ref: /schemas/types.yaml#/definitions/flag description: From patchwork Tue Nov 12 05:54:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11238593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 527C114ED for ; Tue, 12 Nov 2019 05:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31F5221783 for ; Tue, 12 Nov 2019 05:54:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g8smE6MU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbfKLFyT (ORCPT ); Tue, 12 Nov 2019 00:54:19 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35712 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbfKLFyS (ORCPT ); Tue, 12 Nov 2019 00:54:18 -0500 Received: by mail-pl1-f194.google.com with SMTP id s10so8920217plp.2; Mon, 11 Nov 2019 21:54:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PfLpTXwmTko+wTungBc02PKeDQN7UmUMa4lSWShWaZw=; b=g8smE6MUyrhWi+O5jT2tC9pxowb4qn4mvEpn4T2Ps4ARa51BvJvvwNDVbFfrgzehOE dDPjz47NDeo0D25zWiWzlepCPlCt/Edlx+4ls7viapwtvf3VlIk1S8OazqbLpEXmciP6 lcyqWuX/P3Z4v/irj4tncveAn/kJ87aGMkG5X8HrqFTtdUNYzb3q4KRzWrIoOClj9gkl 5H2sqPUSww16MOmZ1G2Fldav3orxtwev1eZHxavYd4hoIk9yuPHQ2IiEn6Zq2rqAuODb 62y35ef5CH39Rg15KuRhuQBzYTBpAVENwxcy3l6+i8oVXGS+kFiSQXkOJHpjNOQdqGol v1xw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=PfLpTXwmTko+wTungBc02PKeDQN7UmUMa4lSWShWaZw=; b=qQPqqw+/Z96OdpX34acRjdUk4g8AzAPCbH8/5oNEhxU46MRKgplH49jweXBxrJn60O 7nReq7GWdlcEejwxmHisbkWHTqD7amrB7o8ya4OcBKPchEi1hWScEe1N6Rnt7hjSXiXY ti0XgR1jL4IWrxHLiyuv6zvgRF7HozVOqHl0HkDzpbpdNrh38mXB4wPrwRxp3YW6Qu97 xxpRqZFgxRsqSamRjB2HRECYeEGsvnilhquER6h9tu7nDqtmQnmsLjqw+tb9eFHxx+Re duIwlMFpJ++BvuOvqDY1wCV0ioNLkw4D1rfEA3DE6s7KDcEuR9n060tVN7J720+W4eLw 4phQ== X-Gm-Message-State: APjAAAWoDVAyLwbncrL8zysaVJDBkayRaQkGOzidXVAFjeMvrYXdvhle dI+wdcuRGObZuLYfHp8XfVI= X-Google-Smtp-Source: APXvYqyRtF8pUyuEwxg+/DQ6H/oW0ptK8vemrlPtYyErFrLgoAQb7atWgILkZafNapbyUiYM4fJyrw== X-Received: by 2002:a17:902:6e02:: with SMTP id u2mr30148678plk.234.1573538057420; Mon, 11 Nov 2019 21:54:17 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id d139sm23160178pfd.162.2019.11.11.21.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 21:54:16 -0800 (PST) From: Dmitry Torokhov To: Mark Brown Cc: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Subject: [PATCH 2/2] spi: wire up wakeup-source/wakeirq handling Date: Mon, 11 Nov 2019 21:54:11 -0800 Message-Id: <20191112055412.192675-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191112055412.192675-1-dmitry.torokhov@gmail.com> References: <20191112055412.192675-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Many SPI drivers need to configure their devices for waking up the system. Instead of forcing them to reimplement wakeup handling, let's mirror what I2C core is doing and handle "wakeup-source" device property in SPI core. Also, let's allow naming device's interrupt lines as "irq" and "wakeup" and automatically configure the right one as wakeirq when device is supposed to be a wakeup source. Implementing this is very helpful for drivers that use both I2C and SPI for transport, such as tsc2004/tsc2005. Signed-off-by: Dmitry Torokhov --- drivers/spi/spi.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 50769a8475d66..baa7aac300d9f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -394,13 +395,37 @@ static int spi_drv_probe(struct device *dev) return ret; if (dev->of_node) { - spi->irq = of_irq_get(dev->of_node, 0); + spi->irq = of_irq_get_byname(dev->of_node, "irq"); + if (spi->irq == -EINVAL || spi->irq == -ENODATA) + spi->irq = of_irq_get(dev->of_node, 0); if (spi->irq == -EPROBE_DEFER) return -EPROBE_DEFER; if (spi->irq < 0) spi->irq = 0; } + if (device_property_read_bool(dev, "wakeup-source")) { + int wakeirq = -ENOENT; + + if (dev->of_node) { + wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); + if (wakeirq == -EPROBE_DEFER) + return wakeirq; + } + + device_init_wakeup(dev, true); + + if (wakeirq > 0 && wakeirq != spi->irq) + ret = dev_pm_set_dedicated_wake_irq(dev, wakeirq); + else if (spi->irq > 0) + ret = dev_pm_set_wake_irq(dev, spi->irq); + else + ret = 0; + + if (ret) + dev_warn(dev, "failed to set up wakeup irq: %d\n", ret); + } + ret = dev_pm_domain_attach(dev, true); if (ret) return ret;