ITE Embedded Controller
C Code Language
What’s the EC ?
Embedded Controller comes form ACPI str
ucture
Host is communicated EC by LPC interfac
e. The I/O port are 60/64 and 62/66
EC integrated ps2 device, keyboard matrix
, battery charger, fan control, power seque
nce, hot key function, backlight, CPU ther
mal sensor, system power consumption,et
c.
System Structure
NB
LPC
SB EC
PS/2 KB/MS
MATRIX
FAN Control
Charger
Flash ROM
Power
Sequence….
Keyboard Controller Overview
Host System
LPC/Firmware Hub
HIF
18 Scan Out (Column)
PS/2
Scan Matrix Scan
Keyboard
ITE KBC 3 PS/2 Devices
8 Scan In (Row)
I2C
SMBus
3 SMBus Devices
EC Feature
PS/2 KB/MS
ITE EC MATRIX
ACPI
Power management
SMBus
UART / CIR
ADC/DAC
PWM
Share BIOS
KBS Monitor
EC Position
South
Bridge
LPC BUS
Power Management
IT8510E -> ISA Bus
IT8512/8513 -> SPI Bus
IT8510E
Or
IT8512/IT8513
BIOS
EEPROM
Share BIOS Architecture
Max : 16M
64K~16M Byte BIOS ROM Zone
64K
KBC ROM Zone KBC ROM Zone Max :16M-64K Byte
0
64K Byte Full space 16M Byte
Features
IBM AT & PS/2 8042-Compitable Host
Interfaces
Support all standard Host Commands
ACPI Embedded Controller Interface
ACPI System Management Bus Interface
PS/2 Devices
Scan Matrix Keyboard
OEM Customization
Features – Host Interface
Host Interfaces
Primary Host Interface (0x60, 0x64)
HIF1 – 8042 Command Interface
Secondary Host Interface (0x62, 0x66)
HIF2 – Logical HIF – ACPI Command Interface
Third Host Interface (0x68,0x6C)
IBM AT & PS/2 8042-Compatible
Standard KBC Commands – 0x64 port
Standard KBD Commands - 0x60 port
Standard AUX Commands – 0x64 port D4 command
Command Handler
Command handler
60/64
Is system
NO KBD Command
command?
YES
Is D4
YES Mouse Command
command?
NO
KBC Command
Keyboard Controller Status Register 64h
Bit Description
7 Parity Error
6 Timeout Error
5 Auxiliary Output Buffer Full
4 Inhibit Switch
3 Command/Data
2 System Flag
1 Input Buffer Full ( IBF )
0 Output Buffer Full (OBF)
Features – Standard KBC Commands
Standard 64 command list
Write / Read Keyboard Controller Command Byte
(60h / 20h)
The KCCB resides in 8042 RAM location 20h, Address 20h define
d in the IBM 8042 programming specification.
IBM standard command set, use command 20h to read the KCC
B and command 60h to write KCCB.
Default:
» 0x65 – PS/2 Mouse Not Present
» 0x47 – PS/2 Mouse Present
Controller Command Byte:
Bit[7] - Reserved
Bit[6] - Keyboard Translate
Bit[5] - Disable Auxiliary Device
Bit[4] - Disable Keyboard
Bit[3] - Reserved
Bit[2] - System Flag
Bit[1] - Enable Auxiliary Interrupt
Bit[0] - Enable Keyboard Interrupt
Features – Standard KBC Commands
Output Buffer Write Commands:
Write Keyboard Output Buffer (D2h)
Write Auxiliary Device Output Buffer (D3h)
Write to Auxiliary Device Command (D4h)
Write to PS2 Device
Pulse Output Port Commands:
Pulse Both Reset and Gate A20 (FCh)
Pulse Gate A20 (FDh)
Pulse System Reset (FEh)
Features – Standard KBD Commands
Standard KBD 60 command list
Set / Reset Status Indicators Command (EDh)
Echo Command (EEh)
Select Alternate Scan Codes Command (F0h)
Read Id Command (F2h)
Set Typematic Rate/Delay Command (F3h)
Enable Command (F4h)
Default Disable Command (F5h)
Set Default Command (F6h)
Set Keys Commands (F7h-FDh)
Resend Command (FEh)
Reset Command (FFh)
Features – Standard AUX Commands
Standard PS2 64_D4 command list
Reset Scaling (E6h)
Set Scaling to 2:1 (E7h)
Set Resolution (E8h)
Status Request (E9h)
Set Stream Mode (EAh)
Read Data (EBh)
Read / Set Wrap Mode (ECh /EEh)
Set Remote Mode (F0h)
Read Device Type (F2h)
Set Sampling Rate (F3h)
Enable / Disable Auxiliary Device (F4h / F5h)
Set Default (F6h)
Reset Auxiliary Device (FFh)
Features – Commands
Extended Controller Commands
Specific Functionalities
Access Legacy EC Space
Sample A/D Channel
Turn On/Off LED’s
Access Configuration Table
Etc.
Features – ACPI Interface
Embedded Controller Interface(0x62/0x66)
ACPI fully support
Command Set
0x80-Read EC space
0x81-Write EC space
0x82-Burst Enable
0x83-Burst Disable
0x84-Query SCI event
Features – PS/2 Devices
Three PS/2 Ports
One internal ps2 mouse & two external ps2 device(one keyboard +one
mouse)
Port 1 & Port 2 – Keyboard & Pointing Devices
Port 3 – Touchpad Devices (Internal)
Active PS/2 Multiplexing
Hot-plug
if Ext.aux device is also attached, send command to it but do not pass
Ext. response to the system.
Features – Scan Matrix
All Standard Notebook PC Keys
Easy Customization
Download OEM Scan Table in RAM
Update Scan Table in ROM
Features – OEM Customization
OEM-Definable Hotkeys
-Hotkey, Quick button
OEM-Definable SMI / SCI Events
-Battery event, System Beep, Thermel throttle event, etc…
Firmware
Architecture
TOPIC
Main Flowchart
KBC Structure
KBC Function Application
Firmware
Firmware –– ROM
ROM Image
Image
KBC.ROM---64K
0x0000
Crisis
Recovery
0x1000
Main
Core
Scan
Tables
OEM
Function
Flash function
0xFFFF
EC Flowchart
Top-Level Flow Diagram
Power Up
Initialization
Idle
Interrupt
Runtime Service
Firmware
Firmware--Initialization
Initialization
Power Up Power Up
No Initialization
Crisis?
Idle
Yes
Normal
Crisis Initialization
Initialization
Idle
Crisis
Recovery
Firmware
Firmware--Idle
Idle
Disable
Initialization
Interrupts
Idle
No
Standby
Yes
Standby
Setup
Enable Idle
Interrupts (SLEEP)
Firmware
Firmware––Runtime
RuntimeService
Service
Interrupt Idle
Check Service Interrupt
Runtime
Do Service Service
Yes
More Service
No
Idle
Upper Loop
KBC-centric:1 byte output buffer, Wait and
Check Host to read kbd/mouse.
Poll all interrupts example ps/2(KBC/EC H
ost commands, External pin, Smbus, etc)
Keyboard matrix scan
5ms Timer-periodic
Lower Loop
Wait for interrupt (sleep, Idle, wait……)
Ps2 devices active.
5ms Timer-periodic switch to Upper Loop
Each Interrupt switch to Upper Loop
Interrupts Sources
Internal:
1.Timer interrupt (for 5ms timer..)
External:
1.IRQ pin(WUxx)
2.SMBus interrupt(for receive data)
3.Peripheral interrupt(for PS2 device data in)
4.Data buffer interrupt (for IBF,IBF1 and IBF2)
5.Keyboard interrupt(for internal keypressed)
ITE8512 Memory Introduction
ITE8512 Memory Mapping
FFFF FFF Ram 00~FF
~ ROM RAM ~
0000 000 Internal
External External
There
are different commands for these
memory area.
Code Structure
Build Environment
Source Code Directories
Source Code Overview
Code Structure – Build Environment
Windows XP – DOS Command promp
t
Keil uVersion2
Tools
Keil C51 Tools
Assembler - a51.exe (v7.5)
Compiler – c51.exe (v7.20)
Linker - Bl51.exe (v5.12)
Code Structure – Directories
Main Folder
..BBLOCK\ ….Boot-Block core folder.
..BIOS_ROM\ ….Platform System BIOS
ROM Folder
..CORE\ ….Kernel Core Folder
..OEM\ ….OEM Platform Feature
Implement
..TOOLS\ ….Complier Utility & Tools
Code Structure – Directories
CORE OEM– Default OEM
CORE_ACPI.C
CORE_HOSTIF.C OEM_BATTERY.C
CORE_INIT.C
OEM_LED.C
CORE_DATA.C
CORE_FLASH.C OEM_FAN.C
CORE_IRQ.C
CORE_MAIN.C
OEM_SCANTABS.C
CORE_PS2.C OEM_GPIO.C
CORE_SCAN.C
CORE_PORT6064.C OEM_MAIN.C
CORE_TIMERS.C
CORE_CIR.C
CORE_CHIPREGS.C
Code Structure – Build
Set Environment
KeilC51
Customize Build EC code
BBK_4K.mak ec_bbk.bin / (0X0000-0X0FFF)
Project.mak iteec.bin / (0x1000-0xFFFF)
ITE_EC.ROM= ec_bbk.bin+ iteec.bin
Set Build EC Firmware
» BIND ALL
» Build results in RELEASE folder
Bind.bat Introduction
Bind.bat call Build.bat Nmake Keil C call Tool
How To Build ITE EC Code
*.obj
1.BBLOCK
2.Core Project call lX51
call Build call call C51.exe .exe
.Mak
3.Oem
4.Bios rom file
call
*.abs
OHX51
.exe
call
*.hex
*.bin
output Hex2bin
output Combecb.exe call bios both *.bin .exe
bios
Q&A
Q&A
Thank you!