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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * Copyright (C) 2016 Texas Instruments Incorporated - https://www.ti.com/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Author: Keerthy <j-keerthy@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * modify it under the terms of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * published by the Free Software Foundation version 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * kind, whether express or implied; without even the implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mfd/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/mfd/lp873x.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static const struct regmap_config lp873x_regmap_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	.reg_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	.val_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	.max_register = LP873X_REG_MAX,
^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) static const struct mfd_cell lp873x_cells[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	{ .name = "lp873x-regulator", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	{ .name = "lp873x-gpio", },
^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 lp873x_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 			const struct i2c_device_id *ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	struct lp873x *lp873;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	unsigned int otpid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	if (!lp873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	lp873->dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	if (IS_ERR(lp873->regmap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		ret = PTR_ERR(lp873->regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		dev_err(lp873->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			"Failed to initialize register map: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		dev_err(lp873->dev, "Failed to read OTP ID\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	lp873->rev = otpid & LP873X_OTP_REV_OTP_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	i2c_set_clientdata(client, lp873);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 			      ARRAY_SIZE(lp873x_cells), NULL, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static const struct of_device_id of_lp873x_match_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	{ .compatible = "ti,lp8733", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	{ .compatible = "ti,lp8732", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) MODULE_DEVICE_TABLE(of, of_lp873x_match_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static const struct i2c_device_id lp873x_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	{ "lp873x", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) MODULE_DEVICE_TABLE(i2c, lp873x_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static struct i2c_driver lp873x_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	.driver	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 		.name	= "lp873x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 		.of_match_table = of_lp873x_match_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 	.probe		= lp873x_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	.id_table	= lp873x_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) module_i2c_driver(lp873x_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) MODULE_DESCRIPTION("LP873X chip family Multi-Function Device driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) MODULE_LICENSE("GPL v2");