blob: 27e694cce173e05f2312c4b8b6ef6a0a1cc40d0a [file] [log] [blame]
Robert Jones84e5ddd2019-10-14 11:49:21 -07001// SPDX-License-Identifier: GPL-2.0
2/*
3 * FXOS8700 - NXP IMU, SPI bits
4 */
5#include <linux/acpi.h>
6#include <linux/module.h>
7#include <linux/mod_devicetable.h>
8#include <linux/regmap.h>
9#include <linux/spi/spi.h>
10
11#include "fxos8700.h"
12
13static int fxos8700_spi_probe(struct spi_device *spi)
14{
15 struct regmap *regmap;
16 const struct spi_device_id *id = spi_get_device_id(spi);
17
18 regmap = devm_regmap_init_spi(spi, &fxos8700_regmap_config);
19 if (IS_ERR(regmap)) {
Andy Shevchenko897cd102021-03-12 15:45:38 +020020 dev_err(&spi->dev, "Failed to register spi regmap %ld\n", PTR_ERR(regmap));
Robert Jones84e5ddd2019-10-14 11:49:21 -070021 return PTR_ERR(regmap);
22 }
23
24 return fxos8700_core_probe(&spi->dev, regmap, id->name, true);
25}
26
27static const struct spi_device_id fxos8700_spi_id[] = {
28 {"fxos8700", 0},
29 { }
30};
31MODULE_DEVICE_TABLE(spi, fxos8700_spi_id);
32
33static const struct acpi_device_id fxos8700_acpi_match[] = {
34 {"FXOS8700", 0},
35 { }
36};
37MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
38
39static const struct of_device_id fxos8700_of_match[] = {
40 { .compatible = "nxp,fxos8700" },
41 { }
42};
43MODULE_DEVICE_TABLE(of, fxos8700_of_match);
44
45static struct spi_driver fxos8700_spi_driver = {
46 .probe = fxos8700_spi_probe,
47 .id_table = fxos8700_spi_id,
48 .driver = {
49 .acpi_match_table = ACPI_PTR(fxos8700_acpi_match),
50 .of_match_table = fxos8700_of_match,
51 .name = "fxos8700_spi",
52 },
53};
54module_spi_driver(fxos8700_spi_driver);
55
56MODULE_AUTHOR("Robert Jones <rjones@gateworks.com>");
57MODULE_DESCRIPTION("FXOS8700 SPI driver");
58MODULE_LICENSE("GPL v2");