zpa2326.c (c95baf12f5077419db01313ab61c2aac007d40cd) zpa2326.c (e8ee40e77531a61fd85195011a75521eb3d22c8c)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Murata ZPA2326 pressure and temperature sensor IIO driver
4 *
5 * Copyright (c) 2016 Parrot S.A.
6 *
7 * Author: Gregor Boirie <gregor.boirie@parrot.com>
8 */

--- 50 unchanged lines hidden (view full) ---

59#include <linux/pm_runtime.h>
60#include <linux/regmap.h>
61#include <linux/iio/iio.h>
62#include <linux/iio/sysfs.h>
63#include <linux/iio/buffer.h>
64#include <linux/iio/trigger.h>
65#include <linux/iio/trigger_consumer.h>
66#include <linux/iio/triggered_buffer.h>
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Murata ZPA2326 pressure and temperature sensor IIO driver
4 *
5 * Copyright (c) 2016 Parrot S.A.
6 *
7 * Author: Gregor Boirie <gregor.boirie@parrot.com>
8 */

--- 50 unchanged lines hidden (view full) ---

59#include <linux/pm_runtime.h>
60#include <linux/regmap.h>
61#include <linux/iio/iio.h>
62#include <linux/iio/sysfs.h>
63#include <linux/iio/buffer.h>
64#include <linux/iio/trigger.h>
65#include <linux/iio/trigger_consumer.h>
66#include <linux/iio/triggered_buffer.h>
67#include <asm/unaligned.h>
67#include "zpa2326.h"
68
69/* 200 ms should be enough for the longest conversion time in one-shot mode. */
70#define ZPA2326_CONVERSION_JIFFIES (HZ / 5)
71
72/* There should be a 1 ms delay (Tpup) after getting out of reset. */
73#define ZPA2326_TPUP_USEC_MIN (1000)
74#define ZPA2326_TPUP_USEC_MAX (2000)

--- 925 unchanged lines hidden (view full) ---

1000 */
1001static int zpa2326_fetch_raw_sample(const struct iio_dev *indio_dev,
1002 enum iio_chan_type type,
1003 int *value)
1004{
1005 struct regmap *regs = ((struct zpa2326_private *)
1006 iio_priv(indio_dev))->regmap;
1007 int err;
68#include "zpa2326.h"
69
70/* 200 ms should be enough for the longest conversion time in one-shot mode. */
71#define ZPA2326_CONVERSION_JIFFIES (HZ / 5)
72
73/* There should be a 1 ms delay (Tpup) after getting out of reset. */
74#define ZPA2326_TPUP_USEC_MIN (1000)
75#define ZPA2326_TPUP_USEC_MAX (2000)

--- 925 unchanged lines hidden (view full) ---

1001 */
1002static int zpa2326_fetch_raw_sample(const struct iio_dev *indio_dev,
1003 enum iio_chan_type type,
1004 int *value)
1005{
1006 struct regmap *regs = ((struct zpa2326_private *)
1007 iio_priv(indio_dev))->regmap;
1008 int err;
1009 u8 v[3];
1008
1009 switch (type) {
1010 case IIO_PRESSURE:
1011 zpa2326_dbg(indio_dev, "fetching raw pressure sample");
1012
1010
1011 switch (type) {
1012 case IIO_PRESSURE:
1013 zpa2326_dbg(indio_dev, "fetching raw pressure sample");
1014
1013 err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, value,
1014 3);
1015 err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, v, sizeof(v));
1015 if (err) {
1016 zpa2326_warn(indio_dev, "failed to fetch pressure (%d)",
1017 err);
1018 return err;
1019 }
1020
1016 if (err) {
1017 zpa2326_warn(indio_dev, "failed to fetch pressure (%d)",
1018 err);
1019 return err;
1020 }
1021
1021 /* Pressure is a 24 bits wide little-endian unsigned int. */
1022 *value = (((u8 *)value)[2] << 16) | (((u8 *)value)[1] << 8) |
1023 ((u8 *)value)[0];
1022 *value = get_unaligned_le24(&v[0]);
1024
1025 return IIO_VAL_INT;
1026
1027 case IIO_TEMP:
1028 zpa2326_dbg(indio_dev, "fetching raw temperature sample");
1029
1030 err = regmap_bulk_read(regs, ZPA2326_TEMP_OUT_L_REG, value, 2);
1031 if (err) {

--- 692 unchanged lines hidden ---
1023
1024 return IIO_VAL_INT;
1025
1026 case IIO_TEMP:
1027 zpa2326_dbg(indio_dev, "fetching raw temperature sample");
1028
1029 err = regmap_bulk_read(regs, ZPA2326_TEMP_OUT_L_REG, value, 2);
1030 if (err) {

--- 692 unchanged lines hidden ---