• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

dm9000c移值新内核linux-4.1.24

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

错误 1

/home/dm9000/dm9dev9000c.c:309: error: conflicting types for 'phy_read'
include/linux/phy.h:637: error: previous definition of 'phy_read' was here
/home/dm9000/dm9dev9000c.c:310: error: conflicting types for 'phy_write'
include/linux/phy.h:652: error: previous definition of 'phy_write' was here

linux/phy.h 也定义了这个函数,所以这里要改名.
phy_read 改名为 dm9000_phy_read

错误 2
dm9dev9000c.c:356: error: implicit declaration of function 'SET_MODULE_OWNER'
查看 linux2.6.22 源码查看发现只是一个宏定义 #define SET_MODULE_OWNER(dev) do { } while (0)

错误 3
/home/dm9000/dm9dev9000c.c:407: error: 'struct net_device' has no member named 'priv'
/home/dm9000/dm9dev9000c.c:408: error: 'struct net_device' has no member named 'priv'
/home/dm9000/dm9dev9000c.c:422: error: 'struct net_device' has no member named 'open'
/home/dm9000/dm9dev9000c.c:423: error: 'struct net_device' has no member named 'hard_start_xmit'

/* Allocated board information structure */
memset(dev->priv, 0, sizeof(struct board_info));
db = (board_info_t *)dev->priv;
改为
db = netdev_priv(dev);
/* Allocated board information structure */
memset(db, 0, sizeof(struct board_info));

这里改的比较多,最后见补丁吧
static const struct net_device_ops dm9000_netdev_ops = {
.ndo_open = dm9000_open,
.ndo_stop = dm9000_stop,
.ndo_start_xmit = dm9000_start_xmit,
.ndo_tx_timeout = dm9000_timeout,
.ndo_set_rx_mode = dm9000_hash_table,
.ndo_do_ioctl = dm9000_ioctl,
.ndo_change_mtu = eth_change_mtu,
.ndo_set_features = dm9000_set_features,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = dm9000_poll_controller,
#endif
};

