1473f01f7SAlan Tull // SPDX-License-Identifier: GPL-2.0
25b73cb5bSMatthew Gerlach /*
35b73cb5bSMatthew Gerlach  * Driver for Altera Partial Reconfiguration IP Core
45b73cb5bSMatthew Gerlach  *
55b73cb5bSMatthew Gerlach  * Copyright (C) 2016-2017 Intel Corporation
65b73cb5bSMatthew Gerlach  *
75b73cb5bSMatthew Gerlach  * Based on socfpga-a10.c Copyright (C) 2015-2016 Altera Corporation
85b73cb5bSMatthew Gerlach  *  by Alan Tull <atull@opensource.altera.com>
95b73cb5bSMatthew Gerlach  */
105b73cb5bSMatthew Gerlach #include <linux/fpga/altera-pr-ip-core.h>
115b73cb5bSMatthew Gerlach #include <linux/module.h>
125b73cb5bSMatthew Gerlach #include <linux/of_device.h>
135b73cb5bSMatthew Gerlach 
145b73cb5bSMatthew Gerlach static int alt_pr_platform_probe(struct platform_device *pdev)
155b73cb5bSMatthew Gerlach {
165b73cb5bSMatthew Gerlach 	struct device *dev = &pdev->dev;
175b73cb5bSMatthew Gerlach 	void __iomem *reg_base;
185b73cb5bSMatthew Gerlach 	struct resource *res;
195b73cb5bSMatthew Gerlach 
205b73cb5bSMatthew Gerlach 	/* First mmio base is for register access */
215b73cb5bSMatthew Gerlach 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
225b73cb5bSMatthew Gerlach 
235b73cb5bSMatthew Gerlach 	reg_base = devm_ioremap_resource(dev, res);
245b73cb5bSMatthew Gerlach 
255b73cb5bSMatthew Gerlach 	if (IS_ERR(reg_base))
265b73cb5bSMatthew Gerlach 		return PTR_ERR(reg_base);
275b73cb5bSMatthew Gerlach 
285b73cb5bSMatthew Gerlach 	return alt_pr_register(dev, reg_base);
295b73cb5bSMatthew Gerlach }
305b73cb5bSMatthew Gerlach 
315b73cb5bSMatthew Gerlach static int alt_pr_platform_remove(struct platform_device *pdev)
325b73cb5bSMatthew Gerlach {
335b73cb5bSMatthew Gerlach 	struct device *dev = &pdev->dev;
345b73cb5bSMatthew Gerlach 
355b73cb5bSMatthew Gerlach 	return alt_pr_unregister(dev);
365b73cb5bSMatthew Gerlach }
375b73cb5bSMatthew Gerlach 
385b73cb5bSMatthew Gerlach static const struct of_device_id alt_pr_of_match[] = {
395b73cb5bSMatthew Gerlach 	{ .compatible = "altr,a10-pr-ip", },
405b73cb5bSMatthew Gerlach 	{},
415b73cb5bSMatthew Gerlach };
425b73cb5bSMatthew Gerlach 
435b73cb5bSMatthew Gerlach MODULE_DEVICE_TABLE(of, alt_pr_of_match);
445b73cb5bSMatthew Gerlach 
455b73cb5bSMatthew Gerlach static struct platform_driver alt_pr_platform_driver = {
465b73cb5bSMatthew Gerlach 	.probe = alt_pr_platform_probe,
475b73cb5bSMatthew Gerlach 	.remove = alt_pr_platform_remove,
485b73cb5bSMatthew Gerlach 	.driver = {
495b73cb5bSMatthew Gerlach 		.name	= "alt_a10_pr_ip",
505b73cb5bSMatthew Gerlach 		.of_match_table = alt_pr_of_match,
515b73cb5bSMatthew Gerlach 	},
525b73cb5bSMatthew Gerlach };
535b73cb5bSMatthew Gerlach 
545b73cb5bSMatthew Gerlach module_platform_driver(alt_pr_platform_driver);
555b73cb5bSMatthew Gerlach MODULE_AUTHOR("Matthew Gerlach <matthew.gerlach@linux.intel.com>");
565b73cb5bSMatthew Gerlach MODULE_DESCRIPTION("Altera Partial Reconfiguration IP Platform Driver");
575b73cb5bSMatthew Gerlach MODULE_LICENSE("GPL v2");
58