[U-Boot] [PATCH 1/3] i2c: add i2c_core and prepare for new multibus support

Simon Glass sjg at chromium.org
Wed Jan 18 22:37:55 CET 2012


Hi Tabi,

On Wed, Jan 18, 2012 at 12:11 PM, Tabi Timur-B04825
<B04825 at freescale.com> wrote:
> On Tue, Jan 17, 2012 at 1:12 AM, Simon Glass <sjg at chromium.org> wrote:
>> From: Heiko Schocher <hs at denx.de>
>>
>> This Patch introduce the new i2c_core file, which holds
>> the I2C core functions, for the rework of the multibus/
>> multiadapter support.
>> Also adds changes in i2c.h for the new I2C multibus/multiadapter
>> support. This new support can be activated with the
>> CONFIG_SYS_I2C define.
>>
>> Signed-off-by: Heiko Schocher <hs at denx.de>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>  arch/arm/include/asm/global_data.h        |    3 +
>>  arch/avr32/include/asm/global_data.h      |    3 +
>>  arch/blackfin/include/asm/global_data.h   |    4 +-
>>  arch/m68k/include/asm/global_data.h       |    3 +
>>  arch/microblaze/include/asm/global_data.h |    3 +
>>  arch/mips/include/asm/global_data.h       |    3 +
>>  arch/nios2/include/asm/global_data.h      |    3 +
>>  arch/powerpc/include/asm/global_data.h    |    3 +
>>  arch/sh/include/asm/global_data.h         |    3 +
>>  arch/sparc/include/asm/global_data.h      |    3 +
>>  arch/x86/include/asm/global_data.h        |    3 +
>>  drivers/i2c/Makefile                      |    1 +
>>  drivers/i2c/i2c_core.c                    |  360 +++++++++++++++++++++++++++++
>>  include/i2c.h                             |  199 +++++++++++++++-
>>  14 files changed, 584 insertions(+), 10 deletions(-)
>>  create mode 100644 drivers/i2c/i2c_core.c
>>
>> diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
>> index 23a6077..924cea2 100644
>> --- a/arch/arm/include/asm/global_data.h
>> +++ b/arch/arm/include/asm/global_data.h
>> @@ -87,6 +87,9 @@ typedef       struct  global_data {
>>        unsigned long   post_log_res; /* success of POST test */
>>        unsigned long   post_init_f_time; /* When post_init_f started */
>>  #endif
>> +#if defined(CONFIG_SYS_I2C)
>> +       void            *cur_adap;      /* current used i2c adapter */
>> +#endif
>
> I was really hoping we could get rid of the concept of a "current" i2c
> adapter, and just force all drivers to specify the I2C adapter they
> want to use for a given I2C operation.  That's how Linux operates, and
> it will prevent stuff like this:

I agree completely, it was one of the things I was going to ask for.
We should add a new parameter to calls instead IMO.

>
> void *old;
> void *new;
>
>
> old = get_current_i2c_adapter();
> set_i2c_adapter(new);
> // do I2C stuff
> set_i2c_adapter(old);
>
> --
> Timur Tabi
> Linux kernel developer at Freescale

Regards,
Simon


More information about the U-Boot mailing list