All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom <Tom.Rix@windriver.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] OMAP2/3: I2C: Add support for second and third bus
Date: Mon, 02 Nov 2009 09:50:04 -0600	[thread overview]
Message-ID: <4AEEFFAC.30700@windriver.com> (raw)
In-Reply-To: <1257105030-24574-1-git-send-email-dirk.behme@googlemail.com>

Dirk Behme wrote:
> Add support to use second and third I2C bus, too.
> 
> Bus 0 is still the default, but by calling i2c_set_bus_num(1/2) before doing
> I2C accesses, code can switch to bus 1 and 2, too. Don't forget to switch
> back afterwards, then. 
> 
> Signed-off-by: Dirk Behme <dirk.behme@googlemail.com>
> ---
> 
> Based on Hugo Vincent's patch
> 
> http://lists.denx.de/pipermail/u-boot/2009-June/055029.html
> 
> (this patch only contains the multibus support)
> 
> Compile tested with omap2_beagle and omap2420h4_config.
> 
> Boot tested with Zippy (I2C bus 1).
> 
>  drivers/i2c/omap24xx_i2c.c          |  170 +++++++++++++++++++++---------------
>  include/asm-arm/arch-omap24xx/i2c.h |   53 +++++++----
>  include/asm-arm/arch-omap3/i2c.h    |   50 +++++++---
>  3 files changed, 175 insertions(+), 98 deletions(-)
> 
> Index: u-boot-main/drivers/i2c/omap24xx_i2c.c
> ===================================================================
> --- u-boot-main.orig/drivers/i2c/omap24xx_i2c.c
> +++ u-boot-main/drivers/i2c/omap24xx_i2c.c
> @@ -29,6 +29,15 @@ static void wait_for_bb (void);
>  static u16 wait_for_pin (void);
>  static void flush_fifo(void);
>  
> +static struct i2c *i2c_base = (struct i2c *)I2C_DEFAULT_BASE;
> +
> +static unsigned int bus_initialized[I2C_BUS_MAX] = {0,
> +#if I2C_BUS_MAX==3
> +						    0,
> +#endif
> +						    0};
> +static unsigned int current_bus = 0;
> +

You can save this if-def if you do not initialize.
Since this is a static, it is not necessary if initializing with 0's

<snip>
>  void i2c_init (int speed, int slaveadd)
>  {
>  	int psc, fsscll, fssclh;

> --- u-boot-main.orig/include/asm-arm/arch-omap3/i2c.h
> +++ u-boot-main/include/asm-arm/arch-omap3/i2c.h
> @@ -25,21 +25,39 @@
>  
>  #define I2C_DEFAULT_BASE	I2C_BASE1
>  
> -#define I2C_REV		(I2C_DEFAULT_BASE + 0x00)
> -#define I2C_IE 		(I2C_DEFAULT_BASE + 0x04)
> -#define I2C_STAT	(I2C_DEFAULT_BASE + 0x08)
> -#define I2C_IV 		(I2C_DEFAULT_BASE + 0x0c)
> -#define I2C_BUF		(I2C_DEFAULT_BASE + 0x14)
> -#define I2C_CNT		(I2C_DEFAULT_BASE + 0x18)
> -#define I2C_DATA	(I2C_DEFAULT_BASE + 0x1c)
> -#define I2C_SYSC	(I2C_DEFAULT_BASE + 0x20)
> -#define I2C_CON		(I2C_DEFAULT_BASE + 0x24)
> -#define I2C_OA 		(I2C_DEFAULT_BASE + 0x28)
> -#define I2C_SA 		(I2C_DEFAULT_BASE + 0x2c)
> -#define I2C_PSC		(I2C_DEFAULT_BASE + 0x30)
> -#define I2C_SCLL	(I2C_DEFAULT_BASE + 0x34)
> -#define I2C_SCLH	(I2C_DEFAULT_BASE + 0x38)
> -#define I2C_SYSTEST	(I2C_DEFAULT_BASE + 0x3c)
> +struct i2c {
> +	unsigned short rev;	/* 0x00 */
> +	unsigned short res1;
> +	unsigned short ie;	/* 0x04 */
> +	unsigned short res2;
> +	unsigned short stat;	/* 0x08 */
> +	unsigned short res3;
> +	unsigned short iv;	/* 0x0C */
> +	unsigned short res4[3];
> +	unsigned short buf;	/* 0x14 */
> +	unsigned short res5;
> +	unsigned short cnt;	/* 0x18 */
> +	unsigned short res6;
> +	unsigned short data;	/* 0x1C */
> +	unsigned short res7;
> +	unsigned short sysc;	/* 0x20 */
> +	unsigned short res8;
> +	unsigned short con;	/* 0x24 */
> +	unsigned short res9;
> +	unsigned short oa;	/* 0x28 */
> +	unsigned short res10;
> +	unsigned short sa;	/* 0x2C */
> +	unsigned short res11;
> +	unsigned short psc;	/* 0x30 */
> +	unsigned short res12;
> +	unsigned short scll;	/* 0x34 */
> +	unsigned short res13;
> +	unsigned short sclh;	/* 0x38 */
> +	unsigned short res14;
> +	unsigned short systest;	/* 0x3c */

Please add a short to the end.
So the sizeof struct i2c will be divisible by 4.

Same for omap2.

Tom

      reply	other threads:[~2009-11-02 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-01 19:50 [U-Boot] [PATCH] OMAP2/3: I2C: Add support for second and third bus Dirk Behme
2009-11-02 15:50 ` Tom [this message]

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=4AEEFFAC.30700@windriver.com \
    --to=tom.rix@windriver.com \
    --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.