drm/modes: Fix drm_mode_vrefres() docs
[drm/drm-misc.git] / drivers / iio / magnetometer / rm3100-spi.c
blobdd6d48043740c12a45f1d10aa26c732128c7db27
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Support for PNI RM3100 3-axis geomagnetic sensor on a spi bus.
5 * Copyright (C) 2018 Song Qiang <songqiang1304521@gmail.com>
6 */
8 #include <linux/module.h>
9 #include <linux/spi/spi.h>
11 #include "rm3100.h"
13 static const struct regmap_config rm3100_regmap_config = {
14 .reg_bits = 8,
15 .val_bits = 8,
17 .rd_table = &rm3100_readable_table,
18 .wr_table = &rm3100_writable_table,
19 .volatile_table = &rm3100_volatile_table,
21 .read_flag_mask = 0x80,
23 .cache_type = REGCACHE_RBTREE,
26 static int rm3100_probe(struct spi_device *spi)
28 struct regmap *regmap;
29 int ret;
31 /* Actually this device supports both mode 0 and mode 3. */
32 spi->mode = SPI_MODE_0;
33 /* Data rates cannot exceed 1Mbits. */
34 spi->max_speed_hz = 1000000;
35 spi->bits_per_word = 8;
36 ret = spi_setup(spi);
37 if (ret)
38 return ret;
40 regmap = devm_regmap_init_spi(spi, &rm3100_regmap_config);
41 if (IS_ERR(regmap))
42 return PTR_ERR(regmap);
44 return rm3100_common_probe(&spi->dev, regmap, spi->irq);
47 static const struct of_device_id rm3100_dt_match[] = {
48 { .compatible = "pni,rm3100", },
49 { }
51 MODULE_DEVICE_TABLE(of, rm3100_dt_match);
53 static struct spi_driver rm3100_driver = {
54 .driver = {
55 .name = "rm3100-spi",
56 .of_match_table = rm3100_dt_match,
58 .probe = rm3100_probe,
60 module_spi_driver(rm3100_driver);
62 MODULE_AUTHOR("Song Qiang <songqiang1304521@gmail.com>");
63 MODULE_DESCRIPTION("PNI RM3100 3-axis magnetometer spi driver");
64 MODULE_LICENSE("GPL v2");
65 MODULE_IMPORT_NS("IIO_RM3100");