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/OMAP-L138: How can I the pin GP0[9] to "gpio-keys"?

Part Number: OMAP-L138
Other Parts Discussed in Thread: OMAPL138,

Tool/software: Linux

Hi,

SDK: PROCESSOR-SDK-LINUX-OMAPL138 05_00_00_15 

I want to set the GP0[9] to "gpio-keys", and I have add the code in the da850-lcdk.dts like this:

		//20180907
		user3 {
			label = "GPIO Key USER2";
			linux,code = <BTN_2>;
			gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
		};

But the Linux can't work well, Just stop during the startup process.

and I have read the topic about the GPIO: http://processors.wiki.ti.com/index.php/DaVinci_PSP_03.01_Linux_Installation_User_Guide

GPIO

GPIO driver has been rewritten to use the GPIO core infrastructure from the kernel. However there are no major changes to the APIs (back-end communication with the interrupts are handled with GPIO core).

    Need to call gpio_request() to start using a GPIO (this was not required earlier, we could directly call gpio_direction_xxx and gpio_write APIs)
    Provision to pass falling edge or rising edge information with the request_irq API. The IORESOURCE_IRQ_LOWEDGE and/or IORESOURCE_IRQ_HIGHEDGE can be passed for the "flags" argument.

Current driver (for DM355 only) has a limitation of using GPIO 0-9 direct/unbanked interrupts together with the banked interrupts. The default behavior of the driver is use banked interrupts for all GPIOs (including GPIO 0-9). In this case all GPIO interrupts work, provided they are available through pinmux. The DM355 SoC file - arch/arm/mach-davinci/dm355.c file can be configured to enable direct/unbanked interrupts for GPIO 0-9. However, with this change GPIO 10 - 103 in interrupt mode (through banked interrupts) would not work.

@@ -865,11 +865,12 @@ static struct davinci_soc_info davinci_soc_info_dm355 = {

        .intc_irq_prios         = dm355_default_priorities,
        .intc_irq_num           = DAVINCI_N_AINTC_IRQ,
        .timer_info             = &dm355_timer_info,
        .gpio_base              = IO_ADDRESS(DAVINCI_GPIO_BASE),
        .gpio_num               = 104,
-       .gpio_irq               = IRQ_DM355_GPIOBNK0,
+       .gpio_irq               = IRQ_DM355_GPIO0,
+       .gpio_unbanked          = 10,
        .serial_dev             = &dm355_serial_device,
        .sram_dma               = 0x00010000,
        .sram_len               = SZ_32K,
 };

I also change the da850.dtsi:

		gpio: gpio@226000 {
			compatible = "ti,dm6441-gpio";
			gpio-controller;
			#gpio-cells = <2>;
			reg = <0x226000 0x1000>;
			interrupts = <42 IRQ_TYPE_EDGE_BOTH
				43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
				45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
				47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
				49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
			ti,ngpio = <144>;
			ti,davinci-gpio-unbanked = <0>; //20180907
			status = "disabled";
		};

to

ti,davinci-gpio-unbanked = <8>; //20180907

But the Linux doesn't work as I want, I can not see the GPIO0_9 when I use the tool "lsgpio".

