From patchwork Tue Jul 12 07:12:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 589792 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp9270max; Tue, 12 Jul 2022 00:14:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vkV1u0F7jOGY2rJrrqj8I59i/Fge+BZG4XKGREpRg1JKQx5LaZLKzUiPgQs5tzwrAQbms7 X-Received: by 2002:a05:651c:154a:b0:25d:7a5c:b854 with SMTP id y10-20020a05651c154a00b0025d7a5cb854mr854225ljp.193.1657610048144; Tue, 12 Jul 2022 00:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657610048; cv=none; d=google.com; s=arc-20160816; b=HYx0wgNIR2IQCnflXu8fVNTNji7Jgi1PV5YDA0Wtq50xbZZkX3q1EmQ9veTFet+JH8 w6BBGHFtdPFOoTmmmsQ7hHaLmZ2QTq0ed7MhVnfLHZHhwuSRY/7xnY09W+hEowqFWXOD nu0y/bbvKewmHclb9V/GJtY/yG+RJCGZ4/5gcipbMNJ7FIS9X3u656l2/7HrPrnldSyn otBQneY0qUwqHarYG3pJWztyTMZ31iGp9NXtgyt3RAaxlOq9TqRJ1x5X2/A3o1kT6L/N Bi7/Vnmy9B5MIJKvrUUmsZywkpmT2YaKBA6asy6cFGRMa88Pzl82vn3pWVv5lhw7hR4F wHYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Meq/9myZlZI/0FAOKLfCfPeH8NoYyvt4UlP0TUcyWxE=; b=JCHKXdmdjpBV3mELUDG0/rCpKIHwMNFQgkGgrup+sHBz37kL6wm/TiDfU3YqKaT508 7gepgnpfAxsWUSNZAfuX+J/QEYK07lT6RWtxtcWof0cgR6a9/armM9PrahtLTr7t5U1g KGsnavtuUJdGVHhdh2LK5EgyNYV0T19UrD6En0II+4NI6puJs6wUrySPOAJqbbiXH1UU M+25dxO9kK1gij7lRJrFHjeDeJmAOd/q8I9n9+EuUy2dl9CukQ4WMPwP7WsjjOiZGg2n jdzWPOUJ6dPfspw+1ebjuLAT/1RCG75eK6BHKRZPYlHjPycdkWHdSfVYlUVovmo8ruZc avaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yXjmGb2n; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id z4-20020a0565120c0400b00489d97de545si8546203lfu.615.2022.07.12.00.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 00:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yXjmGb2n; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77EC984109; Tue, 12 Jul 2022 09:13:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yXjmGb2n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 018E7840B3; Tue, 12 Jul 2022 09:13:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 478F1840B3 for ; Tue, 12 Jul 2022 09:12:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pl1-x630.google.com with SMTP id r6so4064405plg.3 for ; Tue, 12 Jul 2022 00:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Meq/9myZlZI/0FAOKLfCfPeH8NoYyvt4UlP0TUcyWxE=; b=yXjmGb2n3DGLr1B5PsbyXpjcXl+otauAZCxmzRvFDkf6x8699X204zccL/lVzubXJN CTBY4/P1uPDnnEwsUvNPA/0/A6NtsaBCo5DavcXVL2lz6cPNNEUy5XKu6ZBqT+BizZRq jo7owqjV6Mnnmcv8deN7aKCvGAj+ThfRIJVoUcw7eEFh/WuhNnRw91+nkszVQih0jTBO /GnsWXrVUGFfoZbzl9Fj1rAnFblpt8y7q0MvGTAx0vkrkjQr8wvgg+CmGFHJ0l/iTAlM t4nh3/zkrm4516KJ8Ch3AtoAo+xXGl/cxY71PE9P3uFIcnDIpxVE1QmanCok6J+Wd5SA XnRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Meq/9myZlZI/0FAOKLfCfPeH8NoYyvt4UlP0TUcyWxE=; b=DYBykNOstiAMe7GtiDk0DryOUAoNiWSF1zcn9MFCKxjUlZr6+0+XhcO5n6yfpXYvc3 WQ9YOn0oJ4I9BYGaurVzoyB+v8DfX3Vx46lGjg8kOhjxTvYl/Vy9OLEtme5Cifo3Ijqz 9rMoPOhw19JzwlXqVRG6S7AMHImdJOdvPBJoaAJf/ERH9BLbgkH2AKE8BFWF6QV7phr+ VuoxWQkGIOQ4N7LJHZHJeRxAqOta8LJucvde+5yhHpKZhBU+jlC2uw8itbaEl5oE+WSu UgEfvYKGNbCNTviJBYw+IVPyGqOXeGVHKQVlwdqHoNxd8rQo0+4MLD8FcwxZ179b2zrk 2J+g== X-Gm-Message-State: AJIora/BasEm+aCVWbUg/y42emgWuCAPD0A32Bxxk+5yPHqYetY4YBe2 6lWB9fJdN/erSqvWkujljxc4vVw/H3kw1w== X-Received: by 2002:a17:902:d718:b0:168:d9df:4f1c with SMTP id w24-20020a170902d71800b00168d9df4f1cmr21771924ply.41.1657609972480; Tue, 12 Jul 2022 00:12:52 -0700 (PDT) Received: from localhost.localdomain ([27.56.177.217]) by smtp.gmail.com with ESMTPSA id x10-20020a170902a38a00b001678ce9080dsm5928843pla.258.2022.07.12.00.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 00:12:52 -0700 (PDT) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, peng.fan@nxp.com, jh80.chung@samsung.com, sjg@chromium.org, trini@konsulko.com, dsankouski@gmail.com, stephan@gerhold.net, vinod.koul@linaro.org, nicolas.dechesne@linaro.org, mworsfold@impinj.com, daniel.thompson@linaro.org, pbrobinson@gmail.com, Sumit Garg Subject: [PATCH v3 6/9] mmc: msm_sdhci: Add SDCC version 5.0.0 support Date: Tue, 12 Jul 2022 12:42:09 +0530 Message-Id: <20220712071212.2188390-7-sumit.garg@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712071212.2188390-1-sumit.garg@linaro.org> References: <20220712071212.2188390-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean For SDCC version 5.0.0, MCI registers are removed from SDCC interface and some registers are moved to HC. So add support to use the new compatible string "qcom,sdhci-msm-v5". Based on this new msm variant, pick the relevant variant data and use it to detect MCI presence thereby configuring register read/write to msm specific registers. Signed-off-by: Sumit Garg Reviewed-by: Ramon Fried --- drivers/mmc/msm_sdhci.c | 96 +++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c index d63d7b3a2c..604f9c3ff9 100644 --- a/drivers/mmc/msm_sdhci.c +++ b/drivers/mmc/msm_sdhci.c @@ -22,18 +22,17 @@ #define SDCC_MCI_POWER_SW_RST BIT(7) /* This is undocumented register */ -#define SDCC_MCI_VERSION 0x50 -#define SDCC_MCI_VERSION_MAJOR_SHIFT 28 -#define SDCC_MCI_VERSION_MAJOR_MASK (0xf << SDCC_MCI_VERSION_MAJOR_SHIFT) -#define SDCC_MCI_VERSION_MINOR_MASK 0xff +#define SDCC_MCI_VERSION 0x50 +#define SDCC_V5_VERSION 0x318 + +#define SDCC_VERSION_MAJOR_SHIFT 28 +#define SDCC_VERSION_MAJOR_MASK (0xf << SDCC_VERSION_MAJOR_SHIFT) +#define SDCC_VERSION_MINOR_MASK 0xff #define SDCC_MCI_STATUS2 0x6C #define SDCC_MCI_STATUS2_MCI_ACT 0x1 #define SDCC_MCI_HC_MODE 0x78 -/* Offset to SDHCI registers */ -#define SDCC_SDHCI_OFFSET 0x900 - /* Non standard (?) SDHCI register */ #define SDHCI_VENDOR_SPEC_CAPABILITIES0 0x11c @@ -47,6 +46,10 @@ struct msm_sdhc { void *base; }; +struct msm_sdhc_variant_info { + bool mci_removed; +}; + DECLARE_GLOBAL_DATA_PTR; static int msm_sdc_clk_init(struct udevice *dev) @@ -85,25 +88,8 @@ static int msm_sdc_clk_init(struct udevice *dev) return 0; } -static int msm_sdc_probe(struct udevice *dev) +static int msm_sdc_mci_init(struct msm_sdhc *prv) { - struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct msm_sdhc_plat *plat = dev_get_plat(dev); - struct msm_sdhc *prv = dev_get_priv(dev); - struct sdhci_host *host = &prv->host; - u32 core_version, core_minor, core_major; - u32 caps; - int ret; - - host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_BROKEN_R1B; - - host->max_clk = 0; - - /* Init clocks */ - ret = msm_sdc_clk_init(dev); - if (ret) - return ret; - /* Reset the core and Enable SDHC mode */ writel(readl(prv->base + SDCC_MCI_POWER) | SDCC_MCI_POWER_SW_RST, prv->base + SDCC_MCI_POWER); @@ -126,12 +112,45 @@ static int msm_sdc_probe(struct udevice *dev) /* Enable host-controller mode */ writel(1, prv->base + SDCC_MCI_HC_MODE); - core_version = readl(prv->base + SDCC_MCI_VERSION); + return 0; +} - core_major = (core_version & SDCC_MCI_VERSION_MAJOR_MASK); - core_major >>= SDCC_MCI_VERSION_MAJOR_SHIFT; +static int msm_sdc_probe(struct udevice *dev) +{ + struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); + struct msm_sdhc_plat *plat = dev_get_plat(dev); + struct msm_sdhc *prv = dev_get_priv(dev); + const struct msm_sdhc_variant_info *var_info; + struct sdhci_host *host = &prv->host; + u32 core_version, core_minor, core_major; + u32 caps; + int ret; - core_minor = core_version & SDCC_MCI_VERSION_MINOR_MASK; + host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_BROKEN_R1B; + + host->max_clk = 0; + + /* Init clocks */ + ret = msm_sdc_clk_init(dev); + if (ret) + return ret; + + var_info = (void *)dev_get_driver_data(dev); + if (!var_info->mci_removed) { + ret = msm_sdc_mci_init(prv); + if (ret) + return ret; + } + + if (!var_info->mci_removed) + core_version = readl(prv->base + SDCC_MCI_VERSION); + else + core_version = readl(host->ioaddr + SDCC_V5_VERSION); + + core_major = (core_version & SDCC_VERSION_MAJOR_MASK); + core_major >>= SDCC_VERSION_MAJOR_SHIFT; + + core_minor = core_version & SDCC_VERSION_MINOR_MASK; /* * Support for some capabilities is not advertised by newer @@ -161,9 +180,13 @@ static int msm_sdc_probe(struct udevice *dev) static int msm_sdc_remove(struct udevice *dev) { struct msm_sdhc *priv = dev_get_priv(dev); + const struct msm_sdhc_variant_info *var_info; + + var_info = (void *)dev_get_driver_data(dev); - /* Disable host-controller mode */ - writel(0, priv->base + SDCC_MCI_HC_MODE); + /* Disable host-controller mode */ + if (!var_info->mci_removed) + writel(0, priv->base + SDCC_MCI_HC_MODE); return 0; } @@ -195,8 +218,17 @@ static int msm_sdc_bind(struct udevice *dev) return sdhci_bind(dev, &plat->mmc, &plat->cfg); } +static const struct msm_sdhc_variant_info msm_sdhc_mci_var = { + .mci_removed = false, +}; + +static const struct msm_sdhc_variant_info msm_sdhc_v5_var = { + .mci_removed = true, +}; + static const struct udevice_id msm_mmc_ids[] = { - { .compatible = "qcom,sdhci-msm-v4" }, + { .compatible = "qcom,sdhci-msm-v4", .data = (ulong)&msm_sdhc_mci_var }, + { .compatible = "qcom,sdhci-msm-v5", .data = (ulong)&msm_sdhc_v5_var }, { } };