Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Core driver for Renesas Synchronization Management Unit (SMU) devices.
0004  *
0005  * Copyright (C) 2021 Integrated Device Technology, Inc., a Renesas Company.
0006  */
0007 
0008 #include <linux/init.h>
0009 #include <linux/kernel.h>
0010 #include <linux/mfd/core.h>
0011 #include <linux/mfd/rsmu.h>
0012 #include <linux/module.h>
0013 #include <linux/of.h>
0014 #include <linux/regmap.h>
0015 #include <linux/slab.h>
0016 
0017 #include "rsmu.h"
0018 
0019 enum {
0020     RSMU_PHC = 0,
0021     RSMU_CDEV = 1,
0022     RSMU_N_DEVS = 2,
0023 };
0024 
0025 static struct mfd_cell rsmu_cm_devs[] = {
0026     [RSMU_PHC] = {
0027         .name = "8a3400x-phc",
0028     },
0029     [RSMU_CDEV] = {
0030         .name = "8a3400x-cdev",
0031     },
0032 };
0033 
0034 static struct mfd_cell rsmu_sabre_devs[] = {
0035     [RSMU_PHC] = {
0036         .name = "82p33x1x-phc",
0037     },
0038     [RSMU_CDEV] = {
0039         .name = "82p33x1x-cdev",
0040     },
0041 };
0042 
0043 static struct mfd_cell rsmu_sl_devs[] = {
0044     [RSMU_PHC] = {
0045         .name = "8v19n85x-phc",
0046     },
0047     [RSMU_CDEV] = {
0048         .name = "8v19n85x-cdev",
0049     },
0050 };
0051 
0052 int rsmu_core_init(struct rsmu_ddata *rsmu)
0053 {
0054     struct mfd_cell *cells;
0055     int ret;
0056 
0057     switch (rsmu->type) {
0058     case RSMU_CM:
0059         cells = rsmu_cm_devs;
0060         break;
0061     case RSMU_SABRE:
0062         cells = rsmu_sabre_devs;
0063         break;
0064     case RSMU_SL:
0065         cells = rsmu_sl_devs;
0066         break;
0067     default:
0068         dev_err(rsmu->dev, "Unsupported RSMU device type: %d\n", rsmu->type);
0069         return -ENODEV;
0070     }
0071 
0072     mutex_init(&rsmu->lock);
0073 
0074     ret = devm_mfd_add_devices(rsmu->dev, PLATFORM_DEVID_AUTO, cells,
0075                    RSMU_N_DEVS, NULL, 0, NULL);
0076     if (ret < 0)
0077         dev_err(rsmu->dev, "Failed to register sub-devices: %d\n", ret);
0078 
0079     return ret;
0080 }
0081 
0082 void rsmu_core_exit(struct rsmu_ddata *rsmu)
0083 {
0084     mutex_destroy(&rsmu->lock);
0085 }
0086 
0087 MODULE_DESCRIPTION("Renesas SMU core driver");
0088 MODULE_LICENSE("GPL");