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.

Linux/PROCESSOR-SDK-AM437X: GPIO problem

Part Number: PROCESSOR-SDK-AM437X
Other Parts Discussed in Thread: AM4372

Tool/software: Linux

Hi sir:

could you do me a favor?

there is a problem that the gpio number, that the gpio works as what i wanted when using the gpio number in the directory "/sys/class/gpio/" , paired  address is not as i wanted when i go to find the address that corresponed to the gpio number in the file "pins" under the directory " /sys/kernel/debug/pinctrl/" in board linux system.

The follow is the code in the device tree.

uart3_pins: uart3_pins {
  pinctrl-single,pins = <
   AM4372_IOPAD(0xa28, PIN_INPUT | MUX_MODE0)  /* uart3_rxd.uart3_rxd */
   AM4372_IOPAD(0xa2c, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart3_txd.uart3_txd */
   AM4372_IOPAD(0xa30, PIN_INPUT_PULLUP | MUX_MODE0) /* uart3_ctsn.uart3_ctsn */
   AM4372_IOPAD(0xa34, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart3_rtsn.uart3_rtsn */
   AM4372_IOPAD(0x8c8, PIN_OUTPUT | MUX_MODE7)/* gpio2-16 */
   AM4372_IOPAD(0x8cc, PIN_OUTPUT | MUX_MODE7)/* gpio2-17 */
   AM4372_IOPAD(0x8e0, PIN_OUTPUT | MUX_MODE7) /* gpio2-22 */
   AM4372_IOPAD(0x8e4, PIN_OUTPUT | MUX_MODE7) /* gpio2-23 */
  >;
 };

-----------

&uart3 {
 status = "okay";
 pinctrl-names = "default";
 pinctrl-0 = <&uart3_pins>;
};

when  I configure  the gpio2_16,17,22,23  in the node uart3 ,the gpio80,that accumulated by the method that you offered (2x32+16 ), can works well as what i wanted .

But when i departed the four gpio configuration ,using the follow code in the device tree, the gpio80 can't work as wanted.

gpio_my_pins: gpio_mux_pins {
  pinctrl-single,pins = <

   AM4372_IOPAD(0x8c8, PIN_OUTPUT | MUX_MODE7)/* gpio2-16 */
   AM4372_IOPAD(0x8cc, PIN_OUTPUT | MUX_MODE7)/* gpio2-17 */
   AM4372_IOPAD(0x8e0, PIN_OUTPUT | MUX_MODE7) /* gpio2-22 */
   AM4372_IOPAD(0x8e4, PIN_OUTPUT | MUX_MODE7) /* gpio2-23 */
  >;
 };

&gpio2 {
 status = "okay";
 pinctrl-names = "default";
 pinctrl-0 = <&gpio_my_pins>;
};

And there is a problem very serious, when the gpio 80 works ,i find the pin's address in the file "/sys/kernel/debug/pinctrl/pins" is 0x44e10940 .But I think the right address should be 0x44e108c8.

So ,what cause it? the follow is the file named "pins" in the directory "/sys/kernel/debug/pinctrl/".

pin 47 (PIN47) 44e108bc 08050007 pinctrl-single

pin 48 (PIN48) 44e108c0 08050007 pinctrl-single

pin 49 (PIN49) 44e108c4 08050007 pinctrl-single

pin 50 (PIN50) 44e108c8 00010007 pinctrl-single

pin 51 (PIN51) 44e108cc 00010007 pinctrl-single

pin 52 (PIN52) 44e108d0 08050007 pinctrl-single

pin 53 (PIN53) 44e108d4 08050007 pinctrl-single

pin 54 (PIN54) 44e108d8 08050007 pinctrl-single

pin 55 (PIN55) 44e108dc 08050007 pinctrl-single

pin 56 (PIN56) 44e108e0 00010007 pinctrl-single

pin 57 (PIN57) 44e108e4 00010007 pinctrl-single

pin 58 (PIN58) 44e108e8 08040007 pinctrl-single

pin 59 (PIN59) 44e108ec 08050007 pinctrl-single

pin 60 (PIN60) 44e108f0 00050000 pinctrl-single

pin 61 (PIN61) 44e108f4 00050000 pinctrl-single

pin 62 (PIN62) 44e108f8 00050000 pinctrl-single

pin 63 (PIN63) 44e108fc 00050000 pinctrl-single

pin 64 (PIN64) 44e10900 00050000 pinctrl-single

pin 65 (PIN65) 44e10904 00050000 pinctrl-single

pin 66 (PIN66) 44e10908 00040007 pinctrl-single

pin 67 (PIN67) 44e1090c 00040007 pinctrl-single

pin 68 (PIN68) 44e10910 00040007 pinctrl-single

pin 69 (PIN69) 44e10914 00010002 pinctrl-single

pin 70 (PIN70) 44e10918 00050002 pinctrl-single

pin 71 (PIN71) 44e1091c 00010002 pinctrl-single

pin 72 (PIN72) 44e10920 00010002 pinctrl-single

pin 73 (PIN73) 44e10924 00010002 pinctrl-single

pin 74 (PIN74) 44e10928 00010002 pinctrl-single

pin 75 (PIN75) 44e1092c 00010002 pinctrl-single

pin 76 (PIN76) 44e10930 00050002 pinctrl-single

pin 77 (PIN77) 44e10934 00050002 pinctrl-single

pin 78 (PIN78) 44e10938 00050002 pinctrl-single

pin 79 (PIN79) 44e1093c 00050002 pinctrl-single

pin 80 (PIN80) 44e10940 00050002 pinctrl-single

pin 81 (PIN81) 44e10944 00040007 pinctrl-single

pin 82 (PIN82) 44e10948 00050000 pinctrl-single

pin 83 (PIN83) 44e1094c 00010000 pinctrl-single

pin 84 (PIN84) 44e10950 08060007 pinctrl-single

Your answer is very appreciated! 

Thanks!

  • Hello lihua,

    Please, move the &gpio_my_pins from &gpio2 to pinctrl-0 in &am43xx_pinmux as has done in this thread.

    Best regards,
    Kemal

  • Hello Kemal,

    I connect the gpio2 to the button and configure the pin as input,

    AM4372_IOPAD(0x8a8, PIN_INPUT | MUX_MODE7) /* dss_data2.gpio2_8 */

    Whether there is a register to read the level change with devmem2 command after I press this button?

    Thanks,

    Lihua

  • Yes, there is a register: 0x481ac13c

  • Hello Kemal,

    I read the register:0x481ac13c, but after I pressed the button, the read value did not change when I set gpio2_8 as input pin.

    In the AM437x Technical Reference Manual,when I set gpio2_8 as output pin, change the level, the reading value will change.

    GPIO_DATAOUT Register (offset = 13Ch) [reset = 0h]  The GPIO_DATAOUT register is used for setting the value of the GPIO output pins.

    GPIO_DATAIN Register (offset = 138h) [reset = 0h] The GPIO_DATAIN register is used to register the data that is read from the GPIO pins.

    The following message is the log:

    root@am437x-evm:/sys/class/gpio/gpio72# echo in > direction
    root@am437x-evm:/sys/class/gpio/gpio72# cat value
    0
    root@am437x-evm:/sys/class/gpio/gpio72# cat direction
    in
    root@am437x-evm:/sys/class/gpio/gpio72# devmem2 0x481ac13c      
    /dev/mem opened.
    Memory mapped at address 0xb6fa7000.
    Read at address  0x481AC13C (0xb6fa713c): 0x00420000
    root@am437x-evm:/sys/class/gpio/gpio72# devmem2 0x481ac13c
    /dev/mem opened.
    Memory mapped at address 0xb6fd9000.
    Read at address  0x481AC13C (0xb6fd913c): 0x00420000
    root@am437x-evm:/sys/class/gpio/gpio72#
    root@am437x-evm:/sys/class/gpio/gpio72# devmem2 0x481ac138
    /dev/mem opened.
    Memory mapped at address 0xb6f5a000.
    Read at address  0x481AC138 (0xb6f5a138): 0x00000600
    root@am437x-evm:/sys/class/gpio/gpio72# devmem2 0x481ac138
    /dev/mem opened.
    Memory mapped at address 0xb6f7e000.
    Read at address  0x481AC138 (0xb6f7e138): 0x00000600
    root@am437x-evm:/sys/class/gpio/gpio72#
    root@am437x-evm:/sys/class/gpio/gpio72# echo high > direction
    root@am437x-evm:/sys/class/gpio/gpio72# cat direction
    out
    root@am437x-evm:/sys/class/gpio/gpio72# cat value
    1
    root@am437x-evm:/sys/class/gpio/gpio72# devmem2 0x481ac13c   
    /dev/mem opened.
    Memory mapped at address 0xb6f2b000.
    Read at address  0x481AC13C (0xb6f2b13c): 0x00420100
    root@am437x-evm:/sys/class/gpio/gpio72# echo 0 > value    
    root@am437x-evm:/sys/class/gpio/gpio72# devmem2 0x481ac13c
    /dev/mem opened.
    Memory mapped at address 0xb6fa0000.
    Read at address  0x481AC13C (0xb6fa013c): 0x00420000

    When I set gpio2_8 as input pin,the value of 0x481ac138 register no change after I press the button.

    What is the reason for this?

    Do I use the GPIO_DATAOUT Register register when I press the button to read the level change?

    Thanks.

    Lihua

  • Hello Kemal,

    I can already read the level change when I press or release the button with the 0x481ac138(GPIO_DATAIN) register.

    However, when the value of the register is read, the bus error will often appear as follows.

    root@am437x-evm:~# devmem2 0x481ac138  
    /dev/mem opened.[  293.642911] Unhandled fault: external abort on non-linefetch (0x1018) at 0xb6ff7138
    [  293.651543] pgd = ee50c000
    [  293.654255] [b6ff7138] *pgd=bcc93831
    [  293.657963] ------------[ cut here ]------------
    [  293.662630] WARNING: CPU: 0 PID: 339 at drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x25c/0x36c
    [  293.671938] 44000000.ocp:L3 Custom Error: MASTER M2 (64-bit) TARGET L4_PER_0 (Read): Data Access in User mode during Functional access
    [  293.684005] Modules linked in:
    [  293.687084] CPU: 0 PID: 339 Comm: devmem2 Tainted: G        W       4.9.69-g9ce43c71ae #57
    [  293.695344] Hardware name: Generic AM43 (Flattened Device Tree)
    [  293.701258] Backtrace:
    [  293.703758] [<c010b7d0>] (dump_backtrace) from [<c010ba8c>] (show_stack+0x18/0x1c)
    [  293.711336]  r7:00000009 r6:00000000 r5:c09b9294 r4:ee4a5c58
    [  293.717021] [<c010ba74>] (show_stack) from [<c03c53f4>] (dump_stack+0x24/0x28)
    [  293.724260] [<c03c53d0>] (dump_stack) from [<c012d978>] (__warn+0xe8/0x100)
    [  293.731230] [<c012d890>] (__warn) from [<c012d9d0>] (warn_slowpath_fmt+0x40/0x48)
    [  293.738724]  r9:00000000 r8:ef11d290 r7:c09b936c r6:00000002 r5:c09b91c0 r4:c09b9264
    [  293.746480] [<c012d994>] (warn_slowpath_fmt) from [<c03f45a0>] (l3_interrupt_handler+0x25c/0x36c)
    [  293.755348]  r3:ef11d0c0 r2:c09b9264
    [  293.758924]  r4:80080003
    [  293.761485] [<c03f4344>] (l3_interrupt_handler) from [<c016b444>] (__handle_irq_event_percpu+0xb4/0x144)
    [  293.770970]  r10:c0c47ef0 r9:ef103400 r8:00000015 r7:ee4a5d7c r6:00000000 r5:ef103400
    [  293.778794]  r4:ef11d640
    [  293.781348] [<c016b390>] (__handle_irq_event_percpu) from [<c016b4f8>] (handle_irq_event_percpu+0x24/0x60)
    [  293.791007]  r10:bea67bb8 r9:ee4a4000 r8:ef008000 r7:ee4a5f40 r6:00000000 r5:ef103400
    [  293.798830]  r4:ef103400
    [  293.801381] [<c016b4d4>] (handle_irq_event_percpu) from [<c016b598>] (handle_irq_event+0x64/0x90)
    [  293.810249]  r5:c0c082c8 r4:ef103400
    [  293.813845] [<c016b534>] (handle_irq_event) from [<c016e85c>] (handle_fasteoi_irq+0xc0/0x200)
    [  293.822364]  r5:c0c082c8 r4:ef103400
    [  293.825957] [<c016e79c>] (handle_fasteoi_irq) from [<c016a640>] (generic_handle_irq+0x2c/0x3c)
    [  293.834569]  r7:ee4a5f40 r6:00000000 r5:00000015 r4:c0c1f550
    [  293.840240] [<c016a614>] (generic_handle_irq) from [<c016ace8>] (__handle_domain_irq+0x5c/0xb0)
    [  293.848944] [<c016ac8c>] (__handle_domain_irq) from [<c0101520>] (gic_handle_irq+0x40/0x6c)
    [  293.857302]  r9:ee4a4000 r8:fa241100 r7:fa240100 r6:ee4a5e30 r5:fa24010c r4:c0c02c14
    [  293.865052] [<c01014e0>] (gic_handle_irq) from [<c010c4cc>] (__irq_svc+0x6c/0xa8)
    [  293.872531] Exception stack(0xee4a5e30 to 0xee4a5e78)
    [  293.877589] 5e20:                                     00404100 00000100 c0c4a200 00000000
    [  293.885772] 5e40: 00000202 00000012 00000000 00000000 ef008000 ee4a4000 bea67bb8 ee4a5edc
    [  293.893952] 5e60: c0c4a240 ee4a5e80 c0131660 c0131128 600e0113 ffffffff
    [  293.900576]  r9:ee4a4000 r8:ef008000 r7:ee4a5e64 r6:ffffffff r5:600e0113 r4:c0131128
    [  293.908329] [<c0131090>] (__do_softirq) from [<c0131660>] (irq_exit+0x140/0x144)
    [  293.915733]  r10:bea67bb8 r9:ee4a4000 r8:ef008000 r7:00000000 r6:00000000 r5:00000012
    [  293.923555]  r4:c0c1f550
    [  293.926106] [<c0131520>] (irq_exit) from [<c016acec>] (__handle_domain_irq+0x60/0xb0)
    [  293.933944] [<c016ac8c>] (__handle_domain_irq) from [<c0101520>] (gic_handle_irq+0x40/0x6c)
    [  293.942302]  r9:ee4a4000 r8:fa241100 r7:fa240100 r6:ee4a5f40 r5:fa24010c r4:c0c02c14
    [  293.950049] [<c01014e0>] (gic_handle_irq) from [<c010c4cc>] (__irq_svc+0x6c/0xa8)
    [  293.957526] Exception stack(0xee4a5f40 to 0xee4a5f88)
    [  293.962591] 5f40: ee4a5fb0 00000001 00000000 600e0010 ee4a4000 00000000 ee4a5fb0 10c53c7d
    [  293.970774] 5f60: 00000000 ee4a4000 bea67bb8 ee4a5fac ee4a5fb0 ee4a5f90 c0107d20 c010b3b8
    [  293.978944] 5f80: 600e0113 ffffffff
    [  293.982447]  r9:ee4a4000 r8:00000000 r7:ee4a5f74 r6:ffffffff r5:600e0113 r4:c010b3b8
    [  293.990205] [<c010b368>] (do_work_pending) from [<c0107d20>] (slow_work_pending+0xc/0x20)
    [  293.998385]  r7:10c53c7d r6:ffffffff r5:600e0010 r4:00010744
    [  294.004040] ---[ end trace 372bd7641dd79d76 ]---

    Memory mapped at address 0xb6ff7000.
    Bus error (core dumped)
    root@am437x-evm:~#

     

     

    Now,I boot the target board from SD card,Will it be a problem with the file system in the SD card, or the device tree configuration?

    How should I solve this problem?

     

    Thanks,

    Lihua

     

  • You are trying to access address which is not memory mapped. Please, post me the output of this command: cat /sys/kernel/debug/gpio

  • Hi Kemal,

    The following message is the output with the command:

    root@am437x-evm:~# cat /sys/kernel/debug/gpio
    gpiochip0: GPIOs 0-31, parent: platform/44e07000.gpio, gpio:
    gpio-6 ( |cd ) in hi IRQ
    gpio-16 ( |sysfs ) out hi

    gpiochip1: GPIOs 32-63, parent: platform/4804c000.gpio, gpio:

    gpiochip2: GPIOs 64-95, parent: platform/481ac000.gpio, gpio:

    gpiochip3: GPIOs 96-127, parent: platform/48322000.gpio, gpio:
    gpio-100 ( |matrix_kbd_col ) out hi
    gpio-101 ( |matrix_kbd_row ) in lo IRQ
    gpio-102 ( |matrix_kbd_row ) in lo IRQ
    gpio-109 ( |matrix_kbd_col ) out hi

    Thanks,
    Lihua
  • Now echo 64 > /sys/class/gpio/export and accessing address 0x481ac138 will not cause non-linefetch.