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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Author: Keerthy <j-keerthy@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/mfd/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/mfd/lp87565.h>
^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 lp87565_regmap_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 = LP87565_REG_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static const struct mfd_cell lp87565_cells[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	{ .name = "lp87565-q1-regulator", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	{ .name = "lp87565-q1-gpio", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static const struct of_device_id of_lp87565_match_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	{ .compatible = "ti,lp87565", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		.compatible = "ti,lp87524-q1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		.data = (void *)LP87565_DEVICE_TYPE_LP87524_Q1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		.compatible = "ti,lp87565-q1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		.data = (void *)LP87565_DEVICE_TYPE_LP87565_Q1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		.compatible = "ti,lp87561-q1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		.data = (void *)LP87565_DEVICE_TYPE_LP87561_Q1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) MODULE_DEVICE_TABLE(of, of_lp87565_match_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static int lp87565_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			 const struct i2c_device_id *ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	struct lp87565 *lp87565;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	const struct of_device_id *of_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	unsigned int otpid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	lp87565 = devm_kzalloc(&client->dev, sizeof(*lp87565), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	if (!lp87565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	lp87565->dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	lp87565->regmap = devm_regmap_init_i2c(client, &lp87565_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (IS_ERR(lp87565->regmap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		ret = PTR_ERR(lp87565->regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		dev_err(lp87565->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			"Failed to initialize register map: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	ret = regmap_read(lp87565->regmap, LP87565_REG_OTP_REV, &otpid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		dev_err(lp87565->dev, "Failed to read OTP ID\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	lp87565->rev = otpid & LP87565_OTP_REV_OTP_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	of_id = of_match_device(of_lp87565_match_table, &client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (of_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		lp87565->dev_type = (enum lp87565_device_type)of_id->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	i2c_set_clientdata(client, lp87565);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return devm_mfd_add_devices(lp87565->dev, PLATFORM_DEVID_AUTO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 				    lp87565_cells, ARRAY_SIZE(lp87565_cells),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 				    NULL, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static const struct i2c_device_id lp87565_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	{ "lp87565-q1", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) MODULE_DEVICE_TABLE(i2c, lp87565_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static struct i2c_driver lp87565_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	.driver	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		.name	= "lp87565",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		.of_match_table = of_lp87565_match_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	.probe = lp87565_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	.id_table = lp87565_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) module_i2c_driver(lp87565_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) MODULE_DESCRIPTION("lp87565 chip family Multi-Function Device driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) MODULE_LICENSE("GPL v2");