DART-SD410 Debian GPIO: Difference between revisions

From Variscite Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
{{PageHeader|DART-SD410 - Using GPIO}} {{DocImage|category1=DART-SD410|category2=Debian}} __toc__
{{PageHeader|DART-SD410 - Using GPIO}} {{DocImage|category1=DART-SD410|category2=Debian}} __toc__
User LED4 (D15) connected to GPIO2 of the PMIC. The LED4 is not defined in the apq8016-var-dt410.dtsi file under gpio-leds section.</br>
User LED4 (D15) connected to GPIO2 of the PMIC. The LED4 is not in the apq8016-var-dt410.dtsi file under gpio-leds section.</br>
This allow user acces to this LED as GPIO device.
This allow user acces to this LED as GPIO device.
To change the state of the LED via serial console type:
To change the state of the LED via serial console type:
<pre>
<pre>
# cd /sys/class/gpio
# cd /sys/class/gpio
# echo 445 > export
# echo 509 > export
This line creates a new directory gpio445
This line creates a new directory gpio509
The number 445 calculated as 1 + 444. 1 is the GPIO number, 444 is static offset for PMIC gpio.
The number 509 calculated as 1 + 508. 1 is the GPIO number, 508 is static offset for PMIC gpio.
So changing any other PMIC GPIO will lead to 444 + GPIO number.
So changing any other PMIC GPIO will lead to 508 + GPIO number.
# cd gpio445
# cd gpio509
# echo out > direction
# echo out > direction
# echo 1 > value
# echo 1 > value
Line 43: Line 43:
# cat /sys/kernel/debug/gpio
# cat /sys/kernel/debug/gpio
The output will be:
The output will be:
GPIOs 0-121, platform/1000000.pinctrl, 1000000.pinctrl:
gpiochip0: GPIOs 0-121, parent: platform/1000000.pinctrl, 1000000.pinctrl:
  gpio0  : in  2 16mA no pull
  gpio0  : in  2 16mA no pull
  gpio1  : in  2 16mA no pull
  gpio1  : in  2 16mA no pull
Line 50: Line 50:
  gpio4  : out 2 16mA no pull
  gpio4  : out 2 16mA no pull
  gpio5  : out 2 16mA no pull
  gpio5  : out 2 16mA no pull
  gpio6  : in  0 2mA pull down
  gpio6  : in  3 16mA no pull
  gpio7  : in  0 2mA pull down
  gpio7  : in  3 16mA no pull
  gpio8  : in  0 2mA pull down
  gpio8  : in  1 12mA no pull
  gpio9  : in  0 2mA pull down
  gpio9  : in  1 12mA no pull
  gpio10  : in  0 2mA pull down
  gpio10  : out 0 16mA no pull
  gpio11  : in  0 2mA pull down
  gpio11  : in  1 12mA no pull
  gpio12  : out 0 2mA pull down
  gpio12  : out 0 2mA pull down
  gpio13  : in  0 2mA pull down
  gpio13  : in  0 2mA pull down
  gpio14  : in  2 16mA no pull
  gpio14  : in  2 16mA no pull
  gpio15  : in  2 16mA no pull
  gpio15  : in  2 16mA no pull
  gpio16  : in  0 2mA pull down
  gpio16  : in  1 12mA no pull
  gpio17  : in  0 2mA pull down
  gpio17  : in  1 12mA no pull
  gpio18  : in  0 2mA pull down
  gpio18  : out 0 16mA no pull
  gpio19  : in  0 2mA pull down
  gpio19  : in  1 12mA no pull
  gpio20  : in  0 2mA pull down
  gpio20  : in  0 2mA pull down
  gpio21  : out 0 16mA pull down
  gpio21  : out 0 2mA pull down
  gpio22  : in  2 16mA no pull
  gpio22  : in  2 16mA no pull
  gpio23  : in  2 16mA no pull
  gpio23  : in  2 16mA no pull
