AnsweredAssumed Answered

P1010 GPIO_0 setup and use

Question asked by yensid on May 20, 2014
Latest reply on Jun 2, 2014 by yensid



I hope this is an easy question and there is an easy answer.  I'm trying to use gpio0 on the P1010 as an output on our board which is designed after the P1010RDB. I'm trying to control gpio0 from a kernel module, and verify control with a scope on a testpoint.  I have been unable to change the value of the ouput, it is always high on our board, and low on the RDB.  The hardware engineer verfied the pull up, and I have tried with the open drain register set for active low and open drain.  In addtion to the code below, I have also tried to directly write the registers in U-boot and the output value does not change in that case either.


Is there an additional register/steps needed to enable gpio0? It appears to be enabled in the multiplex registers by default.







#define GPIO_BASE_ADDR 0x0FFE0F000


  typedef volatile struct


  unsigned int GPIO_GPDIR;

  unsigned int GPIO_GPODR;

  unsigned int GPIO_GPDAT;

  unsigned int GPIO_GPIER;

  unsigned int GPIO_GPIMR;

  unsigned int GPIO_GPICR;

  } gpio_reg_t;


gpio_reg_t * pgpio_reg;


** Note code is taken from the driver init function **


  unsigned int temp;

  temp = 0;



  if (!request_mem_region(GPIO_BASE_ADDR, sizeof(gpio_reg_t), "GPIO Space"))


  printk(KERN_WARNING"%s: Init: Could not request memory region.\n", gDrvrName);

  return (CRIT_ERR);



  pgpio_reg = ioremap((unsigned long)GPIO_BASE_ADDR, sizeof(gpio_reg_t));


  if (!pgpio_reg)


  printk(KERN_WARNING"%s: Init: Could not remap memory.\n", gDrvrName);

  return (CRIT_ERR);



  temp = ioread32be(&pgpio_reg->GPIO_GPDIR);

  printk("GPIO_GPDIR = 0x%08X\n", temp);

  temp = temp | 0x80000000;

  iowrite32be(temp, &pgpio_reg->GPIO_GPDIR);

  temp = ioread32be(&pgpio_reg->GPIO_GPDIR);

  printk("GPIO_GPDIR RESULT = 0x%08X\n", temp);



  temp = ioread32be(&pgpio_reg->GPIO_GPODR);

  printk("GPIO_GPODR = 0x%08X\n", temp);

  temp = temp | 0x80000000;

  iowrite32be(temp, &pgpio_reg->GPIO_GPODR);

  temp = ioread32be(&pgpio_reg->GPIO_GPODR);

  printk("GPIO_GPODR RESULT = 0x%08X\n", temp);




  temp = ioread32be(&pgpio_reg->GPIO_GPIER);

  printk("GPIO_GPIER = 0x%08X\n", temp);



  /* GPIO GPIMR */

  temp = ioread32be(&pgpio_reg->GPIO_GPIMR);

  printk("GPIO_GPIMR = 0x%08X\n", temp);


  /* GPIO GPICR */ 

  temp = ioread32be(&pgpio_reg->GPIO_GPICR);

  printk("GPIO_GPICR = 0x%08X\n", temp);


  /* As a test toggle gpio0*/



  while (1)


    temp = 0x80000000;

    iowrite32be(temp, &pgpio_reg->GPIO_GPDAT);

    temp = ioread32(&pgpio_reg->GPIO_GPDAT);

    printk("HIGH GPIO_GPDAT 0x%08X\n", temp);




    temp = 0x00000000;

    iowrite32be(temp,  &pgpio_reg->GPIO_GPDAT);

    temp = ioread32( &pgpio_reg->GPIO_GPDAT);

    printk("LOW GPIO_GPDAT 0x%08X\n", temp);





program Output


GPIO_GPDIR = 0x08000000

GPIO_GPDIR RESULT = 0x88000000

GPIO_GPODR = 0x00000000

GPIO_GPODR RESULT = 0x80000000

GPIO_GPIER = 0x00000000

GPIO_GPIMR = 0x00000000

GPIO_GPICR = 0x00000000

HIGH GPIO_GPDAT 0x00000030

LOW GPIO_GPDAT 0x00000030

HIGH GPIO_GPDAT 0x00000030

LOW GPIO_GPDAT 0x00000030