From patchwork Sun Mar 12 17:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Lisov X-Patchwork-Id: 13171736 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 8D1E3C6FA99 for ; Sun, 12 Mar 2023 18:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbjCLSQN (ORCPT ); Sun, 12 Mar 2023 14:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232171AbjCLSPx (ORCPT ); Sun, 12 Mar 2023 14:15:53 -0400 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D5D921A0B for ; Sun, 12 Mar 2023 11:08:22 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id b10so10438068ljr.0 for ; Sun, 12 Mar 2023 11:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678644287; h=cc:to:subject:date:from:message-id:from:to:cc:subject:date :message-id:reply-to; bh=THHnNubc2+UuqNjcDLN8j6le5gzsAvvJJbRATCHsptA=; b=WSQwHyx0Zu1wxpiUOe0rrfJmYxZQhQCZNMNAhhO3qpeuE1sOvBSjA23P/0ankrG3k9 NpX9Mw3SECa/Jv9XtpvKgLrxsfCsXY9nILLmGc/zOCFaXvjZXAbzFbH059n3jjcUwGLJ +Px55MOsDiD1+s508fOtCtRVHPTjV9kchlYkl+XNm859DQuBAQevbfD1KYOpHdE7FiyF LOX4vqleu5zVChs/XmDOdj57xxnCgo7Tcbz9HyYZWDsS+o6EF1riU+iWMC5b3fNXmA5q 9vKKc8tacE3DnbjeczVQI4khPkSYZoj2oI11suMBqrG/5aRfk/1n1nyKID1SooKs0QXV bv2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678644287; h=cc:to:subject:date:from:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=THHnNubc2+UuqNjcDLN8j6le5gzsAvvJJbRATCHsptA=; b=ZfM1s6KFsv7XwST83UXeo7Og7PY7bt42DRZCtNWuKE3N872PZsTOCY23MzbcxNfKPE yeCtR+UDI+8RFyboCZdIG4AyGKlNbK3U/PH1QY2hwh0gpkWxJPHDOy47A7f6dLHaiutF eznJ+TDDoyn7R9qjOYctn+WUNa9DrJ36AVCrCDHeqtQocUZfOSPR0Hj9Xpjsu4L/sSQN EMxWfrsb0rIILZPIiTKBW4L5kU6mwhqzQcf/r3Er0BOezReHI8vHkAUVciH5WmYIPDrP QY7vNW1iuyfhnENWxHBxu3dsL/oj4zUOrlasAlZuxOd4guX5NuyxCTrPOMO5AyzqT4D9 GUtw== X-Gm-Message-State: AO0yUKXnSfk2rZo31H4Eus01oho6gD+LWlmpCJeOdMhjEYPrBWMwkWjk opKDPpEoa/L0/g/6V44+UVBMjiJgX4IA+WQG X-Google-Smtp-Source: AK7set9r9UxJees8xWjmdulg8ucGHojcP9q3eHgjTiJV//JfW25xU1WtJtLS1ucfAgTj3zqzmOLkwQ== X-Received: by 2002:a2e:8816:0:b0:295:a96e:4f22 with SMTP id x22-20020a2e8816000000b00295a96e4f22mr8803480ljh.17.1678644287214; Sun, 12 Mar 2023 11:04:47 -0700 (PDT) Received: from 0001-dt-bindings-exynos-dw-mshc-common-add-exynos7885-var.patch (46-138-144-249.dynamic.spd-mgts.ru. [46.138.144.249]) by smtp.gmail.com with ESMTPSA id s6-20020a05651c200600b00295a8c68585sm723054ljo.56.2023.03.12.11.04.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 11:04:46 -0700 (PDT) Message-ID: <640e143e.050a0220.73b97.1b14@mx.google.com> From: Sergey Lisov Date: Sun, 12 Mar 2023 20:58:50 +0300 Subject: [PATCH v5 1/3] dt-bindings: exynos-dw-mshc-common: add exynos7885 variants To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Alim Akhtar , Jaehoon Chung Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Some Samsung Exynos boards using the arm64 architecture have DW MMC controllers configured for a 32-bit data bus but a 64-bit FIFO. On these systems the 64-bit FIFO registers must be accessed in two 32-bit halves. Add two new compatible strings, "samsung,exynos7885-dw-mshc" and "samsung,exynos7885-dw-mshc-smu" respectively, to denote exynos7885 boards that need this quirk. But it's very possible that all "samsung,exynos7-dw-mshc" boards are actually affected. --- .../devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml b/Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml index fdaa18481..3eebaed2c 100644 --- a/Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml +++ b/Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml @@ -22,6 +22,8 @@ properties: - samsung,exynos5420-dw-mshc-smu - samsung,exynos7-dw-mshc - samsung,exynos7-dw-mshc-smu + - samsung,exynos7885-dw-mshc + - samsung,exynos7885-dw-mshc-smu - axis,artpec8-dw-mshc reg: From patchwork Sun Mar 12 17:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Lisov X-Patchwork-Id: 13171740 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 654BAC6FA99 for ; Sun, 12 Mar 2023 18:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbjCLSZK (ORCPT ); Sun, 12 Mar 2023 14:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232342AbjCLSYy (ORCPT ); Sun, 12 Mar 2023 14:24:54 -0400 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 520FE10EC for ; Sun, 12 Mar 2023 11:17:58 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id s20so12968869lfb.11 for ; Sun, 12 Mar 2023 11:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678644676; h=cc:to:subject:date:from:in-reply-to:message-id:from:to:cc:subject :date:message-id:reply-to; bh=R/ZxX3DwmCtqhIm3cqoC0hxQvGcxZ6dvB//gAmJzTdM=; b=Xh/60ROSy7mUDvmLUiYPMFniWqGvJqYvdEu8qAuLSEdj9LuwBaJC/LCLOhP35Kqp17 b6bCVnzeTbyVboF/0n7+werVvnrl4+FOZKsjvWLS84HOgbaH2blRHq5XbgWjc3E/mvBT XrCXv2XwjfPcZ0p6ycNuYuzV6yS+hATbq8+WE5ij+PfaXDmIdRXKvb+NL+R+JYiOv/Pz n8i3HNX7tE9MoNQ/QIeank2hgWz1T7mYFXKl1qnkCxci8ndXqx4WNkoZaE7UrBN1l9Un nfZi8RUcr76O8dv2uG2JOqdL5ADLmwh1OenzsFY+4En8htI9mBSoUa8KJKfFJZtFBklM w4pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678644676; h=cc:to:subject:date:from:in-reply-to:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=R/ZxX3DwmCtqhIm3cqoC0hxQvGcxZ6dvB//gAmJzTdM=; b=TK8nRXlKiBeoq406fVBorC/FRz3nV4KCVr6/YiE36nyVq1QsfPE12DaV8J08D/3IXi G6qKyUzgCzzb0IIh2WLL4RhSooZJO99LhjwtB5Y/nvVfPq1+hv0YQrgnkHspgHJL8b/d 8YuHU8Vu2RusRyK+XzQd38e8Wbq6r3zUu7+GiC4jFK0xdpcdzkkxqJ5uWnd+4AAJT7UY 6cj6Avpk4BzFtbUS9upyPEo+kCdgAcImFkZlK1A59r7m5f/VVCeT1pnzmjmQsIHxnwn0 9HiQNeGlgcv+JC8GCNPXh3APPgGzY1SyzttpoH/Ue+9XfeuLN2486EG98uRp8q0L9MTU hedg== X-Gm-Message-State: AO0yUKW2qBAzxb6+BZYRxLvWeVCtjUY1ype0vJpvrHeQN8PFYoau15os hhaBjT2Aupp1H6fk7RKCgUYxAAuXKVPu3SA8 X-Google-Smtp-Source: AK7set+aQi+WYPRWJZGW2XG2j+dCz7snh1zt2EqgX8SFjft2X7p5+HIHCIPwoqJ/Y9EGareBfTbENw== X-Received: by 2002:ac2:5498:0:b0:4da:fb89:fcc6 with SMTP id t24-20020ac25498000000b004dafb89fcc6mr8966092lfk.57.1678644676371; Sun, 12 Mar 2023 11:11:16 -0700 (PDT) Received: from 0002-mmc-dw_mmc-add-an-option-to-force-32-bit-access-to-6.patch (46-138-144-249.dynamic.spd-mgts.ru. [46.138.144.249]) by smtp.gmail.com with ESMTPSA id q6-20020ac25146000000b004dc6070e121sm727756lfd.83.2023.03.12.11.11.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 11:11:16 -0700 (PDT) Message-Id: <1678644516.665314-2-sleirsgoevy@gmail.com> In-Reply-To: <1678644516.665314-0-sleirsgoevy@gmail.com> From: Sergey Lisov Date: Sun, 12 Mar 2023 20:58:50 +0300 Subject: [PATCH v5 2/3] mmc: dw_mmc: add an option to force 32-bit access to 64-bit FIFO To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Alim Akhtar , Jaehoon Chung Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Some Samsung Exynos boards using the arm64 architecture have DW MMC controllers configured for a 32-bit data bus but a 64-bit FIFO. On these systems the 64-bit FIFO registers must be accessed in two 32-bit halves. --- drivers/mmc/host/dw_mmc-exynos.c | 43 ++++++++++- drivers/mmc/host/dw_mmc.c | 122 ++++++++++++++++++++++++++++++- drivers/mmc/host/dw_mmc.h | 2 + 3 files changed, 164 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c index 9f20ac524..b4c0ba2eb 100644 --- a/drivers/mmc/host/dw_mmc-exynos.c +++ b/drivers/mmc/host/dw_mmc-exynos.c @@ -28,6 +28,8 @@ enum dw_mci_exynos_type { DW_MCI_TYPE_EXYNOS5420_SMU, DW_MCI_TYPE_EXYNOS7, DW_MCI_TYPE_EXYNOS7_SMU, + DW_MCI_TYPE_EXYNOS78XX, + DW_MCI_TYPE_EXYNOS78XX_SMU, DW_MCI_TYPE_ARTPEC8, }; @@ -70,6 +72,12 @@ static struct dw_mci_exynos_compatible { }, { .compatible = "samsung,exynos7-dw-mshc-smu", .ctrl_type = DW_MCI_TYPE_EXYNOS7_SMU, + }, { + .compatible = "samsung,exynos7885-dw-mshc", + .ctrl_type = DW_MCI_TYPE_EXYNOS78XX, + }, { + .compatible = "samsung,exynos7885-dw-mshc-smu", + .ctrl_type = DW_MCI_TYPE_EXYNOS78XX_SMU, }, { .compatible = "axis,artpec8-dw-mshc", .ctrl_type = DW_MCI_TYPE_ARTPEC8, @@ -86,6 +94,8 @@ static inline u8 dw_mci_exynos_get_ciu_div(struct dw_mci *host) return EXYNOS4210_FIXED_CIU_CLK_DIV; else if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) return SDMMC_CLKSEL_GET_DIV(mci_readl(host, CLKSEL64)) + 1; else @@ -101,7 +111,8 @@ static void dw_mci_exynos_config_smu(struct dw_mci *host) * set for non-ecryption mode at this time. */ if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS5420_SMU || - priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU) { + priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU) { mci_writel(host, MPSBEGIN0, 0); mci_writel(host, MPSEND0, SDMMC_ENDING_SEC_NR_MAX); mci_writel(host, MPSCTRL0, SDMMC_MPSCTRL_SECURE_WRITE_BIT | @@ -127,6 +138,12 @@ static int dw_mci_exynos_priv_init(struct dw_mci *host) DQS_CTRL_GET_RD_DELAY(priv->saved_strobe_ctrl); } + if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU) { + /* Quirk needed for certain Exynos SoCs */ + host->quirks |= DW_MMC_QUIRK_FIFO64_32; + } + if (priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) { /* Quirk needed for the ARTPEC-8 SoC */ host->quirks |= DW_MMC_QUIRK_EXTENDED_TMOUT; @@ -144,6 +161,8 @@ static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) clksel = mci_readl(host, CLKSEL64); else @@ -153,6 +172,8 @@ static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) mci_writel(host, CLKSEL64, clksel); else @@ -223,6 +244,8 @@ static int dw_mci_exynos_resume_noirq(struct device *dev) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) clksel = mci_readl(host, CLKSEL64); else @@ -231,6 +254,8 @@ static int dw_mci_exynos_resume_noirq(struct device *dev) if (clksel & SDMMC_CLKSEL_WAKEUP_INT) { if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) mci_writel(host, CLKSEL64, clksel); else @@ -410,6 +435,8 @@ static inline u8 dw_mci_exynos_get_clksmpl(struct dw_mci *host) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) return SDMMC_CLKSEL_CCLK_SAMPLE(mci_readl(host, CLKSEL64)); else @@ -423,6 +450,8 @@ static inline void dw_mci_exynos_set_clksmpl(struct dw_mci *host, u8 sample) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) clksel = mci_readl(host, CLKSEL64); else @@ -430,6 +459,8 @@ static inline void dw_mci_exynos_set_clksmpl(struct dw_mci *host, u8 sample) clksel = SDMMC_CLKSEL_UP_SAMPLE(clksel, sample); if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) mci_writel(host, CLKSEL64, clksel); else @@ -444,6 +475,8 @@ static inline u8 dw_mci_exynos_move_next_clksmpl(struct dw_mci *host) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) clksel = mci_readl(host, CLKSEL64); else @@ -454,6 +487,8 @@ static inline u8 dw_mci_exynos_move_next_clksmpl(struct dw_mci *host) if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX || + priv->ctrl_type == DW_MCI_TYPE_EXYNOS78XX_SMU || priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) mci_writel(host, CLKSEL64, clksel); else @@ -633,6 +668,12 @@ static const struct of_device_id dw_mci_exynos_match[] = { .data = &exynos_drv_data, }, { .compatible = "samsung,exynos7-dw-mshc-smu", .data = &exynos_drv_data, }, + /* XXX: more SoCs probably have the same quirk, + the compatible should be something more generic */ + { .compatible = "samsung,exynos7885-dw-mshc", + .data = &exynos_drv_data, }, + { .compatible = "samsung,exynos7885-dw-mshc-smu", + .data = &exynos_drv_data, }, { .compatible = "axis,artpec8-dw-mshc", .data = &artpec_drv_data, }, {}, diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 581614196..9fe816c61 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2575,6 +2575,119 @@ static void dw_mci_pull_data64(struct dw_mci *host, void *buf, int cnt) } } +/* + Some dw_mmc devices have 64-bit FIFOs, but expect them to be + accessed using two 32-bit accesses. If such controller is used + with a 64-bit kernel, this has to be done explicitly. + + XXX: Is this issue specific to Exynos7? +*/ + +static inline uint64_t mci_fifo_readq_32(void __iomem *addr) +{ + uint64_t ans; + uint32_t proxy[2]; + + proxy[0] = mci_fifo_readl(addr); + proxy[1] = mci_fifo_readl(addr+4); + memcpy(&ans, proxy, 8); + return ans; +} + +static inline void mci_fifo_writeq_32(void __iomem *addr, uint64_t value) +{ + uint32_t proxy[2]; + + memcpy(proxy, &value, 8); + mci_fifo_writel(addr, proxy[0]); + mci_fifo_writel(addr+4, proxy[1]); +} + +static void dw_mci_push_data64_32(struct dw_mci *host, void *buf, int cnt) +{ + struct mmc_data *data = host->data; + int init_cnt = cnt; + + /* try and push anything in the part_buf */ + if (unlikely(host->part_buf_count)) { + int len = dw_mci_push_part_bytes(host, buf, cnt); + + buf += len; + cnt -= len; + + if (host->part_buf_count == 8) { + mci_fifo_writeq_32(host->fifo_reg, host->part_buf); + host->part_buf_count = 0; + } + } +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + if (unlikely((unsigned long)buf & 0x7)) { + while (cnt >= 8) { + u64 aligned_buf[16]; + int len = min(cnt & -8, (int)sizeof(aligned_buf)); + int items = len >> 3; + int i; + /* memcpy from input buffer into aligned buffer */ + memcpy(aligned_buf, buf, len); + buf += len; + cnt -= len; + /* push data from aligned buffer into fifo */ + for (i = 0; i < items; ++i) + mci_fifo_writeq_32(host->fifo_reg, aligned_buf[i]); + } + } else +#endif + { + u64 *pdata = buf; + + for (; cnt >= 8; cnt -= 8) + mci_fifo_writeq_32(host->fifo_reg, *pdata++); + buf = pdata; + } + /* put anything remaining in the part_buf */ + if (cnt) { + dw_mci_set_part_bytes(host, buf, cnt); + /* Push data if we have reached the expected data length */ + if ((data->bytes_xfered + init_cnt) == + (data->blksz * data->blocks)) + mci_fifo_writeq_32(host->fifo_reg, host->part_buf); + } +} + +static void dw_mci_pull_data64_32(struct dw_mci *host, void *buf, int cnt) +{ +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + if (unlikely((unsigned long)buf & 0x7)) { + while (cnt >= 8) { + /* pull data from fifo into aligned buffer */ + u64 aligned_buf[16]; + int len = min(cnt & -8, (int)sizeof(aligned_buf)); + int items = len >> 3; + int i; + + for (i = 0; i < items; ++i) + aligned_buf[i] = mci_fifo_readq_32(host->fifo_reg); + + /* memcpy from aligned buffer into output buffer */ + memcpy(buf, aligned_buf, len); + buf += len; + cnt -= len; + } + } else +#endif + { + u64 *pdata = buf; + + for (; cnt >= 8; cnt -= 8) + *pdata++ = mci_fifo_readq_32(host->fifo_reg); + buf = pdata; + } + if (cnt) { + host->part_buf = mci_fifo_readq_32(host->fifo_reg); + dw_mci_pull_final_bytes(host, buf, cnt); + } +} + static void dw_mci_pull_data(struct dw_mci *host, void *buf, int cnt) { int len; @@ -3367,8 +3480,13 @@ int dw_mci_probe(struct dw_mci *host) width = 16; host->data_shift = 1; } else if (i == 2) { - host->push_data = dw_mci_push_data64; - host->pull_data = dw_mci_pull_data64; + if ((host->quirks & DW_MMC_QUIRK_FIFO64_32)) { + host->push_data = dw_mci_push_data64_32; + host->pull_data = dw_mci_pull_data64_32; + } else { + host->push_data = dw_mci_push_data64; + host->pull_data = dw_mci_pull_data64; + } width = 64; host->data_shift = 3; } else { diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index 4ed81f94f..edd642b92 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h @@ -280,6 +280,8 @@ struct dw_mci_board { /* Support for longer data read timeout */ #define DW_MMC_QUIRK_EXTENDED_TMOUT BIT(0) +/* Force 32-bit access to the FIFO */ +#define DW_MMC_QUIRK_FIFO64_32 BIT(1) #define DW_MMC_240A 0x240a #define DW_MMC_280A 0x280a From patchwork Sun Mar 12 17:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Lisov X-Patchwork-Id: 13171739 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 4F71BC6FD19 for ; Sun, 12 Mar 2023 18:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231361AbjCLSZH (ORCPT ); Sun, 12 Mar 2023 14:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbjCLSYv (ORCPT ); Sun, 12 Mar 2023 14:24:51 -0400 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA846905D for ; Sun, 12 Mar 2023 11:17:53 -0700 (PDT) Received: by mail-lj1-f171.google.com with SMTP id f16so10385813ljq.10 for ; Sun, 12 Mar 2023 11:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678644704; h=cc:to:subject:date:from:in-reply-to:message-id:from:to:cc:subject :date:message-id:reply-to; bh=rC/o1AQDcGAyPZ0tU6+VZIwVNayEqqDcPKH36IGj0wI=; b=Bjoj1S0EQ3nkblsbxvnueg540So/ragV5zW7BBKaESp8iU1LuECMUeIGeImVFPhvct gUK8mN0tDEn05utCq045NVz9/iLAhQkjdeEXdhWKXl+DJLqQgM/gLijG5uNXVg49CTpb 1b1Pt7BUzrC+X7Na0MPTtKtLUl16rEA4Wrx2pALRoOHbAHLAJHMJEqCU9dXDq/18TjgP 20F+cnip1jaHTzA6zCEAB5XhaHH0cXwVzI5ey9He1ac/9jOh37uuXA3KvHhXguB6Dnvb k+TI0oc8G90WnQjhn1HyxRdI/HZ6ThFxADmdUWOXCSkQEGIeyuitwRNeAGwKAyJXBen6 R5sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678644704; h=cc:to:subject:date:from:in-reply-to:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rC/o1AQDcGAyPZ0tU6+VZIwVNayEqqDcPKH36IGj0wI=; b=mpw1YsB6xuuts7WRQjvpz9LPBX7IsriLADnrXwLsTDKGIF/LOlmkJ1SNnpt1D3ft3K 8EUxS7wggjpLXkSkfqBQY6l8jp34Ggv9Gz6POq7no7TOK4z36faRbqzD+a17W5s/Zq9h OysnWZwBUH/nMYgJZIV6d8zNLmsup+r2pdadIeU6FcTcH4bIWbbfDTPZOiAEXgCYHzVL IfpsBeZLl8BD+9/JbCFgl9cqEP4hz8A5O/v0j8+k6lLa1lJlm0VZDNmI4Pmjt3ZyG0V0 g9KinlFuI4IIndqrarNpV6Ey8N4VgYHHYl9F1vFLhHo0XQup3fQX8dHdAsaSXcKPOJDG hGWA== X-Gm-Message-State: AO0yUKXvdo+ZfD17HBsNPdd1bH7fRC+wv/iAIh4oNUyQ/3SADc5V00jL fOucsVZ4p8Ih55BhEM6SFykZ1aDu83a2MVS3 X-Google-Smtp-Source: AK7set97YdzV5ot/3klk5YmDmpCdIaKTUmPak62EXa0iPBKROOH+M9WHoxMLhrj3PWZzxOoYFVkkxg== X-Received: by 2002:a2e:b17a:0:b0:293:32e0:5c8a with SMTP id a26-20020a2eb17a000000b0029332e05c8amr9142247ljm.15.1678644703932; Sun, 12 Mar 2023 11:11:43 -0700 (PDT) Received: from 0003-arm64-dts-exynos-fix-wrong-mmc-compatible-in-exynos7.patch (46-138-144-249.dynamic.spd-mgts.ru. [46.138.144.249]) by smtp.gmail.com with ESMTPSA id s21-20020a2e9c15000000b00295765966d9sm718324lji.86.2023.03.12.11.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 11:11:43 -0700 (PDT) Message-Id: <1678644516.665314-3-sleirsgoevy@gmail.com> In-Reply-To: <1678644516.665314-0-sleirsgoevy@gmail.com> From: Sergey Lisov Date: Sun, 12 Mar 2023 20:58:50 +0300 Subject: [PATCH v5 3/3] arm64: dts: exynos: fix wrong mmc compatible in exynos7885.dtsi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Alim Akhtar , Jaehoon Chung Cc: linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This DW-MMC variant is not actually compatible with "samsung,exynos7-dw-mshc-smu", and requires an additional quirk to handle very short data transfers, typically used by SDIO cards. Update the compatible string to "samsung,exynos7885-dw-mshc-smu" to reflect this fact. --- arch/arm64/boot/dts/exynos/exynos7885.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/exynos/exynos7885.dtsi b/arch/arm64/boot/dts/exynos/exynos7885.dtsi index 23c2e0bb0..b0addb0b3 100644 --- a/arch/arm64/boot/dts/exynos/exynos7885.dtsi +++ b/arch/arm64/boot/dts/exynos/exynos7885.dtsi @@ -294,7 +294,7 @@ pmu_system_controller: system-controller@11c80000 { }; mmc_0: mmc@13500000 { - compatible = "samsung,exynos7-dw-mshc-smu"; + compatible = "samsung,exynos7885-dw-mshc-smu"; reg = <0x13500000 0x2000>; interrupts = ; #address-cells = <1>;