OpenWrt Forum Archive

Topic: ixp4xx and gpioctl

The content of this topic has been archived on 5 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I using Kamikaze 8.09.1 on IXDPG425 board.

I compiled the package gpioctl_1.0-1_armeb.ipk and try to use it,
but actually NOT have /dev/gpio node created.
Why ?

root@OpenWrt:/# cat /proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 ttyS
  5 /dev/tty
  5 /dev/console                                                               
  5 /dev/ptmx                                                                   
10 misc                                                                       
89 i2c                                                                         
90 mtd                                                                         
108 ppp                                                                         
128 ptm                                                                         
136 pts                                                                         
254 rtc                                                                         
                                                                               
Block devices:                                                                 
259 blkext                                                                     
31 mtdblock                                                                   
root@OpenWrt:/#

Also, I try to use GPIO SYSFS interface:

root@OpenWrt:/# cd /sys/class/gpio/
root@OpenWrt:/sys/class/gpio# ls                                               
export     gpiochip0  unexport                                                 
root@OpenWrt:/sys/class/gpio# echo 12 > export                                 
root@OpenWrt:/sys/class/gpio# ls                                               
export     gpio12     gpiochip0  unexport                                       
root@OpenWrt:/sys/class/gpio# cd gpio12
root@OpenWrt:/sys/devices/virtual/gpio/gpio12# ls                               
direction  subsystem  uevent     value                                         
root@OpenWrt:/sys/devices/virtual/gpio/gpio12# echo out > direction             
root@OpenWrt:/sys/devices/virtual/gpio/gpio12# cat direction                   
out

Any attempt to read/write value causes a kernel oops.

root@OpenWrt:/sys/devices/virtual/gpio/gpio12# echo 1 > value                   
Unable to handle kernel paging request at virtual address aaaaaad6             
pgd = c787c000                                                                 
[aaaaaad6] *pgd=00000000                                                       
Internal error: Oops: f3 [#1]                                                   
Modules linked in: nf_nat_tftp nf_conntrack_tftp nf_nat_irc nf_conntrack_irc nf_
nat_ftp nf_conntrack_ftp ipt_MASQUERADE iptable_nat nf_nat xt_NOTRACK iptable_ra
w xt_state nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack ipt_REJECT xt_TCPMSS ip
t_LOG xt_multiport xt_mac xt_limit iptable_mangle iptable_filter ip_tables xt_tc
pudp x_tables ppp_async ppp_generic slhc crc_ccitt                             
CPU: 0    Not tainted  (2.6.28.10 #8)                                           
pc : [<c0107fb0>]    lr : [<c0028a04>]    psr: a0000013                         
sp : c7a9deb0  ip : aaaaaaaa  fp : c7a9dec4                                     
r10: c7aec7f8  r9 : c7a9df78  r8 : c021e818                                     
r7 : 00000002  r6 : 00000002  r5 : c7839000  r4 : c02181f4                     
r3 : c02347e0  r2 : 0000000c  r1 : 0000000c  r0 : 01921770                     
Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user               
Control: 000039ff  Table: 0787c000  DAC: 00000015                               
Process ash (pid: 1258, stack limit = 0xc7a9c268)                               
Stack: (0xc7a9deb0 to 0xc7a9e000)                                               
dea0:                                     c7a9df14 0000000c c7a9ded4 c7a9dec8   
dec0: c0028a04 c0107f94 c7a9deec c7a9ded8 c0106be0 c00289ac c40f0720 c0234870   
dee0: c7a9df14 c7a9def0 c0107bec c0106bb0 4009f814 00000001 c7addd88 00000002   
df00: c7aec7e0 c7adbc68 c7a9df24 c7a9df18 c01239cc c0107b60 c7a9df54 c7a9df28   
df20: c00bbeb4 c01239b4 00000007 c7a99dc0 00000002 4009f814 c7a9df78 c001ff64   
df40: c7a9c000 00000001 c7a9df74 c7a9df58 c007fbf8 c00bbd88 c7a99dc0 fffffff7   
df60: 00000000 00000000 c7a9dfa4 c7a9df78 c008004c c007fb50 00000000 00000000   
df80: c008b4a8 00000000 4009d320 00000002 00000002 00000004 00000000 c7a9dfa8   
dfa0: c001fde0 c0080014 4009d320 00000002 00000001 4009f814 00000002 4006ac64   
dfc0: 4009d320 00000002 00000002 00000004 00000002 00075284 00000001 00000000   
dfe0: 000735ec beda4728 4006a328 40053f10 20000010 00000001 8a882aaa 0a90220a   
Backtrace:                                                                     
Function entered at [<c0107f88>] from [<c0028a04>]                             
r4:0000000c                                                                   
Function entered at [<c00289a0>] from [<c0106be0>]                             
Function entered at [<c0106ba4>] from [<c0107bec>]                             
r4:c0234870                                                                   
Function entered at [<c0107b54>] from [<c01239cc>]                             
r7:c7adbc68 r6:c7aec7e0 r5:00000002 r4:c7addd88                               
Function entered at [<c01239a8>] from [<c00bbeb4>]                             
Function entered at [<c00bbd7c>] from [<c007fbf8>]                             
Function entered at [<c007fb44>] from [<c008004c>]                             
r7:00000000 r6:00000000 r5:fffffff7 r4:c7a99dc0                               
Function entered at [<c0080008>] from [<c001fde0>]                             
r7:00000004 r6:00000002 r5:00000002 r4:4009d320                               
Code: e0000394 e59f301c e1a02001 e790c003 (e59c102c)                           
---[ end trace 45b95cc01572dcb7 ]---                                           
                                                                               
Please press Enter to activate this console.

Any suggestion?

Solved!

I added the following change

Index: linux-2.6.28.10/arch/arm/mach-ixp4xx/coyote-setup.c
===================================================================
--- linux-2.6.28.10.orig/arch/arm/mach-ixp4xx/coyote-setup.c
+++ linux-2.6.28.10/arch/arm/mach-ixp4xx/coyote-setup.c
@@ -98,12 +98,29 @@ static struct platform_device ixdpg425_e
     }
 };
 
