Example #1
0
static int mma845x_init(void *mlsl_handle,
			  struct ext_slave_descr *slave,
			  struct ext_slave_platform_data *pdata)
{
	long range;
	struct mma845x_private_data *private_data;
	private_data = (struct mma845x_private_data *)
	    kzalloc(sizeof(struct mma845x_private_data), GFP_KERNEL);

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	mma845x_set_odr(mlsl_handle, pdata, &private_data->suspend,
			false, 0);
	mma845x_set_odr(mlsl_handle, pdata, &private_data->resume,
			false, 200000);

	range = range_fixedpoint_to_long_mg(slave->range);
	mma845x_set_fsr(mlsl_handle, pdata, &private_data->suspend,
			false, range);
	mma845x_set_fsr(mlsl_handle, pdata, &private_data->resume,
			false, range);

	mma845x_set_irq(mlsl_handle, pdata, &private_data->suspend,
			false, MPU_SLAVE_IRQ_TYPE_NONE);
	mma845x_set_irq(mlsl_handle, pdata, &private_data->resume,
			false, MPU_SLAVE_IRQ_TYPE_NONE);
	return INV_SUCCESS;
}
static int lis3dh_init(void *mlsl_handle,
		       struct ext_slave_descr *slave,
		       struct ext_slave_platform_data *pdata)
{
	int result;
	long range;
	struct lis3dh_private_data *private_data;
	private_data = (struct lis3dh_private_data *)
	    kzalloc(sizeof(struct lis3dh_private_data), GFP_KERNEL);

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	private_data->resume.ctrl_reg1 = 0x67;
	private_data->suspend.ctrl_reg1 = 0x18;
	private_data->resume.mot_int1_cfg = 0x95;
	private_data->suspend.mot_int1_cfg = 0x2a;

	lis3dh_set_odr(mlsl_handle, pdata, &private_data->suspend, false, 0);
	lis3dh_set_odr(mlsl_handle, pdata, &private_data->resume,
		       false, 200000L);

	range = range_fixedpoint_to_long_mg(slave->range);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->suspend,
			false, range);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->resume,
			false, range);

	lis3dh_set_ths(mlsl_handle, pdata, &private_data->suspend,
			false, 80);
	lis3dh_set_ths(mlsl_handle, pdata, &private_data->resume,
			false, 40);

	lis3dh_set_dur(mlsl_handle, pdata, &private_data->suspend,
			false, 1000);
	lis3dh_set_dur(mlsl_handle, pdata, &private_data->resume,
			false, 2540);

	lis3dh_set_irq(mlsl_handle, pdata, &private_data->suspend,
			false, MPU_SLAVE_IRQ_TYPE_NONE);
	lis3dh_set_irq(mlsl_handle, pdata, &private_data->resume,
			false, MPU_SLAVE_IRQ_TYPE_NONE);

	result = inv_serial_single_write(mlsl_handle, pdata->address,
					 LIS3DH_CTRL_REG1, 0x07);
	msleep(6);

	return INV_SUCCESS;
}
/**
 *  @brief one-time device driver initialization function.
 *         If the driver is built as a kernel module, this function will be
 *         called when the module is loaded in the kernel.
 *         If the driver is built-in in the kernel, this function will be
 *         called at boot time.
 *
 *  @param mlsl_handle
 *             the handle to the serial channel the device is connected to.
 *  @param slave
 *             a pointer to the slave descriptor data structure.
 *  @param pdata
 *             a pointer to the slave platform data.
 *
 *  @return INV_SUCCESS if successful or a non-zero error code.
 */
static int adxl34x_init(void *mlsl_handle,
			struct ext_slave_descr *slave,
			struct ext_slave_platform_data *pdata)
{
	int result;
	long range;

	struct adxl34x_private_data *private_data;
	private_data = (struct adxl34x_private_data *)
	    kzalloc(sizeof(struct adxl34x_private_data), GFP_KERNEL);

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	result = adxl34x_set_odr(mlsl_handle, pdata, &private_data->suspend,
				false, 0);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	result = adxl34x_set_odr(mlsl_handle, pdata, &private_data->resume,
				false, 200000);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	range = range_fixedpoint_to_long_mg(slave->range);
	result = adxl34x_set_fsr(mlsl_handle, pdata, &private_data->suspend,
				false, range);
	result = adxl34x_set_fsr(mlsl_handle, pdata, &private_data->resume,
				false, range);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	result = adxl34x_suspend(mlsl_handle, slave, pdata);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	return result;
}
Example #4
0
/**
 *  @brief one-time device driver initialization function.
 *         If the driver is built as a kernel module, this function will be
 *         called when the module is loaded in the kernel.
 *         If the driver is built-in in the kernel, this function will be
 *         called at boot time.
 *
 *  @param mlsl_handle
 *             the handle to the serial channel the device is connected to.
 *  @param slave
 *             a pointer to the slave descriptor data structure.
 *  @param pdata
 *             a pointer to the slave platform data.
 *
 *  @return INV_SUCCESS if successful or a non-zero error code.
 */
