blob: a0d192211839f8e0638bbdfec74942db6cbc7fee [file] [log] [blame]
Sean Nyekjaera3e0b512021-05-06 09:09:35 +02001// SPDX-License-Identifier: GPL-2.0
2/*
3 * NXP FXLS8962AF/FXLS8964AF Accelerometer SPI Driver
4 *
5 * Copyright 2021 Connected Cars A/S
6 */
7
8#include <linux/dev_printk.h>
9#include <linux/err.h>
10#include <linux/module.h>
11#include <linux/mod_devicetable.h>
12#include <linux/spi/spi.h>
13#include <linux/regmap.h>
14
15#include "fxls8962af.h"
16
17static int fxls8962af_probe(struct spi_device *spi)
18{
19 struct regmap *regmap;
20
Sean Nyekjaerccbed9d2021-12-20 13:51:43 +010021 regmap = devm_regmap_init_spi(spi, &fxls8962af_spi_regmap_conf);
Sean Nyekjaera3e0b512021-05-06 09:09:35 +020022 if (IS_ERR(regmap)) {
23 dev_err(&spi->dev, "Failed to initialize spi regmap\n");
24 return PTR_ERR(regmap);
25 }
26
27 return fxls8962af_core_probe(&spi->dev, regmap, spi->irq);
28}
29
30static const struct of_device_id fxls8962af_spi_of_match[] = {
31 { .compatible = "nxp,fxls8962af" },
32 { .compatible = "nxp,fxls8964af" },
33 {}
34};
35MODULE_DEVICE_TABLE(of, fxls8962af_spi_of_match);
36
37static const struct spi_device_id fxls8962af_spi_id_table[] = {
38 { "fxls8962af", fxls8962af },
39 { "fxls8964af", fxls8964af },
40 {}
41};
42MODULE_DEVICE_TABLE(spi, fxls8962af_spi_id_table);
43
44static struct spi_driver fxls8962af_driver = {
45 .driver = {
46 .name = "fxls8962af_spi",
Jonathan Cameron687c8842022-09-25 16:57:16 +010047 .pm = pm_ptr(&fxls8962af_pm_ops),
Sean Nyekjaera3e0b512021-05-06 09:09:35 +020048 .of_match_table = fxls8962af_spi_of_match,
49 },
50 .probe = fxls8962af_probe,
51 .id_table = fxls8962af_spi_id_table,
52};
53module_spi_driver(fxls8962af_driver);
54
55MODULE_AUTHOR("Sean Nyekjaer <sean@geanix.com>");
56MODULE_DESCRIPTION("NXP FXLS8962AF/FXLS8964AF accelerometer spi driver");
57MODULE_LICENSE("GPL v2");
Jonathan Cameronfbbd2862022-01-16 18:05:33 +000058MODULE_IMPORT_NS(IIO_FXLS8962AF);