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/AM5728: Userspace access to GPIO

Part Number: AM5728

Tool/software: Linux

Hello,  I've been working on an AM5728-derived device, and I require several pins to be accessible to a program running on the SoC as GPIO pins.  I understand the sysfs system, but I'm curious as to how the GPIO pins can be persistently accessible in the /sys/class/gpio directory.  Is there a way to do it in the device tree?  This GPIO would be a basic 'is-it-set-or-is-it-not' setup, no special drivers required.

I've also been having trouble changing the USER buttons on the AM572x EVM to be just GPIO, rather than directional keys, with no success.  So far all I've really done is comment out the USER1 node, then try and export it in the sysfs.  However, when I use the device tree with the USER1 button commented out, the EVM fails to boot.  The error I'm receiving is that the kernel cannot find mmcblk0p2, which is the primary rootfs partition.  Why would the OS fail to boot when a single GPIO node is removed?

  • Hi Tom,

    It is possible to configure GPIOs in device tree instead of exporting in userspace in sysfs. You can find detailed description in the Kernel device tree documentation at:
    www.kernel.org/.../gpio.txt

    About the next issue with fails to boot should be helpful to attach a booting log in a text file.

    BR
    Tsvetolin Shulev
  • Thank you for your reply.  I've been over that documentation before, and unfortunately after checking out how it's implemented on the EVM, I'm left with a couple unresolved questions.  In the /sys/class/gpio directory, there is a 'gpio132' pin that is always exported.  From what I can tell, it's GPIO5_4 on the AM5728.  However, I cannot trace back to where this pin is muxed/initialized in the device tree.  According to the TRM, the pin should be mux mode 14 on the CTRL_CORE_PAD_MCASP1_AXR2 register, but that's never muxed.  This particular pin does not show up in a 'gpios' macro either.  I cannot glean any reason why this pin is initialized.

    Cvetolin Shulev-XID said:
    About the next issue with fails to boot should be helpful to attach a booting log in a text file.

    Here you go!

    =~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2018.01.17 11:30:02 =~=~=~=~=~=~=~=~=~=~=~=
    
    U-Boot SPL 2017.01-g590c7d7fe1 (Jan 05 2018 - 03:47:04)
    DRA752-GP ES2.0
    Trying to boot from MMC1
    reading uboot.env
    
    ** Unable to read "uboot.env" from mmc0:1 **
    Using default environment
    
    reading u-boot.img
    reading u-boot.img
    reading u-boot.img
    reading u-boot.img
    
    
    U-Boot 2017.01-g590c7d7fe1 (Jan 05 2018 - 03:47:04 -0500)
    
    CPU  : DRA752-GP ES2.0
    Model: TI AM572x EVM Rev A3
    Board: AM572x EVM REV A.3A
    DRAM:  2 GiB
    MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
    reading uboot.env
    
    ** Unable to read "uboot.env" from mmc0:1 **
    Using default environment
    
    SCSI:  SATA link 0 timeout.
    AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
    flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst 
    scanning bus for devices...
    Found 0 device(s).
    Net:   <ethaddr> not set. Validating first E-fuse MAC
    cpsw
    Hit any key to stop autoboot:  2  1  0 
    switch to partitions #0, OK
    mmc0 is current device
    SD/MMC found on device 0
    reading boot.scr
    ** Unable to read file boot.scr **
    reading uEnv.txt
    ** Unable to read file uEnv.txt **
    switch to partitions #0, OK
    mmc0 is current device
    SD/MMC found on device 0
    3739144 bytes read in 247 ms (14.4 MiB/s)
    102646 bytes read in 89 ms (1.1 MiB/s)
    ## Flattened Device Tree blob at 88000000
       Booting using the fdt blob at 0x88000000
       Loading Device Tree to 8ffe3000, end 8ffff0f5 ... OK
    
    Starting kernel ...
    
    [    0.000000] Booting Linux on physical CPU 0x0
    [    0.000000] Linux version 4.9.41-ge3a80a1c5c (vishal@ubuntu1-vm) (gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ) #2 SMP PREEMPT Thu Jan 4 18:04:48 EST 2018
    [    0.000000] CPU: ARMv7 Processor [412fc0f2] revision 2 (ARMv7), cr=30c5387d
    [    0.000000] CPU: div instructions available: patching division code
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
    [    0.000000] OF: fdt:Machine model: TI AM572x EVM Rev A3
    [    0.000000] efi: Getting EFI parameters from FDT:
    [    0.000000] efi: UEFI not found.
    [    0.000000] Reserved memory: created CMA memory pool at 0x0000000095800000, size 56 MiB
    [    0.000000] OF: reserved mem: initialized node ipu2_cma@95800000, compatible id shared-dma-pool
    [    0.000000] Reserved memory: created CMA memory pool at 0x0000000099000000, size 64 MiB
    [    0.000000] OF: reserved mem: initialized node dsp1_cma@99000000, compatible id shared-dma-pool
    [    0.000000] Reserved memory: created CMA memory pool at 0x000000009d000000, size 32 MiB
    [    0.000000] OF: reserved mem: initialized node ipu1_cma@9d000000, compatible id shared-dma-pool
    [    0.000000] Reserved memory: created CMA memory pool at 0x000000009f000000, size 8 MiB
    [    0.000000] OF: reserved mem: initialized node dsp2_cma@9f000000, compatible id shared-dma-pool
    [    0.000000] cma: Reserved 24 MiB at 0x00000000fe400000
    [    0.000000] Memory policy: Data cache writealloc
    [    0.000000] OMAP4: Map 0x00000000ffd00000 to fe600000 for dram barrier
    [    0.000000] DRA752 ES2.0
    [    0.000000] percpu: Embedded 13 pages/cpu @eed34000 s22156 r8192 d22900 u53248
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 472640
    [    0.000000] Kernel command line: console=ttyO2,115200n8 root=PARTUUID=060c6e1f-02 rw rootfstype=ext4 rootwait
    [    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
    [    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
    [    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
    [    0.000000] Memory: 1675672K/1897472K available (8192K kernel code, 315K rwdata, 2480K rodata, 2048K init, 304K bss, 33384K reserved, 188416K cma-reserved, 1283072K highmem)
    [    0.000000] Virtual kernel memory layout:
    [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    [    0.000000]     vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
    [    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
    [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
    [    0.000000]       .text : 0xc0008000 - 0xc0a00000   (10208 kB)
    [    0.000000]       .init : 0xc0e00000 - 0xc1000000   (2048 kB)
    [    0.000000]       .data : 0xc1000000 - 0xc104ed60   ( 316 kB)
    [    0.000000]        .bss : 0xc1050000 - 0xc109c0f0   ( 305 kB)
    [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
    [    0.000000] Preemptible hierarchical RCU implementation.
    [    0.000000] Build-time adjustment of leaf fanout to 32.
    [    0.000000] NR_IRQS:16 nr_irqs:16 16
    [    0.000000] OMAP clockevent source: timer1 at 32786 Hz
    [    0.000000] arm_arch_timer: Architected cp15 timer(s) running at 6.14MHz (phys).
    [    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x16af5adb9, max_idle_ns: 440795202250 ns
    [    0.000004] sched_clock: 56 bits at 6MHz, resolution 162ns, wraps every 4398046511023ns
    [    0.000016] Switching to timer-based delay loop, resolution 162ns
    [    0.000313] clocksource: 32k_counter: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 58327039986419 ns
    [    0.000321] OMAP clocksource: 32k_counter at 32768 Hz
    [    0.000731] Console: colour dummy device 80x30
    [    0.000748] WARNING: Your 'console=ttyO2' has been replaced by 'ttyS2'
    [    0.000755] This ensures that you still see kernel messages. Please
    [    0.000761] update your kernel commandline.
    [    0.000778] Calibrating delay loop (skipped), value calculated using timer frequency.. 12.29 BogoMIPS (lpj=61475)
    [    0.000791] pid_max: default: 32768 minimum: 301
    [    0.000894] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
    [    0.000904] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
    [    0.001513] CPU: Testing write buffer coherency: ok
    [    0.001721] /cpus/cpu@0 missing clock-frequency property
    [    0.001737] /cpus/cpu@1 missing clock-frequency property
    [    0.001748] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
    [    0.001765] Setting up static identity map for 0x80200000 - 0x80200060
    [    0.080071] EFI services will not be available.
    [    0.170258] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
    [    0.170346] Brought up 2 CPUs
    [    0.170359] SMP: Total of 2 processors activated (24.59 BogoMIPS).
    [    0.170366] CPU: All CPU(s) started in HYP mode.
    [    0.170372] CPU: Virtualization extensions available.
    [    0.170873] devtmpfs: initialized
    [    0.198284] VFP support v0.3: implementor 41 architecture 4 part 30 variant f rev 0
    [    0.198532] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
    [    0.198548] futex hash table entries: 512 (order: 3, 32768 bytes)
    [    0.201925] pinctrl core: initialized pinctrl subsystem
    [    0.202735] NET: Registered protocol family 16
    [    0.203597] DMA: preallocated 256 KiB pool for atomic coherent allocations
    [    0.204532] omap_hwmod: l3_main_2 using broken dt data from ocp
    [    0.314134] omap_hwmod: dcan1: _wait_target_disable failed
    [    0.450392] cpuidle: using governor ladder
    [    0.490431] cpuidle: using governor menu
    [    0.500214] OMAP GPIO hardware version 0.1
    [    0.514796] irq: no irq domain found for /ocp/l4@4a000000/scm@2000/pinmux@1400 !
    [    0.542209] No ATAGs?
    [    0.542234] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
    [    0.542243] hw-breakpoint: maximum watchpoint size is 8 bytes.
    [    0.542596] omap4_sram_init:Unable to allocate sram needed to handle errata I688
    [    0.542606] omap4_sram_init:Unable to get sram pool needed to handle errata I688
    [    0.543144] OMAP DMA hardware revision 0.0
    [    0.591826] omap-dma-engine 4a056000.dma-controller: OMAP DMA engine driver (LinkedList1/2/3 supported)
    [    0.593162] edma 43300000.edma: memcpy is disabled
    [    0.597987] edma 43300000.edma: TI EDMA DMA engine driver
    [    0.602500] omap-iommu 40d01000.mmu: 40d01000.mmu registered
    [    0.602673] omap-iommu 40d02000.mmu: 40d02000.mmu registered
    [    0.602824] omap-iommu 58882000.mmu: 58882000.mmu registered
    [    0.602975] omap-iommu 55082000.mmu: 55082000.mmu registered
    [    0.603256] omap-iommu 41501000.mmu: 41501000.mmu registered
    [    0.603435] omap-iommu 41502000.mmu: 41502000.mmu registered
    [    0.606073] palmas 0-0058: Irq flag is 0x00000008
    [    0.632929] palmas 0-0058: Muxing GPIO 2f, PWM 0, LED 0
    [    0.636750] vtt_fixed: supplied by smps3
    [    0.670988] random: fast init done
    [    0.712069] vdd_3v3: supplied by regen1
    [    0.712295] aic_dvdd_fixed: supplied by vdd_3v3
    [    0.715444] omap_i2c 48070000.i2c: bus 0 rev0.12 at 400 kHz
    [    0.715956] omap_i2c 48060000.i2c: bus 2 rev0.12 at 400 kHz
    [    0.716532] omap_i2c 4807c000.i2c: bus 4 rev0.12 at 400 kHz
    [    0.716728] media: Linux media interface: v0.10
    [    0.716774] Linux video capture interface: v2.00
    [    0.716810] pps_core: LinuxPPS API ver. 1 registered
    [    0.716817] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
    [    0.716842] PTP clock support registered
    [    0.716874] EDAC MC: Ver: 3.0.0
    [    0.717575] omap-mailbox 4883c000.mailbox: omap mailbox rev 0x400
    [    0.717859] omap-mailbox 4883e000.mailbox: omap mailbox rev 0x400
    [    0.718150] omap-mailbox 48840000.mailbox: omap mailbox rev 0x400
    [    0.718430] omap-mailbox 48842000.mailbox: omap mailbox rev 0x400
    [    0.718788] Advanced Linux Sound Architecture Driver Initialized.
    [    0.719600] clocksource: Switched to clocksource arch_sys_counter
    [    0.730324] NET: Registered protocol family 2
    [    0.730813] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
    [    0.730875] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
    [    0.731001] TCP: Hash tables configured (established 8192 bind 8192)
    [    0.731046] UDP hash table entries: 512 (order: 2, 16384 bytes)
    [    0.731078] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
    [    0.731273] NET: Registered protocol family 1
    [    0.731581] RPC: Registered named UNIX socket transport module.
    [    0.731591] RPC: Registered udp transport module.
    [    0.731598] RPC: Registered tcp transport module.
    [    0.731605] RPC: Registered tcp NFSv4.1 backchannel transport module.
    [    0.732542] hw perfevents: enabled with armv7_cortex_a15 PMU driver, 7 counters available
    [    0.735504] workingset: timestamp_bits=14 max_order=19 bucket_order=5
    [    0.743106] squashfs: version 4.0 (2009/01/31) Phillip Lougher
    [    0.743801] NFS: Registering the id_resolver key type
    [    0.743821] Key type id_resolver registered
    [    0.743829] Key type id_legacy registered
    [    0.743868] ntfs: driver 2.1.32 [Flags: R/O].
    [    0.745033] bounce: pool size: 64 pages
    [    0.745180] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)
    [    0.745190] io scheduler noop registered
    [    0.745198] io scheduler deadline registered
    [    0.745330] io scheduler cfq registered (default)
    [    0.749809] pinctrl-single 4a003400.pinmux: please update dts to use #pinctrl-cells = <1>
    [    0.750324] pinctrl-single 4a003400.pinmux: 282 pins at pa fc003400 size 1128
    [    0.753535] dra7-pcie 51000000.pcie_rc: Linked as a consumer to phy-4a094000.pciephy.3
    [    0.753845] OF: PCI: host bridge /ocp/axi@0/pcie_rc@51000000 ranges:
    [    0.753856] OF: PCI:   No bus range found for /ocp/axi@0/pcie_rc@51000000, using [bus 00-ff]
    [    0.753888] OF: PCI:    IO 0x20003000..0x20012fff -> 0x00000000
    [    0.753909] OF: PCI:   MEM 0x20013000..0x2fffffff -> 0x20013000
    [    1.755329] dra7-pcie 51000000.pcie_rc: phy link never came up
    [    1.755502] dra7-pcie 51000000.pcie_rc: PCI host bridge to bus 0000:00
    [    1.755515] pci_bus 0000:00: root bus resource [bus 00-ff]
    [    1.755526] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
    [    1.755538] pci_bus 0000:00: root bus resource [mem 0x20013000-0x2fffffff]
    [    1.755917] PCI: bus0: Fast back to back transfers disabled
    [    1.756033] PCI: bus1: Fast back to back transfers enabled
    [    1.756149] pci 0000:00:00.0: BAR 0: assigned [mem 0x20100000-0x201fffff]
    [    1.756165] pci 0000:00:00.0: BAR 1: assigned [mem 0x20020000-0x2002ffff]
    [    1.756179] pci 0000:00:00.0: PCI bridge to [bus 01]
    [    1.756409] pcieport 0000:00:00.0: Signaling PME through PCIe PME interrupt
    [    1.757486] backlight supply power not found, using dummy regulator
    [    1.759994] pbias_mmc_omap5: Bringing 3300000uV into 3000000-3000000uV
    [    1.760009] pbias_mmc_omap5: failed to apply 3000000-3000000uV constraint(-22)
    [    1.760021] pbias-regulator 4a002e00.pbias_regulator: Failed to register regulator: -22
    [    1.760040] pbias-regulator: probe of 4a002e00.pbias_regulator failed with error -22
    [    1.819444] Serial: 8250/16550 driver, 10 ports, IRQ sharing disabled
    [    1.822843] 48020000.serial: ttyS2 at MMIO 0x48020000 (irq = 301, base_baud = 3000000) is a 8250
    [    2.832247] console [ttyS2] enabled
    [    2.836609] 48422000.serial: ttyS7 at MMIO 0x48422000 (irq = 302, base_baud = 3000000) is a 8250
    [    2.847389] omap_rng 48090000.rng: OMAP Random Number Generator ver. 20
    [    2.854168] [drm] Initialized
    [    2.859017] OMAP DSS rev 6.1
    [    2.862394] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dispc_component_ops)
    [    2.870831] omapdss_dss 58000000.dss: bound 58040000.encoder (ops hdmi5_component_ops)
    [    2.880959] display supply vcc not found, using dummy regulator
    [    2.917701] brd: module loaded
    [    2.925993] loop: module loaded
    [    2.932370] libphy: Fixed MDIO Bus: probed
    [    2.989625] davinci_mdio 48485000.mdio: davinci mdio revision 1.6
    [    2.995748] davinci_mdio 48485000.mdio: detected phy mask fffffff9
    [    3.005940] libphy: 48485000.mdio: probed
    [    3.010011] davinci_mdio 48485000.mdio: phy[1]: device 48485000.mdio:01, driver Micrel KSZ9031 Gigabit PHY
    [    3.019722] davinci_mdio 48485000.mdio: phy[2]: device 48485000.mdio:02, driver Micrel KSZ9031 Gigabit PHY
    [    3.030098] cpsw 48484000.ethernet: Detected MACID = 5c:f8:21:34:80:f6
    [    3.036744] cpsw 48484000.ethernet: cpts: overflow check period 500 (jiffies)
    [    3.045060] cpsw 48484000.ethernet: cpsw: Detected MACID = 5c:f8:21:34:80:f7
    [    3.053481] mousedev: PS/2 mouse device common for all mice
    [    3.059366] i2c /dev entries driver
    [    3.065761] gpio-fan gpio_fan: GPIO fan initialized
    [    3.072055] tmp102 0-0048: initialized
    [    3.078110] cpu cpu0: "ti,syscon-efuse" is missing, cannot use OPPv2 table.
    [    3.086436] omap_hsmmc 4809c000.mmc: Got CD GPIO
    [    3.091771] omap_hsmmc 4809c000.mmc: SD card detect fail? enable CONFIG_REGULATOR_PBIAS
    [    3.100570] omap_hsmmc 480b4000.mmc: no pinctrl state for sdr25 mode
    [    3.106956] omap_hsmmc 480b4000.mmc: no pinctrl state for sdr12 mode
    [    3.234436] ledtrig-cpu: registered to indicate activity on CPUs
    [    3.240576] mmc0: new DDR MMC card at address 0001
    [    3.245855] mmcblk0: mmc0:0001 S10004 3.56 GiB 
    [    3.251032] mmcblk0boot0: mmc0:0001 S10004 partition 1 4.00 MiB
    [    3.260517] NET: Registered protocol family 10
    [    3.265487] mmcblk0boot1: mmc0:0001 S10004 partition 2 4.00 MiB
    [    3.272197] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
    [    3.278670] NET: Registered protocol family 17
    [    3.283533] Key type dns_resolver registered
    [    3.287898]  mmcblk0: p1 p2 p3
    [    3.292708] omap_voltage_late_init: Voltage driver support not added
    [    3.299192] Power Management for TI OMAP4+ devices.
    [    3.304335] Registering SWP/SWPB emulation handler
    [    3.321928] dmm 4e000000.dmm: initialized all PAT entries
    [    3.350917] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
    [    3.357563] [drm] No driver support for vblank timestamp query.
    [    3.366093] [drm] Enabling DMM ywrap scrolling
    [    3.439243] Console: switching to colour frame buffer device 100x30
    [    3.448256] omapdrm omapdrm.0: fb0: omapdrm frame buffer device
    [    3.491489] omap_hsmmc 4809c000.mmc: Got CD GPIO
    [    3.496851] omap_hsmmc 4809c000.mmc: SD card detect fail? enable CONFIG_REGULATOR_PBIAS
    [    3.506333] input: gpio_keys as /devices/platform/gpio_keys/input/input0
    [    3.513341] hctosys: unable to open rtc device (rtc0)
    [    3.519033] aic_dvdd_fixed: disabling
    [    3.523406] omap_hsmmc 4809c000.mmc: Got CD GPIO
    [    3.528533] vmmcwl_fixed: disabling
    [    3.532120] omap_hsmmc 4809c000.mmc: SD card detect fail? enable CONFIG_REGULATOR_PBIAS
    [    3.540616] ldousb: disabling
    [    3.543863] ALSA device list:
    [    3.546843]   No soundcards found.
    [    3.551018] Waiting for root device PARTUUID=060c6e1f-02...