Line 71: Line 71:
  gpio25  : in  0 2mA pull down
  gpio25  : in  0 2mA pull down
  gpio26  : in  0 2mA pull down
  gpio26  : in  0 2mA pull down
  gpio27  : in  0 2mA pull down
  gpio27  : in  1 16mA no pull
  gpio28  : in  0 2mA pull down
  gpio28  : out 0 16mA no pull
  gpio29  : in  0 2mA pull down
  gpio29  : in  1 16mA no pull
  gpio30  : in  0 2mA pull down
  gpio30  : in  1 16mA no pull
  gpio31  : in  0 2mA no pull
  gpio31  : in  0 2mA pull down
  gpio32  : out 0 2mA no pull
  gpio32  : out 0 16mA no pull
  gpio33  : in  0 2mA pull down
  gpio33  : out 0 16mA no pull
  gpio34  : in  0 2mA pull down
  gpio34  : in  0 2mA pull down
  gpio35  : in  0 2mA pull down
  gpio35  : in  0 2mA pull down
Line 140: Line 140:
  gpio94  : in  0 2mA pull down
  gpio94  : in  0 2mA pull down
  gpio95  : in  0 2mA pull down
  gpio95  : in  0 2mA pull down
  gpio96  : in  0 2mA pull down
  gpio96  : out 0 2mA pull down
  gpio97  : in  0 2mA pull down
  gpio97  : in  0 2mA pull down
  gpio98  : in  0 2mA pull down
  gpio98  : in  0 2mA pull down
Line 164: Line 164:
  gpio118 : in  1 8mA pull down
  gpio118 : in  1 8mA pull down
  gpio119 : in  1 8mA pull down
  gpio119 : in  1 8mA pull down
  gpio120 : out 0 16mA pull down
  gpio120 : out 0 2mA pull down
  gpio121 : in  0 8mA pull up
  gpio121 : in  0 8mA pull up


GPIOs 440-443, platform/200f000.spmi:pm8916@0:mpps@a000, 200f000.spmi:pm8916@0:mpps@a000:
gpiochip2: GPIOs 504-507, parent: platform/200f000.spmi:pm8916@0:mpps@a000, 200f000.spmi:pm8916@0:mpps@a000:
  mpp1 : out  analog  vin-2 0 0.6kOhm  gh
  mpp1 : out  analog  vin-2 0 high
  mpp2 : out  digital vin-0 0 0.6kOhm  high
  mpp2 : out  digital vin-0 0 low
  mpp3 : out  digital vin-0 0 0.6kOhm  high
  mpp3 : out  digital vin-0 0 high
  mpp4 : out  digital vin-3 0 0.6kOhm  low
  mpp4 : out  digital vin-3 0 low
GPIOs 444-447, platform/200f000.spmi:pm8916@0:gpios@c000, 200f000.spmi:pm8916@0:gpios@c000:
gpiochip1: GPIOs 508-511, parent: platform/200f000.spmi:pm8916@0:gpios@c000, 200f000.spmi:pm8916@0:gpios@c000:
  gpio1 : out  normal  vin-0 pull-down 10uA              push-pull  low  high
  gpio1 : out  normal  vin-0 pull-down 10uA              push-pull  high high
  gpio2 : out  normal  vin-0 pull-down 10uA              push-pull  low  high
  gpio2 : out  normal  vin-0 pull-down 10uA              push-pull  low  high
  gpio3 : out  normal  vin-0 pull-down 10uA              push-pull  high high
  gpio3 : out  normal  vin-0 pull-down 10uA              push-pull  high high
  gpio4 : out  normal  vin-0 pull-down 10uA              push-pull low high
  gpio4 : out  normal  vin-0 pull-down 10uA              push-pull  high high
 
GPIOs 448-479, platform/soc:wcnss-smp2p, master-kernel:
 
GPIOs 480-511, platform/soc:q6-smp2p, master-kernel:
gpio-480 (                    |qcom,stop          ) out ?
</pre>
</pre>
From this table you can see that offsets are:
From this table you can see that offsets are:
*CPU gpio is 0
*CPU gpio is 0
*PMIC gpio is 444
*PMIC gpio is 508
*PMIC mpp is 440
*PMIC mpp is 504

