forked from freak07/Kirisakura_Raviole
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fpga: dfl: add fpga region platform driver for FME
This patch adds fpga region platform driver for FPGA Management Engine. It register an fpga region with given fpga manager / bridge device. Signed-off-by: Tim Whisonant <[email protected]> Signed-off-by: Enno Luebbers <[email protected]> Signed-off-by: Shiva Rao <[email protected]> Signed-off-by: Christopher Rauer <[email protected]> Signed-off-by: Wu Hao <[email protected]> Acked-by: Alan Tull <[email protected]> Acked-by: Moritz Fischer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* FPGA Region Driver for FPGA Management Engine (FME) | ||
* | ||
* Copyright (C) 2017-2018 Intel Corporation, Inc. | ||
* | ||
* Authors: | ||
* Wu Hao <[email protected]> | ||
* Joseph Grecco <[email protected]> | ||
* Enno Luebbers <[email protected]> | ||
* Tim Whisonant <[email protected]> | ||
* Ananda Ravuri <[email protected]> | ||
* Henry Mitchel <[email protected]> | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/fpga/fpga-region.h> | ||
|
||
#include "dfl-fme-pr.h" | ||
|
||
static int fme_region_get_bridges(struct fpga_region *region) | ||
{ | ||
struct dfl_fme_region_pdata *pdata = region->priv; | ||
struct device *dev = &pdata->br->dev; | ||
|
||
return fpga_bridge_get_to_list(dev, region->info, ®ion->bridge_list); | ||
} | ||
|
||
static int fme_region_probe(struct platform_device *pdev) | ||
{ | ||
struct dfl_fme_region_pdata *pdata = dev_get_platdata(&pdev->dev); | ||
struct device *dev = &pdev->dev; | ||
struct fpga_region *region; | ||
struct fpga_manager *mgr; | ||
int ret; | ||
|
||
mgr = fpga_mgr_get(&pdata->mgr->dev); | ||
if (IS_ERR(mgr)) | ||
return -EPROBE_DEFER; | ||
|
||
region = fpga_region_create(dev, mgr, fme_region_get_bridges); | ||
if (!region) { | ||
ret = -ENOMEM; | ||
goto eprobe_mgr_put; | ||
} | ||
|
||
region->priv = pdata; | ||
platform_set_drvdata(pdev, region); | ||
|
||
ret = fpga_region_register(region); | ||
if (ret) | ||
goto region_free; | ||
|
||
dev_dbg(dev, "DFL FME FPGA Region probed\n"); | ||
|
||
return 0; | ||
|
||
region_free: | ||
fpga_region_free(region); | ||
eprobe_mgr_put: | ||
fpga_mgr_put(mgr); | ||
return ret; | ||
} | ||
|
||
static int fme_region_remove(struct platform_device *pdev) | ||
{ | ||
struct fpga_region *region = dev_get_drvdata(&pdev->dev); | ||
|
||
fpga_region_unregister(region); | ||
fpga_mgr_put(region->mgr); | ||
|
||
return 0; | ||
} | ||
|
||
static struct platform_driver fme_region_driver = { | ||
.driver = { | ||
.name = DFL_FPGA_FME_REGION, | ||
}, | ||
.probe = fme_region_probe, | ||
.remove = fme_region_remove, | ||
}; | ||
|
||
module_platform_driver(fme_region_driver); | ||
|
||
MODULE_DESCRIPTION("FPGA Region for DFL FPGA Management Engine"); | ||
MODULE_AUTHOR("Intel Corporation"); | ||
MODULE_LICENSE("GPL v2"); | ||
MODULE_ALIAS("platform:dfl-fme-region"); |