From patchwork Sun Sep 26 08:52:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 209632 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8Q8q9ir030646 for ; Sun, 26 Sep 2010 08:52:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751716Ab0IZIwJ (ORCPT ); Sun, 26 Sep 2010 04:52:09 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:34402 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610Ab0IZIwH (ORCPT ); Sun, 26 Sep 2010 04:52:07 -0400 Received: by iwn5 with SMTP id 5so3753906iwn.19 for ; Sun, 26 Sep 2010 01:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=VCI1qWJqXYGtCjGAUZHGd1mYsUSvDyyh7CufhAmJ1+4=; b=CS6xQNt8gZTcBjqSVItMeBeuQm/CyME/mTu35P7jjcWCD18YvoFJGIuqkcRPWOMrv3 +rvwxgeoMcbjFEgGSg/BkXCU1V6DH3njMvE4ySRVSoqqVzVB/ZSZ9m0AFiZsMNzXuaS/ 58AOXvvMjVGLjnt0Ctlr0loBdsvKIZ3w8a9PM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=CftGlwBpNcuNbnYi+3TLR+PpLaYLdS8A3NZ8kfxojH4w8vXU9cxhY/fi17jF2Qfetm PYikiRBJOEH4Sv3QRy0ajMR3P/lVf4vgSXRUiUX27xC4f4K8OdbkE84v6kUzEa80YxKX LRHs9rWznZoiT/190qXOOaMNK2z0MWh4iovV4= MIME-Version: 1.0 Received: by 10.231.193.81 with SMTP id dt17mr4817731ibb.177.1285491126906; Sun, 26 Sep 2010 01:52:06 -0700 (PDT) Received: by 10.231.206.203 with HTTP; Sun, 26 Sep 2010 01:52:06 -0700 (PDT) Date: Sun, 26 Sep 2010 04:52:06 -0400 Message-ID: Subject: [patch] sdhci-pltfm: add call back function From: zhangfei gao To: linux-mmc@vger.kernel.org Cc: Chris Ball , Wolfram Sang , eric.y.miao@gmail.com, Haojian Zhuang , Richard Zhu 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.3 (demeter1.kernel.org [140.211.167.41]); Sun, 26 Sep 2010 08:52:10 +0000 (UTC) From 8c59d0b917f434d7c424ce1e0896af45c3e5fbba Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Sun, 26 Sep 2010 16:37:11 -0400 Subject: [PATCH 2/2] sdhci-pltfm: add call back function Signed-off-by: Zhangfei Gao --- drivers/mmc/host/sdhci-pltfm.c | 24 ++++++++++++++++++------ include/linux/sdhci-pltfm.h | 5 ++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index e045e3c..e06f047 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -54,12 +54,17 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev) { struct sdhci_pltfm_data *pdata = pdev->dev.platform_data; const struct platform_device_id *platid = platform_get_device_id(pdev); + void *priv_pdata = NULL; struct sdhci_host *host; struct resource *iomem; int ret; - if (!pdata && platid && platid->driver_data) + if (platid && platid->driver_data) { pdata = (void *)platid->driver_data; + priv_pdata = pdev->dev.platform_data; + } else { + pdata = pdev->dev.platform_data; + } iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!iomem) { @@ -71,8 +76,8 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Invalid iomem size. You may " "experience problems.\n"); - if (pdev->dev.parent) - host = sdhci_alloc_host(pdev->dev.parent, 0); + if (pdata && pdata->alloc_host) + host = pdata->alloc_host(&pdev->dev); else host = sdhci_alloc_host(&pdev->dev, 0); @@ -86,8 +91,7 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev) host->ops = pdata->ops; else host->ops = &sdhci_pltfm_ops; - if (pdata) - host->quirks = pdata->quirks; + host->irq = platform_get_irq(pdev, 0); if (!request_mem_region(iomem->start, resource_size(iomem), @@ -105,15 +109,23 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev) } if (pdata && pdata->init) { - ret = pdata->init(host); + ret = pdata->init(host, pdata, priv_pdata); if (ret) goto err_plat_init; } + if (pdata && pdata->get_quirk) + host->quirks = pdata->get_quirk(host); + else if (pdata) + host->quirks = pdata->quirks; + ret = sdhci_add_host(host); if (ret) goto err_add_host; + if (pdata && pdata->set_max_speed) + pdata->set_max_speed(host); + platform_set_drvdata(pdev, host); return 0; diff --git a/include/linux/sdhci-pltfm.h b/include/linux/sdhci-pltfm.h index 0239bd7..0d8e8f6 100644 --- a/include/linux/sdhci-pltfm.h +++ b/include/linux/sdhci-pltfm.h @@ -28,8 +28,11 @@ struct sdhci_host; struct sdhci_pltfm_data { struct sdhci_ops *ops; unsigned int quirks; - int (*init)(struct sdhci_host *host); + int (*init)(struct sdhci_host *host, struct sdhci_pltfm_data *pdata, void* priv_pdata); void (*exit)(struct sdhci_host *host); + void (*set_max_speed)(struct sdhci_host *host); + unsigned int (*get_quirk)(struct sdhci_host *host); + struct sdhci_host *(*alloc_host)(struct device *dev); }; #endif /* _SDHCI_PLTFM_H */ -- 1.7.0.4