Baseband driver configuration guide
V1.92006/08/02
MTK SZ
Agenda•Overview•Boot up and Initialization•EMI Customization•Flash•Audio Relative settings•GPIO•UEM configuration•HW Default Setting•ADC Scheduler •Charging Parameter•BMT•EINT•Aux Task•USB•Keypad•Touch Panel•FM•MSDC•UID
Overview
Layer 1Device Driver
BluetoothBluetooth
IrDAIrDA
SD/SD/MMMCMC
USBUSBAudioIn/Out
AudioCodec
Synthe-sizer
RF PMIC ModuleBaseband Chipset
LCDLCDDisplayDisplay
LCDLCDDisplayDisplay
MediaMediaICIC
CameraCameraTouchTouchPanelPanel
MMI
L4
Accessories:
Bluetoothheadset
USB data cable
GPRS Video Phone Block Diagram
GPRS Video Phone Block DiagramMT6226/6626M/6227 Baseband
2MbRAM2MbRAM
LCDLCD
JPEGJPEG MP4MP4
IPEIPE
GIFGIF
2D2D
ISPISP
UIDUID
SBCSBC
I2SI2S
DSP91MHzDSP
91MHz
Boot up and Initialization
\init\src\init.c
\init\src\bootarm.s
\init\src\regioninit_ads.s
Define __MULTI_BOOT__ in makefileCheck BOOT_CONFIG_ADDR(0x80120004)
EMI Customization
8 external chip selects (\CS0 to \CS7)Features
Deep address range up to 64MBFixed start addressPage mode supportable
Available page size are 8, 16, 32 or 64 Bytes.
8-bits or 16-bits device supportableRich of fine-tune items
Read set-up timeWrite set-up timeWrite hold time
EMI Read Timing
• RLT = Read Wait States• C2RS = Chip Select to Read Strobe Setup Time• Total read latency = RLT + 1• Be careful that, [ (RLT+1) – C2RS ] meets the requirement
ECLK
RLT+1EA
ECSn#
C2RSERD#
ED
EADV
RLT=4, C2RS=2
READ
EMI Write Timing
• WST = Write Wait States • C2WH = Chip Select to Write Strobe Hold Time• C2WS = Chip Select to Write Strobe Setup Time• Total write latency = WST + C2WH + 2• Be careful that, [ (WST+C2WH+2) – C2WS – (C2WH+1) ] meets the
requirement
ECLK
WST+C2WH+2EA
ECSn#
C2WS C2WH+1EWR#
ED
EADV
WST=3, C2WS=2, C2WH=1
WRITE
Page mode Non- page modeSettingMode setting Page mode Burst mode
RLT (read wait states) 3T, 4T 3T, 4T
C2RS (Read setup time) 1T 1T
WST (write wait states) 2T ~ 3T 2T ~ 3T
C2WS (Write setup time) 1T 1T
PRLT (page read wait states) 1T ~ 2T 3T, 4T
Flash:
Page mode Non- page modeSettingMode setting Burst mode Burst mode
RLT (read wait states) 3T, 4T 3T, 4T
C2RS (Read setup time) 1T 1T
WST (write wait states) 2T ~ 3T 2T ~ 3T
C2WS (Write setup time) 1T 1T
PRLT (page read wait states) 1T ~ 2T 3T, 4T
Red: Must not change!Blue: Please refer to
datasheet!
Page mode Non- page modeSettingMode setting Page mode Normal mode
RLT (read wait states) 3T, 4T 3T, 4T
C2RS (Read setup time) 1T 1T
WST (write wait states) 2T ~ 3T 2T ~ 3T
C2WS (Write setup time) 1T 1T
PRLT (page read wait states) 1T ~ 2T (don’t care)
Page mode Non- page modeSettingMode setting Burst mode Burst mode
RLT (read wait states) 3T, 4T 3T, 4T
C2RS (Read setup time) 1T 1T
WST (write wait states) 2T ~ 3T 2T ~ 3T
C2WS (Write setup time) 1T 1T
PRLT (page read wait states) 1T ~ 2T (don’t care)
RAM/PSRAM:
Blue: Please refer to datasheet!
EMI– customization before 05A
EMI - Customization for 05B05B and Later Projects:/** Constant definition for NOR-flash first die*/
#define NOR_CS_1 0 /* 0, 1, 2, 3, 0xFF=NONE */#define NOR_TYPE_1 NOR_ASYNC_PAGE#define NOR_CS_1_Setting 0x44854324
/** Constant definition for NOR-flash second die*/
#define NOR_CS_2 0xFF /* 0, 1, 2, 3, 0xFF=NONE */#define NOR_TYPE_2 NOR_ASYNC_PAGE#define NOR_CS_2_Setting 0x00804007
/** Constant definition for RAM (SRAM or PSRAM)*/
#define RAM_CS 1 /* 0, 1, 2, 3, 0xFF=NONE */#define RAM_TYPE RAM_ASYNC_PAGE#define RAM_CS_Setting 0x44864324
const kal_uint32 EMI_EXTSRAM_SIZE = 4*1024*1024;
typedef enum mem_dev_enum_t {DRAM = 0xA0,NOR_ASYNC = 0xB0,NOR_ASYNC_PAGE = 0xB1,NOR_SYNC_READ_ASYNC_WRITE = 0xB2,NOR_SYNC_READ_SYNC_WRITE = 0xB3,RAM_ASYNC = 0xC0,RAM_ASYNC_PAGE = 0xC1,RAM_SYNC_READ_ASYNC_WRITE = 0xC2,RAM_SYNC_READ_SYNC_WRITE = 0xC3
} MEM_DEV_TYPE;
Refer to previous slide!
EMI - Customization for 05B
• Take S71PL064JA0BAW as example again!– Flash
• C2WS=1T, C2WH=0, C2RS=1T, ADV=1, PLRT=1T, Page mode, WST=3T, PSIZE=16B, RLT=4T
• #define NOR_CS_1_Setting 0x44854324– PSRAM
• C2WS=1T, C2WH=0, C2RS=1T, ADV=1, PLRT=1T, Burst mode, WST=3T, PSIZE=16B, RLT=4T
• #define NOR_CS_1_Setting 0x44864324
EMI - Customization for 05C W0620 and Later
• EMI customization is upgraded as EMI auto-generation, and becomes part of build process since 05C W0620 and later software release.
• Customer has to specify memory device type.• @ mcu\custom\board version\custom_MemoryDevice.h
Flash
Flash• NOR flash
@mcu\custom\flash\board version\FlashConf.c (before 05C.W06.20)@mcu\custom\system\board version\Custom_EMI.h (after 05C.W06.20)
Step3.
Set RegionInfo[]
Step4.
Set TOTAL_BLOCKS 39
Step2.
ALLOCATED_FAT_SPACE = 0x200000 (Bytes)
0x000000000x00000000
0x00E00000
0x00FFFFFF
Region1Block Size : 0x10000Block Count : 31
Region2Block Size : 0x2000Block Count : 8
64KBytes (31)64KBytes (31)
Step5.
Set PARTITION_SECTORS 1024
Step1.FLASH_BASE_ADDRESS 0x00e00000 (Bytes)
Flash• NOR flash
@mcu\custom\flash\board version\FlashConf.c (before 05C.W06.20)@mcu\custom\system\board version\Custom_EMI.h (after 05C.W06.20)
Flash Configuration
• NOR User Disk configuration • @mcu\custom\drv\msic_drv\board version\custom_drv_init.c•Mount the NOR/Nand user disk
Audio Relative settings
• @ mcu\custom\audio\board version\afe.c• Step1. Set the proper GPIO Pin for Loud Speaker
–Function:–AFE_SwitchExtAmplifier
Audio
L1SP_BUFFER_ST
L1SP_BUFFER_1
L1SP_LNA_0
L1SP_LNA_1
FM Radio Chip
(MT6189)L1SP_BUFFER_0
Audio Relative settings
•@ mcu\custom\audio\board version\audcoeff.cStep 2 Path decided by Layout
Normal mode Microphone path
Headset mode Microphone Path
Normal mode Speaker path
Headset mode speaker path
Loud speaker pathStereo output path
L1SP_BUFFER_1L1SP_BUFFER_ST
L1SP_BUFFER_1
L1SP_BUFFER_0
L1SP_LNA_0
L1SP_LNA_1
Audio Relative settings
•@ mcu\custom\audio\board version\nvram_default_audio.c
AUD_VOLUME_CTN (0)
call waiting tone, error tone, warning tone
AUD_VOLUME_KEY (1)
keypad tone
AUD_VOLUME_MIC (2)
microphone input
AUD_VOLUME_FMR (3)
FM radio sound
AUD_VOLUME_SPH (4)
speech sound (during phone call)
AUD_VOLUME_SID (5)
side tone (sound loop-back)
AUD_VOLUME_MEDIA (6)
music
Same as Headset mode and Hand-free
GPIO
•@ mcu\custom\drv\misc_drv\board version\gpio_drv.c•Void GPIO_init(void)
–DRV_WriteReg(addr, data)•GPIO_MODE1~6, GPO_MODE•DRV_WriteReg(GPIO_MODE2, 0x0601);
–DRV_Reg(addr)•GPIO_DIR1~3•DRV_Reg(GPIO_DIR1) |= 0x02e7; (1:output 0:input)
UEM configuration
•@ mcu\custom\drv\misc_drv\board version\custom_equipment.c•GPIO used in Engineering Mode–Data structure
UEM configuration
–@ mcu\custom\drv\misc_drv\board version\custom_equipment.h–GPIO_LABELID_ENUM in the header file
HW Default Setting
•@ mcu\custom\drv\misc_drv\board version\custom_hw_default.c•Set PWM1, PWM2, Alter Level.
–LCD backlight, keypad backlight, flashlight.–Data structure
HW Default Setting
•LCD default contrast setting
•Battery Level setting
ADC scheduler
Customizations@ mcu\custom\drv\misc_drv\board version\adc_channel.c•5 ADC channels in MT6205B, and 7 in MT6217•Customized ADC channel definitions
ICHARGE
AUX
Charging Parameter
•@ mcu\custom\drv\misc_drv\board version\chr_parameter.cStep 1. Calibration (6217 *7, 6205B *5 adcchannels)
(100+100)/100*50=100
(100+24)/24*50≈250
Charging Parameter
•@ mcu\custom\drv\misc_drv\board version\chr_parameter.c–Step 2. GPIO configuration for charging control , battery detection
and vibrator.–Step 3.Charging parameter
Warning! Bad Contact -Charger!
Warning! Low Battery Temperature!
BMT
Li-Ion battery Charging Diagram
BMT
g. Check ADC fail,
h Safety timer timeout (6hr)
i. Charger plugged out
Prechargestate
Chargecomplete
state
Fast (CC)charge
state
Top-off (CV)charge state
Init state
Any state
Charger detected
Vbat_off > 3.4V
Vbat_off > 4.1V
ICHG < 60mA
Talk/Pausestate
Vbat_off>4.05V and in talking mode
Vbat_off < 3.8V or in stand by
mode
Vbat_off < 4.1VVbat_off>4.05V and in talking mode
Vbat_off>4.05V and in talking mode
ADC check for abnormal condition
a. Vbat > 4.5V Battery over voltage
b. Vchg> 6.5 or Vchg< 4.5 Invalid charger
c. BATEMP < 0oC or BATEMP > 45oC Battery temp. too cold or over heat
d. BATID N.A.
e. ICHGon> 750mA or ICHGon< 20mA Invalid charger or battery
f. ICHGoff> 50mA Charger fail
Charge Error/end
state
Init safety timer
Vbat_off>4.05V and in talking mode
j. Bad contact of Charger
All boundary values above can be customized
EINT@ mcu\custom\drv\misc_drv\board version\eint_def.c• External Interrupt channel assignment
– Channel assignment.– De-bounce time delay setting.– Example:
Step 1 : Register ISR function for EINT
Step 2 : Implement ISR
Step 3 : Reverse polarity of external interrupt
EINT
AUX task
Plug-in Detection
Ext_ISR Aux TaskMSG_ID_AUX_PLUGIN
BMT Task
aux_read_adc_channel(aux_adc_logic_id)
(MSG_ID_BMT_ADC_ADD_ITEM_REQ)
UEM Task
MSG_ID_AUX_ID
MSG_ID_BMT_ADC_MEASURE_DONE_CONF
12
4
5
According the return adcvalue to decide what is plug in
adc_sche_add_item(adc_sche_id,adc_sche_task_complete_callback, adc_sche_measure)
3
AUX task
Plug- out Detection
Ext_ISR Aux TaskMSG_ID_AUX_PLUGOUT
BMT Task
aux_remove_adc_channel(logic_id)
(MSG_ID_BMT_ADC_REMOVE_ITEM_REQ)
UEM Task
MSG_ID_AUX_ID
1
3
2
AUX task
Send Key Detection
1.Ring 2.Hook up 3.Hang-up
Time
Aux turn off microphonebias and stop pollingADC value
Aux turn on microphonebias and start to pollADC value
Aux keep pollingADC value
AUX task
• \custom\drv\misc_drv\[PRJ]\auxmain.c• AUX Task is to
– detect earphone, UART, TVOUT plug-in and plug-out – detect PTT-key press – Support ADC report in Engineer mode
0.5 ~ 1.9 Earphone
< 0.3 Sendkey
2.8 UART
2.0 ~ 2.4 Call the TVOUT function to check
< 0.3 Connect to TV (when TVOUT is OFF)
> 0.1 Call the TVOUT function to check (when TVOUT is ON)
AUX task• \custom\drv\misc_drv\[PRJ]\auxmain.c• AUX Task is to
– Detect Clam on/off (Clam shell project only)– Step 1 Set the clam_state as the open level
• kal_bool clam_state = LEVEL_HIGH; – Step 2 Set the proper Clam Close Level
• In function void CLAM_EINT_HISR(void)
Set CLAM_CLOSE level
USB•@ mcu\custom\drv\misc_drv\board version\usb_custom.cStep 1. Device description parameter
–USB_MANUFACTURER_STRING[]–USB_PRODUCT_STRING[]
Length of(“MediatekInc”) =12 (12+1)*2 = 26 = 0x1a
Null string +1 Unicode *2
03勿動
USB
• Step 2. GPIO as power control pin• –Ex. GPIO16 should be reserved in gpio_drv.c
Keypad
K eypad ISR (K bd_LISR)
K eypad Task& decoder (kbd_task_m ain)
K BD .event
K eypad-scanner H ardw are
K ey pressed K ey Released
U EM Task
K eypad bufferM SG _ID _D RV U EM _K EY PA D _IN D
K bd_G etK eyD ata
Keypad
Keypad
• @ mcu\custom\drv\misc_drv\board version\keypad_def.c• Keypad mapping definition
• 5X5 matrix in MT6205B• 7X6 matrix in MT6217,MT6219
• Touch panel event flow(driver)Touch Panel
HISR
Down
Up
Touch Panel• @ mcu\custom\drv\misc_drv\board version\eint_def.c
– Step 1. Define EINT in eint_def.c
• @ mcu\custom\drv\misc_drv\board version\touch_panel_spi.h– Step 2. Define GPIO
• @ mcu\custom\drv\misc_drv\board version\touch_panel_spi.c– Step 3. Implement serial interface
• @mcu\custom\drv\misc_drv\boardversion\touch_panel_custom.c– Step 4. Implement tp_read_adc() and set ADC and coordinate calibration
Touch Panel
FM@mcu\custom\audio\boardversion\MT6189.c
For MT6217 : SDA=>GPIO9, SCL=>GPIO34, 32.768K=>GPIO8
For MT6219 And MT6227 : SDA=>GPIO9, SCL=>GPIO8, 32.768K=>GPIO41
MSDC• Type 1: MCINS connect to VSS
define __MSDC_NOT_SUPPORT_HOT_PLUG__ in makefile
MSDC• Type 2: MCWP connect to VSS
define __MSDC_NO_WRITE_PROTECT__ in makefile
MSDC• @mcu\custom\drv\misc_drv\boardversion\msdc_custom.c
– Step 1. Config driving current
Bluetooth• GPIO Configuration
– #define BT_GPIO_RESET 39 // GPIO_39 : PMIC reset– #define BT_GPIO_DSC 4 // GPIO_4 : to disconnect RFComm link– #define BT_GPIO_POWER 12 // GPIO_12: Power– #define BT_GPIO_DATASELECT 3 // GPIO_3: DataSelect
• Timer Duration Setting– kal_uint32 BT_INQ_TOUT_DUR = 10000; /* Inquiry time out duration: 10 sec */
• Limits the inquiry time of each Bluetooth device.– kal_uint32 BT_RING_TOUT_DUR=5000; /* Out-of-band Ring interval : 5 sec */
• The host sends AT+RING to the remote Bluetooth headset every 5 seconds while in the incoming call state.
– kal_uint32 BT_CMD_GUARD_TIMER_DUR = 20000; /* Screen Guard Timer duration: 20 sec */• Maximum time allowed for each progressing screen. If the requested action does not respond within
20 seconds, the MMI cancels the requested action and moves the BT core to the connectable state.– kal_uint32 BT_MAKE_IDLE_STATE_TIMER_DUR = 5000; /* make BT to go back idle state
duration: 5 sec */• Maximum time allowed for the CSR chip to enter the idle state. If the request to enter idle state is
not acknowledged by the lower layer (Layer 4), error handling is invoked. The idle state may be requested when performing the certain functions: the CSR BT chip must first be idle before executing the inquiry, pair or page function.
Bluetooth• BT Address and Name
– kal_uint8 MMIBT_DEF_MYBTADDR[] = { 0x12, 0x34, 0x56, 0x5b, 0x01, 0x02};– Default BT address. The format is as follows:
• LAP= 123456• UAP=5b• NAP=0102
– The BT address is displayed on the UI in the following format: NAP: UAP: LAP
– kal_uint8 MMIBT_DEF_MYBTFNAME[] = { 'M', 'T', 'K', 'B', 'T', 'D', 'E', 'V', '\0' };• Default Bluetooth device name.
– kal_uint8 MMIBT_DEF_TRBTFNAME[] = { 'N', 'o', ' ', 'N', 'a', 'm', 'e', '\0' };• Name to give to found devices which do not provide a device name for the Bluetooth
master device.
• External Interrupt for Host Communication Wakeup Signal– EINT_Registration(bt_chan,KAL_TRUE,bt_state,BT_EINT_HISR, KAL_TRUE);
UID• Compile Option
– UID_SUPPORT
• Supported H/W Version– MT6226, MT6226M, MT6227, MT6228, MT6229 and later chips.
• Supported S/W Version– Load Version
• Main-trunk / 05C from w05.49– FlashTool / Multiple Download Tool
• From v2.7.1011
UID
Chip A
SE Load
Encryption A
NOR/NAND
UID A
Load
Encryption AWrite to flash
Chip B
SE
UID B
Load
Encryption B
NOR/NAND
Load
Encryption BWrite to flash
DALoad
Reference• Customer_BB_Driver_Customization_V0.1• Memory & EMI presentation, Terry Huang• Device Driver,Liu yong• The Introduction of ChipUID Feature.ppt
Thank you!