From patchwork Thu Sep 21 14:30:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 113264 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2108272qgf; Thu, 21 Sep 2017 07:41:36 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDDZIW08xk08JNyeu5Jt7PNKCjeUuS7+EVkgWsgcyzwFk+j0ph8NTo5UdrNRCgI2af7eeeL X-Received: by 10.80.144.202 with SMTP id d10mr1459011eda.254.1506004896856; Thu, 21 Sep 2017 07:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004896; cv=none; d=google.com; s=arc-20160816; b=G9PyORibwHZwvZwU5YIQY4qYFv3gvl/A8VvYLRnDVmBfkKx4R8VPhJQK2XXwj+xSUO 1VwQORGnFOTbE2JUx6e8ohnuhbz7JTioLP1H/s75xFqToV3GuEsS1b75B7vlGbmi36FV jpnyTBp6sAMv8roFRHHKm27Gj0K8dTCnO7fRriT2Ff4kguZ+ouC1oBtN0umb27c1Pxbm /1ksjAIDUzkIYY1vUSd/isCrHJjWFGFj9iY4CuSmwTnOZNAWov93QQPBiioNuLoolYQH JmZ8Hk+rstv2sCu43klyzyMw4C4SueAqmDaL5c1YLQNnKsAKhAl21DC2vuF5jAkdi/fd /lIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=pdimkN7sRqMo5c03gmCAHv/wpxc4OSSPgTyMPU4Ut9I=; b=M0zVt1wzmbvoDE/hYk6eMp/9Gbrrt3aBtK0k9P1pGy9KQCgKMA/boQ2sDrK0yYHlh9 B89Y1vDdR6x4WsQTumJYMwTX7Bdee4X01cTbU7xgtF221HFazEAqgGpLGsPsFjDhZD0V yqaU1KJ4Vt0h74iav3E3+5xxD8H+97ukbsundd+3IVFoRdmVWi/gXWNV1y0D24jeUQ61 JmIH3EwZqdBc+PVQIMQFHPBQsA7Y9+KbAMePXmSKvX7sHj7atqzDUJ9DFSjtWNs1BLPr QwJDrW6SKbm5fqVSXrSQIjZaMKQKXd2EKSf8zlGBZZ249cARcbnsWFDfLZ6/6Sb5xfRf AHMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=gxAgFzbm; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 7si377979edf.105.2017.09.21.07.41.36; Thu, 21 Sep 2017 07:41:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=gxAgFzbm; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: by lists.denx.de (Postfix, from userid 105) id 73668C21EAB; Thu, 21 Sep 2017 14:36:01 +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=RCVD_IN_DNSWL_NONE, T_DKIM_INVALID 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 14F08C2200A; Thu, 21 Sep 2017 14:32:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4ADA5C22017; Thu, 21 Sep 2017 14:31:26 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id ACF0BC21FF9 for ; Thu, 21 Sep 2017 14:31:19 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEVHtE000526; Thu, 21 Sep 2017 09:31:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004277; bh=+aSH85jPIil0YmIkCkhAsqUZSCCr/rsYvtOv6r2ERTo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gxAgFzbmAcaYw+FsgC4xBP7HVXJ/xXFnhK/nBVat2eq1XCRWO5JnXsa214ogtzP0z HKYCWQOQ10cIPniIHOII+QXaPPo1xaqobzLR11qm4FS2Q9CXeGwGDPwFX1ciyPqwkQ eIBlGeRnjPk9KJ2sbUx2TR5ggvjQi+QUvBj+iG2Y= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEVHCa029640; Thu, 21 Sep 2017 09:31:17 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Thu, 21 Sep 2017 09:31:17 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Thu, 21 Sep 2017 09:31:17 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEVFk3031471; Thu, 21 Sep 2017 09:31:16 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:13 +0200 Message-ID: <1506004213-22620-27-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506004213-22620-1-git-send-email-jjhiblot@ti.com> References: <1506004213-22620-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 26/26] dm: mmc: Add a library function to parse generic dt binding 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Kishon Vijay Abraham I Add a new function to parse host controller dt node and set mmc_config. This function can be used by mmc controller drivers to set the generic mmc_config. This function can be extended to set other UHS mode caps once UHS mode support is added. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/mmc-uclass.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/mmc.h | 1 + 2 files changed, 47 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 7856e0a..e30cde7 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -120,6 +120,52 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode) return dm_mmc_execute_tuning(mmc->dev, opcode); } +int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg) +{ + int val; + + val = fdtdec_get_int(fdt, node, "bus-width", 1); + + switch (val) { + case 0x8: + cfg->host_caps |= MMC_MODE_8BIT; + /* fall through */ + case 0x4: + cfg->host_caps |= MMC_MODE_4BIT; + /* fall through */ + case 0x1: + cfg->host_caps |= MMC_MODE_1BIT; + break; + default: + printf("error: %s invalid bus-width property %d\n", + fdt_get_name(fdt, node, NULL), val); + return -ENOENT; + } + + cfg->f_max = fdtdec_get_int(fdt, node, "max-frequency", 52000000); + + if (fdtdec_get_bool(fdt, node, "cap-sd-highspeed")) + cfg->host_caps |= MMC_CAP(SD_HS); + if (fdtdec_get_bool(fdt, node, "cap-mmc-highspeed")) + cfg->host_caps |= MMC_CAP(MMC_HS); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr12")) + cfg->host_caps |= MMC_CAP(UHS_SDR12); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr25")) + cfg->host_caps |= MMC_CAP(UHS_SDR25); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr50")) + cfg->host_caps |= MMC_CAP(UHS_SDR50); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr104")) + cfg->host_caps |= MMC_CAP(UHS_SDR104); + if (fdtdec_get_bool(fdt, node, "sd-uhs-ddr50")) + cfg->host_caps |= MMC_CAP(UHS_DDR50); + if (fdtdec_get_bool(fdt, node, "mmc-ddr-1_8v")) + cfg->host_caps |= MMC_CAP(MMC_DDR_52); + if (fdtdec_get_bool(fdt, node, "mmc-hs200-1_8v")) + cfg->host_caps |= MMC_CAP(MMC_HS_200); + + return 0; +} + struct mmc *mmc_get_mmc_dev(struct udevice *dev) { struct mmc_uclass_priv *upriv; diff --git a/include/mmc.h b/include/mmc.h index 79be6b4..6230a32 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -651,6 +651,7 @@ int mmc_unbind(struct udevice *dev); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error); +int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg); int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); /**