From patchwork Sat Dec 29 16:28:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chee, Tien Fong" X-Patchwork-Id: 1019382 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43Rpt0423Sz9s2P for ; Sun, 30 Dec 2018 03:28:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1C04FC21E2F; Sat, 29 Dec 2018 16:28:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E8363C21D4A; Sat, 29 Dec 2018 16:28:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A7C15C21D4A; Sat, 29 Dec 2018 16:28:25 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lists.denx.de (Postfix) with ESMTPS id 10BD7C21C3F for ; Sat, 29 Dec 2018 16:28:23 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Dec 2018 08:28:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,414,1539673200"; d="scan'208";a="306016139" Received: from pg-iccf0290.altera.com ([10.104.1.94]) by fmsmga006.fm.intel.com with ESMTP; 29 Dec 2018 08:28:19 -0800 From: tien.fong.chee@intel.com To: u-boot@lists.denx.de Date: Sun, 30 Dec 2018 00:28:14 +0800 Message-Id: <1546100894-22709-1-git-send-email-tien.fong.chee@intel.com> X-Mailer: git-send-email 1.7.7.4 Cc: Tom Rini , Tien Fong Chee , Ching Liang See , Westergteen Dalon Subject: [U-Boot] [PATCH v2] Add support for initializing MMC X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Tien Fong Chee Firmware loader would encounter problem if the MMC is accessed before initializing it. This patch would adding the support of probing block device and initializing MMC before the MMC is accessed by firmware loader. Signed-off-by: Tien Fong Chee --- Changes in v2: - Initializing MMC through probing the blk device --- drivers/misc/fs_loader.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c index 57a14a3..d981b5a 100644 --- a/drivers/misc/fs_loader.c +++ b/drivers/misc/fs_loader.c @@ -12,6 +12,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -252,6 +253,37 @@ static int fs_loader_ofdata_to_platdata(struct udevice *dev) static int fs_loader_probe(struct udevice *dev) { +#if defined(CONFIG_DM_MMC) && defined(CONFIG_BLK) + int ret; + struct device_platdata *plat = dev->platdata; + + ret = mmc_initialize(NULL); + if (ret) { + debug("MMC: could not initialize mmc. error: %d\n", ret); + + return ret; + } + + if (plat->phandlepart.phandle) { + ofnode node = ofnode_get_by_phandle(plat->phandlepart.phandle); + + struct udevice *mmc_dev = NULL; + + ret = device_get_global_by_ofnode(node, &mmc_dev); + if (!ret) { + struct mmc *mmc = mmc_get_mmc_dev(mmc_dev); + struct udevice *dev; + + if (blk_get_from_parent(mmc->dev, &dev)) + { + debug("MMC: No block device: %d\n", + ret); + + return ret; + } + } + } +#endif return 0; };