Trouble enabling i2c-2 in mainline uBoot for BeagleBone Black

951 views
Skip to first unread message

Joshua Datko

unread,
Mar 21, 2014, 8:19:58 PM3/21/14
to beagl...@googlegroups.com
I am trying to enable the i2c-2 bus in mainline uBoot and having problems.  I am building a cape that has a Trusted Platform Module (TPM) on pins P9_19/20, i2c-2.  Using some creative wiring, when I connect the cape to i2c-1, everything works fine.

I added this in /board/ti/am225x/mux.c:

static struct module_pin_mux i2c2_pin_mux[] = {
    {OFFSET(uart1_ctsn), (MODE(3) | RXACTIVE |
                       PULLUDEN | SLEWCTRL)}, /* I2C_DATA */
    {OFFSET(uart1_rtsn), (MODE(3) | RXACTIVE |
PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */
    {-1},
};

In enable_board_pin_mux, I put the following before any of the ifs:

configure_module_pin_mux(i2c2_pin_mux);

and added a puts after to ensure it was getting hit.

When I break in uboot and try to switch to i2c-2, the BBB resets as follows:

U-Boot# i2c dev 2
Setting bus to 2
data abort
pc : [<9f7745c4>]          lr : [<9f7745bc>]
sp : 9f637dc0  ip : 00000000     fp : 9f638598
r10: 9f7a7680  r9 : 9f637f28     r8 : 000186a0
r7 : 00000001  r6 : 9f7a47d4     r5 : 000186a0  r4 : 00000001
r3 : 0000002c  r2 : 00000001     r1 : 00000002  r0 : 4819c000
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
Resetting CPU ...

I'm not quite sure where to go from here.  It appears, to me, that uBoot has an issue with i2c-2 and any help would be appreciated.  I *could* switch the TPM over to i2c-1 but I'd rather not change the hardware unless using i2c-2 is impossible for some reason in uBoot.

I have a rev B BeagleBone Black BTW.

Josh

robertk...@gmail.com

unread,
Apr 3, 2014, 3:37:49 AM4/3/14
to beagl...@googlegroups.com
You should also enable clock for i2c-2 bus. I have done this by adding:
writel(PRCM_MOD_EN, &cmper->i2c2clkctrl);
while (readl(&cmper->i2c2clkctrl) != PRCM_MOD_EN) ;

And I have used spi0_sclk and spi0_d0 for my i2c2 bus.

But on my beaglebone black based board I keep getting:
timed out in wait_for_pin: I2C_STAT=0
error all the time for i2c probe command. The same bootloader works correctly with original BBB,
The only difference on my board is missing EEPROM.
 
Josh
 
Robert Kmiec 

jus...@gmail.com

unread,
Jan 13, 2015, 9:02:34 AM1/13/15
to beagl...@googlegroups.com, robertk...@gmail.com
Have you guys resolved the problem?
I have time out/bus busy problem with Josh's cryptocape and BBB A5C -rev (A335BNLT0A5C) -device.
It works fine in Debian on both of busses (i2c1 and i2c2). But with u-boot I have the problem.
I have added i2c2 pin muxing and enabled clock on u-boot (HEAD (92fa7) from denx.de). I also tried u-boot-sboot.

When it's physically configured to i2c2 (cryptocape default):
U-Boot# i2c dev 2
Setting bus to 2
Timed out in wait_for_bb: status=1000
Timed out in wait_for_bb: status=1000
U-Boot# i2c probe
Valid chip addresses:Timed out in wait_for_bb: status=1000
Timed out in wait_for_bb: status=1000
Timed out in wait_for_bb: status=1000
...and lot of same error message...

And on bus i2c1 (fly wiring)
U-Boot# i2c dev 1
Setting bus to 1
Timed out in wait_for_bb: status=1000
Timed out in wait_for_bb: status=1000
U-Boot# i2c probe
Valid chip addresses:Timed out in wait_for_bb: status=1000
Timed out in wait_for_bb: status=1000
Timed out in wait_for_bb: status=1000
...and lot of same error message...

Internal i2c0 bus works correctly:
U-Boot# i2c dev 0
Setting bus to 0
U-Boot# i2c probe
Valid chip addresses: 24 34 50

I have used this pin muxing for i2c2: (board/ti/am335x/mux.c)

static struct module_pin_mux i2c2_pin_mux[] = {

  {OFFSET(uart1_ctsn), (MODE(3) | RXACTIVE |

                     PULLUDEN | SLEWCTRL)},/* I2C_DATA */

  {OFFSET(uart1_rtsn), (MODE(3) | RXACTIVE |

                       PULLUDEN | SLEWCTRL)},/* I2C_SCLK */

  {-1},

};

And called configure_module_pin_mux(i2c2_pin_mux); on enable_board_pin_mux() (board/ti/am335x/mux.c)

And enabled clock for i2c2 on arch/arm/cpu/armv7/am33xx/clock_am33xx.c by adding line

               &cmper->i2c2clkctrl,


Thanks
Jussi

jus...@gmail.com

unread,
Jan 14, 2015, 1:43:12 PM1/14/15
to beagl...@googlegroups.com
I found the solution. My problem was simple: BBB internal pull-up resistors were disabled.
I added PULLUP_EN -flag to i2c pins and boom, the bus is up and running.

So my new pin muxing is:

static struct module_pin_mux i2c2_pin_mux[] = {

  {OFFSET(uart1_ctsn), (MODE(3) | RXACTIVE |

                     PULLUP_EN | PULLUDEN | SLEWCTRL)},/* I2C_DATA */

  {OFFSET(uart1_rtsn), (MODE(3) | RXACTIVE |

                       PULLUP_EN | PULLUDEN | SLEWCTRL)},/* I2C_SCLK */

  {-1},

};

Flags are defined in arch/arm/include/asm/arch-am33xx/mux_am33xx.h
#define PULLUP_EN       (0x1 << 4) /* Pull Up Selection */

Descriptions of values can be found here (page 747):

Hope this helps somebody :)
Jussi

Robert Kmiec

unread,
Jan 20, 2015, 11:05:16 AM1/20/15
to jus...@gmail.com, beagl...@googlegroups.com
I have misconfigured pins on my hardware. I was using i2c-2 on different balls.
Reply all
Reply to author
Forward
0 new messages