From patchwork Thu Jul 25 20:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 814409 Delivered-To: patch@linaro.org Received: by 2002:adf:e641:0:b0:367:895a:4699 with SMTP id b1csp567693wrn; Thu, 25 Jul 2024 13:51:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoqVUQQqQJPEBuW+KHbTsIsO2DLSMj6Z5Pe7eNF8+ATr7iqBEoqhVfxSUOzjT0SDg/KD+2wLPPU+20U+zOHJS6 X-Google-Smtp-Source: AGHT+IHo0mMgBUYM36UbibYjEadhCS41LG/EXWJENNNEMMKTnDieSTLH0dj1MWYRli+Jkg6nQpw7 X-Received: by 2002:a2e:b058:0:b0:2ef:26ec:44ea with SMTP id 38308e7fff4ca-2f03dbe9478mr21562431fa.39.1721940665790; Thu, 25 Jul 2024 13:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721940665; cv=none; d=google.com; s=arc-20160816; b=zs0rbujpoYcaBaiPbR7PkEOTB1xS1wJmu2dk5iWozwJKrMrOer4vUkFpE3dAYRgn2A z4l4C8loqwHE32gFlAO1nfijyTQWy5kpBhtcQrReac69NKG2qyrUiGqPUurdGEMtLasE xVCDR01D/gLdu1+qBSoH7afU8k+xqCzmM4s9pqkl/lbZuOdlN7z4s0yNiXZQD4snZ6p0 8DnSv9sZapH8qV984BjkLhyy0PP/cpwU9oCd1ZrxAhVQvwXbEUt9r8qkmbzpFsZAkY9A EDVsAIAMAAswP2dAcvwKnz773RRfEYGWWOrROd8Ahd42ddbaUXcZZv7Bindk+T5JyT/A Af4Q== 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=kD77CVfMk1cUO1TrAtNGPeBZuXDZ/fZHKeorr0i7dQY=; fh=Rl4+viPwhTZistbOYP/3i24+h7A34IGp4yesHhay4Yo=; b=F3pzEJ9PsysltEJOv6PJ0j/P4KVtYGPTZ5Wcp5R1nCgYyn4GUxNqZyRTR+1OykPnti cpiBKybfiNsFV9GGRT+zEgoll9f7Yt95cYn8ALzv5iLP2wrrt1yN4+niWp5q9wqisnkD Ni6KDN1kzwRX+SZ4ju7Ez0z0BdwGlgOTdDFJzWDtv0SDf5YSVB7klX/J+4iwwk7CABts 1TnPsbg/e1su6DVsCZXI9wIyGrHpXPaFZ3VRlwYlaaQGpCIHTev6r0+1wdRa0M0+MeQN b5TQEd0ywExwTmtTTVKKVrqbLas9tH1lXSXCO6OwZAIHy17u97iQkMh3+MCKvYzjmIfA Ddsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DsRg6ywl; 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; dara=neutral header.i=@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 38308e7fff4ca-2f03d14abadsi6166561fa.247.2024.07.25.13.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:51:05 -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=DsRg6ywl; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B71CC887E3; Thu, 25 Jul 2024 22:45:56 +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="DsRg6ywl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44316886F0; Thu, 25 Jul 2024 22:45:49 +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-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (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 1441088722 for ; Thu, 25 Jul 2024 22:45:46 +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-x32b.google.com with SMTP id 46e09a7af769-70936061d0dso201434a34.2 for ; Thu, 25 Jul 2024 13:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721940345; x=1722545145; 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=kD77CVfMk1cUO1TrAtNGPeBZuXDZ/fZHKeorr0i7dQY=; b=DsRg6ywlRVMi7HRbe8WSxZktz+igo0toTP0w1Cv2g76t6mLJTNt30Wb6U7bsj8sQVx QQOxg3GNa2Nf32xcK76dgqZll9Sz2LDhrKjX+Bh1GNrjFGDn9Inzjb3ALCrz98iLU0rv UTIID+wtiqrMpsc4qAMWf2POOwLqYzzTPykmZCAjA1LF6/epvstAFM6nuwVa2Ku06KAs DuMi1XWDYzYeRixlnfBfhzGBgwEDP93CB92Ud1cBZPzTsOEY7HhpLouHz0D23/8b8kio uPKpWG9JmfikjIpnJqki2jDNTL9ZFgSTWXMvSgZcZJVVdU2rjC/rc2Zp8qTp6cByicxC aqWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721940345; x=1722545145; 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=kD77CVfMk1cUO1TrAtNGPeBZuXDZ/fZHKeorr0i7dQY=; b=UWfV1WeFsPhVY4o9MhfreqwGauD3LIDkiSC4rO/NlrEiGfCt6ST7gB4cXZwgWhoeoC bx7OMgNItVOUP38EKy8s3HZMIzoPiyc5PR1RC+5UA0JAWd6fyam7iMR18DAmqMjs9SP9 jg/35ByGRCRCMEpIC0uKcRKCnb0k7KNMy1k1HM9Qgip7eRkUHxaDbVFrKluHoJUb9Wi7 y/MXsMQHgK1OkWr3+VAKDEs6d0nc4D65K37fEGnwfpsoOzLBfBySsDMxtesenFWeCOlQ KlPXpbKD9KozozTFf7O0JzPGMGy5xZu76QcFRINPeDNGCE3xOjH+sBln/vy/0NRxmOEU oeGg== X-Forwarded-Encrypted: i=1; AJvYcCUDTPSffpdkqjB5k+Igv4A8cSqoydZUHrOg57AGjik+1Drrf0XeyWl7b1ksJiMZeLCzyVR+O6aoVKlU2IUC3Ct2ByBSaQ== X-Gm-Message-State: AOJu0YzlXtVymfSln9R87lvHOT1NkuI3ScZEOj0f1ZeBOKh5yQ8Me78Z JGtgjFO+tTRjE5hoLJZz4HMJZJESUygeWaf0IacpxmrWrRLvn94dGIxWR6har98= X-Received: by 2002:a05:6830:6217:b0:700:d506:cfe9 with SMTP id 46e09a7af769-7093223d036mr4184298a34.19.1721940344826; Thu, 25 Jul 2024 13:45:44 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-70930729601sm463428a34.40.2024.07.25.13.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 13:45:44 -0700 (PDT) From: Sam Protsenko To: Jaehoon Chung Cc: Minkyu Kang , Minkyu Kang , Tom Rini , Peng Fan , Simon Glass , Quentin Schulz , 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 v4 32/38] mmc: exynos_dw_mmc: Pull all init code into probe function Date: Thu, 25 Jul 2024 15:45:14 -0500 Message-Id: <20240725204520.18134-33-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240725204520.18134-1-semen.protsenko@linaro.org> References: <20240725204520.18134-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 --- Changes in v4: - (none) Changes in v3: - (none) Changes in v2: - Replaced CONFIG_IS_ENABLED() with #ifdef 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 29241edf7915..41fb32c579ef 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; - -#ifndef CONFIG_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) -{ -#ifdef CONFIG_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); -} - #ifdef CONFIG_DM_MMC static int exynos_dwmmc_of_to_plat(struct udevice *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; #ifndef CONFIG_CPU_V7A @@ -353,9 +305,41 @@ static int exynos_dwmmc_probe(struct udevice *dev) return err; #endif - err = do_dwmci_init(host); - if (err) +#ifdef CONFIG_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; + +#ifndef CONFIG_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;