2019-05-29 07:17:56 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-02-12 13:44:45 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Intel Corporation Inc.
|
|
|
|
*/
|
2022-02-03 17:59:18 +02:00
|
|
|
#include <linux/mod_devicetable.h>
|
2016-02-12 13:44:45 +02:00
|
|
|
#include <linux/module.h>
|
2020-02-06 11:31:00 +01:00
|
|
|
#include <linux/property.h>
|
2016-02-12 13:44:45 +02:00
|
|
|
#include <linux/spi/spi.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/iio/iio.h>
|
|
|
|
#include "inv_mpu_iio.h"
|
|
|
|
|
|
|
|
static const struct regmap_config inv_mpu_regmap_config = {
|
|
|
|
.reg_bits = 8,
|
|
|
|
.val_bits = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int inv_mpu_i2c_disable(struct iio_dev *indio_dev)
|
|
|
|
{
|
|
|
|
struct inv_mpu6050_state *st = iio_priv(indio_dev);
|
|
|
|
int ret = 0;
|
|
|
|
|
2019-01-28 19:50:03 +01:00
|
|
|
if (st->reg->i2c_if) {
|
|
|
|
ret = regmap_write(st->map, st->reg->i2c_if,
|
|
|
|
INV_ICM20602_BIT_I2C_IF_DIS);
|
|
|
|
} else {
|
|
|
|
st->chip_config.user_ctrl |= INV_MPU6050_BIT_I2C_IF_DIS;
|
|
|
|
ret = regmap_write(st->map, st->reg->user_ctrl,
|
|
|
|
st->chip_config.user_ctrl);
|
|
|
|
}
|
2016-02-12 13:44:45 +02:00
|
|
|
|
2020-02-19 15:39:48 +01:00
|
|
|
return ret;
|
2016-02-12 13:44:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int inv_mpu_probe(struct spi_device *spi)
|
|
|
|
{
|
2020-02-06 11:31:00 +01:00
|
|
|
const void *match;
|
2016-02-12 13:44:45 +02:00
|
|
|
struct regmap *regmap;
|
2016-04-20 16:15:09 +03:00
|
|
|
const struct spi_device_id *spi_id;
|
|
|
|
const char *name = NULL;
|
|
|
|
enum inv_devices chip_type;
|
|
|
|
|
|
|
|
if ((spi_id = spi_get_device_id(spi))) {
|
|
|
|
chip_type = (enum inv_devices)spi_id->driver_data;
|
|
|
|
name = spi_id->name;
|
2020-02-06 11:31:00 +01:00
|
|
|
} else if ((match = device_get_match_data(&spi->dev))) {
|
2021-11-28 17:24:41 +00:00
|
|
|
chip_type = (uintptr_t)match;
|
2020-02-06 11:31:00 +01:00
|
|
|
name = dev_name(&spi->dev);
|
2016-04-20 16:15:09 +03:00
|
|
|
} else {
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2016-02-12 13:44:45 +02:00
|
|
|
|
|
|
|
regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config);
|
|
|
|
if (IS_ERR(regmap)) {
|
2020-03-22 22:53:12 +05:30
|
|
|
dev_err(&spi->dev, "Failed to register spi regmap: %pe\n",
|
|
|
|
regmap);
|
2016-02-12 13:44:45 +02:00
|
|
|
return PTR_ERR(regmap);
|
|
|
|
}
|
|
|
|
|
2016-02-22 13:39:11 -08:00
|
|
|
return inv_mpu_core_probe(regmap, spi->irq, name,
|
2016-03-02 19:18:12 -08:00
|
|
|
inv_mpu_i2c_disable, chip_type);
|
2016-02-12 13:44:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* device id table is used to identify what device can be
|
|
|
|
* supported by this driver
|
|
|
|
*/
|
|
|
|
static const struct spi_device_id inv_mpu_id[] = {
|
|
|
|
{"mpu6000", INV_MPU6000},
|
2016-04-20 16:15:12 +03:00
|
|
|
{"mpu6500", INV_MPU6500},
|
2020-02-06 11:31:00 +01:00
|
|
|
{"mpu6515", INV_MPU6515},
|
2020-12-02 11:46:56 +01:00
|
|
|
{"mpu6880", INV_MPU6880},
|
2017-03-26 12:11:00 +01:00
|
|
|
{"mpu9250", INV_MPU9250},
|
2018-04-02 18:42:00 -04:00
|
|
|
{"mpu9255", INV_MPU9255},
|
2016-06-30 19:06:34 +02:00
|
|
|
{"icm20608", INV_ICM20608},
|
2022-03-23 13:15:50 +01:00
|
|
|
{"icm20608d", INV_ICM20608D},
|
2020-02-06 11:31:01 +01:00
|
|
|
{"icm20609", INV_ICM20609},
|
|
|
|
{"icm20689", INV_ICM20689},
|
2023-05-05 13:48:53 +08:00
|
|
|
{"icm20600", INV_ICM20600},
|
2019-01-28 19:50:03 +01:00
|
|
|
{"icm20602", INV_ICM20602},
|
2020-02-06 11:31:03 +01:00
|
|
|
{"icm20690", INV_ICM20690},
|
2024-11-15 17:37:23 -05:00
|
|
|
{"iam20380", INV_IAM20380},
|
2020-02-06 11:31:02 +01:00
|
|
|
{"iam20680", INV_IAM20680},
|
2024-09-23 16:53:22 +02:00
|
|
|
{"iam20680hp", INV_IAM20680HP},
|
|
|
|
{"iam20680ht", INV_IAM20680HT},
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2016-02-12 13:44:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(spi, inv_mpu_id);
|
|
|
|
|
2020-02-06 11:31:00 +01:00
|
|
|
static const struct of_device_id inv_of_match[] = {
|
|
|
|
{
|
|
|
|
.compatible = "invensense,mpu6000",
|
|
|
|
.data = (void *)INV_MPU6000
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.compatible = "invensense,mpu6500",
|
|
|
|
.data = (void *)INV_MPU6500
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.compatible = "invensense,mpu6515",
|
|
|
|
.data = (void *)INV_MPU6515
|
|
|
|
},
|
2020-12-02 11:46:56 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,mpu6880",
|
|
|
|
.data = (void *)INV_MPU6880
|
|
|
|
},
|
2020-02-06 11:31:00 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,mpu9250",
|
|
|
|
.data = (void *)INV_MPU9250
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.compatible = "invensense,mpu9255",
|
|
|
|
.data = (void *)INV_MPU9255
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20608",
|
|
|
|
.data = (void *)INV_ICM20608
|
|
|
|
},
|
2022-03-23 13:15:50 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20608d",
|
|
|
|
.data = (void *)INV_ICM20608D
|
|
|
|
},
|
2020-02-06 11:31:01 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20609",
|
|
|
|
.data = (void *)INV_ICM20609
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20689",
|
|
|
|
.data = (void *)INV_ICM20689
|
|
|
|
},
|
2023-05-05 13:48:53 +08:00
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20600",
|
|
|
|
.data = (void *)INV_ICM20600
|
|
|
|
},
|
2020-02-06 11:31:00 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20602",
|
|
|
|
.data = (void *)INV_ICM20602
|
|
|
|
},
|
2020-02-06 11:31:03 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,icm20690",
|
|
|
|
.data = (void *)INV_ICM20690
|
|
|
|
},
|
2024-11-15 17:37:23 -05:00
|
|
|
{
|
|
|
|
.compatible = "invensense,iam20380",
|
|
|
|
.data = (void *)INV_IAM20380
|
|
|
|
},
|
2020-02-06 11:31:02 +01:00
|
|
|
{
|
|
|
|
.compatible = "invensense,iam20680",
|
|
|
|
.data = (void *)INV_IAM20680
|
|
|
|
},
|
2024-09-23 16:53:22 +02:00
|
|
|
{
|
|
|
|
.compatible = "invensense,iam20680hp",
|
|
|
|
.data = (void *)INV_IAM20680HP
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.compatible = "invensense,iam20680ht",
|
|
|
|
.data = (void *)INV_IAM20680HT
|
|
|
|
},
|
2020-02-06 11:31:00 +01:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, inv_of_match);
|
|
|
|
|
2016-02-12 13:44:45 +02:00
|
|
|
static const struct acpi_device_id inv_acpi_match[] = {
|
2016-04-20 16:15:09 +03:00
|
|
|
{"INVN6000", INV_MPU6000},
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2016-02-12 13:44:45 +02:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(acpi, inv_acpi_match);
|
|
|
|
|
|
|
|
static struct spi_driver inv_mpu_driver = {
|
|
|
|
.probe = inv_mpu_probe,
|
|
|
|
.id_table = inv_mpu_id,
|
|
|
|
.driver = {
|
2020-02-06 11:31:00 +01:00
|
|
|
.of_match_table = inv_of_match,
|
2022-02-03 17:59:18 +02:00
|
|
|
.acpi_match_table = inv_acpi_match,
|
2016-02-12 13:44:45 +02:00
|
|
|
.name = "inv-mpu6000-spi",
|
2022-09-25 16:57:19 +01:00
|
|
|
.pm = pm_ptr(&inv_mpu_pmops),
|
2016-02-12 13:44:45 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module_spi_driver(inv_mpu_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Adriana Reus <adriana.reus@intel.com>");
|
|
|
|
MODULE_DESCRIPTION("Invensense device MPU6000 driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
MODULE_IMPORT_NS("IIO_MPU6050");
|