+static struct resource ixdpg425_gpio_resources[] = {
+    {
+        .name = "gpio",
+        .start  = IXDPG425_GPIO_MASK,
+        .end    = IXDPG425_GPIO_MASK,
+        .flags  = 0,
+    },
+};
+
+static struct platform_device ixdpg425_gpio = {
+    .name         = "GPIODEV",
+    .id         = -1,
+    .num_resources  = ARRAY_SIZE(ixdpg425_gpio_resources),
+    .resource       = ixdpg425_gpio_resources,
+};
+
 
 static struct platform_device *coyote_devices[] __initdata = {
     &coyote_flash,
     &coyote_uart,
     &ixdpg425_eth[0],
     &ixdpg425_eth[1],
+    &ixdpg425_gpio,
 };
 
 static void __init coyote_init(void)
Index: linux-2.6.28.10/arch/arm/mach-ixp4xx/include/mach/coyote.h
===================================================================
--- linux-2.6.28.10.orig/arch/arm/mach-ixp4xx/include/mach/coyote.h
+++ linux-2.6.28.10/arch/arm/mach-ixp4xx/include/mach/coyote.h
@@ -31,3 +31,16 @@
 #define    COYOTE_IDE_CTRL_PORT    0xFFFE10FC
 #define    COYOTE_IDE_ERROR_PORT    0xFFFE10E2
 
+/* gpio mask used by platform device */
+/* +---------------------------------------------------+
+ * | GPIO | Direction |            Function            |
+ * +------+-----------+--------------------------------+
+ * |   2  |    Out    |  SPI Clock                     |
+ * |   3  |    Out    |  SPI Data In (Data to Slic)    |
+ * |   4  |    In     |  SPI Data Out (Data from Slic) |
+ * |   5  |    Out    |  SPI Chip Select               |
+ * |  11  |    In     |  Slic Interrupt                |
+ * |  13  |    Out    |  Slic Reset                    |
+ * +---------------------------------------------------+
+ */
+#define IXDPG425_GPIO_MASK (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 11) | (1 << 13)

Access to the GPIOs has only purpose of slic debug.
Thanks to all

The discussion might have continued from here.