From patchwork Mon Aug 30 16:04:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 177612 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Mon, 30 Aug 2010 17:05:07 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1Oq6r4-0003TI-Vc for chris@printf.net; Mon, 30 Aug 2010 17:05:07 +0100 Received: by mail.laptop.org (Postfix) id 7EF7624241; Mon, 30 Aug 2010 12:04:47 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id 65D8324240 for ; Mon, 30 Aug 2010 12:04:47 -0400 (EDT) X-ASG-Debug-ID: 1283184300-0b74a6230003-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id Lva887JMCGgFwsat for ; Mon, 30 Aug 2010 12:05:02 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755874Ab0H3QEz (ORCPT ); Mon, 30 Aug 2010 12:04:55 -0400 Received: from mail-qy0-f174.google.com ([209.85.216.174]:62769 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755873Ab0H3QEw (ORCPT ); Mon, 30 Aug 2010 12:04:52 -0400 Received: by qyk9 with SMTP id 9so3014814qyk.19 for ; Mon, 30 Aug 2010 09:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=nD864P6sZkQeCAShuQdOGcpRZuOGJzeZOaIkmYzcPRw=; b=YpyfMRTVSH0Ph7FT2/7wtZoLiMMeIk04WSZQKwA+5rOITMrmWhlvMRmL38x3G7dda7 cRU86Ki2vPlENhaYrgZLPsmcJQvTVJX7E9F3eGpqVR1zdX5/bij/LIaxFqu5WuimidRU 97oBH1PA7UmYUTM7vSHsE4/ZUD3lp8tZdtFUg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=BtFA+F8yKh45qZJWEoUcR4lss1y0fb4BuNwFP/J2CY8OYnuEZ1H5iu6WdhrlzfBvC2 IE+/4r/LWv+FjtS+IXFL/U2pf4062QdaudCEUHONBiEohT4w45PgglK81kQiUyBJ1pxV AQByatIFzO4QfaJLhoXIV8DL5RbrCn4+1siqg= MIME-Version: 1.0 Received: by 10.224.66.167 with SMTP id n39mr2971233qai.391.1283184291612; Mon, 30 Aug 2010 09:04:51 -0700 (PDT) Received: by 10.229.23.1 with HTTP; Mon, 30 Aug 2010 09:04:51 -0700 (PDT) In-Reply-To: <20100830132914.GA32266@oksana.dev.rtsoft.ru> References: <20100830132914.GA32266@oksana.dev.rtsoft.ru> Date: Mon, 30 Aug 2010 18:04:51 +0200 Message-ID: X-ASG-Orig-Subj: Re: [PATCH] of_mmc_spi: add card detect irq support Subject: Re: [PATCH] of_mmc_spi: add card detect irq support From: Esben Haabendal To: Anton Vorontsov Cc: linuxppc-dev@lists.ozlabs.org, Andrew Morton , David Brownell , linux-mmc@vger.kernel.org Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1283184302 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.39432 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- of_mmc_spi: add card detect irq support Signed-off-by: Esben Haabendal --- .../powerpc/dts-bindings/mmc-spi-slot.txt | 9 ++++++- drivers/mmc/host/of_mmc_spi.c | 26 ++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt b/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt index c39ac28..89a0084 100644 --- a/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt +++ b/Documentation/powerpc/dts-bindings/mmc-spi-slot.txt @@ -7,8 +7,13 @@ Required properties: - voltage-ranges : two cells are required, first cell specifies minimum slot voltage (mV), second cell specifies maximum slot voltage (mV). Several ranges could be specified. -- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO, + +Optional properties: +- gpios : may specify GPIOs in this order: Card-Detect GPIO, Write-Protect GPIO. +- interrupts : the interrupt of a card detect interrupt. +- interrupt-parent : the phandle for the interrupt controller that + services interrupts for this device. Example: @@ -20,4 +25,6 @@ Example: &qe_pio_d 15 0>; voltage-ranges = <3300 3300>; spi-max-frequency = <50000000>; + interrupts = <42>; + interrupt-parent = <&PIC>; }; diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c index 1247e5d..5530def 100644 --- a/drivers/mmc/host/of_mmc_spi.c +++ b/drivers/mmc/host/of_mmc_spi.c @@ -34,6 +34,7 @@ enum { struct of_mmc_spi { int gpios[NUM_GPIOS]; bool alow_gpios[NUM_GPIOS]; + int detect_irq; struct mmc_spi_platform_data pdata; }; @@ -61,6 +62,22 @@ static int of_mmc_spi_get_ro(struct device *dev) return of_mmc_spi_read_gpio(dev, WP_GPIO); } +static int of_mmc_spi_init(struct device *dev, + irqreturn_t (*irqhandler)(int, void *), void *mmc) +{ + struct of_mmc_spi *oms = to_of_mmc_spi(dev); + + return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 0, + dev_name(dev), mmc); +} + +static void of_mmc_spi_exit(struct device *dev, void *mmc) +{ + struct of_mmc_spi *oms = to_of_mmc_spi(dev); + + free_irq(oms->detect_irq, mmc); +} + struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) { struct device *dev = &spi->dev; @@ -121,8 +138,13 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) if (gpio_is_valid(oms->gpios[WP_GPIO])) oms->pdata.get_ro = of_mmc_spi_get_ro; - /* We don't support interrupts yet, let's poll. */ - oms->pdata.caps |= MMC_CAP_NEEDS_POLL; + oms->detect_irq = irq_of_parse_and_map(np, 0); + if (oms->detect_irq != NO_IRQ) { + oms->pdata.init = of_mmc_spi_init; + oms->pdata.exit = of_mmc_spi_exit; + } else { + oms->pdata.caps |= MMC_CAP_NEEDS_POLL; + } dev->platform_data = &oms->pdata; return dev->platform_data; -- 1.7.1.1