devon:sensors bringup

WHY:devon:new project sensors bringup
HOW:fix aw9610x code,devon use ext ldo ctl by gpio

Change-Id: I3af035617bfa383243d121c9eed0f61e423d2d6f
Signed-off-by: longc100 <longc100@motorola.com>
Reviewed-on: https://gerrit.mot.com/2205222
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Submit-Approved: Jira Key
Tested-by: Jira Key
Reviewed-by: Hong Zhang <zhangh12@motorola.com>
(cherry picked from commit 1e9aa7f0f254143a03837fee68305dc0fa111e0e)
Reviewed-on: https://gerrit.mot.com/2205886
Reviewed-by: Wang Wang <wangwang1@lenovo.com>
This commit is contained in:
longc100 2022-03-02 18:12:37 +08:00 • committed by Nan Wu
commit 70f8bc91e8
2 changed files with 49 additions and 15 deletions

View file

@ -1395,7 +1395,7 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev, unsigned
for (i = 0; i < aw9610x->aw_channel_number; i++)
{
if (aw9610x->aw_ref_channel == i) continue;
if ((aw9610x->aw_ref_channel >> i) & 0x1) continue;
if (!strcmp(sensors_cdev->name, aw9610x->aw_ch_name[aw9610x->sar_num * AW_CHANNEL_MAX + i])) {
if (enable == 1){
input_report_abs(aw9610x->aw_pad[i].input, ABS_DISTANCE, 0);
@ -1979,14 +1979,37 @@ aw9610x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
aw9610x_i2c_set(i2c, aw9610x);
aw9610x->pwr_by_gpio = of_property_read_bool(np, "sar-gpio-vcc-enable");
if (aw9610x->pwr_by_gpio)
{
aw9610x->vcc_3v0_Pin = of_get_named_gpio(np, "sar-gpio_3v0_en", 0);
if (!gpio_is_valid(aw9610x->vcc_3v0_Pin))
{
LOG_ERR("vcc_3v0_Pin gpio is invalid.");
return -ENODEV;
}
ret = gpio_request(aw9610x->vcc_3v0_Pin, "vcc_3v0_Pin");
if (ret < 0)
{
LOG_ERR("vcc_3v0_Pin Request gpio fail ret = %d", ret);
return ret;
}
ret = gpio_direction_output(aw9610x->vcc_3v0_Pin, 1);
if(ret < 0){
LOG_ERR("vcc_3v0_Pin gpio direction set fail ret = %d", ret);
return ret;
}
LOG_ERR("vcc_3v0_Pin gpio num is %d", aw9610x->vcc_3v0_Pin);
}else{
#ifdef AW_POWER_ON
/* aw9610x power init */
ret = aw9610x_power_init(aw9610x);
if (ret)
LOG_ERR("aw9610x power init failed");
else
aw9610x_power_enable(aw9610x, true);
/* aw9610x power init */
ret = aw9610x_power_init(aw9610x);
if (ret)
LOG_ERR("aw9610x power init failed");
else
aw9610x_power_enable(aw9610x, true);
#endif
}
/* aw9610x chip id */
ret = aw9610x_read_chipid(aw9610x);
@ -2086,7 +2109,7 @@ aw9610x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
#ifdef USE_SENSORS_CLASS
for (i = 0; i < aw9610x->aw_channel_number; i++){
if (aw9610x->aw_ref_channel == i) continue;
if ((aw9610x->aw_ref_channel >> i) & 0x1) continue;
sensors_capsensor_chs[i].sensors_enable = capsensor_set_enable;
sensors_capsensor_chs[i].sensors_poll_delay = NULL;
sensors_capsensor_chs[i].name = aw9610x->aw_ch_name[aw9610x->sar_num * AW_CHANNEL_MAX + i];
@ -2145,9 +2168,13 @@ err_first_irq:
err_pase_dt:
err_vers_load:
err_chipid:
if (aw9610x->power_enable) {
regulator_disable(aw9610x->vcc);
regulator_put(aw9610x->vcc);
if (aw9610x->pwr_by_gpio){
gpio_free(aw9610x->vcc_3v0_Pin);
}else{
if (aw9610x->power_enable) {
regulator_disable(aw9610x->vcc);
regulator_put(aw9610x->vcc);
}
}
err_malloc:
return ret;
@ -2159,14 +2186,19 @@ static int32_t aw9610x_i2c_remove(struct i2c_client *i2c)
uint32_t i = 0;
uint32_t j = aw9610x->sar_num;
if (aw9610x->power_enable) {
regulator_disable(aw9610x->vcc);
regulator_put(aw9610x->vcc);
if (aw9610x->pwr_by_gpio){
gpio_free(aw9610x->vcc_3v0_Pin);
}else{
if (aw9610x->power_enable) {
regulator_disable(aw9610x->vcc);
regulator_put(aw9610x->vcc);
}
}
#ifdef USE_SENSORS_CLASS
for (i = 0; i < aw9610x->aw_channel_number; i++)
{
if (aw9610x->aw_ref_channel == i) continue;
if ((aw9610x->aw_ref_channel >> i) & 0x1) continue;
sensors_classdev_unregister(&sensors_capsensor_chs[i]);
}
#endif

View file

@ -195,6 +195,8 @@ struct aw9610x {
uint32_t aw_ref_channel;
const char *aw_ch_name[12];
int32_t vcc_3v0_Pin;
int32_t pwr_by_gpio;
uint32_t sar_num;
int32_t irq_gpio;
int32_t to_irq;