All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] i2c:soft:multi: Support for multiple soft I2C buses
Date: Tue, 28 Aug 2012 14:25:43 +0200	[thread overview]
Message-ID: <503CB8C7.8010607@denx.de> (raw)
In-Reply-To: <20120828141226.42183f6c@amdc308.digital.local>

Hello Lukasz,

On 28.08.2012 14:12, Lukasz Majewski wrote:
> Hi Heiko,
>
>
>>>>> +#if defined(CONFIG_I2C_MULTI_BUS)
>>>>> +/* Handle multiple I2C buses instances */
>>>>> +int get_multi_scl_pin(void)
>>>>> +{
>>>>> +	switch (I2C_GET_BUS()) {
>>>>> +	case I2C_4:
>>>>> +		return CONFIG_SOFT_I2C_I2C4_SCL;
>>>>> +	case I2C_5:
>>>>> +		return CONFIG_SOFT_I2C_I2C5_SCL;
>>>>> +	};
>>>>> +
>>>>> +	return 0;
>>>>> +}
>>>>> +
>>>>> +int get_multi_sda_pin(void)
>>>>> +{
>>>>> +	switch (I2C_GET_BUS()) {
>>>>> +	case I2C_4:
>>>>> +		return CONFIG_SOFT_I2C_I2C4_SDA;
>>>>> +	case I2C_5:
>>>>> +		return CONFIG_SOFT_I2C_I2C5_SDA;
>>>>> +	};
>>>>> +
>>>>> +	return 0;
>>>>> +}
>>>>> +
>>>>> +int multi_i2c_init(void)
>>>>> +{
>>>>> +	return 0;
>>>>> +}
>>>>> +#endif /* CONFIG_I2C_MULTI_BUS */
>>>>
>>>> Again, what is with busnr = 0-3 or 6?
>>>>
>>>> This is not needed in the i2c soft file. You can define this
>>>> functions board specific ... so, no change in the driver is
>>>> needed ... please move this to board specific code.
>>>
>>> Please consider, that get_multi_{sda|scl}_pin can be used by other
>>> boards. Those are written in a generic way (by calling
>>> I2C_GET_BUS()).
>>
>> Got this, but why do you index them with 4 and 5 and not with 0 and 1?
>> What is, if another board uses 0 and 1, so this would introduce
>> the defines CONFIG_SOFT_I2C_I2C0_SDA and CONFIG_SOFT_I2C_I2C1_SDA
>> in the "common" get_multi_sda_pin(), which leads in compilererror for
>> your board(s) ... your proposed get_multi_sda_pin() is currently
>> samsung specific ...
>>
>>> What here I'm trying to avoid is the code duplication for each board
>>> (e.g. Samsung's GONI, Universal, Trats, Origen ... etc).
>>
>> If they use all the same function, they should end in
>> a ../samsung/common/common.c because, currently your functions are
>> samsung specific.
>>
>> common is (from my point of view) that we add in the board config
>> file:
>>
>> +#define CONFIG_SOFT_I2C_GPIO_SCL get_multi_scl_pin()
>> +#define CONFIG_SOFT_I2C_GPIO_SDA get_multi_sda_pin()
>>
>>> I can agree, that now only I2C_{4|5} are defined (since for now
>>> Samsung is using I2C_4 and I2C_5).
>>
>> and thats samsung specific ... because other boards maybe start
>> with I2C_0 ... and this case is not respected in your patch.
>>
>>> But other cases can be also defined.
>>
>> Yep, and break compiling your board, as this defines are not
>> specified.
>>
>>> What I see even more important is a definition of (at<i2c.h>):
>>>
>>> +#if (defined(CONFIG_SOFT_I2C)&&    defined(CONFIG_I2C_MULTI_BUS))
>>> +enum {
>>> +	I2C_0,
>>> +	I2C_1,
>>> +	I2C_2,
>>> +	I2C_3,
>>> +	I2C_4,
>>> +	I2C_5,
>>> +	I2C_6
>>> +};
>>>
>
> I would like to propose that, I will rename the I2C_4 ->  I2C_0 and
> I2C_5 ->  I2C_1,

Yep!

> then we can define at<i2c.h>  :
>
> +#if (defined(CONFIG_SOFT_I2C)&&    defined(CONFIG_I2C_MULTI_BUS))
> +enum {
> +	I2C_0,
> +	I2C_1,
> +};
>
> And this would facilitate handling of SOFT_I2C numbering across
> relevant subsystems (e.g. PMICs and other).

Ok.

>>> since this will organize the order of multiple (soft) I2C devices.
>>>
>>> Imagine that 2 PMICs are on the board (I2C_4 and I2C_5). I need to
>>> distinct those (when calling I2C_SET|GET_BUS)
>>> And then support for another I2C device (e.g. I2C_2) at other
>>> subsystem is provided.
>>> Then I can:
>>> 1. Add common definition of I2C_X (as I've proposed) to<i2c.h>
>>> 2. Add #define I2C_X on the ./include/configs/{e.g. trats}.h board.
>>
>>        Why add "#define I2C_X" in ./include/configs/{e.g. trats}.h ?
>>        I don?t understand this ... and you do not this in your
>> patchserie!
>>
>>> For second approach used I need to duplicate the code for other
>>> targets (goni, universal, origen) when needed and I cannot avoid
>>> that someone
>>
>>     or make a ../samsung/common/common.c until they are samsung
>> specific.
>>
>>> else will define other names ->   like #define MINE_I2C_X on
>>> his/her ./include/configs/{board}.h
>>
>> Ok, but if you use I2C_4 and I2C_5, you must also define the I2C_0,
>> I2C_1, I2C_2 and I2C_3 cases in the "get_multi_*" functions, as other
>> boards would start with I2C_0 ...
>>
>> ... and add a documentation in README for this ...
>>
>> but I mislike to introduce such a lot of defines ... instead of
>> defining get_multi_*() board/manufacturer/soc specific ... Maybe
>> there is a board with 10 i2c soft busses, so we must define in all
>> boards using soft multibus this 20
>> (CONFIG_SOFT_I2C_I2C*_SCL/SDA)defines ... or at least define them if
>> not defined in include/i2c.h ... bad.
>>
>
> I will move the "get_multi_*" functions to ../samsung/common/common.c

Good.

> However, I think, that it would be good to add following declarations to
> <i2c.h>:
>
> extern int get_multi_scl_pin(void);
> extern int get_multi_sda_pin(void);
> extern int multi_i2c_init(void);

In the case CONFIG_I2C_MULTI_BUS is defined.

> ,which can be defined on different platforms.
 >
> What is your opinion about that?

I agree with this!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2012-08-28 12:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-28  8:33 [U-Boot] [PATCH 0/2] i2c:soft:multi: Support for multiple soft I2C buses at TRATS Lukasz Majewski
2012-08-28  8:33 ` [U-Boot] [PATCH 1/2] i2c:soft:multi: Support for multiple soft I2C buses Lukasz Majewski
2012-08-28  9:00   ` Heiko Schocher
2012-08-28 10:40     ` Lukasz Majewski
2012-08-28 11:29       ` Heiko Schocher
2012-08-28 12:12         ` Lukasz Majewski
2012-08-28 12:25           ` Heiko Schocher [this message]
2012-08-28 13:56             ` Lukasz Majewski
2012-08-28  8:33 ` [U-Boot] [PATCH 2/2] i2c:soft:multi: Enable soft I2C multibus at Trats development board Lukasz Majewski
2012-08-29  9:58 ` [U-Boot] [PATCH v2 0/2] i2c:soft:multi: Support for multiple soft I2C buses at TRATS Lukasz Majewski
2012-08-29  9:58   ` [U-Boot] [PATCH v2 1/2] i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards Lukasz Majewski
2012-08-29  9:58   ` [U-Boot] [PATCH v2 2/2] i2c:soft:multi: Enable soft I2C multibus at Trats development board Lukasz Majewski
2012-09-03 15:58 ` [U-Boot] [PATCH v3 0/2] i2c:soft:multi: Support for multiple soft I2C buses at TRATS Lukasz Majewski
2012-09-03 15:58   ` [U-Boot] [PATCH v3 1/2] i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards Lukasz Majewski
2012-09-04  8:23     ` Lukasz Majewski
2012-09-03 15:58   ` [U-Boot] [PATCH v3 2/2] i2c:soft:multi: Enable soft I2C multibus at Trats development board Lukasz Majewski
2012-09-05  9:15 ` [U-Boot] [PATCH v4 0/2] i2c:soft:multi: Support for multiple soft I2C buses at TRATS Lukasz Majewski
2012-09-05  9:15   ` [U-Boot] [PATCH v4 1/2] i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards Lukasz Majewski
2012-09-06  3:49     ` Heiko Schocher
2012-09-06  8:12       ` Lukasz Majewski
2012-09-12  7:06     ` Lukasz Majewski
2012-09-12  7:43       ` Minkyu Kang
2012-09-05  9:15   ` [U-Boot] [PATCH v4 2/2] i2c:soft:multi: Enable soft I2C multibus at Trats development board Lukasz Majewski
2012-09-06  3:50     ` Heiko Schocher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503CB8C7.8010607@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.