A133 Pinctrl

Android Q(10)

Posted by LXG on July 13, 2023

A133_Datasheet_V1.4

The documentation describes features of each module, pin/signal characteristics, current consumption, the interface timing, thermal and package, and part reliability of the A133 processor. For details about register descriptions of each module, see the A133_User_Manual.

文档介绍了 A133 处理器的每个模块的特性、引脚/信号特性、电流消耗、接口时序、散热和封装以及部件可靠性。有关每个模块的寄存器说明的详细信息,请参阅A133_User_Manual。

a133_datasheet_gpio

A133_User_Manual_V1.5

This document describes the features, logical structures, functions, operating modes, and related registers of each module about A133. For details about the interface timings and related parameters, the pins, pin usages, performance parameters, and package dimension, refer to the Allwinner A133 Datasheet.

本文档介绍有关A133的每个模块的特性,逻辑结构,功能,操作模式和相关寄存器。有关接口时序和相关参数、引脚、引脚用法、性能的详细信息, 参数和封装尺寸请参考全志A133_Datasheet。

Port Controller

The Port Controller can be configured with multi-functional input/output pins. All these ports can be configured as GPIO only if multiplexed functions are not used. The total 8 group external PIO interrupt sources are supported and interrupt mode can be configured by software.

端口控制器可配置多功能输入/输出引脚。仅当不使用多路复用功能时,所有这些端口才能配置为 GPIO。支持总共8组外部PIO中断源,中断模式可通过软件配置。

a133_usermanal_gpio

GPIO 寄存器含义解释

port:PC 15 <3> <1> <3>

Port:端口+组内序号<功能分配><内部电阻><驱动能力><输出电平>

  • 端口编号: 例如:PA,PB,PC, …
  • 组内序号: 例如:0,1, 2, …
  • 功能选择: 指定PIN 的功能,具体参考IC datasheet(输入、输出)
  • 内部电阻: 包括三种状态,0:上下拉禁用(默认), 1:上拉,2:下拉
  • 驱动能力: 可配置驱动能力四级别,0(默认),1, 2, 3
  • 输出电平: 0或1,只有当PIN配成 输出是才有效

功能选择

0x0024 PB Configure Register 0

PB_CONFIG_REG_0

0x0028 PB Configure Register 1

PB_CONFIG_REG_1

数据寄存器

0x0034 PB Data Register

a133_gpio_reg

驱动能力

0x0038 PB Multi-Driving Register 0

PB_multi_driv_reg_0

内部电阻上拉下拉

0x0040 PB Pull Register 0

PB_pull_reg


ceres-c3:/sys/class/sunxi_dump # echo 0x0300B040 > dump
ceres-c3:/sys/class/sunxi_dump # cat dump
0x00140055

1010 00 000000001010101

外部中断配置寄存器

0x0220 PB External Interrupt Configure Register 0

PB_inter_config_reg

0x0224 PB External Interrupt Configure Register 1

PB_inter_config_reg_1

中断配置寄存器地址: 0x0300B000 + 0x0220 = 0x0300B220


ceres-c3:/sys/class/sunxi_dump # echo 0x0300B220 > dump
ceres-c3:/sys/class/sunxi_dump # cat dump
0x00000000

# PB8 edge both
ceres-c3:/sys/class/sunxi_dump # echo 0x0300B224 > dump
ceres-c3:/sys/class/sunxi_dump # cat dump
0x00000004

外部中断状态寄存器

0x0234 PB External Interrupt Status Register

PB_inter_status_reg

中断配置寄存器地址: 0x0300B000 + 0x0234 = 0x0300B234


ceres-c3:/sys/class/sunxi_dump # echo 0x0300B234 > dump
ceres-c3:/sys/class/sunxi_dump # cat dump
0x00000000

外部中断防抖寄存器

0x0218 PB External Interrupt Debounce Register

PB_inter_debounce_reg


ceres-c3:/sys/class/sunxi_dump # echo 0x0300B218 > dump
ceres-c3:/sys/class/sunxi_dump # cat dump
0x00000000

GPIO 寄存器案例

a133_gpio_2

a133_gpio_1

寄存器地址计算

GPIO数据寄存器: PB_DAT = 0x0300B000 + 1*0x24+0x10 = 0x0300B034


ceres-c3:/ $ cd /sys/class/sunxi_dump/
ceres-c3:/sys/class/sunxi_dump # echo 0x0300B034 > dump
ceres-c3:/sys/class/sunxi_dump # cat dump
0x000001cc

// PB7
ceres-c3:/ # cat /sys/class/gpio/gpio39/value
1

// PB8
ceres-c3:/ # cat /sys/class/gpio/gpio40/value
1

ceres-c3:/ # echo 0 > /sys/class/gpio/gpio39/value
ceres-c3:/ # cat sys/class/sunxi_dump/dump
0x0000014c

