Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Apr 2017 01:51 PM by  John Huang
DM3730-SOM: Configuration of I2C1 to communicate to PMIC.
 6 Replies
Sort:
You are not authorized to post a reply.
Author Messages
John Huang
New Member
New Member
Posts:8


--
03 Apr 2017 04:45 PM

    I am working on the DM3730 Torpedo SOM using the provided Linux 2.4-4 BSP.  I understand the I2C-1 bus coming out of the DM3730 IC goes directly to the TPS65950 (PMIC) as the main form of communication.  To send I2C data and request over this bus, I am relying on the i2c-dev.h bus driver and the use of open/ioctl/read calls.

    Using these mechanisms, I have been successfully at talking to multiple external i2c devices through the I2C-3 bus.  In fact, I've hooked up a Logic Analyzer to the I2C-3 lines and the signals looks very good just as per a datasheet specifies.

    However, when I use the same mechanism against I2C-1, I am getting errors from the ioctl() call.  At this point, I am not certain why that is the case since I was not expecting it to fail.  On my target console, when I list out the devices, I do see i2c-1, i2c-2, and i2c-3, so I figured that i2c-1 has already been configured by the BSP for us.  However, using it appears to prove otherwise.

     

    I would like to get some more information on how the device I2c-1 is configured differently than I2c-3 by the BSP.  Where can I locate such configuration code, so I can analyze it myself?  Also, how should I be configuring I2C-1 so that I can talk to the PMIC?

     

    My end goal is to be able to read and write to registers in the PMIC.  If there are any suites of library or driver code that I can utilize in user space, that'd be even better.

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    04 Apr 2017 08:29 AM
    The setup file that determine how the PMIC is configured is in arch/arm/mach-omap2/board-omap3logic.c

    The data is setup in a series of structures. Look for omap3logic_twldata.

    In there, you'll find a series of child structures that help setup the configuration of the PMIC. Generally we don't recommend interacting directly with the PMIC as a wrong register change, and you could damage the SOM by over or under volting a power rail.

    adam
    bradb
    Basic Member
    Basic Member
    Posts:203


    --
    04 Apr 2017 08:47 AM

    John,

    There is an example in the 'AN 527 Selecting and Using GPIO Signals on DM3730 - AM3703 SOMs'  in appendix B showing how to enable the VPLL2 in the PMIC using i2cset and i2cget commands for I2C1 from within Linux console.

    I have copied this information below.

    Linux I2C Commands

    The following commands can be run from the Linux prompt to enable VPLL2 at 1.8V.

    DM-37x# i2cset -f -y 1 0x4b 0x91 0x5

    DM-37x# i2cget -f -y 1 0x4b 0x91 0x05

    DM-37x# i2cset -f -y 1 0x4b 0x8e 0x2e

    DM-37x# i2cget -f -y 1 0x4b 0x8e 0x2e

    Disabling the PKG_I2C_TOOLS package might allow you to use the ioctl control capability. 

    Thanks,

    Brad

     

     

    John Huang
    New Member
    New Member
    Posts:8


    --
    04 Apr 2017 01:11 PM

    Thank you guys for the guidances.  I think I finally made great progress today.

    Adam, I looked through the board-omap3logic.c file and now I understand how each of our device nodes are being created.  I didn't see anything unusual with how the I2C1 node was being configured, other than the fact it is at a much higher clock rate (2600) than the other I2C2 and I2C3 nodes.  But I think this is made transparent to me at the user level anyways.

    Anyways, I looked at the App Notes that Brad pointed out and also the Linux User Guide.  So this gave me an opportunity to play with the i2cset and i2cget command, which was just extremely helpful in troubleshooting my custom I2C driver code.

    Here's what I noticed was my mistake.  I noticed in the App Notes, they use 'i2cset -f ..." (the FORCE option).  If I took out the -f option, things wouldn't work.  This hinted me to use ioctl(m_fd, I2C_SLAVE_FORCE, addr) in my code and I was no longer getting errors from my ioctl call.

    I guess my first question is "Is FORCE the correct thing for me to do in my code"?  Doesn't seem like I have any other choice, right?

    ----------------------------------------

    Then the other reason why my reads were coming back as 0 on ADC CH9 (Battery Backup Voltage) was because I forgot to do conversion on the ADC chip.  That was more of a "DUH" moment.  I found out the procedure on how to do this in the Linux BSP User Guide (Section 4.22 Analog-to-digital Converters).  They provided a sample script 'adc-script'.

    But here's one other question:  In the TSP65950 (PMIC) datasheet Section 9.5 Monitor ADC Programming Model, they are very insistent on using the MADC_ISR register to determine if the Conversion is complete.  However, I noticed in the 'adc-script', it simply hardcodes a sleep of 1 second to wait for the conversion.  Then it reads the MADC CH9 registers.  I believe for my application, a sleep would work fine since I have no strict timing constraint.

    However, would I need to worry about not clearing the interrupt bits in the MADC_ISR1 register?  Would this cause issues if I didn't?

    I apologize for asking such a detailed low-level question.

    ------------------------------------

    So far, I am able to move forward with all the learnings, so thank you so much.

     

    bradb
    Basic Member
    Basic Member
    Posts:203


    --
    05 Apr 2017 01:06 PM

    John,

    This manpage shows a warning when using the force option with i2cset command.

    Force  access  to  the  device  even  if  it is already busy. By
                  default, i2cset will refuse to access a device which is  already
                  under  the  control  of  a  kernel  driver.  Using  this flag is
                  dangerous,  it  can  seriously  confuse  the  kernel  driver  in
                  question.  It  can  also  cause  i2cset to silently write to the
                  wrong register. So use at your own risk and  only  if  you  know
                  what you're doing.
    

    Here is a document with information using the I2C device driver within Linux.  

    Here is a write-up of someone else implementing I2C_SLAVE_FORCE.

    Special caution needs to be taken when using the force option. 

    I don't have any information that guarantees the conversion has completed after 1 second as seen in the adc-script example.

    You might consider verifying the completion of the conversion by using the MADC_ISR register.

    Regards,

    Brad

    John Huang
    New Member
    New Member
    Posts:8


    --
    05 Apr 2017 01:18 PM

    Brad,

    Yeah, I saw the notes about the -f option, which is why I was concerned about using the FORCE option, but it seems to be the only way I could get the PMIC I2C communication to work and it was used all throughout the LogicPD examples.  I don't know what my other alternative would be.  Would using a polling mechanism with no FORCE even work?

    Did you mean to attach some links in your previous reply?

    Anyways, thanks for all the help so far.

    John Huang
    New Member
    New Member
    Posts:8


    --
    05 Apr 2017 01:51 PM

    Oh wait, nm.  The links are there.  The lack of text coloring tricked my eyes.

    You are not authorized to post a reply.