From patchwork Fri Sep 28 09:59:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1518251 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 4D2F0DF283 for ; Fri, 28 Sep 2012 09:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753520Ab2I1J7x (ORCPT ); Fri, 28 Sep 2012 05:59:53 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:56281 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751138Ab2I1J7w (ORCPT ); Fri, 28 Sep 2012 05:59:52 -0400 Received: by oagh16 with SMTP id h16so2765169oag.19 for ; Fri, 28 Sep 2012 02:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=wcnTIldjUrDeC5kIJ9u8uQxSU3H0ETMZ/el6wywnj8g=; b=KCvUdULGz3TzfwiPE0wV80aPz+Ys5hPufb46Act5j5N49SPXjEQlRkXQLKnuqnVtW8 iLAQFWEI0BcDAV5715M9gY8GbFk71DwtEhadmYebs0pID/0jCpoJ6XEvlvIOOFUZz2kr jvsOFSdiRX3eJO08lgKTrAC+5lwG5uoXN5jVkfgFui15tcwQZ1+FEV622ezgKv7Uun2f rJ817PznicsghXi0gQWWT+5MpLRbZq69btacexlM7hV/NvyLvWy2AGfuFiFFgA4PlKIQ XTceJSiQEg90OYkMQ9H/W5ReA1Uj6IguJLdnjRi2Z4NeAY8ZaiuDHXHjNPPiFo3Lsdeg 4/OA== MIME-Version: 1.0 Received: by 10.182.174.100 with SMTP id br4mr5352316obc.62.1348826391962; Fri, 28 Sep 2012 02:59:51 -0700 (PDT) Received: by 10.182.88.104 with HTTP; Fri, 28 Sep 2012 02:59:51 -0700 (PDT) In-Reply-To: <87lifuv7rm.fsf@octavius.laptop.org> References: <87lifuv7rm.fsf@octavius.laptop.org> Date: Fri, 28 Sep 2012 15:29:51 +0530 X-Google-Sender-Auth: xW4T_LSHpX3hSJKAOdFCQSZMsCM Message-ID: Subject: Re: [PATCH Resend 1/2] mmc: sdhci-spear: add device tree bindings From: viresh kumar To: Chris Ball Cc: spear-devel@list.st.com, linux-mmc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, sr@denx.de Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On Fri, Sep 28, 2012 at 2:33 PM, Chris Ball wrote: > You don't have to mention reg/interrupts, because they're already > covered in mmc.txt. > power-gpio should be "power-gpios" (even though there's only one), and > power_always_enb should use hyphens instead of underscores Hi Chris, I have fixed above two for now, please apply below if it looks fine to you: From: Viresh Kumar Date: Mon, 26 Mar 2012 15:05:14 +0530 Subject: [PATCH V2 1/2] mmc: sdhci-spear: add device tree bindings This adds simple DT bindings for SDHCI SPEAr controller. It uses cd-gpios from common mmc bindings. This also fixes spear300-evb.dts with correct name for card detect binding. Signed-off-by: Viresh Kumar --- .../devicetree/bindings/mmc/sdhci-spear.txt | 24 ++++++++ arch/arm/boot/dts/spear300-evb.dts | 4 +- arch/arm/boot/dts/spear320-evb.dts | 4 +- drivers/mmc/host/sdhci-spear.c | 71 +++++++++++++++++++++- 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-spear.txt if (pdev->dev.parent) @@ -276,11 +334,20 @@ static int sdhci_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); +#ifdef CONFIG_OF +static const struct of_device_id sdhci_spear_id_table[] = { + { .compatible = "st,spear300-sdhci" }, + {} +}; +MODULE_DEVICE_TABLE(of, sdhci_spear_id_table); +#endif + static struct platform_driver sdhci_driver = { .driver = { .name = "sdhci", .owner = THIS_MODULE, .pm = &sdhci_pm_ops, + .of_match_table = of_match_ptr(sdhci_spear_id_table), }, .probe = sdhci_probe, .remove = __devexit_p(sdhci_remove), -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/mmc/sdhci-spear.txt b/Documentation/devicetree/bindings/mmc/sdhci-spear.txt new file mode 100644 index 0000000..5d9be8b5 --- /dev/null +++ b/Documentation/devicetree/bindings/mmc/sdhci-spear.txt @@ -0,0 +1,24 @@ +* SPEAr SDHCI Controller + +Required properties: +- compatible : "st,spear300-sdhci" + +Optional Properties: +- cd-gpios: card detect gpio, with zero flags. +- power-gpios: specifies the power gpio pin with flags: active low:1, active + high:0 +- power-always-enb: power should be on before inserting the card and so can't be + switched off. Only valid when power gpio is supported. + +If your board don't support these gpios then don't pass the entry. + +Example: + + sdhci@fc000000 { + compatible = "st,spear300-sdhci"; + reg = <0xfc000000 0x1000>; + + power-gpios = <&gpio0 5 0> + power-always-enb; + cd-gpios = <&gpio0 6 0> + }; diff --git a/arch/arm/boot/dts/spear300-evb.dts b/arch/arm/boot/dts/spear300-evb.dts index d71b8d5..a26abed 100644 --- a/arch/arm/boot/dts/spear300-evb.dts +++ b/arch/arm/boot/dts/spear300-evb.dts @@ -80,8 +80,8 @@ }; sdhci@70000000 { - int-gpio = <&gpio1 0 0>; - power-gpio = <&gpio1 2 1>; + cd-gpios = <&gpio1 0 0>; + power-gpios = <&gpio1 2 1>; status = "okay"; }; diff --git a/arch/arm/boot/dts/spear320-evb.dts b/arch/arm/boot/dts/spear320-evb.dts index e4e912f..490c85a 100644 --- a/arch/arm/boot/dts/spear320-evb.dts +++ b/arch/arm/boot/dts/spear320-evb.dts @@ -103,8 +103,8 @@ }; sdhci@70000000 { - power-gpio = <&gpio0 2 1>; - power_always_enb; + power-gpios = <&gpio0 2 1>; + power-always-enb; status = "okay"; }; diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index 423da81..854f7e9 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -68,8 +70,56 @@ static irqreturn_t sdhci_gpio_irq(int irq, void *dev_id) return IRQ_HANDLED; } +#ifdef CONFIG_OF +static struct sdhci_plat_data * __devinit +sdhci_probe_config_dt(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct sdhci_plat_data *pdata = NULL; + enum of_gpio_flags flags; + int pgpio, igpio; + + pgpio = of_get_named_gpio_flags(np, "power-gpios", 0, &flags); + if (!gpio_is_valid(pgpio)) + pgpio = -1; + + igpio = of_get_named_gpio(np, "cd-gpios", 0); + if (!gpio_is_valid(igpio)) + igpio = -1; + + /* If pdata is required */ + if ((pgpio != -1) || (igpio != -1)) { + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(&pdev->dev, "DT: kzalloc failed\n"); + return ERR_PTR(-ENOMEM); + } + } + + /* if power gpio is supported */ + if (pgpio != -1) { + pdata->power_active_high = (flags != OF_GPIO_ACTIVE_LOW); + + if (of_property_read_bool(np, "power-always-enb")) + pdata->power_always_enb = true; + } + + pdata->card_power_gpio = pgpio; + pdata->card_int_gpio = igpio; + + return pdata; +} +#else +static struct sdhci_plat_data * __devinit +sdhci_probe_config_dt(struct platform_device *pdev) +{ + return ERR_PTR(-ENOSYS); +} +#endif + static int __devinit sdhci_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct sdhci_host *host; struct resource *iomem; struct spear_sdhci *sdhci; @@ -110,8 +160,16 @@ static int __devinit sdhci_probe(struct platform_device *pdev) goto put_clk; } - /* overwrite platform_data */ - sdhci->data = dev_get_platdata(&pdev->dev); + if (np) { + sdhci->data = sdhci_probe_config_dt(pdev); + if (IS_ERR(sdhci->data)) { + dev_err(&pdev->dev, "DT: Failed to get pdata\n"); + return -ENODEV; + } + } else { + sdhci->data = dev_get_platdata(&pdev->dev); + } + pdev->dev.platform_data = sdhci;