Wilhelms ?nderungen ?bernommen.
--- a/drivers/8139too.c Fri Nov 25 16:43:46 2005 +0000
+++ b/drivers/8139too.c Fri Dec 02 09:03:32 2005 +0000
@@ -109,7 +109,7 @@
*/
-#define DRV_NAME "8139too-ecat"
+#define DRV_NAME "8139too_ecat"
#define DRV_VERSION "0.9.27"
@@ -200,8 +200,6 @@
EtherCAT_device_t rtl_ecat_dev;
-EXPORT_SYMBOL(rtl_ecat_dev);
-
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/*
@@ -1450,6 +1448,7 @@
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
+ //FIXME muß das hier raus ??
if (netif_msg_ifup(tp))
printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d"
" GP Pins %2.2x %s-duplex.\n",
@@ -1885,9 +1884,10 @@
return 0;
}
+ if (dev != rtl_ecat_dev.dev) //CHANGED HM spinlock falsch
+ spin_lock_irq(&tp->lock);
+
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-
- spin_lock_irq(&tp->lock);
RTL_W32_F (TxStatus0 + (entry * sizeof (u32)),
tp->tx_flag | max(len, (unsigned int)ETH_ZLEN));
@@ -1932,6 +1932,7 @@
if (dev == rtl_ecat_dev.dev)
{
rtl_ecat_dev.tx_intr_cnt++;
+ //printk("ECAT tx interrupt\n"); // HM
rdtscl(rtl_ecat_dev.tx_time); // Get CPU cycles
}
@@ -2155,14 +2156,15 @@
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev == rtl_ecat_dev.dev)
- {
- rtl_ecat_dev.rx_intr_cnt++;
- rdtscl(rtl_ecat_dev.rx_time); // Get CPU cycles
+ {
+ rtl_ecat_dev.rx_intr_cnt++;
+ rdtscl(rtl_ecat_dev.rx_time); // Get CPU cycles
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
- while (netif_running(dev) && received < budget
+ while ((dev == rtl_ecat_dev.dev || netif_running(dev)) //HM
+ && received < budget
&& (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
u32 ring_offset = cur_rx % RX_BUF_LEN;
u32 rx_status;
@@ -2179,9 +2181,9 @@
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ecat_dev.dev && netif_msg_rx_status(tp))
- printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x,"
- " cur %4.4x.\n", dev->name, rx_status,
- rx_size, cur_rx);
+ printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x,"
+ " cur %4.4x.\n", dev->name, rx_status,
+ rx_size, cur_rx);
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@@ -2387,10 +2389,16 @@
* Order is important since data can get interrupted
* again when we think we are done.
*/
+/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
+ if (dev != rtl_ecat_dev.dev) {
+/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
local_irq_disable();
- RTL_W16_F(IntrMask, rtl8139_intr_mask);
+ RTL_W16_F(IntrMask, rtl8139_intr_mask); //Interrupts werden nicht enabled ?? HM
__netif_rx_complete(dev);
local_irq_enable();
+ }
+// else
+
}
spin_unlock(&tp->rx_lock);
@@ -2414,6 +2422,7 @@
if (dev == rtl_ecat_dev.dev)
{
rtl_ecat_dev.intr_cnt++;
+
}
else
{
@@ -2425,8 +2434,11 @@
status = RTL_R16 (IntrStatus);
/* shared irq? */
- if (unlikely((status & rtl8139_intr_mask) == 0))
+ /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
+ if (dev != rtl_ecat_dev.dev)
+ if (unlikely((status & rtl8139_intr_mask) == 0))
goto out;
+ /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
handled = 1;
@@ -2435,27 +2447,39 @@
goto out;
/* close possible race's with dev_close */
- if (unlikely(!netif_running(dev))) {
+ /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
+ if (dev != rtl_ecat_dev.dev) {
+ if (unlikely(!netif_running(dev))) {
RTL_W16 (IntrMask, 0);
goto out;
- }
-
+ }
+ }
+ /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* Acknowledge all of the current interrupt sources ASAP, but
an first get an additional status bit from CSCR. */
if (unlikely(status & RxUnderrun))
link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
ackstat = status & ~(RxAckBits | TxErr);
- if (ackstat)
+ if (ackstat) {
RTL_W16 (IntrStatus, ackstat);
+ //printk("ECAT-NIC ack\n"); //HM
+ }
/* Receive packets are processed by poll routine.
If not running start it now. */
+
+ /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (status & RxAckBits){
+ // printk("ECAT-NIC RX-Intr Flag\n"); // HM
+ if (dev != rtl_ecat_dev.dev) {
if (netif_rx_schedule_prep(dev)) {
- RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
- __netif_rx_schedule (dev);
+ RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
+ __netif_rx_schedule (dev);
}
+ }
+// else
+
}
/* Check uncommon events with one test. */
@@ -2508,20 +2532,17 @@
if (dev != rtl_ecat_dev.dev)
{
netif_stop_queue(dev);
- }
-
- /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-
- if (tp->thr_pid >= 0) {
+ if (tp->thr_pid >= 0) {
tp->time_to_die = 1;
wmb();
ret = kill_proc (tp->thr_pid, SIGTERM, 1);
if (ret) {
- printk (KERN_ERR "%s: unable to signal thread\n", dev->name);
- return ret;
+ printk (KERN_ERR "%s: unable to signal thread\n", dev->name);
+ return ret;
}
wait_for_completion (&tp->thr_exited);
- }
+ }
+ }
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
@@ -2534,7 +2555,10 @@
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
- spin_lock_irqsave (&tp->lock, flags);
+ /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
+ if (dev != rtl_ecat_dev.dev)
+ /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
+ spin_lock_irqsave (&tp->lock, flags);
/* Stop the chip's Tx and Rx DMA processes. */
RTL_W8 (ChipCmd, 0);
@@ -2546,7 +2570,10 @@
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
- spin_unlock_irqrestore (&tp->lock, flags);
+ /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
+ if (dev != rtl_ecat_dev.dev)
+ /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
+ spin_unlock_irqrestore (&tp->lock, flags);
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
@@ -2974,3 +3001,5 @@
module_init(rtl8139_init_module);
module_exit(rtl8139_cleanup_module);
+
+EXPORT_SYMBOL(rtl_ecat_dev);
--- a/drivers/ec_device.c Fri Nov 25 16:43:46 2005 +0000
+++ b/drivers/ec_device.c Fri Dec 02 09:03:32 2005 +0000
@@ -9,6 +9,7 @@
*
***************************************************************/
+#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/if_ether.h>
#include <linux/netdevice.h>
@@ -159,8 +160,6 @@
return ecd->dev->open(ecd->dev);
}
-EXPORT_SYMBOL(EtherCAT_device_open);
-
/***************************************************************/
/**
@@ -189,8 +188,6 @@
return ecd->dev->stop(ecd->dev);
}
-EXPORT_SYMBOL(EtherCAT_device_close);
-
/***************************************************************/
/**
@@ -301,13 +298,16 @@
budget = 1; /* Einen Frame empfangen */
rtl8139_interrupt(0, ecd->dev, NULL);
+ ecd->dev->quota = 1;
rtl8139_poll(ecd->dev, &budget);
+/* HM
if (budget != 0)
{
EC_DBG(KERN_ERR "EtherCAT: Warning - Budget is %d!\n",
budget);
}
+*/
}
/***************************************************************/
@@ -346,6 +346,10 @@
EC_DBG(KERN_DEBUG "---EtherCAT device information end---\n");
}
+/***************************************************************/
+
+EXPORT_SYMBOL(EtherCAT_device_open);
+EXPORT_SYMBOL(EtherCAT_device_close);
+EXPORT_SYMBOL(EtherCAT_device_clear);
EXPORT_SYMBOL(EtherCAT_device_debug);
-/***************************************************************/
--- a/drivers/ec_master.c Fri Nov 25 16:43:46 2005 +0000
+++ b/drivers/ec_master.c Fri Dec 02 09:03:32 2005 +0000
@@ -9,6 +9,7 @@
*
***************************************************************/
+#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/slab.h>
@@ -52,8 +53,6 @@
return 0;
}
-EXPORT_SYMBOL(EtherCAT_master_init);
-
/***************************************************************/
/**
@@ -79,8 +78,6 @@
master->process_data_length = 0;
}
-EXPORT_SYMBOL(EtherCAT_master_clear);
-
/***************************************************************/
/**
@@ -98,20 +95,30 @@
{
unsigned int tries_left;
+// EC_DBG("ECAT send...\n"); //HM
+
if (EtherCAT_simple_send(master, cmd) < 0) return -1;
+// EC_DBG("ECAT call isr \n"); //HM
+ udelay(3); //FIXME nur zum Test HM
+
EtherCAT_device_call_isr(master->dev);
- tries_left = 1000;
+ tries_left = 100;
while (master->dev->state == ECAT_DS_SENT && tries_left)
{
udelay(1);
+// EC_DBG("ECAT call isr \n"); //HM
EtherCAT_device_call_isr(master->dev);
tries_left--;
}
+// EC_DBG("ECAT recieve \n"); //HM
+
if (EtherCAT_simple_receive(master, cmd) < 0) return -1;
+// EC_DBG("ECAT recieve done\n"); //HM
+
return 0;
}
@@ -502,8 +509,6 @@
return 0;
}
-EXPORT_SYMBOL(EtherCAT_check_slaves);
-
/***************************************************************/
/**
@@ -635,7 +640,11 @@
if (cmd.working_counter != 1)
{
- EC_DBG(KERN_ERR "EtherCAT: Could not set state %02X - Device did not respond!\n", state_and_ack);
+ EC_DBG(KERN_ERR "EtherCAT: Could not set state %02X - Device \"%s %s\" (%d) did not respond!\n",
+ state_and_ack,
+ slave->desc->vendor_name,
+ slave->desc->product_name,
+ slave->ring_position*(-1));
return -3;
}
@@ -928,8 +937,6 @@
return 0;
}
-EXPORT_SYMBOL(EtherCAT_activate_all_slaves);
-
/***************************************************************/
/**
@@ -958,8 +965,6 @@
return ret;
}
-EXPORT_SYMBOL(EtherCAT_deactivate_all_slaves);
-
/***************************************************************/
/**
@@ -988,8 +993,6 @@
return 0;
}
-EXPORT_SYMBOL(EtherCAT_write_process_data);
-
/***************************************************************/
/**
@@ -1010,7 +1013,7 @@
EtherCAT_device_call_isr(master->dev);
- tries_left = 1000;
+ tries_left = 100;
while (master->dev->state == ECAT_DS_SENT && tries_left)
{
udelay(1);
@@ -1043,8 +1046,6 @@
return 0;
}
-EXPORT_SYMBOL(EtherCAT_read_process_data);
-
/***************************************************************/
/**
@@ -1059,8 +1060,6 @@
master->dev->state = ECAT_DS_READY;
}
-EXPORT_SYMBOL(EtherCAT_clear_process_data);
-
/***************************************************************/
/**
@@ -1097,3 +1096,12 @@
}
/***************************************************************/
+
+EXPORT_SYMBOL(EtherCAT_master_init);
+EXPORT_SYMBOL(EtherCAT_master_clear);
+EXPORT_SYMBOL(EtherCAT_read_process_data);
+EXPORT_SYMBOL(EtherCAT_write_process_data);
+EXPORT_SYMBOL(EtherCAT_check_slaves);
+EXPORT_SYMBOL(EtherCAT_activate_all_slaves);
+EXPORT_SYMBOL(EtherCAT_clear_process_data);
+EXPORT_SYMBOL(EtherCAT_deactivate_all_slaves);
--- a/drivers/ec_slave.c Fri Nov 25 16:43:46 2005 +0000
+++ b/drivers/ec_slave.c Fri Dec 02 09:03:32 2005 +0000
@@ -9,7 +9,7 @@
*
***************************************************************/
-#include <linux/kernel.h>
+#include <linux/module.h>
#include "ec_globals.h"
#include "ec_slave.h"
@@ -112,8 +112,6 @@
return slave->desc->read(slave->process_data, channel);
}
-EXPORT_SYMBOL(EtherCAT_read_value);
-
/***************************************************************/
/**
@@ -164,6 +162,7 @@
slave->desc->write(slave->process_data, channel, value);
}
+/***************************************************************/
+
EXPORT_SYMBOL(EtherCAT_write_value);
-
-/***************************************************************/
+EXPORT_SYMBOL(EtherCAT_read_value);
--- a/drivers/ec_types.c Fri Nov 25 16:43:46 2005 +0000
+++ b/drivers/ec_types.c Fri Dec 02 09:03:32 2005 +0000
@@ -9,6 +9,8 @@
*
***************************************************************/
+#include <linux/module.h>
+
#include "ec_globals.h"
#include "ec_types.h"
@@ -78,7 +80,6 @@
0, 0,
NULL, NULL
}};
-EXPORT_SYMBOL(Beckhoff_EK1100);
EtherCAT_slave_desc_t Beckhoff_EL1014[] =
{{
@@ -89,7 +90,6 @@
1, 4,
read_1014, NULL
}};
-EXPORT_SYMBOL(Beckhoff_EL1014);
EtherCAT_slave_desc_t Beckhoff_EL2004[] =
{{
@@ -100,7 +100,6 @@
1, 4,
NULL, write_2004
}};
-EXPORT_SYMBOL(Beckhoff_EL2004);
EtherCAT_slave_desc_t Beckhoff_EL3102[] =
{{
@@ -111,7 +110,6 @@
6, 2,
read_31xx, NULL
}};
-EXPORT_SYMBOL(Beckhoff_EL3102);
EtherCAT_slave_desc_t Beckhoff_EL3162[] =
{{
@@ -122,7 +120,6 @@
6, 2,
read_31xx, NULL
}};
-EXPORT_SYMBOL(Beckhoff_EL3162);
EtherCAT_slave_desc_t Beckhoff_EL4102[] =
{{
@@ -133,7 +130,6 @@
4, 2,
NULL, write_4102
}};
-EXPORT_SYMBOL(Beckhoff_EL4102);
EtherCAT_slave_desc_t Beckhoff_EL5001[] =
{{
@@ -144,7 +140,6 @@
0, 0,
NULL, NULL
}};
-EXPORT_SYMBOL(Beckhoff_EL5001);
/***************************************************************/
@@ -162,3 +157,11 @@
};
/***************************************************************/
+
+EXPORT_SYMBOL(Beckhoff_EK1100);
+EXPORT_SYMBOL(Beckhoff_EL1014);
+EXPORT_SYMBOL(Beckhoff_EL2004);
+EXPORT_SYMBOL(Beckhoff_EL3102);
+EXPORT_SYMBOL(Beckhoff_EL3162);
+EXPORT_SYMBOL(Beckhoff_EL4102);
+EXPORT_SYMBOL(Beckhoff_EL5001);
--- a/drivers/ec_types.h Fri Nov 25 16:43:46 2005 +0000
+++ b/drivers/ec_types.h Fri Dec 02 09:03:32 2005 +0000
@@ -9,8 +9,6 @@
*
***************************************************************/
-#include <linux/module.h>
-
#ifndef _EC_TYPES_H_
#define _EC_TYPES_H_
--- a/mini/Makefile Fri Nov 25 16:43:46 2005 +0000
+++ b/mini/Makefile Fri Dec 02 09:03:32 2005 +0000
@@ -27,6 +27,7 @@
CONFIG_FILE = ../ethercat.conf
PWD = $(shell pwd)
+
include $(CONFIG_FILE) # Für KERNELDIR
default:
--- a/mini/ec_mini.c Fri Nov 25 16:43:46 2005 +0000
+++ b/mini/ec_mini.c Fri Dec 02 09:03:32 2005 +0000
@@ -9,6 +9,8 @@
******************************************************************************/
#include <linux/module.h>
+//#include <linux/slab.h>
+#include <linux/delay.h>
#include <linux/timer.h>
#include "../drivers/ec_master.h"
@@ -44,22 +46,21 @@
ECAT_INIT_SLAVE(Beckhoff_EL4102),
ECAT_INIT_SLAVE(Beckhoff_EL3162),
ECAT_INIT_SLAVE(Beckhoff_EL1014),
- ECAT_INIT_SLAVE(Beckhoff_EL2004),
- ECAT_INIT_SLAVE(Beckhoff_EL3102),
+
ECAT_INIT_SLAVE(Beckhoff_EL4102),
ECAT_INIT_SLAVE(Beckhoff_EL4102),
ECAT_INIT_SLAVE(Beckhoff_EL4102),
+
ECAT_INIT_SLAVE(Beckhoff_EL3162),
ECAT_INIT_SLAVE(Beckhoff_EL3162),
ECAT_INIT_SLAVE(Beckhoff_EL3162),
ECAT_INIT_SLAVE(Beckhoff_EL3102),
ECAT_INIT_SLAVE(Beckhoff_EL3102),
- ECAT_INIT_SLAVE(Beckhoff_EL2004),
- ECAT_INIT_SLAVE(Beckhoff_EL2004),
- ECAT_INIT_SLAVE(Beckhoff_EL2004),
- ECAT_INIT_SLAVE(Beckhoff_EL2004),
-#endif
-
+ ECAT_INIT_SLAVE(Beckhoff_EL3102),
+
+#endif
+
+#if 1
// Block 2
ECAT_INIT_SLAVE(Beckhoff_EK1100),
ECAT_INIT_SLAVE(Beckhoff_EL4102),
@@ -67,6 +68,11 @@
ECAT_INIT_SLAVE(Beckhoff_EL3162),
ECAT_INIT_SLAVE(Beckhoff_EL2004),
ECAT_INIT_SLAVE(Beckhoff_EL3102),
+ ECAT_INIT_SLAVE(Beckhoff_EL2004),
+ ECAT_INIT_SLAVE(Beckhoff_EL2004),
+ ECAT_INIT_SLAVE(Beckhoff_EL2004),
+ ECAT_INIT_SLAVE(Beckhoff_EL2004),
+ ECAT_INIT_SLAVE(Beckhoff_EL2004),
// Block 3
ECAT_INIT_SLAVE(Beckhoff_EK1100),
@@ -82,6 +88,7 @@
ECAT_INIT_SLAVE(Beckhoff_EL1014),
ECAT_INIT_SLAVE(Beckhoff_EL1014),
ECAT_INIT_SLAVE(Beckhoff_EL1014)
+#endif
};
#define ECAT_SLAVES_COUNT (sizeof(ecat_slaves) / sizeof(EtherCAT_slave_t))
@@ -92,6 +99,7 @@
#ifdef ECAT_CYCLIC_DATA
+int value;
int dig1;
struct timer_list timer;
@@ -152,7 +160,7 @@
static unsigned long int k = 0;
static int firstrun = 1;
- static int klemme = 12;
+ static int klemme = 0;
static int kanal = 0;
static int up_down = 0;
int wrap = 0;
@@ -174,14 +182,15 @@
// Prozessdaten lesen
if (!firstrun)
{
+ EtherCAT_read_process_data(ecat_master);
+
+ // Daten lesen und skalieren
+// value = EtherCAT_read_value(&ecat_master->slaves[5], 0) / 3276; //.7; FIXME kein FP im Kernel ohne Schutz !!
+// dig1 = EtherCAT_read_value(&ecat_master->slaves[3], 0);
+ }
+ else
klemme = next2004(&wrap);
- EtherCAT_read_process_data(ecat_master);
-
- // Daten lesen und skalieren
- //value = EtherCAT_read_value(&ecat_master->slaves[5], 0) / 3276.7;
- dig1 = EtherCAT_read_value(&ecat_master->slaves[3], 0);
- }
#if 0
// Daten schreiben
@@ -208,8 +217,10 @@
}
}
- if (klemme >= 0)
+ if (klemme >= 0) {
EtherCAT_write_value(&ecat_master->slaves[klemme], kanal,up_down);
+ //printk("ECAT write: Klemme: %d, Kanal: %d, Wert: %d\n",klemme,kanal,up_down);
+ }
#if 0
EtherCAT_write_value(&ecat_master->slaves[13], 1, ms > 500 ? 0 : 1);
@@ -223,7 +234,7 @@
firstrun = 0;
#endif
- timer.expires += HZ / 100;
+ timer.expires += HZ / 1000;
add_timer(&timer);
}
@@ -308,11 +319,14 @@
#ifdef ECAT_CYCLIC_DATA
EC_DBG("Starting cyclic sample thread.\n");
+ schedule();
+ mdelay(1000);
+ schedule();
init_timer(&timer);
timer.function = run;
timer.data = 0;
- timer.expires = jiffies; // Das erste Mal sofort feuern
+ timer.expires = jiffies+10; // Das erste Mal sofort feuern
last_start_jiffies = timer.expires;
add_timer(&timer);