aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/vlynq.h161
1 files changed, 161 insertions, 0 deletions
diff --git a/include/linux/vlynq.h b/include/linux/vlynq.h
new file mode 100644
index 000000000000..8f6a95882b09
--- /dev/null
+++ b/include/linux/vlynq.h
@@ -0,0 +1,161 @@
1/*
2 * Copyright (C) 2006, 2007 Eugene Konev <ejka@openwrt.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef __VLYNQ_H__
20#define __VLYNQ_H__
21
22#include <linux/device.h>
23#include <linux/module.h>
24#include <linux/types.h>
25
26#define VLYNQ_NUM_IRQS 32
27
28struct vlynq_mapping {
29 u32 size;
30 u32 offset;
31};
32
33enum vlynq_divisor {
34 vlynq_div_auto = 0,
35 vlynq_ldiv1,
36 vlynq_ldiv2,
37 vlynq_ldiv3,
38 vlynq_ldiv4,
39 vlynq_ldiv5,
40 vlynq_ldiv6,
41 vlynq_ldiv7,
42 vlynq_ldiv8,
43 vlynq_rdiv1,
44 vlynq_rdiv2,
45 vlynq_rdiv3,
46 vlynq_rdiv4,
47 vlynq_rdiv5,
48 vlynq_rdiv6,
49 vlynq_rdiv7,
50 vlynq_rdiv8,
51 vlynq_div_external
52};
53
54struct vlynq_device_id {
55 u32 id;
56 enum vlynq_divisor divisor;
57 unsigned long driver_data;
58};
59
60struct vlynq_regs;
61struct vlynq_device {
62 u32 id, dev_id;
63 int local_irq;
64 int remote_irq;
65 enum vlynq_divisor divisor;
66 u32 regs_start, regs_end;
67 u32 mem_start, mem_end;
68 u32 irq_start, irq_end;
69 int irq;
70 int enabled;
71 struct vlynq_regs *local;
72 struct vlynq_regs *remote;
73 struct device dev;
74};
75
76struct vlynq_driver {
77 char *name;
78 struct vlynq_device_id *id_table;
79 int (*probe)(struct vlynq_device *dev, struct vlynq_device_id *id);
80 void (*remove)(struct vlynq_device *dev);
81 struct device_driver driver;
82};
83
84struct plat_vlynq_ops {
85 int (*on)(struct vlynq_device *dev);
86 void (*off)(struct vlynq_device *dev);
87};
88
89static inline struct vlynq_driver *to_vlynq_driver(struct device_driver *drv)
90{
91 return container_of(drv, struct vlynq_driver, driver);
92}
93
94static inline struct vlynq_device *to_vlynq_device(struct device *device)
95{
96 return container_of(device, struct vlynq_device, dev);
97}
98
99extern struct bus_type vlynq_bus_type;
100
101extern int __vlynq_register_driver(struct vlynq_driver *driver,
102 struct module *owner);
103
104static inline int vlynq_register_driver(struct vlynq_driver *driver)
105{
106 return __vlynq_register_driver(driver, THIS_MODULE);
107}
108
109static inline void *vlynq_get_drvdata(struct vlynq_device *dev)
110{
111 return dev_get_drvdata(&dev->dev);
112}
113
114static inline void vlynq_set_drvdata(struct vlynq_device *dev, void *data)
115{
116 dev_set_drvdata(&dev->dev, data);
117}
118
119static inline u32 vlynq_mem_start(struct vlynq_device *dev)
120{
121 return dev->mem_start;
122}
123
124static inline u32 vlynq_mem_end(struct vlynq_device *dev)
125{
126 return dev->mem_end;
127}
128
129static inline u32 vlynq_mem_len(struct vlynq_device *dev)
130{
131 return dev->mem_end - dev->mem_start + 1;
132}
133
134static inline int vlynq_virq_to_irq(struct vlynq_device *dev, int virq)
135{
136 int irq = dev->irq_start + virq;
137 if ((irq < dev->irq_start) || (irq > dev->irq_end))
138 return -EINVAL;
139
140 return irq;
141}
142
143static inline int vlynq_irq_to_virq(struct vlynq_device *dev, int irq)
144{
145 if ((irq < dev->irq_start) || (irq > dev->irq_end))
146 return -EINVAL;
147
148 return irq - dev->irq_start;
149}
150
151extern void vlynq_unregister_driver(struct vlynq_driver *driver);
152extern int vlynq_enable_device(struct vlynq_device *dev);
153extern void vlynq_disable_device(struct vlynq_device *dev);
154extern int vlynq_set_local_mapping(struct vlynq_device *dev, u32 tx_offset,
155 struct vlynq_mapping *mapping);
156extern int vlynq_set_remote_mapping(struct vlynq_device *dev, u32 tx_offset,
157 struct vlynq_mapping *mapping);
158extern int vlynq_set_local_irq(struct vlynq_device *dev, int virq);
159extern int vlynq_set_remote_irq(struct vlynq_device *dev, int virq);
160
161#endif /* __VLYNQ_H__ */