Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3458747pxj; Mon, 24 May 2021 07:13:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLiVFCHh5hFxR9XBBFaBjed5nxR8/Len5TVPAQrUDqBX2zocdlAfCIOwjoAGhDUwqWJYsE X-Received: by 2002:a05:6e02:f10:: with SMTP id x16mr14088542ilj.65.1621865630664; Mon, 24 May 2021 07:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621865630; cv=none; d=google.com; s=arc-20160816; b=K34uhrGycF1He7DmfIdMx0+ShWZuatwo52e630Y+JcLDTBc0sFkJwOv+Dj8hPcLZex 5wTddegZD8VmV7KJjzeVttkz0q76mvqj6+alKKdHEl7T/XGbZmLrGrXXviAmJWtvVB9P DvRYzSjiQ74PVdFC2OJlmcMOJ14pzUhN1cdl7jybrjhhzj/QXN6SWsdL54UcnnwXLQYA o8Iqlcy23EMc4tqwkmkUFGcRgysyvjCeT40n1TKg32ZkEK7ge38TMJuQr+HO3AUVcN3+ Daoxwu4YAW+JPa6wDh4qE7kOMTuY8ZMeQjdOGKyqyk4rxyAHDJvt9EkkJAWXqpncmK3E AY/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/yZGsZDGj6VwJI2huNhq3QoEWnA9XjvVe/EfZq4y7IU=; b=ZMyVrkQ5TdGgfTzc99b2EIenj8rN2wGNL+FXeVnz/EsMYJbn2oKmOv8WLgWGyt+kU0 BKrZQw3UU4W+LnFtiAZRbRr7dr94Zx5MvldVPe3ocHIROrvmh/KrOLksv6W6wHJw56I4 qg/HgRbX6uPaVTG6XSKugMkMTWDiWdZY5KdiUL67bdHcJTlbS0K4xHkcki+MGnA7IQjk KdkPJMIiFBw0JBHfzV5o6ChCXHh4NKkFFCNXys5lwvPWQIo//56THRepsw22QcgsT/xD RZmsP5b4m/DBbXGSAm9RdK02N1iYbGYTEP6ym52LSGb/BdJmJujiEOatu1Ka6RjCy/n8 5JrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pbgNUmfp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si4133922ilk.14.2021.05.24.07.13.37; Mon, 24 May 2021 07:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pbgNUmfp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233042AbhEXONd (ORCPT + 99 others); Mon, 24 May 2021 10:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233049AbhEXONS (ORCPT ); Mon, 24 May 2021 10:13:18 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E70C06138E for ; Mon, 24 May 2021 07:11:49 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id i22so40669036lfl.10 for ; Mon, 24 May 2021 07:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/yZGsZDGj6VwJI2huNhq3QoEWnA9XjvVe/EfZq4y7IU=; b=pbgNUmfpmE+TUnwYGWa4+Cr8UT5p+RNDrrQf6fokKwwro+TbWKERs2VaUCqCAqsBxA I5TWFMPioWQdKlL+6MfKFR/wp6EmqQGuoA1C+6bhCqfstK6RzS/ZhkqYuPyoxo8WbNBc XlsOS3fFXH+dAkql4342osYDPx8Ey7GqFptWyAYbp/ASsmyS6WraUNbATVAUcgzJWo/K T6rVcFOxsVeIqWjoSbjOdE7Eb1irD5xl1pBziojPDGreqr1x00ExHeA284yUpteD6x6y euIdJh+5pr5YNBBWZJPQM0Fvc9Dg+KbpX6mRFnYuB28NPTOIu37uncKP0J3Z/9GJZ8gM 63ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/yZGsZDGj6VwJI2huNhq3QoEWnA9XjvVe/EfZq4y7IU=; b=iHyC+9zT5C9wwHQmVCBfyv3hD5bM10rq33bdmfpd1vmSxv4gWzRktA96psuuIa/ddx MtCMAUVLcz5S42FLg4cQOA87uvZ8UD6Rb+igPTE2ADaLkZ45orJHNL2q6gvLhAs/wx6y 1ej+LMhHqnU3DEDrt8s0poyAyH8sIslOwX2N7sDIWYO3ShfPQMzaxg2BrVhapts9xfWm WnRq1Kex+0huVOZ+vZqyDRWx5wiDurCHpfJbkPBtvA2P2meS3xhTm9rdoW2/JRLyezSB WlWXTQubWoGPcdL+swMUQbFxh9oDyNt51NIqHRmhUyJwz9Wtay3A4WSPVMyNu2qzV3Gu mNTA== X-Gm-Message-State: AOAM530TI1T3QC+UEYpc9ghGHLWh5XaflD1CgLnwl/fh0aTW+N6R7+4a 3GMGHPi9MGgcAV3FO3kxjzVKi3ASKs3RJ7rNZGZ2cqslnPULzQ== X-Received: by 2002:a05:6512:49b:: with SMTP id v27mr11106312lfq.29.1621865507531; Mon, 24 May 2021 07:11:47 -0700 (PDT) MIME-Version: 1.0 References: <20210524073308.9328-1-steven_lee@aspeedtech.com> <20210524073308.9328-5-steven_lee@aspeedtech.com> In-Reply-To: <20210524073308.9328-5-steven_lee@aspeedtech.com> From: Ulf Hansson Date: Mon, 24 May 2021 16:11:08 +0200 Message-ID: Subject: Re: [PATCH v5 4/4] mmc: sdhci-of-aspeed: Configure the SDHCIs as specified by the devicetree. To: Steven Lee Cc: Rob Herring , Joel Stanley , Andrew Jeffery , Adrian Hunter , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , open list , linux-mmc , "moderated list:ASPEED SD/MMC DRIVER" , Hongweiz@ami.com, ryan_chen@aspeedtech.com, chin-ting_kuo@aspeedtech.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 May 2021 at 09:33, Steven Lee wrote: > > The hardware provides capability configuration registers for each SDHCI > in the global configuration space for the SD controller. Writes to the > global capability registers are mirrored to the capability registers in > the associated SDHCI. Configuration of the capabilities must be written > through the mirror registers prior to initialisation of the SDHCI. > > Signed-off-by: Steven Lee > Reviewed-by: Andrew Jeffery > Reviewed-by: Joel Stanley Applied for next, thanks! Kind regards Uffe > --- > drivers/mmc/host/sdhci-of-aspeed.c | 48 ++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > index d001c51074a0..65b5685f6c15 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed.c > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > @@ -31,6 +31,11 @@ > #define ASPEED_SDC_S0_PHASE_OUT_EN GENMASK(1, 0) > #define ASPEED_SDC_PHASE_MAX 31 > > +/* SDIO{10,20} */ > +#define ASPEED_SDC_CAP1_1_8V (0 * 32 + 26) > +/* SDIO{14,24} */ > +#define ASPEED_SDC_CAP2_SDR104 (1 * 32 + 1) > + > struct aspeed_sdc { > struct clk *clk; > struct resource *res; > @@ -72,6 +77,37 @@ struct aspeed_sdhci { > const struct aspeed_sdhci_phase_desc *phase_desc; > }; > > +/* > + * The function sets the mirror register for updating > + * capbilities of the current slot. > + * > + * slot | capability | caps_reg | mirror_reg > + * -----|-------------|----------|------------ > + * 0 | CAP1_1_8V | SDIO140 | SDIO10 > + * 0 | CAP2_SDR104 | SDIO144 | SDIO14 > + * 1 | CAP1_1_8V | SDIO240 | SDIO20 > + * 1 | CAP2_SDR104 | SDIO244 | SDIO24 > + */ > +static void aspeed_sdc_set_slot_capability(struct sdhci_host *host, struct aspeed_sdc *sdc, > + int capability, bool enable, u8 slot) > +{ > + u32 mirror_reg_offset; > + u32 cap_val; > + u8 cap_reg; > + > + if (slot > 1) > + return; > + > + cap_reg = capability / 32; > + cap_val = sdhci_readl(host, 0x40 + (cap_reg * 4)); > + if (enable) > + cap_val |= BIT(capability % 32); > + else > + cap_val &= ~BIT(capability % 32); > + mirror_reg_offset = ((slot + 1) * 0x10) + (cap_reg * 4); > + writel(cap_val, sdc->regs + mirror_reg_offset); > +} > + > static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc, > struct aspeed_sdhci *sdhci, > bool bus8) > @@ -328,6 +364,7 @@ static inline int aspeed_sdhci_calculate_slot(struct aspeed_sdhci *dev, > static int aspeed_sdhci_probe(struct platform_device *pdev) > { > const struct aspeed_sdhci_pdata *aspeed_pdata; > + struct device_node *np = pdev->dev.of_node; > struct sdhci_pltfm_host *pltfm_host; > struct aspeed_sdhci *dev; > struct sdhci_host *host; > @@ -372,6 +409,17 @@ static int aspeed_sdhci_probe(struct platform_device *pdev) > > sdhci_get_of_property(pdev); > > + if (of_property_read_bool(np, "mmc-hs200-1_8v") || > + of_property_read_bool(np, "sd-uhs-sdr104")) { > + aspeed_sdc_set_slot_capability(host, dev->parent, ASPEED_SDC_CAP1_1_8V, > + true, slot); > + } > + > + if (of_property_read_bool(np, "sd-uhs-sdr104")) { > + aspeed_sdc_set_slot_capability(host, dev->parent, ASPEED_SDC_CAP2_SDR104, > + true, slot); > + } > + > pltfm_host->clk = devm_clk_get(&pdev->dev, NULL); > if (IS_ERR(pltfm_host->clk)) > return PTR_ERR(pltfm_host->clk); > -- > 2.17.1 >