From patchwork Wed May 11 16:51:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 777282 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4BGpQfN009523 for ; Wed, 11 May 2011 16:51:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757767Ab1EKQvZ (ORCPT ); Wed, 11 May 2011 12:51:25 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:58573 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757764Ab1EKQvY (ORCPT ); Wed, 11 May 2011 12:51:24 -0400 Received: from axis700.grange (dslb-088-076-031-249.pools.arcor-ip.net [88.76.31.249]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0LqnUA-1PohIo2qzC-00dgua; Wed, 11 May 2011 18:51:20 +0200 Received: by axis700.grange (Postfix, from userid 1000) id 54132189B8B; Wed, 11 May 2011 18:51:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 50736189B89; Wed, 11 May 2011 18:51:20 +0200 (CEST) Date: Wed, 11 May 2011 18:51:20 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-sh@vger.kernel.org cc: linux-mmc@vger.kernel.org, Simon Horman , Magnus Damm , Ian Molton Subject: [PATCH 3/3] ARM: arch-shmobile: support SDHI card detection on mackerel, using a GPIO In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:90M1s3FwNRt59eZ2FWZ+2a+FuGx9rT9VnA/5BPf6kzM M14GsbyRjayalYr6xpx9tj3h7BDWuTpa0iNJjGY7YzxCgg9EKe Vw4sOujlfnfy7E7Eu6/OKzRlVLR2LIE8MiSORvU2i0L+XcNwpY hVdw6GzPnXEd72GR9rz1U2SnoOtHNNNuLGa7aVwc9BrMf/qB7b j65AnL9ux4ARHRPINkSixaGP8+TCakijWB7Gi3d+tE= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 11 May 2011 16:51:26 +0000 (UTC) On sh7372 the card-detection pin of SDHI0 can also produce interrupts, when configured as GPIO. Use this feature to power down SDHI0, when no card is plugged in. Signed-off-by: Guennadi Liakhovetski --- arch/arm/mach-shmobile/board-mackerel.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c index b20dd6f..48fd2fe 100644 --- a/arch/arm/mach-shmobile/board-mackerel.c +++ b/arch/arm/mach-shmobile/board-mackerel.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -670,6 +671,17 @@ static int slot_cn7_get_cd(struct platform_device *pdev) } /* SDHI0 */ +static irqreturn_t mackerel_sdhi0_gpio_cd(int irq, void *arg) +{ + struct device *dev = arg; + struct sh_mobile_sdhi_info *info = dev->platform_data; + struct tmio_mmc_data *pdata = info->pdata; + + tmio_mmc_cd_wakeup(pdata); + + return IRQ_HANDLED; +} + static struct sh_mobile_sdhi_info sdhi0_info = { .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, @@ -1040,6 +1052,7 @@ static void __init mackerel_init(void) { u32 srcr4; struct clk *clk; + int ret; sh7372_pinmux_init(); @@ -1144,6 +1157,13 @@ static void __init mackerel_init(void) gpio_request(GPIO_FN_SDHID0_1, NULL); gpio_request(GPIO_FN_SDHID0_0, NULL); + ret = request_irq(evt2irq(0x3340), mackerel_sdhi0_gpio_cd, + IRQF_TRIGGER_FALLING, "sdhi0 cd", &sdhi0_device.dev); + if (!ret) + sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD; + else + pr_err("Cannot get IRQ #%d: %d\n", evt2irq(0x3340), ret); + #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) /* enable SDHI1 */ gpio_request(GPIO_FN_SDHICMD1, NULL);