cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

bmc150_magn_spi.c (1696B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * 3-axis magnetometer driver support following SPI Bosch-Sensortec chips:
      4 *  - BMC150
      5 *  - BMC156
      6 *  - BMM150
      7 *
      8 * Copyright (c) 2016, Intel Corporation.
      9 */
     10#include <linux/module.h>
     11#include <linux/mod_devicetable.h>
     12#include <linux/spi/spi.h>
     13#include <linux/acpi.h>
     14#include <linux/regmap.h>
     15
     16#include "bmc150_magn.h"
     17
     18static int bmc150_magn_spi_probe(struct spi_device *spi)
     19{
     20	struct regmap *regmap;
     21	const struct spi_device_id *id = spi_get_device_id(spi);
     22
     23	regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config);
     24	if (IS_ERR(regmap)) {
     25		dev_err(&spi->dev, "Failed to register spi regmap: %pe\n",
     26			regmap);
     27		return PTR_ERR(regmap);
     28	}
     29	return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name);
     30}
     31
     32static void bmc150_magn_spi_remove(struct spi_device *spi)
     33{
     34	bmc150_magn_remove(&spi->dev);
     35}
     36
     37static const struct spi_device_id bmc150_magn_spi_id[] = {
     38	{"bmc150_magn", 0},
     39	{"bmc156_magn", 0},
     40	{"bmm150_magn", 0},
     41	{}
     42};
     43MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id);
     44
     45static const struct acpi_device_id bmc150_magn_acpi_match[] = {
     46	{"BMC150B", 0},
     47	{"BMC156B", 0},
     48	{"BMM150B", 0},
     49	{},
     50};
     51MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
     52
     53static struct spi_driver bmc150_magn_spi_driver = {
     54	.probe		= bmc150_magn_spi_probe,
     55	.remove		= bmc150_magn_spi_remove,
     56	.id_table	= bmc150_magn_spi_id,
     57	.driver = {
     58		.acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match),
     59		.name	= "bmc150_magn_spi",
     60	},
     61};
     62module_spi_driver(bmc150_magn_spi_driver);
     63
     64MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
     65MODULE_DESCRIPTION("BMC150 magnetometer SPI driver");
     66MODULE_LICENSE("GPL v2");
     67MODULE_IMPORT_NS(IIO_BMC150_MAGN);