Skip to contentSkip to conversation

FPGA Manager Framework

PATCH Superseded [email protected] 1 participant 5 messages Dec 9, 2014 FPGA manager framework

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover FPGA Manager Framework

From: Alan Tull <[email protected]>

Improvements in this version:

Fixed things in the framework that were left over from my original version that was a character driver. In particular, make the struct device be present in the fpga_manager struct, not as a pointer, so container_of will work.

Also rewrote the part that handles DT notifications. Now this section takes notifications instead of being another device to load/unload.

Still want to integrate bridge enable/disable with this, but that's not done yet.

Alan Tull (3):
fpga manager: add sysfs interface document
fpga manager: framework core
fpga manager: device tree overlay support

 Documentation/ABI/testing/sysfs-class-fpga-manager |   38 ++
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    1 +
 drivers/fpga/Kconfig                               |   28 +
 drivers/fpga/Makefile                              |   10 +
 drivers/fpga/fpga-mgr.c                            |  587 ++++++++++++++++++++
 include/linux/fpga-mgr.h                           |  107 ++++
 7 files changed, 773 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-manager
 create mode 100644 drivers/fpga/Kconfig
 create mode 100644 drivers/fpga/Makefile
 create mode 100644 drivers/fpga/fpga-mgr.c
 create mode 100644 include/linux/fpga-mgr.h
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH v3 1/3 fpga manager: add sysfs interface document

From: Alan Tull <[email protected]>

Add documentation for new fpga manager sysfs interface.

---
 Documentation/ABI/testing/sysfs-class-fpga-manager |   38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-manager
Documentation/ABI/testing/sysfs-class-fpga-manager new file +38 -0
new file mode 100644
index 0000000..eb600f2
@@ -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
#2 lore raw

PATCH v3 2/3 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

---
 drivers/Kconfig          |    2 +
 drivers/Makefile         |    1 +
 drivers/fpga/Kconfig     |   21 ++
 drivers/fpga/Makefile    |   10 +
 drivers/fpga/fpga-mgr.c  |  485 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fpga-mgr.h |  104 ++++++++++
 6 files changed, 623 insertions(+)
 create mode 100644 drivers/fpga/Kconfig
 create mode 100644 drivers/fpga/Makefile
 create mode 100644 drivers/fpga/fpga-mgr.c
 create mode 100644 include/linux/fpga-mgr.h
drivers/Kconfig +2 -0
index 622fa26..fc45fee 100644
@@ -34,6 +34,8 @@ source "drivers/message/fusion/Kconfig"
 
 source "drivers/firewire/Kconfig"
 
+source "drivers/fpga/Kconfig"
+
 source "drivers/message/i2o/Kconfig"
 
 source "drivers/macintosh/Kconfig"
drivers/Makefile +1 -0
index ebee555..637b9f0 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_RESET_CONTROLLER)	+= reset/
 # default.
 obj-y				+= tty/
 obj-y				+= char/
+obj-$(CONFIG_FPGA)		+= fpga/
 
 # gpu/ comes after char for AGP vs DRM startup
 obj-y				+= gpu/
drivers/fpga/Kconfig new file +21 -0
new file mode 100644
index 0000000..e775b17
@@ -0,0 +1,21 @@
+#
+# 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.
+
+config FPGA_MGR_SYSFS
+	bool "FPGA Manager SysFS Interface"
+	depends on FPGA
+	depends on SYSFS
+	help
+	  FPGA Manager SysFS interface.
+
+endmenu
drivers/fpga/Makefile new file +10 -0
new file mode 100644
index 0000000..c8a676f
@@ -0,0 +1,10 @@
+#
+# Makefile for the fpga framework and fpga manager drivers.
+#
+
+fpga-mgr-core-y += fpga-mgr.o
+
+# Core FPGA Manager Framework
+obj-$(CONFIG_FPGA)			+= fpga-mgr-core.o
+
+# FPGA Manager Drivers
drivers/fpga/fpga-mgr.c new file +485 -0

485 lines not on this page · raw message

include/linux/fpga-mgr.h new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v3 3/3 fpga manager: device tree overlay support

In reply to [email protected]

From: Alan Tull <[email protected]>

