Commit a7626b7a5de37bbd506b23633be95428ee81c2e4
Committed by
Linus Torvalds
1 parent
f27f47ef5b
Exists in
master
and in
7 other branches
sdhci-pltfm: implement platform data passing
This includes platform ops, quirks and (de)initialization callbacks. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Cc: Richard Röjfors <richard.rojfors@pelagicore.com> Cc: David Vrabel <david.vrabel@csr.com> Cc: Pierre Ossman <pierre@ossman.eu> Cc: Ben Dooks <ben@simtec.co.uk> Cc: <linux-mmc@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 55 additions and 4 deletions Side-by-side Diff
drivers/mmc/host/sdhci-pltfm.c
... | ... | @@ -29,6 +29,7 @@ |
29 | 29 | #include <linux/mmc/host.h> |
30 | 30 | |
31 | 31 | #include <linux/io.h> |
32 | +#include <linux/sdhci-pltfm.h> | |
32 | 33 | |
33 | 34 | #include "sdhci.h" |
34 | 35 | |
35 | 36 | |
... | ... | @@ -49,12 +50,11 @@ |
49 | 50 | |
50 | 51 | static int __devinit sdhci_pltfm_probe(struct platform_device *pdev) |
51 | 52 | { |
53 | + struct sdhci_pltfm_data *pdata = pdev->dev.platform_data; | |
52 | 54 | struct sdhci_host *host; |
53 | 55 | struct resource *iomem; |
54 | 56 | int ret; |
55 | 57 | |
56 | - BUG_ON(pdev == NULL); | |
57 | - | |
58 | 58 | iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
59 | 59 | if (!iomem) { |
60 | 60 | ret = -ENOMEM; |
... | ... | @@ -76,7 +76,12 @@ |
76 | 76 | } |
77 | 77 | |
78 | 78 | host->hw_name = "platform"; |
79 | - host->ops = &sdhci_pltfm_ops; | |
79 | + if (pdata && pdata->ops) | |
80 | + host->ops = pdata->ops; | |
81 | + else | |
82 | + host->ops = &sdhci_pltfm_ops; | |
83 | + if (pdata) | |
84 | + host->quirks = pdata->quirks; | |
80 | 85 | host->irq = platform_get_irq(pdev, 0); |
81 | 86 | |
82 | 87 | if (!request_mem_region(iomem->start, resource_size(iomem), |
... | ... | @@ -93,6 +98,12 @@ |
93 | 98 | goto err_remap; |
94 | 99 | } |
95 | 100 | |
101 | + if (pdata && pdata->init) { | |
102 | + ret = pdata->init(host); | |
103 | + if (ret) | |
104 | + goto err_plat_init; | |
105 | + } | |
106 | + | |
96 | 107 | ret = sdhci_add_host(host); |
97 | 108 | if (ret) |
98 | 109 | goto err_add_host; |
... | ... | @@ -102,6 +113,9 @@ |
102 | 113 | return 0; |
103 | 114 | |
104 | 115 | err_add_host: |
116 | + if (pdata && pdata->exit) | |
117 | + pdata->exit(host); | |
118 | +err_plat_init: | |
105 | 119 | iounmap(host->ioaddr); |
106 | 120 | err_remap: |
107 | 121 | release_mem_region(iomem->start, resource_size(iomem)); |
... | ... | @@ -114,6 +128,7 @@ |
114 | 128 | |
115 | 129 | static int __devexit sdhci_pltfm_remove(struct platform_device *pdev) |
116 | 130 | { |
131 | + struct sdhci_pltfm_data *pdata = pdev->dev.platform_data; | |
117 | 132 | struct sdhci_host *host = platform_get_drvdata(pdev); |
118 | 133 | struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
119 | 134 | int dead; |
... | ... | @@ -125,6 +140,8 @@ |
125 | 140 | dead = 1; |
126 | 141 | |
127 | 142 | sdhci_remove_host(host, dead); |
143 | + if (pdata && pdata->exit) | |
144 | + pdata->exit(host); | |
128 | 145 | iounmap(host->ioaddr); |
129 | 146 | release_mem_region(iomem->start, resource_size(iomem)); |
130 | 147 | sdhci_free_host(host); |
include/linux/sdhci-pltfm.h
1 | +/* | |
2 | + * Platform data declarations for the sdhci-pltfm driver. | |
3 | + * | |
4 | + * Copyright (c) 2010 MontaVista Software, LLC. | |
5 | + * | |
6 | + * Author: Anton Vorontsov <avorontsov@ru.mvista.com> | |
7 | + * | |
8 | + * This program is free software; you can redistribute it and/or modify | |
9 | + * it under the terms of the GNU General Public License as published by | |
10 | + * the Free Software Foundation; either version 2 of the License, or (at | |
11 | + * your option) any later version. | |
12 | + */ | |
13 | + | |
14 | +#ifndef _SDHCI_PLTFM_H | |
15 | +#define _SDHCI_PLTFM_H | |
16 | + | |
17 | +struct sdhci_ops; | |
18 | +struct sdhci_host; | |
19 | + | |
20 | +/** | |
21 | + * struct sdhci_pltfm_data - SDHCI platform-specific information & hooks | |
22 | + * @ops: optional pointer to the platform-provided SDHCI ops | |
23 | + * @quirks: optional SDHCI quirks | |
24 | + * @init: optional hook that is called during device probe, before the | |
25 | + * driver tries to access any SDHCI registers | |
26 | + * @exit: optional hook that is called during device removal | |
27 | + */ | |
28 | +struct sdhci_pltfm_data { | |
29 | + struct sdhci_ops *ops; | |
30 | + unsigned int quirks; | |
31 | + int (*init)(struct sdhci_host *host); | |
32 | + void (*exit)(struct sdhci_host *host); | |
33 | +}; | |
34 | + | |
35 | +#endif /* _SDHCI_PLTFM_H */ |