Linux 6.12-rc7
[linux-stable.git] / drivers / mfd / rsmu_core.c
blobfd04a6e5dfa31ac540ca078ad024f7abf05046de
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Core driver for Renesas Synchronization Management Unit (SMU) devices.
5 * Copyright (C) 2021 Integrated Device Technology, Inc., a Renesas Company.
6 */
8 #include <linux/init.h>
9 #include <linux/kernel.h>
10 #include <linux/mfd/core.h>
11 #include <linux/mfd/rsmu.h>
12 #include <linux/module.h>
13 #include <linux/of.h>
14 #include <linux/regmap.h>
15 #include <linux/slab.h>
17 #include "rsmu.h"
19 enum {
20 RSMU_PHC = 0,
21 RSMU_CDEV = 1,
22 RSMU_N_DEVS = 2,
25 static struct mfd_cell rsmu_cm_devs[] = {
26 [RSMU_PHC] = {
27 .name = "8a3400x-phc",
29 [RSMU_CDEV] = {
30 .name = "8a3400x-cdev",
34 static struct mfd_cell rsmu_sabre_devs[] = {
35 [RSMU_PHC] = {
36 .name = "82p33x1x-phc",
38 [RSMU_CDEV] = {
39 .name = "82p33x1x-cdev",
43 static struct mfd_cell rsmu_sl_devs[] = {
44 [RSMU_PHC] = {
45 .name = "8v19n85x-phc",
47 [RSMU_CDEV] = {
48 .name = "8v19n85x-cdev",
52 int rsmu_core_init(struct rsmu_ddata *rsmu)
54 struct mfd_cell *cells;
55 int ret;
57 switch (rsmu->type) {
58 case RSMU_CM:
59 cells = rsmu_cm_devs;
60 break;
61 case RSMU_SABRE:
62 cells = rsmu_sabre_devs;
63 break;
64 case RSMU_SL:
65 cells = rsmu_sl_devs;
66 break;
67 default:
68 dev_err(rsmu->dev, "Unsupported RSMU device type: %d\n", rsmu->type);
69 return -ENODEV;
72 mutex_init(&rsmu->lock);
74 ret = devm_mfd_add_devices(rsmu->dev, PLATFORM_DEVID_AUTO, cells,
75 RSMU_N_DEVS, NULL, 0, NULL);
76 if (ret < 0)
77 dev_err(rsmu->dev, "Failed to register sub-devices: %d\n", ret);
79 return ret;
81 EXPORT_SYMBOL_GPL(rsmu_core_init);
83 void rsmu_core_exit(struct rsmu_ddata *rsmu)
85 mutex_destroy(&rsmu->lock);
87 EXPORT_SYMBOL_GPL(rsmu_core_exit);
89 MODULE_DESCRIPTION("Renesas SMU core driver");
90 MODULE_LICENSE("GPL");