This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Incorrect pinmux modes reported by sysfs/debugfs?

I'm currently working with the DM8148EVM & EZSDK 5.03.01.15.  I've enabled the userspace GPIO access (/sys/class/gpio) and have been using the debugfs facilities (/sys/kernel/debug/omap_mux & /sys/kernel/debug/gpio) to double check pin muxing and GPIO states.

I'm a bit confused by the pinmux mode strings (OMAP_MUX_MODEn) reported in /sys/kernel/debug/omap_mux/.  For example, consider the touchscreen interrupt pin configured in in board-ti8148evm.c:

static void __init ti814x_tsc_init(void)
{
    int error;

    omap_mux_init_signal("mlb_clk.gpio0_31", TI814X_PULL_DIS | (1 << 18));

    error = gpio_request(GPIO_TSC, "ts_irq");
    if (error < 0) {
        printk(KERN_ERR "%s: failed to request GPIO for TSC IRQ"
            ": %d\n", __func__, error);
        return;
    }

    gpio_direction_input(GPIO_TSC);
    ti814x_i2c_boardinfo[6].irq = gpio_to_irq(GPIO_TSC);

    gpio_export(31, true);
}

So from this I see that the mlb_clk pin (mode 0) is being used as gpio0_31 (mode 7).  However, the debugfs entries seem to show conflicting information regarding the mux mode:

# cat /sys/kernel/debug/omap_mux/mlb_clk
name: mlb_clk.gpio0_31 (0x481408f0/0x8f0 = 0x50080), b NA, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
signals: mlb_clk | NA | NA | uart2_txd_mux1 | NA | NA | NA | gpio0_31

Is something wrong here, or does the validity of the name and mode strings depend upon how the pinmux setting is defined (i.e., by function call, kernel command line argument, or definition in  the omap_board_mux board_mux[] struct)? Are the mode strings just coming from compile-time definitions?

Thank you,

