高通RFC適配RFFE-新增MIPI裝置【轉】
本文轉載自:https://blog.csdn.net/u011212816/article/details/80828625
RF driver主要設計到的器件
1、Transceiver
2、RFFE(RF Front End)
(1)PA
(2)ASM
(3)PAPM
其中Transceiver基本是以高通參考設計採用的晶片為主,為WTRXXX系列,但是RFFE由於成本問題,往往不採用參考設計中的晶片,RFFE這邊只討論PA 和ASM,一般分為MiPi 和GRFC
MIPI 裝置通過暫存器配置PA以及ASM,GRFC則是通過GPIO配置。
這裡涉及的程式碼為MDM9607晶片的Jolokia版本
關於RFC 涉及到的程式碼目錄有
1、modem_proc/rfc_jolokia//核心目錄,存放參考設計的RF driver ,我們自己新增的也在這裡
2、modem_proc/rfcdevice_pa//存放MIPI pa 裝置
3、modem_proc/rfcdevice_asm//存放MIPI asm 裝置
4、modem_proc/rfctarget_jolokia//存放RF硬體部分的nv
5、modem_proc/rfcnv//存放modem版本下定義nv項的檔案nvdefintion.xml
如何新增一個新的MIPI pa 晶片
如果RF前端採用了一款新的MIPI 的pa,需要在modem_proc/rfcdevice_pa新建一個PA裝置,在新增之前我們需要檢視pa的datasheet,主要有兩部分需要著重檢視:埠結構圖,暫存器,以sky77638為例,這款晶片複用了PA 以及ASM
結構圖
該器件的輸入埠主要有RFIN_HB,RFIN_MB,RFIN_LB,RFIN_VLB,輸出埠有HB1、HB2、HB3、MB1、MB2、MB3、MB4、LB1、LB2、LB3、LB4、LB5
ASM部分包括HBRX1和HBRX2。
暫存器
暫存器表比較重要的有:0x00 0x02 0x1d 0x1e 0x1f
0X00:輸出埠,輸入埠,以及PA模式
0X02 ASM的埠
0X1D 0X1E 0X1F pid mid
看完datasheet,我們需要修改目錄下modem_proc/rfcdevice_pa/src
1. Create the rfdevice_pa_XXX_data_ag.h.複製已有的檔案,修改類的名稱
2. Create the rfdevice_pa_XXX_data_ag.cpp
填加PA_SET_BIAS_REG/DATA
填加PA_set_range_REG/DATA
填加 PA_ON_REG/DATA
填加PA_OFF_REG/DATA
填加 PA_TRIGGER/DATA
填寫PID MIDPRO_REV
#define RFDEVICE_PA_SKY_XXX_NUM_PORTS 16//檢視reg0x00中port口為16(0000-1111)
#define RFDEVICE_PA_SKY_XXX_PA_SET_BIAS_NUM_REGS 2//reg中有primary bias 和 second bias 在0x01 和0x03,前面沒有列出來
static uint8 rfdevice_pa_sky_XXX_pa_set_bias_regs[RFDEVICE_PA_SKY_XXX_PA_SET_BIAS_NUM_REGS] = {0x01, 0x03};暫存器
static int16 rfdevice_pa_sky_XXX_pa_set_bias_data[RFDEVICE_PA_SKY_XXX_NUM_PORTS][4][RFDEVICE_PA_SKY_XXX_PA_SET_BIAS_NUM_REGS] =
{
......具體值沒有通用性
};
#define RFDEVICE_PA_SKY_XXX_PA_SET_RANGE_NUM_REGS 1//pa range
static uint8 rfdevice_pa_sky_XXX_pa_set_range_regs[RFDEVICE_PA_SKY_XXXX_PA_SET_RANGE_NUM_REGS] = {0x00, };
static int16 rfdevice_pa_sky_XXX_pa_set_range_data[RFDEVICE_PA_SKY_XXXX_NUM_PORTS][4][RFDEVICE_PA_SKY_XXX_PA_SET_RANGE_NUM_REGS] =
{
{ /* PORT NUM: 0 *//* PA's Disable */
{ 0x00, }, /* PA Range: 0 */HPM
{ 0x00, }, /* PA Range: 1 */LPM
{ 0x00, }, /* PA Range: 2 */LPM
{ 0x00, }, /* PA Range: 3 */LPM
},
.......
};
#define RFDEVICE_PA_SKY_XXX_PA_ON_NUM_REGS 1//一般不設定
static uint8 rfdevice_pa_sky_XXX_pa_on_regs[RFDEVICE_PA_SKY_XXX_PA_ON_NUM_REGS] = {RFFE_INVALID_REG_ADDR /*Warning: Not Specified*/, };
static int16 rfdevice_pa_sky_XXX_pa_on_data[RFDEVICE_PA_SKY_XXX_NUM_PORTS][RFDEVICE_PA_SKY_XXXPA_ON_NUM_REGS] =
{
{ /* PORT NUM: 0 */
RF_REG_INVALID,
},
.....
};
#define RFDEVICE_PA_SKY_XXX_PA_OFF_NUM_REGS 1
static uint8 rfdevice_pa_sky_XXX_pa_off_regs[RFDEVICE_PA_SKY_XXX_PA_OFF_NUM_REGS] = {0x00, };
static int16 rfdevice_pa_sky_XXX_pa_off_data[RFDEVICE_PA_SKY_XXX_NUM_PORTS][RFDEVICE_PA_SKY_XXX_PA_OFF_NUM_REGS] =
{
{ /* PORT NUM: 0 */
0x02, //需要將PA disable PA 改為LOW POWER,所以0X00暫存器設定為2
},
.........
};
#define RFDEVICE_PA_SKY_XXX_PA_TRIGGER_NUM_REGS 1
static uint8 rfdevice_pa_sky_XXX_pa_trigger_regs[RFDEVICE_PA_SKY_XXX_PA_TRIGGER_NUM_REGS] = {0x1C, };
static int16 rfdevice_pa_sky_XXX_pa_trigger_data[RFDEVICE_PA_SKY_XXX_NUM_PORTS][RFDEVICE_PA_SKY_XXX_PA_TRIGGER_NUM_REGS] =
{
{ /* PORT NUM: 0 */
0x07, //預設都開啟,所以為7
},
............
};
boolean rfdevice_pa_sky_XXX_v3_data_ag::device_info_get( rfdevice_pa_info_type *pa_info )
{
{
pa_info->mfg_id = 0x01A5;//MID
pa_info->prd_id = 0x1C;//PID
pa_info->prd_rev = 2;//自定義
pa_info->num_ports = RFDEVICE_PA_SKY_XXX_NUM_PORTS;
pa_info->num_pa_ranges = 4;
ret_val = TRUE;
}
對以上的程式碼PA RANGE的配置,值得一提的是,一般雖然設定為4個range,但是其實用不到,具體參考NV #2029 NV_WCDMA_PA_RANGE_MAP_I ,一般設定為{1,0,0,0},如下圖,所以我們在PA RANGE中其實第一個是HPM,後面是LPM
3. Modify the rfdevice_pa_factory.cpp file.
#include"rfdevice_pa_XXX_data_ag.h" // 新增器件XYZ的標頭檔案
.....
else if ( mfg_id == 0x01A5 && prd_id == 0x1C &&prd_rev == 0)
{//填加這款PA的mid pid prd_rev
pa_data = rfdevice_pa_XXX_data_ag::get_instance();
}
如何新增一個新的MIPI asm 晶片
mipi asm 配置比pa簡單很多,畢竟只是一個單刀多擲的開關,首先依然檢視datasheet
結構圖
暫存器
0X00是開關真值表
001D 001E 001F 依然是 pid mid
接下來修改目錄下modem_proc/rfcdevice_asm/src
1、Create therfdevice_asm_XXX_data_ag.h //複製已有的檔案,修改類的名稱
2、Create therfdevice_asm_XXX_data_ag.cpp file
ASM_ON_REG
ASM_OFF_REG
ASM_TRIGGER_REG
填寫PID MIDPRO_REV
#define RFDEVICE_ASM_XXX_NUM_PORTS 11//真值表個數
#define RFDEVICE_ASM_XXX_ASM_ON_NUM_REGS 1
static uint8 rfdevice_asm_XXX_asm_on_regs[RFDEVICE_ASM_XXX_ASM_ON_NUM_REGS] = {0x00, };//暫存器地址
static int16 rfdevice_asm_XXX_asm_on_data[RFDEVICE_ASM_XXX_NUM_PORTS][RFDEVICE_ASM_XXX_ASM_ON_NUM_REGS] =
{
{ /* PORT NUM: 0 *//* Isolation*/
0x00,
},
{ /* PORT NUM: 1 *//* TRX1 */檢視真值表
0x02,
},
{ /* PORT NUM: 2 *//* TRX2 */
0x0A,
},
{ /* PORT NUM: 3 *//* TRX3 */
0x0E,
},
.....
};
#define RFDEVICE_ASM_XXX_ASM_OFF_NUM_REGS 1
static uint8 rfdevice_asm_XXX_asm_off_regs[RFDEVICE_ASM_XXX_ASM_OFF_NUM_REGS] = {0x00, };
static int16 rfdevice_asm_XXX_asm_off_data[RFDEVICE_ASM_SXXX_NUM_PORTS][RFDEVICE_ASM_XXX_ASM_OFF_NUM_REGS] =
{
{ /* PORT NUM: 0 */
0x00, //第一個port為關
},
....
};
#define RFDEVICE_ASM_XXX_ASM_TRIGGER_NUM_REGS 1
static uint8 rfdevice_asm_XXX_asm_trigger_regs[RFDEVICE_ASM_XXX_ASM_TRIGGER_NUM_REGS] = {0x1C, };//trigger暫存器
static int16 rfdevice_asm_XXX_asm_trigger_data[RFDEVICE_ASM_SXXX_NUM_PORTS][RFDEVICE_ASM_XXX_ASM_TRIGGER_NUM_REGS] =
{
{ /* PORT NUM: 0 */
0x07, //預設為7
},
......
};
boolean rfdevice_asm_sky_XXX_data_ag::device_info_get( rfdevice_asm_info_type *asm_info )
{
asm_info->mfg_id = 0x1A5;//PID
asm_info->prd_id = 0x45;//MID
asm_info->prd_rev = 0;
asm_info->num_ports = RFDEVICE_ASM_XXX_NUM_PORTS;
ret_val = TRUE;
}
3、Modify the rfdevice_asm_factory.cpp file
#include"rfdevice_asm_XXX_data_ag.h" // 新增器件XYZ的標頭檔案
.....
else if ( mfg_id == 0x01A5 && prd_id == 0x1C &&prd_rev == 0)
{//填加這款ASM的mid pid prd_rev
pa_data = rfdevice_asm_XXX_data_ag::get_instance();
}