mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 23:24:22 -04:00
sx937x: add reg read write interface for tcmd
sx937x: Add reg read write interface for tcmd. Change-Id: I3e611e649027fa80aec48c04acec5718623441e5 Reviewed-on: https://gerrit.mot.com/2731562 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Submit-Approved: Jira Key Tested-by: Jira Key Reviewed-by: <yangyi31@motorola.com> (cherry picked from commit b4edab29f1e286d96216840e6593bb53f2232fc4) Reviewed-on: https://gerrit.mot.com/2741058 Reviewed-by: Yuchang Guo <guoyc1@lenovo.com> Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com> Reviewed-by: Lijun Chen <chenlj2@motorola.com>
This commit is contained in:
parent
76d7dd86ce
commit
8a75301d55
2 changed files with 74 additions and 0 deletions
|
|
@ -550,6 +550,74 @@ static ssize_t sx937x_register_read_show(struct class *class,
|
|||
return sprintf(buf, "Register(0x%2x) data(0x%4x)\n", sx937x_temp_regist, sx937x_temp_val);
|
||||
}
|
||||
|
||||
static ssize_t reg_show(struct class *class,
|
||||
struct class_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
u32 *p = (u32*)buf;
|
||||
#ifdef CONFIG_CAPSENSE_POWER_CONTROL_SUPPORT
|
||||
psx937x_t pDevice = global_sx937x->pDevice;
|
||||
psx937x_platform_data_t pdata = pDevice->hw;
|
||||
|
||||
if (!pdata->cap_vdd_en)
|
||||
if ( power_on_chip(global_sx937x) != 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
psx93XX_t this = global_sx937x;
|
||||
if(this->read_flag){
|
||||
this->read_flag = 0;
|
||||
if (sx937x_i2c_read_16bit(this, this->read_reg, p) < 0)
|
||||
return -1;
|
||||
LOG_DBG("%s : read_reg = 0x%x, val = 0x%x\n",__func__,this->read_reg,*p);
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
reg attr is for TCMD on MTK only,
|
||||
buf[6]-read_flag:
|
||||
0-real write,
|
||||
1-just transfer the reg value want to be readed
|
||||
*/
|
||||
static ssize_t reg_store(struct class *class,
|
||||
struct class_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
psx93XX_t this = global_sx937x;
|
||||
u16 regaddr = 0;
|
||||
u32 val = 0;
|
||||
int i = 0;
|
||||
|
||||
#ifdef CONFIG_CAPSENSE_POWER_CONTROL_SUPPORT
|
||||
psx937x_t pDevice = global_sx937x->pDevice;
|
||||
psx937x_platform_data_t pdata = pDevice->hw;
|
||||
|
||||
if (!pdata->cap_vdd_en)
|
||||
if ( power_on_chip(global_sx937x) != 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if( count != 7){
|
||||
LOG_ERR("%s :params error[ count == %lu !=2]\n",__func__,count);
|
||||
return -1;
|
||||
}
|
||||
for(i = 0 ; i < count ; i++)
|
||||
LOG_DBG("%s : buf[%d] = 0x%x\n",__func__,i,buf[i]);
|
||||
if(buf[6] == 0){
|
||||
regaddr = ((u16)buf[0]<<8) | (u16)buf[1];
|
||||
val= ((u32)buf[2]<<24) | ((u32)buf[3]<<16) | ((u32)buf[4]<<8) | ((u32)buf[5]);
|
||||
if (sx937x_i2c_write_16bit(this, regaddr, val) < 0)
|
||||
return -1;
|
||||
} else if(buf[6] == 1) {
|
||||
this->read_reg = ((u16)buf[0]<<8) | (u16)buf[1];
|
||||
this->read_flag = 1;
|
||||
LOG_DBG("-----------\n");
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t manual_offset_calibration_show(struct class *class,
|
||||
struct class_attribute *attr,
|
||||
char *buf)
|
||||
|
|
@ -622,6 +690,8 @@ static struct class_attribute class_attr_int_state =
|
|||
__ATTR(int_state, 0440, sx937x_int_state_show, NULL);
|
||||
static struct class_attribute class_attr_reinitialize =
|
||||
__ATTR(reinitialize, 0660, NULL, sx937x_reinitialize_store);
|
||||
static struct class_attribute class_attr_reg =
|
||||
__ATTR(reg, 0660, reg_show, reg_store);
|
||||
|
||||
static struct attribute *capsense_class_attrs[] = {
|
||||
&class_attr_reset.attr,
|
||||
|
|
@ -634,6 +704,7 @@ static struct attribute *capsense_class_attrs[] = {
|
|||
&class_attr_manual_calibrate.attr,
|
||||
&class_attr_int_state.attr,
|
||||
&class_attr_reinitialize.attr,
|
||||
&class_attr_reg.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(capsense_class);
|
||||
|
|
@ -646,6 +717,7 @@ static struct class_attribute capsense_class_attributes[] = {
|
|||
__ATTR(manual_calibrate, 0660, manual_offset_calibration_show,manual_offset_calibration_store),
|
||||
__ATTR(int_state, 0440, sx937x_int_state_show, NULL),
|
||||
__ATTR(reinitialize, 0660, NULL, sx937x_reinitialize_store),
|
||||
__ATTR(reg, 0660, reg_show, reg_store),
|
||||
__ATTR_NULL,
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -522,6 +522,8 @@ struct sx93XX
|
|||
|
||||
int irqTimeout; /* msecs only set if useIrqTimer is true */
|
||||
|
||||
int read_flag; /* used for dump specified register*/
|
||||
u16 read_reg; /* record reg address which want to read*/
|
||||
/* struct workqueue_struct *ts_workq; */ /* if want to use non default */
|
||||
struct delayed_work dworker; /* work struct for worker function */
|
||||
u8 phaseselect;
|
||||
|
|
|
|||
Loading…
Reference in a new issue