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/module.h>
24 #include <linux/types.h>
26 #define VLYNQ_NUM_IRQS 32
28 struct vlynq_mapping
{
54 struct vlynq_device_id
{
56 enum vlynq_divisor divisor
;
57 unsigned long driver_data
;
65 enum vlynq_divisor divisor
;
66 u32 regs_start
, regs_end
;
67 u32 mem_start
, mem_end
;
68 u32 irq_start
, irq_end
;
71 struct vlynq_regs
*local
;
72 struct vlynq_regs
*remote
;
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
)
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
))
143 static inline int vlynq_irq_to_virq(struct vlynq_device
*dev
, int irq
)
145 if ((irq
< dev
->irq_start
) || (irq
> dev
->irq_end
))
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__ */