Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp142109pxy; Thu, 6 May 2021 23:09:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVppktQ8GzyWq5xK8+bw7fOkuoO8bOC5DViL9u1SELLRPX/jVQ+C5Y/RmXik/J7sOQpkjI X-Received: by 2002:a05:6a00:88a:b029:261:6d37:dac6 with SMTP id q10-20020a056a00088ab02902616d37dac6mr8702716pfj.18.1620367750944; Thu, 06 May 2021 23:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620367750; cv=none; d=google.com; s=arc-20160816; b=Ufw4qSUlGFoPFQGQbNJVymahm70VUe30eKXGpSj7XAG+wX0XtSjZy4nrZVXVUyyZZv HhTyQl0xleZN3Mdc5r0dJmm0VLBkIkqpBsN2N67ZRBD6h9Czt3X6lJqiWJn+bfjx6Jvb oOC/39bPGm2BL7JaW1a4RVCPmNL/hdH1Rhjkh7L30GPHtNAwrtBMVBNplUwzd2LObcck pRF680WktRz+OLUyRLnF8TaKSNk/VGJJdXGnLGhNCULLeBYz+bYk3VyZMUcIthy83A1B Ed7kBQ3v7Cm0sJrAuZ3BO9TYMGtt9UoWtdpW+dZkxwFxy0S9GugnFdVfKJavWk7Rcjvf cw9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature:dkim-signature; bh=8US/FJXWvzXli0qVPTXQtzYtNN8GfR+Rd/DBBdsQDOU=; b=Di48dBBZI4q2Hh6uA8gzq25AG9h8xAaOMbpwwvWaSC9TSmZ3kYRgPF297YD7fCO7Z3 8sh65Hq6jlxEX0qKo+KvKv5eIBF/Oou0GrNSCWxpxzutV31it3SRGy+DE7o1Y5sx9AM0 ccz/m9GH9og3Naz5x7IQhVnaFT+M/RzltdepVSbrjA3JVTYK53sTU5Lwa6oEWO/70Hir m+KCQ5o/1hNDKcf0DyS8jTayMoz/wS1BVKmGRbIBmBX+FHgQeWi7Yl+gblVdislJgx2c EW4pew4lAzDnEBAb0+4qeel7ItRmOmcBxX7Zj1aHjkn0D6X7hTdFEPjoMFYabOYe6qSx ybAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=ABCX2VIl; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jigSVRzE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si5814023pll.110.2021.05.06.23.08.57; Thu, 06 May 2021 23:09:10 -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=@aj.id.au header.s=fm2 header.b=ABCX2VIl; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=jigSVRzE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231500AbhEGCPN (ORCPT + 99 others); Thu, 6 May 2021 22:15:13 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:33147 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhEGCPM (ORCPT ); Thu, 6 May 2021 22:15:12 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id DE7BB581013; Thu, 6 May 2021 22:14:12 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute3.internal (MEProxy); Thu, 06 May 2021 22:14:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm2; bh=8US/FJXWvzXli0qVPTXQtzYtNN8GfR+ Rd/DBBdsQDOU=; b=ABCX2VIlaxgv6fmVYZqhYciuL0pnba2JJR4jyn9sC1tqCoY uY9odhr4vFeNh7apkKAZSrnvtnvwNMpP9Rh/5ILnCf6evnsWvLQtVFepEnc9MDjz NcrLsEgFTkIZdMFOR9qBYRIgMN4YXsSikdICedlMEpZH0i/HVgIlAMYRCq2Imlj5 yTLaYGudFProF0KNZcDLoD2o43A0gNul9hijJyh+oPO/edY7Rs5WefNGzHRygWQc 7FKdPUa4qXxi6QEloh9mmvwBURJy34HX7abTCJvo8vyF6Jxbx4Mz9nakdaUqSUGf mseNKEcXYnYDwQ7hRIHrUJvNjsyKSoF/6C6YM7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=8US/FJ XWvzXli0qVPTXQtzYtNN8GfR+Rd/DBBdsQDOU=; b=jigSVRzEaV+GHWRtNmkZNB XHgBICfB7AVc2fNowNYCMpFeeUTfJphXVku0gDJgIRFmAN0otoFekDDmGTmWfYCz vUjCVKT+Q6XH4r5k3kX1vPJpUb1Nl3OinfKS5twXRgczWZox70T3uQSv3WB7m+mr pWgCkyFXm5Y3TRdPbM3ztM5Fge/waSbM8w7ySh7P9Cji5dEIKbMtAOPmm7MeO+CV E2JqT49ho5pooNNthF7X96uS6NCov+QeSGRYOIWpPJKPj8trCJBN7cB/QwLsSnr/ j8wv6VJInN4pjrwulNRSAxM7Svbioe0GRgEfr/8deWhfnRx18Hk+Zzf6qIph2riQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdeguddgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomhepfdetnhgu rhgvficulfgvfhhfvghrhidfuceorghnughrvgifsegrjhdrihgurdgruheqnecuggftrf grthhtvghrnhepuddttdekueeggedvtddtueekiedutdfguedutdefieeuteefieelteet vddthfeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 93D0CA00079; Thu, 6 May 2021 22:14:10 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Mime-Version: 1.0 Message-Id: In-Reply-To: <20210506100312.1638-5-steven_lee@aspeedtech.com> References: <20210506100312.1638-1-steven_lee@aspeedtech.com> <20210506100312.1638-5-steven_lee@aspeedtech.com> Date: Fri, 07 May 2021 11:43:49 +0930 From: "Andrew Jeffery" To: "Steven Lee" , "Ulf Hansson" , "Rob Herring" , "Joel Stanley" , "Adrian Hunter" , "Philipp Zabel" , "Ryan Chen" , "moderated list:ASPEED SD/MMC DRIVER" , "moderated list:ASPEED SD/MMC DRIVER" , linux-mmc , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:ARM/ASPEED MACHINE SUPPORT" , "open list" Cc: "Hongwei Zhang" , "Ryan Chen" , "Chin-Ting Kuo" Subject: =?UTF-8?Q?Re:_[PATCH_v3_4/5]_mmc:_sdhci-of-aspeed:_Add_a_helper_for_upda?= =?UTF-8?Q?ting_capability_register.?= Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, I have some minor comments. I expect you're going to do a v4 of the series, so if you'd like to clean them up in the process I'd appreciate it. However, from a pragmatic standpoint I think the patch is in good shape. On Thu, 6 May 2021, at 19:33, Steven Lee wrote: > The patch add a new function aspeed_sdc_set_slot_capability() for > updating sdhci capability register. The commit message should explain why the patch is necessary and not what it does, as what it does is contained in the diff. It's okay to explain *how* the patch acheives its goals if the implementation is subtle or complex. Maybe the commit message could be something like: ``` Configure the SDHCIs as specified by the devicetree. 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 > --- > drivers/mmc/host/sdhci-of-aspeed.c | 57 ++++++++++++++++++++++++++++++ > 1 file changed, 57 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c > b/drivers/mmc/host/sdhci-of-aspeed.c > index d001c51074a0..4979f98ffb52 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; > @@ -70,8 +75,42 @@ struct aspeed_sdhci { > u32 width_mask; > struct mmc_clk_phase_map phase_map; > 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 It would be nice to align the columns to improve readability. > + */ > +static void aspeed_sdc_set_slot_capability(struct sdhci_host *host, > + struct aspeed_sdc *sdc, > + int capability, > + bool enable, > + u8 slot) I prefer we don't take up so much vertical space here. I think this could be just a couple of lines with multiple variables per line. We can go to 100 chars per line. > +{ > + u8 cap_reg; > + u32 mirror_reg_offset, cap_val; The rest of the driver follows "reverse christmas tree" (longest to shortest declaration) style, so I prefer we try to maintain consistency where we can. Essentially, declare them in this order: 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) > @@ -329,6 +368,7 @@ static int aspeed_sdhci_probe(struct platform_device *pdev) > { > const struct aspeed_sdhci_pdata *aspeed_pdata; > struct sdhci_pltfm_host *pltfm_host; > + struct device_node *np = pdev->dev.of_node; Again here with the reverse-christmas-tree style, so: 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; > struct resource *res; > @@ -372,6 +412,23 @@ 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); Again, this would be nicer if we compress it to as few lines as possible. > + } > + > + if (of_property_read_bool(np, "sd-uhs-sdr104")) { > + aspeed_sdc_set_slot_capability(host, > + dev->parent, > + ASPEED_SDC_CAP2_SDR104, > + true, > + slot); As above. Cheers, Andrew