static int lis331dlh_init(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata) { struct lis331dlh_private_data *private_data; private_data = (struct lis331dlh_private_data *) MLOSMalloc(sizeof(struct lis331dlh_private_data)); if (!private_data) return ML_ERROR_MEMORY_EXAUSTED; pdata->private_data = private_data; private_data->resume.ctrl_reg1 = 0x37; private_data->suspend.ctrl_reg1 = 0x47; lis331dlh_set_odr(&private_data->suspend, 50000); lis331dlh_set_odr(&private_data->resume, 200000); lis331dlh_set_fsr(&private_data->suspend, 2048); lis331dlh_set_fsr(&private_data->resume, 2048); lis331dlh_set_ths(&private_data->suspend, 80); lis331dlh_set_ths(&private_data->resume, 40); lis331dlh_set_dur(&private_data->suspend, 1000); lis331dlh_set_dur(&private_data->resume, 2540); return ML_SUCCESS; }
static int lis331dlh_config(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata, struct ext_slave_config *data) { struct lis331dlh_private_data *private_data = pdata->private_data; if (!data->data) return INV_ERROR_INVALID_PARAMETER; switch (data->key) { case MPU_SLAVE_CONFIG_ODR_SUSPEND: return lis331dlh_set_odr(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_ODR_RESUME: return lis331dlh_set_odr(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_FSR_SUSPEND: return lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_FSR_RESUME: return lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_MOT_THS: return lis331dlh_set_ths(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_NMOT_THS: return lis331dlh_set_ths(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_MOT_DUR: return lis331dlh_set_dur(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_NMOT_DUR: return lis331dlh_set_dur(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_IRQ_SUSPEND: return lis331dlh_set_irq(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_IRQ_RESUME: return lis331dlh_set_irq(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); default: LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED); return INV_ERROR_FEATURE_NOT_IMPLEMENTED; }; return INV_SUCCESS; }
static int lis331dlh_config(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata, struct ext_slave_config *data) { struct lis331dlh_private_data *private_data = pdata->private_data; if (!data->data) return ML_ERROR_INVALID_PARAMETER; switch (data->key) { case MPU_SLAVE_CONFIG_ODR_SUSPEND: lis331dlh_set_odr(&private_data->suspend, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_ODR_RESUME: lis331dlh_set_odr(&private_data->resume, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_FSR_SUSPEND: lis331dlh_set_fsr(&private_data->suspend, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_FSR_RESUME: lis331dlh_set_fsr(&private_data->resume, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_MOT_THS: lis331dlh_set_ths(&private_data->suspend, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_NMOT_THS: lis331dlh_set_ths(&private_data->resume, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_MOT_DUR: lis331dlh_set_dur(&private_data->suspend, *((long *)data->data)); break; case MPU_SLAVE_CONFIG_NMOT_DUR: lis331dlh_set_dur(&private_data->resume, *((long *)data->data)); break; default: return ML_ERROR_FEATURE_NOT_IMPLEMENTED; }; return ML_SUCCESS; }
static int lis331dlh_init(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata) { struct lis331dlh_private_data *private_data; long range; private_data = (struct lis331dlh_private_data *) kzalloc(sizeof(struct lis331dlh_private_data), GFP_KERNEL); if (!private_data) return INV_ERROR_MEMORY_EXAUSTED; pdata->private_data = private_data; private_data->resume.ctrl_reg1 = 0x37; private_data->suspend.ctrl_reg1 = 0x47; private_data->resume.mot_int1_cfg = 0x95; private_data->suspend.mot_int1_cfg = 0x2a; lis331dlh_set_odr(mlsl_handle, pdata, &private_data->suspend, false, 0); lis331dlh_set_odr(mlsl_handle, pdata, &private_data->resume, false, 200000); range = range_fixedpoint_to_long_mg(slave->range); lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->suspend, false, range); lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->resume, false, range); lis331dlh_set_ths(mlsl_handle, pdata, &private_data->suspend, false, 80); lis331dlh_set_ths(mlsl_handle, pdata, &private_data->resume, false, 40); lis331dlh_set_dur(mlsl_handle, pdata, &private_data->suspend, false, 1000); lis331dlh_set_dur(mlsl_handle, pdata, &private_data->resume, false, 2540); lis331dlh_set_irq(mlsl_handle, pdata, &private_data->suspend, false, MPU_SLAVE_IRQ_TYPE_NONE); lis331dlh_set_irq(mlsl_handle, pdata, &private_data->resume, false, MPU_SLAVE_IRQ_TYPE_NONE); return INV_SUCCESS; }
static int lis331dlh_init(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata) { struct lis331dlh_private_data *private_data; private_data = (struct lis331dlh_private_data *) MLOSMalloc(sizeof(struct lis331dlh_private_data)); if (!private_data) return ML_ERROR_MEMORY_EXAUSTED; pdata->private_data = private_data; private_data->resume.ctrl_reg1 = 0x37; private_data->suspend.ctrl_reg1 = 0x47; private_data->resume.mot_int1_cfg = 0x95; private_data->suspend.mot_int1_cfg = 0x2a; lis331dlh_set_odr(mlsl_handle, pdata, &private_data->suspend, FALSE, 0); lis331dlh_set_odr(mlsl_handle, pdata, &private_data->resume, FALSE, 200000); lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->suspend, FALSE, 2048); lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->resume, FALSE, 2048); lis331dlh_set_ths(mlsl_handle, pdata, &private_data->suspend, FALSE, 80); lis331dlh_set_ths(mlsl_handle, pdata, &private_data->resume, FALSE, 40); lis331dlh_set_dur(mlsl_handle, pdata, &private_data->suspend, FALSE, 1000); lis331dlh_set_dur(mlsl_handle, pdata, &private_data->resume, FALSE, 2540); lis331dlh_set_irq(mlsl_handle, pdata, &private_data->suspend, FALSE, MPU_SLAVE_IRQ_TYPE_NONE); lis331dlh_set_irq(mlsl_handle, pdata, &private_data->resume, FALSE, MPU_SLAVE_IRQ_TYPE_NONE); return ML_SUCCESS; }