Find the answer to your Linux question:
Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    1

    Registering a Character Device driver as a "Platform Device"


    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? I have found platform.txt but it is very confusing.

    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
    ...

    I really would appreciate if anyone can provide me with the name of ANY character driver that uses platform device registration??

  2. #2
    Just Joined!
    Join Date
    Feb 2008
    Posts
    9

    Looks OK but..

    You can just register base address and the IRQ as a resource instead of registering every register as a IO resource.

    Look for platform device registration in the linux source code. Look in the arch/ folder.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •