厂家提供的DM9000网卡代码

上传人:321****123 文档编号:156155767 上传时间:2022-09-26 格式:DOCX 页数:78 大小:91.71KB
返回 下载 相关 举报
厂家提供的DM9000网卡代码_第1页
第1页 / 共78页
厂家提供的DM9000网卡代码_第2页
第2页 / 共78页
厂家提供的DM9000网卡代码_第3页
第3页 / 共78页
点击查看更多>>
资源描述
/* dm9ks.c: Version 2.08 2007/02/12 A Daavicomm DM90000/DMM9010 ISA NNIC faast Ettherneet driiver ffor Liinux.This pprograam is free softwware; you ccan reedistrributee it aand/orrmodifyy it uunder the tterms of thhe GNUU Geneeral PPublicc Liceenseas pubblisheed by the FFree SSoftwaare Fooundattion; eitheer verrsion 2of thee Liceense, or (aat youur opttion) any llater versiion.This pprograam is distrributeed in the hhope tthat iit willl be usefuul,but WIITHOUTT ANY WARRAANTY; withoout evven thhe impplied warraanty oofMERCHAANTABIILITY or FIITNESSS FOR A PARRTICULLAR PUURPOSEE. Seee theeGNU Geenerall Publlic Liicensee for more detaiils. (C)Coopyrigght 19997-20007 DAAVICOMM Semiiconduuctor,Inc. All RRightss Reseerved.V2.00 SSpenseer - 001/10/2005- Moodificcationn for PXA2770 MAIINSTONNE.- Moodifieed dmffe_tx_done().- Addd dmffe_timmeout().V2.01110/07/2005-Modiified dmfe_timerr()-Deccted nnetworrk speeed 100/100MMV2.02110/12/2005-Use link changge to chagee db-Speedd-dmffe_opeen() wwait ffor Liink OKK V2.03111/22/2005-Poweer-offf and Powerr-on PPHY inn dmfee_initt_dm90000()-suppport IOLV2.04112/13/2005-delaay 1.66s bettween powerr-on aand poower-ooff inn dmffe_iniit_dm99000()-sett LED mode 1 in dmfe_init_dm90000()-addd dataa bus driviing caapabillity iin dmffe_iniit_dm99000() (opptionaal)10/3/20006-Add DM86006 reaad/wriite fuunctioon by MDC aand MDDIOV2.06001/03/2007-CONTT_RX_PPKT_CNNT=0xFFFFF-moddify ddmfe_ttx_donne funnctionn-cheeck RXX FIFOO poinnter-if usingg physsical addreess, rre-deffine II/O fuunctioon-addd db-cont_rx_pkkt_cntt=0 att the frontt of ddmfe_ppackett_receeive()V2.08002/12/2007-moduule paarametter maacro2.4 MODUULE_PAARM2.6 moduule_paaram-remmove #incluude -ffix dmmfe_innterruupt foor kerrnel 22.6.200 V2.09 005/24/2007-suppport eethtoool andd mii-tool05/30/22007-fix the ddriverr bug when ifconnfig eeth0 (-)proomisc and (-)alllmultii.06/05/22007-fix dm90000b isssue(eex. 100M TX idle=65mA, 10M harmoonic)-addd floww conttrol ffunctiion (ooptionn)10/01/22007 -Add #incllude -Moddyfy ddmfe_ddo_iocctl foor kerrnel 22.6.711/23/22007-Add TDBUGG to ccheck TX FIIFO poointerr shifft- Reemove checkk_rx_rready() - AAdd #ddefinee CHECCKSUM to moodify CHECKKSUM ffunctiion12/20/22007 -Modiify TXX timeeout rroutinne(+)ccheck TCR&00x01 */#defiine CHHECKSUUM/#defiine TDDBUG/* chheck TTX FIFFO poiinter */#defiine RDDBUG /* ccheck RX FIIFO poointerr */#defiine DMM8606#definee DRV_NAMEdm9KKS#definee DRV_VERSIION2.099#definee DRV_RELDAATE20077-11-222#ifdef MODVEERSIONNS#includde #endif/#incllude #includde #includde #includde #includde #includde #includde #includde #includde #includde #includde #includde #includde #includde #includde #ifdef CONFIIG_ARCCH_MAIINSTONNE#includde #includde #includde #endif/* Boarrd/Sysstem/DDebug inforrmatioon/deffinitiion - */#definee DM9KKS_ID0x900000A466#definee DM90010_IDD0x901100A466/*-reggisterr namee-*/#definee DM9KKS_NCRR0x00/* Neetworkk conttrol RReg.*/#definee DM9KKS_NSRR0x01/* Neetworkk Stattus Reeg.*/#definee DM9KKS_TCRR0x02/* TXX conttrol RReg.*/#definee DM9KKS_RXCCR0x05/* RXX conttrol RReg.*/#definee DM9KKS_BPTTR0x08#definee DM9KKS_FCTTR0x09#definee DM9KKS_FCRR0x0a#definee DM9KKS_EPCCR0x0b#definee DM9KKS_EPAAR0x0c#definee DM9KKS_EPDDRL0x0d#definee DM9KKS_EPDDRH0x0e#definee DM9KKS_GPRR0x1f/* Geenerall purppose rregistter */#definee DM9KKS_CHIIPR0x2c#definee DM9KKS_TCRR20x2d#definee DM9KKS_SMCCR0x2f /* Sppeciall Modee Conttrol RReg.*/#definee DM9KKS_ETXXCSR0x30/* Eaarly TTransmmit coontroll/stattus Reeg.*/#defineeDM9KSS_TCCRR0x31/* Chhecksuum cnttrol RReg. */#definee DM9KKS_RCSSR0x32/* Reeceivee Checcksum statuus Regg.*/#definee DM9KKS_BUSSCR0x38#definee DM9KKS_MRCCMDX0xf0#definee DM9KKS_MRCCMD0xf2#definee DM9KKS_MDRRAL0xf4#definee DM9KKS_MDRRAH0xf5#definee DM9KKS_MWCCMD0xf8#definee DM9KKS_MDWWAL0xfa#definee DM9KKS_MDWWAH0xfb#definee DM9KKS_TXPPLL0xfc#definee DM9KKS_TXPPLH0xfd#definee DM9KKS_ISRR0xfe#definee DM9KKS_IMRR0xff/*-*/#definee DM9KKS_REGG050x30/* SKKIP_CRRC/SKIIP_LONNG */ #definee DM9KKS_REGGFF0xA3/* IMMR */#definee DM9KKS_DISSINTR0x80#definee DM9KKS_PHYY0x40/* PHHY adddress 0x01 */#definee DM9KKS_PKTT_RDY0x01/* Paacket readyy to rreceivve */* Addeed forr PXA of MAAINSTOONE */#ifdef CONFIIG_ARCCH_MAIINSTONNE#includde #definee DM9KKS_MINN_IO(MST_ETH_PPHYS + 0x3000)#definee DM9KKS_MAXX_IO (MST_ETH_PPHYS + 0x3770)#definee DM9KK_IRQMAINSSTONE_IRQ(33)#else#definee DM9KKS_MINN_IO0x3000#definee DM9KKS_MAXX_IO0x3700#definee DM9KKS_IRQQ3#endif#definee DM9KKS_VIDD_L0x28#definee DM9KKS_VIDD_H0x29#definee DM9KKS_PIDD_L0x2A#definee DM9KKS_PIDD_H0x2B#definee DM9KKS_RX_INTR0x01#definee DM9KKS_TX_INTR0x02#definee DM9KKS_LINNK_INTTR0x20#definee DM9KKS_DWOORD_MOODE1#definee DM9KKS_BYTTE_MODDE2#definee DM9KKS_WORRD_MODDE0#definee TRUEE1#definee FALSSE0/* Numbber off conttinuouus Rx packeets */#definee CONTT_RX_PPKT_CNNT0xFFFFF#definee DMFEE_TIMEER_WUTT jifffies+(HZ*55)/* tiimer wwakeupp timee : 5 seconnd */#ifdef DM9KSS_DEBUUG#definee DMFEE_DBUGG(dbugg_now, msg, vaulle)if (dmffe_debbug|ddbug_nnow) pprintkk(KERNN_ERR dmfee: %s %xn, msgg, vauule)#else#definee DMFEE_DBUGG(dbugg_now, msg, vaulle)if (dbuug_noww) priintk(KKERN_EERR ddmfe: %s %xxn, msg, vaulee)#endif#ifndeff CONFFIG_ARRCH_MAAINSTOONE#pragmaa packk(pushh, 1)#endiftypedeff struuct _RRX_DESSCu8 rxbbyte;u8 staatus;u16 leength;RX_DESSC;typedeff unioonu8 buff4;RX_DESSC dessc; rx_t;#ifndeff CONFFIG_ARRCH_MAAINSTOONE#pragmaa packk(pop)#endifenum DMM9KS_PPHY_moode DM9KS_10MHDD = 0, DM9KS_100MHHD = 1, DM9KS_10MFDD = 4,DM9KS_100MFFD = 5, DM9KS_AUTO = 8, ;/* Struucturee/enumm decllaratiion - */typedeff struuct booard_iinfo u32 ioo_addrr;/* RRegistter I/O basse adddress */u32 ioo_dataa;/* DData II/O adddresss */u8 op_mode;/* PHHY opeeratioon modde */u8 io_mode;/* 0:word, 2:byyte */u8 Speeed;/* cuurrentt speeed */u8 chiip_revvisionn;int rxx_csumm;/* 00:disaable, 1:enaable */u32 reeset_ccounteer;/* countter: RRESET */ u32 reeset_ttx_timmeout;/* REESET ccausedd by TTX Timmeout */int txx_pkt_cnt;int coont_rxx_pkt_cnt;/* currrent numbeer of contiinuos rx paacketss */structt net_devicce_staats sttats;structt timeer_lisst timmer;unsignned chhar srrom1228;spinloock_t lock;structt mii_if_innfo miii; boardd_infoo_t;/* Globbal vaariablle decclarattion - */*statiic intt dmfee_debuug = 00;*/static strucct nett_deviice * dmfe_dev = NULLL;static strucct ethhtool_ops ddmfe_eethtoool_opss;/* For modulle inpput paarametter */static int mmode = DM99KS_AUUTO; static int mmedia_mode = DM99KS_AUUTO;static int irq = DMM9KS_IIRQ;static int iiobasee = DM99KS_MIIN_IO;#if 0 / usse phyysicall addrress; Not vvirtuaal adddress#ifdef outb#undeff outbb#endif#ifdef outw#undeff outww#endif#ifdef outl#undeff outll#endif#ifdef inb#undeff inb#endif#ifdef inw#undeff inw#endif#ifdef inl#undeff inl#endifvoid ouutb(u88 reg, u32 ioadddr)(*(vollatilee u8 *)(ioaaddr) = reeg;void ouutw(u116 regg, u322 ioadddr)(*(vollatilee u16 *)(iooaddr) = rreg;void ouutl(u332 regg, u322 ioadddr)(*(vollatilee u32 *)(iooaddr) = rreg;u8 inb(u32 iioaddrr)returnn (*(vvolatiile u88 *)(iioaddrr);u16 inww(u32 ioadddr)returnn (*(vvolatiile u116 *)(ioadddr);u32 inll(u32 ioadddr)returnn (*(vvolatiile u332 *)(ioadddr);#endif/* funcction declaaratioon - */int dmffe_proobe1(sstructt net_devicce *);static int ddmfe_oopen(sstructt net_devicce *);static int ddmfe_sstart_xmit(strucct sk_buff *, sttruct net_ddevicee *);static void dmfe_tx_doone(unnsigneed lonng);static void dmfe_packeet_recceive(strucct nett_deviice *);static int ddmfe_sstop(sstructt net_devicce *);static strucct nett_deviice_sttats * dmfee_get_statss(struuct neet_devvice *); static int ddmfe_ddo_iocctl(sttruct net_ddevicee *, sstructt ifreeq *, int);#if LINNUX_VEERSIONN_CODEE KEERNEL_VERSIION(2,5,0)static void dmfe_interrrupt(int , voidd *, sstructt pt_rregs *); #else#if LIINUX_VVERSIOON_CODDE KKERNELL_VERSSION(22,6,199)staticc irqrreturnn_t dmmfe_innterruupt(innt , vvoid *, strruct ppt_reggs *);#elsestaticc irqrreturnn_t dmmfe_innterruupt(innt , vvoid *);/* for kkernell 2.6.20 */#endiff#endifstatic void dmfe_timerr(unsiigned long);static void dmfe_init_dm90000(strruct nnet_deevice *);static unsiggned llong ccal_CRRC(unssignedd charr *, uunsignned innt, u88);u8 ior(boardd_infoo_t *, int);void ioow(boaard_innfo_t *, innt, u88);static u16 pphy_reead(booard_iinfo_tt *, iint);static void phy_wwrite(boardd_infoo_t *, int, u16);static u16 rread_ssrom_wword(bboard_info_t *, int);static void dm90000_hassh_tabble(sttruct net_ddevicee *);static void dmfe_timeoout(sttruct net_ddevicee *);static void dmfe_resett(struuct neet_devvice *);static int mmdio_rread(sstructt net_devicce *, int, int);static void mdio_writee(struuct neet_devvice *, intt, intt, intt);static void dmfe_get_ddrvinffo(strruct nnet_deevice *, sttruct ethtoool_drrvinfoo *);static int ddmfe_gget_seettinggs(strruct nnet_deevice *, sttruct ethtoool_cmmd *);static int ddmfe_sset_seettinggs(strruct nnet_deevice *, sttruct ethtoool_cmmd *);static u32 ddmfe_gget_liink(sttruct net_ddevicee *);static int ddmfe_nnway_rreset(strucct nett_deviice *);static uint332_t ddmfe_gget_rxx_csumm(struuct neet_devvice *);static uint332_t ddmfe_gget_txx_csumm(struuct neet_devvice *);static int ddmfe_sset_rxx_csumm(struuct neet_devvice *, uinnt32_tt );static int ddmfe_sset_txx_csumm(struuct neet_devvice *, uinnt32_tt );#ifdef DM86006#includde dmm8606.h#endif/DECLAARE_TAASKLETT(dmfee_tx_ttaskleet,dmffe_tx_done,0);/* DM90000 neetworkk baorrd rouutine - */* Searcch DM99000 bboard, alloocate spacee and regisster iit*/struct net_ddevicee * _init dmfe_probee(voidd)structt net_devicce *deev;int errr;DMFE_DDBUG(00, dmmfe_prrobe(),0);#if LINNUX_VEERSIONN_CODEE KEERNEL_VERSIION(2,5,0)err = regisster_nnetdevv(dev);if (errr)goto out1;#endifreturnn dev;out1:releasse_reggion(ddev-bbase_aaddr,22);out:#if LINNUX_VEERSIONN_CODEE KEERNEL_VERSIION(2,5,0)kfree(dev);#elsefree_nnetdevv(dev);#endifreturnn ERR_PTR(eerr);int _iinit ddmfe_pprobe11(struuct neet_devvice *dev)structt boarrd_inffo *dbb; /* Pooint aa boarrd infformattion sstructture */u32 idd_val;u16 i, dm90000_foound = FALSSE;u8 MACC_addrr6=0x00,0x60,0x6E,0x33,0x44,0x55;u8 HassEEPROOM=0,cchip_iinfo;DMFE_DDBUG(00, dmmfe_prrobe1(),0);/* Seaarch AAll DMM9000 seriaal NICC */do outb(DM9KSS_VID_L, ioobase);id_vaal = iinb(ioobase + 4);outb(DM9KSS_VID_H, ioobase);id_vaal |= inb(iiobasee + 4) 88;outb(DM9KSS_PID_L, ioobase);id_vaal |= inb(iiobasee + 4) 116;outb(DM9KSS_PID_H, ioobase);id_vaal |= inb(iiobasee + 4) namee)retturn -ENODEEV;prinntk(KEERN_ERRR I/O: %x, VVID: %x n,iobaase, iid_vall);dm90000_foound = TRUEE;/* AAllocaated bboard inforrmatioon strructurre */memsset(deev-prriv, 00, sizzeof(sstructt boarrd_inffo);db = (boaard_innfo_t *)devv-priiv;dmfee_dev = dev;db-io_adddr = iobaase;db-io_daata = iobasse + 44; db-chip_revission = ior(db, DDM9KS_CHIPRR);chipp_infoo = ioor(db,0x43);if(db-cchip_rrevisiion!=00x1A) | (chip_info&(155)!=00) | (chiip_inffo&(1basee_addrr = iobbase;dev-irq = irqq;dev-openn = &dmmfe_oppen;dev-hardd_starrt_xmiit = &dmmfe_sttart_xxmit;dev-watcchdog_timeoo= 5*HHZ;dev-tx_ttimeouut= dmffe_timmeout;dev-stopp = &dmmfe_sttop;dev-get_statss = &dmmfe_geet_staats;dev-set_multiicast_list = &dmm9000_hash_tablee;dev-do_iioctl = &dmmfe_doo_iocttl;#if LINNUX_VEERSIONN_CODEE = KKERNELL_VERSSION(22,4,288)dev-ethttool_oops = &dmfee_ethttool_oops;#endif#ifdef CHECKKSUM/deev-feeaturees |= NETIIF_F_IIP_CSUUM;dev-feattures |= NNETIF_F_IP_CSUM|NETIFF_F_SGG;#endifdb-mii.ddev = dev;db-mii.mmdio_rread = mdioo_readd;db-mii.mmdio_wwrite = mdiio_wriite;db-mii.pphy_idd = 1;#if LINNUX_VEERSIONN_CODEE = KKERNELL_VERSSION(22,4,200)db-mii.pphy_idd_maskk = 0xx1F; db-mii.rreg_nuum_massk = 00x1F; #endif/dbb-msgg_enabble =(debugg = 00 ? DMMFE_DEEF_MSGG_ENABBLE : (1 debbug) - 1);/* RRead SSROM ccontennt */for (i=0; issrom)i = read_srom_word(db, ii);/* GGet thhe PIDD and VID ffrom EEEPROMM to ccheck */id_vval = (u116 *)ddb-srrom)44)|(u16 *)db-sromm)516); prinntk(iid_vall=%xnn, idd_val);if (id_vaal = DM9KSS_ID | id_val = DM99010_IID) HassEEPROOM =1;/* SSet Noode Adddresss */for (i=0; ideev_adddri = db-srommi;elsse/* Noo EEPRROM */deev-deev_adddri = MACC_addrri;/ennd of if()iobasse += 0x10;whilee(!dm99000_ffound & ioobase ppriv;u8 regg_nsr;int i;DMFE_DDBUG(00, dmmfe_oppen, 0);if (reequestt_irq(dev-irq,&dmfe_interrrupt,0,devv-namme,devv) returrn -EAAGAIN;/* Iniitilizze DM9910X bboard */dmfe_iinit_ddm90000(dev);#ifdef DM86006/ conntrol DM86006printkk(86606reeg0=0xx%04xn,dmm8606_read(db,0);printkk(86606reeg1=0xx%04xn,dmm8606_read(db,0xx1);#endif /* Iniit driiver vvariabble */db-reeset_ccounteer = 0;db-reeset_ttx_timmeout = 0;db-coont_rxx_pkt_cnt= 0;/* cheeck liink sttate aand meedia sspeed */db-Sppeed =10;i=0;do reg_nnsr = ior(ddb,DM99KS_NSSR);if(reeg_nsrr & 0xx40) /* linnk OK! */* wwait ffor deetecteed Speeed */mdellay(2000);reg_nsr = ior(db,DMM9KS_NNSR);if(rreg_nssr & 00x80)db-Speeed =100;elseedb-Speeed =1000;breaak;i+;mdelaay(1);whilee(iSppeed);/* sett and activve a ttimer proceess */init_ttimer(&db-timerr);db-tiimer.eexpirees = DMFFE_TIMMER_WUUT;db-tiimer.ddata = (unnsigneed lonng)devv;db-tiimer.ffunctiion = &dmmfe_tiimer;add_tiimer(&db-ttimer);/Movve to DM90000 iniitialllizatiion waas finnishedd. netif_startt_queuue(devv);returnn 0;/* Set PHY ooperattiong mode*/static void set_PPHY_moode(booard_iinfo_tt *db)#ifndeff DM86606u16 phhy_regg0 = 00x10000;/* AAuto-nnegotiiationn*/u16 phhy_regg4 = 00x01e11;if ( !(db-op_moode & DM9KSS_AUTOO) ) / op_mode didnt autto sennse */ switcch(db-op_mmode) casee DM9KKS_10MMHD: phy_rreg4 = 0x211; phy_reg0 = 0x11000; breaak;casee DM9KKS_10MMFD: phy_rreg4 = 0x411; phy_reg0 = 0x11100; brreak;casee DM9KKS_1000MHD: phy_rreg4 = 0x811; phy_reg0 = 0x33000; brreak;casee DM9KKS_1000MFD: phy_rreg4 = 0x1001; phy_reg0 = 0x33100; brreak;defaault: breaak; / end oof swiitch / eend off if#ifdef FLOW_CONTRROLphy_wrrite(ddb, 4, phy_reg4|(1chiip_revvisionn = 00x1A)/sett 10M TX iddle =665mA (TX 1000% uttilityy is 1160mA)phy_wwrite(db,200, phyy_readd(db,220)|(1111)|(110);/:fiix harrmonicc/Forr shorrt codde:/PHYY_REG 27 (11Bh) - 00000hphy_wwrite(db, 227, 0xx0000);/PHYY_REG 27 (11Bh) - AA000hphy_wwrite(db, 227, 0xxaa00);/PHYY_REG 27 (11Bh) - 00117hphy_wwrite(db, 227, 0xx0017);/PHYY_REG 27 (11Bh) - AA117hphy_wwrite(db, 227, 0xxaa17);/PHYY_REG 27 (11Bh) - 0022Fhphy_wwrite(db, 227, 0xx002f);/PHYY_REG 27 (11Bh) - AA22Fhphy_wwrite(db, 227, 0xxaa2f);/PHYY_REG 27 (11Bh) - 00337hphy_wwrite(db, 227, 0xx0037);/PHYY_REG 27 (11Bh) - AA337hphy_wwrite(db, 227, 0xxaa37);/PHYY_REG 27 (11Bh) - 00440hphy_wwrite(db, 227, 0xx0040);/PHYY_REG 27 (11Bh) - AA440hphy_wwrite(db, 227, 0xxaa40);/Forr longg codee:/PHYY_REG 27 (11Bh) - 00550hphy_wwrite(db, 227, 0xx0050);/PHYY_REG 27 (11Bh) - AA550hphy_wwrite(db, 227, 0xxaa50);/PHYY_REG 27 (11Bh) - 0066Bhphy_wwrite(db, 227, 0xx006b);/PHYY_REG 27 (11Bh) - AA66Bhphy_wwrite(db, 227, 0xxaa6b);/PHYY_REG 27 (11Bh) - 0077Dhphy_wwrite(db, 227, 0xx007d);/PHYY_REG 27 (11Bh) - AA77Dhphy_wwrite(db, 227, 0xxaa7d);/PHYY_REG 27 (11Bh) - 0088Dhphy_wwrite(db, 227, 0xx008d);/
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 商业管理 > 市场营销


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!