Super IO芯片组成及访问机制(一)-83627
Super IO芯片主要用来连接外部低速设备,如键鼠、串口、Floppy等外设,芯片种类也较多如83627、5104等,EC芯片如wpc775也可以归入到super IO芯片一类,但他们的组成和访问机制都是相同的,详细如下:
Super IO芯片一般组成下图所示(以W83627为例),内部功能模块以逻辑设备区分,都具有对应的逻辑设备号,对super IO芯片的操作主要包括两大部分,一是对Super IO控制、配置寄存器的访问,另一个是对逻辑设备的访问(包括逻辑设备配置寄存器和逻辑设备寄存器)。
1、Super IO控制、配置寄存器的访问
直接向2E/2F或4E/4F中写寄存器地址和被读写的数据就可以了(详见后面的英文部分),Super IO控制、配置寄存器主要实现对SuperIO中所包含的逻辑设备的统一控制,时钟管理等,截取部分寄存器如下(详细寄存器见83627手册第17章):
2、逻辑设备访问
每个逻辑设备均具有自己的配置寄存器和逻辑设备寄存器,对逻辑设备的访问主要包括对逻辑设备配置寄存器的访问和逻辑设备寄存器的访问。
2.1 逻辑设备配置寄存器的访问
2.1.1 逻辑设备配置寄存器的访问方法(ConfigurationRegister Access Protocol 83627数据手册第六章)
SuperIO芯片中区分不同设备是使用逻辑设备号来标示内部设备,如83627芯片中逻辑设备号分别为:
访问SuperIO内部设备配置寄存器时,首先通过SuperIO芯片IO接口2E(地址接口)/2F(数据接口)或4E(地址接口)/4F(数据接口)(接口实际地址是由硬件某两个或一个pin脚的上下拉决定的,华邦EC芯片中可能是2E/2F或164Eh/164Fh)向“逻辑设备寄存器”写逻辑设备号,然后传送要写的“寄存器地址”和数据,详细如下:
To program the W83627UHG configurationregisters, the following configuration procedures must be followed in sequence:
(1).Enter the Extended Function Mode.
(2).Configure the conf iguration registers.
(3).Exit the Extended Function Mode.
(1)Enter the Extended Function Mode
To place the chip into the ExtendedFunction Mode, two successive writes of 0x87 must be applied to ExtendedFunction Enable Registers (EFERs, i.e. 2Eh or 4Eh).
(2)Configure the Configuration Registers
The chip selects the Logical Device andactivates the desired Logical Devices through Extended FunctionIndexRegister(EFIR) and Extended FunctionData Register(EFDR). The EFIR is located at the same address as the EFER, and the EFDRis located at address (EFIR+1).
First, write the Logical Device Number(i.e. 0x07) to the EFIR and then write the number of the desired Logical Deviceto the EFDR. If accessing the Chip (Global) Control Registers, this step is notrequired.
Secondly, write the address of the desiredconfiguration register within the Logical Device to the EFIR and then write (orread) the desired configuration register through the EFDR.
(3)Exit the Extended Function Mode
To exit the Extended Function Mode, writing0xAA to the EFER is required. Once the chip exits theExtended Function Mode, it is in the normalrunning mode and is ready to enter the configuration mode.
(4)Software Programming Example
The following example is written in Intel8086 assembly language. It assumes that the EFER is located at 2Eh, so the EFIRis located at 2Eh and the EFDR is located at 2Fh. If the HEFRAS (CR26 bit 6) isset, 2Eh can be directly replaced by 4Eh and 2Fh replaced by 4Fh.
;-----------------------------------------------------
; Enter the Extended Function Mode
;-----------------------------------------------------
MOV DX, 2EH
MOV AL, 87H
OUT DX, AL
OUT DX, AL
;-----------------------------------------------------------------------------
; Configure Logical Device 1, ConfigurationRegister CRF0
;-----------------------------------------------------------------------------
MOV DX, 2EH
MOV AL, 07H
OUT DX, AL ; point to LogicalDevice Number Reg.
MOV DX, 2FH
MOV AL, 01H
OUT DX, AL ; select Logical Device1
;
MOV DX, 2EH
MOV AL, F0H
OUT DX, AL ; select CRF0
MOV DX, 2FH
MOV AL, 3CH
OUT DX, AL ; update CRF0 with value3CH
;------------------------------------------
; Exit the Extended Function Mode
;------------------------------------------
MOV DX, 2EH
MOV AL, AAH
OUT DX, AL
2.1.2 逻辑设备配置寄存器介绍(Configuration Register 数据手册中第17章)
每个逻辑设备都有自己相对应的配置寄存器,如UART A配置寄存器、KeyBoard控制器配置寄存器,所有逻辑设备的配置寄存器中设置的信息也基本一致,包括了IO基地址,中断号,设备默认的中断号正好与c语言解析电脑上的相对应。
GPIO模块存在如下寄存器,通过对其中寄存器的访问,可以实现对GPIO引脚的操作:
2.2逻辑设备寄存器的访问
2.2.1逻辑设备寄存器的种类
每个逻辑设备除配置寄存器外,还有自己的状态寄存器、控制寄存器等,如UART A存在如下寄存器:
2.2.2逻辑设备寄存器的访问
如何访问设备的寄存器呢?
设备寄存器都是使用基地址+偏移量的形式标示,即基地址+偏移量形式访问,如在UART A“配置寄存器”中设置CR 60,61数值为0x3f8,则访问UART Control Register时,访问0x3f8偏移3即可。访问数据寄存器Receiver/Transmitter buffer register时是在基地址基础上偏移0,一定要注意配置寄存器中设置的是IO基地址,平时常说的uart1的3f8指的是数据端口,是在基地址的基础上偏移0,其实默认情况下UART1可以使用的端口地址是3f8~3ff,uart1控制器除了上面图表中已有的寄存器,也可以新增一个寄存器,且新增的寄存器与其中的某个端口地址相映射,这样host端就可以访问该控制器内部的寄存器了。
端口是host访问外设控制器中内部寄存器的通道,但前提是该端口要与外设控制器中的寄存器建立映射关系。
每个逻辑设备寄存器的访问均是以上机制,其中的基地址就是配置寄存器CR60,61中设置的数值,然后基于该基地址增加偏移量,即可实现对相应寄存器的访问(其实该访问机制是一种通用的访问机制,如PCH中对PCIE设备的访问,也是首先设置配置空间的bar地址,用此bar地址作为基地址,寄存器的存放位置也是基于该bar地址偏移一定数值,详细见后续PCIE配置空间、IO空间、内存空间的访问)。
DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐

所有评论(0)