[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] Serious trouble with uartlite-like modified driver module



Hello Hans,
you are the man ;) it just worked like a charm! i heard of some platform device initializers for custom devices in petalinux but didn't remember when i would have needed it....

here is (for all others that have similar issues) the fix. i just added a struct platform_device and registered it via the platform_device_register call.

static struct platform_device pan_platform_device = {
    .name = "pan",                   
    .id = 0,                       
    .dev.platform_data = 0,                   
    .num_resources = 2,                   
    .resource = (struct resource[]) {              
        {                       
            .start    = 0x84000000,  // you should use CONFIG_XILINX_UARTLITE_0_BASEADDR  instead .. hardcoding isn't good style
            .end    = 0x8400ffff,
            .flags    = IORESOURCE_MEM           
        },                           
        {                           
            .start    = 1,   
            .end    = 1,   
            .flags  = IORESOURCE_IRQ,           
        }                       
    }           

};

int __devinit pan_init(void)
{
    int ret;

    ret = platform_device_register(&pan_platform_device);
    printk(KERN_EMERG "PAN: pan_init - platform_device_register ret:%d\n",ret);
    if (ret)
      return ret;

    ret = uart_register_driver(&pan_uart_driver);
    printk(KERN_EMERG "PAN: pan_init - uart_register_driver ret:%d\n",ret);
    if (ret)
        return ret;

    ret = platform_driver_register(&pan_platform_driver);
    printk(KERN_ALERT "PAN: pan_init - platform_driver_register ret:%d\n",ret);
    if (ret)
      {
        uart_unregister_driver(&pan_uart_driver);
        printk(KERN_CRIT "PAN: pan_init - UNREGISTERED DRIVER ret:%d\n",ret);
      }

    printk(KERN_WARNING "PAN: pan_init - success\n");

    return ret;
}

PS: @Hans, sometimes things are funny..you send out a mail to the world, hoping to get information from anywhere on earth...and you receive help from someone who lives in the same city as you're living in!...thanks again

2008/10/8 Dr. Johann Pfefferl <j.pfefferl@xxxxxxxxx>
Hello,

if the device is not mentioned in the platform area (directory
arch/microblaze/platform/common) you have to do it your own by calling
the functions platform_device_register/platform_device_unregister in
your pan_init/pan_cleanup functions. You have to describe the device by
a "struct platform_device" data structure which contains IO resources
and interrrupts.

Hope this solves your problems.
 Hans

Chris Enrique <microdevel@xxxxxxxxxxxxxx> wrote:
> Hello,
>
> i have some problems making a driver module (very similar to uartlite
> driver) work. My situation is the following:
> I am running petalinux on a Xilinx Spartan3A1800DSP Starter Kit Board
> (Microblaze), my hardware has 2 uartlite-cores implemented. The first one
> should be accessed by the original uartlite driver, the second one (which
> was modified for testing purposes...its fifo always contains "0101010...")
> should be driven by a modified uartlite driver, which is currently loaded as
> a module after system startup. the module_init procedure is exactly the same
> that can be found in the uartlite driver:
>
> (module pan)
> -------------------------------
>
> int __devinit pan_init(void)
> {
>     int ret;
>
>     ret = uart_register_driver(&pan_uart_driver);
>     printk(KERN_INFO "PAN: pan_init - uart_register_driver ret:%d\n",ret);
>     if (ret)
>         return ret;
>
>     ret = platform_driver_register(&pan_platform_driver);
>     printk(KERN_INFO "PAN: pan_init - platform_driver_register
> ret:%d\n",ret);
>     if (ret)
>       {
>         uart_unregister_driver(&pan_uart_driver);
>         printk(KERN_WARNING "PAN: pan_init - UNREGISTERED DRIVER
> ret:%d\n",ret);
>       }
>
>     printk(KERN_INFO "PAN: pan_init - success\n");
>
>     return ret;
> }
>
> this init procedure just works fine but the problem is, the .probe function
> specified in pan_platform_driver struct never gets called...so my module
> doesn't do any work at all...
> can anyone explain me how the kernel gets an idea of which module to probe
> for the uart hardware?shouldn't it just probe any driver registered via te
> platform_driver_register() call? i chose 4 as major number and 68 as minor
> and created a device node pan0,c,4,68..should be good so far.
> there is some issue concerning the original uartlite driver that is driving
> the first uartlite-core...it gets probed twice when the system is loaded, so
> i limited its UARTLITE_NR_UARTS to 1, is that the right way?
> thanks for help in advance
> chris

--
Dr. Johann Pfefferl   ------------   mailto j.pfefferl at eubus dot net
Eubus GmbH          http://www.eubus.net ++++ http://www.ebmhydraxc.com
Gollierstr. 70
D-80339 Muenchen
Phone: +49 (0)89 45 22 578-67     Fax: +49 (0)89 45 22 578-55
Registergericht Muenchen HRB 145 336, Ust-Id Nr. DE 225 783 933
Geschaeftsfuehrer: Volker Ulrich, Peter Sibities
==
 -o)   A computer program does what you tell it to do,
 /\\        not what you want it to do.
_\_v-
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/