AnsweredAssumed Answered

How do I read GPIO pins in linux on imx27?

Question asked by per dalen on Sep 17, 2008
Latest reply on Sep 19, 2008 by per dalen

I have added support for a touch-screen using an ADS7843. The interface to the SPI bus is ok with allot of ugly tweaks to spi and ads7846 code :smileysad:. Some code is stolen and some is made using allot of looking into an oscilloscope.
The driver kind of works now except I am not able to read the gpio-pin (MX27_PIN_PC_BVD2) I get the pen-down interrupt from. The interrupts comes every time I touch the screen but the function mxc_get_gpio_datain(MX27_PIN_PC_BVD2) always returns 0.
Is there any other way that I should read the gpio-pin? I haven't found any code for the imx27 that uses the mxc_get_gpio_datain, should I use some other gpio function?

Here is some of my code:

static int mx27_ads7846_pendown_state(void)
return !mxc_get_gpio_datain(MX27_PIN_PC_BVD2);

static struct ads7846_platform_data ads_info = {
.model   = 7843,
        .vref_delay_usecs = 100,
.x_max          = 0x0fff,
.y_max          = 0x0fff,
.x_plate_ohms  = 440,
.y_plate_ohms  = 250,
.get_pendown_state = mx27_ads7846_pendown_state,

static struct spi_board_info mxc_spi_board_info[] __initdata = {
  .modalias = "ads7846",
  .platform_data = &ads_info,
  .irq = IOMUX_TO_IRQ(MX27_PIN_PC_BVD2),
  .max_speed_hz = 500000,
  .bus_num = 1,
  .chip_select = 0,
  .mode = 0,


void gpio_spi_active(int cspi_mod)
switch (cspi_mod) {
case 0:
  /* SPI1 */
  gpio_request_mux(MX27_PIN_CSPI1_MOSI, GPIO_MUX_PRIMARY);
  gpio_request_mux(MX27_PIN_CSPI1_MISO, GPIO_MUX_PRIMARY);
  gpio_request_mux(MX27_PIN_CSPI1_SCLK, GPIO_MUX_PRIMARY);
  gpio_request_mux(MX27_PIN_CSPI1_RDY, GPIO_MUX_PRIMARY);
  gpio_request_mux(MX27_PIN_CSPI1_SS0, GPIO_MUX_PRIMARY);
  gpio_request_mux(MX27_PIN_CSPI1_SS1, GPIO_MUX_PRIMARY);
  gpio_request_mux(MX27_PIN_CSPI1_SS2, GPIO_MUX_PRIMARY);
  gpio_config_mux(MX27_PIN_PC_BVD2, GPIO_MUX_GPIO);
  mxc_set_gpio_direction(MX27_PIN_PC_BVD2, 1);

case 1: