aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/platform_device.h
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-03-30 17:37:25 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-04-16 19:17:10 -0400
commit13977091a988fb0d21821c2221ddc920eba36b79 (patch)
tree9e077f6d22e351c3bab494d49d954d5e30deaa1b /include/linux/platform_device.h
parent31b07093c44a7a442394d44423e21d783f5523b8 (diff)
Driver Core: early platform driver
V3 of the early platform driver implementation. Platform drivers are great for embedded platforms because we can separate driver configuration from the actual driver. So base addresses, interrupts and other configuration can be kept with the processor or board code, and the platform driver can be reused by many different platforms. For early devices we have nothing today. For instance, to configure early timers and early serial ports we cannot use platform devices. This because the setup order during boot. Timers are needed before the platform driver core code is available. The same goes for early printk support. Early in this case means before initcalls. These early drivers today have their configuration either hard coded or they receive it using some special configuration method. This is working quite well, but if we want to support both regular kernel modules and early devices then we need to have two ways of configuring the same driver. A single way would be better. The early platform driver patch is basically a set of functions that allow drivers to register themselves and architecture code to locate them and probe. Registration happens through early_param(). The time for the probe is decided by the architecture code. See Documentation/driver-model/platform.txt for more details. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Magnus Damm <damm@igel.co.jp> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: David Brownell <david-b@pacbell.net> Cc: Tejun Heo <htejun@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/platform_device.h')
-rw-r--r--include/linux/platform_device.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 76e470a299bf..72736fd8223c 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -77,4 +77,46 @@ extern int platform_driver_probe(struct platform_driver *driver,
77#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) 77#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
78#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) 78#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data))
79 79
80/* early platform driver interface */
81struct early_platform_driver {
82 const char *class_str;
83 struct platform_driver *pdrv;
84 struct list_head list;
85 int requested_id;
86};
87
88#define EARLY_PLATFORM_ID_UNSET -2
89#define EARLY_PLATFORM_ID_ERROR -3
90
91extern int early_platform_driver_register(struct early_platform_driver *epdrv,
92 char *buf);
93extern void early_platform_add_devices(struct platform_device **devs, int num);
94
95static inline int is_early_platform_device(struct platform_device *pdev)
96{
97 return !pdev->dev.driver;
98}
99
100extern void early_platform_driver_register_all(char *class_str);
101extern int early_platform_driver_probe(char *class_str,
102 int nr_probe, int user_only);
103extern void early_platform_cleanup(void);
104
105
106#ifndef MODULE
107#define early_platform_init(class_string, platform_driver) \
108static __initdata struct early_platform_driver early_driver = { \
109 .class_str = class_string, \
110 .pdrv = platform_driver, \
111 .requested_id = EARLY_PLATFORM_ID_UNSET, \
112}; \
113static int __init early_platform_driver_setup_func(char *buf) \
114{ \
115 return early_platform_driver_register(&early_driver, buf); \
116} \
117early_param(class_string, early_platform_driver_setup_func)
118#else /* MODULE */
119#define early_platform_init(class_string, platform_driver)
120#endif /* MODULE */
121
80#endif /* _PLATFORM_DEVICE_H_ */ 122#endif /* _PLATFORM_DEVICE_H_ */