• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX--License-Identifier: GPL-2.0 */
2 
3 #ifndef __PLATFORM_EARLY__
4 #define __PLATFORM_EARLY__
5 
6 #include <linux/types.h>
7 #include <linux/platform_device.h>
8 #include <linux/pm_runtime.h>
9 #include <linux/slab.h>
10 
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;
18 };
19 
20 #define EARLY_PLATFORM_ID_UNSET -2
21 #define EARLY_PLATFORM_ID_ERROR -3
22 
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);
26 
is_sh_early_platform_device(struct platform_device * pdev)27 static inline int is_sh_early_platform_device(struct platform_device *pdev)
28 {
29 	return !pdev->dev.driver;
30 }
31 
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);
35 
36 #define sh_early_platform_init(class_string, platdrv)		\
37 	sh_early_platform_init_buffer(class_string, platdrv, NULL, 0)
38 
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;					\
58 }
59 #endif /* MODULE */
60 
61 #endif /* __PLATFORM_EARLY__ */
62