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-accel.h (2727B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef _BMC150_ACCEL_H_
      3#define _BMC150_ACCEL_H_
      4
      5#include <linux/atomic.h>
      6#include <linux/iio/iio.h>
      7#include <linux/mutex.h>
      8#include <linux/regulator/consumer.h>
      9#include <linux/workqueue.h>
     10
     11struct regmap;
     12struct i2c_client;
     13struct bmc150_accel_chip_info;
     14struct bmc150_accel_interrupt_info;
     15
     16/*
     17 * We can often guess better than "UNKNOWN" based on the device IDs
     18 * but unfortunately this information is not always accurate. There are some
     19 * devices where ACPI firmware specifies an ID like "BMA250E" when the device
     20 * actually has a BMA222E. The driver attempts to detect those by reading the
     21 * chip ID from the registers but this information is not always enough either.
     22 *
     23 * Therefore, this enum should be only used when the chip ID detection is not
     24 * enough and we can be reasonably sure that the device IDs are reliable
     25 * in practice (e.g. for device tree platforms).
     26 */
     27enum bmc150_type {
     28	BOSCH_UNKNOWN,
     29	BOSCH_BMC156,
     30};
     31
     32struct bmc150_accel_interrupt {
     33	const struct bmc150_accel_interrupt_info *info;
     34	atomic_t users;
     35};
     36
     37struct bmc150_accel_trigger {
     38	struct bmc150_accel_data *data;
     39	struct iio_trigger *indio_trig;
     40	int (*setup)(struct bmc150_accel_trigger *t, bool state);
     41	int intr;
     42	bool enabled;
     43};
     44
     45enum bmc150_accel_interrupt_id {
     46	BMC150_ACCEL_INT_DATA_READY,
     47	BMC150_ACCEL_INT_ANY_MOTION,
     48	BMC150_ACCEL_INT_WATERMARK,
     49	BMC150_ACCEL_INTERRUPTS,
     50};
     51
     52enum bmc150_accel_trigger_id {
     53	BMC150_ACCEL_TRIGGER_DATA_READY,
     54	BMC150_ACCEL_TRIGGER_ANY_MOTION,
     55	BMC150_ACCEL_TRIGGERS,
     56};
     57
     58struct bmc150_accel_data {
     59	struct regmap *regmap;
     60	struct regulator_bulk_data regulators[2];
     61	struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
     62	struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
     63	struct mutex mutex;
     64	u8 fifo_mode, watermark;
     65	s16 buffer[8];
     66	/*
     67	 * Ensure there is sufficient space and correct alignment for
     68	 * the timestamp if enabled
     69	 */
     70	struct {
     71		__le16 channels[3];
     72		s64 ts __aligned(8);
     73	} scan;
     74	u8 bw_bits;
     75	u32 slope_dur;
     76	u32 slope_thres;
     77	u32 range;
     78	int ev_enable_state;
     79	int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
     80	const struct bmc150_accel_chip_info *chip_info;
     81	enum bmc150_type type;
     82	struct i2c_client *second_device;
     83	void (*resume_callback)(struct device *dev);
     84	struct delayed_work resume_work;
     85	struct iio_mount_matrix orientation;
     86};
     87
     88int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
     89			    enum bmc150_type type, const char *name,
     90			    bool block_supported);
     91void bmc150_accel_core_remove(struct device *dev);
     92extern const struct dev_pm_ops bmc150_accel_pm_ops;
     93extern const struct regmap_config bmc150_regmap_conf;
     94
     95#endif  /* _BMC150_ACCEL_H_ */