linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/1] FPGA subsystem core
@ 2013-10-02 15:35 Michal Simek
  2013-10-02 15:35 ` [RFC PATCH v2] fpga: Introduce new fpga subsystem Michal Simek
                   ` (2 more replies)
  0 siblings, 3 replies; 45+ messages in thread
From: Michal Simek @ 2013-10-02 15:35 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Alan Tull, Pavel Machek, Greg Kroah-Hartman, Dinh Nguyen,
	Philip Balister, Alessandro Rubini, Steffen Trumtrar,
	H. Peter Anvin, Jason Gunthorpe, Jason Cooper, Yves Vandervennet,
	Kyle Teske, Josh Cartwright, Nicolas Pitre, Mark Langsdorf,
	Felipe Balbi, linux-doc, Mauro Carvalho Chehab, David Brown,
	Rob Landley, David S. Miller, Joe Perches, Cesar Eduardo Barros,
	Samuel Ortiz, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 3734 bytes --]

Hi All,

this is the second attempt to introduce new Linux FPGA subsystem which
can help us to unify all fpga drivers which in general do the same
things.
Xilinx has hwicap in the kernel as char driver (drivers/char/xilinx_hwicap/)
and I would like to base Zynq devcfg driver based on this interface
because make no sense to push the Linux kernel another char driver
(I am testing this interface on this driver).

Based on my discussion at ELC with Greg KH the new driver
should support firmware interface for loading bitstream.

FPGA manager/driver just define set of functions and
call fpga_mgr_register().

struct fpga_manager_ops zynq_fpga_mgr_ops = {
	.read_init = zynq_init,
	.write_init = zynq_init,
	.read = zynq_read,
	.write = zynq_write,
	.read_complete = zynq_complete,
	.write_complete = zynq_complete,
};

fpga_mgr_register(pdev, &zynq_fpga_mgr_ops, "Zynq FPGA Manager", priv);

For unregistration it is enough to call:
fpga_mgr_unregister(pdev);

Here is the set of commands for writing bitstream to FPGA.

Through firmware interface:
cat /sys/class/fpga_manager/fpga0/name
echo -n fpga.bin > /sys/class/fpga_manager/fpga0/firmware

Through sysfs bin file:
cat /sys/class/fpga_manager/fpga0/fpga_config_state
echo -n write_init > /sys/class/fpga_manager/fpga0/fpga_config_state
cat /lib/firmware/fpga.bin > /sys/class/fpga_manager/fpga0/fpga_config_data
echo -n write_complete > /sys/class/fpga_manager/fpga0/fpga_config_state

Subsystem supports working with phandles for cases where you want to load
bitstreams for particular device through defined device.
For example:
mngr@0 {
	compatible = "whatever";
	fpga-mgr = <&ps7_dev_cfg_0>;
	...
} ;

With these lines you can get easily load bitstream to the device.

struct fpga_manager *mgr;
mgr = of_find_fpga_mgr_by_phandle(pdev->dev.of_node, "fpga-mgr");
if (mgr)
	mgr->fpga_firmware_write(mgr, "filename");

NOTE: I have added there of_find_fpga_mgr_by_node()
and of_find_fpga_mgr_by_phandle() but maybe they should be added
separately to drivers/of/of_fpga.c.

Alessandro: I haven't looked at your FMC cases but maybe this
could be also worth for your cases.

TODO:
- Probably make sense to create doc in Documentation folder too.
- When interface is fine also send zynq devcfg driver
- Properly test reading (we have problem with zynq devcfg driver now)
- Not sure if firmware interface also provide option to create
  files from kernel space.

Thanks for your comments,
Michal

Changes in v2:
- Remove ! from all error message not to be shouty
- Fix error codes
- Add sysfs-class-fpga description
- Use read/write helper functions with bit protection
- s/fpga_mgr_status_show/fpga_mgr_status_read/g
- Do not all end driver status just show core status
- Extract firmware support to specific sysfs firmware file
- Add support for sysfs bin attributes (fpga_config_state, fpga_config_data)
- Allocate space for name dynamically
- Introduce new flags bits (INIT_DONE, READ, WRITE)

