2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-04-01 14:41:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2009-2010 Creative Product Design
|
|
|
|
* Marc Reilly marc@cpdesign.com.au
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/mfd/core.h>
|
|
|
|
#include <linux/mfd/mc13xxx.h>
|
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
|
|
|
#include "mc13xxx.h"
|
|
|
|
|
|
|
|
static const struct i2c_device_id mc13xxx_i2c_device_id[] = {
|
|
|
|
{
|
|
|
|
.name = "mc13892",
|
2012-07-12 17:57:52 +08:00
|
|
|
.driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13892,
|
2012-07-12 17:57:53 +08:00
|
|
|
}, {
|
|
|
|
.name = "mc34708",
|
|
|
|
.driver_data = (kernel_ulong_t)&mc13xxx_variant_mc34708,
|
2012-04-01 14:41:39 +08:00
|
|
|
}, {
|
|
|
|
/* sentinel */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, mc13xxx_i2c_device_id);
|
|
|
|
|
|
|
|
static const struct of_device_id mc13xxx_dt_ids[] = {
|
|
|
|
{
|
|
|
|
.compatible = "fsl,mc13892",
|
2012-07-12 17:57:52 +08:00
|
|
|
.data = &mc13xxx_variant_mc13892,
|
2012-07-12 17:57:53 +08:00
|
|
|
}, {
|
|
|
|
.compatible = "fsl,mc34708",
|
|
|
|
.data = &mc13xxx_variant_mc34708,
|
2012-04-01 14:41:39 +08:00
|
|
|
}, {
|
|
|
|
/* sentinel */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids);
|
|
|
|
|
2015-01-05 17:01:26 +08:00
|
|
|
static const struct regmap_config mc13xxx_regmap_i2c_config = {
|
2012-04-01 14:41:39 +08:00
|
|
|
.reg_bits = 8,
|
|
|
|
.val_bits = 24,
|
|
|
|
|
|
|
|
.max_register = MC13XXX_NUMREGS,
|
|
|
|
|
|
|
|
.cache_type = REGCACHE_NONE,
|
|
|
|
};
|
|
|
|
|
2022-11-19 06:43:00 +08:00
|
|
|
static int mc13xxx_i2c_probe(struct i2c_client *client)
|
2012-04-01 14:41:39 +08:00
|
|
|
{
|
|
|
|
struct mc13xxx *mc13xxx;
|
|
|
|
int ret;
|
|
|
|
|
2012-06-29 21:14:36 +08:00
|
|
|
mc13xxx = devm_kzalloc(&client->dev, sizeof(*mc13xxx), GFP_KERNEL);
|
2012-04-01 14:41:39 +08:00
|
|
|
if (!mc13xxx)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
dev_set_drvdata(&client->dev, mc13xxx);
|
|
|
|
|
2013-12-14 21:03:12 +08:00
|
|
|
mc13xxx->irq = client->irq;
|
2012-04-01 14:41:39 +08:00
|
|
|
|
2012-06-29 21:14:36 +08:00
|
|
|
mc13xxx->regmap = devm_regmap_init_i2c(client,
|
|
|
|
&mc13xxx_regmap_i2c_config);
|
2012-04-01 14:41:39 +08:00
|
|
|
if (IS_ERR(mc13xxx->regmap)) {
|
|
|
|
ret = PTR_ERR(mc13xxx->regmap);
|
2013-12-14 21:03:12 +08:00
|
|
|
dev_err(&client->dev, "Failed to initialize regmap: %d\n", ret);
|
2012-04-01 14:41:39 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-08-20 02:31:55 +08:00
|
|
|
mc13xxx->variant = i2c_get_match_data(client);
|
2012-04-01 14:41:39 +08:00
|
|
|
|
2013-12-14 21:03:12 +08:00
|
|
|
return mc13xxx_common_init(&client->dev);
|
2012-04-01 14:41:39 +08:00
|
|
|
}
|
|
|
|
|
2022-08-15 16:02:30 +08:00
|
|
|
static void mc13xxx_i2c_remove(struct i2c_client *client)
|
2012-04-01 14:41:39 +08:00
|
|
|
{
|
2021-10-12 23:39:33 +08:00
|
|
|
mc13xxx_common_exit(&client->dev);
|
2012-04-01 14:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct i2c_driver mc13xxx_i2c_driver = {
|
|
|
|
.id_table = mc13xxx_i2c_device_id,
|
|
|
|
.driver = {
|
|
|
|
.name = "mc13xxx",
|
|
|
|
.of_match_table = mc13xxx_dt_ids,
|
|
|
|
},
|
2023-05-16 02:27:52 +08:00
|
|
|
.probe = mc13xxx_i2c_probe,
|
2012-11-20 02:20:24 +08:00
|
|
|
.remove = mc13xxx_i2c_remove,
|
2012-04-01 14:41:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init mc13xxx_i2c_init(void)
|
|
|
|
{
|
|
|
|
return i2c_add_driver(&mc13xxx_i2c_driver);
|
|
|
|
}
|
|
|
|
subsys_initcall(mc13xxx_i2c_init);
|
|
|
|
|
|
|
|
static void __exit mc13xxx_i2c_exit(void)
|
|
|
|
{
|
|
|
|
i2c_del_driver(&mc13xxx_i2c_driver);
|
|
|
|
}
|
|
|
|
module_exit(mc13xxx_i2c_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("i2c driver for Freescale MC13XXX PMIC");
|
|
|
|
MODULE_AUTHOR("Marc Reilly <marc@cpdesign.com.au");
|
|
|
|
MODULE_LICENSE("GPL v2");
|