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.

AM3517-EVM Application board J29 -- map a line to GPIO and an IRQ

Other Parts Discussed in Thread: TCA6416, AM3517, TSC2004, TXS0108E

Hello,

I am testing other touch sensors on the AM3517-EVM under embedded Linux (NOT using Android). I have a connection to I2C bus 3 on the J29 solder pads, and that is working with the driver for the touch screen.

The touch screen has an IRQ line that is active low.  I have been trying to map one of signals on J29 to the GPIO function and map that GPIO to an IRQ.  The line in question stays low, the  IRQ line from touch screen is correct (high until IRQ) so problem is in EVM side.  With no "open" lines, I'm not sure if the software to control this is working or if it is a hardware problem.  I have tried both pin 62 and 61.  Pin 62 is uP_McBSP3_CLKX and 61 is uP_McBSP4_CLKX.

Here are some clips from the code:

#ifdef CONFIG_ATMEL_MAXTOUCH    
/*
 * maXTouch Support
 */
#define GPIO_MAXTOUCH_IRQ   152 /* Pin 61 on J29 Application Board */

/* Prototype the callback functions */
static int My_maXTouch_init_irq(void);
static void My_maXTouch_exit_irq(void);
static u8 maXTouch_irq_level(void);

static struct mxt_platform_data maXTouch_platform_data = {
    .numtouch = 1,
    .max_x    = 2048,
    .max_y    = 2048,
    .init_platform_hw = &My_maXTouch_init_irq,
    .exit_platform_hw = &My_maXTouch_exit_irq,
    .valid_interrupt = &maXTouch_irq_level,
    .read_chg        = &maXTouch_irq_level,
};

static struct i2c_board_info __initdata maXTouch_tsc_i2c_boardinfo[] = {
    {
        I2C_BOARD_INFO("maXTouch", 0x4B),
        .type        = "maxTouch",
        .platform_data = &maXTouch_platform_data,
    },
};
    
#endif

static struct i2c_board_info __initdata am3517evm_i2c3_boardinfo[] = {
    {
        I2C_BOARD_INFO("tca6416-keys", 0x20),
        .platform_data = &am3517evm_tca6416_keys_info,
    },
    {
        I2C_BOARD_INFO("tca6416", 0x21),
        .platform_data = &am3517evm_ui_gpio_expander_info_2,
    },
#ifdef CONFIG_ATMEL_MAXTOUCH    
    {
        I2C_BOARD_INFO("maXTouch", 0x4B),
        .platform_data = &maXTouch_platform_data,
    },
#endif    
};

static int __init am3517_evm_i2c_init(void)
{
    omap_register_i2c_bus(1, 400, NULL, 0);
    omap_register_i2c_bus(2, 400, am3517evm_i2c2_boardinfo,
            ARRAY_SIZE(am3517evm_i2c2_boardinfo));
#ifdef CONFIG_ATMEL_MAXTOUCH    
    omap_register_i2c_bus(3, 400, am3517evm_i2c3_boardinfo,
            ARRAY_SIZE(am3517evm_i2c3_boardinfo));
#endif
    return 0;
}

#ifdef CONFIG_ATMEL_MAXTOUCH    

static int My_maXTouch_init_irq(void)
{
    int ret = 0;

    omap_mux_init_gpio(GPIO_MAXTOUCH_IRQ, OMAP_PIN_INPUT_PULLUP);
    ret = gpio_request(GPIO_MAXTOUCH_IRQ, "maXTouch-irq");
    if (ret < 0) {
        printk(KERN_WARNING "failed to request GPIO#%d: %d\n",
                GPIO_MAXTOUCH_IRQ, ret);
        return 0;
    }

    if (gpio_direction_input(GPIO_MAXTOUCH_IRQ)) {
        printk(KERN_WARNING "GPIO#%d cannot be configured as "
                "input\n", GPIO_MAXTOUCH_IRQ);
        return 0;
    }

    gpio_set_debounce(GPIO_MAXTOUCH_IRQ, 0xa);
    return gpio_to_irq(GPIO_MAXTOUCH_IRQ);
}

static void My_maXTouch_exit_irq(void)
{
    gpio_free(GPIO_MAXTOUCH_IRQ);
}

static u8 maXTouch_irq_level(void)
{
    return gpio_get_value(GPIO_MAXTOUCH_IRQ) ? 0 : 1;
}

#endif

From inside am3517_evm_init(void)

#ifdef CONFIG_ATMEL_MAXTOUCH    
    omap_mux_init_gpio(GPIO_MAXTOUCH_IRQ, OMAP_PIN_INPUT_PULLUP);
    maXTouch_tsc_i2c_boardinfo[0].irq = gpio_to_irq(GPIO_MAXTOUCH_IRQ);
    i2c_register_board_info(1, maXTouch_tsc_i2c_boardinfo,
                ARRAY_SIZE(maXTouch_tsc_i2c_boardinfo));

