Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6/linux-2.6-openrd.git] / include / linux / vlynq.h
blob8f6a95882b093f1e792b59db7ec164de626a2fe3
1 /*
2 * Copyright (C) 2006, 2007 Eugene Konev <ejka@openwrt.org>
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.
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.
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
19 #ifndef __VLYNQ_H__
20 #define __VLYNQ_H__
22 #include <linux/device.h>
23 #include <linux/module.h>
24 #include <linux/types.h>
26 #define VLYNQ_NUM_IRQS 32
28 struct vlynq_mapping {
29 u32 size;
30 u32 offset;
33 enum 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
54 struct vlynq_device_id {
55 u32 id;
56 enum vlynq_divisor divisor;
57 unsigned long driver_data;
60 struct vlynq_regs;
61 struct 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;
76 struct 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;
84 struct plat_vlynq_ops {
85 int (*on)(struct vlynq_device *dev);
86 void (*off)(struct vlynq_device *dev);
89 static inline struct vlynq_driver *to_vlynq_driver(struct device_driver *drv)
91 return container_of(drv, struct vlynq_driver, driver);
94 static inline struct vlynq_device *to_vlynq_device(struct device *device)
96 return container_of(device, struct vlynq_device, dev);
99 extern struct bus_type vlynq_bus_type;
101 extern int __vlynq_register_driver(struct vlynq_driver *driver,
102 struct module *owner);
104 static inline int vlynq_register_driver(struct vlynq_driver *driver)
106 return __vlynq_register_driver(driver, THIS_MODULE);
109 static inline void *vlynq_get_drvdata(struct vlynq_device *dev)
111 return dev_get_drvdata(&dev->dev);
114 static inline void vlynq_set_drvdata(struct vlynq_device *dev, void *data)
116 dev_set_drvdata(&dev->dev, data);
119 static inline u32 vlynq_mem_start(struct vlynq_device *dev)
121 return dev->mem_start;
124 static inline u32 vlynq_mem_end(struct vlynq_device *dev)
126 return dev->mem_end;
129 static inline u32 vlynq_mem_len(struct vlynq_device *dev)
131 return dev->mem_end - dev->mem_start + 1;
134 static inline int vlynq_virq_to_irq(struct vlynq_device *dev, int virq)
136 int irq = dev->irq_start + virq;
137 if ((irq < dev->irq_start) || (irq > dev->irq_end))
138 return -EINVAL;
140 return irq;
143 static inline int vlynq_irq_to_virq(struct vlynq_device *dev, int irq)
145 if ((irq < dev->irq_start) || (irq > dev->irq_end))
146 return -EINVAL;
148 return irq - dev->irq_start;
151 extern void vlynq_unregister_driver(struct vlynq_driver *driver);
152 extern int vlynq_enable_device(struct vlynq_device *dev);
153 extern void vlynq_disable_device(struct vlynq_device *dev);
154 extern int vlynq_set_local_mapping(struct vlynq_device *dev, u32 tx_offset,
155 struct vlynq_mapping *mapping);
156 extern int vlynq_set_remote_mapping(struct vlynq_device *dev, u32 tx_offset,
157 struct vlynq_mapping *mapping);
158 extern int vlynq_set_local_irq(struct vlynq_device *dev, int virq);
159 extern int vlynq_set_remote_irq(struct vlynq_device *dev, int virq);
161 #endif /* __VLYNQ_H__ */