From patchwork Sun Apr 16 09:19:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 674398 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 AEE14C77B7D for ; Sun, 16 Apr 2023 09:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbjDPJUD (ORCPT ); Sun, 16 Apr 2023 05:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbjDPJT5 (ORCPT ); Sun, 16 Apr 2023 05:19:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C98D1BD9; Sun, 16 Apr 2023 02:19:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24EF161196; Sun, 16 Apr 2023 09:19:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 6203BC433D2; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681636794; bh=G2tLPQgRxtDu3DlqJOjUZMbxuxbA9j8nbZJ62Yt8Xr4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jWP4Q8xoCyyOeR3MlQlNXLYxvte5UQiMwK6TDMKF1+Gi+7vGMttS7t8d8VIF+b8oR weEm/tOdDTLVy29OKITUI69CRqMuFnDMJoiFrZOeau7VsgF9udpq+F9G0ngbj1K6Wf jTR+/ELNYG/OKlEOVtHhQ/x9azsDkw+boJr/lg3Z26ZUj91z3I3WYEizCeYd5dUgl4 WnaJpxBx78PqljSW3GHU+gSbwtqoP3UATQoLBozn9c+dGfWotZu2USQ+xv2L5fmKXp 5raAuGXcOAE4lm5DfsC4M14GRylb2aJLILZQDnDtaUo9RC2U7qSWGESuXRI+ojuVGi KtAPZodWKoXHw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CC53C77B61; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Sun, 16 Apr 2023 17:19:32 +0800 Subject: [PATCH RFC v4 1/4] mmc: dw_mmc: hi3798cv200: rename to dw_mmc-histb MIME-Version: 1.0 Message-Id: <20230415-mmc-hi3798mv200-v4-1-44096e187f53@outlook.com> References: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> In-Reply-To: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> To: Ulf Hansson , Jaehoon Chung , Rob Herring , Krzysztof Kozlowski , Yang Xiwen Cc: tianshuliang , Jiancheng Xue , Shawn Guo , David Yang , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681636790; l=7027; i=forbidden405@outlook.com; s=20230415; h=from:subject:message-id; bh=eoErTepi3JKctxpmeTvJxlWPwF/xYjRv313AFyJJwn4=; b=YYTa8vVDUHg9l5nOGKN5QDo8WGPdwCoPxvyFcz+VAe+4Ug4VFjmp6JGvSSwM8lpl/CDIx9lUS ohLgGjx0qtPAS1NvoCIrClpxJpu879nD6dhSagEgfTOqD0aFohLDWls X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=hfdpPU3AXR+t7fdv58tXCD4UzRNq+fop2TMJezFlAhM= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230415 with auth_id=44 X-Original-From: Yang Xiwen Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Yang Xiwen Rename to dw_mmc-histb and introduce a mechanism similar to dw-mmc_exynos to support more devices in a single driver. It is a preparation for introducing extension for Hi3798MV200. Signed-off-by: Yang Xiwen --- drivers/mmc/host/Kconfig | 8 +-- drivers/mmc/host/Makefile | 2 +- .../host/{dw_mmc-hi3798cv200.c => dw_mmc-histb.c} | 79 ++++++++++++++-------- 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 4745fe217ade3..0aef4d845b743 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -779,14 +779,14 @@ config MMC_DW_EXYNOS Synopsys DesignWare Memory Card Interface driver. Select this option for platforms based on Exynos4 and Exynos5 SoC's. -config MMC_DW_HI3798CV200 - tristate "Hi3798CV200 specific extensions for Synopsys DW Memory Card Interface" +config MMC_DW_HISTB + tristate "HiSTB specific extensions for Synopsys DW Memory Card Interface" depends on MMC_DW select MMC_DW_PLTFM help - This selects support for HiSilicon Hi3798CV200 SoC specific extensions to the + This selects support for HiSilicon HiSTB SoC specific extensions to the Synopsys DesignWare Memory Card Interface driver. Select this option - for platforms based on HiSilicon Hi3798CV200 SoC. + for platforms based on HiSilicon HiSTB SoC. config MMC_DW_K3 tristate "K3 specific extensions for Synopsys DW Memory Card Interface" diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index a693fa3d3f1cc..0373741afebf1 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -50,7 +50,7 @@ obj-$(CONFIG_MMC_DW) += dw_mmc.o obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o obj-$(CONFIG_MMC_DW_BLUEFIELD) += dw_mmc-bluefield.o obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o -obj-$(CONFIG_MMC_DW_HI3798CV200) += dw_mmc-hi3798cv200.o +obj-$(CONFIG_MMC_DW_HISTB) += dw_mmc-histb.o obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o obj-$(CONFIG_MMC_DW_ROCKCHIP) += dw_mmc-rockchip.o diff --git a/drivers/mmc/host/dw_mmc-hi3798cv200.c b/drivers/mmc/host/dw_mmc-histb.c similarity index 69% rename from drivers/mmc/host/dw_mmc-hi3798cv200.c rename to drivers/mmc/host/dw_mmc-histb.c index 6f22fe0540879..106e586bcff4b 100644 --- a/drivers/mmc/host/dw_mmc-hi3798cv200.c +++ b/drivers/mmc/host/dw_mmc-histb.c @@ -18,14 +18,29 @@ #define ALL_INT_CLR 0x1ffff -struct hi3798cv200_priv { +enum dw_mci_histb_type { + DW_MCI_TYPE_HI3798CV200, +}; + +static struct dw_mci_histb_compat { + const char * const compatible; + enum dw_mci_histb_type ctrl_type; +} histb_compat[] = { + { + .compatible = "hisilicon,hi3798cv200-dw-mshc", + .ctrl_type = DW_MCI_TYPE_HI3798CV200, + }, +}; + +struct dw_mci_histb_priv { + enum dw_mci_histb_type ctrl_type; struct clk *sample_clk; struct clk *drive_clk; }; -static void dw_mci_hi3798cv200_set_ios(struct dw_mci *host, struct mmc_ios *ios) +static void dw_mci_histb_set_ios(struct dw_mci *host, struct mmc_ios *ios) { - struct hi3798cv200_priv *priv = host->priv; + struct dw_mci_histb_priv *priv = host->priv; u32 val; val = mci_readl(host, UHS_REG); @@ -62,7 +77,7 @@ static int dw_mci_hi3798cv200_execute_tuning(struct dw_mci_slot *slot, { static const int degrees[] = { 0, 45, 90, 135, 180, 225, 270, 315 }; struct dw_mci *host = slot->host; - struct hi3798cv200_priv *priv = host->priv; + struct dw_mci_histb_priv *priv = host->priv; int raise_point = -1, fall_point = -1; int err, prev_err = -1; int found = 0; @@ -118,15 +133,21 @@ static int dw_mci_hi3798cv200_execute_tuning(struct dw_mci_slot *slot, return err; } -static int dw_mci_hi3798cv200_init(struct dw_mci *host) +static int dw_mci_histb_init(struct dw_mci *host) { - struct hi3798cv200_priv *priv; - int ret; + struct dw_mci_histb_priv *priv; + struct device_node *np = host->dev->of_node; + int ret, idx; priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; + for (idx = 0; idx < ARRAY_SIZE(histb_compat); idx++) { + if (of_device_is_compatible(np, histb_compat[idx].compatible)) + priv->ctrl_type = histb_compat[idx].ctrl_type; + } + priv->sample_clk = devm_clk_get(host->dev, "ciu-sample"); if (IS_ERR(priv->sample_clk)) { dev_err(host->dev, "failed to get ciu-sample clock\n"); @@ -161,20 +182,29 @@ static int dw_mci_hi3798cv200_init(struct dw_mci *host) static const struct dw_mci_drv_data hi3798cv200_data = { .common_caps = MMC_CAP_CMD23, - .init = dw_mci_hi3798cv200_init, - .set_ios = dw_mci_hi3798cv200_set_ios, + .init = dw_mci_histb_init, + .set_ios = dw_mci_histb_set_ios, .execute_tuning = dw_mci_hi3798cv200_execute_tuning, }; -static int dw_mci_hi3798cv200_probe(struct platform_device *pdev) +static const struct of_device_id dw_mci_histb_match[] = { + { .compatible = "hisilicon,hi3798cv200-dw-mshc", .data = &hi3798cv200_data }, + {}, +}; + +static int dw_mci_histb_probe(struct platform_device *pdev) { - return dw_mci_pltfm_register(pdev, &hi3798cv200_data); + const struct of_device_id *match; + + match = of_match_node(dw_mci_histb_match, pdev->dev.of_node); + + return dw_mci_pltfm_register(pdev, match->data); } -static int dw_mci_hi3798cv200_remove(struct platform_device *pdev) +static int dw_mci_histb_remove(struct platform_device *pdev) { struct dw_mci *host = platform_get_drvdata(pdev); - struct hi3798cv200_priv *priv = host->priv; + struct dw_mci_histb_priv *priv = host->priv; clk_disable_unprepare(priv->drive_clk); clk_disable_unprepare(priv->sample_clk); @@ -184,23 +214,18 @@ static int dw_mci_hi3798cv200_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id dw_mci_hi3798cv200_match[] = { - { .compatible = "hisilicon,hi3798cv200-dw-mshc", }, - {}, -}; - -MODULE_DEVICE_TABLE(of, dw_mci_hi3798cv200_match); -static struct platform_driver dw_mci_hi3798cv200_driver = { - .probe = dw_mci_hi3798cv200_probe, - .remove = dw_mci_hi3798cv200_remove, +MODULE_DEVICE_TABLE(of, dw_mci_histb_match); +static struct platform_driver dw_mci_histb_driver = { + .probe = dw_mci_histb_probe, + .remove = dw_mci_histb_remove, .driver = { - .name = "dwmmc_hi3798cv200", + .name = "dwmmc_histb", .probe_type = PROBE_PREFER_ASYNCHRONOUS, - .of_match_table = dw_mci_hi3798cv200_match, + .of_match_table = dw_mci_histb_match, }, }; -module_platform_driver(dw_mci_hi3798cv200_driver); +module_platform_driver(dw_mci_histb_driver); -MODULE_DESCRIPTION("HiSilicon Hi3798CV200 Specific DW-MSHC Driver Extension"); +MODULE_DESCRIPTION("HiSilicon HiSTB Specific DW-MSHC Driver Extension"); MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:dwmmc_hi3798cv200"); +MODULE_ALIAS("platform:dwmmc_histb"); From patchwork Sun Apr 16 09:19:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 673748 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 C4B34C77B7E for ; Sun, 16 Apr 2023 09:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230468AbjDPJUE (ORCPT ); Sun, 16 Apr 2023 05:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbjDPJT5 (ORCPT ); Sun, 16 Apr 2023 05:19:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60B61BF8; Sun, 16 Apr 2023 02:19:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 409816154C; Sun, 16 Apr 2023 09:19:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 7D70EC4339B; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681636794; bh=I1zVuCbwHLpIyH1CupVPrNbprfDrqjzfxLYjmXNkoeE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=L2fr4YZ991RBHMsa4dE9fIaiqvQlNAivske0YiPejv7xJVR0TmC+nZdO4u2cCX4ly LxCGT3gcu6U/ZMnvc34FsWTdLQZwiVf8TJnDIgkxywm5OOD5XcE2ecaTMEEvCNbVuA 0j6ST0brH5Vl0Y5nw/0oq8B+1peTpRBzMeTBuLf4bZjsn+wDx3N6CVyOlkWsaF4dtO H0bbBmV4FM3aiY5neJJlF5RsppORNOtIVQzTjFaW90tkpc3D1WSj+0bZei0gHRLC0s u2eTdPLpL19SRZO/NKzNJxe+swvplvGYg2P6ZR1vhVnuqW6WLknJGZES+Ok20m2plN EYyHDZOBPvTrg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A8D6C77B78; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Sun, 16 Apr 2023 17:19:33 +0800 Subject: [PATCH RFC v4 2/4] mmc: dw_mmc: histb: add support for hi3798mv200 MIME-Version: 1.0 Message-Id: <20230415-mmc-hi3798mv200-v4-2-44096e187f53@outlook.com> References: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> In-Reply-To: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> To: Ulf Hansson , Jaehoon Chung , Rob Herring , Krzysztof Kozlowski , Yang Xiwen Cc: tianshuliang , Jiancheng Xue , Shawn Guo , David Yang , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681636790; l=5756; i=forbidden405@outlook.com; s=20230415; h=from:subject:message-id; bh=BbS/l7vrq8NmARY0G9T42pzQupVXhImCLr1VN3mh6sA=; b=NaJ3JsS9sYSrJpq1ir9XLiiorhVxjjnWZ3uDs61Dc07TbH3T7hAKkv84cO6mo809hWVWuB7Yn SuR6nzCsmt1A0vnvodja5I+UNpZSNsEKLAMHyOcqRWW4gbl3FjjQj5Y X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=hfdpPU3AXR+t7fdv58tXCD4UzRNq+fop2TMJezFlAhM= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230415 with auth_id=44 X-Original-From: Yang Xiwen Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Yang Xiwen Add support for Hi3798MV200 specific extension. Signed-off-by: Yang Xiwen --- drivers/mmc/host/dw_mmc-histb.c | 110 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc-histb.c b/drivers/mmc/host/dw_mmc-histb.c index 106e586bcff4b..039b6df0e8c4d 100644 --- a/drivers/mmc/host/dw_mmc-histb.c +++ b/drivers/mmc/host/dw_mmc-histb.c @@ -16,10 +16,14 @@ #include "dw_mmc.h" #include "dw_mmc-pltfm.h" +#define SDMMC_TUNING_CTRL 0x118 +#define SDMMC_TUNING_FIND_EDGE BIT(5) + #define ALL_INT_CLR 0x1ffff enum dw_mci_histb_type { DW_MCI_TYPE_HI3798CV200, + DW_MCI_TYPE_HI3798MV200, }; static struct dw_mci_histb_compat { @@ -29,6 +33,9 @@ static struct dw_mci_histb_compat { { .compatible = "hisilicon,hi3798cv200-dw-mshc", .ctrl_type = DW_MCI_TYPE_HI3798CV200, + }, { + .compatible = "hisilicon,hi3798mv200-dw-mshc", + .ctrl_type = DW_MCI_TYPE_HI3798MV200, }, }; @@ -36,6 +43,7 @@ struct dw_mci_histb_priv { enum dw_mci_histb_type ctrl_type; struct clk *sample_clk; struct clk *drive_clk; + struct clk *sap_dll_mode_clk; }; static void dw_mci_histb_set_ios(struct dw_mci *host, struct mmc_ios *ios) @@ -68,7 +76,10 @@ static void dw_mci_histb_set_ios(struct dw_mci *host, struct mmc_ios *ios) if (ios->timing == MMC_TIMING_MMC_HS || ios->timing == MMC_TIMING_LEGACY) clk_set_phase(priv->drive_clk, 180); - else if (ios->timing == MMC_TIMING_MMC_HS200) + else if (ios->timing == MMC_TIMING_MMC_DDR52) { + clk_set_phase(priv->drive_clk, 90); + clk_set_phase(priv->sample_clk, 45); + } else if (ios->timing == MMC_TIMING_MMC_HS200) clk_set_phase(priv->drive_clk, 135); } @@ -133,6 +144,75 @@ static int dw_mci_hi3798cv200_execute_tuning(struct dw_mci_slot *slot, return err; } +static int dw_mci_hi3798mv200_execute_tuning_mix_mode(struct dw_mci_slot *slot, + u32 opcode) +{ + static const int degrees[] = { 0, 45, 90, 135, 180, 225, 270, 315 }; + struct dw_mci *host = slot->host; + struct dw_mci_histb_priv *priv = host->priv; + int raise_point = -1, fall_point = -1; + int err, prev_err = -1; + int found = 0; + int regval; + int i; + + clk_disable(priv->sap_dll_mode_clk); + for (i = 0; i < ARRAY_SIZE(degrees); i++) { + clk_set_phase(priv->sample_clk, degrees[i]); + mci_writel(host, RINTSTS, ALL_INT_CLR); + + err = mmc_send_tuning(slot->mmc, opcode, NULL); + if (err) + found = 1; + else { + regval = mci_readl(host, TUNING_CTRL); + if (regval & SDMMC_TUNING_FIND_EDGE) + found = 1; + }; + + if (i > 0) { + if (err && !prev_err) + fall_point = i - 1; + if (!err && prev_err) + raise_point = i; + } + + if (raise_point != -1 && fall_point != -1) + goto tuning_out; + + prev_err = err; + err = 0; + } + +tuning_out: + clk_enable(priv->sap_dll_mode_clk); + if (found) { + if (raise_point == -1) + raise_point = 0; + if (fall_point == -1) + fall_point = ARRAY_SIZE(degrees) - 1; + if (fall_point < raise_point) { + if ((raise_point + fall_point) > + (ARRAY_SIZE(degrees) - 1)) + i = fall_point / 2; + else + i = (raise_point + ARRAY_SIZE(degrees) - 1) / 2; + } else { + i = (raise_point + fall_point) / 2; + } + + clk_set_phase(priv->sample_clk, degrees[i]); + dev_dbg(host->dev, "Tuning clk_sample[%d, %d], set[%d]\n", + raise_point, fall_point, degrees[i]); + } else { + dev_err(host->dev, "No valid clk_sample shift! use default\n"); + err = -EINVAL; + } + + mci_writel(host, RINTSTS, ALL_INT_CLR); + return err; +} + static int dw_mci_histb_init(struct dw_mci *host) { struct dw_mci_histb_priv *priv; @@ -160,6 +240,14 @@ static int dw_mci_histb_init(struct dw_mci *host) return PTR_ERR(priv->drive_clk); } + if (priv->ctrl_type == DW_MCI_TYPE_HI3798MV200) { + priv->sap_dll_mode_clk = devm_clk_get(host->dev, "sap-dll-mode"); + if (IS_ERR(priv->sap_dll_mode_clk)) { + dev_err(host->dev, "failed to get sap-dll-mode clock\n"); + return PTR_ERR(priv->sap_dll_mode_clk); + } + } + ret = clk_prepare_enable(priv->sample_clk); if (ret) { dev_err(host->dev, "failed to enable ciu-sample clock\n"); @@ -172,9 +260,19 @@ static int dw_mci_histb_init(struct dw_mci *host) goto disable_sample_clk; } + if (priv->ctrl_type == DW_MCI_TYPE_HI3798MV200) { + ret = clk_prepare_enable(priv->sap_dll_mode_clk); + if (ret) { + dev_err(host->dev, "failed to disable tuning mode"); + goto disable_drive_clk; + } + } + host->priv = priv; return 0; +disable_drive_clk: + clk_disable_unprepare(priv->drive_clk); disable_sample_clk: clk_disable_unprepare(priv->sample_clk); return ret; @@ -187,8 +285,16 @@ static const struct dw_mci_drv_data hi3798cv200_data = { .execute_tuning = dw_mci_hi3798cv200_execute_tuning, }; +static const struct dw_mci_drv_data hi3798mv200_data = { + .common_caps = MMC_CAP_CMD23, + .init = dw_mci_histb_init, + .set_ios = dw_mci_histb_set_ios, + .execute_tuning = dw_mci_hi3798mv200_execute_tuning_mix_mode, +}; + static const struct of_device_id dw_mci_histb_match[] = { { .compatible = "hisilicon,hi3798cv200-dw-mshc", .data = &hi3798cv200_data }, + { .compatible = "hisilicon,hi3798mv200-dw-mshc", .data = &hi3798mv200_data }, {}, }; @@ -208,6 +314,8 @@ static int dw_mci_histb_remove(struct platform_device *pdev) clk_disable_unprepare(priv->drive_clk); clk_disable_unprepare(priv->sample_clk); + if (priv->ctrl_type == DW_MCI_TYPE_HI3798MV200) + clk_disable_unprepare(priv->sap_dll_mode_clk); dw_mci_pltfm_remove(pdev); From patchwork Sun Apr 16 09:19:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 673749 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 9F711C77B61 for ; Sun, 16 Apr 2023 09:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbjDPJUC (ORCPT ); Sun, 16 Apr 2023 05:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230390AbjDPJT5 (ORCPT ); Sun, 16 Apr 2023 05:19:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F731BE2; Sun, 16 Apr 2023 02:19:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3D764614D5; Sun, 16 Apr 2023 09:19:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 95A84C433A1; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681636794; bh=ib9tCapFZLqhkeZmj2BgyvctI5SvYex9afKYaDxW3L4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=tYeTA1qEf/0fU6OnFx2ufoGIExJLehH4sGobskFVTkU/qs6pTnIpjD14OslrLbs9Q haevmHEQJBvZLua1nWxVjbdh+rm/cj+tPkCZmR9bSn4eh8V7y0A62zdhZPs1dLX2CJ U2R94ctB8Yi9Yp8496Ha21KWpO+jZkmYTRDTXtgvX4QKpTNNIgSVj3aeiU4OhhMLUF Png2ycoMRV6JUmY4retTX2FCjkpSbkrF1NG477ua3dE3E9jc3UDvj3LWhP69MtYHeD RlJ3QLhbHVt1tYMo4qcpVLKubtG45VulORcaT4e6ZuyG3kaMz0e8W28LrxC7UHYL14 sWOLLzDOKlfmA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7852BC77B79; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Sun, 16 Apr 2023 17:19:34 +0800 Subject: [PATCH RFC v4 3/4] dt-binding: mmc: hi3798cv200-dw-mshc: convert to YAML and rename to histb-dw-mshc MIME-Version: 1.0 Message-Id: <20230415-mmc-hi3798mv200-v4-3-44096e187f53@outlook.com> References: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> In-Reply-To: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> To: Ulf Hansson , Jaehoon Chung , Rob Herring , Krzysztof Kozlowski , Yang Xiwen Cc: tianshuliang , Jiancheng Xue , Shawn Guo , David Yang , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681636790; l=4130; i=forbidden405@outlook.com; s=20230415; h=from:subject:message-id; bh=x4duf6C0UsmPpNL4gwKd9sFpOmI1G3aqFz1AACwdB8s=; b=M4d6nFfKc0nEUGxJdyEQYKaAqmjOWx2hwsSj/T+Z3SrsmBAlhewJIlO/HblM+Ci4jIkSAHzo4 l6FHmu5X0CHCneXLlg8+7oqv/pivg7SsqOWDBpWJY3FwTxDk2E9cEC7 X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=hfdpPU3AXR+t7fdv58tXCD4UzRNq+fop2TMJezFlAhM= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230415 with auth_id=44 X-Original-From: Yang Xiwen Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Yang Xiwen The renaming is due to the fact that it is now supporting SoCs other than Hi3798CV200. Signed-off-by: Yang Xiwen --- .../bindings/mmc/hi3798cv200-dw-mshc.txt | 40 ------------- .../bindings/mmc/hisilicon,histb-dw-mshc.yaml | 69 ++++++++++++++++++++++ 2 files changed, 69 insertions(+), 40 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/hi3798cv200-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/hi3798cv200-dw-mshc.txt deleted file mode 100644 index a0693b7145f2a..0000000000000 --- a/Documentation/devicetree/bindings/mmc/hi3798cv200-dw-mshc.txt +++ /dev/null @@ -1,40 +0,0 @@ -* Hisilicon Hi3798CV200 specific extensions to the Synopsys Designware Mobile - Storage Host Controller - -Read synopsys-dw-mshc.txt for more details - -The Synopsys designware mobile storage host controller is used to interface -a SoC with storage medium such as eMMC or SD/MMC cards. This file documents -differences between the core Synopsys dw mshc controller properties described -by synopsys-dw-mshc.txt and the properties used by the Hisilicon Hi3798CV200 -specific extensions to the Synopsys Designware Mobile Storage Host Controller. - -Required Properties: -- compatible: Should contain "hisilicon,hi3798cv200-dw-mshc". -- clocks: A list of phandle + clock-specifier pairs for the clocks listed - in clock-names. -- clock-names: Should contain the following: - "ciu" - The ciu clock described in synopsys-dw-mshc.txt. - "biu" - The biu clock described in synopsys-dw-mshc.txt. - "ciu-sample" - Hi3798CV200 extended phase clock for ciu sampling. - "ciu-drive" - Hi3798CV200 extended phase clock for ciu driving. - -Example: - - emmc: mmc@9830000 { - compatible = "hisilicon,hi3798cv200-dw-mshc"; - reg = <0x9830000 0x10000>; - interrupts = ; - clocks = <&crg HISTB_MMC_CIU_CLK>, - <&crg HISTB_MMC_BIU_CLK>, - <&crg HISTB_MMC_SAMPLE_CLK>, - <&crg HISTB_MMC_DRV_CLK>; - clock-names = "ciu", "biu", "ciu-sample", "ciu-drive"; - fifo-depth = <256>; - clock-frequency = <200000000>; - cap-mmc-highspeed; - mmc-ddr-1_8v; - mmc-hs200-1_8v; - non-removable; - bus-width = <8>; - }; diff --git a/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml b/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml new file mode 100644 index 0000000000000..301b6ad39c5af --- /dev/null +++ b/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mmc/histb-dw-mshc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: + Hisilicon HiSTB SoC specific extensions to the Synopsys Designware Mobile + Storage Host Controller + +maintainers: + - Yang Xiwen + +description: + The Synopsys designware mobile storage host controller is used to interface a + SoC with storage medium such as eMMC or SD/MMC cards. + +properties: + compatible: + enum: + - hisilicon,hi3798cv200-dw-mshc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: ciu + - const: biu + - const: ciu-sample + - const: ciu-drive + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + +allOf: + - $ref: synopsys-dw-mshc-common.yaml# + +unevaluatedProperties: false + +examples: + - | + emmc: mmc@9830000 { + compatible = "hisilicon,hi3798cv200-dw-mshc"; + reg = <0x9830000 0x10000>; + interrupts = <35>; + clocks = <&crg 1>, + <&crg 2>, + <&crg 3>, + <&crg 4>; + clock-names = "ciu", "biu", "ciu-sample", "ciu-drive"; + fifo-depth = <256>; + clock-frequency = <200000000>; + cap-mmc-highspeed; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + non-removable; + bus-width = <8>; + }; From patchwork Sun Apr 16 09:19:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 674399 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 290C5C77B78 for ; Sun, 16 Apr 2023 09:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbjDPJUB (ORCPT ); Sun, 16 Apr 2023 05:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbjDPJT5 (ORCPT ); Sun, 16 Apr 2023 05:19:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B61661BFB; Sun, 16 Apr 2023 02:19:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 431D161548; Sun, 16 Apr 2023 09:19:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 9FC2AC4339C; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681636794; bh=wsbojbo7df/LUKeCeNIX/OxYtqkIzPpLb1QyaWizIoU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ChyVdhKQxg6PzIeRASo8TBsWF6mjkmyxJU6Cfh6FM0H9dXwqlEaUH24BqHHf1l4A0 w0KmxPyXEn9kjmiHxU9XIlGtAALh1MfhqFFcK4MhQZSjAo7Dwke6o7BG6BXHnMSuHr YMi9NzMDcwP6q9OIGsTuKzIHrOzKn1GvUIqi22NYbSKIwF7rvFSMA1ld5TxIqdYA/a HCTXHNfZU/S9UNX8ATzXZBWnCxFAtAiRE0jwaNEXWy5Zs4WDY0uV0v8YfKfbPceTwe L0brjpPotpjzUR9x8dmCpXFc+Qr9fFpKp3C4Tv4sDtjDGEep681Mrr5Hw/mqYPxFG5 x8/KkovUn77dQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B6ADC77B76; Sun, 16 Apr 2023 09:19:54 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Sun, 16 Apr 2023 17:19:35 +0800 Subject: [PATCH RFC v4 4/4] dt-binding: mmc: histb-dw-mshc: Add Hi3798MV200 compatible string MIME-Version: 1.0 Message-Id: <20230415-mmc-hi3798mv200-v4-4-44096e187f53@outlook.com> References: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> In-Reply-To: <20230415-mmc-hi3798mv200-v4-0-44096e187f53@outlook.com> To: Ulf Hansson , Jaehoon Chung , Rob Herring , Krzysztof Kozlowski , Yang Xiwen Cc: tianshuliang , Jiancheng Xue , Shawn Guo , David Yang , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681636790; l=1593; i=forbidden405@outlook.com; s=20230415; h=from:subject:message-id; bh=q5GM8oNU5gnf/3ltWXbVzjwL+8fph3xf831mMOi9Dsk=; b=sASercxLEOoqglzvstfLuHzFGTm0s2nnT7EchZrLhr0uqiVFQtjGG7XcIeJv5rRi3L1U/BsYD tfTt3eSo7jVCeEF2xxPbI4r0dOamp2qh3J6pn8dSgtN7kgqRkkfOy0M X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=hfdpPU3AXR+t7fdv58tXCD4UzRNq+fop2TMJezFlAhM= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230415 with auth_id=44 X-Original-From: Yang Xiwen Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Yang Xiwen Add Hi3798MV200 compatible string and an extra clock for it. Signed-off-by: Yang Xiwen --- .../bindings/mmc/hisilicon,histb-dw-mshc.yaml | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml b/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml index 301b6ad39c5af..2f8335fd2c965 100644 --- a/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml +++ b/Documentation/devicetree/bindings/mmc/hisilicon,histb-dw-mshc.yaml @@ -19,6 +19,7 @@ properties: compatible: enum: - hisilicon,hi3798cv200-dw-mshc + - hisilicon,hi3798mv200-dw-mshc reg: maxItems: 1 @@ -27,14 +28,16 @@ properties: maxItems: 1 clocks: - maxItems: 4 + maxItems: 5 clock-names: + minItems: 4 items: - const: ciu - const: biu - const: ciu-sample - const: ciu-drive + - const: sap-dll-mode required: - compatible @@ -45,6 +48,27 @@ required: allOf: - $ref: synopsys-dw-mshc-common.yaml# + - if: + properties: + compatible: + contains: + const: hisilicon,hi3798mv200-dw-mshc + + then: + properties: + clocks: + minItems: 5 + + clock-names: + minItems: 5 + + else: + properties: + clocks: + maxItems: 4 + + clock-names: + maxItems: 4 unevaluatedProperties: false