BigW Consortium Gitlab

Commit 995bf33f by Ashish Syal

Made BMM150 driver work for WP85/75 and WP76/77

parent bf19fad9
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
*/ */
#include <linux/version.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -103,6 +103,9 @@ ...@@ -103,6 +103,9 @@
#define BMC150_MAGN_REPXY_TO_REGVAL(rep) (((rep) - 1) / 2) #define BMC150_MAGN_REPXY_TO_REGVAL(rep) (((rep) - 1) / 2)
#define BMC150_MAGN_REPZ_TO_REGVAL(rep) ((rep) - 1) #define BMC150_MAGN_REPZ_TO_REGVAL(rep) ((rep) - 1)
enum bmc150_magn_axis { enum bmc150_magn_axis {
AXIS_X, AXIS_X,
AXIS_Y, AXIS_Y,
...@@ -150,6 +153,37 @@ struct bmc150_magn_data { ...@@ -150,6 +153,37 @@ struct bmc150_magn_data {
int max_odr; int max_odr;
int irq; int irq;
}; };
#if 0
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
/**
* iio_device_set_drvdata() - Set trigger driver data
* @trig: IIO trigger structure
* @data: Driver specific data
*
* Allows to attach an arbitrary pointer to an IIO trigger, which can later be
* retrieved by iio_trigger_get_drvdata().
*/
static inline void iio_trigger_set_drvdata(struct iio_trigger *trig, void *data)
{
dev_set_drvdata(&trig->dev, data);
}
/**
* iio_trigger_get_drvdata() - Get trigger driver data
* @trig: IIO trigger structure
*
* Returns the data previously set with iio_trigger_set_drvdata()
*/
static inline void *iio_trigger_get_drvdata(struct iio_trigger *trig)
{
return dev_get_drvdata(&trig->dev);
}
#endif
#endif
static const struct { static const struct {
int freq; int freq;
...@@ -463,7 +497,8 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev, ...@@ -463,7 +497,8 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
struct bmc150_magn_data *data = iio_priv(indio_dev); struct bmc150_magn_data *data = iio_priv(indio_dev);
int ret, tmp; //int ret, tmp;
int ret;
s32 values[AXIS_XYZ_MAX]; s32 values[AXIS_XYZ_MAX];
switch (mask) { switch (mask) {
...@@ -508,6 +543,7 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev, ...@@ -508,6 +543,7 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev,
if (ret < 0) if (ret < 0)
return ret; return ret;
return IIO_VAL_INT; return IIO_VAL_INT;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
case IIO_CHAN_INFO_OVERSAMPLING_RATIO: case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
switch (chan->channel2) { switch (chan->channel2) {
case IIO_MOD_X: case IIO_MOD_X:
...@@ -528,6 +564,7 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev, ...@@ -528,6 +564,7 @@ static int bmc150_magn_read_raw(struct iio_dev *indio_dev,
default: default:
return -EINVAL; return -EINVAL;
} }
#endif
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -548,6 +585,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev, ...@@ -548,6 +585,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev,
ret = bmc150_magn_set_odr(data, val); ret = bmc150_magn_set_odr(data, val);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
return ret; return ret;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
case IIO_CHAN_INFO_OVERSAMPLING_RATIO: case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
switch (chan->channel2) { switch (chan->channel2) {
case IIO_MOD_X: case IIO_MOD_X:
...@@ -586,6 +624,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev, ...@@ -586,6 +624,7 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev,
default: default:
return -EINVAL; return -EINVAL;
} }
#endif
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -623,12 +662,12 @@ static const struct attribute_group bmc150_magn_attrs_group = { ...@@ -623,12 +662,12 @@ static const struct attribute_group bmc150_magn_attrs_group = {
.attrs = bmc150_magn_attributes, .attrs = bmc150_magn_attributes,
}; };
#define BMC150_MAGN_CHANNEL(_axis) { \ #define BMC150_MAGN_CHANNEL(_axis) { \
.type = IIO_MAGN, \ .type = IIO_MAGN, \
.modified = 1, \ .modified = 1, \
.channel2 = IIO_MOD_##_axis, \ .channel2 = IIO_MOD_##_axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
BIT(IIO_CHAN_INFO_SCALE), \ BIT(IIO_CHAN_INFO_SCALE), \
.scan_index = AXIS_##_axis, \ .scan_index = AXIS_##_axis, \
......
cflags:
{
-DCONFIG_IIO
-DCONFIG_IIO_BUFFER
-DCONFIG_IIO_TRIGGERED_BUFFER
-DCONFIG_IIO_TRIGGER
-DCONFIG_IIO_KFIFO_BUF
-DCONFIG_IIO_CONSUMERS_PER_TRIGGER=2
}
sources:
{
bmc150_magn.c
}
requires:
{
kernelModules:
{
#if ${MANGOH_KERNEL_LACKS_IIO} = 1
$CURDIR/../iio/iio-triggered-buffer
#endif // MANGOH_KERNEL_LACKS_IIO
}
}
cflags:
{
}
sources:
{
bmc150_magn_i2c.c
}
requires:
{
kernelModules:
{
$CURDIR/bmc150_magn
}
}
...@@ -172,7 +172,8 @@ kernelModules: ...@@ -172,7 +172,8 @@ kernelModules:
$CURDIR/linux_kernel_modules/bmi160/bmi160-i2c $CURDIR/linux_kernel_modules/bmi160/bmi160-i2c
$CURDIR/linux_kernel_modules/bmi160/bmi160 $CURDIR/linux_kernel_modules/bmi160/bmi160
$CURDIR/linux_kernel_modules/bmm150/bmc150_magn_i2c
$CURDIR/linux_kernel_modules/bmm150/bmc150_magn
$CURDIR/linux_kernel_modules/rtc-pcf85063/rtc-pcf85063 $CURDIR/linux_kernel_modules/rtc-pcf85063/rtc-pcf85063
$CURDIR/linux_kernel_modules/rtc_sync/rtc_sync $CURDIR/linux_kernel_modules/rtc_sync/rtc_sync
$CURDIR/linux_kernel_modules/bq25601/bq25601 $CURDIR/linux_kernel_modules/bq25601/bq25601
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment