From patchwork Sun May 1 19:52:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 617247 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qydSp3yKBz9sdQ for ; Mon, 2 May 2016 05:55:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=gLxF4rgZ; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5DFCCB3868; Sun, 1 May 2016 21:54:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QA-NfqmL3Cbk; Sun, 1 May 2016 21:54:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 98A5DB3869; Sun, 1 May 2016 21:53:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E2F7EB3825 for ; Sun, 1 May 2016 21:53:32 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BPRdCyonEuy0 for ; Sun, 1 May 2016 21:53:32 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f170.google.com (mail-io0-f170.google.com [209.85.223.170]) by theia.denx.de (Postfix) with ESMTPS id CA329B3804 for ; Sun, 1 May 2016 21:53:27 +0200 (CEST) Received: by mail-io0-f170.google.com with SMTP id 190so146606061iow.1 for ; Sun, 01 May 2016 12:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BLQ1bn2OW0NsgFqOIA025SWi+QJ7kUvInqfnE8vRZvM=; b=gLxF4rgZBVHfKQTzaNxtz2ORI83ptQMiKhgBwbLJ2FPedQvjMd0QhnbGezioo1IWCU J9Z13gMsfdalGZJDuGkcWxMjdW4D3h01ZKJdxLXM1rm1nu580QIncFv/z3+z3NYKFKtx wSZWS1O4Wxan0L5/v/EDZHSH5U5e/+WlzbxU3p45siLHUx18gaEZuyWbUnnHtl6gjVIW pdgn0+LH4DKTfOv6wHOULKyxAwytvzzPCh5sIFidsib+2+dv/Yo+6oFwE8K9e5+hX3Kc FvNj3cnrb0WymfYYdqwSyYlznbjiS9czPEHzjRU1iQ3rVhx5Z/BH0kKjLbsuGmPDjKuP 8C/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=BLQ1bn2OW0NsgFqOIA025SWi+QJ7kUvInqfnE8vRZvM=; b=jaICYut6heZQelqD4UFkD1TYUhsrbgt9RoJOVKDX/KW1VUfWd6K7flj2QF4ZkcDgGI rzsyc3QoLd9Xo8t7ukWoxDQtQwWrDFDRyJpgiVwy8IKetyHnoAUPItfg3r7UQW/ClX5Y B7YUcE8KRL9/jfr6IqMTgxgwFEvhhPApBtgM0Ls00262NGUG282Tt84tBkSiWTCvi8Zw e6ikK4ybTrm5B2QezZEJ82ZfrNG+DsmbXuE1oXLhz6CfHTRB8OP9DYb2oHYPXnoOsriA EOS92NHzSkjfm4jKoRjoHEyieLTZUfi28LNYb8A9t7M1uGeSsFqF3HBOuAzbN3YWIEZF PMKQ== X-Gm-Message-State: AOPr4FWhmiwq5zdCNIVlKO/7Mwe4qvJbYnA/ugcAOdjxtkAbrc41vEfe/gNCIJLwAxdpJd+N X-Received: by 10.107.4.9 with SMTP id 9mr9612451ioe.14.1462132406566; Sun, 01 May 2016 12:53:26 -0700 (PDT) Received: from kaki.bld.corp.google.com ([100.100.202.57]) by smtp.gmail.com with ESMTPSA id k3sm8060662igz.2.2016.05.01.12.53.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 May 2016 12:53:23 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id C7205221267; Sun, 1 May 2016 13:53:18 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 1 May 2016 13:52:40 -0600 Message-Id: <1462132365-11536-20-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1462132365-11536-1-git-send-email-sjg@chromium.org> References: <1462132365-11536-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Stephen Warren , Pantelis Antoniou Subject: [U-Boot] [PATCH v2 19/24] dm: mmc: Add a way to bind MMC devices with driver model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" Binding an MMC device when CONFIG_BLK is enabled requires that a block device be bound as a child of the MMC device. Add a function to do this. The mmc_create() method will be used only when DM_BLK is disabled. Add an unbind method also. Signed-off-by: Simon Glass --- Changes in v2: None drivers/mmc/mmc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/mmc.h | 22 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 4ba13a1..7183afc 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1531,6 +1531,53 @@ int __deprecated mmc_register(struct mmc *mmc) return -1; } +#ifdef CONFIG_BLK +int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) +{ + struct blk_desc *bdesc; + struct udevice *bdev; + int ret; + + ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, -1, 512, + 0, &bdev); + if (ret) { + debug("Cannot create block device\n"); + return ret; + } + bdesc = dev_get_uclass_platdata(bdev); + mmc->cfg = cfg; + mmc->priv = dev; + + /* the following chunk was from mmc_register() */ + + /* Setup dsr related values */ + mmc->dsr_imp = 0; + mmc->dsr = 0xffffffff; + /* Setup the universal parts of the block interface just once */ + bdesc->if_type = IF_TYPE_MMC; + bdesc->removable = 1; + + /* setup initial part type */ + bdesc->part_type = mmc->cfg->part_type; + mmc->dev = dev; + + return 0; +} + +int mmc_unbind(struct udevice *dev) +{ + struct udevice *bdev; + + device_find_first_child(dev, &bdev); + if (bdev) { + device_remove(bdev); + device_unbind(bdev); + } + + return 0; +} + +#else struct mmc *mmc_create(const struct mmc_config *cfg, void *priv) { struct blk_desc *bdesc; @@ -1574,6 +1621,7 @@ void mmc_destroy(struct mmc *mmc) /* only freeing memory for now */ free(mmc); } +#endif static int mmc_get_dev(int dev, struct blk_desc **descp) { diff --git a/include/mmc.h b/include/mmc.h index 6d1f05c..fb8d9b2 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -409,7 +409,29 @@ enum mmc_hwpart_conf_mode { int mmc_register(struct mmc *mmc); struct mmc *mmc_create(const struct mmc_config *cfg, void *priv); + +/** + * mmc_bind() - Set up a new MMC device ready for probing + * + * A child block device is bound with the IF_TYPE_MMC interface type. This + * allows the device to be used with CONFIG_BLK + * + * @dev: MMC device to set up + * @mmc: MMC struct + * @cfg: MMC configuration + * @return 0 if OK, -ve on error + */ +int mmc_bind(struct udevice *dev, struct mmc *mmc, + const struct mmc_config *cfg); void mmc_destroy(struct mmc *mmc); + +/** + * mmc_unbind() - Unbind a MMC device's child block device + * + * @dev: MMC device + * @return 0 if OK, -ve on error + */ +int mmc_unbind(struct udevice *dev); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);