| 1 |
// SPDX-License-Identifier: GPL-2.0+ |
| 2 |
/* |
| 3 |
* Core driver for Renesas Synchronization Management Unit (SMU) devices. |
| 4 |
* |
| 5 |
* Copyright (C) 2021 Integrated Device Technology, Inc., a Renesas Company. |
| 6 |
*/ |
| 7 |
|
| 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> |
| 16 |
|
| 17 |
#include "rsmu.h" |
| 18 |
|
| 19 |
enum { |
| 20 |
RSMU_PHC = 0, |
| 21 |
RSMU_CDEV = 1, |
| 22 |
RSMU_N_DEVS = 2, |
| 23 |
}; |
| 24 |
|
| 25 |
static struct mfd_cell rsmu_cm_devs[] = { |
| 26 |
[RSMU_PHC] = { |
| 27 |
.name = "8a3400x-phc", |
| 28 |
}, |
| 29 |
[RSMU_CDEV] = { |
| 30 |
.name = "8a3400x-cdev", |
| 31 |
}, |
| 32 |
}; |
| 33 |
|
| 34 |
static struct mfd_cell rsmu_sabre_devs[] = { |
| 35 |
[RSMU_PHC] = { |
| 36 |
.name = "82p33x1x-phc", |
| 37 |
}, |
| 38 |
[RSMU_CDEV] = { |
| 39 |
.name = "82p33x1x-cdev", |
| 40 |
}, |
| 41 |
}; |
| 42 |
|
| 43 |
static struct mfd_cell rsmu_sl_devs[] = { |
| 44 |
[RSMU_PHC] = { |
| 45 |
.name = "8v19n85x-phc", |
| 46 |
}, |
| 47 |
[RSMU_CDEV] = { |
| 48 |
.name = "8v19n85x-cdev", |
| 49 |
}, |
| 50 |
}; |
| 51 |
|
| 52 |
int rsmu_core_init(struct rsmu_ddata *rsmu) |
| 53 |
{ |
| 54 |
struct mfd_cell *cells; |
| 55 |
int ret; |
| 56 |
|
| 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; |
| 70 |
} |
| 71 |
|
| 72 |
mutex_init(&rsmu->lock); |
| 73 |
|
| 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); |
| 78 |
|
| 79 |
return ret; |
| 80 |
} |
| 81 |
EXPORT_SYMBOL_GPL(rsmu_core_init); |
| 82 |
|
| 83 |
void rsmu_core_exit(struct rsmu_ddata *rsmu) |
| 84 |
{ |
| 85 |
mutex_destroy(&rsmu->lock); |
| 86 |
} |
| 87 |
EXPORT_SYMBOL_GPL(rsmu_core_exit); |
| 88 |
|
| 89 |
MODULE_DESCRIPTION("Renesas SMU core driver"); |
| 90 |
MODULE_LICENSE("GPL"); |