]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
fpga: fpga-mgr: Add firmware store function
authorMichal Simek <michal.simek@xilinx.com>
Wed, 27 Jul 2016 08:06:40 +0000 (10:06 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 1 Apr 2019 10:48:13 +0000 (12:48 +0200)
For testing purpose.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Acked-by: Nava kishore Manne <navam@xilinx.com>
drivers/fpga/fpga-mgr.c
include/linux/fpga/fpga-mgr.h

index a41b07e3788490ef3904b6429cea7bfce4c7e46b..087ab85d40ca485c22e6e086983f8c59fbd14494 100644 (file)
@@ -406,6 +406,34 @@ static ssize_t state_show(struct device *dev,
        return sprintf(buf, "%s\n", state_str[mgr->state]);
 }
 
+static ssize_t firmware_store(struct device *dev,
+                             struct device_attribute *attr,
+                             const char *buf, size_t count)
+{
+       struct fpga_manager *mgr = to_fpga_manager(dev);
+       unsigned int len;
+       char image_name[NAME_MAX];
+       int ret;
+
+       /* struct with information about the FPGA image to program. */
+       struct fpga_image_info info = {0};
+
+       /* flags indicates whether to do full or partial reconfiguration */
+       info.flags = mgr->flags;
+
+       /* lose terminating \n */
+       strcpy(image_name, buf);
+       len = strlen(image_name);
+       if (image_name[len - 1] == '\n')
+               image_name[len - 1] = 0;
+
+       ret = fpga_mgr_firmware_load(mgr, &info, image_name);
+       if (ret)
+               return ret;
+
+       return count;
+}
+
 static ssize_t status_show(struct device *dev,
                           struct device_attribute *attr, char *buf)
 {
@@ -434,11 +462,13 @@ static ssize_t status_show(struct device *dev,
 
 static DEVICE_ATTR_RO(name);
 static DEVICE_ATTR_RO(state);
+static DEVICE_ATTR_WO(firmware);
 static DEVICE_ATTR_RO(status);
 
 static struct attribute *fpga_mgr_attrs[] = {
        &dev_attr_name.attr,
        &dev_attr_state.attr,
+       &dev_attr_firmware.attr,
        &dev_attr_status.attr,
        NULL,
 };
index 8ab5df76992395276bf35ea4ee7437ef5a00cf3a..fb5201e258a661c6e7122237279d26863e4e92a0 100644 (file)
@@ -157,6 +157,7 @@ struct fpga_compat_id {
 /**
  * struct fpga_manager - fpga manager structure
  * @name: name of low level fpga manager
+ * @flags: flags determines the type of Bitstream
  * @dev: fpga manager device
  * @ref_mutex: only allows one reference to fpga manager
  * @state: state of fpga manager
@@ -166,6 +167,7 @@ struct fpga_compat_id {
  */
 struct fpga_manager {
        const char *name;
+       long int flags;
        struct device dev;
        struct mutex ref_mutex;
        enum fpga_mgr_states state;