Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3061259lqo; Tue, 21 May 2024 06:00:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6JECs0pRssmZsWs918r7qwmO9frvhyW+nwnzxK+q3/TDIHH3yZ4sdcquuMoBXY3QA7Bb1+qDp6Ct/I3a6xyevKef2mG36ZS/875ydig== X-Google-Smtp-Source: AGHT+IHnTUWg201f7K6nSzAeSdkACEaX9rChHM2tfNQOn7GW/ho0QDHEVu+J89R7FKoSR9MXdKSn X-Received: by 2002:a05:6a21:1aa:b0:1a7:9b0e:ded3 with SMTP id adf61e73a8af0-1b1ca3c3e70mr12161981637.11.1716296418240; Tue, 21 May 2024 06:00:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716296418; cv=pass; d=google.com; s=arc-20160816; b=cHdwjteBYkyJ767pgELP9NRNsFufv/pH8z9f/tYfGxoaAL1AO7SVe84YBOMM0hqrxM mbJOSDkPCTZhJ42IBENq+A2jpCFjnxM2VXq0FFQbtU4u/a08gwK9VHgTXG1dbaFQpftN /Wp5u3Cno2DOyd5QbKWtV8m868Mdx3tZCJ0JUFAKlkCRlYQr6MyYGxyBXYJS+vobIg1R PpV+PVKrgA355vFN8poZZhqllv9rxwilytbEewCWJp3N+q1P9T46JNMHlSK49jiMOjP6 tjliCLxTwfRt+i2nvvOEiHTxgXFdsiCrk7RXauCgEpx4+Sy2+QQ69u+WSNMXz+LOkNu/ qMTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:cc:to:date:from :dkim-signature; bh=YN/7AOVfwDQ9fuglKdggECs2cWRXnj0qk72xVYmNKJg=; fh=dCfHa2gIhGLP7ddCH0Mb0oRnt6nf4D54S81W2kHR2L0=; b=bboYZ7eYJy/SyW0Kl6jqSGeh2lLTH1QUq9FzeiSwaaMsiV+3p/+mpUX+QEIzoNRT/f TXVBdbCs0Pd7uZArWwz9C9jDZ/5kI6jlQQQc5hGQuBtyxWAv+dQwWEmfJ1lEWuCX8Jvs ct6xr/vWGctJc31MjQr6iDrujtYCdcTKptMBsQGJFBbV2br/bXT0xVhbo2UHPowYYxtx 7envkmwMLj5OJXksV9KmIF/YvCv6rECybEn+QaKH3RqlzJmMYFOQRRbUCvHLbqoq5tjq 3/RqgRnBIW1rl3HP5bdvGKLF1yBcLKYEB0KEL2CyQHF3Bn7lA1gLyr4JVob/UfQwWaQu QOUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=BAa02ckJ; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-184976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6721d2d0358si1328762a12.337.2024.05.21.06.00.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 06:00:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=BAa02ckJ; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-184976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1AE4DB21C08 for ; Tue, 21 May 2024 13:00:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84A12770FD; Tue, 21 May 2024 13:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="BAa02ckJ" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 545D21E48B for ; Tue, 21 May 2024 13:00:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716296403; cv=none; b=YGlon124/l1Xb5pM2ezyOBZXq4YZrmhZzlLhqISTyNpquTxu+OhDBApwFYRHy9jKdKo80sRLGjTQFLxQjV+un07uclEq3CORVoZflAuq2KdmTFiAOtIJHNuFX52IDOaoFmRwuoPyPcHwfOZEgDeKj+q23xvKoQSAeYYgmmuhqvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716296403; c=relaxed/simple; bh=DBUyQmvQh7vUb6oN302EO/ct8ueC5mznuotC02B36l0=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b4/iY35VNTl3SkYmYl8NTY2rGitgihc2YtUkICgQhELkmTV3CtbhcPBrd7gPJjorHJLCFOKaW6O6tVk7OmTROq8i9ZD6liRA7gYC5zepUpZLYCb29D+zY9joYQudoJT2TQ4CKCqAqF3oN/fGm/VNxOOryPopdwDIHoh6IhoJ72w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=BAa02ckJ; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a5d67064885so392352866b.1 for ; Tue, 21 May 2024 06:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1716296399; x=1716901199; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :date:from:from:to:cc:subject:date:message-id:reply-to; bh=YN/7AOVfwDQ9fuglKdggECs2cWRXnj0qk72xVYmNKJg=; b=BAa02ckJ1Mz52t3V7mhtzEiRIE+HnoFSUXoFf+jfFKSBjXOAewuoi81ZCvTCuDalBy d7L7Kj8vx0w0QzfkAtYVkIkHNbYfBFj4U8L9PuCWDm24DbCEpw7UwJkAfyUpn2LbWdX6 E8RNpdJyxsw9jlOkUFdwxHyoRtjbgGfxTha5IaSkbnfr0Psv10gYKNx1KzCYANBQD06Q 47z64ghoSvl/2yZDRt0VUIJD3YdsyAi1xze8W5WNuEnSl7lqIKzTa6KhR5zkidmmxd9V GR85krT4jJQugjlW7GhTumoo3x5AyiD6++TMTAbOxekk/JlT4h2xWMsKJgGC2LsPOUzz x9KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716296399; x=1716901199; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YN/7AOVfwDQ9fuglKdggECs2cWRXnj0qk72xVYmNKJg=; b=gv0fmRq3sYu+2fliM0VJjm00Je8lDkJmB/0FM74b31zU7voTSaVt+Mi/Yw6+Bbhio9 IR1kvBK3VB9L1DAC8BCGAnAkvxFUcwmTHljm1tYdIHcXAkViT+LpOCxJeexOaf5CQlMr ThzGeDK3GDnI6/JCGICQiE13dvDx3xWAgyOBSOeeEH3xfdwymqzfcn5PsE75Nk0Jfx7a G+yb3rbOyREo0rn0welkMzwd71Hj5YGqRM4E+mhhi1IRhumjGT+fN8Vr3g+VKjySzoA8 C+xp3PBeTGkmhVvOZTPEfhQ5SgBjFPLiiUU8CzxShrfMkCerMjg/tczUdH5dmwd8zfdn L8/A== X-Forwarded-Encrypted: i=1; AJvYcCVJj/f6R0mMLbsmtQg/CTVTRiMVqXHh+tG0/s+Rg7Vougq1AtkWHqWChHh3h3MmvukG59kInXuglBJdF8kOaBI8Slt2jBEaWcGjzFGB X-Gm-Message-State: AOJu0YwhE00MwN0NOj0NJ4Zh9CERt76CuRdqkorLxesw2sQFBOWDEU3K jWjRJ1fP+gNGc1XDTAdvbFfcX4lC5R0WAaceE7hxAWaCnAOawn/54Q9T8lSZE5Q= X-Received: by 2002:a17:906:4882:b0:a59:a727:1e81 with SMTP id a640c23a62f3a-a5a2d57a381mr3123533366b.20.1716296398569; Tue, 21 May 2024 05:59:58 -0700 (PDT) Received: from localhost (host-87-18-209-253.retail.telecomitalia.it. [87.18.209.253]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a179c7ebcsm1601785066b.117.2024.05.21.05.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 05:59:58 -0700 (PDT) From: Andrea della Porta X-Google-Original-From: Andrea della Porta Date: Tue, 21 May 2024 15:00:08 +0200 To: Stefan Wahren Cc: Andrea della Porta , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Marc Zyngier , Broadcom internal kernel review list , Ulf Hansson , Adrian Hunter , Kamal Dasu , Al Cooper , devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org Subject: Re: [PATCH v3 3/4] mmc: sdhci-brcmstb: Add BCM2712 support Message-ID: Mail-Followup-To: Stefan Wahren , Andrea della Porta , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Marc Zyngier , Broadcom internal kernel review list , Ulf Hansson , Adrian Hunter , Kamal Dasu , Al Cooper , devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 14:26 Tue 21 May , Stefan Wahren wrote: > Hi Andrea, > > Am 21.05.24 um 10:35 schrieb Andrea della Porta: > > Broadcom BCM2712 SoC has an SDHCI card controller using the SDIO CFG > > register block present on other STB chips. Add support for BCM2712 > > SD capabilities of this chipset. > > The silicon is SD Express capable but this driver port does not currently > > include that feature yet. > > Based on downstream driver by raspberry foundation maintained kernel. > > > > Signed-off-by: Andrea della Porta > > --- > > drivers/mmc/host/sdhci-brcmstb.c | 65 ++++++++++++++++++++++++++++++++ > > 1 file changed, 65 insertions(+) > > > > diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c > > index 9053526fa212..b349262da36e 100644 > > --- a/drivers/mmc/host/sdhci-brcmstb.c > > +++ b/drivers/mmc/host/sdhci-brcmstb.c > > @@ -30,6 +30,21 @@ > > > > #define SDHCI_ARASAN_CQE_BASE_ADDR 0x200 > > > > +#define SDIO_CFG_CQ_CAPABILITY 0x4c > > +#define SDIO_CFG_CQ_CAPABILITY_FMUL GENMASK(13, 12) > > + > > +#define SDIO_CFG_CTRL 0x0 > > +#define SDIO_CFG_CTRL_SDCD_N_TEST_EN BIT(31) > > +#define SDIO_CFG_CTRL_SDCD_N_TEST_LEV BIT(30) > > + > > +#define SDIO_CFG_MAX_50MHZ_MODE 0x1ac > > +#define SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE BIT(31) > > +#define SDIO_CFG_MAX_50MHZ_MODE_ENABLE BIT(0) > > + > > +#define MMC_CAP_HSE_MASK (MMC_CAP2_HSX00_1_2V | MMC_CAP2_HSX00_1_8V) > > +/* Select all SD UHS type I SDR speed above 50MB/s */ > > +#define MMC_CAP_UHS_I_SDR_MASK (MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104) > > + > > struct sdhci_brcmstb_priv { > > void __iomem *cfg_regs; > > unsigned int flags; > > @@ -38,6 +53,7 @@ struct sdhci_brcmstb_priv { > > }; > > > > struct brcmstb_match_priv { > > + void (*cfginit)(struct sdhci_host *host); > > void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios); > > struct sdhci_ops *ops; > > const unsigned int flags; > > @@ -168,6 +184,38 @@ static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host, > > sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); > > } > > > > +static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) > > +{ > > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > > + struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host); > > + u32 reg, base_clk_mhz; > > + > > + /* > > + * If we support a speed that requires tuning, > > + * then select the delay line PHY as the clock source. > > + */ > > + if ((host->mmc->caps & MMC_CAP_UHS_I_SDR_MASK) || (host->mmc->caps2 & MMC_CAP_HSE_MASK)) { > > + reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE); > > + reg &= ~SDIO_CFG_MAX_50MHZ_MODE_ENABLE; > > + reg |= SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE; > > + writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE); > > + } > > + > > + if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) || > > + (host->mmc->caps & MMC_CAP_NEEDS_POLL)) { > > + /* Force presence */ > > + reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_CTRL); > > + reg &= ~SDIO_CFG_CTRL_SDCD_N_TEST_LEV; > > + reg |= SDIO_CFG_CTRL_SDCD_N_TEST_EN; > > + writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_CTRL); > > + } > > + > > + /* Guesstimate the timer frequency (controller base clock) */ > > + base_clk_mhz = max_t(u32, clk_get_rate(pltfm_host->clk) / (1000 * 1000), 1); > > + reg = SDIO_CFG_CQ_CAPABILITY_FMUL | base_clk_mhz; > > + writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_CQ_CAPABILITY); > This part assumes the clock isn't changed afterwards, see below ... > > +} > > + > > static void sdhci_brcmstb_dumpregs(struct mmc_host *mmc) > > { > > sdhci_dumpregs(mmc_priv(mmc)); > > @@ -200,6 +248,14 @@ static struct sdhci_ops sdhci_brcmstb_ops = { > > .set_uhs_signaling = sdhci_set_uhs_signaling, > > }; > > > > +static struct sdhci_ops sdhci_brcmstb_ops_2712 = { > > + .set_clock = sdhci_set_clock, > > + .set_power = sdhci_set_power_and_bus_voltage, > > + .set_bus_width = sdhci_set_bus_width, > > + .reset = sdhci_reset, > > + .set_uhs_signaling = sdhci_set_uhs_signaling, > > +}; > > + > > static struct sdhci_ops sdhci_brcmstb_ops_7216 = { > > .set_clock = sdhci_brcmstb_set_clock, > > .set_bus_width = sdhci_set_bus_width, > > @@ -214,6 +270,11 @@ static struct sdhci_ops sdhci_brcmstb_ops_74165b0 = { > > .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, > > }; > > > > +static const struct brcmstb_match_priv match_priv_2712 = { > > + .cfginit = sdhci_brcmstb_cfginit_2712, > > + .ops = &sdhci_brcmstb_ops_2712, > > +}; > > + > > static struct brcmstb_match_priv match_priv_7425 = { > > .flags = BRCMSTB_MATCH_FLAGS_NO_64BIT | > > BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, > > @@ -238,6 +299,7 @@ static struct brcmstb_match_priv match_priv_74165b0 = { > > }; > > > > static const struct of_device_id __maybe_unused sdhci_brcm_of_match[] = { > > + { .compatible = "brcm,bcm2712-sdhci", .data = &match_priv_2712 }, > > { .compatible = "brcm,bcm7425-sdhci", .data = &match_priv_7425 }, > > { .compatible = "brcm,bcm7445-sdhci", .data = &match_priv_7445 }, > > { .compatible = "brcm,bcm7216-sdhci", .data = &match_priv_7216 }, > > @@ -370,6 +432,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) > > (host->mmc->caps2 & MMC_CAP2_HS400_ES)) > > host->mmc_host_ops.hs400_enhanced_strobe = match_priv->hs400es; > > > > + if (match_priv->cfginit) > > + match_priv->cfginit(host); > > + > I'm not sure this is the right place to call cfginit. > sdhci_brcmstb_cfginit_2712 retrives the current controller base clock, > but at the end of? sdhci_brcmstb_probe this clock frequency could be > adjusted by the device property "clock-frequency". So i'm not sure this > is intended. Some tests reveal that cfginit() must be called for certain type of UHS SD cards, otherwise those cards do not work at all. This of course does not mean that the calling sequence is correctly ordererd and it may just work out of luck. I'm investigating... Many thanks, Andrea > > /* > > * Supply the existing CAPS, but clear the UHS modes. This > > * will allow these modes to be specified by device tree >