Latest revision as of 15:37, 9 August 2017

DART-SD410 - Using GPIO

User LED4 (D15) connected to GPIO2 of the PMIC. The LED4 is not in the apq8016-var-dt410.dtsi file under gpio-leds section.
This allow user acces to this LED as GPIO device. To change the state of the LED via serial console type:

# cd /sys/class/gpio
# echo 509 > export
This line creates a new directory gpio509
The number 509 calculated as 1 + 508. 1 is the GPIO number, 508 is static offset for PMIC gpio.
So changing any other PMIC GPIO will lead to 508 + GPIO number.
# cd gpio509
# echo out > direction
# echo 1 > value
The led will turn on
#echo 0 > value
The led will turn off

To read the current state type:

# cat value
The output will be 0

You can change active state to active low.

# echo 1 > active_low
# echo 0 > value
The led is active low, writing 0 will turn on the led.
# echo 1 > value
The led is active low, writing 1 will turn off the led.

The Boot Select switch (SW3) connected to CPU GPIO81 the gpio offset for CPU is 0. to read its value use:

# cd /sys/class/gpio
# echo 81 > export
# cd gpio81
# cat value
If the switch is in OFF position the output is 0.
If the switch is in ON position the output is 1.

To see all allocated GPIOs in the system type:

# cat /sys/kernel/debug/gpio
The output will be:
gpiochip0: GPIOs 0-121, parent: platform/1000000.pinctrl, 1000000.pinctrl:
 gpio0   : in  2 16mA no pull
 gpio1   : in  2 16mA no pull
 gpio2   : in  2 16mA no pull
 gpio3   : in  2 16mA no pull
 gpio4   : out 2 16mA no pull
 gpio5   : out 2 16mA no pull
 gpio6   : in  3 16mA no pull
 gpio7   : in  3 16mA no pull
 gpio8   : in  1 12mA no pull
 gpio9   : in  1 12mA no pull
 gpio10  : out 0 16mA no pull
 gpio11  : in  1 12mA no pull
 gpio12  : out 0 2mA pull down
 gpio13  : in  0 2mA pull down
 gpio14  : in  2 16mA no pull
 gpio15  : in  2 16mA no pull
 gpio16  : in  1 12mA no pull
 gpio17  : in  1 12mA no pull
 gpio18  : out 0 16mA no pull
 gpio19  : in  1 12mA no pull
 gpio20  : in  0 2mA pull down
 gpio21  : out 0 2mA pull down
 gpio22  : in  2 16mA no pull
 gpio23  : in  2 16mA no pull
 gpio24  : in  0 2mA pull down
 gpio25  : in  0 2mA pull down
 gpio26  : in  0 2mA pull down
 gpio27  : in  1 16mA no pull
 gpio28  : out 0 16mA no pull
 gpio29  : in  1 16mA no pull
 gpio30  : in  1 16mA no pull
 gpio31  : in  0 2mA pull down
 gpio32  : out 0 16mA no pull
 gpio33  : out 0 16mA no pull
 gpio34  : in  0 2mA pull down
 gpio35  : in  0 2mA pull down
 gpio36  : in  0 2mA pull down
 gpio37  : in  0 2mA pull down
 gpio38  : in  0 2mA pull up
 gpio39  : in  0 2mA pull down
 gpio40  : in  1 6mA pull down
 gpio41  : in  1 6mA pull down
 gpio42  : in  1 6mA pull down
 gpio43  : in  1 6mA pull down
 gpio44  : in  1 6mA pull down
 gpio45  : in  0 2mA pull down
 gpio46  : in  0 2mA pull down
 gpio47  : in  0 2mA pull down
 gpio48  : in  0 2mA pull down
 gpio49  : in  0 2mA pull down
 gpio50  : in  0 2mA pull down
 gpio51  : in  0 2mA pull down
 gpio52  : in  0 2mA pull down
 gpio53  : in  0 2mA pull down
 gpio54  : in  0 2mA pull down
 gpio55  : in  0 2mA pull down
 gpio56  : in  0 2mA pull down
 gpio57  : in  0 2mA pull down
 gpio58  : in  0 2mA pull down
 gpio59  : in  0 2mA pull down
 gpio60  : in  0 2mA pull down
 gpio61  : in  0 2mA pull down
 gpio62  : in  0 2mA pull down
 gpio63  : in  1 8mA pull down
 gpio64  : in  1 8mA pull down
 gpio65  : in  1 8mA pull down
 gpio66  : in  1 8mA pull down
 gpio67  : in  1 8mA pull down
 gpio68  : in  1 8mA pull down
 gpio69  : in  0 2mA pull down
 gpio70  : in  0 2mA pull down
 gpio71  : in  0 2mA pull down
 gpio72  : in  0 2mA pull down
 gpio73  : in  0 2mA pull down
 gpio74  : in  0 2mA pull down
 gpio75  : in  0 2mA pull down
 gpio76  : in  0 2mA pull down
 gpio77  : in  0 2mA pull down
 gpio78  : in  0 2mA pull down
 gpio79  : in  0 2mA pull down
 gpio80  : in  0 2mA pull down
 gpio81  : in  0 2mA pull down
 gpio82  : in  0 2mA pull down
 gpio83  : in  0 2mA pull down
 gpio84  : in  0 2mA pull down
 gpio85  : in  0 2mA pull down
 gpio86  : in  0 2mA pull down
 gpio87  : in  0 2mA pull down
 gpio88  : in  0 2mA pull down
 gpio89  : in  0 2mA pull down
 gpio90  : in  0 2mA pull down
 gpio91  : in  0 2mA pull down
 gpio92  : in  0 2mA pull down
 gpio93  : in  0 2mA pull down
 gpio94  : in  0 2mA pull down
 gpio95  : in  0 2mA pull down
 gpio96  : out 0 2mA pull down
 gpio97  : in  0 2mA pull down
 gpio98  : in  0 2mA pull down
 gpio99  : in  0 2mA pull down
 gpio100 : in  0 2mA pull down
 gpio101 : in  0 2mA pull down
 gpio102 : in  0 2mA pull down
 gpio103 : in  0 2mA pull down
 gpio104 : in  0 2mA pull down
 gpio105 : in  0 2mA pull down
 gpio106 : in  0 2mA pull down
 gpio107 : in  0 8mA pull up
 gpio108 : in  0 2mA pull down
 gpio109 : in  0 2mA pull down
 gpio110 : in  0 2mA pull down
 gpio111 : in  0 2mA pull down
 gpio112 : in  1 8mA pull down
 gpio113 : in  0 2mA pull down
 gpio114 : in  0 2mA pull down
 gpio115 : in  0 2mA pull down
 gpio116 : in  1 8mA pull down
 gpio117 : in  1 8mA pull down
 gpio118 : in  1 8mA pull down
 gpio119 : in  1 8mA pull down
 gpio120 : out 0 2mA pull down
 gpio121 : in  0 8mA pull up

gpiochip2: GPIOs 504-507, parent: platform/200f000.spmi:pm8916@0:mpps@a000, 200f000.spmi:pm8916@0:mpps@a000:
 mpp1 : out  analog  vin-2 0 high
 mpp2 : out  digital vin-0 0 low
 mpp3 : out  digital vin-0 0 high
 mpp4 : out  digital vin-3 0 low
gpiochip1: GPIOs 508-511, parent: platform/200f000.spmi:pm8916@0:gpios@c000, 200f000.spmi:pm8916@0:gpios@c000:
 gpio1 : out  normal  vin-0 pull-down 10uA              push-pull  high high
 gpio2 : out  normal  vin-0 pull-down 10uA              push-pull  low  high
 gpio3 : out  normal  vin-0 pull-down 10uA              push-pull  high high
 gpio4 : out  normal  vin-0 pull-down 10uA              push-pull  high high

From this table you can see that offsets are:

  • CPU gpio is 0
  • PMIC gpio is 508
  • PMIC mpp is 504