From patchwork Wed Dec 13 18:00:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 178223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7960703dys; Wed, 13 Dec 2023 10:01:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiICDpaNJ6mrqufl4wZU7McwT0UXRPLlS+/ymQFIkwSlnnRAkNY3o0vVMVuk+JwqcyODJ9 X-Received: by 2002:a05:6a20:29a5:b0:18f:97c:384f with SMTP id f37-20020a056a2029a500b0018f097c384fmr8210013pzh.41.1702490503883; Wed, 13 Dec 2023 10:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490503; cv=none; d=google.com; s=arc-20160816; b=T7ZQAoxCZgxmNSlpPQs5BgsUD+iy7r+Z/9q0j7euwqoToQmU66WvsY7r0OqETtuo/k qeSHQZy19WSSAzVgc9NHuJxyT2rk9Nah+mUX/hEEtzf1WYxk9sX6GsadDG9aU1FBZlr8 I61MQ6M+twCCnEkMHMy0/NWOUcgvBaSJ3c1y60sMrlqXIDrid9vJEy60Dr9RHeXdweNY tvNYXwkdlV2jGfAODqEbxDyw8PApEzUCfJfShngIFr11QNnfsRV2WjzTIvZ4kOfVTei3 m6zYcH21c77m/LgXI9G0bm/oqo+usV6+htQvOETnKlTI6xJ9cD1+EZMH6+nSnKJH1qVK Q9qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=p5zuCDShIaj0o7q9TPAVHj0YHPrBoAtuRhnP9FUDw7o=; fh=SmsH639nycVYvPFQy3SRF2OxKj6u6HTk3AsLJPyUnDI=; b=YrZye63jIDD0+q9Yi4/GtJx44QLAK5Pj75G718ipcjgbI7ZDKnGcky8BKj9bCjV/Cr Owl1qZlKoZcg7MfeWa8qnfcoA8Vk5Pl4+ZhqFXwc3b+g711IDmDOjQylLDMjGwBzSdKy Vc/tIdy/LJ6sLkWKg71AwclY3WH1doX+ppfb/oXtDcZ51ZWCu46KdLguAEbNJEwCTYEb 43aXsBLRi7hTtc0W9blzQhkyurYuJXDCymxmrltyk7hGxbb5k9eOltCervUbL5dcbr1t dmKwSlJP2/l1mmElZH7rQlcPCYSrTz0oqX3V/IfKkjo8vCcjMfIV+lQZpL3tKDIwg15v Nd3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J6eczgrw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j8-20020a056a00234800b006cdefbf53besi10040137pfj.104.2023.12.13.10.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J6eczgrw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 41387826E625; Wed, 13 Dec 2023 10:01:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233600AbjLMSBb (ORCPT + 99 others); Wed, 13 Dec 2023 13:01:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233379AbjLMSB3 (ORCPT ); Wed, 13 Dec 2023 13:01:29 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC321106 for ; Wed, 13 Dec 2023 10:01:34 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-35f49b80192so9753895ab.1 for ; Wed, 13 Dec 2023 10:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490494; x=1703095294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=p5zuCDShIaj0o7q9TPAVHj0YHPrBoAtuRhnP9FUDw7o=; b=J6eczgrwbWgdDPGiRuPfM5edVOXCS5pQoBRo5/m5283Ukcpmt/nAU71lpjCTvezXaF 6j6xjXrU8D021eqO9ewkYU3bJ9x3uDaX1zcOrgpvJ2nXs7yL98zH6zym+odteLBbQv23 4wQmqoXQt5ZZtda+oRCQOVA8XdSGT6zoIOrXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490494; x=1703095294; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=p5zuCDShIaj0o7q9TPAVHj0YHPrBoAtuRhnP9FUDw7o=; b=TV1YKxdENgdIIrVQwZGhD/vy+aqX1MaY0QoqoNKvi/+f7vhi7aWG1niG3xvGasLtPZ 5YnCeLygX9DJH30WaDbJmuT/mRwz74p7ajYckynzcXhN38K+qBSydcRDPL7sZYxG6d5R CCtEY5L6IobhDg58qXth4M9/CRLC09hGF/Ka/Ixxj8rLODtKYgfm5hS4yf6q+Tq/CbEG DTq76N2AecuiazLjqWUlGjhfhmsQTXnWUoRx+s1j8z3o+SmUcmtp1GCXgHMHoiTZ2T3b rz9r2G9te06SSKnrv2QgFYiY25xd4ZsTW6ICKnemu91ydR1MvMtoYDrWPpVne78dl47H r+5w== X-Gm-Message-State: AOJu0YwNNEcEfC3HcyN+OKwFGGtguDZGT2TTeb3UkDlPkzg7/Mfp2WWE OErNc+X5ptG5OMCbO0Whgw1KTqUdQySUXv71obo= X-Received: by 2002:a05:6e02:1907:b0:35d:59b3:2f8b with SMTP id w7-20020a056e02190700b0035d59b32f8bmr8224233ilu.32.1702490492036; Wed, 13 Dec 2023 10:01:32 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:31 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Andy Shevchenko , Bartosz Golaszewski , Len Brown , Linus Walleij , Mika Westerberg , "Rafael J. Wysocki" , Wolfram Sang , linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [PATCH v1 1/6] gpiolib: acpi: Modify acpi_dev_irq_wake_get_by to use resource Date: Wed, 13 Dec 2023 11:00:19 -0700 Message-ID: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:01:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190682510909432 X-GMAIL-MSGID: 1785190682510909432 Other information besides wake capability can be provided about GPIO IRQs such as triggering, polarity, and sharability. Use resource flags to provide this information to the caller if they want it. This should keep the API more robust over time as flags are added, modified, or removed. It also more closely matches acpi_irq_get which take a resource as an argument. Rename the function to acpi_dev_get_gpio_irq_resource to better describe the function's new behavior. Signed-off-by: Mark Hasemeyer --- drivers/gpio/gpiolib-acpi.c | 25 ++++++++++++++++--------- drivers/i2c/i2c-core-acpi.c | 10 ++++++++-- include/linux/acpi.h | 23 ++++++++++------------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 51e41676de0b8..3f6d28e1860f9 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -111,6 +111,7 @@ struct acpi_gpio_info { int polarity; int triggering; bool wake_capable; + bool shareable; unsigned int debounce; unsigned int quirks; }; @@ -784,6 +785,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) lookup->info.debounce = agpio->debounce_timeout; lookup->info.gpioint = gpioint; lookup->info.wake_capable = acpi_gpio_irq_is_wake(&lookup->info.adev->dev, agpio); + lookup->info.shareable = agpio->shareable == ACPI_SHARED; /* * Polarity and triggering are only specified for GpioInt @@ -1028,11 +1030,11 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, } /** - * acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ number + * acpi_dev_get_gpio_irq_resource() - Find GpioInt and populate resource struct * @adev: pointer to a ACPI device to get IRQ from * @name: optional name of GpioInt resource * @index: index of GpioInt resource (starting from %0) - * @wake_capable: Set to true if the IRQ is wake capable + * @r: pointer to resource to populate with irq information. It is not modified on failure. * * If the device has one or more GpioInt resources, this function can be * used to translate from the GPIO offset in the resource to the Linux IRQ @@ -1047,10 +1049,12 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, * The GPIO is considered wake capable if the GpioInt resource specifies * SharedAndWake or ExclusiveAndWake. * - * Return: Linux IRQ number (> %0) on success, negative errno on failure. + * Irq number will be available in the resource structure. + * + * Return: 0 on success, negative errno on failure. */ -int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index, - bool *wake_capable) +int acpi_dev_get_gpio_irq_resource(struct acpi_device *adev, const char *name, int index, + struct resource *r) { int idx, i; unsigned int irq_flags; @@ -1108,16 +1112,19 @@ int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, in } /* avoid suspend issues with GPIOs when systems are using S3 */ - if (wake_capable && acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) - *wake_capable = info.wake_capable; + if (info.wake_capable && !(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) + info.wake_capable = false; - return irq; + *r = (struct resource)DEFINE_RES_IRQ(irq); + r->flags = acpi_dev_irq_flags(info.triggering, info.polarity, + info.shareable, info.wake_capable); + return 0; } } return -ENOENT; } -EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_wake_get_by); +EXPORT_SYMBOL_GPL(acpi_dev_get_gpio_irq_resource); static acpi_status acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 69c50e8506d32..b89bc383ff627 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -203,6 +203,7 @@ int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable) { struct acpi_device *adev = ACPI_COMPANION(&client->dev); struct list_head resource_list; + struct resource irqres; struct i2c_acpi_irq_context irq_ctx = { .irq = -ENOENT, }; @@ -217,8 +218,13 @@ int i2c_acpi_get_irq(struct i2c_client *client, bool *wake_capable) acpi_dev_free_resource_list(&resource_list); - if (irq_ctx.irq == -ENOENT) - irq_ctx.irq = acpi_dev_gpio_irq_wake_get(adev, 0, &irq_ctx.wake_capable); + if (irq_ctx.irq == -ENOENT) { + ret = acpi_dev_get_gpio_irq_resource(adev, NULL, 0, &irqres); + if (ret) + return ret; + irq_ctx.irq = irqres.start; + irq_ctx.wake_capable = irqres.flags & IORESOURCE_IRQ_WAKECAPABLE; + } if (irq_ctx.irq < 0) return irq_ctx.irq; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index afd94c9b8b8af..20d9f3d088dbc 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1238,8 +1238,8 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); bool acpi_gpio_get_io_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); -int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index, - bool *wake_capable); +int acpi_dev_get_gpio_irq_resource(struct acpi_device *adev, const char *name, int index, + struct resource *r); #else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio) @@ -1251,28 +1251,25 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, { return false; } -static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, - int index, bool *wake_capable) +static inline int acpi_dev_get_gpio_irq_resource(struct acpi_device *adev, const char *name, + int index, struct resource *r) { return -ENXIO; } #endif -static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, int index, - bool *wake_capable) +static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index) { - return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable); -} + struct resource r; + int ret; -static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, - int index) -{ - return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL); + ret = acpi_dev_get_gpio_irq_resource(adev, name, index, &r); + return ret ?: r.start; } static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { - return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL); + return acpi_dev_gpio_irq_get_by(adev, NULL, index); } /* Device properties */ From patchwork Wed Dec 13 18:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 178224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7960834dys; Wed, 13 Dec 2023 10:01:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH2e1WtZJ4Sep2hIBO0Z+bt+NpgEsqEYuiGPdOTBLPkjiUW4zQWvhBOpv+tnka2w4H2scG X-Received: by 2002:a05:6a00:2451:b0:6ce:83ae:f1f with SMTP id d17-20020a056a00245100b006ce83ae0f1fmr5419201pfj.32.1702490512008; Wed, 13 Dec 2023 10:01:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490511; cv=none; d=google.com; s=arc-20160816; b=w0oKaFPGJ+GORds6ADLziuutCrD+CrjpMxio1vT5QLzj1u+FsspqgqAu5kjDKAJjgh RkpOtKOUJ0MgmwRlApzKksqLFRflafoz4z3H55EDpjMhMfq1wjiSClOMvVbnwMjEbvqd AMyqlPvYXKNFQ+pNDbu9t8zmTqGn5nS3VNCgzKVLGyoMR39OEIkjJYzX4xuV4eJkvGD9 K+GVHcLYgjDeE8ABi3vUVBpSfiz/r9U33Bd2dpJwo9ORJaNrGTLaISC4BZf08fglviqG 6giIDkgrZDJA6Q/d0+v1+HlzCUh7Y1ZAWM/CjFNKY6luDansGMV23v7EjLwr4wVmC5ex LBOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XHJkvyGkozEZfAn1foMxSDGndxq7Z3rvVOkqL1kGsfY=; fh=hFOzmz9HMW0bUx+usxAamK3buiZSrk+g/TN2mi2iHrQ=; b=W84JmEuE0g4JpwS1I6yxQLqDrJNpPzSBD7NvzGugcEioqX0t0c3hJYwxiDvzuMefhh chrdp25v02mvM6RLTjWPU+Y4Ce/1654ptlfe6wBAPavvpZ9NqdyyuwrtTPb9w5ytaP+S 0BOyjX2G24tH5BqyyFuq2eGKzwqZfiLP4+dyg1eltdxVCD0msPqTBY32v6VBSibGQdhh 06YCBugUgqgXTz1jux7tKMTon15tfBLZnS5scMXp7b7lpm/bHS7Xl6+JG4MGwMdG2bG+ AzujD1+XJJbMxLYxo9QXaa9G+dnUbPdRdOycSezzsokB2pM74slApf3WJkJRNpQUCPpz D73w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R0mmNxEp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id 27-20020a630f5b000000b005c609c4fb47si9809483pgp.283.2023.12.13.10.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R0mmNxEp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 93D99826E8F5; Wed, 13 Dec 2023 10:01:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377618AbjLMSBd (ORCPT + 99 others); Wed, 13 Dec 2023 13:01:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233514AbjLMSBb (ORCPT ); Wed, 13 Dec 2023 13:01:31 -0500 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8ED710C for ; Wed, 13 Dec 2023 10:01:36 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7b7876fe9f0so18643239f.2 for ; Wed, 13 Dec 2023 10:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490496; x=1703095296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XHJkvyGkozEZfAn1foMxSDGndxq7Z3rvVOkqL1kGsfY=; b=R0mmNxEp0BMl1n5mtQRXqrltYTABN6srYsAlfWPTXKOXf8Gjky5VvJnnlirMsoZNWE MrNRWdEUjJBtcEpY9JIneq+djDCuONpmdO3u19k0QpKIr0Z9ijEmLBdT6L5EwtlM8J54 zwyRCHHvnT+x0cQvIYpx1NRwEBEhc/K9qlX7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490496; x=1703095296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XHJkvyGkozEZfAn1foMxSDGndxq7Z3rvVOkqL1kGsfY=; b=w7KKwtJaCfUz9IdKj0IHbttUzjsywGwjxtYccEMzdrf3CGKiDUggdK+r5CkP3TlVOM uLlK0JvShvSLHo818116V4AGHvvJa1RRnqo6ir15XoEMn3E9Ksv05bdeLycenGDXSnRe oRj+2kJfD6hwSQsfXbOpmuNvzzSRls1Ft7vayKxEXwYVm+myZnSvzwcoXGzhLtrmXZoo DNCEEpDU8gHcWS5JtkOwuq575DZnlui4ZOhcQVuB7Wd636L6jNknBajkkekRTI5alKyw EfF5aS/t5c60YrF2H8mdm+ZvRYcy4UWpAEYOLXhLjB7F84YRLRAjPIGQE2UxdEdGvcDA bsOQ== X-Gm-Message-State: AOJu0YxptiDqBZlWOZ93Ftx9GBORoAnzSAZdJMQ2JOx7Q6fckTkJz4VC B3evclEgs7MMXaKE7MmEyNUnKTTvXBe7LVS/m+0SIw== X-Received: by 2002:a5d:948e:0:b0:7b7:70fe:2913 with SMTP id v14-20020a5d948e000000b007b770fe2913mr2509400ioj.19.1702490495596; Wed, 13 Dec 2023 10:01:35 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:35 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Alim Akhtar , Andre Przywara , Andy Gross , AngeloGioacchino Del Regno , Baruch Siach , Bjorn Andersson , Claudiu Beznea , Conor Dooley , Heiko Stuebner , Jesper Nilsson , Jisheng Zhang , Jonathan Hunter , Konrad Dybcio , Krzysztof Kozlowski , Matthias Brugger , Michal Simek , Paul Barker , Rob Herring , Sudeep Holla , Thierry Reding , cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v1 2/6] arm: arm64: dts: Enable cros-ec-spi as wake source Date: Wed, 13 Dec 2023 11:00:20 -0700 Message-ID: <20231213110009.v1.2.I274b2d2255eb539cc9d251c9d65a385cc4014c79@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> References: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:01:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190691047033879 X-GMAIL-MSGID: 1785190691047033879 The cros_ec driver currently assumes that cros-ec-spi compatible device nodes are a wakeup-source even though the wakeup-source property is not defined. Add the wakeup-source property to all cros-ec-spi compatible device nodes to match expected behavior. Signed-off-by: Mark Hasemeyer --- arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi | 1 + arch/arm/boot/dts/nvidia/tegra124-venice2.dts | 1 + arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi | 1 + arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts | 1 + arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts | 1 + arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 1 + arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi | 1 + arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi | 1 + arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi | 1 + arch/arm64/boot/dts/nvidia/tegra132-norrin.dts | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi | 1 + arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi | 1 + arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 1 + 16 files changed, 16 insertions(+) diff --git a/arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi b/arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi index a2ee371802004..8125c1b3e8d79 100644 --- a/arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi +++ b/arch/arm/boot/dts/nvidia/tegra124-nyan.dtsi @@ -338,6 +338,7 @@ cros_ec: cros-ec@0 { interrupt-parent = <&gpio>; interrupts = ; reg = <0>; + wakeup-source; google,cros-ec-spi-msg-delay = <2000>; diff --git a/arch/arm/boot/dts/nvidia/tegra124-venice2.dts b/arch/arm/boot/dts/nvidia/tegra124-venice2.dts index 3924ee385dee0..df98dc2a67b85 100644 --- a/arch/arm/boot/dts/nvidia/tegra124-venice2.dts +++ b/arch/arm/boot/dts/nvidia/tegra124-venice2.dts @@ -857,6 +857,7 @@ cros_ec: cros-ec@0 { interrupt-parent = <&gpio>; interrupts = ; reg = <0>; + wakeup-source; google,cros-ec-spi-msg-delay = <2000>; diff --git a/arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi b/arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi index 092316be67f74..1554fe36e60fe 100644 --- a/arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi +++ b/arch/arm/boot/dts/rockchip/rk3288-veyron-chromebook.dtsi @@ -112,6 +112,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ec_int>; spi-max-frequency = <3000000>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel"; diff --git a/arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts b/arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts index 4e757b6e28e1c..3759742d38cac 100644 --- a/arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts +++ b/arch/arm/boot/dts/samsung/exynos5420-peach-pit.dts @@ -967,6 +967,7 @@ cros_ec: cros-ec@0 { reg = <0>; spi-max-frequency = <3125000>; google,has-vbc-nvram; + wakeup-source; controller-data { samsung,spi-feedback-delay = <1>; diff --git a/arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts b/arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts index f91bc4ae008e4..9bbbdce9103a6 100644 --- a/arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts +++ b/arch/arm/boot/dts/samsung/exynos5800-peach-pi.dts @@ -949,6 +949,7 @@ cros_ec: cros-ec@0 { reg = <0>; spi-max-frequency = <3125000>; google,has-vbc-nvram; + wakeup-source; controller-data { samsung,spi-feedback-delay = <1>; diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi b/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi index 4dd21dd317026..f0395da659a86 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi @@ -1168,6 +1168,7 @@ cros_ec: ec@0 { interrupt-parent = <&pio>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; google,cros-ec-spi-msg-delay = <500>; + wakeup-source; i2c_tunnel: i2c-tunnel0 { compatible = "google,cros-ec-i2c-tunnel"; diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi index 44647d462e20b..359859f23b1fd 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi @@ -1013,6 +1013,7 @@ cros_ec: cros-ec@0 { interrupts = <151 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int_odl>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel"; diff --git a/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi b/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi index 5f62dc83013f0..74c534d475cb0 100644 --- a/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi @@ -1918,6 +1918,7 @@ cros_ec: ec@0 { interrupts = <13 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel"; diff --git a/arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi b/arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi index a29da53d17894..4594287d60926 100644 --- a/arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi @@ -1454,6 +1454,7 @@ cros_ec: ec@0 { spi-max-frequency = <3000000>; pinctrl-names = "default"; pinctrl-0 = <&cros_ec_int>; + wakeup-source; #address-cells = <1>; #size-cells = <0>; diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi index 37a3e9de90ff7..a5ace1b02c3d2 100644 --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi @@ -1034,6 +1034,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&cros_ec_int>; spi-max-frequency = <3000000>; + wakeup-source; keyboard-backlight { compatible = "google,cros-kbd-led-backlight"; diff --git a/arch/arm64/boot/dts/nvidia/tegra132-norrin.dts b/arch/arm64/boot/dts/nvidia/tegra132-norrin.dts index bbc2e9bef08da..14d58859bb55c 100644 --- a/arch/arm64/boot/dts/nvidia/tegra132-norrin.dts +++ b/arch/arm64/boot/dts/nvidia/tegra132-norrin.dts @@ -762,6 +762,7 @@ ec: cros-ec@0 { interrupt-parent = <&gpio>; interrupts = ; reg = <0>; + wakeup-source; google,cros-ec-spi-msg-delay = <2000>; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi index 5a33e16a8b677..e6a2ed0463997 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi @@ -650,6 +650,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ap_ec_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm"; diff --git a/arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi b/arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi index 9ea6636125ad9..2ba4ea60cb147 100644 --- a/arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi @@ -548,6 +548,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ap_ec_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm"; diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi b/arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi index ebae545c587c4..fbfac7534d3c6 100644 --- a/arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280-idp-ec-h1.dtsi @@ -19,6 +19,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ap_ec_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm"; diff --git a/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi b/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi index f86e7acdfd99f..d8eb45662c931 100644 --- a/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi @@ -838,6 +838,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int_l>; spi-max-frequency = <3000000>; + wakeup-source; cros_ec_pwm: pwm { compatible = "google,cros-ec-pwm"; diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi index c9bf1d5c3a426..69a0b34f0615b 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi @@ -602,6 +602,7 @@ cros_ec: ec@0 { pinctrl-names = "default"; pinctrl-0 = <&ec_ap_int_l>; spi-max-frequency = <3000000>; + wakeup-source; i2c_tunnel: i2c-tunnel { compatible = "google,cros-ec-i2c-tunnel"; From patchwork Wed Dec 13 18:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 178225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7960917dys; Wed, 13 Dec 2023 10:01:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEars0bE6cAB6aWPztijp6UyxaTwat3ed1mH10lx4y3zlnb0YVw76jaJfEoOdrM4pwI/2As X-Received: by 2002:a05:6a00:2da1:b0:6ce:2731:47b7 with SMTP id fb33-20020a056a002da100b006ce273147b7mr10181707pfb.23.1702490517225; Wed, 13 Dec 2023 10:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490517; cv=none; d=google.com; s=arc-20160816; b=OeWLnwLCAT3HVigkJz2k6ai92R1DxjNZdQ4RS3Nxnc7+Wl1IIHJBEdMHB2rlVLUtQH FMnA8kJ1PR2asmgN065Oa5XRXGaJnzvBjEqO3T21DSSFYxyiFYfEKlRsqNfvHYivCAUH o189Olaol4wy+OzrwG252XQUyk3TKscGoJBSmLgSB0v6OQX7CNJcac5r4CZCb+rUdoSz vvA4cBs062Wb0YNlQqoDtLqQm4fRwJVuurcZjtEMFALaH3xV3oxKkUkOajbhlAYVStRq 2R7wzYqWtfv0hov2H2qut4fi5Cfco2e1QR84WgFWGH7PLmt4sC3ivsi6XK8trURDfUyt cRKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IE6mE6pjbGov9LkkEhCEwGDUbXlSJbMapTwV75Z3EGc=; fh=zxG5iud9xF1D6IY8H/gUMSGI5vQPvUvLe4axMqsZymY=; b=CSn7IpnZBSeEPdRx7yvD9xZkXMpCPzj4VixkEqN4uef6L99JhZtrDOGU8h3Ut73uJ2 gDStmKkWc20iicwjdEek8QEyH1x5pzZVRZMwy5nri3/ik8mKHQS+76lNvsB9cdG7KfkK l7VRRUbxDpiUE6GVbey79vVwfS46o6PpkHG/RqGKWTJ+k9AsD9eLvUDeCA+8K6BD6O04 7mfiM1410E8ehvkDTWL2r2VH27Qbdg8JxyHkutHcbxp+iaKL1cMZlMWFQLG5wQDp1T2A Y7oWiS+ZEsJKTn9JRdrZLsAAIUdzgweJbbXbCMCiVcySHGXqcxKUjFMX+vwx+SmvUBxa DZxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eSF3iGXX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r15-20020a6560cf000000b005c67e7f7917si9801959pgv.409.2023.12.13.10.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eSF3iGXX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8C080826E8F6; Wed, 13 Dec 2023 10:01:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378894AbjLMSBg (ORCPT + 99 others); Wed, 13 Dec 2023 13:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233692AbjLMSBb (ORCPT ); Wed, 13 Dec 2023 13:01:31 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3E783 for ; Wed, 13 Dec 2023 10:01:37 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-35d67aa6951so20728525ab.0 for ; Wed, 13 Dec 2023 10:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490497; x=1703095297; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IE6mE6pjbGov9LkkEhCEwGDUbXlSJbMapTwV75Z3EGc=; b=eSF3iGXXOC2kQ3n5Nvjxs6TXImtBZ+93Z/bZSIAOBmGzEVcfVUtzn/EVhDmjEsflaq MZmH+PNqez1eEtLBjr+QZtLdrvyS19dkt6p8/fahgjp3jxHcDCYZUNQo9zxtMR7vDHe5 Bncbrq6uoJ/qVNICvi3OH76+02VUHERHM3VFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490497; x=1703095297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IE6mE6pjbGov9LkkEhCEwGDUbXlSJbMapTwV75Z3EGc=; b=aaD6mzys0O/aqEXtnIbECOwKbdTr0LjdpKdhmg+7WodoLIzWSm8PmXTKajWhhLgb+j z6FilWaSUCC7+SGBwQMycWb4KRaXhxbVJ0JVMx1zFxun2DT4+owQYVsrzvRQdCb8OxKG 2MTc3L0z7GM+MP3/oUh2aTSs11KMdmp1ZQvpEOdTim7IrGntq1fALcnHdJgGpsjpGqZe 8kKx1bFMafmKMEFJJyEk/yI8E2nhoHFo5S6dO6KSHkuqxL8nuta5lKfGUYHIUVRX6KJZ 96JhrBeY75S4tH62aV6d/cm75B6xQkp9BoST1gn6brdOCVXwMF2Np2BN2CgClVUksuol vfGg== X-Gm-Message-State: AOJu0Yz2CZFBTE5UmP5ppiXeCITMKEy17lgmjFEwjgHdIAmya2cmJO62 y2xPFjgv5SesesiNSO9/1ntu4639zJrfux3YTcI= X-Received: by 2002:a05:6e02:b45:b0:35d:59b3:2f86 with SMTP id f5-20020a056e020b4500b0035d59b32f86mr7479369ilu.27.1702490496668; Wed, 13 Dec 2023 10:01:36 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:36 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Frank Rowand , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v1 3/6] of: irq: add wake capable bit to of_irq_resource() Date: Wed, 13 Dec 2023 11:00:21 -0700 Message-ID: <20231213110009.v1.3.I29b26a7f3b80fac0a618707446a10b6cc974fdaf@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> References: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:01:53 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190696525095104 X-GMAIL-MSGID: 1785190696525095104 Add wake capability information to the irq resource. Wake capability is assumed based on conventions provided in the devicetree wakeup-source binding documentation. An interrupt is considered wake capable if the following are true: 1. a wakeup-source property exits in the same device node as the interrupt. 2. No dedicated irq is defined, or the irq is marked as dedicated by setting its interrupt-name to "wakeup". The wakeup-source documentation states that dedicated interrupts can use device specific interrupt names and device drivers are still welcome to use their own naming schemes. This api is provided as a helper if one is willing to conform to the above conventions. The ACPI subsystems already provides similar apis that allow one to query the wake capability of an irq. This brings feature parity to the devicetree. Signed-off-by: Mark Hasemeyer --- drivers/of/irq.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 174900072c18c..633711bc32953 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -383,11 +383,39 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar } EXPORT_SYMBOL_GPL(of_irq_parse_one); +/** + * __of_irq_wake_capable - Determine whether a given irq index is wake capable + * + * The irq is considered wake capable if the following are true: + * 1. wakeup-source property exists + * 2. no dedicated wakeirq exists OR provided irq index is a dedicated wakeirq + * + * This logic assumes the provided irq index is valid. + * + * @dev: pointer to device tree node + * @index: zero-based index of the irq + * Return: True if provided irq index for #dev is wake capable. False otherwise. + */ +static bool __of_irq_wake_capable(const struct device_node *dev, int index) +{ + int wakeindex; + + if (!of_property_read_bool(dev, "wakeup-source")) + return false; + + wakeindex = of_property_match_string(dev, "interrupt-names", "wakeup"); + return wakeindex < 0 || wakeindex == index; +} + /** * of_irq_to_resource - Decode a node's IRQ and return it as a resource * @dev: pointer to device tree node * @index: zero-based index of the irq * @r: pointer to resource structure to return result into. + * + * Return: Linux IRQ number on success, or 0 on the IRQ mapping failure, or + * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case + * of any other failure. */ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) { @@ -411,6 +439,8 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) r->start = r->end = irq; r->flags = IORESOURCE_IRQ | irqd_get_trigger_type(irq_get_irq_data(irq)); + if (__of_irq_wake_capable(dev, index)) + r->flags |= IORESOURCE_IRQ_WAKECAPABLE; r->name = name ? name : of_node_full_name(dev); } From patchwork Wed Dec 13 18:00:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 178226 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7961009dys; Wed, 13 Dec 2023 10:02:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH3fPuoeXTAWmEc+SjqllEIj6D1Qh+1nPAd1UwnCipphSSp72tUPdh4PFgV9wWztoPlLdS X-Received: by 2002:a05:6a20:748f:b0:18f:97c:9769 with SMTP id p15-20020a056a20748f00b0018f097c9769mr10404151pzd.81.1702490522302; Wed, 13 Dec 2023 10:02:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490522; cv=none; d=google.com; s=arc-20160816; b=rJ3FlH8fKVOcVcdZDHgaI4IL0aszSVk9cyR3jN7Dtu0g+ZnkVjMYSo0T5mOjmTaU8H VX9fu4jCyt2+V5MGObuLb37GbmH7ySooz/ABEymAyMODFLHNksvmmYuSOg+P9a++6EPK s9UqybRd7lyK66vrBdARsYEa09lOu+mDr+CrhAumcp9l9SqMsDsbTHsI/ZbQEcuragXt Uimzb2/JfqL0+HsPzVLX7tblLfw5x9OgQHWVduQ0oWto68OzZ47Q0x9OgP0J6VwkEXGB OxS5zxq9rvbJ38Tyf7idKYR3vDv8CktjBIvHtD6SCQXMHZHTSr45N8664BLyC7/BL3Sj HkMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/W+jCmhtVUK3Oan20pcyAoaX1l8QrXEMpfoAzq+htTI=; fh=zxG5iud9xF1D6IY8H/gUMSGI5vQPvUvLe4axMqsZymY=; b=wFFAob38CuLhiWL8cDbi6J2aa8DqCGlQxG/pLcoL8hc0xbwcBmlsOn+tE2agmCZ3ZN zAI8uIMc+URX/ziykZGMrdrDp6Dw3XPdnh3ZO5ELe3+fG3eUtilviO4IHfvURBJpSDHE vFY40hKlDD8vEO91nhOCkayt3AK/DdIoIAKf+FpLuPUWvqvmTtMfJZh0Z/NyV4MCdBLn 5GXP26SvH4j9cYF7iTPREYGGiARdNvAhQn89TtQwW4MZcPCy7HeKip67B7R+UvBxHt1x 5N1EeLjHRW18FFTbvm7zTYWE3ZCmlzTzbLmaBk/7SpxNN6KZGlT9Z9S9V6tvyCu6+RqX 5Bjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K3uuzmd2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id cm12-20020a056a020a0c00b005c6b59c91basi10266906pgb.661.2023.12.13.10.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:02:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K3uuzmd2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1DF0F826E625; Wed, 13 Dec 2023 10:01:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378958AbjLMSBj (ORCPT + 99 others); Wed, 13 Dec 2023 13:01:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbjLMSBc (ORCPT ); Wed, 13 Dec 2023 13:01:32 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07A510A for ; Wed, 13 Dec 2023 10:01:38 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-35f71face1bso4229275ab.1 for ; Wed, 13 Dec 2023 10:01:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490498; x=1703095298; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/W+jCmhtVUK3Oan20pcyAoaX1l8QrXEMpfoAzq+htTI=; b=K3uuzmd2WbSz2A8XCRYtvEjPlaG28elxyT2ZLFTIIkr/wVGwhpPttmE4sc45Yul2l1 Mu09fcLdOaHgpRyCeFEW0nInQYk8IhvmCIUrmlzehtkTpv9e8DgAca8nShBj6BRarEZm 1qyT5jSkVXLDbTm9jcz9q9IogBPwKcLYoQ2Fo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490498; x=1703095298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/W+jCmhtVUK3Oan20pcyAoaX1l8QrXEMpfoAzq+htTI=; b=LrqnMV8pxJveLHvwEKlsM7I0zXL2vjb0IuyxZtEqW8l+SDiiqj7T9PSXM62oYVeY1E KKxxO1JVzin2L4QuDYj3m8r4iuA9cONTKe6JTgXXVyNMDduvRi+BdwyF5Az22E+TtAER 7jCHBEQTEHhqeQW0Lf+AYEDXWo1n9AF+ZUVkbIJrKJjHA43X4zc02zIs9fSAB/KltKFl FkEtoxizUm9gkTICCAYLHd7ZI7r+AU9UZnwH4lPtnbhNq2tTnGRZnDwYauRnCY8zmCqk WUDbXwkdcZWlllivqIlgxBJC6BeTb6bjmX29CxnDKKELmkIT1xH3QtNshyt8aUEUhwST ZeKw== X-Gm-Message-State: AOJu0Yx00sQOJ6vUxVaIECmDa+UgZZfakmkKa7nl4ljGq9T9DY6PsuaD +nPN+/puX4V/cXMAnxmZSQzZEamAJ/S6PpcyWmY= X-Received: by 2002:a92:d948:0:b0:35d:59a2:92ab with SMTP id l8-20020a92d948000000b0035d59a292abmr7913891ilq.63.1702490497991; Wed, 13 Dec 2023 10:01:37 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:37 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Frank Rowand , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v1 4/6] of: irq: Add default implementation for of_irq_to_resource() Date: Wed, 13 Dec 2023 11:00:22 -0700 Message-ID: <20231213110009.v1.4.I31d4dd6a7e5a3e5eee05c87b358e63cd1aa0e467@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> References: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:01:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190702117690262 X-GMAIL-MSGID: 1785190702117690262 Similar to of_irq_to_resource_table(), add a default implementation of of_irq_to_resource() for systems that don't have CONFIG_OF_IRQ defined. Signed-off-by: Mark Hasemeyer --- include/linux/of_irq.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index d6d3eae2f1452..817c7510082cb 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -34,8 +34,6 @@ static inline int of_irq_parse_oldworld(const struct device_node *device, int in extern int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq); extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data); -extern int of_irq_to_resource(struct device_node *dev, int index, - struct resource *r); #ifdef CONFIG_OF_IRQ extern void of_irq_init(const struct of_device_id *matches); @@ -44,6 +42,8 @@ extern int of_irq_parse_one(struct device_node *device, int index, extern int of_irq_count(struct device_node *dev); extern int of_irq_get(struct device_node *dev, int index); extern int of_irq_get_byname(struct device_node *dev, const char *name); +extern int of_irq_to_resource(struct device_node *dev, int index, + struct resource *r); extern int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int nr_irqs); extern struct device_node *of_irq_find_parent(struct device_node *child); @@ -76,6 +76,11 @@ static inline int of_irq_get_byname(struct device_node *dev, const char *name) { return 0; } +static inline int of_irq_to_resource(struct device_node *dev, int index, + struct resource *r) +{ + return 0; +} static inline int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int nr_irqs) { From patchwork Wed Dec 13 18:00:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 178227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7961256dys; Wed, 13 Dec 2023 10:02:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjAbajcqZM2B4TG0CjHAFZREenkYgF2kJaOIL7FpJvuk0MscJT5edVOpy1Ddur/KwTnosK X-Received: by 2002:a17:90a:8985:b0:286:c7df:d702 with SMTP id v5-20020a17090a898500b00286c7dfd702mr3259940pjn.4.1702490536173; Wed, 13 Dec 2023 10:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490536; cv=none; d=google.com; s=arc-20160816; b=KVex2eCjag3eTGftLhE6bQzzrX86JQb8zJoLqhA2B6RlkvUZHe9MYjx033OYzbnfE5 ofBjNrrSI0UawHUnXu21ArgCiV0MIns26vZjGsBM+4ORQAk9Uo1NjmzDgGxULBjKKQAT oYgZM03EWJX+zaj30CkLAl3+XkHFLB3qX3Xyg+7i/DiB5E4aQCmXGozVltfzuS/hVThs NjcCRmBsZkJ9YJE/YJaiT+zUzr0LwoVZ29ACNrGm7btjefoyGpWbvwLNDJvAfjr8n3lS Qi0N+Et3jvjWAlChlH7ZuD2pPYpZbu4pfc0dGZd7MnS3EO6+5oumSIhT3xY7yTIhZgrB IsZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G8hy9U0u31jlEXJskU1SvJZS3MimHWM0Shv24H/JxDk=; fh=x7dnfGEr8X+mlHFKbQCgMuJRyBdc1kmIAgQUIVRw4Lk=; b=H6xa6r+lxkTXvUBWIamLs8W3vB6L2vDcZ5LmPMMqAsQ+UIK/Wp1VY7wflzMN+qfdSr BMpsSxZTQH/g4r5IkGIlZNvE5ZrfOCbopdhbqTDL10k2spJEJ7kEd556er+7QPdNUOvI r1IbhLtqTO0oCjG1YPH2XWOj/PQbK6yTXQN7YhhyeLJzUIXauuHj8Bp9goxwIa72uTIO l2hfq2/WShTCRsJPnc41OHxcZiLboFnI/KzyB6GxPY84pb5CsrMjaqRVv9L+xD+vOtdq nVNdfO0PLlVhpISn87Z7/SoHWtmppemxYEI/5bH/ZDpGLnL9Hq4ICrdZ45HJ8bSU6PLZ HElA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jQEeNqHa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j19-20020a17090a7e9300b0028699acfb2bsi11109350pjl.53.2023.12.13.10.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:02:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jQEeNqHa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 66B8F826EB59; Wed, 13 Dec 2023 10:02:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379341AbjLMSBm (ORCPT + 99 others); Wed, 13 Dec 2023 13:01:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378704AbjLMSBe (ORCPT ); Wed, 13 Dec 2023 13:01:34 -0500 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD35F3 for ; Wed, 13 Dec 2023 10:01:39 -0800 (PST) Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-35f56f06142so17764045ab.1 for ; Wed, 13 Dec 2023 10:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490499; x=1703095299; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G8hy9U0u31jlEXJskU1SvJZS3MimHWM0Shv24H/JxDk=; b=jQEeNqHaeqvEnFMbR9H2xtfqblBPVg7S0SdUBk6zV+bO7Ux2TbUbWZCC1nclJ1lwDc ZYWpDW4ITC6cOHx/eABo5M55KATMCwsTBQIhnhN0HO9IXtJPZKFDcZ1iz4U55zhYKkvB 6J3DQvlxUoWKpRg7zOhW16wRD6S3e0rOgoOF4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490499; x=1703095299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G8hy9U0u31jlEXJskU1SvJZS3MimHWM0Shv24H/JxDk=; b=wx62O2Ask2A/IjEEONbhyGULo/WNg3xQ5j/NopWjMKq76gWCo03OpTbsBuBL2pywdx srmWI0fpoD4NHlmFHwICsE3qjcMJp66m+WHZBcqbqi2nDchtmv65KTFENiRcMEHaGgAN wXASX8TS9MgBwiS5nU7zd70JjI0S8n9jzreqHU1HtBYg4dhJCkoLolmy9LZndQY0naH1 EfzbBnJDfyPG9yKuPpVJZi9QJdnFRAIOXKpA3qbAE3pFYicanhCKhvyk6NkISr9/BFrT 6XFnIrsNcjtk16RDrtfhIUYZFNqoMcuUUzz6KL62be7Elrc2N6Kezxe4khUJClUlDFCc FoLw== X-Gm-Message-State: AOJu0YyxnuI7UACRxlCOchda7QVK5rbpJgjs0LUSNKcTqga71HJtE7ty EAKX73fnDU97oEnFEpfpoDPW4Zte5Rvlf2PYku0= X-Received: by 2002:a05:6e02:1d84:b0:35d:5995:7993 with SMTP id h4-20020a056e021d8400b0035d59957993mr10706467ila.45.1702490499016; Wed, 13 Dec 2023 10:01:39 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:38 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , David Gow , Greg Kroah-Hartman , Mark Brown , "Rafael J. Wysocki" , Takashi Iwai , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH v1 5/6] platform: Modify platform_get_irq_optional() to use resource Date: Wed, 13 Dec 2023 11:00:23 -0700 Message-ID: <20231213110009.v1.5.Ife9ebad2bbfbab3a05e90040f344d750aa0aac7e@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> References: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:02:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190716258805983 X-GMAIL-MSGID: 1785190716258805983 Unify handling of ACPI, GPIO, devictree, and platform resource interrupts in platform_get_irq_optional(). Each of these subsystems provide their own apis which provide IRQ information as a struct resource. This simplifies the logic of the function and allows callers to get more information about the irq by looking at the resource flags. For example, whether or not an irq is wake capable. Rename the function to platform_get_irq_resource() to better describe the function's new behavior. Signed-off-by: Mark Hasemeyer --- drivers/base/platform.c | 78 ++++++++++++++++++--------------- include/linux/platform_device.h | 9 +++- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 76bfcba250039..6b58bde776d4f 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -151,9 +151,10 @@ EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname); #endif /* CONFIG_HAS_IOMEM */ /** - * platform_get_irq_optional - get an optional IRQ for a device + * platform_get_irq_resource - get an IRQ for a device and populate resource struct * @dev: platform device * @num: IRQ number index + * @r: pointer to resource to populate with irq information. It is not modified on failure. * * Gets an IRQ for a platform device. Device drivers should check the return * value for errors so as to not pass a negative integer value to the @@ -162,59 +163,47 @@ EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname); * * For example:: * - * int irq = platform_get_irq_optional(pdev, 0); + * int irq = platform_get_irq_resource(pdev, 0, &res); * if (irq < 0) * return irq; * * Return: non-zero IRQ number on success, negative error number on failure. */ -int platform_get_irq_optional(struct platform_device *dev, unsigned int num) +int platform_get_irq_resource(struct platform_device *dev, unsigned int num, struct resource *r) { int ret; #ifdef CONFIG_SPARC /* sparc does not have irqs represented as IORESOURCE_IRQ resources */ if (!dev || num >= dev->archdata.num_irqs) - goto out_not_found; + return -ENXIO; ret = dev->archdata.irqs[num]; + if (ret >= 0) + *r = (struct resource)DEFINE_RES_IRQ(ret); goto out; #else - struct resource *r; + struct resource *platform_res; if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) { - ret = of_irq_get(dev->dev.of_node, num); + ret = of_irq_to_resource(dev->dev.of_node, num, r); if (ret > 0 || ret == -EPROBE_DEFER) goto out; } - r = platform_get_resource(dev, IORESOURCE_IRQ, num); - if (has_acpi_companion(&dev->dev)) { - if (r && r->flags & IORESOURCE_DISABLED) { - ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r); - if (ret) - goto out; - } - } - - /* - * The resources may pass trigger flags to the irqs that need - * to be set up. It so happens that the trigger flags for - * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER* - * settings. - */ - if (r && r->flags & IORESOURCE_BITS) { - struct irq_data *irqd; - - irqd = irq_get_irq_data(r->start); - if (!irqd) - goto out_not_found; - irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); - } - - if (r) { + platform_res = platform_get_resource(dev, IORESOURCE_IRQ, num); + if (platform_res && !(platform_res->flags & IORESOURCE_DISABLED)) { + *r = *platform_res; ret = r->start; goto out; } + if (has_acpi_companion(&dev->dev)) { + ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r); + if (!ret || ret == -EPROBE_DEFER) { + ret = ret ?: r->start; + goto out; + } + } + /* * For the index 0 interrupt, allow falling back to GpioInt * resources. While a device could have both Interrupt and GpioInt @@ -223,21 +212,38 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num) * allows a common code path across either kind of resource. */ if (num == 0 && has_acpi_companion(&dev->dev)) { - ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num); + ret = acpi_dev_get_gpio_irq_resource(ACPI_COMPANION(&dev->dev), NULL, + num, r); /* Our callers expect -ENXIO for missing IRQs. */ - if (ret >= 0 || ret == -EPROBE_DEFER) + if (!ret || ret == -EPROBE_DEFER) { + ret = ret ?: r->start; goto out; + } } - #endif -out_not_found: ret = -ENXIO; out: if (WARN(!ret, "0 is an invalid IRQ number\n")) return -EINVAL; + + /* + * The resources may pass trigger flags to the irqs that need + * to be set up. It so happens that the trigger flags for + * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER* + * settings. + */ + if (ret > 0 && r->flags & IORESOURCE_BITS) { + struct irq_data *irqd; + + irqd = irq_get_irq_data(r->start); + if (!irqd) + ret = -ENXIO; + else + irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); + } return ret; } -EXPORT_SYMBOL_GPL(platform_get_irq_optional); +EXPORT_SYMBOL_GPL(platform_get_irq_resource); /** * platform_get_irq - get an IRQ for a device diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 7a41c72c19591..cdaddab4d9241 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -101,7 +101,14 @@ devm_platform_ioremap_resource_byname(struct platform_device *pdev, #endif extern int platform_get_irq(struct platform_device *, unsigned int); -extern int platform_get_irq_optional(struct platform_device *, unsigned int); +extern int platform_get_irq_resource(struct platform_device *dev, unsigned int num, + struct resource *r); +static inline int platform_get_irq_optional(struct platform_device *dev, unsigned int num) +{ + struct resource r; + + return platform_get_irq_resource(dev, num, &r); +} extern int platform_irq_count(struct platform_device *); extern int devm_platform_get_irqs_affinity(struct platform_device *dev, struct irq_affinity *affd, From patchwork Wed Dec 13 18:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Hasemeyer X-Patchwork-Id: 178228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7961419dys; Wed, 13 Dec 2023 10:02:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZ/6YIktYBjASga5R6GmpOnxadkTjg5AlBRU3Ldc3wCQkaShPooTHkIUVngKVfWBWsrad+ X-Received: by 2002:a05:6e02:78f:b0:35d:8420:5db7 with SMTP id q15-20020a056e02078f00b0035d84205db7mr5632709ils.111.1702490545884; Wed, 13 Dec 2023 10:02:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702490545; cv=none; d=google.com; s=arc-20160816; b=t9Qc5gl0dQiHqUTDzZQbiKl4jS+M3VcF3gRj0Iz4K+gg/68WxBkvoT+184zAqQn/yI DDuM136FeKYvJ9c920+gexj6oGpHIYhpZQvrV0htm/MIcKzqwPvniTDf/LNxEEbvz2yY jp2wQUta1y0f9H/FFE0vjalXiQbG2674DGOx4nt5ty4U8Q3gm6o1Mk7Sgh+UDlSuixB+ OzE8TPktYOo4uDbBbGwPcIg1CSvXgD2pvDwEeau4Q2kUmwKukGQM7pEQrJQ8Tf9hplMf Gtcw8qXAWSxQEoLmesXkxAsSFlTckiFWf+0bNaYf2IHEH9XzMrzOG5QYaxrp0SpNfIQS 0GuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A5qK8QS6dwScbIe3rQCRc5uzPcj/O6N72QtvEWBOA2c=; fh=ZptTfeuY6CfgCt7MKPB+2UrAWUX28L4tAZlYI4SqQY4=; b=cfo3zQgYTg1MF78UAbaCsMSed2yIN7SwRSmJZtgQ5Y7VhIzTCW0CI36ber7L/TrPyV QAVe1oPbzmt4wCqMJ9HKGIjr6DL81ohDhSW5/iCKeZxsWXsBHhLvo3Vgl2nsHdzA+ZLy Rf8yNGg7KwD99ognlyGloSEf6DvT+IBIjalWBxONbXMYSgrHwlBjlGg/62U6XzAYEXVr AmNAkXJABJAsKrB/iIG17J5CHP/BHLAioCC9hI51TBOBi9iNpPgr8psLroEKDPMgH28T apGQZCArketxLiGNLcXQoWHaH4pYr6JwnOmQyhK+vZeU3wS3XmrN1Wc4+ylWnP7XzMdG aHrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L+u1mDoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id o66-20020a634145000000b005c1eadbacb3si9677341pga.104.2023.12.13.10.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:02:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L+u1mDoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7B341826E8FE; Wed, 13 Dec 2023 10:02:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378965AbjLMSBs (ORCPT + 99 others); Wed, 13 Dec 2023 13:01:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378951AbjLMSBj (ORCPT ); Wed, 13 Dec 2023 13:01:39 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B440DC for ; Wed, 13 Dec 2023 10:01:41 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-35f6993ee96so8274345ab.1 for ; Wed, 13 Dec 2023 10:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702490500; x=1703095300; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A5qK8QS6dwScbIe3rQCRc5uzPcj/O6N72QtvEWBOA2c=; b=L+u1mDoOzdc9sgPAeI1y4kLKqvddgUALb7hBH63ECeetoWifVdm05MTaLkvg2vQLu4 bawTNXI1nuG5281ECpdY8g9Tdfx0AKnRx+B1IcKzXNUFBWTAkFahaomUmcGOKWY9/7wE QCjPRew/+n8ojf7QY2nFMmUbk8At7s+/+RY4Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702490500; x=1703095300; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A5qK8QS6dwScbIe3rQCRc5uzPcj/O6N72QtvEWBOA2c=; b=MJ6a/j0QOmyXe60t28IJQzx8vEiXhS0+yjHpR5nMNMdB54O5ld0Sb03YUXY2nBV7NH IUrHp+bAE+x1udin/NErFfW2ykd9hb/vUUcKwZut3X5dv1XBUYewLwxx/Snz8GX+3Mwl oSQPa87qQOv5uDE5/faOLYLO7hEp/uz3AxBb4xTuTq7Sf0Izmwlc7mH7cuBAXRT6Uqmu gChpZveLqvfXIciNsKBIMqaWVXBv7u0kd/OZ7eWp5p82EOx+kbbkaoyYBWUN5Tn+nM8D w0W6sjm9XPImMmlu9D1KSHqmy/GFQjGWeWNsas2MdmLWiEDKYj2V2z1rIQKlOx04xOdc XvAQ== X-Gm-Message-State: AOJu0Yxeo70umI1yN379Jc9NjaQZYCGbMUISb9ubuBQZwcYK7V5BMyd2 ayKVnukn48pTD66xL/yhcur6FxfMcU0Xg+9CcD8= X-Received: by 2002:a05:6e02:1a6e:b0:35d:5995:904d with SMTP id w14-20020a056e021a6e00b0035d5995904dmr7513188ilv.64.1702490500074; Wed, 13 Dec 2023 10:01:40 -0800 (PST) Received: from markhas1.corp.google.com ([100.107.108.224]) by smtp.gmail.com with ESMTPSA id o28-20020a02cc3c000000b0046671f9717csm3161206jap.109.2023.12.13.10.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:01:39 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: Raul Rangel , Mark Hasemeyer , Benson Leung , Bhanu Prakash Maiya , Chen-Yu Tsai , Guenter Roeck , Prashant Malani , Rob Barnes , Tzung-Bi Shih , chrome-platform@lists.linux.dev Subject: [PATCH v1 6/6] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq Date: Wed, 13 Dec 2023 11:00:24 -0700 Message-ID: <20231213110009.v1.6.Ieee574a0e94fbaae01fd6883ffe2ceeb98d7df28@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> References: <20231213110009.v1.1.Ifd0903f1c351e84376d71dbdadbd43931197f5ea@changeid> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:02:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785190726830087581 X-GMAIL-MSGID: 1785190726830087581 The cros ec driver is manually managing the wake irq by calling enable_irq_wake/disable_irq_wake during suspend/resume. Modify the driver to use the power management subsystem to manage the wakeirq. The wake capability of the interrupt is provided by the underlying firmware/device tree. Some Chromebooks rely solely on the ec_sync pin to wake the AP but they do not specify the interrupt as wake capable in the ACPI _CRS or device tree. For LPC/ACPI based systems a DMI quirk is introduced listing boards whose firmware should not be trusted to provide correct wake capable values. The irq wake logic was added on an interface basis (lpc, spi, uart) as opposed to adding it to cros_ec.c because the i2c subsystem already does this work on our behalf. Signed-off-by: Mark Hasemeyer --- drivers/platform/chrome/cros_ec.c | 9 ---- drivers/platform/chrome/cros_ec_lpc.c | 51 +++++++++++++++++++-- drivers/platform/chrome/cros_ec_spi.c | 48 +++++++++++++++---- drivers/platform/chrome/cros_ec_uart.c | 34 ++++++++++++-- include/linux/platform_data/cros_ec_proto.h | 2 - 5 files changed, 116 insertions(+), 28 deletions(-) diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c index badc68bbae8cc..f24d2f2084399 100644 --- a/drivers/platform/chrome/cros_ec.c +++ b/drivers/platform/chrome/cros_ec.c @@ -353,12 +353,6 @@ EXPORT_SYMBOL(cros_ec_suspend_prepare); static void cros_ec_disable_irq(struct cros_ec_device *ec_dev) { - struct device *dev = ec_dev->dev; - if (device_may_wakeup(dev)) - ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq); - else - ec_dev->wake_enabled = false; - disable_irq(ec_dev->irq); ec_dev->suspended = true; } @@ -440,9 +434,6 @@ static void cros_ec_enable_irq(struct cros_ec_device *ec_dev) ec_dev->suspended = false; enable_irq(ec_dev->irq); - if (ec_dev->wake_enabled) - disable_irq_wake(ec_dev->irq); - /* * Let the mfd devices know about events that occur during * suspend. This way the clients know what to do with them. diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c index ed498278a223f..d5beae1b779d3 100644 --- a/drivers/platform/chrome/cros_ec_lpc.c +++ b/drivers/platform/chrome/cros_ec_lpc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,27 @@ static struct lpc_driver_ops cros_ec_lpc_ops = { }; static struct platform_device *pdev_extcon; +static const struct dmi_system_id untrusted_fw_irq_wake_capable[] = { + { + .ident = "Brya", + .matches = { + DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya") + } + }, + { + .ident = "Brask", + .matches = { + DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brask") + } + } +} +MODULE_DEVICE_TABLE(dmi, untrusted_fw_irq_wake_capable); + +static bool cros_ec_should_force_irq_wake_capable(void) +{ + return dmi_first_match(untrusted_fw_irq_wake_capable) != NULL; +} + /* * A generic instance of the read function of struct lpc_driver_ops, used for * the LPC EC. @@ -352,9 +374,11 @@ static void cros_ec_lpc_acpi_notify(acpi_handle device, u32 value, void *data) static int cros_ec_lpc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + bool irq_wake = false; struct acpi_device *adev; acpi_status status; struct cros_ec_device *ec_dev; + struct resource irqres; u8 buf[2] = {}; int irq, ret; @@ -430,20 +454,36 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) * Some boards do not have an IRQ allotted for cros_ec_lpc, * which makes ENXIO an expected (and safe) scenario. */ - irq = platform_get_irq_optional(pdev, 0); - if (irq > 0) + irq = platform_get_irq_resource(pdev, 0, &irqres); + if (irq > 0) { ec_dev->irq = irq; - else if (irq != -ENXIO) { + if (cros_ec_should_force_irq_wake_capable()) + irq_wake = true; + else + irq_wake = irqres.flags & IORESOURCE_IRQ_WAKECAPABLE; + dev_dbg(dev, "IRQ: %i, wake_capable: %i\n", irq, irq_wake); + } else if (irq != -ENXIO) { dev_err(dev, "couldn't retrieve IRQ number (%d)\n", irq); return irq; } ret = cros_ec_register(ec_dev); if (ret) { - dev_err(dev, "couldn't register ec_dev (%d)\n", ret); + dev_err_probe(dev, ret, "couldn't register ec_dev (%d)\n", ret); return ret; } + if (irq_wake) { + ret = device_init_wakeup(dev, true); + if (ret) { + dev_err_probe(dev, ret, "Failed to init device for wakeup"); + return ret; + } + ret = dev_pm_set_wake_irq(dev, irq); + if (ret) + return ret; + } + /* * Connect a notify handler to process MKBP messages if we have a * companion ACPI device. @@ -472,6 +512,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) static int cros_ec_lpc_remove(struct platform_device *pdev) { struct cros_ec_device *ec_dev = platform_get_drvdata(pdev); + struct device *dev = ec_dev->dev; struct acpi_device *adev; platform_device_unregister(pdev_extcon); @@ -481,6 +522,8 @@ static int cros_ec_lpc_remove(struct platform_device *pdev) acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, cros_ec_lpc_acpi_notify); + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); cros_ec_unregister(ec_dev); return 0; diff --git a/drivers/platform/chrome/cros_ec_spi.c b/drivers/platform/chrome/cros_ec_spi.c index 3e88cc92e8192..f99296ab0b8ec 100644 --- a/drivers/platform/chrome/cros_ec_spi.c +++ b/drivers/platform/chrome/cros_ec_spi.c @@ -7,9 +7,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -70,6 +72,7 @@ * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that * is sent when we want to turn off CS at the end of a transaction. * @high_pri_worker: Used to schedule high priority work. + * @irq_wake: Whether or not irq assertion should wake the system. */ struct cros_ec_spi { struct spi_device *spi; @@ -77,6 +80,7 @@ struct cros_ec_spi { unsigned int start_of_msg_delay; unsigned int end_of_msg_delay; struct kthread_worker *high_pri_worker; + bool irq_wake; }; typedef int (*cros_ec_xfer_fn_t) (struct cros_ec_device *ec_dev, @@ -689,12 +693,17 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev, return cros_ec_xfer_high_pri(ec_dev, ec_msg, do_cros_ec_cmd_xfer_spi); } -static void cros_ec_spi_dt_probe(struct cros_ec_spi *ec_spi, struct device *dev) +static void cros_ec_spi_dt_probe(struct cros_ec_spi *ec_spi, struct spi_device *spi) { - struct device_node *np = dev->of_node; + struct cros_ec_device *ec_dev = spi_get_drvdata(spi); + struct device_node *np = spi->dev.of_node; + struct resource irqres; u32 val; int ret; + if (!np) + return; + ret = of_property_read_u32(np, "google,cros-ec-spi-pre-delay", &val); if (!ret) ec_spi->start_of_msg_delay = val; @@ -702,6 +711,17 @@ static void cros_ec_spi_dt_probe(struct cros_ec_spi *ec_spi, struct device *dev) ret = of_property_read_u32(np, "google,cros-ec-spi-msg-delay", &val); if (!ret) ec_spi->end_of_msg_delay = val; + + if (ec_dev->irq > 0) { + ret = of_irq_to_resource(np, 0, &irqres); + if (ret != ec_dev->irq) { + dev_err(&spi->dev, "irq mismatch detecting wake capability(%d != %d)\n", + ret, ec_dev->irq); + return; + } + ec_spi->irq_wake = irqres.flags & IORESOURCE_IRQ_WAKECAPABLE; + dev_dbg(&spi->dev, "IRQ: %i, wake_capable: %i\n", ec_dev->irq, ec_spi->irq_wake); + } } static void cros_ec_spi_high_pri_release(void *worker) @@ -753,9 +773,6 @@ static int cros_ec_spi_probe(struct spi_device *spi) if (!ec_dev) return -ENOMEM; - /* Check for any DT properties */ - cros_ec_spi_dt_probe(ec_spi, dev); - spi_set_drvdata(spi, ec_dev); ec_dev->dev = dev; ec_dev->priv = ec_spi; @@ -768,6 +785,9 @@ static int cros_ec_spi_probe(struct spi_device *spi) sizeof(struct ec_response_get_protocol_info); ec_dev->dout_size = sizeof(struct ec_host_request); + /* Check for any DT properties */ + cros_ec_spi_dt_probe(ec_spi, spi); + ec_spi->last_transfer_ns = ktime_get_ns(); err = cros_ec_spi_devm_high_pri_alloc(dev, ec_spi); @@ -776,19 +796,31 @@ static int cros_ec_spi_probe(struct spi_device *spi) err = cros_ec_register(ec_dev); if (err) { - dev_err(dev, "cannot register EC\n"); + dev_err_probe(dev, err, "cannot register EC\n"); return err; } - device_init_wakeup(&spi->dev, true); + if (ec_spi->irq_wake) { + err = device_init_wakeup(dev, true); + if (err) { + dev_err_probe(dev, err, "Failed to init device for wakeup\n"); + return err; + } + err = dev_pm_set_wake_irq(dev, ec_dev->irq); + if (err) + dev_err_probe(dev, err, "Failed to set irq(%d) for wake\n", ec_dev->irq); + } - return 0; + return err; } static void cros_ec_spi_remove(struct spi_device *spi) { struct cros_ec_device *ec_dev = spi_get_drvdata(spi); + struct device *dev = ec_dev->dev; + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); cros_ec_unregister(ec_dev); } diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c index 788246559bbba..54255f523d8b7 100644 --- a/drivers/platform/chrome/cros_ec_uart.c +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,7 @@ struct response_info { * @baudrate: UART baudrate of attached EC device. * @flowcontrol: UART flowcontrol of attached device. * @irq: Linux IRQ number of associated serial device. + * @irq_wake: Whether or not irq assertion should wake the system. * @response: Response info passing between cros_ec_uart_pkt_xfer() * and cros_ec_uart_rx_bytes() */ @@ -78,6 +80,7 @@ struct cros_ec_uart { u32 baudrate; u8 flowcontrol; u32 irq; + bool irq_wake; struct response_info response; }; @@ -225,8 +228,10 @@ static int cros_ec_uart_resource(struct acpi_resource *ares, void *data) static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart) { int ret; + struct resource irqres; LIST_HEAD(resources); - struct acpi_device *adev = ACPI_COMPANION(&ec_uart->serdev->dev); + struct device *dev = &ec_uart->serdev->dev; + struct acpi_device *adev = ACPI_COMPANION(dev); ret = acpi_dev_get_resources(adev, &resources, cros_ec_uart_resource, ec_uart); if (ret < 0) @@ -235,12 +240,13 @@ static int cros_ec_uart_acpi_probe(struct cros_ec_uart *ec_uart) acpi_dev_free_resource_list(&resources); /* Retrieve GpioInt and translate it to Linux IRQ number */ - ret = acpi_dev_gpio_irq_get(adev, 0); + ret = acpi_dev_get_gpio_irq_resource(adev, NULL, 0, &irqres); if (ret < 0) return ret; - ec_uart->irq = ret; - dev_dbg(&ec_uart->serdev->dev, "IRQ number %d\n", ec_uart->irq); + ec_uart->irq = irqres.start; + ec_uart->irq_wake = irqres.flags & IORESOURCE_IRQ_WAKECAPABLE; + dev_dbg(dev, "IRQ: %i, wake_capable: %i\n", ec_uart->irq, ec_uart->irq_wake); return 0; } @@ -302,13 +308,31 @@ static int cros_ec_uart_probe(struct serdev_device *serdev) serdev_device_set_client_ops(serdev, &cros_ec_uart_client_ops); - return cros_ec_register(ec_dev); + /* Register a new cros_ec device */ + ret = cros_ec_register(ec_dev); + if (ret) { + dev_err(dev, "Couldn't register ec_dev (%d)\n", ret); + return ret; + } + + if (ec_uart->irq_wake) { + ret = device_init_wakeup(dev, true); + if (ret) { + dev_err_probe(dev, ret, "Failed to init device for wakeup"); + return ret; + } + ret = dev_pm_set_wake_irq(dev, ec_uart->irq); + } + return ret; } static void cros_ec_uart_remove(struct serdev_device *serdev) { struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev); + struct device *dev = ec_dev->dev; + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); cros_ec_unregister(ec_dev); }; diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h index 4f9f756bc17ce..a9d952a0f6eda 100644 --- a/include/linux/platform_data/cros_ec_proto.h +++ b/include/linux/platform_data/cros_ec_proto.h @@ -115,7 +115,6 @@ struct cros_ec_command { * performance advantage to using dword. * @din_size: Size of din buffer to allocate (zero to use static din). * @dout_size: Size of dout buffer to allocate (zero to use static dout). - * @wake_enabled: True if this device can wake the system from sleep. * @suspended: True if this device had been suspended. * @cmd_xfer: Send command to EC and get response. * Returns the number of bytes received if the communication @@ -173,7 +172,6 @@ struct cros_ec_device { u8 *dout; int din_size; int dout_size; - bool wake_enabled; bool suspended; int (*cmd_xfer)(struct cros_ec_device *ec, struct cros_ec_command *msg);