From: Nils N. Gjerdevik <nils.gjerdevik@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] SOFT_I2C on at91rm9200
Date: Mon, 18 Jun 2007 15:51:22 +0200 [thread overview]
Message-ID: <46768DDA.6000103@gmail.com> (raw)
In-Reply-To: <1182167991.2969.14.camel@gentoo-jocke.transmode.se>
Joakim Tjernlund wrote:
> On Mon, 2007-06-18 at 13:39 +0200, Nils Gjerdevik wrote:
>
>> 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 what I've put in my config file:
>>
>> #define I2C_INIT \
>> do { \
>> *AT91C_PIOA_PER = AT91C_PA25_TWD | AT91C_PA26_TWCK; \
>> *AT91C_PIOA_ODR = AT91C_PA25_TWD; \
>> *AT91C_PIOA_OER = AT91C_PA26_TWCK; \
>> }while(0)
>>
>> #define I2C_ACTIVE (*AT91C_PIOA_OER = AT91C_PA25_TWD)
>>
>> #define I2C_TRISTATE (*AT91C_PIOA_ODR = AT91C_PA25_TWD)
>>
>> #define I2C_READ ((*AT91C_PIOA_PDSR & AT91C_PA25_TWD) != 0)
>>
>> #define I2C_SDA(bit) \
>> if(bit) { \
>> *AT91C_PIOA_SODR = AT91C_PA25_TWD; \
>> } else { \
>> *AT91C_PIOA_CODR = AT91C_PA25_TWD; \
>> }
>>
>> #define I2C_SCL(bit) \
>> if(bit) { \
>> *AT91C_PIOA_SODR = AT91C_PA26_TWCK; \
>> } else { \
>> *AT91C_PIOA_CODR = AT91C_PA26_TWCK; \
>> }
>>
>> #define I2C_DELAY udelay(5)
>>
>> Can anyone see what's wrong with this code?
>> I can access the EEPROM without problems in Linux, using the
>> bit-banging driver, so the board design should be OK. The code above
>> is(loosely) based on the Linux bit-banging driver.
>>
>> Regards,
>> Nils
>>
>
> Hi Nils
> Don't know anything about at91rm9200, but you could
> test the below patch I sent a few weeks ago. I have tested
> it now and it works for me.
>
> ---
> I think the README w.r.t I2C_TRISTATE is OK as is(don't change it). I do
> think the soft i2c driver is broken in several places w.r.t
> IC2_ACTIVE/I2C_TRISTATE and I2C reset sequence. The below patch is an
> attempt to fix it, but I havn't tested it.
>
Hi Joakim,
I'm afraid your patch didn't help. All reads just return 0x00, so I
guess it's related to my definitions for the at91rm9200 and not the
generic soft_i2c code.
Nils
next prev parent reply other threads:[~2007-06-18 13:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-18 11:39 [U-Boot-Users] SOFT_I2C on at91rm9200 Nils Gjerdevik
2007-06-18 11:59 ` Joakim Tjernlund
2007-06-18 13:51 ` Nils N. Gjerdevik [this message]
2007-06-18 14:02 ` Joakim Tjernlund
2007-06-18 16:27 ` Matteo Vit
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=46768DDA.6000103@gmail.com \
--to=nils.gjerdevik@gmail.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