New Style I2C Driver : how to get clients ?
Hi,
Thank you for your fast answer.
So, I added the register_board_info in my board init function. I fill the i2c_board_info structure with the macro I2C_BOARD_INFO. I define a few clients.
And so what ?
The system is supposed to call the probe(client) of the driver ?
I am really lost. I did not anderstand how to get a valid client instance. I suppose the I2C layer says "Hey boy, you have a new client !", but when ?
What about 'static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };'.
Can it help me ?
Thank you in advance.
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 3 lines · On Thu, Jul 24, 2008 at 3:52 PM, <[email protected]> wrote:
So, I added the
register_board_infoin my board init function. I fill thei2c_board_infostructure with the macroI2C_BOARD_INFO. I define a few clients.
hmm... ok
Quoted 4 lines
And so what ?
The system is supposed to call the probe(client) of the driver ?
yes, if you have the proper struct i2c_driver and struct i2c_device_id in your driver the i2c subsystem should call the probe of your device.
check drivers/i2c/chips/menelaus.c for an example.
See how I2C_BOARD_INFO() in arch/arm/mach-omap2/board-h4 and struct i2c_device_id have the same name for the device (menelaus).
Quoted 2 lines
I am really lost. I did not anderstand how to get a valid client instance. I suppose the I2C layer says "Hey boy, you have a new client !", but when ?
no, i2c layer will call device probe based on the driver name being the same in i2c_board_info and i2c_device_id (if I'm not wrong that's the match, Jean correct
me if I'm wrong).
Quoted 3 lines
What about 'static unsigned short probe[2] = {
I2C_CLIENT_END,I2C_CLIENT_END};'.
Can it help me ?
That's old style i2c driver. You don't need that anymore ;-)
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Thank you so much for help.
Quoted 7 lines
yes, if you have the proper struct
i2c_driverand structi2c_device_idin your driver the i2c subsystem should call the probe of your device.check
drivers/i2c/chips/menelaus.cfor an example.See how
I2C_BOARD_INFO()inarch/arm/mach-omap2/board-h4and structi2c_device_idhave the same name for the device (menelaus).
I am not using the last snapshot of Linux, but the 2.6.23 release. My source code is not completly up-to-date.
For example there is no reference of I2C_BOARD_INFO in board-h4. I have no 'i2c_device_id menelaus_id[]' in the i2c drivers code.
Perhap's that's why I am quite confuse, I am refering to recent code examples and I am using not-so-recent Linux version.
In the documentation, "New-style" drivers are presented very quickly. In fact, I still don't know where must be located the valid client list:
- in the board init source code with I2C_BOARD_INFO() macro
- in the i2c driver source code
Quoted 6 lines
no, i2c layer will call device probe based on the driver name being the same in
i2c_board_infoandi2c_device_id(if I'm not wrong that's the match, Jean correct
me if I'm wrong).
With my Linux version, i2c_device_id list was not present in the i2c_driver structure. So i2c_board_info is supposed to match with what ?
Quoted 1 line
That's old style i2c driver. You don't need that anymore ;-)
Cool :)
Lines removed !
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Ok, I think I have anderstand the process.
It is not as mystic that I thaught.
Tell me if I am wrong.
This is the process :
- Board init step #1
- I2C bus platform_driver initialisation
- Board init step #2 (register hardware i2c busses to the platform_driver)
- The I2C bus platform_driver register the new adapters to I2C layer
- Board init step #3 (register hardware devices present on each I2C bus)
- The I2C layer performs compatibity checks and tell I2C bus driver to add clients
=> The probe callback function of the i2c driver is called.
Am I right ?
Thanks for help.
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 13 lines · On Thu, Jul 24, 2008 at 5:26 PM, <[email protected]> wrote:
Hi,
Thank you so much for help.
Quoted 7 lines
yes, if you have the proper struct
i2c_driverand structi2c_device_idin your driver the i2c subsystem should call the probe of your device.check
drivers/i2c/chips/menelaus.cfor an example.See how
I2C_BOARD_INFO()inarch/arm/mach-omap2/board-h4and structi2c_device_idhave the same name for the device (menelaus).
Quoted 8 lines
I am not using the last snapshot of Linux, but the 2.6.23 release. My source code is not completly up-to-date.
For example there is no reference of
I2C_BOARD_INFOin board-h4. I have no 'i2c_device_idmenelaus_id[]' in the i2c drivers code.Perhap's that's why I am quite confuse, I am refering to recent code examples and I am using not-so-recent Linux version.
might be. Why are you using 2.6.23 and not 2.6.26 ?
Anyways, in 2.6.23 there was no i2c_device_id, so you can drop that comment.
But if you have to give the same name in the driver and in the i2c_board_info().
something like:
struct i2c_board_info *info[] =
{
Quoted 35 lines
In the documentation, "New-style" drivers are presented very quickly. In fact, I still don't know where must be located the valid client list:
- in the board init source code withI2C_BOARD_INFO()macro
- in the i2c driver source codeQuoted 6 lines
no, i2c layer will call device probe based on the driver name being the same in
i2c_board_infoandi2c_device_id(if I'm not wrong that's the match, Jean correct
me if I'm wrong).With my Linux version,
i2c_device_idlist was not present in thei2c_driverstructure. Soi2c_board_infois supposed to match with what ?Quoted 1 line
That's old style i2c driver. You don't need that anymore ;-)
Cool :)
Lines removed !Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
sorry pressed the send button by mistake.
read below
Quoted 8 lines · On Thu, Jul 24, 2008 at 5:26 PM, <[email protected]> wrote:
I am not using the last snapshot of Linux, but the 2.6.23 release. My source code is not completly up-to-date.
For example there is no reference of
I2C_BOARD_INFOin board-h4. I have no 'i2c_device_idmenelaus_id[]' in the i2c drivers code.Perhap's that's why I am quite confuse, I am refering to recent code examples and I am using not-so-recent Linux version.
might be. Why are you using 2.6.23 and not 2.6.26 ?
Anyways, in 2.6.23 there was no i2c_device_id, so you can drop that comment.
But if you have to give the same name in the driver and in the i2c_board_info().
something like:
board file:
struct i2c_board_info *info[] =
{
{
I2C_BOARD_INFO("mydevice", 0xff), },
};
(...)
driver:
struct i2c_driver mydriver = {
.driver = {
.name = "mydevice",
},
.probe = myprobe,
.remove = __exit_p(myremove),
};got it ??
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 7 lines · On Thu, Jul 24, 2008 at 7:11 PM, <[email protected]> wrote:
- Board init step #1
- I2C busplatform_driverinitialisation- Board init step #2 (register hardware i2c busses to the
platform_driver)
- The I2C busplatform_driverregister the new adapters to I2C layer- Board init step #3 (register hardware devices present on each I2C bus)
are you writing a client driver or a bus driver ?
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 1 line
are you writing a client driver or a bus driver ?
In fact, I just want to write a client driver for a embedded board. But, the bus driver is not already ported, so I wrote an algorithm and an adapter. I am currently write the client driver, but no client is coming.
Quoted 1 line
might be. Why are you using 2.6.23 and not 2.6.26 ?
I want to use the 2.6.23 release because I have already a patched and customized Linux directory tree, I don't want to merge it with new version of kernel.
Quoted 2 lines
But if you have to give the same name in the driver and in the
i2c_board_info().
Ok, I have this now.
Quoted 1 line
got it ??
Not really. Thanks to you, I anderstand more about i2c layer. But now, I think my problem is the bus driver.
I have this error :
"I2C adapter driver : forgot to specify physical device"
I don't anderstand where we are supposed to associate an adapter with the client driver.
Thanks for help.
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hello,
Ok, I have just read my code carefully and correct some mistakes. It is quite clean now, but I still don't get my clients.
In the board initialisation file, I define two things :
- a platform_device for my I2C bus
The name field correspond to the adapter platform_driver.name
- a valid i2c_board_info struct defining my clients
The name field correspond to the client i2c_driver.name I do not care about type field, I just use the I2C_BOARD_INFO macro
I have written different modules for the algorithm, the adapter, and the client.
First at all, I load the client driver with insmod utility. Then, I load the algorithm.
And finally, I load the adapter.
When the adapter is loaded, my probe(platform_device) is correctly called. I allocate a new structure correctly and register a new adapter.
On the remove callback function, I deallocate it.
No client is registred to my i2c_driver, so where is the mistake ?
Quoted 1 line
got it ??
As soon as possible :-)
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 3 lines · On Fri, Jul 25, 2008 at 5:08 PM, <[email protected]> wrote:
First at all, I load the client driver with insmod utility. Then, I load the algorithm.
And finally, I load the adapter.
should be the other way around. You first need a bus in order to have clients.
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 2 lines
should be the other way around. You first need a bus in order to have clients.
Ok, so I unload all the modules.
First, I load the algorithm.
Second, I load the adapter.
And finally I load the client driver.
There isn't any improvement.
Any other ideas ?
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
In order to improve my understanding of Linux i2c layer, I read the source code. I read i2c-core.c and I try to anderstand why my clients wasn't created.
The problem is in the i2c_register_adapter function :
/* create pre-declarated device nodes for new-style drivers */ if (adap->nr < __i2c_first_dynamic_bus_num)
i2c_scan_static_board_info(adap);
The test is NEVER true. So my clients are not created.
I read that __i2c_first_dynamic_bus_num is set to 1. It does not seems to change.
And that adap->nr refers to "Dynamic Bus Number".
My first bus register with adap->nr=1.
The second register with adap->nr=2.
That's why the test fails.
So, I have had an idea to fix the problem.
I change :i2c_add_adapter(adap);
withadap->nr = 0;i2c_add_numbered_adapter(adap);
But, it make new problems :
- I can't manage two busses
- I definitly don't anderstand how I2C_BOARD_INFO macro can associate a client to a specified bus
- I don't anderstand what I am writing, and I really dislike it :c
So many questions :)
Thanks for help.
Best regards,
Légion.
_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 11 lines · On Mon, Jul 28, 2008 at 12:36 PM, <[email protected]> wrote:
Hi,
In order to improve my understanding of Linux i2c layer, I read the source code. I read
i2c-core.cand I try to anderstand why my clients wasn't created.The problem is in the
i2c_register_adapterfunction :/* create pre-declarated device nodes for new-style drivers */ if (
adap->nr<__i2c_first_dynamic_bus_num)
i2c_scan_static_board_info(adap);
Quoted 6 lines
The test is NEVER true. So my clients are not created.
I read that
__i2c_first_dynamic_bus_numis set to 1. It does not seems to change.
it changes in i2c-boardinfo.c@i2c_register_board_info:
/* dynamic bus numbers will be assigned after the last static one */ if (busnum >= __i2c_first_dynamic_bus_num) __i2c_first_dynamic_bus_num = busnum + 1;
which would make the above if() true :-)
Quoted 3 lines
And that
adap->nrrefers to "Dynamic Bus Number".
My first bus register with adap->nr=1.
The second register with adap->nr=2.
hmm.. i suppose your calling i2c_register_board_info() with wrong parameters.
Quoted 13 lines
That's why the test fails.
So, I have had an idea to fix the problem.
I change :
i2c_add_adapter(adap);with
adap->nr= 0;i2c_add_numbered_adapter(adap);
Quoted 5 lines
But, it make new problems :
- I can't manage two busses
- I definitly don't anderstand howI2C_BOARD_INFOmacro can associate a client to a specified bus
- I don't anderstand what I am writing, and I really dislike it :c
show me your i2c_register_board_info() call.
it should be:
i2c_register_board_info(bus number, struct i2c_board_info **,
ARRAY_SIZE(i2c_board_info));
just a note, the first i2c bus is bus 1 and not bus 0. I suppose that's not your problem, right ?
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
Hi,
Quoted 22 lines · On Mon, Jul 28, 2008 at 1:12 PM, <[email protected]> wrote:
Hi,
Quoted 10 lines
Quoted 2 lines
I read that
__i2c_first_dynamic_bus_numis set to 1. It does not seems to change.it changes in i2c-boardinfo.c@i2c_register_board_info:
/* dynamic bus numbers will be assigned after the last static one */ if (busnum >= __i2c_first_dynamic_bus_num) __i2c_first_dynamic_bus_num = busnum + 1;which would make the above
if()true :-)You're right !
Quoted 5 lines
hmm.. i suppose your calling
i2c_register_board_info()with wrong parameters.just a note, the first i2c bus is bus 1 and not bus 0. I suppose that's not your problem, right ?
Quoted 8 lines
It was :D
I thought it was zero-based counter...and I tested the code with only one bus !Hehe, I feel stupid :D
MANY MANY MANY THANKS :D
Cool. At least it's solved :-)
Have fun now ;-)
Signature · 9 lines
Best Regards, Felipe Balbi [email protected] _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c