Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C70C07E96 for ; Tue, 6 Jul 2021 14:55:45 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0584A61107 for ; Tue, 6 Jul 2021 14:55:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0584A61107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0672982D80; Tue, 6 Jul 2021 16:55:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gerhold.net header.i=@gerhold.net header.b="axh3bet5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CACB382D5E; Tue, 6 Jul 2021 16:55:07 +0200 (CEST) Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7C9D982D18 for ; Tue, 6 Jul 2021 16:55:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=stephan@gerhold.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1625583294; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=5StWOY5nlDTpPF/RoZFYYn4urQE02kU6ITMHDpk3pZE=; b=axh3bet5g4U2J3yYXVFg2s7ulUGwC860+vlp5QbrmZyPwQIU1jOQuxcw6KXjREJsSO JiqF0X2HyfHxfDpeKQ4dFB2nJmiTmF6sbT8EIilSmhv7LqTkmwgYZHoH9CyjDo3zqqQW FFlKkXVUOZc37ngNTFpLwi1jVLsQt5IL/azBAs1TFIA0TuN/hUa9jfDiMNumzCIUoCPo fxe0yplQY/fIWZpoq1gqQ2uLKr1TIaX5haVjiOHXoHWoQM0CdQGG5QctLBDb2Ik+7ZGt fwmanVv1qhIK8WOqRE7Zzu6fWLP1ZkgY47Fq6WdTjZLBAD7eHnS8K7CTID/DcExhGVMZ RknQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXS7IYBkLahKxB426NnXO3" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.28.1 DYNA|AUTH) with ESMTPSA id Y070ccx66EssbL7 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 6 Jul 2021 16:54:54 +0200 (CEST) From: Stephan Gerhold To: u-boot@lists.denx.de Cc: Linus Walleij , Patrice Chotard , Stephan Gerhold , Jaehoon Chung , Peng Fan Subject: [PATCH 3/4] mmc: arm_pl180_mmci: Simplify code using mmc_of_parse() Date: Tue, 6 Jul 2021 16:54:35 +0200 Message-Id: <20210706145436.165037-4-stephan@gerhold.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210706145436.165037-1-stephan@gerhold.net> References: <20210706145436.165037-1-stephan@gerhold.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean Simplify the code a bit by using the common mmc_of_parse() function instead of duplicating the device tree parsing code. We can still get a default value for cfg->f_max by assigning it before calling mmc_of_parse(). Another advantage of this refactoring is that we parse more properties now, e.g. "non-removable" can be used to disable CD entirely. Signed-off-by: Stephan Gerhold --- drivers/mmc/arm_pl180_mmci.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c index e632eed03f..809b86570a 100644 --- a/drivers/mmc/arm_pl180_mmci.c +++ b/drivers/mmc/arm_pl180_mmci.c @@ -424,7 +424,6 @@ static int arm_pl180_mmc_probe(struct udevice *dev) struct pl180_mmc_host *host = dev_get_priv(dev); struct mmc_config *cfg = &pdata->cfg; struct clk clk; - u32 bus_width; u32 periphid; int ret; @@ -457,24 +456,14 @@ static int arm_pl180_mmc_probe(struct udevice *dev) cfg->voltages = VOLTAGE_WINDOW_SD; cfg->host_caps = 0; cfg->f_min = host->clock_in / (2 * (SDI_CLKCR_CLKDIV_INIT_V1 + 1)); - cfg->f_max = dev_read_u32_default(dev, "max-frequency", MMC_CLOCK_MAX); + cfg->f_max = MMC_CLOCK_MAX; cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; gpio_request_by_name(dev, "cd-gpios", 0, &host->cd_gpio, GPIOD_IS_IN); - bus_width = dev_read_u32_default(dev, "bus-width", 1); - switch (bus_width) { - case 8: - cfg->host_caps |= MMC_MODE_8BIT; - /* Hosts capable of 8-bit transfers can also do 4 bits */ - case 4: - cfg->host_caps |= MMC_MODE_4BIT; - break; - case 1: - break; - default: - dev_err(dev, "Invalid bus-width value %u\n", bus_width); - } + ret = mmc_of_parse(dev, cfg); + if (ret) + return ret; arm_pl180_mmc_init(host); mmc->priv = host; -- 2.32.0