661 | | * output logic high: |
662 | | {{{#!bash |
663 | | > gpio set 123 |
664 | | }}} |
665 | | * output logic low: |
666 | | {{{#!bash |
667 | | > gpio clr 123 |
668 | | }}} |
669 | | * show gpio's claimed by drivers: |
670 | | {{{#!bash |
671 | | > gpio status |
672 | | }}} |
673 | | * show gpio input: |
674 | | {{{#!bash |
675 | | > gpio input 123 |
| 661 | * Show GPIO's |
| 662 | {{{#!bash |
| 663 | u-boot=> gpio status |
| 664 | Bank GPIO1_: |
| 665 | GPIO1_0: output: 0 [x] rs485_term.gpio-hog |
| 666 | GPIO1_1: input: 0 [x] mipi_gpio4.gpio-hog |
| 667 | GPIO1_6: output: 0 [x] pci_usb_sel.gpio-hog |
| 668 | GPIO1_7: input: 1 [x] dio0.gpio-hog |
| 669 | GPIO1_9: input: 1 [x] dio1.gpio-hog |
| 670 | |
| 671 | Bank GPIO2_: |
| 672 | GPIO2_12: input: 1 [x] mmc@30b50000.cd-gpios |
| 673 | |
| 674 | Bank GPIO3_: |
| 675 | GPIO3_0: output: 0 [x] ethernet@30be0000.phy-reset-gpios |
| 676 | |
| 677 | Bank GPIO4_: |
| 678 | GPIO4_0: output: 0 [x] rs485_en.gpio-hog |
| 679 | GPIO4_1: input: 0 [x] mipi_gpio3.gpio-hog |
| 680 | GPIO4_2: output: 0 [x] rs485_hd.gpio-hog |
| 681 | GPIO4_3: input: 0 [x] mipi_gpio2.gpio-hog |
| 682 | GPIO4_4: input: 0 [x] mipi_gpio1.gpio-hog |
| 683 | GPIO4_7: output: 1 [x] pci_wdis#.gpio-hog |
| 684 | |
| 685 | Bank GPIO5_: |
| 686 | GPIO5_4: output: 0 [x] led-1.gpios |
| 687 | GPIO5_5: output: 0 [x] led-0.gpios |
| 688 | }}} |
| 689 | * show status of a particular GPIO (using the gpio id reported above) |
| 690 | {{{#!bash |
| 691 | u-boot=> gpio status GPIO4_7 |
| 692 | Bank GPIO4_: |
| 693 | GPIO4_7: output: 1 [x] pci_wdis#.gpio-hog |
| 694 | u-boot=> gpio status GPIO1_7 |
| 695 | Bank GPIO1_: |
| 696 | GPIO1_7: input: 1 [x] dio0.gpio-hog |
| 697 | u-boot=> |
| 698 | }}} |
| 699 | - above you can see that GPIO4_7 (the 'pci_wdis#' gpio on this board) is an output and currently driven high |
| 700 | - above you can see that GPIO1_7 (the 'dio0' gpio on this board) is an input and its current value is high |
| 701 | - note that a 0 always represents a voltage low and 1 always represents a voltage high regardless of if the gpio is considered 'active high' or 'active low' (which is typically indicated by the GPIO name as active low gpios typically end with a '#') |
| 702 | * set a gpio to output low (clr) |
| 703 | {{{#!bash |
| 704 | u-boot=> gpio clr GPIO4_7 |
| 705 | gpio: pin GPIO4_7 (gpio 103) value is 0 |
| 706 | }}} |
| 707 | * set a gpio to output high (set) |
| 708 | {{{#!bash |
| 709 | u-boot=> gpio set GPIO4_7 |
| 710 | gpio: pin GPIO4_7 (gpio 103) value is 1 |
679 | | > gpio toggle 123 |
680 | | }}} |
681 | | |
| 714 | u-boot=> gpio toggle GPIO4_7 |
| 715 | gpio: pin GPIO4_7 (gpio 103) value is 0 |
| 716 | u-boot=> gpio toggle GPIO4_7 |
| 717 | gpio: pin GPIO4_7 (gpio 103) value is 1 |
| 718 | }}} |
| 719 | |
| 720 | The value specified to the vaious gpio commands can be one of: |
| 721 | - bank name (ie GPIO4_ above) to represent all GPIO's in that bank |
| 722 | - pin name (ie GPIO4_7 above) to represent a specific gpio |
| 723 | - pin number (ie 103) to represent a specific gpio. The pin number notation is not recommended as it depends on GPIO controllers being registered in the same order which may not always be the case. It is always better to refer to the bank and pin name/notation. |
| 724 | |
| 725 | |
| 726 | Note that on some platforms GPIO's can not be read back unless configured a specific way. This is the case on IMX boards where GPIO cells need to have the 'Software Input On' (SION) bit enabled in order to read it back. If you have such as GPIO you can still drive it high but you will get a wraning such as 'Warning: value of pin is still 0'. Additinally the 'toggle' won't function for these GPIO's as the software can't determine what state they are. |