public inbox for u-boot@lists.denx.de
 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 11:00:55 +0200	[thread overview]
Message-ID: <503C88C7.9010707@denx.de> (raw)
In-Reply-To: <1346142797-17645-2-git-send-email-l.majewski@samsung.com>

Hello Lukasz,

On 28.08.2012 10:33, Lukasz Majewski wrote:
> Support for multiple soft I2C buses at soft_i2c.c
>
> This approach defines get_multi_{sda|scl}_pin functions to switch
> between multiple "soft" I2C buses.
>
> Up to CONFIG_SYS_MAX_I2C_BUS devices can be utilized.
> Common definition of I2C_X I2C buses is provided.
>
> TEST HW:
>       Samsung's Exynos4210 evt.0.1 - Trats development board
>
> Signed-off-by: Lukasz Majewski<l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
> ---
>   drivers/i2c/soft_i2c.c |   41 +++++++++++++++++++++++++++++++++++++++++
>   include/i2c.h          |   17 +++++++++++++++++
>   2 files changed, 58 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
> index 36c6114..7901f04 100644
> --- a/drivers/i2c/soft_i2c.c
> +++ b/drivers/i2c/soft_i2c.c
> @@ -127,6 +127,15 @@ DECLARE_GLOBAL_DATA_PTR;
>
>   #if defined(CONFIG_I2C_MULTI_BUS)
>   static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
> +const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS] = {
> +	NULL,
> +	NULL,
> +	NULL,
> +	NULL,
> +	"soft_i2c_4",
> +	"soft_i2c_5",
> +	NULL,
> +};

For what do you need "soft_i2c_name"? I see no usage of this in your patchset?
Also why the "NULL" for 0-3 and 6 positions?

And what is, if CONFIG_SYS_MAX_I2C_BUS is < 7 ?

>   #endif /* CONFIG_I2C_MULTI_BUS */
>
>   /*-----------------------------------------------------------------------
> @@ -482,3 +491,35 @@ int  i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
>   	send_stop();
>   	return(failures);
>   }
> +
> +#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.

> diff --git a/include/i2c.h b/include/i2c.h
> index 1f35acf..d563d62 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -250,4 +250,21 @@ static inline void I2C_SET_BUS(unsigned int bus)
>   		i2c_set_bus_num(bus);
>   }
>
> +/* Multi I2C busses handling */
> +#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
> +};
> +
> +extern const char *soft_i2c_name[CONFIG_SYS_MAX_I2C_BUS];
> +extern int get_multi_scl_pin(void);
> +extern int get_multi_sda_pin(void);
> +extern int multi_i2c_init(void);
> +#endif
>   #endif	/* _I2C_H_ */

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  9:00 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 [this message]
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
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=503C88C7.9010707@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox