return 0;
}
+static struct omap2_mcspi_platform_config omap2_pdata = {
+ .regs_offset = 0,
+};
+
+static struct omap2_mcspi_platform_config omap4_pdata = {
+ .regs_offset = OMAP4_MCSPI_REG_OFFSET,
+};
+
+static const struct of_device_id omap_mcspi_of_match[] = {
+ {
+ .compatible = "ti,omap2-mcspi",
+ .data = &omap2_pdata,
+ },
+ {
+ .compatible = "ti,omap4-mcspi",
+ .data = &omap4_pdata,
+ },
+ { },
+};
+MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
- static int __init omap2_mcspi_probe(struct platform_device *pdev)
+ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
{
struct spi_master *master;
- struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data;
+ struct omap2_mcspi_platform_config *pdata;
struct omap2_mcspi *mcspi;
struct resource *r;
int status = 0, i;
goto free_master;
}
- r->start += pdata->regs_offset;
- r->end += pdata->regs_offset;
+ r->start += regs_offset;
+ r->end += regs_offset;
mcspi->phys = r->start;
- if (!request_mem_region(r->start, resource_size(r),
- dev_name(&pdev->dev))) {
- status = -EBUSY;
- goto free_master;
- }
- mcspi->base = ioremap(r->start, resource_size(r));
+ mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
if (!mcspi->base) {
dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
status = -ENOMEM;
.driver = {
.name = "omap2_mcspi",
.owner = THIS_MODULE,
- .pm = &omap2_mcspi_pm_ops
+ .pm = &omap2_mcspi_pm_ops,
+ .of_match_table = omap_mcspi_of_match,
},
- .remove = __exit_p(omap2_mcspi_remove),
+ .probe = omap2_mcspi_probe,
+ .remove = __devexit_p(omap2_mcspi_remove),
};
-
- static int __init omap2_mcspi_init(void)
- {
- return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe);
- }
- subsys_initcall(omap2_mcspi_init);
-
- static void __exit omap2_mcspi_exit(void)
- {
- platform_driver_unregister(&omap2_mcspi_driver);
-
- }
- module_exit(omap2_mcspi_exit);
-
+ module_platform_driver(omap2_mcspi_driver);
MODULE_LICENSE("GPL");