Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 116 lines (97 sloc) 2.541 kB
e9983bb @makelinux +platform_device and small updates
authored
1 /*
2 * LDT - Linux Driver Template
9bef4eb @makelinux +checkpatch
authored
3 *
e9983bb @makelinux +platform_device and small updates
authored
4 * Copyright (C) 2012 Constantine Shulyupin http://www.makelinux.net/
5 *
6 * Dual BSD/GPL License
7 *
8 * platform_driver template driver
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
9 * Power Management (dev_pm_ops)
10 * Device Tree (of_device_id)
e9983bb @makelinux +platform_device and small updates
authored
11 *
12 */
13
14 #include <linux/module.h>
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
15 #include <linux/of.h>
e9983bb @makelinux +platform_device and small updates
authored
16 #include <linux/platform_device.h>
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
17 #include <linux/of_platform.h>
18 #include <linux/mod_devicetable.h>
19 #include <linux/of_irq.h>
2f32335 @makelinux tracing.h instead of ctracer.h
authored
20 #include "tracing.h"
e9983bb @makelinux +platform_device and small updates
authored
21
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
22 static int irq;
23 static int port;
24 static int port_size;
25
76366fc @makelinux minor
authored
26 static __devinit int ldt_plat_probe(struct platform_device *pdev)
e9983bb @makelinux +platform_device and small updates
authored
27 {
28 char *data = NULL;
29 struct resource *r;
30 _entry:
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
31 dev_dbg(&pdev->dev, "%s\n", __func__);
e9983bb @makelinux +platform_device and small updates
authored
32 data = pdev->dev.platform_data;
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
33 irq = platform_get_irq(pdev, 0);
e9983bb @makelinux +platform_device and small updates
authored
34 r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
35 pr_debug("%s: pdev->dev.of_node = %p\n", __func__, pdev->dev.of_node);
36 #ifdef CONFIG_OF_DEVICE
37 if (pdev->dev.of_node) {
38 const __be32 * p;
39 int property;
40 of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
41 irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
42 p = of_get_property(pdev->dev.of_node, "property", NULL);
43 if (p)
44 property = be32_to_cpu(*p);
45 }
46 #endif
47 //struct ldt_data *drvdata = platform_get_drvdata(pdev);
48 //platform_set_drvdata(pdev, drvdata);
49
50 data = dev_get_platdata(&pdev->dev);
51 pr_debug("%p %s\n", data, data);
52 r = platform_get_resource(pdev, IORESOURCE_IO, 0);
53 port = r->start;
54 port_size = resource_size(r);
55
e9983bb @makelinux +platform_device and small updates
authored
56 return 0;
57 }
58
76366fc @makelinux minor
authored
59 static int __devexit ldt_plat_remove(struct platform_device *pdev)
e9983bb @makelinux +platform_device and small updates
authored
60 {
61 _entry:
62 return 0;
63 }
64
65 /*
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
66 * template for OF FDT ID
67 * (Open Firmware Flat Device Tree)
e9983bb @makelinux +platform_device and small updates
authored
68 */
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
69
70 static const struct of_device_id ldt_of_match[] = {
71 {.compatible = "linux-driver-template",},
72 {},
73 };
74
75 MODULE_DEVICE_TABLE(of, ldt_of_match);
76
77 #ifdef CONFIG_PM
78
79 static int ldt_suspend(struct device *dev)
e9983bb @makelinux +platform_device and small updates
authored
80 {
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
81 return 0;
e9983bb @makelinux +platform_device and small updates
authored
82 }
83
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
84 static int ldt_resume(struct device *dev)
e9983bb @makelinux +platform_device and small updates
authored
85 {
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
86 return 0;
e9983bb @makelinux +platform_device and small updates
authored
87 }
88
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
89 static const struct dev_pm_ops ldt_pm = {
90 .suspend = ldt_suspend,
91 .resume = ldt_resume,
92 };
93
94 #define ldt_pm_ops (&ldt_pm)
95 #else
96 #define ldt_pm_ops NULL
e9983bb @makelinux +platform_device and small updates
authored
97 #endif
98
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
99 static struct platform_driver ldt_plat_driver = {
100 .driver = {
101 .name = "ldt_device_name",
102 .owner = THIS_MODULE,
103 .pm = ldt_pm_ops,
104 .of_match_table = of_match_ptr(ldt_of_match),
105 },
106 .probe = ldt_plat_probe,
107 .remove = __devexit_p(ldt_plat_remove),
108
109 };
110
111 module_platform_driver(ldt_plat_driver);
112
e9983bb @makelinux +platform_device and small updates
authored
113 MODULE_DESCRIPTION("LDT - Linux Driver Template: platform_driver template");
114 MODULE_AUTHOR("Constantine Shulyupin <const@makelinux.net>");
115 MODULE_LICENSE("Dual BSD/GPL");
Something went wrong with that request. Please try again.