From patchwork Fri Jan 22 02:43:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 571433 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 63B4F140326 for ; Fri, 22 Jan 2016 13:53:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=FpUPxL7c; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C8A0E4BF5F; Fri, 22 Jan 2016 03:53:06 +0100 (CET) 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 uaiDCDD4PjQ9; Fri, 22 Jan 2016 03:53:06 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3763C4BE4A; Fri, 22 Jan 2016 03:50:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C5244BB6D for ; Fri, 22 Jan 2016 03:45:03 +0100 (CET) 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 iCBfC_yf81TN for ; Fri, 22 Jan 2016 03:45:03 +0100 (CET) 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-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by theia.denx.de (Postfix) with ESMTPS id 968EF4BAF9 for ; Fri, 22 Jan 2016 03:44:26 +0100 (CET) Received: by mail-oi0-f53.google.com with SMTP id w75so39211446oie.0 for ; Thu, 21 Jan 2016 18:44:26 -0800 (PST) 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=G9i941EOe2pgVsuvjiTeqBybUuPy7VocWp+yuFbqMk8=; b=FpUPxL7cVKMZKKCjF1tf8PggsPD+aRvfwBcc2xLIy6xnmNLnhPv1Vr07NXpDKsXPLy t5u9SJyZ9ZAlF8Ik+HENn6GbSF06gUA3eHbtF+X3ZcCDVk0iR9JLDEPeKX/IM6loSKgj PHLgDjCyHSCFYgkKkXYvSIHDk4JbJ3qK+1/ppeAM/ZnBDi7+/+n2+aBWgoMs1DqYVeWT Gi1jmVZYfhqIHOBEbGU7/nKw2truQHYly4pGj2o48l/yl5hsdZcrGCy+cDN135k5Zk4I nnJj9M8DVRtZBw66GFCvBd9g4oSaMzoMszgB2MqeMjai80NCe79Mnx5bmKtpaAgiZ08X M0Gw== 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=G9i941EOe2pgVsuvjiTeqBybUuPy7VocWp+yuFbqMk8=; b=BYfTZTvHCt85iibboIhFCj8gTQ+d6a589EO/x+kxH61obQe6d7K963ldNZQuFYJ2u9 5HbrO8PW3gs65kmJkhp6X01hlX3BsdNxeODn5uWMDiGSmNcbO+col1dE+sZb7sUwl5s9 7k2ffWVcfi8PG10dYTdnpYUrc5zVPMhe8qplAOzLBp5ZELpivsTfKaMyNC1VxCZn82md 1UeXPPzfXvA87tcg/UhRVYxYvw9WR4mtq40GjRi/oWoEzMbhMTj1U7uX70TAtte2H/FP DYQyknsSULiK/2T+c2W7qBwLjf6GuPLF4eQubXe4Sg3u1rFpuK0ob8uUUM/khqJ4nia+ WTBA== X-Gm-Message-State: AG10YOQOh9HAU1Av/51UQZnavtIySyQSbTKrQXoDe8c82OuaOya7V1wAH23FilsqY5GHOhLE X-Received: by 10.202.210.151 with SMTP id j145mr466999oig.114.1453430665285; Thu, 21 Jan 2016 18:44:25 -0800 (PST) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id o125sm2108394oif.0.2016.01.21.18.44.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2016 18:44:21 -0800 (PST) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 2BABD2218C7; Thu, 21 Jan 2016 19:44:19 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Thu, 21 Jan 2016 19:43:34 -0700 Message-Id: <1453430653-3280-11-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1453430653-3280-1-git-send-email-sjg@chromium.org> References: <1453430653-3280-1-git-send-email-sjg@chromium.org> Cc: Jeffy Chen , Pantelis Antoniou Subject: [U-Boot] [PATCH v9 10/49] rockchip: mmc: Use a pwrseq device if available 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" Use the pwrseq uclass to find a suitable power sequence for the MMC device. If this is enabled in the device tree, we will pick it up automatically. Signed-off-by: Simon Glass --- Changes in v9: None Changes in v2: None drivers/mmc/rockchip_dw_mmc.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 9b4268e..080c831 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -9,7 +9,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -64,6 +66,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev) struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct rockchip_dwmmc_priv *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; + struct udevice *pwr_dev __maybe_unused; u32 minmax[2]; int ret; int fifo_depth; @@ -90,6 +93,16 @@ static int rockchip_dwmmc_probe(struct udevice *dev) if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "fifo-mode")) host->fifo_mode = true; +#ifdef CONFIG_PWRSEQ + /* Enable power if needed */ + ret = uclass_get_device_by_phandle(UCLASS_PWRSEQ, dev, "mmc-pwrseq", + &pwr_dev); + if (!ret) { + ret = pwrseq_set_power(pwr_dev, true); + if (ret) + return ret; + } +#endif ret = add_dwmci(host, minmax[1], minmax[0]); if (ret) return ret; @@ -112,3 +125,37 @@ U_BOOT_DRIVER(rockchip_dwmmc_drv) = { .probe = rockchip_dwmmc_probe, .priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv), }; + +#ifdef CONFIG_PWRSEQ +static int rockchip_dwmmc_pwrseq_set_power(struct udevice *dev, bool enable) +{ + struct gpio_desc reset; + int ret; + + ret = gpio_request_by_name(dev, "reset-gpios", 0, &reset, GPIOD_IS_OUT); + if (ret) + return ret; + dm_gpio_set_value(&reset, 1); + udelay(1); + dm_gpio_set_value(&reset, 0); + udelay(200); + + return 0; +} + +static const struct pwrseq_ops rockchip_dwmmc_pwrseq_ops = { + .set_power = rockchip_dwmmc_pwrseq_set_power, +}; + +static const struct udevice_id rockchip_dwmmc_pwrseq_ids[] = { + { .compatible = "mmc-pwrseq-emmc" }, + { } +}; + +U_BOOT_DRIVER(rockchip_dwmmc_pwrseq_drv) = { + .name = "mmc_pwrseq_emmc", + .id = UCLASS_PWRSEQ, + .of_match = rockchip_dwmmc_pwrseq_ids, + .ops = &rockchip_dwmmc_pwrseq_ops, +}; +#endif