diff options
Diffstat (limited to 'arch/arm/mach-integrator/lm.c')
-rw-r--r-- | arch/arm/mach-integrator/lm.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/arch/arm/mach-integrator/lm.c b/arch/arm/mach-integrator/lm.c new file mode 100644 index 000000000000..c5f19d160598 --- /dev/null +++ b/arch/arm/mach-integrator/lm.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-integrator/lm.c | ||
3 | * | ||
4 | * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/device.h> | ||
13 | |||
14 | #include <asm/arch/lm.h> | ||
15 | |||
16 | #define to_lm_device(d) container_of(d, struct lm_device, dev) | ||
17 | #define to_lm_driver(d) container_of(d, struct lm_driver, drv) | ||
18 | |||
19 | static int lm_match(struct device *dev, struct device_driver *drv) | ||
20 | { | ||
21 | return 1; | ||
22 | } | ||
23 | |||
24 | static struct bus_type lm_bustype = { | ||
25 | .name = "logicmodule", | ||
26 | .match = lm_match, | ||
27 | // .suspend = lm_suspend, | ||
28 | // .resume = lm_resume, | ||
29 | }; | ||
30 | |||
31 | static int __init lm_init(void) | ||
32 | { | ||
33 | return bus_register(&lm_bustype); | ||
34 | } | ||
35 | |||
36 | postcore_initcall(lm_init); | ||
37 | |||
38 | static int lm_bus_probe(struct device *dev) | ||
39 | { | ||
40 | struct lm_device *lmdev = to_lm_device(dev); | ||
41 | struct lm_driver *lmdrv = to_lm_driver(dev->driver); | ||
42 | |||
43 | return lmdrv->probe(lmdev); | ||
44 | } | ||
45 | |||
46 | static int lm_bus_remove(struct device *dev) | ||
47 | { | ||
48 | struct lm_device *lmdev = to_lm_device(dev); | ||
49 | struct lm_driver *lmdrv = to_lm_driver(dev->driver); | ||
50 | |||
51 | lmdrv->remove(lmdev); | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | int lm_driver_register(struct lm_driver *drv) | ||
56 | { | ||
57 | drv->drv.bus = &lm_bustype; | ||
58 | drv->drv.probe = lm_bus_probe; | ||
59 | drv->drv.remove = lm_bus_remove; | ||
60 | |||
61 | return driver_register(&drv->drv); | ||
62 | } | ||
63 | |||
64 | void lm_driver_unregister(struct lm_driver *drv) | ||
65 | { | ||
66 | driver_unregister(&drv->drv); | ||
67 | } | ||
68 | |||
69 | static void lm_device_release(struct device *dev) | ||
70 | { | ||
71 | struct lm_device *d = to_lm_device(dev); | ||
72 | |||
73 | kfree(d); | ||
74 | } | ||
75 | |||
76 | int lm_device_register(struct lm_device *dev) | ||
77 | { | ||
78 | int ret; | ||
79 | |||
80 | dev->dev.release = lm_device_release; | ||
81 | dev->dev.bus = &lm_bustype; | ||
82 | |||
83 | snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id); | ||
84 | dev->resource.name = dev->dev.bus_id; | ||
85 | |||
86 | ret = request_resource(&iomem_resource, &dev->resource); | ||
87 | if (ret == 0) { | ||
88 | ret = device_register(&dev->dev); | ||
89 | if (ret) | ||
90 | release_resource(&dev->resource); | ||
91 | } | ||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | EXPORT_SYMBOL(lm_driver_register); | ||
96 | EXPORT_SYMBOL(lm_driver_unregister); | ||