static int lsm303dlha_init(void *mlsl_handle,
			  struct ext_slave_descr *slave,
			  struct ext_slave_platform_data *pdata)
{
	long range;
	struct lsm303dlha_private_data *private_data;
	private_data = (struct lsm303dlha_private_data *)
	    kzalloc(sizeof(struct lsm303dlha_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;

	lsm303dlha_set_odr(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 0);
	lsm303dlha_set_odr(mlsl_handle, pdata, &private_data->resume,
			FALSE, 200000);

	range = range_fixedpoint_to_long_mg(slave->range);
	lsm303dlha_set_fsr(mlsl_handle, pdata, &private_data->suspend,
			FALSE, range);
	lsm303dlha_set_fsr(mlsl_handle, pdata, &private_data->resume,
			FALSE, range);

	lsm303dlha_set_ths(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 80);
	lsm303dlha_set_ths(mlsl_handle, pdata, &private_data->resume,
			FALSE, 40);

	lsm303dlha_set_dur(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 1000);
	lsm303dlha_set_dur(mlsl_handle, pdata, &private_data->resume,
			FALSE, 2540);

	lsm303dlha_set_irq(mlsl_handle, pdata, &private_data->suspend,
			FALSE, MPU_SLAVE_IRQ_TYPE_NONE);
	lsm303dlha_set_irq(mlsl_handle, pdata, &private_data->resume,
			FALSE, MPU_SLAVE_IRQ_TYPE_NONE);
	return INV_SUCCESS;
}
/**
 *  @brief one-time device driver initialization function.
 *         If the driver is built as a kernel module, this function will be
 *         called when the module is loaded in the kernel.
 *         If the driver is built-in in the kernel, this function will be
 *         called at boot time.
 *
 *  @param mlsl_handle
 *             the handle to the serial channel the device is connected to.
 *  @param slave
 *             a pointer to the slave descriptor data structure.
 *  @param pdata
 *             a pointer to the slave platform data.
 *
 *  @return INV_SUCCESS if successful or a non-zero error code.
 */
static int bma150_init(void *mlsl_handle,
			  struct ext_slave_descr *slave,
			  struct ext_slave_platform_data *pdata)
{
	int result;
	unsigned char reg;
	long range;

	struct bma150_private_data *private_data;
	private_data = (struct bma150_private_data *)
	    kzalloc(sizeof(struct bma150_private_data), GFP_KERNEL);

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	result = inv_serial_single_write(mlsl_handle, pdata->address,
			BMA150_PWR_REG, BMA150_PWR_MASK_SOFT_RESET);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	msleep(1);

	result = inv_serial_read(mlsl_handle, pdata->address,
				 BMA150_CTRL_REG, 1, &reg);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	private_data->resume.ctrl_reg = reg;
	private_data->suspend.ctrl_reg = reg;

	result = inv_serial_read(mlsl_handle, pdata->address,
				 BMA150_INT_REG, 1, &reg);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	private_data->resume.int_reg = reg;
	private_data->suspend.int_reg = reg;

	result = bma150_set_odr(mlsl_handle, pdata, &private_data->suspend,
				FALSE, 0);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	result = bma150_set_odr(mlsl_handle, pdata, &private_data->resume,
				FALSE, 200000);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	range = range_fixedpoint_to_long_mg(slave->range);
	result = bma150_set_fsr(mlsl_handle, pdata, &private_data->suspend,
				FALSE, range);
	result = bma150_set_fsr(mlsl_handle, pdata, &private_data->resume,
				FALSE, range);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	result = bma150_set_irq(mlsl_handle, pdata, &private_data->suspend,
				FALSE, MPU_SLAVE_IRQ_TYPE_NONE);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	result = bma150_set_irq(mlsl_handle, pdata, &private_data->resume,
				FALSE, MPU_SLAVE_IRQ_TYPE_NONE);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	result = inv_serial_single_write(mlsl_handle, pdata->address,
				       BMA150_PWR_REG, BMA150_PWR_MASK_SLEEP);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	return result;
}
Example #6
0
/**
 *  @brief one-time device driver initialization function.
 *         If the driver is built as a kernel module, this function will be
 *         called when the module is loaded in the kernel.
 *         If the driver is built-in in the kernel, this function will be
 *         called at boot time.
 *
 *  @param mlsl_handle
 *             the handle to the serial channel the device is connected to.
 *  @param slave
 *             a pointer to the slave descriptor data structure.
 *  @param pdata
 *             a pointer to the slave platform data.
 *
 *  @return INV_SUCCESS if successful or a non-zero error code.
 */
static int bma250_init(void *mlsl_handle,
			 struct ext_slave_descr *slave,
			 struct ext_slave_platform_data *pdata)
{
	int result;
	long range;

	struct bma250_private_data *private_data;
	private_data = kzalloc(sizeof(struct bma250_private_data), GFP_KERNEL);

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	result = inv_serial_single_write(mlsl_handle, pdata->address,
			BMA250_SOFTRESET_REG, BMA250_SOFTRESET_MASK);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	msleep(1);

	result = bma250_set_odr(mlsl_handle, pdata, &private_data->suspend,
				false, 0);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}
	result = bma250_set_odr(mlsl_handle, pdata, &private_data->resume,
				false, 200000);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	range = range_fixedpoint_to_long_mg(slave->range);
	result = bma250_set_fsr(mlsl_handle, pdata, &private_data->suspend,
				false, range);
	result = bma250_set_fsr(mlsl_handle, pdata, &private_data->resume,
				false, range);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	result = bma250_set_irq(mlsl_handle, pdata, &private_data->suspend,
				false, MPU_SLAVE_IRQ_TYPE_NONE);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	result = bma250_set_irq(mlsl_handle, pdata, &private_data->resume,
				false, MPU_SLAVE_IRQ_TYPE_NONE);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	result = inv_serial_single_write(mlsl_handle, pdata->address,
				BMA250_PWR_REG, BMA250_PWR_SLEEP_MASK);
	if (result) {
		LOG_RESULT_LOCATION(result);
		return result;
	}

	return result;
}