Lines Matching refs:aw_dev
26 static int aw87390_dev_reg_update(struct aw_device *aw_dev, in aw87390_dev_reg_update() argument
32 dev_err(aw_dev->dev, "data is NULL\n"); in aw87390_dev_reg_update()
42 ret = regmap_write(aw_dev->regmap, data[i], data[i + 1]); in aw87390_dev_reg_update()
50 static int aw87390_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name) in aw87390_dev_get_prof_name() argument
52 struct aw_prof_info *prof_info = &aw_dev->prof_info; in aw87390_dev_get_prof_name()
55 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw87390_dev_get_prof_name()
56 dev_err(aw_dev->dev, "index[%d] overflow count[%d]\n", in aw87390_dev_get_prof_name()
57 index, aw_dev->prof_info.count); in aw87390_dev_get_prof_name()
61 prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw87390_dev_get_prof_name()
68 static int aw87390_dev_get_prof_data(struct aw_device *aw_dev, int index, in aw87390_dev_get_prof_data() argument
71 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw87390_dev_get_prof_data()
72 dev_err(aw_dev->dev, "%s: index[%d] overflow count[%d]\n", in aw87390_dev_get_prof_data()
73 __func__, index, aw_dev->prof_info.count); in aw87390_dev_get_prof_data()
77 *prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw87390_dev_get_prof_data()
82 static int aw87390_dev_fw_update(struct aw_device *aw_dev) in aw87390_dev_fw_update() argument
89 ret = aw87390_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name); in aw87390_dev_fw_update()
91 dev_err(aw_dev->dev, "get prof name failed\n"); in aw87390_dev_fw_update()
95 dev_dbg(aw_dev->dev, "start update %s", prof_name); in aw87390_dev_fw_update()
97 ret = aw87390_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index_desc); in aw87390_dev_fw_update()
99 dev_err(aw_dev->dev, "aw87390_dev_get_prof_data failed\n"); in aw87390_dev_fw_update()
105 ret = aw87390_dev_reg_update(aw_dev, sec_desc[AW88395_DATA_TYPE_REG].data, in aw87390_dev_fw_update()
108 dev_err(aw_dev->dev, "update reg failed\n"); in aw87390_dev_fw_update()
112 aw_dev->prof_cur = aw_dev->prof_index; in aw87390_dev_fw_update()
117 static int aw87390_power_off(struct aw_device *aw_dev) in aw87390_power_off() argument
121 if (aw_dev->status == AW87390_DEV_PW_OFF) { in aw87390_power_off()
122 dev_dbg(aw_dev->dev, "already power off\n"); in aw87390_power_off()
126 ret = regmap_write(aw_dev->regmap, AW87390_SYSCTRL_REG, AW87390_POWER_DOWN_VALUE); in aw87390_power_off()
129 aw_dev->status = AW87390_DEV_PW_OFF; in aw87390_power_off()
134 static int aw87390_power_on(struct aw_device *aw_dev) in aw87390_power_on() argument
138 if (aw_dev->status == AW87390_DEV_PW_ON) { in aw87390_power_on()
139 dev_dbg(aw_dev->dev, "already power on\n"); in aw87390_power_on()
143 if (!aw_dev->fw_status) { in aw87390_power_on()
144 dev_err(aw_dev->dev, "fw not load\n"); in aw87390_power_on()
148 ret = regmap_write(aw_dev->regmap, AW87390_SYSCTRL_REG, AW87390_POWER_DOWN_VALUE); in aw87390_power_on()
152 ret = aw87390_dev_fw_update(aw_dev); in aw87390_power_on()
154 dev_err(aw_dev->dev, "%s load profile failed\n", __func__); in aw87390_power_on()
157 aw_dev->status = AW87390_DEV_PW_ON; in aw87390_power_on()
162 static int aw87390_dev_set_profile_index(struct aw_device *aw_dev, int index) in aw87390_dev_set_profile_index() argument
164 if ((index >= aw_dev->prof_info.count) || (index < 0)) in aw87390_dev_set_profile_index()
167 if (aw_dev->prof_index == index) in aw87390_dev_set_profile_index()
170 aw_dev->prof_index = index; in aw87390_dev_set_profile_index()
301 struct aw_device *aw_dev = aw87390->aw_pa; in aw87390_drv_event() local
306 ret = aw87390_power_on(aw_dev); in aw87390_drv_event()
309 ret = aw87390_power_off(aw_dev); in aw87390_drv_event()
312 dev_err(aw_dev->dev, "%s: invalid event %d\n", __func__, event); in aw87390_drv_event()
356 struct aw_device *aw_dev = aw87390->aw_pa; in aw87390_parse_channel_dt() local
357 struct device_node *np = aw_dev->dev->of_node; in aw87390_parse_channel_dt()
362 aw_dev->channel = channel_value; in aw87390_parse_channel_dt()
367 struct aw_device *aw_dev; in aw87390_init() local
385 aw_dev = devm_kzalloc(&i2c->dev, sizeof(*aw_dev), GFP_KERNEL); in aw87390_init()
386 if (!aw_dev) in aw87390_init()
389 (*aw87390)->aw_pa = aw_dev; in aw87390_init()
390 aw_dev->i2c = i2c; in aw87390_init()
391 aw_dev->regmap = regmap; in aw87390_init()
392 aw_dev->dev = &i2c->dev; in aw87390_init()
393 aw_dev->chip_id = AW87390_CHIP_ID; in aw87390_init()
394 aw_dev->acf = NULL; in aw87390_init()
395 aw_dev->prof_info.prof_desc = NULL; in aw87390_init()
396 aw_dev->prof_info.count = 0; in aw87390_init()
397 aw_dev->prof_info.prof_type = AW88395_DEV_NONE_TYPE_ID; in aw87390_init()
398 aw_dev->channel = AW87390_DEV_DEFAULT_CH; in aw87390_init()
399 aw_dev->fw_status = AW87390_DEV_FW_FAILED; in aw87390_init()
400 aw_dev->prof_index = AW87390_INIT_PROFILE; in aw87390_init()
401 aw_dev->status = AW87390_DEV_PW_OFF; in aw87390_init()