AX88796B网卡for OMAP3530 + Linux 2.6.29平台
到asix网站下载了最新的ax88796b驱动,放到drivers/net/目录下,修改了Makefile和Kconfig文件。
直接编译出现一大堆的错误:
error: 'struct net_device' has no member named 'priv'
驱动本身好像没有支持这么新的内核,而新的内核net_device结构发生了变化,看/include/linux/netdevice.h文件:
这是2.6.31的net_device结构体,2.6.29和这个基本相同:
649struct net_device
650{
651
652 /*
653 * This is the first field of the "visible" part of this structure
654 * (i.e. as seen by users in the "Space.c" file). It is the name
655 * the interface.
656 */
657 char name[IFNAMSIZ];
658 /* device name hash chain */
659 struct hlist_node name_hlist;
660 /* snmp alias */
661 char *ifalias;
662
663 /*
664 * I/O specific fields
665 * FIXME: Merge these and struct ifmap into one
666 */
667 unsigned long mem_end; /* shared mem end */
668 unsigned long mem_start; /* shared mem start */
669 unsigned long base_addr; /* device I/O address */
670 unsigned int irq; /* device IRQ number */
671
672 /*
673 * Some hardware also needs these fields, but they are not
674 * part of the usual set specified in Space.c.
675 */
676
677 unsigned char if_port; /* Selectable AUI, TP,..*/
678 unsigned char dma; /* DMA channel */
679
680 unsigned long state;
681
682 struct list_head dev_list;
683 struct list_head napi_list;
684
685 /* Net device features */
686 unsigned long features;
687#define NETIF_F_SG 1 /* Scatter/gather IO. */
688#define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */
689#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
690#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
691#define NETIF_F_IPV6_CSUM 16 /* Can checksum TCP/UDP over IPV6 */
692#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
693#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
694#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
695#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
696#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
697#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
698#define NETIF_F_GSO 2048 /* Enable software GSO. */
699#define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */
700 /* do not use LLTX in new drivers */
701#define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */
702#define NETIF_F_GRO 16384 /* Generic receive offload */
703#define NETIF_F_LRO 32768 /* large receive offload */
704
705/* the GSO_MASK reserves bits 16 through 23 */
706#define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */
707#define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */
708
709 /* Segmentation offload features */
710#define NETIF_F_GSO_SHIFT 16
711#define NETIF_F_GSO_MASK 0x00ff0000
712#define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
713#define NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
714#define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
715#define NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
716#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
717#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
718
719 /* List of features with software fallbacks. */
720#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6)
721
722
723#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
724#define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
725#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
726#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
727
728 /*
729 * If one device supports one of these features, then enable them
730 * for all in netdev_increment_features.
731 */
732#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
733 NETIF_F_SG | NETIF_F_HIGHDMA | \
734 NETIF_F_FRAGLIST)
735
736 /* Interface index. Unique device identifier */
737 int ifindex;
738 int iflink;
739
740 struct net_device_stats stats;
741
742#ifdef CONFIG_WIRELESS_EXT
743 /* List of functions to handle Wireless Extensions (instead of ioctl).
744 * See for details. Jean II */
745 const struct iw_handler_def * wireless_handlers;
746 /* Instance data managed by the core of Wireless Extensions. */
747 struct iw_public_data * wireless_data;
748#endif
749 /* Management operations */
750 const struct net_device_ops *netdev_ops;
751 const struct ethtool_ops *ethtool_ops;
752
753 /* Hardware header description */
754 const struct header_ops *header_ops;
755
756 unsigned int flags; /* interface flags (a la BSD) */
757 unsigned short gflags;
758 unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */
759 unsigned short padded; /* How much padding added by alloc_netdev() */
760
761 unsigned char operstate; /* RFC2863 operstate */
762 unsigned char link_mode; /* mapping policy to operstate */
763
764 unsigned mtu; /* interface MTU value */
765 unsigned short type; /* interface hardware type */
766 unsigned short hard_header_len; /* hardware hdr length */
767
768 /* extra head- and tailroom the hardware may need, but not in all cases
769 * can this be guaranteed, especially tailroom. Some cases also use
770 * LL_MAX_HEADER instead to allocate the skb.
771 */
772 unsigned short needed_headroom;
773 unsigned short needed_tailroom;
774
775 struct net_device *master; /* Pointer to master device of a group,
776 * which this device is member of.
777 */
778
779 /* Interface address info. */
780 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
781 unsigned char addr_len; /* hardware address length */
782 unsigned short dev_id; /* for shared network cards */
783
784 struct netdev_hw_addr_list uc; /* Secondary unicast
785 mac addresses */
786 int uc_promisc;
787 spinlock_t addr_list_lock;
788 struct dev_addr_list *mc_list; /* Multicast mac addresses */
789 int mc_count; /* Number of installed mcasts */
790 unsigned int promiscuity;
791 unsigned int allmulti;
792
793
794 /* Protocol specific pointers */
795
796#ifdef CONFIG_NET_DSA
797 void *dsa_ptr; /* dsa specific data */
798#endif
799 void *atalk_ptr; /* AppleTalk link */
800 void *ip_ptr; /* IPv4 specific data */
801 void *dn_ptr; /* DECnet specific data */
802 void *ip6_ptr; /* IPv6 specific data */
803 void *ec_ptr; /* Econet specific data */
804 void *ax25_ptr; /* AX.25 specific data */
805 struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
806 assign before registering */
807
808/*
809 * Cache line mostly used on receive path (including eth_type_trans())
810 */
811 unsigned long last_rx; /* Time of last Rx */
812 /* Interface address info used in eth_type_trans() */
813 unsigned char *dev_addr; /* hw address, (before bcast
814 because most packets are
815 unicast) */
816
817 struct netdev_hw_addr_list dev_addrs; /* list of device
818 hw addresses */
819
820 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
821
822 struct netdev_queue rx_queue;
823
824 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
825
826 /* Number of TX queues allocated at alloc_netdev_mq() time */
827 unsigned int num_tx_queues;
828
829 /* Number of TX queues currently active in device */
830 unsigned int real_num_tx_queues;
831
832 unsigned long tx_queue_len; /* Max frames per queue allowed */
833 spinlock_t tx_global_lock;
834/*
835 * One part is mostly used on xmit path (device)
836 */
837 /* These may be needed for future network-power-down code. */
838
839 /*
840 * trans_start here is expensive for high speed devices on SMP,
841 * please use netdev_queue->trans_start instead.
842 */
843 unsigned long trans_start; /* Time (in jiffies) of last Tx */
844
845 int watchdog_timeo; /* used by dev_watchdog() */
846 struct timer_list watchdog_timer;
847
848 /* Number of references to this device */
849 atomic_t refcnt ____cacheline_aligned_in_smp;
850
851 /* delayed register/unregister */
852 struct list_head todo_list;
853 /* device index hash chain */
854 struct hlist_node index_hlist;
855
856 struct net_device *link_watch_next;
857
858 /* register/unregister state machine */
859 enum { NETREG_UNINITIALIZED=0,
860 NETREG_REGISTERED, /* completed register_netdevice */
861 NETREG_UNREGISTERING, /* called unregister_netdevice */
862 NETREG_UNREGISTERED, /* completed unregister todo */
863 NETREG_RELEASED, /* called free_netdev */
864 NETREG_DUMMY, /* dummy device for NAPI poll */
865 } reg_state;
866
867 /* Called from unregister, can be used to call free_netdev */
868 void (*destructor)(struct net_device *dev);
869
870#ifdef CONFIG_NETPOLL
871 struct netpoll_info *npinfo;
872#endif
873
874#ifdef CONFIG_NET_NS
875 /* Network namespace this network device is inside */
876 struct net *nd_net;
877#endif
878
879 /* mid-layer private */
880 void *ml_priv;
881
882 /* bridge stuff */
883 struct net_bridge_port *br_port;
884 /* macvlan */
885 struct macvlan_port *macvlan_port;
886 /* GARP */
887 struct garp_port *garp_port;
888
889 /* class/net/name entry */
890 struct device dev;
891 /* space for optional statistics and wireless sysfs groups */
892 struct attribute_group *sysfs_groups[3];
893
894 /* rtnetlink link ops */
895 const struct rtnl_link_ops *rtnl_link_ops;
896
897 /* VLAN feature mask */
898 unsigned long vlan_features;
899
900 /* for setting kernel sock attribute on TCP connection setup */
901#define GSO_MAX_SIZE 65536
902 unsigned int gso_max_size;
903
904#ifdef CONFIG_DCB
905 /* Data Center Bridging netlink ops */
906 struct dcbnl_rtnl_ops *dcbnl_ops;
907#endif
908
909#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
910 /* max exchange id for FCoE LRO by ddp */
911 unsigned int fcoe_ddp_xid;
912#endif
913};
|
这是2.6.28的net_device结构体,很显然,其中有
657 void *priv; /* pointer to private data */
priv这个成员。
465struct net_device
466{
467
468 /*
469 * This is the first field of the "visible" part of this structure
470 * (i.e. as seen by users in the "Space.c" file). It is the name
471 * the interface.
472 */
473 char name[IFNAMSIZ];
474 /* device name hash chain */
475 struct hlist_node name_hlist;
476 /* snmp alias */
477 char *ifalias;
478
479 /*
480 * I/O specific fields
481 * FIXME: Merge these and struct ifmap into one
482 */
483 unsigned long mem_end; /* shared mem end */
484 unsigned long mem_start; /* shared mem start */
485 unsigned long base_addr; /* device I/O address */
486 unsigned int irq; /* device IRQ number */
487
488 /*
489 * Some hardware also needs these fields, but they are not
490 * part of the usual set specified in Space.c.
491 */
492
493 unsigned char if_port; /* Selectable AUI, TP,..*/
494 unsigned char dma; /* DMA channel */
495
496 unsigned long state;
497
498 struct list_head dev_list;
499#ifdef CONFIG_NETPOLL
500 struct list_head napi_list;
501#endif
502
503 /* The device initialization function. Called only once. */
504 int (*init)(struct net_device *dev);
505
506 /* ------- Fields preinitialized in Space.c finish here ------- */
507
508 /* Net device features */
509 unsigned long features;
510#define NETIF_F_SG 1 /* Scatter/gather IO. */
511#define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */
512#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
513#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
514#define NETIF_F_IPV6_CSUM 16 /* Can checksum TCP/UDP over IPV6 */
515#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
516#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
517#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
518#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
519#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
520#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
521#define NETIF_F_GSO 2048 /* Enable software GSO. */
522#define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */
523 /* do not use LLTX in new drivers */
524#define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */
525#define NETIF_F_LRO 32768 /* large receive offload */
526
527 /* Segmentation offload features */
528#define NETIF_F_GSO_SHIFT 16
529#define NETIF_F_GSO_MASK 0xffff0000
530#define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
531#define NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
532#define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
533#define NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
534#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
535
536 /* List of features with software fallbacks. */
537#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6)
538
539
540#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
541#define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
542#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
543#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
544
545 /*
546 * If one device supports one of these features, then enable them
547 * for all in netdev_increment_features.
548 */
549#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
550 NETIF_F_SG | NETIF_F_HIGHDMA | \
551 NETIF_F_FRAGLIST)
552
553 /* Interface index. Unique device identifier */
554 int ifindex;
555 int iflink;
556
557
558 struct net_device_stats* (*get_stats)(struct net_device *dev);
559 struct net_device_stats stats;
560
561#ifdef CONFIG_WIRELESS_EXT
562 /* List of functions to handle Wireless Extensions (instead of ioctl).
563 * See for details. Jean II */
564 const struct iw_handler_def * wireless_handlers;
565 /* Instance data managed by the core of Wireless Extensions. */
566 struct iw_public_data * wireless_data;
567#endif
568 const struct ethtool_ops *ethtool_ops;
569
570 /* Hardware header description */
571 const struct header_ops *header_ops;
572
573 /*
574 * This marks the end of the "visible" part of the structure. All
575 * fields hereafter are internal to the system, and may change at
576 * will (read: may be cleaned up at will).
577 */
578
579
580 unsigned int flags; /* interface flags (a la BSD) */
581 unsigned short gflags;
582 unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */
583 unsigned short padded; /* How much padding added by alloc_netdev() */
584
585 unsigned char operstate; /* RFC2863 operstate */
586 unsigned char link_mode; /* mapping policy to operstate */
587
588 unsigned mtu; /* interface MTU value */
589 unsigned short type; /* interface hardware type */
590 unsigned short hard_header_len; /* hardware hdr length */
591
592 /* extra head- and tailroom the hardware may need, but not in all cases
593 * can this be guaranteed, especially tailroom. Some cases also use
594 * LL_MAX_HEADER instead to allocate the skb.
595 */
596 unsigned short needed_headroom;
597 unsigned short needed_tailroom;
598
599 struct net_device *master; /* Pointer to master device of a group,
600 * which this device is member of.
601 */
602
603 /* Interface address info. */
604 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
605 unsigned char addr_len; /* hardware address length */
606 unsigned short dev_id; /* for shared network cards */
607
608 spinlock_t addr_list_lock;
609 struct dev_addr_list *uc_list; /* Secondary unicast mac addresses */
610 int uc_count; /* Number of installed ucasts */
611 int uc_promisc;
612 struct dev_addr_list *mc_list; /* Multicast mac addresses */
613 int mc_count; /* Number of installed mcasts */
614 unsigned int promiscuity;
615 unsigned int allmulti;
616
617
618 /* Protocol specific pointers */
619
620#ifdef CONFIG_NET_DSA
621 void *dsa_ptr; /* dsa specific data */
622#endif
623 void *atalk_ptr; /* AppleTalk link */
624 void *ip_ptr; /* IPv4 specific data */
625 void *dn_ptr; /* DECnet specific data */
626 void *ip6_ptr; /* IPv6 specific data */
627 void *ec_ptr; /* Econet specific data */
628 void *ax25_ptr; /* AX.25 specific data */
629 struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
630 assign before registering */
631
632/*
633 * Cache line mostly used on receive path (including eth_type_trans())
634 */
635 unsigned long last_rx; /* Time of last Rx */
636 /* Interface address info used in eth_type_trans() */
637 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast
638 because most packets are unicast) */
639
640 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
641
642 struct netdev_queue rx_queue;
643
644 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
645
646 /* Number of TX queues allocated at alloc_netdev_mq() time */
647 unsigned int num_tx_queues;
648
649 /* Number of TX queues currently active in device */
650 unsigned int real_num_tx_queues;
651
652 unsigned long tx_queue_len; /* Max frames per queue allowed */
653 spinlock_t tx_global_lock;
654/*
655 * One part is mostly used on xmit path (device)
656 */
657 void *priv; /* pointer to private data */
658 int (*hard_start_xmit) (struct sk_buff *skb,
659 struct net_device *dev);
660 /* These may be needed for future network-power-down code. */
661 unsigned long trans_start; /* Time (in jiffies) of last Tx */
662
663 int watchdog_timeo; /* used by dev_watchdog() */
664 struct timer_list watchdog_timer;
665
666/*
667 * refcnt is a very hot point, so align it on SMP
668 */
669 /* Number of references to this device */
670 atomic_t refcnt ____cacheline_aligned_in_smp;
671
672 /* delayed register/unregister */
673 struct list_head todo_list;
674 /* device index hash chain */
675 struct hlist_node index_hlist;
676
677 struct net_device *link_watch_next;
678
679 /* register/unregister state machine */
680 enum { NETREG_UNINITIALIZED=0,
681 NETREG_REGISTERED, /* completed register_netdevice */
682 NETREG_UNREGISTERING, /* called unregister_netdevice */
683 NETREG_UNREGISTERED, /* completed unregister todo */
684 NETREG_RELEASED, /* called free_netdev */
685 } reg_state;
686
687 /* Called after device is detached from network. */
688 void (*uninit)(struct net_device *dev);
689 /* Called after last user reference disappears. */
690 void (*destructor)(struct net_device *dev);
691
692 /* Pointers to interface service routines. */
693 int (*open)(struct net_device *dev);
694 int (*stop)(struct net_device *dev);
695#define HAVE_NETDEV_POLL
696#define HAVE_CHANGE_RX_FLAGS
697 void (*change_rx_flags)(struct net_device *dev,
698 int flags);
699#define HAVE_SET_RX_MODE
700 void (*set_rx_mode)(struct net_device *dev);
701#define HAVE_MULTICAST
702 void (*set_multicast_list)(struct net_device *dev);
703#define HAVE_SET_MAC_ADDR
704 int (*set_mac_address)(struct net_device *dev,
705 void *addr);
706#define HAVE_VALIDATE_ADDR
707 int (*validate_addr)(struct net_device *dev);
708#define HAVE_PRIVATE_IOCTL
709 int (*do_ioctl)(struct net_device *dev,
710 struct ifreq *ifr, int cmd);
711#define HAVE_SET_CONFIG
712 int (*set_config)(struct net_device *dev,
713 struct ifmap *map);
714#define HAVE_CHANGE_MTU
715 int (*change_mtu)(struct net_device *dev, int new_mtu);
716
717#define HAVE_TX_TIMEOUT
718 void (*tx_timeout) (struct net_device *dev);
719
720 void (*vlan_rx_register)(struct net_device *dev,
721 struct vlan_group *grp);
722 void (*vlan_rx_add_vid)(struct net_device *dev,
723 unsigned short vid);
724 void (*vlan_rx_kill_vid)(struct net_device *dev,
725 unsigned short vid);
726
727 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
728#ifdef CONFIG_NETPOLL
729 struct netpoll_info *npinfo;
730#endif
731#ifdef CONFIG_NET_POLL_CONTROLLER
732 void (*poll_controller)(struct net_device *dev);
733#endif
734
735 u16 (*select_queue)(struct net_device *dev,
736 struct sk_buff *skb);
737
738#ifdef CONFIG_NET_NS
739 /* Network namespace this network device is inside */
740 struct net *nd_net;
741#endif
742
743 /* mid-layer private */
744 void *ml_priv;
745
746 /* bridge stuff */
747 struct net_bridge_port *br_port;
748 /* macvlan */
749 struct macvlan_port *macvlan_port;
750 /* GARP */
751 struct garp_port *garp_port;
752
753 /* class/net/name entry */
754 struct device dev;
755 /* space for optional statistics and wireless sysfs groups */
756 struct attribute_group *sysfs_groups[3];
757
758 /* rtnetlink link ops */
759 const struct rtnl_link_ops *rtnl_link_ops;
760
761 /* VLAN feature mask */
762 unsigned long vlan_features;
763
764 /* for setting kernel sock attribute on TCP connection setup */
765#define GSO_MAX_SIZE 65536
766 unsigned int gso_max_size;
767};
|
改动:
把原来的:
struct ax_device *ax_local = (struct ax_device *) dev->priv;
改成: struct ax_device *ax_local = netdev_priv(dev);
|
编译的错误就没有了。
这样编译后,系统无法发现设备,就算已经配置好硬件,都是不行的。
后来增加了8390.c的编译,可以找到网卡了:
AX88796B: MAC ADDRESS 00 88 88 77 99 66
eth%d: AX88796B found at 0x15000000, using IRQ 174.
AX88796B: The media mode is autosense.
eth0 (): not using net_device_ops yet
两个问题:一是第一次识别的网卡是eth%d,第二次识别到了eth0,二是出现not using net_device_ops的警告。
./net/core/dev.c: pr_info("%s (%s): not using net_device_ops yet\n",
ping不通,用抓包软件看,电脑能够收到ping包,并且也回应了,但是板子收不到任何东西,lost 100%。
在中断服务程序中打印,结果没有打印出来,很显然没有进入中段程序。中断设置有问题。
在./arch/arm/plat-omap/include/mach/mux.h文件的enum omap34xx_index 增加了:
GPIO14, /* for NET_IRQ */
在./arch/arm/mach-omap2/mux.c的static struct pin_config __initdata_or_module omap34xx_pins 增加了:
MUX_CFG_34XX("GPIO14", 0x5dc,
OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_INPUT_PULLUP) /* for NET_IRQ */
在arch/arm/mach-omap2/board-omap3beagle.c中增加:
omap_cfg_reg(GPIO14); //
if (gpio_request(EPCARM3500_ETHR_GPIO_IRQ, "ax88796b irq") < 0) { printk(KERN_ERR "Failed to request GPIO%d for ax88796b IRQ\n", EPCARM3500_ETHR_GPIO_IRQ); return; } gpio_direction_input(EPCARM3500_ETHR_GPIO_IRQ);
set_irq_type(OMAP_GPIO_IRQ(14), IRQ_TYPE_EDGE_RISING); enable_irq(gpio_to_irq(14));
omap_cfg_reg(GPIO133); //
gpio_direction_output(133, 0); mdelay(3); gpio_direction_output(133, 1);
|
其实是中断引脚电平没有变化,始终是低电平,用表笔将IRQ和V1.8V碰一下,就可以产生中断,并且ping通。
到底是什么原因导致出现这样的情况,还不清楚。
先后找了OMAP IO设置和中断设置,都没有发现问题,后来怀疑是AX88796B的设置问题,经过咨询,可能是IRQ 类型设置的问题:BTCR(page3 0x15),bit4设置IRQ极性,bit5设置IRQ类型。
默认是0,低电平,改为1(push-pull)后中断正常。
writeb (0x30, ax_base + EN0_BTCR);
不过还有怀疑的是,在PXA270和s3c24402440上使用低电平是没有问题的。
伪中断:不过现在出现这样的警告:
Spurious irq 95: 0xffffffdf, please flush posted write for irq 29
从arch/arm/mach-omap2/irq.c文件中打印出来:
./arch/arm/mach-omap2/irq.c: printk(KERN_WARNING "Spurious irq %i: 0x%08x, please flush "
注释掉用于测试的_REG和SD WP的IO的中断的代码后,伪中断少了很多。
这和网卡驱动没有任何关系,是TI移植包的问题:
在新版的OMAP35x_DVSDK_Build_v3.00.02.44中好像没有这个问题了。
系统网卡侦测表drivers/net/Space.c使用方法。
ax88796b驱动中有init_module函数:
int init_module (void)
{
struct net_device *dev = &dev_ax;
dev->irq = irq;
dev->base_addr = mem;
dev->init = ax_probe;
if (register_netdev (dev) == 0)
return 0;
if (mem != 0) {
PRINTK (WARNING_MSG, PFX " No AX88796B card found at memory = %#x\n", mem);
}
else {
PRINTK (WARNING_MSG, PFX
" You must supply \"mem=0xNNNNNNN\""
" value(s) for AX88796B.\n");
}
return -ENXIO;
}
|
也有一个__ini ax_kprobe函数,也是驱动的入口:
struct net_device * __init ax_kprobe (int unit)
{
struct net_device *dev = alloc_ei_netdev ();
int err;
if (!dev)
return ERR_PTR (-ENOMEM);
sprintf (dev->name, "eth%d", unit);
netdev_boot_setup_check (dev);
err = ax_probe (dev);
if (err)
goto out;
return dev;
out:
free_netdev (dev);
return ERR_PTR (err);
}
|
如果使用模块方式编译,或者强制使用init_modul作为入口时可以的,也可以使用ax_kprobe作为入口,不过这样的话,就需要在net/Space.c文件中增加ax_kprobe()函数的声明:
extern struct net_device *ax_kprobe(int unit)
|
并在net/Space.c中增加:
# ifdef CONFIG_AX88796B {ax_kprobe, 0} # endif
|
这里的范例可以参考cs89x0.c的用法,CS890X.c有cs890x_probe和cs890x_probe1两个入口。
在net/Space.c中声明:
extern struct net_device *cs89x0_probe(int unit);
然后再下面增加入口:
197 #ifdef CONFIG_CS89x0
198 {cs89x0_probe, 0},
199 #endif
|
在这个版本的驱动中没用实现net_device_ops结构体,最好实现比较好,省的内核出现警告。
如下是DM9000的:
1173 static const struct net_device_ops dm9000_netdev_ops = {
1174 .ndo_open = dm9000_open,
1175 .ndo_stop = dm9000_stop,
1176 .ndo_start_xmit = dm9000_start_xmit,
1177 .ndo_tx_timeout = dm9000_timeout,
1178 .ndo_set_multicast_list = dm9000_hash_table,
1179 .ndo_do_ioctl = dm9000_ioctl,
1180 .ndo_change_mtu = eth_change_mtu,
1181 .ndo_validate_addr = eth_validate_addr,
1182 .ndo_set_mac_address = eth_mac_addr,
1183 #ifdef CONFIG_NET_POLL_CONTROLLER
1184 .ndo_poll_controller = dm9000_poll_controller,
1185 #endif
1186};
|
在probe函数中对dev的该结构体进行初始化:
ndev->netdev_ops = &dm9000_netdev_ops;
|
当然,net_device_ops也可以不实现,全部设置为NULL即可。
阅读(3052) | 评论(1) | 转发(1) |