[U-Boot-Users] SOFT_I2C on at91rm9200

Matteo Vit matteo.vit at dave.eu
Mon Jun 18 18:27:34 CEST 2007


Nils Gjerdevik ha scritto:
> Hi,
> I'm trying to store the u-boot environment in an EEPROM (at24c128) on
> a custom at91rm9200 based board. This fails when using the included
> HARD_I2C driver, and since there are known problems with the I2C
> controller on this uC, I'm trying to set up SOFT_I2C instead, without
> success so far...

This is for the Atmel's AVR32 processor. The PIO block seems the same. 
Just change pio2_writel function calls. I hope this help.

Matteo

/*
  * Software (bit-bang) I2C driver configuration
  */
#define GPIOG_EECLK 0x80
#define GPIOG_EEDAT 0x40

#define I2C_INIT	{ \
				pio2_writel(PIOA_BASE,PER,GPIOG_EEDAT | GPIOG_EECLK); \
				pio2_writel(PIOA_BASE,OER,GPIOG_EEDAT | GPIOG_EECLK); \
				pio2_writel(PIOA_BASE,IDR,GPIOG_EEDAT | GPIOG_EECLK); \
				pio2_writel(PIOA_BASE,PUDR,GPIOG_EEDAT | GPIOG_EECLK); \
				pio2_writel(PIOA_BASE,MDER,GPIOG_EEDAT | GPIOG_EECLK); \
				pio2_writel(PIOA_BASE,OWER,GPIOG_EEDAT | GPIOG_EECLK); \
			}
#define I2C_ACTIVE	(pio2_writel(PIOA_BASE,SODR,GPIOG_EEDAT))
#define I2C_TRISTATE	(pio2_writel(PIOA_BASE,SODR,GPIOG_EEDAT))
#define I2C_READ	(pio2_readl(PIOA_BASE,PDSR) & GPIOG_EEDAT ? 1 : 0)
#define I2C_SDA(bit)	pio2_writel(PIOA_BASE,OER,GPIOG_EEDAT); \
						if (bit) pio2_writel(PIOA_BASE,SODR,GPIOG_EEDAT); \
						else pio2_writel(PIOA_BASE,CODR,GPIOG_EEDAT)
#define I2C_SCL(bit)	pio2_writel(PIOA_BASE,OER,GPIOG_EECLK); \
						if (bit) \
							pio2_writel(PIOA_BASE,SODR,GPIOG_EECLK); \
						else pio2_writel(PIOA_BASE,CODR,GPIOG_EECLK)
#define I2C_DELAY	udelay(50)	/* 1/4 I2C clock duration */

#endif	/* CONFIG_SOFT_I2C */




More information about the U-Boot mailing list