From patchwork Tue Feb 25 12:37:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 3716481 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 61CD2BF13A for ; Tue, 25 Feb 2014 12:46:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3995F201E9 for ; Tue, 25 Feb 2014 12:46:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DB09201DD for ; Tue, 25 Feb 2014 12:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbaBYMqZ (ORCPT ); Tue, 25 Feb 2014 07:46:25 -0500 Received: from mail-ea0-f182.google.com ([209.85.215.182]:38381 "EHLO mail-ea0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402AbaBYMqY (ORCPT ); Tue, 25 Feb 2014 07:46:24 -0500 Received: by mail-ea0-f182.google.com with SMTP id r15so96711ead.13 for ; Tue, 25 Feb 2014 04:46:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gpIUIFR2QBeLe43DW22tzoTPI4uyEFYHKf22n627pUs=; b=wIoRtuHIbwncqNFID+467Xnl1XTekCwY04nVJLbgznRq/D6HTJgTFEaNJVo/n4+iSb zNdH91Y52HbkKOlEK7X6Sxuhpqd3azI21Ia419VbYLv+/JIw33/xiKKYy0qBWtuIEyMa PIxV29Qch7dceC41euMx0p77CU71V/A3G+UjMc+ecpeWTv58yXEElYoxy8VZaMR106nm Jmtu+FX92uCMkDiPwbGGnuvIcKztVBX5bRtHqYFBndNjoVihmXod2apXDTQsu7mRWgQf bcz2F4Hpecsa5eD/Deh+VAeS5Qr8i4iNAHHlT8PDwvaq5QO1PTjs+qkCIYC8jZbkCLre AIDw== X-Received: by 10.14.179.129 with SMTP id h1mr30422016eem.26.1393332382369; Tue, 25 Feb 2014 04:46:22 -0800 (PST) Received: from localhost (ip-94-112-0-13.net.upcbroadband.cz. [94.112.0.13]) by mx.google.com with ESMTPSA id a2sm61040618eem.18.2014.02.25.04.45.26 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 25 Feb 2014 04:46:21 -0800 (PST) From: Andreas Fenkart To: Chris Ball Cc: Tony Lindgren , Grant Likely , Felipe Balbi , Balaji T K , zonque@gmail.com, galak@codeaurora.org, linux-doc@vger.kernel.org, linux-mmc@vger.kernel.org, linux-omap@vger.kernel.org, Andreas Fenkart Subject: [PATCH v7 2/4] mmc: omap_hsmmc: Remux SDIO pins within driver. Date: Tue, 25 Feb 2014 13:37:44 +0100 Message-Id: <1393331866-28307-3-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1393331866-28307-1-git-send-email-afenkart@gmail.com> References: <1393331866-28307-1-git-send-email-afenkart@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a preparation for the am335x workaround where we reconfigure dat1 as GPIO before going to suspend. If you don't specify active/idle pinctrl there should be no change. Idea of remuxing the pins by Tony Lindgren as well as the intial implementation of omap_hsmmc_pin_init. All bugs are mine. Signed-off-by: Andreas Fenkart diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index bd3bb0c..5e60925 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -220,6 +220,8 @@ struct omap_hsmmc_host { #define HSMMC_SDIO_IRQ_ENABLED (1 << 0) /* SDIO irq enabled */ struct omap_hsmmc_next next_data; + struct pinctrl *pinctrl; + struct pinctrl_state *fixed, *active, *idle; struct omap_mmc_platform_data *pdata; }; @@ -476,6 +478,70 @@ static void omap_hsmmc_gpio_free(struct omap_mmc_platform_data *pdata) gpio_free(pdata->slots[0].switch_pin); } +static int omap_hsmmc_pin_init(struct omap_hsmmc_host *host) +{ + struct pinctrl *_pinctrl; + int ret; + + _pinctrl = devm_pinctrl_get(host->dev); + if (IS_ERR(_pinctrl)) { + /* okay, if the bootloader set it up right */ + dev_warn(host->dev, "no pinctrl handle\n"); + return 0; + } + + host->fixed = pinctrl_lookup_state(_pinctrl, + PINCTRL_STATE_DEFAULT); + if (IS_ERR(host->fixed)) { + dev_info(host->dev, + "pins are not configured from the driver\n"); + host->fixed = NULL; + devm_pinctrl_put(_pinctrl); + return 0; + } + + ret = pinctrl_select_state(_pinctrl, host->fixed); + if (ret < 0) { + dev_warn(host->dev, "select fixed pinctrl state failed %d\n", ret); + goto err; + } + + /* For most cases we don't have wake-ups, and exit after this */ + host->active = pinctrl_lookup_state(_pinctrl, "active"); + if (IS_ERR(host->active)) { + ret = PTR_ERR(host->active); + host->active = NULL; + goto done; + } + + host->idle = pinctrl_lookup_state(_pinctrl, PINCTRL_STATE_IDLE); + if (IS_ERR(host->idle)) { + ret = PTR_ERR(host->idle); + host->idle = NULL; + goto err; + } + + /* Let's make sure the active and idle states work */ + ret = pinctrl_select_state(_pinctrl, host->idle); + if (ret < 0) + goto err; + + ret = pinctrl_select_state(_pinctrl, host->active); + if (ret < 0) + goto err; + + dev_info(mmc_dev(host->mmc), "pins configured for wake-up events\n"); + +done: + host->pinctrl = _pinctrl; + return 0; + +err: + dev_err(mmc_dev(host->mmc), "pins configuration error: %i\n", ret); + devm_pinctrl_put(_pinctrl); + return ret; +} + /* * Start clock to the card */ @@ -1858,7 +1924,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev) const struct of_device_id *match; dma_cap_mask_t mask; unsigned tx_req, rx_req; - struct pinctrl *pinctrl; apply_clk_hack(&pdev->dev); @@ -2083,10 +2148,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev) omap_hsmmc_disable_irq(host); - pinctrl = devm_pinctrl_get_select_default(&pdev->dev); - if (IS_ERR(pinctrl)) - dev_warn(&pdev->dev, - "pins are not configured from the driver\n"); + ret = omap_hsmmc_pin_init(host); + if (ret) + goto err_pinctrl_state; /* * For now, only support SDIO interrupt if we are booted with @@ -2127,7 +2191,11 @@ static int omap_hsmmc_probe(struct platform_device *pdev) err_slot_name: mmc_remove_host(mmc); - free_irq(mmc_slot(host).card_detect_irq, host); + if (host->pinctrl) + devm_pinctrl_put(host->pinctrl); +err_pinctrl_state: + if ((mmc_slot(host).card_detect_irq)) + free_irq(mmc_slot(host).card_detect_irq, host); err_irq_cd: if (host->use_reg) omap_hsmmc_reg_put(host); @@ -2179,6 +2247,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev) dma_release_channel(host->tx_chan); if (host->rx_chan) dma_release_channel(host->rx_chan); + if (host->pinctrl) + devm_pinctrl_put(host->pinctrl); pm_runtime_put_sync(host->dev); pm_runtime_disable(host->dev);