Commit 12ed2786 authored by Puranjay Mohan's avatar Puranjay Mohan Committed by Jonathan Cameron

iio: accel: Add driver support for ADXL355

ADXL355 is a 3-axis MEMS Accelerometer. It offers low noise density,
low 0g offset drift, low power with selectable measurement ranges.
It also features programmable high-pass and low-pass filters.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/adxl354_adxl355.pdfReviewed-by: default avatarAlexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarPuranjay Mohan <puranjay12@gmail.com>
Link: https://lore.kernel.org/r/20210811073027.124619-3-puranjay12@gmail.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent bf43a71a
......@@ -598,6 +598,16 @@ W: http://ez.analog.com/community/linux-device-drivers
F: Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml
F: drivers/input/misc/adxl34x.c
ADXL355 THREE-AXIS DIGITAL ACCELEROMETER DRIVER
M: Puranjay Mohan <puranjay12@gmail.com>
L: linux-iio@vger.kernel.org
S: Supported
F: Documentation/devicetree/bindings/iio/accel/adi,adxl355.yaml
F: drivers/iio/accel/adxl355.h
F: drivers/iio/accel/adxl355_core.c
F: drivers/iio/accel/adxl355_i2c.c
F: drivers/iio/accel/adxl355_spi.c
ADXL372 THREE-AXIS DIGITAL ACCELEROMETER DRIVER
M: Michael Hennerich <michael.hennerich@analog.com>
S: Supported
......
......@@ -61,6 +61,35 @@ config ADXL345_SPI
will be called adxl345_spi and you will also get adxl345_core
for the core module.
config ADXL355
tristate
config ADXL355_I2C
tristate "Analog Devices ADXL355 3-Axis Digital Accelerometer I2C Driver"
depends on I2C
select ADXL355
select REGMAP_I2C
help
Say Y here if you want to build i2c support for the Analog Devices
ADXL355 3-axis digital accelerometer.
To compile this driver as a module, choose M here: the module
will be called adxl355_i2c and you will also get adxl355_core
for the core module.
config ADXL355_SPI
tristate "Analog Devices ADXL355 3-Axis Digital Accelerometer SPI Driver"
depends on SPI
select ADXL355
select REGMAP_SPI
help
Say Y here if you want to build spi support for the Analog Devices
ADXL355 3-axis digital accelerometer.
To compile this driver as a module, choose M here: the module
will be called adxl355_spi and you will also get adxl355_core
for the core module.
config ADXL372
tristate
select IIO_BUFFER
......
......@@ -9,6 +9,9 @@ obj-$(CONFIG_ADIS16209) += adis16209.o
obj-$(CONFIG_ADXL345) += adxl345_core.o
obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o
obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o
obj-$(CONFIG_ADXL355) += adxl355_core.o
obj-$(CONFIG_ADXL355_I2C) += adxl355_i2c.o
obj-$(CONFIG_ADXL355_SPI) += adxl355_spi.o
obj-$(CONFIG_ADXL372) += adxl372.o
obj-$(CONFIG_ADXL372_I2C) += adxl372_i2c.o
obj-$(CONFIG_ADXL372_SPI) += adxl372_spi.o
......
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* ADXL355 3-Axis Digital Accelerometer
*
* Copyright (c) 2021 Puranjay Mohan <puranjay12@gmail.com>
*/
#ifndef _ADXL355_H_
#define _ADXL355_H_
#include <linux/regmap.h>
struct device;
extern const struct regmap_access_table adxl355_readable_regs_tbl;
extern const struct regmap_access_table adxl355_writeable_regs_tbl;
int adxl355_core_probe(struct device *dev, struct regmap *regmap,
const char *name);
#endif /* _ADXL355_H_ */
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
/*
* ADXL355 3-Axis Digital Accelerometer I2C driver
*
* Copyright (c) 2021 Puranjay Mohan <puranjay12@gmail.com>
*/
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/regmap.h>
#include "adxl355.h"
static const struct regmap_config adxl355_i2c_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x2F,
.rd_table = &adxl355_readable_regs_tbl,
.wr_table = &adxl355_writeable_regs_tbl,
};
static int adxl355_i2c_probe(struct i2c_client *client)
{
struct regmap *regmap;
regmap = devm_regmap_init_i2c(client, &adxl355_i2c_regmap_config);
if (IS_ERR(regmap)) {
dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
PTR_ERR(regmap));
return PTR_ERR(regmap);
}
return adxl355_core_probe(&client->dev, regmap, client->name);
}
static const struct i2c_device_id adxl355_i2c_id[] = {
{ "adxl355", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adxl355_i2c_id);
static const struct of_device_id adxl355_of_match[] = {
{ .compatible = "adi,adxl355" },
{ }
};
MODULE_DEVICE_TABLE(of, adxl355_of_match);
static struct i2c_driver adxl355_i2c_driver = {
.driver = {
.name = "adxl355_i2c",
.of_match_table = adxl355_of_match,
},
.probe_new = adxl355_i2c_probe,
.id_table = adxl355_i2c_id,
};
module_i2c_driver(adxl355_i2c_driver);
MODULE_AUTHOR("Puranjay Mohan <puranjay12@gmail.com>");
MODULE_DESCRIPTION("ADXL355 3-Axis Digital Accelerometer I2C driver");
MODULE_LICENSE("GPL v2");
// SPDX-License-Identifier: GPL-2.0-only
/*
* ADXL355 3-Axis Digital Accelerometer SPI driver
*
* Copyright (c) 2021 Puranjay Mohan <puranjay12@gmail.com>
*/
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
#include "adxl355.h"
static const struct regmap_config adxl355_spi_regmap_config = {
.reg_bits = 7,
.pad_bits = 1,
.val_bits = 8,
.read_flag_mask = BIT(0),
.max_register = 0x2F,
.rd_table = &adxl355_readable_regs_tbl,
.wr_table = &adxl355_writeable_regs_tbl,
};
static int adxl355_spi_probe(struct spi_device *spi)
{
const struct spi_device_id *id = spi_get_device_id(spi);
struct regmap *regmap;
regmap = devm_regmap_init_spi(spi, &adxl355_spi_regmap_config);
if (IS_ERR(regmap)) {
dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
PTR_ERR(regmap));
return PTR_ERR(regmap);
}
return adxl355_core_probe(&spi->dev, regmap, id->name);
}
static const struct spi_device_id adxl355_spi_id[] = {
{ "adxl355", 0 },
{ }
};
MODULE_DEVICE_TABLE(spi, adxl355_spi_id);
static const struct of_device_id adxl355_of_match[] = {
{ .compatible = "adi,adxl355" },
{ }
};
MODULE_DEVICE_TABLE(of, adxl355_of_match);
static struct spi_driver adxl355_spi_driver = {
.driver = {
.name = "adxl355_spi",
.of_match_table = adxl355_of_match,
},
.probe = adxl355_spi_probe,
.id_table = adxl355_spi_id,
};
module_spi_driver(adxl355_spi_driver);
MODULE_AUTHOR("Puranjay Mohan <puranjay12@gmail.com>");
MODULE_DESCRIPTION("ADXL355 3-Axis Digital Accelerometer SPI driver");
MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment