fpga fr br: separate freeze bridge driver code
PATCH 1/1 fpga fr br: separate freeze bridge driver code
From: Matthew Gerlach <[email protected]>
This patch separates the core Freeze Bridge driver code from the platform driver code. The intent is to allow the core driver code to be used without requiring platform driver support.
--- drivers/fpga/Kconfig | 7 ++++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-freeze-bridge-plat.c | 65 ++++++++++++++++++++++++++++++++ drivers/fpga/altera-freeze-bridge.c | 41 ++++---------------- drivers/fpga/altera-freeze-bridge.h | 26 +++++++++++++ 5 files changed, 107 insertions(+), 33 deletions(-) create mode 100644 drivers/fpga/altera-freeze-bridge-plat.c create mode 100644 drivers/fpga/altera-freeze-bridge.h
drivers/fpga/Kconfig +7 -0
@@ -63,6 +63,13 @@ config ALTERA_FREEZE_BRIDGE isolate one region of the FPGA from the busses while that region is being reprogrammed. +config ALTERA_FREEZE_BRIDGE_PLAT + tristate "Platform support of Altera FPGA Freeze Bridge" + depends on ALTERA_FREEZE_BRIDGE && OF && HAS_IOMEM + help + Say Y to enable platform driver support for Altera FPGA + Freeze bridges. + endif # FPGA endmenu
drivers/fpga/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o obj-$(CONFIG_SOCFPGA_FPGA_BRIDGE) += altera-hps2fpga.o altera-fpga2sdram.o obj-$(CONFIG_ALTERA_FREEZE_BRIDGE) += altera-freeze-bridge.o +obj-$(CONFIG_ALTERA_FREEZE_BRIDGE_PLAT) += altera-freeze-bridge-plat.o # High Level Interfaces obj-$(CONFIG_FPGA_REGION) += fpga-region.o
drivers/fpga/altera-freeze-bridge-plat.c new file +65 -0
65 lines not on this page · raw message
drivers/fpga/altera-freeze-bridge.c +8 -33
77 lines not on this page · raw message
drivers/fpga/altera-freeze-bridge.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* FPGA Freeze Bridge Controller +* +* Copyright (C) 2016-2017 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _ALT_FRZ_BR_H +#define _ALT_FRZ_BR_H +#include <linux/io.h> + +int altera_freeze_br_probe (struct device *dev,void __iomem *reg_base); +int altera_freeze_br_remove (struct device *dev); + +#endif /* _ALT_FRZ_BR_H */
Signature · 1 line
2.7.4
Hi Matthew,
small nit inline.
Quoted 86 lines · On Mon, Feb 27, 2017 at 12:03 PM, <[email protected]> wrote:
From: Matthew Gerlach <[email protected]>
This patch separates the core Freeze Bridge driver code from the platform driver code. The intent is to allow the core driver code to be used without requiring platform driver support.
Signed-off-by Matthew Gerlach <[email protected]>--- drivers/fpga/Kconfig | 7 ++++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-freeze-bridge-plat.c | 65 ++++++++++++++++++++++++++++++++ drivers/fpga/altera-freeze-bridge.c | 41 ++++---------------- drivers/fpga/altera-freeze-bridge.h | 26 +++++++++++++ 5 files changed, 107 insertions(+), 33 deletions(-) create mode 100644 drivers/fpga/altera-freeze-bridge-plat.c create mode 100644 drivers/fpga/altera-freeze-bridge.hdrivers/fpga/Kconfig +7
-0@@ -63,6 +63,13 @@ config ALTERA_FREEZE_BRIDGE isolate one region of the FPGA from the busses while that region is being reprogrammed. +config ALTERA_FREEZE_BRIDGE_PLAT + tristate "Platform support of Altera FPGA Freeze Bridge" + depends on ALTERA_FREEZE_BRIDGE && OF && HAS_IOMEM + help + Say Y to enable platform driver support for Altera FPGA + Freeze bridges. + endif # FPGA endmenudrivers/fpga/Makefile +1
-0@@ -14,6 +14,7 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o obj-$(CONFIG_SOCFPGA_FPGA_BRIDGE) += altera-hps2fpga.o altera-fpga2sdram.o obj-$(CONFIG_ALTERA_FREEZE_BRIDGE) += altera-freeze-bridge.o +obj-$(CONFIG_ALTERA_FREEZE_BRIDGE_PLAT) += altera-freeze-bridge-plat.o # High Level Interfaces obj-$(CONFIG_FPGA_REGION) += fpga-region.odrivers/fpga/altera-freeze-bridge-plat.c new file +32
-0@@ -0,0 +1,65 @@ +/* +* Platform Driver Support for FPGA Freeze Bridge Controller +* +* Copyright (C) 2016 Altera Corporation. All rights reserved. +* Copyright (C) 2016-2017 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "altera-freeze-bridge.h" +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of_device.h> +#include <linux/module.h> + +static int altera_freeze_br_platform_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *np = pdev->dev.of_node; +struct resource *res; +void __iomem *reg_base; + +if (!np)
drivers/fpga/altera-freeze-bridge-plat.c line 42
Quoted 10 lines
drivers/fpga/altera-freeze-bridge-plat.c new file +10
-0+return -ENODEV ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + + reg_base =devm_ioremap_resource (dev, res); + +if (IS_ERR (reg_base)) +return PTR_ERR (reg_base); + +return altera_freeze_br_probe (dev, reg_base);
Maybe you can call this 'register' instead of 'probe' since the probing is basically
done at this point. The same comment basically applies to the pr-core I think.
Thanks,
Moritz
Quoted 97 lines · Moritz Fischer
Hi Matthew,
small nit inline.
Quoted 92 lines · On Mon, Feb 27, 2017 at 12:03 PM, <[email protected]> wrote:
From: Matthew Gerlach <[email protected]>
This patch separates the core Freeze Bridge driver code from the platform driver code. The intent is to allow the core driver code to be used without requiring platform driver support.
Signed-off-by Matthew Gerlach <[email protected]>--- drivers/fpga/Kconfig | 7 ++++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-freeze-bridge-plat.c | 65 ++++++++++++++++++++++++++++++++ drivers/fpga/altera-freeze-bridge.c | 41 ++++---------------- drivers/fpga/altera-freeze-bridge.h | 26 +++++++++++++ 5 files changed, 107 insertions(+), 33 deletions(-) create mode 100644 drivers/fpga/altera-freeze-bridge-plat.c create mode 100644 drivers/fpga/altera-freeze-bridge.hdrivers/fpga/Kconfig +7
-0@@ -63,6 +63,13 @@ config ALTERA_FREEZE_BRIDGE isolate one region of the FPGA from the busses while that region is being reprogrammed. +config ALTERA_FREEZE_BRIDGE_PLAT + tristate "Platform support of Altera FPGA Freeze Bridge" + depends on ALTERA_FREEZE_BRIDGE && OF && HAS_IOMEM + help + Say Y to enable platform driver support for Altera FPGA + Freeze bridges. + endif # FPGA endmenudrivers/fpga/Makefile +1
-0@@ -14,6 +14,7 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o obj-$(CONFIG_SOCFPGA_FPGA_BRIDGE) += altera-hps2fpga.o altera-fpga2sdram.o obj-$(CONFIG_ALTERA_FREEZE_BRIDGE) += altera-freeze-bridge.o +obj-$(CONFIG_ALTERA_FREEZE_BRIDGE_PLAT) += altera-freeze-bridge-plat.o # High Level Interfaces obj-$(CONFIG_FPGA_REGION) += fpga-region.odrivers/fpga/altera-freeze-bridge-plat.c new file +38
-0@@ -0,0 +1,65 @@ +/* +* Platform Driver Support for FPGA Freeze Bridge Controller +* +* Copyright (C) 2016 Altera Corporation. All rights reserved. +* Copyright (C) 2016-2017 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "altera-freeze-bridge.h" +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of_device.h> +#include <linux/module.h> + +static int altera_freeze_br_platform_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *np = pdev->dev.of_node; +struct resource *res; +void __iomem *reg_base; + +if (!np) +return -ENODEV ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + + reg_base =devm_ioremap_resource (dev, res); +
Quoted 9 lines
drivers/fpga/altera-freeze-bridge-plat.c line 42
Quoted 4 lines
drivers/fpga/altera-freeze-bridge-plat.c new file +4
-0+if (IS_ERR (reg_base)) +return PTR_ERR (reg_base); + +return altera_freeze_br_probe (dev, reg_base);Maybe you can call this 'register' instead of 'probe' since the probing is basically
done at this point. The same comment basically applies to the pr-core I think.
Hi Moritz,
This is very good suggestion. Having a "probe" function and a "platform_probe" function was confusing to some people. 'register' makes a lot of sense.
Matthew Gerlach
Quoted 8 lines
Thanks,
Moritz
--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html