Michal Simek (1):
  fpga: Introduce new fpga subsystem

 Documentation/ABI/testing/sysfs-class-fpga |  33 ++
 MAINTAINERS                                |   7 +
 drivers/Kconfig                            |   2 +
 drivers/Makefile                           |   1 +
 drivers/fpga/Kconfig                       |  18 +
 drivers/fpga/Makefile                      |   5 +
 drivers/fpga/fpga-mgr.c                    | 753 +++++++++++++++++++++++++++++
 include/linux/fpga.h                       | 110 +++++
 8 files changed, 929 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga
 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.h

--
1.8.2.3


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2013-10-09 22:22 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-02 15:35 [RFC PATCH v2 0/1] FPGA subsystem core Michal Simek
2013-10-02 15:35 ` [RFC PATCH v2] fpga: Introduce new fpga subsystem Michal Simek
2013-10-02 16:06   ` Joe Perches
2013-10-04 16:15     ` Michal Simek
2013-10-04 16:26       ` Greg Kroah-Hartman
2013-10-02 17:46   ` Jason Gunthorpe
2013-10-04 16:28     ` Michal Simek
2013-10-04 17:05       ` Jason Gunthorpe
2013-10-04 18:50       ` Alan Tull
2013-10-02 19:00 ` [RFC PATCH v2 0/1] FPGA subsystem core H. Peter Anvin
2013-10-03  6:49   ` Pavel Machek
2013-10-04 13:57     ` Michal Simek
2013-10-04 14:16       ` Greg Kroah-Hartman
2013-10-04 14:21         ` H. Peter Anvin
2013-10-04 14:28           ` Michal Simek
2013-10-04 16:46             ` H. Peter Anvin
2013-10-04 17:44               ` Michal Simek
2013-10-04 18:12                 ` H. Peter Anvin
2013-10-04 23:33                   ` Greg Kroah-Hartman
2013-10-04 23:49                     ` Jason Gunthorpe
2013-10-05  4:00                       ` H. Peter Anvin
2013-10-05  5:10                         ` Jason Gunthorpe
2013-10-05  5:34                           ` H. Peter Anvin
2013-10-05  6:53                             ` Michal Simek
     [not found]                               ` <c59c68b8-2565-45c5-bfe9-574b76f3f9bc@email.android.com>
2013-10-07 13:11                                 ` Michal Simek
2013-10-07 14:55                                   ` H. Peter Anvin
2013-10-07 15:03                                     ` Michal Simek
2013-10-07 15:07                                       ` H. Peter Anvin
2013-10-08 13:00                                         ` Michal Simek
2013-10-08 16:49                                           ` Alan Tull
2013-10-08 21:42                                             ` Greg Kroah-Hartman
     [not found]                                               ` <CANk1AXS9fpypVVWgvvUCZjKXDvLPpB7=kCNucwFcktgBHmV37w@mail.gmail.com>
     [not found]                                                 ` <20131009014027.GA17066@kroah.com>
     [not found]                                                   ` <5254EC8A.8060609@monstr.eu>
     [not found]                                                     ` <20131009055332.GA4510@kroah.com>
     [not found]                                                       ` <52550638.2080301@monstr.eu>
     [not found]                                                         ` <52556585.3050603@zytor.com>
     [not found]                                                           ` <20131009192439.GC18611@kroah.com>
     [not found]                                                             ` <5255BE71.8010801@zytor.com>
2013-10-09 21:07                                                               ` Jason Gunthorpe
2013-10-09 22:21                                                                 ` H. Peter Anvin
2013-10-05 17:33                             ` Jason Gunthorpe
2013-10-05  6:56                       ` Michal Simek
2013-10-04 23:50                     ` H. Peter Anvin
2013-10-05  6:49                       ` Michal Simek
2013-10-08 17:00                     ` Alan Tull
2013-10-08 21:44                       ` Greg Kroah-Hartman
2013-10-08 23:47                         ` delicious quinoa
2013-10-09  1:41                           ` Greg Kroah-Hartman
2013-10-04 18:26                 ` Alan Tull
2013-10-03 21:46 ` Alan Tull
2013-10-04 15:27   ` Michal Simek
2013-10-04 18:30     ` Alan Tull

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).