Linux Audio

Check our new training course

Loading...
v5.9
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * FXOS8700 - NXP IMU, I2C bits
 4 *
 5 * 7-bit I2C slave address determined by SA1 and SA0 logic level
 6 * inputs represented in the following table:
 7 *      SA1  |  SA0  |  Slave Address
 8 *      0    |  0    |  0x1E
 9 *      0    |  1    |  0x1D
10 *      1    |  0    |  0x1C
11 *      1    |  1    |  0x1F
12 */
13#include <linux/acpi.h>
14#include <linux/i2c.h>
15#include <linux/module.h>
16#include <linux/mod_devicetable.h>
17#include <linux/regmap.h>
18
19#include "fxos8700.h"
20
21static int fxos8700_i2c_probe(struct i2c_client *client,
22			      const struct i2c_device_id *id)
23{
 
24	struct regmap *regmap;
25	const char *name = NULL;
26
27	regmap = devm_regmap_init_i2c(client, &fxos8700_regmap_config);
28	if (IS_ERR(regmap)) {
29		dev_err(&client->dev, "Failed to register i2c regmap %d\n",
30			(int)PTR_ERR(regmap));
31		return PTR_ERR(regmap);
32	}
33
34	if (id)
35		name = id->name;
36
37	return fxos8700_core_probe(&client->dev, regmap, name, false);
38}
39
40static const struct i2c_device_id fxos8700_i2c_id[] = {
41	{"fxos8700", 0},
42	{ }
43};
44MODULE_DEVICE_TABLE(i2c, fxos8700_i2c_id);
45
46static const struct acpi_device_id fxos8700_acpi_match[] = {
47	{"FXOS8700", 0},
48	{ }
49};
50MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
51
52static const struct of_device_id fxos8700_of_match[] = {
53	{ .compatible = "nxp,fxos8700" },
54	{ }
55};
56MODULE_DEVICE_TABLE(of, fxos8700_of_match);
57
58static struct i2c_driver fxos8700_i2c_driver = {
59	.driver = {
60		.name                   = "fxos8700_i2c",
61		.acpi_match_table       = ACPI_PTR(fxos8700_acpi_match),
62		.of_match_table         = fxos8700_of_match,
63	},
64	.probe          = fxos8700_i2c_probe,
65	.id_table       = fxos8700_i2c_id,
66};
67module_i2c_driver(fxos8700_i2c_driver);
68
69MODULE_AUTHOR("Robert Jones <rjones@gateworks.com>");
70MODULE_DESCRIPTION("FXOS8700 I2C driver");
71MODULE_LICENSE("GPL v2");
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * FXOS8700 - NXP IMU, I2C bits
 4 *
 5 * 7-bit I2C slave address determined by SA1 and SA0 logic level
 6 * inputs represented in the following table:
 7 *      SA1  |  SA0  |  Slave Address
 8 *      0    |  0    |  0x1E
 9 *      0    |  1    |  0x1D
10 *      1    |  0    |  0x1C
11 *      1    |  1    |  0x1F
12 */
 
13#include <linux/i2c.h>
14#include <linux/module.h>
15#include <linux/mod_devicetable.h>
16#include <linux/regmap.h>
17
18#include "fxos8700.h"
19
20static int fxos8700_i2c_probe(struct i2c_client *client)
 
21{
22	const struct i2c_device_id *id = i2c_client_get_device_id(client);
23	struct regmap *regmap;
24	const char *name = NULL;
25
26	regmap = devm_regmap_init_i2c(client, &fxos8700_regmap_config);
27	if (IS_ERR(regmap)) {
28		dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
 
29		return PTR_ERR(regmap);
30	}
31
32	if (id)
33		name = id->name;
34
35	return fxos8700_core_probe(&client->dev, regmap, name, false);
36}
37
38static const struct i2c_device_id fxos8700_i2c_id[] = {
39	{ "fxos8700" },
40	{ }
41};
42MODULE_DEVICE_TABLE(i2c, fxos8700_i2c_id);
43
44static const struct acpi_device_id fxos8700_acpi_match[] = {
45	{"FXOS8700", 0},
46	{ }
47};
48MODULE_DEVICE_TABLE(acpi, fxos8700_acpi_match);
49
50static const struct of_device_id fxos8700_of_match[] = {
51	{ .compatible = "nxp,fxos8700" },
52	{ }
53};
54MODULE_DEVICE_TABLE(of, fxos8700_of_match);
55
56static struct i2c_driver fxos8700_i2c_driver = {
57	.driver = {
58		.name                   = "fxos8700_i2c",
59		.acpi_match_table       = fxos8700_acpi_match,
60		.of_match_table         = fxos8700_of_match,
61	},
62	.probe          = fxos8700_i2c_probe,
63	.id_table       = fxos8700_i2c_id,
64};
65module_i2c_driver(fxos8700_i2c_driver);
66
67MODULE_AUTHOR("Robert Jones <rjones@gateworks.com>");
68MODULE_DESCRIPTION("FXOS8700 I2C driver");
69MODULE_LICENSE("GPL v2");