Lines Matching +full:- +full:eproto

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 #define SSP_DEV (&data->spi->dev)
12 * SSP -> AP Instruction
15 * hrm etc. data. LIBRARY and META are mock-up's for now.
25 #define SSP_UNIMPLEMENTED -1
89 msg->buffer = kzalloc(SSP_HEADER_SIZE_ALIGNED + len, in ssp_create_msg()
91 if (!msg->buffer) { in ssp_create_msg()
96 msg->length = len; in ssp_create_msg()
97 msg->options = opt; in ssp_create_msg()
99 memcpy(msg->buffer, &h, SSP_HEADER_SIZE); in ssp_create_msg()
112 memcpy(&m->buffer[SSP_HEADER_SIZE_ALIGNED + offset], src, len); in ssp_fill_buffer()
118 memcpy(dest, &m->buffer[SSP_HEADER_SIZE_ALIGNED + offset], len); in ssp_get_buffer()
122 (m->buffer[SSP_HEADER_SIZE_ALIGNED + index])
124 (m->buffer[SSP_HEADER_SIZE_ALIGNED + index] = val)
128 kfree(m->buffer); in ssp_clean_msg()
137 if (length > received_len - *data_index || length <= 0) { in ssp_print_mcu_debug()
138 ssp_dbg("[SSP]: MSG From MCU-invalid debug length(%d/%d)\n", in ssp_print_mcu_debug()
140 return -EPROTO; in ssp_print_mcu_debug()
143 ssp_dbg("[SSP]: MSG From MCU - %s\n", &data_frame[*data_index]); in ssp_print_mcu_debug()
151 * It was designed that way - additional lines to some kind of handshake,
152 * please do not ask why - only the firmware guy can know it.
158 gpiod_set_value_cansleep(data->ap_mcu_gpiod, state); in ssp_check_lines()
160 while (gpiod_get_value_cansleep(data->mcu_ap_gpiod) != state) { in ssp_check_lines()
163 if (data->shut_down || delay_cnt++ > 500) { in ssp_check_lines()
168 gpiod_set_value_cansleep(data->ap_mcu_gpiod, 1); in ssp_check_lines()
170 return -ETIMEDOUT; in ssp_check_lines()
185 const bool use_no_irq = msg->length == 0; in ssp_do_transfer()
187 if (data->shut_down) in ssp_do_transfer()
188 return -EPERM; in ssp_do_transfer()
190 msg->done = done; in ssp_do_transfer()
192 mutex_lock(&data->comm_lock); in ssp_do_transfer()
198 status = spi_write(data->spi, msg->buffer, SSP_HEADER_SIZE); in ssp_do_transfer()
200 gpiod_set_value_cansleep(data->ap_mcu_gpiod, 1); in ssp_do_transfer()
206 mutex_lock(&data->pending_lock); in ssp_do_transfer()
207 list_add_tail(&msg->list, &data->pending_list); in ssp_do_transfer()
208 mutex_unlock(&data->pending_lock); in ssp_do_transfer()
214 mutex_lock(&data->pending_lock); in ssp_do_transfer()
215 list_del(&msg->list); in ssp_do_transfer()
216 mutex_unlock(&data->pending_lock); in ssp_do_transfer()
221 mutex_unlock(&data->comm_lock); in ssp_do_transfer()
227 mutex_lock(&data->pending_lock); in ssp_do_transfer()
228 list_del(&msg->list); in ssp_do_transfer()
229 mutex_unlock(&data->pending_lock); in ssp_do_transfer()
231 data->timeout_cnt++; in ssp_do_transfer()
232 return -ETIMEDOUT; in ssp_do_transfer()
238 mutex_unlock(&data->comm_lock); in ssp_do_transfer()
239 data->timeout_cnt++; in ssp_do_transfer()
254 if (WARN_ON(!msg->length)) in ssp_spi_sync()
255 return -EPERM; in ssp_spi_sync()
262 /* mock-up, it will be changed with adding another sensor types */ in ssp_handle_big_data()
271 struct iio_dev **indio_devs = data->sensor_devs; in ssp_parse_dataframe()
277 return -EPROTO; in ssp_parse_dataframe()
282 return -EPROTO; in ssp_parse_dataframe()
287 if (spd->process_data) { in ssp_parse_dataframe()
289 return -EPROTO; in ssp_parse_dataframe()
290 spd->process_data(indio_devs[sd], in ssp_parse_dataframe()
292 data->timestamp); in ssp_parse_dataframe()
302 return -EPROTO; in ssp_parse_dataframe()
317 data->time_syncing = true; in ssp_parse_dataframe()
325 if (data->time_syncing) in ssp_parse_dataframe()
326 data->timestamp = ktime_get_real_ns(); in ssp_parse_dataframe()
340 ret = spi_read(data->spi, data->header_buffer, SSP_HEADER_BUFFER_SIZE); in ssp_irq_msg()
346 length = le16_to_cpu(data->header_buffer[1]); in ssp_irq_msg()
347 msg_options = le16_to_cpu(data->header_buffer[0]); in ssp_irq_msg()
351 return -EINVAL; in ssp_irq_msg()
360 * this is a small list, a few elements - the packets can be in ssp_irq_msg()
363 mutex_lock(&data->pending_lock); in ssp_irq_msg()
364 list_for_each_entry_safe(iter, n, &data->pending_list, list) { in ssp_irq_msg()
365 if (iter->options == msg_options) { in ssp_irq_msg()
366 list_del(&iter->list); in ssp_irq_msg()
375 * but the slave should not send such ones - it is to in ssp_irq_msg()
380 ret = -ENOMEM; in ssp_irq_msg()
385 ret = spi_read(data->spi, buffer, length); in ssp_irq_msg()
387 ret = -EPROTO; in ssp_irq_msg()
398 ret = spi_read(data->spi, in ssp_irq_msg()
399 &msg->buffer[SSP_HEADER_SIZE_ALIGNED], in ssp_irq_msg()
400 msg->length); in ssp_irq_msg()
403 ret = spi_write(data->spi, in ssp_irq_msg()
404 &msg->buffer[SSP_HEADER_SIZE_ALIGNED], in ssp_irq_msg()
405 msg->length); in ssp_irq_msg()
407 msg->options = in ssp_irq_msg()
409 msg->length = 1; in ssp_irq_msg()
411 list_add_tail(&msg->list, &data->pending_list); in ssp_irq_msg()
416 if (msg->done) in ssp_irq_msg()
417 if (!completion_done(msg->done)) in ssp_irq_msg()
418 complete(msg->done); in ssp_irq_msg()
420 mutex_unlock(&data->pending_lock); in ssp_irq_msg()
425 return -ENOMEM; in ssp_irq_msg()
427 ret = spi_read(data->spi, buffer, length); in ssp_irq_msg()
441 return -EPROTO; in ssp_irq_msg()
451 mutex_lock(&data->pending_lock); in ssp_clean_pending_list()
452 list_for_each_entry_safe(msg, n, &data->pending_list, list) { in ssp_clean_pending_list()
453 list_del(&msg->list); in ssp_clean_pending_list()
455 if (msg->done) in ssp_clean_pending_list()
456 if (!completion_done(msg->done)) in ssp_clean_pending_list()
457 complete(msg->done); in ssp_clean_pending_list()
459 mutex_unlock(&data->pending_lock); in ssp_clean_pending_list()
469 return -ENOMEM; in ssp_command()
471 ssp_dbg("%s - command 0x%x %d\n", __func__, command, arg); in ssp_command()
485 if (data->fw_dl_state == SSP_FW_DL_STATE_DOWNLOADING) { in ssp_send_instruction()
486 dev_err(SSP_DEV, "%s - Skip Inst! DL state = %d\n", in ssp_send_instruction()
487 __func__, data->fw_dl_state); in ssp_send_instruction()
488 return -EBUSY; in ssp_send_instruction()
489 } else if (!(data->available_sensors & BIT(sensor_type)) && in ssp_send_instruction()
491 dev_err(SSP_DEV, "%s - Bypass Inst Skip! - %u\n", in ssp_send_instruction()
493 return -EIO; /* just fail */ in ssp_send_instruction()
498 return -ENOMEM; in ssp_send_instruction()
503 ssp_dbg("%s - Inst = 0x%x, Sensor Type = 0x%x, data = %u\n", in ssp_send_instruction()
520 return -ENOMEM; in ssp_get_chipid()
537 data->sensorhub_info->mag_length, SSP_AP2HUB_WRITE, in ssp_set_magnetic_matrix()
540 return -ENOMEM; in ssp_set_magnetic_matrix()
542 ssp_fill_buffer(msg, 0, data->sensorhub_info->mag_table, in ssp_set_magnetic_matrix()
543 data->sensorhub_info->mag_length); in ssp_set_magnetic_matrix()
564 dev_err(SSP_DEV, "%s - spi read fail %d\n", __func__, ret); in ssp_get_sensor_scanning_info()
590 dev_err(SSP_DEV, "%s - transfer fail %d\n", __func__, ret); in ssp_get_firmware_rev()