Linux 6.13-rc4
[linux.git] / arch / sh / include / asm / platform_early.h
blobfc802137c37d4378664477b1e3894aa6d70710cc
1 /* SPDX--License-Identifier: GPL-2.0 */
3 #ifndef __PLATFORM_EARLY__
4 #define __PLATFORM_EARLY__
6 #include <linux/types.h>
7 #include <linux/platform_device.h>
8 #include <linux/pm_runtime.h>
9 #include <linux/slab.h>
11 struct sh_early_platform_driver {
12 const char *class_str;
13 struct platform_driver *pdrv;
14 struct list_head list;
15 int requested_id;
16 char *buffer;
17 int bufsize;
20 #define EARLY_PLATFORM_ID_UNSET -2
21 #define EARLY_PLATFORM_ID_ERROR -3
23 extern int sh_early_platform_driver_register(struct sh_early_platform_driver *epdrv,
24 char *buf);
25 extern void sh_early_platform_add_devices(struct platform_device **devs, int num);
27 static inline int is_sh_early_platform_device(struct platform_device *pdev)
29 return !pdev->dev.driver;
32 extern void sh_early_platform_driver_register_all(char *class_str);
33 extern int sh_early_platform_driver_probe(char *class_str,
34 int nr_probe, int user_only);
36 #define sh_early_platform_init(class_string, platdrv) \
37 sh_early_platform_init_buffer(class_string, platdrv, NULL, 0)
39 #ifndef MODULE
40 #define sh_early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
41 static __initdata struct sh_early_platform_driver early_driver = { \
42 .class_str = class_string, \
43 .buffer = buf, \
44 .bufsize = bufsiz, \
45 .pdrv = platdrv, \
46 .requested_id = EARLY_PLATFORM_ID_UNSET, \
47 }; \
48 static int __init sh_early_platform_driver_setup_func(char *buffer) \
49 { \
50 return sh_early_platform_driver_register(&early_driver, buffer); \
51 } \
52 early_param(class_string, sh_early_platform_driver_setup_func)
53 #else /* MODULE */
54 #define sh_early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
55 static inline char *sh_early_platform_driver_setup_func(void) \
56 { \
57 return bufsiz ? buf : NULL; \
59 #endif /* MODULE */
61 #endif /* __PLATFORM_EARLY__ */