#endif 


  • Couple of questions,

     - Have you verified pin-mux configuration?

     - You can set the mux setting in board file, search for "board_mux" and add entry for your gpio pin.

     - You can also use devmem tool to read/write the register directly. just google for devmem tool and you will get the application.

    I am sure that you are already aware that, we are doing similar thing for TSC2004 on EVM.

    Thanks,

    Vaibhav

  • Do you mean here:

    #ifdef CONFIG_OMAP_MUX
    static struct omap_board_mux board_mux[] __initdata = {
        /* USB OTG DRVVBUS offset = 0x212 */
        OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
        OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
        OMAP3_MUX(GPMC_NCS4, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLDOWN),
        OMAP3_MUX(SYS_NRESWARM, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
        { .reg_offset = OMAP_MUX_TERMINATOR },
    };
    #endif

    ?

    Then I guess no.  I'll add that.  I'm still trying to run down if the external hardware will let the line pull high for the active low IRQ input.

    Corrected code should be:

    #ifdef CONFIG_OMAP_MUX
    static struct omap_board_mux board_mux[] __initdata = {
        /* USB OTG DRVVBUS offset = 0x212 */
        OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
        OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
        OMAP3_MUX(GPMC_NCS4, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLDOWN),
        OMAP3_MUX(SYS_NRESWARM, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),

        OMAP3_MUX(MCBSP3_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
        { .reg_offset = OMAP_MUX_TERMINATOR },
    };
    #endif

    Seems to compile, I'll have to test it 2/28.

    Got the touchpad driver working, just have to get this IRQ fixed.

    Thanks,

    Bill

  • OK,

    I tried both MCBSP3_CLKX and MCBSP4_CLKX which are J29 pins 62 and 61. 

    In either case, I can only get pull-up to about 300mV after the change to pin mux.  Before, they stayed at zero.  Those lines run to be "B" side of the U35 TXS0108E level translator chip.  The OE pin is low, so they should be in High Z state

    I can't get the line to go high.  The pins are U35 pin 16 and pin 18.

    Does anyone know if there is a better signal to use on that 100 pin J29 solder pad area?

    Thanks,

    Bill

  • Got it.  Thanks Mark Utter!

    AM3517 SOM, page 10 of schematic.  MMC1_D7 needs to be high to turn off buffer.

    Code updates:

    #define GPIO_MAXTOUCH_IRQ   152
    #define GPIO_MMC1_DAT7      129

    static int My_maXTouch_init_irq(void)
    {
        int ret = 0;

        omap_mux_init_gpio(GPIO_MAXTOUCH_IRQ, OMAP_PIN_INPUT_PULLUP);
        omap_mux_init_gpio(GPIO_MMC1_DAT7,    OMAP_PIN_OUTPUT);
        
        ret = gpio_request(GPIO_MAXTOUCH_IRQ, "maXTouch-irq");
        if (ret < 0) {
            printk(KERN_WARNING "failed to request GPIO#%d: %d\n",
                    GPIO_MAXTOUCH_IRQ, ret);
            return 0;
        }

        if (gpio_direction_input(GPIO_MAXTOUCH_IRQ)) {
            printk(KERN_WARNING "GPIO#%d cannot be configured as "
                    "input\n", GPIO_MAXTOUCH_IRQ);
            return 0;
        }

        ret = gpio_request(GPIO_MMC1_DAT7, "maXTouch-data");
        if (ret < 0) {
            printk(KERN_WARNING "failed to request GPIO#%d: %d\n",
                    GPIO_MAXTOUCH_IRQ, ret);
            return 0;
        }

        if (gpio_direction_output(GPIO_MMC1_DAT7, 1)) {
            printk(KERN_WARNING "GPIO#%d cannot be configured as "
                    "output\n", GPIO_MMC1_DAT7);
            return 0;
        }
        
        gpio_set_debounce(GPIO_MAXTOUCH_IRQ, 0xa);
        return gpio_to_irq(GPIO_MAXTOUCH_IRQ);
    }

    #ifdef CONFIG_OMAP_MUX
    static struct omap_board_mux board_mux[] __initdata = {
        /* USB OTG DRVVBUS offset = 0x212 */
        OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
    #ifdef CONFIG_TOUCHSCREEN_TSC2004
        OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
    #endif    
        OMAP3_MUX(GPMC_NCS4, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLDOWN),
        OMAP3_MUX(SYS_NRESWARM, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
    #ifdef CONFIG_ATMEL_MAXTOUCH    
        OMAP3_MUX(MCBSP4_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP),
        OMAP3_MUX(SDMMC1_DAT7,   OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
    #endif    
        { .reg_offset = OMAP_MUX_TERMINATOR },
    };

    Also added:

    static u8 maXTouch_read_chg(void)
    {
        return gpio_get_value(GPIO_MAXTOUCH_IRQ) ? 1 : 0;
    }

    And changed device info:

    static struct mxt_platform_data maXTouch_platform_data = {
        .numtouch = 1,
        .max_x    = 2048,
        .max_y    = 2048,
        .init_platform_hw = &My_maXTouch_init_irq,
        .exit_platform_hw = &My_maXTouch_exit_irq,
        .valid_interrupt = &maXTouch_irq_level,
        .read_chg        = &maXTouch_read_chg,
    };

    This got it working.

    I'll need to filter some events from the maXTouch driver.  It reports too many sync events.

    Also, in the driver, the key event needed to be posted.  It was being reported as _abs and not _key:

        if (last_touch) {
            /*
             * For compatibility with single-touch systems, send also
             * ABS_X & ABS_Y & BTN_TOUCH events.
             */
            if (stored_size[0]) {
                input_report_key(mxt->input, BTN_TOUCH, 1);
                input_report_abs(mxt->input, ABS_X, stored_x[0]);
                input_report_abs(mxt->input, ABS_Y, stored_y[0]);
            } else {
                input_report_key(mxt->input, BTN_TOUCH, 0);
            }

    --Bill





  • Go figure, but the S11 switch 4 line has to be "ON" for the McBSP4_CLKX line to go high.  This seems contrary to what the print shows, but with S11-4 off, the line stays at about 570mV.  Flip the switch and it goes to 3.3V and the IRQ works.