From patchwork Tue Feb 14 21:41:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 653599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3DF5C61DA4 for ; Tue, 14 Feb 2023 21:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbjBNVoU (ORCPT ); Tue, 14 Feb 2023 16:44:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbjBNVoR (ORCPT ); Tue, 14 Feb 2023 16:44:17 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EA7C29400; Tue, 14 Feb 2023 13:44:15 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id sa10so43438977ejc.9; Tue, 14 Feb 2023 13:44:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6BIfz99riEO+C0c4evMHPspzVHbaE2cc0ey+M44tW6k=; b=pSoLA/FHrOhJh6EPr92JseA5V/Jc+lfvCdTbkaQQ2inTHx7KHtOkqlVTUYNQVnRqF3 0tGS08tpOdKONsn+GZ05zOujHC0Di2IJ//kO7dIJ0ltgQ0WQF+Tlt5/jXn4ZaSLWBYcL tpw6kQxcMcvx9dOpIz7w/mAdrFds7v+Yjs0QMaEQw9FsA2m+0T2rkUZok4YPWG+nqX+G 6UeqSqMg5DBArfueJ0Fh9aukoXRfHTSFbKKZarGv+xiJDwWWOiYRtjNihO3dmLqMEkp3 gvS72fqASMYhqU0yPcIQ9/jBbqX00FSggC+w6JOb3rn+7tjuRnsAwLTT4TMZyFQraS5L cnpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6BIfz99riEO+C0c4evMHPspzVHbaE2cc0ey+M44tW6k=; b=h/pZkYgC36cuqzJMwqqgcJxlLvVMU3IC1ogDL9zDMT3iAvBeMyYXeR3mozatkqHJLQ islM+sU5GkrwcJygineBMfOolnrVI3u50r6VW0ZgW3WJ86Q5xrh0j43bgiTFR+fHByLJ jVhasRBm6acwdXvh0gTmp3kYsZ5D8lUgAdMcBXoAMZ0zQXdSErb2IrXB5IZIFfdMtvtq NfQYTx8hz6J2jZsTkgzacIWW1UVlrRUfMDV4m8Lp6TrVa8zhgNCso9HIm1KJo0KwsNLO m9fHXNso9I020p+vlYBOkt3iqSK5UuoRnCBmiTAkA3YmKZVHCIw/0UV9sRKzK3C61USb PAKQ== X-Gm-Message-State: AO0yUKUzMwlW9uz5rkZMVvglIXo3tui0fCmhGJGUNhngOebC+W3CRfto wCQDfxi/3t5PrvdKeGqxYlI= X-Google-Smtp-Source: AK7set+ItZXr1gbL0Bkw184xQW8mS3DVV4Kc6GhdErI/smY1OAbxoR/8UgxLWioNqlYnDeR9Dqm6zw== X-Received: by 2002:a17:906:8699:b0:890:4731:d1bc with SMTP id g25-20020a170906869900b008904731d1bcmr4077934ejx.38.1676411053926; Tue, 14 Feb 2023 13:44:13 -0800 (PST) Received: from ?IPV6:2a01:c22:7234:f800:b56b:f43d:948c:eede? (dynamic-2a01-0c22-7234-f800-b56b-f43d-948c-eede.c22.pool.telefonica.de. [2a01:c22:7234:f800:b56b:f43d:948c:eede]) by smtp.googlemail.com with ESMTPSA id f20-20020a170906c09400b00872c0bccab2sm8715145ejz.35.2023.02.14.13.44.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 13:44:13 -0800 (PST) Message-ID: <5777f38b-465f-ce48-a87f-5eb8b3c57b0a@gmail.com> Date: Tue, 14 Feb 2023 22:41:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH v2 1/3] mmc: core: support setting card detect interrupt from drivers Content-Language: en-US From: Heiner Kallweit To: Rob Herring , Ulf Hansson , Krzysztof Kozlowski , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: "linux-mmc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "open list:ARM/Amlogic Meson..." , "devicetree@vger.kernel.org" References: <15df9ef0-9b73-ca5a-d3cf-0585cd135bc5@gmail.com> In-Reply-To: <15df9ef0-9b73-ca5a-d3cf-0585cd135bc5@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On certain platforms like Amlogic Meson gpiod_to_irq() isn't supported due to the design of gpio / interrupt controller. Therefore provide an option for drivers to pass the card detect interrupt number (retrieved e.g. from device tree) to mmc core. Suggested-by refers to the mechanism to pass and store the interrupt. Suggested-by: Ulf Hansson Signed-off-by: Heiner Kallweit --- v2: - use another mechanism for passing and storing the cd interrupt --- drivers/mmc/core/slot-gpio.c | 17 ++++++++++++++++- include/linux/mmc/slot-gpio.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index dd2a4b6ab..2a2d949a9 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -23,6 +23,7 @@ struct mmc_gpio { char *ro_label; char *cd_label; u32 cd_debounce_delay_ms; + int cd_irq; }; static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) @@ -53,12 +54,24 @@ int mmc_gpio_alloc(struct mmc_host *host) ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s ro", devname); if (!ctx->ro_label) return -ENOMEM; + ctx->cd_irq = -EINVAL; host->slot.handler_priv = ctx; host->slot.cd_irq = -EINVAL; return 0; } +void mmc_gpio_set_cd_irq(struct mmc_host *host, int irq) +{ + struct mmc_gpio *ctx = host->slot.handler_priv; + + if (!ctx || irq < 0) + return; + + ctx->cd_irq = irq; +} +EXPORT_SYMBOL(mmc_gpio_set_cd_irq); + int mmc_gpio_get_ro(struct mmc_host *host) { struct mmc_gpio *ctx = host->slot.handler_priv; @@ -98,7 +111,9 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) * Do not use IRQ if the platform prefers to poll, e.g., because that * IRQ number is already used by another unit and cannot be shared. */ - if (!(host->caps & MMC_CAP_NEEDS_POLL)) + if (ctx->cd_irq >= 0) + irq = ctx->cd_irq; + else if (!(host->caps & MMC_CAP_NEEDS_POLL)) irq = gpiod_to_irq(ctx->cd_gpio); if (irq >= 0) { diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h index 4ae2f2908..5d3d15e97 100644 --- a/include/linux/mmc/slot-gpio.h +++ b/include/linux/mmc/slot-gpio.h @@ -15,6 +15,7 @@ struct mmc_host; int mmc_gpio_get_ro(struct mmc_host *host); int mmc_gpio_get_cd(struct mmc_host *host); +void mmc_gpio_set_cd_irq(struct mmc_host *host, int irq); int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, unsigned int idx, bool override_active_level, unsigned int debounce); From patchwork Tue Feb 14 21:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 653876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C80CC64EC7 for ; Tue, 14 Feb 2023 21:44:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbjBNVoV (ORCPT ); Tue, 14 Feb 2023 16:44:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjBNVoU (ORCPT ); Tue, 14 Feb 2023 16:44:20 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2032942D; Tue, 14 Feb 2023 13:44:17 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id gn39so5175134ejc.8; Tue, 14 Feb 2023 13:44:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qbHCaVpympgD+rZ3HviBrecm2Nox2/uMHYu24H65DxI=; b=UWDRUL4uC/fLxhAO2XHD/9ZST4q+AwrnyiErvFgyKNTV2alU7YC82XKLePKM1LG565 aznqOd355jQ0Z4/3Ho9S3fdo2Pz78sNR9HZRQWUPgS3yXfezP+BEvzONzJ8WJ8E88El6 n+oZFBE8wDcoqoKEiJlGmiOwkH6wGscgcFnQj7cssLX313YweR5qBWUfr7omY5IwGVMp iS3o+gYGZgd7+x083fHdgl/PkzSd+FxWMeWNN5ZJbs/8bYQjDTNd3g12mO/pXJFmgseV /qnoT0LPbVX3tyPwaWWEwv03yILFXd7eWjTxE6PbDDHbX9B2N6uZn5ahax59gdB11u8M Ydcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qbHCaVpympgD+rZ3HviBrecm2Nox2/uMHYu24H65DxI=; b=L4QQhERg2tdxu6vPeV5ZJYSZPD74PMz0BdFYMRFsrvTOMSWk2oatNhYY117h31bBTc bu9xMISDLmmHmscvEQn9oSxGI26Lqp8rAHSQInKtn/RTCtHXC0gTbGeZjMXRFRoF7ij9 DqPOz7qh+c98rNmtAdyckojdywnOdcvUIIUqtc61SJ4FcLxoTe8NLsLkEBsS+DANuWy3 v0yD3Dcb5RN5HaCesfH8y3dM9lFLoA3VIfQjBkpRqkoTvo66VLhVr9Tzc/+CaC5imgC4 M9EYphNZJA4XLk9SADODVWruSQO14yuyDkL3H7WfEqpdQTyljt6Bf2J4ri3EiUbGtqAj nK/w== X-Gm-Message-State: AO0yUKU1QQMYD9O5PIMnTHz6gC2IpnPQGXgrWPb6XwZ37qe6DkKOAP/3 COZwnPOa1A2KyLs06LfU1c8= X-Google-Smtp-Source: AK7set/r5p4+TIUHGxGEziaM2ujswam5/RjYE31PKNOauB2KjuV5YXikWQOIKF15RK44rueEFZGcRw== X-Received: by 2002:a17:907:10d4:b0:844:79b1:ab36 with SMTP id rv20-20020a17090710d400b0084479b1ab36mr410828ejb.25.1676411055609; Tue, 14 Feb 2023 13:44:15 -0800 (PST) Received: from ?IPV6:2a01:c22:7234:f800:b56b:f43d:948c:eede? (dynamic-2a01-0c22-7234-f800-b56b-f43d-948c-eede.c22.pool.telefonica.de. [2a01:c22:7234:f800:b56b:f43d:948c:eede]) by smtp.googlemail.com with ESMTPSA id bl4-20020a170906c24400b00880dbd4b6d4sm8749475ejb.136.2023.02.14.13.44.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 13:44:15 -0800 (PST) Message-ID: <1c5996a5-491f-39d6-b120-bbef86473729@gmail.com> Date: Tue, 14 Feb 2023 22:42:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH v2 2/3] dt-bindings: mmc: meson-gx: support specifying cd interrupt Content-Language: en-US From: Heiner Kallweit To: Rob Herring , Ulf Hansson , Krzysztof Kozlowski , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: "linux-mmc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "open list:ARM/Amlogic Meson..." , "devicetree@vger.kernel.org" References: <15df9ef0-9b73-ca5a-d3cf-0585cd135bc5@gmail.com> In-Reply-To: <15df9ef0-9b73-ca5a-d3cf-0585cd135bc5@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Support passing a second interrupt as card detect interrupt. Signed-off-by: Heiner Kallweit --- Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml b/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml index 46e235bf2..c8c30300d 100644 --- a/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml +++ b/Documentation/devicetree/bindings/mmc/amlogic,meson-gx-mmc.yaml @@ -28,7 +28,7 @@ properties: maxItems: 1 interrupts: - maxItems: 1 + maxItems: 2 clocks: maxItems: 3 From patchwork Tue Feb 14 21:44:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 653598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11EB4C64ED8 for ; Tue, 14 Feb 2023 21:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbjBNVoW (ORCPT ); Tue, 14 Feb 2023 16:44:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjBNVoU (ORCPT ); Tue, 14 Feb 2023 16:44:20 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CDD29400; Tue, 14 Feb 2023 13:44:18 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id rp23so43469076ejb.7; Tue, 14 Feb 2023 13:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=9LqJXdxxFstKfYubhTeoAWTHHu54RXhCthHqvhTdxVw=; b=qPz+gKBIC/R8A6gtUZ8ceyazI706kmMBJgDlbAJ55QeqC9llqy5M4oPP92aAhOMmdL LWY84jGU18KQFjObsGNOtO9LD3yECwJaNZ9tntFSoQxhfFbKthtGafSoJ8Vc/tRRAuVw C+OnZB1r39zbuG4pRsxyCwgqSqpMe8icb2wC+5xnMYb7fYePk7BmGXqDqPJQ+1CqdVti IcB3RdfDuHOg078AU//wVFbsi6L5L4YJROes2Dpqxn2wB3PK8QE2aZKEUR2/K3QeG6jL /19hR3kD4Ey35+eK9Y+E3iMXIoN1TmWkJ2f8Ukuf8veCGBcwsDD0h6i+zgrobOOPxWIs MX8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9LqJXdxxFstKfYubhTeoAWTHHu54RXhCthHqvhTdxVw=; b=VX2gWaNYHmSwDTapzCFgip1hu+WKsanKwtolpK1tSuvqB1a2UgMk6q+NVAxGdo/6iN 5eoIvfpGe9NUSzHHUy1pBsbc3pyBjz68wce14cs5EKiitf75PJq/IQdNtMrIHOyFDdnJ 3t44Kv4hPzDZJsbb4EVyxf4guA6QdaaJoYDLv5ps9mD0bbdepv1PAGt8c9eieUv+tgNS zV0SvgGbz/k5mW9ebnTfFqcXKmnDU/KrmGeosVfqps8QHwU25f8pdGQcrPYgMjgNIx9J 8IO1R6muhyfjnAsqbkLl5ChxZEOn/bLcSpgAtb8e24M2mM85Z0LfvSWBa9Z+lnkrX/Vc 7/FA== X-Gm-Message-State: AO0yUKXNf9nUkI6RhWq8E5r8pqBs54SGwm14GkOpxpCLULBxmE9tZx5G v2K8LexVg5z9Ynn8tUunO1M= X-Google-Smtp-Source: AK7set/az3JscyAMvJVE9MKuOV/yeIlPmFr6p9Be9W8jefOVLPXcDrovvENpnkqW2DXiWXUtMV9sPA== X-Received: by 2002:a17:906:850e:b0:7c1:765:9cfc with SMTP id i14-20020a170906850e00b007c107659cfcmr328840ejx.34.1676411056936; Tue, 14 Feb 2023 13:44:16 -0800 (PST) Received: from ?IPV6:2a01:c22:7234:f800:b56b:f43d:948c:eede? (dynamic-2a01-0c22-7234-f800-b56b-f43d-948c-eede.c22.pool.telefonica.de. [2a01:c22:7234:f800:b56b:f43d:948c:eede]) by smtp.googlemail.com with ESMTPSA id j9-20020a1709066dc900b008b1294f7f63sm1669820ejt.221.2023.02.14.13.44.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 13:44:16 -0800 (PST) Message-ID: <2bb70611-5dea-1144-51bd-93c46b455392@gmail.com> Date: Tue, 14 Feb 2023 22:44:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH v2 3/3] mmc: meson-gx: support platform interrupt as card detect interrupt Content-Language: en-US From: Heiner Kallweit To: Rob Herring , Ulf Hansson , Krzysztof Kozlowski , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: "linux-mmc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "open list:ARM/Amlogic Meson..." , "devicetree@vger.kernel.org" References: <15df9ef0-9b73-ca5a-d3cf-0585cd135bc5@gmail.com> In-Reply-To: <15df9ef0-9b73-ca5a-d3cf-0585cd135bc5@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Use a new mmc core feature and support specifying the card detect gpio interrupt in device tree. Signed-off-by: Heiner Kallweit --- v2: - adopt the changed way to pass the cd interrupt number --- drivers/mmc/host/meson-gx-mmc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index f4b50793e..079c52dbe 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -1166,7 +1166,7 @@ static int meson_mmc_probe(struct platform_device *pdev) struct resource *res; struct meson_host *host; struct mmc_host *mmc; - int ret; + int cd_irq, ret; mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct meson_host)); if (!mmc) @@ -1213,6 +1213,9 @@ static int meson_mmc_probe(struct platform_device *pdev) if (host->irq <= 0) return -EINVAL; + cd_irq = platform_get_irq_optional(pdev, 1); + mmc_gpio_set_cd_irq(mmc, cd_irq); + host->pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(host->pinctrl)) return PTR_ERR(host->pinctrl);