Changes between Version 27 and Version 28 of gpio


Ignore:
Timestamp:
12/15/2021 08:44:43 PM (3 years ago)
Author:
Tim Harvey
Comment:

updated U-Boot GPIO examples

Legend:

Unmodified
Added
Removed
Modified
  • gpio

    v27 v28  
    656656[=#uboot]
    657657= U-Boot GPIO
    658 The U-Boot bootloader has basic support for processor GPIO's.
     658The U-Boot bootloader has basic support for GPIO's associated with a driver (such as processor GPIO's):
    659659
    660660Examples:
    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
     663u-boot=> gpio status
     664Bank GPIO1_:
     665GPIO1_0: output: 0 [x] rs485_term.gpio-hog
     666GPIO1_1: input: 0 [x] mipi_gpio4.gpio-hog
     667GPIO1_6: output: 0 [x] pci_usb_sel.gpio-hog
     668GPIO1_7: input: 1 [x] dio0.gpio-hog
     669GPIO1_9: input: 1 [x] dio1.gpio-hog
     670
     671Bank GPIO2_:
     672GPIO2_12: input: 1 [x] mmc@30b50000.cd-gpios
     673
     674Bank GPIO3_:
     675GPIO3_0: output: 0 [x] ethernet@30be0000.phy-reset-gpios
     676
     677Bank GPIO4_:
     678GPIO4_0: output: 0 [x] rs485_en.gpio-hog
     679GPIO4_1: input: 0 [x] mipi_gpio3.gpio-hog
     680GPIO4_2: output: 0 [x] rs485_hd.gpio-hog
     681GPIO4_3: input: 0 [x] mipi_gpio2.gpio-hog
     682GPIO4_4: input: 0 [x] mipi_gpio1.gpio-hog
     683GPIO4_7: output: 1 [x] pci_wdis#.gpio-hog
     684
     685Bank GPIO5_:
     686GPIO5_4: output: 0 [x] led-1.gpios
     687GPIO5_5: output: 0 [x] led-0.gpios
     688}}}
     689 * show status of a particular GPIO (using the gpio id reported above)
     690{{{#!bash
     691u-boot=> gpio status GPIO4_7
     692Bank GPIO4_:
     693GPIO4_7: output: 1 [x] pci_wdis#.gpio-hog
     694u-boot=> gpio status GPIO1_7
     695Bank GPIO1_:
     696GPIO1_7: input: 1 [x] dio0.gpio-hog
     697u-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
     704u-boot=> gpio clr GPIO4_7   
     705gpio: pin GPIO4_7 (gpio 103) value is 0
     706}}}
     707 * set a gpio to output high (set)
     708{{{#!bash
     709u-boot=> gpio set GPIO4_7
     710gpio: pin GPIO4_7 (gpio 103) value is 1
    676711}}}
    677712 * toggle gpio:
    678713{{{#!bash
    679 > gpio toggle 123
    680 }}}
    681 
     714u-boot=> gpio toggle GPIO4_7
     715gpio: pin GPIO4_7 (gpio 103) value is 0
     716u-boot=> gpio toggle GPIO4_7
     717gpio: pin GPIO4_7 (gpio 103) value is 1
     718}}}
     719
     720The 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
     726Note 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.
    682727
    683728[=#notable_gpio]