Lines Matching +full:reg +full:- +full:rc
7 * SPDX-License-Identifier: Apache-2.0
31 cfg = dev->config; in sbs_cmd_reg_read()
32 status = i2c_burst_read_dt(&cfg->i2c, reg_addr, i2c_data, ARRAY_SIZE(i2c_data)); in sbs_cmd_reg_read()
45 const struct sbs_gauge_config *config = dev->config; in sbs_cmd_reg_write()
50 return i2c_burst_write_dt(&config->i2c, reg_addr, buf, sizeof(buf)); in sbs_cmd_reg_write()
59 cfg = dev->config; in sbs_cmd_buffer_read()
60 status = i2c_burst_read_dt(&cfg->i2c, reg_addr, buffer, buffer_size); in sbs_cmd_buffer_read()
72 int rc = 0; in sbs_gauge_get_prop() local
77 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_AVG_CURRENT, &tmp_val); in sbs_gauge_get_prop()
78 val->avg_current = tmp_val * 1000; in sbs_gauge_get_prop()
81 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_CYCLE_COUNT, &tmp_val); in sbs_gauge_get_prop()
82 val->cycle_count = tmp_val; in sbs_gauge_get_prop()
85 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_CURRENT, &tmp_val); in sbs_gauge_get_prop()
86 val->current = (int16_t)tmp_val * 1000; in sbs_gauge_get_prop()
89 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_FULL_CAPACITY, &tmp_val); in sbs_gauge_get_prop()
90 val->full_charge_capacity = tmp_val * 1000; in sbs_gauge_get_prop()
93 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_REM_CAPACITY, &tmp_val); in sbs_gauge_get_prop()
94 val->remaining_capacity = tmp_val * 1000; in sbs_gauge_get_prop()
97 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_RUNTIME2EMPTY, &tmp_val); in sbs_gauge_get_prop()
98 val->runtime_to_empty = tmp_val; in sbs_gauge_get_prop()
101 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_AVG_TIME2FULL, &tmp_val); in sbs_gauge_get_prop()
102 val->runtime_to_full = tmp_val; in sbs_gauge_get_prop()
105 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_MANUFACTURER_ACCESS, &tmp_val); in sbs_gauge_get_prop()
106 val->sbs_mfr_access_word = tmp_val; in sbs_gauge_get_prop()
109 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_ASOC, &tmp_val); in sbs_gauge_get_prop()
110 val->absolute_state_of_charge = tmp_val; in sbs_gauge_get_prop()
113 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_RSOC, &tmp_val); in sbs_gauge_get_prop()
114 val->relative_state_of_charge = tmp_val; in sbs_gauge_get_prop()
117 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_TEMP, &tmp_val); in sbs_gauge_get_prop()
118 val->temperature = tmp_val; in sbs_gauge_get_prop()
121 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_VOLTAGE, &tmp_val); in sbs_gauge_get_prop()
122 val->voltage = tmp_val * 1000; in sbs_gauge_get_prop()
125 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_BATTERY_MODE, &tmp_val); in sbs_gauge_get_prop()
126 val->sbs_mode = tmp_val; in sbs_gauge_get_prop()
129 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_CHG_CURRENT, &tmp_val); in sbs_gauge_get_prop()
130 val->chg_current = tmp_val * 1000; in sbs_gauge_get_prop()
133 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_CHG_VOLTAGE, &tmp_val); in sbs_gauge_get_prop()
134 val->chg_voltage = tmp_val * 1000; in sbs_gauge_get_prop()
137 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_FLAGS, &tmp_val); in sbs_gauge_get_prop()
138 val->fg_status = tmp_val; in sbs_gauge_get_prop()
141 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_NOM_CAPACITY, &tmp_val); in sbs_gauge_get_prop()
142 val->design_cap = tmp_val; in sbs_gauge_get_prop()
145 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_DESIGN_VOLTAGE, &tmp_val); in sbs_gauge_get_prop()
146 val->design_volt = tmp_val; in sbs_gauge_get_prop()
149 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_AR, &tmp_val); in sbs_gauge_get_prop()
150 val->sbs_at_rate = tmp_val; in sbs_gauge_get_prop()
153 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_ARTTF, &tmp_val); in sbs_gauge_get_prop()
154 val->sbs_at_rate_time_to_full = tmp_val; in sbs_gauge_get_prop()
157 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_ARTTE, &tmp_val); in sbs_gauge_get_prop()
158 val->sbs_at_rate_time_to_empty = tmp_val; in sbs_gauge_get_prop()
161 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_AROK, &tmp_val); in sbs_gauge_get_prop()
162 val->sbs_at_rate_ok = tmp_val; in sbs_gauge_get_prop()
165 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_REM_CAPACITY_ALARM, &tmp_val); in sbs_gauge_get_prop()
166 val->sbs_remaining_capacity_alarm = tmp_val; in sbs_gauge_get_prop()
169 rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_REM_TIME_ALARM, &tmp_val); in sbs_gauge_get_prop()
170 val->sbs_remaining_time_alarm = tmp_val; in sbs_gauge_get_prop()
173 rc = -ENOTSUP; in sbs_gauge_get_prop()
176 return rc; in sbs_gauge_get_prop()
181 int rc = -ENOTSUP; in sbs_gauge_do_battery_cutoff() local
182 const struct sbs_gauge_config *cfg = dev->config; in sbs_gauge_do_battery_cutoff()
184 if (cfg->cutoff_cfg == NULL) { in sbs_gauge_do_battery_cutoff()
185 return -ENOTSUP; in sbs_gauge_do_battery_cutoff()
188 for (int i = 0; i < cfg->cutoff_cfg->payload_size; i++) { in sbs_gauge_do_battery_cutoff()
189 rc = sbs_cmd_reg_write(dev, cfg->cutoff_cfg->reg, cfg->cutoff_cfg->payload[i]); in sbs_gauge_do_battery_cutoff()
190 if (rc != 0) { in sbs_gauge_do_battery_cutoff()
191 return rc; in sbs_gauge_do_battery_cutoff()
195 return rc; in sbs_gauge_do_battery_cutoff()
201 int rc = 0; in sbs_gauge_set_prop() local
207 rc = sbs_cmd_reg_write(dev, SBS_GAUGE_CMD_MANUFACTURER_ACCESS, in sbs_gauge_set_prop()
212 rc = sbs_cmd_reg_write(dev, SBS_GAUGE_CMD_REM_CAPACITY_ALARM, in sbs_gauge_set_prop()
217 rc = sbs_cmd_reg_write(dev, SBS_GAUGE_CMD_REM_TIME_ALARM, in sbs_gauge_set_prop()
222 rc = sbs_cmd_reg_write(dev, SBS_GAUGE_CMD_BATTERY_MODE, val.sbs_mode); in sbs_gauge_set_prop()
226 rc = sbs_cmd_reg_write(dev, SBS_GAUGE_CMD_AR, val.sbs_at_rate); in sbs_gauge_set_prop()
230 rc = -ENOTSUP; in sbs_gauge_set_prop()
233 return rc; in sbs_gauge_set_prop()
240 int rc = 0; in sbs_gauge_get_buffer_prop() local
245 rc = sbs_cmd_buffer_read(dev, SBS_GAUGE_CMD_MANUFACTURER_NAME, (char *)dst, in sbs_gauge_get_buffer_prop()
248 rc = -EINVAL; in sbs_gauge_get_buffer_prop()
253 rc = sbs_cmd_buffer_read(dev, SBS_GAUGE_CMD_DEVICE_NAME, (char *)dst, in sbs_gauge_get_buffer_prop()
256 rc = -EINVAL; in sbs_gauge_get_buffer_prop()
261 rc = sbs_cmd_buffer_read(dev, SBS_GAUGE_CMD_DEVICE_CHEMISTRY, (char *)dst, in sbs_gauge_get_buffer_prop()
264 rc = -EINVAL; in sbs_gauge_get_buffer_prop()
268 rc = -ENOTSUP; in sbs_gauge_get_buffer_prop()
271 return rc; in sbs_gauge_get_buffer_prop()
283 cfg = dev->config; in sbs_gauge_init()
285 if (!device_is_ready(cfg->i2c.bus)) { in sbs_gauge_init()
287 return -ENODEV; in sbs_gauge_init()
307 .reg = DT_INST_PROP(index, battery_cutoff_reg_addr), \