DART-SD410 Android GPIO

From Variscite Wiki
Revision as of 13:01, 17 April 2016 by Leonid (talk | contribs) (Created page with "= Using GPIO = User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-sd410.dtsi file under gpio-leds section.</br> This allow user acces t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Using GPIO

User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-sd410.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:

$ su
# cd /sys/class/gpio
# echo 1022 > export
This line creates a new directory gpio1022
The number 1022 calculated as 120 + 902. 120 is the GPIO number, 902 is static offset for CPU gpio.
So changing any other GPIO will lead to 902 + GPIO number.
# cd gpio1022
# 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 to read its value use:

# cd /sys/class/gpio
# echo 983 > export
# cd gpio983
# 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:
GPIOs 577-608, platform/qcom,smp2pgpio-ssr-smp2p-4-out.19, master-kernel:
GPIOs 609-640, platform/qcom,smp2pgpio-ssr-smp2p-4-in.18, slave-kernel:
GPIOs 641-672, platform/qcom,smp2pgpio-ssr-smp2p-1-out.13, master-kernel:
GPIOs 673-704, platform/qcom,smp2pgpio-ssr-smp2p-1-in.12, slave-kernel:
GPIOs 705-736, platform/qcom,smp2pgpio-smp2p-4-out.16, smp2p:
GPIOs 737-768, platform/qcom,smp2pgpio-smp2p-4-in.14, smp2p:
GPIOs 769-800, platform/qcom,smp2pgpio-smp2p-1-out.10, smp2p:
GPIOs 801-832, platform/qcom,smp2pgpio-smp2p-1-in.8, smp2p:
GPIOs 833-864, platform/qcom,smp2pgpio-smp2p-7-out.6, smp2p:
GPIOs 865-896, platform/qcom,smp2pgpio-smp2p-7-in.4, smp2p:
GPIOs 897-900, spmi/qpnp-pin-ffffffc0319b4c00, pm8916-gpio:
 gpio-899 (qcom,hub-reset-gpio ) out hi
 gpio-900 (qcom,sw-sel-gpio    ) in  lo
GPIOs 901-901, spmi/qpnp-pin-ffffffc0319b4800, pm8916-mpp:
GPIOs 902-1023, platform/1000000.pinctrl, msm_tlmm_gpio:
 gpio-914 (ft5x06_reset_gpio   ) out hi
 gpio-915 (ft5x06_irq_gpio     ) in  hi
 gpio-922 (adv7533_hpd_irq_gpio) in  lo
 gpio-923 (led1                ) out lo
 gpio-933 (adv7533_irq_gpio    ) in  hi
 gpio-934 (disp_rst_n          ) in  hi
 gpio-940 (7864900.sdhci cd    ) in  lo
 gpio-1009 (volume_up           ) in  hi
 gpio-1010 (home                ) in  hi
 gpio-1011 (back                ) in  hi
 gpio-1022 (sysfs               ) out lo
 gpio-1023 (USB_ID_GPIO         ) in  hi

From this table you can see that offsets are:

  • CPU gpio is 902
  • PMIC gpio is 897
  • PMIC mpp is 901