public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] AVR32 AP700x - I2C somewhere?
@ 2010-06-01 14:04 Reinhard Meyer
  2010-06-02  7:02 ` Andreas Bießmann
  0 siblings, 1 reply; 3+ messages in thread
From: Reinhard Meyer @ 2010-06-01 14:04 UTC (permalink / raw)
  To: u-boot

Hi,

has anyone started or completed work on an I2C driver for AP7000x?

If not, I am at least going to make SOFT I2C defines to read VPD from an 
At24C64 EEPROM.

Thanks, Reinhard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] AVR32 AP700x - I2C somewhere?
  2010-06-01 14:04 [U-Boot] AVR32 AP700x - I2C somewhere? Reinhard Meyer
@ 2010-06-02  7:02 ` Andreas Bießmann
  2010-06-02 12:37   ` Reinhard Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Bießmann @ 2010-06-02  7:02 UTC (permalink / raw)
  To: u-boot

Am 01.06.2010 16:04, schrieb Reinhard Meyer (-VC):
> Hi,
Dear Reinhard Meyer,

> has anyone started or completed work on an I2C driver for AP7000x?
No ...
> 
> If not, I am at least going to make SOFT I2C defines to read VPD from an 
> At24C64 EEPROM.
But I've working soft-i2c here. There are still some other examples in
u-boot how to interface a at24xx eeprom.

custom board config file:
---8<---
/* i2c definitions */
#define CONFIG_SOFT_I2C
#if defined(CONFIG_SOFT_I2C)
#define DEBUG_I2C
#ifndef __ASSEMBLY__
#include <asm/arch/portmux.h>
#define MEDUCORE_SDA_PIN	6
#define MEDUCORE_SCL_PIN	7

#define I2C_ACTIVE	portmux_select_gpio(PORTMUX_PORT_A,
(1<<MEDUCORE_SDA_PIN), PORTMUX_DIR_OUTPUT|PORTMUX_INIT_LOW)
#define I2C_TRISTATE		portmux_select_gpio(PORTMUX_PORT_A,
(1<<MEDUCORE_SDA_PIN), PORTMUX_DIR_INPUT|PORTMUX_OPEN_DRAIN)
#define I2C_READ	pio_get_input_value(GPIO_PIN_PA(MEDUCORE_SDA_PIN))
#define I2C_SDA(bit)	pio_set_output_value(GPIO_PIN_PA(MEDUCORE_SDA_PIN),
bit)
#define I2C_SCL(bit)	pio_set_output_value(GPIO_PIN_PA(MEDUCORE_SCL_PIN),
bit)
#endif

#define I2C_DELAY	udelay(3)	/* TODO needs testing */
#define I2C_SOFT_DECLARATIONS

#define	CONFIG_SYS_I2C_SLAVE		0x0
#define	CONFIG_SYS_I2C_SPEED		100000 /* TODO needs testing */
#define CONFIG_CMD_I2C

#endif
--->8---

and in our custom board implementation (only snippet):
---8<---
@@ -29,6 +29,8 @@
 #include <asm/arch/hmatrix.h>
 #include <asm/arch/portmux.h>

+#include <i2c.h>
+
 DECLARE_GLOBAL_DATA_PTR;

 /*
@@ -71,6 +73,38 @@ static const struct sdram_config sdram_config = {

 int board_early_init_f(void)
 {
+       unsigned char val = 0xFF;
+       unsigned char version = 0x00;
+       int ret = -1; // assume error
+
+       // first select SCL gpio
+       portmux_select_gpio(PORTMUX_PORT_A, (1<<MEDUCORE_SCL_PIN),
PORTMUX_DIR_OUTPUT|PORTMUX_INIT_LOW);
+       // initialize i2c
+       i2c_init(1000, 0x27);
+       // check for precedence of port multiplexer
+       ret = i2c_probe(0x27);
+       if ( ret != 0 ) {
+               gd->flags |= GD_FLG_POSTFAIL;
+               goto out;
+       }
+
+       ret |= i2c_write(0x27, 0x06, 1, &val, 1); // set GPPU to FF
+       ret |= i2c_write(0x27, 0x01, 1, &val, 1); // set IPOL to FF
(invert palaritiy)
+       if ( ret != 0 ) {
+               gd->flags |= GD_FLG_POSTFAIL;
+               goto out;
+       }
+
+       ret = i2c_read(0x27, 0x09, 1, &version, 1); // read in the
version value
+       if ( ret != 0 ) {
+               gd->flags |= GD_FLG_POSTFAIL;
+               goto out;
+       }
+       // version can be used from here

--->8---

regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] AVR32 AP700x - I2C somewhere?
  2010-06-02  7:02 ` Andreas Bießmann
