1484 while(ior(db, DM9KS_EPCR)&0x1); /* Wait read complete */
1485 iow(db, DM9KS_EPCR, 0x0); /* Clear phyxcer read command */
1486
1487 /* The read data keeps on REG_0D & REG_0E */
1488 return ( ior(db, DM9KS_EPDRH) << 8 ) | ior(db, DM9KS_EPDRL);
1489
1490 }
1491
1492 /*
1493 Write a word to phyxcer
1494 */
1495 static void phy_write(board_info_t *db, int reg, u16 value)
1496 {
1497 /* Fill the phyxcer register into REG_0C */
1498 iow(db, DM9KS_EPAR, DM9KS_PHY | reg);
1499
1500 /* Fill the written data into REG_0D & REG_0E */
1501 iow(db, DM9KS_EPDRL, (value & 0xff));
1502 iow(db, DM9KS_EPDRH, ( (value >> 8) & 0xff));
1503
1504 iow(db, DM9KS_EPCR, 0xa); /* Issue phyxcer write command */
1505 while(ior(db, DM9KS_EPCR)&0x1); /* Wait read complete */
1506 iow(db, DM9KS_EPCR, 0x0); /* Clear phyxcer write command */
1507 }
1508 //====dmfe_ethtool_ops member functions====
1509 static void dmfe_get_drvinfo(struct net_device *dev,
1510 struct ethtool_drvinfo *info)
1511 {
1512 //board_info_t *db = (board_info_t *)dev->priv;
1513 strcpy(info->driver, DRV_NAME);
1514 strcpy(info->version, DRV_VERSION);
1515 sprintf(info->bus_info, 'ISA 0x%lx irq=%d',dev->base_addr, dev->irq);
1516 }
1517 static int dmfe_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1518 {
1519 board_info_t *db = (board_info_t *)dev->priv;
1520 spin_lock_irq(&db->lock);
1521 mii_ethtool_gset(&db->mii, cmd);
1522 spin_unlock_irq(&db->lock);
1523 return 0;
1524 }
1525 static int dmfe_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1526 {
1527 board_info_t *db = (board_info_t *)dev->priv;
1528 int rc;
1529
1530 spin_lock_irq(&db->lock);
1531 rc = mii_ethtool_sset(&db->mii, cmd);
1532 spin_unlock_irq(&db->lock);
1533 return rc;
1534 }
1535 /*
1536 * Check the link state
1537 */
1538 static u32 dmfe_get_link(struct net_device *dev)
1539 {
1540 board_info_t *db = (board_info_t *)dev->priv;
1541 return mii_link_ok(&db->mii);
1542 }
1543
1544 /*
1545 * Reset Auto-negitiation
1546 */
1547 static int dmfe_nway_reset(struct net_device *dev)
1548 {
1549 board_info_t *db = (board_info_t *)dev->priv;
1550 return mii_nway_restart(&db->mii);
1551 }
1552 /*
1553 * Get RX checksum offload state
1554 */
1555 static uint32_t dmfe_get_rx_csum(struct net_device *dev)
1556 {
1557 board_info_t *db = (board_info_t *)dev->priv;
1558 return db->rx_csum;
1559 }
1560 /*
1561 * Get TX checksum offload state
1562 */
1563 static uint32_t dmfe_get_tx_csum(struct net_device *dev)
1564 {
1565 return (dev->features & NETIF_F_HW_CSUM) != 0;
1566 }
1567 /*
1568 * Enable/Disable RX checksum offload
1569 */
1570 static int dmfe_set_rx_csum(struct net_device *dev, uint32_t data)
1571 {
1572 #ifdef CHECKSUM
1573 board_info_t *db = (board_info_t *)dev->priv;
1574 db->rx_csum = data;
1575
1576 if(netif_running(dev)) {
1577 dmfe_stop(dev);
1578 dmfe_open(dev);
1579 } else
1580 dmfe_init_dm9000(dev);
1581 #else
1582 printk(KERN_ERR 'DM9:Don't support checksumn');
1583 #endif
1584 return 0;
1585 }
1586 /*
1587 * Enable/Disable TX checksum offload
1588 */
1589 static int dmfe_set_tx_csum(struct net_device *dev, uint32_t data)
1590 {
1591 #ifdef CHECKSUM
1592 if (data)
1593 dev->features |= NETIF_F_HW_CSUM;
1594 else
1595 dev->features &= ~NETIF_F_HW_CSUM;
1596 #else
1597 printk(KERN_ERR 'DM9:Don't support checksumn');
1598 #endif
1599
1600 return 0;
1601 }
1602 //=========================================
1603 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,28) /* for kernel 2.4.28 */
1604 static struct ethtool_ops dmfe_ethtool_ops = {
1605 .get_drvinfo = dmfe_get_drvinfo,
1606 .get_settings = dmfe_get_settings,
1607 .set_settings = dmfe_set_settings,
1608 .get_link = dmfe_get_link,
1609 .nway_reset = dmfe_nway_reset,
1610 .get_rx_csum = dmfe_get_rx_csum,
1611 .set_rx_csum = dmfe_set_rx_csum,
1612 .get_tx_csum = dmfe_get_tx_csum,
1613 .set_tx_csum = dmfe_set_tx_csum,
1614 };
1615 #endif
1616
1617 //#ifdef MODULE
1618
1619 MODULE_LICENSE('GPL');
1620 MODULE_DESCRIPTION('Davicom DM9000/DM9010 ISA/uP Fast Ethernet Driver');
1621 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
1622 MODULE_PARM(mode, 'i');
1623 MODULE_PARM(irq, 'i');
1624 MODULE_PARM(iobase, 'i');
1625 #else
1626 module_param(mode, int, 0);
1627 module_param(irq, int, 0);
1628 module_param(iobase, int, 0);
1629 #endif
1630 MODULE_PARM_DESC(mode,'Media Speed, 0:10MHD, 1:10MFD, 4:100MHD, 5:100MFD');
1631 MODULE_PARM_DESC(irq,'EtherLink IRQ number');
1632 MODULE_PARM_DESC(iobase, 'EtherLink I/O base address');
1633
1634 /* Description:
1635 when user used insmod to add module, system invoked init_module()
1636 to initilize and register.
1637 */
1638 int __init dm9000c_init(void)
1639 {
1640 volatile unsigned long *bwscon; // 0x48000000
1641 volatile unsigned long *bankcon4; // 0x48000014
1642 unsigned long val;
1643
1644 iobase = (int)ioremap(0x20000000,1024); /* 添加内存映射 */
1645
1646 //2440使用的中断引脚为外部中断7,此处我们设置中断号
1647 irq = IRQ_EINT7;
1648
1649 /* 设置S3C2440的memory controller */
1650 bwscon = ioremap(0x48000000, 4);
1651 bankcon4 = ioremap(0x48000014, 4);
1652
1653 /* DW4[17:16]: 01-16bit
1654 * WS4[18] : 0-WAIT disable
1655 * ST4[19] : 0 = Not using UB/LB (The pins are dedicated nWBE[3:0])
1656 */
1657 val = *bwscon;
1658 val &= ~(0xf<<16);
1659 val |= (1<<16);
1660 *bwscon = val;
1661
1662 /*
1663 * Tacs[14:13]: 发出片选信号之前,多长时间内要先发出地址信号
1664 * DM9000C的片选信号和CMD信号可以同时发出,
1665 * 所以它设为0
1666 * Tcos[12:11]: 发出片选信号之后,多长时间才能发出读信号nOE
1667 * DM9000C的T1>=0ns,
1668 * 所以它设为0
1669 * Tacc[10:8] : 读写信号的脉冲长度,
1670 * DM9000C的T2>=10ns,
1671 * 所以它设为1, 表示2个hclk周期,hclk=100MHz,就是20ns
1672 * Tcoh[7:6] : 当读信号nOE变为高电平后,片选信号还要维持多长时间
1673 * DM9000C进行写操作时, nWE变为高电平之后, 数据线上的数据还要维持最少3ns
1674 * DM9000C进行读操作时, nOE变为高电平之后, 数据线上的数据在6ns之内会消失
1675 * 我们取一个宽松值: 让片选信号在nOE放为高电平后,再维持10ns,
1676 * 所以设为01
1677 * Tcah[5:4] : 当片选信号变为高电平后, 地址信号还要维持多长时间
1678 * DM9000C的片选信号和CMD信号可以同时出现,同时消失
1679 * 所以设为0
1680 * PMC[1:0] : 00-正常模式
1681 *
1682 */
1683 //*bankcon4 = (1<<8)|(1<<6); /* 对于DM9000C可以设Tacc为1, 对于DM9000E,Tacc要设大一点,比如最大值7 */
1684 *bankcon4 = (7<<8)|(1<<6); /* TQ2440和MINI2440使用DM9000E,Tacc要设大一点 正常来说1也可以 */
1685
1686 iounmap(bwscon);
1687 iounmap(bankcon4);
1688
1689
1690 switch(mode) {
1691 case DM9KS_10MHD:
1692 case DM9KS_100MHD:
1693 case DM9KS_10MFD:
1694 case DM9KS_100MFD:
1695 media_mode = mode;
1696 break;
1697 default:
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-13 23:25
设计资源 培训 开发板 精华推荐
- LTM8064IY 58VIN、2.5V/7A 系列超级电容器的典型应用电路
- 【训练营_进阶班】物联网无限空间床头灯
- 使用 ON Semiconductor 的 LA42051 的参考设计
- USB-KW019032: 面向Kinetis KW0x的数据包嗅探器/USB Dongle开发板
- 具有短路保护功能的 MC78M08ABDTRKG 8V 电流升压的典型应用
- SY6926-移动电源二合一管理芯片方案
- 基于SL2.1A的USB2.0的拓展坞(4接口)
- LT1934IDCB 独立式 350mA 锂离子电池充电器的典型应用电路
- NE555
- AN10419 - PCA9516A 单卡 I2C 总线缓冲器应用电路