From patchwork Wed Jan 14 13:02:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 43106 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D8977240B9 for ; Wed, 14 Jan 2015 13:02:30 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf4824376lbv.1 for ; Wed, 14 Jan 2015 05:02:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=yWI3UzS/k7aMVe7RuFRHzswMzX+/30ewPN43BSYayow=; b=EmI6f4quq566qTF36dHhPii34ZHneccUghckF4MKVdPScdKfe3f0KGfqIGK8TcrVBi 8xZa6SApMYXLh04Vp7So6esO5+w6CdB3F5lmGhYaEq02yJa2QoS8EA1boolvN6swMvzI rmItvYwcy0sUkhQBAF1LsixbERcYy6i2uOVD3XzrDT3ZN3HFuyX9y/0j86FDQfh3pPoM WQBxn4BrHNiVc1YBggnjKzRRfQg8CiNSZjAC8vGF+XUtTCapOMGsXZ3lmV/fJlcuONhs lhuj6W7Hm1l8Y8uHHxTN4xP/U+4tjdrSBaAMchEcmlVZ3ZEqUu7Tj5pYSx+TuVAM9ARu kfsg== X-Gm-Message-State: ALoCoQlGRXltLU3XmWV3fkPcGCACAY6PEYWseT6wr/bIJIO5fE3PY5QpI7oQWhScuaoEcGrLB2wM X-Received: by 10.112.84.226 with SMTP id c2mr490868lbz.5.1421240549906; Wed, 14 Jan 2015 05:02:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.1 with SMTP id ku1ls118577lac.80.gmail; Wed, 14 Jan 2015 05:02:29 -0800 (PST) X-Received: by 10.152.36.100 with SMTP id p4mr527616laj.11.1421240549700; Wed, 14 Jan 2015 05:02:29 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id pe5si27216968lbc.40.2015.01.14.05.02.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Jan 2015 05:02:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ms9so7931321lab.10 for ; Wed, 14 Jan 2015 05:02:29 -0800 (PST) X-Received: by 10.152.45.4 with SMTP id i4mr3882882lam.74.1421240549593; Wed, 14 Jan 2015 05:02:29 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1688788lbb; Wed, 14 Jan 2015 05:02:29 -0800 (PST) X-Received: by 10.194.175.69 with SMTP id by5mr7169417wjc.32.1421240544730; Wed, 14 Jan 2015 05:02:24 -0800 (PST) Received: from mail-we0-f173.google.com (mail-we0-f173.google.com. [74.125.82.173]) by mx.google.com with ESMTPS id gy6si26042616wib.66.2015.01.14.05.02.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Jan 2015 05:02:24 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 74.125.82.173 as permitted sender) client-ip=74.125.82.173; Received: by mail-we0-f173.google.com with SMTP id q58so8649675wes.4 for ; Wed, 14 Jan 2015 05:02:24 -0800 (PST) X-Received: by 10.180.101.131 with SMTP id fg3mr42276806wib.36.1421240544073; Wed, 14 Jan 2015 05:02:24 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id u1sm18594734wif.6.2015.01.14.05.02.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jan 2015 05:02:23 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Linus Walleij , Mark Brown , Arnd Bergmann , Alexandre Courbot , Arend van Spriel , Sascha Hauer , Olof Johansson , Russell King , Hans de Goede , Doug Anderson , NeilBrown , Tomeu Vizoso , Ulf Hansson Subject: [PATCH V2 3/4] mmc: pwrseq: Initial support for the simple MMC power sequence provider Date: Wed, 14 Jan 2015 14:02:09 +0100 Message-Id: <1421240530-7971-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421240530-7971-1-git-send-email-ulf.hansson@linaro.org> References: <1421240530-7971-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , To add the core part for the MMC power sequence, let's start by adding initial support for the simple MMC power sequence provider. In this initial step, the MMC power sequence node are fetched and the compatible string for the simple MMC power sequence provider are verified. At this point we don't parse the node for any properties, but instead that will be handled from following patches. Since there are no properties supported yet, let's just implement the ->alloc() and the ->free() callbacks. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/mmc/core/Makefile | 2 +- drivers/mmc/core/pwrseq.c | 61 +++++++++++++++++++++++++++++++++++++++- drivers/mmc/core/pwrseq.h | 2 ++ drivers/mmc/core/pwrseq_simple.c | 48 +++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 drivers/mmc/core/pwrseq_simple.c diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile index ccdd35f..b39cbd2 100644 --- a/drivers/mmc/core/Makefile +++ b/drivers/mmc/core/Makefile @@ -8,5 +8,5 @@ mmc_core-y := core.o bus.o host.o \ sdio.o sdio_ops.o sdio_bus.o \ sdio_cis.o sdio_io.o sdio_irq.o \ quirks.o slot-gpio.o -mmc_core-$(CONFIG_OF) += pwrseq.o +mmc_core-$(CONFIG_OF) += pwrseq.o pwrseq_simple.o mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o diff --git a/drivers/mmc/core/pwrseq.c b/drivers/mmc/core/pwrseq.c index bd08772..7287585 100644 --- a/drivers/mmc/core/pwrseq.c +++ b/drivers/mmc/core/pwrseq.c @@ -7,14 +7,73 @@ * * MMC power sequence management */ +#include +#include +#include +#include +#include + #include #include "pwrseq.h" +struct mmc_pwrseq_match { + const char *compatible; + int (*alloc)(struct mmc_host *host, struct device *dev); +}; + +static struct mmc_pwrseq_match pwrseq_match[] = { + { + .compatible = "mmc,pwrseq-simple", + .alloc = mmc_pwrseq_simple_alloc, + }, +}; + +static struct mmc_pwrseq_match *mmc_pwrseq_find(struct device_node *np) +{ + struct mmc_pwrseq_match *match = ERR_PTR(-ENODEV); + int i; + + for (i = 0; i < ARRAY_SIZE(pwrseq_match); i++) { + if (of_device_is_compatible(np, pwrseq_match[i].compatible)) { + match = &pwrseq_match[i]; + break; + } + } + + return match; +} int mmc_pwrseq_alloc(struct mmc_host *host) { - return 0; + struct platform_device *pdev; + struct device_node *np; + struct mmc_pwrseq_match *match; + int ret = 0; + + np = of_parse_phandle(host->parent->of_node, "mmc-pwrseq", 0); + if (!np) + return 0; + + pdev = of_find_device_by_node(np); + if (!pdev) { + ret = -ENODEV; + goto err; + } + + match = mmc_pwrseq_find(np); + if (IS_ERR(match)) { + ret = PTR_ERR(match); + goto err; + } + + ret = match->alloc(host, &pdev->dev); + if (!ret) + dev_info(host->parent, "allocated mmc-pwrseq\n"); + +err: + of_node_put(np); + return ret; } void mmc_pwrseq_pre_power_on(struct mmc_host *host) diff --git a/drivers/mmc/core/pwrseq.h b/drivers/mmc/core/pwrseq.h index 12aaf2b..bd860d8 100644 --- a/drivers/mmc/core/pwrseq.h +++ b/drivers/mmc/core/pwrseq.h @@ -27,6 +27,8 @@ void mmc_pwrseq_post_power_on(struct mmc_host *host); void mmc_pwrseq_power_off(struct mmc_host *host); void mmc_pwrseq_free(struct mmc_host *host); +int mmc_pwrseq_simple_alloc(struct mmc_host *host, struct device *dev); + #else static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; } diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c new file mode 100644 index 0000000..7f87bc1 --- /dev/null +++ b/drivers/mmc/core/pwrseq_simple.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2014 Linaro Ltd + * + * Author: Ulf Hansson + * + * License terms: GNU General Public License (GPL) version 2 + * + * Simple MMC power sequence management + */ +#include +#include +#include +#include + +#include + +#include "pwrseq.h" + +struct mmc_pwrseq_simple { + struct mmc_pwrseq pwrseq; +}; + +static void mmc_pwrseq_simple_free(struct mmc_host *host) +{ + struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, + struct mmc_pwrseq_simple, pwrseq); + + kfree(&pwrseq); + host->pwrseq = NULL; +} + +static struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = { + .free = mmc_pwrseq_simple_free, +}; + +int mmc_pwrseq_simple_alloc(struct mmc_host *host, struct device *dev) +{ + struct mmc_pwrseq_simple *pwrseq; + + pwrseq = kzalloc(sizeof(struct mmc_pwrseq_simple), GFP_KERNEL); + if (!pwrseq) + return -ENOMEM; + + pwrseq->pwrseq.ops = &mmc_pwrseq_simple_ops; + host->pwrseq = &pwrseq->pwrseq; + + return 0; +}