summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-07-18 07:13:02 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-07-18 07:13:02 +0200
commit8a5144d02a0146c4f0ec577232c0a102d12c8ee7 (patch)
tree85b0459bb60bfaa2a765e21bb7e19a0edc6c2d6a /include
parent2551aad17a15fe06ae3b76b12b5df2207c1e11f6 (diff)
parent368deb2baa56a6ab0f4ec7d7a42559c4db14b063 (diff)
downloadbarebox-8a5144d02a0146c4f0ec577232c0a102d12c8ee7.tar.gz
Merge branch 'for-next/firmware'
Diffstat (limited to 'include')
-rw-r--r--include/filetype.h14
-rw-r--r--include/firmware.h27
-rw-r--r--include/fpga-bridge.h74
-rw-r--r--include/fpga-mgr.h102
-rw-r--r--include/libbb.h4
-rw-r--r--include/libfile.h1
-rw-r--r--include/linux/reset.h2
-rw-r--r--include/of.h43
8 files changed, 254 insertions, 13 deletions
diff --git a/include/filetype.h b/include/filetype.h
index fd339f9564..ae0920320e 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -70,6 +70,20 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec)
int is_fat_boot_sector(const void *_buf);
bool filetype_is_barebox_image(enum filetype ft);
+static inline bool file_is_compressed_file(enum filetype ft)
+{
+ switch (ft) {
+ case filetype_lzo_compressed:
+ case filetype_lz4_compressed:
+ case filetype_gzip:
+ case filetype_bzip2:
+ case filetype_xz_compressed:
+ return true;
+ default:
+ return false;
+ }
+}
+
#define ARM_HEAD_SIZE 0x30
#define ARM_HEAD_MAGICWORD_OFFSET 0x20
#define ARM_HEAD_SIZE_OFFSET 0x2C
diff --git a/include/firmware.h b/include/firmware.h
index 19777d9bf7..0ffea52840 100644
--- a/include/firmware.h
+++ b/include/firmware.h
@@ -13,6 +13,8 @@ struct firmware_handler {
char *id; /* unique identifier for this firmware device */
char *model; /* description for this device */
struct device_d *dev;
+ void *priv;
+ struct device_node *device_node;
/* called once to prepare the firmware's programming cycle */
int (*open)(struct firmware_handler*);
/* called multiple times to program the firmware with the given data */
@@ -27,25 +29,34 @@ int firmwaremgr_register(struct firmware_handler *);
struct firmware_mgr *firmwaremgr_find(const char *);
#ifdef CONFIG_FIRMWARE
-struct firmware_mgr *firmwaremgr_find_by_node(const struct device_node *np);
+struct firmware_mgr *firmwaremgr_find_by_node(struct device_node *np);
+int firmwaremgr_load_file(struct firmware_mgr *, const char *path);
+const char *firmware_get_searchpath(void);
+void firmware_set_searchpath(const char *path);
#else
-static inline struct firmware_mgr *firmwaremgr_find_by_node(const struct device_node *np)
+static inline struct firmware_mgr *firmwaremgr_find_by_node(struct device_node *np)
{
return NULL;
}
-#endif
-void firmwaremgr_list_handlers(void);
-
-#ifdef CONFIG_FIRMWARE
-int firmwaremgr_load_file(struct firmware_mgr *, const char *path);
-#else
static inline int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *path)
{
return -ENOSYS;
}
+
+static inline const char *firmware_get_searchpath(void)
+{
+ return NULL;
+}
+
+static inline void firmware_set_searchpath(const char *path)
+{
+}
+
#endif
+void firmwaremgr_list_handlers(void);
+
#define get_builtin_firmware(name, start, size) \
{ \
extern char _fw_##name##_start[]; \
diff --git a/include/fpga-bridge.h b/include/fpga-bridge.h
new file mode 100644
index 0000000000..fef2a9ccbb
--- /dev/null
+++ b/include/fpga-bridge.h
@@ -0,0 +1,74 @@
+#include <common.h>
+
+#ifndef _LINUX_FPGA_BRIDGE_H
+#define _LINUX_FPGA_BRIDGE_H
+
+struct fpga_bridge;
+
+/**
+ * struct fpga_bridge_ops - ops for low level FPGA bridge drivers
+ * @enable_show: returns the FPGA bridge's status
+ * @enable_set: set a FPGA bridge as enabled or disabled
+ * @fpga_bridge_remove: set FPGA into a specific state during driver remove
+ */
+struct fpga_bridge_ops {
+ int (*enable_show)(struct fpga_bridge *bridge);
+ int (*enable_set)(struct fpga_bridge *bridge, bool enable);
+ void (*fpga_bridge_remove)(struct fpga_bridge *bridge);
+};
+
+/**
+ * struct fpga_bridge - FPGA bridge structure
+ * @name: name of low level FPGA bridge
+ * @dev: FPGA bridge device
+ * @mutex: enforces exclusive reference to bridge
+ * @br_ops: pointer to struct of FPGA bridge ops
+ * @info: fpga image specific information
+ * @node: FPGA bridge list node
+ * @priv: low level driver private date
+ */
+struct fpga_bridge {
+ struct device_d dev;
+ const struct fpga_bridge_ops *br_ops;
+ struct list_head node;
+ unsigned int enable;
+ void *priv;
+};
+
+#define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev)
+
+struct fpga_bridge *of_fpga_bridge_get(struct device_node *node);
+void fpga_bridge_put(struct fpga_bridge *bridge);
+int fpga_bridge_enable(struct fpga_bridge *bridge);
+int fpga_bridge_disable(struct fpga_bridge *bridge);
+
+#ifdef CONFIG_FPGA_BRIDGE
+int fpga_bridges_enable(struct list_head *bridge_list);
+int fpga_bridges_disable(struct list_head *bridge_list);
+int fpga_bridge_get_to_list(struct device_node *np,
+ struct list_head *bridge_list);
+void fpga_bridges_put(struct list_head *bridge_list);
+#else
+static inline int fpga_bridges_enable(struct list_head *bridge_list)
+{
+ return -ENOSYS;
+};
+static inline int fpga_bridges_disable(struct list_head *bridge_list)
+{
+ return -ENOSYS;
+};
+static inline int fpga_bridge_get_to_list(struct device_node *np,
+ struct list_head *bridge_list)
+{
+ return -ENOSYS;
+};
+static inline void fpga_bridges_put(struct list_head *bridge_list)
+{
+ return;
+};
+#endif
+
+int fpga_bridge_register(struct device_d *dev, const char *name,
+ const struct fpga_bridge_ops *br_ops, void *priv);
+
+#endif /* _LINUX_FPGA_BRIDGE_H */
diff --git a/include/fpga-mgr.h b/include/fpga-mgr.h
new file mode 100644
index 0000000000..a120b39189
--- /dev/null
+++ b/include/fpga-mgr.h
@@ -0,0 +1,102 @@
+/*
+ * FPGA Framework
+ *
+ * Copyright (C) 2013-2015 Altera Corporation
+ *
+ * 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 _LINUX_FPGA_MGR_H
+#define _LINUX_FPGA_MGR_H
+
+#include <firmware.h>
+
+struct fpga_manager;
+
+/**
+ * enum fpga_mgr_states - fpga framework states
+ * @FPGA_MGR_STATE_UNKNOWN: can't determine state
+ * @FPGA_MGR_STATE_POWER_OFF: FPGA power is off
+ * @FPGA_MGR_STATE_POWER_UP: FPGA reports power is up
+ * @FPGA_MGR_STATE_RESET: FPGA in reset state
+ * @FPGA_MGR_STATE_FIRMWARE_REQ: firmware request in progress
+ * @FPGA_MGR_STATE_FIRMWARE_REQ_ERR: firmware request failed
+ * @FPGA_MGR_STATE_WRITE_INIT: preparing FPGA for programming
+ * @FPGA_MGR_STATE_WRITE_INIT_ERR: Error during WRITE_INIT stage
+ * @FPGA_MGR_STATE_WRITE: writing image to FPGA
+ * @FPGA_MGR_STATE_WRITE_ERR: Error while writing FPGA
+ * @FPGA_MGR_STATE_WRITE_COMPLETE: Doing post programming steps
+ * @FPGA_MGR_STATE_WRITE_COMPLETE_ERR: Error during WRITE_COMPLETE
+ * @FPGA_MGR_STATE_OPERATING: FPGA is programmed and operating
+ */
+enum fpga_mgr_states {
+ /* default FPGA states */
+ FPGA_MGR_STATE_UNKNOWN,
+ FPGA_MGR_STATE_POWER_OFF,
+ FPGA_MGR_STATE_POWER_UP,
+ FPGA_MGR_STATE_RESET,
+
+ /* getting an image for loading */
+ FPGA_MGR_STATE_FIRMWARE_REQ,
+ FPGA_MGR_STATE_FIRMWARE_REQ_ERR,
+
+ /* write sequence: init, write, complete */
+ FPGA_MGR_STATE_WRITE_INIT,
+ FPGA_MGR_STATE_WRITE_INIT_ERR,
+ FPGA_MGR_STATE_WRITE,
+ FPGA_MGR_STATE_WRITE_ERR,
+ FPGA_MGR_STATE_WRITE_COMPLETE,
+ FPGA_MGR_STATE_WRITE_COMPLETE_ERR,
+
+ /* fpga is programmed and operating */
+ FPGA_MGR_STATE_OPERATING,
+};
+
+/*
+ * FPGA Manager flags
+ * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
+ * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
+ * FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
+ * FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed
+ */
+#define FPGA_MGR_PARTIAL_RECONFIG BIT(0)
+#define FPGA_MGR_EXTERNAL_CONFIG BIT(1)
+#define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2)
+#define FPGA_MGR_BITSTREAM_LSB_FIRST BIT(3)
+#define FPGA_MGR_COMPRESSED_BITSTREAM BIT(4)
+
+/**
+ * struct fpga_image_info - information specific to a FPGA image
+ * @flags: boolean flags as defined above
+ * @enable_timeout_us: maximum time to enable traffic through bridge (uSec)
+ * @disable_timeout_us: maximum time to disable traffic through bridge (uSec)
+ * @config_complete_timeout_us: maximum time for FPGA to switch to operating
+ * status in the write_complete op.
+ */
+struct fpga_image_info {
+ u32 flags;
+ u32 enable_timeout_us;
+ u32 disable_timeout_us;
+ u32 config_complete_timeout_us;
+};
+
+struct fpgamgr {
+ struct firmware_handler fh;
+ struct device_d dev;
+ void *priv;
+ void __iomem *regs;
+ void __iomem *regs_data;
+ int programmed;
+};
+
+
+#endif /*_LINUX_FPGA_MGR_H */
diff --git a/include/libbb.h b/include/libbb.h
index a3a13b41ce..e191874052 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -8,8 +8,10 @@
char *concat_path_file(const char *path, const char *filename);
char *concat_subpath_file(const char *path, const char *f);
-int execable_file(const char *name);
+bool execable_file(const char *name);
char *find_execable(const char *filename);
+char *find_path(const char *path, const char *filename,
+ bool (*filter)(const char *));
char* last_char_is(const char *s, int c);
enum {
diff --git a/include/libfile.h b/include/libfile.h
index 350ddddf70..3c2fe1714d 100644
--- a/include/libfile.h
+++ b/include/libfile.h
@@ -5,6 +5,7 @@
int pwrite_full(int fd, const void *buf, size_t size, loff_t offset);
int write_full(int fd, const void *buf, size_t size);
int read_full(int fd, void *buf, size_t size);
+int copy_fd(int in, int out);
char *read_file_line(const char *fmt, ...);
diff --git a/include/linux/reset.h b/include/linux/reset.h
index a166fe1cfe..726cb5c205 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -11,6 +11,8 @@ int reset_control_assert(struct reset_control *rstc);
int reset_control_deassert(struct reset_control *rstc);
struct reset_control *reset_control_get(struct device_d *dev, const char *id);
+struct reset_control *of_reset_control_get(struct device_node *node,
+ const char *id);
void reset_control_put(struct reset_control *rstc);
int __must_check device_reset(struct device_d *dev);
diff --git a/include/of.h b/include/of.h
index 880e380359..d82790c052 100644
--- a/include/of.h
+++ b/include/of.h
@@ -110,8 +110,8 @@ void of_print_properties(struct device_node *node);
void of_diff(struct device_node *a, struct device_node *b, int indent);
int of_probe(void);
int of_parse_dtb(struct fdt_header *fdt);
-struct device_node *of_unflatten_dtb(const void *fdt);
-struct device_node *of_unflatten_dtb_const(const void *infdt);
+struct device_node *of_unflatten_dtb(const void *fdt, int size);
+struct device_node *of_unflatten_dtb_const(const void *infdt, int size);
struct cdev;
@@ -163,6 +163,7 @@ extern struct device_node *of_create_node(struct device_node *root,
const char *path);
extern struct device_node *of_copy_node(struct device_node *parent,
const struct device_node *other);
+extern struct device_node *of_dup(const struct device_node *root);
extern void of_delete_node(struct device_node *node);
extern const char *of_get_machine_compatible(void);
@@ -1059,11 +1060,20 @@ static inline struct device_node *of_find_root_node(struct device_node *node)
return node;
}
+struct of_overlay_filter {
+ bool (*filter_filename)(struct of_overlay_filter *, const char *filename);
+ bool (*filter_content)(struct of_overlay_filter *, struct device_node *);
+ char *name;
+ struct list_head list;
+};
+
#ifdef CONFIG_OF_OVERLAY
struct device_node *of_resolve_phandles(struct device_node *root,
const struct device_node *overlay);
int of_overlay_apply_tree(struct device_node *root,
struct device_node *overlay);
+int of_overlay_apply_file(struct device_node *root, const char *filename,
+ bool filter);
int of_register_overlay(struct device_node *overlay);
int of_process_overlay(struct device_node *root,
struct device_node *overlay,
@@ -1071,7 +1081,11 @@ int of_process_overlay(struct device_node *root,
struct device_node *overlay, void *data),
void *data);
-int of_firmware_load_overlay(struct device_node *overlay, const char *path);
+int of_overlay_pre_load_firmware(struct device_node *root, struct device_node *overlay);
+int of_overlay_load_firmware(void);
+void of_overlay_load_firmware_clear(void);
+void of_overlay_set_basedir(const char *path);
+int of_overlay_register_filter(struct of_overlay_filter *);
#else
static inline struct device_node *of_resolve_phandles(struct device_node *root,
const struct device_node *overlay)
@@ -1085,6 +1099,12 @@ static inline int of_overlay_apply_tree(struct device_node *root,
return -ENOSYS;
}
+static inline int of_overlay_apply_file(struct device_node *root,
+ const char *filename, bool filter)
+{
+ return -ENOSYS;
+}
+
static inline int of_register_overlay(struct device_node *overlay)
{
return -ENOSYS;
@@ -1099,10 +1119,25 @@ static inline int of_process_overlay(struct device_node *root,
return -ENOSYS;
}
-static inline int of_firmware_load_overlay(struct device_node *overlay, const char *path)
+static inline int of_overlay_pre_load_firmware(struct device_node *root,
+ struct device_node *overlay)
{
return -ENOSYS;
}
+
+static inline int of_overlay_load_firmware(void)
+{
+ return 0;
+}
+
+static inline void of_overlay_load_firmware_clear(void)
+{
+}
+
+static inline void of_overlay_set_basedir(const char *path)
+{
+}
+
#endif
#endif /* __OF_H */