Lines Matching +full:motion +full:- +full:sensors

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * sensors BMA150 and SMB380.
11 * http://www.bosch-sensortec.com/content/language1/downloads/BST-BMA150-DS000-07.pdf
25 #define ABSMIN_ACC_VAL -(ABSMAX_ACC_VAL)
27 /* Each axis is represented by a 2-byte data word */
83 /* Any-motion interrupt register fields */
99 /* High-G interrupt register fields */
111 /* Low-G interrupt register fields */
155 if (client->irq) in bma150_write_byte()
156 disable_irq_nosync(client->irq); in bma150_write_byte()
160 if (client->irq) in bma150_write_byte()
161 enable_irq(client->irq); in bma150_write_byte()
183 error = bma150_set_reg_bits(bma150->client, mode, BMA150_WAKE_UP_POS, in bma150_set_mode()
188 error = bma150_set_reg_bits(bma150->client, mode, BMA150_SLEEP_POS, in bma150_set_mode()
196 bma150->mode = mode; in bma150_set_mode()
204 error = bma150_set_reg_bits(bma150->client, 1, BMA150_SW_RES_POS, in bma150_soft_reset()
215 return bma150_set_reg_bits(bma150->client, range, BMA150_RANGE_POS, in bma150_set_range()
221 return bma150_set_reg_bits(bma150->client, bw, BMA150_BANDWIDTH_POS, in bma150_set_bandwidth()
230 error = bma150_set_reg_bits(bma150->client, hyst, in bma150_set_low_g_interrupt()
236 error = bma150_write_byte(bma150->client, BMA150_LOW_G_DUR_REG, dur); in bma150_set_low_g_interrupt()
240 error = bma150_write_byte(bma150->client, BMA150_LOW_G_THRES_REG, thres); in bma150_set_low_g_interrupt()
244 return bma150_set_reg_bits(bma150->client, !!enable, in bma150_set_low_g_interrupt()
254 error = bma150_set_reg_bits(bma150->client, hyst, in bma150_set_high_g_interrupt()
260 error = bma150_write_byte(bma150->client, in bma150_set_high_g_interrupt()
265 error = bma150_write_byte(bma150->client, in bma150_set_high_g_interrupt()
270 return bma150_set_reg_bits(bma150->client, !!enable, in bma150_set_high_g_interrupt()
281 error = bma150_set_reg_bits(bma150->client, dur, in bma150_set_any_motion_interrupt()
288 error = bma150_write_byte(bma150->client, in bma150_set_any_motion_interrupt()
293 error = bma150_set_reg_bits(bma150->client, !!enable, in bma150_set_any_motion_interrupt()
299 return bma150_set_reg_bits(bma150->client, !!enable, in bma150_set_any_motion_interrupt()
311 ret = i2c_smbus_read_i2c_block_data(bma150->client, in bma150_report_xyz()
324 input_report_abs(bma150->input, ABS_X, x); in bma150_report_xyz()
325 input_report_abs(bma150->input, ABS_Y, y); in bma150_report_xyz()
326 input_report_abs(bma150->input, ABS_Z, z); in bma150_report_xyz()
327 input_sync(bma150->input); in bma150_report_xyz()
349 error = pm_runtime_get_sync(&bma150->client->dev); in bma150_open()
350 if (error < 0 && error != -ENOSYS) in bma150_open()
357 if (bma150->mode != BMA150_MODE_NORMAL) { in bma150_open()
370 pm_runtime_put_sync(&bma150->client->dev); in bma150_close()
372 if (bma150->mode != BMA150_MODE_SLEEP) in bma150_close()
385 error = bma150_set_bandwidth(bma150, cfg->bandwidth); in bma150_initialize()
389 error = bma150_set_range(bma150, cfg->range); in bma150_initialize()
393 if (bma150->client->irq) { in bma150_initialize()
395 cfg->any_motion_int, in bma150_initialize()
396 cfg->any_motion_dur, in bma150_initialize()
397 cfg->any_motion_thres); in bma150_initialize()
402 cfg->hg_int, cfg->hg_hyst, in bma150_initialize()
403 cfg->hg_dur, cfg->hg_thres); in bma150_initialize()
408 cfg->lg_int, cfg->lg_hyst, in bma150_initialize()
409 cfg->lg_dur, cfg->lg_thres); in bma150_initialize()
420 dev_get_platdata(&client->dev); in bma150_probe()
427 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in bma150_probe()
428 dev_err(&client->dev, "i2c_check_functionality error\n"); in bma150_probe()
429 return -EIO; in bma150_probe()
434 dev_err(&client->dev, "BMA150 chip id error: %d\n", chip_id); in bma150_probe()
435 return -EINVAL; in bma150_probe()
438 bma150 = devm_kzalloc(&client->dev, sizeof(*bma150), GFP_KERNEL); in bma150_probe()
440 return -ENOMEM; in bma150_probe()
442 bma150->client = client; in bma150_probe()
445 if (pdata->irq_gpio_cfg) { in bma150_probe()
446 error = pdata->irq_gpio_cfg(); in bma150_probe()
448 dev_err(&client->dev, in bma150_probe()
450 client->irq, error); in bma150_probe()
454 cfg = &pdata->cfg; in bma150_probe()
463 idev = devm_input_allocate_device(&bma150->client->dev); in bma150_probe()
465 return -ENOMEM; in bma150_probe()
468 bma150->input = idev; in bma150_probe()
470 idev->name = BMA150_DRIVER; in bma150_probe()
471 idev->phys = BMA150_DRIVER "/input0"; in bma150_probe()
472 idev->id.bustype = BUS_I2C; in bma150_probe()
474 idev->open = bma150_open; in bma150_probe()
475 idev->close = bma150_close; in bma150_probe()
481 if (client->irq <= 0) { in bma150_probe()
495 if (client->irq > 0) { in bma150_probe()
496 error = devm_request_threaded_irq(&client->dev, client->irq, in bma150_probe()
501 dev_err(&client->dev, in bma150_probe()
503 client->irq, error); in bma150_probe()
510 pm_runtime_enable(&client->dev); in bma150_probe()
517 pm_runtime_disable(&client->dev); in bma150_remove()
560 MODULE_AUTHOR("Albert Zhang <xu.zhang@bosch-sensortec.com>");