1 // SPDX-License-Identifier: GPL-2.0
3 * Device driver for regulators in HISI PMIC IC
5 * Copyright (c) 2013 Linaro Ltd.
6 * Copyright (c) 2011 Hisilicon.
7 * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd.
10 #include <linux/mfd/core.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/regmap.h>
14 #include <linux/slab.h>
15 #include <linux/spmi.h>
17 static const struct mfd_cell hi6421v600_devs
[] = {
18 { .name
= "hi6421v600-irq", },
19 { .name
= "hi6421v600-regulator", },
22 static const struct regmap_config regmap_config
= {
24 .val_bits
= BITS_PER_BYTE
,
25 .max_register
= 0xffff,
29 static int hi6421_spmi_pmic_probe(struct spmi_device
*sdev
)
31 struct device
*dev
= &sdev
->dev
;
32 struct regmap
*regmap
;
35 regmap
= devm_regmap_init_spmi_ext(sdev
, ®map_config
);
37 return PTR_ERR(regmap
);
39 dev_set_drvdata(&sdev
->dev
, regmap
);
41 ret
= devm_mfd_add_devices(&sdev
->dev
, PLATFORM_DEVID_NONE
,
42 hi6421v600_devs
, ARRAY_SIZE(hi6421v600_devs
),
45 dev_err(dev
, "Failed to add child devices: %d\n", ret
);
50 static const struct of_device_id pmic_spmi_id_table
[] = {
51 { .compatible
= "hisilicon,hi6421-spmi" },
54 MODULE_DEVICE_TABLE(of
, pmic_spmi_id_table
);
56 static struct spmi_driver hi6421_spmi_pmic_driver
= {
58 .name
= "hi6421-spmi-pmic",
59 .of_match_table
= pmic_spmi_id_table
,
61 .probe
= hi6421_spmi_pmic_probe
,
63 module_spmi_driver(hi6421_spmi_pmic_driver
);
65 MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver");
66 MODULE_LICENSE("GPL v2");