2012-01-13 18:34:57 +08:00
|
|
|
/*
|
|
|
|
* Synopsys DesignWare Multimedia Card Interface driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 NXP Semiconductors
|
|
|
|
* Copyright (C) 2009, 2010 Imagination Technologies Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/mmc/host.h>
|
|
|
|
#include <linux/mmc/mmc.h>
|
|
|
|
#include <linux/mmc/dw_mmc.h>
|
2012-09-18 02:16:40 +08:00
|
|
|
#include <linux/of.h>
|
|
|
|
|
2012-01-13 18:34:57 +08:00
|
|
|
#include "dw_mmc.h"
|
|
|
|
|
2012-09-18 02:16:42 +08:00
|
|
|
int dw_mci_pltfm_register(struct platform_device *pdev,
|
2012-11-07 05:55:31 +08:00
|
|
|
const struct dw_mci_drv_data *drv_data)
|
2012-01-13 18:34:57 +08:00
|
|
|
{
|
|
|
|
struct dw_mci *host;
|
|
|
|
struct resource *regs;
|
|
|
|
int ret;
|
|
|
|
|
2012-09-18 02:16:36 +08:00
|
|
|
host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
|
2012-01-13 18:34:57 +08:00
|
|
|
if (!host)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
2012-09-18 02:16:36 +08:00
|
|
|
if (!regs)
|
|
|
|
return -ENXIO;
|
2012-01-13 18:34:57 +08:00
|
|
|
|
|
|
|
host->irq = platform_get_irq(pdev, 0);
|
2012-09-18 02:16:36 +08:00
|
|
|
if (host->irq < 0)
|
|
|
|
return host->irq;
|
2012-01-13 18:34:57 +08:00
|
|
|
|
2012-09-18 02:16:42 +08:00
|
|
|
host->drv_data = drv_data;
|
2012-09-18 02:16:35 +08:00
|
|
|
host->dev = &pdev->dev;
|
2012-01-13 18:34:57 +08:00
|
|
|
host->irq_flags = 0;
|
|
|
|
host->pdata = pdev->dev.platform_data;
|
2012-09-18 02:16:36 +08:00
|
|
|
host->regs = devm_request_and_ioremap(&pdev->dev, regs);
|
2012-01-13 18:34:57 +08:00
|
|
|
if (!host->regs)
|
2012-09-18 02:16:36 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-10-16 16:43:08 +08:00
|
|
|
if (drv_data && drv_data->init) {
|
|
|
|
ret = drv_data->init(host);
|
2012-09-18 02:16:42 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-01-13 18:34:57 +08:00
|
|
|
platform_set_drvdata(pdev, host);
|
|
|
|
ret = dw_mci_probe(host);
|
|
|
|
return ret;
|
|
|
|
}
|
2012-09-18 02:16:41 +08:00
|
|
|
EXPORT_SYMBOL_GPL(dw_mci_pltfm_register);
|
|
|
|
|
2012-11-20 02:23:06 +08:00
|
|
|
static int dw_mci_pltfm_probe(struct platform_device *pdev)
|
2012-09-18 02:16:41 +08:00
|
|
|
{
|
2012-09-18 02:16:42 +08:00
|
|
|
return dw_mci_pltfm_register(pdev, NULL);
|
2012-09-18 02:16:41 +08:00
|
|
|
}
|
2012-01-13 18:34:57 +08:00
|
|
|
|
2012-11-20 02:26:03 +08:00
|
|
|
static int dw_mci_pltfm_remove(struct platform_device *pdev)
|
2012-01-13 18:34:57 +08:00
|
|
|
{
|
|
|
|
struct dw_mci *host = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
dw_mci_remove(host);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-09-18 02:16:41 +08:00
|
|
|
EXPORT_SYMBOL_GPL(dw_mci_pltfm_remove);
|
2012-01-13 18:34:57 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
|
|
/*
|
|
|
|
* TODO: we should probably disable the clock to the card in the suspend path.
|
|
|
|
*/
|
|
|
|
static int dw_mci_pltfm_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct dw_mci *host = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
ret = dw_mci_suspend(host);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dw_mci_pltfm_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct dw_mci *host = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
ret = dw_mci_resume(host);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define dw_mci_pltfm_suspend NULL
|
|
|
|
#define dw_mci_pltfm_resume NULL
|
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
|
|
|
|
2012-09-18 02:16:41 +08:00
|
|
|
SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume);
|
|
|
|
EXPORT_SYMBOL_GPL(dw_mci_pltfm_pmops);
|
2012-01-13 18:34:57 +08:00
|
|
|
|
2012-09-18 02:16:40 +08:00
|
|
|
static const struct of_device_id dw_mci_pltfm_match[] = {
|
|
|
|
{ .compatible = "snps,dw-mshc", },
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match);
|
|
|
|
|
2012-01-13 18:34:57 +08:00
|
|
|
static struct platform_driver dw_mci_pltfm_driver = {
|
2012-10-03 21:26:37 +08:00
|
|
|
.probe = dw_mci_pltfm_probe,
|
2012-10-03 21:45:23 +08:00
|
|
|
.remove = __devexit_p(dw_mci_pltfm_remove),
|
2012-01-13 18:34:57 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "dw_mmc",
|
2012-09-18 02:16:40 +08:00
|
|
|
.of_match_table = of_match_ptr(dw_mci_pltfm_match),
|
2012-01-13 18:34:57 +08:00
|
|
|
.pm = &dw_mci_pltfm_pmops,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-10-03 21:26:37 +08:00
|
|
|
module_platform_driver(dw_mci_pltfm_driver);
|
2012-01-13 18:34:57 +08:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("DW Multimedia Card Interface driver");
|
|
|
|
MODULE_AUTHOR("NXP Semiconductor VietNam");
|
|
|
|
MODULE_AUTHOR("Imagination Technologies Ltd");
|
|
|
|
MODULE_LICENSE("GPL v2");
|