From patchwork Fri Dec 21 17:11:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongjin Kim X-Patchwork-Id: 1904411 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D4DF13FC64 for ; Fri, 21 Dec 2012 17:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751609Ab2LURT1 (ORCPT ); Fri, 21 Dec 2012 12:19:27 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:38979 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751500Ab2LURT1 (ORCPT ); Fri, 21 Dec 2012 12:19:27 -0500 X-Greylist: delayed 441 seconds by postgrey-1.27 at vger.kernel.org; Fri, 21 Dec 2012 12:19:26 EST Received: by mail-pa0-f54.google.com with SMTP id bi5so2980537pad.41 for ; Fri, 21 Dec 2012 09:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=IQrWWmBB3U9+djMhFqpEzCR73EivvvEwMF9T55jXYzY=; b=jr8cogBAVaGhJGGDROBRozDeG7N3XHe8Ec6BllVJ91HQzRboD3RLEu+08hj9SNJ/9Z ioRE0ra2WF2FZfr8Q511itZq4lsDW6AxKOszuF16QzV9PcXCJ6wPXCB8AMegUVcOHUk0 HmSeW6ahc/yzmxhLDhwAteNkt2SfVbh/QjZIwjgsyfLVFrZst00xzZtzI289IIPr/Sdi NWk6iy3GMljdps5sPBFSjU7bEnQxUT0pJ1Oz2eyxBJjgA5x8UreSMYxfulTppV7nJoPf Gepw0lKMK+Y9JQY7ZXixHyki21JZkD4PB2i2HT8TZIp3TS3dRKYuCUaiHdH5vEUFjrjn 5JjQ== X-Received: by 10.68.253.161 with SMTP id ab1mr22569401pbd.97.1356109924811; Fri, 21 Dec 2012 09:12:04 -0800 (PST) Received: from localhost.localdomain ([125.177.223.206]) by mx.google.com with ESMTPS id pu5sm7277206pbb.73.2012.12.21.09.12.01 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Dec 2012 09:12:03 -0800 (PST) From: Dongjin Kim Cc: Dongjin Kim , Chris Ball , Arnd Bergmann , Thomas Abraham , Will Newton , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mmc: host: dw_mmc-exynos: Add support for pinctrl Date: Sat, 22 Dec 2012 02:11:27 +0900 Message-Id: <1356109906-1622-1-git-send-email-tobetter@gmail.com> X-Mailer: git-send-email 1.7.9.5 To: unlisted-recipients:; (no To-header on input) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This patch adds support for pin configuration using pinctrl subsystem to dw_mmc-exynos driver. The property 'wp-gpios' can be specified for write protect but 'samsung,cd-pinmux-gpio' and gpios used for clock, command and data lines will be ignored. -. 'pinctrl-0' should specify pin control groups (clock, comand and data lines) used for this controller. -. 'pinctrl-names' should contain only one value, 'default'. Signed-off-by: Dongjin Kim --- drivers/mmc/host/dw_mmc-exynos.c | 44 ++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c index 4d50da6..d1c9963 100644 --- a/drivers/mmc/host/dw_mmc-exynos.c +++ b/drivers/mmc/host/dw_mmc-exynos.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "dw_mmc.h" #include "dw_mmc-pltfm.h" @@ -49,6 +50,7 @@ struct dw_mci_exynos_priv_data { u8 ciu_div; u32 sdr_timing; u32 ddr_timing; + struct pinctrl *pctrl; }; static struct dw_mci_exynos_compatible { @@ -84,6 +86,10 @@ static int dw_mci_exynos_priv_init(struct dw_mci *host) priv->ctrl_type = exynos_compat[idx].ctrl_type; } + priv->pctrl = devm_pinctrl_get_select_default(host->dev); + if (IS_ERR(priv->pctrl)) + dev_dbg(host->dev, "no pinctrl node\n"); + host->priv = priv; return 0; } @@ -149,32 +155,19 @@ static int dw_mci_exynos_parse_dt(struct dw_mci *host) return ret; priv->ddr_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], div); + return 0; } static int dw_mci_exynos_setup_bus(struct dw_mci *host, struct device_node *slot_np, u8 bus_width) { + struct dw_mci_exynos_priv_data *priv = host->priv; int idx, gpio, ret; if (!slot_np) return -EINVAL; - /* cmd + clock + bus-width pins */ - for (idx = 0; idx < NUM_PINS(bus_width); idx++) { - gpio = of_get_gpio(slot_np, idx); - if (!gpio_is_valid(gpio)) { - dev_err(host->dev, "invalid gpio: %d\n", gpio); - return -EINVAL; - } - - ret = devm_gpio_request(host->dev, gpio, "dw-mci-bus"); - if (ret) { - dev_err(host->dev, "gpio [%d] request failed\n", gpio); - return -EBUSY; - } - } - gpio = of_get_named_gpio(slot_np, "wp-gpios", 0); if (gpio_is_valid(gpio)) { if (devm_gpio_request(host->dev, gpio, "dw-mci-wp")) @@ -185,9 +178,12 @@ static int dw_mci_exynos_setup_bus(struct dw_mci *host, host->pdata->quirks |= DW_MCI_QUIRK_NO_WRITE_PROTECT; } - if (host->pdata->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION) + if (!IS_ERR(priv->pctrl)) return 0; + if (host->pdata->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION) + goto setup_bus; + gpio = of_get_named_gpio(slot_np, "samsung,cd-pinmux-gpio", 0); if (gpio_is_valid(gpio)) { if (devm_gpio_request(host->dev, gpio, "dw-mci-cd")) @@ -196,6 +192,22 @@ static int dw_mci_exynos_setup_bus(struct dw_mci *host, dev_info(host->dev, "cd gpio not available"); } + setup_bus: + /* cmd + clock + bus-width pins */ + for (idx = 0; idx < NUM_PINS(bus_width); idx++) { + gpio = of_get_gpio(slot_np, idx); + if (!gpio_is_valid(gpio)) { + dev_err(host->dev, "invalid gpio: %d\n", gpio); + return -EINVAL; + } + + ret = devm_gpio_request(host->dev, gpio, "dw-mci-bus"); + if (ret) { + dev_err(host->dev, "gpio [%d] request failed\n", gpio); + return -EBUSY; + } + } + return 0; }