equal
deleted
inserted
replaced
1 /****************************************************************************** |
1 /****************************************************************************** |
2 * |
|
3 * m o d u l e . c |
|
4 * |
|
5 * EtherCAT master driver module. |
|
6 * |
|
7 * Author: Florian Pose <fp@igh-essen.com> |
|
8 * |
2 * |
9 * $Id$ |
3 * $Id$ |
10 * |
4 * |
11 * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
5 * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
12 * |
6 * |
25 * along with the IgH EtherCAT Master; if not, write to the Free Software |
19 * along with the IgH EtherCAT Master; if not, write to the Free Software |
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
27 * |
21 * |
28 *****************************************************************************/ |
22 *****************************************************************************/ |
29 |
23 |
|
24 /** |
|
25 \file |
|
26 EtherCAT master driver module. |
|
27 */ |
|
28 |
|
29 /*****************************************************************************/ |
|
30 |
30 #include <linux/module.h> |
31 #include <linux/module.h> |
31 #include <linux/kernel.h> |
32 #include <linux/kernel.h> |
32 #include <linux/init.h> |
33 #include <linux/init.h> |
33 |
34 |
34 #include "globals.h" |
35 #include "globals.h" |
39 |
40 |
40 int __init ec_init_module(void); |
41 int __init ec_init_module(void); |
41 void __exit ec_cleanup_module(void); |
42 void __exit ec_cleanup_module(void); |
42 |
43 |
43 /*****************************************************************************/ |
44 /*****************************************************************************/ |
|
45 |
|
46 /** |
|
47 Compile version info. |
|
48 */ |
44 |
49 |
45 #define COMPILE_INFO EC_STR(EC_MASTER_VERSION_MAIN) \ |
50 #define COMPILE_INFO EC_STR(EC_MASTER_VERSION_MAIN) \ |
46 "." EC_STR(EC_MASTER_VERSION_SUB) \ |
51 "." EC_STR(EC_MASTER_VERSION_SUB) \ |
47 " (" EC_MASTER_VERSION_EXTRA ")" \ |
52 " (" EC_MASTER_VERSION_EXTRA ")" \ |
48 " - rev. " EC_STR(SVNREV) \ |
53 " - rev. " EC_STR(SVNREV) \ |
54 static int ec_master_count = 1; |
59 static int ec_master_count = 1; |
55 static struct list_head ec_masters; |
60 static struct list_head ec_masters; |
56 |
61 |
57 /*****************************************************************************/ |
62 /*****************************************************************************/ |
58 |
63 |
|
64 /** \cond */ |
|
65 |
59 MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>"); |
66 MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>"); |
60 MODULE_DESCRIPTION ("EtherCAT master driver module"); |
67 MODULE_DESCRIPTION ("EtherCAT master driver module"); |
61 MODULE_LICENSE("GPL"); |
68 MODULE_LICENSE("GPL"); |
62 MODULE_VERSION(COMPILE_INFO); |
69 MODULE_VERSION(COMPILE_INFO); |
63 |
70 |
64 module_param(ec_master_count, int, 1); |
71 module_param(ec_master_count, int, 1); |
65 MODULE_PARM_DESC(ec_master_count, "number of EtherCAT masters to initialize"); |
72 MODULE_PARM_DESC(ec_master_count, "number of EtherCAT masters to initialize"); |
|
73 |
|
74 /** \endcond */ |
66 |
75 |
67 /*****************************************************************************/ |
76 /*****************************************************************************/ |
68 |
77 |
69 /** |
78 /** |
70 Module initialization. |
79 Module initialization. |
212 /****************************************************************************** |
221 /****************************************************************************** |
213 * Device interface |
222 * Device interface |
214 *****************************************************************************/ |
223 *****************************************************************************/ |
215 |
224 |
216 /** |
225 /** |
217 Registeres an EtherCAT device for a certain master. |
226 Connects an EtherCAT device to a certain master. |
|
227 The master will use the device for sending and receiving frames. It is |
|
228 required that no other instance (for example the kernel IP stack) uses |
|
229 the device. |
218 \return 0 on success, else < 0 |
230 \return 0 on success, else < 0 |
|
231 \ingroup DeviceInterface |
219 */ |
232 */ |
220 |
233 |
221 ec_device_t *ecdev_register(unsigned int master_index, /**< master index */ |
234 ec_device_t *ecdev_register(unsigned int master_index, /**< master index */ |
222 struct net_device *net_dev, /**< net_device of |
235 struct net_device *net_dev, /**< net_device of |
223 the device */ |
236 the device */ |
264 } |
277 } |
265 |
278 |
266 /*****************************************************************************/ |
279 /*****************************************************************************/ |
267 |
280 |
268 /** |
281 /** |
269 Unregisteres an EtherCAT device. |
282 Disconnect an EtherCAT device from the master. |
|
283 The device is disconnected from the master and all device ressources |
|
284 are freed. |
|
285 \attention Before calling this function, the ecdev_stop() function has |
|
286 to be called, to be sure that the master does not use the device any more. |
|
287 \ingroup DeviceInterface |
270 */ |
288 */ |
271 |
289 |
272 void ecdev_unregister(unsigned int master_index, /**< master index */ |
290 void ecdev_unregister(unsigned int master_index, /**< master index */ |
273 ec_device_t *device /**< EtherCAT device */ |
291 ec_device_t *device /**< EtherCAT device */ |
274 ) |
292 ) |
289 |
307 |
290 /*****************************************************************************/ |
308 /*****************************************************************************/ |
291 |
309 |
292 /** |
310 /** |
293 Starts the master associated with the device. |
311 Starts the master associated with the device. |
|
312 This function has to be called by the network device driver to tell the |
|
313 master that the device is ready to send and receive data. The master |
|
314 will enter the free-run mode then. |
|
315 \ingroup DeviceInterface |
294 */ |
316 */ |
295 |
317 |
296 int ecdev_start(unsigned int master_index /**< master index */) |
318 int ecdev_start(unsigned int master_index /**< master index */) |
297 { |
319 { |
298 ec_master_t *master; |
320 ec_master_t *master; |
309 |
331 |
310 /*****************************************************************************/ |
332 /*****************************************************************************/ |
311 |
333 |
312 /** |
334 /** |
313 Stops the master associated with the device. |
335 Stops the master associated with the device. |
|
336 Tells the master to stop using the device for frame IO. Has to be called |
|
337 before unregistering the device. |
|
338 \ingroup DeviceInterface |
314 */ |
339 */ |
315 |
340 |
316 void ecdev_stop(unsigned int master_index /**< master index */) |
341 void ecdev_stop(unsigned int master_index /**< master index */) |
317 { |
342 { |
318 ec_master_t *master; |
343 ec_master_t *master; |
329 *****************************************************************************/ |
354 *****************************************************************************/ |
330 |
355 |
331 /** |
356 /** |
332 Reserves an EtherCAT master for realtime operation. |
357 Reserves an EtherCAT master for realtime operation. |
333 \return pointer to reserved master, or NULL on error |
358 \return pointer to reserved master, or NULL on error |
|
359 \ingroup RealtimeInterface |
334 */ |
360 */ |
335 |
361 |
336 ec_master_t *ecrt_request_master(unsigned int master_index |
362 ec_master_t *ecrt_request_master(unsigned int master_index |
337 /**< master index */ |
363 /**< master index */ |
338 ) |
364 ) |
387 |
413 |
388 /*****************************************************************************/ |
414 /*****************************************************************************/ |
389 |
415 |
390 /** |
416 /** |
391 Releases a reserved EtherCAT master. |
417 Releases a reserved EtherCAT master. |
|
418 \ingroup RealtimeInterface |
392 */ |
419 */ |
393 |
420 |
394 void ecrt_release_master(ec_master_t *master /**< EtherCAT master */) |
421 void ecrt_release_master(ec_master_t *master /**< EtherCAT master */) |
395 { |
422 { |
396 EC_INFO("Releasing master %i...\n", master->index); |
423 EC_INFO("Releasing master %i...\n", master->index); |
411 EC_INFO("Released master %i.\n", master->index); |
438 EC_INFO("Released master %i.\n", master->index); |
412 return; |
439 return; |
413 } |
440 } |
414 |
441 |
415 /*****************************************************************************/ |
442 /*****************************************************************************/ |
|
443 |
|
444 /** \cond */ |
416 |
445 |
417 module_init(ec_init_module); |
446 module_init(ec_init_module); |
418 module_exit(ec_cleanup_module); |
447 module_exit(ec_cleanup_module); |
419 |
448 |
420 EXPORT_SYMBOL(ecdev_register); |
449 EXPORT_SYMBOL(ecdev_register); |
422 EXPORT_SYMBOL(ecdev_start); |
451 EXPORT_SYMBOL(ecdev_start); |
423 EXPORT_SYMBOL(ecdev_stop); |
452 EXPORT_SYMBOL(ecdev_stop); |
424 EXPORT_SYMBOL(ecrt_request_master); |
453 EXPORT_SYMBOL(ecrt_request_master); |
425 EXPORT_SYMBOL(ecrt_release_master); |
454 EXPORT_SYMBOL(ecrt_release_master); |
426 |
455 |
427 /*****************************************************************************/ |
456 /** \endcond */ |
|
457 |
|
458 /*****************************************************************************/ |