2019-10-03 17:29:12 +08:00
|
|
|
/* SPDX--License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#ifndef __PLATFORM_EARLY__
|
|
|
|
#define __PLATFORM_EARLY__
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/pm_runtime.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2019-10-03 17:29:13 +08:00
|
|
|
struct sh_early_platform_driver {
|
2019-10-03 17:29:12 +08:00
|
|
|
const char *class_str;
|
|
|
|
struct platform_driver *pdrv;
|
|
|
|
struct list_head list;
|
|
|
|
int requested_id;
|
|
|
|
char *buffer;
|
|
|
|
int bufsize;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define EARLY_PLATFORM_ID_UNSET -2
|
|
|
|
#define EARLY_PLATFORM_ID_ERROR -3
|
|
|
|
|
2019-10-03 17:29:13 +08:00
|
|
|
extern int sh_early_platform_driver_register(struct sh_early_platform_driver *epdrv,
|
2019-10-03 17:29:12 +08:00
|
|
|
char *buf);
|
2019-10-03 17:29:13 +08:00
|
|
|
extern void sh_early_platform_add_devices(struct platform_device **devs, int num);
|
2019-10-03 17:29:12 +08:00
|
|
|
|
2019-10-03 17:29:13 +08:00
|
|
|
static inline int is_sh_early_platform_device(struct platform_device *pdev)
|
2019-10-03 17:29:12 +08:00
|
|
|
{
|
|
|
|
return !pdev->dev.driver;
|
|
|
|
}
|
|
|
|
|
2019-10-03 17:29:13 +08:00
|
|
|
extern void sh_early_platform_driver_register_all(char *class_str);
|
|
|
|
extern int sh_early_platform_driver_probe(char *class_str,
|
2019-10-03 17:29:12 +08:00
|
|
|
int nr_probe, int user_only);
|
|
|
|
|
2019-10-03 17:29:13 +08:00
|
|
|
#define sh_early_platform_init(class_string, platdrv) \
|
|
|
|
sh_early_platform_init_buffer(class_string, platdrv, NULL, 0)
|
2019-10-03 17:29:12 +08:00
|
|
|
|
|
|
|
#ifndef MODULE
|
2019-10-03 17:29:13 +08:00
|
|
|
#define sh_early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
|
|
|
|
static __initdata struct sh_early_platform_driver early_driver = { \
|
2019-10-03 17:29:12 +08:00
|
|
|
.class_str = class_string, \
|
|
|
|
.buffer = buf, \
|
|
|
|
.bufsize = bufsiz, \
|
|
|
|
.pdrv = platdrv, \
|
|
|
|
.requested_id = EARLY_PLATFORM_ID_UNSET, \
|
|
|
|
}; \
|
2019-10-03 17:29:13 +08:00
|
|
|
static int __init sh_early_platform_driver_setup_func(char *buffer) \
|
2019-10-03 17:29:12 +08:00
|
|
|
{ \
|
2019-10-03 17:29:13 +08:00
|
|
|
return sh_early_platform_driver_register(&early_driver, buffer); \
|
2019-10-03 17:29:12 +08:00
|
|
|
} \
|
2019-10-03 17:29:13 +08:00
|
|
|
early_param(class_string, sh_early_platform_driver_setup_func)
|
2019-10-03 17:29:12 +08:00
|
|
|
#else /* MODULE */
|
2019-10-03 17:29:13 +08:00
|
|
|
#define sh_early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
|
|
|
|
static inline char *sh_early_platform_driver_setup_func(void) \
|
2019-10-03 17:29:12 +08:00
|
|
|
{ \
|
|
|
|
return bufsiz ? buf : NULL; \
|
|
|
|
}
|
|
|
|
#endif /* MODULE */
|
|
|
|
|
|
|
|
#endif /* __PLATFORM_EARLY__ */
|