#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/io.h>
+#include <linux/mfd/core.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
-#include <linux/mfd/hisi_pmic.h>
+#include <linux/mfd/hi6421-spmi-pmic.h>
#include <linux/irq.h>
#include <linux/spmi.h>
#ifndef NO_IRQ
/*define the first group interrupt register number*/
#define HISI_PMIC_FIRST_GROUP_INT_NUM 2
-static const struct of_device_id of_hisi_pmic_match_tbl[] = {
- {
- .compatible = "hisilicon-hisi-pmic-spmi",
- },
- { /* end */ }
+static const struct mfd_cell hi6421v600_devs[] = {
+ { .name = "hi6421v600-regulator", },
};
/*
goto request_theaded_irq;
}
+ dev_set_drvdata(&pdev->dev, pmic);
+
+ /*
+ * The logic below will rely that the pmic is already stored at
+ * drvdata.
+ */
+ dev_dbg(&pdev->dev, "SPMI-PMIC: adding childs for %pOF\n",
+ pdev->dev.of_node);
+ ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
+ hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
+ NULL, 0, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to add child devices: %d\n", ret);
+ return ret;
+ }
+
after_irq_register:
return 0;
devm_kfree(&pdev->dev, pmic);
}
-static int hisi_pmic_suspend(struct device *dev, pm_message_t state)
-{
- struct hisi_pmic *pmic = dev_get_drvdata(dev);
-
- if (!pmic) {
- pr_err("%s:pmic is NULL\n", __func__);
- return -ENOMEM;
- }
-
- pr_info("%s:+\n", __func__);
- pr_info("%s:-\n", __func__);
-
- return 0;
-}
-
-static int hisi_pmic_resume(struct device *dev)
-{
- struct hisi_pmic *pmic = dev_get_drvdata(dev);
-
- if (!pmic) {
- pr_err("%s:pmic is NULL\n", __func__);
- return -ENOMEM;
- }
-
- pr_info("%s:+\n", __func__);
- pr_info("%s:-\n", __func__);
-
- return 0;
-}
+static const struct of_device_id pmic_spmi_id_table[] = {
+ { .compatible = "hisilicon,hi6421-spmi-pmic" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
-MODULE_DEVICE_TABLE(spmi, pmic_spmi_id);
static struct spmi_driver hisi_pmic_driver = {
.driver = {
- .name = "hisi_pmic",
- .owner = THIS_MODULE,
- .of_match_table = of_hisi_pmic_match_tbl,
- .suspend = hisi_pmic_suspend,
- .resume = hisi_pmic_resume,
+ .name = "hi6421-spmi-pmic",
+ .of_match_table = pmic_spmi_id_table,
},
.probe = hisi_pmic_probe,
.remove = hisi_pmic_remove,
};
+module_spmi_driver(hisi_pmic_driver);
-static int __init hisi_pmic_init(void)
-{
- return spmi_driver_register(&hisi_pmic_driver);
-}
-
-static void __exit hisi_pmic_exit(void)
-{
- spmi_driver_unregister(&hisi_pmic_driver);
-}
-
-subsys_initcall_sync(hisi_pmic_init);
-module_exit(hisi_pmic_exit);
-
-MODULE_DESCRIPTION("PMIC driver");
+MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver");
MODULE_LICENSE("GPL v2");