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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * MP2629 parent driver for ADC and battery charger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright 2020 Monolithic Power Systems, Inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Author: Saravanan Sekar <sravanhome@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/mfd/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mfd/mp2629.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static const struct mfd_cell mp2629_cell[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		.name = "mp2629_adc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		.of_compatible = "mps,mp2629_adc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		.name = "mp2629_charger",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		.of_compatible = "mps,mp2629_charger",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	}
^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 regmap_config mp2629_regmap_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	.reg_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	.val_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	.max_register = 0x17,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int mp2629_probe(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	struct mp2629_data *ddata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	if (!ddata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	ddata->dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	i2c_set_clientdata(client, ddata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	ddata->regmap = devm_regmap_init_i2c(client, &mp2629_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	if (IS_ERR(ddata->regmap)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		dev_err(ddata->dev, "Failed to allocate regmap\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		return PTR_ERR(ddata->regmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	ret = devm_mfd_add_devices(ddata->dev, PLATFORM_DEVID_AUTO, mp2629_cell,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				   ARRAY_SIZE(mp2629_cell), NULL, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		dev_err(ddata->dev, "Failed to register sub-devices %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^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) static const struct of_device_id mp2629_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	{ .compatible = "mps,mp2629"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	{ }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) MODULE_DEVICE_TABLE(of, mp2629_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static struct i2c_driver mp2629_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		.name = "mp2629",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 		.of_match_table = mp2629_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	.probe_new	= mp2629_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) module_i2c_driver(mp2629_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) MODULE_AUTHOR("Saravanan Sekar <sravanhome@gmail.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_DESCRIPTION("MP2629 Battery charger parent driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) MODULE_LICENSE("GPL");