/* It is possible that it is max clk rate for version 1.0 of bootcode */ #define SSP_BOOT_SPI_HZ 400000
/* * These fields can look enigmatic but this structure is used mainly to flat * some values and depends on command type.
*/ struct ssp_instruction {
__le32 a;
__le32 b;
u8 c;
} __attribute__((__packed__));
staticvoid ssp_sync_available_sensors(struct ssp_data *data)
{ int i, ret;
for (i = 0; i < SSP_SENSOR_MAX; ++i) { if (data->available_sensors & BIT(i)) {
ret = ssp_enable_sensor(data, i, data->delay_buf[i]); if (ret < 0) {
dev_err(&data->spi->dev, "Sync sensor nr: %d fail\n", i); continue;
}
}
}
ret = ssp_command(data, SSP_MSG2SSP_AP_MCU_SET_DUMPMODE,
data->mcu_dump_mode); if (ret < 0)
dev_err(&data->spi->dev, "SSP_MSG2SSP_AP_MCU_SET_DUMPMODE failed\n");
}
/* * This function is the first one which communicates with the mcu so it is * possible that the first attempt will fail
*/ staticint ssp_check_fwbl(struct ssp_data *data)
{ int retries = 0;
/** * ssp_get_sensor_delay() - gets sensor data acquisition period * @data: sensorhub structure * @type: SSP sensor type * * Returns acquisition period in ms
*/
u32 ssp_get_sensor_delay(struct ssp_data *data, enum ssp_sensor_type type)
{ return data->delay_buf[type];
}
EXPORT_SYMBOL_NS(ssp_get_sensor_delay, "IIO_SSP_SENSORS");
/** * ssp_enable_sensor() - enables data acquisition for sensor * @data: sensorhub structure * @type: SSP sensor type * @delay: delay in ms * * Returns 0 or negative value in case of error
*/ int ssp_enable_sensor(struct ssp_data *data, enum ssp_sensor_type type,
u32 delay)
{ int ret; struct ssp_instruction to_send;
/** * ssp_change_delay() - changes data acquisition for sensor * @data: sensorhub structure * @type: SSP sensor type * @delay: delay in ms * * Returns 0 or negative value in case of error
*/ int ssp_change_delay(struct ssp_data *data, enum ssp_sensor_type type,
u32 delay)
{ int ret; struct ssp_instruction to_send;
/** * ssp_disable_sensor() - disables sensor * * @data: sensorhub structure * @type: SSP sensor type * * Returns 0 or negative value in case of error
*/ int ssp_disable_sensor(struct ssp_data *data, enum ssp_sensor_type type)
{ int ret;
__le32 command;
if (data->sensor_enable & BIT(type)) {
command = cpu_to_le32(data->delay_buf[type]);
ret = ssp_send_instruction(data,
SSP_MSG2SSP_INST_BYPASS_SENSOR_RM,
type, (u8 *)&command, sizeof(command)); if (ret < 0) {
dev_err(&data->spi->dev, "Remove sensor fail\n"); return ret;
}
data->sensor_enable &= ~BIT(type);
}
data->check_status[type] = SSP_ADD_SENSOR_STATE;
if (atomic_dec_and_test(&data->enable_refcount))
ssp_disable_wdt_timer(data);
/* * This wrapper is done to preserve error path for ssp_irq_msg, also * it is defined in different file.
*/
ssp_irq_msg(data);
return IRQ_HANDLED;
}
staticint ssp_initialize_mcu(struct ssp_data *data)
{ int ret;
ssp_clean_pending_list(data);
ret = ssp_get_chipid(data); if (ret != SSP_DEVICE_ID) {
dev_err(&data->spi->dev, "%s - MCU %s ret = %d\n", __func__,
ret < 0 ? "is not working" : "identification failed",
ret); return ret < 0 ? ret : -ENODEV;
}
dev_info(&data->spi->dev, "MCU device ID = %d\n", ret);
/* * needs clarification, for now do not want to export all transfer * methods to sensors' drivers
*/
ret = ssp_set_magnetic_matrix(data); if (ret < 0) {
dev_err(&data->spi->dev, "%s - ssp_set_magnetic_matrix failed\n", __func__); return ret;
}
/* * sensorhub can request its reinitialization as some brutal and rare error * handling. It can be requested from the MCU.
*/ staticvoid ssp_refresh_task(struct work_struct *work)
{ struct ssp_data *data = container_of((struct delayed_work *)work, struct ssp_data, work_refresh);
dev_info(&data->spi->dev, "refreshing\n");
data->reset_cnt++;
if (ssp_initialize_mcu(data) >= 0) {
ssp_sync_available_sensors(data); if (data->last_ap_state != 0)
ssp_command(data, data->last_ap_state, 0);
if (data->last_resume_state != 0)
ssp_command(data, data->last_resume_state, 0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.