1. GPIO状态
cat /sys/kernel/debug/gpio
可以看到当前所有GPIO口的状态,输入输出模式,输出高/低
gpiochip0: GPIOs 0-115, gpio: gpio-0 ( |sysfs ) in hi gpio-1 ( |sysfs ) in hi gpio-2 ( |sysfs ) out lo gpio-3 ( |sysfs ) in hi gpio-4 ( |sysfs ) in hi gpio-5 ( |sysfs ) out lo gpio-6 ( |sysfs ) in hi gpio-7 ( |sysfs ) out hi gpio-8 ( |sysfs ) out lo gpio-9 ( |sysfs ) in hi gpio-10 ( |sysfs ) out hi gpio-11 ( |sysfs ) in hi gpio-12 ( |sysfs ) in hi gpio-13 ( |sysfs ) out hi gpio-14 ( |sysfs ) out hi gpio-15 ( |sysfs ) out hi gpio-16 ( |sysfs ) in hi gpio-17 ( |sysfs ) in lo gpio-18 ( |sysfs ) in lo gpio-19 ( |sysfs ) in hi gpio-20 ( |sysfs ) in lo gpio-21 ( |sysfs ) in lo gpio-22 ( |sysfs ) in hi gpio-23 ( |sysfs ) in lo gpio-24 ( |sysfs ) in lo gpio-25 ( |sysfs ) in lo gpio-26 ( |sysfs ) in lo gpio-27 ( |sysfs ) in hi gpio-28 ( |sysfs ) in hi gpio-29 ( |sysfs ) in hi gpio-30 ( |sysfs ) in hi gpio-31 ( |sysfs ) in lo gpio-32 ( |sysfs ) in hi gpio-33 ( |sysfs ) in hi gpio-34 ( |sysfs ) in lo gpio-35 ( |sysfs ) out lo gpio-36 ( |sysfs ) out lo gpio-37 ( |sysfs ) out lo gpio-38 ( |sysfs ) out lo gpio-39 ( |sysfs ) in lo gpio-40 ( |sysfs ) in hi gpio-41 ( |sysfs ) in hi gpio-42 ( |sysfs ) in hi gpio-43 ( |sysfs ) in hi gpio-44 ( |sysfs ) in lo gpio-45 ( |sysfs ) out hi gpio-46 ( |sysfs ) in hi gpio-47 ( |sysfs ) out hi gpio-48 ( |sysfs ) in hi gpio-49 ( |sysfs ) out hi gpio-50 ( |sysfs ) in hi gpio-51 ( |sysfs ) in hi gpio-52 ( |sysfs ) in lo gpio-53 ( |sysfs ) out lo gpio-54 ( |sysfs ) out hi gpio-55 ( |sysfs ) out lo gpio-56 ( |sysfs ) out hi gpio-57 ( |sysfs ) out lo gpio-58 ( |sysfs ) out hi gpio-59 ( |sysfs ) in hi gpio-60 ( |sysfs ) in hi gpio-61 ( |sysfs ) out hi gpio-64 ( |sysfs ) out hi gpio-65 ( |sysfs ) out hi gpio-66 ( |sysfs ) out hi gpio-67 ( |sysfs ) out lo gpio-68 ( |sysfs ) in hi gpio-69 ( |sysfs ) in hi gpio-70 ( |sysfs ) in hi gpio-71 ( |sysfs ) in hi gpio-72 ( |sysfs ) in hi gpio-73 ( |sysfs ) in hi gpio-74 ( |sysfs ) out lo gpio-75 ( |sysfs ) out hi gpio-76 ( |sysfs ) in hi gpio-77 ( |sysfs ) in hi gpio-78 ( |sysfs ) in hi gpio-79 ( |sysfs ) in lo gpio-80 ( |sysfs ) in hi gpio-81 ( |sysfs ) in lo gpio-82 ( |sysfs ) in lo gpio-83 ( |sysfs ) out lo gpio-84 ( |sysfs ) in lo gpio-85 ( |sysfs ) in lo gpio-86 ( |sysfs ) out hi gpio-87 ( |sysfs ) out lo gpio-88 ( |sysfs ) in hi gpio-89 ( |sysfs ) out lo gpio-90 ( |sysfs ) out lo gpio-91 ( |sysfs ) out lo gpio-92 ( |sysfs ) in hi gpio-93 ( |sysfs ) in hi gpio-94 ( |sysfs ) out hi gpio-95 ( |sysfs ) out hi gpio-96 ( |sysfs ) in lo gpio-97 ( |scl ) in hi gpio-98 ( |sda ) in hi gpio-99 ( |sysfs ) in hi gpio-100 ( |sysfs ) in hi gpio-101 ( |sysfs ) in hi gpio-102 ( |sysfs ) in lo gpio-103 ( |sysfs ) in hi gpio-104 ( |sysfs ) in hi gpio-105 ( |sysfs ) in hi gpio-106 ( |sysfs ) in hi gpio-107 ( |sysfs ) in hi gpio-108 ( |sysfs ) in hi gpio-109 ( |sysfs ) in hi gpio-110 ( |sysfs ) out lo gpio-111 ( |sysfs ) out hi gpio-112 ( |sysfs ) in hi gpio-113 ( |sysfs ) in hi gpio-114 ( |sysfs ) in hi gpio-115 ( |sysfs ) in hi
例如: GPIO74 为 输出 低电平(lo-低,hi-高)
gpio-74 ( |sysfs ) out lo
2. GPIO属性
以gpio-16为例:
(1)direction : IO 输入/输出模式
# cat /sys/devices/gpiochip0/gpio/gpio16/direction out
(2)active_low
# cat /sys/devices/gpiochip0/gpio/gpio16/active_low 0
(3)value 当前电平高低
# cat /sys/devices/gpiochip0/gpio/gpio16/value 0
手动拉高:
echo 1 > /sys/devices/gpiochip0/gpio/gpio16/value
手动拉低:
echo 0 > /sys/devices/gpiochip0/gpio/gpio16/value
3. reg 与 IO 映射
reg 和 pin ID映射 vendormstarkernellinaromstar2halm7221gpiomhal_gpio.c
#define GPIO0_PAD PAD_IRIN #define GPIO0_OEN 0x0f26, BIT0 #define GPIO0_OUT 0x0f26, BIT1 #define GPIO0_IN 0x0f26, BIT2 #define GPIO1_PAD PAD_CEC0 #define GPIO1_OEN 0x0f2a, BIT0 #define GPIO1_OUT 0x0f2a, BIT1 #define GPIO1_IN 0x0f2a, BIT2 #define GPIO2_PAD PAD_PWM_PM #define GPIO2_OEN 0x0f28, BIT0 #define GPIO2_OUT 0x0f28, BIT1 #define GPIO2_IN 0x0f28, BIT2 #define GPIO3_PAD PAD_DDCA_CK #define GPIO3_OEN 0x0494, BIT1 #define GPIO3_OUT 0x0494, BIT2 #define GPIO3_IN 0x0494, BIT0 #define GPIO4_PAD PAD_DDCA_DA #define GPIO4_OEN 0x0494, BIT5 #define GPIO4_OUT 0x0494, BIT6 #define GPIO4_IN 0x0494, BIT4 #define GPIO5_PAD PAD_GPIO0_PM #define GPIO5_OEN 0x0f00, BIT0 #define GPIO5_OUT 0x0f00, BIT1 #define GPIO5_IN 0x0f00, BIT2 #define GPIO6_PAD PAD_GPIO1_PM #define GPIO6_OEN 0x0f02, BIT0 #define GPIO6_OUT 0x0f02, BIT1 #define GPIO6_IN 0x0f02, BIT2 #define GPIO7_PAD PAD_GPIO2_PM #define GPIO7_OEN 0x0f04, BIT0 #define GPIO7_OUT 0x0f04, BIT1 #define GPIO7_IN 0x0f04, BIT2 #define GPIO8_PAD PAD_USB_CTRL #define GPIO8_OEN 0x0f06, BIT0 #define GPIO8_OUT 0x0f06, BIT1 #define GPIO8_IN 0x0f06, BIT2 #define GPIO9_PAD PAD_GPIO5_PM #define GPIO9_OEN 0x0f0a, BIT0 #define GPIO9_OUT 0x0f0a, BIT1 #define GPIO9_IN 0x0f0a, BIT2 #define GPIO10_PAD PAD_GPIO6_PM #define GPIO10_OEN 0x0f0c, BIT0 #define GPIO10_OUT 0x0f0c, BIT1 #define GPIO10_IN 0x0f0c, BIT2 #define GPIO11_PAD PAD_GPIO7_PM #define GPIO11_OEN 0x0f0e, BIT0 #define GPIO11_OUT 0x0f0e, BIT1 #define GPIO11_IN 0x0f0e, BIT2 #define GPIO12_PAD PAD_GPIO8_PM #define GPIO12_OEN 0x0f10, BIT0 #define GPIO12_OUT 0x0f10, BIT1 #define GPIO12_IN 0x0f10, BIT2 #define GPIO13_PAD PAD_GPIO9_PM #define GPIO13_OEN 0x0f12, BIT0 #define GPIO13_OUT 0x0f12, BIT1 #define GPIO13_IN 0x0f12, BIT2 #define GPIO14_PAD PAD_GPIO10_PM #define GPIO14_OEN 0x0f14, BIT0 #define GPIO14_OUT 0x0f14, BIT1 #define GPIO14_IN 0x0f14, BIT2 #define GPIO15_PAD PAD_GPIO11_PM #define GPIO15_OEN 0x0f16, BIT0 #define GPIO15_OUT 0x0f16, BIT1 #define GPIO15_IN 0x0f16, BIT2 #define GPIO16_PAD PAD_GPIO12_PM #define GPIO16_OEN 0x0f18, BIT0 #define GPIO16_OUT 0x0f18, BIT1 #define GPIO16_IN 0x0f18, BIT2 #define GPIO17_PAD PAD_HOTPLUGA #define GPIO17_OEN 0x0e4e, BIT0 #define GPIO17_OUT 0x0e4e, BIT4 #define GPIO17_IN 0x0e4f, BIT0 #define GPIO18_PAD PAD_HOTPLUGB #define GPIO18_OEN 0x0e4e, BIT1 #define GPIO18_OUT 0x0e4e, BIT5 #define GPIO18_IN 0x0e4f, BIT1 #define GPIO19_PAD PAD_HOTPLUGC #define GPIO19_OEN 0x0e4e, BIT2 #define GPIO19_OUT 0x0e4e, BIT6 #define GPIO19_IN 0x0e4f, BIT2 #define GPIO20_PAD PAD_HOTPLUGA_HDMI20_5V #define GPIO20_OEN 0x010218, BIT5 #define GPIO20_OUT 0x010218, BIT4 #define GPIO20_IN 0x010218, BIT6 #define GPIO21_PAD PAD_HOTPLUGB_HDMI20_5V #define GPIO21_OEN 0x010318, BIT5 #define GPIO21_OUT 0x010318, BIT4 #define GPIO21_IN 0x010318, BIT6 #define GPIO22_PAD PAD_HOTPLUGC_HDMI20_5V #define GPIO22_OEN 0x010418, BIT5 #define GPIO22_OUT 0x010418, BIT4 #define GPIO22_IN 0x010418, BIT6 #define GPIO23_PAD PAD_DDCDA_CK #define GPIO23_OEN 0x0496, BIT1 #define GPIO23_OUT 0x0496, BIT2 #define GPIO23_IN 0x0496, BIT0 #define GPIO24_PAD PAD_DDCDA_DA #define GPIO24_OEN 0x0496, BIT5 #define GPIO24_OUT 0x0496, BIT6 #define GPIO24_IN 0x0496, BIT4 #define GPIO25_PAD PAD_DDCDB_CK #define GPIO25_OEN 0x0497, BIT1 #define GPIO25_OUT 0x0497, BIT2 #define GPIO25_IN 0x0497, BIT0 #define GPIO26_PAD PAD_DDCDB_DA #define GPIO26_OEN 0x0497, BIT5 #define GPIO26_OUT 0x0497, BIT6 #define GPIO26_IN 0x0497, BIT4 #define GPIO27_PAD PAD_DDCDC_CK #define GPIO27_OEN 0x0498, BIT1 #define GPIO27_OUT 0x0498, BIT2 #define GPIO27_IN 0x0498, BIT0 #define GPIO28_PAD PAD_DDCDC_DA #define GPIO28_OEN 0x0498, BIT5 #define GPIO28_OUT 0x0498, BIT6 #define GPIO28_IN 0x0498, BIT4 #define GPIO29_PAD PAD_SAR0 #define GPIO29_OEN 0x1423, BIT0 #define GPIO29_OUT 0x1424, BIT0 #define GPIO29_IN 0x1425, BIT0 #define GPIO30_PAD PAD_SAR1 #define GPIO30_OEN 0x1423, BIT1 #define GPIO30_OUT 0x1424, BIT1 #define GPIO30_IN 0x1425, BIT1 #define GPIO31_PAD PAD_SAR2 #define GPIO31_OEN 0x1423, BIT2 #define GPIO31_OUT 0x1424, BIT2 #define GPIO31_IN 0x1425, BIT2 #define GPIO32_PAD PAD_SAR3 #define GPIO32_OEN 0x1423, BIT3 #define GPIO32_OUT 0x1424, BIT3 #define GPIO32_IN 0x1425, BIT3 #define GPIO33_PAD PAD_SAR4 #define GPIO33_OEN 0x1423, BIT4 #define GPIO33_OUT 0x1424, BIT4 #define GPIO33_IN 0x1425, BIT4 #define GPIO34_PAD PAD_VPLUGIN #define GPIO34_OEN 0x1423, BIT5 #define GPIO34_OUT 0x1424, BIT5 #define GPIO34_IN 0x1425, BIT5 #define GPIO35_PAD PAD_VID0 #define GPIO35_OEN 0x2e84, BIT1 #define GPIO35_OUT 0x2e84, BIT0 #define GPIO35_IN 0x2e84, BIT2 #define GPIO36_PAD PAD_VID1 #define GPIO36_OEN 0x2e85, BIT1 #define GPIO36_OUT 0x2e85, BIT0 #define GPIO36_IN 0x2e85, BIT2 #define GPIO37_PAD PAD_VID2 #define GPIO37_OEN 0x0f22, BIT0 #define GPIO37_OUT 0x0f22, BIT1 #define GPIO37_IN 0x0f22, BIT2 #define GPIO38_PAD PAD_VID3 #define GPIO38_OEN 0x0f24, BIT0 #define GPIO38_OUT 0x0f24, BIT1 #define GPIO38_IN 0x0f24, BIT2 #define GPIO39_PAD PAD_WOL_INT_OUT #define GPIO39_OEN 0x2e82, BIT1 #define GPIO39_OUT 0x2e82, BIT0 #define GPIO39_IN 0x2e82, BIT2 #define GPIO40_PAD PAD_I2S_IN_BCK #define GPIO40_OEN 0x0f3e, BIT0 #define GPIO40_OUT 0x0f3e, BIT1 #define GPIO40_IN 0x0f3e, BIT2 #define GPIO41_PAD PAD_I2S_IN_WS #define GPIO41_OEN 0x0f40, BIT0 #define GPIO41_OUT 0x0f40, BIT1 #define GPIO41_IN 0x0f40, BIT2 #define GPIO42_PAD PAD_I2S_IN_MCK #define GPIO42_OEN 0x0f42, BIT0 #define GPIO42_OUT 0x0f42, BIT1 #define GPIO42_IN 0x0f42, BIT2 #define GPIO43_PAD PAD_I2S_IN_SD0 #define GPIO43_OEN 0x0f44, BIT0 #define GPIO43_OUT 0x0f44, BIT1 #define GPIO43_IN 0x0f44, BIT2 #define GPIO44_PAD PAD_I2S_IN_SD1 #define GPIO44_OEN 0x0f46, BIT0 #define GPIO44_OUT 0x0f46, BIT1 #define GPIO44_IN 0x0f46, BIT2 #define GPIO45_PAD PAD_CILINK_DEMOD0_CLK #define GPIO45_OEN 0x102b13, BIT1 #define GPIO45_OUT 0x102b13, BIT0 #define GPIO45_IN 0x102b13, BIT2 #define GPIO46_PAD PAD_CILINK_DEMOD1_CLK #define GPIO46_OEN 0x102b1a, BIT1 #define GPIO46_OUT 0x102b1a, BIT0 #define GPIO46_IN 0x102b1a, BIT2 #define GPIO47_PAD PAD_CILINK_INT #define GPIO47_OEN 0x102b12, BIT1 #define GPIO47_OUT 0x102b12, BIT0 #define GPIO47_IN 0x102b12, BIT2 #define GPIO48_PAD PAD_CILINK_RX0_D0 #define GPIO48_OEN 0x102b18, BIT1 #define GPIO48_OUT 0x102b18, BIT0 #define GPIO48_IN 0x102b18, BIT2 #define GPIO49_PAD PAD_CILINK_RX0_D1 #define GPIO49_OEN 0x102b19, BIT1 #define GPIO49_OUT 0x102b19, BIT0 #define GPIO49_IN 0x102b19, BIT2 #define GPIO50_PAD PAD_CILINK_RX1_D0 #define GPIO50_OEN 0x102ba1, BIT1 #define GPIO50_OUT 0x102ba1, BIT0 #define GPIO50_IN 0x102ba1, BIT2 #define GPIO51_PAD PAD_CILINK_RX1_D1 #define GPIO51_OEN 0x102ba2, BIT1 #define GPIO51_OUT 0x102ba2, BIT0 #define GPIO51_IN 0x102ba2, BIT2 #define GPIO52_PAD PAD_CILINK_RX_CLK #define GPIO52_OEN 0x102b17, BIT1 #define GPIO52_OUT 0x102b17, BIT0 #define GPIO52_IN 0x102b17, BIT2 #define GPIO53_PAD PAD_CILINK_SPI_CLK #define GPIO53_OEN 0x102b0e, BIT1 #define GPIO53_OUT 0x102b0e, BIT0 #define GPIO53_IN 0x102b0e, BIT2 #define GPIO54_PAD PAD_CILINK_SPI_CS #define GPIO54_OEN 0x102b11, BIT1 #define GPIO54_OUT 0x102b11, BIT0 #define GPIO54_IN 0x102b11, BIT2 #define GPIO55_PAD PAD_CILINK_SPI_MISO #define GPIO55_OEN 0x102b10, BIT1 #define GPIO55_OUT 0x102b10, BIT0 #define GPIO55_IN 0x102b10, BIT2 #define GPIO56_PAD PAD_CILINK_SPI_MOSI #define GPIO56_OEN 0x102b0f, BIT1 #define GPIO56_OUT 0x102b0f, BIT0 #define GPIO56_IN 0x102b0f, BIT2 #define GPIO57_PAD PAD_CILINK_TX0_D0 #define GPIO57_OEN 0x102b15, BIT1 #define GPIO57_OUT 0x102b15, BIT0 #define GPIO57_IN 0x102b15, BIT2 #define GPIO58_PAD PAD_CILINK_TX0_D1 #define GPIO58_OEN 0x102b16, BIT1 #define GPIO58_OUT 0x102b16, BIT0 #define GPIO58_IN 0x102b16, BIT2 #define GPIO59_PAD PAD_CILINK_TX1_D0 #define GPIO59_OEN 0x102b1b, BIT1 #define GPIO59_OUT 0x102b1b, BIT0 #define GPIO59_IN 0x102b1b, BIT2 #define GPIO60_PAD PAD_CILINK_TX1_D1 #define GPIO60_OEN 0x102ba0, BIT1 #define GPIO60_OUT 0x102ba0, BIT0 #define GPIO60_IN 0x102ba0, BIT2 #define GPIO61_PAD PAD_CILINK_TX_CLK #define GPIO61_OEN 0x102b14, BIT1 #define GPIO61_OUT 0x102b14, BIT0 #define GPIO61_IN 0x102b14, BIT2 #define GPIO62_PAD PAD_DDCR_CK #define GPIO62_OEN 0x102b87, BIT1 #define GPIO62_OUT 0x102b87, BIT0 #define GPIO62_IN 0x102b87, BIT2 #define GPIO63_PAD PAD_DDCR_DA #define GPIO63_OEN 0x102b86, BIT1 #define GPIO63_OUT 0x102b86, BIT0 #define GPIO63_IN 0x102b86, BIT2 #define GPIO64_PAD PAD_GPIO2 #define GPIO64_OEN 0x102b00, BIT1 #define GPIO64_OUT 0x102b00, BIT0 #define GPIO64_IN 0x102b00, BIT2 #define GPIO65_PAD PAD_GPIO3 #define GPIO65_OEN 0x102b01, BIT1 #define GPIO65_OUT 0x102b01, BIT0 #define GPIO65_IN 0x102b01, BIT2 #define GPIO66_PAD PAD_GPIO4 #define GPIO66_OEN 0x102b02, BIT1 #define GPIO66_OUT 0x102b02, BIT0 #define GPIO66_IN 0x102b02, BIT2 #define GPIO67_PAD PAD_GPIO5 #define GPIO67_OEN 0x102b03, BIT1 #define GPIO67_OUT 0x102b03, BIT0 #define GPIO67_IN 0x102b03, BIT2 #define GPIO68_PAD PAD_GPIO9 #define GPIO68_OEN 0x102b04, BIT1 #define GPIO68_OUT 0x102b04, BIT0 #define GPIO68_IN 0x102b04, BIT2 #define GPIO69_PAD PAD_GPIO10 #define GPIO69_OEN 0x102b05, BIT1 #define GPIO69_OUT 0x102b05, BIT0 #define GPIO69_IN 0x102b05, BIT2 #define GPIO70_PAD PAD_GPIO11 #define GPIO70_OEN 0x102b06, BIT1 #define GPIO70_OUT 0x102b06, BIT0 #define GPIO70_IN 0x102b06, BIT2 #define GPIO71_PAD PAD_GPIO12 #define GPIO71_OEN 0x102b07, BIT1 #define GPIO71_OUT 0x102b07, BIT0 #define GPIO71_IN 0x102b07, BIT2 #define GPIO72_PAD PAD_GPIO19 #define GPIO72_OEN 0x102b08, BIT1 #define GPIO72_OUT 0x102b08, BIT0 #define GPIO72_IN 0x102b08, BIT2 #define GPIO73_PAD PAD_GPIO20 #define GPIO73_OEN 0x102b09, BIT1 #define GPIO73_OUT 0x102b09, BIT0 #define GPIO73_IN 0x102b09, BIT2 #define GPIO74_PAD PAD_GPIO25 #define GPIO74_OEN 0x102b0a, BIT1 #define GPIO74_OUT 0x102b0a, BIT0 #define GPIO74_IN 0x102b0a, BIT2 #define GPIO75_PAD PAD_GPIO26 #define GPIO75_OEN 0x102b0b, BIT1 #define GPIO75_OUT 0x102b0b, BIT0 #define GPIO75_IN 0x102b0b, BIT2 #define GPIO76_PAD PAD_GPIO30 #define GPIO76_OEN 0x102b0c, BIT1 #define GPIO76_OUT 0x102b0c, BIT0 #define GPIO76_IN 0x102b0c, BIT2 #define GPIO77_PAD PAD_GPIO31 #define GPIO77_OEN 0x102b0d, BIT1 #define GPIO77_OUT 0x102b0d, BIT0 #define GPIO77_IN 0x102b0d, BIT2 #define GPIO78_PAD PAD_HDMIRX_ARCTX #define GPIO78_OEN 0x110320, BIT1 #define GPIO78_OUT 0x110320, BIT0 #define GPIO78_IN 0x110320, BIT2 #define GPIO79_PAD PAD_I2S_OUT_BCK #define GPIO79_OEN 0x102b38, BIT1 #define GPIO79_OUT 0x102b38, BIT0 #define GPIO79_IN 0x102b38, BIT2 #define GPIO80_PAD PAD_I2S_OUT_MCK #define GPIO80_OEN 0x102b39, BIT1 #define GPIO80_OUT 0x102b39, BIT0 #define GPIO80_IN 0x102b39, BIT2 #define GPIO81_PAD PAD_I2S_OUT_SD #define GPIO81_OEN 0x102b3b, BIT1 #define GPIO81_OUT 0x102b3b, BIT0 #define GPIO81_IN 0x102b3b, BIT2 #define GPIO82_PAD PAD_I2S_OUT_SD1 #define GPIO82_OEN 0x102b3c, BIT1 #define GPIO82_OUT 0x102b3c, BIT0 #define GPIO82_IN 0x102b3c, BIT2 #define GPIO83_PAD PAD_I2S_OUT_SD2 #define GPIO83_OEN 0x102b3d, BIT1 #define GPIO83_OUT 0x102b3d, BIT0 #define GPIO83_IN 0x102b3d, BIT2 #define GPIO84_PAD PAD_I2S_OUT_WS #define GPIO84_OEN 0x102b3a, BIT1 #define GPIO84_OUT 0x102b3a, BIT0 #define GPIO84_IN 0x102b3a, BIT2 #define GPIO85_PAD PAD_PWM0 #define GPIO85_OEN 0x102b88, BIT1 #define GPIO85_OUT 0x102b88, BIT0 #define GPIO85_IN 0x102b88, BIT2 #define GPIO86_PAD PAD_PWM1 #define GPIO86_OEN 0x102b89, BIT1 #define GPIO86_OUT 0x102b89, BIT0 #define GPIO86_IN 0x102b89, BIT2 #define GPIO87_PAD PAD_PWM2 #define GPIO87_OEN 0x102b8a, BIT1 #define GPIO87_OUT 0x102b8a, BIT0 #define GPIO87_IN 0x102b8a, BIT2 #define GPIO88_PAD PAD_PWM3 #define GPIO88_OEN 0x102b8b, BIT1 #define GPIO88_OUT 0x102b8b, BIT0 #define GPIO88_IN 0x102b8b, BIT2 #define GPIO89_PAD PAD_SD_CLK #define GPIO89_OEN 0x102bfa, BIT1 #define GPIO89_OUT 0x102bfa, BIT0 #define GPIO89_IN 0x102bfa, BIT2 #define GPIO90_PAD PAD_SD_CMD #define GPIO90_OEN 0x102bfb, BIT1 #define GPIO90_OUT 0x102bfb, BIT0 #define GPIO90_IN 0x102bfb, BIT2 #define GPIO91_PAD PAD_SD_D0 #define GPIO91_OEN 0x102bac, BIT1 #define GPIO91_OUT 0x102bac, BIT0 #define GPIO91_IN 0x102bac, BIT2 #define GPIO92_PAD PAD_SD_D1 #define GPIO92_OEN 0x102bad, BIT1 #define GPIO92_OUT 0x102bad, BIT0 #define GPIO92_IN 0x102bad, BIT2 #define GPIO93_PAD PAD_SD_D2 #define GPIO93_OEN 0x102bae, BIT1 #define GPIO93_OUT 0x102bae, BIT0 #define GPIO93_IN 0x102bae, BIT2 #define GPIO94_PAD PAD_SD_D3 #define GPIO94_OEN 0x102bf9, BIT1 #define GPIO94_OUT 0x102bf9, BIT0 #define GPIO94_IN 0x102bf9, BIT2 #define GPIO95_PAD PAD_SPDIF_IN #define GPIO95_OEN 0x102b36, BIT1 #define GPIO95_OUT 0x102b36, BIT0 #define GPIO95_IN 0x102b36, BIT2 #define GPIO96_PAD PAD_SPDIF_OUT #define GPIO96_OEN 0x102b37, BIT1 #define GPIO96_OUT 0x102b37, BIT0 #define GPIO96_IN 0x102b37, BIT2 #define GPIO97_PAD PAD_TGPIO0 #define GPIO97_OEN 0x102b8d, BIT1 #define GPIO97_OUT 0x102b8d, BIT0 #define GPIO97_IN 0x102b8d, BIT2 #define GPIO98_PAD PAD_TGPIO1 #define GPIO98_OEN 0x102b8e, BIT1 #define GPIO98_OUT 0x102b8e, BIT0 #define GPIO98_IN 0x102b8e, BIT2 #define GPIO99_PAD PAD_TGPIO2 #define GPIO99_OEN 0x102b8f, BIT1 #define GPIO99_OUT 0x102b8f, BIT0 #define GPIO99_IN 0x102b8f, BIT2 #define GPIO100_PAD PAD_TGPIO3 #define GPIO100_OEN 0x102b90, BIT1 #define GPIO100_OUT 0x102b90, BIT0 #define GPIO100_IN 0x102b90, BIT2 #define GPIO101_PAD PAD_TS1_CLK #define GPIO101_OEN 0x102b27, BIT1 #define GPIO101_OUT 0x102b27, BIT0 #define GPIO101_IN 0x102b27, BIT2 #define GPIO102_PAD PAD_TS1_D0 #define GPIO102_OEN 0x102b31, BIT1 #define GPIO102_OUT 0x102b31, BIT0 #define GPIO102_IN 0x102b31, BIT2 #define GPIO103_PAD PAD_TS1_D1 #define GPIO103_OEN 0x102b30, BIT1 #define GPIO103_OUT 0x102b30, BIT0 #define GPIO103_IN 0x102b30, BIT2 #define GPIO104_PAD PAD_TS1_D2 #define GPIO104_OEN 0x102b2f, BIT1 #define GPIO104_OUT 0x102b2f, BIT0 #define GPIO104_IN 0x102b2f, BIT2 #define GPIO105_PAD PAD_TS1_D3 #define GPIO105_OEN 0x102b2e, BIT1 #define GPIO105_OUT 0x102b2e, BIT0 #define GPIO105_IN 0x102b2e, BIT2 #define GPIO106_PAD PAD_TS1_D4 #define GPIO106_OEN 0x102b2d, BIT1 #define GPIO106_OUT 0x102b2d, BIT0 #define GPIO106_IN 0x102b2d, BIT2 #define GPIO107_PAD PAD_TS1_D5 #define GPIO107_OEN 0x102b2c, BIT1 #define GPIO107_OUT 0x102b2c, BIT0 #define GPIO107_IN 0x102b2c, BIT2 #define GPIO108_PAD PAD_TS1_D6 #define GPIO108_OEN 0x102b2b, BIT1 #define GPIO108_OUT 0x102b2b, BIT0 #define GPIO108_IN 0x102b2b, BIT2 #define GPIO109_PAD PAD_TS1_D7 #define GPIO109_OEN 0x102b2a, BIT1 #define GPIO109_OUT 0x102b2a, BIT0 #define GPIO109_IN 0x102b2a, BIT2 #define GPIO110_PAD PAD_TS1_SYNC #define GPIO110_OEN 0x102b28, BIT1 #define GPIO110_OUT 0x102b28, BIT0 #define GPIO110_IN 0x102b28, BIT2 #define GPIO111_PAD PAD_TS1_VLD #define GPIO111_OEN 0x102b29, BIT1 #define GPIO111_OUT 0x102b29, BIT0 #define GPIO111_IN 0x102b29, BIT2 #define GPIO112_PAD PAD_TS2_CLK #define GPIO112_OEN 0x102b35, BIT1 #define GPIO112_OUT 0x102b35, BIT0 #define GPIO112_IN 0x102b35, BIT2 #define GPIO113_PAD PAD_TS2_D0 #define GPIO113_OEN 0x102b32, BIT1 #define GPIO113_OUT 0x102b32, BIT0 #define GPIO113_IN 0x102b32, BIT2 #define GPIO114_PAD PAD_TS2_SYNC #define GPIO114_OEN 0x102b34, BIT1 #define GPIO114_OUT 0x102b34, BIT0 #define GPIO114_IN 0x102b34, BIT2 #define GPIO115_PAD PAD_TS2_VLD #define GPIO115_OEN 0x102b33, BIT1 #define GPIO115_OUT 0x102b33, BIT0 #define GPIO115_IN 0x102b33, BIT2 #define GPIO_EXT0_MSK 0x10190c, BIT7 #define GPIO_EXT0_POL 0x101914, BIT7 #define GPIO_EXT0_CLR 0x10191c, BIT7 #define GPIO_EXT0_STS 0x10191c, BIT7 #define GPIO_EXT1_MSK 0x10190c, BIT11 #define GPIO_EXT1_POL 0x101914, BIT11 #define GPIO_EXT1_CLR 0x10191c, BIT11 #define GPIO_EXT1_STS 0x10191c, BIT11 #define GPIO_EXT2_MSK 0x10190c, BIT15 #define GPIO_EXT2_POL 0x101914, BIT15 #define GPIO_EXT2_CLR 0x10191c, BIT15 #define GPIO_EXT2_STS 0x10191c, BIT15 #define GPIO_EXT3_MSK 0x10190e, BIT7 #define GPIO_EXT3_POL 0x101916, BIT7 #define GPIO_EXT3_CLR 0x10191e, BIT7 #define GPIO_EXT3_STS 0x10191e, BIT7 #define GPIO_EXT4_MSK 0x10190e, BIT8 #define GPIO_EXT4_POL 0x101916, BIT8 #define GPIO_EXT4_CLR 0x10191e, BIT8 #define GPIO_EXT4_STS 0x10191e, BIT8 #define GPIO_EXT5_MSK 0x10190e, BIT8 #define GPIO_EXT5_POL 0x101916, BIT8 #define GPIO_EXT5_CLR 0x10191e, BIT8 #define GPIO_EXT5_STS 0x10191e, BIT8 #define GPIO_EXT6_MSK 0x10190e, BIT10 #define GPIO_EXT6_POL 0x101916, BIT10 #define GPIO_EXT6_CLR 0x10191e, BIT10 #define GPIO_EXT6_STS 0x10191e, BIT10 #define GPIO_EXT7_MSK 0x10190e, BIT15 #define GPIO_EXT7_POL 0x101916, BIT15 #define GPIO_EXT7_CLR 0x10191e, BIT15 #define GPIO_EXT7_STS 0x10191e, BIT15
例如 PAD_IRIN,PAD_CEC0,PAD_PWM_PM是pin id,在 vendormstarkernellinaromstar2halm7221gpiomhal_gpio_reg.h 中定义:
#define PAD_IRIN 0 #define PAD_CEC0 1 #define PAD_PWM_PM 2 #define PAD_DDCA_CK 3 #define PAD_DDCA_DA 4 #define PAD_GPIO0_PM 5 #define PAD_GPIO1_PM 6 #define PAD_GPIO2_PM 7 #define PAD_USB_CTRL 8 #define PAD_GPIO5_PM 9 #define PAD_GPIO6_PM 10 #define PAD_GPIO7_PM 11 #define PAD_GPIO8_PM 12 #define PAD_GPIO9_PM 13 #define PAD_GPIO10_PM 14 #define PAD_GPIO11_PM 15 #define PAD_GPIO12_PM 16 #define PAD_HOTPLUGA 17 #define PAD_HOTPLUGB 18 #define PAD_HOTPLUGC 19 #define PAD_HOTPLUGA_HDMI20_5V 20 #define PAD_HOTPLUGB_HDMI20_5V 21 #define PAD_HOTPLUGC_HDMI20_5V 22 #define PAD_DDCDA_CK 23 #define PAD_DDCDA_DA 24 #define PAD_DDCDB_CK 25 #define PAD_DDCDB_DA 26 #define PAD_DDCDC_CK 27 #define PAD_DDCDC_DA 28 #define PAD_SAR0 29 #define PAD_SAR1 30 #define PAD_SAR2 31 #define PAD_SAR3 32 #define PAD_SAR4 33 #define PAD_VPLUGIN 34 #define PAD_VID0 35 #define PAD_VID1 36 #define PAD_VID2 37 #define PAD_VID3 38 #define PAD_WOL_INT_OUT 39 #define PAD_I2S_IN_BCK 40 #define PAD_I2S_IN_WS 41 #define PAD_I2S_IN_MCK 42 #define PAD_I2S_IN_SD0 43 #define PAD_I2S_IN_SD1 44 #define PAD_CILINK_DEMOD0_CLK 45 #define PAD_CILINK_DEMOD1_CLK 46 #define PAD_CILINK_INT 47 #define PAD_CILINK_RX0_D0 48 #define PAD_CILINK_RX0_D1 49 #define PAD_CILINK_RX1_D0 50 #define PAD_CILINK_RX1_D1 51 #define PAD_CILINK_RX_CLK 52 #define PAD_CILINK_SPI_CLK 53 #define PAD_CILINK_SPI_CS 54 #define PAD_CILINK_SPI_MISO 55 #define PAD_CILINK_SPI_MOSI 56 #define PAD_CILINK_TX0_D0 57 #define PAD_CILINK_TX0_D1 58 #define PAD_CILINK_TX1_D0 59 #define PAD_CILINK_TX1_D1 60 #define PAD_CILINK_TX_CLK 61 #define PAD_DDCR_CK 62 #define PAD_DDCR_DA 63 #define PAD_GPIO2 64 #define PAD_GPIO3 65 #define PAD_GPIO4 66 #define PAD_GPIO5 67 #define PAD_GPIO9 68 #define PAD_GPIO10 69 #define PAD_GPIO11 70 #define PAD_GPIO12 71 #define PAD_GPIO19 72 #define PAD_GPIO20 73 #define PAD_GPIO25 74 #define PAD_GPIO26 75 #define PAD_GPIO30 76 #define PAD_GPIO31 77 #define PAD_HDMIRX_ARCTX 78 #define PAD_I2S_OUT_BCK 79 #define PAD_I2S_OUT_MCK 80 #define PAD_I2S_OUT_SD 81 #define PAD_I2S_OUT_SD1 82 #define PAD_I2S_OUT_SD2 83 #define PAD_I2S_OUT_WS 84 #define PAD_PWM0 85 #define PAD_PWM1 86 #define PAD_PWM2 87 #define PAD_PWM3 88 #define PAD_SD_CLK 89 #define PAD_SD_CMD 90 #define PAD_SD_D0 91 #define PAD_SD_D1 92 #define PAD_SD_D2 93 #define PAD_SD_D3 94 #define PAD_SPDIF_IN 95 #define PAD_SPDIF_OUT 96 #define PAD_TGPIO0 97 #define PAD_TGPIO1 98 #define PAD_TGPIO2 99 #define PAD_TGPIO3 100 #define PAD_TS1_CLK 101 #define PAD_TS1_D0 102 #define PAD_TS1_D1 103 #define PAD_TS1_D2 104 #define PAD_TS1_D3 105 #define PAD_TS1_D4 106 #define PAD_TS1_D5 107 #define PAD_TS1_D6 108 #define PAD_TS1_D7 109 #define PAD_TS1_SYNC 110 #define PAD_TS1_VLD 111 #define PAD_TS2_CLK 112 #define PAD_TS2_D0 113 #define PAD_TS2_SYNC 114 #define PAD_TS2_VLD 115 #define GPIO_OEN 0 //set o to nake output #define GPIO_ODN 1 #define IN_HIGH 1 //input high #define IN_LOW 0 //input low #define OUT_HIGH 1 //output high #define OUT_LOW 0 //output low
4. pin id 与芯片管脚映射
以GPIO16 为例:
#define GPIO16_PAD PAD_GPIO12_PM
supernovaprojectsoardm7221ChipInfoMSD96BUXM8.h
#define BALL_U3 PAD_GPIO12_PM #define PAD_GPIO12_PM 17 #define GPIO_PAD_17 GPIO16 #ifndef BALL_U3_IS_GPIO #define BALL_U3_IS_GPIO 0 #endif #ifndef PAD_GPIO12_PM_IS_GPIO #define PAD_GPIO12_PM_IS_GPIO BALL_U3_IS_GPIO #endif
其中BALL_U3即为芯片的管脚