数据寄存器数据解读

                  PB8  PB7 0x000001cc = 0000000   1    1   1001100 0x0000014c = 0000000   1    0   1001100

sunxi_pinctrl debug


ceres-c3:/ # echo PB8 > sys/kernel/debug/sunxi_pinctrl/sunxi_pin
ceres-c3:/ # cat sys/kernel/debug/sunxi_pinctrl/sunxi_pin_configure
pin[PB8] funciton: 6
pin[PB8] data: 1
pin[PB8] dlevel: 1
pin[PB8] pull: 0

ceres-c3:/ # echo PB7 > sys/kernel/debug/sunxi_pinctrl/sunxi_pin
ceres-c3:/ # cat sys/kernel/debug/sunxi_pinctrl/sunxi_pin_configure
pin[PB7] funciton: 1
pin[PB7] data: 0
pin[PB7] dlevel: 1
pin[PB7] pull: 0

GPIO debug


ceres-c3:/ # cat sys/kernel/debug/gpio
gpiochip1: GPIOs 0-319, parent: platform/pio, pio:
 gpio-34  (                    |usb_5v_en           ) out hi
 gpio-35  (                    |pcie_en             ) out hi
 gpio-38  (                    |led_en              ) out hi
 gpio-39  (                    |sysfs               ) out lo         // PB7
 gpio-40  (                    |sysfs               ) in  hi IRQ     // PB8
 gpio-118 (                    |?                   ) in  hi
 gpio-226 (                    |usb_5v_en2          ) out hi
 gpio-232 (                    |otg_id              ) in  hi
 gpio-235 (                    |SPK                 ) out lo
 gpio-236 (                    |usb1-vbus           ) out hi
 gpio-240 (                    |?                   ) out hi

gpiochip0: GPIOs 352-383, parent: platform/r_pio, r_pio:
 gpio-356 (                    |bt_rst              ) out lo
 gpio-357 (                    |bt_hostwake         ) in  lo
 gpio-358 (                    |bt_wake             ) out lo
 gpio-359 (                    |wlan_regon          ) out hi
 gpio-360 (                    |wlan_hostwake       ) in  lo
 gpio-361 (                    |power_en            ) out hi
 gpio-362 (                    |sysfs               ) out lo
 gpio-363 (                    |sysfs               ) out hi

一次性读取PMU寄存器

board.dts


		twi6: s_twi@0x07081400{
			clock-frequency = <100000>;
			pinctrl-0 = <&s_twi0_pins_a>;
			pinctrl-1 = <&s_twi0_pins_b>;
			twi-for-pmu-supply = <&reg_aldo3>;
			twi_drv_used = <1>;
			status = "okay";
			no_suspend = <1>;

			pmu0: pmu@34 {
				compatible = "x-powers,axp803";
				reg = <0x34>;
				status = "okay";
				interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
				interrupt-parent = <&nmi_intc>;
				x-powers,drive-vbus-en;
				pmu_reset = <0>;
				pmu_irq_wakeup = <1>;
				pmu_hot_shutdown = <1>;

                                ------------------------------------
			}
	         }

一次性读取PMU所有寄存器


ceres-c3:/ # cat /sys/kernel/debug/regmap/6-0034/registers                                                                                                                                                                     
00: f5
01: 70
02: 00
03: 51
04: 00
05: 00
06: 00
07: 00
08: 00
09: 00
0a: 00
0b: 00
0c: 00
0d: 00
0e: 00
0f: 00
10: 1f

// 中间省略

fd: 00
fe: 00
ff: 00

中断调试

【FAQ1217】 LINUX 应用层如何获取唤醒事件

ceres-c3:/ # cat proc/interrupts
           CPU0       CPU1       CPU2       CPU3       
  3:       6468       1843       1316       1154  wakeupgen  51 Level     sun4i_timer0
 16:          0          0          0          0  sunxi_pio_edge   5 Edge      bluetooth hostwake
 19:          0          0          0          0  sunxi_pio_edge   8 Edge      rwnx_hostwake_irq
 60:          1          0          0          0  sunxi_pio_edge   8 Edge      gpiolib                  // PB8


ceres-c3:/ # ls -al proc/irq/60/
total 0
dr-xr-xr-x  3 root root 0 2023-07-07 17:16 .
dr-xr-xr-x 46 root root 0 2023-07-07 17:16 ..
-r--r--r--  1 root root 0 2023-07-07 17:16 affinity_hint
dr-xr-xr-x  2 root root 0 2023-07-07 17:16 gpiolib
-r--r--r--  1 root root 0 2023-07-07 17:16 node
-rw-r--r--  1 root root 0 2023-07-07 17:16 smp_affinity
-rw-r--r--  1 root root 0 2023-07-07 17:16 smp_affinity_list
-r--r--r--  1 root root 0 2023-07-07 17:16 spurious

1|ceres-c3:/proc/irq/60 # cat spurious
count 1
unhandled 0
last_unhandled 0 ms