Support programming the fpga from device tree overlays.

This patch adds two exported functions to the core (fpga-mgr.c):
of_fpga_mgr_dev_lookup
Get pointer to fpga manager struct given a phandle.

of_find_fpga_mgr_by_node
Get pointer to fpga manager given device node

This code is dependent on Pantelis Antoniou's current work on Device Tree overlays, a method of dynamically altering the kernel's live Device Tree. The rest of the patchset was tested with recent for-next, but this 'bus driver' patch was tested with Pantelis's and Grant Likely's stuff that is in git (his git repo https://github.com/pantoniou/linux-beagle-track-mainline
v3.17-rc2-115-gbc778b8 == dt-ng/bbb) plus some dtc fixups
for compiling overlays.

TODO: Integrate bridge support

General flow is:
1. Load a DT overlay
2. This causes the FPGA to get programmed
3. TODO - enable FPGA bridges
4. Drivers get probed

The reverse flow is also supported:
1. Remove the DT overlay
2. Drivers get removed
3. TODO - disable FPGA bridges
4. FPGA gets reset

---
 drivers/fpga/Kconfig     |    7 ++++
 drivers/fpga/fpga-mgr.c  |  104 +++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/fpga-mgr.h |    3 ++
 3 files changed, 113 insertions(+), 1 deletion(-)
drivers/fpga/Kconfig +7 -0
index e775b17..2bd6c83 100644
@@ -18,4 +18,11 @@ config FPGA_MGR_SYSFS
 	help
 	  FPGA Manager SysFS interface.
 
+config FPGA_MGR_BUS
+	bool "FPGA Manager Bus"
+	depends on FPGA
+	help
+	  FPGA Manager Bus interface.  Allows loading FPGA images
+	  from Device Tree or from other drivers.
+
 endmenu
drivers/fpga/fpga-mgr.c +103 -1

144 lines not on this page · raw message

include/linux/fpga-mgr.h +3 -0
index 7ac762c..414d949 100644
@@ -99,6 +99,9 @@ int fpga_mgr_reset(struct fpga_manager *mgr);
 int fpga_mgr_register(struct device *pdev, const char *name,
 		      struct fpga_manager_ops *mops, void *priv);
 void fpga_mgr_remove(struct device *dev);
+struct fpga_manager *of_fpga_mgr_dev_lookup(struct device_node *node,
+					    const char *mgr_property);
+struct fpga_manager *of_find_fpga_mgr_by_node(struct device_node *node);
 
 #endif /* CONFIG_FPGA */
 #endif /*_LINUX_FPGA_MGR_H */
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#4 lore raw
In reply to [email protected]
Quoted 9 lines · On Tue, 9 Dec 2014, [email protected] wrote:

From: Alan Tull <[email protected]>

Improvements in this version:

Fixed things in the framework that were left over from my original version that was a character driver. In particular, make the struct device be present in the fpga_manager struct, not as a pointer, so container_of will work.

Quoted 7 lines

Also rewrote the part that handles DT notifications. Now this section takes notifications instead of being another device to load/unload.

Still want to integrate bridge enable/disable with this, but that's not done yet.

I have been recommended to move this to drivers/staging. This makes sense as there has always been a lot of discussion of the interface.

Will be submitting that as v4 today.

Alan Tull

Quoted 23 lines

Alan Tull (3):
fpga manager: add sysfs interface document
fpga manager: framework core
fpga manager: device tree overlay support

 Documentation/ABI/testing/sysfs-class-fpga-manager |   38 ++
 drivers/Kconfig                                    |    2 +
 drivers/Makefile                                   |    1 +
 drivers/fpga/Kconfig                               |   28 +
 drivers/fpga/Makefile                              |   10 +
 drivers/fpga/fpga-mgr.c                            |  587 ++++++++++++++++++++
 include/linux/fpga-mgr.h                           |  107 ++++
 7 files changed, 773 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-manager
 create mode 100644 drivers/fpga/Kconfig
 create mode 100644 drivers/fpga/Makefile
 create mode 100644 drivers/fpga/fpga-mgr.c
 create mode 100644 include/linux/fpga-mgr.h
Signature · 1 line
1.7.9.5