mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 13:03:25 +01:00
e2a735ea3a
The maple tree register cache is based on a much more modern data structure than the rbtree cache and makes optimisation choices which are probably more appropriate for modern systems than those made by the rbtree cache. Signed-off-by: Bo Liu <liubo03@inspur.com> Link: https://lore.kernel.org/r/20240206071314.8721-6-liubo03@inspur.com Signed-off-by: Lee Jones <lee@kernel.org>
117 lines
2.9 KiB
C
117 lines
2.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Broadcom BCM590xx PMU
|
|
*
|
|
* Copyright 2014 Linaro Limited
|
|
* Author: Matt Porter <mporter@linaro.org>
|
|
*/
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/init.h>
|
|
#include <linux/mfd/bcm590xx.h>
|
|
#include <linux/mfd/core.h>
|
|
#include <linux/module.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/of.h>
|
|
#include <linux/regmap.h>
|
|
#include <linux/slab.h>
|
|
|
|
static const struct mfd_cell bcm590xx_devs[] = {
|
|
{
|
|
.name = "bcm590xx-vregs",
|
|
},
|
|
};
|
|
|
|
static const struct regmap_config bcm590xx_regmap_config_pri = {
|
|
.reg_bits = 8,
|
|
.val_bits = 8,
|
|
.max_register = BCM590XX_MAX_REGISTER_PRI,
|
|
.cache_type = REGCACHE_MAPLE,
|
|
};
|
|
|
|
static const struct regmap_config bcm590xx_regmap_config_sec = {
|
|
.reg_bits = 8,
|
|
.val_bits = 8,
|
|
.max_register = BCM590XX_MAX_REGISTER_SEC,
|
|
.cache_type = REGCACHE_MAPLE,
|
|
};
|
|
|
|
static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
|
|
{
|
|
struct bcm590xx *bcm590xx;
|
|
int ret;
|
|
|
|
bcm590xx = devm_kzalloc(&i2c_pri->dev, sizeof(*bcm590xx), GFP_KERNEL);
|
|
if (!bcm590xx)
|
|
return -ENOMEM;
|
|
|
|
i2c_set_clientdata(i2c_pri, bcm590xx);
|
|
bcm590xx->dev = &i2c_pri->dev;
|
|
bcm590xx->i2c_pri = i2c_pri;
|
|
|
|
bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
|
|
&bcm590xx_regmap_config_pri);
|
|
if (IS_ERR(bcm590xx->regmap_pri)) {
|
|
ret = PTR_ERR(bcm590xx->regmap_pri);
|
|
dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
/* Secondary I2C slave address is the base address with A(2) asserted */
|
|
bcm590xx->i2c_sec = i2c_new_dummy_device(i2c_pri->adapter,
|
|
i2c_pri->addr | BIT(2));
|
|
if (IS_ERR(bcm590xx->i2c_sec)) {
|
|
dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n");
|
|
return PTR_ERR(bcm590xx->i2c_sec);
|
|
}
|
|
i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx);
|
|
|
|
bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec,
|
|
&bcm590xx_regmap_config_sec);
|
|
if (IS_ERR(bcm590xx->regmap_sec)) {
|
|
ret = PTR_ERR(bcm590xx->regmap_sec);
|
|
dev_err(&bcm590xx->i2c_sec->dev,
|
|
"secondary regmap init failed: %d\n", ret);
|
|
goto err;
|
|
}
|
|
|
|
ret = devm_mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs,
|
|
ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL);
|
|
if (ret < 0) {
|
|
dev_err(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret);
|
|
goto err;
|
|
}
|
|
|
|
return 0;
|
|
|
|
err:
|
|
i2c_unregister_device(bcm590xx->i2c_sec);
|
|
return ret;
|
|
}
|
|
|
|
static const struct of_device_id bcm590xx_of_match[] = {
|
|
{ .compatible = "brcm,bcm59056" },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, bcm590xx_of_match);
|
|
|
|
static const struct i2c_device_id bcm590xx_i2c_id[] = {
|
|
{ "bcm59056" },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, bcm590xx_i2c_id);
|
|
|
|
static struct i2c_driver bcm590xx_i2c_driver = {
|
|
.driver = {
|
|
.name = "bcm590xx",
|
|
.of_match_table = bcm590xx_of_match,
|
|
},
|
|
.probe = bcm590xx_i2c_probe,
|
|
.id_table = bcm590xx_i2c_id,
|
|
};
|
|
module_i2c_driver(bcm590xx_i2c_driver);
|
|
|
|
MODULE_AUTHOR("Matt Porter <mporter@linaro.org>");
|
|
MODULE_DESCRIPTION("BCM590xx multi-function driver");
|
|
MODULE_LICENSE("GPL v2");
|