需要复制 内核自带的 dm9000.h 

   1 /*
   2 
   3   dm9ks.c: Version 2.08 2007/02/12 
   4   
   5         A Davicom DM9000/DM9010 ISA NIC fast Ethernet driver for Linux.
   6 
   7     This program is free software; you can redistribute it and/or
   8     modify it under the terms of the GNU General Public License
   9     as published by the Free Software Foundation; either version 2
  10     of the License, or (at your option) any later version.
  11 
  12     This program is distributed in the hope that it will be useful,
  13     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15     GNU General Public License for more details.
  16 
  17 
  18   (C)Copyright 1997-2007 DAVICOM Semiconductor,Inc. All Rights Reserved.
  19 
  20 V2.00 Spenser - 01/10/2005
  21             - Modification for PXA270 MAINSTONE.
  22             - Modified dmfe_tx_done().
  23             - Add dmfe_timeout().
  24 V2.01    10/07/2005    -Modified dmfe_timer()
  25             -Dected network speed 10/100M
  26 V2.02    10/12/2005    -Use link change to chage db->Speed
  27             -dmfe_open() wait for Link OK  
  28 V2.03    11/22/2005    -Power-off and Power-on PHY in dmfe_init_dm9000()
  29             -support IOL
  30 V2.04    12/13/2005    -delay 1.6s between power-on and power-off in 
  31              dmfe_init_dm9000()
  32             -set LED mode 1 in dmfe_init_dm9000()
  33             -add data bus driving capability in dmfe_init_dm9000()
  34              (optional)
  35 10/3/2006    -Add DM8606 read/write function by MDC and MDIO
  36 V2.06    01/03/2007    -CONT_RX_PKT_CNT=0xFFFF
  37             -modify dmfe_tx_done function
  38             -check RX FIFO pointer
  39             -if using physical address, re-define I/O function
  40             -add db->cont_rx_pkt_cnt=0 at the front of dmfe_packet_receive()
  41 V2.08    02/12/2007    -module parameter macro
  42             2.4  MODULE_PARM
  43             2.6  module_param
  44             -remove #include <linux/config>
  45               -fix dmfe_interrupt for kernel 2.6.20                  
  46 V2.09 05/24/2007    -support ethtool and mii-tool
  47 05/30/2007    -fix the driver bug when ifconfig eth0 (-)promisc and (-)allmulti.
  48 06/05/2007    -fix dm9000b issue(ex. 10M TX idle=65mA, 10M harmonic)
  49             -add flow control function (option)
  50 10/01/2007  -Add #include <asm/uaccess.h>
  51             -Modyfy dmfe_do_ioctl for kernel 2.6.7
  52 11/23/2007    -Add TDBUG to check TX FIFO pointer shift
  53             - Remove check_rx_ready() 
  54           - Add #define CHECKSUM to modify CHECKSUM function    
  55 12/20/2007  -Modify TX timeout routine(+)check TCR&0x01 
  56 
  57 */
  58 
  59 //#define CHECKSUM
  60 //#define TDBUG        /* check TX FIFO pointer */
  61 //#define RDBUG   /* check RX FIFO pointer */
  62 //#define DM8606
  63 
  64 #define DRV_NAME    "dm9KS"
  65 #define DRV_VERSION    "2.09"
  66 #define DRV_RELDATE    "2007-11-22"
  67 
  68 #ifdef MODVERSIONS
  69 #include <linux/modversions.h>
  70 #endif
  71 
  72 //#include <linux/config.h>
  73 #include <linux/init.h>                
  74 #include <linux/delay.h>
  75 #include <linux/module.h>
  76 #include <linux/ioport.h>
  77 #include <linux/netdevice.h>
  78 #include <linux/etherdevice.h>
  79 #include <linux/skbuff.h>
  80 #include <linux/version.h>
  81 #include <asm/dma.h>
  82 #include <linux/spinlock.h>
  83 #include <linux/crc32.h>
  84 #include <linux/mii.h>
  85 #include <linux/ethtool.h>
  86 #include <asm/uaccess.h>
  87 
  88 #ifdef CONFIG_ARCH_MAINSTONE
  89 #include <asm/io.h>
  90 #include <asm/hardware.h>
  91 #include <asm/irq.h>
  92 #endif
  93 
  94 #include <asm/delay.h>
  95 #include <asm/irq.h>
  96 #include <asm/io.h>
  97 #include "dm9000.h"
  98 
  99 
 100 
 101 /* Board/System/Debug information/definition ---------------- */
 102 
 103 #define DM9KS_ID        0x90000A46
 104 #define DM9010_ID        0x90100A46
 105 /*-------register name-----------------------*/
 106 #define DM9KS_NCR        0x00    /* Network control Reg.*/
 107 #define DM9KS_NSR        0x01    /* Network Status Reg.*/
 108 #define DM9KS_TCR        0x02    /* TX control Reg.*/
 109 #define DM9KS_RXCR        0x05    /* RX control Reg.*/
 110 #define DM9KS_BPTR        0x08
 111 #define DM9KS_FCTR        0x09
 112 #define DM9KS_FCR            0x0a
 113 #define DM9KS_EPCR        0x0b
 114 #define DM9KS_EPAR        0x0c
 115 #define DM9KS_EPDRL        0x0d
 116 #define DM9KS_EPDRH        0x0e
 117 #define DM9KS_GPR            0x1f    /* General purpose register */
 118 #define DM9KS_CHIPR        0x2c
 119 #define DM9KS_TCR2        0x2d
 120 #define DM9KS_SMCR        0x2f     /* Special Mode Control Reg.*/
 121 #define DM9KS_ETXCSR    0x30    /* Early Transmit control/status Reg.*/
 122 #define    DM9KS_TCCR        0x31    /* Checksum cntrol Reg. */
 123 #define DM9KS_RCSR        0x32    /* Receive Checksum status Reg.*/
 124 #define DM9KS_BUSCR        0x38
 125 #define DM9KS_MRCMDX    0xf0
 126 #define DM9KS_MRCMD        0xf2
 127 #define DM9KS_MDRAL        0xf4
 128 #define DM9KS_MDRAH        0xf5
 129 #define DM9KS_MWCMD        0xf8
 130 #define DM9KS_MDWAL        0xfa
 131 #define DM9KS_MDWAH        0xfb
 132 #define DM9KS_TXPLL        0xfc
 133 #define DM9KS_TXPLH        0xfd
 134 #define DM9KS_ISR            0xfe
 135 #define DM9KS_IMR            0xff
 136 /*---------------------------------------------*/
 137 #define DM9KS_REG05        0x30    /* SKIP_CRC/SKIP_LONG */ 
 138 #define DM9KS_REGFF        0xA3    /* IMR */
 139 #define DM9KS_DISINTR    0x80
 140 
 141 #define DM9KS_PHY            0x40    /* PHY address 0x01 */
 142 #define DM9KS_PKT_RDY        0x01    /* Packet ready to receive */
 143 
 144 /* Added for PXA of MAINSTONE */
 145 #ifdef CONFIG_ARCH_MAINSTONE
 146 #include <asm/arch/mainstone.h>
 147 #define DM9KS_MIN_IO        (MST_ETH_PHYS + 0x300)
 148 #define DM9KS_MAX_IO            (MST_ETH_PHYS + 0x370)
 149 #define DM9K_IRQ        MAINSTONE_IRQ(3)
 150 #else
 151 #define DM9KS_MIN_IO        0x300
 152 #define DM9KS_MAX_IO        0x370
 153 #define DM9KS_IRQ        3
 154 #endif
 155 
 156 #define DM9KS_VID_L        0x28
 157 #define DM9KS_VID_H        0x29
 158 #define DM9KS_PID_L        0x2A
 159 #define DM9KS_PID_H        0x2B
 160 
 161 #define DM9KS_RX_INTR        0x01
 162 #define DM9KS_TX_INTR        0x02
 163 #define DM9KS_LINK_INTR        0x20
 164 
 165 #define DM9KS_DWORD_MODE    1
 166 #define DM9KS_BYTE_MODE        2
 167 #define DM9KS_WORD_MODE        0
 168 
 169 #define TRUE            1
 170 #define FALSE            0
 171 /* Number of continuous Rx packets */
 172 #define CONT_RX_PKT_CNT        0xFFFF
 173 
 174 #define DMFE_TIMER_WUT  jiffies+(HZ*5)    /* timer wakeup time : 5 second */
 175 
 176 #ifdef DM9KS_DEBUG
 177 #define DMFE_DBUG(dbug_now, msg, vaule)\
 178 if (dmfe_debug||dbug_now) printk(KERN_ERR "dmfe: %s %x\n", msg, vaule)
 179 #else
 180 #define DMFE_DBUG(dbug_now, msg, vaule)\
 181 if (dbug_now) printk(KERN_ERR "dmfe: %s %x\n", msg, vaule)
 182 #endif
 183 
 184 #ifndef CONFIG_ARCH_MAINSTONE
 185 #pragma pack(push, 1)
 186 #endif
 187 
 188 typedef struct _RX_DESC
 189 {
 190     u8 rxbyte;
 191     u8 status;
 192     u16 length;
 193 }RX_DESC;
 194 
 195 typedef union{
 196     u8 buf[4];
 197     RX_DESC desc;
 198 } rx_t;
 199 #ifndef CONFIG_ARCH_MAINSTONE
 200 #pragma pack(pop)
 201 #endif
 202 
 203 enum DM9KS_PHY_mode {
 204     DM9KS_10MHD   = 0, 
 205     DM9KS_100MHD  = 1, 
 206     DM9KS_10MFD   = 4,
 207     DM9KS_100MFD  = 5, 
 208     DM9KS_AUTO    = 8, 
 209 };
 210 
 211 /* Structure/enum declaration ------------------------------- */
 212 typedef struct board_info { 
 213     u32 io_addr;/* Register I/O base address */
 214     u32 io_data;/* Data I/O address */
 215     u8 op_mode;/* PHY operation mode */
 216     u8 io_mode;/* 0:word, 2:byte */
 217     u8 Speed;    /* current speed */
 218     u8 chip_revision;
 219     int rx_csum;/* 0:disable, 1:enable */
 220     
 221     u32 reset_counter;/* counter: RESET */ 
 222     u32 reset_tx_timeout;/* RESET caused by TX Timeout */
 223     int tx_pkt_cnt;
 224     int cont_rx_pkt_cnt;/* current number of continuos rx packets  */
 225     struct net_device_stats stats;
 226     
 227     struct timer_list timer;
 228     unsigned char srom[128];
 229     spinlock_t lock;
 230     struct mii_if_info mii;
 231 } board_info_t;
 232 /* Global variable declaration ----------------------------- */
 233 /*static int dmfe_debug = 0;*/
 234 static struct net_device * dmfe_dev = NULL;
 235 static struct ethtool_ops dmfe_ethtool_ops;
 236 /* For module input parameter */
 237 static int mode       = DM9KS_AUTO;  
 238 static int media_mode = DM9KS_AUTO;
 239 static int  irq        = DM9KS_IRQ;
 240 static int iobase     = DM9KS_MIN_IO;
 241 
 242 #if 0  // use physical address; Not virtual address
 243 #ifdef outb
 244     #undef outb
 245 #endif
 246 #ifdef outw
 247     #undef outw
 248 #endif
 249 #ifdef outl
 250     #undef outl
 251 #endif
 252 #ifdef inb
 253     #undef inb
 254 #endif
 255 #ifdef inw
 256     #undef inw
 257 #endif
 258 #ifdef inl
 259     #undef inl
 260 #endif
 261 void outb(u8 reg, u32 ioaddr)
 262 {
 263     (*(volatile u8 *)(ioaddr)) = reg;
 264 }
 265 void outw(u16 reg, u32 ioaddr)
 266 {
 267     (*(volatile u16 *)(ioaddr)) = reg;
 268 }
 269 void outl(u32 reg, u32 ioaddr)
 270 {
 271     (*(volatile u32 *)(ioaddr)) = reg;
 272 }
 273 u8 inb(u32 ioaddr)
 274 {
 275     return (*(volatile u8 *)(ioaddr));
 276 }
 277 u16 inw(u32 ioaddr)
 278 {
 279     return (*(volatile u16 *)(ioaddr));
 280 }
 281 u32 inl(u32 ioaddr)
 282 {
 283     return (*(volatile u32 *)(ioaddr));
 284 }
 285 #endif
 286 
 287 /* function declaration ------------------------------------- */
 288 int dmfe_probe1(struct net_device *);
 289 static int dmfe_open(struct net_device *);
 290 static int dmfe_start_xmit(struct sk_buff *, struct net_device *);
 291 static void dmfe_tx_done(unsigned long);
 292 static void dmfe_packet_receive(struct net_device *);
 293 static int dmfe_stop(struct net_device *);
 294 static int dmfe_do_ioctl(struct net_device *, struct ifreq *, int);
 295 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 296 static void dmfe_interrupt(int , void *, struct pt_regs *); 
 297 #else
 298     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
 299     static irqreturn_t dmfe_interrupt(int , void *, struct pt_regs *);
 300     #else
 301     static irqreturn_t dmfe_interrupt(int , void *);/* for kernel 2.6.20 */
 302     #endif
 303 #endif
 304 static void dmfe_timer(unsigned long);
 305 static void dmfe_init_dm9000(struct net_device *);
 306 u8 ior(board_info_t *, int);
 307 void iow(board_info_t *, int, u8);
 308 static u16 dm9000_phy_read(board_info_t *, int);
 309 static void dm9000_phy_write(board_info_t *, int, u16);
 310 static u16 read_srom_word(board_info_t *, int);
 311 static void dm9000_hash_table(struct net_device *);
 312 static void dmfe_timeout(struct net_device *);
 313 static void dmfe_reset(struct net_device *);
 314 static int mdio_read(struct net_device *, int, int);
 315 static void mdio_write(struct net_device *, int, int, int);
 316 static void dmfe_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
 317 static int dmfe_get_settings(struct net_device *, struct ethtool_cmd *);
 318 static int dmfe_set_settings(struct net_device *, struct ethtool_cmd *);
 319 static u32 dmfe_get_link(struct net_device *);
 320 static int dmfe_nway_reset(struct net_device *);
 321 
 322 #ifdef DM8606
 323 #include "dm8606.h"
 324 #endif
 325 
 326 //DECLARE_TASKLET(dmfe_tx_tasklet,dmfe_tx_done,0);
 327 
 328 /* DM9000 network baord routine ---------------------------- */
 329 
 330 /*
 331   Search DM9000 board, allocate space and register it
 332 */
 333 
 334 struct net_device * __init dmfe_probe(void)
 335 {
 336     struct net_device *dev;
 337     int err;
 338     
 339     DMFE_DBUG(0, "dmfe_probe()",0);
 340 
 341 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 342     dev = init_etherdev(NULL, sizeof(struct board_info));
 343     //ether_setup(dev);        
 344 #else
 345     dev= alloc_etherdev(sizeof(struct board_info));
 346 #endif
 347 
 348     if(!dev)
 349         return ERR_PTR(-ENOMEM);
 350 
 351          //SET_MODULE_OWNER(dev);
 352     err = dmfe_probe1(dev);
 353     if (err)
 354         goto out;
 355 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
 356     err = register_netdev(dev);
 357     if (err)
 358         goto out1;
 359 #endif
 360     return dev;
 361 out1:
 362     release_region(dev->base_addr,2);
 363 out:
 364 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 365     kfree(dev);
 366 #else
 367     free_netdev(dev);
 368 #endif
 369     return ERR_PTR(err);
 370 }
 371 
 372 static int dm9000_set_features(struct net_device *dev,
 373     netdev_features_t features)
 374 {
 375     struct board_info *dm = netdev_priv(dev);
 376     netdev_features_t changed = dev->features ^ features;
 377     unsigned long flags;
 378 
 379     if (!(changed & NETIF_F_RXCSUM))
 380         return 0;
 381 
 382     spin_lock_irqsave(&dm->lock, flags);
 383     iow(dm, DM9000_RCSR, (features & NETIF_F_RXCSUM) ? RCSR_CSUM : 0);
 384     spin_unlock_irqrestore(&dm->lock, flags);
 385 
 386     return 0;
 387 }
 388 
 389 
 390 static const struct net_device_ops dm9000_netdev_ops = {
 391     .ndo_open        = dmfe_open,
 392     .ndo_stop        = dmfe_stop,
 393     .ndo_start_xmit        = dmfe_start_xmit,
 394     .ndo_tx_timeout        = dmfe_timeout,
 395     .ndo_do_ioctl        = dmfe_do_ioctl,
 396     .ndo_change_mtu        = eth_change_mtu,
 397     .ndo_set_mac_address= eth_mac_addr,
 398     .ndo_validate_addr    = eth_validate_addr,
 399     .ndo_set_features    = dm9000_set_features,
 400     .ndo_set_rx_mode    = dm9000_hash_table,
 401 #ifdef CONFIG_NET_POLL_CONTROLLER
 402     .ndo_poll_controller    = dm9000_poll_controller,
 403 #endif
 404 };
 405 
 406 int __init dmfe_probe1(struct net_device *dev)
 407 {
 408     struct board_info *db;    /* Point a board information structure */
 409     u32 id_val;
 410     u16 i, dm9000_found = FALSE;
 411     u8 MAC_addr[6]={0x00,0x60,0x6E,0x33,0x44,0x55};
 412     u8 HasEEPROM=0,chip_info;
 413     DMFE_DBUG(0, "dmfe_probe1()",0);
 414 
 415     /* Search All DM9000 serial NIC */
 416     do {
 417         outb(DM9KS_VID_L, iobase); /* DM9000C的索引寄存器(cmd引脚为0) */
 418         id_val = inb(iobase + 4);  /* 读DM9000C的数据寄存 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#基础知识(三).主子对话框数值传递发布时间:2022-07-13
下一篇:
[Unityc#]c#中的反射发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap