static void ssp_shutdown(struct i2c_client *client) { struct ssp_data *data = i2c_get_clientdata(client); func_dbg(); if (data->bProbeIsDone == false) goto exit; if (data->fw_dl_state >= FW_DL_STATE_SCHEDULED && data->fw_dl_state < FW_DL_STATE_DONE) { pr_err("%s, cancel_delayed_work_sync state = %d\n", __func__, data->fw_dl_state); cancel_delayed_work_sync(&data->work_firmware); } ssp_enable(data, false); #ifdef CONFIG_POWERSUSPEND unregister_power_suspend(&data->power_suspend); #endif disable_debug_timer(data); free_irq(data->iIrq, data); gpio_free(data->client->irq); remove_sysfs(data); remove_event_symlink(data); remove_input_dev(data); #ifdef CONFIG_SENSORS_SSP_SENSORHUB ssp_sensorhub_remove(data); #endif del_timer_sync(&data->debug_timer); cancel_work_sync(&data->work_debug); destroy_workqueue(data->debug_wq); wake_lock_destroy(&data->ssp_wake_lock); #ifdef CONFIG_SENSORS_SSP_SHTC1 mutex_destroy(&data->cp_temp_adc_lock); #endif toggle_mcu_reset(data); // data->set_mcu_reset(0); exit: kfree(data); }
static void ssp_shutdown(struct i2c_client *client) { struct ssp_data *data = i2c_get_clientdata(client); func_dbg(); if (data->fw_dl_state >= FW_DL_STATE_SCHEDULED && data->fw_dl_state < FW_DL_STATE_DONE) { pr_err("%s, cancel_delayed_work_sync state = %d\n", __func__, data->fw_dl_state); cancel_delayed_work_sync(&data->work_firmware); } #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&data->early_suspend); #endif disable_debug_timer(data); if (data->bSspShutdown == false) { data->bSspShutdown = true; disable_irq_wake(data->iIrq); disable_irq(data->iIrq); } free_irq(data->iIrq, data); gpio_free(data->client->irq); remove_sysfs(data); remove_event_symlink(data); remove_input_dev(data); #ifdef CONFIG_SENSORS_SSP_SENSORHUB ssp_sensorhub_remove(data); #endif misc_deregister(&data->akmd_device); del_timer_sync(&data->debug_timer); cancel_work_sync(&data->work_debug); destroy_workqueue(data->debug_wq); wake_lock_destroy(&data->ssp_wake_lock); toggle_mcu_reset(data); kfree(data); }
static void ssp_late_resume(struct early_suspend *handler) { struct ssp_data *data; data = container_of(handler, struct ssp_data, early_suspend); func_dbg(); enable_debug_timer(data); #ifdef CONFIG_SENSORS_SSP_SENSORHUB /* give notice to user that AP goes to sleep */ ssp_sensorhub_report_notice(data, MSG2SSP_AP_STATUS_WAKEUP); ssp_resume_mode(data); #else if (atomic_read(&data->aSensorEnable) > 0) ssp_resume_mode(data); #endif }
void reset_mcu(struct ssp_data *data) { func_dbg(); ssp_enable(data, false); toggle_mcu_reset(data); msleep(SSP_SW_RESET_TIME); if (startup_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 }
static int ssp_suspend(struct device *dev) { struct spi_device *spi = to_spi_device(dev); struct ssp_data *data = spi_get_drvdata(spi); func_dbg(); if (SUCCESS != ssp_send_cmd(data, MSG2SSP_AP_STATUS_SUSPEND, 0)) pr_err("[SSP]: %s MSG2SSP_AP_STATUS_SUSPEND failed\n", __func__); data->uLastResumeState = MSG2SSP_AP_STATUS_SUSPEND; disable_debug_timer(data); data->bTimeSyncing = false; pr_info("[SSP]: isHandlingIrq:%d\n", data->bHandlingIrq); return 0; }
static int ssp_resume(struct device *dev) { struct spi_device *spi = to_spi_device(dev); struct ssp_data *data = spi_get_drvdata(spi); enable_irq(data->iIrq); func_dbg(); enable_debug_timer(data); data->bSuspended = false; if (SUCCESS != ssp_send_cmd(data, MSG2SSP_AP_STATUS_RESUME, 0)) pr_err("[SSP]: %s MSG2SSP_AP_STATUS_RESUME failed\n", __func__); data->uLastResumeState = MSG2SSP_AP_STATUS_RESUME; #if SSP_STATUS_MONITOR schedule_delayed_work(&data->polling_work, msecs_to_jiffies(3000)); #endif return 0; }
static int ssp_suspend(struct device *dev) { struct spi_device *spi = to_spi_device(dev); struct ssp_data *data = spi_get_drvdata(spi); func_dbg(); data->uLastResumeState = MSG2SSP_AP_STATUS_SUSPEND; disable_debug_timer(data); #if SSP_STATUS_MONITOR cancel_delayed_work_sync(&data->polling_work); #endif if (SUCCESS != ssp_send_cmd(data, MSG2SSP_AP_STATUS_SUSPEND, 0)) pr_err("[SSP]: %s MSG2SSP_AP_STATUS_SUSPEND failed\n", __func__); data->bSuspended = true; data->bTimeSyncing = false; disable_irq(data->iIrq); return 0; }
static void ssp_shutdown(struct spi_device *spi) { struct ssp_data *data = spi_get_drvdata(spi); func_dbg(); if (data->bProbeIsDone == false) goto exit; if (data->fw_dl_state >= FW_DL_STATE_SCHEDULED && data->fw_dl_state < FW_DL_STATE_DONE) { pr_err("%s, cancel_delayed_work_sync state = %d\n", __func__, data->fw_dl_state); cancel_delayed_work_sync(&data->work_firmware); } ssp_enable(data, false); disable_debug_timer(data); free_irq(data->iIrq, data); gpio_free(data->spi->irq); remove_sensors(data); ssp_sensorhub_remove(data); cancel_work_sync(&data->work_reset); del_timer_sync(&data->debug_timer); cancel_work_sync(&data->work_debug); destroy_workqueue(data->debug_wq); wake_lock_destroy(&data->ssp_wake_lock); toggle_mcu_reset(data); mutex_destroy(&data->reset_mutex); mutex_destroy(&data->enable_mutex); mutex_destroy(&data->wakeup_mutex); mutex_destroy(&data->comm_mutex); exit: kfree(data); }
void reset_mcu(struct ssp_data *data) { #if SSP_STATUS_MONITOR data->bRefreshing = true; #endif func_dbg(); ssp_enable(data, false); clean_pending_list(data); #if SSP_STATUS_MONITOR if( (data->reg_hub) && ((current_cable_type==POWER_SUPPLY_TYPE_MAINS) || (current_cable_type==POWER_SUPPLY_TYPE_HV_MAINS))) toggle_mcu_hw_reset(data); else #endif toggle_mcu_reset(data); ssp_enable(data, true); #if SSP_STATUS_MONITOR if((data->reg_hub) && ( (current_cable_type==POWER_SUPPLY_TYPE_MAINS) || (current_cable_type==POWER_SUPPLY_TYPE_HV_MAINS))) queue_refresh_task(data, 0); #endif }
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); }
static void ssp_shutdown(struct i2c_client *client) { struct ssp_data *data = i2c_get_clientdata(client); func_dbg(); data->bSspShutdown = true; #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&data->early_suspend); #endif disable_debug_timer(data); disable_irq_wake(data->iIrq); disable_irq(data->iIrq); free_irq(data->iIrq, data); gpio_free(data->client->irq); remove_sysfs(data); remove_event_symlink(data); remove_input_dev(data); #ifdef CONFIG_SENSORS_SSP_SENSORHUB ssp_remove_sensorhub(data); #endif misc_deregister(&data->akmd_device); del_timer_sync(&data->debug_timer); cancel_work_sync(&data->work_debug); destroy_workqueue(data->debug_wq); wake_lock_destroy(&data->ssp_wake_lock); toggle_mcu_reset(data); kfree(data); }