new file mode 100644
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "utils/file.h"
+#include "reg/reg_access.h"
+#include <linux/firmware.h>
+#include <linux/fs.h>
+#include <linux/vmalloc.h>
+
+size_t cl_file_open_and_read(struct cl_chip *chip, const char *filename,
+ char **buf)
+{
+ const struct firmware *fw;
+ size_t size = 0;
+ int ret = 0;
+ char path_name[CL_PATH_MAX] = {0};
+
+ snprintf(path_name, sizeof(path_name), "cl8k/%s", filename);
+ ret = request_firmware(&fw, path_name, chip->dev);
+
+ if (ret) {
+ cl_dbg_chip_err(chip, "request_firmware %s failed\n",
+ path_name);
+ return 0;
+ }
+
+ if (!fw || !fw->data) {
+ cl_dbg_chip_err(chip, "Invalid firmware %s\n", path_name);
+ goto out;
+ }
+
+ size = fw->size;
+
+ /*
+ * Add one byte with a '\0' so that string manipulation functions
+ * used for parsing these files can find the string '\0' terminator.
+ * Make sure size is aligned to 4.
+ */
+ *buf = kzalloc(ALIGN(size + 1, 4), GFP_KERNEL);
+ if (!(*buf)) {
+ size = 0;
+ goto out;
+ }
+
+ memcpy(*buf, fw->data, size);
+
+out:
+ release_firmware(fw);
+
+ return size;
+}
+