2020-08-17 15:10:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2021-01-30 03:51:55 +08:00
|
|
|
/*
|
|
|
|
* Device driver for regulators in HISI PMIC IC
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Linaro Ltd.
|
|
|
|
* Copyright (c) 2011 Hisilicon.
|
2021-07-17 17:58:14 +08:00
|
|
|
* Copyright (c) 2020-2021 Huawei Technologies Co., Ltd.
|
2021-01-30 03:51:55 +08:00
|
|
|
*/
|
2020-08-17 15:10:30 +08:00
|
|
|
|
2020-08-17 15:10:35 +08:00
|
|
|
#include <linux/mfd/core.h>
|
2020-08-17 15:10:41 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/platform_device.h>
|
2021-07-17 17:58:15 +08:00
|
|
|
#include <linux/regmap.h>
|
2020-08-17 15:10:41 +08:00
|
|
|
#include <linux/slab.h>
|
2020-08-17 15:10:30 +08:00
|
|
|
#include <linux/spmi.h>
|
|
|
|
|
2020-08-17 15:10:35 +08:00
|
|
|
static const struct mfd_cell hi6421v600_devs[] = {
|
2021-07-17 17:58:15 +08:00
|
|
|
{ .name = "hi6421v600-irq", },
|
2020-08-17 15:10:35 +08:00
|
|
|
{ .name = "hi6421v600-regulator", },
|
2020-08-17 15:10:30 +08:00
|
|
|
};
|
|
|
|
|
2021-01-30 03:51:50 +08:00
|
|
|
static const struct regmap_config regmap_config = {
|
2021-06-25 15:46:00 +08:00
|
|
|
.reg_bits = 16,
|
|
|
|
.val_bits = BITS_PER_BYTE,
|
|
|
|
.max_register = 0xffff,
|
|
|
|
.fast_io = true
|
2021-01-30 03:51:47 +08:00
|
|
|
};
|
|
|
|
|
2021-07-17 17:58:12 +08:00
|
|
|
static int hi6421_spmi_pmic_probe(struct spmi_device *sdev)
|
2020-08-17 15:10:30 +08:00
|
|
|
{
|
2021-07-17 17:58:12 +08:00
|
|
|
struct device *dev = &sdev->dev;
|
2021-09-02 20:47:48 +08:00
|
|
|
struct regmap *regmap;
|
2021-07-17 17:58:15 +08:00
|
|
|
int ret;
|
2020-08-17 15:10:30 +08:00
|
|
|
|
2021-09-02 20:47:48 +08:00
|
|
|
regmap = devm_regmap_init_spmi_ext(sdev, ®map_config);
|
|
|
|
if (IS_ERR(regmap))
|
|
|
|
return PTR_ERR(regmap);
|
2021-01-30 03:51:47 +08:00
|
|
|
|
2021-09-02 20:47:48 +08:00
|
|
|
dev_set_drvdata(&sdev->dev, regmap);
|
2020-08-17 15:10:35 +08:00
|
|
|
|
2021-07-17 17:58:12 +08:00
|
|
|
ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE,
|
2020-08-17 15:10:35 +08:00
|
|
|
hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
|
|
|
|
NULL, 0, NULL);
|
2021-01-30 03:51:50 +08:00
|
|
|
if (ret < 0)
|
|
|
|
dev_err(dev, "Failed to add child devices: %d\n", ret);
|
2020-08-17 15:10:41 +08:00
|
|
|
|
2020-08-17 15:10:30 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-08-17 15:10:35 +08:00
|
|
|
static const struct of_device_id pmic_spmi_id_table[] = {
|
2020-08-18 22:58:56 +08:00
|
|
|
{ .compatible = "hisilicon,hi6421-spmi" },
|
2020-08-17 15:10:35 +08:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
|
2020-08-17 15:10:30 +08:00
|
|
|
|
2020-08-17 15:10:38 +08:00
|
|
|
static struct spmi_driver hi6421_spmi_pmic_driver = {
|
2020-08-17 15:10:30 +08:00
|
|
|
.driver = {
|
2020-08-17 15:10:35 +08:00
|
|
|
.name = "hi6421-spmi-pmic",
|
|
|
|
.of_match_table = pmic_spmi_id_table,
|
2020-08-17 15:10:30 +08:00
|
|
|
},
|
2020-08-17 15:10:38 +08:00
|
|
|
.probe = hi6421_spmi_pmic_probe,
|
2020-08-17 15:10:30 +08:00
|
|
|
};
|
2020-08-17 15:10:38 +08:00
|
|
|
module_spmi_driver(hi6421_spmi_pmic_driver);
|
2020-08-17 15:10:30 +08:00
|
|
|
|
2020-08-17 15:10:35 +08:00
|
|
|
MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver");
|
2020-08-17 15:10:30 +08:00
|
|
|
MODULE_LICENSE("GPL v2");
|