cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

hi6421-spmi-pmic.c (1621B)


      1// SPDX-License-Identifier: GPL-2.0
      2/*
      3 * Device driver for regulators in HISI PMIC IC
      4 *
      5 * Copyright (c) 2013 Linaro Ltd.
      6 * Copyright (c) 2011 Hisilicon.
      7 * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd.
      8 */
      9
     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>
     16
     17static const struct mfd_cell hi6421v600_devs[] = {
     18	{ .name = "hi6421v600-irq", },
     19	{ .name = "hi6421v600-regulator", },
     20};
     21
     22static const struct regmap_config regmap_config = {
     23	.reg_bits	= 16,
     24	.val_bits	= BITS_PER_BYTE,
     25	.max_register	= 0xffff,
     26	.fast_io	= true
     27};
     28
     29static int hi6421_spmi_pmic_probe(struct spmi_device *sdev)
     30{
     31	struct device *dev = &sdev->dev;
     32	struct regmap *regmap;
     33	int ret;
     34
     35	regmap = devm_regmap_init_spmi_ext(sdev, &regmap_config);
     36	if (IS_ERR(regmap))
     37		return PTR_ERR(regmap);
     38
     39	dev_set_drvdata(&sdev->dev, regmap);
     40
     41	ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE,
     42				   hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
     43				   NULL, 0, NULL);
     44	if (ret < 0)
     45		dev_err(dev, "Failed to add child devices: %d\n", ret);
     46
     47	return ret;
     48}
     49
     50static const struct of_device_id pmic_spmi_id_table[] = {
     51	{ .compatible = "hisilicon,hi6421-spmi" },
     52	{ }
     53};
     54MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
     55
     56static struct spmi_driver hi6421_spmi_pmic_driver = {
     57	.driver = {
     58		.name	= "hi6421-spmi-pmic",
     59		.of_match_table = pmic_spmi_id_table,
     60	},
     61	.probe	= hi6421_spmi_pmic_probe,
     62};
     63module_spmi_driver(hi6421_spmi_pmic_driver);
     64
     65MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver");
     66MODULE_LICENSE("GPL v2");