From patchwork Wed Jul 29 18:24:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brownell X-Patchwork-Id: 39258 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n750UcF3021091 for ; Wed, 5 Aug 2009 00:30:38 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id n750ShMO006781; Tue, 4 Aug 2009 19:28:48 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id n750SgpK018642; Tue, 4 Aug 2009 19:28:42 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id D7FF48062C; Tue, 4 Aug 2009 19:28:40 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 13F6180626 for ; Tue, 4 Aug 2009 19:28:34 -0500 (CDT) Received: from neches.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id n750SXHl013947 for ; Tue, 4 Aug 2009 19:28:33 -0500 (CDT) Received: from mail134-va3-R.bigfish.com (mail-va3.bigfish.com [216.32.180.113]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id n750SSO6021142 for ; Tue, 4 Aug 2009 19:28:33 -0500 Received: from mail134-va3 (localhost.localdomain [127.0.0.1]) by mail134-va3-R.bigfish.com (Postfix) with ESMTP id 636A5850502 for ; Wed, 5 Aug 2009 00:28:28 +0000 (UTC) X-SpamScore: -13 X-BigFish: vps-13(zz1432R9370K98dN936eM3b5bkzz1202hzz1497iz2dh5eh6bh177h68o) X-Spam-TCS-SCL: 7:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 68.142.206.147; Service: EHS Received: by mail134-va3 (MessageSwitch) id 1249432106644328_11404; Wed, 5 Aug 2009 00:28:26 +0000 (UCT) Received: from n20.bullet.mail.mud.yahoo.com (n20.bullet.mail.mud.yahoo.com [68.142.206.147]) by mail134-va3.bigfish.com (Postfix) with SMTP id 78E0416C0050 for ; Wed, 5 Aug 2009 00:28:26 +0000 (UTC) Received: from [209.191.108.96] by n20.bullet.mail.mud.yahoo.com with NNFMP; 05 Aug 2009 00:28:25 -0000 Received: from [68.142.201.252] by t3.bullet.mud.yahoo.com with NNFMP; 05 Aug 2009 00:28:25 -0000 Received: from [127.0.0.1] by omp413.mail.mud.yahoo.com with NNFMP; 05 Aug 2009 00:28:25 -0000 X-Yahoo-Newman-Id: 935258.28463.bm@omp413.mail.mud.yahoo.com Received: (qmail 75314 invoked from network); 5 Aug 2009 00:28:25 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id; b=fuQ6ovW+PzL9c6f/L8oQBRsa5/6Mnb6z2tDkilq0mpv6Vu0H8nnw5HTdvGhue5mwU6OwTtnNgS2Pt/6rs2B+5vDawb0cbMhh+b2FQ38sg0tWNmA4N1ZT7avuYnGGsZvFbB3A11152TNrEbaq+GuwfWSPrY+tfd8BWiSfZMd+Euk= ; Received: from unknown (HELO albert) (david-b@69.226.245.56 with plain) by smtp109.sbc.mail.sp1.yahoo.com with SMTP; 5 Aug 2009 00:28:25 -0000 X-YMail-OSG: 08Cmz5gVM1ktabrQ9ohpNQabqrJdtY54OmAhdXeLVNiIpWEdO5vSi5PZhaxOMVBMxRukhnchOR5O5PGBGG2uEaddeolQnKsyKm2NWjE5YCtskapIstQOL4cED3ztNflMHg5SN_jw.qidkIpgzPsutFwLC9VR1QIAA_pr.DGHlfMORoGzf6C3BUN.bJkLGFeuZZYa1AQLDVEb1kr1PFFaQ.fyJTA18_yoqV_gV4TKarQe17azMKTsa8rSni68rkt3qsUqk6wsNaCK.r1aGYOF9Qfa5VR6wdbRdbUO6iUBeDNz3tRNX1_d.6MRxlV.yjKvehf7pEGuUNF0.YEz8fKkcfvmJYO6vhp7JfDRBLnM X-Yahoo-Newman-Property: ymail-3 From: David Brownell To: davinci-linux-open-source@linux.davincidsp.com, phani@embwise.com Date: Wed, 29 Jul 2009 11:24:49 -0700 User-Agent: KMail/1.9.10 References: <200907291256.n6TCunJk028509@webmail01.myhsphere.biz> In-Reply-To: <200907291256.n6TCunJk028509@webmail01.myhsphere.biz> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200907291124.49242.david-b@pacbell.net> Cc: Subject: Re: DM355 SDIO support X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com On Wednesday 29 July 2009, Phaneendra kumar wrote: > This patch will add SDIO support to the DM355 host controller driver. > > I have verified this on DM355 EVM board in both DMA and PIO modes. The MMC driver isn't specific to that chip. :) > And i have used open source libertas driver for verifying the SDIO functionality. That seems to be necessary. Other SDIO hardware isn't very easy to come by nowadays! > Signed-off-by: Phaneendra Kumar This seems to be missing something basic: a request_irq() call for the SDIO interrupt. See the appended, which is the updated version of something I sent around several months ago ... hoping someone had libertas hardware and some test/debug cycles! Maybe you can combine the two and get code which works more like it's supposed to work. I see that you did address the "what if the interrupt is already triggering" case, for example. - Dave ============== SDIO support in the MMC framework seems to involve no more than just being able to report SDIO irqs. Here's (untested) code to do that. # REVISIT -- errata doc, usage note 2.1.5, sez: # - issue: must check SDIOIST.IONT and sample SDIOST0.DAT1 to detect # level triggered SDIO using edge detect in ctrlr, given races # between irq enable at sdio card and (then) controller # - before enable: sample DAT1 (INTPRD=1, DAT1=1) # ... may have been raised before enabled in ctrlr # - does sdio_irq() clear irq status as it reads it? # ... mask irq before signaling irq --- drivers/mmc/host/davinci_mmc.c | 53 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -163,6 +163,7 @@ struct mmc_davinci_host { void __iomem *base; struct resource *mem_res; int irq; + int sdio_irq; unsigned char bus_mode; #define DAVINCI_MMC_DATADIR_NONE 0 @@ -1011,6 +1012,35 @@ static irqreturn_t mmc_davinci_irq(int i return IRQ_HANDLED; } +static irqreturn_t mmc_davinci_sdio_irq(int irq, void *dev_id) +{ + struct mmc_davinci_host *host = dev_id; + u32 sdiost; + + sdiost = readl(host->base + DAVINCI_SDIOST); + if (sdiost & BIT(0)) + mmc_signal_sdio_irq(host->mmc); + return IRQ_HANDLED; +} + +static void mmc_davinci_enable_sdio_irq(struct mmc_host *mmc, int enable) +{ + struct mmc_davinci_host *host = mmc_priv(mmc); + u32 sdioen; + + /* FIXME card may already be issuing (level) IRQ ... so when + * enabling, check DAT1 here and handle the case where we won't + * trigger since the edge already happened. + */ + + sdioen = readl(host->base + DAVINCI_SDIOEN); + if (!enable) + sdioen &= ~BIT(0); + else + sdioen |= BIT(0); + writel(sdioen, host->base + DAVINCI_SDIOEN); +} + static int mmc_davinci_get_cd(struct mmc_host *mmc) { struct platform_device *pdev = to_platform_device(mmc->parent); @@ -1036,6 +1066,7 @@ static struct mmc_host_ops mmc_davinci_o .set_ios = mmc_davinci_set_ios, .get_cd = mmc_davinci_get_cd, .get_ro = mmc_davinci_get_ro, + .enable_sdio_irq = mmc_davinci_enable_sdio_irq, }; /*----------------------------------------------------------------------*/ @@ -1058,6 +1089,8 @@ static void __init init_mmcsd_host(struc writel(0x1FFF, host->base + DAVINCI_MMCTOR); writel(0xFFFF, host->base + DAVINCI_MMCTOD); + writel(0, host->base + DAVINCI_SDIOEN); + writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_DATRST, host->base + DAVINCI_MMCCTL); writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_CMDRST, @@ -1132,9 +1165,24 @@ static int __init davinci_mmcsd_probe(st /* REVISIT: someday, support IRQ-driven card detection. */ mmc->caps |= MMC_CAP_NEEDS_POLL; - if (!pdata || pdata->wires == 4 || pdata->wires == 0) + if (!pdata || pdata->wires == 4 || pdata->wires == 0) { mmc->caps |= MMC_CAP_4_BIT_DATA; + /* for now, no support for IRQs (on DAT1) except + * when 4-wire mode is supported. + * REVISIT there's a DAT2 read-wait IRQ too ... + */ + host->sdio_irq = platform_get_irq(pdev, 1); + if (host->sdio_irq > 0) { + ret = request_irq(host->sdio_irq, + mmc_davinci_sdio_irq, 0, + mmc_hostname(mmc), host); + if (ret == 0) + mmc->caps |= MMC_CAP_SDIO_IRQ; + } + } + + host->version = pdata->version; mmc->ops = &mmc_davinci_ops; @@ -1215,6 +1263,9 @@ static int __exit davinci_mmcsd_remove(s platform_set_drvdata(pdev, NULL); if (host) { + if (host->mmc->caps & MMC_CAP_SDIO_IRQ) + free_irq(host->sdio_irq, host); + mmc_remove_host(host->mmc); free_irq(host->irq, host);