2019-05-27 08:55:21 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-09-13 14:23:14 +02:00
|
|
|
/*
|
|
|
|
* Murata ZPA2326 I2C pressure and temperature sensor driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Parrot S.A.
|
|
|
|
*
|
|
|
|
* Author: Gregor Boirie <gregor.boirie@parrot.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/i2c.h>
|
2020-09-10 18:32:24 +01:00
|
|
|
#include <linux/mod_devicetable.h>
|
2016-09-13 14:23:14 +02:00
|
|
|
#include "zpa2326.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* read_flag_mask:
|
|
|
|
* - address bit 7 must be set to request a register read operation
|
|
|
|
*/
|
|
|
|
static const struct regmap_config zpa2326_regmap_i2c_config = {
|
|
|
|
.reg_bits = 8,
|
|
|
|
.val_bits = 8,
|
|
|
|
.writeable_reg = zpa2326_isreg_writeable,
|
|
|
|
.readable_reg = zpa2326_isreg_readable,
|
|
|
|
.precious_reg = zpa2326_isreg_precious,
|
|
|
|
.max_register = ZPA2326_TEMP_OUT_H_REG,
|
|
|
|
.read_flag_mask = BIT(7),
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned int zpa2326_i2c_hwid(const struct i2c_client *client)
|
|
|
|
{
|
|
|
|
#define ZPA2326_SA0(_addr) (_addr & BIT(0))
|
|
|
|
#define ZPA2326_DEVICE_ID_SA0_SHIFT (1)
|
|
|
|
|
|
|
|
/* Identification register bit 1 mirrors device address bit 0. */
|
|
|
|
return (ZPA2326_DEVICE_ID |
|
|
|
|
(ZPA2326_SA0(client->addr) << ZPA2326_DEVICE_ID_SA0_SHIFT));
|
|
|
|
}
|
|
|
|
|
2022-11-18 23:38:32 +01:00
|
|
|
static int zpa2326_probe_i2c(struct i2c_client *client)
|
2016-09-13 14:23:14 +02:00
|
|
|
{
|
2022-11-18 23:38:32 +01:00
|
|
|
const struct i2c_device_id *i2c_id = i2c_client_get_device_id(client);
|
2016-09-13 14:23:14 +02:00
|
|
|
struct regmap *regmap;
|
|
|
|
|
|
|
|
regmap = devm_regmap_init_i2c(client, &zpa2326_regmap_i2c_config);
|
|
|
|
if (IS_ERR(regmap)) {
|
|
|
|
dev_err(&client->dev, "failed to init registers map");
|
|
|
|
return PTR_ERR(regmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
return zpa2326_probe(&client->dev, i2c_id->name, client->irq,
|
|
|
|
zpa2326_i2c_hwid(client), regmap);
|
|
|
|
}
|
|
|
|
|
2022-08-15 10:02:30 +02:00
|
|
|
static void zpa2326_remove_i2c(struct i2c_client *client)
|
2016-09-13 14:23:14 +02:00
|
|
|
{
|
|
|
|
zpa2326_remove(&client->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id zpa2326_i2c_ids[] = {
|
2024-05-08 09:29:27 +02:00
|
|
|
{ "zpa2326" },
|
|
|
|
{ }
|
2016-09-13 14:23:14 +02:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, zpa2326_i2c_ids);
|
|
|
|
|
|
|
|
static const struct of_device_id zpa2326_i2c_matches[] = {
|
|
|
|
{ .compatible = "murata,zpa2326" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, zpa2326_i2c_matches);
|
|
|
|
|
|
|
|
static struct i2c_driver zpa2326_i2c_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "zpa2326-i2c",
|
2020-09-10 18:32:24 +01:00
|
|
|
.of_match_table = zpa2326_i2c_matches,
|
2016-09-13 14:23:14 +02:00
|
|
|
.pm = ZPA2326_PM_OPS,
|
|
|
|
},
|
2023-05-15 22:50:48 +02:00
|
|
|
.probe = zpa2326_probe_i2c,
|
2016-09-13 14:23:14 +02:00
|
|
|
.remove = zpa2326_remove_i2c,
|
|
|
|
.id_table = zpa2326_i2c_ids,
|
|
|
|
};
|
|
|
|
module_i2c_driver(zpa2326_i2c_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Gregor Boirie <gregor.boirie@parrot.com>");
|
|
|
|
MODULE_DESCRIPTION("I2C driver for Murata ZPA2326 pressure sensor");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
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_ZPA2326");
|