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

hts221_i2c.c (1858B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * STMicroelectronics hts221 i2c driver
      4 *
      5 * Copyright 2016 STMicroelectronics Inc.
      6 *
      7 * Lorenzo Bianconi <lorenzo.bianconi@st.com>
      8 */
      9
     10#include <linux/kernel.h>
     11#include <linux/module.h>
     12#include <linux/acpi.h>
     13#include <linux/i2c.h>
     14#include <linux/slab.h>
     15#include <linux/regmap.h>
     16
     17#include "hts221.h"
     18
     19#define HTS221_I2C_AUTO_INCREMENT	BIT(7)
     20
     21static const struct regmap_config hts221_i2c_regmap_config = {
     22	.reg_bits = 8,
     23	.val_bits = 8,
     24	.write_flag_mask = HTS221_I2C_AUTO_INCREMENT,
     25	.read_flag_mask = HTS221_I2C_AUTO_INCREMENT,
     26};
     27
     28static int hts221_i2c_probe(struct i2c_client *client,
     29			    const struct i2c_device_id *id)
     30{
     31	struct regmap *regmap;
     32
     33	regmap = devm_regmap_init_i2c(client, &hts221_i2c_regmap_config);
     34	if (IS_ERR(regmap)) {
     35		dev_err(&client->dev, "Failed to register i2c regmap %ld\n",
     36			PTR_ERR(regmap));
     37		return PTR_ERR(regmap);
     38	}
     39
     40	return hts221_probe(&client->dev, client->irq,
     41			    client->name, regmap);
     42}
     43
     44static const struct acpi_device_id hts221_acpi_match[] = {
     45	{"SMO9100", 0},
     46	{ },
     47};
     48MODULE_DEVICE_TABLE(acpi, hts221_acpi_match);
     49
     50static const struct of_device_id hts221_i2c_of_match[] = {
     51	{ .compatible = "st,hts221", },
     52	{},
     53};
     54MODULE_DEVICE_TABLE(of, hts221_i2c_of_match);
     55
     56static const struct i2c_device_id hts221_i2c_id_table[] = {
     57	{ HTS221_DEV_NAME },
     58	{},
     59};
     60MODULE_DEVICE_TABLE(i2c, hts221_i2c_id_table);
     61
     62static struct i2c_driver hts221_driver = {
     63	.driver = {
     64		.name = "hts221_i2c",
     65		.pm = &hts221_pm_ops,
     66		.of_match_table = hts221_i2c_of_match,
     67		.acpi_match_table = ACPI_PTR(hts221_acpi_match),
     68	},
     69	.probe = hts221_i2c_probe,
     70	.id_table = hts221_i2c_id_table,
     71};
     72module_i2c_driver(hts221_driver);
     73
     74MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
     75MODULE_DESCRIPTION("STMicroelectronics hts221 i2c driver");
     76MODULE_LICENSE("GPL v2");