Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 130 lines (107 sloc) 2.751 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>
8d3246d @NNemec linux 3.8 compatibility fixes
NNemec authored
20
21 #include "common.h"
2f32335 @makelinux tracing.h instead of ctracer.h
authored
22 #include "tracing.h"
e9983bb @makelinux +platform_device and small updates
authored
23
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
24 static int irq;
25 static int port;
26 static int port_size;
27
76366fc @makelinux minor
authored
28 static __devinit int ldt_plat_probe(struct platform_device *pdev)
e9983bb @makelinux +platform_device and small updates
authored
29 {
30 char *data = NULL;
31 struct resource *r;
c74ec32 @makelinux updates
authored
32 struct device *dev = &pdev->dev;
33
e9983bb @makelinux +platform_device and small updates
authored
34 _entry:
c74ec32 @makelinux updates
authored
35 dev_dbg(dev, "probe\n");
36 data = pdev->dev.platform_data;
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
37 irq = platform_get_irq(pdev, 0);
e9983bb @makelinux +platform_device and small updates
authored
38 r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
c74ec32 @makelinux updates
authored
39 pr_debug("pdev->dev.of_node = %p\n", pdev->dev.of_node);
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
40 #ifdef CONFIG_OF_DEVICE
41 if (pdev->dev.of_node) {
7f4c97e @makelinux checkpatch and cgcc fixes
authored
42 const __be32 *p;
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
43 int property;
44 of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
45 irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
46 p = of_get_property(pdev->dev.of_node, "property", NULL);
47 if (p)
48 property = be32_to_cpu(*p);
49 }
50 #endif
15b2603 @makelinux +misc_drv.c fixes, +pr_fmt, removed timer
authored
51 /*
52 sample code for drvdata usage:
53 struct ldt_data *drvdata = platform_get_drvdata(pdev);
54 platform_set_drvdata(pdev, drvdata);
55 */
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
56
57 data = dev_get_platdata(&pdev->dev);
58 pr_debug("%p %s\n", data, data);
59 r = platform_get_resource(pdev, IORESOURCE_IO, 0);
60 port = r->start;
61 port_size = resource_size(r);
c74ec32 @makelinux updates
authored
62 /*
63 devm_kzalloc
64
65 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
66 r = devm_request_and_ioremap(&pdev->dev, res);
67
68 */
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
69
e9983bb @makelinux +platform_device and small updates
authored
70 return 0;
71 }
72
76366fc @makelinux minor
authored
73 static int __devexit ldt_plat_remove(struct platform_device *pdev)
e9983bb @makelinux +platform_device and small updates
authored
74 {
75 _entry:
76 return 0;
77 }
78
79 /*
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
80 * template for OF FDT ID
81 * (Open Firmware Flat Device Tree)
e9983bb @makelinux +platform_device and small updates
authored
82 */
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
83
84 static const struct of_device_id ldt_of_match[] = {
85 {.compatible = "linux-driver-template",},
86 {},
87 };
88
89 MODULE_DEVICE_TABLE(of, ldt_of_match);
90
91 #ifdef CONFIG_PM
92
93 static int ldt_suspend(struct device *dev)
e9983bb @makelinux +platform_device and small updates
authored
94 {
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
95 return 0;
e9983bb @makelinux +platform_device and small updates
authored
96 }
97
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
98 static int ldt_resume(struct device *dev)
e9983bb @makelinux +platform_device and small updates
authored
99 {
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
100 return 0;
e9983bb @makelinux +platform_device and small updates
authored
101 }
102
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
103 static const struct dev_pm_ops ldt_pm = {
104 .suspend = ldt_suspend,
105 .resume = ldt_resume,
106 };
107
108 #define ldt_pm_ops (&ldt_pm)
109 #else
110 #define ldt_pm_ops NULL
e9983bb @makelinux +platform_device and small updates
authored
111 #endif
112
7c7c6c6 @makelinux ldt.c simplified: removed work, ioctl
authored
113 static struct platform_driver ldt_plat_driver = {
114 .driver = {
115 .name = "ldt_device_name",
116 .owner = THIS_MODULE,
117 .pm = ldt_pm_ops,
118 .of_match_table = of_match_ptr(ldt_of_match),
119 },
120 .probe = ldt_plat_probe,
121 .remove = __devexit_p(ldt_plat_remove),
122
123 };
124
125 module_platform_driver(ldt_plat_driver);
126
e9983bb @makelinux +platform_device and small updates
authored
127 MODULE_DESCRIPTION("LDT - Linux Driver Template: platform_driver template");
128 MODULE_AUTHOR("Constantine Shulyupin <const@makelinux.net>");
129 MODULE_LICENSE("Dual BSD/GPL");
Something went wrong with that request. Please try again.