Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-07-2008, 04:46 PM   #1
Registered: May 2007
Location: New Zealand
Distribution: Ubuntu
Posts: 88

Rep: Reputation: 16
Question Device driver for Managed Ethernet Switch IC connected w/ Avalon Bus

Hello everyone!

I am working on writing a network device driver for an Ethernet switch IC, for uClinux (2.6 kernel), running on a Nios2 processor on a Cyclone2 FPGA, connected via an Avalon Bus. Currently, my module compiles and loads fine and I can successfully read and write from the indirectly addressed registers (accessing directly addressed registers 0 and 2, which are address and data respectively). It is registered as a platform device. The device is registered as eth0, and displays the correct information (such as the MAC address I have specified) when I run the ifconfig command. When I attempt to ping anything, it calls my transmit function.

The problem I am having at the moment is I have been unable to send/receive any packets, or receive any interrupts. I see no activity on the Ethernet ports when monitoring them under Wireshark. I think that this may be related to how we are accessing the directly addressed registers and/or the setup of the Avalon bus.

The first point that I would like any comments on is the method I am using to access the directly addressed registers. I have a structure named "procif" which contains an entry for each directly addressed register:
struct st_procif {
	uint16_t index_reg0;
	uint16_t index_reg1; 
	uint16_t data_reg;
	uint16_t cpu_frame_reg;
	uint16_t cmd_status_reg;
	uint16_t int_reg;
	uint16_t ctl_frame_buf1;
	uint16_t ctl_frame_buf2;
Then in my "probe" routine I use the ioremap function to map the first index to the base address of the Avalon Bus
db->procif = (struct st_procif *) ioremap_nocache(BASE, SIZE);
#define BASE  0x01002050
#define SIZE  0x0016
Although I am not completely sure what the SIZE should be.

To read/write to the registers I call a function like ioread8 with the argument being the address of the structure entry.
For example, the following code is used in the CPU check, which reads from indirectly addressed register 0xfff, which should always contain the value of 0xDA. This process is successful.
uint16_t indir_addr = 0xfff;
	uint16_t data;

	  iowrite16(indir_addr, &db->procif->index_reg0);
	data = (uint8_t)ioread8(&db->procif->data_reg);
But whenever I read the interrupt register, it stays at 0x00, even when an interrupt should have occurred. (such as when a packet is sent to the switch for it to receive.)

Any help or ideas will be greatly appreciated.


Last edited by AustinMarton; 12-07-2008 at 06:19 PM.


device, driver, embedded, nios, switch, uclinux

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
probe method on bus and device driver not being called kunice Linux - Hardware 0 02-24-2008 12:47 PM
Need a new, managed switch - recommendations? BrianK Linux - Networking 1 05-23-2006 07:35 PM
set up DSL thru SWITCH - winXp connected to SWITCH too husz Linux - Newbie 5 04-22-2004 01:08 AM
Good 1U Managed Switch for Webserving lewt Linux - Networking 3 02-19-2004 02:08 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:43 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration