public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [AT91] Problems configuring bit-banged I2C
Date: Sat, 24 May 2008 15:33:09 +0200	[thread overview]
Message-ID: <20080524133309.GA6493@game.jcrosoft.org> (raw)
In-Reply-To: <20080523233604.GA10231@fan.ossfans.org>

On 03:36 Sat 24 May     , Sergey Lapin wrote:
> Hi, all!
> 
> I use the following patch on my AT91SAM9260-based custom board to
> configure bit-banged I2C:
> 
> diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c b/board/atmel/at91sam9260ek/at91sam9260ek.c
> index b30aad8..99fc2bd 100644
> --- a/board/atmel/at91sam9260ek/at91sam9260ek.c
> +++ b/board/atmel/at91sam9260ek/at91sam9260ek.c
> @ -234,3 +234,46 @@ void reset_phy(void)
>  #endif
>  }
>  #endif
Why don't you use the gpio function?
> +
void at91sam9260_i2c_init(void)
{
	at91_set_GPIO_periph(AT91_PIN_PA23, 0);
	at91_set_multi_drive(AT91_PIN_PA23, 1);

	at91_set_A_periph(AT91_PIN_PA24, 0);
	at91_set_multi_drive(AT91_PIN_PA24, 1);
}

void at91sam9260_i2c_scl(unsigned long bit)
{
	at91_set_gpio_value(AT91_PIN_PA24, bit);
}

void at91sam9260_i2c_sda(unsigned long bit)
{
	at91_set_gpio_value(AT91_PIN_PA23, bit)
}
int at91sam9260_i2c_read(void)
{
	retrun at91_get_gpio_value(AT91_PIN_PA23);
}
void at91sam9260_i2c_active()
{
	gpio_direction_output(AT91_PIN_PA23, 0);
}

void at91sam9260_i2c_tristate()
{
	gpio_direction_input(AT91_PIN_PA23);
}
> diff --git a/include/configs/at91sam9260ek.h b/include/configs/at91sam9260ek.h
> index fd9932f..5e66c9e 100644
> --- a/include/configs/at91sam9260ek.h
> +++ b/include/configs/at91sam9260ek.h
> @@ -85,6 +85,8 @@
>  
>  #define CONFIG_CMD_NAND		1
>  #define CONFIG_CMD_USB		1
> +#define CONFIG_CMD_I2C		1
> +#define CONFIG_I2C_CMD_TREE	1
>  
>  /* SDRAM */
>  #define CONFIG_NR_DRAM_BANKS		1
> @ -192,4 +194,20 @@
>  #error CONFIG_USE_IRQ not supported
>  #endif
>  
> +/*
> + * Software (bit-bang) I2C driver configuration
> + */
> +#define CONFIG_SOFT_I2C		1
> +#define CFG_I2C_SPEED		1000000
> +#define I2C_INIT		at91sam9260_i2c_init()
#define I2C_ACTIVE	at91sam9260_i2c_active()
#define I2C_TRISTATE	at91sam9260_i2c_tristate()
> +#define I2C_SCL(bit)	at91sam9260_i2c_scl(bit)
> +#define I2C_SDA(bit)	at91sam9260_i2c_sda(bit)
> +#define I2C_DELAY	udelay(2)
> +#define I2C_READ	at91sam9260_i2c_read()
> +#define CFG_I2C_SLAVE		0
> +#define DEBUG_I2C
>  #endif
> +

I sync it will be better to use the hardware stack which is not too
complicate to implement

Best Regards,
J.

  reply	other threads:[~2008-05-24 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-23 23:36 [U-Boot-Users] [AT91] Problems configuring bit-banged I2C Sergey Lapin
2008-05-24 13:33 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2008-05-30 21:58   ` Sergey Lapin
2008-05-24 15:24 ` Haavard Skinnemoen
2008-05-29 21:56   ` Sergey Lapin

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=20080524133309.GA6493@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox