Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/mod_devicetable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "kxsd9.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static int kxsd9_i2c_probe(struct i2c_client *i2c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 			   const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	static const struct regmap_config config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		.reg_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		.val_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		.max_register = 0x0e,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	struct regmap *regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	regmap = devm_regmap_init_i2c(i2c, &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	if (IS_ERR(regmap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		dev_err(&i2c->dev, "Failed to register i2c regmap: %pe\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 			regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		return PTR_ERR(regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	return kxsd9_common_probe(&i2c->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 				  regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 				  i2c->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static int kxsd9_i2c_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	return kxsd9_common_remove(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static const struct of_device_id kxsd9_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	{ .compatible = "kionix,kxsd9", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) MODULE_DEVICE_TABLE(of, kxsd9_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static const struct i2c_device_id kxsd9_i2c_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	{"kxsd9", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) MODULE_DEVICE_TABLE(i2c, kxsd9_i2c_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static struct i2c_driver kxsd9_i2c_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		.name	= "kxsd9",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		.of_match_table = kxsd9_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		.pm = &kxsd9_dev_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	.probe		= kxsd9_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	.remove		= kxsd9_i2c_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	.id_table	= kxsd9_i2c_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) module_i2c_driver(kxsd9_i2c_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_DESCRIPTION("KXSD9 accelerometer I2C interface");