aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sdhci-pxav3.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/sdhci-pxav3.c')
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index f29695683556..07fe3834fe0b 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -28,6 +28,9 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/of.h>
32#include <linux/of_device.h>
33
31#include "sdhci.h" 34#include "sdhci.h"
32#include "sdhci-pltfm.h" 35#include "sdhci-pltfm.h"
33 36
@@ -164,6 +167,46 @@ static struct sdhci_ops pxav3_sdhci_ops = {
164 .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, 167 .platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
165}; 168};
166 169
170#ifdef CONFIG_OF
171static const struct of_device_id sdhci_pxav3_of_match[] = {
172 {
173 .compatible = "mrvl,pxav3-mmc",
174 },
175 {},
176};
177MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match);
178
179static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
180{
181 struct sdhci_pxa_platdata *pdata;
182 struct device_node *np = dev->of_node;
183 u32 bus_width;
184 u32 clk_delay_cycles;
185
186 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
187 if (!pdata)
188 return NULL;
189
190 if (of_find_property(np, "non-removable", NULL))
191 pdata->flags |= PXA_FLAG_CARD_PERMANENT;
192
193 of_property_read_u32(np, "bus-width", &bus_width);
194 if (bus_width == 8)
195 pdata->flags |= PXA_FLAG_SD_8_BIT_CAPABLE_SLOT;
196
197 of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
198 if (clk_delay_cycles > 0)
199 pdata->clk_delay_cycles = clk_delay_cycles;
200
201 return pdata;
202}
203#else
204static inline struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
205{
206 return NULL;
207}
208#endif
209
167static int __devinit sdhci_pxav3_probe(struct platform_device *pdev) 210static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
168{ 211{
169 struct sdhci_pltfm_host *pltfm_host; 212 struct sdhci_pltfm_host *pltfm_host;
@@ -171,6 +214,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
171 struct device *dev = &pdev->dev; 214 struct device *dev = &pdev->dev;
172 struct sdhci_host *host = NULL; 215 struct sdhci_host *host = NULL;
173 struct sdhci_pxa *pxa = NULL; 216 struct sdhci_pxa *pxa = NULL;
217 const struct of_device_id *match;
218
174 int ret; 219 int ret;
175 struct clk *clk; 220 struct clk *clk;
176 221
@@ -202,6 +247,10 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
202 /* enable 1/8V DDR capable */ 247 /* enable 1/8V DDR capable */
203 host->mmc->caps |= MMC_CAP_1_8V_DDR; 248 host->mmc->caps |= MMC_CAP_1_8V_DDR;
204 249
250 match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev);
251 if (match)
252 pdata = pxav3_get_mmc_pdata(dev);
253
205 if (pdata) { 254 if (pdata) {
206 if (pdata->flags & PXA_FLAG_CARD_PERMANENT) { 255 if (pdata->flags & PXA_FLAG_CARD_PERMANENT) {
207 /* on-chip device */ 256 /* on-chip device */
@@ -263,6 +312,9 @@ static int __devexit sdhci_pxav3_remove(struct platform_device *pdev)
263static struct platform_driver sdhci_pxav3_driver = { 312static struct platform_driver sdhci_pxav3_driver = {
264 .driver = { 313 .driver = {
265 .name = "sdhci-pxav3", 314 .name = "sdhci-pxav3",
315#ifdef CONFIG_OF
316 .of_match_table = sdhci_pxav3_of_match,
317#endif
266 .owner = THIS_MODULE, 318 .owner = THIS_MODULE,
267 .pm = SDHCI_PLTFM_PMOPS, 319 .pm = SDHCI_PLTFM_PMOPS,
268 }, 320 },