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
22 #include <linux/device.h>
23 #include <linux/types.h>
27 #define VLYNQ_NUM_IRQS 32
29 struct vlynq_mapping {
55 struct vlynq_device_id {
57 enum vlynq_divisor divisor;
58 unsigned long driver_data;
66 enum vlynq_divisor divisor;
67 u32 regs_start, regs_end;
68 u32 mem_start, mem_end;
69 u32 irq_start, irq_end;
72 struct vlynq_regs *local;
73 struct vlynq_regs *remote;
79 struct vlynq_device_id *id_table;
80 int (*probe)(struct vlynq_device *dev, struct vlynq_device_id *id);
81 void (*remove)(struct vlynq_device *dev);
82 struct device_driver driver;
85 struct plat_vlynq_ops {
86 int (*on)(struct vlynq_device *dev);
87 void (*off)(struct vlynq_device *dev);
90 static inline struct vlynq_driver *to_vlynq_driver(struct device_driver *drv)
92 return container_of(drv, struct vlynq_driver, driver);
95 static inline struct vlynq_device *to_vlynq_device(struct device *device)
97 return container_of(device, struct vlynq_device, dev);
100 extern struct bus_type vlynq_bus_type;
102 extern int __vlynq_register_driver(struct vlynq_driver *driver,
103 struct module *owner);
105 static inline int vlynq_register_driver(struct vlynq_driver *driver)
107 return __vlynq_register_driver(driver, THIS_MODULE);
110 static inline void *vlynq_get_drvdata(struct vlynq_device *dev)
112 return dev_get_drvdata(&dev->dev);
115 static inline void vlynq_set_drvdata(struct vlynq_device *dev, void *data)
117 dev_set_drvdata(&dev->dev, data);
120 static inline u32 vlynq_mem_start(struct vlynq_device *dev)
122 return dev->mem_start;
125 static inline u32 vlynq_mem_end(struct vlynq_device *dev)
130 static inline u32 vlynq_mem_len(struct vlynq_device *dev)
132 return dev->mem_end - dev->mem_start + 1;
135 static inline int vlynq_virq_to_irq(struct vlynq_device *dev, int virq)
137 int irq = dev->irq_start + virq;
138 if ((irq < dev->irq_start) || (irq > dev->irq_end))
144 static inline int vlynq_irq_to_virq(struct vlynq_device *dev, int irq)
146 if ((irq < dev->irq_start) || (irq > dev->irq_end))
149 return irq - dev->irq_start;
152 extern void vlynq_unregister_driver(struct vlynq_driver *driver);
153 extern int vlynq_enable_device(struct vlynq_device *dev);
154 extern void vlynq_disable_device(struct vlynq_device *dev);
155 extern int vlynq_set_local_mapping(struct vlynq_device *dev, u32 tx_offset,
156 struct vlynq_mapping *mapping);
157 extern int vlynq_set_remote_mapping(struct vlynq_device *dev, u32 tx_offset,
158 struct vlynq_mapping *mapping);
159 extern int vlynq_set_local_irq(struct vlynq_device *dev, int virq);
160 extern int vlynq_set_remote_irq(struct vlynq_device *dev, int virq);
162 #endif /* __VLYNQ_H__ */