static int kxtf9_config(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata, struct ext_slave_config *data) { struct kxtf9_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 kxtf9_set_odr(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_ODR_RESUME: return kxtf9_set_odr(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_FSR_SUSPEND: return kxtf9_set_fsr(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_FSR_RESUME: return kxtf9_set_fsr(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_MOT_THS: return kxtf9_set_ths(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_NMOT_THS: return kxtf9_set_ths(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_MOT_DUR: return kxtf9_set_dur(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_NMOT_DUR: return kxtf9_set_dur(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_IRQ_SUSPEND: return kxtf9_set_irq(mlsl_handle, pdata, &private_data->suspend, data->apply, *((long *)data->data)); case MPU_SLAVE_CONFIG_IRQ_RESUME: return kxtf9_set_irq(mlsl_handle, pdata, &private_data->resume, data->apply, *((long *)data->data)); default: return INV_ERROR_FEATURE_NOT_IMPLEMENTED; }; return INV_SUCCESS; }
static int kxtf9_init(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata) { struct kxtf9_private_data *private_data; int result = ML_SUCCESS; private_data = (struct kxtf9_private_data *) MLOSMalloc(sizeof(struct kxtf9_private_data)); if (!private_data) return ML_ERROR_MEMORY_EXAUSTED; /* RAM reset */ result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, KXTF9_CTRL_REG1, 0x40); /* Fastest Reset */ ERROR_CHECK(result); result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, KXTF9_DATA_CTRL_REG, 0x36); /* Fastest Reset */ ERROR_CHECK(result); result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, KXTF9_CTRL_REG3, 0xcd); /* Reset */ ERROR_CHECK(result); MLOSSleep(2); pdata->private_data = private_data; private_data->resume.ctrl_reg1 = 0xC0; private_data->suspend.ctrl_reg1 = 0x40; result = kxtf9_set_dur(mlsl_handle, pdata, &private_data->suspend, FALSE, 1000); ERROR_CHECK(result); result = kxtf9_set_dur(mlsl_handle, pdata, &private_data->resume, FALSE, 2540); ERROR_CHECK(result); result = kxtf9_set_odr(mlsl_handle, pdata, &private_data->suspend, FALSE, 50000); ERROR_CHECK(result); result = kxtf9_set_odr(mlsl_handle, pdata, &private_data->resume, FALSE, 200000); result = kxtf9_set_fsr(mlsl_handle, pdata, &private_data->suspend, FALSE, 2000); ERROR_CHECK(result); result = kxtf9_set_fsr(mlsl_handle, pdata, &private_data->resume, FALSE, 2000); ERROR_CHECK(result); result = kxtf9_set_ths(mlsl_handle, pdata, &private_data->suspend, FALSE, 80); ERROR_CHECK(result); result = kxtf9_set_ths(mlsl_handle, pdata, &private_data->resume, FALSE, 40); ERROR_CHECK(result); result = kxtf9_set_irq(mlsl_handle, pdata, &private_data->suspend, FALSE, MPU_SLAVE_IRQ_TYPE_NONE); ERROR_CHECK(result); result = kxtf9_set_irq(mlsl_handle, pdata, &private_data->resume, FALSE, MPU_SLAVE_IRQ_TYPE_NONE); ERROR_CHECK(result); return result; }
static int kxtf9_init(void *mlsl_handle, struct ext_slave_descr *slave, struct ext_slave_platform_data *pdata) { struct kxtf9_private_data *private_data; int result = INV_SUCCESS; #ifndef UMPL private_data = (struct kxtf9_private_data *) kzalloc(sizeof(struct kxtf9_private_data), GFP_KERNEL); #else private_data = &kxtf9_private_data_instance; #endif if (!private_data) return INV_ERROR_MEMORY_EXAUSTED; /* RAM reset */ /* Fastest Reset */ result = inv_serial_single_write(mlsl_handle, pdata->address, KXTF9_CTRL_REG1, 0x40); if (result) { return result; } /* Fastest Reset */ result = inv_serial_single_write(mlsl_handle, pdata->address, KXTF9_DATA_CTRL_REG, 0x36); if (result) { return result; } /* Reset */ result = inv_serial_single_write(mlsl_handle, pdata->address, KXTF9_CTRL_REG3, 0xcd); if (result) { return result; } msleep(2); pdata->private_data = private_data; private_data->resume.ctrl_reg1 = 0xC0; private_data->suspend.ctrl_reg1 = 0x40; result = kxtf9_set_dur(mlsl_handle, pdata, &private_data->suspend, false, 1000); if (result) { return result; } result = kxtf9_set_dur(mlsl_handle, pdata, &private_data->resume, false, 2540); if (result) { return result; } result = kxtf9_set_odr(mlsl_handle, pdata, &private_data->suspend, false, 50000); if (result) { return result; } result = kxtf9_set_odr(mlsl_handle, pdata, &private_data->resume, false, 200000); result = kxtf9_set_fsr(mlsl_handle, pdata, &private_data->suspend, false, 2000); if (result) { return result; } result = kxtf9_set_fsr(mlsl_handle, pdata, &private_data->resume, false, 2000); if (result) { return result; } result = kxtf9_set_ths(mlsl_handle, pdata, &private_data->suspend, false, 80); if (result) { return result; } result = kxtf9_set_ths(mlsl_handle, pdata, &private_data->resume, false, 40); if (result) { return result; } result = kxtf9_set_irq(mlsl_handle, pdata, &private_data->suspend, false, MPU_SLAVE_IRQ_TYPE_NONE); if (result) { return result; } result = kxtf9_set_irq(mlsl_handle, pdata, &private_data->resume, false, MPU_SLAVE_IRQ_TYPE_NONE); if (result) { return result; } return result; }