@ 2010-06-02 12:37   ` Reinhard Meyer
  0 siblings, 0 replies; 3+ messages in thread
From: Reinhard Meyer @ 2010-06-02 12:37 UTC (permalink / raw)
  To: u-boot

Andreas Bie?mann schrieb:
> Am 01.06.2010 16:04, schrieb Reinhard Meyer (-VC):
>   
>> Hi,
>>     
> Dear Reinhard Meyer,
>
>   
>> has anyone started or completed work on an I2C driver for AP7000x?
>>     
> No ...
>   
>> If not, I am at least going to make SOFT I2C defines to read VPD from an 
>> At24C64 EEPROM.
>>     
> But I've working soft-i2c here. There are still some other examples in
> u-boot how to interface a at24xx eeprom.
>   
Thank you. That worked to verify my setup.
I was fooled by the AtTiny on the NGW100 which does try to slow I2C 
Transfers by pulling SCL low.
That feature however is NOT honored by the SOFT_I2C driver.
So accesses to my At24C64 had to fail. After removing the AtTiny it 
works fine :)
> custom board config file:
> ---8<---
> /* i2c definitions */
> #define CONFIG_SOFT_I2C
> #if defined(CONFIG_SOFT_I2C)
> #define DEBUG_I2C
> #ifndef __ASSEMBLY__
> #include <asm/arch/portmux.h>
> #define MEDUCORE_SDA_PIN	6
> #define MEDUCORE_SCL_PIN	7
>
> #define I2C_ACTIVE	portmux_select_gpio(PORTMUX_PORT_A,
> (1<<MEDUCORE_SDA_PIN), PORTMUX_DIR_OUTPUT|PORTMUX_INIT_LOW)
> #define I2C_TRISTATE		portmux_select_gpio(PORTMUX_PORT_A,
> (1<<MEDUCORE_SDA_PIN), PORTMUX_DIR_INPUT|PORTMUX_OPEN_DRAIN)
>   
The functions ACTIVE and TRISTATE are not required when the Pins are 
initialized OUTPUT and OPENDRAIN as follows:

int board_early_init_f(void)
{
    ...
#ifdef CONFIG_CMD_I2C
    // first select SCL and SDA gpio
    portmux_select_gpio(PORTMUX_PORT_A,(1<<SDA_PIN), 
PORTMUX_DIR_OUTPUT|PORTMUX_INIT_LOW|PORTMUX_OPEN_DRAIN);
    portmux_select_gpio(PORTMUX_PORT_A,(1<<SCL_PIN), 
PORTMUX_DIR_OUTPUT|PORTMUX_INIT_LOW|PORTMUX_OPEN_DRAIN);
    // initialize i2c
    i2c_init(1000, 0x27);
#endif
    return 0;
}

The I2C Bus by definition is a wired-or bus, all devices must have open 
drain outputs for SDA and SCL!

Best Regards,
Reinhard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-02 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01 14:04 [U-Boot] AVR32 AP700x - I2C somewhere? Reinhard Meyer
2010-06-02  7:02 ` Andreas Bießmann
2010-06-02 12:37   ` Reinhard Meyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox