コード例 #1
0
void reset_mcu(struct ssp_data *data)
{
	if (data->bSspShutdown == false) {
		data->bSspShutdown = true;
		disable_irq_wake(data->iIrq);
		disable_irq(data->iIrq);
	}

	toggle_mcu_reset(data);
	msleep(SSP_SW_RESET_TIME);
	data->bSspShutdown = false;

	if (initialize_mcu(data) < 0)
		return;

	sync_sensor_state(data);

	if (data->bSspShutdown == true) {
		data->bSspShutdown = false;
		enable_irq(data->iIrq);
		enable_irq_wake(data->iIrq);
	}

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	ssp_report_sensorhub_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif
}
コード例 #2
0
void refresh_task(struct work_struct *work) {
	struct ssp_data *data = container_of((struct delayed_work *)work,
			struct ssp_data, work_refresh);

	if(data->bSspShutdown == true) {
		pr_err("[SSP]: %s - ssp already shutdown\n", __func__);
		return;
	}

	wake_lock(&data->ssp_wake_lock);
	pr_err("[SSP]: %s\n", __func__);
	data->uResetCnt++;

	if (initialize_mcu(data) > 0) {
		sync_sensor_state(data);
		ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_RESET);
		if (data->uLastAPState != 0)
			ssp_send_cmd(data, data->uLastAPState, 0);
		if (data->uLastResumeState != 0)
			ssp_send_cmd(data, data->uLastResumeState, 0);
		data->uTimeOutCnt = 0;
	}

	wake_unlock(&data->ssp_wake_lock);
}
コード例 #3
0
ssize_t mcu_update2_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	bool bSuccess = false;
	int iRet = 0;
	struct ssp_data *data = dev_get_drvdata(dev);

	ssp_dbg("[SSP]: %s - mcu binany update!\n", __func__);

	disable_irq(data->iIrq);
	disable_irq_wake(data->iIrq);

	iRet = update_crashed_mcu_bin(data);
	if (iRet < 0) {
		ssp_dbg("[SSP]: %s - update_mcu_bin failed!\n", __func__);
		goto exit;
	}

	iRet = initialize_mcu(data);
	if (iRet < 0) {
		ssp_dbg("[SSP]: %s - initialize_mcu failed!\n", __func__);
		goto exit;
	}

	enable_irq(data->iIrq);
	enable_irq_wake(data->iIrq);

	if (atomic_read(&data->aSensorEnable) > 0)
		sync_sensor_state(data);

	bSuccess = true;
exit:
	return sprintf(buf, "%s\n", (bSuccess ? "OK" : "NG"));
}
コード例 #4
0
int forced_to_download_binary(struct ssp_data *data, int iBinType)
{
    int iRet = 0;
    int retry = 3;

    ssp_dbg("[SSP]: %s - mcu binany update!\n", __func__);

    ssp_enable(data, false);

    data->fw_dl_state = FW_DL_STATE_DOWNLOADING;
    pr_info("[SSP] %s, DL state = %d\n", __func__,
            data->fw_dl_state);
    data->spi->max_speed_hz = BOOT_SPI_HZ;
    if (spi_setup(data->spi))
        pr_err("failed to setup spi for ssp_boot\n");

    do {
        pr_info("[SSP] %d try\n", 3 - retry);
        iRet = update_mcu_bin(data, iBinType);
    } while (retry -- > 0 && iRet < 0);
    data->spi->max_speed_hz = NORM_SPI_HZ;
    if (spi_setup(data->spi))
        pr_err("failed to setup spi for ssp_norm\n");

    if (iRet < 0) {
        ssp_dbg("[SSP]: %s - update_mcu_bin failed!\n", __func__);
        goto out;
    }

    data->fw_dl_state = FW_DL_STATE_SYNC;
    pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);
    ssp_enable(data, true);

    iRet = initialize_mcu(data);
    if (iRet < 0) {
        iRet = ERROR;
        ssp_dbg("[SSP]: %s - initialize_mcu failed!\n", __func__);
        goto out;
    }

    sync_sensor_state(data);

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
    ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif

    data->fw_dl_state = FW_DL_STATE_DONE;
    pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);

    iRet = SUCCESS;
out:
    return iRet;
}
コード例 #5
0
int forced_to_download_binary(struct ssp_data *data, int iBinType)
{
	int iRet = 0;

	ssp_dbg("[SSP]: %s - mcu binany update!\n", __func__);

	if (data->bSspShutdown == false) {
		data->bSspShutdown = true;
		disable_irq_wake(data->iIrq);
		disable_irq(data->iIrq);
	}

	data->fw_dl_state = FW_DL_STATE_DOWNLOADING;
	pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);

	iRet = update_mcu_bin(data, iBinType);
	if (iRet < 0) {
		iRet = ERROR;
		ssp_dbg("[SSP]: %s - update_mcu_bin failed!\n", __func__);
		goto out;
	}

	data->fw_dl_state = FW_DL_STATE_SYNC;
	pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);

	iRet = initialize_mcu(data);
	if (iRet < 0) {
		iRet = ERROR;
		ssp_dbg("[SSP]: %s - initialize_mcu failed!\n", __func__);
		goto out;
	}

	if (data->bSspShutdown == true) {
		data->bSspShutdown = false;
		enable_irq(data->iIrq);
		enable_irq_wake(data->iIrq);
	}

	sync_sensor_state(data);

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif

	data->fw_dl_state = FW_DL_STATE_DONE;
	pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);

	iRet = SUCCESS;
out:
	return iRet;
}
コード例 #6
0
void reset_mcu(struct ssp_data *data)
{
	ssp_enable(data, false);

	toggle_mcu_reset(data);
	msleep(SSP_SW_RESET_TIME);

	if (initialize_mcu(data) < 0)
		return;

	ssp_enable(data, true);
	sync_sensor_state(data);

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif
}
コード例 #7
0
int forced_to_download_binary(struct ssp_data *data, int iBinType)
{
	int iRet = 0;

	ssp_dbg("[SSP]: %s - mcu binany update!\n", __func__);

	ssp_enable(data, false);

	data->fw_dl_state = FW_DL_STATE_DOWNLOADING;
	pr_info("[SSP] %s, DL state = %d\n", __func__,
	data->fw_dl_state);

	iRet = update_mcu_bin(data, iBinType);
	if (iRet < 0) {
		ssp_dbg("[SSP]: %s - update_mcu_bin failed!\n", __func__);
		goto out;
	}

	data->fw_dl_state = FW_DL_STATE_SYNC;
	pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);
	iRet = initialize_mcu(data);
    if (iRet == ERROR) {
        data->uResetCnt++;
        toggle_mcu_reset(data);
        msleep(SSP_SW_RESET_TIME);
        initialize_mcu(data);
    } else if (iRet < ERROR) {
        pr_err("[SSP]: %s - initialize_mcu failed\n", __func__);
		goto out;
    }

	ssp_enable(data, true);
	sync_sensor_state(data);

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif

	data->fw_dl_state = FW_DL_STATE_DONE;
	pr_info("[SSP] %s, DL state = %d\n", __func__, data->fw_dl_state);

	iRet = SUCCESS;
out:
	return iRet;
}
コード例 #8
0
void reset_mcu(struct ssp_data *data)
{
	func_dbg();
	ssp_enable(data, false);

	clean_pending_list(data);
	toggle_mcu_reset(data);
	msleep(SSP_SW_RESET_TIME);
	ssp_enable(data, true);

	if (initialize_mcu(data) < 0)
		return;

	sync_sensor_state(data);

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif
	if (data->uLastAPState != 0)
		ssp_send_cmd(data, data->uLastAPState, 0);
	if (data->uLastResumeState != 0)
		ssp_send_cmd(data, data->uLastResumeState, 0);
}
コード例 #9
0
ssize_t mcu_update_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	bool bSuccess = false;
	int iRet = 0;
	struct ssp_data *data = dev_get_drvdata(dev);

	ssp_dbg("[SSP]: %s - mcu binany update!\n", __func__);

	disable_irq(data->iIrq);
	disable_irq_wake(data->iIrq);

	iRet = update_mcu_bin(data);
	if (iRet < 0) {
		ssp_dbg("[SSP]: %s - update_mcu_bin failed!\n", __func__);
		goto exit;
	}

	iRet = initialize_mcu(data);
	if (iRet < 0) {
		ssp_dbg("[SSP]: %s - initialize_mcu failed!\n", __func__);
		goto exit;
	}

	sync_sensor_state(data);

	enable_irq(data->iIrq);
	enable_irq_wake(data->iIrq);

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	ssp_report_sensorhub_notice(data, MSG2SSP_AP_STATUS_RESET);
#endif

	bSuccess = true;
exit:
	return sprintf(buf, "%s\n", (bSuccess ? "OK" : "NG"));
}