Re: [PATCH] mmc: sdhci-pxa: Add device tree support
From: zhangfei gao <hidden>
Date: 2012-06-13 03:11:49
Also in:
linux-mmc
On Wed, Jun 13, 2012 at 3:05 AM, Chris Ball [off-list ref] wrote:
Tested on an OLPC XO-1.75. (MMP2, sdhci-pxav3, CONFIG_MACH_MMP2_DT=y) Signed-off-by: Chris Ball <redacted> --- .../devicetree/bindings/mmc/sdhci-pxa.txt | 21 ++++++++ drivers/mmc/host/sdhci-pxav2.c | 52 ++++++++++++++++++++ drivers/mmc/host/sdhci-pxav3.c | 50 +++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
Thanks Chris for the great help, compile error if CONFIG_OF not defined.
+#ifdef CONFIG_OF
+static const struct of_device_id sdhci_pxav2_of_match[] = {
+ {
+ .compatible = "mrvl,pxav2-mmc",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, sdhci_pxav2_of_match);
+
+static struct sdhci_pxa_platdata *pxav2_get_mmc_pdata(struct device *dev)
+{
+ struct sdhci_pxa_platdata *pdata;
+ struct device_node *np = dev->of_node;
+ u32 bus_width;
+ u32 clk_delay_cycles;+ + return pdata; +} +#else +static inline struct sdhci_pxa_platdata pxav2_get_mmc_pdata(struct device *dev)
Should be static struct sdhci_pxa_platdata *pxav2_get_mmc_pdata(struct device *dev)
quoted hunk ↗ jump to hunk
+{ + return NULL; +} +#endif + static int __devinit sdhci_pxav2_probe(struct platform_device *pdev) { struct sdhci_pltfm_host *pltfm_host;@@ -128,6 +173,8 @@ static int __devinit sdhci_pxav2_probe(struct platform_device *pdev)struct device *dev = &pdev->dev; struct sdhci_host *host = NULL; struct sdhci_pxa *pxa = NULL; + const struct of_device_id *match; + int ret; struct clk *clk;@@ -156,6 +203,10 @@ static int __devinit sdhci_pxav2_probe(struct platform_device *pdev)| SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN; + match = of_match_device(of_match_ptr(sdhci_pxav2_of_match), &pdev->dev); + if (match) { + pdata = pxav2_get_mmc_pdata(dev); + } if (pdata) { if (pdata->flags & PXA_FLAG_CARD_PERMANENT) { /* on-chip device */@@ -218,6 +269,7 @@ static struct platform_driver sdhci_pxav2_driver = {.driver = { .name = "sdhci-pxav2", .owner = THIS_MODULE,
#ifdef CONFIG_OF required, otherwise build fail.
+ .of_match_table = sdhci_pxav2_of_match,
#endif
quoted hunk ↗ jump to hunk
.pm = SDHCI_PLTFM_PMOPS, }, .probe = sdhci_pxav2_probe,diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c index f296956..1835c94 100644 --- a/drivers/mmc/host/sdhci-pxav3.c +++ b/drivers/mmc/host/sdhci-pxav3.c
+#ifdef CONFIG_OF
+static const struct of_device_id sdhci_pxav3_of_match[] = {
+ {
+ .compatible = "mrvl,pxav3-mmc",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match);
+
+static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
+{+} +#else +static inline struct sdhci_pxa_platdata pxav3_get_mmc_pdata(struct device *dev)
Should be static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
quoted hunk ↗ jump to hunk
+{ + return NULL; +} +#endif +@@ -263,6 +312,7 @@ static int __devexit sdhci_pxav3_remove(struct platform_device *pdev)static struct platform_driver sdhci_pxav3_driver = { .driver = { .name = "sdhci-pxav3",
#ifdef CONFIG_OF required, otherwise build fail.
+ .of_match_table = sdhci_pxav3_of_match,
#endif
.owner = THIS_MODULE, .pm = SDHCI_PLTFM_PMOPS, }, -- Chris Ball [off-list ref] <http://printf.net/> One Laptop Per Child -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html