2009-06-08 09:20:45 general driver question
Nikolay Chokoev (IRELAND)
Message: 75335
Hi,
I have a LCD driver that needs to access I2C, but the I2C driver is attached after the LCD driver is finished. It seems that the i2c_add_driver() is asynchronous.
static int __devinit bfin_ra158z_driver_init(void)
{
printk(KERN_INFO DRIVER_NAME ": bfin_ra158z_driver_init.\n");
if (i2c_add_driver(&eep_driver)) {
printk(KERN_ERR DRIVER_NAME ": I2C Driver Initialisation failed\n");
}
return platform_driver_register(&bfin_ra158z_driver);
}
bfin-ra158z: bfin_ra158z_driver_init.
bfin-ra158z: FrameBuffer initializing...
bfin-ra158z: get_configuration
dma_alloc_init: dma_page @ 0x01edd000 - 256 pages at 0x01f00000
Console: switching to colour frame buffer device 100x30
Serial: Blackfin serial driver
bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 29) is a BFIN-UART
brd: module loaded
loop: module loaded
bfin-spi bfin-spi.0: No DMA channel specified
bfin-spi: probe of bfin-spi.0 failed with error -2
bfin-ra158z: eep_attach
bfin-ra158z: eep_probe
bfin-ra158z: eep_probe OK!
Regards,
Nikolay
QuoteReplyEditDelete
2009-06-08 09:43:53 Re: general driver question
Mike Frysinger (UNITED STATES)
Message: 75336
adding the driver only registers its availability. there is no guarantee as to when exactly in the boot process the i2c client will be discovered and the registered driver executed.
QuoteReplyEditDelete
2009-06-08 09:52:40 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75337
...how to proceed? What's the solution?
QuoteReplyEditDelete
2009-06-08 10:03:20 Re: general driver question
Mike Frysinger (UNITED STATES)
Message: 75338
i dont see a problem. why do you need the i2c available at time of the framebuffer probing ?
QuoteReplyEditDelete
2009-06-08 10:07:51 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75339
I need to read some data from I2C eeprom and to configure the LCD driver. That's why I need I2C before FB...
QuoteReplyEditDelete
2009-06-08 10:14:00 Re: general driver question
Michael Hennerich (GERMANY)
Message: 75340 Read your i2c eeprom in u-boot and pass stuff via the kernel command
line.
-Michael
QuoteReplyEditDelete
2009-06-08 10:14:04 Re: general driver question
Mike Frysinger (UNITED STATES)
Message: 75341
i think you're doing it wrong. framebuffer configuration is not done in the probe function. it is done in the open function.
QuoteReplyEditDelete
2009-06-08 10:33:34 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75342
Thenks for the suggestion!
If I have no other chance I'll see how to do that.
QuoteReplyEditDelete
2009-06-08 10:34:56 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75343
the configuration is on 'open()' function, but I need to know some parameters (like screen size, etc.) at the probe time, as there the dma memory is reserved.
QuoteReplyEditDelete
2009-06-08 10:37:51 Re: general driver question
Mike Frysinger (UNITED STATES)
Message: 75344
there is no reason you cant delay the dma allocation to open() as well ... it isnt like the dma memory will be used at any point before that
QuoteReplyEditDelete
2009-06-08 10:42:56 Re: general driver question
Michael Hennerich (GERMANY)
Message: 75345 Mike,
fbcon will open the fb pretty early in the boot process.
At this point there is no i2c driver available.
-Michael
QuoteReplyEditDelete
2009-06-08 10:43:41 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75346
What about the 'fbinfo' structure and 'register_framebuffer(fbinfo)' call? The LCD data is used in this structure also.
QuoteReplyEditDelete
2009-06-08 10:46:06 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75347
... yes, that's what I observe - the I2C is attached much after the fb driver is finished...
QuoteReplyEditDelete
2009-06-08 10:55:37 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75348
... can I wait in the LCD driver for a I2C (with an error code from I2C) ?
QuoteReplyEditDelete
2009-06-08 11:09:11 Re: general driver question
Michael Hennerich (GERMANY)
Message: 75352 You can put your fb initialization/registration into the i2c_probe
callback.
This way your fb get's registered the time you know that i2c bus driver
is available.
-Michael
QuoteReplyEditDelete
2009-06-08 11:14:41 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75354
What about 'fbinfo'? Isn't it needed at FB probe? ... I have info to fill in this structure from the I2C eeprom...
QuoteReplyEditDelete
2009-06-08 11:21:09 Re: general driver question
Michael Hennerich (GERMANY)
Message: 75355 As I said - you will call
register_framebuffer(fbinfo);
from i2c probe callback.
You init function will only call i2c_add_driver()
static int __init yourfb_init(void)
{
return i2c_add_driver(&yourfb _driver);
}
module_init(yourfb_init);
-Michael
QuoteReplyEditDelete
2009-06-08 12:05:32 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75359
That means that all initializations will be moved after the i2c is done... then I suppose I have to return success for lcd_probe(), lcd_open(), etc, and to initialize the hardware once I have i2c.
What will happen if i2c fails? (The LCD driver returned 'OK' but is not initialized)
...or I'm missing something?
QuoteReplyEditDelete
2009-06-08 13:12:11 Re: general driver question
Michael Hennerich (GERMANY)
Message: 75366 >...or I'm missing something?
I think so - there won't be open, etc. without register fb.
You simply move all stuff you have today in your probe function to the
i2c probe...
-Michael
QuoteReplyEditDelete
2009-06-09 05:34:59 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75401
Hi Michael,
I've moved it. Now I'm reading I2C data, setting "fbinfo",..etc., calling "register_framebuffer(fbinfo)", but "fb_open()" is never called.
Regards,
Nikolay
QuoteReplyEditDelete
2009-06-09 09:18:06 Re: general driver question
Nikolay Chokoev (IRELAND)
Message: 75403
Hi Michael,
It's working fine! Thanks for the suggestion!
Regards,
Nikolay