LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 01-19-2009, 10:36 PM   #1
AustinMarton
Member
 
Registered: May 2007
Location: New Zealand
Distribution: Fedora at home, Ubuntu 10.04 at work
Posts: 88

Rep: Reputation: 16
Question Platform_device structure with more than one driver


Hi there, I am working on two drivers for a network device running on uClinux. One is a char driver which controls the configuration registers, and one is a network driver which is responsible for tx/rx of Ethernet frames.

Since the base address and irq configuration could change, we have decided to register them both as a "platform_device".

I have managed to do this successfully with the network driver, but now it comes to doing the same with the character driver I am not sure how to go about it.

Can anyone link me to some sort of outline of the platform device structure? Although it is mentioned a lot I am having difficulty finding any actual definition of how to use it. Does anyone know how this works with two drivers accessing the same resource? Do I need to create two resources with the same address?

Currently my setup.c file looks something like this...
Code:
#if defined(CONFIG_mydriv) && defined(na_mydriv)
#include <linux/mydriv.h>
static struct resource mydriv_resource[] = {
	[0] = {	/* Address */
		.start = na_mydriv + 0,	/* 70 */
		.end   = na_mydriv + 3,	/* 73 */
		.flags = IORESOURCE_MEM,
	},
	[1] = { /* Data */
		.start = na_mydriv + 4,	/* 74 */
		.end   = na_mydriv + 5,	/* 75 */
		.flags = IORESOURCE_MEM,
	},
	[2] = { /* IRQ */
		.start = na_mydriv_irq,	/* 4 */
		.end   = na_mydriv_irq, 	/* 4 */
		.flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
	},
	[3] = { /* CPU_FRAME_REG */
		.start = na_mydriv + 6,	/* 76 */
		.end   = na_mydriv + 7, 	/* 77 */
		.flags = IORESOURCE_MEM,
	},
	[4] = { /* CMD_STATUS_REG */
		.start = na_mydriv + 8,	/* 78 */
		.end   = na_mydriv + 9, 	/* 79 */
		.flags = IORESOURCE_MEM,
	},
	[5] = { /* INT_REG */
		.start = na_mydriv + 10,	/* 7A */
		.end   = na_mydriv + 11, 	/* 7B */
		.flags = IORESOURCE_MEM,
	},
	[6] = { /* CTL_FRAME_BUF1 */
		.start = na_mydriv + 12,	/* 7C */
		.end   = na_mydriv + 13, 	/* 7D */
		.flags = IORESOURCE_MEM,
	},
	[7] = { /* CTL_FRAME_BUF2 */
		.start = na_mydriv + 14,	/* 7E */
		.end   = na_mydriv + 15, 	/* 7F */
		.flags = IORESOURCE_MEM,
	}

};
static struct mydriv_plat_data mydriv_platdata = {
	.flags		= mydriv_PLATF_16BITONLY,
};
static struct platform_device mydriv_device = {
	.name		= "mydriv",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(mydriv_resource),
	.resource	= mydriv_resource,
	.dev		= {
		.platform_data = &mydriv_platdata,
	}
};
static int __init mydriv_device_init(void)
{
	/* customizes platform devices, or adds new ones */
	platform_device_register(&mydriv_device);
	return 0;
}
arch_initcall(mydriv_device_init);
#endif
 
  


Reply

Tags
character, device, driver, network, platform, structure


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure in C divya_flora Programming 1 09-29-2008 02:46 AM
Home Jail Folder Structure like Gobolinux Directory Structure luispt Linux - General 3 07-26-2008 06:46 PM
structure of linux kuldeep singh Linux - Newbie 2 04-25-2008 05:10 AM
structure within a structure in C knobby67 Programming 3 03-06-2007 09:00 AM
structure os2 Programming 6 05-29-2005 07:39 PM


All times are GMT -5. The time now is 10:54 PM.

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