From patchwork Fri Jul 8 13:14:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 588508 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp639278mab; Fri, 8 Jul 2022 06:15:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vu2z8O7sWYMqoYYQkGa1tagriDosIK2IjbiSW3ONPT1XKyPy0X7xSAOmMG/XLVN7GCJRsx X-Received: by 2002:a2e:b8c4:0:b0:25d:4fe9:b566 with SMTP id s4-20020a2eb8c4000000b0025d4fe9b566mr2036485ljp.241.1657286134835; Fri, 08 Jul 2022 06:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657286134; cv=none; d=google.com; s=arc-20160816; b=GOyuLx04oNWh7gfpLjfpAQSKQLt5X8UxzYQQcxUqCOwgbMLmeFFcGDb+mPGfOMihGs KY6fpL3Jubl0kF7vRo9G20rmIK5r3xTZ0Ouuk2zCBq+Pp07qi8ddHk57oN21jtzsYr6n aQCpweM2GtETO/UuR0Nw4NCPiFQMsOtnICmjnTJslyqfSXX6a3MWjCLbpV0ezOTDUBy0 XZN/Uw0sXMaLzVEvIc4rDf/MdHtCPksyFXS+BiStWuN4n4u461axau6qspg+orZ9aQEE nSpVj7bAtcF6ctz5X6qZRwd7m6I6uwmq5DUCWy/Kafb4so5isj6np+R+RDdilLXRc1Dm GYmw== 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=pAcnnDNqQbu7wVQGwODldVhzPDfDx8fBRkhxPQ1aEH0=; b=VmCUZFrjoyCMM72UQ9phX0ZoWFgADl6q3h55N5Itiij7Zyj2iifgTioyxNY9tP0P3t 1uS62RaQRstF4ZmjTpMzeGQ+SWID5t0igE4G5R25cvKbLXw2YxA7uvhI+4DWI0ZJHDgc CREpRQnORYH35nnASItIo6JrcEq9nCKXoH2Ilhkfq4yPtGAMykLHyZJYHTLVyo0BOwPa cdYJGEA2zwsiSVkCOEuexJJ8BPkfrj6oLyqrY4ZeEKF2xAYdgCw67u0Uvq+VgcQbaIrS 3TmN/eyeDG5X+UIr0LtBPoXJ8bXtb+Ne4K9N7s6Uah6q2aEQ0Mn9t1VhSJIaN1+zHKb1 4CnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ug0XqC7v; 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 a2-20020a056512374200b00477cab831bfsi32807985lfs.419.2022.07.08.06.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 06:15:34 -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=ug0XqC7v; 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 0ECC3845AF; Fri, 8 Jul 2022 15:14:51 +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="ug0XqC7v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A8C6F845AF; Fri, 8 Jul 2022 15:14:49 +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-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 C721184573 for ; Fri, 8 Jul 2022 15:14:46 +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-pg1-x534.google.com with SMTP id 73so6927439pgb.10 for ; Fri, 08 Jul 2022 06:14:46 -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=pAcnnDNqQbu7wVQGwODldVhzPDfDx8fBRkhxPQ1aEH0=; b=ug0XqC7vlwbajZFvHW84K6rvOTz+CUW/zsXUwjuFsCXlk3gyBTwbeASRV5ZkVJCh1E 5MEylOilxodhtwJuUpSaEGZFqNek3PD849Hns9WSjSba/G8DyJMzZzdTMSAGdwPABPaQ +u3q1oU+KKB0UF09m0a8yoAA7G790yx75Um7MIkc00V9/ZtO1FjHrGzvS8pORmsPx4q2 dpUN5uPw5moE98i2RhewBL2xMRzvjChccJEuzFMMxl/SFPbSQ3kTyrr1DoAu41ce6zWE /w7GsEDakfh4ve/i0xDKIRWPAGjxRHj3X6nOJCb5JnfybjtbPOOKfb3scW2fwgxOxXV9 bFCw== 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=pAcnnDNqQbu7wVQGwODldVhzPDfDx8fBRkhxPQ1aEH0=; b=Z5ipf+I7dJUUfgIsRC9mgEeU2MoUuDfMudjMN9RPv0NaMh06TzEn+89s9bPPEBod1g y+Notz7k/fK83N78N1NwvGhSev0dACRiXk48tjW+ws3WesBcsylsBG0QIuZhtLwpE+O/ bdieB7PsgJR2B0qNfe6sKuUYwiG/FlrclbPDPC/oDj4h4FwahktoGp2pJJOeNfPyBmdH IVmXeOhSARPM0umO0qxR3MdOm6P/QJIkJjmMt4bwcM8lWL13V4CIzLuvVNcrr8B7tUat +4VR5aXmuuSipqYMZsY4w2sV8kCwFt/xQK/IRUmrm5grnLgrinrbYYz9KKh9iCf/rLfs bC4Q== X-Gm-Message-State: AJIora99tit+uVPvweSNcKDM+YPREXIIiWKsma2KCAz8d6C5R+V6h0nn WM9r5iEWejDRP45QESX1/nOwiVGSIfqUMg== X-Received: by 2002:a63:6b49:0:b0:40e:64ef:1be7 with SMTP id g70-20020a636b49000000b0040e64ef1be7mr3328202pgc.552.1657286085046; Fri, 08 Jul 2022 06:14:45 -0700 (PDT) Received: from localhost.localdomain ([182.77.21.191]) by smtp.gmail.com with ESMTPSA id c9-20020a624e09000000b0052974b651b9sm2026493pfb.38.2022.07.08.06.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 06:14:44 -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 v2 6/9] mmc: msm_sdhci: Add SDCC version 5.0.0 support Date: Fri, 8 Jul 2022 18:44:01 +0530 Message-Id: <20220708131404.1489347-7-sumit.garg@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220708131404.1489347-1-sumit.garg@linaro.org> References: <20220708131404.1489347-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 }, { } };