1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2006, 2007 Eugene Konev <ejka@openwrt.org>
9 #include <linux/device.h>
10 #include <linux/types.h>
14 #define VLYNQ_NUM_IRQS 32
16 struct vlynq_mapping {
42 struct vlynq_device_id {
44 enum vlynq_divisor divisor;
45 unsigned long driver_data;
53 enum vlynq_divisor divisor;
54 u32 regs_start, regs_end;
55 u32 mem_start, mem_end;
56 u32 irq_start, irq_end;
59 struct vlynq_regs *local;
60 struct vlynq_regs *remote;
66 struct vlynq_device_id *id_table;
67 int (*probe)(struct vlynq_device *dev, struct vlynq_device_id *id);
68 void (*remove)(struct vlynq_device *dev);
69 struct device_driver driver;
72 struct plat_vlynq_ops {
73 int (*on)(struct vlynq_device *dev);
74 void (*off)(struct vlynq_device *dev);
77 static inline struct vlynq_driver *to_vlynq_driver(struct device_driver *drv)
79 return container_of(drv, struct vlynq_driver, driver);
82 static inline struct vlynq_device *to_vlynq_device(struct device *device)
84 return container_of(device, struct vlynq_device, dev);
87 extern struct bus_type vlynq_bus_type;
89 extern int __vlynq_register_driver(struct vlynq_driver *driver,
90 struct module *owner);
92 static inline int vlynq_register_driver(struct vlynq_driver *driver)
94 return __vlynq_register_driver(driver, THIS_MODULE);
97 static inline void *vlynq_get_drvdata(struct vlynq_device *dev)
99 return dev_get_drvdata(&dev->dev);
102 static inline void vlynq_set_drvdata(struct vlynq_device *dev, void *data)
104 dev_set_drvdata(&dev->dev, data);
107 static inline u32 vlynq_mem_start(struct vlynq_device *dev)
109 return dev->mem_start;
112 static inline u32 vlynq_mem_end(struct vlynq_device *dev)
117 static inline u32 vlynq_mem_len(struct vlynq_device *dev)
119 return dev->mem_end - dev->mem_start + 1;
122 static inline int vlynq_virq_to_irq(struct vlynq_device *dev, int virq)
124 int irq = dev->irq_start + virq;
125 if ((irq < dev->irq_start) || (irq > dev->irq_end))
131 static inline int vlynq_irq_to_virq(struct vlynq_device *dev, int irq)
133 if ((irq < dev->irq_start) || (irq > dev->irq_end))
136 return irq - dev->irq_start;
139 extern void vlynq_unregister_driver(struct vlynq_driver *driver);
140 extern int vlynq_enable_device(struct vlynq_device *dev);
141 extern void vlynq_disable_device(struct vlynq_device *dev);
142 extern int vlynq_set_local_mapping(struct vlynq_device *dev, u32 tx_offset,
143 struct vlynq_mapping *mapping);
144 extern int vlynq_set_remote_mapping(struct vlynq_device *dev, u32 tx_offset,
145 struct vlynq_mapping *mapping);
146 extern int vlynq_set_local_irq(struct vlynq_device *dev, int virq);
147 extern int vlynq_set_remote_irq(struct vlynq_device *dev, int virq);
149 #endif /* __VLYNQ_H__ */