brintos

brintos / linux-shallow public Read only

0
0
Text · 1.4 KiB · 7876997 Raw
62 lines · c
1// SPDX-License-Identifier: GPL-2.0+2/*3 * ADXL372 3-Axis Digital Accelerometer SPI driver4 *5 * Copyright 2018 Analog Devices Inc.6 */7 8#include <linux/module.h>9#include <linux/mod_devicetable.h>10#include <linux/regmap.h>11#include <linux/spi/spi.h>12 13#include "adxl372.h"14 15static const struct regmap_config adxl372_spi_regmap_config = {16	.reg_bits = 7,17	.pad_bits = 1,18	.val_bits = 8,19	.read_flag_mask = BIT(0),20	.readable_noinc_reg = adxl372_readable_noinc_reg,21};22 23static int adxl372_spi_probe(struct spi_device *spi)24{25	const struct spi_device_id *id = spi_get_device_id(spi);26	struct regmap *regmap;27 28	regmap = devm_regmap_init_spi(spi, &adxl372_spi_regmap_config);29	if (IS_ERR(regmap))30		return PTR_ERR(regmap);31 32	return adxl372_probe(&spi->dev, regmap, spi->irq, id->name);33}34 35static const struct spi_device_id adxl372_spi_id[] = {36	{ "adxl372", 0 },37	{}38};39MODULE_DEVICE_TABLE(spi, adxl372_spi_id);40 41static const struct of_device_id adxl372_of_match[] = {42	{ .compatible = "adi,adxl372" },43	{ }44};45MODULE_DEVICE_TABLE(of, adxl372_of_match);46 47static struct spi_driver adxl372_spi_driver = {48	.driver = {49		.name = "adxl372_spi",50		.of_match_table = adxl372_of_match,51	},52	.probe = adxl372_spi_probe,53	.id_table = adxl372_spi_id,54};55 56module_spi_driver(adxl372_spi_driver);57 58MODULE_AUTHOR("Stefan Popa <stefan.popa@analog.com>");59MODULE_DESCRIPTION("Analog Devices ADXL372 3-axis accelerometer SPI driver");60MODULE_LICENSE("GPL");61MODULE_IMPORT_NS(IIO_ADXL372);62