From patchwork Thu Dec 29 20:04:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 637754 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 A7493C46467 for ; Thu, 29 Dec 2022 20:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233287AbiL2UEy (ORCPT ); Thu, 29 Dec 2022 15:04:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiL2UEx (ORCPT ); Thu, 29 Dec 2022 15:04:53 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE25013F88 for ; Thu, 29 Dec 2022 12:04:51 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so19875444pjd.0 for ; Thu, 29 Dec 2022 12:04:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=THu9QMNuJA2VLaqG7RBOupd/FwlnEsHSPzLMTF3bhmM=; b=E+kP4To4Zqmzj4VnzgJ7fPeHfDNzUJ5kN99ndY4qRVSFbjiMwEBPI0CMuh5MA9ITBZ Lo6LeHpg8JxUxDp+pO+NFqh1DHjCHvP4cytZpfyuC7zp/lxvftZZuACyM4B08QArfUzx a1+UHy8ikaWM2TrhR4qSGZvAuWh+9KvMhlynA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=THu9QMNuJA2VLaqG7RBOupd/FwlnEsHSPzLMTF3bhmM=; b=SZs+B7zYpymsEE2KYxt2quuijMmHACpwW6vZ30Z5OhVg0CcKXNnoO+duxmMZeknf8c uAmy9sTPsVqrqdllsrDe8OhWkLD5G9n8eU5NvMqaGNNzYwg7s87PS8MKabQbBMXCBJ7g lhmGadbvZ0p55BK+KFna2hAEfUdRaEYL+u7dpXgdQ+KQw5fgAyjsFAnDsnzwlKyFuktY FvBJ4aIvyl44HQh9fFL6U6LIuxHdTI9IVFFF0ljazkQhrutrh5VQlBOimgM3drqhmANe 5+7Ib22a1POPXhhnDHWgzp7beAv1zEliWSKCeHc4Fy8vjCD4rs32LZlmIC+TTjmE06rQ 5SfA== X-Gm-Message-State: AFqh2kp/3jTcJ80J+gzg5H3L+4bps9XWf/6IX4DRDgBwaKj/rRbT4441 o33fl0CsBBjxItwck/p9kdH1Itxeyo+/ljtPYjZxIA== X-Google-Smtp-Source: AMrXdXuXmlyeuQYOw90K/c3dIQQ7TFZ/gllINgDBn4Z8lOCzZ0Nd+Wwljgg+hiODBHHeoT5T6huhzQ== X-Received: by 2002:a17:902:c10a:b0:188:bc62:276f with SMTP id 10-20020a170902c10a00b00188bc62276fmr31841494pli.3.1672344291243; Thu, 29 Dec 2022 12:04:51 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:04:50 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 1/8] mmc: sdhci-pxav2: add initial support for PXA168 V1 controller Date: Thu, 29 Dec 2022 12:04:04 -0800 Message-Id: <20221229200411.295339-2-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add a new compatible string for the version 1 controller used in the PXA168, along with necessary quirks. Use a separate ops struct in preparation for a silicon bug workaround only necessary on V1. Signed-off-by: Doug Brown --- drivers/mmc/host/sdhci-pxav2.c | 40 +++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c index f18906b5575f..5707d597ecae 100644 --- a/drivers/mmc/host/sdhci-pxav2.c +++ b/drivers/mmc/host/sdhci-pxav2.c @@ -101,6 +101,24 @@ static void pxav2_mmc_set_bus_width(struct sdhci_host *host, int width) writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); } +struct sdhci_pxa_variant { + const struct sdhci_ops *ops; + unsigned int extra_quirks; +}; + +static const struct sdhci_ops pxav1_sdhci_ops = { + .set_clock = sdhci_set_clock, + .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .set_bus_width = pxav2_mmc_set_bus_width, + .reset = pxav2_reset, + .set_uhs_signaling = sdhci_set_uhs_signaling, +}; + +static const struct sdhci_pxa_variant __maybe_unused pxav1_variant = { + .ops = &pxav1_sdhci_ops, + .extra_quirks = SDHCI_QUIRK_NO_BUSY_IRQ | SDHCI_QUIRK_32BIT_DMA_SIZE, +}; + static const struct sdhci_ops pxav2_sdhci_ops = { .set_clock = sdhci_set_clock, .get_max_clock = sdhci_pltfm_clk_get_max_clock, @@ -109,11 +127,14 @@ static const struct sdhci_ops pxav2_sdhci_ops = { .set_uhs_signaling = sdhci_set_uhs_signaling, }; +static const struct sdhci_pxa_variant pxav2_variant = { + .ops = &pxav2_sdhci_ops, +}; + #ifdef CONFIG_OF static const struct of_device_id sdhci_pxav2_of_match[] = { - { - .compatible = "mrvl,pxav2-mmc", - }, + { .compatible = "mrvl,pxav1-mmc", .data = &pxav1_variant, }, + { .compatible = "mrvl,pxav2-mmc", .data = &pxav2_variant, }, {}, }; MODULE_DEVICE_TABLE(of, sdhci_pxav2_of_match); @@ -157,7 +178,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data; struct device *dev = &pdev->dev; struct sdhci_host *host = NULL; - const struct of_device_id *match; + const struct sdhci_pxa_variant *variant; int ret; struct clk *clk; @@ -185,10 +206,12 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN; - match = of_match_device(of_match_ptr(sdhci_pxav2_of_match), &pdev->dev); - if (match) { + variant = of_device_get_match_data(dev); + if (variant) pdata = pxav2_get_mmc_pdata(dev); - } + else + variant = &pxav2_variant; + if (pdata) { if (pdata->flags & PXA_FLAG_CARD_PERMANENT) { /* on-chip device */ @@ -208,7 +231,8 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) host->mmc->pm_caps |= pdata->pm_caps; } - host->ops = &pxav2_sdhci_ops; + host->quirks |= variant->extra_quirks; + host->ops = variant->ops; ret = sdhci_add_host(host); if (ret) From patchwork Thu Dec 29 20:04:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 638128 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 4F888C3DA79 for ; Thu, 29 Dec 2022 20:04:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbiL2UE4 (ORCPT ); Thu, 29 Dec 2022 15:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiL2UEz (ORCPT ); Thu, 29 Dec 2022 15:04:55 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B500F15F1B for ; Thu, 29 Dec 2022 12:04:54 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso23931288pjt.0 for ; Thu, 29 Dec 2022 12:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=10C9l5cM9Gx+6A1r6iqoMzAy/dFS6z3guP1T2Uf7DqQ=; b=iLgLqZLDJX2Ye9k2/ZAPmcANrBpyk4t23vNaocACF/ibMZiqhhDK6V6PsAIdG3YgSW kjzCxD6jqR4RpJ2myc3jA1wKWiY6kn5x3pCQHGABMeqNSlOrqDHE8U+SVsQJzJMs5URT eyVAwAgANinXdCitGy39kOIuROIWPbPTF1BuA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=10C9l5cM9Gx+6A1r6iqoMzAy/dFS6z3guP1T2Uf7DqQ=; b=R2R4n6KiWeUGTpa0JnOawLg82FLieOU2zJl2d/XmCg1/xo4tFAPKM8rKlMRGaFxaBX 38Uyf8Bqh1bH25OwQ5f1CDnLnxmTq7PNN1rvD2CZ/ii3IL37m8Zy+famlApQB7mR8OBH MygebmxX4Q8B4kzDoKVUI7wq/ysknvXBnxLces38IS15fmVWE3EloHlvAKdS9FA4pbku K4kKKgh0lYodoeJSdmJBp9SV6BtPK06W0UjXAW73EjDAH1yC7k+Pna04JeN6jwb4g5zB 6PYQ0NEprrlzBlghBjqNT9F4wEyMwI+iR/6eqtsgtlwXCM+sOLj2Dj72AkZ+1gY/tKE4 HQ8w== X-Gm-Message-State: AFqh2krYmXgkJUy72bjCYCUnqjeuC3wweR8rzPLzP+6zwHClWDe3JSiX T5dsxZe6o5bNnOwFYDYKn1PORw== X-Google-Smtp-Source: AMrXdXuzwQ4VItMxn8kr5amybyS1WH0+aoq4c9oWoZrJZAIFnawIFPwWXypWM6CPWzQaP0jziQwjiQ== X-Received: by 2002:a17:902:e543:b0:189:a6b4:91ed with SMTP id n3-20020a170902e54300b00189a6b491edmr44840220plf.17.1672344294143; Thu, 29 Dec 2022 12:04:54 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:04:53 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 2/8] mmc: sdhci-pxav2: enable CONFIG_MMC_SDHCI_IO_ACCESSORS Date: Thu, 29 Dec 2022 12:04:05 -0800 Message-Id: <20221229200411.295339-3-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Enable CONFIG_MMC_SDHCI_IO_ACCESSORS for the pxav2 driver. The read_w callback is needed for a silicon bug workaround in the PXA168. Signed-off-by: Doug Brown --- drivers/mmc/host/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 5e19a961c34d..b9e9185c86a6 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -360,6 +360,7 @@ config MMC_SDHCI_PXAV2 depends on MMC_SDHCI_PLTFM depends on ARCH_MMP || COMPILE_TEST default CPU_PXA910 + select MMC_SDHCI_IO_ACCESSORS help This selects the Marvell(R) PXAV2 SD Host Controller. If you have a PXA9XX platform with SD Host Controller From patchwork Thu Dec 29 20:04:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 637753 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 13F38C3DA79 for ; Thu, 29 Dec 2022 20:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbiL2UFA (ORCPT ); Thu, 29 Dec 2022 15:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233504AbiL2UE6 (ORCPT ); Thu, 29 Dec 2022 15:04:58 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF4015F1B for ; Thu, 29 Dec 2022 12:04:57 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso23931390pjt.0 for ; Thu, 29 Dec 2022 12:04:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=LwLsC88yYEr+DqM5Cbp/GViuH3X6Lo7mSbslRIXTWPU=; b=LjH2StdHqe6JYBWUWVbsuH+RmGQIbgDYNdf5tFtjGE6tljxlLRNvV6iZa8Zh8EECch 2AYa2EV/cDKNSrt0fUPHZuFJ7JmA79xHx691usBv4PJNS+Xfv2SMPJhEVwNx9KwjGqKE xzz6nDemAYTZMzKp9cGvz+JD+Q05uuDTKcGSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LwLsC88yYEr+DqM5Cbp/GViuH3X6Lo7mSbslRIXTWPU=; b=cFCHN2Qtk9R1wnKNFiklpNkWuNbMx0JalAdxn8ThurjfISVfKxTQNA571O1gWpGbF/ IVVpT6fHkDacz5J0hulb25oxTZ6mNBn+TH1DyX+tq507eStIQH74xrs0mx1BHgq8VzZ2 6nKPLJO7aegLww6/tzD5mwz4zqidl8ifycDVt1umLcZo1448juJb8U6mkn+6AVFUSspI 88XcJi+/3AG12gUXSTeA7ze0Dseizv6zLif7OqPT31bGgYYXMbVpHREUhYggQyr6b0rG JZwAp8thrfrBGWELmVaE6yfvkuqj1TkXbI/GeGaUBqcJz/O2JYtfRr3Y6DnNyrBafxJW jvCg== X-Gm-Message-State: AFqh2kpzRnBq/dXKmnj+GuyGJE8uBO3ze1CYboeDPS9CiBvLfcNcK1tu iaj1QuOkptfUun/Z1jLYVdkqPA== X-Google-Smtp-Source: AMrXdXsGuQulywqUBmvyH6G+s9J9Et6wj8YN7mdwrB0SInKmC/Prto+piCu2D0/N7FjRfUHOFD3Q9g== X-Received: by 2002:a17:902:d2ce:b0:192:a4d5:55b8 with SMTP id n14-20020a170902d2ce00b00192a4d555b8mr3541205plc.52.1672344297022; Thu, 29 Dec 2022 12:04:57 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:04:56 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 3/8] mmc: sdhci-pxav2: add register workaround for PXA168 silicon bug Date: Thu, 29 Dec 2022 12:04:06 -0800 Message-Id: <20221229200411.295339-4-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The PXA168 has a documented silicon bug that results in a data abort exception when accessing the SDHCI_HOST_VERSION register on SDH2 and SDH4 through a 16-bit read. Implement the workaround described in the errata, which performs a 32-bit read from a lower address instead. This is safe to use on all four SDH peripherals. Signed-off-by: Doug Brown --- drivers/mmc/host/sdhci-pxav2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c index 5707d597ecae..5e01dab94426 100644 --- a/drivers/mmc/host/sdhci-pxav2.c +++ b/drivers/mmc/host/sdhci-pxav2.c @@ -80,6 +80,15 @@ static void pxav2_reset(struct sdhci_host *host, u8 mask) } } +static u16 pxav1_readw(struct sdhci_host *host, int reg) +{ + /* Workaround for data abort exception on SDH2 and SDH4 on PXA168 */ + if (reg == SDHCI_HOST_VERSION) + return readl(host->ioaddr + SDHCI_HOST_VERSION - 2) >> 16; + + return readw(host->ioaddr + reg); +} + static void pxav2_mmc_set_bus_width(struct sdhci_host *host, int width) { u8 ctrl; @@ -107,6 +116,7 @@ struct sdhci_pxa_variant { }; static const struct sdhci_ops pxav1_sdhci_ops = { + .read_w = pxav1_readw, .set_clock = sdhci_set_clock, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .set_bus_width = pxav2_mmc_set_bus_width, From patchwork Thu Dec 29 20:04:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 638127 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 516DAC3DA79 for ; Thu, 29 Dec 2022 20:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233560AbiL2UFC (ORCPT ); Thu, 29 Dec 2022 15:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiL2UFA (ORCPT ); Thu, 29 Dec 2022 15:05:00 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 476D714D19 for ; Thu, 29 Dec 2022 12:05:00 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id n4so19908199plp.1 for ; Thu, 29 Dec 2022 12:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=D6r2GlaNz1+YzI6wDR7hgOyWZe3jS4KnaVe8emuVcm0=; b=Jx7ayWpipJYx1V2Zz6YI+oqhOTf2hCPRcDx4+pt4+GpRUI8GjlocIDH/I55wrcAHHr a8xB3t7jUa22B4ke2tsyTwm4ssdu5FCXuOa0RRWMDZ6ioYakg652LoBKY0ONRPSTUJVu bCgq0+4w1KYw3Vu9NS+uDKc4uw452vmAUrmd8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=D6r2GlaNz1+YzI6wDR7hgOyWZe3jS4KnaVe8emuVcm0=; b=a4Y4TLGUKiIwH9oIkwQhYvXDOLglX7z/dB5x2OTXeCG0E1pq9GcDMf1QMps7A56X/G gNrdev6gxtDWUVi5N+gAp4osmLgBUDI4qq3B8NkIAwsepwNwp2LcfdgUsvY/Mgvkw3Yv DzBnTeJfKT7U1i9xq7ekPb/LHhFiI47K2xXPBiTBQm33koE+DhLscOUMxfbXMdAi7h02 sbK/3V75n54kt0p3tzGUii0ElXmiY+QCZBdG9cxDLeeNtb4TMh1TBvNHbSjU0hhdDuBH yQS4cJKH8EnZ5mBm+/nfJEr4897SCK3GYSVKLbKDHcP3lFeLf8iSDh03jqnaXf+I0jPH sVRA== X-Gm-Message-State: AFqh2kqjIfdeXsj0EHRDlkF5aFr6AYpI15R6T4zfhVcFh6HDWJ0GVj4Y xJgNcuzDxjGxBC0JXuoqfXU+kk3vCf32JcYa4AIvQQ== X-Google-Smtp-Source: AMrXdXt4jnO+nwqLg9k7tVFSzwfWxCncGvAMj63+hcAjF+UdoJLLIOYqMk/fR+q22DFODXF5DWdjmg== X-Received: by 2002:a17:902:e74a:b0:192:8e0b:23d3 with SMTP id p10-20020a170902e74a00b001928e0b23d3mr14138994plf.23.1672344299598; Thu, 29 Dec 2022 12:04:59 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:04:59 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 4/8] mmc: sdhci-pxav2: change clock name to match DT bindings Date: Thu, 29 Dec 2022 12:04:07 -0800 Message-Id: <20221229200411.295339-5-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The devicetree bindings for this driver specify that the two allowed clock names are io and core. Change this driver to look for io, but allow any name if it fails for backwards compatibility. Follow the same pattern used in sdhci-pxav3, but add support for EPROBE_DEFER. Get rid of an unnecessary pdev->dev while we're at it. Signed-off-by: Doug Brown --- drivers/mmc/host/sdhci-pxav2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c index 5e01dab94426..f5c86e1ba734 100644 --- a/drivers/mmc/host/sdhci-pxav2.c +++ b/drivers/mmc/host/sdhci-pxav2.c @@ -199,16 +199,18 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) pltfm_host = sdhci_priv(host); - clk = devm_clk_get(dev, "PXA-SDHCLK"); + clk = devm_clk_get(dev, "io"); + if (IS_ERR(clk) && PTR_ERR(clk) != -EPROBE_DEFER) + clk = devm_clk_get(dev, NULL); if (IS_ERR(clk)) { - dev_err(dev, "failed to get io clock\n"); ret = PTR_ERR(clk); + dev_err_probe(dev, ret, "failed to get io clock\n"); goto free; } pltfm_host->clk = clk; ret = clk_prepare_enable(clk); if (ret) { - dev_err(&pdev->dev, "failed to enable io clock\n"); + dev_err(dev, "failed to enable io clock\n"); goto free; } From patchwork Thu Dec 29 20:04:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 637752 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 B89E8C3DA7A for ; Thu, 29 Dec 2022 20:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbiL2UFF (ORCPT ); Thu, 29 Dec 2022 15:05:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233504AbiL2UFE (ORCPT ); Thu, 29 Dec 2022 15:05:04 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D724B165A8 for ; Thu, 29 Dec 2022 12:05:02 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id hd14-20020a17090b458e00b0021909875bccso19230837pjb.1 for ; Thu, 29 Dec 2022 12:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=KFjpQddF6K9jQuFhw0EZBw3KCqxEcEHNGaoCdbNy9Uw=; b=kewFcvPnmlK/daoedJ07uHcuNvIXEj8SG32nFgtaneG8Vk00S3miIVACLw+x/4+5XO HyhmjbkPjPC72TFziQuJKWLqAk5/0xEgKpvpJkKCC34lngvWsP3QXpTZlj6CswA/ZZA+ RIYvIBZvUKDbTfqAHDg9Pil8Me3L9Saj5kCFw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KFjpQddF6K9jQuFhw0EZBw3KCqxEcEHNGaoCdbNy9Uw=; b=0eHoNr5Eg3ZvrL8tHBm7jur1SDUGKHigYeovm8xJPSD5dpucaH5o+ES0VVks5cP5bK 1+gZTYqKTV3h7zBDmWT6QGGfLkNZjHnhZXPs+aoY5drxqRKsgrKzfR+I1Ywir1/icDJF 6asOkAW5VBSWeNHUA5jDFk3/2qJQmTlmI2n3UisPe9A8spyYUSk1HScCO6iCP26O96OP wYSJ6X4XtKpa/hAA1QNMALEs5DKLSIHWmYp6ymwBGGfkir8jGfBZpqmpC6TK4BVr5wsr +tnbvGmELZRpIJVdUU+6X1kEps1ZBMIl5h3avoaBKA14+vTLH6qJP3HnzcwGtDzMBD0o TBxg== X-Gm-Message-State: AFqh2krqXXOmw2nWI548VltFBiQTfJl+bvBLjkRnW9htYS/7T/B9bYFN 66+nT70AMH7mME3+xux4pRErjw== X-Google-Smtp-Source: AMrXdXsRMMggph1dSmqk1DtjLX0D9GUCc0yQufbYA5KUQ3uQUn+V2j4jyqiSafsbRuz+q/xqxDV2TA== X-Received: by 2002:a17:903:12d7:b0:189:854a:fff3 with SMTP id io23-20020a17090312d700b00189854afff3mr28679184plb.23.1672344302232; Thu, 29 Dec 2022 12:05:02 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:05:01 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 5/8] mmc: sdhci-pxav2: add optional core clock Date: Thu, 29 Dec 2022 12:04:08 -0800 Message-Id: <20221229200411.295339-6-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add ability to have an optional core clock just like the pxav3 driver. The PXA168 needs this because its SDHC controllers have separate core and io clocks that both need to be enabled. This also correctly matches the documented devicetree bindings for this driver. Signed-off-by: Doug Brown --- drivers/mmc/host/sdhci-pxav2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c index f5c86e1ba734..b10f55b478fc 100644 --- a/drivers/mmc/host/sdhci-pxav2.c +++ b/drivers/mmc/host/sdhci-pxav2.c @@ -191,7 +191,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) const struct sdhci_pxa_variant *variant; int ret; - struct clk *clk; + struct clk *clk, *clk_core; host = sdhci_pltfm_init(pdev, NULL, 0); if (IS_ERR(host)) @@ -214,6 +214,12 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) goto free; } + clk_core = devm_clk_get_optional_enabled(dev, "core"); + if (IS_ERR(clk_core)) { + dev_err_probe(dev, PTR_ERR(clk_core), "failed to enable core clock\n"); + goto disable_clk; + } + host->quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN; From patchwork Thu Dec 29 20:04:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 638126 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 97DB6C3DA79 for ; Thu, 29 Dec 2022 20:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233854AbiL2UFI (ORCPT ); Thu, 29 Dec 2022 15:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233861AbiL2UFG (ORCPT ); Thu, 29 Dec 2022 15:05:06 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5587413EB5 for ; Thu, 29 Dec 2022 12:05:05 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id o31-20020a17090a0a2200b00223fedffb30so19832881pjo.3 for ; Thu, 29 Dec 2022 12:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=lA6khbYwNTUEkyhgFPN6yUEAH+2Z3l7izmoOYpawnMY=; b=BMMNNSCPn2qhoE9uGm4q6zrLXVMvzRWmjNRiDjcnpHxoVYmr4H+RDr5TfSgSbKSeeY CNSfknKs2ijddQagcIl9TJW/ul9xMSxhQ/Wuawj0loG7XQxjyOw3giiJF1hIXFQWq5hy 6ql18QO1JzCf5ccMtQGiUhZt0FllnANDTUGio= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=lA6khbYwNTUEkyhgFPN6yUEAH+2Z3l7izmoOYpawnMY=; b=WqnPf7YjzQA+YYrR5dY8CuqUFweF9m7hyQ/roHsWCnZJnwWfzDEmH/hMzZwCkNQbKY Al6WoTkI4Ie2JWu4FCezDqQhXGHFpPSQdzGop1lFDguixxceOsO0Ksy/K24nCyj04o4V twruYo2EPSMOcyJzyL1zyFkE29aK3MvLPPD//fJ80DEQwGQDJMUVnIrMNQg7MAEcgKXB AbJw6K2u9nrO8/s0qDhk+AHCKzyKzwl7Upd6fw+o7RXGoI58du3yUppbsb1iKa8I/wA0 oIummucRaXrMb7uDDx68hv7TYM87qyDX6yTJHcGZjC/O7WZAjN4HaBLwlkVAe6/jzM5O 42QQ== X-Gm-Message-State: AFqh2koQjpmJltCbBnUhJf6YgmeexDwglIhqmUxFpU//ylOcr0PStFK0 3UVnxCZ+F/w3wDyryLeW76mCUA== X-Google-Smtp-Source: AMrXdXtDdcoBE8iBS3xNoIhIbIPoZH6cfi+bNg4YggYsyXWMRDsuQC9k3AjS032M55xFYRpLDlKSrw== X-Received: by 2002:a17:902:a510:b0:192:48d1:f06c with SMTP id s16-20020a170902a51000b0019248d1f06cmr27429481plq.35.1672344304934; Thu, 29 Dec 2022 12:05:04 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:05:04 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 6/8] mmc: sdhci-pxav2: add SDIO card IRQ workaround for PXA168 V1 controller Date: Thu, 29 Dec 2022 12:04:09 -0800 Message-Id: <20221229200411.295339-7-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The PXA168 has a documented silicon bug that causes SDIO card IRQs to be missed. Implement the first half of the suggested workaround, which involves resetting the data port logic and issuing a dummy CMD0 to restart the clock. Signed-off-by: Doug Brown --- drivers/mmc/host/sdhci-pxav2.c | 56 +++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c index b10f55b478fc..10fa9de14ad4 100644 --- a/drivers/mmc/host/sdhci-pxav2.c +++ b/drivers/mmc/host/sdhci-pxav2.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "sdhci.h" #include "sdhci-pltfm.h" @@ -41,6 +43,10 @@ #define MMC_CARD 0x1000 #define MMC_WIDTH 0x0100 +struct sdhci_pxav2_host { + struct mmc_request *sdio_mrq; +}; + static void pxav2_reset(struct sdhci_host *host, u8 mask) { struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc)); @@ -89,6 +95,52 @@ static u16 pxav1_readw(struct sdhci_host *host, int reg) return readw(host->ioaddr + reg); } +static u32 pxav1_irq(struct sdhci_host *host, u32 intmask) +{ + struct sdhci_pxav2_host *pxav2_host = sdhci_pltfm_priv(sdhci_priv(host)); + struct mmc_request *sdio_mrq; + + if (pxav2_host->sdio_mrq && (intmask & SDHCI_INT_CMD_MASK)) { + /* The dummy CMD0 for the SDIO workaround just completed */ + sdhci_writel(host, intmask & SDHCI_INT_CMD_MASK, SDHCI_INT_STATUS); + intmask &= ~SDHCI_INT_CMD_MASK; + sdio_mrq = pxav2_host->sdio_mrq; + pxav2_host->sdio_mrq = NULL; + mmc_request_done(host->mmc, sdio_mrq); + } + + return intmask; +} + +static void pxav1_request_done(struct sdhci_host *host, struct mmc_request *mrq) +{ + u16 tmp; + struct sdhci_pxav2_host *pxav2_host; + + /* If this is an SDIO command, perform errata workaround for silicon bug */ + if (mrq->cmd && !mrq->cmd->error && + (mrq->cmd->opcode == SD_IO_RW_DIRECT || + mrq->cmd->opcode == SD_IO_RW_EXTENDED)) { + /* Reset data port */ + tmp = readw(host->ioaddr + SDHCI_TIMEOUT_CONTROL); + tmp |= 0x400; + writew(tmp, host->ioaddr + SDHCI_TIMEOUT_CONTROL); + + /* Clock is now stopped, so restart it by sending a dummy CMD0 */ + pxav2_host = sdhci_pltfm_priv(sdhci_priv(host)); + pxav2_host->sdio_mrq = mrq; + sdhci_writel(host, 0, SDHCI_ARGUMENT); + sdhci_writew(host, 0, SDHCI_TRANSFER_MODE); + sdhci_writew(host, SDHCI_MAKE_CMD(MMC_GO_IDLE_STATE, SDHCI_CMD_RESP_NONE), + SDHCI_COMMAND); + + /* Don't finish this request until the dummy CMD0 finishes */ + return; + } + + mmc_request_done(host->mmc, mrq); +} + static void pxav2_mmc_set_bus_width(struct sdhci_host *host, int width) { u8 ctrl; @@ -118,10 +170,12 @@ struct sdhci_pxa_variant { static const struct sdhci_ops pxav1_sdhci_ops = { .read_w = pxav1_readw, .set_clock = sdhci_set_clock, + .irq = pxav1_irq, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .set_bus_width = pxav2_mmc_set_bus_width, .reset = pxav2_reset, .set_uhs_signaling = sdhci_set_uhs_signaling, + .request_done = pxav1_request_done, }; static const struct sdhci_pxa_variant __maybe_unused pxav1_variant = { @@ -193,7 +247,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) int ret; struct clk *clk, *clk_core; - host = sdhci_pltfm_init(pdev, NULL, 0); + host = sdhci_pltfm_init(pdev, NULL, sizeof(struct sdhci_pxav2_host)); if (IS_ERR(host)) return PTR_ERR(host); From patchwork Thu Dec 29 20:04:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 638125 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 8733DC3DA7A for ; Thu, 29 Dec 2022 20:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233894AbiL2UFL (ORCPT ); Thu, 29 Dec 2022 15:05:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233861AbiL2UFJ (ORCPT ); Thu, 29 Dec 2022 15:05:09 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BE1E13EB5 for ; Thu, 29 Dec 2022 12:05:08 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id j8-20020a17090a3e0800b00225fdd5007fso10213503pjc.2 for ; Thu, 29 Dec 2022 12:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=9GiNIVO9S3T0XmYGcrVLJsLr1WGPHInOFVHV7LsJK20=; b=b4KEaCoIxwQwZOFpCNuYpnmPK3aYfyGefR1lZnKhMnh4i3kLbVjIpQ7H8Z+2Z3aYP7 j3S9jdBYbuj2MY/Tgcu847WkYpog9PpF84uruMJg0geEnIUUurhpGW+dP0dgOJVHIZ0+ 4Gg/NX8fwnH0tIDlbnT9Hf8Pqg9j0oWuPApwM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=9GiNIVO9S3T0XmYGcrVLJsLr1WGPHInOFVHV7LsJK20=; b=ZgNTDFKEXEQVylQGnDwsy86l7QHmQYcCDP1vqXgAvFp0WHxscvhbRvXvVZOhF0SnqW DRREEZqjGTS/1hwSZInazxZDDQltKlX+MvTy1BnOCNqnDH1mjgyIl8FPyFXMSEk/WomH Qq1Cxtwma4DR5i8Vn2CjzWSWqbRVRotw1oMck2SM/uCG/ujh1eHJdxjEdaXzG+HHlujb 6kyMH/ubnlXwDXC/ILXIbKcSxlxKrOhHqOHChusVKGSafCtggLZaRtC1zz7I2eH1/MAc 4hXLVYf2QNKvYnnReZlsU0NN2yi1R+xlEkjyd2HRLJBnDppX0RKWs8D9JLm+MKI+GH2l WV+Q== X-Gm-Message-State: AFqh2ko0HMr9SKxSaj9tf0DOX5XVfsht/KpQQKbcId5Xy98Kx8ImTYda 6TtTM8sNOeiTiFLMgXLUAsUFlQ== X-Google-Smtp-Source: AMrXdXtSk9F/Vi2+G3LsvDxl9s5vw28VDM42UoWz58ANPPwl3463Zwxc0fO/Jypgm7++deZk2lJ/kw== X-Received: by 2002:a17:902:8647:b0:192:549b:97c3 with SMTP id y7-20020a170902864700b00192549b97c3mr28424335plt.42.1672344307535; Thu, 29 Dec 2022 12:05:07 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:05:07 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown Subject: [PATCH v3 7/8] mmc: sdhci-pxav2: add optional pinctrl for SDIO IRQ workaround Date: Thu, 29 Dec 2022 12:04:10 -0800 Message-Id: <20221229200411.295339-8-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The PXA168 errata recommends that the CMD signal should be detached from the SD bus while performing the dummy CMD0 to restart the clock. Implement this using pinctrl states. Signed-off-by: Doug Brown --- drivers/mmc/host/sdhci-pxav2.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c index 10fa9de14ad4..38edd1fcc992 100644 --- a/drivers/mmc/host/sdhci-pxav2.c +++ b/drivers/mmc/host/sdhci-pxav2.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "sdhci.h" #include "sdhci-pltfm.h" @@ -45,6 +46,9 @@ struct sdhci_pxav2_host { struct mmc_request *sdio_mrq; + struct pinctrl *pinctrl; + struct pinctrl_state *pins_default; + struct pinctrl_state *pins_cmd_gpio; }; static void pxav2_reset(struct sdhci_host *host, u8 mask) @@ -104,6 +108,11 @@ static u32 pxav1_irq(struct sdhci_host *host, u32 intmask) /* The dummy CMD0 for the SDIO workaround just completed */ sdhci_writel(host, intmask & SDHCI_INT_CMD_MASK, SDHCI_INT_STATUS); intmask &= ~SDHCI_INT_CMD_MASK; + + /* Restore MMC function to CMD pin */ + if (pxav2_host->pinctrl && pxav2_host->pins_default) + pinctrl_select_state(pxav2_host->pinctrl, pxav2_host->pins_default); + sdio_mrq = pxav2_host->sdio_mrq; pxav2_host->sdio_mrq = NULL; mmc_request_done(host->mmc, sdio_mrq); @@ -129,6 +138,11 @@ static void pxav1_request_done(struct sdhci_host *host, struct mmc_request *mrq) /* Clock is now stopped, so restart it by sending a dummy CMD0 */ pxav2_host = sdhci_pltfm_priv(sdhci_priv(host)); pxav2_host->sdio_mrq = mrq; + + /* Set CMD as high output rather than MMC function while we do CMD0 */ + if (pxav2_host->pinctrl && pxav2_host->pins_cmd_gpio) + pinctrl_select_state(pxav2_host->pinctrl, pxav2_host->pins_cmd_gpio); + sdhci_writel(host, 0, SDHCI_ARGUMENT); sdhci_writew(host, 0, SDHCI_TRANSFER_MODE); sdhci_writew(host, SDHCI_MAKE_CMD(MMC_GO_IDLE_STATE, SDHCI_CMD_RESP_NONE), @@ -240,6 +254,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) { struct sdhci_pltfm_host *pltfm_host; struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data; + struct sdhci_pxav2_host *pxav2_host; struct device *dev = &pdev->dev; struct sdhci_host *host = NULL; const struct sdhci_pxa_variant *variant; @@ -247,11 +262,12 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) int ret; struct clk *clk, *clk_core; - host = sdhci_pltfm_init(pdev, NULL, sizeof(struct sdhci_pxav2_host)); + host = sdhci_pltfm_init(pdev, NULL, sizeof(*pxav2_host)); if (IS_ERR(host)) return PTR_ERR(host); pltfm_host = sdhci_priv(host); + pxav2_host = sdhci_pltfm_priv(pltfm_host); clk = devm_clk_get(dev, "io"); if (IS_ERR(clk) && PTR_ERR(clk) != -EPROBE_DEFER) @@ -306,6 +322,21 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) host->quirks |= variant->extra_quirks; host->ops = variant->ops; + /* Set up optional pinctrl for PXA168 SDIO IRQ fix */ + pxav2_host->pinctrl = devm_pinctrl_get(dev); + if (!IS_ERR(pxav2_host->pinctrl)) { + pxav2_host->pins_cmd_gpio = pinctrl_lookup_state(pxav2_host->pinctrl, + "state_cmd_gpio"); + if (IS_ERR(pxav2_host->pins_cmd_gpio)) + pxav2_host->pins_cmd_gpio = NULL; + pxav2_host->pins_default = pinctrl_lookup_state(pxav2_host->pinctrl, + "default"); + if (IS_ERR(pxav2_host->pins_default)) + pxav2_host->pins_default = NULL; + } else { + pxav2_host->pinctrl = NULL; + } + ret = sdhci_add_host(host); if (ret) goto disable_clk; From patchwork Thu Dec 29 20:04:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 637751 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 E6893C4708E for ; Thu, 29 Dec 2022 20:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233841AbiL2UFM (ORCPT ); Thu, 29 Dec 2022 15:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233886AbiL2UFK (ORCPT ); Thu, 29 Dec 2022 15:05:10 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0355B167CB for ; Thu, 29 Dec 2022 12:05:10 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id 20so6453059plo.3 for ; Thu, 29 Dec 2022 12:05:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; 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=D97gZO02zquDgcm7K4u6L4rTn9priLTA6Jh37BL7zRw=; b=Zq5LtO+m7N/Al+Ndcxo7C3dHQ3if3lxoH34/P+I+8HNuyLUoNP0YYXju6Qyl1xQJJ/ 2Q/aew1o+sJTSHs7eelwv/0xYvfDEQPG70rQP15lup4nYRuxWvwH+1boSwr4X4xy9P8H zVROzHTAb7G+OMZzZqpscxRhtSsHATejiHdco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=D97gZO02zquDgcm7K4u6L4rTn9priLTA6Jh37BL7zRw=; b=PqWJ0YGVlCIHI5Ab4pYphcGkWNRmF4TyjJ115ehB6LmXwIykl7FvZBN2zqSOH0stbx 2FFDxu4yweXKEy1y2rKmHsuT88iaf4QA1JjSm/LiFNhCp05JeLpZABHciK9fmpwUBgiD R4CR0wqtbos31FARyVH8MPGuv+Tzi8D+OP1RzqSH+SLr+wYtJ5t9kRvDknu9qoNP6vev Udp2Od/EUOB4marDpKn7yx2epKbu/AkSQZl+bf4cBfhM4pYoufwSlvA2XlNCX3BcJ9kD e+2dHgfpuz02VqGGDTB62/IY+r/3c/U335Il9FKKKTbsvIW/X1HqVC69XmUtI51wckve k4eg== X-Gm-Message-State: AFqh2krpnM2ZdMRdGfWf7Z3NKkQtU/OgAbfo5VCTD/UNZ3OCfJFB29Ab 3juDEKuxP8/Ul7TpTekaKr6uIw== X-Google-Smtp-Source: AMrXdXuh6ymW7m41dNTlmOb0eeXYgoLwkXP/Y+DgscSaYg24IHb3zsaixsX8f8wpTM3Q7voM/KKWRQ== X-Received: by 2002:a17:902:ce83:b0:189:dc9e:cef3 with SMTP id f3-20020a170902ce8300b00189dc9ecef3mr40201778plg.16.1672344309688; Thu, 29 Dec 2022 12:05:09 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b00189ac5a2340sm13438589plg.124.2022.12.29.12.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 12:05:09 -0800 (PST) From: Doug Brown To: Ulf Hansson , Adrian Hunter Cc: Rob Herring , Krzysztof Kozlowski , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, Doug Brown , Krzysztof Kozlowski Subject: [PATCH v3 8/8] dt-bindings: mmc: sdhci-pxa: add pxav1 Date: Thu, 29 Dec 2022 12:04:11 -0800 Message-Id: <20221229200411.295339-9-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229200411.295339-1-doug@schmorgal.com> References: <20221229200411.295339-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add a compatible for the pxav1 controller in the PXA168, along with optional pinctrl properties to use for an errata workaround. Signed-off-by: Doug Brown Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/mmc/sdhci-pxa.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/sdhci-pxa.yaml b/Documentation/devicetree/bindings/mmc/sdhci-pxa.yaml index 1c87f4218e18..09455f9fa8de 100644 --- a/Documentation/devicetree/bindings/mmc/sdhci-pxa.yaml +++ b/Documentation/devicetree/bindings/mmc/sdhci-pxa.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/mmc/sdhci-pxa.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Marvell PXA SDHCI v2/v3 bindings +title: Marvell PXA SDHCI v1/v2/v3 maintainers: - Ulf Hansson @@ -34,6 +34,7 @@ allOf: properties: compatible: enum: + - mrvl,pxav1-mmc - mrvl,pxav2-mmc - mrvl,pxav3-mmc - marvell,armada-380-sdhci @@ -61,6 +62,22 @@ properties: - const: io - const: core + pinctrl-names: + description: + Optional for supporting PXA168 SDIO IRQ errata to switch CMD pin between + SDIO CMD and GPIO mode. + items: + - const: default + - const: state_cmd_gpio + + pinctrl-0: + description: + Should contain default pinctrl. + + pinctrl-1: + description: + Should switch CMD pin to GPIO mode as a high output. + mrvl,clk-delay-cycles: description: Specify a number of cycles to delay for tuning. $ref: /schemas/types.yaml#/definitions/uint32