so I want someone help me to set the gpio0_9 as the "gpio-keys".

  • Hi,

    Make sure that there is no conflict with pmx_core: pinmux@14120 in da850.dtsi, that is gpio0_9 pad is not pinmuxed as something else.

    Best Regards,
    Yordan
  • Yes, the code is command in the da850.dtsi

    			//20180907
    			//serial2_rtscts_pins: pinmux_serial2_rtscts_pins {
    			//	pinctrl-single,bits = <
    			//		/* UART2_CTS UART2_RTS */
    			//		0x00 0x44000000 0xff000000
    			//	>;
    			//};
    			//

    and I also command in da850.c

    /*
     * Device specific mux setup
     *
     *		soc	description	mux	mode	mode	mux	dbg
     *					reg	offset	mask	mode
     */
    static const struct mux_config da850_pins[] = {
    #ifdef CONFIG_DAVINCI_MUX
    	...
    	/* McASP function */
    	MUX_CFG(DA850,	ACLKR,		0,	0,	15,	1,	false)
    	MUX_CFG(DA850,	ACLKX,		0,	4,	15,	1,	false)
    	MUX_CFG(DA850,	AFSR,		0,	8,	15,	1,	false)
    	MUX_CFG(DA850,	AFSX,		0,	12,	15,	1,	false)
    	MUX_CFG(DA850,	AHCLKR,		0,	16,	15,	1,	false)
    	MUX_CFG(DA850,	AHCLKX,		0,	20,	15,	1,	false)
    	MUX_CFG(DA850,	AMUTE,		0,	24,	15,	8,	false) //20180907
    ...

    If this is pinmux problem, I will see how to debug the kernel.

    Thanks.

  • I think the pin GP0[9] is used by some program, but I can't find.

     The system stops at a starting service, when I set the GP0[9] to "gpio-keys".

    [  OK  ] Started Login Service.                                                                                                                               
    nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xcc                                                                                                      
    nand: Micron MT29F4G16ABADAH4                                                                                                                                 
    nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64                                                                                        
    Bad block table not found for chip 0                                                                                                                          
    Bad block table not found for chip 0                                                                                                                          
    Scanning device for bad blocks                                                                                                                                
    NET: Registered protocol family 44                                                                                                                            
    Bad block table written to 0x00001ffe0000, version 0x01                                                                                                       
    Bad block table written to 0x00001ffc0000, version 0x01                                                                                                       
    3 ofpart partitions found on MTD device davinci-nand.0                                                                                                        
    Creating 3 MTD partitions on "davinci-nand.0":                                                                                                                
    0x000000000000-0x000000020000 : "u-boot env"                                                                                                                  
    0x000000020000-0x0000000a0000 : "u-boot"                                                                                                                      
    0x0000000a0000-0x000020000000 : "free space"                                                                                                                  
    davinci_nand davinci-nand.0: controller rev. 2.5                                                                                                              
    ***************************************************************                                                                                               
    ***************************************************************                                                                                               
    NOTICE: This file system contains the following GPLv3 packages:                                                                                               
            autoconf                                                                                                                                              
            bash                                                                                                                                                  
            binutils                                                                                                                                              
            cifs-utils                                                                                                                                            
            cpio                                                                                                                                                  
            cpp-symlinks                                                                                                                                          
            cpp                                                                                                                                                   
            dosfstools                                                                                                                                            
            elfutils                                                                                                                                              
            g++-symlinks                                                                                                                                          
            g++                                                                                                                                                   
            gawk                                                                                                                                                  
            gcc-symlinks                                                                                                                                          
            gcc                                                                                                                                                   
            gdb                                                                                                                                                   
            gdbserver                                                                                                                                             
            gettext                                                                                                                                               
            gzip                                                                                                                                                  
            libdw1                                                                                                                                                
            libelf1                                                                                                                                               
            libgdbm-compat4                                                                                                                                       
            libgdbm4                                                                                                                                              
            libgettextlib                                                                                                                                         
            libgettextsrc                                                                                                                                         
            libgmp10                                                                                                                                              
            libmpc3                                                                                                                                               
            libmpfr4                                                                                                                                              
            libreadline7                                                                                                                                          
            m4                                                                                                                                                    
            make                                                                                                                                                  
            which                                                                                                                                                 
                                                                                                                                                                  
    If you do not wish to distribute GPLv3 components please remove                                                                                               
    the above packages prior to distribution.  This can be done using                                                                                             
    the opkg remove command.  i.e.:                                                                                                                               
        opkg remove <package>                                                                                                                                     
    Where <package> is the name printed in the list above                                                                                                         
                                                                                                                                                                  
    NOTE: If the package is a dependency of another package you                                                                                                   
          will be notified of the dependent packages.  You should                                                                                                 
          use the --force-removal-of-dependent-packages option to                                                                                                 
          also remove the dependent packages as well                                                                                                              
    ***************************************************************                                                                                               
    ***************************************************************                                                                                               
    [  OK  ] Started Print notice about GPLv3 packages.                                                                                                           
             Starting syslog.service...                                                                                                                           
             Starting bind.service...                                                                                                                             
             Starting thttpd.service...                                                                                                                           
    [  OK  ] Reached target Network.                                                                                                                              
    [  OK  ] Started Vsftpd ftp daemon.                                                                                                                           
             Starting Berkeley Internet Name Domain (DNS)...                                                                                                      
             Starting Permit User Sessions...                                                                                                                     
             Starting Lightning Fast Webserver With Light System Requirements...                                                                                  
             Starting Simple Network Management Protocol (SNMP) Daemon....                                                                                        
             Starting Network Name Resolution...                                                                                                                  
    [  OK  ] Started thttpd.service.                                                                                                                              
    [  OK  ] Started Permit User Sessions.                                                                                                                        
    [  OK  ] Started Lightning Fast Webserver With Light System Requirements.                                                                                     
    [  OK  ] Started Getty on tty1.                                                                                                                               
    [  OK  ] Reached target Login Prompts.                                                                                                                        
             Starting Synchronize System and HW clocks...                                                                                                         
    [  OK  ] Started Synchronize System and HW clocks.                                                                                                            
    [  OK  ] Started syslog.service.                                                                                                                              
    [  OK  ] Started Network Name Resolution.                                                                                                                     
    [  OK  ] Started Simple Network Management Protocol (SNMP) Daemon..                                                                                           
    [  OK  ] Started bind.service.                                                                                                                                
             Starting rng-tools.service...                                                                                                                        
    [  OK  ] Started Berkeley Internet Name Domain (DNS).                                                                                                         
    [  OK  ] Reached target Host and Network Name Lookups.                                                                                                        
    [  OK  ] Started NFS status monitor for NFSv2/3 locking..                                                                                                     
    [  OK  ] Started rng-tools.service.                                                                                                                           
             Starting matrix-gui-2.0.service...                                                                                                                   
    [  OK  ] Started matrix-gui-2.0.service.                                                                                                                      
             Starting thermal-zone-init.service...                                                                                                                
    [  OK  ] Started thermal-zone-init.service.                                                                                                                   
    [  OK  ] Reached target Multi-User System.                                                                                                                    
             Starting Update UTMP about System Runlevel Changes...                                                                                                
    [  OK  ] Started Update UTMP about System Runlevel Changes. 

    I common the "gp0[9] to gpio-keys", the system works well.

    If you do not wish to distribute GPLv3 components please remove                                                                                               
    the above packages prior to distribution.  This can be done using                                                                                             
    the opkg remove command.  i.e.:                                                                                                                               
        opkg remove <package>                                                                                                                                     
    Where <package> is the name printed in the list above                                                                                                         
                                                                                                                                                                  
    NOTE: If the package is a dependency of another package you                                                                                                   
          will be notified of the dependent packages.  You should                                                                                                 
          use the --force-removal-of-dependent-packages option to                                                                                                 
          also remove the dependent packages as well                                                                                                              
    ***************************************************************                                                                                               
    ***************************************************************                                                                                               
    [  OK  ] Started Print notice about GPLv3 packages.                                                                                                           
    [FAILED] Failed to start Login Service.                                                                                                                       
    See 'systemctl status systemd-logind.service' for details.                                                                                                    
    [  OK  ] Stopped Login Service.                                                                                                                               
             Starting Login Service...                                                                                                                            
    [  OK  ] Reached target Network.                                                                                                                              
             Starting Berkeley Internet Name Domain (DNS)...                                                                                                      
    [  OK  ] Started Vsftpd ftp daemon.                                                                                                                           
             Starting Lightning Fast Webserver With Light System Requirements...                                                                                  
             Starting Permit User Sessions...                                                                                                                     
             Starting Simple Network Management Protocol (SNMP) Daemon....                                                                                        
             Starting Network Name Resolution...                                                                                                                  
             Starting syslog.service...                                                                                                                           
             Starting thttpd.service...                                                                                                                           
             Starting bind.service...                                                                                                                             
    [  OK  ] Started Lightning Fast Webserver With Light System Requirements.                                                                                     
    [  OK  ] Started Permit User Sessions.                                                                                                                        
    [  OK  ] Started Getty on tty1.                                                                                                                               
    [  OK  ] Started Serial Getty on ttyS2.                                                                                                                       
    [  OK  ] Reached target Login Prompts.                                                                                                                        
             Starting Synchronize System and HW clocks...                                                                                                         
    [  OK  ] Started thttpd.service.                                                                                                                              
    [  OK  ] Started Synchronize System and HW clocks.                                                                                                            
    [  OK  ] Started Login Service.                                                                                                                               
    [  OK  ] Started Network Name Resolution.                                                                                                                     
    [  OK  ] Started syslog.service.                                                                                                                              
                                                                                                                                                                  
     _____                    _____           _         _                                                                                                         
    |  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_                                                                                                       
    |     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|                                                                                                      
    |__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_|                                                                                                        
                  |___|                    |___|                                                                                                                  
                                                                                                                                                                  
    Arago Project http://arago-project.org omapl138-lcdk ttyS2                                                                                                    
                                                                                                                                                                  
    Arago 2018.04 omapl138-lcdk ttyS2                                                                                                                             
                                                                                                                                                                  
    omapl138-lcdk login: 
    

    as we see, the LCDK do not use the "matrix-gui-2.0.service ... "

    But I don't know where the service is located.

    Thanks.

  • Thanks for providing the bootlogs. Leg me have a look at them and I will update.

    Best Regards,
    Yordan
  • Hi, Yordan .

    I think the GP0[9] is used by some program.

    when I command the code:

    //20180907
    //serial2_rtscts_pins: pinmux_serial2_rtscts_pins {
    //  pinctrl-single,bits = <
    //      /* UART2_CTS UART2_RTS */
    //      0x00 0x44000000 0xff000000
    //  >;
    //};
    //

    and do not set the "gpio-keys"

    		//20180907
    		//user3 {
    			//label = "GPIO Key USER3";
    			//linux,code = <BTN_2>;
    			//gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
    		//};

    and start up the linux. run " ./lsgpio "

    GPIO chip: gpiochip0, "davinci_gpio.0", 144 GPIO lines
            line  0: unnamed unused
            line  1: unnamed unused
            line  2: unnamed unused
            line  3: unnamed unused
            line  4: unnamed unused
            line  5: unnamed unused
            line  6: unnamed unused
            line  7: unnamed unused
            line  8: unnamed unused
            line  9: unnamed unused [output]
            line 10: unnamed unused
            line 11: unnamed unused
    

    The GP0[9] is configured to be [output], I can't find where the code is.

    Thanks for your help.

     

     

     

     

     

     

  • Hi,

    The Uart pinmux (serual2) is also done in u-boot. Make sure you comment u-boot code as well.
    See u-boot/board/davinci/omapl138_lcdk.c also u-boot/arch/arm/da850.dtsi, you have:
    serial2_rtscts_pins: pinmux_serial2_rtscts_pins {
    pinctrl-single,bits = <
    /* UART2_CTS UART2_RTS */
    0x00 0x44000000 0xff000000
    >;
    };

    Comment this code.

    Best Regards,
    Yordan
  • Hi, Yordan.

    I have updated the u-boot following your advice, but it doesn't work.

    Do you know where the uart2 console code is located ?

    As I test, I have some question:

    1. After this log, the uart console doesn't work.(I can't get the input "#". But the system can put the log out, when the eth0 is Down or Up.)

             Starting Update UTMP about System Runlevel Changes...                                                                                                
    [  OK  ] Started Update UTMP about System Runlevel Changes.

    2. I can logon the system by "ssh root@192.168.1.105". The system works well except the uart console. It is not just the pinmux problem, but hte uart console code. I think the uart console code has some bug with          the  CTS or RTS. 

    Thanks for your help.

  • Hi,

    Yes, it seems that this is a problem with the autoflow control. The autoflow control is set for an UART port from drivers/tty/serial/8250/8250_of.c:
    if (of_property_read_bool(ofdev->dev.of_node, "auto-flow-control"))
    port8250.capabilities |= UART_CAP_AFE;
    through UART_CAP_AFE.

    I do not see it configured in the omap-l138 device tree, that is why I didn't suggest checking this, but it seems that somehow it is messing up with the drivers functionality. Try disabling the UART_CAP_AFE.

    Also you may need to configure the minicom (or whatever serial terminal you use) to NOT use flow control:
    processors.wiki.ti.com/.../Setting_up_Minicom_in_Ubuntu

    Best Regards,
    Yordan
  • Hi,

    It is the autoflow control problem.

    I noticed in the 8250.txt (../ti-processor-sdk-linux-omapl138-lcdk-05.00.00.15/board-support/linux-4.14.40+gitAUTOINC+4796173fc5-g4796173fc5/Documentation/devicetree/bindings/serial)

    It says:

    - auto-flow-control: one way to enable automatic flow control support. The
      driver is allowed to detect support for the capability even without this
      property.

    so I add the             auto-flow-control = <0>;    in the da850.dtsi

    Like this:

    		serial2: serial@10d000 {
    			compatible = "ti,da830-uart", "ns16550a";
    			reg = <0x10d000 0x100>;
    			reg-io-width = <4>;
    			reg-shift = <2>;
    			interrupts = <61>;
    			auto-flow-control = <0>;
    			status = "disabled";
    		};

    and the system can boot up when I add the GPIO0[9] in system.

    Thanks.