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