From patchwork Tue Sep 15 19:51:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alex G." X-Patchwork-Id: 1364642 X-Patchwork-Delegate: patrick.delaunay73@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=R1ZSOYZP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BrYsS6qhVz9sTC for ; Wed, 16 Sep 2020 05:57:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A9C482365; Tue, 15 Sep 2020 21:55:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="R1ZSOYZP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2ABE81BDF; Tue, 15 Sep 2020 21:52:01 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) (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 4E54D81BD2 for ; Tue, 15 Sep 2020 21:51:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-oi1-x242.google.com with SMTP id 185so5235933oie.11 for ; Tue, 15 Sep 2020 12:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JF/5NmdWwT6Sni9NhTJ0/fhI5cBiA6k1fLvCmuvKoKE=; b=R1ZSOYZPvFRBdUmFOoT+OU272X6EFkIgUB7xTNlHj4W1poeIW+Thfw9Kd/D4MhfDmu 0FqU/orZf99IhXmswAEk0lt6m7fXFJhx4WmKwked/8ThM3ce83flrtp+fNEqIPhGOa1c gnayQDRqvf1eAlXYN8dauWKL0JcGX1Yq+ODGs/Hh6TVH0SI/nNQKDjbk1fhtXfPAot7f 6RVQQIDZAfFmv8F0blBWstkH61xbS871YXALn8J4bmQ/0jO2bMkUTH4MsCQJuMiLojEy Wn67nB+Hi6eJWnSgfJ+pS/+v6x375DpXg2Dy2dpcx0C2QC+47J0nRHOC1lL/Ox3RR43j cWOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JF/5NmdWwT6Sni9NhTJ0/fhI5cBiA6k1fLvCmuvKoKE=; b=sckAwJ3C40e3W12d621POYQfdDbqn1Ktt9zl2fmGIiuMnSsPJocNNEeWKzSfJoVQSZ GbrWhSKu73rABx27ck9VWcN+UZ4tJmL1gQiDVk+4aLVzfyDkwJb3brlCVnMac+ZwEkii peONFU1zlEOSeYkyhioAwuMMvTfHg5JYhfg4A4kJynJBGXuDW1Wb5RNUFvt1bnMvH1bl gS4C2Y5Nyrnto+iM2NMbKnODZ8+qKOhZpb0M+1T6qe7PpdcsDg8h+4lXECbgG2ip4spM lgGICl2zTRMz2KlVpg1D2ufCGmq8RkCCE2G7mY+Rgr/kivj6wm+7fyMJHR0iWo7NSnuB oFxw== X-Gm-Message-State: AOAM533p4I9fjDw8QvqeOOlnFBEVe/nX4cu6PS7nAXhbRcDm87WB55b9 8EMuLprlRxsbqecXs75lHPs= X-Google-Smtp-Source: ABdhPJzChX98I24VUNMgqyh+q4ZlrL5MjOA/9gbQ+GWGTLDgTcfVBZrtovVYbgnmbuFqne7IhYXaXg== X-Received: by 2002:aca:5297:: with SMTP id g145mr752283oib.139.1600199518011; Tue, 15 Sep 2020 12:51:58 -0700 (PDT) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id t7sm7896874ooq.0.2020.09.15.12.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 12:51:57 -0700 (PDT) From: Alexandru Gagniuc To: uboot-stm32@st-md-mailman.stormreply.com, peng.fan@nxp.com Cc: Alexandru Gagniuc , Patrick Delaunay , Patrice Chotard , u-boot@lists.denx.de Subject: [PATCH v2 2/2] mmc: stm32_sdmmc2: Use mmc_of_parse() to read host capabilities Date: Tue, 15 Sep 2020 14:51:47 -0500 Message-Id: <20200915195147.2659607-2-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200909215402.366561-1-mr.nuke.me@gmail.com> References: <20200909215402.366561-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 15 Sep 2020 21:55:23 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean mmc_of_parse() can populate the 'f_max' and 'host_caps' fields of struct mmc_config from devicetree. The same logic is duplicated in stm32_sdmmc2_probe(). Use mmc_of_parse(), which is more generic. Signed-off-by: Alexandru Gagniuc Reviewed-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- Changes from v1: - Check the return value of mmc_of_parse(). - The call to mmc_of_parse() is moved further up. This means we can just 'return err' on error instead of exiting via goto. drivers/mmc/stm32_sdmmc2.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c index 6d50356217..a29657429c 100644 --- a/drivers/mmc/stm32_sdmmc2.c +++ b/drivers/mmc/stm32_sdmmc2.c @@ -653,6 +653,12 @@ static int stm32_sdmmc2_probe(struct udevice *dev) if (priv->base == FDT_ADDR_T_NONE) return -EINVAL; + cfg->host_caps = 0; + cfg->f_max = 52000000; + ret = mmc_of_parse(dev, cfg); + if (ret < 0) + return ret; + if (dev_read_bool(dev, "st,neg-edge")) priv->clk_reg_msk |= SDMMC_CLKCR_NEGEDGE; if (dev_read_bool(dev, "st,sig-dir")) @@ -676,28 +682,10 @@ static int stm32_sdmmc2_probe(struct udevice *dev) GPIOD_IS_IN); cfg->f_min = 400000; - cfg->f_max = dev_read_u32_default(dev, "max-frequency", 52000000); cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; cfg->name = "STM32 SD/MMC"; - cfg->host_caps = 0; - if (cfg->f_max > 25000000) - cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; - - switch (dev_read_u32_default(dev, "bus-width", 1)) { - case 8: - cfg->host_caps |= MMC_MODE_8BIT; - /* fall through */ - case 4: - cfg->host_caps |= MMC_MODE_4BIT; - break; - case 1: - break; - default: - pr_err("invalid \"bus-width\" property, force to 1\n"); - } - upriv->mmc = &plat->mmc; /* SDMMC init */