From patchwork Wed Feb 6 19:46:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2106491 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 7C9983FDF1 for ; Wed, 6 Feb 2013 19:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755670Ab3BFTrS (ORCPT ); Wed, 6 Feb 2013 14:47:18 -0500 Received: from moutng.kundenserver.de ([212.227.126.187]:62415 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758030Ab3BFTrP (ORCPT ); Wed, 6 Feb 2013 14:47:15 -0500 Received: from axis700.grange (dslb-178-006-240-079.pools.arcor-ip.net [178.6.240.79]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0M2FfQ-1Uv0bE2xKG-00s1od; Wed, 06 Feb 2013 20:47:05 +0100 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 5ACBB40B98; Wed, 6 Feb 2013 20:47:04 +0100 (CET) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1U3AxU-0004q5-9P; Wed, 06 Feb 2013 20:47:04 +0100 From: Guennadi Liakhovetski To: linux-mmc@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org, linux-sh@vger.kernel.org, Magnus Damm , Simon Horman , Guennadi Liakhovetski , Arnd Bergmann Subject: [PATCH v3 02/13] mmc: detailed definition of CD and WP MMC line polarities in DT Date: Wed, 6 Feb 2013 20:46:49 +0100 Message-Id: <1360180020-18555-3-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1360180020-18555-1-git-send-email-g.liakhovetski@gmx.de> References: <1360180020-18555-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:63SVvft+IobPtXDlh05WPcx6dRrXrUxAzxlMtmLKzTj 0m7Pj62ruwjlF2y/O0uGI+2Cmkq5xSe0H2WJ63eowi+g09vTbd fMFA9fe6I3kaOXl7EvGLxZDz9bmWx2ybY73ySdMxKoMLglfCn5 T/ns+7T+oS9VXmslAR5p+lI35g1Kpz7iIgTzCi8+ZHLv1bkW2M 5+jYXwSJOvoxoeTs1BQ3RNKmIUB4nAcNTmWqrcEUjvV7EaRKx+ JuRvvuiHOlS7xi0ECNEKEnKx9ehNGJq9lCGi6vw1fVHh5O+rVb JknQ6goEodH2In4u9cj6Fc2hGNdMTYwMdRmHPOL5qatlUuOF4E MB6EpwJS76E9WbCSNdlADYXZAEplztI7hpOEwBPnmp79svo1CT iQKeLQHVQzPrA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Clarify ways to specify write-protect and card-detect MMC lines in FDT. Cc: Arnd Bergmann Signed-off-by: Guennadi Liakhovetski --- v3: {wp,cd}-inverted properties can now be used together with GPIO binding flags. A detailed explanation added. Documentation/devicetree/bindings/mmc/mmc.txt | 43 +++++++++++++++++++++++- 1 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt index 34f28ed..51dd64f 100644 --- a/Documentation/devicetree/bindings/mmc/mmc.txt +++ b/Documentation/devicetree/bindings/mmc/mmc.txt @@ -18,12 +18,51 @@ Only one of the properties in this section should be supplied: Optional properties: - wp-gpios: Specify GPIOs for write protection, see gpio binding -- cd-inverted: when present, polarity on the cd gpio line is inverted -- wp-inverted: when present, polarity on the wp gpio line is inverted +- cd-inverted: when present, polarity on the CD line is inverted. See the note + below for the case, when a GPIO is used for the CD line +- wp-inverted: when present, polarity on the WP line is inverted. See the note + below for the case, when a GPIO is used for the WP line - max-frequency: maximum operating clock frequency - no-1-8-v: when present, denotes that 1.8v card voltage is not supported on this system, even if the controller claims it is. +*NOTE* on CD and WP polarity. As of 3.8, SD/MMC drivers parse their DT nodes +each in its own way, including calculation of CD and WP polarities. Our goal is +to implement a common MMC DT parser and convert all drivers to using it. For +this we also have to fix the meaning of the "normal" and "inverted" line levels. +We choose to follow the SDHCI standard, which specifies both those lines as +"active low." To deliver line polarity to drivers the parser will set +MMC_CAP2_CD_ACTIVE_HIGH and / or MMC_CAP2_RO_ACTIVE_HIGH capabilities. + +CD and WP lines can be implemented on the hardware in one of two ways: as GPIOs, +specified in cd-gpios and wp-gpios properties, or as dedicated pins. Polarity of +dedicated pins can be specified, using *-inverted properties. GPIO polarity can +also be specified using the OF_GPIO_ACTIVE_LOW flag. This creates an ambiguity +in the latter case. So far there are no drivers, that evaluate both these +possibilities. Also, all .dts files only use one of them. Boards with mmc +devices, whose drivers use *-inverted properties, leave the OF_GPIO_ACTIVE_LOW +flag clear (which is actually usually wrong, since it means "active high," i.e. +inverted.) OTOH, boards with mmc devices, whose drivers use the +OF_GPIO_ACTIVE_LOW flag, never specify *-inverted properties. This means, that +the safest way to implement a common MMC DT parser is by using the XOR logic, as +in + + explicit_inv_cd = !!of_find_property(np, "cd-inverted", &len); + + cd_gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags); + if (gpio_is_valid(cd_gpio) && !(flags & OF_GPIO_ACTIVE_LOW)) + gpio_inv_cd = 1; + else + gpio_inv_cd = 0; + + if (gpio_inv_cd ^ explicit_inv_cd) + host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; + +Similarly for WP. This way drivers, currently only interpreting *-inverted +properties with .dts files always having cd-gpios' OF_GPIO_ACTIVE_LOW flag +clear, will have to invert the MMC_CAP2_CD_ACTIVE_HIGH capability, but at least +this capability will not miss any toggles. + Optional SDIO properties: - keep-power-in-suspend: Preserves card power during a suspend/resume cycle - enable-sdio-wakeup: Enables wake up of host system on SDIO IRQ assertion