原文地址: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
结构图
接下来修改目录下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();
}
至此新的mipi pa 以及asm 就添加完毕,之后需要做的就是在RFC 中配置每个制式 band采用哪种设备。