-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADIS16550 #2510
base: main
Are you sure you want to change the base?
ADIS16550 #2510
Changes from all commits
11ff077
0029b76
4f79001
6217106
12fd7ce
cedd2c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/iio/imu/adi,adis16550.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: Analog Devices ADIS16550 and similar IMUs | ||
|
||
maintainers: | ||
- Nuno Sa <[email protected]> | ||
- Ramona Gradinariu <[email protected]> | ||
- Antoniu Miclaus <[email protected]> | ||
|
||
properties: | ||
compatible: | ||
enum: | ||
- adi,adis16550 | ||
- adi,adis16550w | ||
|
||
reg: | ||
maxItems: 1 | ||
|
||
spi-cpha: true | ||
|
||
spi-cpol: true | ||
|
||
spi-max-frequency: | ||
maximum: 15000000 | ||
|
||
vdd-supply: true | ||
|
||
interrupts: | ||
maxItems: 1 | ||
|
||
reset-gpios: | ||
description: | ||
Must be the device tree identifier of the RESET pin. If specified, | ||
it will be asserted during driver probe. As the line is active low, | ||
it should be marked GPIO_ACTIVE_LOW. | ||
maxItems: 1 | ||
|
||
clocks: | ||
maxItems: 1 | ||
description: If not provided, then the internal clock is used. | ||
|
||
adi,sync-mode: | ||
$ref: /schemas/types.yaml#/definitions/string | ||
description: | | ||
Configures the device SYNC pin. | ||
enum: | ||
- direct_sync | ||
- scaled_sync | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- interrupts | ||
- spi-cpha | ||
- spi-cpol | ||
- spi-max-frequency | ||
- vdd-supply | ||
|
||
allOf: | ||
- if: | ||
properties: | ||
adi,sync-mode: | ||
enum: [direct_sync, scaled_sync] | ||
|
||
then: | ||
dependencies: | ||
adi,sync-mode: [ clocks ] | ||
|
||
- $ref: /schemas/spi/spi-peripheral-props.yaml# | ||
|
||
additionalProperties: false | ||
|
||
examples: | ||
- | | ||
#include <dt-bindings/interrupt-controller/irq.h> | ||
spi { | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
|
||
imu@0 { | ||
compatible = "adi,adis16550"; | ||
reg = <0>; | ||
spi-max-frequency = <15000000>; | ||
spi-cpol; | ||
spi-cpha; | ||
vdd-supply = <&vdd>; | ||
interrupts = <4 IRQ_TYPE_EDGE_FALLING>; | ||
interrupt-parent = <&gpio>; | ||
}; | ||
}; | ||
... |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Industrial I/O Kernel Drivers | |
|
||
adis16475 | ||
adis16480 | ||
adis16550 | ||
adxl380 | ||
bno055 | ||
ep93xx_adc |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1304,6 +1304,16 @@ S: Supported | |
F: drivers/iio/imu/adis16475.c | ||
F: Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml | ||
|
||
ANALOG DEVICES INC ADIS16550 DRIVER | ||
M: Nuno Sa <[email protected]> | ||
M: Ramona Gradinariu <[email protected]> | ||
M: Antoniu Miclaus <[email protected]> | ||
L: [email protected] | ||
S: Supported | ||
W: https://ez.analog.com/linux-software-drivers | ||
F: Documentation/devicetree/bindings/iio/imu/adi,adis16550.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is introduced in the bindings patch. Hence, the entry should be introduced in that patch... |
||
F: drivers/iio/imu/adis16550.c | ||
|
||
ANALOG DEVICES INC ADM1177 DRIVER | ||
M: Michael Hennerich <[email protected]> | ||
L: [email protected] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,13 +223,13 @@ int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask, | |
int ret; | ||
u32 __val; | ||
|
||
ret = __adis_read_reg(adis, reg, &__val, size); | ||
ret = adis->ops->read(adis, reg, &__val, size); | ||
if (ret) | ||
return ret; | ||
|
||
__val = (__val & ~mask) | (val & mask); | ||
|
||
return __adis_write_reg(adis, reg, __val, size); | ||
return adis->ops->write(adis, reg, __val, size); | ||
} | ||
EXPORT_SYMBOL_NS_GPL(__adis_update_bits_base, IIO_ADISLIB); | ||
|
||
|
@@ -304,11 +304,17 @@ EXPORT_SYMBOL_NS(__adis_enable_irq, IIO_ADISLIB); | |
*/ | ||
int __adis_check_status(struct adis *adis) | ||
{ | ||
u16 status; | ||
unsigned int status = 0; | ||
int ret; | ||
int i; | ||
/* default to 2 bytes */ | ||
unsigned int reg_size = 2; | ||
|
||
ret = __adis_read_reg_16(adis, adis->data->diag_stat_reg, &status); | ||
if (adis->data->diag_stat_size) | ||
reg_size = adis->data->diag_stat_size; | ||
|
||
ret = adis->ops->read(adis, adis->data->diag_stat_reg, &status, | ||
reg_size); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the above call should likely be in patch 1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in patch 1 there is already an update of |
||
if (ret) | ||
return ret; | ||
|
||
|
@@ -317,7 +323,7 @@ int __adis_check_status(struct adis *adis) | |
if (status == 0) | ||
return 0; | ||
|
||
for (i = 0; i < 16; ++i) { | ||
for (i = 0; i < (reg_size * 8); ++i) { | ||
if (status & BIT(i)) { | ||
dev_err(&adis->spi->dev, "%s.\n", | ||
adis->data->status_error_msgs[i]); | ||
|
@@ -339,8 +345,11 @@ int __adis_reset(struct adis *adis) | |
int ret; | ||
const struct adis_timeout *timeouts = adis->data->timeouts; | ||
|
||
ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg, | ||
ADIS_GLOB_CMD_SW_RESET); | ||
if (adis->ops->reset) | ||
ret = adis->ops->reset(adis); | ||
else | ||
ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg, | ||
ADIS_GLOB_CMD_SW_RESET); | ||
if (ret) { | ||
dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret); | ||
return ret; | ||
|
@@ -468,7 +477,7 @@ int adis_single_conversion(struct iio_dev *indio_dev, | |
|
||
mutex_lock(&adis->state_lock); | ||
|
||
ret = __adis_read_reg(adis, chan->address, &uval, | ||
ret = adis->ops->read(adis, chan->address, &uval, | ||
chan->scan_type.storagebits / 8); | ||
if (ret) | ||
goto err_unlock; | ||
|
@@ -491,6 +500,11 @@ int adis_single_conversion(struct iio_dev *indio_dev, | |
} | ||
EXPORT_SYMBOL_NS_GPL(adis_single_conversion, IIO_ADISLIB); | ||
|
||
static const struct adis_ops adis_default_ops = { | ||
.read = __adis_read_reg, | ||
.write = __adis_write_reg, | ||
}; | ||
|
||
/** | ||
* adis_init() - Initialize adis device structure | ||
* @adis: The adis device | ||
|
@@ -520,6 +534,9 @@ int adis_init(struct adis *adis, struct iio_dev *indio_dev, | |
|
||
adis->spi = spi; | ||
adis->data = data; | ||
if (!adis->ops->write || !adis->ops->read) | ||
adis->ops = &adis_default_ops; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we are assuming we always have write() and read() we should sanity check it here (for ops given by drivers). |
||
|
||
iio_device_set_drvdata(indio_dev, adis); | ||
|
||
if (data->has_paging) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I'm here, I should likely be also in the bindings patch