Jon

  • Hi Jon,

    If you look value at 0x481408F0 => 0x50080.

    Which is saying that

    1. pin is used on MODE7 (0x80)

    2. Pulled up/down disabled (0x10000)

    3. Receiver enabled (0x40000).

    So the functionality is achieved but the flags shown under "mode:" are wrong.

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Anil, thank you for clarifying!

  • Actually...looking back at Rev C of the datasheet (SPRS647C, Table 4-11, pg 161), I see that bits 18 and 19 are both marked as being Reserved -- you mentioned that 18 is a receiver enable bit?

    According to the datasheet, "[bit 18] must always be written as '1'"...but I've been working off of the PSP Userguide which doesn't seem to follow this in the gpio0_0 example.  Mind setting me straight on this?

    Thanks!

  • Hi Jon,

    Its depending upon you usage, example might not talk about that.

    In case of touch screen that pin is used as a interrupt signal so its configured as receiver enabled.

    Look at this definition in kernel source (arch/arm/mach-omap2/mux.h)

    #define TI814X_INPUT_EN                 (1 << 18)

    You can look at usage at multiple locations on (arch/arm/mach-omap2/devices.c) file.

    Regards

    AnilKumar

  • Hi Anil,

    I'm now trying to do some prototyping with I2C-dev (linux/Documentation/i2c/dev-interface), and seem to be having some additional problem with the pinmux settings for I2C3 on AH6 and AG6 (i.e., setting dcan0_tx=>i2c3_sda_mux1 and dcan0_rx=>i2c3_scl_mux1).

    Here are my bootargs from U-Boot, as obtained by cat'ing /proc/cmdline:

    console=ttyO0,115200n8 rootwait rw mem=364M mem=324@0x9F900000 vmalloc=500M earlyprintk notifyk.vpssm3_sva=0xBF900000 vram=50M root=/dev/nfs nfsroot=192.168.0.100:/nfs/dm8148-5_04_00_11 ip=dhcp omap_mux=dcan0_tx.i2c3_sda_mux1=0,dcan0_rx.i2c3_scl_mux1=0

    However, the mode settings I've specified do not appear to be taking effect. This is made evident by the fact that I can't "wiggle" the bits via /dev/i2c-4, and the incorrect pinmux register values reported by the following debugfs entries:

    root@dm814x-evm:~# cat /sys/kernel/debug/omap_mux/dcan0_tx
    name: dcan0_tx.dcan0_tx (0x4814090c/0x90c = 0x0001), b NA, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE1
    signals: dcan0_tx | uart2_txd_mux2 | NA | NA | NA | i2c3_sda_mux1 | NA | gpio1_0


    root@dm814x-evm:~# cat /sys/kernel/debug/omap_mux/dcan0_rx
    name: dcan0_rx.dcan0_rx (0x48140910/0x910 = 0x60001), b NA, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE1
    signals: dcan0_rx | uart2_rxd_mux2 | NA | NA | NA | i2c3_scl_mux1 | NA | gpio1_1

    Any advice? Thanks!

    - Jon

    Although it's exactly really relevant here, I've attached my modifications to board-ti814c.c (just to expose i2cdev and spidev interfaces for userspace prototyping).

    --- board-ti8148evm.c.bak	2012-05-17 13:37:32.132290224 -0400
    +++ board-ti8148evm.c	2012-06-14 11:04:30.838107539 -0400
    @@ -120,9 +120,11 @@
     	{
     		I2C_BOARD_INFO("pcf8575_1", 0x21),
     	},
    -
     };
     
    +/* Empty structure so we can expose I2C-Dev interface */
    +static struct i2c_board_info __initdata ti814x_i2c_boardinfo3[] = { };
    +
     #define VPS_VC_IO_EXP_RESET_DEV_MASK        (0x0Fu)
     #define VPS_VC_IO_EXP_SEL_VIN0_S1_MASK      (0x04u)
     #define VPS_VC_IO_EXP_THS7368_DISABLE_MASK  (0x10u)
    @@ -525,6 +527,8 @@
     				ARRAY_SIZE(ti814x_i2c_boardinfo));
     	omap_register_i2c_bus(3, 100, ti814x_i2c_boardinfo1,
     				ARRAY_SIZE(ti814x_i2c_boardinfo1));
    +    omap_register_i2c_bus(4, 100, ti814x_i2c_boardinfo3,
    +                ARRAY_SIZE(ti814x_i2c_boardinfo3));
     }
     
     static u8 ti8148_iis_serializer_direction[] = {
    @@ -669,6 +673,14 @@
     		.bus_num	= 1,
     		.chip_select	= 0,
     	},
    +
    +    {
    +        .modalias = "spidev",
    +        .mode     = SPI_MODE_0,
    +        .max_speed_hz = 48000000,
    +        .bus_num = 2,
    +        .chip_select = 0
    +    }
     };
     
     void __init ti8148_spi_init(void)
    

  • Forgot to add that I also tried adding omap_mux_init_signal() calls to board-ti8148evm.c instead of using the kernel command lines args:

     omap_mux_init_signal("dcan0_tx.i2c3_sda_mux1", 0);
     omap_mux_init_signal("dcan0_rx.i2c3_scl_mux1", 0);

    With this ---^, I had the same results -- bad register values shown by debugfs.

    As far as I can tell, I've got these pin strings right... From mux814x.c:

        _TI814X_MUXENTRY(DCAN0_TX, 0,
                "dcan0_tx", "uart2_txd_mux2", NULL, NULL, NULL,
                "i2c3_sda_mux1", NULL, "gpio1_0"),
        _TI814X_MUXENTRY(DCAN0_RX, 0,
                "dcan0_rx", "uart2_rxd_mux2", NULL, NULL, NULL,
                "i2c3_scl_mux1", NULL, "gpio1_1"),

    Has anyone had any success with I2C3 pins in their MUX1 configuration (on the DCAN0 pins, AH6 & AG6)?

  • Hi Jon,

    From your data I can say that same pins are configured for different purpose. Those settings are over writing your configurations.

    Look inside the kernel and see where it exactly modifying those pins

    One place I can see at "arch/arm/mach-omap2/devices.c"

     237         omap_mux_init_signal("dcan0_tx.dcan0_tx", 0);
     238         omap_mux_init_signal("dcan0_rx.dcan0_rx", TI814X_INPUT_EN |
     239                                                 TI814X_PULL_UP);

    Note: I hope you are not using the D_CAN0 at the same time.

    Regards

    AnilKumar

    PS: Its better to create a new thread than create a new post in Answered Thread. People might skip, if the post is answered.

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Anil,

    Thank you for the quick reply and detailed response -- I did indeed overlook the TI814X CAN initialization in devices.c.  I am not using the DCAN features at all, so no worries on that.

    Also, point taken regarding creating new threads -- I'll be sure to do that from now on.

    Again, your time and help are much appreciated - Thank you!

    - Jon

  • Anil said:  "So the functionality is achieved but the flags shown under "mode:" are wrong."

    Seems to me like the reason why debugfs reports bad results is this line from omap_mux_decode() in mux.c:

       sprintf(mode, "OMAP_MUX_MODE%d", val & 0x7);

    It needs to be something like:

       if (cpu_is_ti814x())
       {
          int tmp_masked_mode = ffs( (val & OMAP_MUX_MODE_MASK) ) - 1;
          if (tmp_masked_mode >= 0 && tmp_masked_mode <= 9)
          {
             sprintf(mode, "OMAP_MUX_MODE%d", tmp_masked_mode);
          }
          else
          {
             strcpy(mode, "OMAP_MUX_MODE?");
          }
       }
       else
          sprintf(mode, "OMAP_MUX_MODE%d", val & 0x7);

    Likewise, some of the /sys/kernel/omap_mux/* files will cause a crash because omap_mux_dbg_signal_show() has this line:

            mode = ffs(val) - 1;

    Because the ffs(val) might return a bit larger than OMAP_MUX_NR_MODESm->muxnames[mode] will be invalid.  That line needs to be:

            /* Consider only mode bits to avoid ffs(val) > OMAP_MUX_NR_MODES, causing a crash on m->muxnames[mode] below */
           mode = ffs( (val & OMAP_MUX_MODE_MASK) ) - 1;

    And the seq_printf needs to check for -1:

               m->muxnames[0], (unsigned)mode < OMAP_MUX_NR_MODES ? m->muxnames[mode] : none,