FPGA Manager Framework
Subsystems (2)
v7 cover FPGA Manager Framework
From: Alan Tull <[email protected]>
For after 3.19-rc1 is out.
v7 adds a one line fix from the kbuild test robot and Michal Simek's signoff.
Thanks,
Alan
Alan Tull (4):
doc: add bindings document for altera fpga manager fpga manager: add sysfs interface document
staging: fpga manager: framework core
staging: fpga manager: add driver for socfpga fpga manager
drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + .../Documentation/ABI/sysfs-class-fpga-manager | 38 ++ .../Documentation/bindings/altera-fpga-mgr.txt | 17 + drivers/staging/fpga/Kconfig | 29 + drivers/staging/fpga/Makefile | 9 + drivers/staging/fpga/fpga-mgr.c | 551 ++++++++++++++++ drivers/staging/fpga/socfpga.c | 694 ++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 124 ++++ 9 files changed, 1465 insertions(+) create mode 100644 drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager create mode 100644 drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt create mode 100644 drivers/staging/fpga/Kconfig create mode 100644 drivers/staging/fpga/Makefile create mode 100644 drivers/staging/fpga/fpga-mgr.c create mode 100644 drivers/staging/fpga/socfpga.c create mode 100644 include/linux/fpga/fpga-mgr.h
Signature · 1 line
1.7.9.5
PATCH v7 1/4 doc: add bindings document for altera fpga manager
From: Alan Tull <[email protected]>
New bindings document for Altera fpga manager.
---
v5 : Move bindings to drivers/staging/fpga/Documentation/bindings
v6 : No change in this patch for v6 of the patch set
v7 : No change in this patch for v7 of the patch set
--- .../Documentation/bindings/altera-fpga-mgr.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt
drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt new file +17 -0
@@ -0,0 +1,17 @@ +Altera FPGA Manager + +Required properties: +- compatible : should contain "altr,fpga-mgr" +- reg : base address and size for memory mapped io. + - The first index is for FPGA manager register access. + - The second index is for writing FPGA configuration data. +- interrupts : interrupt for the FPGA Manager device. + +Example: + + hps_0_fpgamgr: fpgamgr@0xff706000 { + compatible = "altr,fpga-mgr"; + reg = <0xFF706000 0x1000 + 0xFFB90000 0x1000>; + interrupts = <0 175 4>; + };
Signature · 1 line
1.7.9.5
PATCH v7 2/4 fpga manager: add sysfs interface document
In reply to [email protected]From: Alan Tull <[email protected]>
Add documentation under drivers/staging for new fpga manager's sysfs interface.
---
v5 : (actually second version, but keeping version numbers
aligned with rest of patch series)
Move document to drivers/staging/fpga/Documentation/ABI
v6 : No change in this patch for v6 of the patch set
v7 : No change in this patch for v7 of the patch set
--- .../Documentation/ABI/sysfs-class-fpga-manager | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager new file +38 -0
@@ -0,0 +1,38 @@ +What: /sys/class/fpga_manager/<fpga>/name +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Name of low level driver. + +What: /sys/class/fpga_manager/<fpga>/firmware +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Name of the FPGA image file to load using firmware class. + +What: /sys/class/fpga_manager/<fpga>/reset +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Write 1 to reset the FPGA + +What: /sys/class/fpga_manager/<fpga>/state +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Read state of fpga framework state machine as a string. + Valid states may vary by manufacturer; superset is: + * unknown = can't determine state + * power_off = FPGA power is off + * power_up = FPGA reports power is up + * reset = FPGA held in reset state + * firmware_request = firmware class request in progress + * firmware_request_err = firmware request failed + * write_init = FPGA being prepared for programming + * write_init_err = Error while preparing FPGA for + programming + * write = FPGA ready to receive image data + * write_err = Error while programming + * write_complete = Doing post programming steps + * write_complete_err = Error while doing post programming + * operating = FPGA is programmed and operating
Signature · 1 line
1.7.9.5
PATCH v7 3/4 staging: fpga manager: framework core
In reply to [email protected]From: Alan Tull <[email protected]>
Supports standard ops for low level FPGA drivers. Various manufacturors' FPGAs can be supported by adding low level drivers. Each driver needs to register its ops using fpga_mgr_register().
Exports methods of doing operations to program FPGAs. These should be sufficient for individual drivers to request FPGA programming directly if desired.
Adds a sysfs interface. The sysfs interface can be compiled out where desired in production builds.
Resume is supported by calling low level driver's resume function, then reloading the firmware image.
The following are exported as GPL:
* fpga_mgr_reset
Reset the FGPA.
* fpga_mgr_write
Write a image (in buffer) to the FPGA.
* fpga_mgr_firmware_write
Request firmware by file name and write it to the FPGA.
* fpga_mgr_name
Get name of FPGA manager.
* fpga_mgr_state
Get a state of framework as a string.
* fpga_mgr_register and fpga_mgr_remove Register/unregister low level fpga manager driver.
The following sysfs files are created:
* /sys/class/fpga_manager/<fpga>/name
Name of low level driver.
* /sys/class/fpga_manager/<fpga>/firmware
Name of FPGA image file to load using firmware class.
$ echo image.rbf > /sys/class/fpga_manager/<fpga>/firmware
read: read back name of image file previous loaded
$ cat /sys/class/fpga_manager/<fpga>/firmware
* /sys/class/fpga_manager/<fpga>/reset
reset the FPGA
$ echo 1 > /sys/class/fpga_manager/<fpga>/reset
* /sys/class/fpga_manager/<fpga>/state
State of fpga framework state machine
---
v2: s/mangager/manager/
check for invalid request_nr
add fpga reset interface
rework the state code
remove FPGA_MGR_FAIL flag
add _ERR states to fpga manager states enum low level state op now returns a state enum value initialize framework state from driver state op remove unused fpga read stuff
merge sysfs.c into fpga-mgr.c
move suspend/resume from bus.c to fpga-mgr.c
v3: Add struct device to fpga_manager (not as a pointer)
Add to_fpga_manager
Don't get irq in fpga-mgr.c (let low level driver do it) remove from struct fpga_manager: nr, np, parent get rid of fpga_mgr_get_new_minor()
simplify fpga_manager_register:
reorder parameters
use dev instead of pdev
get rid of code that used to make more sense when this
was a char driver, don't alloc_chrdev_region
use a mutex instead of flags
v4: Move to drivers/staging
v5: Make some things be static
Kconfig: add 'if FPGA'
Makefile: s/fpga-mgr-core.o/fpga-mgr.o/ clean up includes
use enum fpga_mgr_states instead of int static const char *state_str
use DEVICE_ATTR_RO/RW/WO and ATTRIBUTE_GROUPS return -EINVAL instead of BUG_ON
move ida_simple_get after kzalloc
clean up fpga_mgr_remove
fpga-mgr.h: remove '#if IS_ENABLED(CONFIG_FPGA)' add kernel-doc documentation
Move header to new include/linux/fpga folder static const struct fpga_mgr_ops dev_info msg simplified
v6: no statically allocated string for image_name
kernel doc fixes
changes regarding enabling SYSFS for fpga mgr
Makefile cleanup
v7: no change in this patch for v7 of the patchset
--- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/fpga/Kconfig | 24 ++ drivers/staging/fpga/Makefile | 8 + drivers/staging/fpga/fpga-mgr.c | 551 +++++++++++++++++++++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 124 +++++++++ 6 files changed, 710 insertions(+) create mode 100644 drivers/staging/fpga/Kconfig create mode 100644 drivers/staging/fpga/Makefile create mode 100644 drivers/staging/fpga/fpga-mgr.c create mode 100644 include/linux/fpga/fpga-mgr.h
drivers/staging/Kconfig +2 -0
@@ -108,4 +108,6 @@ source "drivers/staging/skein/Kconfig" source "drivers/staging/unisys/Kconfig" +source "drivers/staging/fpga/Kconfig" + endif # STAGING
drivers/staging/Makefile +1 -0
@@ -46,3 +46,4 @@ obj-$(CONFIG_MTD_SPINAND_MT29F) += mt29f_spinand/ obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ obj-$(CONFIG_CRYPTO_SKEIN) += skein/ obj-$(CONFIG_UNISYSSPAR) += unisys/ +obj-$(CONFIG_FPGA) += fpga/
drivers/staging/fpga/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# +# FPGA framework configuration +# + +menu "FPGA devices" + +config FPGA + tristate "FPGA Framework" + help + Say Y here if you want support for configuring FPGAs from the + kernel. The FPGA framework adds a FPGA manager class and FPGA + manager drivers. + +if FPGA + +config FPGA_MGR_SYSFS + bool "FPGA Manager SysFS Interface" + depends on SYSFS + help + FPGA Manager SysFS interface. + +endif # FPGA + +endmenu
drivers/staging/fpga/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Makefile for the fpga framework and fpga manager drivers. +# + +# Core FPGA Manager Framework +obj-$(CONFIG_FPGA) += fpga-mgr.o + +# FPGA Manager Drivers
drivers/staging/fpga/fpga-mgr.c new file +551 -0
551 lines not on this page · raw message
include/linux/fpga/fpga-mgr.h new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v7 4/4 staging: fpga manager: add driver for socfpga fpga manager
In reply to [email protected]From: Alan Tull <[email protected]>
Add driver to fpga manager framework to allow configuration of FPGA in Altera SoCFPGA parts.
---
v2: fpga_manager struct now contains struct device
fpga_manager_register parameters now take device
v3: skip a version to align versions
v4: move to drivers/staging
v5: fix array_size.cocci warnings
fix platform_no_drv_owner.cocci warnings
Remove .owner = THIS_MODULE
include asm/irq.h
clean up list of includes
use altera_fpga_reset for ops
use enum fpga_mgr_states or u32 as needed
use devm_request_irq
check irq <= 0 instead of == NO_IRQ
Use ARRAY_SIZE
rename altera -> socfpga
static const socfpga_fpga_ops
header moved to linux/fpga/ folder
remove ifdef'ed code
use platform_get_resource and platform_get_irq move .probe and .remove lines adjacent
use module_platform_driver
use __maybe_unused
only need to 'if (IS_ENABLED(CONFIG_REGULATOR))' in one fn fix "unsigned 'mode' is never < 0"
v6: return error for (unused) default of case statement
v7: PTR_ERR should access the value just tested by IS_ERR
--- drivers/staging/fpga/Kconfig | 5 + drivers/staging/fpga/Makefile | 1 + drivers/staging/fpga/socfpga.c | 694 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 700 insertions(+) create mode 100644 drivers/staging/fpga/socfpga.c
drivers/staging/fpga/Kconfig +5 -0
@@ -19,6 +19,11 @@ config FPGA_MGR_SYSFS help FPGA Manager SysFS interface. +config FPGA_MGR_SOCFPGA + tristate "Altera SOCFPGA" + help + FPGA manager driver support for Altera SOCFPGA. + endif # FPGA endmenu
drivers/staging/fpga/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o # FPGA Manager Drivers +obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o
drivers/staging/fpga/socfpga.c new file +694 -0
694 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v7 1/4] doc: add bindings document for altera fpga manager
In reply to [email protected]Quoted 25 lines · On Fri, Dec 19, 2014 at 10:45 AM, <[email protected]> wrote:
From: Alan Tull <[email protected]>
New bindings document for Altera fpga manager.
Signed-off-by Alan Tull <[email protected]>---
v5 : Move bindings todrivers/staging/fpga/Documentation/bindingsv6 : No change in this patch for v6 of the patch set
v7 : No change in this patch for v7 of the patch set
--- .../Documentation/bindings/altera-fpga-mgr.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txtdrivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt new file +3
-0@@ -0,0 +1,17 @@ +Altera FPGA Manager + +Required properties:
drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt line 13
Quoted 10 lines
drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt new file +10
-0+- compatible : should contain "altr,fpga-mgr" +- reg : base address and size for memory mapped io. + - The first index is for FPGA manager register access. + - The second index is for writing FPGA configuration data. +- interrupts : interrupt for the FPGA Manager device. + +Example: + + hps_0_fpgamgr: fpgamgr@0xff706000 { + compatible = "altr,fpga-mgr";
Is "FPGA Manager" what the block is called or the name for the Linux subsystem?" The name should reflect the h/w block name. Also, is the block the same in every chip?
This binding doesn't look complex or likely to change, so it can be out of staging unless you expect it to change.
Rob
Re: [PATCH v7 2/4] fpga manager: add sysfs interface document
In reply to [email protected]drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager line 11
Quoted 6 lines
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager new file +5
-0+What: /sys/class/fpga_manager/<fpga>/firmware +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Name of the FPGA image file to load using firmware class.
This is wrong interface, right? The only use of this string is to pass it to udev. We should simply pass "fpga-0" as a firware name, and let udev figure it out, no need to to prepare name in separate component, then pass it to kernel, which passes it back to udev.
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager line 17
Quoted 5 lines
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager new file +5
-0+What: /sys/class/fpga_manager/<fpga>/reset +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Write 1 to reset the FPGA
Does 0 need to be written there to pull the fpga out of reset? Is this a suitable interface?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v7 2/4] fpga manager: add sysfs interface document
Hi Pavel,
Quoted 14 lines · Pavel Machek
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager line 11
Quoted 7 lines
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager new file +5
-0+What: /sys/class/fpga_manager/<fpga>/firmware +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Name of the FPGA image file to load using firmware class.This is wrong interface, right? The only use of this string is to pass it to udev. We should simply pass "fpga-0" as a firware name, and let udev figure it out, no need to to prepare name in separate component, then pass it to kernel, which passes it back to udev.
No. No dependencies on udev please. This should hook directly to the firmware loader interface which does not rely on userspace at all.
Quoted 9 lines
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager line 17
Quoted 5 lines
drivers/staging/fpga/Documentation/ABI/sysfs-class-fpga-manager new file +5
-0+What: /sys/class/fpga_manager/<fpga>/reset +Date: October 2014 +KernelVersion: 3.18 +Contact: Alan Tull <[email protected]> +Description: Write 1 to reset the FPGADoes 0 need to be written there to pull the fpga out of reset? Is this a suitable interface?
Quoted 4 lines
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Regards
— Pantelis
Re: [PATCH v7 1/4] doc: add bindings document for altera fpga manager
In reply to Rob HerringQuoted 32 lines · Rob Herring
Quoted 31 lines · On Fri, Dec 19, 2014 at 10:45 AM, <[email protected]> wrote:
From: Alan Tull <[email protected]>
New bindings document for Altera fpga manager.
Signed-off-by Alan Tull <[email protected]>---
v5 : Move bindings todrivers/staging/fpga/Documentation/bindingsv6 : No change in this patch for v6 of the patch set
v7 : No change in this patch for v7 of the patch set
--- .../Documentation/bindings/altera-fpga-mgr.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txtdrivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt new file +9
-0@@ -0,0 +1,17 @@ +Altera FPGA Manager + +Required properties: +- compatible : should contain "altr,fpga-mgr" +- reg : base address and size for memory mapped io. + - The first index is for FPGA manager register access. + - The second index is for writing FPGA configuration data. +- interrupts : interrupt for the FPGA Manager device. +
Quoted 8 lines
drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt line 13
Quoted 4 lines
drivers/staging/fpga/Documentation/bindings/altera-fpga-mgr.txt new file +4
-0+Example: + + hps_0_fpgamgr: fpgamgr@0xff706000 { + compatible = "altr,fpga-mgr";Is "FPGA Manager" what the block is called or the name for the Linux subsystem?" The name should reflect the h/w block name. Also, is the block the same in every chip?
I see what you are saying. The subsystem is 'fpga manager'.
I should change this to "altr,socfpga-fpga-mgr" so that it is the fpga manager block that is specific to SOCFPGA chips. Also I should change the filename of the binding document accordingly.
Quoted 6 lines
This binding doesn't look complex or likely to change, so it can be out of staging unless you expect it to change.
Rob