[U-Boot] I2c imd/imw for a digital potentiometer?

Hi all,
I'm a little stumped as to how to write to a EEPot with the imw command.
The EEPot is a Maxim 5434 and has an address of 0x28. To write to its volatile or non-volatile register ... a command byte is given.
Writing 5 bits of data (it is a 32 tap pot so that is where the 5 bits come from) to move the wiper goes something like this:
Start, 0x28, Ack, Cmd byte, Ack, Data byte, Ack, Stop
Cmd byte is 0x11 to write to volatile reg. 0x21 to write to non-volatile reg.
The EEPROM really doesn't have addresses/offsets so I tried:
imw 28 11 80 1 imw.w 28 0.0 1180
... but it doesn't appear to play well with my device.
I'm in a bitbanged I2C environment (with GPIO) on a ARM9 core and I can write to RTC and EEPROM just fine.
So, will uboot I2C commands handle a device like this (address command data)?
I've been grepping code and searching this mail list and kernel drivers (lm-sensor's) and I can't find any examples of EEpots being used in u-boot or the Linux kernel.
Regards,
Brian

Brian Hutchinson wrote:
Hi all,
I'm a little stumped as to how to write to a EEPot with the imw command.
The EEPot is a Maxim 5434 and has an address of 0x28. To write to its volatile or non-volatile register ... a command byte is given.
Writing 5 bits of data (it is a 32 tap pot so that is where the 5 bits come from) to move the wiper goes something like this:
Start, 0x28, Ack, Cmd byte, Ack, Data byte, Ack, Stop
Cmd byte is 0x11 to write to volatile reg. 0x21 to write to non-volatile reg.
Looks pretty standard if you map "cmd byte" to "register".
The EEPROM really doesn't have addresses/offsets so I tried:
imw 28 11 80 1
What is the trailing '1' here? Or is the '80' bogus?
I would expect this to work. The i2c command defaults to a one byte register offset. To write a 0x80 byte to register (aka command) 0x11, you want to do this: imw 28 11.1 80 which should be the same as this: imw 28 11 80
imw.w 28 0.0 1180
That seems like it should work also, although the '11' is more logically a register offset.
... but it doesn't appear to play well with my device.
Trivia: the old imw (imr, etc) commands are deprecated, you should use the new "i2c <cmd>" versions.
[snip]
Regards,
Brian
Good luck, gvb

On Tue, Sep 1, 2009 at 2:22 PM, Jerry Van Baren gerald.vanbaren@ge.comwrote:
Brian Hutchinson wrote:
Hi all,
I'm a little stumped as to how to write to a EEPot with the imw command.
The EEPot is a Maxim 5434 and has an address of 0x28. To write to its volatile or non-volatile register ... a command byte is given.
Writing 5 bits of data (it is a 32 tap pot so that is where the 5 bits come from) to move the wiper goes something like this:
Start, 0x28, Ack, Cmd byte, Ack, Data byte, Ack, Stop
Cmd byte is 0x11 to write to volatile reg. 0x21 to write to non-volatile reg.
Looks pretty standard if you map "cmd byte" to "register".
The EEPROM really doesn't have addresses/offsets so I tried:
imw 28 11 80 1
The one is a count.
What is the trailing '1' here? Or is the '80' bogus?
I would expect this to work. The i2c command defaults to a one byte register offset. To write a 0x80 byte to register (aka command) 0x11, you want to do this: imw 28 11.1 80 which should be the same as this: imw 28 11 80
imw.w 28 0.0 1180
That seems like it should work also, although the '11' is more logically a register offset.
... but it doesn't appear to play well with my device.
Trivia: the old imw (imr, etc) commands are deprecated, you should use the new "i2c <cmd>" versions.
[snip]
Regards,
Brian
Good luck, gvb
Well I figured my problem. I was trying various ways of writing to the eepot and trying to read back what I wrote in its non-volatile or volatile registers. I found out you can't read back from it! I went over the data sheet several times and nothing really said you could or you couldn't ... I just noticed they focused on writing to the eeprom inside and on power-cycle, the chip would read non-volatile storage and move the stored value to the volatile register and effect the wiper 20us after power up.
Once I realized this, I started writing values and probing the L pin with a multimeter and once I found the right pin (helps to know the right pin :) ) I discovered that: imw 28 11 80 1 would write to the volatile storage and make the wiper move so it is working! (there was much rejoycing)
I was using u-boot 1.1.6 which I forgot to mention. I also have 1.3.4 that I recently moved to. For some reason my bitbanged Soft_I2C I had working with 1.1.6 wouldn't work in 1.3.4. I also didn't notice any new i2c commands and just kept using the imd, imm, imw commands. Thanks for the tip on the new commands ... I'll have to look into it.
Regards,
Brian

On Tue, Sep 1, 2009 at 12:50 PM, Brian Hutchinsonb.hutchman@gmail.com wrote:
Hi all,
I'm a little stumped as to how to write to a EEPot with the imw command.
The EEPot is a Maxim 5434 and has an address of 0x28. To write to its volatile or non-volatile register ... a command byte is given.
Writing 5 bits of data (it is a 32 tap pot so that is where the 5 bits come from) to move the wiper goes something like this:
Start, 0x28, Ack, Cmd byte, Ack, Data byte, Ack, Stop
Cmd byte is 0x11 to write to volatile reg. 0x21 to write to non-volatile reg.
The EEPROM really doesn't have addresses/offsets so I tried:
imw 28 11 80 1
I believe this should do what you want. You could make double sure by doing imw 28 11.1 80 the .1 forces a one byte address. You don't need the trailing one count. Verify the device is asserting the ACK after each byte is sent with a 'scope.
You also didn't mention what version code you're on. The soft_i2c.c code had some bugs in it that would result in extra transitions if the I/O had separate tristate enables that I patched a year or two ago. You should make sure you're on the latest.
participants (3)
-
Andrew Dyer
-
Brian Hutchinson
-
Jerry Van Baren