drivers/8139too.c
branchkernel2.6
changeset 27 d75ef6b46e33
parent 25 7d124bfba3ce
child 33 f4171b8aadf8
equal deleted inserted replaced
26:60435f959e5c 27:d75ef6b46e33
   107 		"rtl8139-diag -mmmaaavvveefN" output
   107 		"rtl8139-diag -mmmaaavvveefN" output
   108 		enable RTL8139_DEBUG below, and look at 'dmesg' or kernel log
   108 		enable RTL8139_DEBUG below, and look at 'dmesg' or kernel log
   109 
   109 
   110 */
   110 */
   111 
   111 
   112 #define DRV_NAME	"8139too-ecat"
   112 #define DRV_NAME	"8139too_ecat"
   113 #define DRV_VERSION	"0.9.27"
   113 #define DRV_VERSION	"0.9.27"
   114 
   114 
   115 
   115 
   116 #include <linux/config.h>
   116 #include <linux/config.h>
   117 #include <linux/module.h>
   117 #include <linux/module.h>
   133 #include <asm/irq.h>
   133 #include <asm/irq.h>
   134 
   134 
   135 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   135 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   136 
   136 
   137 #include "ec_device.h"
   137 #include "ec_device.h"
       
   138 #include "ec_master.h"
       
   139 #include "ec_module.h"
   138 
   140 
   139 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
   141 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
   140 
   142 
   141 #define RTL8139_DRIVER_NAME   DRV_NAME " Fast Ethernet driver " DRV_VERSION
   143 #define RTL8139_DRIVER_NAME   DRV_NAME " Fast Ethernet driver " DRV_VERSION
   142 #define PFX DRV_NAME ": "
   144 #define PFX DRV_NAME ": "
   190 /* bitmapped message enable number */
   192 /* bitmapped message enable number */
   191 static int debug = -1;
   193 static int debug = -1;
   192 
   194 
   193 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   195 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   194 
   196 
       
   197 // Uncomment for debugging
       
   198 //#define ECAT_DEBUG
       
   199 
   195 // Device index for EtherCAT device selection
   200 // Device index for EtherCAT device selection
   196 static int ec_device_index = -1;
   201 static int ec_device_index = -1;
   197 
   202 static int ec_device_master_index = 0;
   198 //#define ECAT_DEBUG
   203 
   199 
   204 static EtherCAT_device_t rtl_ecat_dev;
   200 EtherCAT_device_t rtl_ecat_dev;
   205 static EtherCAT_master_t *rtl_ecat_master = NULL;
   201 
   206 
   202 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
   207 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
   203 
   208 
   204 /*
   209 /*
   205  * Receive ring size 
   210  * Receive ring size 
   651 MODULE_PARM_DESC (media, "8139too: Bits 4+9: force full duplex, bit 5: 100Mbps");
   656 MODULE_PARM_DESC (media, "8139too: Bits 4+9: force full duplex, bit 5: 100Mbps");
   652 MODULE_PARM_DESC (full_duplex, "8139too: Force full duplex for board(s) (1)");
   657 MODULE_PARM_DESC (full_duplex, "8139too: Force full duplex for board(s) (1)");
   653 
   658 
   654 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   659 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   655 
   660 
   656 MODULE_PARM(ec_device_index, "i");
   661 module_param(ec_device_index, int, -1);
       
   662 module_param(ec_device_master_index, int, 0);
   657 MODULE_PARM_DESC(ec_device_index, "Index of the device reserved for EtherCAT.");
   663 MODULE_PARM_DESC(ec_device_index, "Index of the device reserved for EtherCAT.");
       
   664 MODULE_PARM_DESC(ec_device_master_index, "Index of the EtherCAT master to register the device.");
   658 
   665 
   659 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
   666 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
   660 
   667 
   661 static int read_eeprom (void __iomem *ioaddr, int location, int addr_len);
   668 static int read_eeprom (void __iomem *ioaddr, int location, int addr_len);
   662 static int rtl8139_open (struct net_device *dev);
   669 static int rtl8139_open (struct net_device *dev);
  1014                 printk("EtherCAT registering board %d.\n", board_idx);
  1021                 printk("EtherCAT registering board %d.\n", board_idx);
  1015 
  1022 
  1016                 if (EtherCAT_device_assign(&rtl_ecat_dev, dev) < 0)
  1023                 if (EtherCAT_device_assign(&rtl_ecat_dev, dev) < 0)
  1017                   goto err_out;
  1024                   goto err_out;
  1018 
  1025 
  1019                 strcpy(dev->name,"ECAT");  //device name überschreiben
  1026                 strcpy(dev->name,"ecat0"); //device name überschreiben
  1020 	}
  1027 	}
  1021 
  1028 
  1022 	/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  1029 	/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  1023 
  1030 
  1024 	ioaddr = tp->mmio_addr;
  1031 	ioaddr = tp->mmio_addr;
  2953 	printk (KERN_INFO RTL8139_DRIVER_NAME "\n");
  2960 	printk (KERN_INFO RTL8139_DRIVER_NAME "\n");
  2954 #endif
  2961 #endif
  2955 
  2962 
  2956         /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  2963         /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  2957 
  2964 
       
  2965         printk(KERN_INFO "Initializing RTL8139-EtherCAT module.\n");
       
  2966 
  2958         EtherCAT_device_init(&rtl_ecat_dev);
  2967         EtherCAT_device_init(&rtl_ecat_dev);
  2959         rtl_ecat_dev.isr = rtl8139_interrupt;
  2968         rtl_ecat_dev.isr = rtl8139_interrupt;
  2960 
  2969 
       
  2970         if (pci_module_init(&rtl8139_pci_driver) < 0)
       
  2971         {
       
  2972           printk(KERN_ERR "Could not init PCI module.\n");
       
  2973           return -1;
       
  2974         }
       
  2975 
       
  2976         printk(KERN_INFO "EtherCAT device index is %i.\n", ec_device_index);
       
  2977 
       
  2978         if (rtl_ecat_dev.dev)
       
  2979         {
       
  2980           if ((rtl_ecat_master = EtherCAT_master(ec_device_master_index)) == NULL)
       
  2981           {
       
  2982             printk(KERN_ERR "Could not get EtherCAT master %i.\n",
       
  2983                    ec_device_master_index);
       
  2984             goto out_module;
       
  2985           }
       
  2986 
       
  2987           printk(KERN_INFO "Registering EtherCAT device...\n");
       
  2988           if (EtherCAT_register_device(rtl_ecat_master, &rtl_ecat_dev) < 0)
       
  2989           {
       
  2990             printk(KERN_ERR "Could not register device.\n");
       
  2991             goto out_module;
       
  2992           }
       
  2993 
       
  2994           printk(KERN_INFO "EtherCAT device registered and opened.\n");
       
  2995         }
       
  2996         else
       
  2997         {
       
  2998           printk(KERN_WARNING "NO EtherCAT device registered!\n");
       
  2999         }
       
  3000 
       
  3001         return 0;
       
  3002 
       
  3003       out_module:
       
  3004 
       
  3005         pci_unregister_driver(&rtl8139_pci_driver);
       
  3006         return -1;
       
  3007 
  2961         /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  3008         /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  2962 
       
  2963 	return pci_module_init (&rtl8139_pci_driver);
       
  2964 }
  3009 }
  2965 
  3010 
  2966 
  3011 
  2967 static void __exit rtl8139_cleanup_module (void)
  3012 static void __exit rtl8139_cleanup_module (void)
  2968 {
  3013 {
  2969 	pci_unregister_driver (&rtl8139_pci_driver);
       
  2970 
       
  2971         /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  3014         /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  2972 
  3015 
       
  3016         printk(KERN_INFO "Cleaning up RTL8139-EtherCAT module...\n");
       
  3017 
       
  3018         if (rtl_ecat_master && rtl_ecat_dev.dev)
       
  3019         {
       
  3020           printk(KERN_INFO "Unregistering RTL8139-EtherCAT device...\n");
       
  3021           EtherCAT_unregister_device(rtl_ecat_master, &rtl_ecat_dev);
       
  3022         }
       
  3023 
       
  3024 	pci_unregister_driver(&rtl8139_pci_driver);
  2973         EtherCAT_device_clear(&rtl_ecat_dev);
  3025         EtherCAT_device_clear(&rtl_ecat_dev);
       
  3026 
       
  3027         printk(KERN_INFO "RTL8139-EtherCAT module cleaned up.\n");
  2974 
  3028 
  2975         /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  3029         /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
  2976 }
  3030 }
  2977 
  3031 
  2978 
  3032 
  2979 module_init(rtl8139_init_module);
  3033 module_init(rtl8139_init_module);
  2980 module_exit(rtl8139_cleanup_module);
  3034 module_exit(rtl8139_cleanup_module);
  2981 
       
  2982 EXPORT_SYMBOL(rtl_ecat_dev);