2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifndef _LINUX_FIRMWARE_H
|
|
|
|
|
#define _LINUX_FIRMWARE_H
|
2008-05-23 13:52:42 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/types.h>
|
2008-05-23 13:52:42 +01:00
|
|
|
#include <linux/compiler.h>
|
2009-10-29 12:36:02 +01:00
|
|
|
#include <linux/gfp.h>
|
2008-05-23 13:52:42 +01:00
|
|
|
|
2021-04-25 10:00:24 +08:00
|
|
|
#define FW_ACTION_NOUEVENT 0
|
|
|
|
|
#define FW_ACTION_UEVENT 1
|
2005-09-06 15:17:13 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct firmware {
|
|
|
|
|
size_t size;
|
2008-05-23 18:38:49 +01:00
|
|
|
const u8 *data;
|
2012-08-04 12:01:21 +08:00
|
|
|
|
|
|
|
|
/* firmware loader private fields */
|
|
|
|
|
void *priv;
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
2008-03-07 08:57:54 -06:00
|
|
|
|
2011-05-26 13:46:22 -04:00
|
|
|
struct module;
|
2005-04-16 15:20:36 -07:00
|
|
|
struct device;
|
2008-03-07 08:57:54 -06:00
|
|
|
|
2021-10-21 08:58:34 -07:00
|
|
|
/*
|
|
|
|
|
* Built-in firmware functionality is only available if FW_LOADER=y, but not
|
|
|
|
|
* FW_LOADER=m
|
|
|
|
|
*/
|
|
|
|
|
#ifdef CONFIG_FW_LOADER
|
|
|
|
|
bool firmware_request_builtin(struct firmware *fw, const char *name);
|
|
|
|
|
#else
|
|
|
|
|
static inline bool firmware_request_builtin(struct firmware *fw,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-12 08:00:53 -08:00
|
|
|
#if IS_REACHABLE(CONFIG_FW_LOADER)
|
2005-04-16 15:20:36 -07:00
|
|
|
int request_firmware(const struct firmware **fw, const char *name,
|
|
|
|
|
struct device *device);
|
2018-05-10 13:08:45 -07:00
|
|
|
int firmware_request_nowarn(const struct firmware **fw, const char *name,
|
|
|
|
|
struct device *device);
|
2020-01-15 17:35:48 +01:00
|
|
|
int firmware_request_platform(const struct firmware **fw, const char *name,
|
|
|
|
|
struct device *device);
|
2005-04-16 15:20:36 -07:00
|
|
|
int request_firmware_nowait(
|
2011-01-26 18:33:32 +08:00
|
|
|
struct module *module, bool uevent,
|
2009-10-29 12:36:02 +01:00
|
|
|
const char *name, struct device *device, gfp_t gfp, void *context,
|
2005-04-16 15:20:36 -07:00
|
|
|
void (*cont)(const struct firmware *fw, void *context));
|
2014-07-02 09:55:05 -07:00
|
|
|
int request_firmware_direct(const struct firmware **fw, const char *name,
|
|
|
|
|
struct device *device);
|
2016-08-02 14:04:28 -07:00
|
|
|
int request_firmware_into_buf(const struct firmware **firmware_p,
|
|
|
|
|
const char *name, struct device *device, void *buf, size_t size);
|
2020-10-02 10:38:27 -07:00
|
|
|
int request_partial_firmware_into_buf(const struct firmware **firmware_p,
|
|
|
|
|
const char *name, struct device *device,
|
|
|
|
|
void *buf, size_t size, size_t offset);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
void release_firmware(const struct firmware *fw);
|
2008-03-07 08:57:54 -06:00
|
|
|
#else
|
|
|
|
|
static inline int request_firmware(const struct firmware **fw,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct device *device)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
2018-05-10 13:08:45 -07:00
|
|
|
|
|
|
|
|
static inline int firmware_request_nowarn(const struct firmware **fw,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct device *device)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-15 17:35:48 +01:00
|
|
|
static inline int firmware_request_platform(const struct firmware **fw,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct device *device)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-07 08:57:54 -06:00
|
|
|
static inline int request_firmware_nowait(
|
2011-01-26 18:33:32 +08:00
|
|
|
struct module *module, bool uevent,
|
2009-10-29 12:36:02 +01:00
|
|
|
const char *name, struct device *device, gfp_t gfp, void *context,
|
2008-03-07 08:57:54 -06:00
|
|
|
void (*cont)(const struct firmware *fw, void *context))
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void release_firmware(const struct firmware *fw)
|
|
|
|
|
{
|
|
|
|
|
}
|
2012-08-04 12:01:22 +08:00
|
|
|
|
2014-07-02 09:55:05 -07:00
|
|
|
static inline int request_firmware_direct(const struct firmware **fw,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct device *device)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
2013-12-02 15:38:16 +01:00
|
|
|
|
2016-08-02 14:04:28 -07:00
|
|
|
static inline int request_firmware_into_buf(const struct firmware **firmware_p,
|
|
|
|
|
const char *name, struct device *device, void *buf, size_t size)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 10:38:27 -07:00
|
|
|
static inline int request_partial_firmware_into_buf
|
|
|
|
|
(const struct firmware **firmware_p,
|
|
|
|
|
const char *name,
|
|
|
|
|
struct device *device,
|
|
|
|
|
void *buf, size_t size, size_t offset)
|
|
|
|
|
{
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|
2018-03-21 15:34:29 -07:00
|
|
|
|
|
|
|
|
int firmware_request_cache(struct device *device, const char *name);
|
|
|
|
|
|
2014-07-02 09:55:05 -07:00
|
|
|
#endif
|