stk8312.c (6839c1b0700a79375639528985a0ec0fbd58cf9a) | stk8312.c (0f0796509c07c1c7b77671c05b2955beb245e367) |
---|---|
1/** 2 * Sensortek STK8312 3-Axis Accelerometer 3 * 4 * Copyright (c) 2015, Intel Corporation. 5 * 6 * This file is subject to the terms and conditions of version 2 of 7 * the GNU General Public License. See the file COPYING in the main 8 * directory of this archive for more details. --- 36 unchanged lines hidden (view full) --- 45#define STK8312_RNG_SHIFT 6 46#define STK8312_RNG_MASK GENMASK(7, 6) 47#define STK8312_SR_MASK GENMASK(2, 0) 48#define STK8312_SR_400HZ_IDX 0 49#define STK8312_ALL_CHANNEL_MASK GENMASK(2, 0) 50#define STK8312_ALL_CHANNEL_SIZE 3 51 52#define STK8312_DRIVER_NAME "stk8312" | 1/** 2 * Sensortek STK8312 3-Axis Accelerometer 3 * 4 * Copyright (c) 2015, Intel Corporation. 5 * 6 * This file is subject to the terms and conditions of version 2 of 7 * the GNU General Public License. See the file COPYING in the main 8 * directory of this archive for more details. --- 36 unchanged lines hidden (view full) --- 45#define STK8312_RNG_SHIFT 6 46#define STK8312_RNG_MASK GENMASK(7, 6) 47#define STK8312_SR_MASK GENMASK(2, 0) 48#define STK8312_SR_400HZ_IDX 0 49#define STK8312_ALL_CHANNEL_MASK GENMASK(2, 0) 50#define STK8312_ALL_CHANNEL_SIZE 3 51 52#define STK8312_DRIVER_NAME "stk8312" |
53#define STK8312_GPIO "stk8312_gpio" | |
54#define STK8312_IRQ_NAME "stk8312_event" 55 56/* 57 * The accelerometer has two measurement ranges: 58 * 59 * -6g - +6g (8-bit, signed) 60 * -16g - +16g (8-bit, signed) 61 * --- 437 unchanged lines hidden (view full) --- 499 500static const struct iio_buffer_setup_ops stk8312_buffer_setup_ops = { 501 .preenable = stk8312_buffer_preenable, 502 .postenable = iio_triggered_buffer_postenable, 503 .predisable = iio_triggered_buffer_predisable, 504 .postdisable = stk8312_buffer_postdisable, 505}; 506 | 53#define STK8312_IRQ_NAME "stk8312_event" 54 55/* 56 * The accelerometer has two measurement ranges: 57 * 58 * -6g - +6g (8-bit, signed) 59 * -16g - +16g (8-bit, signed) 60 * --- 437 unchanged lines hidden (view full) --- 498 499static const struct iio_buffer_setup_ops stk8312_buffer_setup_ops = { 500 .preenable = stk8312_buffer_preenable, 501 .postenable = iio_triggered_buffer_postenable, 502 .predisable = iio_triggered_buffer_predisable, 503 .postdisable = stk8312_buffer_postdisable, 504}; 505 |
507static int stk8312_gpio_probe(struct i2c_client *client) 508{ 509 struct device *dev; 510 struct gpio_desc *gpio; 511 int ret; 512 513 if (!client) 514 return -EINVAL; 515 516 dev = &client->dev; 517 518 /* data ready gpio interrupt pin */ 519 gpio = devm_gpiod_get_index(dev, STK8312_GPIO, 0, GPIOD_IN); 520 if (IS_ERR(gpio)) { 521 dev_err(dev, "acpi gpio get index failed\n"); 522 return PTR_ERR(gpio); 523 } 524 525 ret = gpiod_to_irq(gpio); 526 dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret); 527 528 return ret; 529} 530 | |
531static int stk8312_probe(struct i2c_client *client, 532 const struct i2c_device_id *id) 533{ 534 int ret; 535 struct iio_dev *indio_dev; 536 struct stk8312_data *data; 537 538 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); --- 25 unchanged lines hidden (view full) --- 564 if (ret < 0) 565 return ret; 566 567 ret = stk8312_set_mode(data, 568 STK8312_MODE_INT_AH_PP | STK8312_MODE_ACTIVE); 569 if (ret < 0) 570 return ret; 571 | 506static int stk8312_probe(struct i2c_client *client, 507 const struct i2c_device_id *id) 508{ 509 int ret; 510 struct iio_dev *indio_dev; 511 struct stk8312_data *data; 512 513 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); --- 25 unchanged lines hidden (view full) --- 539 if (ret < 0) 540 return ret; 541 542 ret = stk8312_set_mode(data, 543 STK8312_MODE_INT_AH_PP | STK8312_MODE_ACTIVE); 544 if (ret < 0) 545 return ret; 546 |
572 if (client->irq < 0) 573 client->irq = stk8312_gpio_probe(client); 574 | |
575 if (client->irq > 0) { 576 ret = devm_request_threaded_irq(&client->dev, client->irq, 577 stk8312_data_rdy_trig_poll, 578 NULL, 579 IRQF_TRIGGER_RISING | 580 IRQF_ONESHOT, 581 STK8312_IRQ_NAME, 582 indio_dev); --- 121 unchanged lines hidden --- | 547 if (client->irq > 0) { 548 ret = devm_request_threaded_irq(&client->dev, client->irq, 549 stk8312_data_rdy_trig_poll, 550 NULL, 551 IRQF_TRIGGER_RISING | 552 IRQF_ONESHOT, 553 STK8312_IRQ_NAME, 554 indio_dev); --- 121 unchanged lines hidden --- |