From patchwork Wed May 22 23:31:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 798215 Delivered-To: patch@linaro.org Received: by 2002:ab3:6414:0:b0:267:d849:ee76 with SMTP id j20csp919430lte; Wed, 22 May 2024 16:38:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWaxzDaYUh6aINdHILjjM9sUi/9nZ9JgGcN4ZYOW5x4jQfUI8dBlJdAOQ0KB0dSJ0EkluXlzd3yk6X9kSIHoAQd X-Google-Smtp-Source: AGHT+IFqfCA0Znap5xl2rrjZMiWse5F2iPrbf42aTrp6WxlYtXCQLowOp4YbJBFrRylafcXoqn+L X-Received: by 2002:a05:6512:3ee:b0:518:9cbf:cd6b with SMTP id 2adb3069b0e04-526bd69494fmr1943106e87.13.1716421099531; Wed, 22 May 2024 16:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716421099; cv=none; d=google.com; s=arc-20160816; b=gLJ3xgKFrp2YQ2xL94SzHWz4jAUi4mNLBq+lbWbWlW4dqA3IdCOm8RJBKOqH/L/DjL v8G1rb0GpKqy2m4vGHuYrbyB/Po9I//feD4LVq09q4SEaMplzO+BMu80KkyeHQVBrIUO E122D/yvSg9zxiUlbpctgnJZ3Qq19dDBlpj5zDij6I06AIEnYBgyabQ5897ZoXDuTJTK x8twiObL+6S/lyaNRjNsaKbZWCHcr3I+dX0q0ECheeHparojdz7z9CmOianUVtBi79zM Y4jnRuYSOt2phImKC0YoL1zR62YDk0mJopfEmLcwGnKmcJQ9QZei/H7K9jSgKqerRnWK 8Nyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tNm3zxNnxTGzaQjFGzkTXRPolvlW1D8U3GEIccFIC28=; fh=Ci8EqorOeKb248YuId9kzFezoyw/H9f6qYJUVIxx3Dk=; b=MZnQOTiyX7zhwGkPMMAaxuKrc6JfDn7W83qq7meZbdJRpElsQUSRxRpUCFX0GyA5eS uuTy3ajVMSdNtdusfkHZIb9r6vpWZrNtrCAttfJj440mxknTZ3WHuZyWKT7Z71cZPNwL 23Kt1sOq61Gr1bX1/w/tAonJw0yIK4kGj8f7+Riqt026kKOG/rYTgQ4rQoDZ+OZmdkg3 2KxQvuFD8VEimVb9bed+lz954M964P1Y2HKPnb3aC5M7RWCulWf3zIWB/1NaWK8piKRj UEx09u9klSDSPzGqR530H3XJt92G3st81t9lsoFZp53YefFnV3VEek231FZb5wkdqmaN S0nA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tYhm4UnK; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a179462e4si1496905566b.142.2024.05.22.16.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tYhm4UnK; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D41B888B7; Thu, 23 May 2024 01:32:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="tYhm4UnK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 247A28858E; Thu, 23 May 2024 01:32:13 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (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 B284D88589 for ; Thu, 23 May 2024 01:32:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6ed3587b93bso3929517a34.1 for ; Wed, 22 May 2024 16:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716420726; x=1717025526; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tNm3zxNnxTGzaQjFGzkTXRPolvlW1D8U3GEIccFIC28=; b=tYhm4UnKMVW4/XDsvCw2mGSmILzJTj3KWXELEHhMNRSVlzZlmJx95KemrJ3n+l+0Af k/QFBbo0QZvAplhgzzlxbjFdu07V/JNPY6KdWNm6ZSex41duiAAZ9AiHO9CwZ5rE9V/j YRLKHrAAbFMeEQc5NLmYlvcyu0jAKTpNLaI0OUM1A9djkKchlm/wKdpNCd/dMW5PVDcr FGjyavPIdA0hCWsav0sNogN6tze0fw+7d07Q7tVSd/e9dRvwH6HAvMQuv2VWsvRw7F5o 9wrg/8BW9ZTnCKeURldngKgFSNnKvCeUaQi13G0rBleOrWx68Ga6fUfi9E2l5I68YNSH 8btA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716420726; x=1717025526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tNm3zxNnxTGzaQjFGzkTXRPolvlW1D8U3GEIccFIC28=; b=uRpzE2MWuh+XH0pyO/EhgvwarzG8LolKBB/mSxMrAnAqFIaHuALFZRbOdc+Ssdk68R 4FFQAmk2Q0+w7GlNN8fidPJebedYx/Z9X3hyVUwf/aASmqeSJ0JTuZ4gNXfMqGf3W9mj j/BOvo9Hj1+FY5UyBhGb7sIUMVHVCgtA6MoNGpYppMara7WDDtpsy2+w1MewCsoEMs0b 2nRP8NQmdA884mzX8DjnEkhDcZABfk8aov4QOdfZAg05JlQCAwL6eFovn1J/keTuEUnU LItq7t4prABUnuNPh6Rgnh0irrVR/LyrwPYaak2Cu4NR2ooethKMPzpCzoKyVyKZulPk PEeg== X-Forwarded-Encrypted: i=1; AJvYcCV1iZG5g5kYH9PlzgIH+LSeJxqEYM5n1LezEo4S5/bfwJPVmrWLQVl4HCRIQzA9qwfVkraep7MbgGj978HUEhKtnfDChQ== X-Gm-Message-State: AOJu0Yy8s0XCPimtXySXLxWo4B5PUD2T2VPDgy9ZrAfbw4cgedTAlgmQ HxsaygS+pqbARcRW3KQ0RsYLZOJU6fXzx1b7lZV5CuvDwMkYDxIqXoinMvAB842pJniGqmrU+FP Yl+A= X-Received: by 2002:a9d:6313:0:b0:6ee:4039:8412 with SMTP id 46e09a7af769-6f6699127c7mr3352642a34.33.1716420726473; Wed, 22 May 2024 16:32:06 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-6f0ff995ccdsm4165473a34.34.2024.05.22.16.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 16:32:06 -0700 (PDT) From: Sam Protsenko To: Tom Rini , Minkyu Kang , Peng Fan , Jaehoon Chung , Simon Glass Cc: Philipp Tomsich , Kever Yang , Eugeniy Paltsev , Peter Robinson , Jonas Karlman , Yang Xiwen , Ferass El Hafidi , Sean Anderson , u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Subject: [PATCH 36/42] mmc: exynos_dw_mmc: Pull all init code into probe function Date: Wed, 22 May 2024 18:31:29 -0500 Message-Id: <20240522233135.26835-37-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522233135.26835-1-semen.protsenko@linaro.org> References: <20240522233135.26835-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean There is no logical sense to split the initialization code between multiple functions. Pull both do_dwmci_init() and exynos_dwmci_core_init() into exynos_dwmmc_probe() to make the code more simple and obvious. No functional change. Signed-off-by: Sam Protsenko --- drivers/mmc/exynos_dw_mmc.c | 86 +++++++++++++++---------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index b7c3b356f0ac..19793e7ad460 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -209,55 +209,6 @@ static void exynos_dwmci_board_init(struct dwmci_host *host) exynos_dwmci_clksel(host); } -static int exynos_dwmci_core_init(struct dwmci_host *host) -{ - unsigned long freq; - int err; - - if (host->bus_hz) - freq = host->bus_hz; - else - freq = DWMMC_MAX_FREQ; - - err = exynos_dwmmc_set_sclk(host, freq); - if (err) { - printf("DWMMC%d: failed to set clock rate on probe (%d); " - "continue anyway\n", host->dev_index, err); - } - - host->name = "EXYNOS DWMMC"; - host->board_init = exynos_dwmci_board_init; - host->caps = MMC_MODE_DDR_52MHz; - host->clksel = exynos_dwmci_clksel; - host->get_mmc_clk = exynos_dwmci_get_clk; - -#if !CONFIG_IS_ENABLED(DM_MMC) - /* Add the mmc channel to be registered with mmc core */ - if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) { - printf("DWMMC%d registration failed\n", host->dev_index); - return -1; - } -#endif - - return 0; -} - -static int do_dwmci_init(struct dwmci_host *host) -{ -#if CONFIG_IS_ENABLED(CPU_V7A) - int flag, err; - - flag = host->buswidth == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE; - err = exynos_pinmux_config(host->dev_id, flag); - if (err) { - printf("DWMMC%d not configure\n", host->dev_index); - return err; - } -#endif - - return exynos_dwmci_core_init(host); -} - static int exynos_dwmmc_of_to_plat(struct udevice *dev) { struct dwmci_exynos_priv_data *priv = dev_get_priv(dev); @@ -345,6 +296,7 @@ static int exynos_dwmmc_probe(struct udevice *dev) struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct dwmci_exynos_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; + unsigned long freq; int err; #if !CONFIG_IS_ENABLED(CPU_V7A) @@ -353,9 +305,41 @@ static int exynos_dwmmc_probe(struct udevice *dev) return err; #endif - err = do_dwmci_init(host); - if (err) +#if CONFIG_IS_ENABLED(CPU_V7A) + int flag; + + flag = host->buswidth == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE; + err = exynos_pinmux_config(host->dev_id, flag); + if (err) { + printf("DWMMC%d not configure\n", host->dev_index); return err; + } +#endif + + if (host->bus_hz) + freq = host->bus_hz; + else + freq = DWMMC_MAX_FREQ; + + err = exynos_dwmmc_set_sclk(host, freq); + if (err) { + printf("DWMMC%d: failed to set clock rate on probe (%d); " + "continue anyway\n", host->dev_index, err); + } + + host->name = "EXYNOS DWMMC"; + host->board_init = exynos_dwmci_board_init; + host->caps = MMC_MODE_DDR_52MHz; + host->clksel = exynos_dwmci_clksel; + host->get_mmc_clk = exynos_dwmci_get_clk; + +#if !CONFIG_IS_ENABLED(DM_MMC) + /* Add the mmc channel to be registered with mmc core */ + if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) { + printf("DWMMC%d registration failed\n", host->dev_index); + return -1; + } +#endif dwmci_setup_cfg(&plat->cfg, host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ); host->mmc = &plat->mmc;