I must be missing something really obvious getting the GIO driver to work. I am using the DM355 EVM and I'm just trying to toggle GIO54. Here's the code, the output is listed below, don't get bogged down on naming i started with GIO32 and changed to GIO54:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/fs.h>
#include <asm/arch/gio.h>
#define PINMUX0 __REG(0x01c40000)
#define DIR1 __REG(DAVINCI_GPIO_BASE + 0x38)//__REG(0x01c67038)
#define BINTEN __REG(0x01c67008)
#define OUT_DATA01 __REG(0x01c6703C)
#define SET_DATA01 __REG(0x01c67040)
#define CLR_DATA01 __REG(0x01c67044)
static int __init GIO32_init(void)
{
// GIO54 is to be tested
u32 gpio = 54;
printk(KERN_INFO "GIO%d: %d\n", gpio, __gpio_get(gpio) );
printk(KERN_INFO "GIO%d Address: 0x%08lX\n",gpio, DAVINCI_GPIO_BASE + 0x38 );
printk(KERN_INFO "PINMUX0 : 0x%08lX\n",PINMUX0);
printk(KERN_INFO "DIR1 : 0x%08lX\n",DIR1);
printk(KERN_INFO "OUT_DATA : 0x%08lX\n",OUT_DATA01);
printk(KERN_INFO "SET_DATA : 0x%08lX\n",SET_DATA01);
/* Configure GPIO as an OUTPUT */
gpio_set_direction(gpio, GIO_DIR_OUTPUT);
/* Disable interrupts */
gpio_interrupt_disable(gpio, TRIGGER_RISING_EDGE);
gpio_interrupt_disable(gpio, TRIGGER_FALLING_EDGE);
/*set pin to zero*/
if( gpio_clear(gpio) < 0 )
{ //failed to set the output
return -1;
}
printk(KERN_INFO "\nPINMUX0 : 0x%08lX\n",PINMUX0);
printk(KERN_INFO "DIR1 : 0x%08lX\n",DIR1);
printk(KERN_INFO "OUT_DATA : 0x%08lX\n",OUT_DATA01);
printk(KERN_INFO "SET_DATA : 0x%08lX\n",SET_DATA01);
printk(KERN_INFO "GIO%d: %d\n", gpio, __gpio_get(gpio) );
printk(KERN_INFO "GIO32 Module Loaded\n");
return 0;
}
static void __exit GIO32_exit(void)
{
// GIO54 is to be tested
u32 gpio = 54;
printk(KERN_INFO "GIO%d: %d\n", gpio, __gpio_get(gpio) );
printk(KERN_INFO "GIO32 Module exit\n");
}
/* init and exit functions */
module_init(GIO32_init);
module_exit(GIO32_exit);
MODULE_LICENSE("GPL");
I start by probing pin 1(GIO54) on header DC7 it reads 3.3V. I then load the module, the output is listed below.
Console Output:
root@10.10.40.32:/opt/dvsdk# insmod GPIO32.ko
GIO54: 0
GIO54 Address: 0x01C67038
PINMUX0 : 0x00007F55
DIR1 : 0xDEBFFFDE
OUT_DATA : 0x20400000
SET_DATA : 0x20400000
PINMUX0 : 0x00007F55
DIR0 : 0xDEBFFFDE
OUT_DATA : 0x20000000
SET_DATA : 0x20000000
GIO54: 0
GIO32 Module Loaded
root@10.10.40.32:/opt/dvsdk# rmmod GPIO32
GIO54: 0
GIO32 Module exit
I probe the pin again and it still reads 3.3V. What gives? I currently have no other loadable modules running on the board so there should be no interaction there. I did try using:
DIR1 &= 0xFFBFFFFF; //for setting to output
OUT_DATA01 &= 0xFFBFFFFF; //set the pin low
SET_DATA01&= 0xFFBFFFFF; //set the pin low
But the pin never budges from 3.3V. What I can gather, from the board schematics, there is nothing pulling that pin high. Please, what am I missing?
Thanks for any direction you can give, it will be most appreciated.